@codemirror/view 6.15.0 → 6.15.1
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 +24 -10
- package/dist/index.js +24 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2502,7 +2502,7 @@ class DocView extends ContentView {
|
|
|
2502
2502
|
this.view = view;
|
|
2503
2503
|
this.decorations = [];
|
|
2504
2504
|
this.dynamicDecorationMap = [];
|
|
2505
|
-
this.hasComposition =
|
|
2505
|
+
this.hasComposition = null;
|
|
2506
2506
|
this.markedForComposition = new Set;
|
|
2507
2507
|
// Track a minimum width for the editor. When measuring sizes in
|
|
2508
2508
|
// measureVisibleLineHeights, this is updated to point at the width
|
|
@@ -2542,9 +2542,13 @@ class DocView extends ContentView {
|
|
|
2542
2542
|
}
|
|
2543
2543
|
}
|
|
2544
2544
|
let composition = this.view.inputState.composing < 0 ? null : findCompositionRange(this.view, update.changes);
|
|
2545
|
-
if (this.hasComposition)
|
|
2545
|
+
if (this.hasComposition) {
|
|
2546
2546
|
this.markedForComposition.clear();
|
|
2547
|
-
|
|
2547
|
+
let { from, to } = this.hasComposition;
|
|
2548
|
+
changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))
|
|
2549
|
+
.addToSet(changedRanges.slice());
|
|
2550
|
+
}
|
|
2551
|
+
this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
|
|
2548
2552
|
// When the DOM nodes around the selection are moved to another
|
|
2549
2553
|
// parent, Chrome sometimes reports a different selection through
|
|
2550
2554
|
// getSelection than the one that it actually shows to the user.
|
|
@@ -2613,9 +2617,16 @@ class DocView extends ContentView {
|
|
|
2613
2617
|
openStart = before.openStart;
|
|
2614
2618
|
openEnd = after.openEnd;
|
|
2615
2619
|
let compLine = this.compositionView(composition);
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2620
|
+
if (after.content.length) {
|
|
2621
|
+
compLine.breakAfter = after.content[0].breakAfter;
|
|
2622
|
+
if (compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0))
|
|
2623
|
+
after.content.shift();
|
|
2624
|
+
}
|
|
2625
|
+
if (before.content.length) {
|
|
2626
|
+
if (compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd))
|
|
2627
|
+
before.content.pop();
|
|
2628
|
+
}
|
|
2629
|
+
content = before.content.concat(compLine).concat(after.content);
|
|
2619
2630
|
}
|
|
2620
2631
|
else {
|
|
2621
2632
|
({ content, breakAtStart, openStart, openEnd } =
|
|
@@ -2642,9 +2653,11 @@ class DocView extends ContentView {
|
|
|
2642
2653
|
cView.flags |= 8 /* Composition */;
|
|
2643
2654
|
this.markedForComposition.add(cView);
|
|
2644
2655
|
let prev = ContentView.get(dom);
|
|
2645
|
-
if (prev)
|
|
2646
|
-
prev
|
|
2647
|
-
|
|
2656
|
+
if (prev != cView) {
|
|
2657
|
+
if (prev)
|
|
2658
|
+
prev.dom = null;
|
|
2659
|
+
cView.setDOM(dom);
|
|
2660
|
+
}
|
|
2648
2661
|
};
|
|
2649
2662
|
let pos = this.childPos(composition.range.fromB, 1);
|
|
2650
2663
|
let cView = this.children[pos.i];
|
|
@@ -2980,7 +2993,8 @@ function findCompositionNode(view) {
|
|
|
2980
2993
|
}
|
|
2981
2994
|
}
|
|
2982
2995
|
}
|
|
2983
|
-
|
|
2996
|
+
let { main } = view.state.selection;
|
|
2997
|
+
return from > main.head || to < main.head ? null : { from, to, node: textNode };
|
|
2984
2998
|
}
|
|
2985
2999
|
function findCompositionRange(view, changes) {
|
|
2986
3000
|
let found = findCompositionNode(view);
|
package/dist/index.js
CHANGED
|
@@ -2496,7 +2496,7 @@ class DocView extends ContentView {
|
|
|
2496
2496
|
this.view = view;
|
|
2497
2497
|
this.decorations = [];
|
|
2498
2498
|
this.dynamicDecorationMap = [];
|
|
2499
|
-
this.hasComposition =
|
|
2499
|
+
this.hasComposition = null;
|
|
2500
2500
|
this.markedForComposition = new Set;
|
|
2501
2501
|
// Track a minimum width for the editor. When measuring sizes in
|
|
2502
2502
|
// measureVisibleLineHeights, this is updated to point at the width
|
|
@@ -2536,9 +2536,13 @@ class DocView extends ContentView {
|
|
|
2536
2536
|
}
|
|
2537
2537
|
}
|
|
2538
2538
|
let composition = this.view.inputState.composing < 0 ? null : findCompositionRange(this.view, update.changes);
|
|
2539
|
-
if (this.hasComposition)
|
|
2539
|
+
if (this.hasComposition) {
|
|
2540
2540
|
this.markedForComposition.clear();
|
|
2541
|
-
|
|
2541
|
+
let { from, to } = this.hasComposition;
|
|
2542
|
+
changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))
|
|
2543
|
+
.addToSet(changedRanges.slice());
|
|
2544
|
+
}
|
|
2545
|
+
this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
|
|
2542
2546
|
// When the DOM nodes around the selection are moved to another
|
|
2543
2547
|
// parent, Chrome sometimes reports a different selection through
|
|
2544
2548
|
// getSelection than the one that it actually shows to the user.
|
|
@@ -2607,9 +2611,16 @@ class DocView extends ContentView {
|
|
|
2607
2611
|
openStart = before.openStart;
|
|
2608
2612
|
openEnd = after.openEnd;
|
|
2609
2613
|
let compLine = this.compositionView(composition);
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2614
|
+
if (after.content.length) {
|
|
2615
|
+
compLine.breakAfter = after.content[0].breakAfter;
|
|
2616
|
+
if (compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0))
|
|
2617
|
+
after.content.shift();
|
|
2618
|
+
}
|
|
2619
|
+
if (before.content.length) {
|
|
2620
|
+
if (compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd))
|
|
2621
|
+
before.content.pop();
|
|
2622
|
+
}
|
|
2623
|
+
content = before.content.concat(compLine).concat(after.content);
|
|
2613
2624
|
}
|
|
2614
2625
|
else {
|
|
2615
2626
|
({ content, breakAtStart, openStart, openEnd } =
|
|
@@ -2636,9 +2647,11 @@ class DocView extends ContentView {
|
|
|
2636
2647
|
cView.flags |= 8 /* Composition */;
|
|
2637
2648
|
this.markedForComposition.add(cView);
|
|
2638
2649
|
let prev = ContentView.get(dom);
|
|
2639
|
-
if (prev)
|
|
2640
|
-
prev
|
|
2641
|
-
|
|
2650
|
+
if (prev != cView) {
|
|
2651
|
+
if (prev)
|
|
2652
|
+
prev.dom = null;
|
|
2653
|
+
cView.setDOM(dom);
|
|
2654
|
+
}
|
|
2642
2655
|
};
|
|
2643
2656
|
let pos = this.childPos(composition.range.fromB, 1);
|
|
2644
2657
|
let cView = this.children[pos.i];
|
|
@@ -2974,7 +2987,8 @@ function findCompositionNode(view) {
|
|
|
2974
2987
|
}
|
|
2975
2988
|
}
|
|
2976
2989
|
}
|
|
2977
|
-
|
|
2990
|
+
let { main } = view.state.selection;
|
|
2991
|
+
return from > main.head || to < main.head ? null : { from, to, node: textNode };
|
|
2978
2992
|
}
|
|
2979
2993
|
function findCompositionRange(view, changes) {
|
|
2980
2994
|
let found = findCompositionNode(view);
|