@codemirror/view 6.35.0 → 6.35.2
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 +19 -9
- package/dist/index.js +19 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 6.35.2 (2024-12-07)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue on Chrome where typing at the end of the document would insert a character after the cursor.
|
|
6
|
+
|
|
7
|
+
## 6.35.1 (2024-12-06)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Work around another crash caused by incorrect composition positions reported by `EditContext`.
|
|
12
|
+
|
|
13
|
+
Stop disabling custom cursors on Safari version 11.4 and up, which support `caret-color`.
|
|
14
|
+
|
|
15
|
+
Fix an issue where a tooltip with wrapped content could, in some circumstances, fail to find a stable position due to a cyclic dependency between its width and its position.
|
|
16
|
+
|
|
1
17
|
## 6.35.0 (2024-11-21)
|
|
2
18
|
|
|
3
19
|
### New features
|
package/dist/index.cjs
CHANGED
|
@@ -7180,8 +7180,10 @@ class EditContextManager {
|
|
|
7180
7180
|
if (change.from == change.to && !change.insert.length)
|
|
7181
7181
|
return;
|
|
7182
7182
|
this.pendingContextChange = change;
|
|
7183
|
-
if (!view.state.readOnly)
|
|
7184
|
-
|
|
7183
|
+
if (!view.state.readOnly) {
|
|
7184
|
+
let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
|
|
7185
|
+
applyDOMChangeInner(view, change, state.EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
|
|
7186
|
+
}
|
|
7185
7187
|
// If the transaction didn't flush our change, revert it so
|
|
7186
7188
|
// that the context is in sync with the editor state again.
|
|
7187
7189
|
if (this.pendingContextChange) {
|
|
@@ -7204,9 +7206,11 @@ class EditContextManager {
|
|
|
7204
7206
|
for (let format of e.getTextFormats()) {
|
|
7205
7207
|
let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
|
|
7206
7208
|
if (lineStyle != "None" && thickness != "None") {
|
|
7207
|
-
let
|
|
7208
|
-
|
|
7209
|
-
|
|
7209
|
+
let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
|
|
7210
|
+
if (from < to) {
|
|
7211
|
+
let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
|
|
7212
|
+
deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
|
|
7213
|
+
}
|
|
7210
7214
|
}
|
|
7211
7215
|
}
|
|
7212
7216
|
view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
|
|
@@ -7318,7 +7322,8 @@ class EditContextManager {
|
|
|
7318
7322
|
this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
|
|
7319
7323
|
this.to - this.from > 10000 /* CxVp.Margin */ * 3);
|
|
7320
7324
|
}
|
|
7321
|
-
toEditorPos(contextPos) {
|
|
7325
|
+
toEditorPos(contextPos, clipLen = this.to - this.from) {
|
|
7326
|
+
contextPos = Math.min(contextPos, clipLen);
|
|
7322
7327
|
let c = this.composing;
|
|
7323
7328
|
return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
|
|
7324
7329
|
}
|
|
@@ -8983,7 +8988,7 @@ function layer(config) {
|
|
|
8983
8988
|
];
|
|
8984
8989
|
}
|
|
8985
8990
|
|
|
8986
|
-
const CanHidePrimary = !browser.ios
|
|
8991
|
+
const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
|
|
8987
8992
|
const selectionConfig = state.Facet.define({
|
|
8988
8993
|
combine(configs) {
|
|
8989
8994
|
return state.combineConfig(configs, {
|
|
@@ -9990,11 +9995,11 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9990
9995
|
top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
|
|
9991
9996
|
if (this.position == "absolute") {
|
|
9992
9997
|
dom.style.top = (top - measured.parent.top) / scaleY + "px";
|
|
9993
|
-
dom
|
|
9998
|
+
setLeftStyle(dom, (left - measured.parent.left) / scaleX);
|
|
9994
9999
|
}
|
|
9995
10000
|
else {
|
|
9996
10001
|
dom.style.top = top / scaleY + "px";
|
|
9997
|
-
dom
|
|
10002
|
+
setLeftStyle(dom, left / scaleX);
|
|
9998
10003
|
}
|
|
9999
10004
|
if (arrow) {
|
|
10000
10005
|
let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
|
|
@@ -10025,6 +10030,11 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
10025
10030
|
scroll() { this.maybeMeasure(); }
|
|
10026
10031
|
}
|
|
10027
10032
|
});
|
|
10033
|
+
function setLeftStyle(elt, value) {
|
|
10034
|
+
let current = parseInt(elt.style.left, 10);
|
|
10035
|
+
if (isNaN(current) || Math.abs(value - current) > 1)
|
|
10036
|
+
elt.style.left = value + "px";
|
|
10037
|
+
}
|
|
10028
10038
|
const baseTheme = EditorView.baseTheme({
|
|
10029
10039
|
".cm-tooltip": {
|
|
10030
10040
|
zIndex: 500,
|
package/dist/index.js
CHANGED
|
@@ -7175,8 +7175,10 @@ class EditContextManager {
|
|
|
7175
7175
|
if (change.from == change.to && !change.insert.length)
|
|
7176
7176
|
return;
|
|
7177
7177
|
this.pendingContextChange = change;
|
|
7178
|
-
if (!view.state.readOnly)
|
|
7179
|
-
|
|
7178
|
+
if (!view.state.readOnly) {
|
|
7179
|
+
let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
|
|
7180
|
+
applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
|
|
7181
|
+
}
|
|
7180
7182
|
// If the transaction didn't flush our change, revert it so
|
|
7181
7183
|
// that the context is in sync with the editor state again.
|
|
7182
7184
|
if (this.pendingContextChange) {
|
|
@@ -7199,9 +7201,11 @@ class EditContextManager {
|
|
|
7199
7201
|
for (let format of e.getTextFormats()) {
|
|
7200
7202
|
let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
|
|
7201
7203
|
if (lineStyle != "None" && thickness != "None") {
|
|
7202
|
-
let
|
|
7203
|
-
|
|
7204
|
-
|
|
7204
|
+
let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
|
|
7205
|
+
if (from < to) {
|
|
7206
|
+
let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
|
|
7207
|
+
deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
|
|
7208
|
+
}
|
|
7205
7209
|
}
|
|
7206
7210
|
}
|
|
7207
7211
|
view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
|
|
@@ -7313,7 +7317,8 @@ class EditContextManager {
|
|
|
7313
7317
|
this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
|
|
7314
7318
|
this.to - this.from > 10000 /* CxVp.Margin */ * 3);
|
|
7315
7319
|
}
|
|
7316
|
-
toEditorPos(contextPos) {
|
|
7320
|
+
toEditorPos(contextPos, clipLen = this.to - this.from) {
|
|
7321
|
+
contextPos = Math.min(contextPos, clipLen);
|
|
7317
7322
|
let c = this.composing;
|
|
7318
7323
|
return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
|
|
7319
7324
|
}
|
|
@@ -8978,7 +8983,7 @@ function layer(config) {
|
|
|
8978
8983
|
];
|
|
8979
8984
|
}
|
|
8980
8985
|
|
|
8981
|
-
const CanHidePrimary = !browser.ios
|
|
8986
|
+
const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
|
|
8982
8987
|
const selectionConfig = /*@__PURE__*/Facet.define({
|
|
8983
8988
|
combine(configs) {
|
|
8984
8989
|
return combineConfig(configs, {
|
|
@@ -9985,11 +9990,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9985
9990
|
top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
|
|
9986
9991
|
if (this.position == "absolute") {
|
|
9987
9992
|
dom.style.top = (top - measured.parent.top) / scaleY + "px";
|
|
9988
|
-
dom
|
|
9993
|
+
setLeftStyle(dom, (left - measured.parent.left) / scaleX);
|
|
9989
9994
|
}
|
|
9990
9995
|
else {
|
|
9991
9996
|
dom.style.top = top / scaleY + "px";
|
|
9992
|
-
dom
|
|
9997
|
+
setLeftStyle(dom, left / scaleX);
|
|
9993
9998
|
}
|
|
9994
9999
|
if (arrow) {
|
|
9995
10000
|
let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
|
|
@@ -10020,6 +10025,11 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
10020
10025
|
scroll() { this.maybeMeasure(); }
|
|
10021
10026
|
}
|
|
10022
10027
|
});
|
|
10028
|
+
function setLeftStyle(elt, value) {
|
|
10029
|
+
let current = parseInt(elt.style.left, 10);
|
|
10030
|
+
if (isNaN(current) || Math.abs(value - current) > 1)
|
|
10031
|
+
elt.style.left = value + "px";
|
|
10032
|
+
}
|
|
10023
10033
|
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
10024
10034
|
".cm-tooltip": {
|
|
10025
10035
|
zIndex: 500,
|