@codemirror/view 6.36.3 → 6.36.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 +14 -0
- package/dist/index.cjs +21 -14
- package/dist/index.js +21 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 6.36.5 (2025-03-29)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where some browsers wouldn't enable context menu paste when clicking on placeholder text.
|
|
6
|
+
|
|
7
|
+
Fix an issue where cursor height would unnecessarily be based on a placeholder node's dimensions, and thus be off from the text height.
|
|
8
|
+
|
|
9
|
+
## 6.36.4 (2025-03-03)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Fix an issue where scrolling down to a range higher than the viewport could in some situations fail to scroll to the proper position.
|
|
14
|
+
|
|
1
15
|
## 6.36.3 (2025-02-18)
|
|
2
16
|
|
|
3
17
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -133,14 +133,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
133
133
|
let moveX = 0, moveY = 0;
|
|
134
134
|
if (y == "nearest") {
|
|
135
135
|
if (rect.top < bounding.top) {
|
|
136
|
-
moveY =
|
|
136
|
+
moveY = rect.top - (bounding.top + yMargin);
|
|
137
137
|
if (side > 0 && rect.bottom > bounding.bottom + moveY)
|
|
138
|
-
moveY = rect.bottom - bounding.bottom +
|
|
138
|
+
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
139
139
|
}
|
|
140
140
|
else if (rect.bottom > bounding.bottom) {
|
|
141
141
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
142
142
|
if (side < 0 && (rect.top - moveY) < bounding.top)
|
|
143
|
-
moveY =
|
|
143
|
+
moveY = rect.top - (bounding.top + yMargin);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
@@ -152,14 +152,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
152
152
|
}
|
|
153
153
|
if (x == "nearest") {
|
|
154
154
|
if (rect.left < bounding.left) {
|
|
155
|
-
moveX =
|
|
155
|
+
moveX = rect.left - (bounding.left + xMargin);
|
|
156
156
|
if (side > 0 && rect.right > bounding.right + moveX)
|
|
157
|
-
moveX = rect.right - bounding.right +
|
|
157
|
+
moveX = rect.right - bounding.right + xMargin;
|
|
158
158
|
}
|
|
159
159
|
else if (rect.right > bounding.right) {
|
|
160
160
|
moveX = rect.right - bounding.right + xMargin;
|
|
161
161
|
if (side < 0 && rect.left < bounding.left + moveX)
|
|
162
|
-
moveX =
|
|
162
|
+
moveX = rect.left - (bounding.left + xMargin);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
@@ -194,6 +194,10 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
194
194
|
}
|
|
195
195
|
if (top)
|
|
196
196
|
break;
|
|
197
|
+
if (rect.top < bounding.top || rect.bottom > bounding.bottom ||
|
|
198
|
+
rect.left < bounding.left || rect.right > bounding.right)
|
|
199
|
+
rect = { left: Math.max(rect.left, bounding.left), right: Math.min(rect.right, bounding.right),
|
|
200
|
+
top: Math.max(rect.top, bounding.top), bottom: Math.min(rect.bottom, bounding.bottom) };
|
|
197
201
|
cur = cur.assignedSlot || cur.parentNode;
|
|
198
202
|
}
|
|
199
203
|
else if (cur.nodeType == 11) { // A shadow root
|
|
@@ -1068,7 +1072,7 @@ function coordsInChildren(view, pos, side) {
|
|
|
1068
1072
|
if (child.children.length) {
|
|
1069
1073
|
scan(child, pos - off);
|
|
1070
1074
|
}
|
|
1071
|
-
else if ((!after || after.isHidden && side > 0) &&
|
|
1075
|
+
else if ((!after || after.isHidden && (side > 0 || onSameLine(after, child))) &&
|
|
1072
1076
|
(end > pos || off == end && child.getSide() > 0)) {
|
|
1073
1077
|
after = child;
|
|
1074
1078
|
afterPos = pos - off;
|
|
@@ -1094,6 +1098,10 @@ function fallbackRect(view) {
|
|
|
1094
1098
|
let rects = clientRectsFor(last);
|
|
1095
1099
|
return rects[rects.length - 1] || null;
|
|
1096
1100
|
}
|
|
1101
|
+
function onSameLine(a, b) {
|
|
1102
|
+
let posA = a.coordsAt(0, 1), posB = b.coordsAt(0, 1);
|
|
1103
|
+
return posA && posB && posB.top < posA.bottom;
|
|
1104
|
+
}
|
|
1097
1105
|
|
|
1098
1106
|
function combineAttrs(source, target) {
|
|
1099
1107
|
for (let name in source) {
|
|
@@ -6615,6 +6623,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
|
6615
6623
|
color: "#888",
|
|
6616
6624
|
display: "inline-block",
|
|
6617
6625
|
verticalAlign: "top",
|
|
6626
|
+
userSelect: "none"
|
|
6618
6627
|
},
|
|
6619
6628
|
".cm-highlightSpace": {
|
|
6620
6629
|
backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
|
|
@@ -9029,7 +9038,6 @@ function layer(config) {
|
|
|
9029
9038
|
];
|
|
9030
9039
|
}
|
|
9031
9040
|
|
|
9032
|
-
const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
|
|
9033
9041
|
const selectionConfig = state.Facet.define({
|
|
9034
9042
|
combine(configs) {
|
|
9035
9043
|
return state.combineConfig(configs, {
|
|
@@ -9086,7 +9094,7 @@ const cursorLayer = layer({
|
|
|
9086
9094
|
let cursors = [];
|
|
9087
9095
|
for (let r of state$1.selection.ranges) {
|
|
9088
9096
|
let prim = r == state$1.selection.main;
|
|
9089
|
-
if (r.empty
|
|
9097
|
+
if (r.empty || conf.drawRangeCursor) {
|
|
9090
9098
|
let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
|
|
9091
9099
|
let cursor = r.empty ? r : state.EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
|
|
9092
9100
|
for (let piece of RectangleMarker.forRange(view, className, cursor))
|
|
@@ -9122,11 +9130,13 @@ const selectionLayer = layer({
|
|
|
9122
9130
|
},
|
|
9123
9131
|
class: "cm-selectionLayer"
|
|
9124
9132
|
});
|
|
9125
|
-
const
|
|
9133
|
+
const hideNativeSelection = state.Prec.highest(EditorView.theme({
|
|
9126
9134
|
".cm-line": {
|
|
9127
9135
|
"& ::selection, &::selection": { backgroundColor: "transparent !important" },
|
|
9136
|
+
caretColor: "transparent !important"
|
|
9128
9137
|
},
|
|
9129
9138
|
".cm-content": {
|
|
9139
|
+
caretColor: "transparent !important",
|
|
9130
9140
|
"& :focus": {
|
|
9131
9141
|
caretColor: "initial !important",
|
|
9132
9142
|
"&::selection, & ::selection": {
|
|
@@ -9134,10 +9144,7 @@ const themeSpec = {
|
|
|
9134
9144
|
}
|
|
9135
9145
|
}
|
|
9136
9146
|
}
|
|
9137
|
-
};
|
|
9138
|
-
if (CanHidePrimary)
|
|
9139
|
-
themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
|
|
9140
|
-
const hideNativeSelection = state.Prec.highest(EditorView.theme(themeSpec));
|
|
9147
|
+
}));
|
|
9141
9148
|
|
|
9142
9149
|
const setDropCursorPos = state.StateEffect.define({
|
|
9143
9150
|
map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
|
package/dist/index.js
CHANGED
|
@@ -131,14 +131,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
131
131
|
let moveX = 0, moveY = 0;
|
|
132
132
|
if (y == "nearest") {
|
|
133
133
|
if (rect.top < bounding.top) {
|
|
134
|
-
moveY =
|
|
134
|
+
moveY = rect.top - (bounding.top + yMargin);
|
|
135
135
|
if (side > 0 && rect.bottom > bounding.bottom + moveY)
|
|
136
|
-
moveY = rect.bottom - bounding.bottom +
|
|
136
|
+
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
137
137
|
}
|
|
138
138
|
else if (rect.bottom > bounding.bottom) {
|
|
139
139
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
140
140
|
if (side < 0 && (rect.top - moveY) < bounding.top)
|
|
141
|
-
moveY =
|
|
141
|
+
moveY = rect.top - (bounding.top + yMargin);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
@@ -150,14 +150,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
150
150
|
}
|
|
151
151
|
if (x == "nearest") {
|
|
152
152
|
if (rect.left < bounding.left) {
|
|
153
|
-
moveX =
|
|
153
|
+
moveX = rect.left - (bounding.left + xMargin);
|
|
154
154
|
if (side > 0 && rect.right > bounding.right + moveX)
|
|
155
|
-
moveX = rect.right - bounding.right +
|
|
155
|
+
moveX = rect.right - bounding.right + xMargin;
|
|
156
156
|
}
|
|
157
157
|
else if (rect.right > bounding.right) {
|
|
158
158
|
moveX = rect.right - bounding.right + xMargin;
|
|
159
159
|
if (side < 0 && rect.left < bounding.left + moveX)
|
|
160
|
-
moveX =
|
|
160
|
+
moveX = rect.left - (bounding.left + xMargin);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
@@ -192,6 +192,10 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
192
192
|
}
|
|
193
193
|
if (top)
|
|
194
194
|
break;
|
|
195
|
+
if (rect.top < bounding.top || rect.bottom > bounding.bottom ||
|
|
196
|
+
rect.left < bounding.left || rect.right > bounding.right)
|
|
197
|
+
rect = { left: Math.max(rect.left, bounding.left), right: Math.min(rect.right, bounding.right),
|
|
198
|
+
top: Math.max(rect.top, bounding.top), bottom: Math.min(rect.bottom, bounding.bottom) };
|
|
195
199
|
cur = cur.assignedSlot || cur.parentNode;
|
|
196
200
|
}
|
|
197
201
|
else if (cur.nodeType == 11) { // A shadow root
|
|
@@ -1066,7 +1070,7 @@ function coordsInChildren(view, pos, side) {
|
|
|
1066
1070
|
if (child.children.length) {
|
|
1067
1071
|
scan(child, pos - off);
|
|
1068
1072
|
}
|
|
1069
|
-
else if ((!after || after.isHidden && side > 0) &&
|
|
1073
|
+
else if ((!after || after.isHidden && (side > 0 || onSameLine(after, child))) &&
|
|
1070
1074
|
(end > pos || off == end && child.getSide() > 0)) {
|
|
1071
1075
|
after = child;
|
|
1072
1076
|
afterPos = pos - off;
|
|
@@ -1092,6 +1096,10 @@ function fallbackRect(view) {
|
|
|
1092
1096
|
let rects = clientRectsFor(last);
|
|
1093
1097
|
return rects[rects.length - 1] || null;
|
|
1094
1098
|
}
|
|
1099
|
+
function onSameLine(a, b) {
|
|
1100
|
+
let posA = a.coordsAt(0, 1), posB = b.coordsAt(0, 1);
|
|
1101
|
+
return posA && posB && posB.top < posA.bottom;
|
|
1102
|
+
}
|
|
1095
1103
|
|
|
1096
1104
|
function combineAttrs(source, target) {
|
|
1097
1105
|
for (let name in source) {
|
|
@@ -6610,6 +6618,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
6610
6618
|
color: "#888",
|
|
6611
6619
|
display: "inline-block",
|
|
6612
6620
|
verticalAlign: "top",
|
|
6621
|
+
userSelect: "none"
|
|
6613
6622
|
},
|
|
6614
6623
|
".cm-highlightSpace": {
|
|
6615
6624
|
backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
|
|
@@ -9024,7 +9033,6 @@ function layer(config) {
|
|
|
9024
9033
|
];
|
|
9025
9034
|
}
|
|
9026
9035
|
|
|
9027
|
-
const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
|
|
9028
9036
|
const selectionConfig = /*@__PURE__*/Facet.define({
|
|
9029
9037
|
combine(configs) {
|
|
9030
9038
|
return combineConfig(configs, {
|
|
@@ -9081,7 +9089,7 @@ const cursorLayer = /*@__PURE__*/layer({
|
|
|
9081
9089
|
let cursors = [];
|
|
9082
9090
|
for (let r of state.selection.ranges) {
|
|
9083
9091
|
let prim = r == state.selection.main;
|
|
9084
|
-
if (r.empty
|
|
9092
|
+
if (r.empty || conf.drawRangeCursor) {
|
|
9085
9093
|
let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
|
|
9086
9094
|
let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
|
|
9087
9095
|
for (let piece of RectangleMarker.forRange(view, className, cursor))
|
|
@@ -9117,11 +9125,13 @@ const selectionLayer = /*@__PURE__*/layer({
|
|
|
9117
9125
|
},
|
|
9118
9126
|
class: "cm-selectionLayer"
|
|
9119
9127
|
});
|
|
9120
|
-
const
|
|
9128
|
+
const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme({
|
|
9121
9129
|
".cm-line": {
|
|
9122
9130
|
"& ::selection, &::selection": { backgroundColor: "transparent !important" },
|
|
9131
|
+
caretColor: "transparent !important"
|
|
9123
9132
|
},
|
|
9124
9133
|
".cm-content": {
|
|
9134
|
+
caretColor: "transparent !important",
|
|
9125
9135
|
"& :focus": {
|
|
9126
9136
|
caretColor: "initial !important",
|
|
9127
9137
|
"&::selection, & ::selection": {
|
|
@@ -9129,10 +9139,7 @@ const themeSpec = {
|
|
|
9129
9139
|
}
|
|
9130
9140
|
}
|
|
9131
9141
|
}
|
|
9132
|
-
};
|
|
9133
|
-
if (CanHidePrimary)
|
|
9134
|
-
themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
|
|
9135
|
-
const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
|
|
9142
|
+
}));
|
|
9136
9143
|
|
|
9137
9144
|
const setDropCursorPos = /*@__PURE__*/StateEffect.define({
|
|
9138
9145
|
map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
|