@veltra/desktop 1.9.2 → 1.11.0

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.
Files changed (110) hide show
  1. package/dist/components/ai-button/ai-button.js +117 -0
  2. package/dist/components/ai-button/ai-button.js.map +1 -0
  3. package/dist/components/ai-button/style.d.ts +1 -0
  4. package/dist/components/ai-button/style.js +3 -0
  5. package/dist/components/ai-button/style2.css +29 -0
  6. package/dist/components/code-editor/basic-setup.js +5 -5
  7. package/dist/components/code-editor/code-editor.js +2 -2
  8. package/dist/components/code-editor/langs/bash/index.js +2 -2
  9. package/dist/components/code-editor/langs/powershell/index.js +2 -2
  10. package/dist/components/code-editor/langs/spel/index.js +1 -1
  11. package/dist/components/code-editor/langs/spel/language.js +1 -1
  12. package/dist/components/code-editor/shell-extension.js +2 -2
  13. package/dist/components/file-viewer/previewers/pdf-worker-wrapper.js.map +1 -1
  14. package/dist/components/file-viewer/previewers/sheet-previewer.js +10 -14
  15. package/dist/components/file-viewer/previewers/sheet-previewer.js.map +1 -1
  16. package/dist/components/file-viewer/style2.css +42 -176
  17. package/dist/components/index.d.ts +2 -1
  18. package/dist/components/index.js +3 -1
  19. package/dist/components/index.js.map +1 -1
  20. package/dist/index.d.ts +108 -106
  21. package/dist/index.js +107 -106
  22. package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +3 -3
  23. package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
  24. package/dist/node_modules/.bun/{@codemirror_commands@6.11.0 → @codemirror_commands@6.11.1}/node_modules/@codemirror/commands/dist/index.js +7 -7
  25. package/dist/node_modules/.bun/@codemirror_commands@6.11.1/node_modules/@codemirror/commands/dist/index.js.map +1 -0
  26. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +3 -3
  27. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -1
  28. package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js +3 -3
  29. package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js.map +1 -1
  30. package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +2 -2
  31. package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js.map +1 -1
  32. package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +5 -5
  33. package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -1
  34. package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +1 -1
  35. package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js.map +1 -1
  36. package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js +5 -5
  37. package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js.map +1 -1
  38. package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +3 -3
  39. package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -1
  40. package/dist/node_modules/.bun/{@codemirror_language@6.12.4 → @codemirror_language@6.13.1}/node_modules/@codemirror/language/dist/index.js +8 -171
  41. package/dist/node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
  42. package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js +1 -1
  43. package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js.map +1 -1
  44. package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js +1 -1
  45. package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js.map +1 -1
  46. package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +2 -2
  47. package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js.map +1 -1
  48. package/dist/node_modules/.bun/{@codemirror_search@6.7.1 → @codemirror_search@6.7.2}/node_modules/@codemirror/search/dist/index.js +10 -3
  49. package/dist/node_modules/.bun/@codemirror_search@6.7.2/node_modules/@codemirror/search/dist/index.js.map +1 -0
  50. package/dist/node_modules/.bun/{@codemirror_state@6.7.1 → @codemirror_state@6.7.6}/node_modules/@codemirror/state/dist/index.js +51 -17
  51. package/dist/node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js.map +1 -0
  52. package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js +169 -0
  53. package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js.map +1 -0
  54. package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +3 -3
  55. package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -1
  56. package/dist/node_modules/.bun/{@codemirror_view@6.43.9 → @codemirror_view@6.43.14}/node_modules/@codemirror/view/dist/index.js +160 -94
  57. package/dist/node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js.map +1 -0
  58. package/dist/node_modules/.bun/{@lezer_common@1.5.2 → @lezer_common@1.5.3}/node_modules/@lezer/common/dist/index.js +4 -4
  59. package/dist/node_modules/.bun/{@lezer_common@1.5.2 → @lezer_common@1.5.3}/node_modules/@lezer/common/dist/index.js.map +1 -1
  60. package/dist/node_modules/.bun/@lezer_css@1.3.9/node_modules/@lezer/css/dist/index.js +278 -0
  61. package/dist/node_modules/.bun/@lezer_css@1.3.9/node_modules/@lezer/css/dist/index.js.map +1 -0
  62. package/dist/node_modules/.bun/{@lezer_highlight@1.2.3 → @lezer_highlight@1.2.5}/node_modules/@lezer/highlight/dist/index.js +4 -4
  63. package/dist/node_modules/.bun/@lezer_highlight@1.2.5/node_modules/@lezer/highlight/dist/index.js.map +1 -0
  64. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +3 -3
  65. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -1
  66. package/dist/node_modules/.bun/@lezer_java@1.1.5/node_modules/@lezer/java/dist/index.js +240 -0
  67. package/dist/node_modules/.bun/@lezer_java@1.1.5/node_modules/@lezer/java/dist/index.js.map +1 -0
  68. package/dist/node_modules/.bun/@lezer_javascript@1.5.6/node_modules/@lezer/javascript/dist/index.js +491 -0
  69. package/dist/node_modules/.bun/@lezer_javascript@1.5.6/node_modules/@lezer/javascript/dist/index.js.map +1 -0
  70. package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js +2 -2
  71. package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js.map +1 -1
  72. package/dist/node_modules/.bun/{@lezer_lr@1.4.10 → @lezer_lr@1.4.11}/node_modules/@lezer/lr/dist/index.js +41 -29
  73. package/dist/node_modules/.bun/@lezer_lr@1.4.11/node_modules/@lezer/lr/dist/index.js.map +1 -0
  74. package/dist/node_modules/.bun/{@lezer_markdown@1.7.2 → @lezer_markdown@1.8.0}/node_modules/@lezer/markdown/dist/index.js +17 -8
  75. package/dist/node_modules/.bun/@lezer_markdown@1.8.0/node_modules/@lezer/markdown/dist/index.js.map +1 -0
  76. package/dist/node_modules/.bun/{@marijn_find-cluster-break@1.0.3 → @marijn_find-cluster-break@1.0.4}/node_modules/@marijn/find-cluster-break/src/index.js +2 -2
  77. package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.4/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -0
  78. package/dist/node_modules/.bun/crelt@1.0.7/node_modules/crelt/index.js.map +1 -1
  79. package/dist/node_modules/.bun/{style-mod@4.1.3 → style-mod@4.1.4}/node_modules/style-mod/src/style-mod.js +9 -4
  80. package/dist/node_modules/.bun/style-mod@4.1.4/node_modules/style-mod/src/style-mod.js.map +1 -0
  81. package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js.map +1 -1
  82. package/dist/types/ai-button.d.ts +42 -0
  83. package/dist/types/index.d.ts +2 -1
  84. package/package.json +16 -22
  85. package/src/components/ai-button/__test__/ai-button.test.ts +375 -0
  86. package/src/components/ai-button/ai-button.vue +87 -0
  87. package/src/components/ai-button/index.ts +1 -0
  88. package/src/components/ai-button/style.scss +19 -0
  89. package/src/components/ai-button/style.ts +3 -0
  90. package/src/components/file-viewer/previewers/sheet-previewer.vue +7 -12
  91. package/src/components/file-viewer/style.scss +52 -233
  92. package/src/components/index.ts +2 -0
  93. package/src/types/ai-button.ts +44 -0
  94. package/src/types/index.ts +2 -0
  95. package/dist/node_modules/.bun/@codemirror_commands@6.11.0/node_modules/@codemirror/commands/dist/index.js.map +0 -1
  96. package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +0 -1
  97. package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +0 -1
  98. package/dist/node_modules/.bun/@codemirror_state@6.7.1/node_modules/@codemirror/state/dist/index.js.map +0 -1
  99. package/dist/node_modules/.bun/@codemirror_view@6.43.9/node_modules/@codemirror/view/dist/index.js.map +0 -1
  100. package/dist/node_modules/.bun/@lezer_css@1.3.6/node_modules/@lezer/css/dist/index.js +0 -268
  101. package/dist/node_modules/.bun/@lezer_css@1.3.6/node_modules/@lezer/css/dist/index.js.map +0 -1
  102. package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js.map +0 -1
  103. package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js +0 -235
  104. package/dist/node_modules/.bun/@lezer_java@1.1.3/node_modules/@lezer/java/dist/index.js.map +0 -1
  105. package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +0 -491
  106. package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js.map +0 -1
  107. package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js.map +0 -1
  108. package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js.map +0 -1
  109. package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.3/node_modules/@marijn/find-cluster-break/src/index.js.map +0 -1
  110. package/dist/node_modules/.bun/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { Annotation, ChangeSet, CharCategory, EditorSelection, EditorState, Facet, MapMode, Prec, RangeSet, RangeSetBuilder, RangeValue, StateEffect, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn } from "../../../../../@codemirror_state@6.7.1/node_modules/@codemirror/state/dist/index.js";
2
- import { StyleModule } from "../../../../../style-mod@4.1.3/node_modules/style-mod/src/style-mod.js";
1
+ import { Annotation, ChangeSet, CharCategory, EditorSelection, EditorState, Facet, MapMode, Prec, RangeSet, RangeSetBuilder, RangeValue, StateEffect, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn } from "../../../../../@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js";
2
+ import { StyleModule } from "../../../../../style-mod@4.1.4/node_modules/style-mod/src/style-mod.js";
3
3
  import { base, keyName, shift } from "../../../../../w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js";
4
4
  import crelt from "../../../../../crelt@1.0.7/node_modules/crelt/index.js";
5
- //#region ../../node_modules/.bun/@codemirror+view@6.43.9/node_modules/@codemirror/view/dist/index.js
5
+ //#region ../../node_modules/.bun/@codemirror+view@6.43.14/node_modules/@codemirror/view/dist/index.js
6
6
  let nav = typeof navigator != "undefined" ? navigator : {
7
7
  userAgent: "",
8
8
  vendor: "",
@@ -48,7 +48,7 @@ function attrsEq(a, b, ignore) {
48
48
  if (!a) a = noAttrs;
49
49
  if (!b) b = noAttrs;
50
50
  let keysA = Object.keys(a), keysB = Object.keys(b);
51
- if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) != keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0)) return false;
51
+ if (keysA.length - 0 != keysB.length - 0) return false;
52
52
  for (let key of keysA) if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key])) return false;
53
53
  return true;
54
54
  }
@@ -385,6 +385,8 @@ var BlockWrapper = class BlockWrapper extends RangeValue {
385
385
  }
386
386
  };
387
387
  BlockWrapper.prototype.startSide = BlockWrapper.prototype.endSide = -1;
388
+ const isElt = (node) => node.nodeType == 1;
389
+ const isText = (node) => node.nodeType == 3;
388
390
  function getSelection(root) {
389
391
  let target;
390
392
  if (root.nodeType == 11) target = root.getSelection ? root : root.ownerDocument;
@@ -403,8 +405,8 @@ function hasSelection(dom, selection) {
403
405
  }
404
406
  }
405
407
  function clientRectsFor(dom) {
406
- if (dom.nodeType == 3) return textRange(dom, 0, dom.nodeValue.length).getClientRects();
407
- else if (dom.nodeType == 1) return dom.getClientRects();
408
+ if (isText(dom)) return textRange(dom, 0, dom.nodeValue.length).getClientRects();
409
+ else if (isElt(dom)) return dom.getClientRects();
408
410
  else return [];
409
411
  }
410
412
  function isEquivalentPosition(node, off, targetNode, targetOff) {
@@ -417,7 +419,7 @@ function domIndex(node) {
417
419
  }
418
420
  }
419
421
  function isBlockElement(node) {
420
- return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
422
+ return isElt(node) && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
421
423
  }
422
424
  function scanFor(node, off, targetNode, targetOff, dir) {
423
425
  for (;;) {
@@ -425,18 +427,18 @@ function scanFor(node, off, targetNode, targetOff, dir) {
425
427
  if (off == (dir < 0 ? 0 : maxOffset(node))) {
426
428
  if (node.nodeName == "DIV") return false;
427
429
  let parent = node.parentNode;
428
- if (!parent || parent.nodeType != 1) return false;
430
+ if (!parent || !isElt(parent)) return false;
429
431
  off = domIndex(node) + (dir < 0 ? 0 : 1);
430
432
  node = parent;
431
- } else if (node.nodeType == 1) {
433
+ } else if (isElt(node)) {
432
434
  node = node.childNodes[off + (dir < 0 ? -1 : 0)];
433
- if (node.nodeType == 1 && node.contentEditable == "false") return false;
435
+ if (isElt(node) && (node.nodeName == "IMG" || node.nodeName == "BR" || node.contentEditable == "false")) return false;
434
436
  off = dir < 0 ? maxOffset(node) : 0;
435
437
  } else return false;
436
438
  }
437
439
  }
438
440
  function maxOffset(node) {
439
- return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
441
+ return isText(node) ? node.nodeValue.length : node.childNodes.length;
440
442
  }
441
443
  function flattenRect(rect, toLeft) {
442
444
  let { left, right } = rect;
@@ -476,7 +478,7 @@ function getScale(elt, rect) {
476
478
  }
477
479
  function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
478
480
  let doc = dom.ownerDocument, win = doc.defaultView || window;
479
- for (let cur = dom, stop = false; cur && !stop;) if (cur.nodeType == 1) {
481
+ for (let cur = dom, stop = false; cur && !stop;) if (isElt(cur)) {
480
482
  let bounding, top = cur == doc.body;
481
483
  let scaleX = 1, scaleY = 1;
482
484
  if (top) bounding = windowRect(win);
@@ -555,7 +557,7 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
555
557
  function scrollableParents(dom, getX = true) {
556
558
  let doc = dom.ownerDocument, x = null, y = null;
557
559
  for (let cur = dom.parentNode; cur;) if (cur == doc.body || (!getX || x) && y) break;
558
- else if (cur.nodeType == 1) {
560
+ else if (isElt(cur)) {
559
561
  if (!y && cur.scrollHeight > cur.clientHeight) y = cur;
560
562
  if (getX && !x && cur.scrollWidth > cur.clientWidth) x = cur;
561
563
  cur = cur.assignedSlot || cur.parentNode;
@@ -589,7 +591,7 @@ var DOMSelectionState = class {
589
591
  };
590
592
  function getScrollStack(target) {
591
593
  let stack = [];
592
- for (let cur = target; cur; cur = cur.nodeType == 11 ? cur.host : cur.parentNode) if (cur.nodeType == 1) stack.push({
594
+ for (let cur = target; cur; cur = cur.nodeType == 11 ? cur.host : cur.parentNode) if (isElt(cur)) stack.push({
593
595
  node: cur,
594
596
  left: cur.scrollLeft,
595
597
  top: cur.scrollTop
@@ -653,7 +655,7 @@ function atElementStart(doc, selection) {
653
655
  if (!node || selection.anchorNode != node || selection.anchorOffset != offset) return false;
654
656
  offset = Math.min(offset, maxOffset(node));
655
657
  for (;;) if (offset) {
656
- if (node.nodeType != 1) return false;
658
+ if (!isElt(node)) return false;
657
659
  let prev = node.childNodes[offset - 1];
658
660
  if (prev.contentEditable == "false") offset--;
659
661
  else {
@@ -671,11 +673,11 @@ function isScrolledToBottom(elt) {
671
673
  return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);
672
674
  }
673
675
  function textNodeBefore(startNode, startOffset) {
674
- for (let node = startNode, offset = startOffset;;) if (node.nodeType == 3 && offset > 0) return {
676
+ for (let node = startNode, offset = startOffset;;) if (isText(node) && offset > 0) return {
675
677
  node,
676
678
  offset
677
679
  };
678
- else if (node.nodeType == 1 && offset > 0) {
680
+ else if (isElt(node) && offset > 0) {
679
681
  if (node.contentEditable == "false") return null;
680
682
  node = node.childNodes[offset - 1];
681
683
  offset = maxOffset(node);
@@ -685,11 +687,11 @@ function textNodeBefore(startNode, startOffset) {
685
687
  } else return null;
686
688
  }
687
689
  function textNodeAfter(startNode, startOffset) {
688
- for (let node = startNode, offset = startOffset;;) if (node.nodeType == 3 && offset < node.nodeValue.length) return {
690
+ for (let node = startNode, offset = startOffset;;) if (isText(node) && offset < node.nodeValue.length) return {
689
691
  node,
690
692
  offset
691
693
  };
692
- else if (node.nodeType == 1 && offset < node.childNodes.length) {
694
+ else if (isElt(node) && offset < node.childNodes.length) {
693
695
  if (node.contentEditable == "false") return null;
694
696
  node = node.childNodes[offset];
695
697
  offset = 0;
@@ -991,8 +993,15 @@ function trivialOrder(length) {
991
993
  let movedOver = "";
992
994
  function moveVisually(line, order, dir, start, forward) {
993
995
  var _a;
994
- let startIndex = start.head - line.from;
995
- let spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
996
+ if (!line.length) return null;
997
+ let startIndex = start.head - line.from, spanI;
998
+ if (start.head == line.from && start.assoc < 0) {
999
+ if (!forward) return null;
1000
+ startIndex = order[spanI = 0].side(false, dir);
1001
+ } else if (start.head == line.to && start.assoc > 0) {
1002
+ if (forward) return null;
1003
+ startIndex = order[spanI = order.length - 1].side(true, dir);
1004
+ } else spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
996
1005
  let span = order[spanI], spanEnd = span.side(forward, dir);
997
1006
  if (startIndex == spanEnd) {
998
1007
  let nextI = spanI += forward ? 1 : -1;
@@ -1005,7 +1014,10 @@ function moveVisually(line, order, dir, start, forward) {
1005
1014
  if (nextIndex < span.from || nextIndex > span.to) nextIndex = spanEnd;
1006
1015
  movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
1007
1016
  let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
1008
- if (nextSpan && nextIndex == spanEnd && nextSpan.level + (forward ? 0 : 1) < span.level) return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
1017
+ if (nextIndex == spanEnd) {
1018
+ if (!nextSpan) return forward ? EditorSelection.cursor(line.to, 1) : EditorSelection.cursor(line.from, -1);
1019
+ if (nextSpan.level + (forward ? 0 : 1) < span.level) return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
1020
+ }
1009
1021
  return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
1010
1022
  }
1011
1023
  function autoDirection(text, from, to) {
@@ -1606,17 +1618,17 @@ var LineTile = class LineTile extends CompositeTile {
1606
1618
  get domAttrs() {
1607
1619
  return this.attrs;
1608
1620
  }
1609
- resolveInline(pos, side, forCoords) {
1621
+ resolveInline(pos, side, forCoords = false) {
1610
1622
  let before = null, beforeOff = -1, after = null, afterOff = -1;
1611
1623
  function scan(tile, pos) {
1612
1624
  for (let i = 0, off = 0; i < tile.children.length && off <= pos; i++) {
1613
1625
  let child = tile.children[i], end = off + child.length;
1614
1626
  if (end >= pos) {
1615
1627
  if (child.isComposite()) scan(child, pos - off);
1616
- else if ((!after || after.isHidden && (side > 0 && !(after.flags & 32) || forCoords && onSameLine(after, child))) && (end > pos || child.flags & 32 && side <= 1)) {
1628
+ else if ((!after || forCoords && after.isHidden && (side > 0 && !(after.flags & 32) || forCoords && onSameLine(after, child))) && (end > pos || child.flags & 32 && side <= 1)) {
1617
1629
  after = child;
1618
1630
  afterOff = pos - off;
1619
- } else if (off < pos || child.flags & 16 && !child.isHidden && side >= -1) {
1631
+ } else if (off < pos || child.flags & 16 && !(forCoords && child.isHidden) && side >= -1) {
1620
1632
  before = child;
1621
1633
  beforeOff = pos - off;
1622
1634
  }
@@ -1899,11 +1911,11 @@ var TileBuilder = class {
1899
1911
  if (last.dom != mark.dom) last.setDOM(freeNode(mark.dom));
1900
1912
  head = last;
1901
1913
  } else {
1914
+ let { dom } = mark;
1902
1915
  if (this.cache.reused.get(mark)) {
1903
- let tile = Tile.get(mark.dom);
1904
- if (tile) tile.setDOM(freeNode(mark.dom));
1916
+ if (Tile.get(mark.dom)) dom = freeNode(mark.dom);
1905
1917
  }
1906
- let nw = MarkTile.of(mark.mark, mark.dom);
1918
+ let nw = MarkTile.of(mark.mark, dom);
1907
1919
  head.append(nw);
1908
1920
  head = nw;
1909
1921
  }
@@ -2316,12 +2328,13 @@ var TileUpdate = class {
2316
2328
  if (tile instanceof MarkTile) marks.push(tile);
2317
2329
  else if (tile === null || tile === void 0 ? void 0 : tile.isLine()) line = tile;
2318
2330
  else if (tile instanceof BlockWrapperTile);
2319
- else if (parent.nodeName == "DIV" && !line && parent != this.view.contentDOM) line = new LineTile(parent, lineBaseAttrs);
2331
+ else if (parent.nodeName == "DIV" && !line) line = new LineTile(parent, lineBaseAttrs);
2320
2332
  else if (!line) marks.push(MarkTile.of(new MarkDecoration({
2321
2333
  tagName: parent.nodeName.toLowerCase(),
2322
2334
  attributes: getAttrs(parent)
2323
2335
  }), parent));
2324
2336
  }
2337
+ if (!line) return null;
2325
2338
  return {
2326
2339
  line,
2327
2340
  marks
@@ -2850,7 +2863,7 @@ function destroyDropped(tile, reused) {
2850
2863
  }
2851
2864
  }
2852
2865
  function betweenUneditable(pos) {
2853
- return pos.node.nodeType == 1 && pos.node.firstChild && (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") && (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
2866
+ return isElt(pos.node) && pos.node.firstChild && (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") && (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
2854
2867
  }
2855
2868
  function findCompositionNode(view, headPos) {
2856
2869
  let sel = view.observer.selectionRange;
@@ -2888,7 +2901,7 @@ function findCompositionRange(view, changes, headPos) {
2888
2901
  };
2889
2902
  }
2890
2903
  function nextToUneditable(node, offset) {
2891
- if (node.nodeType != 1) return 0;
2904
+ if (!isElt(node)) return 0;
2892
2905
  return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 : 0) | (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 : 0);
2893
2906
  }
2894
2907
  let DecorationComparator$1 = class DecorationComparator {
@@ -2928,7 +2941,7 @@ function findChangedWrappers(a, b, diff) {
2928
2941
  return comp.changes;
2929
2942
  }
2930
2943
  function inUneditable(node, inside) {
2931
- for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) if (cur.nodeType == 1 && cur.contentEditable == "false") return true;
2944
+ for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) if (isElt(cur) && cur.contentEditable == "false") return true;
2932
2945
  return false;
2933
2946
  }
2934
2947
  function touchesComposition(changes, composition) {
@@ -3013,18 +3026,18 @@ function blockAt(view, pos, side) {
3013
3026
  return line;
3014
3027
  }
3015
3028
  function moveToLineBoundary(view, start, forward, includeWrap) {
3016
- let line = blockAt(view, start.head, start.assoc || -1);
3017
- let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
3029
+ let block = blockAt(view, start.head, start.assoc || -1);
3030
+ let coords = !includeWrap || block.type != BlockType.Text || !(view.lineWrapping || block.widgetLineBreaks) ? null : view.coordsAtPos(start.assoc < 0 && start.head > block.from ? start.head - 1 : start.head);
3018
3031
  if (coords) {
3019
3032
  let editorRect = view.dom.getBoundingClientRect();
3020
- let direction = view.textDirectionAt(line.from);
3033
+ let direction = view.textDirectionAt(block.from);
3021
3034
  let pos = view.posAtCoords({
3022
3035
  x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,
3023
3036
  y: (coords.top + coords.bottom) / 2
3024
3037
  });
3025
3038
  if (pos != null) return EditorSelection.cursor(pos, forward ? -1 : 1);
3026
3039
  }
3027
- return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
3040
+ return EditorSelection.cursor(forward ? block.to : block.from, forward ? -1 : 1);
3028
3041
  }
3029
3042
  function moveByChar(view, start, forward, by) {
3030
3043
  let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
@@ -3036,7 +3049,7 @@ function moveByChar(view, start, forward, by) {
3036
3049
  char = "\n";
3037
3050
  line = view.state.doc.line(line.number + (forward ? 1 : -1));
3038
3051
  spans = view.bidiSpans(line);
3039
- next = view.visualLineSide(line, !forward);
3052
+ next = forward ? EditorSelection.cursor(line.from, -1) : EditorSelection.cursor(line.to, 1);
3040
3053
  }
3041
3054
  if (!check) {
3042
3055
  if (!by) return next;
@@ -3228,7 +3241,7 @@ var InlineCoordsScan = class {
3228
3241
  }
3229
3242
  if (!closestRect) {
3230
3243
  if (!below && !above) return {
3231
- i: positions[0],
3244
+ i: 0,
3232
3245
  after: false
3233
3246
  };
3234
3247
  let side = above && (!below || this.y - above.bottom < below.top - this.y) ? above : below;
@@ -3274,7 +3287,7 @@ var InlineCoordsScan = class {
3274
3287
  let scan = this.scan(positions, (i) => {
3275
3288
  let child = tile.children[i];
3276
3289
  if (child.flags & 48) return null;
3277
- return (child.dom.nodeType == 1 ? child.dom : textRange(child.dom, 0, child.length)).getClientRects();
3290
+ return (isElt(child.dom) ? child.dom : textRange(child.dom, 0, child.length)).getClientRects();
3278
3291
  });
3279
3292
  let child = tile.children[scan.i], pos = positions[scan.i];
3280
3293
  if (child.isText()) return this.scanText(child, pos);
@@ -3343,16 +3356,16 @@ var DOMReader = class {
3343
3356
  this.findPointInside(node, fromView.length);
3344
3357
  for (let i = fromView.iter(); !i.next().done;) if (i.lineBreak) this.lineBreak();
3345
3358
  else this.append(i.value);
3346
- } else if (node.nodeType == 3) this.readTextNode(node);
3359
+ } else if (isText(node)) this.readTextNode(node);
3347
3360
  else if (node.nodeName == "BR") {
3348
3361
  if (node.nextSibling) this.lineBreak();
3349
- } else if (node.nodeType == 1) this.readRange(node.firstChild, null);
3362
+ } else if (isElt(node)) this.readRange(node.firstChild, null);
3350
3363
  }
3351
3364
  findPointBefore(node, next) {
3352
3365
  for (let point of this.points) if (point.node == node && node.childNodes[point.offset] == next) point.pos = this.text.length;
3353
3366
  }
3354
3367
  findPointInside(node, length) {
3355
- for (let point of this.points) if (node.nodeType == 3 ? point.node == node : node.contains(point.node)) point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
3368
+ for (let point of this.points) if (isText(node) ? point.node == node : node.contains(point.node)) point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
3356
3369
  }
3357
3370
  };
3358
3371
  function isAtEnd(parent, node, offset) {
@@ -3635,7 +3648,7 @@ function selectionPoints(view) {
3635
3648
  function selectionFromPoints(points, base) {
3636
3649
  if (points.length == 0) return null;
3637
3650
  let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
3638
- return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;
3651
+ return anchor < 0 || head < 0 ? null : anchor == head ? EditorSelection.create([EditorSelection.cursor(head + base, -1)]) : EditorSelection.single(anchor + base, head + base);
3639
3652
  }
3640
3653
  function sameSelPos(selection, range) {
3641
3654
  return range.head == selection.main.head && range.anchor == selection.main.anchor;
@@ -3729,12 +3742,14 @@ var InputState = class {
3729
3742
  shiftKey: event.shiftKey
3730
3743
  };
3731
3744
  if (mods.shiftKey && browser.ios && !/^(off|none)$/.test(this.view.contentDOM.autocapitalize) && iosVirtualKeyboardOpen(this.view.win)) mods.shiftKey = false;
3732
- this.pendingIOSKey = {
3745
+ let pending = this.pendingIOSKey = {
3733
3746
  key: event.key,
3734
3747
  keyCode: event.keyCode,
3735
3748
  mods
3736
3749
  };
3737
- setTimeout(() => this.flushIOSKey(), 250);
3750
+ setTimeout(() => {
3751
+ if (this.pendingIOSKey == pending) this.flushIOSKey();
3752
+ }, 50);
3738
3753
  return true;
3739
3754
  }
3740
3755
  if (event.keyCode != 229) this.view.observer.forceFlush();
@@ -3742,7 +3757,7 @@ var InputState = class {
3742
3757
  }
3743
3758
  flushIOSKey(change) {
3744
3759
  let key = this.pendingIOSKey;
3745
- if (!key) return false;
3760
+ if (!key || this.view.observer.pendingRecords().length) return false;
3746
3761
  if (key.key == "Enter" && change && change.from < change.to && /^\S+$/.test(change.insert.toString())) return false;
3747
3762
  this.pendingIOSKey = void 0;
3748
3763
  return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key.mods);
@@ -3996,7 +4011,7 @@ function doPaste(view, input) {
3996
4011
  from: line.from,
3997
4012
  insert
3998
4013
  },
3999
- range: EditorSelection.cursor(range.from + insert.length)
4014
+ range: EditorSelection.cursor(range.from + insert.length, -1)
4000
4015
  };
4001
4016
  });
4002
4017
  } else if (byLine) changes = state.changeByRange((range) => {
@@ -4007,7 +4022,7 @@ function doPaste(view, input) {
4007
4022
  to: range.to,
4008
4023
  insert: line.text
4009
4024
  },
4010
- range: EditorSelection.cursor(range.from + line.length)
4025
+ range: EditorSelection.cursor(range.from + line.length, -1)
4011
4026
  };
4012
4027
  });
4013
4028
  else changes = state.replaceSelection(text);
@@ -4316,10 +4331,20 @@ observers.blur = (view) => {
4316
4331
  view.observer.clearSelectionRange();
4317
4332
  updateForFocusChange(view);
4318
4333
  };
4319
- observers.compositionstart = observers.compositionupdate = (view) => {
4334
+ observers.compositionstart = observers.compositionupdate = (view, event) => {
4320
4335
  if (view.observer.editContext) return;
4321
4336
  if (view.inputState.compositionFirstChange == null) view.inputState.compositionFirstChange = true;
4322
- if (view.inputState.composing < 0) view.inputState.composing = 0;
4337
+ if (view.inputState.composing < 0) {
4338
+ let { main } = view.state.selection;
4339
+ if (!main.empty && view.lineBlockAt(main.from).from != view.lineBlockAt(main.to).from && !view.state.readOnly) view.dispatch({
4340
+ changes: view.state.selection.ranges.filter((r) => !r.empty).map((r) => ({
4341
+ from: r.from,
4342
+ to: r.to
4343
+ })),
4344
+ userEvent: "input"
4345
+ });
4346
+ view.inputState.composing = 0;
4347
+ }
4323
4348
  };
4324
4349
  observers.compositionend = (view) => {
4325
4350
  if (view.observer.editContext) return;
@@ -4596,12 +4621,12 @@ var HeightMap = class HeightMap {
4596
4621
  let next = nodes[--j];
4597
4622
  if (next) after += next.size;
4598
4623
  }
4599
- let brk = 0;
4624
+ let brk = false;
4600
4625
  if (nodes[i - 1] == null) {
4601
- brk = 1;
4626
+ brk = true;
4602
4627
  i--;
4603
4628
  } else if (nodes[i] == null) {
4604
- brk = 1;
4629
+ brk = true;
4605
4630
  j++;
4606
4631
  }
4607
4632
  return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
@@ -4800,7 +4825,7 @@ var HeightMapGap = class HeightMapGap extends HeightMap {
4800
4825
  };
4801
4826
  var HeightMapBranch = class extends HeightMap {
4802
4827
  constructor(left, brk, right) {
4803
- super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 : 0));
4828
+ super(left.length + (brk ? 1 : 0) + right.length, left.height + right.height, (brk ? 1 : 0) | (left.outdated || right.outdated ? 2 : 0));
4804
4829
  this.left = left;
4805
4830
  this.right = right;
4806
4831
  this.size = left.size + right.size;
@@ -4828,9 +4853,9 @@ var HeightMapBranch = class extends HeightMap {
4828
4853
  if (to >= rightOffset) this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);
4829
4854
  } else {
4830
4855
  let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);
4831
- if (from < mid.from) this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);
4856
+ if (from < mid.from) this.left.forEachLine(from, Math.min(to, mid.from - 1), oracle, top, offset, f);
4832
4857
  if (mid.to >= from && mid.from <= to) f(mid);
4833
- if (to > mid.to) this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);
4858
+ if (to > mid.to) this.right.forEachLine(Math.max(from, mid.to + 1), to, oracle, rightTop, rightOffset, f);
4834
4859
  }
4835
4860
  }
4836
4861
  replace(from, to, nodes) {
@@ -5015,17 +5040,16 @@ function visiblePixelRange(dom, paddingTop) {
5015
5040
  let doc = dom.ownerDocument, win = doc.defaultView || window;
5016
5041
  let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
5017
5042
  let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
5018
- for (let parent = dom.parentNode; parent && parent != doc.body;) if (parent.nodeType == 1) {
5019
- let elt = parent;
5020
- let style = window.getComputedStyle(elt);
5021
- if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) && style.overflow != "visible") {
5022
- let parentRect = elt.getBoundingClientRect();
5043
+ for (let parent = dom.parentNode; parent && parent != doc.body;) if (isElt(parent)) {
5044
+ let style = window.getComputedStyle(parent);
5045
+ if ((parent.scrollHeight > parent.clientHeight || parent.scrollWidth > parent.clientWidth) && style.overflow != "visible") {
5046
+ let parentRect = parent.getBoundingClientRect();
5023
5047
  left = Math.max(left, parentRect.left);
5024
5048
  right = Math.min(right, parentRect.right);
5025
5049
  top = Math.max(top, parentRect.top);
5026
5050
  bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
5027
5051
  }
5028
- parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
5052
+ parent = style.position == "absolute" || style.position == "fixed" ? parent.offsetParent : parent.parentNode;
5029
5053
  } else if (parent.nodeType == 11) parent = parent.host;
5030
5054
  else break;
5031
5055
  return {
@@ -5437,7 +5461,7 @@ var ViewState = class {
5437
5461
  return height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom && this.viewportLines.find((l) => l.top <= height && l.bottom >= height) || scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);
5438
5462
  }
5439
5463
  getScrollOffset() {
5440
- return (this.scrollParent == this.view.scrollDOM ? this.scrollParent.scrollTop : (this.scrollParent ? this.scrollParent.getBoundingClientRect().top : 0) - this.view.contentDOM.getBoundingClientRect().top) * this.scaleY;
5464
+ return this.scrollParent == this.view.scrollDOM ? this.scrollParent.scrollTop * this.scaleY : (this.scrollParent ? this.scrollParent.getBoundingClientRect().top : 0) - this.view.contentDOM.getBoundingClientRect().top;
5441
5465
  }
5442
5466
  scrollAnchorAt(scrollOffset) {
5443
5467
  let block = this.lineBlockAtHeight(scrollOffset + 8);
@@ -5777,7 +5801,7 @@ const baseTheme$1 = /*@__PURE__*/ buildTheme("." + baseThemeID, {
5777
5801
  verticalAlign: "bottom"
5778
5802
  },
5779
5803
  ".cm-widgetBuffer": {
5780
- verticalAlign: "text-top",
5804
+ verticalAlign: "baseline",
5781
5805
  height: "1em",
5782
5806
  width: 0,
5783
5807
  display: "inline"
@@ -5789,8 +5813,9 @@ const baseTheme$1 = /*@__PURE__*/ buildTheme("." + baseThemeID, {
5789
5813
  userSelect: "none"
5790
5814
  },
5791
5815
  ".cm-highlightSpace": {
5792
- backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
5793
- backgroundPosition: "center"
5816
+ background: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",
5817
+ backgroundSize: ".4em",
5818
+ backgroundPosition: "calc(min(50%, 0px)) center"
5794
5819
  },
5795
5820
  ".cm-highlightTab": {
5796
5821
  backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
@@ -5976,7 +6001,7 @@ var DOMObserver = class {
5976
6001
  listenForScroll() {
5977
6002
  this.parentCheck = -1;
5978
6003
  let i = 0, changed = null;
5979
- for (let dom = this.dom; dom;) if (dom.nodeType == 1) {
6004
+ for (let dom = this.dom; dom;) if (isElt(dom)) {
5980
6005
  if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom) i++;
5981
6006
  else if (!changed) changed = this.scrollTargets.slice(0, i);
5982
6007
  if (changed) changed.push(dom);
@@ -6092,14 +6117,14 @@ var DOMObserver = class {
6092
6117
  flush(readSelection = true) {
6093
6118
  if (this.delayedFlush >= 0 || this.delayedAndroidKey) return false;
6094
6119
  if (readSelection) this.readSelectionRange();
6095
- let domChange = this.readChange();
6120
+ let selChange = this.selectionChanged, domChange = this.readChange();
6096
6121
  if (!domChange) {
6097
6122
  this.view.requestMeasure();
6098
6123
  return false;
6099
6124
  }
6100
6125
  let startState = this.view.state;
6101
6126
  let handled = applyDOMChange(this.view, domChange);
6102
- if (this.view.state == startState && (domChange.domChanged || domChange.newSel && !sameSelPos(this.view.state.selection, domChange.newSel.main))) this.view.update([]);
6127
+ if (this.view.state == startState && (domChange.domChanged || selChange)) this.view.update([]);
6103
6128
  return handled;
6104
6129
  }
6105
6130
  readMutation(rec) {
@@ -6488,6 +6513,7 @@ var EditorView = class EditorView {
6488
6513
  @internal
6489
6514
  */
6490
6515
  this.measureRequests = [];
6516
+ this.clearAnnouncement = -1;
6491
6517
  this.contentDOM = document.createElement("div");
6492
6518
  this.scrollDOM = document.createElement("div");
6493
6519
  this.scrollDOM.tabIndex = -1;
@@ -6682,7 +6708,7 @@ var EditorView = class EditorView {
6682
6708
  if (flush) this.observer.forceFlush();
6683
6709
  let updated = null;
6684
6710
  let scroll = this.viewState.scrollParent, scrollOffset = this.viewState.getScrollOffset();
6685
- let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
6711
+ let { scrollAnchorPos, scrollAnchorHeight, scaleY: scrollScale } = this.viewState;
6686
6712
  if (Math.abs(scrollOffset - this.viewState.scrollOffset) > 1) scrollAnchorHeight = -1;
6687
6713
  this.viewState.scrollAnchorHeight = -1;
6688
6714
  try {
@@ -6690,12 +6716,13 @@ var EditorView = class EditorView {
6690
6716
  if (scrollAnchorHeight < 0) {
6691
6717
  if (isScrolledToBottom(scroll || this.win)) {
6692
6718
  scrollAnchorPos = -1;
6693
- scrollAnchorHeight = this.viewState.heightMap.height;
6719
+ scrollAnchorHeight = this.viewState.heightMap.height / this.viewState.scaleY;
6694
6720
  } else {
6695
6721
  let block = this.viewState.scrollAnchorAt(scrollOffset);
6696
6722
  scrollAnchorPos = block.from;
6697
6723
  scrollAnchorHeight = block.top;
6698
6724
  }
6725
+ scrollScale = this.viewState.scaleY;
6699
6726
  }
6700
6727
  this.updateState = 1;
6701
6728
  let changed = this.viewState.measure();
@@ -6741,7 +6768,7 @@ var EditorView = class EditorView {
6741
6768
  scrollAnchorHeight = -1;
6742
6769
  continue;
6743
6770
  } else {
6744
- let diff = ((scrollAnchorPos < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(scrollAnchorPos).top) - scrollAnchorHeight) / this.scaleY;
6771
+ let diff = (scrollAnchorPos < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(scrollAnchorPos).top) / this.viewState.scaleY - scrollAnchorHeight / scrollScale;
6745
6772
  if ((diff > 1 || diff < -1) && !(browser.ios && this.inputState.lastIOSMomentumScroll > Date.now() - 100) && (scroll == this.scrollDOM || this.hasFocus || Math.max(this.inputState.lastWheelEvent, this.inputState.lastTouchTime) > Date.now() - 100)) {
6746
6773
  scrollOffset = scrollOffset + diff;
6747
6774
  if (!scroll) this.win.scrollBy(0, diff);
@@ -6795,8 +6822,14 @@ var EditorView = class EditorView {
6795
6822
  showAnnouncements(trs) {
6796
6823
  let first = true;
6797
6824
  for (let tr of trs) for (let effect of tr.effects) if (effect.is(EditorView.announce)) {
6798
- if (first) this.announceDOM.textContent = "";
6799
- first = false;
6825
+ if (first) {
6826
+ this.announceDOM.textContent = "";
6827
+ this.win.clearTimeout(this.clearAnnouncement);
6828
+ this.clearAnnouncement = this.win.setTimeout(() => {
6829
+ this.announceDOM.textContent = "\xA0";
6830
+ }, 200);
6831
+ first = false;
6832
+ }
6800
6833
  let div = this.announceDOM.appendChild(document.createElement("div"));
6801
6834
  div.textContent = effect.value;
6802
6835
  }
@@ -6813,7 +6846,7 @@ var EditorView = class EditorView {
6813
6846
  /**
6814
6847
  Schedule a layout measurement, optionally providing callbacks to
6815
6848
  do custom DOM measuring followed by a DOM write phase. Using
6816
- this is preferable reading DOM layout directly from, for
6849
+ this is preferable to reading DOM layout directly from, for
6817
6850
  example, an event handler, because it'll make sure measuring and
6818
6851
  drawing done by other components is synchronized, avoiding
6819
6852
  unnecessary DOM layout computations.
@@ -6946,15 +6979,11 @@ var EditorView = class EditorView {
6946
6979
  return skipAtoms(this, start, moveByChar(this, start, forward, (initial) => byGroup(this, start.head, initial)));
6947
6980
  }
6948
6981
  /**
6949
- Get the cursor position visually at the start or end of a line.
6950
- Note that this may differ from the _logical_ position at its
6951
- start or end (which is simply at `line.from`/`line.to`) if text
6952
- at the start or end goes against the line's base text direction.
6982
+ **\[DEPRECATED]** Get the cursor position visually at the start
6983
+ or end of a line.
6953
6984
  */
6954
6985
  visualLineSide(line, end) {
6955
- let order = this.bidiSpans(line), dir = this.textDirectionAt(line.from);
6956
- let span = order[end ? order.length - 1 : 0];
6957
- return EditorSelection.cursor(span.side(end, dir) + line.from, span.forward(!end, dir) ? 1 : -1);
6986
+ return end ? EditorSelection.cursor(line.to, 1) : EditorSelection.cursor(line.from, -1);
6958
6987
  }
6959
6988
  /**
6960
6989
  Move to the next line boundary in the given direction. If
@@ -7023,6 +7052,15 @@ var EditorView = class EditorView {
7023
7052
  this.readMeasured();
7024
7053
  let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
7025
7054
  let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
7055
+ if (line.length && (pos == line.from && side < 0 || pos == line.to && side > 0) && span.dir != this.textDirectionAt(line.from)) {
7056
+ if (pos == line.to) {
7057
+ pos = line.from + span.from;
7058
+ side = 1;
7059
+ } else {
7060
+ pos = line.from + span.to;
7061
+ side = -1;
7062
+ }
7063
+ }
7026
7064
  return this.docView.coordsAt(pos, side, span.dir == Direction.RTL);
7027
7065
  }
7028
7066
  /**
@@ -7140,6 +7178,7 @@ var EditorView = class EditorView {
7140
7178
  this.docView.destroy();
7141
7179
  this.dom.remove();
7142
7180
  this.observer.destroy();
7181
+ this.win.clearTimeout(this.clearAnnouncement);
7143
7182
  if (this.measureScheduled > -1) this.win.cancelAnimationFrame(this.measureScheduled);
7144
7183
  this.destroyed = true;
7145
7184
  }
@@ -7883,6 +7922,7 @@ Define a layer.
7883
7922
  function layer(config) {
7884
7923
  return [ViewPlugin.define((v) => new LayerView(v, config)), layerOrder.of(config)];
7885
7924
  }
7925
+ const drawMainRange = !browser.ios;
7886
7926
  const selectionConfig = /*@__PURE__*/ Facet.define({ combine(configs) {
7887
7927
  return combineConfig(configs, {
7888
7928
  cursorBlinkRate: 1200,
@@ -7956,7 +7996,7 @@ const selectionLayer = /*@__PURE__*/ layer({
7956
7996
  above: false,
7957
7997
  markers(view) {
7958
7998
  let markers = [], { main, ranges } = view.state.selection;
7959
- for (let r of ranges) if (!r.empty) for (let marker of RectangleMarker.forRange(view, "cm-selectionBackground", r)) markers.push(marker);
7999
+ for (let r of ranges) if (!r.empty && (drawMainRange || r != main)) for (let marker of RectangleMarker.forRange(view, "cm-selectionBackground", r)) markers.push(marker);
7960
8000
  if (browser.ios && !main.empty && view.state.facet(selectionConfig).iosSelectionHandles) {
7961
8001
  for (let piece of RectangleMarker.forRange(view, "cm-selectionHandle cm-selectionHandle-start", EditorSelection.cursor(main.from, 1))) markers.push(piece);
7962
8002
  for (let piece of RectangleMarker.forRange(view, "cm-selectionHandle cm-selectionHandle-end", EditorSelection.cursor(main.to, 1))) markers.push(piece);
@@ -7971,14 +8011,14 @@ const selectionLayer = /*@__PURE__*/ layer({
7971
8011
  const selectionBg = browser.gecko && browser.gecko_version == 153 ? "#ffffff01" : "transparent";
7972
8012
  const hideNativeSelection = /*@__PURE__*/ Prec.highest(/*@__PURE__*/ EditorView.theme({
7973
8013
  ".cm-line": {
7974
- "& ::selection, &::selection": { backgroundColor: `${selectionBg} !important` },
8014
+ ...drawMainRange ? { "& ::selection, &::selection": { backgroundColor: `${selectionBg} !important` } } : {},
7975
8015
  caretColor: "transparent !important"
7976
8016
  },
7977
8017
  ".cm-content": {
7978
8018
  caretColor: "transparent !important",
7979
8019
  "& :focus": {
7980
8020
  caretColor: "initial !important",
7981
- "&::selection, & ::selection": { backgroundColor: "Highlight !important" }
8021
+ ...drawMainRange ? { "&::selection, & ::selection": { backgroundColor: "Highlight !important" } } : {}
7982
8022
  }
7983
8023
  }
7984
8024
  }));
@@ -8514,13 +8554,26 @@ Creates an extension that configures tooltip behavior.
8514
8554
  function tooltips(config = {}) {
8515
8555
  return tooltipConfig.of(config);
8516
8556
  }
8557
+ function fixedRange(view) {
8558
+ let docElt = view.dom.ownerDocument.documentElement, width = docElt.clientWidth;
8559
+ let style = getComputedStyle(docElt);
8560
+ if (!/stable/.test(style.scrollbarGutter || "")) return {
8561
+ left: 0,
8562
+ right: width
8563
+ };
8564
+ let rect = docElt.getBoundingClientRect(), scrollX = view.win.scrollX;
8565
+ return {
8566
+ left: Math.max(0, rect.left + scrollX - parseFloat(style.marginLeft)),
8567
+ right: Math.min(width, rect.right + scrollX + parseFloat(style.marginRight))
8568
+ };
8569
+ }
8517
8570
  function windowSpace(view) {
8518
- let docElt = view.dom.ownerDocument.documentElement;
8571
+ let { left, right } = fixedRange(view);
8519
8572
  return {
8520
8573
  top: 0,
8521
- left: 0,
8522
- bottom: docElt.clientHeight,
8523
- right: docElt.clientWidth
8574
+ left,
8575
+ right,
8576
+ bottom: view.dom.ownerDocument.documentElement.clientHeight
8524
8577
  };
8525
8578
  }
8526
8579
  const tooltipConfig = /*@__PURE__*/ Facet.define({ combine: (values) => {
@@ -8633,7 +8686,7 @@ const tooltipPlugin = /*@__PURE__*/ ViewPlugin.fromClass(class {
8633
8686
  clearTimeout(this.measureTimeout);
8634
8687
  }
8635
8688
  readMeasure() {
8636
- let scaleX = 1, scaleY = 1, makeAbsolute = false;
8689
+ let scaleX = 1, scaleY = 1, makeAbsolute = false, fixedLeft = 0;
8637
8690
  if (this.position == "fixed" && this.manager.tooltipViews.length) {
8638
8691
  let { dom } = this.manager.tooltipViews[0];
8639
8692
  if (browser.safari) {
@@ -8649,7 +8702,7 @@ const tooltipPlugin = /*@__PURE__*/ ViewPlugin.fromClass(class {
8649
8702
  scaleY = rect.height / this.parent.offsetHeight;
8650
8703
  }
8651
8704
  } else ({scaleX, scaleY} = this.view.viewState);
8652
- }
8705
+ } else fixedLeft = fixedRange(this.view).left;
8653
8706
  let visible = this.view.scrollDOM.getBoundingClientRect(), margins = getScrollMargins(this.view);
8654
8707
  return {
8655
8708
  visible: {
@@ -8667,7 +8720,8 @@ const tooltipPlugin = /*@__PURE__*/ ViewPlugin.fromClass(class {
8667
8720
  space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
8668
8721
  scaleX,
8669
8722
  scaleY,
8670
- makeAbsolute
8723
+ makeAbsolute,
8724
+ fixedLeft
8671
8725
  };
8672
8726
  }
8673
8727
  writeMeasure(measured) {
@@ -8712,7 +8766,7 @@ const tooltipPlugin = /*@__PURE__*/ ViewPlugin.fromClass(class {
8712
8766
  setLeftStyle(dom, (left - measured.parent.left) / scaleX);
8713
8767
  } else {
8714
8768
  dom.style.top = top / scaleY + "px";
8715
- setLeftStyle(dom, left / scaleX);
8769
+ setLeftStyle(dom, (left - measured.fixedLeft) / scaleX);
8716
8770
  }
8717
8771
  if (arrow) {
8718
8772
  let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 - 7);
@@ -9292,6 +9346,18 @@ function showDialog(view, config) {
9292
9346
  })
9293
9347
  };
9294
9348
  }
9349
+ /**
9350
+ Find the [`Panel`](https://codemirror.net/6/docs/ref/#view.Panel) for an open dialog, using a class
9351
+ name as identifier.
9352
+ */
9353
+ function getDialog(view, className) {
9354
+ let dialogs = view.state.field(dialogField, false) || [];
9355
+ for (let open of dialogs) {
9356
+ let panel = getPanel(view, open);
9357
+ if (panel && panel.dom.classList.contains(className)) return panel;
9358
+ }
9359
+ return null;
9360
+ }
9295
9361
  const dialogField = /*@__PURE__*/ StateField.define({
9296
9362
  create() {
9297
9363
  return [];
@@ -9819,6 +9885,6 @@ function highlightActiveLineGutter() {
9819
9885
  return activeLineGutterHighlighter;
9820
9886
  }
9821
9887
  //#endregion
9822
- export { BidiSpan, BlockInfo, BlockType, BlockWrapper, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, activateHover, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutterWidgetClass, gutters, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, rectangularSelection, runScopeHandlers, showDialog, showPanel, showTooltip, tooltips };
9888
+ export { BidiSpan, BlockInfo, BlockType, BlockWrapper, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, activateHover, crosshairCursor, drawSelection, dropCursor, getDialog, getPanel, getTooltip, gutter, gutterLineClass, gutterWidgetClass, gutters, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumberWidgetMarker, lineNumbers, logException, rectangularSelection, runScopeHandlers, showDialog, showPanel, showTooltip, tooltips };
9823
9889
 
9824
9890
  //# sourceMappingURL=index.js.map