@maketribe/ms-app 3.0.35 → 3.0.37

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 (93) hide show
  1. package/dist/cjs/dataview/material/material-group/MaterialGroupTree.js +1 -0
  2. package/dist/cjs/dataview/material/material-group/MaterialGroupTree.js.map +1 -1
  3. package/dist/cjs/dataview/member/MemberTable.js +2 -2
  4. package/dist/cjs/dataview/member/MemberTable.js.map +1 -1
  5. package/dist/cjs/dataview/menu/MenuTable.js +33 -0
  6. package/dist/cjs/dataview/menu/MenuTable.js.map +1 -1
  7. package/dist/cjs/layouts/components/header/tools.js +7 -2
  8. package/dist/cjs/layouts/components/header/tools.js.map +1 -1
  9. package/dist/cjs/node_modules/.pnpm/{@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e → @codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm}/node_modules/@codemirror/autocomplete/dist/index.js +77 -25
  10. package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
  11. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +7 -1433
  12. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
  13. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1484 -0
  14. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
  15. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1751 -0
  16. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
  17. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +0 -1030
  18. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
  19. package/dist/cjs/node_modules/.pnpm/{@codemirror_lint@6.4.2 → @codemirror_lint@6.5.0}/node_modules/@codemirror/lint/dist/index.js +8 -7
  20. package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
  21. package/dist/cjs/node_modules/.pnpm/{@codemirror_search@6.5.5 → @codemirror_search@6.5.6}/node_modules/@codemirror/search/dist/index.js +9 -9
  22. package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
  23. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +0 -42
  24. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
  25. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3958 -0
  26. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
  27. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +3 -2161
  28. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
  29. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10580 -0
  30. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
  31. package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1668 -0
  32. package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
  33. package/dist/cjs/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js +7 -7
  34. package/dist/cjs/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js.map +1 -1
  35. package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +177 -0
  36. package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
  37. package/dist/cjs/node_modules/.pnpm/vue-codemirror@6.1.1_codemirror@6.0.1_vue@3.3.4/node_modules/vue-codemirror/dist/vue-codemirror.esm.js +1 -1
  38. package/dist/esm/dataview/material/material-group/MaterialGroupTree.js +1 -0
  39. package/dist/esm/dataview/material/material-group/MaterialGroupTree.js.map +1 -1
  40. package/dist/esm/dataview/member/MemberTable.js +2 -2
  41. package/dist/esm/dataview/member/MemberTable.js.map +1 -1
  42. package/dist/esm/dataview/menu/MenuTable.js +34 -1
  43. package/dist/esm/dataview/menu/MenuTable.js.map +1 -1
  44. package/dist/esm/layouts/components/header/tools.js +7 -2
  45. package/dist/esm/layouts/components/header/tools.js.map +1 -1
  46. package/dist/esm/node_modules/.pnpm/{@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e → @codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm}/node_modules/@codemirror/autocomplete/dist/index.js +77 -25
  47. package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
  48. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +4 -1357
  49. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
  50. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1408 -0
  51. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
  52. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1715 -0
  53. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
  54. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +4 -1011
  55. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
  56. package/dist/esm/node_modules/.pnpm/{@codemirror_lint@6.4.2 → @codemirror_lint@6.5.0}/node_modules/@codemirror/lint/dist/index.js +8 -7
  57. package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
  58. package/dist/esm/node_modules/.pnpm/{@codemirror_search@6.5.5 → @codemirror_search@6.5.6}/node_modules/@codemirror/search/dist/index.js +9 -9
  59. package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
  60. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +1 -41
  61. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
  62. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3930 -0
  63. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
  64. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +5 -2142
  65. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
  66. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10548 -0
  67. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
  68. package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1658 -0
  69. package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
  70. package/dist/esm/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js +8 -8
  71. package/dist/esm/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js.map +1 -1
  72. package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +175 -0
  73. package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
  74. package/dist/esm/node_modules/.pnpm/vue-codemirror@6.1.1_codemirror@6.0.1_vue@3.3.4/node_modules/vue-codemirror/dist/vue-codemirror.esm.js +1 -1
  75. package/dist/style/components/classify-search.css +1 -1
  76. package/dist/style/components/index.css +1 -1
  77. package/dist/style/index.css +2 -2
  78. package/dist/style/layouts/default/header.css +1 -1
  79. package/dist/style/layouts/default/index.css +1 -1
  80. package/dist/style/layouts/index.css +1 -1
  81. package/dist/style/src/components/classify-search.scss +5 -2
  82. package/dist/style/src/layouts/default/header.scss +4 -0
  83. package/package.json +3 -3
  84. package/src/dataview/material/material-group/MaterialGroupTree.ts +1 -0
  85. package/src/dataview/member/MemberTable.tsx +2 -2
  86. package/src/dataview/menu/MenuTable.ts +34 -1
  87. package/src/layouts/components/header/tools.tsx +6 -1
  88. package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
  89. package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
  90. package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
  91. package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
  92. package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
  93. package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { MapMode, EditorSelection, EditorState, Transaction, Prec, Facet, StateEffect, RangeValue, RangeSet, ChangeSet, findClusterBreak, findColumn, Annotation, Text, codePointAt, codePointSize, CharCategory, countColumn, combineConfig, StateField, RangeSetBuilder } from '../../../../../@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js';
1
+ import { MapMode, EditorSelection, EditorState, Transaction, Prec, Facet, StateEffect, RangeValue, RangeSet, ChangeSet, findClusterBreak, findColumn, Annotation, Text, codePointAt, codePointSize, CharCategory } from '../../../../../@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js';
2
2
  import { StyleModule } from '../../../../../style-mod@4.1.0/node_modules/style-mod/src/style-mod.js';
3
3
  import { keyName, base, shift } from '../../../../../w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js';
4
4
 
@@ -7999,14 +7999,6 @@ function getKeymap(state) {
7999
7999
  Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
8000
8000
  return map;
8001
8001
  }
8002
- /**
8003
- Run the key handlers registered for a given scope. The event
8004
- object should be a `"keydown"` event. Returns true if any of the
8005
- handlers handled it.
8006
- */
8007
- function runScopeHandlers(view, event, scope) {
8008
- return runHandlers(getKeymap(view.state), event, view, scope);
8009
- }
8010
8002
  let storedPrefix = null;
8011
8003
  const PrefixTimeout = 4000;
8012
8004
  function buildKeymap(bindings, platform = currentPlatform) {
@@ -8135,350 +8127,7 @@ function runHandlers(map, event, view, scope) {
8135
8127
  return handled;
8136
8128
  }
8137
8129
 
8138
- /**
8139
- Implementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates
8140
- a rectangle at a given set of coordinates.
8141
- */
8142
- class RectangleMarker {
8143
- /**
8144
- Create a marker with the given class and dimensions. If `width`
8145
- is null, the DOM element will get no width style.
8146
- */
8147
- constructor(className,
8148
- /**
8149
- The left position of the marker (in pixels, document-relative).
8150
- */
8151
- left,
8152
- /**
8153
- The top position of the marker.
8154
- */
8155
- top,
8156
- /**
8157
- The width of the marker, or null if it shouldn't get a width assigned.
8158
- */
8159
- width,
8160
- /**
8161
- The height of the marker.
8162
- */
8163
- height) {
8164
- this.className = className;
8165
- this.left = left;
8166
- this.top = top;
8167
- this.width = width;
8168
- this.height = height;
8169
- }
8170
- draw() {
8171
- let elt = document.createElement("div");
8172
- elt.className = this.className;
8173
- this.adjust(elt);
8174
- return elt;
8175
- }
8176
- update(elt, prev) {
8177
- if (prev.className != this.className)
8178
- return false;
8179
- this.adjust(elt);
8180
- return true;
8181
- }
8182
- adjust(elt) {
8183
- elt.style.left = this.left + "px";
8184
- elt.style.top = this.top + "px";
8185
- if (this.width != null)
8186
- elt.style.width = this.width + "px";
8187
- elt.style.height = this.height + "px";
8188
- }
8189
- eq(p) {
8190
- return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&
8191
- this.className == p.className;
8192
- }
8193
- /**
8194
- Create a set of rectangles for the given selection range,
8195
- assigning them theclass`className`. Will create a single
8196
- rectangle for empty ranges, and a set of selection-style
8197
- rectangles covering the range's content (in a bidi-aware
8198
- way) for non-empty ones.
8199
- */
8200
- static forRange(view, className, range) {
8201
- if (range.empty) {
8202
- let pos = view.coordsAtPos(range.head, range.assoc || 1);
8203
- if (!pos)
8204
- return [];
8205
- let base = getBase(view);
8206
- return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];
8207
- }
8208
- else {
8209
- return rectanglesForRange(view, className, range);
8210
- }
8211
- }
8212
- }
8213
- function getBase(view) {
8214
- let rect = view.scrollDOM.getBoundingClientRect();
8215
- let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;
8216
- return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };
8217
- }
8218
- function wrappedLine(view, pos, inside) {
8219
- let range = EditorSelection.cursor(pos);
8220
- return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),
8221
- to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
8222
- type: BlockType.Text };
8223
- }
8224
- function rectanglesForRange(view, className, range) {
8225
- if (range.to <= view.viewport.from || range.from >= view.viewport.to)
8226
- return [];
8227
- let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
8228
- let ltr = view.textDirection == Direction.LTR;
8229
- let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
8230
- let lineElt = content.querySelector(".cm-line"), lineStyle = lineElt && window.getComputedStyle(lineElt);
8231
- let leftSide = contentRect.left +
8232
- (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
8233
- let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
8234
- let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
8235
- let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
8236
- let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
8237
- if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
8238
- visualStart = wrappedLine(view, from, visualStart);
8239
- if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
8240
- visualEnd = wrappedLine(view, to, visualEnd);
8241
- if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
8242
- return pieces(drawForLine(range.from, range.to, visualStart));
8243
- }
8244
- else {
8245
- let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
8246
- let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
8247
- let between = [];
8248
- if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||
8249
- startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)
8250
- between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
8251
- else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)
8252
- top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
8253
- return pieces(top).concat(between).concat(pieces(bottom));
8254
- }
8255
- function piece(left, top, right, bottom) {
8256
- return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);
8257
- }
8258
- function pieces({ top, bottom, horizontal }) {
8259
- let pieces = [];
8260
- for (let i = 0; i < horizontal.length; i += 2)
8261
- pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));
8262
- return pieces;
8263
- }
8264
- // Gets passed from/to in line-local positions
8265
- function drawForLine(from, to, line) {
8266
- let top = 1e9, bottom = -1e9, horizontal = [];
8267
- function addSpan(from, fromOpen, to, toOpen, dir) {
8268
- // Passing 2/-2 is a kludge to force the view to return
8269
- // coordinates on the proper side of block widgets, since
8270
- // normalizing the side there, though appropriate for most
8271
- // coordsAtPos queries, would break selection drawing.
8272
- let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));
8273
- let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));
8274
- if (!fromCoords || !toCoords)
8275
- return;
8276
- top = Math.min(fromCoords.top, toCoords.top, top);
8277
- bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
8278
- if (dir == Direction.LTR)
8279
- horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);
8280
- else
8281
- horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
8282
- }
8283
- let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;
8284
- // Split the range by visible range and document line
8285
- for (let r of view.visibleRanges)
8286
- if (r.to > start && r.from < end) {
8287
- for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {
8288
- let docLine = view.state.doc.lineAt(pos);
8289
- for (let span of view.bidiSpans(docLine)) {
8290
- let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;
8291
- if (spanFrom >= endPos)
8292
- break;
8293
- if (spanTo > pos)
8294
- addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);
8295
- }
8296
- pos = docLine.to + 1;
8297
- if (pos >= endPos)
8298
- break;
8299
- }
8300
- }
8301
- if (horizontal.length == 0)
8302
- addSpan(start, from == null, end, to == null, view.textDirection);
8303
- return { top, bottom, horizontal };
8304
- }
8305
- function drawForWidget(block, top) {
8306
- let y = contentRect.top + (top ? block.top : block.bottom);
8307
- return { top: y, bottom: y, horizontal: [] };
8308
- }
8309
- }
8310
- function sameMarker(a, b) {
8311
- return a.constructor == b.constructor && a.eq(b);
8312
- }
8313
- class LayerView {
8314
- constructor(view, layer) {
8315
- this.view = view;
8316
- this.layer = layer;
8317
- this.drawn = [];
8318
- this.scaleX = 1;
8319
- this.scaleY = 1;
8320
- this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };
8321
- this.dom = view.scrollDOM.appendChild(document.createElement("div"));
8322
- this.dom.classList.add("cm-layer");
8323
- if (layer.above)
8324
- this.dom.classList.add("cm-layer-above");
8325
- if (layer.class)
8326
- this.dom.classList.add(layer.class);
8327
- this.scale();
8328
- this.dom.setAttribute("aria-hidden", "true");
8329
- this.setOrder(view.state);
8330
- view.requestMeasure(this.measureReq);
8331
- if (layer.mount)
8332
- layer.mount(this.dom, view);
8333
- }
8334
- update(update) {
8335
- if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))
8336
- this.setOrder(update.state);
8337
- if (this.layer.update(update, this.dom) || update.geometryChanged) {
8338
- this.scale();
8339
- update.view.requestMeasure(this.measureReq);
8340
- }
8341
- }
8342
- setOrder(state) {
8343
- let pos = 0, order = state.facet(layerOrder);
8344
- while (pos < order.length && order[pos] != this.layer)
8345
- pos++;
8346
- this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);
8347
- }
8348
- measure() {
8349
- return this.layer.markers(this.view);
8350
- }
8351
- scale() {
8352
- let { scaleX, scaleY } = this.view;
8353
- if (scaleX != this.scaleX || scaleY != this.scaleY) {
8354
- this.scaleX = scaleX;
8355
- this.scaleY = scaleY;
8356
- this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;
8357
- }
8358
- }
8359
- draw(markers) {
8360
- if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {
8361
- let old = this.dom.firstChild, oldI = 0;
8362
- for (let marker of markers) {
8363
- if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&
8364
- marker.update(old, this.drawn[oldI])) {
8365
- old = old.nextSibling;
8366
- oldI++;
8367
- }
8368
- else {
8369
- this.dom.insertBefore(marker.draw(), old);
8370
- }
8371
- }
8372
- while (old) {
8373
- let next = old.nextSibling;
8374
- old.remove();
8375
- old = next;
8376
- }
8377
- this.drawn = markers;
8378
- }
8379
- }
8380
- destroy() {
8381
- if (this.layer.destroy)
8382
- this.layer.destroy(this.dom, this.view);
8383
- this.dom.remove();
8384
- }
8385
- }
8386
- const layerOrder = /*@__PURE__*/Facet.define();
8387
- /**
8388
- Define a layer.
8389
- */
8390
- function layer(config) {
8391
- return [
8392
- ViewPlugin.define(v => new LayerView(v, config)),
8393
- layerOrder.of(config)
8394
- ];
8395
- }
8396
-
8397
8130
  const CanHidePrimary = !browser.ios; // FIXME test IE
8398
- const selectionConfig = /*@__PURE__*/Facet.define({
8399
- combine(configs) {
8400
- return combineConfig(configs, {
8401
- cursorBlinkRate: 1200,
8402
- drawRangeCursor: true
8403
- }, {
8404
- cursorBlinkRate: (a, b) => Math.min(a, b),
8405
- drawRangeCursor: (a, b) => a || b
8406
- });
8407
- }
8408
- });
8409
- /**
8410
- Returns an extension that hides the browser's native selection and
8411
- cursor, replacing the selection with a background behind the text
8412
- (with the `cm-selectionBackground` class), and the
8413
- cursors with elements overlaid over the code (using
8414
- `cm-cursor-primary` and `cm-cursor-secondary`).
8415
-
8416
- This allows the editor to display secondary selection ranges, and
8417
- tends to produce a type of selection more in line with that users
8418
- expect in a text editor (the native selection styling will often
8419
- leave gaps between lines and won't fill the horizontal space after
8420
- a line when the selection continues past it).
8421
-
8422
- It does have a performance cost, in that it requires an extra DOM
8423
- layout cycle for many updates (the selection is drawn based on DOM
8424
- layout information that's only available after laying out the
8425
- content).
8426
- */
8427
- function drawSelection(config = {}) {
8428
- return [
8429
- selectionConfig.of(config),
8430
- cursorLayer,
8431
- selectionLayer,
8432
- hideNativeSelection,
8433
- nativeSelectionHidden.of(true)
8434
- ];
8435
- }
8436
- function configChanged(update) {
8437
- return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
8438
- }
8439
- const cursorLayer = /*@__PURE__*/layer({
8440
- above: true,
8441
- markers(view) {
8442
- let { state } = view, conf = state.facet(selectionConfig);
8443
- let cursors = [];
8444
- for (let r of state.selection.ranges) {
8445
- let prim = r == state.selection.main;
8446
- if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
8447
- let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
8448
- let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
8449
- for (let piece of RectangleMarker.forRange(view, className, cursor))
8450
- cursors.push(piece);
8451
- }
8452
- }
8453
- return cursors;
8454
- },
8455
- update(update, dom) {
8456
- if (update.transactions.some(tr => tr.selection))
8457
- dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
8458
- let confChange = configChanged(update);
8459
- if (confChange)
8460
- setBlinkRate(update.state, dom);
8461
- return update.docChanged || update.selectionSet || confChange;
8462
- },
8463
- mount(dom, view) {
8464
- setBlinkRate(view.state, dom);
8465
- },
8466
- class: "cm-cursorLayer"
8467
- });
8468
- function setBlinkRate(state, dom) {
8469
- dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + "ms";
8470
- }
8471
- const selectionLayer = /*@__PURE__*/layer({
8472
- above: false,
8473
- markers(view) {
8474
- return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, "cm-selectionBackground", r))
8475
- .reduce((a, b) => a.concat(b));
8476
- },
8477
- update(update, dom) {
8478
- return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);
8479
- },
8480
- class: "cm-selectionLayer"
8481
- });
8482
8131
  const themeSpec = {
8483
8132
  ".cm-line": {
8484
8133
  "& ::selection": { backgroundColor: "transparent !important" },
@@ -8489,406 +8138,6 @@ if (CanHidePrimary) {
8489
8138
  themeSpec[".cm-line"].caretColor = "transparent !important";
8490
8139
  themeSpec[".cm-content"] = { caretColor: "transparent !important" };
8491
8140
  }
8492
- const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
8493
-
8494
- const setDropCursorPos = /*@__PURE__*/StateEffect.define({
8495
- map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
8496
- });
8497
- const dropCursorPos = /*@__PURE__*/StateField.define({
8498
- create() { return null; },
8499
- update(pos, tr) {
8500
- if (pos != null)
8501
- pos = tr.changes.mapPos(pos);
8502
- return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);
8503
- }
8504
- });
8505
- const drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {
8506
- constructor(view) {
8507
- this.view = view;
8508
- this.cursor = null;
8509
- this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
8510
- }
8511
- update(update) {
8512
- var _a;
8513
- let cursorPos = update.state.field(dropCursorPos);
8514
- if (cursorPos == null) {
8515
- if (this.cursor != null) {
8516
- (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();
8517
- this.cursor = null;
8518
- }
8519
- }
8520
- else {
8521
- if (!this.cursor) {
8522
- this.cursor = this.view.scrollDOM.appendChild(document.createElement("div"));
8523
- this.cursor.className = "cm-dropCursor";
8524
- }
8525
- if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)
8526
- this.view.requestMeasure(this.measureReq);
8527
- }
8528
- }
8529
- readPos() {
8530
- let { view } = this;
8531
- let pos = view.state.field(dropCursorPos);
8532
- let rect = pos != null && view.coordsAtPos(pos);
8533
- if (!rect)
8534
- return null;
8535
- let outer = view.scrollDOM.getBoundingClientRect();
8536
- return {
8537
- left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,
8538
- top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,
8539
- height: rect.bottom - rect.top
8540
- };
8541
- }
8542
- drawCursor(pos) {
8543
- if (this.cursor) {
8544
- let { scaleX, scaleY } = this.view;
8545
- if (pos) {
8546
- this.cursor.style.left = pos.left / scaleX + "px";
8547
- this.cursor.style.top = pos.top / scaleY + "px";
8548
- this.cursor.style.height = pos.height / scaleY + "px";
8549
- }
8550
- else {
8551
- this.cursor.style.left = "-100000px";
8552
- }
8553
- }
8554
- }
8555
- destroy() {
8556
- if (this.cursor)
8557
- this.cursor.remove();
8558
- }
8559
- setDropPos(pos) {
8560
- if (this.view.state.field(dropCursorPos) != pos)
8561
- this.view.dispatch({ effects: setDropCursorPos.of(pos) });
8562
- }
8563
- }, {
8564
- eventObservers: {
8565
- dragover(event) {
8566
- this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));
8567
- },
8568
- dragleave(event) {
8569
- if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))
8570
- this.setDropPos(null);
8571
- },
8572
- dragend() {
8573
- this.setDropPos(null);
8574
- },
8575
- drop() {
8576
- this.setDropPos(null);
8577
- }
8578
- }
8579
- });
8580
- /**
8581
- Draws a cursor at the current drop position when something is
8582
- dragged over the editor.
8583
- */
8584
- function dropCursor() {
8585
- return [dropCursorPos, drawDropCursor];
8586
- }
8587
-
8588
- function iterMatches(doc, re, from, to, f) {
8589
- re.lastIndex = 0;
8590
- for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {
8591
- if (!cursor.lineBreak)
8592
- while (m = re.exec(cursor.value))
8593
- f(pos + m.index, m);
8594
- }
8595
- }
8596
- function matchRanges(view, maxLength) {
8597
- let visible = view.visibleRanges;
8598
- if (visible.length == 1 && visible[0].from == view.viewport.from &&
8599
- visible[0].to == view.viewport.to)
8600
- return visible;
8601
- let result = [];
8602
- for (let { from, to } of visible) {
8603
- from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);
8604
- to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);
8605
- if (result.length && result[result.length - 1].to >= from)
8606
- result[result.length - 1].to = to;
8607
- else
8608
- result.push({ from, to });
8609
- }
8610
- return result;
8611
- }
8612
- /**
8613
- Helper class used to make it easier to maintain decorations on
8614
- visible code that matches a given regular expression. To be used
8615
- in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
8616
- represent a matching configuration.
8617
- */
8618
- class MatchDecorator {
8619
- /**
8620
- Create a decorator.
8621
- */
8622
- constructor(config) {
8623
- const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;
8624
- if (!regexp.global)
8625
- throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
8626
- this.regexp = regexp;
8627
- if (decorate) {
8628
- this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);
8629
- }
8630
- else if (typeof decoration == "function") {
8631
- this.addMatch = (match, view, from, add) => {
8632
- let deco = decoration(match, view, from);
8633
- if (deco)
8634
- add(from, from + match[0].length, deco);
8635
- };
8636
- }
8637
- else if (decoration) {
8638
- this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);
8639
- }
8640
- else {
8641
- throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
8642
- }
8643
- this.boundary = boundary;
8644
- this.maxLength = maxLength;
8645
- }
8646
- /**
8647
- Compute the full set of decorations for matches in the given
8648
- view's viewport. You'll want to call this when initializing your
8649
- plugin.
8650
- */
8651
- createDeco(view) {
8652
- let build = new RangeSetBuilder(), add = build.add.bind(build);
8653
- for (let { from, to } of matchRanges(view, this.maxLength))
8654
- iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));
8655
- return build.finish();
8656
- }
8657
- /**
8658
- Update a set of decorations for a view update. `deco` _must_ be
8659
- the set of decorations produced by _this_ `MatchDecorator` for
8660
- the view state before the update.
8661
- */
8662
- updateDeco(update, deco) {
8663
- let changeFrom = 1e9, changeTo = -1;
8664
- if (update.docChanged)
8665
- update.changes.iterChanges((_f, _t, from, to) => {
8666
- if (to > update.view.viewport.from && from < update.view.viewport.to) {
8667
- changeFrom = Math.min(from, changeFrom);
8668
- changeTo = Math.max(to, changeTo);
8669
- }
8670
- });
8671
- if (update.viewportChanged || changeTo - changeFrom > 1000)
8672
- return this.createDeco(update.view);
8673
- if (changeTo > -1)
8674
- return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);
8675
- return deco;
8676
- }
8677
- updateRange(view, deco, updateFrom, updateTo) {
8678
- for (let r of view.visibleRanges) {
8679
- let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);
8680
- if (to > from) {
8681
- let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;
8682
- let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);
8683
- if (this.boundary) {
8684
- for (; from > fromLine.from; from--)
8685
- if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {
8686
- start = from;
8687
- break;
8688
- }
8689
- for (; to < toLine.to; to++)
8690
- if (this.boundary.test(toLine.text[to - toLine.from])) {
8691
- end = to;
8692
- break;
8693
- }
8694
- }
8695
- let ranges = [], m;
8696
- let add = (from, to, deco) => ranges.push(deco.range(from, to));
8697
- if (fromLine == toLine) {
8698
- this.regexp.lastIndex = start - fromLine.from;
8699
- while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)
8700
- this.addMatch(m, view, m.index + fromLine.from, add);
8701
- }
8702
- else {
8703
- iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));
8704
- }
8705
- deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });
8706
- }
8707
- }
8708
- return deco;
8709
- }
8710
- }
8711
-
8712
- const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
8713
- const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
8714
- const Names = {
8715
- 0: "null",
8716
- 7: "bell",
8717
- 8: "backspace",
8718
- 10: "newline",
8719
- 11: "vertical tab",
8720
- 13: "carriage return",
8721
- 27: "escape",
8722
- 8203: "zero width space",
8723
- 8204: "zero width non-joiner",
8724
- 8205: "zero width joiner",
8725
- 8206: "left-to-right mark",
8726
- 8207: "right-to-left mark",
8727
- 8232: "line separator",
8728
- 8237: "left-to-right override",
8729
- 8238: "right-to-left override",
8730
- 8294: "left-to-right isolate",
8731
- 8295: "right-to-left isolate",
8732
- 8297: "pop directional isolate",
8733
- 8233: "paragraph separator",
8734
- 65279: "zero width no-break space",
8735
- 65532: "object replacement"
8736
- };
8737
- let _supportsTabSize = null;
8738
- function supportsTabSize() {
8739
- var _a;
8740
- if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
8741
- let styles = document.body.style;
8742
- _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
8743
- }
8744
- return _supportsTabSize || false;
8745
- }
8746
- const specialCharConfig = /*@__PURE__*/Facet.define({
8747
- combine(configs) {
8748
- let config = combineConfig(configs, {
8749
- render: null,
8750
- specialChars: Specials,
8751
- addSpecialChars: null
8752
- });
8753
- if (config.replaceTabs = !supportsTabSize())
8754
- config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
8755
- if (config.addSpecialChars)
8756
- config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
8757
- return config;
8758
- }
8759
- });
8760
- /**
8761
- Returns an extension that installs highlighting of special
8762
- characters.
8763
- */
8764
- function highlightSpecialChars(
8765
- /**
8766
- Configuration options.
8767
- */
8768
- config = {}) {
8769
- return [specialCharConfig.of(config), specialCharPlugin()];
8770
- }
8771
- let _plugin = null;
8772
- function specialCharPlugin() {
8773
- return _plugin || (_plugin = ViewPlugin.fromClass(class {
8774
- constructor(view) {
8775
- this.view = view;
8776
- this.decorations = Decoration.none;
8777
- this.decorationCache = Object.create(null);
8778
- this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
8779
- this.decorations = this.decorator.createDeco(view);
8780
- }
8781
- makeDecorator(conf) {
8782
- return new MatchDecorator({
8783
- regexp: conf.specialChars,
8784
- decoration: (m, view, pos) => {
8785
- let { doc } = view.state;
8786
- let code = codePointAt(m[0], 0);
8787
- if (code == 9) {
8788
- let line = doc.lineAt(pos);
8789
- let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);
8790
- return Decoration.replace({
8791
- widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)
8792
- });
8793
- }
8794
- return this.decorationCache[code] ||
8795
- (this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));
8796
- },
8797
- boundary: conf.replaceTabs ? undefined : /[^]/
8798
- });
8799
- }
8800
- update(update) {
8801
- let conf = update.state.facet(specialCharConfig);
8802
- if (update.startState.facet(specialCharConfig) != conf) {
8803
- this.decorator = this.makeDecorator(conf);
8804
- this.decorations = this.decorator.createDeco(update.view);
8805
- }
8806
- else {
8807
- this.decorations = this.decorator.updateDeco(update, this.decorations);
8808
- }
8809
- }
8810
- }, {
8811
- decorations: v => v.decorations
8812
- }));
8813
- }
8814
- const DefaultPlaceholder = "\u2022";
8815
- // Assigns placeholder characters from the Control Pictures block to
8816
- // ASCII control characters
8817
- function placeholder$1(code) {
8818
- if (code >= 32)
8819
- return DefaultPlaceholder;
8820
- if (code == 10)
8821
- return "\u2424";
8822
- return String.fromCharCode(9216 + code);
8823
- }
8824
- class SpecialCharWidget extends WidgetType {
8825
- constructor(options, code) {
8826
- super();
8827
- this.options = options;
8828
- this.code = code;
8829
- }
8830
- eq(other) { return other.code == this.code; }
8831
- toDOM(view) {
8832
- let ph = placeholder$1(this.code);
8833
- let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
8834
- let custom = this.options.render && this.options.render(this.code, desc, ph);
8835
- if (custom)
8836
- return custom;
8837
- let span = document.createElement("span");
8838
- span.textContent = ph;
8839
- span.title = desc;
8840
- span.setAttribute("aria-label", desc);
8841
- span.className = "cm-specialChar";
8842
- return span;
8843
- }
8844
- ignoreEvent() { return false; }
8845
- }
8846
- class TabWidget extends WidgetType {
8847
- constructor(width) {
8848
- super();
8849
- this.width = width;
8850
- }
8851
- eq(other) { return other.width == this.width; }
8852
- toDOM() {
8853
- let span = document.createElement("span");
8854
- span.textContent = "\t";
8855
- span.className = "cm-tab";
8856
- span.style.width = this.width + "px";
8857
- return span;
8858
- }
8859
- ignoreEvent() { return false; }
8860
- }
8861
-
8862
- /**
8863
- Mark lines that have a cursor on them with the `"cm-activeLine"`
8864
- DOM class.
8865
- */
8866
- function highlightActiveLine() {
8867
- return activeLineHighlighter;
8868
- }
8869
- const lineDeco = /*@__PURE__*/Decoration.line({ class: "cm-activeLine" });
8870
- const activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
8871
- constructor(view) {
8872
- this.decorations = this.getDeco(view);
8873
- }
8874
- update(update) {
8875
- if (update.docChanged || update.selectionSet)
8876
- this.decorations = this.getDeco(update.view);
8877
- }
8878
- getDeco(view) {
8879
- let lastLineStart = -1, deco = [];
8880
- for (let r of view.state.selection.ranges) {
8881
- let line = view.lineBlockAt(r.head);
8882
- if (line.from > lastLineStart) {
8883
- deco.push(lineDeco.range(line.from));
8884
- lastLineStart = line.from;
8885
- }
8886
- }
8887
- return Decoration.set(deco);
8888
- }
8889
- }, {
8890
- decorations: v => v.decorations
8891
- });
8892
8141
 
8893
8142
  class Placeholder extends WidgetType {
8894
8143
  constructor(content) {
@@ -8935,955 +8184,10 @@ function placeholder(content) {
8935
8184
  }, { decorations: v => v.decorations });
8936
8185
  }
8937
8186
 
8938
- // Don't compute precise column positions for line offsets above this
8939
- // (since it could get expensive). Assume offset==column for them.
8940
- const MaxOff = 2000;
8941
- function rectangleFor(state, a, b) {
8942
- let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
8943
- let ranges = [];
8944
- if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {
8945
- let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);
8946
- for (let i = startLine; i <= endLine; i++) {
8947
- let line = state.doc.line(i);
8948
- if (line.length <= endOff)
8949
- ranges.push(EditorSelection.range(line.from + startOff, line.to + endOff));
8950
- }
8951
- }
8952
- else {
8953
- let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);
8954
- for (let i = startLine; i <= endLine; i++) {
8955
- let line = state.doc.line(i);
8956
- let start = findColumn(line.text, startCol, state.tabSize, true);
8957
- if (start < 0) {
8958
- ranges.push(EditorSelection.cursor(line.to));
8959
- }
8960
- else {
8961
- let end = findColumn(line.text, endCol, state.tabSize);
8962
- ranges.push(EditorSelection.range(line.from + start, line.from + end));
8963
- }
8964
- }
8965
- }
8966
- return ranges;
8967
- }
8968
- function absoluteColumn(view, x) {
8969
- let ref = view.coordsAtPos(view.viewport.from);
8970
- return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;
8971
- }
8972
- function getPos(view, event) {
8973
- let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
8974
- let line = view.state.doc.lineAt(offset), off = offset - line.from;
8975
- let col = off > MaxOff ? -1
8976
- : off == line.length ? absoluteColumn(view, event.clientX)
8977
- : countColumn(line.text, view.state.tabSize, offset - line.from);
8978
- return { line: line.number, col, off };
8979
- }
8980
- function rectangleSelectionStyle(view, event) {
8981
- let start = getPos(view, event), startSel = view.state.selection;
8982
- if (!start)
8983
- return null;
8984
- return {
8985
- update(update) {
8986
- if (update.docChanged) {
8987
- let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);
8988
- let newLine = update.state.doc.lineAt(newStart);
8989
- start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };
8990
- startSel = startSel.map(update.changes);
8991
- }
8992
- },
8993
- get(event, _extend, multiple) {
8994
- let cur = getPos(view, event);
8995
- if (!cur)
8996
- return startSel;
8997
- let ranges = rectangleFor(view.state, start, cur);
8998
- if (!ranges.length)
8999
- return startSel;
9000
- if (multiple)
9001
- return EditorSelection.create(ranges.concat(startSel.ranges));
9002
- else
9003
- return EditorSelection.create(ranges);
9004
- }
9005
- };
9006
- }
9007
- /**
9008
- Create an extension that enables rectangular selections. By
9009
- default, it will react to left mouse drag with the Alt key held
9010
- down. When such a selection occurs, the text within the rectangle
9011
- that was dragged over will be selected, as one selection
9012
- [range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
9013
- */
9014
- function rectangularSelection(options) {
9015
- let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);
9016
- return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
9017
- }
9018
- const keys = {
9019
- Alt: [18, e => !!e.altKey],
9020
- Control: [17, e => !!e.ctrlKey],
9021
- Shift: [16, e => !!e.shiftKey],
9022
- Meta: [91, e => !!e.metaKey]
9023
- };
9024
- const showCrosshair = { style: "cursor: crosshair" };
9025
8187
  /**
9026
- Returns an extension that turns the pointer cursor into a
9027
- crosshair when a given modifier key, defaulting to Alt, is held
9028
- down. Can serve as a visual hint that rectangular selection is
9029
- going to happen when paired with
9030
- [`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).
9031
- */
9032
- function crosshairCursor(options = {}) {
9033
- let [code, getter] = keys[options.key || "Alt"];
9034
- let plugin = ViewPlugin.fromClass(class {
9035
- constructor(view) {
9036
- this.view = view;
9037
- this.isDown = false;
9038
- }
9039
- set(isDown) {
9040
- if (this.isDown != isDown) {
9041
- this.isDown = isDown;
9042
- this.view.update([]);
9043
- }
9044
- }
9045
- }, {
9046
- eventObservers: {
9047
- keydown(e) {
9048
- this.set(e.keyCode == code || getter(e));
9049
- },
9050
- keyup(e) {
9051
- if (e.keyCode == code || !getter(e))
9052
- this.set(false);
9053
- },
9054
- mousemove(e) {
9055
- this.set(getter(e));
9056
- }
9057
- }
9058
- });
9059
- return [
9060
- plugin,
9061
- EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })
9062
- ];
9063
- }
9064
-
9065
- const Outside = "-10000px";
9066
- class TooltipViewManager {
9067
- constructor(view, facet, createTooltipView) {
9068
- this.facet = facet;
9069
- this.createTooltipView = createTooltipView;
9070
- this.input = view.state.facet(facet);
9071
- this.tooltips = this.input.filter(t => t);
9072
- this.tooltipViews = this.tooltips.map(createTooltipView);
9073
- }
9074
- update(update, above) {
9075
- var _a;
9076
- let input = update.state.facet(this.facet);
9077
- let tooltips = input.filter(x => x);
9078
- if (input === this.input) {
9079
- for (let t of this.tooltipViews)
9080
- if (t.update)
9081
- t.update(update);
9082
- return false;
9083
- }
9084
- let tooltipViews = [], newAbove = above ? [] : null;
9085
- for (let i = 0; i < tooltips.length; i++) {
9086
- let tip = tooltips[i], known = -1;
9087
- if (!tip)
9088
- continue;
9089
- for (let i = 0; i < this.tooltips.length; i++) {
9090
- let other = this.tooltips[i];
9091
- if (other && other.create == tip.create)
9092
- known = i;
9093
- }
9094
- if (known < 0) {
9095
- tooltipViews[i] = this.createTooltipView(tip);
9096
- if (newAbove)
9097
- newAbove[i] = !!tip.above;
9098
- }
9099
- else {
9100
- let tooltipView = tooltipViews[i] = this.tooltipViews[known];
9101
- if (newAbove)
9102
- newAbove[i] = above[known];
9103
- if (tooltipView.update)
9104
- tooltipView.update(update);
9105
- }
9106
- }
9107
- for (let t of this.tooltipViews)
9108
- if (tooltipViews.indexOf(t) < 0) {
9109
- t.dom.remove();
9110
- (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
9111
- }
9112
- if (above) {
9113
- newAbove.forEach((val, i) => above[i] = val);
9114
- above.length = newAbove.length;
9115
- }
9116
- this.input = input;
9117
- this.tooltips = tooltips;
9118
- this.tooltipViews = tooltipViews;
9119
- return true;
9120
- }
9121
- }
9122
- function windowSpace(view) {
9123
- let { win } = view;
9124
- return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
9125
- }
9126
- const tooltipConfig = /*@__PURE__*/Facet.define({
9127
- combine: values => {
9128
- var _a, _b, _c;
9129
- return ({
9130
- position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
9131
- parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
9132
- tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
9133
- });
9134
- }
9135
- });
9136
- const knownHeight = /*@__PURE__*/new WeakMap();
9137
- const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
9138
- constructor(view) {
9139
- this.view = view;
9140
- this.above = [];
9141
- this.inView = true;
9142
- this.madeAbsolute = false;
9143
- this.lastTransaction = 0;
9144
- this.measureTimeout = -1;
9145
- let config = view.state.facet(tooltipConfig);
9146
- this.position = config.position;
9147
- this.parent = config.parent;
9148
- this.classes = view.themeClasses;
9149
- this.createContainer();
9150
- this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
9151
- this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));
9152
- this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
9153
- if (Date.now() > this.lastTransaction - 50 &&
9154
- entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
9155
- this.measureSoon();
9156
- }, { threshold: [1] }) : null;
9157
- this.observeIntersection();
9158
- view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
9159
- this.maybeMeasure();
9160
- }
9161
- createContainer() {
9162
- if (this.parent) {
9163
- this.container = document.createElement("div");
9164
- this.container.style.position = "relative";
9165
- this.container.className = this.view.themeClasses;
9166
- this.parent.appendChild(this.container);
9167
- }
9168
- else {
9169
- this.container = this.view.dom;
9170
- }
9171
- }
9172
- observeIntersection() {
9173
- if (this.intersectionObserver) {
9174
- this.intersectionObserver.disconnect();
9175
- for (let tooltip of this.manager.tooltipViews)
9176
- this.intersectionObserver.observe(tooltip.dom);
9177
- }
9178
- }
9179
- measureSoon() {
9180
- if (this.measureTimeout < 0)
9181
- this.measureTimeout = setTimeout(() => {
9182
- this.measureTimeout = -1;
9183
- this.maybeMeasure();
9184
- }, 50);
9185
- }
9186
- update(update) {
9187
- if (update.transactions.length)
9188
- this.lastTransaction = Date.now();
9189
- let updated = this.manager.update(update, this.above);
9190
- if (updated)
9191
- this.observeIntersection();
9192
- let shouldMeasure = updated || update.geometryChanged;
9193
- let newConfig = update.state.facet(tooltipConfig);
9194
- if (newConfig.position != this.position && !this.madeAbsolute) {
9195
- this.position = newConfig.position;
9196
- for (let t of this.manager.tooltipViews)
9197
- t.dom.style.position = this.position;
9198
- shouldMeasure = true;
9199
- }
9200
- if (newConfig.parent != this.parent) {
9201
- if (this.parent)
9202
- this.container.remove();
9203
- this.parent = newConfig.parent;
9204
- this.createContainer();
9205
- for (let t of this.manager.tooltipViews)
9206
- this.container.appendChild(t.dom);
9207
- shouldMeasure = true;
9208
- }
9209
- else if (this.parent && this.view.themeClasses != this.classes) {
9210
- this.classes = this.container.className = this.view.themeClasses;
9211
- }
9212
- if (shouldMeasure)
9213
- this.maybeMeasure();
9214
- }
9215
- createTooltip(tooltip) {
9216
- let tooltipView = tooltip.create(this.view);
9217
- tooltipView.dom.classList.add("cm-tooltip");
9218
- if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
9219
- let arrow = document.createElement("div");
9220
- arrow.className = "cm-tooltip-arrow";
9221
- tooltipView.dom.appendChild(arrow);
9222
- }
9223
- tooltipView.dom.style.position = this.position;
9224
- tooltipView.dom.style.top = Outside;
9225
- tooltipView.dom.style.left = "0px";
9226
- this.container.appendChild(tooltipView.dom);
9227
- if (tooltipView.mount)
9228
- tooltipView.mount(this.view);
9229
- return tooltipView;
9230
- }
9231
- destroy() {
9232
- var _a, _b;
9233
- this.view.win.removeEventListener("resize", this.measureSoon);
9234
- for (let tooltipView of this.manager.tooltipViews) {
9235
- tooltipView.dom.remove();
9236
- (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
9237
- }
9238
- if (this.parent)
9239
- this.container.remove();
9240
- (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
9241
- clearTimeout(this.measureTimeout);
9242
- }
9243
- readMeasure() {
9244
- let editor = this.view.dom.getBoundingClientRect();
9245
- let scaleX = 1, scaleY = 1, makeAbsolute = false;
9246
- if (this.position == "fixed" && this.manager.tooltipViews.length) {
9247
- let { dom } = this.manager.tooltipViews[0];
9248
- if (browser.gecko) {
9249
- // Firefox sets the element's `offsetParent` to the
9250
- // transformed element when a transform interferes with fixed
9251
- // positioning.
9252
- makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
9253
- }
9254
- else {
9255
- // On other browsers, we have to awkwardly try and use other
9256
- // information to detect a transform.
9257
- if (this.view.scaleX != 1 || this.view.scaleY != 1) {
9258
- makeAbsolute = true;
9259
- }
9260
- else if (dom.style.top == Outside && dom.style.left == "0px") {
9261
- let rect = dom.getBoundingClientRect();
9262
- makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
9263
- }
9264
- }
9265
- }
9266
- if (makeAbsolute || this.position == "absolute") {
9267
- if (this.parent) {
9268
- let rect = this.parent.getBoundingClientRect();
9269
- if (rect.width && rect.height) {
9270
- scaleX = rect.width / this.parent.offsetWidth;
9271
- scaleY = rect.height / this.parent.offsetHeight;
9272
- }
9273
- }
9274
- else {
9275
- ({ scaleX, scaleY } = this.view.viewState);
9276
- }
9277
- }
9278
- return {
9279
- editor,
9280
- parent: this.parent ? this.container.getBoundingClientRect() : editor,
9281
- pos: this.manager.tooltips.map((t, i) => {
9282
- let tv = this.manager.tooltipViews[i];
9283
- return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
9284
- }),
9285
- size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
9286
- space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
9287
- scaleX, scaleY, makeAbsolute
9288
- };
9289
- }
9290
- writeMeasure(measured) {
9291
- var _a;
9292
- if (measured.makeAbsolute) {
9293
- this.madeAbsolute = true;
9294
- this.position = "absolute";
9295
- for (let t of this.manager.tooltipViews)
9296
- t.dom.style.position = "absolute";
9297
- }
9298
- let { editor, space, scaleX, scaleY } = measured;
9299
- let others = [];
9300
- for (let i = 0; i < this.manager.tooltips.length; i++) {
9301
- let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
9302
- let pos = measured.pos[i], size = measured.size[i];
9303
- // Hide tooltips that are outside of the editor.
9304
- if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||
9305
- pos.top >= Math.min(editor.bottom, space.bottom) ||
9306
- pos.right < Math.max(editor.left, space.left) - .1 ||
9307
- pos.left > Math.min(editor.right, space.right) + .1) {
9308
- dom.style.top = Outside;
9309
- continue;
9310
- }
9311
- let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
9312
- let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
9313
- let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
9314
- let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
9315
- let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
9316
- : ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
9317
- : Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
9318
- let above = this.above[i];
9319
- if (!tooltip.strictSide && (above
9320
- ? pos.top - (size.bottom - size.top) - offset.y < space.top
9321
- : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
9322
- above == (space.bottom - pos.bottom > pos.top - space.top))
9323
- above = this.above[i] = !above;
9324
- let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
9325
- if (spaceVert < height && tView.resize !== false) {
9326
- if (spaceVert < this.view.defaultLineHeight) {
9327
- dom.style.top = Outside;
9328
- continue;
9329
- }
9330
- knownHeight.set(tView, height);
9331
- dom.style.height = (height = spaceVert) / scaleY + "px";
9332
- }
9333
- else if (dom.style.height) {
9334
- dom.style.height = "";
9335
- }
9336
- let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
9337
- let right = left + width;
9338
- if (tView.overlap !== true)
9339
- for (let r of others)
9340
- if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
9341
- top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
9342
- if (this.position == "absolute") {
9343
- dom.style.top = (top - measured.parent.top) / scaleY + "px";
9344
- dom.style.left = (left - measured.parent.left) / scaleX + "px";
9345
- }
9346
- else {
9347
- dom.style.top = top / scaleY + "px";
9348
- dom.style.left = left / scaleX + "px";
9349
- }
9350
- if (arrow) {
9351
- let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
9352
- arrow.style.left = arrowLeft / scaleX + "px";
9353
- }
9354
- if (tView.overlap !== true)
9355
- others.push({ left, top, right, bottom: top + height });
9356
- dom.classList.toggle("cm-tooltip-above", above);
9357
- dom.classList.toggle("cm-tooltip-below", !above);
9358
- if (tView.positioned)
9359
- tView.positioned(measured.space);
9360
- }
9361
- }
9362
- maybeMeasure() {
9363
- if (this.manager.tooltips.length) {
9364
- if (this.view.inView)
9365
- this.view.requestMeasure(this.measureReq);
9366
- if (this.inView != this.view.inView) {
9367
- this.inView = this.view.inView;
9368
- if (!this.inView)
9369
- for (let tv of this.manager.tooltipViews)
9370
- tv.dom.style.top = Outside;
9371
- }
9372
- }
9373
- }
9374
- }, {
9375
- eventObservers: {
9376
- scroll() { this.maybeMeasure(); }
9377
- }
9378
- });
9379
- const baseTheme = /*@__PURE__*/EditorView.baseTheme({
9380
- ".cm-tooltip": {
9381
- zIndex: 100,
9382
- boxSizing: "border-box"
9383
- },
9384
- "&light .cm-tooltip": {
9385
- border: "1px solid #bbb",
9386
- backgroundColor: "#f5f5f5"
9387
- },
9388
- "&light .cm-tooltip-section:not(:first-child)": {
9389
- borderTop: "1px solid #bbb",
9390
- },
9391
- "&dark .cm-tooltip": {
9392
- backgroundColor: "#333338",
9393
- color: "white"
9394
- },
9395
- ".cm-tooltip-arrow": {
9396
- height: `${7 /* Arrow.Size */}px`,
9397
- width: `${7 /* Arrow.Size */ * 2}px`,
9398
- position: "absolute",
9399
- zIndex: -1,
9400
- overflow: "hidden",
9401
- "&:before, &:after": {
9402
- content: "''",
9403
- position: "absolute",
9404
- width: 0,
9405
- height: 0,
9406
- borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
9407
- borderRight: `${7 /* Arrow.Size */}px solid transparent`,
9408
- },
9409
- ".cm-tooltip-above &": {
9410
- bottom: `-${7 /* Arrow.Size */}px`,
9411
- "&:before": {
9412
- borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
9413
- },
9414
- "&:after": {
9415
- borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
9416
- bottom: "1px"
9417
- }
9418
- },
9419
- ".cm-tooltip-below &": {
9420
- top: `-${7 /* Arrow.Size */}px`,
9421
- "&:before": {
9422
- borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
9423
- },
9424
- "&:after": {
9425
- borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
9426
- top: "1px"
9427
- }
9428
- },
9429
- },
9430
- "&dark .cm-tooltip .cm-tooltip-arrow": {
9431
- "&:before": {
9432
- borderTopColor: "#333338",
9433
- borderBottomColor: "#333338"
9434
- },
9435
- "&:after": {
9436
- borderTopColor: "transparent",
9437
- borderBottomColor: "transparent"
9438
- }
9439
- }
9440
- });
9441
- const noOffset = { x: 0, y: 0 };
9442
- /**
9443
- Facet to which an extension can add a value to show a tooltip.
9444
- */
9445
- const showTooltip = /*@__PURE__*/Facet.define({
9446
- enables: [tooltipPlugin, baseTheme]
9447
- });
9448
- const showHoverTooltip = /*@__PURE__*/Facet.define();
9449
- class HoverTooltipHost {
9450
- // Needs to be static so that host tooltip instances always match
9451
- static create(view) {
9452
- return new HoverTooltipHost(view);
9453
- }
9454
- constructor(view) {
9455
- this.view = view;
9456
- this.mounted = false;
9457
- this.dom = document.createElement("div");
9458
- this.dom.classList.add("cm-tooltip-hover");
9459
- this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
9460
- }
9461
- createHostedView(tooltip) {
9462
- let hostedView = tooltip.create(this.view);
9463
- hostedView.dom.classList.add("cm-tooltip-section");
9464
- this.dom.appendChild(hostedView.dom);
9465
- if (this.mounted && hostedView.mount)
9466
- hostedView.mount(this.view);
9467
- return hostedView;
9468
- }
9469
- mount(view) {
9470
- for (let hostedView of this.manager.tooltipViews) {
9471
- if (hostedView.mount)
9472
- hostedView.mount(view);
9473
- }
9474
- this.mounted = true;
9475
- }
9476
- positioned(space) {
9477
- for (let hostedView of this.manager.tooltipViews) {
9478
- if (hostedView.positioned)
9479
- hostedView.positioned(space);
9480
- }
9481
- }
9482
- update(update) {
9483
- this.manager.update(update);
9484
- }
9485
- destroy() {
9486
- var _a;
9487
- for (let t of this.manager.tooltipViews)
9488
- (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
9489
- }
9490
- passProp(name) {
9491
- let value = undefined;
9492
- for (let view of this.manager.tooltipViews) {
9493
- let given = view[name];
9494
- if (given !== undefined) {
9495
- if (value === undefined)
9496
- value = given;
9497
- else if (value !== given)
9498
- return undefined;
9499
- }
9500
- }
9501
- return value;
9502
- }
9503
- get offset() { return this.passProp("offset"); }
9504
- get getCoords() { return this.passProp("getCoords"); }
9505
- get overlap() { return this.passProp("overlap"); }
9506
- get resize() { return this.passProp("resize"); }
9507
- }
9508
- const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
9509
- let tooltips = state.facet(showHoverTooltip).filter(t => t);
9510
- if (tooltips.length === 0)
9511
- return null;
9512
- return {
9513
- pos: Math.min(...tooltips.map(t => t.pos)),
9514
- end: Math.max(...tooltips.map(t => { var _a; return (_a = t.end) !== null && _a !== void 0 ? _a : t.pos; })),
9515
- create: HoverTooltipHost.create,
9516
- above: tooltips[0].above,
9517
- arrow: tooltips.some(t => t.arrow),
9518
- };
9519
- });
9520
- class HoverPlugin {
9521
- constructor(view, source, field, setHover, hoverTime) {
9522
- this.view = view;
9523
- this.source = source;
9524
- this.field = field;
9525
- this.setHover = setHover;
9526
- this.hoverTime = hoverTime;
9527
- this.hoverTimeout = -1;
9528
- this.restartTimeout = -1;
9529
- this.pending = null;
9530
- this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
9531
- this.checkHover = this.checkHover.bind(this);
9532
- view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
9533
- view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
9534
- }
9535
- update() {
9536
- if (this.pending) {
9537
- this.pending = null;
9538
- clearTimeout(this.restartTimeout);
9539
- this.restartTimeout = setTimeout(() => this.startHover(), 20);
9540
- }
9541
- }
9542
- get active() {
9543
- return this.view.state.field(this.field);
9544
- }
9545
- checkHover() {
9546
- this.hoverTimeout = -1;
9547
- if (this.active)
9548
- return;
9549
- let hovered = Date.now() - this.lastMove.time;
9550
- if (hovered < this.hoverTime)
9551
- this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
9552
- else
9553
- this.startHover();
9554
- }
9555
- startHover() {
9556
- clearTimeout(this.restartTimeout);
9557
- let { view, lastMove } = this;
9558
- let desc = view.docView.nearest(lastMove.target);
9559
- if (!desc)
9560
- return;
9561
- let pos, side = 1;
9562
- if (desc instanceof WidgetView) {
9563
- pos = desc.posAtStart;
9564
- }
9565
- else {
9566
- pos = view.posAtCoords(lastMove);
9567
- if (pos == null)
9568
- return;
9569
- let posCoords = view.coordsAtPos(pos);
9570
- if (!posCoords ||
9571
- lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
9572
- lastMove.x < posCoords.left - view.defaultCharacterWidth ||
9573
- lastMove.x > posCoords.right + view.defaultCharacterWidth)
9574
- return;
9575
- let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
9576
- let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;
9577
- side = (lastMove.x < posCoords.left ? -rtl : rtl);
9578
- }
9579
- let open = this.source(view, pos, side);
9580
- if (open === null || open === void 0 ? void 0 : open.then) {
9581
- let pending = this.pending = { pos };
9582
- open.then(result => {
9583
- if (this.pending == pending) {
9584
- this.pending = null;
9585
- if (result)
9586
- view.dispatch({ effects: this.setHover.of(result) });
9587
- }
9588
- }, e => logException(view.state, e, "hover tooltip"));
9589
- }
9590
- else if (open) {
9591
- view.dispatch({ effects: this.setHover.of(open) });
9592
- }
9593
- }
9594
- get tooltip() {
9595
- let plugin = this.view.plugin(tooltipPlugin);
9596
- let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost.create) : -1;
9597
- return index > -1 ? plugin.manager.tooltipViews[index] : null;
9598
- }
9599
- mousemove(event) {
9600
- var _a;
9601
- this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
9602
- if (this.hoverTimeout < 0)
9603
- this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
9604
- let { active, tooltip } = this;
9605
- if (active && tooltip && !isInTooltip(tooltip.dom, event) || this.pending) {
9606
- let { pos } = active || this.pending, end = (_a = active === null || active === void 0 ? void 0 : active.end) !== null && _a !== void 0 ? _a : pos;
9607
- if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
9608
- : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {
9609
- this.view.dispatch({ effects: this.setHover.of(null) });
9610
- this.pending = null;
9611
- }
9612
- }
9613
- }
9614
- mouseleave(event) {
9615
- clearTimeout(this.hoverTimeout);
9616
- this.hoverTimeout = -1;
9617
- let { active } = this;
9618
- if (active) {
9619
- let { tooltip } = this;
9620
- let inTooltip = tooltip && tooltip.dom.contains(event.relatedTarget);
9621
- if (!inTooltip)
9622
- this.view.dispatch({ effects: this.setHover.of(null) });
9623
- else
9624
- this.watchTooltipLeave(tooltip.dom);
9625
- }
9626
- }
9627
- watchTooltipLeave(tooltip) {
9628
- let watch = (event) => {
9629
- tooltip.removeEventListener("mouseleave", watch);
9630
- if (this.active && !this.view.dom.contains(event.relatedTarget))
9631
- this.view.dispatch({ effects: this.setHover.of(null) });
9632
- };
9633
- tooltip.addEventListener("mouseleave", watch);
9634
- }
9635
- destroy() {
9636
- clearTimeout(this.hoverTimeout);
9637
- this.view.dom.removeEventListener("mouseleave", this.mouseleave);
9638
- this.view.dom.removeEventListener("mousemove", this.mousemove);
9639
- }
9640
- }
9641
- const tooltipMargin = 4;
9642
- function isInTooltip(tooltip, event) {
9643
- let rect = tooltip.getBoundingClientRect();
9644
- return event.clientX >= rect.left - tooltipMargin && event.clientX <= rect.right + tooltipMargin &&
9645
- event.clientY >= rect.top - tooltipMargin && event.clientY <= rect.bottom + tooltipMargin;
9646
- }
9647
- function isOverRange(view, from, to, x, y, margin) {
9648
- let rect = view.scrollDOM.getBoundingClientRect();
9649
- let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;
9650
- if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)
9651
- return false;
9652
- let pos = view.posAtCoords({ x, y }, false);
9653
- return pos >= from && pos <= to;
9654
- }
9655
- /**
9656
- Set up a hover tooltip, which shows up when the pointer hovers
9657
- over ranges of text. The callback is called when the mouse hovers
9658
- over the document text. It should, if there is a tooltip
9659
- associated with position `pos`, return the tooltip description
9660
- (either directly or in a promise). The `side` argument indicates
9661
- on which side of the position the pointer is—it will be -1 if the
9662
- pointer is before the position, 1 if after the position.
9663
-
9664
- Note that all hover tooltips are hosted within a single tooltip
9665
- container element. This allows multiple tooltips over the same
9666
- range to be "merged" together without overlapping.
9667
- */
9668
- function hoverTooltip(source, options = {}) {
9669
- let setHover = StateEffect.define();
9670
- let hoverState = StateField.define({
9671
- create() { return null; },
9672
- update(value, tr) {
9673
- if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
9674
- options.hideOn && options.hideOn(tr, value)))
9675
- return null;
9676
- if (value && tr.docChanged) {
9677
- let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);
9678
- if (newPos == null)
9679
- return null;
9680
- let copy = Object.assign(Object.create(null), value);
9681
- copy.pos = newPos;
9682
- if (value.end != null)
9683
- copy.end = tr.changes.mapPos(value.end);
9684
- value = copy;
9685
- }
9686
- for (let effect of tr.effects) {
9687
- if (effect.is(setHover))
9688
- value = effect.value;
9689
- if (effect.is(closeHoverTooltipEffect))
9690
- value = null;
9691
- }
9692
- return value;
9693
- },
9694
- provide: f => showHoverTooltip.from(f)
9695
- });
9696
- return [
9697
- hoverState,
9698
- ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
9699
- showHoverTooltipHost
9700
- ];
9701
- }
9702
- /**
9703
- Get the active tooltip view for a given tooltip, if available.
9704
- */
9705
- function getTooltip(view, tooltip) {
9706
- let plugin = view.plugin(tooltipPlugin);
9707
- if (!plugin)
9708
- return null;
9709
- let found = plugin.manager.tooltips.indexOf(tooltip);
9710
- return found < 0 ? null : plugin.manager.tooltipViews[found];
9711
- }
9712
- const closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();
9713
-
9714
- const panelConfig = /*@__PURE__*/Facet.define({
9715
- combine(configs) {
9716
- let topContainer, bottomContainer;
9717
- for (let c of configs) {
9718
- topContainer = topContainer || c.topContainer;
9719
- bottomContainer = bottomContainer || c.bottomContainer;
9720
- }
9721
- return { topContainer, bottomContainer };
9722
- }
9723
- });
9724
- /**
9725
- Get the active panel created by the given constructor, if any.
9726
- This can be useful when you need access to your panels' DOM
9727
- structure.
9728
- */
9729
- function getPanel(view, panel) {
9730
- let plugin = view.plugin(panelPlugin);
9731
- let index = plugin ? plugin.specs.indexOf(panel) : -1;
9732
- return index > -1 ? plugin.panels[index] : null;
9733
- }
9734
- const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
9735
- constructor(view) {
9736
- this.input = view.state.facet(showPanel);
9737
- this.specs = this.input.filter(s => s);
9738
- this.panels = this.specs.map(spec => spec(view));
9739
- let conf = view.state.facet(panelConfig);
9740
- this.top = new PanelGroup(view, true, conf.topContainer);
9741
- this.bottom = new PanelGroup(view, false, conf.bottomContainer);
9742
- this.top.sync(this.panels.filter(p => p.top));
9743
- this.bottom.sync(this.panels.filter(p => !p.top));
9744
- for (let p of this.panels) {
9745
- p.dom.classList.add("cm-panel");
9746
- if (p.mount)
9747
- p.mount();
9748
- }
9749
- }
9750
- update(update) {
9751
- let conf = update.state.facet(panelConfig);
9752
- if (this.top.container != conf.topContainer) {
9753
- this.top.sync([]);
9754
- this.top = new PanelGroup(update.view, true, conf.topContainer);
9755
- }
9756
- if (this.bottom.container != conf.bottomContainer) {
9757
- this.bottom.sync([]);
9758
- this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
9759
- }
9760
- this.top.syncClasses();
9761
- this.bottom.syncClasses();
9762
- let input = update.state.facet(showPanel);
9763
- if (input != this.input) {
9764
- let specs = input.filter(x => x);
9765
- let panels = [], top = [], bottom = [], mount = [];
9766
- for (let spec of specs) {
9767
- let known = this.specs.indexOf(spec), panel;
9768
- if (known < 0) {
9769
- panel = spec(update.view);
9770
- mount.push(panel);
9771
- }
9772
- else {
9773
- panel = this.panels[known];
9774
- if (panel.update)
9775
- panel.update(update);
9776
- }
9777
- panels.push(panel);
9778
- (panel.top ? top : bottom).push(panel);
9779
- }
9780
- this.specs = specs;
9781
- this.panels = panels;
9782
- this.top.sync(top);
9783
- this.bottom.sync(bottom);
9784
- for (let p of mount) {
9785
- p.dom.classList.add("cm-panel");
9786
- if (p.mount)
9787
- p.mount();
9788
- }
9789
- }
9790
- else {
9791
- for (let p of this.panels)
9792
- if (p.update)
9793
- p.update(update);
9794
- }
9795
- }
9796
- destroy() {
9797
- this.top.sync([]);
9798
- this.bottom.sync([]);
9799
- }
9800
- }, {
9801
- provide: plugin => EditorView.scrollMargins.of(view => {
9802
- let value = view.plugin(plugin);
9803
- return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
9804
- })
9805
- });
9806
- class PanelGroup {
9807
- constructor(view, top, container) {
9808
- this.view = view;
9809
- this.top = top;
9810
- this.container = container;
9811
- this.dom = undefined;
9812
- this.classes = "";
9813
- this.panels = [];
9814
- this.syncClasses();
9815
- }
9816
- sync(panels) {
9817
- for (let p of this.panels)
9818
- if (p.destroy && panels.indexOf(p) < 0)
9819
- p.destroy();
9820
- this.panels = panels;
9821
- this.syncDOM();
9822
- }
9823
- syncDOM() {
9824
- if (this.panels.length == 0) {
9825
- if (this.dom) {
9826
- this.dom.remove();
9827
- this.dom = undefined;
9828
- }
9829
- return;
9830
- }
9831
- if (!this.dom) {
9832
- this.dom = document.createElement("div");
9833
- this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
9834
- this.dom.style[this.top ? "top" : "bottom"] = "0";
9835
- let parent = this.container || this.view.dom;
9836
- parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
9837
- }
9838
- let curDOM = this.dom.firstChild;
9839
- for (let panel of this.panels) {
9840
- if (panel.dom.parentNode == this.dom) {
9841
- while (curDOM != panel.dom)
9842
- curDOM = rm(curDOM);
9843
- curDOM = curDOM.nextSibling;
9844
- }
9845
- else {
9846
- this.dom.insertBefore(panel.dom, curDOM);
9847
- }
9848
- }
9849
- while (curDOM)
9850
- curDOM = rm(curDOM);
9851
- }
9852
- scrollMargin() {
9853
- return !this.dom || this.container ? 0
9854
- : Math.max(0, this.top ?
9855
- this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
9856
- Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
9857
- }
9858
- syncClasses() {
9859
- if (!this.container || this.classes == this.view.themeClasses)
9860
- return;
9861
- for (let cls of this.classes.split(" "))
9862
- if (cls)
9863
- this.container.classList.remove(cls);
9864
- for (let cls of (this.classes = this.view.themeClasses).split(" "))
9865
- if (cls)
9866
- this.container.classList.add(cls);
9867
- }
9868
- }
9869
- function rm(node) {
9870
- let next = node.nextSibling;
9871
- node.remove();
9872
- return next;
9873
- }
9874
- /**
9875
- Opening a panel is done by providing a constructor function for
9876
- the panel through this facet. (The panel is closed again when its
9877
- constructor is no longer provided.) Values of `null` are ignored.
9878
- */
9879
- const showPanel = /*@__PURE__*/Facet.define({
9880
- enables: panelPlugin
9881
- });
9882
-
9883
- /**
9884
- A gutter marker represents a bit of information attached to a line
9885
- in a specific gutter. Your own custom markers have to extend this
9886
- class.
8188
+ A gutter marker represents a bit of information attached to a line
8189
+ in a specific gutter. Your own custom markers have to extend this
8190
+ class.
9887
8191
  */
9888
8192
  class GutterMarker extends RangeValue {
9889
8193
  /**
@@ -9907,447 +8211,6 @@ GutterMarker.prototype.toDOM = undefined;
9907
8211
  GutterMarker.prototype.mapMode = MapMode.TrackBefore;
9908
8212
  GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
9909
8213
  GutterMarker.prototype.point = true;
9910
- /**
9911
- Facet used to add a class to all gutter elements for a given line.
9912
- Markers given to this facet should _only_ define an
9913
- [`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
9914
- [`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
9915
- in all gutters for the line).
9916
- */
9917
- const gutterLineClass = /*@__PURE__*/Facet.define();
9918
- const defaults = {
9919
- class: "",
9920
- renderEmptyElements: false,
9921
- elementStyle: "",
9922
- markers: () => RangeSet.empty,
9923
- lineMarker: () => null,
9924
- widgetMarker: () => null,
9925
- lineMarkerChange: null,
9926
- initialSpacer: null,
9927
- updateSpacer: null,
9928
- domEventHandlers: {}
9929
- };
9930
- const activeGutters = /*@__PURE__*/Facet.define();
9931
- /**
9932
- Define an editor gutter. The order in which the gutters appear is
9933
- determined by their extension priority.
9934
- */
9935
- function gutter(config) {
9936
- return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];
9937
- }
9938
- const unfixGutters = /*@__PURE__*/Facet.define({
9939
- combine: values => values.some(x => x)
9940
- });
9941
- /**
9942
- The gutter-drawing plugin is automatically enabled when you add a
9943
- gutter, but you can use this function to explicitly configure it.
9944
-
9945
- Unless `fixed` is explicitly set to `false`, the gutters are
9946
- fixed, meaning they don't scroll along with the content
9947
- horizontally (except on Internet Explorer, which doesn't support
9948
- CSS [`position:
9949
- sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
9950
- */
9951
- function gutters(config) {
9952
- let result = [
9953
- gutterView,
9954
- ];
9955
- if (config && config.fixed === false)
9956
- result.push(unfixGutters.of(true));
9957
- return result;
9958
- }
9959
- const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
9960
- constructor(view) {
9961
- this.view = view;
9962
- this.prevViewport = view.viewport;
9963
- this.dom = document.createElement("div");
9964
- this.dom.className = "cm-gutters";
9965
- this.dom.setAttribute("aria-hidden", "true");
9966
- this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
9967
- this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));
9968
- for (let gutter of this.gutters)
9969
- this.dom.appendChild(gutter.dom);
9970
- this.fixed = !view.state.facet(unfixGutters);
9971
- if (this.fixed) {
9972
- // FIXME IE11 fallback, which doesn't support position: sticky,
9973
- // by using position: relative + event handlers that realign the
9974
- // gutter (or just force fixed=false on IE11?)
9975
- this.dom.style.position = "sticky";
9976
- }
9977
- this.syncGutters(false);
9978
- view.scrollDOM.insertBefore(this.dom, view.contentDOM);
9979
- }
9980
- update(update) {
9981
- if (this.updateGutters(update)) {
9982
- // Detach during sync when the viewport changed significantly
9983
- // (such as during scrolling), since for large updates that is
9984
- // faster.
9985
- let vpA = this.prevViewport, vpB = update.view.viewport;
9986
- let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
9987
- this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
9988
- }
9989
- if (update.geometryChanged)
9990
- this.dom.style.minHeight = this.view.contentHeight + "px";
9991
- if (this.view.state.facet(unfixGutters) != !this.fixed) {
9992
- this.fixed = !this.fixed;
9993
- this.dom.style.position = this.fixed ? "sticky" : "";
9994
- }
9995
- this.prevViewport = update.view.viewport;
9996
- }
9997
- syncGutters(detach) {
9998
- let after = this.dom.nextSibling;
9999
- if (detach)
10000
- this.dom.remove();
10001
- let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);
10002
- let classSet = [];
10003
- let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
10004
- for (let line of this.view.viewportLineBlocks) {
10005
- if (classSet.length)
10006
- classSet = [];
10007
- if (Array.isArray(line.type)) {
10008
- let first = true;
10009
- for (let b of line.type) {
10010
- if (b.type == BlockType.Text && first) {
10011
- advanceCursor(lineClasses, classSet, b.from);
10012
- for (let cx of contexts)
10013
- cx.line(this.view, b, classSet);
10014
- first = false;
10015
- }
10016
- else if (b.widget) {
10017
- for (let cx of contexts)
10018
- cx.widget(this.view, b);
10019
- }
10020
- }
10021
- }
10022
- else if (line.type == BlockType.Text) {
10023
- advanceCursor(lineClasses, classSet, line.from);
10024
- for (let cx of contexts)
10025
- cx.line(this.view, line, classSet);
10026
- }
10027
- else if (line.widget) {
10028
- for (let cx of contexts)
10029
- cx.widget(this.view, line);
10030
- }
10031
- }
10032
- for (let cx of contexts)
10033
- cx.finish();
10034
- if (detach)
10035
- this.view.scrollDOM.insertBefore(this.dom, after);
10036
- }
10037
- updateGutters(update) {
10038
- let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);
10039
- let change = update.docChanged || update.heightChanged || update.viewportChanged ||
10040
- !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);
10041
- if (prev == cur) {
10042
- for (let gutter of this.gutters)
10043
- if (gutter.update(update))
10044
- change = true;
10045
- }
10046
- else {
10047
- change = true;
10048
- let gutters = [];
10049
- for (let conf of cur) {
10050
- let known = prev.indexOf(conf);
10051
- if (known < 0) {
10052
- gutters.push(new SingleGutterView(this.view, conf));
10053
- }
10054
- else {
10055
- this.gutters[known].update(update);
10056
- gutters.push(this.gutters[known]);
10057
- }
10058
- }
10059
- for (let g of this.gutters) {
10060
- g.dom.remove();
10061
- if (gutters.indexOf(g) < 0)
10062
- g.destroy();
10063
- }
10064
- for (let g of gutters)
10065
- this.dom.appendChild(g.dom);
10066
- this.gutters = gutters;
10067
- }
10068
- return change;
10069
- }
10070
- destroy() {
10071
- for (let view of this.gutters)
10072
- view.destroy();
10073
- this.dom.remove();
10074
- }
10075
- }, {
10076
- provide: plugin => EditorView.scrollMargins.of(view => {
10077
- let value = view.plugin(plugin);
10078
- if (!value || value.gutters.length == 0 || !value.fixed)
10079
- return null;
10080
- return view.textDirection == Direction.LTR
10081
- ? { left: value.dom.offsetWidth * view.scaleX }
10082
- : { right: value.dom.offsetWidth * view.scaleX };
10083
- })
10084
- });
10085
- function asArray(val) { return (Array.isArray(val) ? val : [val]); }
10086
- function advanceCursor(cursor, collect, pos) {
10087
- while (cursor.value && cursor.from <= pos) {
10088
- if (cursor.from == pos)
10089
- collect.push(cursor.value);
10090
- cursor.next();
10091
- }
10092
- }
10093
- class UpdateContext {
10094
- constructor(gutter, viewport, height) {
10095
- this.gutter = gutter;
10096
- this.height = height;
10097
- this.i = 0;
10098
- this.cursor = RangeSet.iter(gutter.markers, viewport.from);
10099
- }
10100
- addElement(view, block, markers) {
10101
- let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
10102
- if (this.i == gutter.elements.length) {
10103
- let newElt = new GutterElement(view, height, above, markers);
10104
- gutter.elements.push(newElt);
10105
- gutter.dom.appendChild(newElt.dom);
10106
- }
10107
- else {
10108
- gutter.elements[this.i].update(view, height, above, markers);
10109
- }
10110
- this.height = block.bottom;
10111
- this.i++;
10112
- }
10113
- line(view, line, extraMarkers) {
10114
- let localMarkers = [];
10115
- advanceCursor(this.cursor, localMarkers, line.from);
10116
- if (extraMarkers.length)
10117
- localMarkers = localMarkers.concat(extraMarkers);
10118
- let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
10119
- if (forLine)
10120
- localMarkers.unshift(forLine);
10121
- let gutter = this.gutter;
10122
- if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
10123
- return;
10124
- this.addElement(view, line, localMarkers);
10125
- }
10126
- widget(view, block) {
10127
- let marker = this.gutter.config.widgetMarker(view, block.widget, block);
10128
- if (marker)
10129
- this.addElement(view, block, [marker]);
10130
- }
10131
- finish() {
10132
- let gutter = this.gutter;
10133
- while (gutter.elements.length > this.i) {
10134
- let last = gutter.elements.pop();
10135
- gutter.dom.removeChild(last.dom);
10136
- last.destroy();
10137
- }
10138
- }
10139
- }
10140
- class SingleGutterView {
10141
- constructor(view, config) {
10142
- this.view = view;
10143
- this.config = config;
10144
- this.elements = [];
10145
- this.spacer = null;
10146
- this.dom = document.createElement("div");
10147
- this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
10148
- for (let prop in config.domEventHandlers) {
10149
- this.dom.addEventListener(prop, (event) => {
10150
- let target = event.target, y;
10151
- if (target != this.dom && this.dom.contains(target)) {
10152
- while (target.parentNode != this.dom)
10153
- target = target.parentNode;
10154
- let rect = target.getBoundingClientRect();
10155
- y = (rect.top + rect.bottom) / 2;
10156
- }
10157
- else {
10158
- y = event.clientY;
10159
- }
10160
- let line = view.lineBlockAtHeight(y - view.documentTop);
10161
- if (config.domEventHandlers[prop](view, line, event))
10162
- event.preventDefault();
10163
- });
10164
- }
10165
- this.markers = asArray(config.markers(view));
10166
- if (config.initialSpacer) {
10167
- this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);
10168
- this.dom.appendChild(this.spacer.dom);
10169
- this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
10170
- }
10171
- }
10172
- update(update) {
10173
- let prevMarkers = this.markers;
10174
- this.markers = asArray(this.config.markers(update.view));
10175
- if (this.spacer && this.config.updateSpacer) {
10176
- let updated = this.config.updateSpacer(this.spacer.markers[0], update);
10177
- if (updated != this.spacer.markers[0])
10178
- this.spacer.update(update.view, 0, 0, [updated]);
10179
- }
10180
- let vp = update.view.viewport;
10181
- return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||
10182
- (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
10183
- }
10184
- destroy() {
10185
- for (let elt of this.elements)
10186
- elt.destroy();
10187
- }
10188
- }
10189
- class GutterElement {
10190
- constructor(view, height, above, markers) {
10191
- this.height = -1;
10192
- this.above = 0;
10193
- this.markers = [];
10194
- this.dom = document.createElement("div");
10195
- this.dom.className = "cm-gutterElement";
10196
- this.update(view, height, above, markers);
10197
- }
10198
- update(view, height, above, markers) {
10199
- if (this.height != height) {
10200
- this.height = height;
10201
- this.dom.style.height = height + "px";
10202
- }
10203
- if (this.above != above)
10204
- this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
10205
- if (!sameMarkers(this.markers, markers))
10206
- this.setMarkers(view, markers);
10207
- }
10208
- setMarkers(view, markers) {
10209
- let cls = "cm-gutterElement", domPos = this.dom.firstChild;
10210
- for (let iNew = 0, iOld = 0;;) {
10211
- let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
10212
- if (marker) {
10213
- let c = marker.elementClass;
10214
- if (c)
10215
- cls += " " + c;
10216
- for (let i = iOld; i < this.markers.length; i++)
10217
- if (this.markers[i].compare(marker)) {
10218
- skipTo = i;
10219
- matched = true;
10220
- break;
10221
- }
10222
- }
10223
- else {
10224
- skipTo = this.markers.length;
10225
- }
10226
- while (iOld < skipTo) {
10227
- let next = this.markers[iOld++];
10228
- if (next.toDOM) {
10229
- next.destroy(domPos);
10230
- let after = domPos.nextSibling;
10231
- domPos.remove();
10232
- domPos = after;
10233
- }
10234
- }
10235
- if (!marker)
10236
- break;
10237
- if (marker.toDOM) {
10238
- if (matched)
10239
- domPos = domPos.nextSibling;
10240
- else
10241
- this.dom.insertBefore(marker.toDOM(view), domPos);
10242
- }
10243
- if (matched)
10244
- iOld++;
10245
- }
10246
- this.dom.className = cls;
10247
- this.markers = markers;
10248
- }
10249
- destroy() {
10250
- this.setMarkers(null, []); // First argument not used unless creating markers
10251
- }
10252
- }
10253
- function sameMarkers(a, b) {
10254
- if (a.length != b.length)
10255
- return false;
10256
- for (let i = 0; i < a.length; i++)
10257
- if (!a[i].compare(b[i]))
10258
- return false;
10259
- return true;
10260
- }
10261
- /**
10262
- Facet used to provide markers to the line number gutter.
10263
- */
10264
- const lineNumberMarkers = /*@__PURE__*/Facet.define();
10265
- const lineNumberConfig = /*@__PURE__*/Facet.define({
10266
- combine(values) {
10267
- return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {
10268
- domEventHandlers(a, b) {
10269
- let result = Object.assign({}, a);
10270
- for (let event in b) {
10271
- let exists = result[event], add = b[event];
10272
- result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
10273
- }
10274
- return result;
10275
- }
10276
- });
10277
- }
10278
- });
10279
- class NumberMarker extends GutterMarker {
10280
- constructor(number) {
10281
- super();
10282
- this.number = number;
10283
- }
10284
- eq(other) { return this.number == other.number; }
10285
- toDOM() { return document.createTextNode(this.number); }
10286
- }
10287
- function formatNumber(view, number) {
10288
- return view.state.facet(lineNumberConfig).formatNumber(number, view.state);
10289
- }
10290
- const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({
10291
- class: "cm-lineNumbers",
10292
- renderEmptyElements: false,
10293
- markers(view) { return view.state.facet(lineNumberMarkers); },
10294
- lineMarker(view, line, others) {
10295
- if (others.some(m => m.toDOM))
10296
- return null;
10297
- return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
10298
- },
10299
- widgetMarker: () => null,
10300
- lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
10301
- initialSpacer(view) {
10302
- return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
10303
- },
10304
- updateSpacer(spacer, update) {
10305
- let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
10306
- return max == spacer.number ? spacer : new NumberMarker(max);
10307
- },
10308
- domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
10309
- }));
10310
- /**
10311
- Create a line number gutter extension.
10312
- */
10313
- function lineNumbers(config = {}) {
10314
- return [
10315
- lineNumberConfig.of(config),
10316
- gutters(),
10317
- lineNumberGutter
10318
- ];
10319
- }
10320
- function maxLineNumber(lines) {
10321
- let last = 9;
10322
- while (last < lines)
10323
- last = last * 10 + 9;
10324
- return last;
10325
- }
10326
- const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {
10327
- constructor() {
10328
- super(...arguments);
10329
- this.elementClass = "cm-activeLineGutter";
10330
- }
10331
- };
10332
- const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute(["selection"], state => {
10333
- let marks = [], last = -1;
10334
- for (let range of state.selection.ranges) {
10335
- let linePos = state.doc.lineAt(range.head).from;
10336
- if (linePos > last) {
10337
- last = linePos;
10338
- marks.push(activeLineGutterMarker.range(linePos));
10339
- }
10340
- }
10341
- return RangeSet.of(marks);
10342
- });
10343
- /**
10344
- Returns an extension that adds a `cm-activeLineGutter` class to
10345
- all gutter elements on the [active
10346
- line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
10347
- */
10348
- function highlightActiveLineGutter() {
10349
- return activeLineGutterHighlighter;
10350
- }
10351
8214
 
10352
- export { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, placeholder, rectangularSelection, runScopeHandlers, showPanel, showTooltip };
8215
+ export { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, ViewPlugin, ViewUpdate, WidgetType, keymap, logException, placeholder };
10353
8216
  //# sourceMappingURL=index.js.map