@codemirror/view 6.36.5 → 6.36.7

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,21 @@
1
+ ## 6.36.7 (2025-05-02)
2
+
3
+ ### Bug fixes
4
+
5
+ Use the `aria-placeholder` attribute to communicate the placeholder text to screen readers.
6
+
7
+ Fix a crash when `EditorView.composing` or `.compositionStarted` are accessed during view initialization.
8
+
9
+ ## 6.36.6 (2025-04-24)
10
+
11
+ ### Bug fixes
12
+
13
+ Fix an issue where `drawSelection` would draw selections starting at a block widget not at a line break in an odd way.
14
+
15
+ Fix an issue where the editor would inappropriately scroll when editing near the bottom of the document with line wrapping enabled, in some cases.
16
+
17
+ Fix an issue that caused unnecessary transactions on focus change.
18
+
1
19
  ## 6.36.5 (2025-03-29)
2
20
 
3
21
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -3660,17 +3660,26 @@ function isSuspiciousChromeCaretResult(node, offset, x) {
3660
3660
  : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
3661
3661
  return x - rect.left > 5;
3662
3662
  }
3663
- function blockAt(view, pos) {
3663
+ function blockAt(view, pos, side) {
3664
3664
  let line = view.lineBlockAt(pos);
3665
- if (Array.isArray(line.type))
3665
+ if (Array.isArray(line.type)) {
3666
+ let best;
3666
3667
  for (let l of line.type) {
3667
- if (l.to > pos || l.to == pos && (l.to == line.to || l.type == exports.BlockType.Text))
3668
+ if (l.from > pos)
3669
+ break;
3670
+ if (l.to < pos)
3671
+ continue;
3672
+ if (l.from < pos && l.to > pos)
3668
3673
  return l;
3674
+ if (!best || (l.type == exports.BlockType.Text && (best.type != l.type || (side < 0 ? l.from < pos : l.to > pos))))
3675
+ best = l;
3669
3676
  }
3677
+ return best || line;
3678
+ }
3670
3679
  return line;
3671
3680
  }
3672
3681
  function moveToLineBoundary(view, start, forward, includeWrap) {
3673
- let line = blockAt(view, start.head);
3682
+ let line = blockAt(view, start.head, start.assoc || -1);
3674
3683
  let coords = !includeWrap || line.type != exports.BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
3675
3684
  : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
3676
3685
  if (coords) {
@@ -4905,7 +4914,7 @@ function focusChangeTransaction(state, focus) {
4905
4914
  if (effect)
4906
4915
  effects.push(effect);
4907
4916
  }
4908
- return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
4917
+ return effects.length ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
4909
4918
  }
4910
4919
  function updateForFocusChange(view) {
4911
4920
  setTimeout(() => {
@@ -5941,7 +5950,7 @@ class ViewState {
5941
5950
  }
5942
5951
  else {
5943
5952
  this.scrollAnchorPos = -1;
5944
- this.scrollAnchorHeight = this.heightMap.height;
5953
+ this.scrollAnchorHeight = prevHeight;
5945
5954
  }
5946
5955
  let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
5947
5956
  if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
@@ -7437,14 +7446,14 @@ class EditorView {
7437
7446
  [IME](https://en.wikipedia.org/wiki/Input_method), and at least
7438
7447
  one change has been made in the current composition.
7439
7448
  */
7440
- get composing() { return this.inputState.composing > 0; }
7449
+ get composing() { return !!this.inputState && this.inputState.composing > 0; }
7441
7450
  /**
7442
7451
  Indicates whether the user is currently in composing state. Note
7443
7452
  that on some platforms, like Android, this will be the case a
7444
7453
  lot, since just putting the cursor on a word starts a
7445
7454
  composition there.
7446
7455
  */
7447
- get compositionStarted() { return this.inputState.composing >= 0; }
7456
+ get compositionStarted() { return !!this.inputState && this.inputState.composing >= 0; }
7448
7457
  /**
7449
7458
  The document or shadow root that the view lives in.
7450
7459
  */
@@ -8871,7 +8880,7 @@ function rectanglesForRange(view, className, range) {
8871
8880
  let leftSide = contentRect.left +
8872
8881
  (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
8873
8882
  let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
8874
- let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
8883
+ let startBlock = blockAt(view, from, 1), endBlock = blockAt(view, to, -1);
8875
8884
  let visualStart = startBlock.type == exports.BlockType.Text ? startBlock : null;
8876
8885
  let visualEnd = endBlock.type == exports.BlockType.Text ? endBlock : null;
8877
8886
  if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
@@ -9585,10 +9594,7 @@ class Placeholder extends WidgetType {
9585
9594
  wrap.appendChild(typeof this.content == "string" ? document.createTextNode(this.content) :
9586
9595
  typeof this.content == "function" ? this.content(view) :
9587
9596
  this.content.cloneNode(true));
9588
- if (typeof this.content == "string")
9589
- wrap.setAttribute("aria-label", "placeholder " + this.content);
9590
- else
9591
- wrap.setAttribute("aria-hidden", "true");
9597
+ wrap.setAttribute("aria-hidden", "true");
9592
9598
  return wrap;
9593
9599
  }
9594
9600
  coordsAt(dom) {
@@ -9609,7 +9615,7 @@ Extension that enables a placeholder—a piece of example content
9609
9615
  to show when the editor is empty.
9610
9616
  */
9611
9617
  function placeholder(content) {
9612
- return ViewPlugin.fromClass(class {
9618
+ let plugin = ViewPlugin.fromClass(class {
9613
9619
  constructor(view) {
9614
9620
  this.view = view;
9615
9621
  this.placeholder = content
@@ -9618,6 +9624,9 @@ function placeholder(content) {
9618
9624
  }
9619
9625
  get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }
9620
9626
  }, { decorations: v => v.decorations });
9627
+ return typeof content == "string" ? [
9628
+ plugin, EditorView.contentAttributes.of({ "aria-placeholder": content })
9629
+ ] : plugin;
9621
9630
  }
9622
9631
 
9623
9632
  // Don't compute precise column positions for line offsets above this
package/dist/index.js CHANGED
@@ -3656,17 +3656,26 @@ function isSuspiciousChromeCaretResult(node, offset, x) {
3656
3656
  : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
3657
3657
  return x - rect.left > 5;
3658
3658
  }
3659
- function blockAt(view, pos) {
3659
+ function blockAt(view, pos, side) {
3660
3660
  let line = view.lineBlockAt(pos);
3661
- if (Array.isArray(line.type))
3661
+ if (Array.isArray(line.type)) {
3662
+ let best;
3662
3663
  for (let l of line.type) {
3663
- if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
3664
+ if (l.from > pos)
3665
+ break;
3666
+ if (l.to < pos)
3667
+ continue;
3668
+ if (l.from < pos && l.to > pos)
3664
3669
  return l;
3670
+ if (!best || (l.type == BlockType.Text && (best.type != l.type || (side < 0 ? l.from < pos : l.to > pos))))
3671
+ best = l;
3665
3672
  }
3673
+ return best || line;
3674
+ }
3666
3675
  return line;
3667
3676
  }
3668
3677
  function moveToLineBoundary(view, start, forward, includeWrap) {
3669
- let line = blockAt(view, start.head);
3678
+ let line = blockAt(view, start.head, start.assoc || -1);
3670
3679
  let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
3671
3680
  : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
3672
3681
  if (coords) {
@@ -4901,7 +4910,7 @@ function focusChangeTransaction(state, focus) {
4901
4910
  if (effect)
4902
4911
  effects.push(effect);
4903
4912
  }
4904
- return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
4913
+ return effects.length ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
4905
4914
  }
4906
4915
  function updateForFocusChange(view) {
4907
4916
  setTimeout(() => {
@@ -5936,7 +5945,7 @@ class ViewState {
5936
5945
  }
5937
5946
  else {
5938
5947
  this.scrollAnchorPos = -1;
5939
- this.scrollAnchorHeight = this.heightMap.height;
5948
+ this.scrollAnchorHeight = prevHeight;
5940
5949
  }
5941
5950
  let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
5942
5951
  if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
@@ -7432,14 +7441,14 @@ class EditorView {
7432
7441
  [IME](https://en.wikipedia.org/wiki/Input_method), and at least
7433
7442
  one change has been made in the current composition.
7434
7443
  */
7435
- get composing() { return this.inputState.composing > 0; }
7444
+ get composing() { return !!this.inputState && this.inputState.composing > 0; }
7436
7445
  /**
7437
7446
  Indicates whether the user is currently in composing state. Note
7438
7447
  that on some platforms, like Android, this will be the case a
7439
7448
  lot, since just putting the cursor on a word starts a
7440
7449
  composition there.
7441
7450
  */
7442
- get compositionStarted() { return this.inputState.composing >= 0; }
7451
+ get compositionStarted() { return !!this.inputState && this.inputState.composing >= 0; }
7443
7452
  /**
7444
7453
  The document or shadow root that the view lives in.
7445
7454
  */
@@ -8866,7 +8875,7 @@ function rectanglesForRange(view, className, range) {
8866
8875
  let leftSide = contentRect.left +
8867
8876
  (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
8868
8877
  let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
8869
- let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
8878
+ let startBlock = blockAt(view, from, 1), endBlock = blockAt(view, to, -1);
8870
8879
  let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
8871
8880
  let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
8872
8881
  if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
@@ -9580,10 +9589,7 @@ class Placeholder extends WidgetType {
9580
9589
  wrap.appendChild(typeof this.content == "string" ? document.createTextNode(this.content) :
9581
9590
  typeof this.content == "function" ? this.content(view) :
9582
9591
  this.content.cloneNode(true));
9583
- if (typeof this.content == "string")
9584
- wrap.setAttribute("aria-label", "placeholder " + this.content);
9585
- else
9586
- wrap.setAttribute("aria-hidden", "true");
9592
+ wrap.setAttribute("aria-hidden", "true");
9587
9593
  return wrap;
9588
9594
  }
9589
9595
  coordsAt(dom) {
@@ -9604,7 +9610,7 @@ Extension that enables a placeholder—a piece of example content
9604
9610
  to show when the editor is empty.
9605
9611
  */
9606
9612
  function placeholder(content) {
9607
- return ViewPlugin.fromClass(class {
9613
+ let plugin = ViewPlugin.fromClass(class {
9608
9614
  constructor(view) {
9609
9615
  this.view = view;
9610
9616
  this.placeholder = content
@@ -9613,6 +9619,9 @@ function placeholder(content) {
9613
9619
  }
9614
9620
  get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }
9615
9621
  }, { decorations: v => v.decorations });
9622
+ return typeof content == "string" ? [
9623
+ plugin, EditorView.contentAttributes.of({ "aria-placeholder": content })
9624
+ ] : plugin;
9616
9625
  }
9617
9626
 
9618
9627
  // Don't compute precise column positions for line offsets above this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.36.5",
3
+ "version": "6.36.7",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",
package/tdrawlog.txt ADDED
@@ -0,0 +1,96 @@
1
+ 372 --- Process Attached
2
+ 372 --- lmap success
3
+ 372 --- Init TAConfig
4
+ 372 --- Install Limit Crack
5
+ 372 --- IncreaseAISearchMapEntriesLimit
6
+ 372 --- WriteNewLimit
7
+ 372 --- IncreaseCompositeBuf
8
+ 372 --- IncreaseSfxLimit
9
+ 372 --- FullScreenMinimap init
10
+ 372 --- DirectDrawCreate
11
+ 372 --- IDDraw Created
12
+ 372 --- returning from DirectDrawCreate
13
+ 372 --- SetCooperativeLevel
14
+ 372 --- SetCooperativeLevel, GUI theadid = 372
15
+ 372 --- SetDisplayMode
16
+ 372 --- CreateSurface
17
+ 372 --- New Dialog
18
+ 372 --- New AlliesWhiteboard
19
+ 372 --- New CIncome
20
+ 372 --- New CTAHook
21
+ 372 --- New CWarp
22
+ 372 --- New CMapRect
23
+ 372 --- New CChangeQueue
24
+ 372 --- New CMinimapHandler
25
+ 372 --- IDDrawSurface Created
26
+ 372 --- GetAttachedSurface
27
+ 372 --- CreateClipper
28
+ 372 --- SetClipper
29
+ 372 --- CreatePalette
30
+ 372 --- SetPalette
31
+ 372 --- New ExternQuickKey
32
+ 372 --- Blt
33
+ 404 --- MegamapTAStuff
34
+ 404 --- UnitsMap Surface Init
35
+ 372 --- IsLost
36
+ 372 --- [DDrawSurface::Release] ...
37
+ 372 --- DDRAW::Release
38
+ 372 --- DirectDrawCreate
39
+ 372 --- IDDraw Created
40
+ 372 --- returning from DirectDrawCreate
41
+ 372 --- SetCooperativeLevel
42
+ 372 --- SetCooperativeLevel, GUI theadid = 372
43
+ 372 --- SetDisplayMode
44
+ 372 --- CreateSurface
45
+ 372 --- New Dialog
46
+ 372 --- New AlliesWhiteboard
47
+ 372 --- New CIncome
48
+ 372 --- New CTAHook
49
+ 372 --- New CWarp
50
+ 372 --- New CMapRect
51
+ 372 --- New CChangeQueue
52
+ 372 --- New CMinimapHandler
53
+ 372 --- UnitsMap Surface Init
54
+ 372 --- IDDrawSurface Created
55
+ 372 --- GetAttachedSurface
56
+ 372 --- CreateClipper
57
+ 372 --- SetClipper
58
+ 372 --- CreatePalette
59
+ 372 --- SetPalette
60
+ 372 --- [WindSpeedSyncProc] initialsing RNG using current time. t=809896644
61
+ 372 --- InitPictureColors
62
+ 372 --- InitUnSelectedPictureColors
63
+ 372 --- InitUnSelectedPictureColors
64
+ 372 --- IsLost
65
+ 372 --- [DDrawSurface::Release] ...
66
+ 372 --- DDRAW::Release
67
+ 372 --- DirectDrawCreate
68
+ 372 --- IDDraw Created
69
+ 372 --- returning from DirectDrawCreate
70
+ 372 --- SetCooperativeLevel
71
+ 372 --- SetCooperativeLevel, GUI theadid = 372
72
+ 372 --- SetDisplayMode
73
+ 372 --- CreateSurface
74
+ 372 --- New Dialog
75
+ 372 --- New AlliesWhiteboard
76
+ 372 --- New CIncome
77
+ 372 --- New CTAHook
78
+ 372 --- New CWarp
79
+ 372 --- New CMapRect
80
+ 372 --- New CChangeQueue
81
+ 372 --- New CMinimapHandler
82
+ 372 --- UnitsMap Surface Init
83
+ 372 --- IDDrawSurface Created
84
+ 372 --- GetAttachedSurface
85
+ 372 --- CreateClipper
86
+ 372 --- SetClipper
87
+ 372 --- CreatePalette
88
+ 372 --- SetPalette
89
+ 372 --- [DDrawSurface::Release] ...
90
+ 372 --- DDRAW::Release
91
+ 372 --- Release AddtionRoutine_CircleSelect
92
+ 372 --- Uninstall Limit Crack
93
+ 372 --- Release IncreaseUnitTypeLimit
94
+ 372 --- Release IncreaseCompositeBuf
95
+ 372 --- Release IncreaseSfxLimit
96
+ 372 --- Release AddtionRoutine_CircleSelect