@codemirror/view 6.7.1 → 6.7.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 6.7.2 (2023-01-04)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a regression where the cursor didn't restart its blink cycle when moving it with the pointer.
6
+
7
+ Even without a `key` property, measure request objects that are already scheduled will not be scheduled again by `requestMeasure`.
8
+
9
+ Fix an issue where keymaps incorrectly interpreted key events that used Ctrl+Alt modifiers to simulate AltGr on Windows.
10
+
11
+ Fix a bug where line decorations with a different `class` property would be treated as equal.
12
+
13
+ Fix a bug that caused `drawSelection` to not notice when it was reconfigured.
14
+
15
+ Fix a crash in the gutter extension caused by sharing of mutable arrays.
16
+
17
+ Fix a regression that caused touch selection on mobile platforms to not work in an uneditable editor.
18
+
19
+ Fix a bug where DOM events on the boundary between lines could get assigned to the wrong line.
20
+
1
21
  ## 6.7.1 (2022-12-12)
2
22
 
3
23
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1348,7 +1348,9 @@ class LineDecoration extends Decoration {
1348
1348
  super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
1349
1349
  }
1350
1350
  eq(other) {
1351
- return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
1351
+ return other instanceof LineDecoration &&
1352
+ this.spec.class == other.spec.class &&
1353
+ attrsEq(this.spec.attributes, other.spec.attributes);
1352
1354
  }
1353
1355
  range(from, to = from) {
1354
1356
  if (to != from)
@@ -5325,7 +5327,7 @@ function buildTheme(main, spec, scopes) {
5325
5327
  });
5326
5328
  }
5327
5329
  const baseTheme$1 = buildTheme("." + baseThemeID, {
5328
- "&.cm-editor": {
5330
+ "&": {
5329
5331
  position: "relative !important",
5330
5332
  boxSizing: "border-box",
5331
5333
  "&.cm-focused": {
@@ -5609,7 +5611,7 @@ function applyDOMChange(view, domChange) {
5609
5611
  insert: state.Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
5610
5612
  }
5611
5613
  }
5612
- else if (newSel && (!view.hasFocus || !view.state.facet(editable) || newSel.main.eq(sel))) {
5614
+ else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
5613
5615
  newSel = null;
5614
5616
  }
5615
5617
  if (!change && !newSel)
@@ -6673,6 +6675,8 @@ class EditorView {
6673
6675
  if (this.measureScheduled < 0)
6674
6676
  this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
6675
6677
  if (request) {
6678
+ if (this.measureRequests.indexOf(request) > -1)
6679
+ return;
6676
6680
  if (request.key != null)
6677
6681
  for (let i = 0; i < this.measureRequests.length; i++) {
6678
6682
  if (this.measureRequests[i].key === request.key) {
@@ -7356,6 +7360,8 @@ function runHandlers(map, event, view, scope) {
7356
7360
  if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
7357
7361
  return true;
7358
7362
  if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
7363
+ // Ctrl-Alt may be used for AltGr on Windows
7364
+ !(browser.windows && event.ctrlKey && event.altKey) &&
7359
7365
  (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
7360
7366
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
7361
7367
  return true;
@@ -7650,7 +7656,7 @@ function drawSelection(config = {}) {
7650
7656
  ];
7651
7657
  }
7652
7658
  function configChanged(update) {
7653
- return update.startState.facet(selectionConfig) != update.startState.facet(selectionConfig);
7659
+ return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
7654
7660
  }
7655
7661
  const cursorLayer = layer({
7656
7662
  above: true,
@@ -7669,7 +7675,7 @@ const cursorLayer = layer({
7669
7675
  return cursors;
7670
7676
  },
7671
7677
  update(update, dom) {
7672
- if (update.transactions.some(tr => tr.scrollIntoView))
7678
+ if (update.transactions.some(tr => tr.selection))
7673
7679
  dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
7674
7680
  let confChange = configChanged(update);
7675
7681
  if (confChange)
@@ -9235,15 +9241,14 @@ class UpdateContext {
9235
9241
  constructor(gutter, viewport, height) {
9236
9242
  this.gutter = gutter;
9237
9243
  this.height = height;
9238
- this.localMarkers = [];
9239
9244
  this.i = 0;
9240
9245
  this.cursor = state.RangeSet.iter(gutter.markers, viewport.from);
9241
9246
  }
9242
9247
  line(view, line, extraMarkers) {
9243
- if (this.localMarkers.length)
9244
- this.localMarkers = [];
9245
- advanceCursor(this.cursor, this.localMarkers, line.from);
9246
- let localMarkers = extraMarkers.length ? this.localMarkers.concat(extraMarkers) : this.localMarkers;
9248
+ let localMarkers = [];
9249
+ advanceCursor(this.cursor, localMarkers, line.from);
9250
+ if (extraMarkers.length)
9251
+ localMarkers = localMarkers.concat(extraMarkers);
9247
9252
  let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
9248
9253
  if (forLine)
9249
9254
  localMarkers.unshift(forLine);
@@ -9281,7 +9286,17 @@ class SingleGutterView {
9281
9286
  this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
9282
9287
  for (let prop in config.domEventHandlers) {
9283
9288
  this.dom.addEventListener(prop, (event) => {
9284
- let line = view.lineBlockAtHeight(event.clientY - view.documentTop);
9289
+ let target = event.target, y;
9290
+ if (target != this.dom && this.dom.contains(target)) {
9291
+ while (target.parentNode != this.dom)
9292
+ target = target.parentNode;
9293
+ let rect = target.getBoundingClientRect();
9294
+ y = (rect.top + rect.bottom) / 2;
9295
+ }
9296
+ else {
9297
+ y = event.clientY;
9298
+ }
9299
+ let line = view.lineBlockAtHeight(y - view.documentTop);
9285
9300
  if (config.domEventHandlers[prop](view, line, event))
9286
9301
  event.preventDefault();
9287
9302
  });
package/dist/index.js CHANGED
@@ -1343,7 +1343,9 @@ class LineDecoration extends Decoration {
1343
1343
  super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
1344
1344
  }
1345
1345
  eq(other) {
1346
- return other instanceof LineDecoration && attrsEq(this.spec.attributes, other.spec.attributes);
1346
+ return other instanceof LineDecoration &&
1347
+ this.spec.class == other.spec.class &&
1348
+ attrsEq(this.spec.attributes, other.spec.attributes);
1347
1349
  }
1348
1350
  range(from, to = from) {
1349
1351
  if (to != from)
@@ -5318,7 +5320,7 @@ function buildTheme(main, spec, scopes) {
5318
5320
  });
5319
5321
  }
5320
5322
  const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
5321
- "&.cm-editor": {
5323
+ "&": {
5322
5324
  position: "relative !important",
5323
5325
  boxSizing: "border-box",
5324
5326
  "&.cm-focused": {
@@ -5602,7 +5604,7 @@ function applyDOMChange(view, domChange) {
5602
5604
  insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
5603
5605
  }
5604
5606
  }
5605
- else if (newSel && (!view.hasFocus || !view.state.facet(editable) || newSel.main.eq(sel))) {
5607
+ else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
5606
5608
  newSel = null;
5607
5609
  }
5608
5610
  if (!change && !newSel)
@@ -6666,6 +6668,8 @@ class EditorView {
6666
6668
  if (this.measureScheduled < 0)
6667
6669
  this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
6668
6670
  if (request) {
6671
+ if (this.measureRequests.indexOf(request) > -1)
6672
+ return;
6669
6673
  if (request.key != null)
6670
6674
  for (let i = 0; i < this.measureRequests.length; i++) {
6671
6675
  if (this.measureRequests[i].key === request.key) {
@@ -7349,6 +7353,8 @@ function runHandlers(map, event, view, scope) {
7349
7353
  if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
7350
7354
  return true;
7351
7355
  if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
7356
+ // Ctrl-Alt may be used for AltGr on Windows
7357
+ !(browser.windows && event.ctrlKey && event.altKey) &&
7352
7358
  (baseName = base[event.keyCode]) && baseName != name) {
7353
7359
  if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
7354
7360
  return true;
@@ -7643,7 +7649,7 @@ function drawSelection(config = {}) {
7643
7649
  ];
7644
7650
  }
7645
7651
  function configChanged(update) {
7646
- return update.startState.facet(selectionConfig) != update.startState.facet(selectionConfig);
7652
+ return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
7647
7653
  }
7648
7654
  const cursorLayer = /*@__PURE__*/layer({
7649
7655
  above: true,
@@ -7662,7 +7668,7 @@ const cursorLayer = /*@__PURE__*/layer({
7662
7668
  return cursors;
7663
7669
  },
7664
7670
  update(update, dom) {
7665
- if (update.transactions.some(tr => tr.scrollIntoView))
7671
+ if (update.transactions.some(tr => tr.selection))
7666
7672
  dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
7667
7673
  let confChange = configChanged(update);
7668
7674
  if (confChange)
@@ -9228,15 +9234,14 @@ class UpdateContext {
9228
9234
  constructor(gutter, viewport, height) {
9229
9235
  this.gutter = gutter;
9230
9236
  this.height = height;
9231
- this.localMarkers = [];
9232
9237
  this.i = 0;
9233
9238
  this.cursor = RangeSet.iter(gutter.markers, viewport.from);
9234
9239
  }
9235
9240
  line(view, line, extraMarkers) {
9236
- if (this.localMarkers.length)
9237
- this.localMarkers = [];
9238
- advanceCursor(this.cursor, this.localMarkers, line.from);
9239
- let localMarkers = extraMarkers.length ? this.localMarkers.concat(extraMarkers) : this.localMarkers;
9241
+ let localMarkers = [];
9242
+ advanceCursor(this.cursor, localMarkers, line.from);
9243
+ if (extraMarkers.length)
9244
+ localMarkers = localMarkers.concat(extraMarkers);
9240
9245
  let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
9241
9246
  if (forLine)
9242
9247
  localMarkers.unshift(forLine);
@@ -9274,7 +9279,17 @@ class SingleGutterView {
9274
9279
  this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
9275
9280
  for (let prop in config.domEventHandlers) {
9276
9281
  this.dom.addEventListener(prop, (event) => {
9277
- let line = view.lineBlockAtHeight(event.clientY - view.documentTop);
9282
+ let target = event.target, y;
9283
+ if (target != this.dom && this.dom.contains(target)) {
9284
+ while (target.parentNode != this.dom)
9285
+ target = target.parentNode;
9286
+ let rect = target.getBoundingClientRect();
9287
+ y = (rect.top + rect.bottom) / 2;
9288
+ }
9289
+ else {
9290
+ y = event.clientY;
9291
+ }
9292
+ let line = view.lineBlockAtHeight(y - view.documentTop);
9278
9293
  if (config.domEventHandlers[prop](view, line, event))
9279
9294
  event.preventDefault();
9280
9295
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.7.1",
3
+ "version": "6.7.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",