prosemirror-view 1.41.8 → 1.42.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 +18 -0
- package/dist/index.cjs +231 -146
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +136 -72
- package/package.json +2 -2
- package/src/clipboard.ts +14 -3
- package/src/domchange.ts +3 -13
- package/src/domobserver.ts +4 -1
- package/src/index.ts +3 -2
- package/src/input.ts +88 -34
- package/src/selection.ts +6 -6
- package/src/viewdesc.ts +31 -14
package/dist/index.cjs
CHANGED
|
@@ -1272,7 +1272,7 @@ var MarkViewDesc = function (_ViewDesc3) {
|
|
|
1272
1272
|
var NodeViewDesc = function (_ViewDesc4) {
|
|
1273
1273
|
_inherits(NodeViewDesc, _ViewDesc4);
|
|
1274
1274
|
var _super4 = _createSuper(NodeViewDesc);
|
|
1275
|
-
function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM
|
|
1275
|
+
function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM) {
|
|
1276
1276
|
var _this4;
|
|
1277
1277
|
_classCallCheck(this, NodeViewDesc);
|
|
1278
1278
|
_this4 = _super4.call(this, parent, [], dom, contentDOM);
|
|
@@ -1474,23 +1474,23 @@ var NodeViewDesc = function (_ViewDesc4) {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
var nodeDOM = dom;
|
|
1476
1476
|
dom = applyOuterDeco(dom, outerDeco, node);
|
|
1477
|
-
if (spec) return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null, nodeDOM, spec
|
|
1477
|
+
if (spec) return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null, nodeDOM, spec);else if (node.isText) return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM);else return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null, nodeDOM);
|
|
1478
1478
|
}
|
|
1479
1479
|
}]);
|
|
1480
1480
|
return NodeViewDesc;
|
|
1481
1481
|
}(ViewDesc);
|
|
1482
1482
|
function docViewDesc(doc, outerDeco, innerDeco, dom, view) {
|
|
1483
1483
|
applyOuterDeco(dom, outerDeco, doc);
|
|
1484
|
-
var docView = new NodeViewDesc(undefined, doc, outerDeco, innerDeco, dom, dom, dom
|
|
1484
|
+
var docView = new NodeViewDesc(undefined, doc, outerDeco, innerDeco, dom, dom, dom);
|
|
1485
1485
|
if (docView.contentDOM) docView.updateChildren(view, 0);
|
|
1486
1486
|
return docView;
|
|
1487
1487
|
}
|
|
1488
1488
|
var TextViewDesc = function (_NodeViewDesc) {
|
|
1489
1489
|
_inherits(TextViewDesc, _NodeViewDesc);
|
|
1490
1490
|
var _super5 = _createSuper(TextViewDesc);
|
|
1491
|
-
function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM
|
|
1491
|
+
function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM) {
|
|
1492
1492
|
_classCallCheck(this, TextViewDesc);
|
|
1493
|
-
return _super5.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM
|
|
1493
|
+
return _super5.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM);
|
|
1494
1494
|
}
|
|
1495
1495
|
_createClass(TextViewDesc, [{
|
|
1496
1496
|
key: "parseRule",
|
|
@@ -1542,10 +1542,10 @@ var TextViewDesc = function (_NodeViewDesc) {
|
|
|
1542
1542
|
}
|
|
1543
1543
|
}, {
|
|
1544
1544
|
key: "slice",
|
|
1545
|
-
value: function slice(from, to,
|
|
1545
|
+
value: function slice(from, to, _view) {
|
|
1546
1546
|
var node = this.node.cut(from, to),
|
|
1547
1547
|
dom = document.createTextNode(node.text);
|
|
1548
|
-
return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom
|
|
1548
|
+
return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom);
|
|
1549
1549
|
}
|
|
1550
1550
|
}, {
|
|
1551
1551
|
key: "markDirty",
|
|
@@ -1601,10 +1601,10 @@ var TrailingHackViewDesc = function (_ViewDesc5) {
|
|
|
1601
1601
|
var CustomNodeViewDesc = function (_NodeViewDesc2) {
|
|
1602
1602
|
_inherits(CustomNodeViewDesc, _NodeViewDesc2);
|
|
1603
1603
|
var _super7 = _createSuper(CustomNodeViewDesc);
|
|
1604
|
-
function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec
|
|
1604
|
+
function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec) {
|
|
1605
1605
|
var _this7;
|
|
1606
1606
|
_classCallCheck(this, CustomNodeViewDesc);
|
|
1607
|
-
_this7 = _super7.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM
|
|
1607
|
+
_this7 = _super7.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM);
|
|
1608
1608
|
_this7.spec = spec;
|
|
1609
1609
|
return _this7;
|
|
1610
1610
|
}
|
|
@@ -1810,6 +1810,14 @@ var ViewTreeUpdater = function () {
|
|
|
1810
1810
|
break;
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
|
+
if (found < 0 && this.index < this.top.children.length) {
|
|
1814
|
+
var cur = this.top.children[this.index];
|
|
1815
|
+
if (cur instanceof MarkViewDesc && cur.dirty != NODE_DIRTY && cur.mark.type == marks[depth].type && cur.spec.update && !this.isLocked(cur.dom) && cur.spec.update(marks[depth])) {
|
|
1816
|
+
cur.mark = marks[depth];
|
|
1817
|
+
found = this.index;
|
|
1818
|
+
this.changed = true;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1813
1821
|
if (found > -1) {
|
|
1814
1822
|
if (found > this.index) {
|
|
1815
1823
|
this.changed = true;
|
|
@@ -2201,11 +2209,11 @@ function selectionToDOM(view) {
|
|
|
2201
2209
|
var sel = view.state.selection;
|
|
2202
2210
|
syncNodeSelection(view, sel);
|
|
2203
2211
|
if (!editorOwnsSelection(view)) return;
|
|
2204
|
-
|
|
2212
|
+
var mouseDown = view.input.mouseDown;
|
|
2213
|
+
if (!force && chrome && mouseDown) {
|
|
2205
2214
|
var domSel = view.domSelectionRange(),
|
|
2206
2215
|
curSel = view.domObserver.currentSelection;
|
|
2207
|
-
if (domSel.anchorNode && curSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset, curSel.anchorNode, curSel.anchorOffset)) {
|
|
2208
|
-
view.input.mouseDown.delayedSelectionSync = true;
|
|
2216
|
+
if (domSel.anchorNode && curSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset, curSel.anchorNode, curSel.anchorOffset) && mouseDown.delaySelUpdate()) {
|
|
2209
2217
|
view.domObserver.setCurSelection();
|
|
2210
2218
|
return;
|
|
2211
2219
|
}
|
|
@@ -2831,9 +2839,8 @@ var wrapMap = {
|
|
|
2831
2839
|
td: ["table", "tbody", "tr"],
|
|
2832
2840
|
th: ["table", "tbody", "tr"]
|
|
2833
2841
|
};
|
|
2834
|
-
var _detachedDoc = null;
|
|
2835
2842
|
function detachedDoc() {
|
|
2836
|
-
return
|
|
2843
|
+
return document.implementation.createHTMLDocument("title");
|
|
2837
2844
|
}
|
|
2838
2845
|
var _policy = null;
|
|
2839
2846
|
function maybeWrapTrusted(html) {
|
|
@@ -2849,7 +2856,8 @@ function maybeWrapTrusted(html) {
|
|
|
2849
2856
|
function readHTML(html) {
|
|
2850
2857
|
var metas = /^(\s*<meta [^>]*>)*/.exec(html);
|
|
2851
2858
|
if (metas) html = html.slice(metas[0].length);
|
|
2852
|
-
var
|
|
2859
|
+
var doc = detachedDoc(),
|
|
2860
|
+
elt = doc.body;
|
|
2853
2861
|
var firstTag = /<([a-z][^>\s]+)/i.exec(html),
|
|
2854
2862
|
wrap;
|
|
2855
2863
|
if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) html = wrap.map(function (n) {
|
|
@@ -2859,6 +2867,16 @@ function readHTML(html) {
|
|
|
2859
2867
|
}).reverse().join("");
|
|
2860
2868
|
elt.innerHTML = maybeWrapTrusted(html);
|
|
2861
2869
|
if (wrap) for (var i = 0; i < wrap.length; i++) elt = elt.querySelector(wrap[i]) || elt;
|
|
2870
|
+
for (var _i6 = 0; _i6 < doc.styleSheets.length; _i6++) {
|
|
2871
|
+
var style = doc.styleSheets[_i6];
|
|
2872
|
+
for (var j = 0; j < style.rules.length; j++) {
|
|
2873
|
+
var rule = style.rules[j];
|
|
2874
|
+
if (rule instanceof CSSStyleRule) {
|
|
2875
|
+
var matches = elt.querySelectorAll(rule.selectorText);
|
|
2876
|
+
for (var k = 0; k < matches.length; k++) matches[k].style.cssText += rule.style.cssText;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2862
2880
|
return elt;
|
|
2863
2881
|
}
|
|
2864
2882
|
function restoreReplacedSpaces(dom) {
|
|
@@ -2949,6 +2967,7 @@ function setSelectionOrigin(view, origin) {
|
|
|
2949
2967
|
view.input.lastSelectionTime = Date.now();
|
|
2950
2968
|
}
|
|
2951
2969
|
function destroyInput(view) {
|
|
2970
|
+
if (view.input.mouseDown) view.input.mouseDown.done();
|
|
2952
2971
|
view.domObserver.stop();
|
|
2953
2972
|
for (var type in view.input.eventHandlers) view.dom.removeEventListener(type, view.input.eventHandlers[type]);
|
|
2954
2973
|
clearTimeout(view.input.composingTimeout);
|
|
@@ -2979,7 +2998,7 @@ function _dispatchEvent(view, event) {
|
|
|
2979
2998
|
editHandlers.keydown = function (view, _event) {
|
|
2980
2999
|
var event = _event;
|
|
2981
3000
|
view.input.shiftKey = event.keyCode == 16 || event.shiftKey;
|
|
2982
|
-
if (inOrNearComposition(view
|
|
3001
|
+
if (inOrNearComposition(view)) return;
|
|
2983
3002
|
view.input.lastKeyCode = event.keyCode;
|
|
2984
3003
|
view.input.lastKeyCodeTime = Date.now();
|
|
2985
3004
|
if (android && chrome && event.keyCode == 13) return;
|
|
@@ -3008,7 +3027,7 @@ editHandlers.keyup = function (view, event) {
|
|
|
3008
3027
|
};
|
|
3009
3028
|
editHandlers.keypress = function (view, _event) {
|
|
3010
3029
|
var event = _event;
|
|
3011
|
-
if (inOrNearComposition(view
|
|
3030
|
+
if (inOrNearComposition(view) || !event.charCode || event.ctrlKey && !event.altKey || mac && event.metaKey) return;
|
|
3012
3031
|
if (view.someProp("handleKeyPress", function (f) {
|
|
3013
3032
|
return f(view, event);
|
|
3014
3033
|
})) {
|
|
@@ -3110,21 +3129,23 @@ function handleTripleClick(view, pos, inside, event) {
|
|
|
3110
3129
|
}
|
|
3111
3130
|
function defaultTripleClick(view, inside, event) {
|
|
3112
3131
|
if (event.button != 0) return false;
|
|
3132
|
+
var selection = selectionForTripleClick(view, inside, true),
|
|
3133
|
+
doc = view.state.doc;
|
|
3134
|
+
if (!selection) return false;
|
|
3135
|
+
updateSelection(view, selection, "pointer");
|
|
3136
|
+
if (selection instanceof prosemirrorState.TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
|
|
3137
|
+
return true;
|
|
3138
|
+
}
|
|
3139
|
+
function selectionForTripleClick(view, inside, selectNodes) {
|
|
3113
3140
|
var doc = view.state.doc;
|
|
3114
|
-
if (inside == -1)
|
|
3115
|
-
if (doc.inlineContent) {
|
|
3116
|
-
updateSelection(view, prosemirrorState.TextSelection.create(doc, 0, doc.content.size), "pointer");
|
|
3117
|
-
return true;
|
|
3118
|
-
}
|
|
3119
|
-
return false;
|
|
3120
|
-
}
|
|
3141
|
+
if (inside == -1) return doc.inlineContent ? prosemirrorState.TextSelection.create(doc, 0, doc.content.size) : null;
|
|
3121
3142
|
var $pos = doc.resolve(inside);
|
|
3122
3143
|
for (var i = $pos.depth + 1; i > 0; i--) {
|
|
3123
3144
|
var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
|
|
3124
3145
|
var nodePos = $pos.before(i);
|
|
3125
|
-
if (node.inlineContent)
|
|
3126
|
-
return true;
|
|
3146
|
+
if (node.inlineContent) return prosemirrorState.TextSelection.create(doc, nodePos + 1, nodePos + 1 + node.content.size);else if (selectNodes && prosemirrorState.NodeSelection.isSelectable(node)) return prosemirrorState.NodeSelection.create(doc, nodePos);
|
|
3127
3147
|
}
|
|
3148
|
+
return null;
|
|
3128
3149
|
}
|
|
3129
3150
|
function forceDOMFlush(view) {
|
|
3130
3151
|
return endComposition(view);
|
|
@@ -3146,11 +3167,11 @@ handlers.mousedown = function (view, _event) {
|
|
|
3146
3167
|
type: type,
|
|
3147
3168
|
button: event.button
|
|
3148
3169
|
};
|
|
3170
|
+
if (view.input.mouseDown) view.input.mouseDown.done();
|
|
3149
3171
|
var pos = view.posAtCoords(eventCoords(event));
|
|
3150
3172
|
if (!pos) return;
|
|
3151
3173
|
if (type == "singleClick") {
|
|
3152
|
-
|
|
3153
|
-
view.input.mouseDown = new MouseDown(view, pos, event, !!flushed);
|
|
3174
|
+
view.input.mouseDown = new LeftMouseDown(view, pos, event, !!flushed);
|
|
3154
3175
|
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
|
|
3155
3176
|
event.preventDefault();
|
|
3156
3177
|
} else {
|
|
@@ -3158,18 +3179,52 @@ handlers.mousedown = function (view, _event) {
|
|
|
3158
3179
|
}
|
|
3159
3180
|
};
|
|
3160
3181
|
var MouseDown = function () {
|
|
3161
|
-
function MouseDown(view
|
|
3162
|
-
var _this8 = this;
|
|
3182
|
+
function MouseDown(view) {
|
|
3163
3183
|
_classCallCheck(this, MouseDown);
|
|
3164
3184
|
this.view = view;
|
|
3165
|
-
this.pos = pos;
|
|
3166
|
-
this.event = event;
|
|
3167
|
-
this.flushed = flushed;
|
|
3168
|
-
this.delayedSelectionSync = false;
|
|
3169
3185
|
this.mightDrag = null;
|
|
3170
|
-
this.
|
|
3171
|
-
this.
|
|
3172
|
-
|
|
3186
|
+
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
3187
|
+
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3188
|
+
}
|
|
3189
|
+
_createClass(MouseDown, [{
|
|
3190
|
+
key: "up",
|
|
3191
|
+
value: function up(event) {
|
|
3192
|
+
this.done();
|
|
3193
|
+
}
|
|
3194
|
+
}, {
|
|
3195
|
+
key: "move",
|
|
3196
|
+
value: function move(event) {
|
|
3197
|
+
if (event.buttons == 0) this.done();
|
|
3198
|
+
}
|
|
3199
|
+
}, {
|
|
3200
|
+
key: "done",
|
|
3201
|
+
value: function done() {
|
|
3202
|
+
this.view.root.removeEventListener("mouseup", this.up);
|
|
3203
|
+
this.view.root.removeEventListener("mousemove", this.move);
|
|
3204
|
+
if (this.view.input.mouseDown == this) this.view.input.mouseDown = null;
|
|
3205
|
+
}
|
|
3206
|
+
}, {
|
|
3207
|
+
key: "delaySelUpdate",
|
|
3208
|
+
value: function delaySelUpdate() {
|
|
3209
|
+
return false;
|
|
3210
|
+
}
|
|
3211
|
+
}]);
|
|
3212
|
+
return MouseDown;
|
|
3213
|
+
}();
|
|
3214
|
+
var LeftMouseDown = function (_MouseDown) {
|
|
3215
|
+
_inherits(LeftMouseDown, _MouseDown);
|
|
3216
|
+
var _super8 = _createSuper(LeftMouseDown);
|
|
3217
|
+
function LeftMouseDown(view, pos, event, flushed) {
|
|
3218
|
+
var _this8;
|
|
3219
|
+
_classCallCheck(this, LeftMouseDown);
|
|
3220
|
+
_this8 = _super8.call(this, view);
|
|
3221
|
+
_this8.pos = pos;
|
|
3222
|
+
_this8.event = event;
|
|
3223
|
+
_this8.flushed = flushed;
|
|
3224
|
+
_this8.delayedSelectionSync = false;
|
|
3225
|
+
_this8.startDoc = view.state.doc;
|
|
3226
|
+
_this8.selectNode = !!event[selectNodeModifier];
|
|
3227
|
+
_this8.allowDefault = event.shiftKey;
|
|
3173
3228
|
var targetNode, targetPos;
|
|
3174
3229
|
if (pos.inside > -1) {
|
|
3175
3230
|
targetNode = view.state.doc.nodeAt(pos.inside);
|
|
@@ -3181,32 +3236,30 @@ var MouseDown = function () {
|
|
|
3181
3236
|
}
|
|
3182
3237
|
var target = flushed ? null : event.target;
|
|
3183
3238
|
var targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3184
|
-
|
|
3239
|
+
_this8.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
|
|
3185
3240
|
var selection = view.state.selection;
|
|
3186
|
-
if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos))
|
|
3241
|
+
if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos)) _this8.mightDrag = {
|
|
3187
3242
|
node: targetNode,
|
|
3188
3243
|
pos: targetPos,
|
|
3189
|
-
addAttr: !!(
|
|
3190
|
-
setUneditable: !!(
|
|
3244
|
+
addAttr: !!(_this8.target && !_this8.target.draggable),
|
|
3245
|
+
setUneditable: !!(_this8.target && gecko && !_this8.target.hasAttribute("contentEditable"))
|
|
3191
3246
|
};
|
|
3192
|
-
if (
|
|
3193
|
-
|
|
3194
|
-
if (
|
|
3195
|
-
if (
|
|
3196
|
-
if (_this8.view.input.mouseDown == _this8) _this8.target.setAttribute("contentEditable", "false");
|
|
3247
|
+
if (_this8.target && _this8.mightDrag && (_this8.mightDrag.addAttr || _this8.mightDrag.setUneditable)) {
|
|
3248
|
+
_this8.view.domObserver.stop();
|
|
3249
|
+
if (_this8.mightDrag.addAttr) _this8.target.draggable = true;
|
|
3250
|
+
if (_this8.mightDrag.setUneditable) setTimeout(function () {
|
|
3251
|
+
if (_this8.view.input.mouseDown == _assertThisInitialized(_this8)) _this8.target.setAttribute("contentEditable", "false");
|
|
3197
3252
|
}, 20);
|
|
3198
|
-
|
|
3253
|
+
_this8.view.domObserver.start();
|
|
3199
3254
|
}
|
|
3200
|
-
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
3201
|
-
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3202
3255
|
setSelectionOrigin(view, "pointer");
|
|
3256
|
+
return _this8;
|
|
3203
3257
|
}
|
|
3204
|
-
_createClass(
|
|
3258
|
+
_createClass(LeftMouseDown, [{
|
|
3205
3259
|
key: "done",
|
|
3206
3260
|
value: function done() {
|
|
3207
3261
|
var _this9 = this;
|
|
3208
|
-
|
|
3209
|
-
this.view.root.removeEventListener("mousemove", this.move);
|
|
3262
|
+
_get(_getPrototypeOf(LeftMouseDown.prototype), "done", this).call(this);
|
|
3210
3263
|
if (this.mightDrag && this.target) {
|
|
3211
3264
|
this.view.domObserver.stop();
|
|
3212
3265
|
if (this.mightDrag.addAttr) this.target.removeAttribute("draggable");
|
|
@@ -3214,9 +3267,8 @@ var MouseDown = function () {
|
|
|
3214
3267
|
this.view.domObserver.start();
|
|
3215
3268
|
}
|
|
3216
3269
|
if (this.delayedSelectionSync) setTimeout(function () {
|
|
3217
|
-
|
|
3270
|
+
if (!_this9.view.isDestroyed) selectionToDOM(_this9.view);
|
|
3218
3271
|
});
|
|
3219
|
-
this.view.input.mouseDown = null;
|
|
3220
3272
|
}
|
|
3221
3273
|
}, {
|
|
3222
3274
|
key: "up",
|
|
@@ -3242,16 +3294,57 @@ var MouseDown = function () {
|
|
|
3242
3294
|
value: function move(event) {
|
|
3243
3295
|
this.updateAllowDefault(event);
|
|
3244
3296
|
setSelectionOrigin(this.view, "pointer");
|
|
3245
|
-
|
|
3297
|
+
_get(_getPrototypeOf(LeftMouseDown.prototype), "move", this).call(this, event);
|
|
3246
3298
|
}
|
|
3247
3299
|
}, {
|
|
3248
3300
|
key: "updateAllowDefault",
|
|
3249
3301
|
value: function updateAllowDefault(event) {
|
|
3250
3302
|
if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4)) this.allowDefault = true;
|
|
3251
3303
|
}
|
|
3304
|
+
}, {
|
|
3305
|
+
key: "delaySelUpdate",
|
|
3306
|
+
value: function delaySelUpdate() {
|
|
3307
|
+
if (!this.allowDefault) return false;
|
|
3308
|
+
this.delayedSelectionSync = true;
|
|
3309
|
+
return true;
|
|
3310
|
+
}
|
|
3252
3311
|
}]);
|
|
3253
|
-
return
|
|
3254
|
-
}();
|
|
3312
|
+
return LeftMouseDown;
|
|
3313
|
+
}(MouseDown);
|
|
3314
|
+
var TripleClickDrag = function (_MouseDown2) {
|
|
3315
|
+
_inherits(TripleClickDrag, _MouseDown2);
|
|
3316
|
+
var _super9 = _createSuper(TripleClickDrag);
|
|
3317
|
+
function TripleClickDrag(view, startSelection) {
|
|
3318
|
+
var _this10;
|
|
3319
|
+
_classCallCheck(this, TripleClickDrag);
|
|
3320
|
+
_this10 = _super9.call(this, view);
|
|
3321
|
+
_this10.startSelection = startSelection;
|
|
3322
|
+
_this10.startDoc = view.state.doc;
|
|
3323
|
+
return _this10;
|
|
3324
|
+
}
|
|
3325
|
+
_createClass(TripleClickDrag, [{
|
|
3326
|
+
key: "move",
|
|
3327
|
+
value: function move(event) {
|
|
3328
|
+
if (event.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) {
|
|
3329
|
+
this.done();
|
|
3330
|
+
return;
|
|
3331
|
+
}
|
|
3332
|
+
event.preventDefault();
|
|
3333
|
+
setSelectionOrigin(this.view, "pointer");
|
|
3334
|
+
var pos = this.view.posAtCoords(eventCoords(event));
|
|
3335
|
+
var target = pos && selectionForTripleClick(this.view, pos.inside, false);
|
|
3336
|
+
if (!target) return;
|
|
3337
|
+
var doc = this.view.state.doc,
|
|
3338
|
+
start = this.startSelection;
|
|
3339
|
+
var _ref5 = target.from < start.from ? [start.to, target.from] : [start.from, target.to],
|
|
3340
|
+
_ref6 = _slicedToArray(_ref5, 2),
|
|
3341
|
+
anchor = _ref6[0],
|
|
3342
|
+
head = _ref6[1];
|
|
3343
|
+
updateSelection(this.view, prosemirrorState.TextSelection.create(doc, anchor, head), "pointer");
|
|
3344
|
+
}
|
|
3345
|
+
}]);
|
|
3346
|
+
return TripleClickDrag;
|
|
3347
|
+
}(MouseDown);
|
|
3255
3348
|
handlers.touchstart = function (view) {
|
|
3256
3349
|
view.input.lastTouch = Date.now();
|
|
3257
3350
|
forceDOMFlush(view);
|
|
@@ -3266,7 +3359,7 @@ handlers.contextmenu = function (view) {
|
|
|
3266
3359
|
};
|
|
3267
3360
|
function inOrNearComposition(view, event) {
|
|
3268
3361
|
if (view.composing) return true;
|
|
3269
|
-
if (safari && Math.abs(
|
|
3362
|
+
if (safari && Math.abs(Date.now() - view.input.compositionEndedAt) < 500) {
|
|
3270
3363
|
view.input.compositionEndedAt = -2e8;
|
|
3271
3364
|
return true;
|
|
3272
3365
|
}
|
|
@@ -3317,7 +3410,7 @@ function selectionBeforeUneditable(view) {
|
|
|
3317
3410
|
editHandlers.compositionend = function (view, event) {
|
|
3318
3411
|
if (view.composing) {
|
|
3319
3412
|
view.input.composing = false;
|
|
3320
|
-
view.input.compositionEndedAt =
|
|
3413
|
+
view.input.compositionEndedAt = Date.now();
|
|
3321
3414
|
view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
|
|
3322
3415
|
view.input.compositionNode = null;
|
|
3323
3416
|
if (view.input.badSafariComposition) view.domObserver.forceFlush();else if (view.input.compositionPendingChanges) Promise.resolve().then(function () {
|
|
@@ -3336,7 +3429,7 @@ function scheduleComposeEnd(view, delay) {
|
|
|
3336
3429
|
function clearComposition(view) {
|
|
3337
3430
|
if (view.composing) {
|
|
3338
3431
|
view.input.composing = false;
|
|
3339
|
-
view.input.compositionEndedAt =
|
|
3432
|
+
view.input.compositionEndedAt = Date.now();
|
|
3340
3433
|
}
|
|
3341
3434
|
while (view.input.compositionNodes.length > 0) view.input.compositionNodes.pop().markParentsDirty();
|
|
3342
3435
|
}
|
|
@@ -3358,11 +3451,6 @@ function findCompositionNode(view) {
|
|
|
3358
3451
|
}
|
|
3359
3452
|
return textBefore || textAfter;
|
|
3360
3453
|
}
|
|
3361
|
-
function timestampFromCustomEvent() {
|
|
3362
|
-
var event = document.createEvent("Event");
|
|
3363
|
-
event.initEvent("event", true, true);
|
|
3364
|
-
return event.timeStamp;
|
|
3365
|
-
}
|
|
3366
3454
|
function endComposition(view) {
|
|
3367
3455
|
var restarting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3368
3456
|
if (android && view.domObserver.flushingSoon >= 0) return;
|
|
@@ -3782,10 +3870,10 @@ var DecorationSet = function () {
|
|
|
3782
3870
|
var span = this.local[i];
|
|
3783
3871
|
if (span.from <= end && span.to >= start && (!predicate || predicate(span.spec))) result.push(span.copy(span.from + offset, span.to + offset));
|
|
3784
3872
|
}
|
|
3785
|
-
for (var
|
|
3786
|
-
if (this.children[
|
|
3787
|
-
var childOff = this.children[
|
|
3788
|
-
this.children[
|
|
3873
|
+
for (var _i7 = 0; _i7 < this.children.length; _i7 += 3) {
|
|
3874
|
+
if (this.children[_i7] < end && this.children[_i7 + 1] > start) {
|
|
3875
|
+
var childOff = this.children[_i7] + 1;
|
|
3876
|
+
this.children[_i7 + 2].findInner(start - childOff, end - childOff, result, offset + childOff, predicate);
|
|
3789
3877
|
}
|
|
3790
3878
|
}
|
|
3791
3879
|
}
|
|
@@ -3815,14 +3903,14 @@ var DecorationSet = function () {
|
|
|
3815
3903
|
}, {
|
|
3816
3904
|
key: "addInner",
|
|
3817
3905
|
value: function addInner(doc, decorations, offset) {
|
|
3818
|
-
var
|
|
3906
|
+
var _this11 = this;
|
|
3819
3907
|
var children,
|
|
3820
3908
|
childIndex = 0;
|
|
3821
3909
|
doc.forEach(function (childNode, childOffset) {
|
|
3822
3910
|
var baseOffset = childOffset + offset,
|
|
3823
3911
|
found;
|
|
3824
3912
|
if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) return;
|
|
3825
|
-
if (!children) children =
|
|
3913
|
+
if (!children) children = _this11.children.slice();
|
|
3826
3914
|
while (childIndex < children.length && children[childIndex] < childOffset) childIndex += 3;
|
|
3827
3915
|
if (children[childIndex] == childOffset) children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1);else children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec));
|
|
3828
3916
|
childIndex += 3;
|
|
@@ -3862,7 +3950,7 @@ var DecorationSet = function () {
|
|
|
3862
3950
|
i -= 3;
|
|
3863
3951
|
}
|
|
3864
3952
|
}
|
|
3865
|
-
if (local.length) for (var
|
|
3953
|
+
if (local.length) for (var _i8 = 0, _span; _i8 < decorations.length; _i8++) if (_span = decorations[_i8]) {
|
|
3866
3954
|
for (var _j2 = 0; _j2 < local.length; _j2++) if (local[_j2].eq(_span, offset)) {
|
|
3867
3955
|
if (local == this.local) local = this.local.slice();
|
|
3868
3956
|
local.splice(_j2--, 1);
|
|
@@ -3883,8 +3971,8 @@ var DecorationSet = function () {
|
|
|
3883
3971
|
}
|
|
3884
3972
|
var start = offset + 1,
|
|
3885
3973
|
end = start + node.content.size;
|
|
3886
|
-
for (var
|
|
3887
|
-
var dec = this.local[
|
|
3974
|
+
for (var _i9 = 0; _i9 < this.local.length; _i9++) {
|
|
3975
|
+
var dec = this.local[_i9];
|
|
3888
3976
|
if (dec.from < end && dec.to > start && dec.type instanceof InlineType) {
|
|
3889
3977
|
var from = Math.max(start, dec.from) - start,
|
|
3890
3978
|
to = Math.min(end, dec.to) - start;
|
|
@@ -3903,7 +3991,7 @@ var DecorationSet = function () {
|
|
|
3903
3991
|
if (this == other) return true;
|
|
3904
3992
|
if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) return false;
|
|
3905
3993
|
for (var i = 0; i < this.local.length; i++) if (!this.local[i].eq(other.local[i])) return false;
|
|
3906
|
-
for (var
|
|
3994
|
+
for (var _i10 = 0; _i10 < this.children.length; _i10 += 3) if (this.children[_i10] != other.children[_i10] || this.children[_i10 + 1] != other.children[_i10 + 1] || !this.children[_i10 + 2].eq(other.children[_i10 + 2])) return false;
|
|
3907
3995
|
return true;
|
|
3908
3996
|
}
|
|
3909
3997
|
}, {
|
|
@@ -4020,15 +4108,15 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
4020
4108
|
var moved = 0;
|
|
4021
4109
|
mapping.maps[i].forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
4022
4110
|
var dSize = newEnd - newStart - (oldEnd - oldStart);
|
|
4023
|
-
for (var
|
|
4024
|
-
var end = children[
|
|
4111
|
+
for (var _i14 = 0; _i14 < children.length; _i14 += 3) {
|
|
4112
|
+
var end = children[_i14 + 1];
|
|
4025
4113
|
if (end < 0 || oldStart > end + _baseOffset - moved) continue;
|
|
4026
|
-
var start = children[
|
|
4114
|
+
var start = children[_i14] + _baseOffset - moved;
|
|
4027
4115
|
if (oldEnd >= start) {
|
|
4028
|
-
children[
|
|
4116
|
+
children[_i14 + 1] = oldStart <= start ? -2 : -1;
|
|
4029
4117
|
} else if (oldStart >= _baseOffset && dSize) {
|
|
4030
|
-
children[
|
|
4031
|
-
children[
|
|
4118
|
+
children[_i14] += dSize;
|
|
4119
|
+
children[_i14 + 1] += dSize;
|
|
4032
4120
|
}
|
|
4033
4121
|
}
|
|
4034
4122
|
moved += dSize;
|
|
@@ -4040,32 +4128,32 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
4040
4128
|
_loop4(baseOffset);
|
|
4041
4129
|
}
|
|
4042
4130
|
var mustRebuild = false;
|
|
4043
|
-
for (var
|
|
4044
|
-
if (children[
|
|
4131
|
+
for (var _i11 = 0; _i11 < children.length; _i11 += 3) if (children[_i11 + 1] < 0) {
|
|
4132
|
+
if (children[_i11 + 1] == -2) {
|
|
4045
4133
|
mustRebuild = true;
|
|
4046
|
-
children[
|
|
4134
|
+
children[_i11 + 1] = -1;
|
|
4047
4135
|
continue;
|
|
4048
4136
|
}
|
|
4049
|
-
var from = mapping.map(oldChildren[
|
|
4137
|
+
var from = mapping.map(oldChildren[_i11] + oldOffset),
|
|
4050
4138
|
fromLocal = from - offset;
|
|
4051
4139
|
if (fromLocal < 0 || fromLocal >= node.content.size) {
|
|
4052
4140
|
mustRebuild = true;
|
|
4053
4141
|
continue;
|
|
4054
4142
|
}
|
|
4055
|
-
var to = mapping.map(oldChildren[
|
|
4143
|
+
var to = mapping.map(oldChildren[_i11 + 1] + oldOffset, -1),
|
|
4056
4144
|
toLocal = to - offset;
|
|
4057
4145
|
var _node$content$findInd2 = node.content.findIndex(fromLocal),
|
|
4058
4146
|
index = _node$content$findInd2.index,
|
|
4059
4147
|
childOffset = _node$content$findInd2.offset;
|
|
4060
4148
|
var childNode = node.maybeChild(index);
|
|
4061
4149
|
if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {
|
|
4062
|
-
var mapped = children[
|
|
4150
|
+
var mapped = children[_i11 + 2].mapInner(mapping, childNode, from + 1, oldChildren[_i11] + oldOffset + 1, options);
|
|
4063
4151
|
if (mapped != empty) {
|
|
4064
|
-
children[
|
|
4065
|
-
children[
|
|
4066
|
-
children[
|
|
4152
|
+
children[_i11] = fromLocal;
|
|
4153
|
+
children[_i11 + 1] = toLocal;
|
|
4154
|
+
children[_i11 + 2] = mapped;
|
|
4067
4155
|
} else {
|
|
4068
|
-
children[
|
|
4156
|
+
children[_i11 + 1] = -2;
|
|
4069
4157
|
mustRebuild = true;
|
|
4070
4158
|
}
|
|
4071
4159
|
} else {
|
|
@@ -4076,14 +4164,14 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
4076
4164
|
var decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal, mapping, offset, oldOffset, options);
|
|
4077
4165
|
var built = buildTree(decorations, node, 0, options);
|
|
4078
4166
|
newLocal = built.local;
|
|
4079
|
-
for (var
|
|
4080
|
-
children.splice(
|
|
4081
|
-
|
|
4167
|
+
for (var _i12 = 0; _i12 < children.length; _i12 += 3) if (children[_i12 + 1] < 0) {
|
|
4168
|
+
children.splice(_i12, 3);
|
|
4169
|
+
_i12 -= 3;
|
|
4082
4170
|
}
|
|
4083
|
-
for (var
|
|
4084
|
-
var _from2 = built.children[
|
|
4171
|
+
for (var _i13 = 0, j = 0; _i13 < built.children.length; _i13 += 3) {
|
|
4172
|
+
var _from2 = built.children[_i13];
|
|
4085
4173
|
while (j < children.length && children[j] < _from2) j += 3;
|
|
4086
|
-
children.splice(j, 0, built.children[
|
|
4174
|
+
children.splice(j, 0, built.children[_i13], built.children[_i13 + 1], built.children[_i13 + 2]);
|
|
4087
4175
|
}
|
|
4088
4176
|
}
|
|
4089
4177
|
return new DecorationSet(newLocal.sort(byPos), children);
|
|
@@ -4103,7 +4191,7 @@ function mapAndGatherRemainingDecorations(children, oldChildren, decorations, ma
|
|
|
4103
4191
|
var mapped = set.local[i].map(mapping, offset, oldOffset);
|
|
4104
4192
|
if (mapped) decorations.push(mapped);else if (options.onRemove) options.onRemove(set.local[i].spec);
|
|
4105
4193
|
}
|
|
4106
|
-
for (var
|
|
4194
|
+
for (var _i15 = 0; _i15 < set.children.length; _i15 += 3) gather(set.children[_i15 + 2], set.children[_i15] + oldOffset + 1);
|
|
4107
4195
|
}
|
|
4108
4196
|
for (var i = 0; i < children.length; i += 3) if (children[i + 1] == -1) gather(children[i + 2], oldChildren[i] + oldOffset + 1);
|
|
4109
4197
|
return decorations;
|
|
@@ -4224,7 +4312,7 @@ var SelectionState = function () {
|
|
|
4224
4312
|
}();
|
|
4225
4313
|
var DOMObserver = function () {
|
|
4226
4314
|
function DOMObserver(view, handleDOMChange) {
|
|
4227
|
-
var
|
|
4315
|
+
var _this12 = this;
|
|
4228
4316
|
_classCallCheck(this, DOMObserver);
|
|
4229
4317
|
this.view = view;
|
|
4230
4318
|
this.handleDOMChange = handleDOMChange;
|
|
@@ -4236,28 +4324,28 @@ var DOMObserver = function () {
|
|
|
4236
4324
|
this.suppressingSelectionUpdates = false;
|
|
4237
4325
|
this.lastChangedTextNode = null;
|
|
4238
4326
|
this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) {
|
|
4239
|
-
for (var i = 0; i < mutations.length; i++)
|
|
4327
|
+
for (var i = 0; i < mutations.length; i++) _this12.queue.push(mutations[i]);
|
|
4240
4328
|
if (ie && ie_version <= 11 && mutations.some(function (m) {
|
|
4241
4329
|
return m.type == "childList" && m.removedNodes.length || m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length;
|
|
4242
4330
|
})) {
|
|
4243
|
-
|
|
4331
|
+
_this12.flushSoon();
|
|
4244
4332
|
} else if (safari && view.composing && mutations.some(function (m) {
|
|
4245
4333
|
return m.type == "childList" && m.target.nodeName == "TR";
|
|
4246
4334
|
})) {
|
|
4247
4335
|
view.input.badSafariComposition = true;
|
|
4248
|
-
|
|
4336
|
+
_this12.flushSoon();
|
|
4249
4337
|
} else {
|
|
4250
|
-
|
|
4338
|
+
_this12.flush();
|
|
4251
4339
|
}
|
|
4252
4340
|
});
|
|
4253
4341
|
if (useCharData) {
|
|
4254
4342
|
this.onCharData = function (e) {
|
|
4255
|
-
|
|
4343
|
+
_this12.queue.push({
|
|
4256
4344
|
target: e.target,
|
|
4257
4345
|
type: "characterData",
|
|
4258
4346
|
oldValue: e.prevValue
|
|
4259
4347
|
});
|
|
4260
|
-
|
|
4348
|
+
_this12.flushSoon();
|
|
4261
4349
|
};
|
|
4262
4350
|
}
|
|
4263
4351
|
this.onSelectionChange = this.onSelectionChange.bind(this);
|
|
@@ -4265,10 +4353,10 @@ var DOMObserver = function () {
|
|
|
4265
4353
|
_createClass(DOMObserver, [{
|
|
4266
4354
|
key: "flushSoon",
|
|
4267
4355
|
value: function flushSoon() {
|
|
4268
|
-
var
|
|
4356
|
+
var _this13 = this;
|
|
4269
4357
|
if (this.flushingSoon < 0) this.flushingSoon = window.setTimeout(function () {
|
|
4270
|
-
|
|
4271
|
-
|
|
4358
|
+
_this13.flushingSoon = -1;
|
|
4359
|
+
_this13.flush();
|
|
4272
4360
|
}, 20);
|
|
4273
4361
|
}
|
|
4274
4362
|
}, {
|
|
@@ -4293,13 +4381,13 @@ var DOMObserver = function () {
|
|
|
4293
4381
|
}, {
|
|
4294
4382
|
key: "stop",
|
|
4295
4383
|
value: function stop() {
|
|
4296
|
-
var
|
|
4384
|
+
var _this14 = this;
|
|
4297
4385
|
if (this.observer) {
|
|
4298
4386
|
var take = this.observer.takeRecords();
|
|
4299
4387
|
if (take.length) {
|
|
4300
4388
|
for (var i = 0; i < take.length; i++) this.queue.push(take[i]);
|
|
4301
4389
|
window.setTimeout(function () {
|
|
4302
|
-
return
|
|
4390
|
+
return _this14.flush();
|
|
4303
4391
|
}, 20);
|
|
4304
4392
|
}
|
|
4305
4393
|
this.observer.disconnect();
|
|
@@ -4320,10 +4408,10 @@ var DOMObserver = function () {
|
|
|
4320
4408
|
}, {
|
|
4321
4409
|
key: "suppressSelectionUpdates",
|
|
4322
4410
|
value: function suppressSelectionUpdates() {
|
|
4323
|
-
var
|
|
4411
|
+
var _this15 = this;
|
|
4324
4412
|
this.suppressingSelectionUpdates = true;
|
|
4325
4413
|
setTimeout(function () {
|
|
4326
|
-
return
|
|
4414
|
+
return _this15.suppressingSelectionUpdates = false;
|
|
4327
4415
|
}, 50);
|
|
4328
4416
|
}
|
|
4329
4417
|
}, {
|
|
@@ -4406,7 +4494,9 @@ var DOMObserver = function () {
|
|
|
4406
4494
|
}
|
|
4407
4495
|
if (added.some(function (n) {
|
|
4408
4496
|
return n.nodeName == "BR";
|
|
4409
|
-
}) && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
|
|
4497
|
+
}) && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some(function (m) {
|
|
4498
|
+
return m.type == "childList" && m.removedNodes.length;
|
|
4499
|
+
}))) {
|
|
4410
4500
|
var _iterator3 = _createForOfIteratorHelper(added),
|
|
4411
4501
|
_step3;
|
|
4412
4502
|
try {
|
|
@@ -4494,8 +4584,8 @@ var DOMObserver = function () {
|
|
|
4494
4584
|
var prev = mut.previousSibling,
|
|
4495
4585
|
next = mut.nextSibling;
|
|
4496
4586
|
if (ie && ie_version <= 11 && mut.addedNodes.length) {
|
|
4497
|
-
for (var
|
|
4498
|
-
var _mut$addedNodes$_i = mut.addedNodes[
|
|
4587
|
+
for (var _i16 = 0; _i16 < mut.addedNodes.length; _i16++) {
|
|
4588
|
+
var _mut$addedNodes$_i = mut.addedNodes[_i16],
|
|
4499
4589
|
previousSibling = _mut$addedNodes$_i.previousSibling,
|
|
4500
4590
|
nextSibling = _mut$addedNodes$_i.nextSibling;
|
|
4501
4591
|
if (!previousSibling || Array.prototype.indexOf.call(mut.addedNodes, previousSibling) < 0) prev = previousSibling;
|
|
@@ -4546,11 +4636,11 @@ function rangeToSelectionRange(view, range) {
|
|
|
4546
4636
|
focusOffset = range.endOffset;
|
|
4547
4637
|
var currentAnchor = view.domAtPos(view.state.selection.anchor);
|
|
4548
4638
|
if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset)) {
|
|
4549
|
-
var
|
|
4550
|
-
anchorNode =
|
|
4551
|
-
anchorOffset =
|
|
4552
|
-
focusNode =
|
|
4553
|
-
focusOffset =
|
|
4639
|
+
var _ref7 = [focusNode, focusOffset, anchorNode, anchorOffset];
|
|
4640
|
+
anchorNode = _ref7[0];
|
|
4641
|
+
anchorOffset = _ref7[1];
|
|
4642
|
+
focusNode = _ref7[2];
|
|
4643
|
+
focusOffset = _ref7[3];
|
|
4554
4644
|
}
|
|
4555
4645
|
return {
|
|
4556
4646
|
anchorNode: anchorNode,
|
|
@@ -4861,7 +4951,7 @@ function isMarkChange(cur, prev) {
|
|
|
4861
4951
|
mark,
|
|
4862
4952
|
update;
|
|
4863
4953
|
for (var i = 0; i < prevMarks.length; i++) added = prevMarks[i].removeFromSet(added);
|
|
4864
|
-
for (var
|
|
4954
|
+
for (var _i17 = 0; _i17 < curMarks.length; _i17++) removed = curMarks[_i17].removeFromSet(removed);
|
|
4865
4955
|
if (added.length == 1 && removed.length == 0) {
|
|
4866
4956
|
mark = added[0];
|
|
4867
4957
|
type = "add";
|
|
@@ -4878,7 +4968,7 @@ function isMarkChange(cur, prev) {
|
|
|
4878
4968
|
return null;
|
|
4879
4969
|
}
|
|
4880
4970
|
var updated = [];
|
|
4881
|
-
for (var
|
|
4971
|
+
for (var _i18 = 0; _i18 < prev.childCount; _i18++) updated.push(update(prev.child(_i18)));
|
|
4882
4972
|
if (prosemirrorModel.Fragment.from(updated).eq(cur)) return {
|
|
4883
4973
|
mark: mark,
|
|
4884
4974
|
type: type
|
|
@@ -4914,25 +5004,25 @@ function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
|
4914
5004
|
return end;
|
|
4915
5005
|
}
|
|
4916
5006
|
function findDiff(a, b, pos, preferredPos, preferredSide) {
|
|
4917
|
-
var start = a.findDiffStart(b, pos)
|
|
5007
|
+
var start = a.findDiffStart(b, pos),
|
|
5008
|
+
lenA = pos + a.size,
|
|
5009
|
+
lenB = pos + b.size;
|
|
4918
5010
|
if (start == null) return null;
|
|
4919
|
-
var _a$findDiffEnd = a.findDiffEnd(b,
|
|
5011
|
+
var _a$findDiffEnd = a.findDiffEnd(b, lenA, lenB),
|
|
4920
5012
|
endA = _a$findDiffEnd.a,
|
|
4921
5013
|
endB = _a$findDiffEnd.b;
|
|
4922
5014
|
if (preferredSide == "end") {
|
|
4923
5015
|
var adjust = Math.max(0, start - Math.min(endA, endB));
|
|
4924
5016
|
preferredPos -= endA + adjust - start;
|
|
4925
5017
|
}
|
|
4926
|
-
if (endA < start &&
|
|
5018
|
+
if (endA < start && lenA < lenB) {
|
|
4927
5019
|
var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0;
|
|
4928
5020
|
start -= move;
|
|
4929
|
-
if (start && start < b.size && isSurrogatePair(b.textBetween(start - 1, start + 1))) start += move ? 1 : -1;
|
|
4930
5021
|
endB = start + (endB - endA);
|
|
4931
5022
|
endA = start;
|
|
4932
5023
|
} else if (endB < start) {
|
|
4933
5024
|
var _move = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0;
|
|
4934
5025
|
start -= _move;
|
|
4935
|
-
if (start && start < a.size && isSurrogatePair(a.textBetween(start - 1, start + 1))) start += _move ? 1 : -1;
|
|
4936
5026
|
endA = start + (endA - endB);
|
|
4937
5027
|
endB = start;
|
|
4938
5028
|
}
|
|
@@ -4942,17 +5032,11 @@ function findDiff(a, b, pos, preferredPos, preferredSide) {
|
|
|
4942
5032
|
endB: endB
|
|
4943
5033
|
};
|
|
4944
5034
|
}
|
|
4945
|
-
function isSurrogatePair(str) {
|
|
4946
|
-
if (str.length != 2) return false;
|
|
4947
|
-
var a = str.charCodeAt(0),
|
|
4948
|
-
b = str.charCodeAt(1);
|
|
4949
|
-
return a >= 0xDC00 && a <= 0xDFFF && b >= 0xD800 && b <= 0xDBFF;
|
|
4950
|
-
}
|
|
4951
5035
|
var __parseFromClipboard = parseFromClipboard;
|
|
4952
5036
|
var __endComposition = endComposition;
|
|
4953
5037
|
var EditorView = function () {
|
|
4954
5038
|
function EditorView(place, props) {
|
|
4955
|
-
var
|
|
5039
|
+
var _this16 = this;
|
|
4956
5040
|
_classCallCheck(this, EditorView);
|
|
4957
5041
|
this._root = null;
|
|
4958
5042
|
this.focused = false;
|
|
@@ -4980,7 +5064,7 @@ var EditorView = function () {
|
|
|
4980
5064
|
this.nodeViews = buildNodeViews(this);
|
|
4981
5065
|
this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);
|
|
4982
5066
|
this.domObserver = new DOMObserver(this, function (from, to, typeOver, added) {
|
|
4983
|
-
return readDOMChange(
|
|
5067
|
+
return readDOMChange(_this16, from, to, typeOver, added);
|
|
4984
5068
|
});
|
|
4985
5069
|
this.domObserver.start();
|
|
4986
5070
|
initInput(this);
|
|
@@ -5072,7 +5156,8 @@ var EditorView = function () {
|
|
|
5072
5156
|
}
|
|
5073
5157
|
if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites))) forceSelUpdate = true;
|
|
5074
5158
|
}
|
|
5075
|
-
|
|
5159
|
+
var mouseDown = this.input.mouseDown;
|
|
5160
|
+
if (forceSelUpdate || !(mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && anchorInRightPlace(this) && mouseDown.delaySelUpdate())) {
|
|
5076
5161
|
selectionToDOM(this, forceSelUpdate);
|
|
5077
5162
|
} else {
|
|
5078
5163
|
syncNodeSelection(this, state.selection);
|
|
@@ -5093,10 +5178,10 @@ var EditorView = function () {
|
|
|
5093
5178
|
}, {
|
|
5094
5179
|
key: "scrollToSelection",
|
|
5095
5180
|
value: function scrollToSelection() {
|
|
5096
|
-
var
|
|
5181
|
+
var _this17 = this;
|
|
5097
5182
|
var startDOM = this.domSelectionRange().focusNode;
|
|
5098
5183
|
if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) ;else if (this.someProp("handleScrollToSelection", function (f) {
|
|
5099
|
-
return f(
|
|
5184
|
+
return f(_this17);
|
|
5100
5185
|
})) ;else if (this.state.selection instanceof prosemirrorState.NodeSelection) {
|
|
5101
5186
|
var target = this.docView.domAfterPos(this.state.selection.from);
|
|
5102
5187
|
if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
@@ -5120,13 +5205,13 @@ var EditorView = function () {
|
|
|
5120
5205
|
var plugin = this.directPlugins[i];
|
|
5121
5206
|
if (plugin.spec.view) this.pluginViews.push(plugin.spec.view(this));
|
|
5122
5207
|
}
|
|
5123
|
-
for (var
|
|
5124
|
-
var _plugin = this.state.plugins[
|
|
5208
|
+
for (var _i19 = 0; _i19 < this.state.plugins.length; _i19++) {
|
|
5209
|
+
var _plugin = this.state.plugins[_i19];
|
|
5125
5210
|
if (_plugin.spec.view) this.pluginViews.push(_plugin.spec.view(this));
|
|
5126
5211
|
}
|
|
5127
5212
|
} else {
|
|
5128
|
-
for (var
|
|
5129
|
-
var pluginView = this.pluginViews[
|
|
5213
|
+
for (var _i20 = 0; _i20 < this.pluginViews.length; _i20++) {
|
|
5214
|
+
var pluginView = this.pluginViews[_i20];
|
|
5130
5215
|
if (pluginView.update) pluginView.update(this, prevState);
|
|
5131
5216
|
}
|
|
5132
5217
|
}
|
|
@@ -5156,8 +5241,8 @@ var EditorView = function () {
|
|
|
5156
5241
|
if (_prop != null && (value = f ? f(_prop) : _prop)) return value;
|
|
5157
5242
|
}
|
|
5158
5243
|
var plugins = this.state.plugins;
|
|
5159
|
-
if (plugins) for (var
|
|
5160
|
-
var _prop2 = plugins[
|
|
5244
|
+
if (plugins) for (var _i21 = 0; _i21 < plugins.length; _i21++) {
|
|
5245
|
+
var _prop2 = plugins[_i21].props[propName];
|
|
5161
5246
|
if (_prop2 != null && (value = f ? f(_prop2) : _prop2)) return value;
|
|
5162
5247
|
}
|
|
5163
5248
|
}
|
|
@@ -5187,7 +5272,7 @@ var EditorView = function () {
|
|
|
5187
5272
|
}, {
|
|
5188
5273
|
key: "root",
|
|
5189
5274
|
get: function get() {
|
|
5190
|
-
var
|
|
5275
|
+
var _this18 = this;
|
|
5191
5276
|
var cached = this._root;
|
|
5192
5277
|
if (cached == null) {
|
|
5193
5278
|
var _loop5 = function _loop5(search) {
|
|
@@ -5196,7 +5281,7 @@ var EditorView = function () {
|
|
|
5196
5281
|
return search.ownerDocument.getSelection();
|
|
5197
5282
|
};
|
|
5198
5283
|
return {
|
|
5199
|
-
v:
|
|
5284
|
+
v: _this18._root = search
|
|
5200
5285
|
};
|
|
5201
5286
|
}
|
|
5202
5287
|
},
|