@codemirror/view 6.39.3 → 6.39.5
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 +20 -0
- package/dist/index.cjs +42 -54
- package/dist/index.js +42 -54
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 6.39.5 (2025-12-22)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where replaced widgets alone on a line weren't reused and didn't get their `updateDOM` method called.
|
|
6
|
+
|
|
7
|
+
Fix a bug where, when selecting full lines at the end of the document and inserting a character on Chrome, an inappropriate extra newline was inserted.
|
|
8
|
+
|
|
9
|
+
## 6.39.4 (2025-12-12)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Fix a bug where paste events handlers on Chrome could fail to run when pasting on a blank line.
|
|
14
|
+
|
|
15
|
+
Fix a regression causing the native cursor to get stuck before block widgets with side>0.
|
|
16
|
+
|
|
17
|
+
Fix a crash in content DOM building after a block widget.
|
|
18
|
+
|
|
19
|
+
Fix a bug in `posAtCoords` that would in some circumstances make it return positions on the wrong side of a block widget.
|
|
20
|
+
|
|
1
21
|
## 6.39.3 (2025-12-11)
|
|
2
22
|
|
|
3
23
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1991,7 +1991,7 @@ class LineTile extends CompositeTile {
|
|
|
1991
1991
|
if (this.dom.contains(tile.dom)) {
|
|
1992
1992
|
if (tile.isText())
|
|
1993
1993
|
return new DOMPos(tile.dom, Math.min(tile.dom.nodeValue.length, offset));
|
|
1994
|
-
return tile.domPosFor(offset, side);
|
|
1994
|
+
return tile.domPosFor(offset, tile.flags & 16 /* TileFlag.Before */ ? 1 : tile.flags & 32 /* TileFlag.After */ ? -1 : side);
|
|
1995
1995
|
}
|
|
1996
1996
|
let parent = found.tile.parent, saw = false;
|
|
1997
1997
|
for (let ch of parent.children) {
|
|
@@ -2573,6 +2573,16 @@ class TileUpdate {
|
|
|
2573
2573
|
this.builder = new TileBuilder(this.cache, new DocTile(view, view.contentDOM), state.RangeSet.iter(blockWrappers));
|
|
2574
2574
|
this.cache.reused.set(old, 2 /* Reused.DOM */);
|
|
2575
2575
|
this.old = new TilePointer(old);
|
|
2576
|
+
this.reuseWalker = {
|
|
2577
|
+
skip: (tile, from, to) => {
|
|
2578
|
+
this.cache.add(tile);
|
|
2579
|
+
if (tile.isComposite())
|
|
2580
|
+
return false;
|
|
2581
|
+
},
|
|
2582
|
+
enter: tile => this.cache.add(tile),
|
|
2583
|
+
leave: () => { },
|
|
2584
|
+
break: () => { }
|
|
2585
|
+
};
|
|
2576
2586
|
}
|
|
2577
2587
|
run(changes, composition) {
|
|
2578
2588
|
let compositionContext = composition && this.getCompositionContext(composition.text);
|
|
@@ -2623,12 +2633,14 @@ class TileUpdate {
|
|
|
2623
2633
|
this.builder.addBlockWidget(widget);
|
|
2624
2634
|
}
|
|
2625
2635
|
else {
|
|
2636
|
+
this.builder.ensureLine(null);
|
|
2626
2637
|
this.builder.addInlineWidget(widget, activeMarks, openMarks);
|
|
2627
2638
|
openMarks = activeMarks.length;
|
|
2628
2639
|
}
|
|
2629
2640
|
}
|
|
2630
2641
|
}
|
|
2631
2642
|
else if (tile.isText()) {
|
|
2643
|
+
this.builder.ensureLine(null);
|
|
2632
2644
|
if (!from && to == tile.length) {
|
|
2633
2645
|
this.builder.addText(tile.text, activeMarks, openMarks, this.cache.reuse(tile));
|
|
2634
2646
|
}
|
|
@@ -2647,6 +2659,7 @@ class TileUpdate {
|
|
|
2647
2659
|
this.cache.add(tile);
|
|
2648
2660
|
}
|
|
2649
2661
|
else if (tile instanceof MarkTile) {
|
|
2662
|
+
this.builder.ensureLine(null);
|
|
2650
2663
|
this.builder.addMark(tile, activeMarks, openMarks);
|
|
2651
2664
|
this.cache.reused.set(tile, 1 /* Reused.Full */);
|
|
2652
2665
|
openMarks = activeMarks.length;
|
|
@@ -2744,15 +2757,14 @@ class TileUpdate {
|
|
|
2744
2757
|
this.openMarks = openEnd;
|
|
2745
2758
|
}
|
|
2746
2759
|
forward(from, to) {
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
});
|
|
2760
|
+
if (to - from <= 10) {
|
|
2761
|
+
this.old.advance(to - from, 1, this.reuseWalker);
|
|
2762
|
+
}
|
|
2763
|
+
else {
|
|
2764
|
+
this.old.advance(5, -1, this.reuseWalker);
|
|
2765
|
+
this.old.advance(to - from - 10, -1);
|
|
2766
|
+
this.old.advance(5, 1, this.reuseWalker);
|
|
2767
|
+
}
|
|
2756
2768
|
}
|
|
2757
2769
|
getCompositionContext(text) {
|
|
2758
2770
|
let marks = [], line = null;
|
|
@@ -3074,7 +3086,7 @@ class DocView {
|
|
|
3074
3086
|
let { anchorNode, anchorOffset } = view.observer.selectionRange;
|
|
3075
3087
|
if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
|
|
3076
3088
|
return;
|
|
3077
|
-
let line = this.lineAt(cursor.head);
|
|
3089
|
+
let line = this.lineAt(cursor.head, cursor.assoc);
|
|
3078
3090
|
if (!line)
|
|
3079
3091
|
return;
|
|
3080
3092
|
let lineStart = line.posAtStart;
|
|
@@ -3153,7 +3165,7 @@ class DocView {
|
|
|
3153
3165
|
let after, afterOff = -1, afterBad = false;
|
|
3154
3166
|
this.tile.blockTiles((tile, off) => {
|
|
3155
3167
|
if (tile.isWidget()) {
|
|
3156
|
-
if ((tile.flags & 32 /* TileFlag.After */) &&
|
|
3168
|
+
if ((tile.flags & 32 /* TileFlag.After */) && off >= pos)
|
|
3157
3169
|
return true;
|
|
3158
3170
|
if (tile.flags & 16 /* TileFlag.Before */)
|
|
3159
3171
|
beforeBad = true;
|
|
@@ -3191,8 +3203,8 @@ class DocView {
|
|
|
3191
3203
|
}
|
|
3192
3204
|
return tile.coordsIn(offset, side);
|
|
3193
3205
|
}
|
|
3194
|
-
lineAt(pos) {
|
|
3195
|
-
let { tile } = this.tile.resolveBlock(pos,
|
|
3206
|
+
lineAt(pos, side) {
|
|
3207
|
+
let { tile } = this.tile.resolveBlock(pos, side);
|
|
3196
3208
|
return tile.isLine() ? tile : null;
|
|
3197
3209
|
}
|
|
3198
3210
|
coordsForChar(pos) {
|
|
@@ -3738,7 +3750,10 @@ function posAtCoords(view, coords, precise, scanY) {
|
|
|
3738
3750
|
if (block.type != exports.BlockType.Text)
|
|
3739
3751
|
return yOffset < (block.top + block.bottom) / 2 ? new PosAssoc(block.from, 1) : new PosAssoc(block.to, -1);
|
|
3740
3752
|
// Here we know we're in a line, so run the logic for inline layout
|
|
3741
|
-
|
|
3753
|
+
let line = view.docView.lineAt(block.from, 2);
|
|
3754
|
+
if (!line || line.length != block.length)
|
|
3755
|
+
line = view.docView.lineAt(block.from, -2);
|
|
3756
|
+
return posAtCoordsInline(view, line, block.from, x, y);
|
|
3742
3757
|
}
|
|
3743
3758
|
// Scan through the rectangles for the content of a tile, finding the
|
|
3744
3759
|
// one closest to the given coordinates, prefering closeness in Y over
|
|
@@ -3821,10 +3836,11 @@ function dirAt(view, pos) {
|
|
|
3821
3836
|
|
|
3822
3837
|
const LineBreakPlaceholder = "\uffff";
|
|
3823
3838
|
class DOMReader {
|
|
3824
|
-
constructor(points,
|
|
3839
|
+
constructor(points, view) {
|
|
3825
3840
|
this.points = points;
|
|
3841
|
+
this.view = view;
|
|
3826
3842
|
this.text = "";
|
|
3827
|
-
this.lineSeparator = state
|
|
3843
|
+
this.lineSeparator = view.state.facet(state.EditorState.lineSeparator);
|
|
3828
3844
|
}
|
|
3829
3845
|
append(text) {
|
|
3830
3846
|
this.text += text;
|
|
@@ -3842,7 +3858,7 @@ class DOMReader {
|
|
|
3842
3858
|
this.readNode(cur);
|
|
3843
3859
|
let tile = Tile.get(cur), next = cur.nextSibling;
|
|
3844
3860
|
if (next == end) {
|
|
3845
|
-
if ((tile === null || tile === void 0 ? void 0 : tile.breakAfter) && !next)
|
|
3861
|
+
if ((tile === null || tile === void 0 ? void 0 : tile.breakAfter) && !next && parent != this.view.contentDOM)
|
|
3846
3862
|
this.lineBreak();
|
|
3847
3863
|
break;
|
|
3848
3864
|
}
|
|
@@ -3967,7 +3983,7 @@ class DOMChange {
|
|
|
3967
3983
|
}
|
|
3968
3984
|
else if (start > -1 && (this.bounds = domBoundsAround(view.docView.tile, start, end, 0))) {
|
|
3969
3985
|
let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
|
|
3970
|
-
let reader = new DOMReader(selPoints, view
|
|
3986
|
+
let reader = new DOMReader(selPoints, view);
|
|
3971
3987
|
reader.readRange(this.bounds.startDOM, this.bounds.endDOM);
|
|
3972
3988
|
this.text = reader.text;
|
|
3973
3989
|
this.newSel = selectionFromPoints(selPoints, this.bounds.from);
|
|
@@ -4657,7 +4673,8 @@ function eventBelongsToEditor(view, event) {
|
|
|
4657
4673
|
if (event.defaultPrevented)
|
|
4658
4674
|
return false;
|
|
4659
4675
|
for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode)
|
|
4660
|
-
if (!node || node.nodeType == 11 ||
|
|
4676
|
+
if (!node || node.nodeType == 11 ||
|
|
4677
|
+
((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event)))
|
|
4661
4678
|
return false;
|
|
4662
4679
|
return true;
|
|
4663
4680
|
}
|
|
@@ -4776,42 +4793,13 @@ function rangeForClick(view, pos, bias, type) {
|
|
|
4776
4793
|
return groupAt(view.state, pos, bias);
|
|
4777
4794
|
}
|
|
4778
4795
|
else { // Triple click
|
|
4779
|
-
let visual = view.docView.lineAt(pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
|
|
4796
|
+
let visual = view.docView.lineAt(pos, bias), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
|
|
4780
4797
|
let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
|
|
4781
4798
|
if (to < view.state.doc.length && to == line.to)
|
|
4782
4799
|
to++;
|
|
4783
4800
|
return state.EditorSelection.range(from, to);
|
|
4784
4801
|
}
|
|
4785
4802
|
}
|
|
4786
|
-
let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
|
|
4787
|
-
// Try to determine, for the given coordinates, associated with the
|
|
4788
|
-
// given position, whether they are related to the element before or
|
|
4789
|
-
// the element after the position.
|
|
4790
|
-
function findPositionSide(view, pos, x, y) {
|
|
4791
|
-
let line = view.docView.lineAt(pos);
|
|
4792
|
-
if (!line)
|
|
4793
|
-
return 1;
|
|
4794
|
-
let off = pos - line.posAtStart;
|
|
4795
|
-
// Line boundaries point into the line
|
|
4796
|
-
if (off == 0)
|
|
4797
|
-
return 1;
|
|
4798
|
-
if (off == line.length)
|
|
4799
|
-
return -1;
|
|
4800
|
-
// Positions on top of an element point at that element
|
|
4801
|
-
let before = line.coordsIn(off, -1);
|
|
4802
|
-
if (before && inside(x, y, before))
|
|
4803
|
-
return -1;
|
|
4804
|
-
let after = line.coordsIn(off, 1);
|
|
4805
|
-
if (after && inside(x, y, after))
|
|
4806
|
-
return 1;
|
|
4807
|
-
// This is probably a line wrap point. Pick before if the point is
|
|
4808
|
-
// above its bottom.
|
|
4809
|
-
return before && before.bottom >= y ? -1 : 1;
|
|
4810
|
-
}
|
|
4811
|
-
function queryPos(view, event) {
|
|
4812
|
-
let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
4813
|
-
return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };
|
|
4814
|
-
}
|
|
4815
4803
|
const BadMouseDetail = browser.ie && browser.ie_version <= 11;
|
|
4816
4804
|
let lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;
|
|
4817
4805
|
function getClickType(event) {
|
|
@@ -4824,7 +4812,7 @@ function getClickType(event) {
|
|
|
4824
4812
|
Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;
|
|
4825
4813
|
}
|
|
4826
4814
|
function basicMouseSelection(view, event) {
|
|
4827
|
-
let start =
|
|
4815
|
+
let start = view.posAndSideAtCoords({ x: event.clientX, y: event.clientY }, false), type = getClickType(event);
|
|
4828
4816
|
let startSel = view.state.selection;
|
|
4829
4817
|
return {
|
|
4830
4818
|
update(update) {
|
|
@@ -4834,10 +4822,10 @@ function basicMouseSelection(view, event) {
|
|
|
4834
4822
|
}
|
|
4835
4823
|
},
|
|
4836
4824
|
get(event, extend, multiple) {
|
|
4837
|
-
let cur =
|
|
4838
|
-
let range = rangeForClick(view, cur.pos, cur.
|
|
4825
|
+
let cur = view.posAndSideAtCoords({ x: event.clientX, y: event.clientY }, false), removed;
|
|
4826
|
+
let range = rangeForClick(view, cur.pos, cur.assoc, type);
|
|
4839
4827
|
if (start.pos != cur.pos && !extend) {
|
|
4840
|
-
let startRange = rangeForClick(view, start.pos, start.
|
|
4828
|
+
let startRange = rangeForClick(view, start.pos, start.assoc, type);
|
|
4841
4829
|
let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
|
|
4842
4830
|
range = from < range.from ? state.EditorSelection.range(from, to) : state.EditorSelection.range(to, from);
|
|
4843
4831
|
}
|
package/dist/index.js
CHANGED
|
@@ -1987,7 +1987,7 @@ class LineTile extends CompositeTile {
|
|
|
1987
1987
|
if (this.dom.contains(tile.dom)) {
|
|
1988
1988
|
if (tile.isText())
|
|
1989
1989
|
return new DOMPos(tile.dom, Math.min(tile.dom.nodeValue.length, offset));
|
|
1990
|
-
return tile.domPosFor(offset, side);
|
|
1990
|
+
return tile.domPosFor(offset, tile.flags & 16 /* TileFlag.Before */ ? 1 : tile.flags & 32 /* TileFlag.After */ ? -1 : side);
|
|
1991
1991
|
}
|
|
1992
1992
|
let parent = found.tile.parent, saw = false;
|
|
1993
1993
|
for (let ch of parent.children) {
|
|
@@ -2569,6 +2569,16 @@ class TileUpdate {
|
|
|
2569
2569
|
this.builder = new TileBuilder(this.cache, new DocTile(view, view.contentDOM), RangeSet.iter(blockWrappers));
|
|
2570
2570
|
this.cache.reused.set(old, 2 /* Reused.DOM */);
|
|
2571
2571
|
this.old = new TilePointer(old);
|
|
2572
|
+
this.reuseWalker = {
|
|
2573
|
+
skip: (tile, from, to) => {
|
|
2574
|
+
this.cache.add(tile);
|
|
2575
|
+
if (tile.isComposite())
|
|
2576
|
+
return false;
|
|
2577
|
+
},
|
|
2578
|
+
enter: tile => this.cache.add(tile),
|
|
2579
|
+
leave: () => { },
|
|
2580
|
+
break: () => { }
|
|
2581
|
+
};
|
|
2572
2582
|
}
|
|
2573
2583
|
run(changes, composition) {
|
|
2574
2584
|
let compositionContext = composition && this.getCompositionContext(composition.text);
|
|
@@ -2619,12 +2629,14 @@ class TileUpdate {
|
|
|
2619
2629
|
this.builder.addBlockWidget(widget);
|
|
2620
2630
|
}
|
|
2621
2631
|
else {
|
|
2632
|
+
this.builder.ensureLine(null);
|
|
2622
2633
|
this.builder.addInlineWidget(widget, activeMarks, openMarks);
|
|
2623
2634
|
openMarks = activeMarks.length;
|
|
2624
2635
|
}
|
|
2625
2636
|
}
|
|
2626
2637
|
}
|
|
2627
2638
|
else if (tile.isText()) {
|
|
2639
|
+
this.builder.ensureLine(null);
|
|
2628
2640
|
if (!from && to == tile.length) {
|
|
2629
2641
|
this.builder.addText(tile.text, activeMarks, openMarks, this.cache.reuse(tile));
|
|
2630
2642
|
}
|
|
@@ -2643,6 +2655,7 @@ class TileUpdate {
|
|
|
2643
2655
|
this.cache.add(tile);
|
|
2644
2656
|
}
|
|
2645
2657
|
else if (tile instanceof MarkTile) {
|
|
2658
|
+
this.builder.ensureLine(null);
|
|
2646
2659
|
this.builder.addMark(tile, activeMarks, openMarks);
|
|
2647
2660
|
this.cache.reused.set(tile, 1 /* Reused.Full */);
|
|
2648
2661
|
openMarks = activeMarks.length;
|
|
@@ -2740,15 +2753,14 @@ class TileUpdate {
|
|
|
2740
2753
|
this.openMarks = openEnd;
|
|
2741
2754
|
}
|
|
2742
2755
|
forward(from, to) {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
});
|
|
2756
|
+
if (to - from <= 10) {
|
|
2757
|
+
this.old.advance(to - from, 1, this.reuseWalker);
|
|
2758
|
+
}
|
|
2759
|
+
else {
|
|
2760
|
+
this.old.advance(5, -1, this.reuseWalker);
|
|
2761
|
+
this.old.advance(to - from - 10, -1);
|
|
2762
|
+
this.old.advance(5, 1, this.reuseWalker);
|
|
2763
|
+
}
|
|
2752
2764
|
}
|
|
2753
2765
|
getCompositionContext(text) {
|
|
2754
2766
|
let marks = [], line = null;
|
|
@@ -3070,7 +3082,7 @@ class DocView {
|
|
|
3070
3082
|
let { anchorNode, anchorOffset } = view.observer.selectionRange;
|
|
3071
3083
|
if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
|
|
3072
3084
|
return;
|
|
3073
|
-
let line = this.lineAt(cursor.head);
|
|
3085
|
+
let line = this.lineAt(cursor.head, cursor.assoc);
|
|
3074
3086
|
if (!line)
|
|
3075
3087
|
return;
|
|
3076
3088
|
let lineStart = line.posAtStart;
|
|
@@ -3149,7 +3161,7 @@ class DocView {
|
|
|
3149
3161
|
let after, afterOff = -1, afterBad = false;
|
|
3150
3162
|
this.tile.blockTiles((tile, off) => {
|
|
3151
3163
|
if (tile.isWidget()) {
|
|
3152
|
-
if ((tile.flags & 32 /* TileFlag.After */) &&
|
|
3164
|
+
if ((tile.flags & 32 /* TileFlag.After */) && off >= pos)
|
|
3153
3165
|
return true;
|
|
3154
3166
|
if (tile.flags & 16 /* TileFlag.Before */)
|
|
3155
3167
|
beforeBad = true;
|
|
@@ -3187,8 +3199,8 @@ class DocView {
|
|
|
3187
3199
|
}
|
|
3188
3200
|
return tile.coordsIn(offset, side);
|
|
3189
3201
|
}
|
|
3190
|
-
lineAt(pos) {
|
|
3191
|
-
let { tile } = this.tile.resolveBlock(pos,
|
|
3202
|
+
lineAt(pos, side) {
|
|
3203
|
+
let { tile } = this.tile.resolveBlock(pos, side);
|
|
3192
3204
|
return tile.isLine() ? tile : null;
|
|
3193
3205
|
}
|
|
3194
3206
|
coordsForChar(pos) {
|
|
@@ -3734,7 +3746,10 @@ function posAtCoords(view, coords, precise, scanY) {
|
|
|
3734
3746
|
if (block.type != BlockType.Text)
|
|
3735
3747
|
return yOffset < (block.top + block.bottom) / 2 ? new PosAssoc(block.from, 1) : new PosAssoc(block.to, -1);
|
|
3736
3748
|
// Here we know we're in a line, so run the logic for inline layout
|
|
3737
|
-
|
|
3749
|
+
let line = view.docView.lineAt(block.from, 2);
|
|
3750
|
+
if (!line || line.length != block.length)
|
|
3751
|
+
line = view.docView.lineAt(block.from, -2);
|
|
3752
|
+
return posAtCoordsInline(view, line, block.from, x, y);
|
|
3738
3753
|
}
|
|
3739
3754
|
// Scan through the rectangles for the content of a tile, finding the
|
|
3740
3755
|
// one closest to the given coordinates, prefering closeness in Y over
|
|
@@ -3817,10 +3832,11 @@ function dirAt(view, pos) {
|
|
|
3817
3832
|
|
|
3818
3833
|
const LineBreakPlaceholder = "\uffff";
|
|
3819
3834
|
class DOMReader {
|
|
3820
|
-
constructor(points,
|
|
3835
|
+
constructor(points, view) {
|
|
3821
3836
|
this.points = points;
|
|
3837
|
+
this.view = view;
|
|
3822
3838
|
this.text = "";
|
|
3823
|
-
this.lineSeparator = state.facet(EditorState.lineSeparator);
|
|
3839
|
+
this.lineSeparator = view.state.facet(EditorState.lineSeparator);
|
|
3824
3840
|
}
|
|
3825
3841
|
append(text) {
|
|
3826
3842
|
this.text += text;
|
|
@@ -3838,7 +3854,7 @@ class DOMReader {
|
|
|
3838
3854
|
this.readNode(cur);
|
|
3839
3855
|
let tile = Tile.get(cur), next = cur.nextSibling;
|
|
3840
3856
|
if (next == end) {
|
|
3841
|
-
if ((tile === null || tile === void 0 ? void 0 : tile.breakAfter) && !next)
|
|
3857
|
+
if ((tile === null || tile === void 0 ? void 0 : tile.breakAfter) && !next && parent != this.view.contentDOM)
|
|
3842
3858
|
this.lineBreak();
|
|
3843
3859
|
break;
|
|
3844
3860
|
}
|
|
@@ -3963,7 +3979,7 @@ class DOMChange {
|
|
|
3963
3979
|
}
|
|
3964
3980
|
else if (start > -1 && (this.bounds = domBoundsAround(view.docView.tile, start, end, 0))) {
|
|
3965
3981
|
let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
|
|
3966
|
-
let reader = new DOMReader(selPoints, view
|
|
3982
|
+
let reader = new DOMReader(selPoints, view);
|
|
3967
3983
|
reader.readRange(this.bounds.startDOM, this.bounds.endDOM);
|
|
3968
3984
|
this.text = reader.text;
|
|
3969
3985
|
this.newSel = selectionFromPoints(selPoints, this.bounds.from);
|
|
@@ -4653,7 +4669,8 @@ function eventBelongsToEditor(view, event) {
|
|
|
4653
4669
|
if (event.defaultPrevented)
|
|
4654
4670
|
return false;
|
|
4655
4671
|
for (let node = event.target, tile; node != view.contentDOM; node = node.parentNode)
|
|
4656
|
-
if (!node || node.nodeType == 11 ||
|
|
4672
|
+
if (!node || node.nodeType == 11 ||
|
|
4673
|
+
((tile = Tile.get(node)) && tile.isWidget() && !tile.isHidden && tile.widget.ignoreEvent(event)))
|
|
4657
4674
|
return false;
|
|
4658
4675
|
return true;
|
|
4659
4676
|
}
|
|
@@ -4772,42 +4789,13 @@ function rangeForClick(view, pos, bias, type) {
|
|
|
4772
4789
|
return groupAt(view.state, pos, bias);
|
|
4773
4790
|
}
|
|
4774
4791
|
else { // Triple click
|
|
4775
|
-
let visual = view.docView.lineAt(pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
|
|
4792
|
+
let visual = view.docView.lineAt(pos, bias), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
|
|
4776
4793
|
let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
|
|
4777
4794
|
if (to < view.state.doc.length && to == line.to)
|
|
4778
4795
|
to++;
|
|
4779
4796
|
return EditorSelection.range(from, to);
|
|
4780
4797
|
}
|
|
4781
4798
|
}
|
|
4782
|
-
let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
|
|
4783
|
-
// Try to determine, for the given coordinates, associated with the
|
|
4784
|
-
// given position, whether they are related to the element before or
|
|
4785
|
-
// the element after the position.
|
|
4786
|
-
function findPositionSide(view, pos, x, y) {
|
|
4787
|
-
let line = view.docView.lineAt(pos);
|
|
4788
|
-
if (!line)
|
|
4789
|
-
return 1;
|
|
4790
|
-
let off = pos - line.posAtStart;
|
|
4791
|
-
// Line boundaries point into the line
|
|
4792
|
-
if (off == 0)
|
|
4793
|
-
return 1;
|
|
4794
|
-
if (off == line.length)
|
|
4795
|
-
return -1;
|
|
4796
|
-
// Positions on top of an element point at that element
|
|
4797
|
-
let before = line.coordsIn(off, -1);
|
|
4798
|
-
if (before && inside(x, y, before))
|
|
4799
|
-
return -1;
|
|
4800
|
-
let after = line.coordsIn(off, 1);
|
|
4801
|
-
if (after && inside(x, y, after))
|
|
4802
|
-
return 1;
|
|
4803
|
-
// This is probably a line wrap point. Pick before if the point is
|
|
4804
|
-
// above its bottom.
|
|
4805
|
-
return before && before.bottom >= y ? -1 : 1;
|
|
4806
|
-
}
|
|
4807
|
-
function queryPos(view, event) {
|
|
4808
|
-
let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
4809
|
-
return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };
|
|
4810
|
-
}
|
|
4811
4799
|
const BadMouseDetail = browser.ie && browser.ie_version <= 11;
|
|
4812
4800
|
let lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;
|
|
4813
4801
|
function getClickType(event) {
|
|
@@ -4820,7 +4808,7 @@ function getClickType(event) {
|
|
|
4820
4808
|
Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;
|
|
4821
4809
|
}
|
|
4822
4810
|
function basicMouseSelection(view, event) {
|
|
4823
|
-
let start =
|
|
4811
|
+
let start = view.posAndSideAtCoords({ x: event.clientX, y: event.clientY }, false), type = getClickType(event);
|
|
4824
4812
|
let startSel = view.state.selection;
|
|
4825
4813
|
return {
|
|
4826
4814
|
update(update) {
|
|
@@ -4830,10 +4818,10 @@ function basicMouseSelection(view, event) {
|
|
|
4830
4818
|
}
|
|
4831
4819
|
},
|
|
4832
4820
|
get(event, extend, multiple) {
|
|
4833
|
-
let cur =
|
|
4834
|
-
let range = rangeForClick(view, cur.pos, cur.
|
|
4821
|
+
let cur = view.posAndSideAtCoords({ x: event.clientX, y: event.clientY }, false), removed;
|
|
4822
|
+
let range = rangeForClick(view, cur.pos, cur.assoc, type);
|
|
4835
4823
|
if (start.pos != cur.pos && !extend) {
|
|
4836
|
-
let startRange = rangeForClick(view, start.pos, start.
|
|
4824
|
+
let startRange = rangeForClick(view, start.pos, start.assoc, type);
|
|
4837
4825
|
let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
|
|
4838
4826
|
range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
|
|
4839
4827
|
}
|