prosemirror-view 1.31.8 → 1.32.0
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +14 -0
- package/package.json +1 -1
- package/src/domcoords.ts +5 -0
- package/src/index.ts +6 -0
- package/src/viewdesc.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 1.32.0 (2023-09-27)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Work around an issue on Chrome where, when clicking above the right side of an uneditable node, the cursor would be put after the node.
|
|
6
|
+
|
|
7
|
+
Fix a bug that could corrupt the composition when it occurs next to text identical to the composed characters.
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
The new `EditorView.updateRoot` method can be used to make the editor update its DOM root when it is moved to a new document or shadow tree.
|
|
12
|
+
|
|
1
13
|
## 1.31.8 (2023-09-12)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -513,6 +513,8 @@ function _posAtCoords(view, coords) {
|
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
var prev;
|
|
517
|
+
if (webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
|
|
516
518
|
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
|
|
517
519
|
}
|
|
518
520
|
|
|
@@ -2479,6 +2481,7 @@ function findTextInFragment(frag, text, from, to) {
|
|
|
2479
2481
|
}
|
|
2480
2482
|
|
|
2481
2483
|
if (pos >= from) {
|
|
2484
|
+
if (pos >= to && str.slice(to - text.length - childStart, to - childStart) == text) return to - text.length;
|
|
2482
2485
|
var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
|
|
2483
2486
|
if (found >= 0 && found + text.length + childStart >= from) return childStart + found;
|
|
2484
2487
|
if (from == to && str.length >= to + text.length - childStart && str.slice(to - childStart, to - childStart + text.length) == text) return to;
|
|
@@ -5943,6 +5946,11 @@ var EditorView = function () {
|
|
|
5943
5946
|
|
|
5944
5947
|
return cached || document;
|
|
5945
5948
|
}
|
|
5949
|
+
}, {
|
|
5950
|
+
key: "updateRoot",
|
|
5951
|
+
value: function updateRoot() {
|
|
5952
|
+
this._root = null;
|
|
5953
|
+
}
|
|
5946
5954
|
}, {
|
|
5947
5955
|
key: "posAtCoords",
|
|
5948
5956
|
value: function posAtCoords(coords) {
|
package/dist/index.d.cts
CHANGED
|
@@ -492,6 +492,11 @@ declare class EditorView {
|
|
|
492
492
|
*/
|
|
493
493
|
get root(): Document | ShadowRoot;
|
|
494
494
|
/**
|
|
495
|
+
When an existing editor view is moved to a new document or
|
|
496
|
+
shadow tree, call this to make it recompute its root.
|
|
497
|
+
*/
|
|
498
|
+
updateRoot(): void;
|
|
499
|
+
/**
|
|
495
500
|
Given a pair of viewport coordinates, return the document
|
|
496
501
|
position that corresponds to them. May return null if the given
|
|
497
502
|
coordinates aren't inside of the editor. When an object is
|
package/dist/index.d.ts
CHANGED
|
@@ -492,6 +492,11 @@ declare class EditorView {
|
|
|
492
492
|
*/
|
|
493
493
|
get root(): Document | ShadowRoot;
|
|
494
494
|
/**
|
|
495
|
+
When an existing editor view is moved to a new document or
|
|
496
|
+
shadow tree, call this to make it recompute its root.
|
|
497
|
+
*/
|
|
498
|
+
updateRoot(): void;
|
|
499
|
+
/**
|
|
495
500
|
Given a pair of viewport coordinates, return the document
|
|
496
501
|
position that corresponds to them. May return null if the given
|
|
497
502
|
coordinates aren't inside of the editor. When an object is
|
package/dist/index.js
CHANGED
|
@@ -426,6 +426,11 @@ function posAtCoords(view, coords) {
|
|
|
426
426
|
offset++;
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
+
let prev;
|
|
430
|
+
// When clicking above the right side of an uneditable node, Chrome will report a cursor position after that node.
|
|
431
|
+
if (webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 &&
|
|
432
|
+
prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top)
|
|
433
|
+
offset--;
|
|
429
434
|
// Suspiciously specific kludge to work around caret*FromPoint
|
|
430
435
|
// never returning a position at the end of the document
|
|
431
436
|
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 &&
|
|
@@ -2068,6 +2073,8 @@ function findTextInFragment(frag, text, from, to) {
|
|
|
2068
2073
|
str += next.text;
|
|
2069
2074
|
}
|
|
2070
2075
|
if (pos >= from) {
|
|
2076
|
+
if (pos >= to && str.slice(to - text.length - childStart, to - childStart) == text)
|
|
2077
|
+
return to - text.length;
|
|
2071
2078
|
let found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
|
|
2072
2079
|
if (found >= 0 && found + text.length + childStart >= from)
|
|
2073
2080
|
return childStart + found;
|
|
@@ -5354,6 +5361,13 @@ class EditorView {
|
|
|
5354
5361
|
return cached || document;
|
|
5355
5362
|
}
|
|
5356
5363
|
/**
|
|
5364
|
+
When an existing editor view is moved to a new document or
|
|
5365
|
+
shadow tree, call this to make it recompute its root.
|
|
5366
|
+
*/
|
|
5367
|
+
updateRoot() {
|
|
5368
|
+
this._root = null;
|
|
5369
|
+
}
|
|
5370
|
+
/**
|
|
5357
5371
|
Given a pair of viewport coordinates, return the document
|
|
5358
5372
|
position that corresponds to them. May return null if the given
|
|
5359
5373
|
coordinates aren't inside of the editor. When an object is
|
package/package.json
CHANGED
package/src/domcoords.ts
CHANGED
|
@@ -294,6 +294,11 @@ export function posAtCoords(view: EditorView, coords: {top: number, left: number
|
|
|
294
294
|
offset++
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
+
let prev
|
|
298
|
+
// When clicking above the right side of an uneditable node, Chrome will report a cursor position after that node.
|
|
299
|
+
if (browser.webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 &&
|
|
300
|
+
(prev as HTMLElement).contentEditable == "false" && (prev as HTMLElement).getBoundingClientRect().top >= coords.top)
|
|
301
|
+
offset--
|
|
297
302
|
// Suspiciously specific kludge to work around caret*FromPoint
|
|
298
303
|
// never returning a position at the end of the document
|
|
299
304
|
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild!.nodeType == 1 &&
|
package/src/index.ts
CHANGED
|
@@ -339,6 +339,12 @@ export class EditorView {
|
|
|
339
339
|
return cached || document
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
/// When an existing editor view is moved to a new document or
|
|
343
|
+
/// shadow tree, call this to make it recompute its root.
|
|
344
|
+
updateRoot() {
|
|
345
|
+
this._root = null
|
|
346
|
+
}
|
|
347
|
+
|
|
342
348
|
/// Given a pair of viewport coordinates, return the document
|
|
343
349
|
/// position that corresponds to them. May return null if the given
|
|
344
350
|
/// coordinates aren't inside of the editor. When an object is
|
package/src/viewdesc.ts
CHANGED
|
@@ -1499,6 +1499,8 @@ function findTextInFragment(frag: Fragment, text: string, from: number, to: numb
|
|
|
1499
1499
|
str += next.text
|
|
1500
1500
|
}
|
|
1501
1501
|
if (pos >= from) {
|
|
1502
|
+
if (pos >= to && str.slice(to - text.length - childStart, to - childStart) == text)
|
|
1503
|
+
return to - text.length
|
|
1502
1504
|
let found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1
|
|
1503
1505
|
if (found >= 0 && found + text.length + childStart >= from)
|
|
1504
1506
|
return childStart + found
|