@codemirror/view 6.39.0-beta.4 → 6.39.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 +14 -0
- package/dist/index.cjs +12 -10
- package/dist/index.js +12 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 6.39.0 (2025-12-08)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Properly handle bidirectional text in `posAtCoords`.
|
|
6
|
+
|
|
7
|
+
Avoid computing a zero character width (leading to divisions by zero) when the editor is hidden and the browser doesn't have a layout for it.
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
The `posAndSideAtCoords` method is an extended version of `posAtCoords` that also tells you which side of the position the coordinates are associated with.
|
|
12
|
+
|
|
13
|
+
Add support for block wrappers, decoration-like things that allow extension code to create DOM nodes around groups of lines.
|
|
14
|
+
|
|
1
15
|
## 6.38.8 (2025-11-17)
|
|
2
16
|
|
|
3
17
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2397,7 +2397,7 @@ class TileBuilder {
|
|
|
2397
2397
|
for (let cur = this.blockWrappers; cur.value && cur.from <= this.pos; cur.next())
|
|
2398
2398
|
if (cur.to >= this.pos) {
|
|
2399
2399
|
let wrap = new OpenWrapper(cur.from, cur.to, cur.value, cur.rank), i = this.wrappers.length;
|
|
2400
|
-
while (i > 0 && this.wrappers[i - 1].rank
|
|
2400
|
+
while (i > 0 && (this.wrappers[i - 1].rank - wrap.rank || this.wrappers[i - 1].to - wrap.to) < 0)
|
|
2401
2401
|
i--;
|
|
2402
2402
|
this.wrappers.splice(i, 0, wrap);
|
|
2403
2403
|
}
|
|
@@ -2653,8 +2653,10 @@ class TileUpdate {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
else {
|
|
2655
2655
|
this.cache.add(tile);
|
|
2656
|
-
if (tile instanceof MarkTile)
|
|
2656
|
+
if (tile instanceof MarkTile) {
|
|
2657
2657
|
activeMarks.unshift(tile.mark);
|
|
2658
|
+
openMarks++;
|
|
2659
|
+
}
|
|
2658
2660
|
}
|
|
2659
2661
|
this.openWidget = false;
|
|
2660
2662
|
},
|
|
@@ -3229,20 +3231,18 @@ class DocView {
|
|
|
3229
3231
|
if (pos > to)
|
|
3230
3232
|
break;
|
|
3231
3233
|
let child = tile.children[i], end = pos + child.length;
|
|
3234
|
+
let childRect = child.dom.getBoundingClientRect(), { height } = childRect;
|
|
3235
|
+
if (measureBounds && !i)
|
|
3236
|
+
spaceAbove += childRect.top - measureBounds.top;
|
|
3232
3237
|
if (child instanceof BlockWrapperTile) {
|
|
3233
3238
|
if (end > from)
|
|
3234
|
-
scan(child, pos,
|
|
3239
|
+
scan(child, pos, childRect);
|
|
3235
3240
|
}
|
|
3236
3241
|
else if (pos >= from) {
|
|
3237
|
-
let childRect = child.dom.getBoundingClientRect(), { height } = childRect;
|
|
3238
|
-
if (measureBounds && !i)
|
|
3239
|
-
spaceAbove += childRect.top - measureBounds.top;
|
|
3240
3242
|
if (spaceAbove > 0)
|
|
3241
3243
|
result.push(-spaceAbove);
|
|
3242
3244
|
result.push(height + spaceAbove);
|
|
3243
3245
|
spaceAbove = 0;
|
|
3244
|
-
if (measureBounds && i == tile.children.length - 1)
|
|
3245
|
-
spaceAbove += measureBounds.bottom - childRect.bottom;
|
|
3246
3246
|
if (isWider) {
|
|
3247
3247
|
let last = child.dom.lastChild;
|
|
3248
3248
|
let rects = last ? clientRectsFor(last) : [];
|
|
@@ -3258,6 +3258,8 @@ class DocView {
|
|
|
3258
3258
|
}
|
|
3259
3259
|
}
|
|
3260
3260
|
}
|
|
3261
|
+
if (measureBounds && i == tile.children.length - 1)
|
|
3262
|
+
spaceAbove += measureBounds.bottom - childRect.bottom;
|
|
3261
3263
|
pos = end + child.breakAfter;
|
|
3262
3264
|
}
|
|
3263
3265
|
};
|
|
@@ -3301,8 +3303,8 @@ class DocView {
|
|
|
3301
3303
|
this.tile.dom.appendChild(dummy);
|
|
3302
3304
|
let rect = clientRectsFor(dummy.firstChild)[0];
|
|
3303
3305
|
lineHeight = dummy.getBoundingClientRect().height;
|
|
3304
|
-
charWidth = rect ? rect.width / 27 : 7;
|
|
3305
|
-
textHeight = rect ? rect.height : lineHeight;
|
|
3306
|
+
charWidth = rect && rect.width ? rect.width / 27 : 7;
|
|
3307
|
+
textHeight = rect && rect.height ? rect.height : lineHeight;
|
|
3306
3308
|
dummy.remove();
|
|
3307
3309
|
});
|
|
3308
3310
|
return { lineHeight, charWidth, textHeight };
|
package/dist/index.js
CHANGED
|
@@ -2393,7 +2393,7 @@ class TileBuilder {
|
|
|
2393
2393
|
for (let cur = this.blockWrappers; cur.value && cur.from <= this.pos; cur.next())
|
|
2394
2394
|
if (cur.to >= this.pos) {
|
|
2395
2395
|
let wrap = new OpenWrapper(cur.from, cur.to, cur.value, cur.rank), i = this.wrappers.length;
|
|
2396
|
-
while (i > 0 && this.wrappers[i - 1].rank
|
|
2396
|
+
while (i > 0 && (this.wrappers[i - 1].rank - wrap.rank || this.wrappers[i - 1].to - wrap.to) < 0)
|
|
2397
2397
|
i--;
|
|
2398
2398
|
this.wrappers.splice(i, 0, wrap);
|
|
2399
2399
|
}
|
|
@@ -2649,8 +2649,10 @@ class TileUpdate {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
else {
|
|
2651
2651
|
this.cache.add(tile);
|
|
2652
|
-
if (tile instanceof MarkTile)
|
|
2652
|
+
if (tile instanceof MarkTile) {
|
|
2653
2653
|
activeMarks.unshift(tile.mark);
|
|
2654
|
+
openMarks++;
|
|
2655
|
+
}
|
|
2654
2656
|
}
|
|
2655
2657
|
this.openWidget = false;
|
|
2656
2658
|
},
|
|
@@ -3225,20 +3227,18 @@ class DocView {
|
|
|
3225
3227
|
if (pos > to)
|
|
3226
3228
|
break;
|
|
3227
3229
|
let child = tile.children[i], end = pos + child.length;
|
|
3230
|
+
let childRect = child.dom.getBoundingClientRect(), { height } = childRect;
|
|
3231
|
+
if (measureBounds && !i)
|
|
3232
|
+
spaceAbove += childRect.top - measureBounds.top;
|
|
3228
3233
|
if (child instanceof BlockWrapperTile) {
|
|
3229
3234
|
if (end > from)
|
|
3230
|
-
scan(child, pos,
|
|
3235
|
+
scan(child, pos, childRect);
|
|
3231
3236
|
}
|
|
3232
3237
|
else if (pos >= from) {
|
|
3233
|
-
let childRect = child.dom.getBoundingClientRect(), { height } = childRect;
|
|
3234
|
-
if (measureBounds && !i)
|
|
3235
|
-
spaceAbove += childRect.top - measureBounds.top;
|
|
3236
3238
|
if (spaceAbove > 0)
|
|
3237
3239
|
result.push(-spaceAbove);
|
|
3238
3240
|
result.push(height + spaceAbove);
|
|
3239
3241
|
spaceAbove = 0;
|
|
3240
|
-
if (measureBounds && i == tile.children.length - 1)
|
|
3241
|
-
spaceAbove += measureBounds.bottom - childRect.bottom;
|
|
3242
3242
|
if (isWider) {
|
|
3243
3243
|
let last = child.dom.lastChild;
|
|
3244
3244
|
let rects = last ? clientRectsFor(last) : [];
|
|
@@ -3254,6 +3254,8 @@ class DocView {
|
|
|
3254
3254
|
}
|
|
3255
3255
|
}
|
|
3256
3256
|
}
|
|
3257
|
+
if (measureBounds && i == tile.children.length - 1)
|
|
3258
|
+
spaceAbove += measureBounds.bottom - childRect.bottom;
|
|
3257
3259
|
pos = end + child.breakAfter;
|
|
3258
3260
|
}
|
|
3259
3261
|
};
|
|
@@ -3297,8 +3299,8 @@ class DocView {
|
|
|
3297
3299
|
this.tile.dom.appendChild(dummy);
|
|
3298
3300
|
let rect = clientRectsFor(dummy.firstChild)[0];
|
|
3299
3301
|
lineHeight = dummy.getBoundingClientRect().height;
|
|
3300
|
-
charWidth = rect ? rect.width / 27 : 7;
|
|
3301
|
-
textHeight = rect ? rect.height : lineHeight;
|
|
3302
|
+
charWidth = rect && rect.width ? rect.width / 27 : 7;
|
|
3303
|
+
textHeight = rect && rect.height ? rect.height : lineHeight;
|
|
3302
3304
|
dummy.remove();
|
|
3303
3305
|
});
|
|
3304
3306
|
return { lineHeight, charWidth, textHeight };
|