@onereach/ui-components 4.10.3 → 4.10.4-beta.2954.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 (70) hide show
  1. package/dist/bundled/v2/components/OrCode/OrCode.js +29 -83
  2. package/dist/bundled/v2/components/OrCode/index.js +2 -2
  3. package/dist/bundled/v2/components/OrCode/lang.js +2 -2
  4. package/dist/bundled/v2/components/OrCode/theme.js +1 -1
  5. package/dist/bundled/v2/components/OrInputV3/OrInput.js +17 -9
  6. package/dist/bundled/v2/components/OrModal/OrModal.js +1 -1
  7. package/dist/bundled/v2/components/index.js +2 -2
  8. package/dist/bundled/v2/hooks/useTheme.js +171 -172
  9. package/dist/bundled/v2/{index-cf2c3c27.js → index-a67049f4.js} +393 -253
  10. package/dist/bundled/v2/index.js +2 -2
  11. package/dist/bundled/v2/{lang-0fb8f78b.js → lang-02d1cdeb.js} +431 -365
  12. package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-3e7aa91a.js → OrCardCollection.vue_vue_type_script_lang-af7eb570.js} +1 -1
  13. package/dist/bundled/v3/{OrCode.vue_vue_type_script_lang-46846a36.js → OrCode.vue_vue_type_script_lang-f02bd2ce.js} +30 -84
  14. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-93458f1f.js → OrConfirm.vue_vue_type_script_lang-32350b03.js} +1 -1
  15. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-51f9e144.js → OrConfirm.vue_vue_type_script_lang-8e1752aa.js} +1 -1
  16. package/dist/bundled/v3/{OrInput.vue_vue_type_script_lang-66363c62.js → OrInput.vue_vue_type_script_lang-0c8510c2.js} +1 -1
  17. package/dist/bundled/v3/{OrModal.vue_vue_type_script_lang-153819d3.js → OrModal.vue_vue_type_script_lang-c4ef6dd6.js} +1 -1
  18. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-18dc2df8.js → OrSearch.vue_vue_type_script_lang-756be4f1.js} +1 -1
  19. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-72c1db17.js → OrSelect.vue_vue_type_script_lang-dc33e8c8.js} +1 -1
  20. package/dist/bundled/v3/components/OrCardCollectionV3/OrCardCollection.js +4 -4
  21. package/dist/bundled/v3/components/OrCardCollectionV3/index.js +3 -3
  22. package/dist/bundled/v3/components/OrCode/OrCode.js +5 -5
  23. package/dist/bundled/v3/components/OrCode/index.js +4 -4
  24. package/dist/bundled/v3/components/OrCode/lang.js +2 -2
  25. package/dist/bundled/v3/components/OrCode/theme.js +1 -1
  26. package/dist/bundled/v3/components/OrConfirm/OrConfirm.js +3 -3
  27. package/dist/bundled/v3/components/OrConfirm/index.js +2 -2
  28. package/dist/bundled/v3/components/OrConfirmV3/OrConfirm.js +3 -3
  29. package/dist/bundled/v3/components/OrConfirmV3/index.js +2 -2
  30. package/dist/bundled/v3/components/OrInputV3/OrInput.js +9 -8
  31. package/dist/bundled/v3/components/OrInputV3/OrInput.vue.d.ts +2 -1
  32. package/dist/bundled/v3/components/OrInputV3/index.js +1 -1
  33. package/dist/bundled/v3/components/OrModal/OrModal.js +2 -2
  34. package/dist/bundled/v3/components/OrModal/index.js +1 -1
  35. package/dist/bundled/v3/components/OrSearchV3/OrSearch.js +3 -3
  36. package/dist/bundled/v3/components/OrSearchV3/index.js +2 -2
  37. package/dist/bundled/v3/components/OrSelectV3/OrSelect.js +3 -3
  38. package/dist/bundled/v3/components/OrSelectV3/index.js +2 -2
  39. package/dist/bundled/v3/components/index.js +10 -10
  40. package/dist/bundled/v3/hooks/useTheme.js +171 -172
  41. package/dist/bundled/v3/{index-cf2c3c27.js → index-a67049f4.js} +393 -253
  42. package/dist/bundled/v3/index.js +10 -10
  43. package/dist/bundled/v3/{lang-0fb8f78b.js → lang-02d1cdeb.js} +431 -365
  44. package/dist/esm/v2/{OrCardCollection-79b90811.js → OrCardCollection-cfa31f60.js} +1 -1
  45. package/dist/esm/v2/{OrConfirm-0b56c11f.js → OrConfirm-e347e6d8.js} +1 -1
  46. package/dist/esm/v2/{OrInput-2eeff16a.js → OrInput-1ac05c06.js} +17 -9
  47. package/dist/esm/v2/{OrSearch-33e3b0e4.js → OrSearch-345cc833.js} +1 -1
  48. package/dist/esm/v2/{OrSelect-1ee299d9.js → OrSelect-7304a89a.js} +1 -1
  49. package/dist/esm/v2/components/index.js +5 -5
  50. package/dist/esm/v2/components/or-card-collection-v3/index.js +3 -3
  51. package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
  52. package/dist/esm/v2/components/or-input-v3/index.js +1 -1
  53. package/dist/esm/v2/components/or-search-v3/index.js +2 -2
  54. package/dist/esm/v2/components/or-select-v3/index.js +2 -2
  55. package/dist/esm/v2/index.js +5 -5
  56. package/dist/esm/v3/{OrCardCollection-76f937d5.js → OrCardCollection-65ba52be.js} +1 -1
  57. package/dist/esm/v3/{OrConfirm-5509c440.js → OrConfirm-28e1bb15.js} +1 -1
  58. package/dist/esm/v3/{OrInput-c653aedb.js → OrInput-58866c13.js} +8 -7
  59. package/dist/esm/v3/{OrSearch-b945651d.js → OrSearch-b6f37991.js} +1 -1
  60. package/dist/esm/v3/{OrSelect-5a2c078d.js → OrSelect-1c58ccaf.js} +1 -1
  61. package/dist/esm/v3/components/index.js +5 -5
  62. package/dist/esm/v3/components/or-card-collection-v3/index.js +3 -3
  63. package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
  64. package/dist/esm/v3/components/or-input-v3/OrInput.vue.d.ts +2 -1
  65. package/dist/esm/v3/components/or-input-v3/index.js +1 -1
  66. package/dist/esm/v3/components/or-search-v3/index.js +2 -2
  67. package/dist/esm/v3/components/or-select-v3/index.js +2 -2
  68. package/dist/esm/v3/index.js +5 -5
  69. package/package.json +2 -3
  70. package/src/components/or-input-v3/OrInput.vue +2 -1
@@ -3895,19 +3895,23 @@ class StyleModule {
3895
3895
  (root[SET] || new StyleSet(root)).mount(Array.isArray(modules) ? modules : [modules]);
3896
3896
  }
3897
3897
  }
3898
- let adoptedSet = null;
3898
+ let adoptedSet = new Map(); //<Document, StyleSet>
3899
+
3899
3900
  class StyleSet {
3900
3901
  constructor(root) {
3901
- if (!root.head && root.adoptedStyleSheets && typeof CSSStyleSheet != "undefined") {
3902
- if (adoptedSet) {
3903
- root.adoptedStyleSheets = [adoptedSet.sheet, ...root.adoptedStyleSheets];
3904
- return root[SET] = adoptedSet;
3902
+ let doc = root.ownerDocument || root,
3903
+ win = doc.defaultView;
3904
+ if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
3905
+ let adopted = adoptedSet.get(doc);
3906
+ if (adopted) {
3907
+ root.adoptedStyleSheets = [adopted.sheet, ...root.adoptedStyleSheets];
3908
+ return root[SET] = adopted;
3905
3909
  }
3906
- this.sheet = new CSSStyleSheet();
3910
+ this.sheet = new win.CSSStyleSheet();
3907
3911
  root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
3908
- adoptedSet = this;
3912
+ adoptedSet.set(doc, this);
3909
3913
  } else {
3910
- this.styleTag = (root.ownerDocument || root).createElement("style");
3914
+ this.styleTag = doc.createElement("style");
3911
3915
  let target = root.head || root;
3912
3916
  target.insertBefore(this.styleTag, target.firstChild);
3913
3917
  }
@@ -4152,12 +4156,6 @@ function scanFor(node, off, targetNode, targetOff, dir) {
4152
4156
  function maxOffset(node) {
4153
4157
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
4154
4158
  }
4155
- const Rect0 = {
4156
- left: 0,
4157
- right: 0,
4158
- top: 0,
4159
- bottom: 0
4160
- };
4161
4159
  function flattenRect(rect, left) {
4162
4160
  let x = left ? rect.left : rect.right;
4163
4161
  return {
@@ -4290,7 +4288,12 @@ class DOMSelectionState {
4290
4288
  return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset && this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
4291
4289
  }
4292
4290
  setRange(range) {
4293
- this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
4291
+ let {
4292
+ anchorNode,
4293
+ focusNode
4294
+ } = range;
4295
+ // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)
4296
+ this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));
4294
4297
  }
4295
4298
  set(anchorNode, anchorOffset, focusNode, focusOffset) {
4296
4299
  this.anchorNode = anchorNode;
@@ -4367,6 +4370,8 @@ function atElementStart(doc, selection) {
4367
4370
  let node = selection.focusNode,
4368
4371
  offset = selection.focusOffset;
4369
4372
  if (!node || selection.anchorNode != node || selection.anchorOffset != offset) return false;
4373
+ // Safari can report bogus offsets (#1152)
4374
+ offset = Math.min(offset, maxOffset(node));
4370
4375
  for (;;) {
4371
4376
  if (offset) {
4372
4377
  if (node.nodeType != 1) return false;
@@ -4425,12 +4430,6 @@ class ContentView {
4425
4430
  posAfter(view) {
4426
4431
  return this.posBefore(view) + view.length;
4427
4432
  }
4428
- // Will return a rectangle directly before (when side < 0), after
4429
- // (side > 0) or directly on (when the browser supports it) the
4430
- // given position.
4431
- coordsAt(_pos, _side) {
4432
- return null;
4433
- }
4434
4433
  sync(view, track) {
4435
4434
  if (this.dirty & 2 /* Dirty.Node */) {
4436
4435
  let parent = this.dom;
@@ -4888,13 +4887,16 @@ function textCoords(text, pos, side) {
4888
4887
  if (side < 0) from--;else if (to < length) to++;
4889
4888
  }
4890
4889
  let rects = textRange(text, from, to).getClientRects();
4891
- if (!rects.length) return Rect0;
4890
+ if (!rects.length) return null;
4892
4891
  let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
4893
4892
  if (browser.safari && !flatten && rect.width == 0) rect = Array.prototype.find.call(rects, r => r.width) || rect;
4894
4893
  return flatten ? flattenRect(rect, flatten < 0) : rect || null;
4895
4894
  }
4896
4895
  // Also used for collapsed ranges that don't have a placeholder widget!
4897
4896
  class WidgetView extends ContentView {
4897
+ static create(widget, length, side) {
4898
+ return new (widget.customView || WidgetView)(widget, length, side);
4899
+ }
4898
4900
  constructor(widget, length, side) {
4899
4901
  super();
4900
4902
  this.widget = widget;
@@ -4902,9 +4904,6 @@ class WidgetView extends ContentView {
4902
4904
  this.side = side;
4903
4905
  this.prevWidget = null;
4904
4906
  }
4905
- static create(widget, length, side) {
4906
- return new (widget.customView || WidgetView)(widget, length, side);
4907
- }
4908
4907
  split(from) {
4909
4908
  let result = WidgetView.create(this.widget, this.length - from, this.side);
4910
4909
  this.length -= from;
@@ -4927,13 +4926,12 @@ class WidgetView extends ContentView {
4927
4926
  return true;
4928
4927
  }
4929
4928
  become(other) {
4930
- if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
4931
- if (this.widget.constructor == other.widget.constructor) {
4932
- if (!this.widget.compare(other.widget)) this.markDirty(true);
4933
- if (this.dom && !this.prevWidget) this.prevWidget = this.widget;
4934
- this.widget = other.widget;
4935
- return true;
4936
- }
4929
+ if (other instanceof WidgetView && other.side == this.side && this.widget.constructor == other.widget.constructor) {
4930
+ if (!this.widget.compare(other.widget)) this.markDirty(true);
4931
+ if (this.dom && !this.prevWidget) this.prevWidget = this.widget;
4932
+ this.widget = other.widget;
4933
+ this.length = other.length;
4934
+ return true;
4937
4935
  }
4938
4936
  return false;
4939
4937
  }
@@ -4961,9 +4959,11 @@ class WidgetView extends ContentView {
4961
4959
  return null;
4962
4960
  }
4963
4961
  coordsAt(pos, side) {
4962
+ let custom = this.widget.coordsAt(this.dom, pos, side);
4963
+ if (custom) return custom;
4964
4964
  let rects = this.dom.getClientRects(),
4965
4965
  rect = null;
4966
- if (!rects.length) return Rect0;
4966
+ if (!rects.length) return null;
4967
4967
  for (let i = pos > 0 ? rects.length - 1 : 0;; i += pos > 0 ? -1 : 1) {
4968
4968
  rect = rects[i];
4969
4969
  if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom) break;
@@ -4991,7 +4991,7 @@ class CompositionView extends WidgetView {
4991
4991
  text
4992
4992
  } = this.widget;
4993
4993
  if (!topView) return new DOMPos(text, Math.min(pos, text.nodeValue.length));
4994
- return scanCompositionTree(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos(text, Math.min(p, text.nodeValue.length)));
4994
+ return scanCompositionTree(pos, 0, topView, text, this.length - topView.length, (v, p) => v.domAtPos(p), (text, p) => new DOMPos(text, Math.min(p, text.nodeValue.length)));
4995
4995
  }
4996
4996
  sync() {
4997
4997
  this.setDOM(this.widget.toDOM());
@@ -5002,7 +5002,7 @@ class CompositionView extends WidgetView {
5002
5002
  text
5003
5003
  } = this.widget;
5004
5004
  if (!topView) return Math.min(offset, this.length);
5005
- return posFromDOMInCompositionTree(node, offset, topView, text);
5005
+ return posFromDOMInCompositionTree(node, offset, topView, text, this.length - topView.length);
5006
5006
  }
5007
5007
  ignoreMutation() {
5008
5008
  return false;
@@ -5016,7 +5016,7 @@ class CompositionView extends WidgetView {
5016
5016
  text
5017
5017
  } = this.widget;
5018
5018
  if (!topView) return textCoords(text, pos, side);
5019
- return scanCompositionTree(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords(text, pos, side));
5019
+ return scanCompositionTree(pos, side, topView, text, this.length - topView.length, (v, pos, side) => v.coordsAt(pos, side), (text, pos, side) => textCoords(text, pos, side));
5020
5020
  }
5021
5021
  destroy() {
5022
5022
  var _a;
@@ -5033,36 +5033,92 @@ class CompositionView extends WidgetView {
5033
5033
  // Uses the old structure of a chunk of content view frozen for
5034
5034
  // composition to try and find a reasonable DOM location for the given
5035
5035
  // offset.
5036
- function scanCompositionTree(pos, side, view, text, enterView, fromText) {
5036
+ function scanCompositionTree(pos, side, view, text, dLen, enterView, fromText) {
5037
5037
  if (view instanceof MarkView) {
5038
5038
  for (let child = view.dom.firstChild; child; child = child.nextSibling) {
5039
5039
  let desc = ContentView.get(child);
5040
- if (!desc) return fromText(pos, side);
5041
- let hasComp = contains(child, text);
5042
- let len = desc.length + (hasComp ? text.nodeValue.length : 0);
5043
- if (pos < len || pos == len && desc.getSide() <= 0) return hasComp ? scanCompositionTree(pos, side, desc, text, enterView, fromText) : enterView(desc, pos, side);
5044
- pos -= len;
5040
+ if (!desc) {
5041
+ let inner = scanCompositionNode(pos, side, child, fromText);
5042
+ if (typeof inner != "number") return inner;
5043
+ pos = inner;
5044
+ } else {
5045
+ let hasComp = contains(child, text);
5046
+ let len = desc.length + (hasComp ? dLen : 0);
5047
+ if (pos < len || pos == len && desc.getSide() <= 0) return hasComp ? scanCompositionTree(pos, side, desc, text, dLen, enterView, fromText) : enterView(desc, pos, side);
5048
+ pos -= len;
5049
+ }
5045
5050
  }
5046
5051
  return enterView(view, view.length, -1);
5047
5052
  } else if (view.dom == text) {
5048
- return fromText(pos, side);
5053
+ return fromText(text, pos, side);
5049
5054
  } else {
5050
5055
  return enterView(view, pos, side);
5051
5056
  }
5052
5057
  }
5053
- function posFromDOMInCompositionTree(node, offset, view, text) {
5058
+ function scanCompositionNode(pos, side, node, fromText) {
5059
+ if (node.nodeType == 3) {
5060
+ let len = node.nodeValue.length;
5061
+ if (pos <= len) return fromText(node, pos, side);
5062
+ pos -= len;
5063
+ } else if (node.nodeType == 1 && node.contentEditable != "false") {
5064
+ for (let child = node.firstChild; child; child = child.nextSibling) {
5065
+ let inner = scanCompositionNode(pos, side, child, fromText);
5066
+ if (typeof inner != "number") return inner;
5067
+ pos = inner;
5068
+ }
5069
+ }
5070
+ return pos;
5071
+ }
5072
+ function posFromDOMInCompositionTree(node, offset, view, text, dLen) {
5054
5073
  if (view instanceof MarkView) {
5055
5074
  let pos = 0;
5056
- for (let child of view.children) {
5057
- let hasComp = contains(child.dom, text);
5058
- if (contains(child.dom, node)) return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, child, text) : child.localPosFromDOM(node, offset));
5059
- pos += hasComp ? text.nodeValue.length : child.length;
5075
+ for (let child = view.dom.firstChild; child; child = child.nextSibling) {
5076
+ let childView = ContentView.get(child);
5077
+ if (childView) {
5078
+ let hasComp = contains(child, text);
5079
+ if (contains(child, node)) return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, childView, text, dLen) : childView.localPosFromDOM(node, offset));
5080
+ pos += childView.length + (hasComp ? dLen : 0);
5081
+ } else {
5082
+ let inner = posFromDOMInOpaqueNode(node, offset, child);
5083
+ if (inner.result != null) return pos + inner.result;
5084
+ pos += inner.size;
5085
+ }
5060
5086
  }
5061
5087
  } else if (view.dom == text) {
5062
5088
  return Math.min(offset, text.nodeValue.length);
5063
5089
  }
5064
5090
  return view.localPosFromDOM(node, offset);
5065
5091
  }
5092
+ function posFromDOMInOpaqueNode(node, offset, target) {
5093
+ if (target.nodeType == 3) {
5094
+ return node == target ? {
5095
+ result: offset
5096
+ } : {
5097
+ size: target.nodeValue.length
5098
+ };
5099
+ } else if (target.nodeType == 1 && target.contentEditable != "false") {
5100
+ let pos = 0;
5101
+ for (let child = target.firstChild, i = 0;; child = child.nextSibling, i++) {
5102
+ if (node == target && i == offset) return {
5103
+ result: pos
5104
+ };
5105
+ if (!child) return {
5106
+ size: pos
5107
+ };
5108
+ let inner = posFromDOMInOpaqueNode(node, offset, child);
5109
+ if (inner.result != null) return {
5110
+ result: offset + inner.result
5111
+ };
5112
+ pos += inner.size;
5113
+ }
5114
+ } else {
5115
+ return target.contains(node) ? {
5116
+ result: 0
5117
+ } : {
5118
+ size: 0
5119
+ };
5120
+ }
5121
+ }
5066
5122
  // These are drawn around uneditable widgets to avoid a number of
5067
5123
  // browser bugs that show up when the cursor is directly next to
5068
5124
  // uneditable inline content.
@@ -5104,16 +5160,7 @@ class WidgetBufferView extends ContentView {
5104
5160
  return null;
5105
5161
  }
5106
5162
  coordsAt(pos) {
5107
- let imgRect = this.dom.getBoundingClientRect();
5108
- // Since the <img> height doesn't correspond to text height, try
5109
- // to borrow the height from some sibling node.
5110
- let siblingRect = inlineSiblingRect(this, this.side > 0 ? -1 : 1);
5111
- return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top ? {
5112
- left: imgRect.left,
5113
- right: imgRect.right,
5114
- top: siblingRect.top,
5115
- bottom: siblingRect.bottom
5116
- } : imgRect;
5163
+ return this.dom.getBoundingClientRect();
5117
5164
  }
5118
5165
  get overrideDOMText() {
5119
5166
  return Text.empty;
@@ -5123,28 +5170,6 @@ class WidgetBufferView extends ContentView {
5123
5170
  }
5124
5171
  }
5125
5172
  TextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;
5126
- function inlineSiblingRect(view, side) {
5127
- let parent = view.parent,
5128
- index = parent ? parent.children.indexOf(view) : -1;
5129
- while (parent && index >= 0) {
5130
- if (side < 0 ? index > 0 : index < parent.children.length) {
5131
- let next = parent.children[index + side];
5132
- if (next instanceof TextView) {
5133
- let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
5134
- if (nextRect) return nextRect;
5135
- }
5136
- index += side;
5137
- } else if (parent instanceof MarkView && parent.parent) {
5138
- index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
5139
- parent = parent.parent;
5140
- } else {
5141
- let last = parent.dom.lastChild;
5142
- if (last && last.nodeName == "BR") return last.getClientRects()[0];
5143
- break;
5144
- }
5145
- }
5146
- return undefined;
5147
- }
5148
5173
  function inlineDOMAtPos(parent, pos) {
5149
5174
  let dom = parent.dom,
5150
5175
  {
@@ -5195,10 +5220,10 @@ function coordsInChildren(view, pos, side) {
5195
5220
  if (end >= pos) {
5196
5221
  if (child.children.length) {
5197
5222
  scan(child, pos - off);
5198
- } else if ((!after || after instanceof WidgetBufferView && side > 0) && (end > pos || off == end && child.getSide() > 0)) {
5223
+ } else if ((!after || after.isHidden && side > 0) && (end > pos || off == end && child.getSide() > 0)) {
5199
5224
  after = child;
5200
5225
  afterPos = pos - off;
5201
- } else if (off < pos || off == end && child.getSide() < 0) {
5226
+ } else if (off < pos || off == end && child.getSide() < 0 && !child.isHidden) {
5202
5227
  before = child;
5203
5228
  beforePos = pos - off;
5204
5229
  }
@@ -5295,6 +5320,16 @@ class WidgetType {
5295
5320
  return true;
5296
5321
  }
5297
5322
  /**
5323
+ Override the way screen coordinates for positions at/in the
5324
+ widget are found. `pos` will be the offset into the widget, and
5325
+ `side` the side of the position that is being queried—less than
5326
+ zero for before, greater than zero for after, and zero for
5327
+ directly at that position.
5328
+ */
5329
+ coordsAt(dom, pos, side) {
5330
+ return null;
5331
+ }
5332
+ /**
5298
5333
  @internal
5299
5334
  */
5300
5335
  get customView() {
@@ -5727,11 +5762,12 @@ class BlockWidgetView extends ContentView {
5727
5762
  return null;
5728
5763
  }
5729
5764
  become(other) {
5730
- if (other instanceof BlockWidgetView && other.type == this.type && other.widget.constructor == this.widget.constructor) {
5765
+ if (other instanceof BlockWidgetView && other.widget.constructor == this.widget.constructor) {
5731
5766
  if (!other.widget.compare(this.widget)) this.markDirty(true);
5732
5767
  if (this.dom && !this.prevWidget) this.prevWidget = this.widget;
5733
5768
  this.widget = other.widget;
5734
5769
  this.length = other.length;
5770
+ this.type = other.type;
5735
5771
  this.breakAfter = other.breakAfter;
5736
5772
  return true;
5737
5773
  }
@@ -5749,6 +5785,9 @@ class BlockWidgetView extends ContentView {
5749
5785
  get isWidget() {
5750
5786
  return true;
5751
5787
  }
5788
+ coordsAt(pos, side) {
5789
+ return this.widget.coordsAt(this.dom, pos, side);
5790
+ }
5752
5791
  destroy() {
5753
5792
  super.destroy();
5754
5793
  if (this.dom) this.widget.destroy(this.dom);
@@ -6080,6 +6119,27 @@ const contentAttributes = /*@__PURE__*/Facet.define();
6080
6119
  const decorations = /*@__PURE__*/Facet.define();
6081
6120
  const atomicRanges = /*@__PURE__*/Facet.define();
6082
6121
  const scrollMargins = /*@__PURE__*/Facet.define();
6122
+ function getScrollMargins(view) {
6123
+ let left = 0,
6124
+ right = 0,
6125
+ top = 0,
6126
+ bottom = 0;
6127
+ for (let source of view.state.facet(scrollMargins)) {
6128
+ let m = source(view);
6129
+ if (m) {
6130
+ if (m.left != null) left = Math.max(left, m.left);
6131
+ if (m.right != null) right = Math.max(right, m.right);
6132
+ if (m.top != null) top = Math.max(top, m.top);
6133
+ if (m.bottom != null) bottom = Math.max(bottom, m.bottom);
6134
+ }
6135
+ }
6136
+ return {
6137
+ left,
6138
+ right,
6139
+ top,
6140
+ bottom
6141
+ };
6142
+ }
6083
6143
  const styleModule = /*@__PURE__*/Facet.define();
6084
6144
  class ChangedRange {
6085
6145
  constructor(fromA, toA, fromB, toB) {
@@ -6261,6 +6321,12 @@ Represents a contiguous range of text that has a single direction
6261
6321
  (as in left-to-right or right-to-left).
6262
6322
  */
6263
6323
  class BidiSpan {
6324
+ /**
6325
+ The direction of this span.
6326
+ */
6327
+ get dir() {
6328
+ return this.level % 2 ? RTL : LTR;
6329
+ }
6264
6330
  /**
6265
6331
  @internal
6266
6332
  */
@@ -6286,12 +6352,6 @@ class BidiSpan {
6286
6352
  this.level = level;
6287
6353
  }
6288
6354
  /**
6289
- The direction of this span.
6290
- */
6291
- get dir() {
6292
- return this.level % 2 ? RTL : LTR;
6293
- }
6294
- /**
6295
6355
  @internal
6296
6356
  */
6297
6357
  side(end, dir) {
@@ -6512,12 +6572,13 @@ class DOMReader {
6512
6572
  let parent = start.parentNode;
6513
6573
  for (let cur = start;;) {
6514
6574
  this.findPointBefore(parent, cur);
6575
+ let oldLen = this.text.length;
6515
6576
  this.readNode(cur);
6516
6577
  let next = cur.nextSibling;
6517
6578
  if (next == end) break;
6518
6579
  let view = ContentView.get(cur),
6519
6580
  nextView = ContentView.get(next);
6520
- if (view && nextView ? view.breakAfter : (view ? view.breakAfter : isBlockElement(cur)) || isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore)) this.lineBreak();
6581
+ if (view && nextView ? view.breakAfter : (view ? view.breakAfter : isBlockElement(cur)) || isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen) this.lineBreak();
6521
6582
  cur = next;
6522
6583
  }
6523
6584
  this.findPointBefore(parent, end);
@@ -6579,6 +6640,9 @@ class DOMPoint {
6579
6640
  }
6580
6641
  }
6581
6642
  class DocView extends ContentView {
6643
+ get length() {
6644
+ return this.view.state.doc.length;
6645
+ }
6582
6646
  constructor(view) {
6583
6647
  super();
6584
6648
  this.view = view;
@@ -6609,9 +6673,6 @@ class DocView extends ContentView {
6609
6673
  this.updateDeco();
6610
6674
  this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
6611
6675
  }
6612
- get length() {
6613
- return this.view.state.doc.length;
6614
- }
6615
6676
  // Update the document view to a given state. scrollIntoView can be
6616
6677
  // used as a hint to compute a new viewport that includes that
6617
6678
  // position, if we know the editor is going to scroll that position
@@ -6716,7 +6777,10 @@ class DocView extends ContentView {
6716
6777
  let mustRead = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6717
6778
  let fromPointer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6718
6779
  if (mustRead || !this.view.observer.selectionRange.focusNode) this.view.observer.readSelectionRange();
6719
- if (!(fromPointer || this.mayControlSelection())) return;
6780
+ let activeElt = this.view.root.activeElement,
6781
+ focused = activeElt == this.dom;
6782
+ let selectionNotFocus = !focused && hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));
6783
+ if (!(focused || fromPointer || selectionNotFocus)) return;
6720
6784
  let force = this.forceSelection;
6721
6785
  this.forceSelection = false;
6722
6786
  let main = this.view.state.selection.main;
@@ -6777,6 +6841,10 @@ class DocView extends ContentView {
6777
6841
  rawSel.removeAllRanges();
6778
6842
  rawSel.addRange(range);
6779
6843
  }
6844
+ if (selectionNotFocus && this.view.root.activeElement == this.dom) {
6845
+ this.dom.blur();
6846
+ if (activeElt) activeElt.focus();
6847
+ }
6780
6848
  });
6781
6849
  this.view.observer.setSelectionRange(anchor, head);
6782
6850
  }
@@ -6811,10 +6879,6 @@ class DocView extends ContentView {
6811
6879
  let newRange = view.observer.selectionRange;
6812
6880
  if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from) sel.collapse(anchorNode, anchorOffset);
6813
6881
  }
6814
- mayControlSelection() {
6815
- let active = this.view.root.activeElement;
6816
- return active == this.dom || hasSelection(this.dom, this.view.observer.selectionRange) && !(active && this.dom.contains(active));
6817
- }
6818
6882
  nearest(dom) {
6819
6883
  for (let cur = dom; cur;) {
6820
6884
  let domView = ContentView.get(cur);
@@ -6970,27 +7034,12 @@ class DocView extends ContentView {
6970
7034
  right: Math.max(rect.right, other.right),
6971
7035
  bottom: Math.max(rect.bottom, other.bottom)
6972
7036
  };
6973
- let mLeft = 0,
6974
- mRight = 0,
6975
- mTop = 0,
6976
- mBottom = 0;
6977
- for (let margins of this.view.state.facet(scrollMargins).map(f => f(this.view))) if (margins) {
6978
- let {
6979
- left,
6980
- right,
6981
- top,
6982
- bottom
6983
- } = margins;
6984
- if (left != null) mLeft = Math.max(mLeft, left);
6985
- if (right != null) mRight = Math.max(mRight, right);
6986
- if (top != null) mTop = Math.max(mTop, top);
6987
- if (bottom != null) mBottom = Math.max(mBottom, bottom);
6988
- }
7037
+ let margins = getScrollMargins(this.view);
6989
7038
  let targetRect = {
6990
- left: rect.left - mLeft,
6991
- top: rect.top - mTop,
6992
- right: rect.right + mRight,
6993
- bottom: rect.bottom + mBottom
7039
+ left: rect.left - margins.left,
7040
+ top: rect.top - margins.top,
7041
+ right: rect.right + margins.right,
7042
+ bottom: rect.bottom + margins.bottom
6994
7043
  };
6995
7044
  scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction.LTR);
6996
7045
  }
@@ -7070,9 +7119,10 @@ function computeCompositionDeco(view, changes) {
7070
7119
  state
7071
7120
  } = view,
7072
7121
  text = node.nodeType == 3 ? node.nodeValue : new DOMReader([], state).readRange(node.firstChild, null).text;
7122
+ if (text.indexOf(LineBreakPlaceholder) > -1) return Decoration.none; // Don't try to preserve multi-line compositions
7073
7123
  if (newTo - newFrom < text.length) {
7074
- if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder) == text) newTo = newFrom + text.length;else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder) == text) newFrom = newTo - text.length;else return Decoration.none;
7075
- } else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder) != text) {
7124
+ if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length)) == text) newTo = newFrom + text.length;else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo) == text) newFrom = newTo - text.length;else return Decoration.none;
7125
+ } else if (state.doc.sliceString(newFrom, newTo) != text) {
7076
7126
  return Decoration.none;
7077
7127
  }
7078
7128
  let topView = ContentView.get(node);
@@ -7489,24 +7539,32 @@ function moveVertically(view, start, forward, distance) {
7489
7539
  if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) return EditorSelection.cursor(pos, start.assoc, undefined, goal);
7490
7540
  }
7491
7541
  }
7492
- function skipAtoms(view, oldPos, pos) {
7493
- let atoms = view.state.facet(atomicRanges).map(f => f(view));
7542
+ function skipAtomicRanges(atoms, pos, bias) {
7494
7543
  for (;;) {
7495
- let moved = false;
7544
+ let moved = 0;
7496
7545
  for (let set of atoms) {
7497
- set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
7498
- if (pos.from > from && pos.from < to) {
7499
- pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
7500
- moved = true;
7546
+ set.between(pos - 1, pos + 1, (from, to, value) => {
7547
+ if (pos > from && pos < to) {
7548
+ let side = moved || bias || (pos - from < to - pos ? -1 : 1);
7549
+ pos = side < 0 ? from : to;
7550
+ moved = side;
7501
7551
  }
7502
7552
  });
7503
7553
  }
7504
7554
  if (!moved) return pos;
7505
7555
  }
7506
7556
  }
7557
+ function skipAtoms(view, oldPos, pos) {
7558
+ let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
7559
+ return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
7560
+ }
7507
7561
 
7508
7562
  // This will also be where dragging info and such goes
7509
7563
  class InputState {
7564
+ setSelectionOrigin(origin) {
7565
+ this.lastSelectionOrigin = origin;
7566
+ this.lastSelectionTime = Date.now();
7567
+ }
7510
7568
  constructor(view) {
7511
7569
  this.lastKeyCode = 0;
7512
7570
  this.lastKeyTime = 0;
@@ -7571,6 +7629,9 @@ class InputState {
7571
7629
  }
7572
7630
  }
7573
7631
  });
7632
+ view.scrollDOM.addEventListener("drop", event => {
7633
+ if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) handleEvent(handlers.drop, event);
7634
+ });
7574
7635
  if (browser.chrome && browser.chrome_version == 102) {
7575
7636
  // FIXME remove at some point
7576
7637
  // On Chrome 102, viewport updates somehow stop wheel-based
@@ -7591,10 +7652,6 @@ class InputState {
7591
7652
  // issue where the composition vanishes when you press enter.
7592
7653
  if (browser.safari) view.contentDOM.addEventListener("input", () => null);
7593
7654
  }
7594
- setSelectionOrigin(origin) {
7595
- this.lastSelectionOrigin = origin;
7596
- this.lastSelectionTime = Date.now();
7597
- }
7598
7655
  ensureHandlers(view, plugins) {
7599
7656
  var _a;
7600
7657
  let handlers;
@@ -7645,6 +7702,7 @@ class InputState {
7645
7702
  this.lastKeyCode = event.keyCode;
7646
7703
  this.lastKeyTime = Date.now();
7647
7704
  if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000) return true;
7705
+ if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0) view.inputState.lastEscPress = 0;
7648
7706
  // Chrome for Android usually doesn't fire proper key events, but
7649
7707
  // occasionally does, usually surrounded by a bunch of complicated
7650
7708
  // composition changes. When an enter or backspace key event is
@@ -7735,6 +7793,7 @@ class MouseSelection {
7735
7793
  this.scrolling = -1;
7736
7794
  this.lastEvent = startEvent;
7737
7795
  this.scrollParent = scrollableParent(view.contentDOM);
7796
+ this.atoms = view.state.facet(atomicRanges).map(f => f(view));
7738
7797
  let doc = view.contentDOM.ownerDocument;
7739
7798
  doc.addEventListener("mousemove", this.move = this.move.bind(this));
7740
7799
  doc.addEventListener("mouseup", this.up = this.up.bind(this));
@@ -7764,8 +7823,9 @@ class MouseSelection {
7764
7823
  right: this.view.win.innerWidth,
7765
7824
  bottom: this.view.win.innerHeight
7766
7825
  };
7767
- if (event.clientX <= rect.left + dragScrollMargin) sx = -dragScrollSpeed(rect.left - event.clientX);else if (event.clientX >= rect.right - dragScrollMargin) sx = dragScrollSpeed(event.clientX - rect.right);
7768
- if (event.clientY <= rect.top + dragScrollMargin) sy = -dragScrollSpeed(rect.top - event.clientY);else if (event.clientY >= rect.bottom - dragScrollMargin) sy = dragScrollSpeed(event.clientY - rect.bottom);
7826
+ let margins = getScrollMargins(this.view);
7827
+ if (event.clientX - margins.left <= rect.left + dragScrollMargin) sx = -dragScrollSpeed(rect.left - event.clientX);else if (event.clientX + margins.right >= rect.right - dragScrollMargin) sx = dragScrollSpeed(event.clientX - rect.right);
7828
+ if (event.clientY - margins.top <= rect.top + dragScrollMargin) sy = -dragScrollSpeed(rect.top - event.clientY);else if (event.clientY + margins.bottom >= rect.bottom - dragScrollMargin) sy = dragScrollSpeed(event.clientY - rect.bottom);
7769
7829
  this.setScrollSpeed(sx, sy);
7770
7830
  }
7771
7831
  up(event) {
@@ -7801,9 +7861,32 @@ class MouseSelection {
7801
7861
  }
7802
7862
  if (this.dragging === false) this.select(this.lastEvent);
7803
7863
  }
7864
+ skipAtoms(sel) {
7865
+ let ranges = null;
7866
+ for (let i = 0; i < sel.ranges.length; i++) {
7867
+ let range = sel.ranges[i],
7868
+ updated = null;
7869
+ if (range.empty) {
7870
+ let pos = skipAtomicRanges(this.atoms, range.from, 0);
7871
+ if (pos != range.from) updated = EditorSelection.cursor(pos, -1);
7872
+ } else {
7873
+ let from = skipAtomicRanges(this.atoms, range.from, -1);
7874
+ let to = skipAtomicRanges(this.atoms, range.to, 1);
7875
+ if (from != range.from || to != range.to) updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
7876
+ }
7877
+ if (updated) {
7878
+ if (!ranges) ranges = sel.ranges.slice();
7879
+ ranges[i] = updated;
7880
+ }
7881
+ }
7882
+ return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
7883
+ }
7804
7884
  select(event) {
7805
- let selection = this.style.get(event, this.extend, this.multiple);
7806
- if (this.mustSelect || !selection.eq(this.view.state.selection) || selection.main.assoc != this.view.state.selection.main.assoc) this.view.dispatch({
7885
+ let {
7886
+ view
7887
+ } = this,
7888
+ selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
7889
+ if (this.mustSelect || !selection.eq(view.state.selection) || selection.main.assoc != view.state.selection.main.assoc) this.view.dispatch({
7807
7890
  selection,
7808
7891
  userEvent: "select.pointer"
7809
7892
  });
@@ -7910,7 +7993,7 @@ function doPaste(view, input) {
7910
7993
  }
7911
7994
  handlers.keydown = (view, event) => {
7912
7995
  view.inputState.setSelectionOrigin("select");
7913
- if (event.keyCode == 27) view.inputState.lastEscPress = Date.now();else if (modifierCodes.indexOf(event.keyCode) < 0) view.inputState.lastEscPress = 0;
7996
+ if (event.keyCode == 27) view.inputState.lastEscPress = Date.now();
7914
7997
  };
7915
7998
  handlers.touchstart = (view, e) => {
7916
7999
  view.inputState.lastTouchTime = Date.now();
@@ -8231,11 +8314,20 @@ handlers.compositionend = view => {
8231
8314
  view.inputState.compositionPendingKey = true;
8232
8315
  view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
8233
8316
  view.inputState.compositionFirstChange = null;
8234
- if (browser.chrome && browser.android) view.observer.flushSoon();
8235
- setTimeout(() => {
8236
- // Force the composition state to be cleared if it hasn't already been
8237
- if (view.inputState.composing < 0 && view.docView.compositionDeco.size) view.update([]);
8238
- }, 50);
8317
+ if (browser.chrome && browser.android) {
8318
+ // Delay flushing for a bit on Android because it'll often fire a
8319
+ // bunch of contradictory changes in a row at end of compositon
8320
+ view.observer.flushSoon();
8321
+ } else if (view.inputState.compositionPendingChange) {
8322
+ // If we found pending records, schedule a flush.
8323
+ Promise.resolve().then(() => view.observer.flush());
8324
+ } else {
8325
+ // Otherwise, make sure that, if no changes come in soon, the
8326
+ // composition view is cleared.
8327
+ setTimeout(() => {
8328
+ if (view.inputState.composing < 0 && view.docView.compositionDeco.size) view.update([]);
8329
+ }, 50);
8330
+ }
8239
8331
  };
8240
8332
  handlers.contextmenu = view => {
8241
8333
  view.inputState.lastContextMenu = Date.now();
@@ -8369,15 +8461,34 @@ class BlockInfo {
8369
8461
  */
8370
8462
  height,
8371
8463
  /**
8372
- The type of element this is. When querying lines, this may be
8373
- an array of all the blocks that make up the line.
8464
+ @internal
8465
+ */
8466
+ children,
8467
+ /**
8468
+ @internal
8374
8469
  */
8375
- type) {
8470
+ deco) {
8376
8471
  this.from = from;
8377
8472
  this.length = length;
8378
8473
  this.top = top;
8379
8474
  this.height = height;
8380
- this.type = type;
8475
+ this.children = children;
8476
+ this.deco = deco;
8477
+ }
8478
+ /**
8479
+ The type of element this is. When querying lines, this may be
8480
+ an array of all the blocks that make up the line.
8481
+ */
8482
+ get type() {
8483
+ var _a, _b, _c;
8484
+ return (_c = (_a = this.children) !== null && _a !== void 0 ? _a : (_b = this.deco) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : BlockType.Text;
8485
+ }
8486
+ /**
8487
+ If this is a widget block, this will return the widget
8488
+ associated with it.
8489
+ */
8490
+ get widget() {
8491
+ return this.deco && this.deco.widget;
8381
8492
  }
8382
8493
  /**
8383
8494
  The end of the element as a document position.
@@ -8395,8 +8506,8 @@ class BlockInfo {
8395
8506
  @internal
8396
8507
  */
8397
8508
  join(other) {
8398
- let detail = (Array.isArray(this.type) ? this.type : [this]).concat(Array.isArray(other.type) ? other.type : [other]);
8399
- return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
8509
+ let children = (this.children || [this]).concat(other.children || [other]);
8510
+ return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, children, null);
8400
8511
  }
8401
8512
  }
8402
8513
  var QueryType = /*@__PURE__*/function (QueryType) {
@@ -8516,12 +8627,12 @@ class HeightMap {
8516
8627
  }
8517
8628
  HeightMap.prototype.size = 1;
8518
8629
  class HeightMapBlock extends HeightMap {
8519
- constructor(length, height, type) {
8630
+ constructor(length, height, deco) {
8520
8631
  super(length, height);
8521
- this.type = type;
8632
+ this.deco = deco;
8522
8633
  }
8523
8634
  blockAt(_height, _oracle, top, offset) {
8524
- return new BlockInfo(offset, this.length, top, this.height, this.type);
8635
+ return new BlockInfo(offset, this.length, top, this.height, null, this.deco);
8525
8636
  }
8526
8637
  lineAt(_value, _type, oracle, top, offset) {
8527
8638
  return this.blockAt(0, oracle, top, offset);
@@ -8542,7 +8653,7 @@ class HeightMapBlock extends HeightMap {
8542
8653
  }
8543
8654
  class HeightMapText extends HeightMapBlock {
8544
8655
  constructor(length, height) {
8545
- super(length, height, BlockType.Text);
8656
+ super(length, height, null);
8546
8657
  this.collapsed = 0; // Amount of collapsed content in the line
8547
8658
  this.widgetHeight = 0; // Maximum inline widget height
8548
8659
  }
@@ -8582,7 +8693,7 @@ class HeightMapGap extends HeightMap {
8582
8693
  if (oracle.lineWrapping) {
8583
8694
  let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);
8584
8695
  perLine = totalPerLine / lines;
8585
- perChar = (this.height - totalPerLine) / (this.length - lines - 1);
8696
+ if (this.length > lines + 1) perChar = (this.height - totalPerLine) / (this.length - lines - 1);
8586
8697
  } else {
8587
8698
  perLine = this.height / lines;
8588
8699
  }
@@ -8605,14 +8716,14 @@ class HeightMapGap extends HeightMap {
8605
8716
  let line = oracle.doc.lineAt(guess),
8606
8717
  lineHeight = perLine + line.length * perChar;
8607
8718
  let lineTop = Math.max(top, height - lineHeight / 2);
8608
- return new BlockInfo(line.from, line.length, lineTop, lineHeight, BlockType.Text);
8719
+ return new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null);
8609
8720
  } else {
8610
8721
  let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
8611
8722
  let {
8612
8723
  from,
8613
8724
  length
8614
8725
  } = oracle.doc.line(firstLine + line);
8615
- return new BlockInfo(from, length, top + perLine * line, perLine, BlockType.Text);
8726
+ return new BlockInfo(from, length, top + perLine * line, perLine, null, null);
8616
8727
  }
8617
8728
  }
8618
8729
  lineAt(value, type, oracle, top, offset) {
@@ -8622,7 +8733,7 @@ class HeightMapGap extends HeightMap {
8622
8733
  from,
8623
8734
  to
8624
8735
  } = oracle.doc.lineAt(value);
8625
- return new BlockInfo(from, to - from, 0, 0, BlockType.Text);
8736
+ return new BlockInfo(from, to - from, 0, 0, null, null);
8626
8737
  }
8627
8738
  let {
8628
8739
  firstLine,
@@ -8633,7 +8744,7 @@ class HeightMapGap extends HeightMap {
8633
8744
  lineHeight = perLine + line.length * perChar;
8634
8745
  let linesAbove = line.number - firstLine;
8635
8746
  let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
8636
- return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, BlockType.Text);
8747
+ return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, null, null);
8637
8748
  }
8638
8749
  forEachLine(from, to, oracle, top, offset, f) {
8639
8750
  from = Math.max(from, offset);
@@ -8650,7 +8761,7 @@ class HeightMapGap extends HeightMap {
8650
8761
  lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
8651
8762
  }
8652
8763
  let lineHeight = perLine + perChar * line.length;
8653
- f(new BlockInfo(line.from, line.length, lineTop, lineHeight, BlockType.Text));
8764
+ f(new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null));
8654
8765
  lineTop += lineHeight;
8655
8766
  pos = line.to + 1;
8656
8767
  }
@@ -8850,7 +8961,7 @@ class NodeBuilder {
8850
8961
  if (height < 0) height = this.oracle.lineHeight;
8851
8962
  let len = to - from;
8852
8963
  if (deco.block) {
8853
- this.addBlock(new HeightMapBlock(len, height, deco.type));
8964
+ this.addBlock(new HeightMapBlock(len, height, deco));
8854
8965
  } else if (len || height >= relevantWidgetHeight) {
8855
8966
  this.addLineDeco(height, len);
8856
8967
  }
@@ -8888,11 +8999,13 @@ class NodeBuilder {
8888
8999
  return line;
8889
9000
  }
8890
9001
  addBlock(block) {
9002
+ var _a;
8891
9003
  this.enterLine();
8892
- if (block.type == BlockType.WidgetAfter && !this.isCovered) this.ensureLine();
9004
+ let type = (_a = block.deco) === null || _a === void 0 ? void 0 : _a.type;
9005
+ if (type == BlockType.WidgetAfter && !this.isCovered) this.ensureLine();
8893
9006
  this.nodes.push(block);
8894
9007
  this.writtenTo = this.pos = this.pos + block.length;
8895
- if (block.type != BlockType.WidgetBefore) this.covering = block;
9008
+ if (type != BlockType.WidgetBefore) this.covering = block;
8896
9009
  }
8897
9010
  addLineDeco(height, length) {
8898
9011
  let line = this.ensureLine();
@@ -9540,7 +9653,7 @@ function scaleBlock(block, scaler) {
9540
9653
  if (scaler.scale == 1) return block;
9541
9654
  let bTop = scaler.toDOM(block.top),
9542
9655
  bBottom = scaler.toDOM(block.bottom);
9543
- return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock(b, scaler)) : block.type);
9656
+ return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, block.children && block.children.map(b => scaleBlock(b, scaler)), block.deco);
9544
9657
  }
9545
9658
  const theme = /*@__PURE__*/Facet.define({
9546
9659
  combine: strs => strs.join(" ")
@@ -9640,16 +9753,16 @@ const baseTheme$1$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
9640
9753
  "&dark .cm-selectionBackground": {
9641
9754
  background: "#222"
9642
9755
  },
9643
- "&light.cm-focused .cm-selectionBackground": {
9756
+ "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
9644
9757
  background: "#d7d4f0"
9645
9758
  },
9646
- "&dark.cm-focused .cm-selectionBackground": {
9759
+ "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
9647
9760
  background: "#233"
9648
9761
  },
9649
9762
  ".cm-cursorLayer": {
9650
9763
  pointerEvents: "none"
9651
9764
  },
9652
- "&.cm-focused .cm-cursorLayer": {
9765
+ "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
9653
9766
  animation: "steps(1) cm-blink 1.2s infinite"
9654
9767
  },
9655
9768
  // Two animations defined so that we can switch between them to
@@ -9683,7 +9796,7 @@ const baseTheme$1$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
9683
9796
  ".cm-dropCursor": {
9684
9797
  position: "absolute"
9685
9798
  },
9686
- "&.cm-focused .cm-cursor": {
9799
+ "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
9687
9800
  display: "block"
9688
9801
  },
9689
9802
  "&light .cm-activeLine": {
@@ -9857,6 +9970,7 @@ function applyDOMChange(view, domChange) {
9857
9970
  newSel
9858
9971
  } = domChange,
9859
9972
  sel = view.state.selection.main;
9973
+ let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;
9860
9974
  if (domChange.bounds) {
9861
9975
  let {
9862
9976
  from,
@@ -9866,7 +9980,7 @@ function applyDOMChange(view, domChange) {
9866
9980
  preferredSide = null;
9867
9981
  // Prefer anchoring to end when Backspace is pressed (or, on
9868
9982
  // Android, when something was deleted)
9869
- if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 || browser.android && domChange.text.length < to - from) {
9983
+ if (lastKey === 8 || browser.android && domChange.text.length < to - from) {
9870
9984
  preferredPos = sel.to;
9871
9985
  preferredSide = "end";
9872
9986
  }
@@ -9874,7 +9988,7 @@ function applyDOMChange(view, domChange) {
9874
9988
  if (diff) {
9875
9989
  // Chrome inserts two newlines when pressing shift-enter at the
9876
9990
  // end of a line. DomChange drops one of those.
9877
- if (browser.chrome && view.inputState.lastKeyCode == 13 && diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder) diff.toB--;
9991
+ if (browser.chrome && lastKey == 13 && diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder) diff.toB--;
9878
9992
  change = {
9879
9993
  from: from + diff.from,
9880
9994
  to: from + diff.toA,
@@ -9930,7 +10044,7 @@ function applyDOMChange(view, domChange) {
9930
10044
  // events. (Some of these keys are also handled by beforeinput
9931
10045
  // events and the pendingAndroidKey mechanism, but that's not
9932
10046
  // reliable in all situations.)
9933
- if (browser.android && (change.from == sel.from && change.to == sel.to && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46))) return true;
10047
+ if (browser.android && (change.from == sel.from && change.to == sel.to && change.insert.length == 1 && change.insert.lines == 2 && dispatchKey(view.contentDOM, "Enter", 13) || (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 || lastKey == 8 && change.insert.length < change.to - change.from) && dispatchKey(view.contentDOM, "Backspace", 8) || change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 && dispatchKey(view.contentDOM, "Delete", 46))) return true;
9934
10048
  let text = change.insert.toString();
9935
10049
  if (view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text))) return true;
9936
10050
  if (view.inputState.composing >= 0) view.inputState.composing++;
@@ -10147,7 +10261,9 @@ class DOMObserver {
10147
10261
  this.intersecting = !this.intersecting;
10148
10262
  if (this.intersecting != this.view.inView) this.onScrollChanged(document.createEvent("Event"));
10149
10263
  }
10150
- }, {});
10264
+ }, {
10265
+ threshold: [0, .001]
10266
+ });
10151
10267
  this.intersection.observe(this.dom);
10152
10268
  this.gapIntersection = new IntersectionObserver(entries => {
10153
10269
  if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0) this.onScrollChanged(document.createEvent("Event"));
@@ -10300,7 +10416,10 @@ class DOMObserver {
10300
10416
  let key = this.delayedAndroidKey;
10301
10417
  if (key) {
10302
10418
  this.clearDelayedAndroidKey();
10303
- if (!this.flush() && key.force) dispatchKey(this.dom, key.key, key.keyCode);
10419
+ this.view.inputState.lastKeyCode = key.keyCode;
10420
+ this.view.inputState.lastKeyTime = Date.now();
10421
+ let flushed = this.flush();
10422
+ if (!flushed && key.force) dispatchKey(this.dom, key.key, key.keyCode);
10304
10423
  }
10305
10424
  };
10306
10425
  this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);
@@ -10514,58 +10633,6 @@ line number gutter. It handles events and dispatches state
10514
10633
  transactions for editing actions.
10515
10634
  */
10516
10635
  class EditorView {
10517
- /**
10518
- Construct a new view. You'll want to either provide a `parent`
10519
- option, or put `view.dom` into your document after creating a
10520
- view, so that the user can see the editor.
10521
- */
10522
- constructor() {
10523
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10524
- this.plugins = [];
10525
- this.pluginMap = new Map();
10526
- this.editorAttrs = {};
10527
- this.contentAttrs = {};
10528
- this.bidiCache = [];
10529
- this.destroyed = false;
10530
- /**
10531
- @internal
10532
- */
10533
- this.updateState = 2 /* UpdateState.Updating */;
10534
- /**
10535
- @internal
10536
- */
10537
- this.measureScheduled = -1;
10538
- /**
10539
- @internal
10540
- */
10541
- this.measureRequests = [];
10542
- this.contentDOM = document.createElement("div");
10543
- this.scrollDOM = document.createElement("div");
10544
- this.scrollDOM.tabIndex = -1;
10545
- this.scrollDOM.className = "cm-scroller";
10546
- this.scrollDOM.appendChild(this.contentDOM);
10547
- this.announceDOM = document.createElement("div");
10548
- this.announceDOM.style.cssText = "position: fixed; top: -10000px";
10549
- this.announceDOM.setAttribute("aria-live", "polite");
10550
- this.dom = document.createElement("div");
10551
- this.dom.appendChild(this.announceDOM);
10552
- this.dom.appendChild(this.scrollDOM);
10553
- this._dispatch = config.dispatch || (tr => this.update([tr]));
10554
- this.dispatch = this.dispatch.bind(this);
10555
- this._root = config.root || getRoot(config.parent) || document;
10556
- this.viewState = new ViewState(config.state || EditorState.create(config));
10557
- this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
10558
- for (let plugin of this.plugins) plugin.update(this);
10559
- this.observer = new DOMObserver(this);
10560
- this.inputState = new InputState(this);
10561
- this.inputState.ensureHandlers(this, this.plugins);
10562
- this.docView = new DocView(this);
10563
- this.mountStyles();
10564
- this.updateAttrs();
10565
- this.updateState = 0 /* UpdateState.Idle */;
10566
- this.requestMeasure();
10567
- if (config.parent) config.parent.appendChild(this.dom);
10568
- }
10569
10636
  /**
10570
10637
  The current editor state.
10571
10638
  */
@@ -10629,8 +10696,61 @@ class EditorView {
10629
10696
  get win() {
10630
10697
  return this.dom.ownerDocument.defaultView || window;
10631
10698
  }
10699
+ /**
10700
+ Construct a new view. You'll want to either provide a `parent`
10701
+ option, or put `view.dom` into your document after creating a
10702
+ view, so that the user can see the editor.
10703
+ */
10704
+ constructor() {
10705
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10706
+ this.plugins = [];
10707
+ this.pluginMap = new Map();
10708
+ this.editorAttrs = {};
10709
+ this.contentAttrs = {};
10710
+ this.bidiCache = [];
10711
+ this.destroyed = false;
10712
+ /**
10713
+ @internal
10714
+ */
10715
+ this.updateState = 2 /* UpdateState.Updating */;
10716
+ /**
10717
+ @internal
10718
+ */
10719
+ this.measureScheduled = -1;
10720
+ /**
10721
+ @internal
10722
+ */
10723
+ this.measureRequests = [];
10724
+ this.contentDOM = document.createElement("div");
10725
+ this.scrollDOM = document.createElement("div");
10726
+ this.scrollDOM.tabIndex = -1;
10727
+ this.scrollDOM.className = "cm-scroller";
10728
+ this.scrollDOM.appendChild(this.contentDOM);
10729
+ this.announceDOM = document.createElement("div");
10730
+ this.announceDOM.style.cssText = "position: fixed; top: -10000px";
10731
+ this.announceDOM.setAttribute("aria-live", "polite");
10732
+ this.dom = document.createElement("div");
10733
+ this.dom.appendChild(this.announceDOM);
10734
+ this.dom.appendChild(this.scrollDOM);
10735
+ this._dispatch = config.dispatch || (tr => this.update([tr]));
10736
+ this.dispatch = this.dispatch.bind(this);
10737
+ this._root = config.root || getRoot(config.parent) || document;
10738
+ this.viewState = new ViewState(config.state || EditorState.create(config));
10739
+ this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
10740
+ for (let plugin of this.plugins) plugin.update(this);
10741
+ this.observer = new DOMObserver(this);
10742
+ this.inputState = new InputState(this);
10743
+ this.inputState.ensureHandlers(this, this.plugins);
10744
+ this.docView = new DocView(this);
10745
+ this.mountStyles();
10746
+ this.updateAttrs();
10747
+ this.updateState = 0 /* UpdateState.Idle */;
10748
+ this.requestMeasure();
10749
+ if (config.parent) config.parent.appendChild(this.dom);
10750
+ }
10632
10751
  dispatch() {
10633
- this._dispatch(arguments.length == 1 && (arguments.length <= 0 ? undefined : arguments[0]) instanceof Transaction ? arguments.length <= 0 ? undefined : arguments[0] : this.state.update(...arguments));
10752
+ let tr = arguments.length == 1 && (arguments.length <= 0 ? undefined : arguments[0]) instanceof Transaction ? arguments.length <= 0 ? undefined : arguments[0] : this.state.update(...arguments);
10753
+ this._dispatch(tr, this);
10634
10754
  }
10635
10755
  /**
10636
10756
  Update the view for the given array of transactions. This will
@@ -11710,7 +11830,7 @@ function rectanglesForRange(view, className, range) {
11710
11830
  let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
11711
11831
  let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
11712
11832
  let between = [];
11713
- if ((visualStart || startBlock).to < (visualEnd || endBlock).from - 1) between.push(piece(leftSide, top.bottom, rightSide, bottom.top));else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text) top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
11833
+ if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0)) between.push(piece(leftSide, top.bottom, rightSide, bottom.top));else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text) top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
11714
11834
  return pieces(top).concat(between).concat(pieces(bottom));
11715
11835
  }
11716
11836
  function piece(left, top, right, bottom) {
@@ -11739,6 +11859,7 @@ function rectanglesForRange(view, className, range) {
11739
11859
  // coordsAtPos queries, would break selection drawing.
11740
11860
  let fromCoords = view.coordsAtPos(from, from == line.to ? -2 : 2);
11741
11861
  let toCoords = view.coordsAtPos(to, to == line.from ? 2 : -2);
11862
+ if (!fromCoords || !toCoords) return;
11742
11863
  top = Math.min(fromCoords.top, toCoords.top, top);
11743
11864
  bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
11744
11865
  if (dir == Direction.LTR) horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);else horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
@@ -12428,10 +12549,10 @@ function rectangularSelection(options) {
12428
12549
  return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
12429
12550
  }
12430
12551
  const keys = {
12431
- Alt: [18, e => e.altKey],
12432
- Control: [17, e => e.ctrlKey],
12433
- Shift: [16, e => e.shiftKey],
12434
- Meta: [91, e => e.metaKey]
12552
+ Alt: [18, e => !!e.altKey],
12553
+ Control: [17, e => !!e.ctrlKey],
12554
+ Shift: [16, e => !!e.shiftKey],
12555
+ Meta: [91, e => !!e.metaKey]
12435
12556
  };
12436
12557
  const showCrosshair = {
12437
12558
  style: "cursor: crosshair"
@@ -12804,6 +12925,10 @@ const showTooltip = /*@__PURE__*/Facet.define({
12804
12925
  });
12805
12926
  const showHoverTooltip = /*@__PURE__*/Facet.define();
12806
12927
  class HoverTooltipHost {
12928
+ // Needs to be static so that host tooltip instances always match
12929
+ static create(view) {
12930
+ return new HoverTooltipHost(view);
12931
+ }
12807
12932
  constructor(view) {
12808
12933
  this.view = view;
12809
12934
  this.mounted = false;
@@ -12811,10 +12936,6 @@ class HoverTooltipHost {
12811
12936
  this.dom.classList.add("cm-tooltip-hover");
12812
12937
  this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
12813
12938
  }
12814
- // Needs to be static so that host tooltip instances always match
12815
- static create(view) {
12816
- return new HoverTooltipHost(view);
12817
- }
12818
12939
  createHostedView(tooltip) {
12819
12940
  let hostedView = tooltip.create(this.view);
12820
12941
  hostedView.dom.classList.add("cm-tooltip-section");
@@ -12836,6 +12957,10 @@ class HoverTooltipHost {
12836
12957
  update(update) {
12837
12958
  this.manager.update(update);
12838
12959
  }
12960
+ destroy() {
12961
+ var _a;
12962
+ for (let t of this.manager.tooltipViews) (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
12963
+ }
12839
12964
  }
12840
12965
  const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
12841
12966
  let tooltips = state.facet(showHoverTooltip).filter(t => t);
@@ -13221,6 +13346,7 @@ const defaults = {
13221
13346
  elementStyle: "",
13222
13347
  markers: () => RangeSet.empty,
13223
13348
  lineMarker: () => null,
13349
+ widgetMarker: () => null,
13224
13350
  lineMarkerChange: null,
13225
13351
  initialSpacer: null,
13226
13352
  updateSpacer: null,
@@ -13296,19 +13422,22 @@ const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
13296
13422
  let classSet = [];
13297
13423
  let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
13298
13424
  for (let line of this.view.viewportLineBlocks) {
13299
- let text;
13425
+ if (classSet.length) classSet = [];
13300
13426
  if (Array.isArray(line.type)) {
13301
- for (let b of line.type) if (b.type == BlockType.Text) {
13302
- text = b;
13303
- break;
13427
+ let first = true;
13428
+ for (let b of line.type) {
13429
+ if (b.type == BlockType.Text && first) {
13430
+ advanceCursor(lineClasses, classSet, b.from);
13431
+ for (let cx of contexts) cx.line(this.view, b, classSet);
13432
+ first = false;
13433
+ } else if (b.widget) {
13434
+ for (let cx of contexts) cx.widget(this.view, b);
13435
+ }
13304
13436
  }
13305
- } else {
13306
- text = line.type == BlockType.Text ? line : undefined;
13437
+ } else if (line.type == BlockType.Text) {
13438
+ advanceCursor(lineClasses, classSet, line.from);
13439
+ for (let cx of contexts) cx.line(this.view, line, classSet);
13307
13440
  }
13308
- if (!text) continue;
13309
- if (classSet.length) classSet = [];
13310
- advanceCursor(lineClasses, classSet, line.from);
13311
- for (let cx of contexts) cx.line(this.view, text, classSet);
13312
13441
  }
13313
13442
  for (let cx of contexts) cx.finish();
13314
13443
  if (detach) this.view.scrollDOM.insertBefore(this.dom, after);
@@ -13371,6 +13500,21 @@ class UpdateContext {
13371
13500
  this.i = 0;
13372
13501
  this.cursor = RangeSet.iter(gutter.markers, viewport.from);
13373
13502
  }
13503
+ addElement(view, block, markers) {
13504
+ let {
13505
+ gutter
13506
+ } = this,
13507
+ above = block.top - this.height;
13508
+ if (this.i == gutter.elements.length) {
13509
+ let newElt = new GutterElement(view, block.height, above, markers);
13510
+ gutter.elements.push(newElt);
13511
+ gutter.dom.appendChild(newElt.dom);
13512
+ } else {
13513
+ gutter.elements[this.i].update(view, block.height, above, markers);
13514
+ }
13515
+ this.height = block.bottom;
13516
+ this.i++;
13517
+ }
13374
13518
  line(view, line, extraMarkers) {
13375
13519
  let localMarkers = [];
13376
13520
  advanceCursor(this.cursor, localMarkers, line.from);
@@ -13379,16 +13523,11 @@ class UpdateContext {
13379
13523
  if (forLine) localMarkers.unshift(forLine);
13380
13524
  let gutter = this.gutter;
13381
13525
  if (localMarkers.length == 0 && !gutter.config.renderEmptyElements) return;
13382
- let above = line.top - this.height;
13383
- if (this.i == gutter.elements.length) {
13384
- let newElt = new GutterElement(view, line.height, above, localMarkers);
13385
- gutter.elements.push(newElt);
13386
- gutter.dom.appendChild(newElt.dom);
13387
- } else {
13388
- gutter.elements[this.i].update(view, line.height, above, localMarkers);
13389
- }
13390
- this.height = line.bottom;
13391
- this.i++;
13526
+ this.addElement(view, line, localMarkers);
13527
+ }
13528
+ widget(view, block) {
13529
+ let marker = this.gutter.config.widgetMarker(view, block.widget, block);
13530
+ if (marker) this.addElement(view, block, [marker]);
13392
13531
  }
13393
13532
  finish() {
13394
13533
  let gutter = this.gutter;
@@ -13550,6 +13689,7 @@ const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig],
13550
13689
  if (others.some(m => m.toDOM)) return null;
13551
13690
  return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
13552
13691
  },
13692
+ widgetMarker: () => null,
13553
13693
  lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
13554
13694
  initialSpacer(view) {
13555
13695
  return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
@@ -18388,4 +18528,4 @@ function createTokenType(extra, tagStr) {
18388
18528
  return type.id;
18389
18529
  }
18390
18530
 
18391
- export { getTooltip as $, Annotation as A, highlightSpecialChars as B, ChangeSet as C, Direction as D, EditorView as E, Facet as F, foldGutter as G, drawSelection as H, IndentContext as I, dropCursor as J, indentOnInput as K, syntaxHighlighting as L, defaultHighlightStyle as M, NodeProp as N, bracketMatching as O, Prec as P, rectangularSelection as Q, RangeSetBuilder as R, StateField as S, Transaction as T, crosshairCursor as U, ViewPlugin as V, WidgetType as W, highlightActiveLine as X, keymap as Y, foldKeymap as Z, showTooltip as _, EditorSelection as a, MapMode as a0, RangeValue as a1, RangeSet as a2, Parser as a3, NodeSet as a4, NodeType as a5, DefaultBufferLength as a6, Tree as a7, IterMode as a8, styleTags as a9, tags as aa, parseMixed as ab, LanguageSupport as ac, LRLanguage as ad, indentNodeProp as ae, continuedIndent as af, foldNodeProp as ag, foldInside as ah, flatIndent as ai, delimitedIndent as aj, NodeWeakMap as ak, Tag as al, Language as am, defineLanguageFacet as an, languageDataProp as ao, LanguageDescription as ap, ParseContext as aq, HighlightStyle as ar, ChangeDesc as b, combineConfig as c, Text as d, indentUnit as e, countColumn as f, getIndentation as g, getIndentUnit as h, indentString as i, StateEffect as j, findClusterBreak as k, Decoration as l, matchBrackets as m, codePointAt as n, codePointSize as o, getPanel as p, CharCategory as q, fromCodePoint as r, syntaxTree as s, showPanel as t, EditorState as u, runScopeHandlers as v, hoverTooltip as w, logException as x, lineNumbers as y, highlightActiveLineGutter as z };
18531
+ export { showTooltip as $, Annotation as A, foldGutter as B, ChangeSet as C, Direction as D, EditorView as E, Facet as F, drawSelection as G, dropCursor as H, IndentContext as I, indentOnInput as J, syntaxHighlighting as K, defaultHighlightStyle as L, bracketMatching as M, NodeProp as N, rectangularSelection as O, Prec as P, crosshairCursor as Q, RangeSetBuilder as R, StateField as S, Transaction as T, highlightActiveLine as U, ViewPlugin as V, WidgetType as W, keymap as X, foldKeymap as Y, getTooltip as Z, logException as _, EditorSelection as a, MapMode as a0, RangeValue as a1, RangeSet as a2, Parser as a3, NodeSet as a4, NodeType as a5, DefaultBufferLength as a6, Tree as a7, IterMode as a8, styleTags as a9, tags as aa, parseMixed as ab, LanguageSupport as ac, LRLanguage as ad, indentNodeProp as ae, continuedIndent as af, foldNodeProp as ag, foldInside as ah, flatIndent as ai, delimitedIndent as aj, NodeWeakMap as ak, Tag as al, Language as am, defineLanguageFacet as an, languageDataProp as ao, LanguageDescription as ap, ParseContext as aq, HighlightStyle as ar, ChangeDesc as b, combineConfig as c, Text as d, indentUnit as e, countColumn as f, getIndentation as g, getIndentUnit as h, indentString as i, StateEffect as j, findClusterBreak as k, Decoration as l, matchBrackets as m, codePointAt as n, codePointSize as o, getPanel as p, CharCategory as q, fromCodePoint as r, syntaxTree as s, showPanel as t, EditorState as u, runScopeHandlers as v, hoverTooltip as w, lineNumbers as x, highlightActiveLineGutter as y, highlightSpecialChars as z };