prosemirror-view 1.23.10 → 1.23.13
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 +18 -0
- package/dist/index.es.js +39 -17
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +39 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/domchange.js +7 -5
- package/src/domobserver.js +2 -2
- package/src/index.js +2 -2
- package/src/viewdesc.js +29 -9
package/dist/index.js
CHANGED
|
@@ -1300,8 +1300,23 @@ var NodeViewDesc = /*@__PURE__*/(function (ViewDesc) {
|
|
|
1300
1300
|
// whether this is a problem
|
|
1301
1301
|
var rule = {node: this.node.type.name, attrs: this.node.attrs};
|
|
1302
1302
|
if (this.node.type.whitespace == "pre") { rule.preserveWhitespace = "full"; }
|
|
1303
|
-
if (this.contentDOM
|
|
1304
|
-
|
|
1303
|
+
if (!this.contentDOM) {
|
|
1304
|
+
rule.getContent = function () { return this$1.node.content; };
|
|
1305
|
+
} else if (!this.contentLost) {
|
|
1306
|
+
rule.contentElement = this.contentDOM;
|
|
1307
|
+
} else {
|
|
1308
|
+
// Chrome likes to randomly recreate parent nodes when
|
|
1309
|
+
// backspacing things. When that happens, this tries to find the
|
|
1310
|
+
// new parent.
|
|
1311
|
+
for (var i = this.children.length - 1; i >= 0; i--) {
|
|
1312
|
+
var child = this.children[i];
|
|
1313
|
+
if (this.dom.contains(child.dom.parentNode)) {
|
|
1314
|
+
rule.contentElement = child.dom.parentNode;
|
|
1315
|
+
break
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (!rule.contentElement) { rule.getContent = function () { return prosemirrorModel.Fragment.empty; }; }
|
|
1319
|
+
}
|
|
1305
1320
|
return rule
|
|
1306
1321
|
};
|
|
1307
1322
|
|
|
@@ -1910,21 +1925,24 @@ ViewTreeUpdater.prototype.placeWidget = function placeWidget (widget, view, pos)
|
|
|
1910
1925
|
// Make sure a textblock looks and behaves correctly in
|
|
1911
1926
|
// contentEditable.
|
|
1912
1927
|
ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks () {
|
|
1913
|
-
var lastChild = this.top.children[this.index - 1];
|
|
1914
|
-
while (lastChild instanceof MarkViewDesc) {
|
|
1928
|
+
var lastChild = this.top.children[this.index - 1], parent = this.top;
|
|
1929
|
+
while (lastChild instanceof MarkViewDesc) {
|
|
1930
|
+
parent = lastChild;
|
|
1931
|
+
lastChild = parent.children[parent.children.length - 1];
|
|
1932
|
+
}
|
|
1915
1933
|
|
|
1916
1934
|
if (!lastChild || // Empty textblock
|
|
1917
1935
|
!(lastChild instanceof TextViewDesc) ||
|
|
1918
1936
|
/\n$/.test(lastChild.node.text)) {
|
|
1919
1937
|
// Avoid bugs in Safari's cursor drawing (#1165) and Chrome's mouse selection (#1152)
|
|
1920
1938
|
if ((result.safari || result.chrome) && lastChild && lastChild.dom.contentEditable == "false")
|
|
1921
|
-
{ this.addHackNode("IMG"); }
|
|
1922
|
-
this.addHackNode("BR");
|
|
1939
|
+
{ this.addHackNode("IMG", parent); }
|
|
1940
|
+
this.addHackNode("BR", this.top);
|
|
1923
1941
|
}
|
|
1924
1942
|
};
|
|
1925
1943
|
|
|
1926
|
-
ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
1927
|
-
if (this.index <
|
|
1944
|
+
ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName, parent) {
|
|
1945
|
+
if (parent == this.top && this.index < parent.children.length && parent.children[this.index].matchesHack(nodeName)) {
|
|
1928
1946
|
this.index++;
|
|
1929
1947
|
} else {
|
|
1930
1948
|
var dom = document.createElement(nodeName);
|
|
@@ -1933,7 +1951,9 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
|
|
|
1933
1951
|
dom.alt = "";
|
|
1934
1952
|
}
|
|
1935
1953
|
if (nodeName == "BR") { dom.className = "ProseMirror-trailingBreak"; }
|
|
1936
|
-
|
|
1954
|
+
var hack = new TrailingHackViewDesc(this.top, nothing, dom, null);
|
|
1955
|
+
if (parent != this.top) { parent.children.push(hack); }
|
|
1956
|
+
else { parent.children.splice(this.index++, 0, hack); }
|
|
1937
1957
|
this.changed = true;
|
|
1938
1958
|
}
|
|
1939
1959
|
};
|
|
@@ -2714,15 +2734,17 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
2714
2734
|
view.lastKeyCode = null;
|
|
2715
2735
|
|
|
2716
2736
|
var change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
|
|
2737
|
+
if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) &&
|
|
2738
|
+
addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }) &&
|
|
2739
|
+
(!change || change.endA >= change.endB) &&
|
|
2740
|
+
view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); })) {
|
|
2741
|
+
view.lastIOSEnter = 0;
|
|
2742
|
+
return
|
|
2743
|
+
}
|
|
2717
2744
|
if (!change) {
|
|
2718
2745
|
if (typeOver && sel instanceof prosemirrorState.TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) &&
|
|
2719
2746
|
!view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {
|
|
2720
2747
|
change = {start: sel.from, endA: sel.to, endB: sel.to};
|
|
2721
|
-
} else if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) &&
|
|
2722
|
-
addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }) &&
|
|
2723
|
-
view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); })) {
|
|
2724
|
-
view.lastIOSEnter = 0;
|
|
2725
|
-
return
|
|
2726
2748
|
} else {
|
|
2727
2749
|
if (parse.sel) {
|
|
2728
2750
|
var sel$1 = resolveSelection(view, view.state.doc, parse.sel);
|
|
@@ -3342,7 +3364,7 @@ DOMObserver.prototype.flush = function flush () {
|
|
|
3342
3364
|
}
|
|
3343
3365
|
|
|
3344
3366
|
var sel = this.view.root.getSelection();
|
|
3345
|
-
var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) &&
|
|
3367
|
+
var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(this.view) && !this.ignoreSelectionChange(sel);
|
|
3346
3368
|
|
|
3347
3369
|
var from = -1, to = -1, typeOver = false, added = [];
|
|
3348
3370
|
if (this.view.editable) {
|
|
@@ -4935,7 +4957,7 @@ var prototypeAccessors$2 = { props: { configurable: true },root: { configurable:
|
|
|
4935
4957
|
|
|
4936
4958
|
// composing:: boolean
|
|
4937
4959
|
// Holds `true` when a
|
|
4938
|
-
// [composition](https://
|
|
4960
|
+
// [composition](https://w3c.github.io/uievents/#events-compositionevents)
|
|
4939
4961
|
// is active.
|
|
4940
4962
|
|
|
4941
4963
|
// :: DirectEditorProps
|
|
@@ -5512,7 +5534,7 @@ function checkStateComponent(plugin) {
|
|
|
5512
5534
|
|
|
5513
5535
|
// DirectEditorProps:: interface extends EditorProps
|
|
5514
5536
|
//
|
|
5515
|
-
// The props object given directly to the editor view supports
|
|
5537
|
+
// The props object given directly to the editor view supports some
|
|
5516
5538
|
// fields that can't be used in plugins:
|
|
5517
5539
|
//
|
|
5518
5540
|
// state:: EditorState
|