@nerd-bible/wordgard 0.5.3-beta0 → 0.5.3-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.js +14 -7
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -1858,7 +1858,9 @@ class CompositeTile extends Tile {
|
|
|
1858
1858
|
return CoordPos.create(start + this.length - 2 * this.boundary, -1);
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
|
-
function rowScan(x, y, scan) {
|
|
1861
|
+
function rowScan(x, y, scan, depth = 0) {
|
|
1862
|
+
if (depth > 1)
|
|
1863
|
+
return null;
|
|
1862
1864
|
let closest = null, closestDx = 1e8, closestRect = null;
|
|
1863
1865
|
let above = null, below = null;
|
|
1864
1866
|
scan((rect, value) => {
|
|
@@ -1884,16 +1886,16 @@ function rowScan(x, y, scan) {
|
|
|
1884
1886
|
if (closestRect) {
|
|
1885
1887
|
if (closestDx) {
|
|
1886
1888
|
if (above && above.bottom > closestRect.top)
|
|
1887
|
-
return rowScan(x, above.bottom - 1, scan);
|
|
1889
|
+
return rowScan(x, above.bottom - 1, scan, depth + 1);
|
|
1888
1890
|
if (below && below.top < closestRect.bottom)
|
|
1889
|
-
return rowScan(x, below.top + 1, scan);
|
|
1891
|
+
return rowScan(x, below.top + 1, scan, depth + 1);
|
|
1890
1892
|
}
|
|
1891
1893
|
return { closest: closest, rect: closestRect };
|
|
1892
1894
|
}
|
|
1893
1895
|
let side = above && (!below || (y - above.bottom < below.top - y)) ? above : below;
|
|
1894
1896
|
if (!side)
|
|
1895
1897
|
return null;
|
|
1896
|
-
return rowScan(x, (side.top + side.bottom) / 2, scan);
|
|
1898
|
+
return rowScan(x, (side.top + side.bottom) / 2, scan, depth + 1);
|
|
1897
1899
|
}
|
|
1898
1900
|
function ltrAt(state, pos, assoc, textblock) {
|
|
1899
1901
|
if (textblock === undefined) {
|
|
@@ -4154,6 +4156,10 @@ class InputState {
|
|
|
4154
4156
|
this._domMapping = this._domMapping.compose(pending[this.domMappingIndex++].changes);
|
|
4155
4157
|
return this._domMapping;
|
|
4156
4158
|
}
|
|
4159
|
+
get unflushedSelection() {
|
|
4160
|
+
let { pending } = this.wg.viewState;
|
|
4161
|
+
return pending.some(tr => tr.selection && !tr.isUserEvent("input"));
|
|
4162
|
+
}
|
|
4157
4163
|
posAtDOM(node, offset, assoc = -1) {
|
|
4158
4164
|
if (this.domMapping.empty && !this.domChanges)
|
|
4159
4165
|
return this.wg.docTile.posFromDOM(node, offset);
|
|
@@ -4173,7 +4179,7 @@ class InputState {
|
|
|
4173
4179
|
}
|
|
4174
4180
|
let command = inputTypeCommands[type];
|
|
4175
4181
|
if ((type == "deleteContentBackward" || type == "deleteContentForward") && range &&
|
|
4176
|
-
range.from != range.to && (sel.empty
|
|
4182
|
+
range.from != range.to && !this.unflushedSelection && (sel.empty
|
|
4177
4183
|
? !isSingleChar(this.domDoc, data.domRange.from, data.domRange.to) ||
|
|
4178
4184
|
sel.head != (type == "deleteContentBackward" ? range.to : range.from)
|
|
4179
4185
|
: sel.from != range.from || sel.to != range.to)) {
|
|
@@ -4184,11 +4190,12 @@ class InputState {
|
|
|
4184
4190
|
}
|
|
4185
4191
|
else if (type == "insertText") {
|
|
4186
4192
|
let insert = event.data.replace(/\r\n?|\n/g, " ");
|
|
4187
|
-
|
|
4193
|
+
let { from, to } = this.unflushedSelection ? wg.state.selection : range;
|
|
4194
|
+
Command.dispatch(wg, insertText, { from, to, insert, userEvent: "input.type" });
|
|
4188
4195
|
}
|
|
4189
4196
|
else if ((type == "insertReplacementText" || type == "insertFromYank")) {
|
|
4190
4197
|
let read = readClipboard(wg.state, event.dataTransfer, wg.state.sel.head, true);
|
|
4191
|
-
let { from, to } = range;
|
|
4198
|
+
let { from, to } = this.unflushedSelection ? wg.state.selection : range;
|
|
4192
4199
|
let sel = wg.state.selection, touchesSel = from <= sel.to && to >= sel.from;
|
|
4193
4200
|
if (read)
|
|
4194
4201
|
wg.dispatch({
|