@codemirror/view 6.15.2 → 6.16.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 +16 -0
- package/dist/index.cjs +43 -7
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +43 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 6.16.0 (2023-07-31)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue that made the gutter not stick in place when the editor was in a right-to-left context.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
The new `EditorView.coordsForChar` method returns the client rectangle for a given character in the editor.
|
|
10
|
+
|
|
11
|
+
## 6.15.3 (2023-07-18)
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
|
|
15
|
+
Fix another crash regression for compositions before line breaks.
|
|
16
|
+
|
|
1
17
|
## 6.15.2 (2023-07-18)
|
|
2
18
|
|
|
3
19
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2617,14 +2617,17 @@ class DocView extends ContentView {
|
|
|
2617
2617
|
openStart = before.openStart;
|
|
2618
2618
|
openEnd = after.openEnd;
|
|
2619
2619
|
let compLine = this.compositionView(composition);
|
|
2620
|
-
if (after.
|
|
2620
|
+
if (after.breakAtStart) {
|
|
2621
|
+
compLine.breakAfter = 1;
|
|
2622
|
+
}
|
|
2623
|
+
else if (after.content.length &&
|
|
2624
|
+
compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
|
|
2621
2625
|
compLine.breakAfter = after.content[0].breakAfter;
|
|
2622
|
-
|
|
2623
|
-
after.content.shift();
|
|
2626
|
+
after.content.shift();
|
|
2624
2627
|
}
|
|
2625
|
-
if (before.content.length
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
+
if (before.content.length &&
|
|
2629
|
+
compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
|
|
2630
|
+
before.content.pop();
|
|
2628
2631
|
}
|
|
2629
2632
|
content = before.content.concat(compLine).concat(after.content);
|
|
2630
2633
|
}
|
|
@@ -2820,6 +2823,28 @@ class DocView extends ContentView {
|
|
|
2820
2823
|
off = start;
|
|
2821
2824
|
}
|
|
2822
2825
|
}
|
|
2826
|
+
coordsForChar(pos) {
|
|
2827
|
+
let { i, off } = this.childPos(pos, 1), child = this.children[i];
|
|
2828
|
+
if (!(child instanceof LineView))
|
|
2829
|
+
return null;
|
|
2830
|
+
while (child.children.length) {
|
|
2831
|
+
let { i, off: childOff } = child.childPos(off, 1);
|
|
2832
|
+
for (;; i++) {
|
|
2833
|
+
if (i == child.children.length)
|
|
2834
|
+
return null;
|
|
2835
|
+
if ((child = child.children[i]).length)
|
|
2836
|
+
break;
|
|
2837
|
+
}
|
|
2838
|
+
off = childOff;
|
|
2839
|
+
}
|
|
2840
|
+
if (!(child instanceof TextView))
|
|
2841
|
+
return null;
|
|
2842
|
+
let end = state.findClusterBreak(child.text, off);
|
|
2843
|
+
if (end == off)
|
|
2844
|
+
return null;
|
|
2845
|
+
let rects = textRange(child.dom, off, end).getClientRects();
|
|
2846
|
+
return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0];
|
|
2847
|
+
}
|
|
2823
2848
|
measureVisibleLineHeights(viewport) {
|
|
2824
2849
|
let result = [], { from, to } = viewport;
|
|
2825
2850
|
let contentWidth = this.view.contentDOM.clientWidth;
|
|
@@ -5692,7 +5717,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
|
5692
5717
|
display: "flex",
|
|
5693
5718
|
height: "100%",
|
|
5694
5719
|
boxSizing: "border-box",
|
|
5695
|
-
|
|
5720
|
+
insetInlineStart: 0,
|
|
5696
5721
|
zIndex: 200
|
|
5697
5722
|
},
|
|
5698
5723
|
"&light .cm-gutters": {
|
|
@@ -7156,6 +7181,17 @@ class EditorView {
|
|
|
7156
7181
|
return flattenRect(rect, (span.dir == exports.Direction.LTR) == (side > 0));
|
|
7157
7182
|
}
|
|
7158
7183
|
/**
|
|
7184
|
+
Return the rectangle around a given character. If `pos` does not
|
|
7185
|
+
point in front of a character that is in the viewport and
|
|
7186
|
+
rendered (i.e. not replaced, not a line break), this will return
|
|
7187
|
+
null. For space characters that are a line wrap point, this will
|
|
7188
|
+
return the position before the line break.
|
|
7189
|
+
*/
|
|
7190
|
+
coordsForChar(pos) {
|
|
7191
|
+
this.readMeasured();
|
|
7192
|
+
return this.docView.coordsForChar(pos);
|
|
7193
|
+
}
|
|
7194
|
+
/**
|
|
7159
7195
|
The default width of a character in the editor. May not
|
|
7160
7196
|
accurately reflect the width of all characters (given variable
|
|
7161
7197
|
width fonts or styling of invididual ranges).
|
package/dist/index.d.cts
CHANGED
|
@@ -907,6 +907,14 @@ declare class EditorView {
|
|
|
907
907
|
*/
|
|
908
908
|
coordsAtPos(pos: number, side?: -1 | 1): Rect | null;
|
|
909
909
|
/**
|
|
910
|
+
Return the rectangle around a given character. If `pos` does not
|
|
911
|
+
point in front of a character that is in the viewport and
|
|
912
|
+
rendered (i.e. not replaced, not a line break), this will return
|
|
913
|
+
null. For space characters that are a line wrap point, this will
|
|
914
|
+
return the position before the line break.
|
|
915
|
+
*/
|
|
916
|
+
coordsForChar(pos: number): Rect | null;
|
|
917
|
+
/**
|
|
910
918
|
The default width of a character in the editor. May not
|
|
911
919
|
accurately reflect the width of all characters (given variable
|
|
912
920
|
width fonts or styling of invididual ranges).
|
package/dist/index.d.ts
CHANGED
|
@@ -907,6 +907,14 @@ declare class EditorView {
|
|
|
907
907
|
*/
|
|
908
908
|
coordsAtPos(pos: number, side?: -1 | 1): Rect | null;
|
|
909
909
|
/**
|
|
910
|
+
Return the rectangle around a given character. If `pos` does not
|
|
911
|
+
point in front of a character that is in the viewport and
|
|
912
|
+
rendered (i.e. not replaced, not a line break), this will return
|
|
913
|
+
null. For space characters that are a line wrap point, this will
|
|
914
|
+
return the position before the line break.
|
|
915
|
+
*/
|
|
916
|
+
coordsForChar(pos: number): Rect | null;
|
|
917
|
+
/**
|
|
910
918
|
The default width of a character in the editor. May not
|
|
911
919
|
accurately reflect the width of all characters (given variable
|
|
912
920
|
width fonts or styling of invididual ranges).
|
package/dist/index.js
CHANGED
|
@@ -2611,14 +2611,17 @@ class DocView extends ContentView {
|
|
|
2611
2611
|
openStart = before.openStart;
|
|
2612
2612
|
openEnd = after.openEnd;
|
|
2613
2613
|
let compLine = this.compositionView(composition);
|
|
2614
|
-
if (after.
|
|
2614
|
+
if (after.breakAtStart) {
|
|
2615
|
+
compLine.breakAfter = 1;
|
|
2616
|
+
}
|
|
2617
|
+
else if (after.content.length &&
|
|
2618
|
+
compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
|
|
2615
2619
|
compLine.breakAfter = after.content[0].breakAfter;
|
|
2616
|
-
|
|
2617
|
-
after.content.shift();
|
|
2620
|
+
after.content.shift();
|
|
2618
2621
|
}
|
|
2619
|
-
if (before.content.length
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
+
if (before.content.length &&
|
|
2623
|
+
compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
|
|
2624
|
+
before.content.pop();
|
|
2622
2625
|
}
|
|
2623
2626
|
content = before.content.concat(compLine).concat(after.content);
|
|
2624
2627
|
}
|
|
@@ -2814,6 +2817,28 @@ class DocView extends ContentView {
|
|
|
2814
2817
|
off = start;
|
|
2815
2818
|
}
|
|
2816
2819
|
}
|
|
2820
|
+
coordsForChar(pos) {
|
|
2821
|
+
let { i, off } = this.childPos(pos, 1), child = this.children[i];
|
|
2822
|
+
if (!(child instanceof LineView))
|
|
2823
|
+
return null;
|
|
2824
|
+
while (child.children.length) {
|
|
2825
|
+
let { i, off: childOff } = child.childPos(off, 1);
|
|
2826
|
+
for (;; i++) {
|
|
2827
|
+
if (i == child.children.length)
|
|
2828
|
+
return null;
|
|
2829
|
+
if ((child = child.children[i]).length)
|
|
2830
|
+
break;
|
|
2831
|
+
}
|
|
2832
|
+
off = childOff;
|
|
2833
|
+
}
|
|
2834
|
+
if (!(child instanceof TextView))
|
|
2835
|
+
return null;
|
|
2836
|
+
let end = findClusterBreak(child.text, off);
|
|
2837
|
+
if (end == off)
|
|
2838
|
+
return null;
|
|
2839
|
+
let rects = textRange(child.dom, off, end).getClientRects();
|
|
2840
|
+
return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0];
|
|
2841
|
+
}
|
|
2817
2842
|
measureVisibleLineHeights(viewport) {
|
|
2818
2843
|
let result = [], { from, to } = viewport;
|
|
2819
2844
|
let contentWidth = this.view.contentDOM.clientWidth;
|
|
@@ -5685,7 +5710,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5685
5710
|
display: "flex",
|
|
5686
5711
|
height: "100%",
|
|
5687
5712
|
boxSizing: "border-box",
|
|
5688
|
-
|
|
5713
|
+
insetInlineStart: 0,
|
|
5689
5714
|
zIndex: 200
|
|
5690
5715
|
},
|
|
5691
5716
|
"&light .cm-gutters": {
|
|
@@ -7149,6 +7174,17 @@ class EditorView {
|
|
|
7149
7174
|
return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));
|
|
7150
7175
|
}
|
|
7151
7176
|
/**
|
|
7177
|
+
Return the rectangle around a given character. If `pos` does not
|
|
7178
|
+
point in front of a character that is in the viewport and
|
|
7179
|
+
rendered (i.e. not replaced, not a line break), this will return
|
|
7180
|
+
null. For space characters that are a line wrap point, this will
|
|
7181
|
+
return the position before the line break.
|
|
7182
|
+
*/
|
|
7183
|
+
coordsForChar(pos) {
|
|
7184
|
+
this.readMeasured();
|
|
7185
|
+
return this.docView.coordsForChar(pos);
|
|
7186
|
+
}
|
|
7187
|
+
/**
|
|
7152
7188
|
The default width of a character in the editor. May not
|
|
7153
7189
|
accurately reflect the width of all characters (given variable
|
|
7154
7190
|
width fonts or styling of invididual ranges).
|