@codemirror/view 0.20.7 → 6.0.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.
@@ -11,6 +11,6 @@ jobs:
11
11
  with:
12
12
  # You should create a personal access token and store it in your repository
13
13
  token: ${{ secrets.DISPATCH_AUTH }}
14
- repo: codemirror.next
14
+ repo: dev
15
15
  owner: codemirror
16
16
  event_type: push
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 6.0.2 (2022-06-23)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a CSS issue that broke horizontal scroll width stabilization.
6
+
7
+ Fix a bug where `defaultLineHeight` could get an incorrect value in very narrow editors.
8
+
9
+ ## 6.0.1 (2022-06-17)
10
+
11
+ ### Bug fixes
12
+
13
+ Avoid DOM selection corruption when the editor doesn't have focus but has selection and updates its content.
14
+
15
+ 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).
16
+
17
+ ## 6.0.0 (2022-06-08)
18
+
19
+ ### New features
20
+
21
+ The new static `EditorView.findFromDOM` method can be used to retrieve an editor instance from its DOM structure.
22
+
23
+ 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.
24
+
1
25
  ## 0.20.7 (2022-05-30)
2
26
 
3
27
  ### Bug fixes
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @codemirror/view [![NPM version](https://img.shields.io/npm/v/@codemirror/view.svg)](https://www.npmjs.org/package/@codemirror/view)
2
2
 
3
- [ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#view) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/view/blob/main/CHANGELOG.md) ]
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/) code editor.
6
+ [CodeMirror](https://codemirror.net/) code editor.
7
7
 
8
- The [project page](https://codemirror.net/6/) has more information, a
9
- number of [examples](https://codemirror.net/6/examples/) and the
10
- [documentation](https://codemirror.net/6/docs/).
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
@@ -2545,7 +2545,7 @@ class DocView extends ContentView {
2545
2545
  }
2546
2546
  // Sync the DOM selection to this.state.selection
2547
2547
  updateSelection(mustRead = false, fromPointer = false) {
2548
- if (mustRead)
2548
+ if (mustRead || !this.view.observer.selectionRange.focusNode)
2549
2549
  this.view.observer.readSelectionRange();
2550
2550
  if (!(fromPointer || this.mayControlSelection()) ||
2551
2551
  browser.ios && this.view.inputState.rapidCompositionStart)
@@ -2580,7 +2580,8 @@ class DocView extends ContentView {
2580
2580
  this.dom.focus({ preventScroll: true });
2581
2581
  }
2582
2582
  let rawSel = getSelection(this.root);
2583
- if (main.empty) {
2583
+ if (!rawSel) ;
2584
+ else if (main.empty) {
2584
2585
  // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
2585
2586
  if (browser.gecko) {
2586
2587
  let nextTo = nextToUneditable(anchor.node, anchor.offset);
@@ -2622,7 +2623,7 @@ class DocView extends ContentView {
2622
2623
  return;
2623
2624
  let cursor = this.view.state.selection.main;
2624
2625
  let sel = getSelection(this.root);
2625
- if (!cursor.empty || !cursor.assoc || !sel.modify)
2626
+ if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
2626
2627
  return;
2627
2628
  let line = LineView.find(this, cursor.head);
2628
2629
  if (!line)
@@ -2638,8 +2639,9 @@ class DocView extends ContentView {
2638
2639
  sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
2639
2640
  }
2640
2641
  mayControlSelection() {
2641
- return this.view.state.facet(editable) ? this.root.activeElement == this.dom
2642
- : hasSelection(this.dom, this.view.observer.selectionRange);
2642
+ let active = this.root.activeElement;
2643
+ return active == this.dom ||
2644
+ hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
2643
2645
  }
2644
2646
  nearest(dom) {
2645
2647
  for (let cur = dom; cur;) {
@@ -2724,6 +2726,7 @@ class DocView extends ContentView {
2724
2726
  // If no workable line exists, force a layout of a measurable element
2725
2727
  let dummy = document.createElement("div"), lineHeight, charWidth;
2726
2728
  dummy.className = "cm-line";
2729
+ dummy.style.width = "99999px";
2727
2730
  dummy.textContent = "abc def ghi jkl mno pqr stu";
2728
2731
  this.view.observer.ignore(() => {
2729
2732
  this.dom.appendChild(dummy);
@@ -3536,7 +3539,7 @@ function isInPrimarySelection(view, event) {
3536
3539
  // On boundary clicks, check whether the coordinates are inside the
3537
3540
  // selection's client rectangles
3538
3541
  let sel = getSelection(view.root);
3539
- if (sel.rangeCount == 0)
3542
+ if (!sel || sel.rangeCount == 0)
3540
3543
  return true;
3541
3544
  let rects = sel.getRangeAt(0).getClientRects();
3542
3545
  for (let i = 0; i < rects.length; i++) {
@@ -5164,6 +5167,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
5164
5167
  ".cm-content": {
5165
5168
  margin: 0,
5166
5169
  flexGrow: 2,
5170
+ flexShrink: 0,
5167
5171
  minHeight: "100%",
5168
5172
  display: "block",
5169
5173
  whiteSpace: "pre",
@@ -5179,7 +5183,8 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
5179
5183
  whiteSpace_fallback: "pre-wrap",
5180
5184
  whiteSpace: "break-spaces",
5181
5185
  wordBreak: "break-word",
5182
- overflowWrap: "anywhere"
5186
+ overflowWrap: "anywhere",
5187
+ flexShrink: 1
5183
5188
  },
5184
5189
  "&light .cm-content": { caretColor: "black" },
5185
5190
  "&dark .cm-content": { caretColor: "white" },
@@ -5495,12 +5500,12 @@ class DOMObserver {
5495
5500
  this.flush(false);
5496
5501
  }
5497
5502
  readSelectionRange() {
5498
- let { root } = this.view, domSel = getSelection(root);
5503
+ let { root } = this.view;
5499
5504
  // The Selection object is broken in shadow roots in Safari. See
5500
- // https://github.com/codemirror/codemirror.next/issues/414
5505
+ // https://github.com/codemirror/dev/issues/414
5501
5506
  let range = browser.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
5502
- safariSelectionRangeHack(this.view) || domSel;
5503
- if (this.selectionRange.eq(range))
5507
+ safariSelectionRangeHack(this.view) || getSelection(root);
5508
+ if (!range || this.selectionRange.eq(range))
5504
5509
  return false;
5505
5510
  this.selectionRange.setRange(range);
5506
5511
  return this.selectionChanged = true;
@@ -5959,11 +5964,7 @@ class EditorView {
5959
5964
  option, or put `view.dom` into your document after creating a
5960
5965
  view, so that the user can see the editor.
5961
5966
  */
5962
- constructor(
5963
- /**
5964
- Initialization options.
5965
- */
5966
- config = {}) {
5967
+ constructor(config = {}) {
5967
5968
  this.plugins = [];
5968
5969
  this.pluginMap = new Map;
5969
5970
  this.editorAttrs = {};
@@ -5996,7 +5997,7 @@ class EditorView {
5996
5997
  this._dispatch = config.dispatch || ((tr) => this.update([tr]));
5997
5998
  this.dispatch = this.dispatch.bind(this);
5998
5999
  this.root = (config.root || getRoot(config.parent) || document);
5999
- this.viewState = new ViewState(config.state || state.EditorState.create());
6000
+ this.viewState = new ViewState(config.state || state.EditorState.create(config));
6000
6001
  this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
6001
6002
  for (let plugin of this.plugins)
6002
6003
  plugin.update(this);
@@ -6671,6 +6672,16 @@ class EditorView {
6671
6672
  static baseTheme(spec) {
6672
6673
  return state.Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6673
6674
  }
6675
+ /**
6676
+ Retrieve an editor view instance from the view's DOM
6677
+ representation.
6678
+ */
6679
+ static findFromDOM(dom) {
6680
+ var _a;
6681
+ let content = dom.querySelector(".cm-content");
6682
+ let cView = content && ContentView.get(content) || ContentView.get(dom);
6683
+ return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
6684
+ }
6674
6685
  }
6675
6686
  /**
6676
6687
  Facet to add a [style
@@ -6960,7 +6971,8 @@ function buildKeymap(bindings, platform = currentPlatform) {
6960
6971
  return bound;
6961
6972
  }
6962
6973
  function runHandlers(map, event, view, scope) {
6963
- let name = w3cKeyname.keyName(event), isChar = name.length == 1 && name != " ";
6974
+ let name = w3cKeyname.keyName(event);
6975
+ let charCode = state.codePointAt(name, 0), isChar = state.codePointSize(charCode) == name.length && name != " ";
6964
6976
  let prefix = "", fallthrough = false;
6965
6977
  if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
6966
6978
  prefix = storedPrefix.prefix + " ";
@@ -6981,10 +6993,13 @@ function runHandlers(map, event, view, scope) {
6981
6993
  if (scopeObj) {
6982
6994
  if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
6983
6995
  return true;
6984
- if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
6996
+ if (isChar && (event.shiftKey || event.altKey || event.metaKey || charCode > 127) &&
6985
6997
  (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
6986
6998
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
6987
6999
  return true;
7000
+ else if (event.shiftKey && w3cKeyname.shift[event.keyCode] != baseName &&
7001
+ runFor(scopeObj[prefix + modifiers(w3cKeyname.shift[event.keyCode], event, false)]))
7002
+ return true;
6988
7003
  }
6989
7004
  else if (isChar && event.shiftKey) {
6990
7005
  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
- interface EditorConfig {
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. Defaults to an extension-less state
565
- with an empty document.
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, codePointAt, countColumn } from '@codemirror/state';
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;
@@ -2539,7 +2539,7 @@ class DocView extends ContentView {
2539
2539
  }
2540
2540
  // Sync the DOM selection to this.state.selection
2541
2541
  updateSelection(mustRead = false, fromPointer = false) {
2542
- if (mustRead)
2542
+ if (mustRead || !this.view.observer.selectionRange.focusNode)
2543
2543
  this.view.observer.readSelectionRange();
2544
2544
  if (!(fromPointer || this.mayControlSelection()) ||
2545
2545
  browser.ios && this.view.inputState.rapidCompositionStart)
@@ -2574,7 +2574,8 @@ class DocView extends ContentView {
2574
2574
  this.dom.focus({ preventScroll: true });
2575
2575
  }
2576
2576
  let rawSel = getSelection(this.root);
2577
- if (main.empty) {
2577
+ if (!rawSel) ;
2578
+ else if (main.empty) {
2578
2579
  // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
2579
2580
  if (browser.gecko) {
2580
2581
  let nextTo = nextToUneditable(anchor.node, anchor.offset);
@@ -2616,7 +2617,7 @@ class DocView extends ContentView {
2616
2617
  return;
2617
2618
  let cursor = this.view.state.selection.main;
2618
2619
  let sel = getSelection(this.root);
2619
- if (!cursor.empty || !cursor.assoc || !sel.modify)
2620
+ if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
2620
2621
  return;
2621
2622
  let line = LineView.find(this, cursor.head);
2622
2623
  if (!line)
@@ -2632,8 +2633,9 @@ class DocView extends ContentView {
2632
2633
  sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
2633
2634
  }
2634
2635
  mayControlSelection() {
2635
- return this.view.state.facet(editable) ? this.root.activeElement == this.dom
2636
- : hasSelection(this.dom, this.view.observer.selectionRange);
2636
+ let active = this.root.activeElement;
2637
+ return active == this.dom ||
2638
+ hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
2637
2639
  }
2638
2640
  nearest(dom) {
2639
2641
  for (let cur = dom; cur;) {
@@ -2718,6 +2720,7 @@ class DocView extends ContentView {
2718
2720
  // If no workable line exists, force a layout of a measurable element
2719
2721
  let dummy = document.createElement("div"), lineHeight, charWidth;
2720
2722
  dummy.className = "cm-line";
2723
+ dummy.style.width = "99999px";
2721
2724
  dummy.textContent = "abc def ghi jkl mno pqr stu";
2722
2725
  this.view.observer.ignore(() => {
2723
2726
  this.dom.appendChild(dummy);
@@ -3530,7 +3533,7 @@ function isInPrimarySelection(view, event) {
3530
3533
  // On boundary clicks, check whether the coordinates are inside the
3531
3534
  // selection's client rectangles
3532
3535
  let sel = getSelection(view.root);
3533
- if (sel.rangeCount == 0)
3536
+ if (!sel || sel.rangeCount == 0)
3534
3537
  return true;
3535
3538
  let rects = sel.getRangeAt(0).getClientRects();
3536
3539
  for (let i = 0; i < rects.length; i++) {
@@ -5157,6 +5160,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
5157
5160
  ".cm-content": {
5158
5161
  margin: 0,
5159
5162
  flexGrow: 2,
5163
+ flexShrink: 0,
5160
5164
  minHeight: "100%",
5161
5165
  display: "block",
5162
5166
  whiteSpace: "pre",
@@ -5172,7 +5176,8 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
5172
5176
  whiteSpace_fallback: "pre-wrap",
5173
5177
  whiteSpace: "break-spaces",
5174
5178
  wordBreak: "break-word",
5175
- overflowWrap: "anywhere"
5179
+ overflowWrap: "anywhere",
5180
+ flexShrink: 1
5176
5181
  },
5177
5182
  "&light .cm-content": { caretColor: "black" },
5178
5183
  "&dark .cm-content": { caretColor: "white" },
@@ -5488,12 +5493,12 @@ class DOMObserver {
5488
5493
  this.flush(false);
5489
5494
  }
5490
5495
  readSelectionRange() {
5491
- let { root } = this.view, domSel = getSelection(root);
5496
+ let { root } = this.view;
5492
5497
  // The Selection object is broken in shadow roots in Safari. See
5493
- // https://github.com/codemirror/codemirror.next/issues/414
5498
+ // https://github.com/codemirror/dev/issues/414
5494
5499
  let range = browser.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
5495
- safariSelectionRangeHack(this.view) || domSel;
5496
- if (this.selectionRange.eq(range))
5500
+ safariSelectionRangeHack(this.view) || getSelection(root);
5501
+ if (!range || this.selectionRange.eq(range))
5497
5502
  return false;
5498
5503
  this.selectionRange.setRange(range);
5499
5504
  return this.selectionChanged = true;
@@ -5952,11 +5957,7 @@ class EditorView {
5952
5957
  option, or put `view.dom` into your document after creating a
5953
5958
  view, so that the user can see the editor.
5954
5959
  */
5955
- constructor(
5956
- /**
5957
- Initialization options.
5958
- */
5959
- config = {}) {
5960
+ constructor(config = {}) {
5960
5961
  this.plugins = [];
5961
5962
  this.pluginMap = new Map;
5962
5963
  this.editorAttrs = {};
@@ -5989,7 +5990,7 @@ class EditorView {
5989
5990
  this._dispatch = config.dispatch || ((tr) => this.update([tr]));
5990
5991
  this.dispatch = this.dispatch.bind(this);
5991
5992
  this.root = (config.root || getRoot(config.parent) || document);
5992
- this.viewState = new ViewState(config.state || EditorState.create());
5993
+ this.viewState = new ViewState(config.state || EditorState.create(config));
5993
5994
  this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
5994
5995
  for (let plugin of this.plugins)
5995
5996
  plugin.update(this);
@@ -6664,6 +6665,16 @@ class EditorView {
6664
6665
  static baseTheme(spec) {
6665
6666
  return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6666
6667
  }
6668
+ /**
6669
+ Retrieve an editor view instance from the view's DOM
6670
+ representation.
6671
+ */
6672
+ static findFromDOM(dom) {
6673
+ var _a;
6674
+ let content = dom.querySelector(".cm-content");
6675
+ let cView = content && ContentView.get(content) || ContentView.get(dom);
6676
+ return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
6677
+ }
6667
6678
  }
6668
6679
  /**
6669
6680
  Facet to add a [style
@@ -6953,7 +6964,8 @@ function buildKeymap(bindings, platform = currentPlatform) {
6953
6964
  return bound;
6954
6965
  }
6955
6966
  function runHandlers(map, event, view, scope) {
6956
- let name = keyName(event), isChar = name.length == 1 && name != " ";
6967
+ let name = keyName(event);
6968
+ let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
6957
6969
  let prefix = "", fallthrough = false;
6958
6970
  if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
6959
6971
  prefix = storedPrefix.prefix + " ";
@@ -6974,10 +6986,13 @@ function runHandlers(map, event, view, scope) {
6974
6986
  if (scopeObj) {
6975
6987
  if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
6976
6988
  return true;
6977
- if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
6989
+ if (isChar && (event.shiftKey || event.altKey || event.metaKey || charCode > 127) &&
6978
6990
  (baseName = base[event.keyCode]) && baseName != name) {
6979
6991
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
6980
6992
  return true;
6993
+ else if (event.shiftKey && shift[event.keyCode] != baseName &&
6994
+ runFor(scopeObj[prefix + modifiers(shift[event.keyCode], event, false)]))
6995
+ return true;
6981
6996
  }
6982
6997
  else if (isChar && event.shiftKey) {
6983
6998
  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.20.7",
3
+ "version": "6.0.2",
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.20.0",
29
+ "@codemirror/state": "^6.0.0",
30
30
  "style-mod": "^4.0.0",
31
31
  "w3c-keyname": "^2.2.4"
32
32
  },