@codemirror/view 0.20.6 → 6.0.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/.github/workflows/dispatch.yml +1 -1
- package/CHANGELOG.md +28 -0
- package/README.md +5 -5
- package/dist/index.cjs +70 -39
- package/dist/index.d.ts +17 -10
- package/dist/index.js +72 -41
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## 6.0.1 (2022-06-17)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Avoid DOM selection corruption when the editor doesn't have focus but has selection and updates its content.
|
|
6
|
+
|
|
7
|
+
Fall back to dispatching by key code when a key event produces a non-ASCII character (so that Cyrillic and Arabic keyboards can still use bindings specified with Latin characters).
|
|
8
|
+
|
|
9
|
+
## 6.0.0 (2022-06-08)
|
|
10
|
+
|
|
11
|
+
### New features
|
|
12
|
+
|
|
13
|
+
The new static `EditorView.findFromDOM` method can be used to retrieve an editor instance from its DOM structure.
|
|
14
|
+
|
|
15
|
+
Instead of passing a constructed state to the `EditorView` constructor, it is now also possible to inline the configuration options to the state in the view config object.
|
|
16
|
+
|
|
17
|
+
## 0.20.7 (2022-05-30)
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
Fix an issue on Chrome Android where the DOM could fail to display the actual document after backspace.
|
|
22
|
+
|
|
23
|
+
Avoid an issue on Chrome Android where DOM changes were sometimes inappropriately replace by a backspace key effect due to spurious beforeinput events.
|
|
24
|
+
|
|
25
|
+
Fix a problem where the content element's width didn't cover the width of the actual content.
|
|
26
|
+
|
|
27
|
+
Work around a bug in Chrome 102 which caused wheel scrolling of the editor to be interrupted every few lines.
|
|
28
|
+
|
|
1
29
|
## 0.20.6 (2022-05-20)
|
|
2
30
|
|
|
3
31
|
### Bug fixes
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# @codemirror/view [](https://www.npmjs.org/package/@codemirror/view)
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://codemirror.net/
|
|
3
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#view) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/view/blob/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This package implements the DOM view component for the
|
|
6
|
-
[CodeMirror](https://codemirror.net/
|
|
6
|
+
[CodeMirror](https://codemirror.net/) code editor.
|
|
7
7
|
|
|
8
|
-
The [project page](https://codemirror.net/
|
|
9
|
-
number of [examples](https://codemirror.net/
|
|
10
|
-
[documentation](https://codemirror.net/
|
|
8
|
+
The [project page](https://codemirror.net/) has more information, a
|
|
9
|
+
number of [examples](https://codemirror.net/examples/) and the
|
|
10
|
+
[documentation](https://codemirror.net/docs/).
|
|
11
11
|
|
|
12
12
|
This code is released under an
|
|
13
13
|
[MIT license](https://github.com/codemirror/view/tree/main/LICENSE).
|
package/dist/index.cjs
CHANGED
|
@@ -754,7 +754,7 @@ function textCoords(text, pos, side) {
|
|
|
754
754
|
from--;
|
|
755
755
|
flatten = 1;
|
|
756
756
|
} // FIXME this is wrong in RTL text
|
|
757
|
-
else {
|
|
757
|
+
else if (to < length) {
|
|
758
758
|
to++;
|
|
759
759
|
flatten = -1;
|
|
760
760
|
}
|
|
@@ -763,7 +763,7 @@ function textCoords(text, pos, side) {
|
|
|
763
763
|
else {
|
|
764
764
|
if (side < 0)
|
|
765
765
|
from--;
|
|
766
|
-
else
|
|
766
|
+
else if (to < length)
|
|
767
767
|
to++;
|
|
768
768
|
}
|
|
769
769
|
let rects = textRange(text, from, to).getClientRects();
|
|
@@ -1379,6 +1379,7 @@ class LineView extends ContentView {
|
|
|
1379
1379
|
transferDOM(other) {
|
|
1380
1380
|
if (!this.dom)
|
|
1381
1381
|
return;
|
|
1382
|
+
this.markDirty();
|
|
1382
1383
|
other.setDOM(this.dom);
|
|
1383
1384
|
other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
|
|
1384
1385
|
this.prevAttrs = undefined;
|
|
@@ -2510,7 +2511,7 @@ class DocView extends ContentView {
|
|
|
2510
2511
|
// no relayout is triggered and I cannot imagine how it can
|
|
2511
2512
|
// recompute the scroll position without a layout)
|
|
2512
2513
|
this.dom.style.height = this.view.viewState.contentHeight + "px";
|
|
2513
|
-
this.dom.style.
|
|
2514
|
+
this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
|
|
2514
2515
|
// Chrome will sometimes, when DOM mutations occur directly
|
|
2515
2516
|
// around the selection, get confused and report a different
|
|
2516
2517
|
// selection from the one it displays (issue #218). This tries
|
|
@@ -2544,7 +2545,7 @@ class DocView extends ContentView {
|
|
|
2544
2545
|
}
|
|
2545
2546
|
// Sync the DOM selection to this.state.selection
|
|
2546
2547
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2547
|
-
if (mustRead)
|
|
2548
|
+
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2548
2549
|
this.view.observer.readSelectionRange();
|
|
2549
2550
|
if (!(fromPointer || this.mayControlSelection()) ||
|
|
2550
2551
|
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
@@ -2579,7 +2580,8 @@ class DocView extends ContentView {
|
|
|
2579
2580
|
this.dom.focus({ preventScroll: true });
|
|
2580
2581
|
}
|
|
2581
2582
|
let rawSel = getSelection(this.root);
|
|
2582
|
-
if (
|
|
2583
|
+
if (!rawSel) ;
|
|
2584
|
+
else if (main.empty) {
|
|
2583
2585
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2584
2586
|
if (browser.gecko) {
|
|
2585
2587
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
@@ -2621,7 +2623,7 @@ class DocView extends ContentView {
|
|
|
2621
2623
|
return;
|
|
2622
2624
|
let cursor = this.view.state.selection.main;
|
|
2623
2625
|
let sel = getSelection(this.root);
|
|
2624
|
-
if (!cursor.empty || !cursor.assoc || !sel.modify)
|
|
2626
|
+
if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
|
|
2625
2627
|
return;
|
|
2626
2628
|
let line = LineView.find(this, cursor.head);
|
|
2627
2629
|
if (!line)
|
|
@@ -2637,8 +2639,9 @@ class DocView extends ContentView {
|
|
|
2637
2639
|
sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
|
|
2638
2640
|
}
|
|
2639
2641
|
mayControlSelection() {
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
+
let active = this.root.activeElement;
|
|
2643
|
+
return active == this.dom ||
|
|
2644
|
+
hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
|
|
2642
2645
|
}
|
|
2643
2646
|
nearest(dom) {
|
|
2644
2647
|
for (let cur = dom; cur;) {
|
|
@@ -3268,6 +3271,7 @@ class InputState {
|
|
|
3268
3271
|
constructor(view) {
|
|
3269
3272
|
this.lastKeyCode = 0;
|
|
3270
3273
|
this.lastKeyTime = 0;
|
|
3274
|
+
this.chromeScrollHack = -1;
|
|
3271
3275
|
// On iOS, some keys need to have their default behavior happen
|
|
3272
3276
|
// (after which we retroactively handle them and reset the DOM) to
|
|
3273
3277
|
// avoid messing up the virtual keyboard state.
|
|
@@ -3308,6 +3312,21 @@ class InputState {
|
|
|
3308
3312
|
});
|
|
3309
3313
|
this.registeredEvents.push(type);
|
|
3310
3314
|
}
|
|
3315
|
+
if (browser.chrome && browser.chrome_version >= 102) {
|
|
3316
|
+
// On Chrome 102, viewport updates somehow stop wheel-based
|
|
3317
|
+
// scrolling. Turning off pointer events during the scroll seems
|
|
3318
|
+
// to avoid the issue.
|
|
3319
|
+
view.scrollDOM.addEventListener("wheel", () => {
|
|
3320
|
+
if (this.chromeScrollHack < 0)
|
|
3321
|
+
view.contentDOM.style.pointerEvents = "none";
|
|
3322
|
+
else
|
|
3323
|
+
window.clearTimeout(this.chromeScrollHack);
|
|
3324
|
+
this.chromeScrollHack = setTimeout(() => {
|
|
3325
|
+
this.chromeScrollHack = -1;
|
|
3326
|
+
view.contentDOM.style.pointerEvents = "";
|
|
3327
|
+
}, 100);
|
|
3328
|
+
}, { passive: true });
|
|
3329
|
+
}
|
|
3311
3330
|
this.notifiedFocused = view.hasFocus;
|
|
3312
3331
|
// On Safari adding an input event handler somehow prevents an
|
|
3313
3332
|
// issue where the composition vanishes when you press enter.
|
|
@@ -3519,7 +3538,7 @@ function isInPrimarySelection(view, event) {
|
|
|
3519
3538
|
// On boundary clicks, check whether the coordinates are inside the
|
|
3520
3539
|
// selection's client rectangles
|
|
3521
3540
|
let sel = getSelection(view.root);
|
|
3522
|
-
if (sel.rangeCount == 0)
|
|
3541
|
+
if (!sel || sel.rangeCount == 0)
|
|
3523
3542
|
return true;
|
|
3524
3543
|
let rects = sel.getRangeAt(0).getClientRects();
|
|
3525
3544
|
for (let i = 0; i < rects.length; i++) {
|
|
@@ -5478,12 +5497,12 @@ class DOMObserver {
|
|
|
5478
5497
|
this.flush(false);
|
|
5479
5498
|
}
|
|
5480
5499
|
readSelectionRange() {
|
|
5481
|
-
let { root } = this.view
|
|
5500
|
+
let { root } = this.view;
|
|
5482
5501
|
// The Selection object is broken in shadow roots in Safari. See
|
|
5483
|
-
// https://github.com/codemirror/
|
|
5502
|
+
// https://github.com/codemirror/dev/issues/414
|
|
5484
5503
|
let range = browser.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
|
|
5485
|
-
safariSelectionRangeHack(this.view) ||
|
|
5486
|
-
if (this.selectionRange.eq(range))
|
|
5504
|
+
safariSelectionRangeHack(this.view) || getSelection(root);
|
|
5505
|
+
if (!range || this.selectionRange.eq(range))
|
|
5487
5506
|
return false;
|
|
5488
5507
|
this.selectionRange.setRange(range);
|
|
5489
5508
|
return this.selectionChanged = true;
|
|
@@ -5564,21 +5583,16 @@ class DOMObserver {
|
|
|
5564
5583
|
// composition events that, when interrupted, cause text duplication
|
|
5565
5584
|
// or other kinds of corruption. This hack makes the editor back off
|
|
5566
5585
|
// from handling DOM changes for a moment when such a key is
|
|
5567
|
-
// detected (via beforeinput or keydown), and then
|
|
5568
|
-
//
|
|
5586
|
+
// detected (via beforeinput or keydown), and then tries to flush
|
|
5587
|
+
// them or, if that has no effect, dispatches the given key.
|
|
5569
5588
|
delayAndroidKey(key, keyCode) {
|
|
5570
5589
|
if (!this.delayedAndroidKey)
|
|
5571
5590
|
requestAnimationFrame(() => {
|
|
5572
5591
|
let key = this.delayedAndroidKey;
|
|
5573
5592
|
this.delayedAndroidKey = null;
|
|
5574
|
-
|
|
5575
|
-
this.
|
|
5576
|
-
|
|
5577
|
-
this.processRecords();
|
|
5578
|
-
else
|
|
5579
|
-
this.flush();
|
|
5580
|
-
if (this.view.state == startState)
|
|
5581
|
-
this.view.update([]);
|
|
5593
|
+
this.delayedFlush = -1;
|
|
5594
|
+
if (!this.flush())
|
|
5595
|
+
dispatchKey(this.view.contentDOM, key.key, key.keyCode);
|
|
5582
5596
|
});
|
|
5583
5597
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5584
5598
|
// Enter always takes precedence.
|
|
@@ -5634,10 +5648,11 @@ class DOMObserver {
|
|
|
5634
5648
|
return;
|
|
5635
5649
|
this.selectionChanged = false;
|
|
5636
5650
|
let startState = this.view.state;
|
|
5637
|
-
this.onChange(from, to, typeOver);
|
|
5651
|
+
let handled = this.onChange(from, to, typeOver);
|
|
5638
5652
|
// The view wasn't updated
|
|
5639
5653
|
if (this.view.state == startState)
|
|
5640
5654
|
this.view.update([]);
|
|
5655
|
+
return handled;
|
|
5641
5656
|
}
|
|
5642
5657
|
readMutation(rec) {
|
|
5643
5658
|
let cView = this.view.docView.nearest(rec.target);
|
|
@@ -5720,7 +5735,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5720
5735
|
if (start > -1) {
|
|
5721
5736
|
let bounds = view.docView.domBoundsAround(start, end, 0);
|
|
5722
5737
|
if (!bounds || view.state.readOnly)
|
|
5723
|
-
return;
|
|
5738
|
+
return false;
|
|
5724
5739
|
let { from, to } = bounds;
|
|
5725
5740
|
let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints(view);
|
|
5726
5741
|
let reader = new DOMReader(selPoints, view.state);
|
|
@@ -5760,7 +5775,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5760
5775
|
newSel = state.EditorSelection.single(anchor, head);
|
|
5761
5776
|
}
|
|
5762
5777
|
if (!change && !newSel)
|
|
5763
|
-
return;
|
|
5778
|
+
return false;
|
|
5764
5779
|
// Heuristic to notice typing over a selected character
|
|
5765
5780
|
if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
|
|
5766
5781
|
change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
|
|
@@ -5776,13 +5791,13 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5776
5791
|
};
|
|
5777
5792
|
// Detect insert-period-on-double-space Mac behavior, and transform
|
|
5778
5793
|
// it into a regular space insert.
|
|
5779
|
-
else if (browser.mac && change && change.from == change.to && change.from == sel.head - 1 &&
|
|
5794
|
+
else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&
|
|
5780
5795
|
change.insert.toString() == ".")
|
|
5781
5796
|
change = { from: sel.from, to: sel.to, insert: state.Text.of([" "]) };
|
|
5782
5797
|
if (change) {
|
|
5783
5798
|
let startState = view.state;
|
|
5784
5799
|
if (browser.ios && view.inputState.flushIOSKey(view))
|
|
5785
|
-
return;
|
|
5800
|
+
return true;
|
|
5786
5801
|
// Android browsers don't fire reasonable key events for enter,
|
|
5787
5802
|
// backspace, or delete. So this detects changes that look like
|
|
5788
5803
|
// they're caused by those keys, and reinterprets them as key
|
|
@@ -5797,10 +5812,10 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5797
5812
|
dispatchKey(view.contentDOM, "Backspace", 8)) ||
|
|
5798
5813
|
(change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
|
|
5799
5814
|
dispatchKey(view.contentDOM, "Delete", 46))))
|
|
5800
|
-
return;
|
|
5815
|
+
return true;
|
|
5801
5816
|
let text = change.insert.toString();
|
|
5802
5817
|
if (view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text)))
|
|
5803
|
-
return;
|
|
5818
|
+
return true;
|
|
5804
5819
|
if (view.inputState.composing >= 0)
|
|
5805
5820
|
view.inputState.composing++;
|
|
5806
5821
|
let tr;
|
|
@@ -5856,6 +5871,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5856
5871
|
}
|
|
5857
5872
|
}
|
|
5858
5873
|
view.dispatch(tr, { scrollIntoView: true, userEvent });
|
|
5874
|
+
return true;
|
|
5859
5875
|
}
|
|
5860
5876
|
else if (newSel && !newSel.main.eq(sel)) {
|
|
5861
5877
|
let scrollIntoView = false, userEvent = "select";
|
|
@@ -5865,6 +5881,10 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5865
5881
|
userEvent = view.inputState.lastSelectionOrigin;
|
|
5866
5882
|
}
|
|
5867
5883
|
view.dispatch({ selection: newSel, scrollIntoView, userEvent });
|
|
5884
|
+
return true;
|
|
5885
|
+
}
|
|
5886
|
+
else {
|
|
5887
|
+
return false;
|
|
5868
5888
|
}
|
|
5869
5889
|
}
|
|
5870
5890
|
function findDiff(a, b, preferredPos, preferredSide) {
|
|
@@ -5941,11 +5961,7 @@ class EditorView {
|
|
|
5941
5961
|
option, or put `view.dom` into your document after creating a
|
|
5942
5962
|
view, so that the user can see the editor.
|
|
5943
5963
|
*/
|
|
5944
|
-
constructor(
|
|
5945
|
-
/**
|
|
5946
|
-
Initialization options.
|
|
5947
|
-
*/
|
|
5948
|
-
config = {}) {
|
|
5964
|
+
constructor(config = {}) {
|
|
5949
5965
|
this.plugins = [];
|
|
5950
5966
|
this.pluginMap = new Map;
|
|
5951
5967
|
this.editorAttrs = {};
|
|
@@ -5978,12 +5994,12 @@ class EditorView {
|
|
|
5978
5994
|
this._dispatch = config.dispatch || ((tr) => this.update([tr]));
|
|
5979
5995
|
this.dispatch = this.dispatch.bind(this);
|
|
5980
5996
|
this.root = (config.root || getRoot(config.parent) || document);
|
|
5981
|
-
this.viewState = new ViewState(config.state || state.EditorState.create());
|
|
5997
|
+
this.viewState = new ViewState(config.state || state.EditorState.create(config));
|
|
5982
5998
|
this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
|
|
5983
5999
|
for (let plugin of this.plugins)
|
|
5984
6000
|
plugin.update(this);
|
|
5985
6001
|
this.observer = new DOMObserver(this, (from, to, typeOver) => {
|
|
5986
|
-
applyDOMChange(this, from, to, typeOver);
|
|
6002
|
+
return applyDOMChange(this, from, to, typeOver);
|
|
5987
6003
|
}, event => {
|
|
5988
6004
|
this.inputState.runScrollHandlers(this, event);
|
|
5989
6005
|
if (this.observer.intersecting)
|
|
@@ -6064,6 +6080,7 @@ class EditorView {
|
|
|
6064
6080
|
this.viewState.state = state$1;
|
|
6065
6081
|
return;
|
|
6066
6082
|
}
|
|
6083
|
+
this.observer.clear();
|
|
6067
6084
|
// When the phrases change, redraw the editor
|
|
6068
6085
|
if (state$1.facet(state.EditorState.phrases) != this.state.facet(state.EditorState.phrases))
|
|
6069
6086
|
return this.setState(state$1);
|
|
@@ -6652,6 +6669,16 @@ class EditorView {
|
|
|
6652
6669
|
static baseTheme(spec) {
|
|
6653
6670
|
return state.Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
|
|
6654
6671
|
}
|
|
6672
|
+
/**
|
|
6673
|
+
Retrieve an editor view instance from the view's DOM
|
|
6674
|
+
representation.
|
|
6675
|
+
*/
|
|
6676
|
+
static findFromDOM(dom) {
|
|
6677
|
+
var _a;
|
|
6678
|
+
let content = dom.querySelector(".cm-content");
|
|
6679
|
+
let cView = content && ContentView.get(content) || ContentView.get(dom);
|
|
6680
|
+
return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
|
|
6681
|
+
}
|
|
6655
6682
|
}
|
|
6656
6683
|
/**
|
|
6657
6684
|
Facet to add a [style
|
|
@@ -6941,7 +6968,8 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
6941
6968
|
return bound;
|
|
6942
6969
|
}
|
|
6943
6970
|
function runHandlers(map, event, view, scope) {
|
|
6944
|
-
let name = w3cKeyname.keyName(event)
|
|
6971
|
+
let name = w3cKeyname.keyName(event);
|
|
6972
|
+
let charCode = state.codePointAt(name, 0), isChar = state.codePointSize(charCode) == name.length && name != " ";
|
|
6945
6973
|
let prefix = "", fallthrough = false;
|
|
6946
6974
|
if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
|
|
6947
6975
|
prefix = storedPrefix.prefix + " ";
|
|
@@ -6962,10 +6990,13 @@ function runHandlers(map, event, view, scope) {
|
|
|
6962
6990
|
if (scopeObj) {
|
|
6963
6991
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
6964
6992
|
return true;
|
|
6965
|
-
if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
|
|
6993
|
+
if (isChar && (event.shiftKey || event.altKey || event.metaKey || charCode > 127) &&
|
|
6966
6994
|
(baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
|
|
6967
6995
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
6968
6996
|
return true;
|
|
6997
|
+
else if (event.shiftKey && w3cKeyname.shift[event.keyCode] != baseName &&
|
|
6998
|
+
runFor(scopeObj[prefix + modifiers(w3cKeyname.shift[event.keyCode], event, false)]))
|
|
6999
|
+
return true;
|
|
6969
7000
|
}
|
|
6970
7001
|
else if (isChar && event.shiftKey) {
|
|
6971
7002
|
if (runFor(scopeObj[prefix + modifiers(name, event, true)]))
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _codemirror_state from '@codemirror/state';
|
|
2
|
-
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
2
|
+
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, EditorStateConfig, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
3
3
|
import { StyleModule, StyleSpec } from 'style-mod';
|
|
4
4
|
|
|
5
5
|
declare type Attrs = {
|
|
@@ -559,10 +559,16 @@ declare class BidiSpan {
|
|
|
559
559
|
get dir(): Direction;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
|
|
562
|
+
/**
|
|
563
|
+
The type of object given to the [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
564
|
+
constructor.
|
|
565
|
+
*/
|
|
566
|
+
interface EditorViewConfig extends EditorStateConfig {
|
|
563
567
|
/**
|
|
564
|
-
The view's initial state.
|
|
565
|
-
|
|
568
|
+
The view's initial state. If not given, a new state is created
|
|
569
|
+
by passing this configuration object to
|
|
570
|
+
[`EditorState.create`](https://codemirror.net/6/docs/ref/#state.EditorState^create), using its
|
|
571
|
+
`doc`, `selection`, and `extensions` field (if provided).
|
|
566
572
|
*/
|
|
567
573
|
state?: EditorState;
|
|
568
574
|
/**
|
|
@@ -676,11 +682,7 @@ declare class EditorView {
|
|
|
676
682
|
option, or put `view.dom` into your document after creating a
|
|
677
683
|
view, so that the user can see the editor.
|
|
678
684
|
*/
|
|
679
|
-
constructor(
|
|
680
|
-
/**
|
|
681
|
-
Initialization options.
|
|
682
|
-
*/
|
|
683
|
-
config?: EditorConfig);
|
|
685
|
+
constructor(config?: EditorViewConfig);
|
|
684
686
|
/**
|
|
685
687
|
All regular editor state updates should go through this. It
|
|
686
688
|
takes a transaction or transaction spec and updates the view to
|
|
@@ -1131,6 +1133,11 @@ declare class EditorView {
|
|
|
1131
1133
|
search match).
|
|
1132
1134
|
*/
|
|
1133
1135
|
static announce: _codemirror_state.StateEffectType<string>;
|
|
1136
|
+
/**
|
|
1137
|
+
Retrieve an editor view instance from the view's DOM
|
|
1138
|
+
representation.
|
|
1139
|
+
*/
|
|
1140
|
+
static findFromDOM(dom: HTMLElement): EditorView | null;
|
|
1134
1141
|
}
|
|
1135
1142
|
/**
|
|
1136
1143
|
Helper type that maps event names to event object types, or the
|
|
@@ -1783,4 +1790,4 @@ line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
|
|
|
1783
1790
|
*/
|
|
1784
1791
|
declare function highlightActiveLineGutter(): Extension;
|
|
1785
1792
|
|
|
1786
|
-
export { BidiSpan, BlockInfo, BlockType, Command, DOMEventHandlers, DOMEventMap, Decoration, DecorationSet, Direction, EditorView, GutterMarker, KeyBinding, MatchDecorator, MouseSelectionStyle, Panel, PanelConstructor, PluginSpec, PluginValue, Rect, Tooltip, TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
|
1793
|
+
export { BidiSpan, BlockInfo, BlockType, Command, DOMEventHandlers, DOMEventMap, Decoration, DecorationSet, Direction, EditorView, EditorViewConfig, GutterMarker, KeyBinding, MatchDecorator, MouseSelectionStyle, Panel, PanelConstructor, PluginSpec, PluginValue, Rect, Tooltip, TooltipView, ViewPlugin, ViewUpdate, WidgetType, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, EditorState, findColumn, CharCategory, Prec, Transaction, combineConfig, StateField, RangeSetBuilder,
|
|
1
|
+
import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, EditorState, findColumn, CharCategory, Prec, Transaction, codePointAt, codePointSize, combineConfig, StateField, RangeSetBuilder, countColumn } from '@codemirror/state';
|
|
2
2
|
import { StyleModule } from 'style-mod';
|
|
3
|
-
import { keyName, base } from 'w3c-keyname';
|
|
3
|
+
import { keyName, base, shift } from 'w3c-keyname';
|
|
4
4
|
|
|
5
5
|
function getSelection(root) {
|
|
6
6
|
let target;
|
|
@@ -750,7 +750,7 @@ function textCoords(text, pos, side) {
|
|
|
750
750
|
from--;
|
|
751
751
|
flatten = 1;
|
|
752
752
|
} // FIXME this is wrong in RTL text
|
|
753
|
-
else {
|
|
753
|
+
else if (to < length) {
|
|
754
754
|
to++;
|
|
755
755
|
flatten = -1;
|
|
756
756
|
}
|
|
@@ -759,7 +759,7 @@ function textCoords(text, pos, side) {
|
|
|
759
759
|
else {
|
|
760
760
|
if (side < 0)
|
|
761
761
|
from--;
|
|
762
|
-
else
|
|
762
|
+
else if (to < length)
|
|
763
763
|
to++;
|
|
764
764
|
}
|
|
765
765
|
let rects = textRange(text, from, to).getClientRects();
|
|
@@ -1374,6 +1374,7 @@ class LineView extends ContentView {
|
|
|
1374
1374
|
transferDOM(other) {
|
|
1375
1375
|
if (!this.dom)
|
|
1376
1376
|
return;
|
|
1377
|
+
this.markDirty();
|
|
1377
1378
|
other.setDOM(this.dom);
|
|
1378
1379
|
other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
|
|
1379
1380
|
this.prevAttrs = undefined;
|
|
@@ -2504,7 +2505,7 @@ class DocView extends ContentView {
|
|
|
2504
2505
|
// no relayout is triggered and I cannot imagine how it can
|
|
2505
2506
|
// recompute the scroll position without a layout)
|
|
2506
2507
|
this.dom.style.height = this.view.viewState.contentHeight + "px";
|
|
2507
|
-
this.dom.style.
|
|
2508
|
+
this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
|
|
2508
2509
|
// Chrome will sometimes, when DOM mutations occur directly
|
|
2509
2510
|
// around the selection, get confused and report a different
|
|
2510
2511
|
// selection from the one it displays (issue #218). This tries
|
|
@@ -2538,7 +2539,7 @@ class DocView extends ContentView {
|
|
|
2538
2539
|
}
|
|
2539
2540
|
// Sync the DOM selection to this.state.selection
|
|
2540
2541
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
2541
|
-
if (mustRead)
|
|
2542
|
+
if (mustRead || !this.view.observer.selectionRange.focusNode)
|
|
2542
2543
|
this.view.observer.readSelectionRange();
|
|
2543
2544
|
if (!(fromPointer || this.mayControlSelection()) ||
|
|
2544
2545
|
browser.ios && this.view.inputState.rapidCompositionStart)
|
|
@@ -2573,7 +2574,8 @@ class DocView extends ContentView {
|
|
|
2573
2574
|
this.dom.focus({ preventScroll: true });
|
|
2574
2575
|
}
|
|
2575
2576
|
let rawSel = getSelection(this.root);
|
|
2576
|
-
if (
|
|
2577
|
+
if (!rawSel) ;
|
|
2578
|
+
else if (main.empty) {
|
|
2577
2579
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
|
|
2578
2580
|
if (browser.gecko) {
|
|
2579
2581
|
let nextTo = nextToUneditable(anchor.node, anchor.offset);
|
|
@@ -2615,7 +2617,7 @@ class DocView extends ContentView {
|
|
|
2615
2617
|
return;
|
|
2616
2618
|
let cursor = this.view.state.selection.main;
|
|
2617
2619
|
let sel = getSelection(this.root);
|
|
2618
|
-
if (!cursor.empty || !cursor.assoc || !sel.modify)
|
|
2620
|
+
if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
|
|
2619
2621
|
return;
|
|
2620
2622
|
let line = LineView.find(this, cursor.head);
|
|
2621
2623
|
if (!line)
|
|
@@ -2631,8 +2633,9 @@ class DocView extends ContentView {
|
|
|
2631
2633
|
sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
|
|
2632
2634
|
}
|
|
2633
2635
|
mayControlSelection() {
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
+
let active = this.root.activeElement;
|
|
2637
|
+
return active == this.dom ||
|
|
2638
|
+
hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
|
|
2636
2639
|
}
|
|
2637
2640
|
nearest(dom) {
|
|
2638
2641
|
for (let cur = dom; cur;) {
|
|
@@ -3262,6 +3265,7 @@ class InputState {
|
|
|
3262
3265
|
constructor(view) {
|
|
3263
3266
|
this.lastKeyCode = 0;
|
|
3264
3267
|
this.lastKeyTime = 0;
|
|
3268
|
+
this.chromeScrollHack = -1;
|
|
3265
3269
|
// On iOS, some keys need to have their default behavior happen
|
|
3266
3270
|
// (after which we retroactively handle them and reset the DOM) to
|
|
3267
3271
|
// avoid messing up the virtual keyboard state.
|
|
@@ -3302,6 +3306,21 @@ class InputState {
|
|
|
3302
3306
|
});
|
|
3303
3307
|
this.registeredEvents.push(type);
|
|
3304
3308
|
}
|
|
3309
|
+
if (browser.chrome && browser.chrome_version >= 102) {
|
|
3310
|
+
// On Chrome 102, viewport updates somehow stop wheel-based
|
|
3311
|
+
// scrolling. Turning off pointer events during the scroll seems
|
|
3312
|
+
// to avoid the issue.
|
|
3313
|
+
view.scrollDOM.addEventListener("wheel", () => {
|
|
3314
|
+
if (this.chromeScrollHack < 0)
|
|
3315
|
+
view.contentDOM.style.pointerEvents = "none";
|
|
3316
|
+
else
|
|
3317
|
+
window.clearTimeout(this.chromeScrollHack);
|
|
3318
|
+
this.chromeScrollHack = setTimeout(() => {
|
|
3319
|
+
this.chromeScrollHack = -1;
|
|
3320
|
+
view.contentDOM.style.pointerEvents = "";
|
|
3321
|
+
}, 100);
|
|
3322
|
+
}, { passive: true });
|
|
3323
|
+
}
|
|
3305
3324
|
this.notifiedFocused = view.hasFocus;
|
|
3306
3325
|
// On Safari adding an input event handler somehow prevents an
|
|
3307
3326
|
// issue where the composition vanishes when you press enter.
|
|
@@ -3513,7 +3532,7 @@ function isInPrimarySelection(view, event) {
|
|
|
3513
3532
|
// On boundary clicks, check whether the coordinates are inside the
|
|
3514
3533
|
// selection's client rectangles
|
|
3515
3534
|
let sel = getSelection(view.root);
|
|
3516
|
-
if (sel.rangeCount == 0)
|
|
3535
|
+
if (!sel || sel.rangeCount == 0)
|
|
3517
3536
|
return true;
|
|
3518
3537
|
let rects = sel.getRangeAt(0).getClientRects();
|
|
3519
3538
|
for (let i = 0; i < rects.length; i++) {
|
|
@@ -5471,12 +5490,12 @@ class DOMObserver {
|
|
|
5471
5490
|
this.flush(false);
|
|
5472
5491
|
}
|
|
5473
5492
|
readSelectionRange() {
|
|
5474
|
-
let { root } = this.view
|
|
5493
|
+
let { root } = this.view;
|
|
5475
5494
|
// The Selection object is broken in shadow roots in Safari. See
|
|
5476
|
-
// https://github.com/codemirror/
|
|
5495
|
+
// https://github.com/codemirror/dev/issues/414
|
|
5477
5496
|
let range = browser.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
|
|
5478
|
-
safariSelectionRangeHack(this.view) ||
|
|
5479
|
-
if (this.selectionRange.eq(range))
|
|
5497
|
+
safariSelectionRangeHack(this.view) || getSelection(root);
|
|
5498
|
+
if (!range || this.selectionRange.eq(range))
|
|
5480
5499
|
return false;
|
|
5481
5500
|
this.selectionRange.setRange(range);
|
|
5482
5501
|
return this.selectionChanged = true;
|
|
@@ -5557,21 +5576,16 @@ class DOMObserver {
|
|
|
5557
5576
|
// composition events that, when interrupted, cause text duplication
|
|
5558
5577
|
// or other kinds of corruption. This hack makes the editor back off
|
|
5559
5578
|
// from handling DOM changes for a moment when such a key is
|
|
5560
|
-
// detected (via beforeinput or keydown), and then
|
|
5561
|
-
//
|
|
5579
|
+
// detected (via beforeinput or keydown), and then tries to flush
|
|
5580
|
+
// them or, if that has no effect, dispatches the given key.
|
|
5562
5581
|
delayAndroidKey(key, keyCode) {
|
|
5563
5582
|
if (!this.delayedAndroidKey)
|
|
5564
5583
|
requestAnimationFrame(() => {
|
|
5565
5584
|
let key = this.delayedAndroidKey;
|
|
5566
5585
|
this.delayedAndroidKey = null;
|
|
5567
|
-
|
|
5568
|
-
this.
|
|
5569
|
-
|
|
5570
|
-
this.processRecords();
|
|
5571
|
-
else
|
|
5572
|
-
this.flush();
|
|
5573
|
-
if (this.view.state == startState)
|
|
5574
|
-
this.view.update([]);
|
|
5586
|
+
this.delayedFlush = -1;
|
|
5587
|
+
if (!this.flush())
|
|
5588
|
+
dispatchKey(this.view.contentDOM, key.key, key.keyCode);
|
|
5575
5589
|
});
|
|
5576
5590
|
// Since backspace beforeinput is sometimes signalled spuriously,
|
|
5577
5591
|
// Enter always takes precedence.
|
|
@@ -5627,10 +5641,11 @@ class DOMObserver {
|
|
|
5627
5641
|
return;
|
|
5628
5642
|
this.selectionChanged = false;
|
|
5629
5643
|
let startState = this.view.state;
|
|
5630
|
-
this.onChange(from, to, typeOver);
|
|
5644
|
+
let handled = this.onChange(from, to, typeOver);
|
|
5631
5645
|
// The view wasn't updated
|
|
5632
5646
|
if (this.view.state == startState)
|
|
5633
5647
|
this.view.update([]);
|
|
5648
|
+
return handled;
|
|
5634
5649
|
}
|
|
5635
5650
|
readMutation(rec) {
|
|
5636
5651
|
let cView = this.view.docView.nearest(rec.target);
|
|
@@ -5713,7 +5728,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5713
5728
|
if (start > -1) {
|
|
5714
5729
|
let bounds = view.docView.domBoundsAround(start, end, 0);
|
|
5715
5730
|
if (!bounds || view.state.readOnly)
|
|
5716
|
-
return;
|
|
5731
|
+
return false;
|
|
5717
5732
|
let { from, to } = bounds;
|
|
5718
5733
|
let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints(view);
|
|
5719
5734
|
let reader = new DOMReader(selPoints, view.state);
|
|
@@ -5753,7 +5768,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5753
5768
|
newSel = EditorSelection.single(anchor, head);
|
|
5754
5769
|
}
|
|
5755
5770
|
if (!change && !newSel)
|
|
5756
|
-
return;
|
|
5771
|
+
return false;
|
|
5757
5772
|
// Heuristic to notice typing over a selected character
|
|
5758
5773
|
if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
|
|
5759
5774
|
change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
|
|
@@ -5769,13 +5784,13 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5769
5784
|
};
|
|
5770
5785
|
// Detect insert-period-on-double-space Mac behavior, and transform
|
|
5771
5786
|
// it into a regular space insert.
|
|
5772
|
-
else if (browser.mac && change && change.from == change.to && change.from == sel.head - 1 &&
|
|
5787
|
+
else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&
|
|
5773
5788
|
change.insert.toString() == ".")
|
|
5774
5789
|
change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
|
|
5775
5790
|
if (change) {
|
|
5776
5791
|
let startState = view.state;
|
|
5777
5792
|
if (browser.ios && view.inputState.flushIOSKey(view))
|
|
5778
|
-
return;
|
|
5793
|
+
return true;
|
|
5779
5794
|
// Android browsers don't fire reasonable key events for enter,
|
|
5780
5795
|
// backspace, or delete. So this detects changes that look like
|
|
5781
5796
|
// they're caused by those keys, and reinterprets them as key
|
|
@@ -5790,10 +5805,10 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5790
5805
|
dispatchKey(view.contentDOM, "Backspace", 8)) ||
|
|
5791
5806
|
(change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
|
|
5792
5807
|
dispatchKey(view.contentDOM, "Delete", 46))))
|
|
5793
|
-
return;
|
|
5808
|
+
return true;
|
|
5794
5809
|
let text = change.insert.toString();
|
|
5795
5810
|
if (view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text)))
|
|
5796
|
-
return;
|
|
5811
|
+
return true;
|
|
5797
5812
|
if (view.inputState.composing >= 0)
|
|
5798
5813
|
view.inputState.composing++;
|
|
5799
5814
|
let tr;
|
|
@@ -5849,6 +5864,7 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5849
5864
|
}
|
|
5850
5865
|
}
|
|
5851
5866
|
view.dispatch(tr, { scrollIntoView: true, userEvent });
|
|
5867
|
+
return true;
|
|
5852
5868
|
}
|
|
5853
5869
|
else if (newSel && !newSel.main.eq(sel)) {
|
|
5854
5870
|
let scrollIntoView = false, userEvent = "select";
|
|
@@ -5858,6 +5874,10 @@ function applyDOMChange(view, start, end, typeOver) {
|
|
|
5858
5874
|
userEvent = view.inputState.lastSelectionOrigin;
|
|
5859
5875
|
}
|
|
5860
5876
|
view.dispatch({ selection: newSel, scrollIntoView, userEvent });
|
|
5877
|
+
return true;
|
|
5878
|
+
}
|
|
5879
|
+
else {
|
|
5880
|
+
return false;
|
|
5861
5881
|
}
|
|
5862
5882
|
}
|
|
5863
5883
|
function findDiff(a, b, preferredPos, preferredSide) {
|
|
@@ -5934,11 +5954,7 @@ class EditorView {
|
|
|
5934
5954
|
option, or put `view.dom` into your document after creating a
|
|
5935
5955
|
view, so that the user can see the editor.
|
|
5936
5956
|
*/
|
|
5937
|
-
constructor(
|
|
5938
|
-
/**
|
|
5939
|
-
Initialization options.
|
|
5940
|
-
*/
|
|
5941
|
-
config = {}) {
|
|
5957
|
+
constructor(config = {}) {
|
|
5942
5958
|
this.plugins = [];
|
|
5943
5959
|
this.pluginMap = new Map;
|
|
5944
5960
|
this.editorAttrs = {};
|
|
@@ -5971,12 +5987,12 @@ class EditorView {
|
|
|
5971
5987
|
this._dispatch = config.dispatch || ((tr) => this.update([tr]));
|
|
5972
5988
|
this.dispatch = this.dispatch.bind(this);
|
|
5973
5989
|
this.root = (config.root || getRoot(config.parent) || document);
|
|
5974
|
-
this.viewState = new ViewState(config.state || EditorState.create());
|
|
5990
|
+
this.viewState = new ViewState(config.state || EditorState.create(config));
|
|
5975
5991
|
this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
|
|
5976
5992
|
for (let plugin of this.plugins)
|
|
5977
5993
|
plugin.update(this);
|
|
5978
5994
|
this.observer = new DOMObserver(this, (from, to, typeOver) => {
|
|
5979
|
-
applyDOMChange(this, from, to, typeOver);
|
|
5995
|
+
return applyDOMChange(this, from, to, typeOver);
|
|
5980
5996
|
}, event => {
|
|
5981
5997
|
this.inputState.runScrollHandlers(this, event);
|
|
5982
5998
|
if (this.observer.intersecting)
|
|
@@ -6057,6 +6073,7 @@ class EditorView {
|
|
|
6057
6073
|
this.viewState.state = state;
|
|
6058
6074
|
return;
|
|
6059
6075
|
}
|
|
6076
|
+
this.observer.clear();
|
|
6060
6077
|
// When the phrases change, redraw the editor
|
|
6061
6078
|
if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))
|
|
6062
6079
|
return this.setState(state);
|
|
@@ -6645,6 +6662,16 @@ class EditorView {
|
|
|
6645
6662
|
static baseTheme(spec) {
|
|
6646
6663
|
return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
|
|
6647
6664
|
}
|
|
6665
|
+
/**
|
|
6666
|
+
Retrieve an editor view instance from the view's DOM
|
|
6667
|
+
representation.
|
|
6668
|
+
*/
|
|
6669
|
+
static findFromDOM(dom) {
|
|
6670
|
+
var _a;
|
|
6671
|
+
let content = dom.querySelector(".cm-content");
|
|
6672
|
+
let cView = content && ContentView.get(content) || ContentView.get(dom);
|
|
6673
|
+
return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
|
|
6674
|
+
}
|
|
6648
6675
|
}
|
|
6649
6676
|
/**
|
|
6650
6677
|
Facet to add a [style
|
|
@@ -6934,7 +6961,8 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
6934
6961
|
return bound;
|
|
6935
6962
|
}
|
|
6936
6963
|
function runHandlers(map, event, view, scope) {
|
|
6937
|
-
let name = keyName(event)
|
|
6964
|
+
let name = keyName(event);
|
|
6965
|
+
let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
|
|
6938
6966
|
let prefix = "", fallthrough = false;
|
|
6939
6967
|
if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
|
|
6940
6968
|
prefix = storedPrefix.prefix + " ";
|
|
@@ -6955,10 +6983,13 @@ function runHandlers(map, event, view, scope) {
|
|
|
6955
6983
|
if (scopeObj) {
|
|
6956
6984
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
6957
6985
|
return true;
|
|
6958
|
-
if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
|
|
6986
|
+
if (isChar && (event.shiftKey || event.altKey || event.metaKey || charCode > 127) &&
|
|
6959
6987
|
(baseName = base[event.keyCode]) && baseName != name) {
|
|
6960
6988
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
6961
6989
|
return true;
|
|
6990
|
+
else if (event.shiftKey && shift[event.keyCode] != baseName &&
|
|
6991
|
+
runFor(scopeObj[prefix + modifiers(shift[event.keyCode], event, false)]))
|
|
6992
|
+
return true;
|
|
6962
6993
|
}
|
|
6963
6994
|
else if (isChar && event.shiftKey) {
|
|
6964
6995
|
if (runFor(scopeObj[prefix + modifiers(name, event, true)]))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "DOM view component for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@codemirror/state": "^0.
|
|
29
|
+
"@codemirror/state": "^6.0.0",
|
|
30
30
|
"style-mod": "^4.0.0",
|
|
31
31
|
"w3c-keyname": "^2.2.4"
|
|
32
32
|
},
|