prosemirror-view 1.41.7 → 1.41.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 +18 -2
- package/CONTRIBUTING.md +19 -19
- package/README.md +3 -3
- package/dist/index.cjs +164 -96
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +105 -64
- package/package.json +3 -3
- package/src/domchange.ts +3 -13
- package/src/domobserver.ts +4 -1
- package/src/index.ts +4 -3
- package/src/input.ts +94 -39
- package/src/selection.ts +6 -6
- package/src/viewdesc.ts +8 -8
- package/style/prosemirror.css +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2201,11 +2201,11 @@ function selectionToDOM(view) {
|
|
|
2201
2201
|
var sel = view.state.selection;
|
|
2202
2202
|
syncNodeSelection(view, sel);
|
|
2203
2203
|
if (!editorOwnsSelection(view)) return;
|
|
2204
|
-
|
|
2204
|
+
var mouseDown = view.input.mouseDown;
|
|
2205
|
+
if (!force && chrome && mouseDown) {
|
|
2205
2206
|
var domSel = view.domSelectionRange(),
|
|
2206
2207
|
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;
|
|
2208
|
+
if (domSel.anchorNode && curSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset, curSel.anchorNode, curSel.anchorOffset) && mouseDown.delaySelUpdate()) {
|
|
2209
2209
|
view.domObserver.setCurSelection();
|
|
2210
2210
|
return;
|
|
2211
2211
|
}
|
|
@@ -2949,6 +2949,7 @@ function setSelectionOrigin(view, origin) {
|
|
|
2949
2949
|
view.input.lastSelectionTime = Date.now();
|
|
2950
2950
|
}
|
|
2951
2951
|
function destroyInput(view) {
|
|
2952
|
+
if (view.input.mouseDown) view.input.mouseDown.done();
|
|
2952
2953
|
view.domObserver.stop();
|
|
2953
2954
|
for (var type in view.input.eventHandlers) view.dom.removeEventListener(type, view.input.eventHandlers[type]);
|
|
2954
2955
|
clearTimeout(view.input.composingTimeout);
|
|
@@ -2979,7 +2980,7 @@ function _dispatchEvent(view, event) {
|
|
|
2979
2980
|
editHandlers.keydown = function (view, _event) {
|
|
2980
2981
|
var event = _event;
|
|
2981
2982
|
view.input.shiftKey = event.keyCode == 16 || event.shiftKey;
|
|
2982
|
-
if (inOrNearComposition(view
|
|
2983
|
+
if (inOrNearComposition(view)) return;
|
|
2983
2984
|
view.input.lastKeyCode = event.keyCode;
|
|
2984
2985
|
view.input.lastKeyCodeTime = Date.now();
|
|
2985
2986
|
if (android && chrome && event.keyCode == 13) return;
|
|
@@ -3008,7 +3009,7 @@ editHandlers.keyup = function (view, event) {
|
|
|
3008
3009
|
};
|
|
3009
3010
|
editHandlers.keypress = function (view, _event) {
|
|
3010
3011
|
var event = _event;
|
|
3011
|
-
if (inOrNearComposition(view
|
|
3012
|
+
if (inOrNearComposition(view) || !event.charCode || event.ctrlKey && !event.altKey || mac && event.metaKey) return;
|
|
3012
3013
|
if (view.someProp("handleKeyPress", function (f) {
|
|
3013
3014
|
return f(view, event);
|
|
3014
3015
|
})) {
|
|
@@ -3110,21 +3111,23 @@ function handleTripleClick(view, pos, inside, event) {
|
|
|
3110
3111
|
}
|
|
3111
3112
|
function defaultTripleClick(view, inside, event) {
|
|
3112
3113
|
if (event.button != 0) return false;
|
|
3114
|
+
var selection = selectionForTripleClick(view, inside, true),
|
|
3115
|
+
doc = view.state.doc;
|
|
3116
|
+
if (!selection) return false;
|
|
3117
|
+
updateSelection(view, selection, "pointer");
|
|
3118
|
+
if (selection instanceof prosemirrorState.TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
|
|
3119
|
+
return true;
|
|
3120
|
+
}
|
|
3121
|
+
function selectionForTripleClick(view, inside, selectNodes) {
|
|
3113
3122
|
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
|
-
}
|
|
3123
|
+
if (inside == -1) return doc.inlineContent ? prosemirrorState.TextSelection.create(doc, 0, doc.content.size) : null;
|
|
3121
3124
|
var $pos = doc.resolve(inside);
|
|
3122
3125
|
for (var i = $pos.depth + 1; i > 0; i--) {
|
|
3123
3126
|
var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
|
|
3124
3127
|
var nodePos = $pos.before(i);
|
|
3125
|
-
if (node.inlineContent)
|
|
3126
|
-
return true;
|
|
3128
|
+
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
3129
|
}
|
|
3130
|
+
return null;
|
|
3128
3131
|
}
|
|
3129
3132
|
function forceDOMFlush(view) {
|
|
3130
3133
|
return endComposition(view);
|
|
@@ -3146,11 +3149,11 @@ handlers.mousedown = function (view, _event) {
|
|
|
3146
3149
|
type: type,
|
|
3147
3150
|
button: event.button
|
|
3148
3151
|
};
|
|
3152
|
+
if (view.input.mouseDown) view.input.mouseDown.done();
|
|
3149
3153
|
var pos = view.posAtCoords(eventCoords(event));
|
|
3150
3154
|
if (!pos) return;
|
|
3151
3155
|
if (type == "singleClick") {
|
|
3152
|
-
|
|
3153
|
-
view.input.mouseDown = new MouseDown(view, pos, event, !!flushed);
|
|
3156
|
+
view.input.mouseDown = new LeftMouseDown(view, pos, event, !!flushed);
|
|
3154
3157
|
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
|
|
3155
3158
|
event.preventDefault();
|
|
3156
3159
|
} else {
|
|
@@ -3158,18 +3161,52 @@ handlers.mousedown = function (view, _event) {
|
|
|
3158
3161
|
}
|
|
3159
3162
|
};
|
|
3160
3163
|
var MouseDown = function () {
|
|
3161
|
-
function MouseDown(view
|
|
3162
|
-
var _this8 = this;
|
|
3164
|
+
function MouseDown(view) {
|
|
3163
3165
|
_classCallCheck(this, MouseDown);
|
|
3164
3166
|
this.view = view;
|
|
3165
|
-
this.pos = pos;
|
|
3166
|
-
this.event = event;
|
|
3167
|
-
this.flushed = flushed;
|
|
3168
|
-
this.delayedSelectionSync = false;
|
|
3169
3167
|
this.mightDrag = null;
|
|
3170
|
-
this.
|
|
3171
|
-
this.
|
|
3172
|
-
|
|
3168
|
+
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
3169
|
+
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3170
|
+
}
|
|
3171
|
+
_createClass(MouseDown, [{
|
|
3172
|
+
key: "up",
|
|
3173
|
+
value: function up(event) {
|
|
3174
|
+
this.done();
|
|
3175
|
+
}
|
|
3176
|
+
}, {
|
|
3177
|
+
key: "move",
|
|
3178
|
+
value: function move(event) {
|
|
3179
|
+
if (event.buttons == 0) this.done();
|
|
3180
|
+
}
|
|
3181
|
+
}, {
|
|
3182
|
+
key: "done",
|
|
3183
|
+
value: function done() {
|
|
3184
|
+
this.view.root.removeEventListener("mouseup", this.up);
|
|
3185
|
+
this.view.root.removeEventListener("mousemove", this.move);
|
|
3186
|
+
if (this.view.input.mouseDown == this) this.view.input.mouseDown = null;
|
|
3187
|
+
}
|
|
3188
|
+
}, {
|
|
3189
|
+
key: "delaySelUpdate",
|
|
3190
|
+
value: function delaySelUpdate() {
|
|
3191
|
+
return false;
|
|
3192
|
+
}
|
|
3193
|
+
}]);
|
|
3194
|
+
return MouseDown;
|
|
3195
|
+
}();
|
|
3196
|
+
var LeftMouseDown = function (_MouseDown) {
|
|
3197
|
+
_inherits(LeftMouseDown, _MouseDown);
|
|
3198
|
+
var _super8 = _createSuper(LeftMouseDown);
|
|
3199
|
+
function LeftMouseDown(view, pos, event, flushed) {
|
|
3200
|
+
var _this8;
|
|
3201
|
+
_classCallCheck(this, LeftMouseDown);
|
|
3202
|
+
_this8 = _super8.call(this, view);
|
|
3203
|
+
_this8.pos = pos;
|
|
3204
|
+
_this8.event = event;
|
|
3205
|
+
_this8.flushed = flushed;
|
|
3206
|
+
_this8.delayedSelectionSync = false;
|
|
3207
|
+
_this8.startDoc = view.state.doc;
|
|
3208
|
+
_this8.selectNode = !!event[selectNodeModifier];
|
|
3209
|
+
_this8.allowDefault = event.shiftKey;
|
|
3173
3210
|
var targetNode, targetPos;
|
|
3174
3211
|
if (pos.inside > -1) {
|
|
3175
3212
|
targetNode = view.state.doc.nodeAt(pos.inside);
|
|
@@ -3181,32 +3218,30 @@ var MouseDown = function () {
|
|
|
3181
3218
|
}
|
|
3182
3219
|
var target = flushed ? null : event.target;
|
|
3183
3220
|
var targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3184
|
-
|
|
3221
|
+
_this8.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
|
|
3185
3222
|
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)
|
|
3223
|
+
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
3224
|
node: targetNode,
|
|
3188
3225
|
pos: targetPos,
|
|
3189
|
-
addAttr: !!(
|
|
3190
|
-
setUneditable: !!(
|
|
3226
|
+
addAttr: !!(_this8.target && !_this8.target.draggable),
|
|
3227
|
+
setUneditable: !!(_this8.target && gecko && !_this8.target.hasAttribute("contentEditable"))
|
|
3191
3228
|
};
|
|
3192
|
-
if (
|
|
3193
|
-
|
|
3194
|
-
if (
|
|
3195
|
-
if (
|
|
3196
|
-
if (_this8.view.input.mouseDown == _this8) _this8.target.setAttribute("contentEditable", "false");
|
|
3229
|
+
if (_this8.target && _this8.mightDrag && (_this8.mightDrag.addAttr || _this8.mightDrag.setUneditable)) {
|
|
3230
|
+
_this8.view.domObserver.stop();
|
|
3231
|
+
if (_this8.mightDrag.addAttr) _this8.target.draggable = true;
|
|
3232
|
+
if (_this8.mightDrag.setUneditable) setTimeout(function () {
|
|
3233
|
+
if (_this8.view.input.mouseDown == _assertThisInitialized(_this8)) _this8.target.setAttribute("contentEditable", "false");
|
|
3197
3234
|
}, 20);
|
|
3198
|
-
|
|
3235
|
+
_this8.view.domObserver.start();
|
|
3199
3236
|
}
|
|
3200
|
-
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
3201
|
-
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3202
3237
|
setSelectionOrigin(view, "pointer");
|
|
3238
|
+
return _this8;
|
|
3203
3239
|
}
|
|
3204
|
-
_createClass(
|
|
3240
|
+
_createClass(LeftMouseDown, [{
|
|
3205
3241
|
key: "done",
|
|
3206
3242
|
value: function done() {
|
|
3207
3243
|
var _this9 = this;
|
|
3208
|
-
|
|
3209
|
-
this.view.root.removeEventListener("mousemove", this.move);
|
|
3244
|
+
_get(_getPrototypeOf(LeftMouseDown.prototype), "done", this).call(this);
|
|
3210
3245
|
if (this.mightDrag && this.target) {
|
|
3211
3246
|
this.view.domObserver.stop();
|
|
3212
3247
|
if (this.mightDrag.addAttr) this.target.removeAttribute("draggable");
|
|
@@ -3214,9 +3249,8 @@ var MouseDown = function () {
|
|
|
3214
3249
|
this.view.domObserver.start();
|
|
3215
3250
|
}
|
|
3216
3251
|
if (this.delayedSelectionSync) setTimeout(function () {
|
|
3217
|
-
|
|
3252
|
+
if (!_this9.view.isDestroyed) selectionToDOM(_this9.view);
|
|
3218
3253
|
});
|
|
3219
|
-
this.view.input.mouseDown = null;
|
|
3220
3254
|
}
|
|
3221
3255
|
}, {
|
|
3222
3256
|
key: "up",
|
|
@@ -3242,16 +3276,57 @@ var MouseDown = function () {
|
|
|
3242
3276
|
value: function move(event) {
|
|
3243
3277
|
this.updateAllowDefault(event);
|
|
3244
3278
|
setSelectionOrigin(this.view, "pointer");
|
|
3245
|
-
|
|
3279
|
+
_get(_getPrototypeOf(LeftMouseDown.prototype), "move", this).call(this, event);
|
|
3246
3280
|
}
|
|
3247
3281
|
}, {
|
|
3248
3282
|
key: "updateAllowDefault",
|
|
3249
3283
|
value: function updateAllowDefault(event) {
|
|
3250
3284
|
if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4)) this.allowDefault = true;
|
|
3251
3285
|
}
|
|
3286
|
+
}, {
|
|
3287
|
+
key: "delaySelUpdate",
|
|
3288
|
+
value: function delaySelUpdate() {
|
|
3289
|
+
if (!this.allowDefault) return false;
|
|
3290
|
+
this.delayedSelectionSync = true;
|
|
3291
|
+
return true;
|
|
3292
|
+
}
|
|
3252
3293
|
}]);
|
|
3253
|
-
return
|
|
3254
|
-
}();
|
|
3294
|
+
return LeftMouseDown;
|
|
3295
|
+
}(MouseDown);
|
|
3296
|
+
var TripleClickDrag = function (_MouseDown2) {
|
|
3297
|
+
_inherits(TripleClickDrag, _MouseDown2);
|
|
3298
|
+
var _super9 = _createSuper(TripleClickDrag);
|
|
3299
|
+
function TripleClickDrag(view, startSelection) {
|
|
3300
|
+
var _this10;
|
|
3301
|
+
_classCallCheck(this, TripleClickDrag);
|
|
3302
|
+
_this10 = _super9.call(this, view);
|
|
3303
|
+
_this10.startSelection = startSelection;
|
|
3304
|
+
_this10.startDoc = view.state.doc;
|
|
3305
|
+
return _this10;
|
|
3306
|
+
}
|
|
3307
|
+
_createClass(TripleClickDrag, [{
|
|
3308
|
+
key: "move",
|
|
3309
|
+
value: function move(event) {
|
|
3310
|
+
if (event.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) {
|
|
3311
|
+
this.done();
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
event.preventDefault();
|
|
3315
|
+
setSelectionOrigin(this.view, "pointer");
|
|
3316
|
+
var pos = this.view.posAtCoords(eventCoords(event));
|
|
3317
|
+
var target = pos && selectionForTripleClick(this.view, pos.inside, false);
|
|
3318
|
+
if (!target) return;
|
|
3319
|
+
var doc = this.view.state.doc,
|
|
3320
|
+
start = this.startSelection;
|
|
3321
|
+
var _ref5 = target.from < start.from ? [start.to, target.from] : [start.from, target.to],
|
|
3322
|
+
_ref6 = _slicedToArray(_ref5, 2),
|
|
3323
|
+
anchor = _ref6[0],
|
|
3324
|
+
head = _ref6[1];
|
|
3325
|
+
updateSelection(this.view, prosemirrorState.TextSelection.create(doc, anchor, head), "pointer");
|
|
3326
|
+
}
|
|
3327
|
+
}]);
|
|
3328
|
+
return TripleClickDrag;
|
|
3329
|
+
}(MouseDown);
|
|
3255
3330
|
handlers.touchstart = function (view) {
|
|
3256
3331
|
view.input.lastTouch = Date.now();
|
|
3257
3332
|
forceDOMFlush(view);
|
|
@@ -3266,7 +3341,7 @@ handlers.contextmenu = function (view) {
|
|
|
3266
3341
|
};
|
|
3267
3342
|
function inOrNearComposition(view, event) {
|
|
3268
3343
|
if (view.composing) return true;
|
|
3269
|
-
if (safari && Math.abs(
|
|
3344
|
+
if (safari && Math.abs(Date.now() - view.input.compositionEndedAt) < 500) {
|
|
3270
3345
|
view.input.compositionEndedAt = -2e8;
|
|
3271
3346
|
return true;
|
|
3272
3347
|
}
|
|
@@ -3317,7 +3392,7 @@ function selectionBeforeUneditable(view) {
|
|
|
3317
3392
|
editHandlers.compositionend = function (view, event) {
|
|
3318
3393
|
if (view.composing) {
|
|
3319
3394
|
view.input.composing = false;
|
|
3320
|
-
view.input.compositionEndedAt =
|
|
3395
|
+
view.input.compositionEndedAt = Date.now();
|
|
3321
3396
|
view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
|
|
3322
3397
|
view.input.compositionNode = null;
|
|
3323
3398
|
if (view.input.badSafariComposition) view.domObserver.forceFlush();else if (view.input.compositionPendingChanges) Promise.resolve().then(function () {
|
|
@@ -3336,7 +3411,7 @@ function scheduleComposeEnd(view, delay) {
|
|
|
3336
3411
|
function clearComposition(view) {
|
|
3337
3412
|
if (view.composing) {
|
|
3338
3413
|
view.input.composing = false;
|
|
3339
|
-
view.input.compositionEndedAt =
|
|
3414
|
+
view.input.compositionEndedAt = Date.now();
|
|
3340
3415
|
}
|
|
3341
3416
|
while (view.input.compositionNodes.length > 0) view.input.compositionNodes.pop().markParentsDirty();
|
|
3342
3417
|
}
|
|
@@ -3358,11 +3433,6 @@ function findCompositionNode(view) {
|
|
|
3358
3433
|
}
|
|
3359
3434
|
return textBefore || textAfter;
|
|
3360
3435
|
}
|
|
3361
|
-
function timestampFromCustomEvent() {
|
|
3362
|
-
var event = document.createEvent("Event");
|
|
3363
|
-
event.initEvent("event", true, true);
|
|
3364
|
-
return event.timeStamp;
|
|
3365
|
-
}
|
|
3366
3436
|
function endComposition(view) {
|
|
3367
3437
|
var restarting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3368
3438
|
if (android && view.domObserver.flushingSoon >= 0) return;
|
|
@@ -3462,10 +3532,11 @@ var Dragging = _createClass(function Dragging(slice, move, node) {
|
|
|
3462
3532
|
});
|
|
3463
3533
|
var dragCopyModifier = mac ? "altKey" : "ctrlKey";
|
|
3464
3534
|
function dragMoves(view, event) {
|
|
3465
|
-
var
|
|
3466
|
-
|
|
3535
|
+
var copy;
|
|
3536
|
+
view.someProp("dragCopies", function (test) {
|
|
3537
|
+
copy = copy || test(event);
|
|
3467
3538
|
});
|
|
3468
|
-
return
|
|
3539
|
+
return copy != null ? !copy : !event[dragCopyModifier];
|
|
3469
3540
|
}
|
|
3470
3541
|
handlers.dragstart = function (view, _event) {
|
|
3471
3542
|
var event = _event;
|
|
@@ -3814,14 +3885,14 @@ var DecorationSet = function () {
|
|
|
3814
3885
|
}, {
|
|
3815
3886
|
key: "addInner",
|
|
3816
3887
|
value: function addInner(doc, decorations, offset) {
|
|
3817
|
-
var
|
|
3888
|
+
var _this11 = this;
|
|
3818
3889
|
var children,
|
|
3819
3890
|
childIndex = 0;
|
|
3820
3891
|
doc.forEach(function (childNode, childOffset) {
|
|
3821
3892
|
var baseOffset = childOffset + offset,
|
|
3822
3893
|
found;
|
|
3823
3894
|
if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) return;
|
|
3824
|
-
if (!children) children =
|
|
3895
|
+
if (!children) children = _this11.children.slice();
|
|
3825
3896
|
while (childIndex < children.length && children[childIndex] < childOffset) childIndex += 3;
|
|
3826
3897
|
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));
|
|
3827
3898
|
childIndex += 3;
|
|
@@ -4223,7 +4294,7 @@ var SelectionState = function () {
|
|
|
4223
4294
|
}();
|
|
4224
4295
|
var DOMObserver = function () {
|
|
4225
4296
|
function DOMObserver(view, handleDOMChange) {
|
|
4226
|
-
var
|
|
4297
|
+
var _this12 = this;
|
|
4227
4298
|
_classCallCheck(this, DOMObserver);
|
|
4228
4299
|
this.view = view;
|
|
4229
4300
|
this.handleDOMChange = handleDOMChange;
|
|
@@ -4235,28 +4306,28 @@ var DOMObserver = function () {
|
|
|
4235
4306
|
this.suppressingSelectionUpdates = false;
|
|
4236
4307
|
this.lastChangedTextNode = null;
|
|
4237
4308
|
this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) {
|
|
4238
|
-
for (var i = 0; i < mutations.length; i++)
|
|
4309
|
+
for (var i = 0; i < mutations.length; i++) _this12.queue.push(mutations[i]);
|
|
4239
4310
|
if (ie && ie_version <= 11 && mutations.some(function (m) {
|
|
4240
4311
|
return m.type == "childList" && m.removedNodes.length || m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length;
|
|
4241
4312
|
})) {
|
|
4242
|
-
|
|
4313
|
+
_this12.flushSoon();
|
|
4243
4314
|
} else if (safari && view.composing && mutations.some(function (m) {
|
|
4244
4315
|
return m.type == "childList" && m.target.nodeName == "TR";
|
|
4245
4316
|
})) {
|
|
4246
4317
|
view.input.badSafariComposition = true;
|
|
4247
|
-
|
|
4318
|
+
_this12.flushSoon();
|
|
4248
4319
|
} else {
|
|
4249
|
-
|
|
4320
|
+
_this12.flush();
|
|
4250
4321
|
}
|
|
4251
4322
|
});
|
|
4252
4323
|
if (useCharData) {
|
|
4253
4324
|
this.onCharData = function (e) {
|
|
4254
|
-
|
|
4325
|
+
_this12.queue.push({
|
|
4255
4326
|
target: e.target,
|
|
4256
4327
|
type: "characterData",
|
|
4257
4328
|
oldValue: e.prevValue
|
|
4258
4329
|
});
|
|
4259
|
-
|
|
4330
|
+
_this12.flushSoon();
|
|
4260
4331
|
};
|
|
4261
4332
|
}
|
|
4262
4333
|
this.onSelectionChange = this.onSelectionChange.bind(this);
|
|
@@ -4264,10 +4335,10 @@ var DOMObserver = function () {
|
|
|
4264
4335
|
_createClass(DOMObserver, [{
|
|
4265
4336
|
key: "flushSoon",
|
|
4266
4337
|
value: function flushSoon() {
|
|
4267
|
-
var
|
|
4338
|
+
var _this13 = this;
|
|
4268
4339
|
if (this.flushingSoon < 0) this.flushingSoon = window.setTimeout(function () {
|
|
4269
|
-
|
|
4270
|
-
|
|
4340
|
+
_this13.flushingSoon = -1;
|
|
4341
|
+
_this13.flush();
|
|
4271
4342
|
}, 20);
|
|
4272
4343
|
}
|
|
4273
4344
|
}, {
|
|
@@ -4292,13 +4363,13 @@ var DOMObserver = function () {
|
|
|
4292
4363
|
}, {
|
|
4293
4364
|
key: "stop",
|
|
4294
4365
|
value: function stop() {
|
|
4295
|
-
var
|
|
4366
|
+
var _this14 = this;
|
|
4296
4367
|
if (this.observer) {
|
|
4297
4368
|
var take = this.observer.takeRecords();
|
|
4298
4369
|
if (take.length) {
|
|
4299
4370
|
for (var i = 0; i < take.length; i++) this.queue.push(take[i]);
|
|
4300
4371
|
window.setTimeout(function () {
|
|
4301
|
-
return
|
|
4372
|
+
return _this14.flush();
|
|
4302
4373
|
}, 20);
|
|
4303
4374
|
}
|
|
4304
4375
|
this.observer.disconnect();
|
|
@@ -4319,10 +4390,10 @@ var DOMObserver = function () {
|
|
|
4319
4390
|
}, {
|
|
4320
4391
|
key: "suppressSelectionUpdates",
|
|
4321
4392
|
value: function suppressSelectionUpdates() {
|
|
4322
|
-
var
|
|
4393
|
+
var _this15 = this;
|
|
4323
4394
|
this.suppressingSelectionUpdates = true;
|
|
4324
4395
|
setTimeout(function () {
|
|
4325
|
-
return
|
|
4396
|
+
return _this15.suppressingSelectionUpdates = false;
|
|
4326
4397
|
}, 50);
|
|
4327
4398
|
}
|
|
4328
4399
|
}, {
|
|
@@ -4405,7 +4476,9 @@ var DOMObserver = function () {
|
|
|
4405
4476
|
}
|
|
4406
4477
|
if (added.some(function (n) {
|
|
4407
4478
|
return n.nodeName == "BR";
|
|
4408
|
-
}) && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
|
|
4479
|
+
}) && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some(function (m) {
|
|
4480
|
+
return m.type == "childList" && m.removedNodes.length;
|
|
4481
|
+
}))) {
|
|
4409
4482
|
var _iterator3 = _createForOfIteratorHelper(added),
|
|
4410
4483
|
_step3;
|
|
4411
4484
|
try {
|
|
@@ -4545,11 +4618,11 @@ function rangeToSelectionRange(view, range) {
|
|
|
4545
4618
|
focusOffset = range.endOffset;
|
|
4546
4619
|
var currentAnchor = view.domAtPos(view.state.selection.anchor);
|
|
4547
4620
|
if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset)) {
|
|
4548
|
-
var
|
|
4549
|
-
anchorNode =
|
|
4550
|
-
anchorOffset =
|
|
4551
|
-
focusNode =
|
|
4552
|
-
focusOffset =
|
|
4621
|
+
var _ref7 = [focusNode, focusOffset, anchorNode, anchorOffset];
|
|
4622
|
+
anchorNode = _ref7[0];
|
|
4623
|
+
anchorOffset = _ref7[1];
|
|
4624
|
+
focusNode = _ref7[2];
|
|
4625
|
+
focusOffset = _ref7[3];
|
|
4553
4626
|
}
|
|
4554
4627
|
return {
|
|
4555
4628
|
anchorNode: anchorNode,
|
|
@@ -4913,25 +4986,25 @@ function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
|
4913
4986
|
return end;
|
|
4914
4987
|
}
|
|
4915
4988
|
function findDiff(a, b, pos, preferredPos, preferredSide) {
|
|
4916
|
-
var start = a.findDiffStart(b, pos)
|
|
4989
|
+
var start = a.findDiffStart(b, pos),
|
|
4990
|
+
lenA = pos + a.size,
|
|
4991
|
+
lenB = pos + b.size;
|
|
4917
4992
|
if (start == null) return null;
|
|
4918
|
-
var _a$findDiffEnd = a.findDiffEnd(b,
|
|
4993
|
+
var _a$findDiffEnd = a.findDiffEnd(b, lenA, lenB),
|
|
4919
4994
|
endA = _a$findDiffEnd.a,
|
|
4920
4995
|
endB = _a$findDiffEnd.b;
|
|
4921
4996
|
if (preferredSide == "end") {
|
|
4922
4997
|
var adjust = Math.max(0, start - Math.min(endA, endB));
|
|
4923
4998
|
preferredPos -= endA + adjust - start;
|
|
4924
4999
|
}
|
|
4925
|
-
if (endA < start &&
|
|
5000
|
+
if (endA < start && lenA < lenB) {
|
|
4926
5001
|
var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0;
|
|
4927
5002
|
start -= move;
|
|
4928
|
-
if (start && start < b.size && isSurrogatePair(b.textBetween(start - 1, start + 1))) start += move ? 1 : -1;
|
|
4929
5003
|
endB = start + (endB - endA);
|
|
4930
5004
|
endA = start;
|
|
4931
5005
|
} else if (endB < start) {
|
|
4932
5006
|
var _move = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0;
|
|
4933
5007
|
start -= _move;
|
|
4934
|
-
if (start && start < a.size && isSurrogatePair(a.textBetween(start - 1, start + 1))) start += _move ? 1 : -1;
|
|
4935
5008
|
endA = start + (endA - endB);
|
|
4936
5009
|
endB = start;
|
|
4937
5010
|
}
|
|
@@ -4941,17 +5014,11 @@ function findDiff(a, b, pos, preferredPos, preferredSide) {
|
|
|
4941
5014
|
endB: endB
|
|
4942
5015
|
};
|
|
4943
5016
|
}
|
|
4944
|
-
function isSurrogatePair(str) {
|
|
4945
|
-
if (str.length != 2) return false;
|
|
4946
|
-
var a = str.charCodeAt(0),
|
|
4947
|
-
b = str.charCodeAt(1);
|
|
4948
|
-
return a >= 0xDC00 && a <= 0xDFFF && b >= 0xD800 && b <= 0xDBFF;
|
|
4949
|
-
}
|
|
4950
5017
|
var __parseFromClipboard = parseFromClipboard;
|
|
4951
5018
|
var __endComposition = endComposition;
|
|
4952
5019
|
var EditorView = function () {
|
|
4953
5020
|
function EditorView(place, props) {
|
|
4954
|
-
var
|
|
5021
|
+
var _this16 = this;
|
|
4955
5022
|
_classCallCheck(this, EditorView);
|
|
4956
5023
|
this._root = null;
|
|
4957
5024
|
this.focused = false;
|
|
@@ -4979,7 +5046,7 @@ var EditorView = function () {
|
|
|
4979
5046
|
this.nodeViews = buildNodeViews(this);
|
|
4980
5047
|
this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);
|
|
4981
5048
|
this.domObserver = new DOMObserver(this, function (from, to, typeOver, added) {
|
|
4982
|
-
return readDOMChange(
|
|
5049
|
+
return readDOMChange(_this16, from, to, typeOver, added);
|
|
4983
5050
|
});
|
|
4984
5051
|
this.domObserver.start();
|
|
4985
5052
|
initInput(this);
|
|
@@ -5071,7 +5138,8 @@ var EditorView = function () {
|
|
|
5071
5138
|
}
|
|
5072
5139
|
if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites))) forceSelUpdate = true;
|
|
5073
5140
|
}
|
|
5074
|
-
|
|
5141
|
+
var mouseDown = this.input.mouseDown;
|
|
5142
|
+
if (forceSelUpdate || !(mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && anchorInRightPlace(this) && mouseDown.delaySelUpdate())) {
|
|
5075
5143
|
selectionToDOM(this, forceSelUpdate);
|
|
5076
5144
|
} else {
|
|
5077
5145
|
syncNodeSelection(this, state.selection);
|
|
@@ -5092,10 +5160,10 @@ var EditorView = function () {
|
|
|
5092
5160
|
}, {
|
|
5093
5161
|
key: "scrollToSelection",
|
|
5094
5162
|
value: function scrollToSelection() {
|
|
5095
|
-
var
|
|
5163
|
+
var _this17 = this;
|
|
5096
5164
|
var startDOM = this.domSelectionRange().focusNode;
|
|
5097
5165
|
if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) ;else if (this.someProp("handleScrollToSelection", function (f) {
|
|
5098
|
-
return f(
|
|
5166
|
+
return f(_this17);
|
|
5099
5167
|
})) ;else if (this.state.selection instanceof prosemirrorState.NodeSelection) {
|
|
5100
5168
|
var target = this.docView.domAfterPos(this.state.selection.from);
|
|
5101
5169
|
if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
@@ -5186,7 +5254,7 @@ var EditorView = function () {
|
|
|
5186
5254
|
}, {
|
|
5187
5255
|
key: "root",
|
|
5188
5256
|
get: function get() {
|
|
5189
|
-
var
|
|
5257
|
+
var _this18 = this;
|
|
5190
5258
|
var cached = this._root;
|
|
5191
5259
|
if (cached == null) {
|
|
5192
5260
|
var _loop5 = function _loop5(search) {
|
|
@@ -5195,7 +5263,7 @@ var EditorView = function () {
|
|
|
5195
5263
|
return search.ownerDocument.getSelection();
|
|
5196
5264
|
};
|
|
5197
5265
|
return {
|
|
5198
|
-
v:
|
|
5266
|
+
v: _this18._root = search
|
|
5199
5267
|
};
|
|
5200
5268
|
}
|
|
5201
5269
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -275,7 +275,7 @@ interface NodeView {
|
|
|
275
275
|
/**
|
|
276
276
|
The outer DOM node that represents the document node.
|
|
277
277
|
*/
|
|
278
|
-
dom:
|
|
278
|
+
dom: HTMLElement;
|
|
279
279
|
/**
|
|
280
280
|
The DOM node that should hold the node's content. Only meaningful
|
|
281
281
|
if the node view also defines a `dom` property and if its node
|
|
@@ -356,7 +356,7 @@ interface MarkView {
|
|
|
356
356
|
/**
|
|
357
357
|
The outer DOM node that represents the document node.
|
|
358
358
|
*/
|
|
359
|
-
dom:
|
|
359
|
+
dom: HTMLElement;
|
|
360
360
|
/**
|
|
361
361
|
The DOM node that should hold the mark's content. When this is not
|
|
362
362
|
present, the `dom` property is used as the content DOM.
|
package/dist/index.d.ts
CHANGED
|
@@ -275,7 +275,7 @@ interface NodeView {
|
|
|
275
275
|
/**
|
|
276
276
|
The outer DOM node that represents the document node.
|
|
277
277
|
*/
|
|
278
|
-
dom:
|
|
278
|
+
dom: HTMLElement;
|
|
279
279
|
/**
|
|
280
280
|
The DOM node that should hold the node's content. Only meaningful
|
|
281
281
|
if the node view also defines a `dom` property and if its node
|
|
@@ -356,7 +356,7 @@ interface MarkView {
|
|
|
356
356
|
/**
|
|
357
357
|
The outer DOM node that represents the document node.
|
|
358
358
|
*/
|
|
359
|
-
dom:
|
|
359
|
+
dom: HTMLElement;
|
|
360
360
|
/**
|
|
361
361
|
The DOM node that should hold the mark's content. When this is not
|
|
362
362
|
present, the `dom` property is used as the content DOM.
|