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