Commit f87cd08
committed
refactor(super-editor): route mixed-bidi Backspace through handleBackspace chain
The MixedBidiBackspace extension previously bound Backspace via addShortcuts
and dispatched its own transaction. That bypassed the canonical handleBackspace
chain in core/extensions/keymap.js, skipping:
- dispatchHistoryBoundary (so undo grouping diverged from regular Backspace),
- the tr.setMeta('inputType', 'deleteContentBackward') hop (tracked-changes
helpers gate Backspace-specific wrapping on this meta - see
trackChangesHelpers/trackedTransaction.js:447,
trackChangesHelpers/replaceAroundStep.js:162),
- deleteBlockSdtAtTextBlockStart for SDT block boundaries,
- the rest of the specialized run-aware ladder.
Refactor:
- Expose mixedBidiBackspace as a chain command via addCommands(); shape
matches the existing backspaceAcrossRuns / backspaceNextToRun pattern
(factory returning ({state, view, tr, dispatch}) => boolean).
- Insert into the Backspace chain in keymap.js after backspaceAcrossRuns
(specialized cross-run handling) and before deleteSelection (generic
fallback), guarded with `?? false` so the chain works when the extension
is unregistered.
- Split the detection logic into pure resolveMixedBidiBackspaceRange so the
command body stays tiny.
- Tests rewritten to call the chain command shape directly and pin: chain
dry-run mode (dispatch=undefined) returns true without mutating tr,
non-mixed boundaries fall through, both RTL+LTR and LTR+RTL boundaries
handled, posAtDOM is skipped early for pure-LTR/RTL lines.1 parent 8ce8602 commit f87cd08
3 files changed
Lines changed: 102 additions & 91 deletions
File tree
- packages/super-editor/src/editors/v1
- core/extensions
- extensions/mixed-bidi-backspace
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
Lines changed: 50 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
113 | 121 | | |
114 | | - | |
| 122 | + | |
115 | 123 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
119 | 127 | | |
120 | 128 | | |
121 | | - | |
| 129 | + | |
122 | 130 | | |
123 | 131 | | |
124 | | - | |
| 132 | + | |
125 | 133 | | |
126 | 134 | | |
127 | | - | |
| 135 | + | |
128 | 136 | | |
129 | 137 | | |
130 | 138 | | |
131 | | - | |
| 139 | + | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
139 | | - | |
| 147 | + | |
140 | 148 | | |
141 | | - | |
142 | | - | |
| 149 | + | |
| 150 | + | |
143 | 151 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 152 | + | |
147 | 153 | | |
148 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
149 | 180 | | |
150 | 181 | | |
151 | 182 | | |
152 | | - | |
| 183 | + | |
153 | 184 | | |
154 | | - | |
| 185 | + | |
155 | 186 | | |
156 | 187 | | |
157 | 188 | | |
158 | 189 | | |
159 | 190 | | |
160 | 191 | | |
161 | 192 | | |
| 193 | + | |
162 | 194 | | |
Lines changed: 51 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 72 | + | |
| 73 | + | |
79 | 74 | | |
80 | 75 | | |
81 | | - | |
| 76 | + | |
82 | 77 | | |
83 | 78 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
87 | 82 | | |
88 | 83 | | |
89 | 84 | | |
90 | 85 | | |
91 | 86 | | |
92 | 87 | | |
93 | 88 | | |
94 | | - | |
| 89 | + | |
95 | 90 | | |
96 | 91 | | |
97 | | - | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 96 | + | |
| 97 | + | |
118 | 98 | | |
119 | 99 | | |
120 | 100 | | |
121 | 101 | | |
122 | 102 | | |
123 | 103 | | |
124 | 104 | | |
125 | | - | |
| 105 | + | |
126 | 106 | | |
127 | 107 | | |
128 | | - | |
129 | 108 | | |
130 | 109 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
134 | 113 | | |
135 | 114 | | |
136 | | - | |
| 115 | + | |
137 | 116 | | |
138 | 117 | | |
139 | 118 | | |
140 | | - | |
| 119 | + | |
141 | 120 | | |
142 | 121 | | |
143 | | - | |
| 122 | + | |
| 123 | + | |
144 | 124 | | |
145 | 125 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
152 | 132 | | |
153 | 133 | | |
| 134 | + | |
154 | 135 | | |
155 | | - | |
| 136 | + | |
156 | 137 | | |
157 | 138 | | |
158 | | - | |
159 | 139 | | |
160 | 140 | | |
161 | | - | |
162 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
163 | 146 | | |
164 | 147 | | |
165 | | - | |
166 | | - | |
| 148 | + | |
| 149 | + | |
167 | 150 | | |
168 | 151 | | |
169 | 152 | | |
170 | | - | |
171 | | - | |
| 153 | + | |
| 154 | + | |
172 | 155 | | |
173 | | - | |
| 156 | + | |
174 | 157 | | |
175 | 158 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
182 | 165 | | |
183 | 166 | | |
184 | | - | |
185 | 167 | | |
186 | | - | |
| 168 | + | |
187 | 169 | | |
188 | | - | |
189 | | - | |
190 | 170 | | |
191 | 171 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
199 | 177 | | |
200 | 178 | | |
0 commit comments