prosemirror-view 1.33.7 → 1.33.8
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 +6 -0
- package/dist/index.cjs +10 -2
- package/dist/index.js +11 -3
- package/package.json +1 -1
- package/src/domobserver.ts +7 -1
- package/src/input.ts +2 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3247,7 +3247,9 @@ function findCompositionNode(view) {
|
|
|
3247
3247
|
var textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
|
|
3248
3248
|
var textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
|
|
3249
3249
|
if (textBefore && textAfter && textBefore != textAfter) {
|
|
3250
|
-
var descAfter = textAfter.pmViewDesc
|
|
3250
|
+
var descAfter = textAfter.pmViewDesc,
|
|
3251
|
+
lastChanged = view.domObserver.lastChangedTextNode;
|
|
3252
|
+
if (textBefore == lastChanged || textAfter == lastChanged) return lastChanged;
|
|
3251
3253
|
if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
|
|
3252
3254
|
return textAfter;
|
|
3253
3255
|
} else if (view.input.compositionNode == textAfter) {
|
|
@@ -4111,6 +4113,7 @@ var DOMObserver = function () {
|
|
|
4111
4113
|
this.currentSelection = new SelectionState();
|
|
4112
4114
|
this.onCharData = null;
|
|
4113
4115
|
this.suppressingSelectionUpdates = false;
|
|
4116
|
+
this.lastChangedTextNode = null;
|
|
4114
4117
|
this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) {
|
|
4115
4118
|
for (var i = 0; i < mutations.length; i++) _this11.queue.push(mutations[i]);
|
|
4116
4119
|
if (ie && ie_version <= 11 && mutations.some(function (m) {
|
|
@@ -4321,7 +4324,11 @@ var DOMObserver = function () {
|
|
|
4321
4324
|
if (mut.type == "attributes" && (desc == this.view.docView || mut.attributeName == "contenteditable" || mut.attributeName == "style" && !mut.oldValue && !mut.target.getAttribute("style"))) return null;
|
|
4322
4325
|
if (!desc || desc.ignoreMutation(mut)) return null;
|
|
4323
4326
|
if (mut.type == "childList") {
|
|
4324
|
-
for (var i = 0; i < mut.addedNodes.length; i++)
|
|
4327
|
+
for (var i = 0; i < mut.addedNodes.length; i++) {
|
|
4328
|
+
var node = mut.addedNodes[i];
|
|
4329
|
+
added.push(node);
|
|
4330
|
+
if (node.nodeType == 3) this.lastChangedTextNode = node;
|
|
4331
|
+
}
|
|
4325
4332
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {
|
|
4326
4333
|
from: desc.posBefore,
|
|
4327
4334
|
to: desc.posAfter
|
|
@@ -4351,6 +4358,7 @@ var DOMObserver = function () {
|
|
|
4351
4358
|
to: desc.posAtEnd + desc.border
|
|
4352
4359
|
};
|
|
4353
4360
|
} else {
|
|
4361
|
+
this.lastChangedTextNode = mut.target;
|
|
4354
4362
|
return {
|
|
4355
4363
|
from: desc.posAtStart,
|
|
4356
4364
|
to: desc.posAtEnd,
|
package/dist/index.js
CHANGED
|
@@ -3460,7 +3460,9 @@ function findCompositionNode(view) {
|
|
|
3460
3460
|
let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
|
|
3461
3461
|
let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
|
|
3462
3462
|
if (textBefore && textAfter && textBefore != textAfter) {
|
|
3463
|
-
let descAfter = textAfter.pmViewDesc;
|
|
3463
|
+
let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode;
|
|
3464
|
+
if (textBefore == lastChanged || textAfter == lastChanged)
|
|
3465
|
+
return lastChanged;
|
|
3464
3466
|
if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
|
|
3465
3467
|
return textAfter;
|
|
3466
3468
|
}
|
|
@@ -4472,6 +4474,7 @@ class DOMObserver {
|
|
|
4472
4474
|
this.currentSelection = new SelectionState;
|
|
4473
4475
|
this.onCharData = null;
|
|
4474
4476
|
this.suppressingSelectionUpdates = false;
|
|
4477
|
+
this.lastChangedTextNode = null;
|
|
4475
4478
|
this.observer = window.MutationObserver &&
|
|
4476
4479
|
new window.MutationObserver(mutations => {
|
|
4477
4480
|
for (let i = 0; i < mutations.length; i++)
|
|
@@ -4661,8 +4664,12 @@ class DOMObserver {
|
|
|
4661
4664
|
if (!desc || desc.ignoreMutation(mut))
|
|
4662
4665
|
return null;
|
|
4663
4666
|
if (mut.type == "childList") {
|
|
4664
|
-
for (let i = 0; i < mut.addedNodes.length; i++)
|
|
4665
|
-
|
|
4667
|
+
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
4668
|
+
let node = mut.addedNodes[i];
|
|
4669
|
+
added.push(node);
|
|
4670
|
+
if (node.nodeType == 3)
|
|
4671
|
+
this.lastChangedTextNode = node;
|
|
4672
|
+
}
|
|
4666
4673
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
|
|
4667
4674
|
return { from: desc.posBefore, to: desc.posAfter };
|
|
4668
4675
|
let prev = mut.previousSibling, next = mut.nextSibling;
|
|
@@ -4689,6 +4696,7 @@ class DOMObserver {
|
|
|
4689
4696
|
return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border };
|
|
4690
4697
|
}
|
|
4691
4698
|
else { // "characterData"
|
|
4699
|
+
this.lastChangedTextNode = mut.target;
|
|
4692
4700
|
return {
|
|
4693
4701
|
from: desc.posAtStart,
|
|
4694
4702
|
to: desc.posAtEnd,
|
package/package.json
CHANGED
package/src/domobserver.ts
CHANGED
|
@@ -43,6 +43,7 @@ export class DOMObserver {
|
|
|
43
43
|
currentSelection = new SelectionState
|
|
44
44
|
onCharData: ((e: Event) => void) | null = null
|
|
45
45
|
suppressingSelectionUpdates = false
|
|
46
|
+
lastChangedTextNode: Text | null = null
|
|
46
47
|
|
|
47
48
|
constructor(
|
|
48
49
|
readonly view: EditorView,
|
|
@@ -235,7 +236,11 @@ export class DOMObserver {
|
|
|
235
236
|
if (!desc || desc.ignoreMutation(mut)) return null
|
|
236
237
|
|
|
237
238
|
if (mut.type == "childList") {
|
|
238
|
-
for (let i = 0; i < mut.addedNodes.length; i++)
|
|
239
|
+
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
240
|
+
let node = mut.addedNodes[i]
|
|
241
|
+
added.push(node)
|
|
242
|
+
if (node.nodeType == 3) this.lastChangedTextNode = node as Text
|
|
243
|
+
}
|
|
239
244
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
|
|
240
245
|
return {from: desc.posBefore, to: desc.posAfter}
|
|
241
246
|
let prev = mut.previousSibling, next = mut.nextSibling
|
|
@@ -258,6 +263,7 @@ export class DOMObserver {
|
|
|
258
263
|
} else if (mut.type == "attributes") {
|
|
259
264
|
return {from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border}
|
|
260
265
|
} else { // "characterData"
|
|
266
|
+
this.lastChangedTextNode = mut.target as Text
|
|
261
267
|
return {
|
|
262
268
|
from: desc.posAtStart,
|
|
263
269
|
to: desc.posAtEnd,
|
package/src/input.ts
CHANGED
|
@@ -517,7 +517,8 @@ export function findCompositionNode(view: EditorView) {
|
|
|
517
517
|
let textBefore = textNodeBefore(sel.focusNode, sel.focusOffset)
|
|
518
518
|
let textAfter = textNodeAfter(sel.focusNode, sel.focusOffset)
|
|
519
519
|
if (textBefore && textAfter && textBefore != textAfter) {
|
|
520
|
-
let descAfter = textAfter.pmViewDesc
|
|
520
|
+
let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode
|
|
521
|
+
if (textBefore == lastChanged || textAfter == lastChanged) return lastChanged
|
|
521
522
|
if (!descAfter || !descAfter.isText(textAfter.nodeValue!)) {
|
|
522
523
|
return textAfter
|
|
523
524
|
} else if (view.input.compositionNode == textAfter) {
|