prosemirror-view 1.23.6 → 1.23.9
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 +20 -0
- package/dist/index.es.js +23 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/dom.js +2 -1
- package/src/domchange.js +5 -2
- package/src/domobserver.js +1 -1
- package/src/index.js +5 -1
- package/src/input.js +1 -1
- package/src/viewdesc.js +9 -3
package/dist/index.js
CHANGED
|
@@ -68,7 +68,8 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
68
68
|
if (node == targetNode && off == targetOff) { return true }
|
|
69
69
|
if (off == (dir < 0 ? 0 : nodeSize(node))) {
|
|
70
70
|
var parent = node.parentNode;
|
|
71
|
-
if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
|
|
71
|
+
if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
|
|
72
|
+
node.contentEditable == "false")
|
|
72
73
|
{ return false }
|
|
73
74
|
off = domIndex(node) + (dir < 0 ? 0 : 1);
|
|
74
75
|
node = parent;
|
|
@@ -1927,7 +1928,10 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
|
1927
1928
|
this.index++;
|
|
1928
1929
|
} else {
|
|
1929
1930
|
var dom = document.createElement(nodeName);
|
|
1930
|
-
if (nodeName == "IMG") {
|
|
1931
|
+
if (nodeName == "IMG") {
|
|
1932
|
+
dom.className = "ProseMirror-separator";
|
|
1933
|
+
dom.alt = "";
|
|
1934
|
+
}
|
|
1931
1935
|
if (nodeName == "BR") { dom.className = "ProseMirror-trailingBreak"; }
|
|
1932
1936
|
this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
|
|
1933
1937
|
this.changed = true;
|
|
@@ -2085,10 +2089,13 @@ function findTextInFragment(frag, text, from, to) {
|
|
|
2085
2089
|
if (!next.isText) { break }
|
|
2086
2090
|
str += next.text;
|
|
2087
2091
|
}
|
|
2088
|
-
if (pos >= from
|
|
2089
|
-
var found = str.lastIndexOf(text, to - childStart - 1);
|
|
2092
|
+
if (pos >= from) {
|
|
2093
|
+
var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
|
|
2090
2094
|
if (found >= 0 && found + text.length + childStart >= from)
|
|
2091
2095
|
{ return childStart + found }
|
|
2096
|
+
if (from == to && str.length >= (to + text.length) - childStart &&
|
|
2097
|
+
str.slice(to - childStart, to - childStart + text.length) == text)
|
|
2098
|
+
{ return to }
|
|
2092
2099
|
}
|
|
2093
2100
|
}
|
|
2094
2101
|
return -1
|
|
@@ -2685,6 +2692,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
2685
2692
|
|
|
2686
2693
|
var sel = view.state.selection;
|
|
2687
2694
|
var parse = parseBetween(view, from, to);
|
|
2695
|
+
|
|
2688
2696
|
// Chrome sometimes leaves the cursor before the inserted text when
|
|
2689
2697
|
// composing after a cursor wrapper. This moves it forward.
|
|
2690
2698
|
if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
|
|
@@ -2730,9 +2738,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
2730
2738
|
if (view.state.selection.from < view.state.selection.to &&
|
|
2731
2739
|
change.start == change.endB &&
|
|
2732
2740
|
view.state.selection instanceof prosemirrorState.TextSelection) {
|
|
2733
|
-
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2
|
|
2741
|
+
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 &&
|
|
2742
|
+
view.state.selection.from >= parse.from) {
|
|
2734
2743
|
change.start = view.state.selection.from;
|
|
2735
|
-
} else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2
|
|
2744
|
+
} else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 &&
|
|
2745
|
+
view.state.selection.to <= parse.to) {
|
|
2736
2746
|
change.endB += (view.state.selection.to - change.endA);
|
|
2737
2747
|
change.endA = view.state.selection.to;
|
|
2738
2748
|
}
|
|
@@ -3362,7 +3372,7 @@ DOMObserver.prototype.flush = function flush () {
|
|
|
3362
3372
|
checkCSS(this.view);
|
|
3363
3373
|
}
|
|
3364
3374
|
this.handleDOMChange(from, to, typeOver, added);
|
|
3365
|
-
if (this.view.docView.dirty) { this.view.updateState(this.view.state); }
|
|
3375
|
+
if (this.view.docView && this.view.docView.dirty) { this.view.updateState(this.view.state); }
|
|
3366
3376
|
else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }
|
|
3367
3377
|
this.currentSelection.set(sel);
|
|
3368
3378
|
}
|
|
@@ -3913,7 +3923,7 @@ function endComposition(view, forceUpdate) {
|
|
|
3913
3923
|
if (result.android && view.domObserver.flushingSoon >= 0) { return }
|
|
3914
3924
|
view.domObserver.forceFlush();
|
|
3915
3925
|
clearComposition(view);
|
|
3916
|
-
if (forceUpdate || view.docView.dirty) {
|
|
3926
|
+
if (forceUpdate || view.docView && view.docView.dirty) {
|
|
3917
3927
|
var sel = selectionFromDOM(view);
|
|
3918
3928
|
if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }
|
|
3919
3929
|
else { view.updateState(view.state); }
|
|
@@ -5281,6 +5291,7 @@ function updateCursorWrapper(view) {
|
|
|
5281
5291
|
var dom = document.createElement("img");
|
|
5282
5292
|
dom.className = "ProseMirror-separator";
|
|
5283
5293
|
dom.setAttribute("mark-placeholder", "true");
|
|
5294
|
+
dom.setAttribute("alt", "");
|
|
5284
5295
|
view.cursorWrapper = {dom: dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})};
|
|
5285
5296
|
} else {
|
|
5286
5297
|
view.cursorWrapper = null;
|
|
@@ -5455,7 +5466,10 @@ function checkStateComponent(plugin) {
|
|
|
5455
5466
|
// The DOM serializer to use when putting content onto the
|
|
5456
5467
|
// clipboard. If not given, the result of
|
|
5457
5468
|
// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
|
|
5458
|
-
// will be used.
|
|
5469
|
+
// will be used. This object will only have its
|
|
5470
|
+
// [`serializeFragment`](#model.DOMSerializer.serializeFragment)
|
|
5471
|
+
// method called, and you may provide an alternative object type
|
|
5472
|
+
// implementing a compatible method.
|
|
5459
5473
|
//
|
|
5460
5474
|
// clipboardTextSerializer:: ?(Slice) → string
|
|
5461
5475
|
// A function that will be called to get the text for the current
|