@maketribe/ms-app 3.0.36 → 3.0.38

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 (83) hide show
  1. package/dist/cjs/dataview/member/MemberTable.js +2 -2
  2. package/dist/cjs/dataview/member/MemberTable.js.map +1 -1
  3. package/dist/cjs/layouts/components/header/tools.js +7 -2
  4. package/dist/cjs/layouts/components/header/tools.js.map +1 -1
  5. 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
  6. 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
  7. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +7 -1433
  8. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
  9. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1484 -0
  10. package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
  11. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1751 -0
  12. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
  13. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +0 -1030
  14. package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
  15. 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
  16. package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
  17. 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
  18. package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
  19. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +0 -42
  20. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
  21. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3958 -0
  22. package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
  23. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +3 -2161
  24. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
  25. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10580 -0
  26. package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
  27. package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1668 -0
  28. package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
  29. 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
  30. 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
  31. package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +177 -0
  32. package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
  33. 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
  34. package/dist/esm/dataview/member/MemberTable.js +2 -2
  35. package/dist/esm/dataview/member/MemberTable.js.map +1 -1
  36. package/dist/esm/layouts/components/header/tools.js +7 -2
  37. package/dist/esm/layouts/components/header/tools.js.map +1 -1
  38. 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
  39. 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
  40. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +4 -1357
  41. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
  42. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1408 -0
  43. package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
  44. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1715 -0
  45. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
  46. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +4 -1011
  47. package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
  48. 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
  49. package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
  50. 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
  51. package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
  52. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +1 -41
  53. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
  54. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3930 -0
  55. package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
  56. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +5 -2142
  57. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
  58. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10548 -0
  59. package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
  60. package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1658 -0
  61. package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
  62. 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
  63. 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
  64. package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +175 -0
  65. package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
  66. 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
  67. package/dist/style/components/classify-search.css +1 -1
  68. package/dist/style/components/index.css +1 -1
  69. package/dist/style/index.css +2 -2
  70. package/dist/style/layouts/default/header.css +1 -1
  71. package/dist/style/layouts/default/index.css +1 -1
  72. package/dist/style/layouts/index.css +1 -1
  73. package/dist/style/src/components/classify-search.scss +5 -2
  74. package/dist/style/src/layouts/default/header.scss +4 -0
  75. package/package.json +3 -3
  76. package/src/dataview/member/MemberTable.tsx +2 -2
  77. package/src/layouts/components/header/tools.tsx +6 -1
  78. 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
  79. package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
  80. package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
  81. 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
  82. package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
  83. package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
@@ -1,8 +1,7 @@
1
1
  import { NodeType, NodeProp, IterMode, Tree, TreeFragment, Parser } from '../../../../../@lezer_common@1.1.1/node_modules/@lezer/common/dist/index.js';
2
- import { Facet, StateField, EditorState, StateEffect, RangeSet, countColumn, combineConfig, RangeSetBuilder, Prec } from '../../../../../@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js';
3
- import { EditorView, ViewPlugin, logException, gutter, Decoration, WidgetType, GutterMarker } from '../../../../../@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js';
4
- import { tags, styleTags, tagHighlighter, highlightTree } from '../../../../../@lezer_highlight@1.2.0/node_modules/@lezer/highlight/dist/index.js';
5
- import { StyleModule } from '../../../../../style-mod@4.1.0/node_modules/style-mod/src/style-mod.js';
2
+ import { Facet, StateField, EditorState, StateEffect } from '../../../../../@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js';
3
+ import { EditorView, ViewPlugin, logException } from '../../../../../@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js';
4
+ import { tags, styleTags } from '../../../../../@lezer_highlight@1.2.0/node_modules/@lezer/highlight/dist/index.js';
6
5
 
7
6
  var _a;
8
7
  /**
@@ -639,17 +638,6 @@ class LanguageSupport {
639
638
  this.extension = [language, support];
640
639
  }
641
640
  }
642
-
643
- /**
644
- Facet that defines a way to provide a function that computes the
645
- appropriate indentation depth, as a column number (see
646
- [`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given
647
- line. A return value of `null` indicates no indentation can be
648
- determined, and the line should inherit the indentation of the one
649
- above it. A return value of `undefined` defers to the next indent
650
- service.
651
- */
652
- const indentService = /*@__PURE__*/Facet.define();
653
641
  /**
654
642
  Facet for overriding the unit by which indentation happens. Should
655
643
  be a string consisting either entirely of the same whitespace
@@ -695,120 +683,6 @@ function indentString(state, cols) {
695
683
  return result;
696
684
  }
697
685
  /**
698
- Get the indentation, as a column number, at the given position.
699
- Will first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)
700
- that are registered, and if none of those return an indentation,
701
- this will check the syntax tree for the [indent node
702
- prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a
703
- number when an indentation could be determined, and null
704
- otherwise.
705
- */
706
- function getIndentation(context, pos) {
707
- if (context instanceof EditorState)
708
- context = new IndentContext(context);
709
- for (let service of context.state.facet(indentService)) {
710
- let result = service(context, pos);
711
- if (result !== undefined)
712
- return result;
713
- }
714
- let tree = syntaxTree(context.state);
715
- return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;
716
- }
717
- /**
718
- Indentation contexts are used when calling [indentation
719
- services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
720
- useful in indentation logic, and can selectively override the
721
- indentation reported for some lines.
722
- */
723
- class IndentContext {
724
- /**
725
- Create an indent context.
726
- */
727
- constructor(
728
- /**
729
- The editor state.
730
- */
731
- state,
732
- /**
733
- @internal
734
- */
735
- options = {}) {
736
- this.state = state;
737
- this.options = options;
738
- this.unit = getIndentUnit(state);
739
- }
740
- /**
741
- Get a description of the line at the given position, taking
742
- [simulated line
743
- breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
744
- into account. If there is such a break at `pos`, the `bias`
745
- argument determines whether the part of the line line before or
746
- after the break is used.
747
- */
748
- lineAt(pos, bias = 1) {
749
- let line = this.state.doc.lineAt(pos);
750
- let { simulateBreak, simulateDoubleBreak } = this.options;
751
- if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
752
- if (simulateDoubleBreak && simulateBreak == pos)
753
- return { text: "", from: pos };
754
- else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
755
- return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
756
- else
757
- return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
758
- }
759
- return line;
760
- }
761
- /**
762
- Get the text directly after `pos`, either the entire line
763
- or the next 100 characters, whichever is shorter.
764
- */
765
- textAfterPos(pos, bias = 1) {
766
- if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
767
- return "";
768
- let { text, from } = this.lineAt(pos, bias);
769
- return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
770
- }
771
- /**
772
- Find the column for the given position.
773
- */
774
- column(pos, bias = 1) {
775
- let { text, from } = this.lineAt(pos, bias);
776
- let result = this.countColumn(text, pos - from);
777
- let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
778
- if (override > -1)
779
- result += override - this.countColumn(text, text.search(/\S|$/));
780
- return result;
781
- }
782
- /**
783
- Find the column position (taking tabs into account) of the given
784
- position in the given string.
785
- */
786
- countColumn(line, pos = line.length) {
787
- return countColumn(line, this.state.tabSize, pos);
788
- }
789
- /**
790
- Find the indentation column of the line at the given point.
791
- */
792
- lineIndent(pos, bias = 1) {
793
- let { text, from } = this.lineAt(pos, bias);
794
- let override = this.options.overrideIndentation;
795
- if (override) {
796
- let overriden = override(from);
797
- if (overriden > -1)
798
- return overriden;
799
- }
800
- return this.countColumn(text, text.search(/\S|$/));
801
- }
802
- /**
803
- Returns the [simulated line
804
- break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
805
- for this context, if any.
806
- */
807
- get simulatedBreak() {
808
- return this.options.simulateBreak || null;
809
- }
810
- }
811
- /**
812
686
  A syntax tree node prop used to associate indentation strategies
813
687
  with node types. Such a strategy is a function from an indentation
814
688
  context to a column number (see also
@@ -816,148 +690,6 @@ context to a column number (see also
816
690
  indicates that no definitive indentation can be determined.
817
691
  */
818
692
  const indentNodeProp = /*@__PURE__*/new NodeProp();
819
- // Compute the indentation for a given position from the syntax tree.
820
- function syntaxIndentation(cx, ast, pos) {
821
- let stack = ast.resolveStack(pos);
822
- let inner = stack.node.enterUnfinishedNodesBefore(pos);
823
- if (inner != stack.node) {
824
- let add = [];
825
- for (let cur = inner; cur != stack.node; cur = cur.parent)
826
- add.push(cur);
827
- for (let i = add.length - 1; i >= 0; i--)
828
- stack = { node: add[i], next: stack };
829
- }
830
- return indentFor(stack, cx, pos);
831
- }
832
- function indentFor(stack, cx, pos) {
833
- for (let cur = stack; cur; cur = cur.next) {
834
- let strategy = indentStrategy(cur.node);
835
- if (strategy)
836
- return strategy(TreeIndentContext.create(cx, pos, cur));
837
- }
838
- return 0;
839
- }
840
- function ignoreClosed(cx) {
841
- return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
842
- }
843
- function indentStrategy(tree) {
844
- let strategy = tree.type.prop(indentNodeProp);
845
- if (strategy)
846
- return strategy;
847
- let first = tree.firstChild, close;
848
- if (first && (close = first.type.prop(NodeProp.closedBy))) {
849
- let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
850
- return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
851
- }
852
- return tree.parent == null ? topIndent : null;
853
- }
854
- function topIndent() { return 0; }
855
- /**
856
- Objects of this type provide context information and helper
857
- methods to indentation functions registered on syntax nodes.
858
- */
859
- class TreeIndentContext extends IndentContext {
860
- constructor(base,
861
- /**
862
- The position at which indentation is being computed.
863
- */
864
- pos,
865
- /**
866
- @internal
867
- */
868
- context) {
869
- super(base.state, base.options);
870
- this.base = base;
871
- this.pos = pos;
872
- this.context = context;
873
- }
874
- /**
875
- The syntax tree node to which the indentation strategy
876
- applies.
877
- */
878
- get node() { return this.context.node; }
879
- /**
880
- @internal
881
- */
882
- static create(base, pos, context) {
883
- return new TreeIndentContext(base, pos, context);
884
- }
885
- /**
886
- Get the text directly after `this.pos`, either the entire line
887
- or the next 100 characters, whichever is shorter.
888
- */
889
- get textAfter() {
890
- return this.textAfterPos(this.pos);
891
- }
892
- /**
893
- Get the indentation at the reference line for `this.node`, which
894
- is the line on which it starts, unless there is a node that is
895
- _not_ a parent of this node covering the start of that line. If
896
- so, the line at the start of that node is tried, again skipping
897
- on if it is covered by another such node.
898
- */
899
- get baseIndent() {
900
- return this.baseIndentFor(this.node);
901
- }
902
- /**
903
- Get the indentation for the reference line of the given node
904
- (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
905
- */
906
- baseIndentFor(node) {
907
- let line = this.state.doc.lineAt(node.from);
908
- // Skip line starts that are covered by a sibling (or cousin, etc)
909
- for (;;) {
910
- let atBreak = node.resolve(line.from);
911
- while (atBreak.parent && atBreak.parent.from == atBreak.from)
912
- atBreak = atBreak.parent;
913
- if (isParent(atBreak, node))
914
- break;
915
- line = this.state.doc.lineAt(atBreak.from);
916
- }
917
- return this.lineIndent(line.from);
918
- }
919
- /**
920
- Continue looking for indentations in the node's parent nodes,
921
- and return the result of that.
922
- */
923
- continue() {
924
- return indentFor(this.context.next, this.base, this.pos);
925
- }
926
- }
927
- function isParent(parent, of) {
928
- for (let cur = of; cur; cur = cur.parent)
929
- if (parent == cur)
930
- return true;
931
- return false;
932
- }
933
- // Check whether a delimited node is aligned (meaning there are
934
- // non-skipped nodes on the same line as the opening delimiter). And
935
- // if so, return the opening token.
936
- function bracketedAligned(context) {
937
- let tree = context.node;
938
- let openToken = tree.childAfter(tree.from), last = tree.lastChild;
939
- if (!openToken)
940
- return null;
941
- let sim = context.options.simulateBreak;
942
- let openLine = context.state.doc.lineAt(openToken.from);
943
- let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
944
- for (let pos = openToken.to;;) {
945
- let next = tree.childAfter(pos);
946
- if (!next || next == last)
947
- return null;
948
- if (!next.type.isSkipped)
949
- return next.from < lineEnd ? openToken : null;
950
- pos = next.to;
951
- }
952
- }
953
- function delimitedStrategy(context, align, units, closing, closedAt) {
954
- let after = context.textAfter, space = after.match(/^\s*/)[0].length;
955
- let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
956
- let aligned = align ? bracketedAligned(context) : null;
957
- if (aligned)
958
- return closed ? context.column(aligned.from) : context.column(aligned.to);
959
- return context.baseIndent + (closed ? 0 : context.unit * units);
960
- }
961
693
  /**
962
694
  Creates an indentation strategy that, by default, indents
963
695
  continued lines one unit more than the node's base indentation.
@@ -972,58 +704,6 @@ function continuedIndent({ except, units = 1 } = {}) {
972
704
  return context.baseIndent + (matchExcept ? 0 : units * context.unit);
973
705
  };
974
706
  }
975
- const DontIndentBeyond = 200;
976
- /**
977
- Enables reindentation on input. When a language defines an
978
- `indentOnInput` field in its [language
979
- data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
980
- expression, the line at the cursor will be reindented whenever new
981
- text is typed and the input from the start of the line up to the
982
- cursor matches that regexp.
983
-
984
- To avoid unneccesary reindents, it is recommended to start the
985
- regexp with `^` (usually followed by `\s*`), and end it with `$`.
986
- For example, `/^\s*\}$/` will reindent when a closing brace is
987
- added at the start of a line.
988
- */
989
- function indentOnInput() {
990
- return EditorState.transactionFilter.of(tr => {
991
- if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
992
- return tr;
993
- let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
994
- if (!rules.length)
995
- return tr;
996
- let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
997
- if (head > line.from + DontIndentBeyond)
998
- return tr;
999
- let lineStart = doc.sliceString(line.from, head);
1000
- if (!rules.some(r => r.test(lineStart)))
1001
- return tr;
1002
- let { state } = tr, last = -1, changes = [];
1003
- for (let { head } of state.selection.ranges) {
1004
- let line = state.doc.lineAt(head);
1005
- if (line.from == last)
1006
- continue;
1007
- last = line.from;
1008
- let indent = getIndentation(state, line.from);
1009
- if (indent == null)
1010
- continue;
1011
- let cur = /^\s*/.exec(line.text)[0];
1012
- let norm = indentString(state, indent);
1013
- if (cur != norm)
1014
- changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
1015
- }
1016
- return changes.length ? [tr, { changes, sequential: true }] : tr;
1017
- });
1018
- }
1019
-
1020
- /**
1021
- A facet that registers a code folding service. When called with
1022
- the extent of a line, such a function should return a foldable
1023
- range that starts on that line (but continues beyond it), if one
1024
- can be found.
1025
- */
1026
- const foldService = /*@__PURE__*/Facet.define();
1027
707
  /**
1028
708
  This node prop is used to associate folding information with
1029
709
  syntax node types. Given a syntax node, it should check whether
@@ -1040,693 +720,6 @@ function foldInside(node) {
1040
720
  let first = node.firstChild, last = node.lastChild;
1041
721
  return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
1042
722
  }
1043
- function syntaxFolding(state, start, end) {
1044
- let tree = syntaxTree(state);
1045
- if (tree.length < end)
1046
- return null;
1047
- let stack = tree.resolveStack(end, 1);
1048
- let found = null;
1049
- for (let iter = stack; iter; iter = iter.next) {
1050
- let cur = iter.node;
1051
- if (cur.to <= end || cur.from > end)
1052
- continue;
1053
- if (found && cur.from < start)
1054
- break;
1055
- let prop = cur.type.prop(foldNodeProp);
1056
- if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
1057
- let value = prop(cur, state);
1058
- if (value && value.from <= end && value.from >= start && value.to > end)
1059
- found = value;
1060
- }
1061
- }
1062
- return found;
1063
- }
1064
- function isUnfinished(node) {
1065
- let ch = node.lastChild;
1066
- return ch && ch.to == node.to && ch.type.isError;
1067
- }
1068
- /**
1069
- Check whether the given line is foldable. First asks any fold
1070
- services registered through
1071
- [`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
1072
- a result, tries to query the [fold node
1073
- prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
1074
- of the line.
1075
- */
1076
- function foldable(state, lineStart, lineEnd) {
1077
- for (let service of state.facet(foldService)) {
1078
- let result = service(state, lineStart, lineEnd);
1079
- if (result)
1080
- return result;
1081
- }
1082
- return syntaxFolding(state, lineStart, lineEnd);
1083
- }
1084
- function mapRange(range, mapping) {
1085
- let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
1086
- return from >= to ? undefined : { from, to };
1087
- }
1088
- /**
1089
- State effect that can be attached to a transaction to fold the
1090
- given range. (You probably only need this in exceptional
1091
- circumstances—usually you'll just want to let
1092
- [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
1093
- gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
1094
- */
1095
- const foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
1096
- /**
1097
- State effect that unfolds the given range (if it was folded).
1098
- */
1099
- const unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
1100
- function selectedLines(view) {
1101
- let lines = [];
1102
- for (let { head } of view.state.selection.ranges) {
1103
- if (lines.some(l => l.from <= head && l.to >= head))
1104
- continue;
1105
- lines.push(view.lineBlockAt(head));
1106
- }
1107
- return lines;
1108
- }
1109
- /**
1110
- The state field that stores the folded ranges (as a [decoration
1111
- set](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to
1112
- [`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and
1113
- [`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold
1114
- state.
1115
- */
1116
- const foldState = /*@__PURE__*/StateField.define({
1117
- create() {
1118
- return Decoration.none;
1119
- },
1120
- update(folded, tr) {
1121
- folded = folded.map(tr.changes);
1122
- for (let e of tr.effects) {
1123
- if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
1124
- let { preparePlaceholder } = tr.state.facet(foldConfig);
1125
- let widget = !preparePlaceholder ? foldWidget :
1126
- Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });
1127
- folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });
1128
- }
1129
- else if (e.is(unfoldEffect)) {
1130
- folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
1131
- filterFrom: e.value.from, filterTo: e.value.to });
1132
- }
1133
- }
1134
- // Clear folded ranges that cover the selection head
1135
- if (tr.selection) {
1136
- let onSelection = false, { head } = tr.selection.main;
1137
- folded.between(head, head, (a, b) => { if (a < head && b > head)
1138
- onSelection = true; });
1139
- if (onSelection)
1140
- folded = folded.update({
1141
- filterFrom: head,
1142
- filterTo: head,
1143
- filter: (a, b) => b <= head || a >= head
1144
- });
1145
- }
1146
- return folded;
1147
- },
1148
- provide: f => EditorView.decorations.from(f),
1149
- toJSON(folded, state) {
1150
- let ranges = [];
1151
- folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });
1152
- return ranges;
1153
- },
1154
- fromJSON(value) {
1155
- if (!Array.isArray(value) || value.length % 2)
1156
- throw new RangeError("Invalid JSON for fold state");
1157
- let ranges = [];
1158
- for (let i = 0; i < value.length;) {
1159
- let from = value[i++], to = value[i++];
1160
- if (typeof from != "number" || typeof to != "number")
1161
- throw new RangeError("Invalid JSON for fold state");
1162
- ranges.push(foldWidget.range(from, to));
1163
- }
1164
- return Decoration.set(ranges, true);
1165
- }
1166
- });
1167
- function findFold(state, from, to) {
1168
- var _a;
1169
- let found = null;
1170
- (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {
1171
- if (!found || found.from > from)
1172
- found = { from, to };
1173
- });
1174
- return found;
1175
- }
1176
- function foldExists(folded, from, to) {
1177
- let found = false;
1178
- folded.between(from, from, (a, b) => { if (a == from && b == to)
1179
- found = true; });
1180
- return found;
1181
- }
1182
- function maybeEnable(state, other) {
1183
- return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));
1184
- }
1185
- /**
1186
- Fold the lines that are selected, if possible.
1187
- */
1188
- const foldCode = view => {
1189
- for (let line of selectedLines(view)) {
1190
- let range = foldable(view.state, line.from, line.to);
1191
- if (range) {
1192
- view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
1193
- return true;
1194
- }
1195
- }
1196
- return false;
1197
- };
1198
- /**
1199
- Unfold folded ranges on selected lines.
1200
- */
1201
- const unfoldCode = view => {
1202
- if (!view.state.field(foldState, false))
1203
- return false;
1204
- let effects = [];
1205
- for (let line of selectedLines(view)) {
1206
- let folded = findFold(view.state, line.from, line.to);
1207
- if (folded)
1208
- effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
1209
- }
1210
- if (effects.length)
1211
- view.dispatch({ effects });
1212
- return effects.length > 0;
1213
- };
1214
- function announceFold(view, range, fold = true) {
1215
- let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
1216
- return EditorView.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
1217
- }
1218
- /**
1219
- Fold all top-level foldable ranges. Note that, in most cases,
1220
- folding information will depend on the [syntax
1221
- tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
1222
- reliably when the document hasn't been fully parsed (either
1223
- because the editor state was only just initialized, or because the
1224
- document is so big that the parser decided not to parse it
1225
- entirely).
1226
- */
1227
- const foldAll = view => {
1228
- let { state } = view, effects = [];
1229
- for (let pos = 0; pos < state.doc.length;) {
1230
- let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
1231
- if (range)
1232
- effects.push(foldEffect.of(range));
1233
- pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
1234
- }
1235
- if (effects.length)
1236
- view.dispatch({ effects: maybeEnable(view.state, effects) });
1237
- return !!effects.length;
1238
- };
1239
- /**
1240
- Unfold all folded code.
1241
- */
1242
- const unfoldAll = view => {
1243
- let field = view.state.field(foldState, false);
1244
- if (!field || !field.size)
1245
- return false;
1246
- let effects = [];
1247
- field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
1248
- view.dispatch({ effects });
1249
- return true;
1250
- };
1251
- /**
1252
- Default fold-related key bindings.
1253
-
1254
- - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
1255
- - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
1256
- - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
1257
- - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
1258
- */
1259
- const foldKeymap = [
1260
- { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
1261
- { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
1262
- { key: "Ctrl-Alt-[", run: foldAll },
1263
- { key: "Ctrl-Alt-]", run: unfoldAll }
1264
- ];
1265
- const defaultConfig = {
1266
- placeholderDOM: null,
1267
- preparePlaceholder: null,
1268
- placeholderText: "…"
1269
- };
1270
- const foldConfig = /*@__PURE__*/Facet.define({
1271
- combine(values) { return combineConfig(values, defaultConfig); }
1272
- });
1273
- /**
1274
- Create an extension that configures code folding.
1275
- */
1276
- function codeFolding(config) {
1277
- let result = [foldState, baseTheme$1];
1278
- if (config)
1279
- result.push(foldConfig.of(config));
1280
- return result;
1281
- }
1282
- function widgetToDOM(view, prepared) {
1283
- let { state } = view, conf = state.facet(foldConfig);
1284
- let onclick = (event) => {
1285
- let line = view.lineBlockAt(view.posAtDOM(event.target));
1286
- let folded = findFold(view.state, line.from, line.to);
1287
- if (folded)
1288
- view.dispatch({ effects: unfoldEffect.of(folded) });
1289
- event.preventDefault();
1290
- };
1291
- if (conf.placeholderDOM)
1292
- return conf.placeholderDOM(view, onclick, prepared);
1293
- let element = document.createElement("span");
1294
- element.textContent = conf.placeholderText;
1295
- element.setAttribute("aria-label", state.phrase("folded code"));
1296
- element.title = state.phrase("unfold");
1297
- element.className = "cm-foldPlaceholder";
1298
- element.onclick = onclick;
1299
- return element;
1300
- }
1301
- const foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {
1302
- toDOM(view) { return widgetToDOM(view, null); }
1303
- } });
1304
- class PreparedFoldWidget extends WidgetType {
1305
- constructor(value) {
1306
- super();
1307
- this.value = value;
1308
- }
1309
- eq(other) { return this.value == other.value; }
1310
- toDOM(view) { return widgetToDOM(view, this.value); }
1311
- }
1312
- const foldGutterDefaults = {
1313
- openText: "⌄",
1314
- closedText: "›",
1315
- markerDOM: null,
1316
- domEventHandlers: {},
1317
- foldingChanged: () => false
1318
- };
1319
- class FoldMarker extends GutterMarker {
1320
- constructor(config, open) {
1321
- super();
1322
- this.config = config;
1323
- this.open = open;
1324
- }
1325
- eq(other) { return this.config == other.config && this.open == other.open; }
1326
- toDOM(view) {
1327
- if (this.config.markerDOM)
1328
- return this.config.markerDOM(this.open);
1329
- let span = document.createElement("span");
1330
- span.textContent = this.open ? this.config.openText : this.config.closedText;
1331
- span.title = view.state.phrase(this.open ? "Fold line" : "Unfold line");
1332
- return span;
1333
- }
1334
- }
1335
- /**
1336
- Create an extension that registers a fold gutter, which shows a
1337
- fold status indicator before foldable lines (which can be clicked
1338
- to fold or unfold the line).
1339
- */
1340
- function foldGutter(config = {}) {
1341
- let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
1342
- let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
1343
- let markers = ViewPlugin.fromClass(class {
1344
- constructor(view) {
1345
- this.from = view.viewport.from;
1346
- this.markers = this.buildMarkers(view);
1347
- }
1348
- update(update) {
1349
- if (update.docChanged || update.viewportChanged ||
1350
- update.startState.facet(language) != update.state.facet(language) ||
1351
- update.startState.field(foldState, false) != update.state.field(foldState, false) ||
1352
- syntaxTree(update.startState) != syntaxTree(update.state) ||
1353
- fullConfig.foldingChanged(update))
1354
- this.markers = this.buildMarkers(update.view);
1355
- }
1356
- buildMarkers(view) {
1357
- let builder = new RangeSetBuilder();
1358
- for (let line of view.viewportLineBlocks) {
1359
- let mark = findFold(view.state, line.from, line.to) ? canUnfold
1360
- : foldable(view.state, line.from, line.to) ? canFold : null;
1361
- if (mark)
1362
- builder.add(line.from, line.from, mark);
1363
- }
1364
- return builder.finish();
1365
- }
1366
- });
1367
- let { domEventHandlers } = fullConfig;
1368
- return [
1369
- markers,
1370
- gutter({
1371
- class: "cm-foldGutter",
1372
- markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },
1373
- initialSpacer() {
1374
- return new FoldMarker(fullConfig, false);
1375
- },
1376
- domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
1377
- if (domEventHandlers.click && domEventHandlers.click(view, line, event))
1378
- return true;
1379
- let folded = findFold(view.state, line.from, line.to);
1380
- if (folded) {
1381
- view.dispatch({ effects: unfoldEffect.of(folded) });
1382
- return true;
1383
- }
1384
- let range = foldable(view.state, line.from, line.to);
1385
- if (range) {
1386
- view.dispatch({ effects: foldEffect.of(range) });
1387
- return true;
1388
- }
1389
- return false;
1390
- } })
1391
- }),
1392
- codeFolding()
1393
- ];
1394
- }
1395
- const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
1396
- ".cm-foldPlaceholder": {
1397
- backgroundColor: "#eee",
1398
- border: "1px solid #ddd",
1399
- color: "#888",
1400
- borderRadius: ".2em",
1401
- margin: "0 1px",
1402
- padding: "0 1px",
1403
- cursor: "pointer"
1404
- },
1405
- ".cm-foldGutter span": {
1406
- padding: "0 1px",
1407
- cursor: "pointer"
1408
- }
1409
- });
1410
-
1411
- /**
1412
- A highlight style associates CSS styles with higlighting
1413
- [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
1414
- */
1415
- class HighlightStyle {
1416
- constructor(
1417
- /**
1418
- The tag styles used to create this highlight style.
1419
- */
1420
- specs, options) {
1421
- this.specs = specs;
1422
- let modSpec;
1423
- function def(spec) {
1424
- let cls = StyleModule.newName();
1425
- (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
1426
- return cls;
1427
- }
1428
- const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
1429
- const scopeOpt = options.scope;
1430
- this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
1431
- : scopeOpt ? (type) => type == scopeOpt : undefined;
1432
- this.style = tagHighlighter(specs.map(style => ({
1433
- tag: style.tag,
1434
- class: style.class || def(Object.assign({}, style, { tag: null }))
1435
- })), {
1436
- all,
1437
- }).style;
1438
- this.module = modSpec ? new StyleModule(modSpec) : null;
1439
- this.themeType = options.themeType;
1440
- }
1441
- /**
1442
- Create a highlighter style that associates the given styles to
1443
- the given tags. The specs must be objects that hold a style tag
1444
- or array of tags in their `tag` property, and either a single
1445
- `class` property providing a static CSS class (for highlighter
1446
- that rely on external styling), or a
1447
- [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
1448
- set of CSS properties (which define the styling for those tags).
1449
-
1450
- The CSS rules created for a highlighter will be emitted in the
1451
- order of the spec's properties. That means that for elements that
1452
- have multiple tags associated with them, styles defined further
1453
- down in the list will have a higher CSS precedence than styles
1454
- defined earlier.
1455
- */
1456
- static define(specs, options) {
1457
- return new HighlightStyle(specs, options || {});
1458
- }
1459
- }
1460
- const highlighterFacet = /*@__PURE__*/Facet.define();
1461
- const fallbackHighlighter = /*@__PURE__*/Facet.define({
1462
- combine(values) { return values.length ? [values[0]] : null; }
1463
- });
1464
- function getHighlighters(state) {
1465
- let main = state.facet(highlighterFacet);
1466
- return main.length ? main : state.facet(fallbackHighlighter);
1467
- }
1468
- /**
1469
- Wrap a highlighter in an editor extension that uses it to apply
1470
- syntax highlighting to the editor content.
1471
-
1472
- When multiple (non-fallback) styles are provided, the styling
1473
- applied is the union of the classes they emit.
1474
- */
1475
- function syntaxHighlighting(highlighter, options) {
1476
- let ext = [treeHighlighter], themeType;
1477
- if (highlighter instanceof HighlightStyle) {
1478
- if (highlighter.module)
1479
- ext.push(EditorView.styleModule.of(highlighter.module));
1480
- themeType = highlighter.themeType;
1481
- }
1482
- if (options === null || options === void 0 ? void 0 : options.fallback)
1483
- ext.push(fallbackHighlighter.of(highlighter));
1484
- else if (themeType)
1485
- ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
1486
- return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
1487
- }));
1488
- else
1489
- ext.push(highlighterFacet.of(highlighter));
1490
- return ext;
1491
- }
1492
- class TreeHighlighter {
1493
- constructor(view) {
1494
- this.markCache = Object.create(null);
1495
- this.tree = syntaxTree(view.state);
1496
- this.decorations = this.buildDeco(view, getHighlighters(view.state));
1497
- }
1498
- update(update) {
1499
- let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
1500
- let styleChange = highlighters != getHighlighters(update.startState);
1501
- if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {
1502
- this.decorations = this.decorations.map(update.changes);
1503
- }
1504
- else if (tree != this.tree || update.viewportChanged || styleChange) {
1505
- this.tree = tree;
1506
- this.decorations = this.buildDeco(update.view, highlighters);
1507
- }
1508
- }
1509
- buildDeco(view, highlighters) {
1510
- if (!highlighters || !this.tree.length)
1511
- return Decoration.none;
1512
- let builder = new RangeSetBuilder();
1513
- for (let { from, to } of view.visibleRanges) {
1514
- highlightTree(this.tree, highlighters, (from, to, style) => {
1515
- builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
1516
- }, from, to);
1517
- }
1518
- return builder.finish();
1519
- }
1520
- }
1521
- const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
1522
- decorations: v => v.decorations
1523
- }));
1524
- /**
1525
- A default highlight style (works well with light themes).
1526
- */
1527
- const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
1528
- { tag: tags.meta,
1529
- color: "#404740" },
1530
- { tag: tags.link,
1531
- textDecoration: "underline" },
1532
- { tag: tags.heading,
1533
- textDecoration: "underline",
1534
- fontWeight: "bold" },
1535
- { tag: tags.emphasis,
1536
- fontStyle: "italic" },
1537
- { tag: tags.strong,
1538
- fontWeight: "bold" },
1539
- { tag: tags.strikethrough,
1540
- textDecoration: "line-through" },
1541
- { tag: tags.keyword,
1542
- color: "#708" },
1543
- { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
1544
- color: "#219" },
1545
- { tag: [tags.literal, tags.inserted],
1546
- color: "#164" },
1547
- { tag: [tags.string, tags.deleted],
1548
- color: "#a11" },
1549
- { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
1550
- color: "#e40" },
1551
- { tag: /*@__PURE__*/tags.definition(tags.variableName),
1552
- color: "#00f" },
1553
- { tag: /*@__PURE__*/tags.local(tags.variableName),
1554
- color: "#30a" },
1555
- { tag: [tags.typeName, tags.namespace],
1556
- color: "#085" },
1557
- { tag: tags.className,
1558
- color: "#167" },
1559
- { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
1560
- color: "#256" },
1561
- { tag: /*@__PURE__*/tags.definition(tags.propertyName),
1562
- color: "#00c" },
1563
- { tag: tags.comment,
1564
- color: "#940" },
1565
- { tag: tags.invalid,
1566
- color: "#f00" }
1567
- ]);
1568
-
1569
- const baseTheme = /*@__PURE__*/EditorView.baseTheme({
1570
- "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
1571
- "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
1572
- });
1573
- const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
1574
- const bracketMatchingConfig = /*@__PURE__*/Facet.define({
1575
- combine(configs) {
1576
- return combineConfig(configs, {
1577
- afterCursor: true,
1578
- brackets: DefaultBrackets,
1579
- maxScanDistance: DefaultScanDist,
1580
- renderMatch: defaultRenderMatch
1581
- });
1582
- }
1583
- });
1584
- const matchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-nonmatchingBracket" });
1585
- function defaultRenderMatch(match) {
1586
- let decorations = [];
1587
- let mark = match.matched ? matchingMark : nonmatchingMark;
1588
- decorations.push(mark.range(match.start.from, match.start.to));
1589
- if (match.end)
1590
- decorations.push(mark.range(match.end.from, match.end.to));
1591
- return decorations;
1592
- }
1593
- const bracketMatchingState = /*@__PURE__*/StateField.define({
1594
- create() { return Decoration.none; },
1595
- update(deco, tr) {
1596
- if (!tr.docChanged && !tr.selection)
1597
- return deco;
1598
- let decorations = [];
1599
- let config = tr.state.facet(bracketMatchingConfig);
1600
- for (let range of tr.state.selection.ranges) {
1601
- if (!range.empty)
1602
- continue;
1603
- let match = matchBrackets(tr.state, range.head, -1, config)
1604
- || (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))
1605
- || (config.afterCursor &&
1606
- (matchBrackets(tr.state, range.head, 1, config) ||
1607
- (range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));
1608
- if (match)
1609
- decorations = decorations.concat(config.renderMatch(match, tr.state));
1610
- }
1611
- return Decoration.set(decorations, true);
1612
- },
1613
- provide: f => EditorView.decorations.from(f)
1614
- });
1615
- const bracketMatchingUnique = [
1616
- bracketMatchingState,
1617
- baseTheme
1618
- ];
1619
- /**
1620
- Create an extension that enables bracket matching. Whenever the
1621
- cursor is next to a bracket, that bracket and the one it matches
1622
- are highlighted. Or, when no matching bracket is found, another
1623
- highlighting style is used to indicate this.
1624
- */
1625
- function bracketMatching(config = {}) {
1626
- return [bracketMatchingConfig.of(config), bracketMatchingUnique];
1627
- }
1628
- /**
1629
- When larger syntax nodes, such as HTML tags, are marked as
1630
- opening/closing, it can be a bit messy to treat the whole node as
1631
- a matchable bracket. This node prop allows you to define, for such
1632
- a node, a ‘handle’—the part of the node that is highlighted, and
1633
- that the cursor must be on to activate highlighting in the first
1634
- place.
1635
- */
1636
- const bracketMatchingHandle = /*@__PURE__*/new NodeProp();
1637
- function matchingNodes(node, dir, brackets) {
1638
- let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);
1639
- if (byProp)
1640
- return byProp;
1641
- if (node.name.length == 1) {
1642
- let index = brackets.indexOf(node.name);
1643
- if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
1644
- return [brackets[index + dir]];
1645
- }
1646
- return null;
1647
- }
1648
- function findHandle(node) {
1649
- let hasHandle = node.type.prop(bracketMatchingHandle);
1650
- return hasHandle ? hasHandle(node.node) : node;
1651
- }
1652
- /**
1653
- Find the matching bracket for the token at `pos`, scanning
1654
- direction `dir`. Only the `brackets` and `maxScanDistance`
1655
- properties are used from `config`, if given. Returns null if no
1656
- bracket was found at `pos`, or a match result otherwise.
1657
- */
1658
- function matchBrackets(state, pos, dir, config = {}) {
1659
- let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
1660
- let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);
1661
- for (let cur = node; cur; cur = cur.parent) {
1662
- let matches = matchingNodes(cur.type, dir, brackets);
1663
- if (matches && cur.from < cur.to) {
1664
- let handle = findHandle(cur);
1665
- if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))
1666
- return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);
1667
- }
1668
- }
1669
- return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
1670
- }
1671
- function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {
1672
- let parent = token.parent, firstToken = { from: handle.from, to: handle.to };
1673
- let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
1674
- if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
1675
- do {
1676
- if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
1677
- if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
1678
- let endHandle = findHandle(cursor);
1679
- return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };
1680
- }
1681
- else if (matchingNodes(cursor.type, dir, brackets)) {
1682
- depth++;
1683
- }
1684
- else if (matchingNodes(cursor.type, -dir, brackets)) {
1685
- if (depth == 0) {
1686
- let endHandle = findHandle(cursor);
1687
- return {
1688
- start: firstToken,
1689
- end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,
1690
- matched: false
1691
- };
1692
- }
1693
- depth--;
1694
- }
1695
- }
1696
- } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
1697
- return { start: firstToken, matched: false };
1698
- }
1699
- function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
1700
- let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
1701
- let bracket = brackets.indexOf(startCh);
1702
- if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
1703
- return null;
1704
- let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
1705
- let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
1706
- for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
1707
- let text = iter.value;
1708
- if (dir < 0)
1709
- distance += text.length;
1710
- let basePos = pos + distance * dir;
1711
- for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
1712
- let found = brackets.indexOf(text[pos]);
1713
- if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)
1714
- continue;
1715
- if ((found % 2 == 0) == (dir > 0)) {
1716
- depth++;
1717
- }
1718
- else if (depth == 1) { // Closing
1719
- return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
1720
- }
1721
- else {
1722
- depth--;
1723
- }
1724
- }
1725
- if (dir > 0)
1726
- distance += text.length;
1727
- }
1728
- return iter.done ? { start: startToken, matched: false } : null;
1729
- }
1730
723
  const noTokens = /*@__PURE__*/Object.create(null);
1731
724
  const typeArray = [NodeType.none];
1732
725
  const warned = [];
@@ -1794,5 +787,5 @@ function createTokenType(extra, tagStr) {
1794
787
  return type.id;
1795
788
  }
1796
789
 
1797
- export { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageSupport, ParseContext, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, getIndentUnit, getIndentation, indentNodeProp, indentOnInput, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxTree, unfoldAll, unfoldCode, unfoldEffect };
790
+ export { DocInput, LRLanguage, Language, LanguageSupport, ParseContext, continuedIndent, defineLanguageFacet, foldInside, foldNodeProp, getIndentUnit, indentNodeProp, indentString, indentUnit, language, languageDataProp, sublanguageProp, syntaxTree };
1798
791
  //# sourceMappingURL=index.js.map