prosemirror-view 1.23.3 → 1.23.4
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 +10 -0
- package/dist/index.es.js +22 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/input.js +13 -1
- package/src/selection.js +7 -3
- package/src/viewdesc.js +2 -2
package/package.json
CHANGED
package/src/input.js
CHANGED
|
@@ -100,9 +100,14 @@ export function dispatchEvent(view, event) {
|
|
|
100
100
|
editHandlers.keydown = (view, event) => {
|
|
101
101
|
view.shiftKey = event.keyCode == 16 || event.shiftKey
|
|
102
102
|
if (inOrNearComposition(view, event)) return
|
|
103
|
-
if (event.keyCode != 229) view.domObserver.forceFlush()
|
|
104
103
|
view.lastKeyCode = event.keyCode
|
|
105
104
|
view.lastKeyCodeTime = Date.now()
|
|
105
|
+
// Suppress enter key events on Chrome Android, because those tend
|
|
106
|
+
// to be part of a confused sequence of composition events fired,
|
|
107
|
+
// and handling them eagerly tends to corrupt the input.
|
|
108
|
+
if (browser.android && browser.chrome && event.keyCode == 13) return
|
|
109
|
+
if (event.keyCode != 229) view.domObserver.forceFlush()
|
|
110
|
+
|
|
106
111
|
// On iOS, if we preventDefault enter key presses, the virtual
|
|
107
112
|
// keyboard gets confused. So the hack here is to set a flag that
|
|
108
113
|
// makes the DOM change code recognize that what just happens should
|
|
@@ -477,6 +482,7 @@ function timestampFromCustomEvent() {
|
|
|
477
482
|
}
|
|
478
483
|
|
|
479
484
|
export function endComposition(view, forceUpdate) {
|
|
485
|
+
if (browser.android && view.domObserver.flushingSoon >= 0) return
|
|
480
486
|
view.domObserver.forceFlush()
|
|
481
487
|
clearComposition(view)
|
|
482
488
|
if (forceUpdate || view.docView.dirty) {
|
|
@@ -564,6 +570,11 @@ function doPaste(view, text, html, e) {
|
|
|
564
570
|
}
|
|
565
571
|
|
|
566
572
|
editHandlers.paste = (view, e) => {
|
|
573
|
+
// Handling paste from JavaScript during composition is very poorly
|
|
574
|
+
// handled by browsers, so as a dodgy but preferable kludge, we just
|
|
575
|
+
// let the browser do its native thing there, except on Android,
|
|
576
|
+
// where the editor is almost always composing.
|
|
577
|
+
if (view.composing && !browser.android) return
|
|
567
578
|
let data = brokenClipboardAPI ? null : e.clipboardData
|
|
568
579
|
if (data && doPaste(view, data.getData("text/plain"), data.getData("text/html"), e)) e.preventDefault()
|
|
569
580
|
else capturePaste(view, e)
|
|
@@ -696,6 +707,7 @@ handlers.beforeinput = (view, event) => {
|
|
|
696
707
|
// Very specific hack to deal with backspace sometimes failing on
|
|
697
708
|
// Chrome Android when after an uneditable node.
|
|
698
709
|
if (browser.chrome && browser.android && event.inputType == "deleteContentBackward") {
|
|
710
|
+
view.domObserver.flushSoon()
|
|
699
711
|
let {domChangeCount} = view
|
|
700
712
|
setTimeout(() => {
|
|
701
713
|
if (view.domChangeCount != domChangeCount) return // Event already had some effect
|
package/src/selection.js
CHANGED
|
@@ -43,9 +43,13 @@ export function selectionToDOM(view, force) {
|
|
|
43
43
|
if (!editorOwnsSelection(view)) return
|
|
44
44
|
|
|
45
45
|
if (!force && view.mouseDown && view.mouseDown.allowDefault) {
|
|
46
|
-
view.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
let domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection
|
|
47
|
+
if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
|
|
48
|
+
curSel.anchorNode, curSel.anchorOffset)) {
|
|
49
|
+
view.mouseDown.delayedSelectionSync = true
|
|
50
|
+
view.domObserver.setCurSelection()
|
|
51
|
+
return
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
view.domObserver.disconnectSelection()
|
package/src/viewdesc.js
CHANGED
|
@@ -1422,8 +1422,8 @@ function findTextInFragment(frag, text, from, to) {
|
|
|
1422
1422
|
if (!next.isText) break
|
|
1423
1423
|
str += next.text
|
|
1424
1424
|
}
|
|
1425
|
-
if (pos >= from) {
|
|
1426
|
-
let found = str.lastIndexOf(text, to - childStart)
|
|
1425
|
+
if (pos >= from && childStart < to) {
|
|
1426
|
+
let found = str.lastIndexOf(text, to - childStart - 1)
|
|
1427
1427
|
if (found >= 0 && found + text.length + childStart >= from)
|
|
1428
1428
|
return childStart + found
|
|
1429
1429
|
}
|