@codemirror/view 6.40.0 → 6.41.1
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 +18 -0
- package/README.md +2 -2
- package/dist/index.cjs +49 -15
- package/dist/index.d.cts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.js +49 -15
- package/package.json +2 -2
- package/.github/workflows/dispatch.yml +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.41.1 (2026-04-18)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where, on some platforms, clicking after the end of a wrapped line would put the cursor in the wrong position.
|
|
6
|
+
|
|
7
|
+
## 6.41.0 (2026-04-01)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix an issue where `EditorView.posAtCoords` could incorrectly return a position near a higher element on the line, in mixed-font-size lines.
|
|
12
|
+
|
|
13
|
+
Expand the workaround for the Webkit bug that causes nonexistent selections to stay visible to be active on non-Safari Webkit browsers.
|
|
14
|
+
|
|
15
|
+
### New features
|
|
16
|
+
|
|
17
|
+
The new `EditorView.cursorScrollMargin` facet can now be used to configure the extra space used when scrolling the cursor into view.
|
|
18
|
+
|
|
1
19
|
## 6.40.0 (2026-03-12)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @codemirror/view [](https://www.npmjs.org/package/@codemirror/view)
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#view) | [**ISSUES**](https://
|
|
3
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#view) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/view/src/branch/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This package implements the DOM view component for the
|
|
6
6
|
[CodeMirror](https://codemirror.net/) code editor.
|
|
@@ -10,7 +10,7 @@ number of [examples](https://codemirror.net/examples/) and the
|
|
|
10
10
|
[documentation](https://codemirror.net/docs/).
|
|
11
11
|
|
|
12
12
|
This code is released under an
|
|
13
|
-
[MIT license](https://
|
|
13
|
+
[MIT license](https://code.haverbeke.berlin/codemirror/view/tree/main/LICENSE).
|
|
14
14
|
|
|
15
15
|
We aim to be an inclusive, welcoming community. To make that explicit,
|
|
16
16
|
we have a [code of
|
package/dist/index.cjs
CHANGED
|
@@ -548,12 +548,12 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
548
548
|
}
|
|
549
549
|
let moveX = 0, moveY = 0;
|
|
550
550
|
if (y == "nearest") {
|
|
551
|
-
if (rect.top < bounding.top) {
|
|
551
|
+
if (rect.top < bounding.top + yMargin) {
|
|
552
552
|
moveY = rect.top - (bounding.top + yMargin);
|
|
553
553
|
if (side > 0 && rect.bottom > bounding.bottom + moveY)
|
|
554
554
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
555
555
|
}
|
|
556
|
-
else if (rect.bottom > bounding.bottom) {
|
|
556
|
+
else if (rect.bottom > bounding.bottom - yMargin) {
|
|
557
557
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
558
558
|
if (side < 0 && (rect.top - moveY) < bounding.top)
|
|
559
559
|
moveY = rect.top - (bounding.top + yMargin);
|
|
@@ -567,12 +567,12 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
567
567
|
moveY = targetTop - bounding.top;
|
|
568
568
|
}
|
|
569
569
|
if (x == "nearest") {
|
|
570
|
-
if (rect.left < bounding.left) {
|
|
570
|
+
if (rect.left < bounding.left + xMargin) {
|
|
571
571
|
moveX = rect.left - (bounding.left + xMargin);
|
|
572
572
|
if (side > 0 && rect.right > bounding.right + moveX)
|
|
573
573
|
moveX = rect.right - bounding.right + xMargin;
|
|
574
574
|
}
|
|
575
|
-
else if (rect.right > bounding.right) {
|
|
575
|
+
else if (rect.right > bounding.right - xMargin) {
|
|
576
576
|
moveX = rect.right - bounding.right + xMargin;
|
|
577
577
|
if (side < 0 && rect.left < bounding.left + moveX)
|
|
578
578
|
moveX = rect.left - (bounding.left + xMargin);
|
|
@@ -1313,7 +1313,7 @@ const nativeSelectionHidden = state.Facet.define({
|
|
|
1313
1313
|
});
|
|
1314
1314
|
const scrollHandler = state.Facet.define();
|
|
1315
1315
|
class ScrollTarget {
|
|
1316
|
-
constructor(range, y
|
|
1316
|
+
constructor(range, y, x, yMargin, xMargin,
|
|
1317
1317
|
// This data structure is abused to also store precise scroll
|
|
1318
1318
|
// snapshots, instead of a `scrollIntoView` request. When this
|
|
1319
1319
|
// flag is `true`, `range` points at a position in the reference
|
|
@@ -3910,6 +3910,19 @@ class InlineCoordsScan {
|
|
|
3910
3910
|
this.y = (side.top + side.bottom) / 2;
|
|
3911
3911
|
return this.scan(positions, getRects);
|
|
3912
3912
|
}
|
|
3913
|
+
// Handle the case where closest matched a higher element on the
|
|
3914
|
+
// same line as an element below/above the coords
|
|
3915
|
+
if (closestDx) {
|
|
3916
|
+
let { top, bottom } = closestRect;
|
|
3917
|
+
if (above && above.bottom > (top + top + bottom) / 3) {
|
|
3918
|
+
this.y = above.bottom - 1;
|
|
3919
|
+
return this.scan(positions, getRects);
|
|
3920
|
+
}
|
|
3921
|
+
if (below && below.top < (top + bottom + bottom) / 3) {
|
|
3922
|
+
this.y = below.top + 1;
|
|
3923
|
+
return this.scan(positions, getRects);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3913
3926
|
let ltr = (bidi ? this.dirAt(positions[closestI], 1) : this.baseDir) == exports.Direction.LTR;
|
|
3914
3927
|
return {
|
|
3915
3928
|
i: closestI,
|
|
@@ -5276,8 +5289,8 @@ handlers.beforeinput = (view, event) => {
|
|
|
5276
5289
|
const appliedFirefoxHack = new Set;
|
|
5277
5290
|
// In Firefox, when cut/copy handlers are added to the document, that
|
|
5278
5291
|
// somehow avoids a bug where those events aren't fired when the
|
|
5279
|
-
// selection is empty. See
|
|
5280
|
-
//
|
|
5292
|
+
// selection is empty. See issue #1082 and
|
|
5293
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=995961
|
|
5281
5294
|
function firefoxCopyCutHack(doc) {
|
|
5282
5295
|
if (!appliedFirefoxHack.has(doc)) {
|
|
5283
5296
|
appliedFirefoxHack.add(doc);
|
|
@@ -6764,7 +6777,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
|
6764
6777
|
flexShrink: 0,
|
|
6765
6778
|
display: "block",
|
|
6766
6779
|
whiteSpace: "pre",
|
|
6767
|
-
wordWrap: "normal", //
|
|
6780
|
+
wordWrap: "normal", // Issue #456
|
|
6768
6781
|
boxSizing: "border-box",
|
|
6769
6782
|
minHeight: "100%",
|
|
6770
6783
|
padding: "4px 0",
|
|
@@ -7183,7 +7196,7 @@ class DOMObserver {
|
|
|
7183
7196
|
readSelectionRange() {
|
|
7184
7197
|
let { view } = this;
|
|
7185
7198
|
// The Selection object is broken in shadow roots in Safari. See
|
|
7186
|
-
//
|
|
7199
|
+
// issue #414
|
|
7187
7200
|
let selection = getSelection(view.root);
|
|
7188
7201
|
if (!selection)
|
|
7189
7202
|
return false;
|
|
@@ -7927,7 +7940,8 @@ class EditorView {
|
|
|
7927
7940
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
7928
7941
|
if (tr.scrollIntoView) {
|
|
7929
7942
|
let { main } = tr.state.selection;
|
|
7930
|
-
|
|
7943
|
+
let { x, y } = this.state.facet(EditorView.cursorScrollMargin);
|
|
7944
|
+
scrollTarget = new ScrollTarget(main.empty ? main : state.EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1), "nearest", "nearest", y, x);
|
|
7931
7945
|
}
|
|
7932
7946
|
for (let e of tr.effects)
|
|
7933
7947
|
if (e.is(scrollIntoView))
|
|
@@ -8584,7 +8598,8 @@ class EditorView {
|
|
|
8584
8598
|
cause it to scroll the given position or range into view.
|
|
8585
8599
|
*/
|
|
8586
8600
|
static scrollIntoView(pos, options = {}) {
|
|
8587
|
-
|
|
8601
|
+
var _a, _b, _c, _d;
|
|
8602
|
+
return scrollIntoView.of(new ScrollTarget(typeof pos == "number" ? state.EditorSelection.cursor(pos) : pos, (_a = options.y) !== null && _a !== void 0 ? _a : "nearest", (_b = options.x) !== null && _b !== void 0 ? _b : "nearest", (_c = options.yMargin) !== null && _c !== void 0 ? _c : 5, (_d = options.xMargin) !== null && _d !== void 0 ? _d : 5));
|
|
8588
8603
|
}
|
|
8589
8604
|
/**
|
|
8590
8605
|
Return an effect that resets the editor to its current (at the
|
|
@@ -8650,7 +8665,7 @@ class EditorView {
|
|
|
8650
8665
|
}
|
|
8651
8666
|
/**
|
|
8652
8667
|
Create a theme extension. The first argument can be a
|
|
8653
|
-
[`style-mod`](https://
|
|
8668
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
|
|
8654
8669
|
style spec providing the styles for the theme. These will be
|
|
8655
8670
|
prefixed with a generated class for the style.
|
|
8656
8671
|
|
|
@@ -8696,7 +8711,7 @@ class EditorView {
|
|
|
8696
8711
|
}
|
|
8697
8712
|
/**
|
|
8698
8713
|
Facet to add a [style
|
|
8699
|
-
module](https://
|
|
8714
|
+
module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
|
|
8700
8715
|
an editor view. The view will ensure that the module is
|
|
8701
8716
|
mounted in its [document
|
|
8702
8717
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
@@ -8843,11 +8858,30 @@ supported.)
|
|
|
8843
8858
|
*/
|
|
8844
8859
|
EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
|
|
8845
8860
|
/**
|
|
8861
|
+
Can be used to specify the distance that scrolling cursor into
|
|
8862
|
+
view keeps it away from the sides of the editor, either as a
|
|
8863
|
+
single pixel number or two different values for the different
|
|
8864
|
+
axes. Defaults to 5 pixels on both axes.
|
|
8865
|
+
*/
|
|
8866
|
+
EditorView.cursorScrollMargin = state.Facet.define({
|
|
8867
|
+
combine: inputs => {
|
|
8868
|
+
let x = 5, y = 5;
|
|
8869
|
+
for (let i of inputs) {
|
|
8870
|
+
if (typeof i == "number")
|
|
8871
|
+
x = y = i;
|
|
8872
|
+
else
|
|
8873
|
+
({ x, y } = i);
|
|
8874
|
+
}
|
|
8875
|
+
return { x, y };
|
|
8876
|
+
}
|
|
8877
|
+
});
|
|
8878
|
+
/**
|
|
8846
8879
|
Facet that allows extensions to provide additional scroll
|
|
8847
8880
|
margins (space around the sides of the scrolling element that
|
|
8848
8881
|
should be considered invisible). This can be useful when the
|
|
8849
8882
|
plugin introduces elements that cover part of that element (for
|
|
8850
|
-
example a horizontally fixed gutter).
|
|
8883
|
+
example a horizontally fixed gutter). Not to be confused with
|
|
8884
|
+
[`cursorScrollMargin`](https://codemirror.net/6/docs/ref/#view.EditorView^cursorScrollMargin).
|
|
8851
8885
|
*/
|
|
8852
8886
|
EditorView.scrollMargins = scrollMargins;
|
|
8853
8887
|
/**
|
|
@@ -9383,7 +9417,7 @@ class LayerView {
|
|
|
9383
9417
|
old = next;
|
|
9384
9418
|
}
|
|
9385
9419
|
this.drawn = markers;
|
|
9386
|
-
if (browser.
|
|
9420
|
+
if (browser.webkit) // Issue #1600, 1627, 1686
|
|
9387
9421
|
this.dom.style.display = this.dom.firstChild ? "" : "none";
|
|
9388
9422
|
}
|
|
9389
9423
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -404,7 +404,7 @@ declare class ScrollTarget {
|
|
|
404
404
|
readonly yMargin: number;
|
|
405
405
|
readonly xMargin: number;
|
|
406
406
|
readonly isSnapshot: boolean;
|
|
407
|
-
constructor(range: SelectionRange, y
|
|
407
|
+
constructor(range: SelectionRange, y: ScrollStrategy, x: ScrollStrategy, yMargin: number, xMargin: number, isSnapshot?: boolean);
|
|
408
408
|
map(changes: ChangeDesc): ScrollTarget;
|
|
409
409
|
clip(state: EditorState): ScrollTarget;
|
|
410
410
|
}
|
|
@@ -1177,7 +1177,7 @@ declare class EditorView {
|
|
|
1177
1177
|
setTabFocusMode(to?: boolean | number): void;
|
|
1178
1178
|
/**
|
|
1179
1179
|
Facet to add a [style
|
|
1180
|
-
module](https://
|
|
1180
|
+
module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
|
|
1181
1181
|
an editor view. The view will ensure that the module is
|
|
1182
1182
|
mounted in its [document
|
|
1183
1183
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
@@ -1356,16 +1356,30 @@ declare class EditorView {
|
|
|
1356
1356
|
*/
|
|
1357
1357
|
static bidiIsolatedRanges: Facet<DecorationSet | ((view: EditorView) => DecorationSet), readonly (DecorationSet | ((view: EditorView) => DecorationSet))[]>;
|
|
1358
1358
|
/**
|
|
1359
|
+
Can be used to specify the distance that scrolling cursor into
|
|
1360
|
+
view keeps it away from the sides of the editor, either as a
|
|
1361
|
+
single pixel number or two different values for the different
|
|
1362
|
+
axes. Defaults to 5 pixels on both axes.
|
|
1363
|
+
*/
|
|
1364
|
+
static cursorScrollMargin: Facet<number | {
|
|
1365
|
+
x: number;
|
|
1366
|
+
y: number;
|
|
1367
|
+
}, {
|
|
1368
|
+
x: number;
|
|
1369
|
+
y: number;
|
|
1370
|
+
}>;
|
|
1371
|
+
/**
|
|
1359
1372
|
Facet that allows extensions to provide additional scroll
|
|
1360
1373
|
margins (space around the sides of the scrolling element that
|
|
1361
1374
|
should be considered invisible). This can be useful when the
|
|
1362
1375
|
plugin introduces elements that cover part of that element (for
|
|
1363
|
-
example a horizontally fixed gutter).
|
|
1376
|
+
example a horizontally fixed gutter). Not to be confused with
|
|
1377
|
+
[`cursorScrollMargin`](https://codemirror.net/6/docs/ref/#view.EditorView^cursorScrollMargin).
|
|
1364
1378
|
*/
|
|
1365
1379
|
static scrollMargins: Facet<(view: EditorView) => Partial<Rect> | null, readonly ((view: EditorView) => Partial<Rect> | null)[]>;
|
|
1366
1380
|
/**
|
|
1367
1381
|
Create a theme extension. The first argument can be a
|
|
1368
|
-
[`style-mod`](https://
|
|
1382
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
|
|
1369
1383
|
style spec providing the styles for the theme. These will be
|
|
1370
1384
|
prefixed with a generated class for the style.
|
|
1371
1385
|
|
package/dist/index.d.ts
CHANGED
|
@@ -404,7 +404,7 @@ declare class ScrollTarget {
|
|
|
404
404
|
readonly yMargin: number;
|
|
405
405
|
readonly xMargin: number;
|
|
406
406
|
readonly isSnapshot: boolean;
|
|
407
|
-
constructor(range: SelectionRange, y
|
|
407
|
+
constructor(range: SelectionRange, y: ScrollStrategy, x: ScrollStrategy, yMargin: number, xMargin: number, isSnapshot?: boolean);
|
|
408
408
|
map(changes: ChangeDesc): ScrollTarget;
|
|
409
409
|
clip(state: EditorState): ScrollTarget;
|
|
410
410
|
}
|
|
@@ -1177,7 +1177,7 @@ declare class EditorView {
|
|
|
1177
1177
|
setTabFocusMode(to?: boolean | number): void;
|
|
1178
1178
|
/**
|
|
1179
1179
|
Facet to add a [style
|
|
1180
|
-
module](https://
|
|
1180
|
+
module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
|
|
1181
1181
|
an editor view. The view will ensure that the module is
|
|
1182
1182
|
mounted in its [document
|
|
1183
1183
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
@@ -1356,16 +1356,30 @@ declare class EditorView {
|
|
|
1356
1356
|
*/
|
|
1357
1357
|
static bidiIsolatedRanges: Facet<DecorationSet | ((view: EditorView) => DecorationSet), readonly (DecorationSet | ((view: EditorView) => DecorationSet))[]>;
|
|
1358
1358
|
/**
|
|
1359
|
+
Can be used to specify the distance that scrolling cursor into
|
|
1360
|
+
view keeps it away from the sides of the editor, either as a
|
|
1361
|
+
single pixel number or two different values for the different
|
|
1362
|
+
axes. Defaults to 5 pixels on both axes.
|
|
1363
|
+
*/
|
|
1364
|
+
static cursorScrollMargin: Facet<number | {
|
|
1365
|
+
x: number;
|
|
1366
|
+
y: number;
|
|
1367
|
+
}, {
|
|
1368
|
+
x: number;
|
|
1369
|
+
y: number;
|
|
1370
|
+
}>;
|
|
1371
|
+
/**
|
|
1359
1372
|
Facet that allows extensions to provide additional scroll
|
|
1360
1373
|
margins (space around the sides of the scrolling element that
|
|
1361
1374
|
should be considered invisible). This can be useful when the
|
|
1362
1375
|
plugin introduces elements that cover part of that element (for
|
|
1363
|
-
example a horizontally fixed gutter).
|
|
1376
|
+
example a horizontally fixed gutter). Not to be confused with
|
|
1377
|
+
[`cursorScrollMargin`](https://codemirror.net/6/docs/ref/#view.EditorView^cursorScrollMargin).
|
|
1364
1378
|
*/
|
|
1365
1379
|
static scrollMargins: Facet<(view: EditorView) => Partial<Rect> | null, readonly ((view: EditorView) => Partial<Rect> | null)[]>;
|
|
1366
1380
|
/**
|
|
1367
1381
|
Create a theme extension. The first argument can be a
|
|
1368
|
-
[`style-mod`](https://
|
|
1382
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
|
|
1369
1383
|
style spec providing the styles for the theme. These will be
|
|
1370
1384
|
prefixed with a generated class for the style.
|
|
1371
1385
|
|
package/dist/index.js
CHANGED
|
@@ -545,12 +545,12 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
545
545
|
}
|
|
546
546
|
let moveX = 0, moveY = 0;
|
|
547
547
|
if (y == "nearest") {
|
|
548
|
-
if (rect.top < bounding.top) {
|
|
548
|
+
if (rect.top < bounding.top + yMargin) {
|
|
549
549
|
moveY = rect.top - (bounding.top + yMargin);
|
|
550
550
|
if (side > 0 && rect.bottom > bounding.bottom + moveY)
|
|
551
551
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
552
552
|
}
|
|
553
|
-
else if (rect.bottom > bounding.bottom) {
|
|
553
|
+
else if (rect.bottom > bounding.bottom - yMargin) {
|
|
554
554
|
moveY = rect.bottom - bounding.bottom + yMargin;
|
|
555
555
|
if (side < 0 && (rect.top - moveY) < bounding.top)
|
|
556
556
|
moveY = rect.top - (bounding.top + yMargin);
|
|
@@ -564,12 +564,12 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
564
564
|
moveY = targetTop - bounding.top;
|
|
565
565
|
}
|
|
566
566
|
if (x == "nearest") {
|
|
567
|
-
if (rect.left < bounding.left) {
|
|
567
|
+
if (rect.left < bounding.left + xMargin) {
|
|
568
568
|
moveX = rect.left - (bounding.left + xMargin);
|
|
569
569
|
if (side > 0 && rect.right > bounding.right + moveX)
|
|
570
570
|
moveX = rect.right - bounding.right + xMargin;
|
|
571
571
|
}
|
|
572
|
-
else if (rect.right > bounding.right) {
|
|
572
|
+
else if (rect.right > bounding.right - xMargin) {
|
|
573
573
|
moveX = rect.right - bounding.right + xMargin;
|
|
574
574
|
if (side < 0 && rect.left < bounding.left + moveX)
|
|
575
575
|
moveX = rect.left - (bounding.left + xMargin);
|
|
@@ -1309,7 +1309,7 @@ const nativeSelectionHidden = /*@__PURE__*/Facet.define({
|
|
|
1309
1309
|
});
|
|
1310
1310
|
const scrollHandler = /*@__PURE__*/Facet.define();
|
|
1311
1311
|
class ScrollTarget {
|
|
1312
|
-
constructor(range, y
|
|
1312
|
+
constructor(range, y, x, yMargin, xMargin,
|
|
1313
1313
|
// This data structure is abused to also store precise scroll
|
|
1314
1314
|
// snapshots, instead of a `scrollIntoView` request. When this
|
|
1315
1315
|
// flag is `true`, `range` points at a position in the reference
|
|
@@ -3906,6 +3906,19 @@ class InlineCoordsScan {
|
|
|
3906
3906
|
this.y = (side.top + side.bottom) / 2;
|
|
3907
3907
|
return this.scan(positions, getRects);
|
|
3908
3908
|
}
|
|
3909
|
+
// Handle the case where closest matched a higher element on the
|
|
3910
|
+
// same line as an element below/above the coords
|
|
3911
|
+
if (closestDx) {
|
|
3912
|
+
let { top, bottom } = closestRect;
|
|
3913
|
+
if (above && above.bottom > (top + top + bottom) / 3) {
|
|
3914
|
+
this.y = above.bottom - 1;
|
|
3915
|
+
return this.scan(positions, getRects);
|
|
3916
|
+
}
|
|
3917
|
+
if (below && below.top < (top + bottom + bottom) / 3) {
|
|
3918
|
+
this.y = below.top + 1;
|
|
3919
|
+
return this.scan(positions, getRects);
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3909
3922
|
let ltr = (bidi ? this.dirAt(positions[closestI], 1) : this.baseDir) == Direction.LTR;
|
|
3910
3923
|
return {
|
|
3911
3924
|
i: closestI,
|
|
@@ -5272,8 +5285,8 @@ handlers.beforeinput = (view, event) => {
|
|
|
5272
5285
|
const appliedFirefoxHack = /*@__PURE__*/new Set;
|
|
5273
5286
|
// In Firefox, when cut/copy handlers are added to the document, that
|
|
5274
5287
|
// somehow avoids a bug where those events aren't fired when the
|
|
5275
|
-
// selection is empty. See
|
|
5276
|
-
//
|
|
5288
|
+
// selection is empty. See issue #1082 and
|
|
5289
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=995961
|
|
5277
5290
|
function firefoxCopyCutHack(doc) {
|
|
5278
5291
|
if (!appliedFirefoxHack.has(doc)) {
|
|
5279
5292
|
appliedFirefoxHack.add(doc);
|
|
@@ -6759,7 +6772,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
6759
6772
|
flexShrink: 0,
|
|
6760
6773
|
display: "block",
|
|
6761
6774
|
whiteSpace: "pre",
|
|
6762
|
-
wordWrap: "normal", //
|
|
6775
|
+
wordWrap: "normal", // Issue #456
|
|
6763
6776
|
boxSizing: "border-box",
|
|
6764
6777
|
minHeight: "100%",
|
|
6765
6778
|
padding: "4px 0",
|
|
@@ -7178,7 +7191,7 @@ class DOMObserver {
|
|
|
7178
7191
|
readSelectionRange() {
|
|
7179
7192
|
let { view } = this;
|
|
7180
7193
|
// The Selection object is broken in shadow roots in Safari. See
|
|
7181
|
-
//
|
|
7194
|
+
// issue #414
|
|
7182
7195
|
let selection = getSelection(view.root);
|
|
7183
7196
|
if (!selection)
|
|
7184
7197
|
return false;
|
|
@@ -7922,7 +7935,8 @@ class EditorView {
|
|
|
7922
7935
|
scrollTarget = scrollTarget.map(tr.changes);
|
|
7923
7936
|
if (tr.scrollIntoView) {
|
|
7924
7937
|
let { main } = tr.state.selection;
|
|
7925
|
-
|
|
7938
|
+
let { x, y } = this.state.facet(EditorView.cursorScrollMargin);
|
|
7939
|
+
scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1), "nearest", "nearest", y, x);
|
|
7926
7940
|
}
|
|
7927
7941
|
for (let e of tr.effects)
|
|
7928
7942
|
if (e.is(scrollIntoView))
|
|
@@ -8579,7 +8593,8 @@ class EditorView {
|
|
|
8579
8593
|
cause it to scroll the given position or range into view.
|
|
8580
8594
|
*/
|
|
8581
8595
|
static scrollIntoView(pos, options = {}) {
|
|
8582
|
-
|
|
8596
|
+
var _a, _b, _c, _d;
|
|
8597
|
+
return scrollIntoView.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, (_a = options.y) !== null && _a !== void 0 ? _a : "nearest", (_b = options.x) !== null && _b !== void 0 ? _b : "nearest", (_c = options.yMargin) !== null && _c !== void 0 ? _c : 5, (_d = options.xMargin) !== null && _d !== void 0 ? _d : 5));
|
|
8583
8598
|
}
|
|
8584
8599
|
/**
|
|
8585
8600
|
Return an effect that resets the editor to its current (at the
|
|
@@ -8645,7 +8660,7 @@ class EditorView {
|
|
|
8645
8660
|
}
|
|
8646
8661
|
/**
|
|
8647
8662
|
Create a theme extension. The first argument can be a
|
|
8648
|
-
[`style-mod`](https://
|
|
8663
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)
|
|
8649
8664
|
style spec providing the styles for the theme. These will be
|
|
8650
8665
|
prefixed with a generated class for the style.
|
|
8651
8666
|
|
|
@@ -8691,7 +8706,7 @@ class EditorView {
|
|
|
8691
8706
|
}
|
|
8692
8707
|
/**
|
|
8693
8708
|
Facet to add a [style
|
|
8694
|
-
module](https://
|
|
8709
|
+
module](https://code.haverbeke.berlin/marijn/style-mod#documentation) to
|
|
8695
8710
|
an editor view. The view will ensure that the module is
|
|
8696
8711
|
mounted in its [document
|
|
8697
8712
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
@@ -8838,11 +8853,30 @@ supported.)
|
|
|
8838
8853
|
*/
|
|
8839
8854
|
EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
|
|
8840
8855
|
/**
|
|
8856
|
+
Can be used to specify the distance that scrolling cursor into
|
|
8857
|
+
view keeps it away from the sides of the editor, either as a
|
|
8858
|
+
single pixel number or two different values for the different
|
|
8859
|
+
axes. Defaults to 5 pixels on both axes.
|
|
8860
|
+
*/
|
|
8861
|
+
EditorView.cursorScrollMargin = /*@__PURE__*/Facet.define({
|
|
8862
|
+
combine: inputs => {
|
|
8863
|
+
let x = 5, y = 5;
|
|
8864
|
+
for (let i of inputs) {
|
|
8865
|
+
if (typeof i == "number")
|
|
8866
|
+
x = y = i;
|
|
8867
|
+
else
|
|
8868
|
+
({ x, y } = i);
|
|
8869
|
+
}
|
|
8870
|
+
return { x, y };
|
|
8871
|
+
}
|
|
8872
|
+
});
|
|
8873
|
+
/**
|
|
8841
8874
|
Facet that allows extensions to provide additional scroll
|
|
8842
8875
|
margins (space around the sides of the scrolling element that
|
|
8843
8876
|
should be considered invisible). This can be useful when the
|
|
8844
8877
|
plugin introduces elements that cover part of that element (for
|
|
8845
|
-
example a horizontally fixed gutter).
|
|
8878
|
+
example a horizontally fixed gutter). Not to be confused with
|
|
8879
|
+
[`cursorScrollMargin`](https://codemirror.net/6/docs/ref/#view.EditorView^cursorScrollMargin).
|
|
8846
8880
|
*/
|
|
8847
8881
|
EditorView.scrollMargins = scrollMargins;
|
|
8848
8882
|
/**
|
|
@@ -9378,7 +9412,7 @@ class LayerView {
|
|
|
9378
9412
|
old = next;
|
|
9379
9413
|
}
|
|
9380
9414
|
this.drawn = markers;
|
|
9381
|
-
if (browser.
|
|
9415
|
+
if (browser.webkit) // Issue #1600, 1627, 1686
|
|
9382
9416
|
this.dom.style.display = this.dom.firstChild ? "" : "none";
|
|
9383
9417
|
}
|
|
9384
9418
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/view",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.1",
|
|
4
4
|
"description": "DOM view component for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "git+https://
|
|
39
|
+
"url": "git+https://code.haverbeke.berlin/codemirror/view.git"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name: Trigger CI
|
|
2
|
-
on: push
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
build:
|
|
6
|
-
name: Dispatch to main repo
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- name: Emit repository_dispatch
|
|
10
|
-
uses: mvasigh/dispatch-action@main
|
|
11
|
-
with:
|
|
12
|
-
# You should create a personal access token and store it in your repository
|
|
13
|
-
token: ${{ secrets.DISPATCH_AUTH }}
|
|
14
|
-
repo: dev
|
|
15
|
-
owner: codemirror
|
|
16
|
-
event_type: push
|