@axdspub/axiom-ui-forms 0.2.8 → 0.2.9
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/library/axiom-ui-forms.d.ts +36 -4
- package/library/esm/_virtual/index10.js +2 -2
- package/library/esm/_virtual/index11.js +2 -2
- package/library/esm/_virtual/index12.js +6 -2
- package/library/esm/_virtual/index12.js.map +1 -1
- package/library/esm/_virtual/index13.js +6 -2
- package/library/esm/_virtual/index13.js.map +1 -1
- package/library/esm/_virtual/index14.js +2 -2
- package/library/esm/_virtual/index15.js +4 -0
- package/library/esm/_virtual/index15.js.map +1 -0
- package/library/esm/_virtual/index16.js +4 -0
- package/library/esm/_virtual/index16.js.map +1 -0
- package/library/esm/_virtual/index17.js +4 -0
- package/library/esm/_virtual/index17.js.map +1 -0
- package/library/esm/_virtual/index6.js +2 -2
- package/library/esm/_virtual/index6.js.map +1 -1
- package/library/esm/_virtual/index7.js +2 -2
- package/library/esm/_virtual/index7.js.map +1 -1
- package/library/esm/_virtual/index8.js +2 -2
- package/library/esm/_virtual/index9.js +2 -2
- package/library/esm/_virtual/utilities.js +4 -0
- package/library/esm/_virtual/utilities.js.map +1 -0
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js +241 -9
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js.map +1 -1
- package/library/esm/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/extends.js.map +1 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js.map +1 -0
- package/library/esm/node_modules/@codemirror/autocomplete/dist/index.js +1652 -0
- package/library/esm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/commands/dist/index.js +1444 -0
- package/library/esm/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lang-json/dist/index.js +33 -0
- package/library/esm/node_modules/@codemirror/lang-json/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lang-yaml/dist/index.js +59 -0
- package/library/esm/node_modules/@codemirror/lang-yaml/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/language/dist/index.js +1821 -0
- package/library/esm/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lint/dist/index.js +589 -0
- package/library/esm/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/search/dist/index.js +1227 -0
- package/library/esm/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/state/dist/index.js +3882 -0
- package/library/esm/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/theme-one-dark/dist/index.js +114 -0
- package/library/esm/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/view/dist/index.js +11052 -0
- package/library/esm/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/common/dist/index.js +1704 -0
- package/library/esm/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/highlight/dist/index.js +876 -0
- package/library/esm/node_modules/@lezer/highlight/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/json/dist/index.js +38 -0
- package/library/esm/node_modules/@lezer/json/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/lr/dist/index.js +1855 -0
- package/library/esm/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/yaml/dist/index.js +392 -0
- package/library/esm/node_modules/@lezer/yaml/dist/index.js.map +1 -0
- package/library/esm/node_modules/@marijn/find-cluster-break/src/index.js +83 -0
- package/library/esm/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -0
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js +67 -1
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js.map +1 -1
- package/library/esm/node_modules/@uiw/codemirror-extensions-basic-setup/esm/index.js +100 -0
- package/library/esm/node_modules/@uiw/codemirror-extensions-basic-setup/esm/index.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/getDefaultExtensions.js +58 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/getDefaultExtensions.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/index.js +89 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/index.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/theme/light.js +12 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/theme/light.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/useCodeMirror.js +151 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/useCodeMirror.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/utils.js +19 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/utils.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/deserialize.js +77 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/deserialize.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/index.js +25 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/index.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/serialize.js +159 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/serialize.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/types.js +14 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/types.js.map +1 -0
- package/library/esm/node_modules/ajv/dist/compile/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/validation/index.js +1 -1
- package/library/esm/node_modules/bail/index.js +15 -0
- package/library/esm/node_modules/bail/index.js.map +1 -0
- package/library/esm/node_modules/comma-separated-tokens/index.js +37 -0
- package/library/esm/node_modules/comma-separated-tokens/index.js.map +1 -0
- package/library/esm/node_modules/crelt/index.js +30 -0
- package/library/esm/node_modules/crelt/index.js.map +1 -0
- package/library/esm/node_modules/decode-named-character-reference/index.dom.js +39 -0
- package/library/esm/node_modules/decode-named-character-reference/index.dom.js.map +1 -0
- package/library/esm/node_modules/devlop/lib/default.js +6 -0
- package/library/esm/node_modules/devlop/lib/default.js.map +1 -0
- package/library/esm/node_modules/estree-util-is-identifier-name/lib/index.js +31 -0
- package/library/esm/node_modules/estree-util-is-identifier-name/lib/index.js.map +1 -0
- package/library/esm/node_modules/extend/index.js +127 -0
- package/library/esm/node_modules/extend/index.js.map +1 -0
- package/library/esm/node_modules/fast-uri/index.js +1 -1
- package/library/esm/node_modules/hast-util-to-jsx-runtime/lib/index.js +791 -0
- package/library/esm/node_modules/hast-util-to-jsx-runtime/lib/index.js.map +1 -0
- package/library/esm/node_modules/hast-util-whitespace/lib/index.js +37 -0
- package/library/esm/node_modules/hast-util-whitespace/lib/index.js.map +1 -0
- package/library/esm/node_modules/html-url-attributes/lib/index.js +34 -0
- package/library/esm/node_modules/html-url-attributes/lib/index.js.map +1 -0
- package/library/esm/node_modules/inline-style-parser/index.js +268 -0
- package/library/esm/node_modules/inline-style-parser/index.js.map +1 -0
- package/library/esm/node_modules/js-yaml/dist/js-yaml.js +3850 -0
- package/library/esm/node_modules/js-yaml/dist/js-yaml.js.map +1 -0
- package/library/esm/node_modules/json-schema-traverse/index.js +1 -1
- package/library/esm/node_modules/mdast-util-from-markdown/lib/index.js +1181 -0
- package/library/esm/node_modules/mdast-util-from-markdown/lib/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/footer.js +197 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/footer.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/break.js +27 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/break.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/code.js +51 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/code.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/delete.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/delete.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js +74 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/heading.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/heading.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/html.js +32 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/html.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js +45 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image.js +40 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/index.js +67 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js +36 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js +50 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link.js +41 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list-item.js +126 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list-item.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list.js +57 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/root.js +27 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/root.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/strong.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/strong.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js +33 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-row.js +70 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-row.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table.js +65 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/text.js +29 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/text.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/index.js +105 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/revert.js +56 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/revert.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/state.js +322 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/state.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-string/lib/index.js +111 -0
- package/library/esm/node_modules/mdast-util-to-string/lib/index.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/constructs.js +108 -0
- package/library/esm/node_modules/micromark/lib/constructs.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/create-tokenizer.js +576 -0
- package/library/esm/node_modules/micromark/lib/create-tokenizer.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/content.js +83 -0
- package/library/esm/node_modules/micromark/lib/initialize/content.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/document.js +361 -0
- package/library/esm/node_modules/micromark/lib/initialize/document.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/flow.js +62 -0
- package/library/esm/node_modules/micromark/lib/initialize/flow.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/text.js +213 -0
- package/library/esm/node_modules/micromark/lib/initialize/text.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/parse.js +60 -0
- package/library/esm/node_modules/micromark/lib/parse.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/postprocess.js +22 -0
- package/library/esm/node_modules/micromark/lib/postprocess.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/preprocess.js +118 -0
- package/library/esm/node_modules/micromark/lib/preprocess.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/attention.js +245 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/attention.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/autolink.js +237 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/autolink.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/blank-line.js +65 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/blank-line.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/block-quote.js +147 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/block-quote.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-escape.js +68 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-escape.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-reference.js +153 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-reference.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-fenced.js +464 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-fenced.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-indented.js +181 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-indented.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-text.js +228 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-text.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/content.js +167 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/content.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/definition.js +258 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/definition.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/hard-break-escape.js +64 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/hard-break-escape.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/heading-atx.js +199 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/heading-atx.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-flow.js +880 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-flow.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-text.js +682 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-text.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-end.js +564 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-end.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-image.js +106 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-image.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-link.js +59 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-link.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/line-ending.js +36 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/line-ending.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/list.js +217 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/list.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/setext-underline.js +189 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/setext-underline.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/thematic-break.js +106 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/thematic-break.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-destination/index.js +210 -0
- package/library/esm/node_modules/micromark-factory-destination/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-label/index.js +152 -0
- package/library/esm/node_modules/micromark-factory-label/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-space/index.js +68 -0
- package/library/esm/node_modules/micromark-factory-space/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-title/index.js +162 -0
- package/library/esm/node_modules/micromark-factory-title/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-whitespace/index.js +48 -0
- package/library/esm/node_modules/micromark-factory-whitespace/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-character/index.js +249 -0
- package/library/esm/node_modules/micromark-util-character/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-chunked/index.js +84 -0
- package/library/esm/node_modules/micromark-util-chunked/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-classify-character/index.js +31 -0
- package/library/esm/node_modules/micromark-util-classify-character/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-combine-extensions/index.js +96 -0
- package/library/esm/node_modules/micromark-util-combine-extensions/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-decode-numeric-character-reference/index.js +35 -0
- package/library/esm/node_modules/micromark-util-decode-numeric-character-reference/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-decode-string/index.js +49 -0
- package/library/esm/node_modules/micromark-util-decode-string/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-html-tag-name/index.js +96 -0
- package/library/esm/node_modules/micromark-util-html-tag-name/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-normalize-identifier/index.js +36 -0
- package/library/esm/node_modules/micromark-util-normalize-identifier/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-resolve-all/index.js +35 -0
- package/library/esm/node_modules/micromark-util-resolve-all/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-sanitize-uri/index.js +67 -0
- package/library/esm/node_modules/micromark-util-sanitize-uri/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-subtokenize/index.js +227 -0
- package/library/esm/node_modules/micromark-util-subtokenize/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-subtokenize/lib/splice-buffer.js +254 -0
- package/library/esm/node_modules/micromark-util-subtokenize/lib/splice-buffer.js.map +1 -0
- package/library/esm/node_modules/property-information/index.js +16 -0
- package/library/esm/node_modules/property-information/index.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/aria.js +64 -0
- package/library/esm/node_modules/property-information/lib/aria.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/find.js +101 -0
- package/library/esm/node_modules/property-information/lib/find.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/hast-to-react.js +33 -0
- package/library/esm/node_modules/property-information/lib/hast-to-react.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/html.js +318 -0
- package/library/esm/node_modules/property-information/lib/html.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/normalize.js +15 -0
- package/library/esm/node_modules/property-information/lib/normalize.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/svg.js +564 -0
- package/library/esm/node_modules/property-information/lib/svg.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/case-insensitive-transform.js +16 -0
- package/library/esm/node_modules/property-information/lib/util/case-insensitive-transform.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
- package/library/esm/node_modules/property-information/lib/util/case-sensitive-transform.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/create.js +47 -0
- package/library/esm/node_modules/property-information/lib/util/create.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/defined-info.js +64 -0
- package/library/esm/node_modules/property-information/lib/util/defined-info.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/info.js +35 -0
- package/library/esm/node_modules/property-information/lib/util/info.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/merge.js +31 -0
- package/library/esm/node_modules/property-information/lib/util/merge.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/schema.js +32 -0
- package/library/esm/node_modules/property-information/lib/util/schema.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/types.js +16 -0
- package/library/esm/node_modules/property-information/lib/util/types.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xlink.js +20 -0
- package/library/esm/node_modules/property-information/lib/xlink.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xml.js +12 -0
- package/library/esm/node_modules/property-information/lib/xml.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xmlns.js +12 -0
- package/library/esm/node_modules/property-information/lib/xmlns.js.map +1 -0
- package/library/esm/node_modules/react-markdown/lib/index.js +267 -0
- package/library/esm/node_modules/react-markdown/lib/index.js.map +1 -0
- package/library/esm/node_modules/react-router/dist/development/chunk-HA7DTUK3.js +1 -1
- package/library/esm/node_modules/react-router/node_modules/cookie/dist/index.js +1 -1
- package/library/esm/node_modules/remark-parse/lib/index.js +43 -0
- package/library/esm/node_modules/remark-parse/lib/index.js.map +1 -0
- package/library/esm/node_modules/remark-rehype/lib/index.js +132 -0
- package/library/esm/node_modules/remark-rehype/lib/index.js.map +1 -0
- package/library/esm/node_modules/space-separated-tokens/index.js +23 -0
- package/library/esm/node_modules/space-separated-tokens/index.js.map +1 -0
- package/library/esm/node_modules/style-mod/src/style-mod.js +175 -0
- package/library/esm/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/library/esm/node_modules/style-to-js/cjs/index.js +38 -0
- package/library/esm/node_modules/style-to-js/cjs/index.js.map +1 -0
- package/library/esm/node_modules/style-to-js/cjs/utilities.js +58 -0
- package/library/esm/node_modules/style-to-js/cjs/utilities.js.map +1 -0
- package/library/esm/node_modules/style-to-object/cjs/index.js +56 -0
- package/library/esm/node_modules/style-to-object/cjs/index.js.map +1 -0
- package/library/esm/node_modules/trim-lines/index.js +72 -0
- package/library/esm/node_modules/trim-lines/index.js.map +1 -0
- package/library/esm/node_modules/trough/lib/index.js +209 -0
- package/library/esm/node_modules/trough/lib/index.js.map +1 -0
- package/library/esm/node_modules/unified/lib/callable-instance.js +47 -0
- package/library/esm/node_modules/unified/lib/callable-instance.js.map +1 -0
- package/library/esm/node_modules/unified/lib/index.js +979 -0
- package/library/esm/node_modules/unified/lib/index.js.map +1 -0
- package/library/esm/node_modules/unified/node_modules/is-plain-obj/index.js +11 -0
- package/library/esm/node_modules/unified/node_modules/is-plain-obj/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-is/lib/index.js +179 -0
- package/library/esm/node_modules/unist-util-is/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-position/lib/index.js +98 -0
- package/library/esm/node_modules/unist-util-position/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-stringify-position/lib/index.js +87 -0
- package/library/esm/node_modules/unist-util-stringify-position/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit/lib/index.js +95 -0
- package/library/esm/node_modules/unist-util-visit/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/color.js +10 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/color.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/index.js +188 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/index.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/index.js +644 -0
- package/library/esm/node_modules/vfile/lib/index.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minpath.browser.js +427 -0
- package/library/esm/node_modules/vfile/lib/minpath.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minproc.browser.js +11 -0
- package/library/esm/node_modules/vfile/lib/minproc.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minurl.browser.js +77 -0
- package/library/esm/node_modules/vfile/lib/minurl.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minurl.shared.js +34 -0
- package/library/esm/node_modules/vfile/lib/minurl.shared.js.map +1 -0
- package/library/esm/node_modules/vfile-message/lib/index.js +305 -0
- package/library/esm/node_modules/vfile-message/lib/index.js.map +1 -0
- package/library/esm/node_modules/w3c-keyname/index.js +122 -0
- package/library/esm/node_modules/w3c-keyname/index.js.map +1 -0
- package/library/esm/src/Form/Components/FieldLabel.js +13 -3
- package/library/esm/src/Form/Components/FieldLabel.js.map +1 -1
- package/library/esm/src/Form/Components/InlineMarkdown.js +15 -0
- package/library/esm/src/Form/Components/InlineMarkdown.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/Boolean.js +5 -2
- package/library/esm/src/Form/Components/Inputs/Boolean.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeoJSONInputLoader.js +1 -1
- package/library/esm/src/Form/Components/Inputs/Geometry.js +290 -329
- package/library/esm/src/Form/Components/Inputs/Geometry.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/JSON.js +132 -0
- package/library/esm/src/Form/Components/Inputs/JSON.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/JSONInputLoader.js +19 -0
- package/library/esm/src/Form/Components/Inputs/JSONInputLoader.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/Number.js +78 -8
- package/library/esm/src/Form/Components/Inputs/Number.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/inputMap.js +2 -2
- package/library/esm/src/Form/Components/Inputs/inputMap.js.map +1 -1
- package/library/esm/src/Form/Creator/FormCreator.js +6 -2
- package/library/esm/src/Form/Creator/FormCreator.js.map +1 -1
- package/library/esm/src/Form/Creator/FormHeader.js +7 -5
- package/library/esm/src/Form/Creator/FormHeader.js.map +1 -1
- package/library/esm/src/Form/Creator/Page.js +4 -3
- package/library/esm/src/Form/Creator/Page.js.map +1 -1
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js +41 -0
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js.map +1 -0
- package/library/esm/src/Form/helpers.js +1 -1
- package/library/esm/src/Form/helpers.js.map +1 -1
- package/library/esm/src/Form/schemaToFormHelpers.js +87 -1
- package/library/esm/src/Form/schemaToFormHelpers.js.map +1 -1
- package/library/esm/src/library.js +1 -1
- package/package.json +7 -1
- package/library/esm/src/Form/Components/Inputs/JSONString.js +0 -34
- package/library/esm/src/Form/Components/Inputs/JSONString.js.map +0 -1
@@ -0,0 +1,1821 @@
|
|
1
|
+
import { NodeProp, Tree, IterMode, TreeFragment, Parser, NodeType } from '../../../@lezer/common/dist/index.js';
|
2
|
+
import { EditorState, Facet, Prec, StateEffect, StateField, RangeSetBuilder, countColumn, combineConfig, RangeSet } from '../../state/dist/index.js';
|
3
|
+
import { EditorView, ViewPlugin, gutter, logException, Decoration, GutterMarker, WidgetType, Direction } from '../../view/dist/index.js';
|
4
|
+
import { tagHighlighter, tags, highlightTree, styleTags } from '../../../@lezer/highlight/dist/index.js';
|
5
|
+
import { StyleModule } from '../../../style-mod/src/style-mod.js';
|
6
|
+
|
7
|
+
var _a;
|
8
|
+
/**
|
9
|
+
Node prop stored in a parser's top syntax node to provide the
|
10
|
+
facet that stores language-specific data for that language.
|
11
|
+
*/
|
12
|
+
const languageDataProp = /*@__PURE__*/new NodeProp();
|
13
|
+
/**
|
14
|
+
Helper function to define a facet (to be added to the top syntax
|
15
|
+
node(s) for a language via
|
16
|
+
[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
|
17
|
+
used to associate language data with the language. You
|
18
|
+
probably only need this when subclassing
|
19
|
+
[`Language`](https://codemirror.net/6/docs/ref/#language.Language).
|
20
|
+
*/
|
21
|
+
function defineLanguageFacet(baseData) {
|
22
|
+
return Facet.define({
|
23
|
+
combine: baseData ? values => values.concat(baseData) : undefined
|
24
|
+
});
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
Syntax node prop used to register sublanguages. Should be added to
|
28
|
+
the top level node type for the language.
|
29
|
+
*/
|
30
|
+
const sublanguageProp = /*@__PURE__*/new NodeProp();
|
31
|
+
/**
|
32
|
+
A language object manages parsing and per-language
|
33
|
+
[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
|
34
|
+
managed as a [Lezer](https://lezer.codemirror.net) tree. The class
|
35
|
+
can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
|
36
|
+
subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
|
37
|
+
via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
|
38
|
+
for stream parsers.
|
39
|
+
*/
|
40
|
+
class Language {
|
41
|
+
/**
|
42
|
+
Construct a language object. If you need to invoke this
|
43
|
+
directly, first define a data facet with
|
44
|
+
[`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
|
45
|
+
configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
|
46
|
+
to the language's outer syntax node.
|
47
|
+
*/
|
48
|
+
constructor(
|
49
|
+
/**
|
50
|
+
The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
|
51
|
+
used for this language.
|
52
|
+
*/
|
53
|
+
data, parser, extraExtensions = [],
|
54
|
+
/**
|
55
|
+
A language name.
|
56
|
+
*/
|
57
|
+
name = "") {
|
58
|
+
this.data = data;
|
59
|
+
this.name = name;
|
60
|
+
// Kludge to define EditorState.tree as a debugging helper,
|
61
|
+
// without the EditorState package actually knowing about
|
62
|
+
// languages and lezer trees.
|
63
|
+
if (!EditorState.prototype.hasOwnProperty("tree"))
|
64
|
+
Object.defineProperty(EditorState.prototype, "tree", { get() { return syntaxTree(this); } });
|
65
|
+
this.parser = parser;
|
66
|
+
this.extension = [
|
67
|
+
language.of(this),
|
68
|
+
EditorState.languageData.of((state, pos, side) => {
|
69
|
+
let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);
|
70
|
+
if (!data)
|
71
|
+
return [];
|
72
|
+
let base = state.facet(data), sub = top.type.prop(sublanguageProp);
|
73
|
+
if (sub) {
|
74
|
+
let innerNode = top.resolve(pos - top.from, side);
|
75
|
+
for (let sublang of sub)
|
76
|
+
if (sublang.test(innerNode, state)) {
|
77
|
+
let data = state.facet(sublang.facet);
|
78
|
+
return sublang.type == "replace" ? data : data.concat(base);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
return base;
|
82
|
+
})
|
83
|
+
].concat(extraExtensions);
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
Query whether this language is active at the given position.
|
87
|
+
*/
|
88
|
+
isActiveAt(state, pos, side = -1) {
|
89
|
+
return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
Find the document regions that were parsed using this language.
|
93
|
+
The returned regions will _include_ any nested languages rooted
|
94
|
+
in this language, when those exist.
|
95
|
+
*/
|
96
|
+
findRegions(state) {
|
97
|
+
let lang = state.facet(language);
|
98
|
+
if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
|
99
|
+
return [{ from: 0, to: state.doc.length }];
|
100
|
+
if (!lang || !lang.allowsNesting)
|
101
|
+
return [];
|
102
|
+
let result = [];
|
103
|
+
let explore = (tree, from) => {
|
104
|
+
if (tree.prop(languageDataProp) == this.data) {
|
105
|
+
result.push({ from, to: from + tree.length });
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
let mount = tree.prop(NodeProp.mounted);
|
109
|
+
if (mount) {
|
110
|
+
if (mount.tree.prop(languageDataProp) == this.data) {
|
111
|
+
if (mount.overlay)
|
112
|
+
for (let r of mount.overlay)
|
113
|
+
result.push({ from: r.from + from, to: r.to + from });
|
114
|
+
else
|
115
|
+
result.push({ from: from, to: from + tree.length });
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
else if (mount.overlay) {
|
119
|
+
let size = result.length;
|
120
|
+
explore(mount.tree, mount.overlay[0].from + from);
|
121
|
+
if (result.length > size)
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
for (let i = 0; i < tree.children.length; i++) {
|
126
|
+
let ch = tree.children[i];
|
127
|
+
if (ch instanceof Tree)
|
128
|
+
explore(ch, tree.positions[i] + from);
|
129
|
+
}
|
130
|
+
};
|
131
|
+
explore(syntaxTree(state), 0);
|
132
|
+
return result;
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
Indicates whether this language allows nested languages. The
|
136
|
+
default implementation returns true.
|
137
|
+
*/
|
138
|
+
get allowsNesting() { return true; }
|
139
|
+
}
|
140
|
+
/**
|
141
|
+
@internal
|
142
|
+
*/
|
143
|
+
Language.setState = /*@__PURE__*/StateEffect.define();
|
144
|
+
function topNodeAt(state, pos, side) {
|
145
|
+
let topLang = state.facet(language), tree = syntaxTree(state).topNode;
|
146
|
+
if (!topLang || topLang.allowsNesting) {
|
147
|
+
for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))
|
148
|
+
if (node.type.isTop)
|
149
|
+
tree = node;
|
150
|
+
}
|
151
|
+
return tree;
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
155
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
156
|
+
parsers.
|
157
|
+
*/
|
158
|
+
class LRLanguage extends Language {
|
159
|
+
constructor(data, parser, name) {
|
160
|
+
super(data, parser, [], name);
|
161
|
+
this.parser = parser;
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
Define a language from a parser.
|
165
|
+
*/
|
166
|
+
static define(spec) {
|
167
|
+
let data = defineLanguageFacet(spec.languageData);
|
168
|
+
return new LRLanguage(data, spec.parser.configure({
|
169
|
+
props: [languageDataProp.add(type => type.isTop ? data : undefined)]
|
170
|
+
}), spec.name);
|
171
|
+
}
|
172
|
+
/**
|
173
|
+
Create a new instance of this language with a reconfigured
|
174
|
+
version of its parser and optionally a new name.
|
175
|
+
*/
|
176
|
+
configure(options, name) {
|
177
|
+
return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
|
178
|
+
}
|
179
|
+
get allowsNesting() { return this.parser.hasWrappers(); }
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
Get the syntax tree for a state, which is the current (possibly
|
183
|
+
incomplete) parse tree of the active
|
184
|
+
[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
|
185
|
+
language available.
|
186
|
+
*/
|
187
|
+
function syntaxTree(state) {
|
188
|
+
let field = state.field(Language.state, false);
|
189
|
+
return field ? field.tree : Tree.empty;
|
190
|
+
}
|
191
|
+
/**
|
192
|
+
Lezer-style
|
193
|
+
[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
|
194
|
+
object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
|
195
|
+
*/
|
196
|
+
class DocInput {
|
197
|
+
/**
|
198
|
+
Create an input object for the given document.
|
199
|
+
*/
|
200
|
+
constructor(doc) {
|
201
|
+
this.doc = doc;
|
202
|
+
this.cursorPos = 0;
|
203
|
+
this.string = "";
|
204
|
+
this.cursor = doc.iter();
|
205
|
+
}
|
206
|
+
get length() { return this.doc.length; }
|
207
|
+
syncTo(pos) {
|
208
|
+
this.string = this.cursor.next(pos - this.cursorPos).value;
|
209
|
+
this.cursorPos = pos + this.string.length;
|
210
|
+
return this.cursorPos - this.string.length;
|
211
|
+
}
|
212
|
+
chunk(pos) {
|
213
|
+
this.syncTo(pos);
|
214
|
+
return this.string;
|
215
|
+
}
|
216
|
+
get lineChunks() { return true; }
|
217
|
+
read(from, to) {
|
218
|
+
let stringStart = this.cursorPos - this.string.length;
|
219
|
+
if (from < stringStart || to >= this.cursorPos)
|
220
|
+
return this.doc.sliceString(from, to);
|
221
|
+
else
|
222
|
+
return this.string.slice(from - stringStart, to - stringStart);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
let currentContext = null;
|
226
|
+
/**
|
227
|
+
A parse context provided to parsers working on the editor content.
|
228
|
+
*/
|
229
|
+
class ParseContext {
|
230
|
+
constructor(parser,
|
231
|
+
/**
|
232
|
+
The current editor state.
|
233
|
+
*/
|
234
|
+
state,
|
235
|
+
/**
|
236
|
+
Tree fragments that can be reused by incremental re-parses.
|
237
|
+
*/
|
238
|
+
fragments = [],
|
239
|
+
/**
|
240
|
+
@internal
|
241
|
+
*/
|
242
|
+
tree,
|
243
|
+
/**
|
244
|
+
@internal
|
245
|
+
*/
|
246
|
+
treeLen,
|
247
|
+
/**
|
248
|
+
The current editor viewport (or some overapproximation
|
249
|
+
thereof). Intended to be used for opportunistically avoiding
|
250
|
+
work (in which case
|
251
|
+
[`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
|
252
|
+
should be called to make sure the parser is restarted when the
|
253
|
+
skipped region becomes visible).
|
254
|
+
*/
|
255
|
+
viewport,
|
256
|
+
/**
|
257
|
+
@internal
|
258
|
+
*/
|
259
|
+
skipped,
|
260
|
+
/**
|
261
|
+
This is where skipping parsers can register a promise that,
|
262
|
+
when resolved, will schedule a new parse. It is cleared when
|
263
|
+
the parse worker picks up the promise. @internal
|
264
|
+
*/
|
265
|
+
scheduleOn) {
|
266
|
+
this.parser = parser;
|
267
|
+
this.state = state;
|
268
|
+
this.fragments = fragments;
|
269
|
+
this.tree = tree;
|
270
|
+
this.treeLen = treeLen;
|
271
|
+
this.viewport = viewport;
|
272
|
+
this.skipped = skipped;
|
273
|
+
this.scheduleOn = scheduleOn;
|
274
|
+
this.parse = null;
|
275
|
+
/**
|
276
|
+
@internal
|
277
|
+
*/
|
278
|
+
this.tempSkipped = [];
|
279
|
+
}
|
280
|
+
/**
|
281
|
+
@internal
|
282
|
+
*/
|
283
|
+
static create(parser, state, viewport) {
|
284
|
+
return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
|
285
|
+
}
|
286
|
+
startParse() {
|
287
|
+
return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
|
288
|
+
}
|
289
|
+
/**
|
290
|
+
@internal
|
291
|
+
*/
|
292
|
+
work(until, upto) {
|
293
|
+
if (upto != null && upto >= this.state.doc.length)
|
294
|
+
upto = undefined;
|
295
|
+
if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
|
296
|
+
this.takeTree();
|
297
|
+
return true;
|
298
|
+
}
|
299
|
+
return this.withContext(() => {
|
300
|
+
var _a;
|
301
|
+
if (typeof until == "number") {
|
302
|
+
let endTime = Date.now() + until;
|
303
|
+
until = () => Date.now() > endTime;
|
304
|
+
}
|
305
|
+
if (!this.parse)
|
306
|
+
this.parse = this.startParse();
|
307
|
+
if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
|
308
|
+
upto < this.state.doc.length)
|
309
|
+
this.parse.stopAt(upto);
|
310
|
+
for (;;) {
|
311
|
+
let done = this.parse.advance();
|
312
|
+
if (done) {
|
313
|
+
this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
|
314
|
+
this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
|
315
|
+
this.tree = done;
|
316
|
+
this.parse = null;
|
317
|
+
if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
|
318
|
+
this.parse = this.startParse();
|
319
|
+
else
|
320
|
+
return true;
|
321
|
+
}
|
322
|
+
if (until())
|
323
|
+
return false;
|
324
|
+
}
|
325
|
+
});
|
326
|
+
}
|
327
|
+
/**
|
328
|
+
@internal
|
329
|
+
*/
|
330
|
+
takeTree() {
|
331
|
+
let pos, tree;
|
332
|
+
if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
|
333
|
+
if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
|
334
|
+
this.parse.stopAt(pos);
|
335
|
+
this.withContext(() => { while (!(tree = this.parse.advance())) { } });
|
336
|
+
this.treeLen = pos;
|
337
|
+
this.tree = tree;
|
338
|
+
this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
|
339
|
+
this.parse = null;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
withContext(f) {
|
343
|
+
let prev = currentContext;
|
344
|
+
currentContext = this;
|
345
|
+
try {
|
346
|
+
return f();
|
347
|
+
}
|
348
|
+
finally {
|
349
|
+
currentContext = prev;
|
350
|
+
}
|
351
|
+
}
|
352
|
+
withoutTempSkipped(fragments) {
|
353
|
+
for (let r; r = this.tempSkipped.pop();)
|
354
|
+
fragments = cutFragments(fragments, r.from, r.to);
|
355
|
+
return fragments;
|
356
|
+
}
|
357
|
+
/**
|
358
|
+
@internal
|
359
|
+
*/
|
360
|
+
changes(changes, newState) {
|
361
|
+
let { fragments, tree, treeLen, viewport, skipped } = this;
|
362
|
+
this.takeTree();
|
363
|
+
if (!changes.empty) {
|
364
|
+
let ranges = [];
|
365
|
+
changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
|
366
|
+
fragments = TreeFragment.applyChanges(fragments, ranges);
|
367
|
+
tree = Tree.empty;
|
368
|
+
treeLen = 0;
|
369
|
+
viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
|
370
|
+
if (this.skipped.length) {
|
371
|
+
skipped = [];
|
372
|
+
for (let r of this.skipped) {
|
373
|
+
let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
|
374
|
+
if (from < to)
|
375
|
+
skipped.push({ from, to });
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
|
380
|
+
}
|
381
|
+
/**
|
382
|
+
@internal
|
383
|
+
*/
|
384
|
+
updateViewport(viewport) {
|
385
|
+
if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
|
386
|
+
return false;
|
387
|
+
this.viewport = viewport;
|
388
|
+
let startLen = this.skipped.length;
|
389
|
+
for (let i = 0; i < this.skipped.length; i++) {
|
390
|
+
let { from, to } = this.skipped[i];
|
391
|
+
if (from < viewport.to && to > viewport.from) {
|
392
|
+
this.fragments = cutFragments(this.fragments, from, to);
|
393
|
+
this.skipped.splice(i--, 1);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
if (this.skipped.length >= startLen)
|
397
|
+
return false;
|
398
|
+
this.reset();
|
399
|
+
return true;
|
400
|
+
}
|
401
|
+
/**
|
402
|
+
@internal
|
403
|
+
*/
|
404
|
+
reset() {
|
405
|
+
if (this.parse) {
|
406
|
+
this.takeTree();
|
407
|
+
this.parse = null;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
/**
|
411
|
+
Notify the parse scheduler that the given region was skipped
|
412
|
+
because it wasn't in view, and the parse should be restarted
|
413
|
+
when it comes into view.
|
414
|
+
*/
|
415
|
+
skipUntilInView(from, to) {
|
416
|
+
this.skipped.push({ from, to });
|
417
|
+
}
|
418
|
+
/**
|
419
|
+
Returns a parser intended to be used as placeholder when
|
420
|
+
asynchronously loading a nested parser. It'll skip its input and
|
421
|
+
mark it as not-really-parsed, so that the next update will parse
|
422
|
+
it again.
|
423
|
+
|
424
|
+
When `until` is given, a reparse will be scheduled when that
|
425
|
+
promise resolves.
|
426
|
+
*/
|
427
|
+
static getSkippingParser(until) {
|
428
|
+
return new class extends Parser {
|
429
|
+
createParse(input, fragments, ranges) {
|
430
|
+
let from = ranges[0].from, to = ranges[ranges.length - 1].to;
|
431
|
+
let parser = {
|
432
|
+
parsedPos: from,
|
433
|
+
advance() {
|
434
|
+
let cx = currentContext;
|
435
|
+
if (cx) {
|
436
|
+
for (let r of ranges)
|
437
|
+
cx.tempSkipped.push(r);
|
438
|
+
if (until)
|
439
|
+
cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
|
440
|
+
}
|
441
|
+
this.parsedPos = to;
|
442
|
+
return new Tree(NodeType.none, [], [], to - from);
|
443
|
+
},
|
444
|
+
stoppedAt: null,
|
445
|
+
stopAt() { }
|
446
|
+
};
|
447
|
+
return parser;
|
448
|
+
}
|
449
|
+
};
|
450
|
+
}
|
451
|
+
/**
|
452
|
+
@internal
|
453
|
+
*/
|
454
|
+
isDone(upto) {
|
455
|
+
upto = Math.min(upto, this.state.doc.length);
|
456
|
+
let frags = this.fragments;
|
457
|
+
return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
|
458
|
+
}
|
459
|
+
/**
|
460
|
+
Get the context for the current parse, or `null` if no editor
|
461
|
+
parse is in progress.
|
462
|
+
*/
|
463
|
+
static get() { return currentContext; }
|
464
|
+
}
|
465
|
+
function cutFragments(fragments, from, to) {
|
466
|
+
return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
|
467
|
+
}
|
468
|
+
class LanguageState {
|
469
|
+
constructor(
|
470
|
+
// A mutable parse state that is used to preserve work done during
|
471
|
+
// the lifetime of a state when moving to the next state.
|
472
|
+
context) {
|
473
|
+
this.context = context;
|
474
|
+
this.tree = context.tree;
|
475
|
+
}
|
476
|
+
apply(tr) {
|
477
|
+
if (!tr.docChanged && this.tree == this.context.tree)
|
478
|
+
return this;
|
479
|
+
let newCx = this.context.changes(tr.changes, tr.state);
|
480
|
+
// If the previous parse wasn't done, go forward only up to its
|
481
|
+
// end position or the end of the viewport, to avoid slowing down
|
482
|
+
// state updates with parse work beyond the viewport.
|
483
|
+
let upto = this.context.treeLen == tr.startState.doc.length ? undefined
|
484
|
+
: Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
|
485
|
+
if (!newCx.work(20 /* Work.Apply */, upto))
|
486
|
+
newCx.takeTree();
|
487
|
+
return new LanguageState(newCx);
|
488
|
+
}
|
489
|
+
static init(state) {
|
490
|
+
let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
|
491
|
+
let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
|
492
|
+
if (!parseState.work(20 /* Work.Apply */, vpTo))
|
493
|
+
parseState.takeTree();
|
494
|
+
return new LanguageState(parseState);
|
495
|
+
}
|
496
|
+
}
|
497
|
+
Language.state = /*@__PURE__*/StateField.define({
|
498
|
+
create: LanguageState.init,
|
499
|
+
update(value, tr) {
|
500
|
+
for (let e of tr.effects)
|
501
|
+
if (e.is(Language.setState))
|
502
|
+
return e.value;
|
503
|
+
if (tr.startState.facet(language) != tr.state.facet(language))
|
504
|
+
return LanguageState.init(tr.state);
|
505
|
+
return value.apply(tr);
|
506
|
+
}
|
507
|
+
});
|
508
|
+
let requestIdle = (callback) => {
|
509
|
+
let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
|
510
|
+
return () => clearTimeout(timeout);
|
511
|
+
};
|
512
|
+
if (typeof requestIdleCallback != "undefined")
|
513
|
+
requestIdle = (callback) => {
|
514
|
+
let idle = -1, timeout = setTimeout(() => {
|
515
|
+
idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
|
516
|
+
}, 100 /* Work.MinPause */);
|
517
|
+
return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
|
518
|
+
};
|
519
|
+
const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
|
520
|
+
? () => navigator.scheduling.isInputPending() : null;
|
521
|
+
const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
|
522
|
+
constructor(view) {
|
523
|
+
this.view = view;
|
524
|
+
this.working = null;
|
525
|
+
this.workScheduled = 0;
|
526
|
+
// End of the current time chunk
|
527
|
+
this.chunkEnd = -1;
|
528
|
+
// Milliseconds of budget left for this chunk
|
529
|
+
this.chunkBudget = -1;
|
530
|
+
this.work = this.work.bind(this);
|
531
|
+
this.scheduleWork();
|
532
|
+
}
|
533
|
+
update(update) {
|
534
|
+
let cx = this.view.state.field(Language.state).context;
|
535
|
+
if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
|
536
|
+
this.scheduleWork();
|
537
|
+
if (update.docChanged || update.selectionSet) {
|
538
|
+
if (this.view.hasFocus)
|
539
|
+
this.chunkBudget += 50 /* Work.ChangeBonus */;
|
540
|
+
this.scheduleWork();
|
541
|
+
}
|
542
|
+
this.checkAsyncSchedule(cx);
|
543
|
+
}
|
544
|
+
scheduleWork() {
|
545
|
+
if (this.working)
|
546
|
+
return;
|
547
|
+
let { state } = this.view, field = state.field(Language.state);
|
548
|
+
if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
|
549
|
+
this.working = requestIdle(this.work);
|
550
|
+
}
|
551
|
+
work(deadline) {
|
552
|
+
this.working = null;
|
553
|
+
let now = Date.now();
|
554
|
+
if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
|
555
|
+
this.chunkEnd = now + 30000 /* Work.ChunkTime */;
|
556
|
+
this.chunkBudget = 3000 /* Work.ChunkBudget */;
|
557
|
+
}
|
558
|
+
if (this.chunkBudget <= 0)
|
559
|
+
return; // No more budget
|
560
|
+
let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
|
561
|
+
if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
|
562
|
+
return;
|
563
|
+
let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
|
564
|
+
let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
|
565
|
+
let done = field.context.work(() => {
|
566
|
+
return isInputPending && isInputPending() || Date.now() > endTime;
|
567
|
+
}, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
|
568
|
+
this.chunkBudget -= Date.now() - now;
|
569
|
+
if (done || this.chunkBudget <= 0) {
|
570
|
+
field.context.takeTree();
|
571
|
+
this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
|
572
|
+
}
|
573
|
+
if (this.chunkBudget > 0 && !(done && !viewportFirst))
|
574
|
+
this.scheduleWork();
|
575
|
+
this.checkAsyncSchedule(field.context);
|
576
|
+
}
|
577
|
+
checkAsyncSchedule(cx) {
|
578
|
+
if (cx.scheduleOn) {
|
579
|
+
this.workScheduled++;
|
580
|
+
cx.scheduleOn
|
581
|
+
.then(() => this.scheduleWork())
|
582
|
+
.catch(err => logException(this.view.state, err))
|
583
|
+
.then(() => this.workScheduled--);
|
584
|
+
cx.scheduleOn = null;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
destroy() {
|
588
|
+
if (this.working)
|
589
|
+
this.working();
|
590
|
+
}
|
591
|
+
isWorking() {
|
592
|
+
return !!(this.working || this.workScheduled > 0);
|
593
|
+
}
|
594
|
+
}, {
|
595
|
+
eventHandlers: { focus() { this.scheduleWork(); } }
|
596
|
+
});
|
597
|
+
/**
|
598
|
+
The facet used to associate a language with an editor state. Used
|
599
|
+
by `Language` object's `extension` property (so you don't need to
|
600
|
+
manually wrap your languages in this). Can be used to access the
|
601
|
+
current language on a state.
|
602
|
+
*/
|
603
|
+
const language = /*@__PURE__*/Facet.define({
|
604
|
+
combine(languages) { return languages.length ? languages[0] : null; },
|
605
|
+
enables: language => [
|
606
|
+
Language.state,
|
607
|
+
parseWorker,
|
608
|
+
EditorView.contentAttributes.compute([language], state => {
|
609
|
+
let lang = state.facet(language);
|
610
|
+
return lang && lang.name ? { "data-language": lang.name } : {};
|
611
|
+
})
|
612
|
+
]
|
613
|
+
});
|
614
|
+
/**
|
615
|
+
This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
|
616
|
+
optional set of supporting extensions. Language packages are
|
617
|
+
encouraged to export a function that optionally takes a
|
618
|
+
configuration object and returns a `LanguageSupport` instance, as
|
619
|
+
the main way for client code to use the package.
|
620
|
+
*/
|
621
|
+
class LanguageSupport {
|
622
|
+
/**
|
623
|
+
Create a language support object.
|
624
|
+
*/
|
625
|
+
constructor(
|
626
|
+
/**
|
627
|
+
The language object.
|
628
|
+
*/
|
629
|
+
language,
|
630
|
+
/**
|
631
|
+
An optional set of supporting extensions. When nesting a
|
632
|
+
language in another language, the outer language is encouraged
|
633
|
+
to include the supporting extensions for its inner languages
|
634
|
+
in its own set of support extensions.
|
635
|
+
*/
|
636
|
+
support = []) {
|
637
|
+
this.language = language;
|
638
|
+
this.support = support;
|
639
|
+
this.extension = [language, support];
|
640
|
+
}
|
641
|
+
}
|
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
|
+
/**
|
654
|
+
Facet for overriding the unit by which indentation happens. Should
|
655
|
+
be a string consisting either entirely of the same whitespace
|
656
|
+
character. When not set, this defaults to 2 spaces.
|
657
|
+
*/
|
658
|
+
const indentUnit = /*@__PURE__*/Facet.define({
|
659
|
+
combine: values => {
|
660
|
+
if (!values.length)
|
661
|
+
return " ";
|
662
|
+
let unit = values[0];
|
663
|
+
if (!unit || /\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))
|
664
|
+
throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
|
665
|
+
return unit;
|
666
|
+
}
|
667
|
+
});
|
668
|
+
/**
|
669
|
+
Return the _column width_ of an indent unit in the state.
|
670
|
+
Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
|
671
|
+
facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
|
672
|
+
contains tabs.
|
673
|
+
*/
|
674
|
+
function getIndentUnit(state) {
|
675
|
+
let unit = state.facet(indentUnit);
|
676
|
+
return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
|
677
|
+
}
|
678
|
+
/**
|
679
|
+
Create an indentation string that covers columns 0 to `cols`.
|
680
|
+
Will use tabs for as much of the columns as possible when the
|
681
|
+
[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
|
682
|
+
tabs.
|
683
|
+
*/
|
684
|
+
function indentString(state, cols) {
|
685
|
+
let result = "", ts = state.tabSize, ch = state.facet(indentUnit)[0];
|
686
|
+
if (ch == "\t") {
|
687
|
+
while (cols >= ts) {
|
688
|
+
result += "\t";
|
689
|
+
cols -= ts;
|
690
|
+
}
|
691
|
+
ch = " ";
|
692
|
+
}
|
693
|
+
for (let i = 0; i < cols; i++)
|
694
|
+
result += ch;
|
695
|
+
return result;
|
696
|
+
}
|
697
|
+
/**
|
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
|
+
A syntax tree node prop used to associate indentation strategies
|
813
|
+
with node types. Such a strategy is a function from an indentation
|
814
|
+
context to a column number (see also
|
815
|
+
[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
|
816
|
+
indicates that no definitive indentation can be determined.
|
817
|
+
*/
|
818
|
+
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 = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
|
823
|
+
if (inner != stack.node) {
|
824
|
+
let add = [];
|
825
|
+
for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); 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
|
+
if (next.from >= lineEnd)
|
950
|
+
return null;
|
951
|
+
let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
|
952
|
+
return { from: openToken.from, to: openToken.to + space };
|
953
|
+
}
|
954
|
+
pos = next.to;
|
955
|
+
}
|
956
|
+
}
|
957
|
+
/**
|
958
|
+
An indentation strategy for delimited (usually bracketed) nodes.
|
959
|
+
Will, by default, indent one unit more than the parent's base
|
960
|
+
indent unless the line starts with a closing token. When `align`
|
961
|
+
is true and there are non-skipped nodes on the node's opening
|
962
|
+
line, the content of the node will be aligned with the end of the
|
963
|
+
opening node, like this:
|
964
|
+
|
965
|
+
foo(bar,
|
966
|
+
baz)
|
967
|
+
*/
|
968
|
+
function delimitedIndent({ closing, align = true, units = 1 }) {
|
969
|
+
return (context) => delimitedStrategy(context, align, units, closing);
|
970
|
+
}
|
971
|
+
function delimitedStrategy(context, align, units, closing, closedAt) {
|
972
|
+
let after = context.textAfter, space = after.match(/^\s*/)[0].length;
|
973
|
+
let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
|
974
|
+
let aligned = align ? bracketedAligned(context) : null;
|
975
|
+
if (aligned)
|
976
|
+
return closed ? context.column(aligned.from) : context.column(aligned.to);
|
977
|
+
return context.baseIndent + (closed ? 0 : context.unit * units);
|
978
|
+
}
|
979
|
+
/**
|
980
|
+
Creates an indentation strategy that, by default, indents
|
981
|
+
continued lines one unit more than the node's base indentation.
|
982
|
+
You can provide `except` to prevent indentation of lines that
|
983
|
+
match a pattern (for example `/^else\b/` in `if`/`else`
|
984
|
+
constructs), and you can change the amount of units used with the
|
985
|
+
`units` option.
|
986
|
+
*/
|
987
|
+
function continuedIndent({ except, units = 1 } = {}) {
|
988
|
+
return (context) => {
|
989
|
+
let matchExcept = except && except.test(context.textAfter);
|
990
|
+
return context.baseIndent + (matchExcept ? 0 : units * context.unit);
|
991
|
+
};
|
992
|
+
}
|
993
|
+
const DontIndentBeyond = 200;
|
994
|
+
/**
|
995
|
+
Enables reindentation on input. When a language defines an
|
996
|
+
`indentOnInput` field in its [language
|
997
|
+
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
|
998
|
+
expression, the line at the cursor will be reindented whenever new
|
999
|
+
text is typed and the input from the start of the line up to the
|
1000
|
+
cursor matches that regexp.
|
1001
|
+
|
1002
|
+
To avoid unneccesary reindents, it is recommended to start the
|
1003
|
+
regexp with `^` (usually followed by `\s*`), and end it with `$`.
|
1004
|
+
For example, `/^\s*\}$/` will reindent when a closing brace is
|
1005
|
+
added at the start of a line.
|
1006
|
+
*/
|
1007
|
+
function indentOnInput() {
|
1008
|
+
return EditorState.transactionFilter.of(tr => {
|
1009
|
+
if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
|
1010
|
+
return tr;
|
1011
|
+
let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
|
1012
|
+
if (!rules.length)
|
1013
|
+
return tr;
|
1014
|
+
let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
|
1015
|
+
if (head > line.from + DontIndentBeyond)
|
1016
|
+
return tr;
|
1017
|
+
let lineStart = doc.sliceString(line.from, head);
|
1018
|
+
if (!rules.some(r => r.test(lineStart)))
|
1019
|
+
return tr;
|
1020
|
+
let { state } = tr, last = -1, changes = [];
|
1021
|
+
for (let { head } of state.selection.ranges) {
|
1022
|
+
let line = state.doc.lineAt(head);
|
1023
|
+
if (line.from == last)
|
1024
|
+
continue;
|
1025
|
+
last = line.from;
|
1026
|
+
let indent = getIndentation(state, line.from);
|
1027
|
+
if (indent == null)
|
1028
|
+
continue;
|
1029
|
+
let cur = /^\s*/.exec(line.text)[0];
|
1030
|
+
let norm = indentString(state, indent);
|
1031
|
+
if (cur != norm)
|
1032
|
+
changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
|
1033
|
+
}
|
1034
|
+
return changes.length ? [tr, { changes, sequential: true }] : tr;
|
1035
|
+
});
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
/**
|
1039
|
+
A facet that registers a code folding service. When called with
|
1040
|
+
the extent of a line, such a function should return a foldable
|
1041
|
+
range that starts on that line (but continues beyond it), if one
|
1042
|
+
can be found.
|
1043
|
+
*/
|
1044
|
+
const foldService = /*@__PURE__*/Facet.define();
|
1045
|
+
/**
|
1046
|
+
This node prop is used to associate folding information with
|
1047
|
+
syntax node types. Given a syntax node, it should check whether
|
1048
|
+
that tree is foldable and return the range that can be collapsed
|
1049
|
+
when it is.
|
1050
|
+
*/
|
1051
|
+
const foldNodeProp = /*@__PURE__*/new NodeProp();
|
1052
|
+
/**
|
1053
|
+
[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
|
1054
|
+
the first and the last child of a syntax node. Useful for nodes
|
1055
|
+
that start and end with delimiters.
|
1056
|
+
*/
|
1057
|
+
function foldInside(node) {
|
1058
|
+
let first = node.firstChild, last = node.lastChild;
|
1059
|
+
return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
|
1060
|
+
}
|
1061
|
+
function syntaxFolding(state, start, end) {
|
1062
|
+
let tree = syntaxTree(state);
|
1063
|
+
if (tree.length < end)
|
1064
|
+
return null;
|
1065
|
+
let stack = tree.resolveStack(end, 1);
|
1066
|
+
let found = null;
|
1067
|
+
for (let iter = stack; iter; iter = iter.next) {
|
1068
|
+
let cur = iter.node;
|
1069
|
+
if (cur.to <= end || cur.from > end)
|
1070
|
+
continue;
|
1071
|
+
if (found && cur.from < start)
|
1072
|
+
break;
|
1073
|
+
let prop = cur.type.prop(foldNodeProp);
|
1074
|
+
if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
|
1075
|
+
let value = prop(cur, state);
|
1076
|
+
if (value && value.from <= end && value.from >= start && value.to > end)
|
1077
|
+
found = value;
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
return found;
|
1081
|
+
}
|
1082
|
+
function isUnfinished(node) {
|
1083
|
+
let ch = node.lastChild;
|
1084
|
+
return ch && ch.to == node.to && ch.type.isError;
|
1085
|
+
}
|
1086
|
+
/**
|
1087
|
+
Check whether the given line is foldable. First asks any fold
|
1088
|
+
services registered through
|
1089
|
+
[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
|
1090
|
+
a result, tries to query the [fold node
|
1091
|
+
prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
|
1092
|
+
of the line.
|
1093
|
+
*/
|
1094
|
+
function foldable(state, lineStart, lineEnd) {
|
1095
|
+
for (let service of state.facet(foldService)) {
|
1096
|
+
let result = service(state, lineStart, lineEnd);
|
1097
|
+
if (result)
|
1098
|
+
return result;
|
1099
|
+
}
|
1100
|
+
return syntaxFolding(state, lineStart, lineEnd);
|
1101
|
+
}
|
1102
|
+
function mapRange(range, mapping) {
|
1103
|
+
let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
|
1104
|
+
return from >= to ? undefined : { from, to };
|
1105
|
+
}
|
1106
|
+
/**
|
1107
|
+
State effect that can be attached to a transaction to fold the
|
1108
|
+
given range. (You probably only need this in exceptional
|
1109
|
+
circumstances—usually you'll just want to let
|
1110
|
+
[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
|
1111
|
+
gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
|
1112
|
+
*/
|
1113
|
+
const foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
|
1114
|
+
/**
|
1115
|
+
State effect that unfolds the given range (if it was folded).
|
1116
|
+
*/
|
1117
|
+
const unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
|
1118
|
+
function selectedLines(view) {
|
1119
|
+
let lines = [];
|
1120
|
+
for (let { head } of view.state.selection.ranges) {
|
1121
|
+
if (lines.some(l => l.from <= head && l.to >= head))
|
1122
|
+
continue;
|
1123
|
+
lines.push(view.lineBlockAt(head));
|
1124
|
+
}
|
1125
|
+
return lines;
|
1126
|
+
}
|
1127
|
+
/**
|
1128
|
+
The state field that stores the folded ranges (as a [decoration
|
1129
|
+
set](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to
|
1130
|
+
[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and
|
1131
|
+
[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold
|
1132
|
+
state.
|
1133
|
+
*/
|
1134
|
+
const foldState = /*@__PURE__*/StateField.define({
|
1135
|
+
create() {
|
1136
|
+
return Decoration.none;
|
1137
|
+
},
|
1138
|
+
update(folded, tr) {
|
1139
|
+
folded = folded.map(tr.changes);
|
1140
|
+
for (let e of tr.effects) {
|
1141
|
+
if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
|
1142
|
+
let { preparePlaceholder } = tr.state.facet(foldConfig);
|
1143
|
+
let widget = !preparePlaceholder ? foldWidget :
|
1144
|
+
Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });
|
1145
|
+
folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });
|
1146
|
+
}
|
1147
|
+
else if (e.is(unfoldEffect)) {
|
1148
|
+
folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
|
1149
|
+
filterFrom: e.value.from, filterTo: e.value.to });
|
1150
|
+
}
|
1151
|
+
}
|
1152
|
+
// Clear folded ranges that cover the selection head
|
1153
|
+
if (tr.selection) {
|
1154
|
+
let onSelection = false, { head } = tr.selection.main;
|
1155
|
+
folded.between(head, head, (a, b) => { if (a < head && b > head)
|
1156
|
+
onSelection = true; });
|
1157
|
+
if (onSelection)
|
1158
|
+
folded = folded.update({
|
1159
|
+
filterFrom: head,
|
1160
|
+
filterTo: head,
|
1161
|
+
filter: (a, b) => b <= head || a >= head
|
1162
|
+
});
|
1163
|
+
}
|
1164
|
+
return folded;
|
1165
|
+
},
|
1166
|
+
provide: f => EditorView.decorations.from(f),
|
1167
|
+
toJSON(folded, state) {
|
1168
|
+
let ranges = [];
|
1169
|
+
folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });
|
1170
|
+
return ranges;
|
1171
|
+
},
|
1172
|
+
fromJSON(value) {
|
1173
|
+
if (!Array.isArray(value) || value.length % 2)
|
1174
|
+
throw new RangeError("Invalid JSON for fold state");
|
1175
|
+
let ranges = [];
|
1176
|
+
for (let i = 0; i < value.length;) {
|
1177
|
+
let from = value[i++], to = value[i++];
|
1178
|
+
if (typeof from != "number" || typeof to != "number")
|
1179
|
+
throw new RangeError("Invalid JSON for fold state");
|
1180
|
+
ranges.push(foldWidget.range(from, to));
|
1181
|
+
}
|
1182
|
+
return Decoration.set(ranges, true);
|
1183
|
+
}
|
1184
|
+
});
|
1185
|
+
function findFold(state, from, to) {
|
1186
|
+
var _a;
|
1187
|
+
let found = null;
|
1188
|
+
(_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {
|
1189
|
+
if (!found || found.from > from)
|
1190
|
+
found = { from, to };
|
1191
|
+
});
|
1192
|
+
return found;
|
1193
|
+
}
|
1194
|
+
function foldExists(folded, from, to) {
|
1195
|
+
let found = false;
|
1196
|
+
folded.between(from, from, (a, b) => { if (a == from && b == to)
|
1197
|
+
found = true; });
|
1198
|
+
return found;
|
1199
|
+
}
|
1200
|
+
function maybeEnable(state, other) {
|
1201
|
+
return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));
|
1202
|
+
}
|
1203
|
+
/**
|
1204
|
+
Fold the lines that are selected, if possible.
|
1205
|
+
*/
|
1206
|
+
const foldCode = view => {
|
1207
|
+
for (let line of selectedLines(view)) {
|
1208
|
+
let range = foldable(view.state, line.from, line.to);
|
1209
|
+
if (range) {
|
1210
|
+
view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
|
1211
|
+
return true;
|
1212
|
+
}
|
1213
|
+
}
|
1214
|
+
return false;
|
1215
|
+
};
|
1216
|
+
/**
|
1217
|
+
Unfold folded ranges on selected lines.
|
1218
|
+
*/
|
1219
|
+
const unfoldCode = view => {
|
1220
|
+
if (!view.state.field(foldState, false))
|
1221
|
+
return false;
|
1222
|
+
let effects = [];
|
1223
|
+
for (let line of selectedLines(view)) {
|
1224
|
+
let folded = findFold(view.state, line.from, line.to);
|
1225
|
+
if (folded)
|
1226
|
+
effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
|
1227
|
+
}
|
1228
|
+
if (effects.length)
|
1229
|
+
view.dispatch({ effects });
|
1230
|
+
return effects.length > 0;
|
1231
|
+
};
|
1232
|
+
function announceFold(view, range, fold = true) {
|
1233
|
+
let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
|
1234
|
+
return EditorView.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
|
1235
|
+
}
|
1236
|
+
/**
|
1237
|
+
Fold all top-level foldable ranges. Note that, in most cases,
|
1238
|
+
folding information will depend on the [syntax
|
1239
|
+
tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
|
1240
|
+
reliably when the document hasn't been fully parsed (either
|
1241
|
+
because the editor state was only just initialized, or because the
|
1242
|
+
document is so big that the parser decided not to parse it
|
1243
|
+
entirely).
|
1244
|
+
*/
|
1245
|
+
const foldAll = view => {
|
1246
|
+
let { state } = view, effects = [];
|
1247
|
+
for (let pos = 0; pos < state.doc.length;) {
|
1248
|
+
let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
|
1249
|
+
if (range)
|
1250
|
+
effects.push(foldEffect.of(range));
|
1251
|
+
pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
|
1252
|
+
}
|
1253
|
+
if (effects.length)
|
1254
|
+
view.dispatch({ effects: maybeEnable(view.state, effects) });
|
1255
|
+
return !!effects.length;
|
1256
|
+
};
|
1257
|
+
/**
|
1258
|
+
Unfold all folded code.
|
1259
|
+
*/
|
1260
|
+
const unfoldAll = view => {
|
1261
|
+
let field = view.state.field(foldState, false);
|
1262
|
+
if (!field || !field.size)
|
1263
|
+
return false;
|
1264
|
+
let effects = [];
|
1265
|
+
field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
|
1266
|
+
view.dispatch({ effects });
|
1267
|
+
return true;
|
1268
|
+
};
|
1269
|
+
/**
|
1270
|
+
Default fold-related key bindings.
|
1271
|
+
|
1272
|
+
- Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
|
1273
|
+
- Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
|
1274
|
+
- Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
|
1275
|
+
- Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
|
1276
|
+
*/
|
1277
|
+
const foldKeymap = [
|
1278
|
+
{ key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
|
1279
|
+
{ key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
|
1280
|
+
{ key: "Ctrl-Alt-[", run: foldAll },
|
1281
|
+
{ key: "Ctrl-Alt-]", run: unfoldAll }
|
1282
|
+
];
|
1283
|
+
const defaultConfig = {
|
1284
|
+
placeholderDOM: null,
|
1285
|
+
preparePlaceholder: null,
|
1286
|
+
placeholderText: "…"
|
1287
|
+
};
|
1288
|
+
const foldConfig = /*@__PURE__*/Facet.define({
|
1289
|
+
combine(values) { return combineConfig(values, defaultConfig); }
|
1290
|
+
});
|
1291
|
+
/**
|
1292
|
+
Create an extension that configures code folding.
|
1293
|
+
*/
|
1294
|
+
function codeFolding(config) {
|
1295
|
+
let result = [foldState, baseTheme$1];
|
1296
|
+
return result;
|
1297
|
+
}
|
1298
|
+
function widgetToDOM(view, prepared) {
|
1299
|
+
let { state } = view, conf = state.facet(foldConfig);
|
1300
|
+
let onclick = (event) => {
|
1301
|
+
let line = view.lineBlockAt(view.posAtDOM(event.target));
|
1302
|
+
let folded = findFold(view.state, line.from, line.to);
|
1303
|
+
if (folded)
|
1304
|
+
view.dispatch({ effects: unfoldEffect.of(folded) });
|
1305
|
+
event.preventDefault();
|
1306
|
+
};
|
1307
|
+
if (conf.placeholderDOM)
|
1308
|
+
return conf.placeholderDOM(view, onclick, prepared);
|
1309
|
+
let element = document.createElement("span");
|
1310
|
+
element.textContent = conf.placeholderText;
|
1311
|
+
element.setAttribute("aria-label", state.phrase("folded code"));
|
1312
|
+
element.title = state.phrase("unfold");
|
1313
|
+
element.className = "cm-foldPlaceholder";
|
1314
|
+
element.onclick = onclick;
|
1315
|
+
return element;
|
1316
|
+
}
|
1317
|
+
const foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {
|
1318
|
+
toDOM(view) { return widgetToDOM(view, null); }
|
1319
|
+
} });
|
1320
|
+
class PreparedFoldWidget extends WidgetType {
|
1321
|
+
constructor(value) {
|
1322
|
+
super();
|
1323
|
+
this.value = value;
|
1324
|
+
}
|
1325
|
+
eq(other) { return this.value == other.value; }
|
1326
|
+
toDOM(view) { return widgetToDOM(view, this.value); }
|
1327
|
+
}
|
1328
|
+
const foldGutterDefaults = {
|
1329
|
+
openText: "⌄",
|
1330
|
+
closedText: "›",
|
1331
|
+
markerDOM: null,
|
1332
|
+
domEventHandlers: {},
|
1333
|
+
foldingChanged: () => false
|
1334
|
+
};
|
1335
|
+
class FoldMarker extends GutterMarker {
|
1336
|
+
constructor(config, open) {
|
1337
|
+
super();
|
1338
|
+
this.config = config;
|
1339
|
+
this.open = open;
|
1340
|
+
}
|
1341
|
+
eq(other) { return this.config == other.config && this.open == other.open; }
|
1342
|
+
toDOM(view) {
|
1343
|
+
if (this.config.markerDOM)
|
1344
|
+
return this.config.markerDOM(this.open);
|
1345
|
+
let span = document.createElement("span");
|
1346
|
+
span.textContent = this.open ? this.config.openText : this.config.closedText;
|
1347
|
+
span.title = view.state.phrase(this.open ? "Fold line" : "Unfold line");
|
1348
|
+
return span;
|
1349
|
+
}
|
1350
|
+
}
|
1351
|
+
/**
|
1352
|
+
Create an extension that registers a fold gutter, which shows a
|
1353
|
+
fold status indicator before foldable lines (which can be clicked
|
1354
|
+
to fold or unfold the line).
|
1355
|
+
*/
|
1356
|
+
function foldGutter(config = {}) {
|
1357
|
+
let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
|
1358
|
+
let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
|
1359
|
+
let markers = ViewPlugin.fromClass(class {
|
1360
|
+
constructor(view) {
|
1361
|
+
this.from = view.viewport.from;
|
1362
|
+
this.markers = this.buildMarkers(view);
|
1363
|
+
}
|
1364
|
+
update(update) {
|
1365
|
+
if (update.docChanged || update.viewportChanged ||
|
1366
|
+
update.startState.facet(language) != update.state.facet(language) ||
|
1367
|
+
update.startState.field(foldState, false) != update.state.field(foldState, false) ||
|
1368
|
+
syntaxTree(update.startState) != syntaxTree(update.state) ||
|
1369
|
+
fullConfig.foldingChanged(update))
|
1370
|
+
this.markers = this.buildMarkers(update.view);
|
1371
|
+
}
|
1372
|
+
buildMarkers(view) {
|
1373
|
+
let builder = new RangeSetBuilder();
|
1374
|
+
for (let line of view.viewportLineBlocks) {
|
1375
|
+
let mark = findFold(view.state, line.from, line.to) ? canUnfold
|
1376
|
+
: foldable(view.state, line.from, line.to) ? canFold : null;
|
1377
|
+
if (mark)
|
1378
|
+
builder.add(line.from, line.from, mark);
|
1379
|
+
}
|
1380
|
+
return builder.finish();
|
1381
|
+
}
|
1382
|
+
});
|
1383
|
+
let { domEventHandlers } = fullConfig;
|
1384
|
+
return [
|
1385
|
+
markers,
|
1386
|
+
gutter({
|
1387
|
+
class: "cm-foldGutter",
|
1388
|
+
markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },
|
1389
|
+
initialSpacer() {
|
1390
|
+
return new FoldMarker(fullConfig, false);
|
1391
|
+
},
|
1392
|
+
domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
|
1393
|
+
if (domEventHandlers.click && domEventHandlers.click(view, line, event))
|
1394
|
+
return true;
|
1395
|
+
let folded = findFold(view.state, line.from, line.to);
|
1396
|
+
if (folded) {
|
1397
|
+
view.dispatch({ effects: unfoldEffect.of(folded) });
|
1398
|
+
return true;
|
1399
|
+
}
|
1400
|
+
let range = foldable(view.state, line.from, line.to);
|
1401
|
+
if (range) {
|
1402
|
+
view.dispatch({ effects: foldEffect.of(range) });
|
1403
|
+
return true;
|
1404
|
+
}
|
1405
|
+
return false;
|
1406
|
+
} })
|
1407
|
+
}),
|
1408
|
+
codeFolding()
|
1409
|
+
];
|
1410
|
+
}
|
1411
|
+
const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
|
1412
|
+
".cm-foldPlaceholder": {
|
1413
|
+
backgroundColor: "#eee",
|
1414
|
+
border: "1px solid #ddd",
|
1415
|
+
color: "#888",
|
1416
|
+
borderRadius: ".2em",
|
1417
|
+
margin: "0 1px",
|
1418
|
+
padding: "0 1px",
|
1419
|
+
cursor: "pointer"
|
1420
|
+
},
|
1421
|
+
".cm-foldGutter span": {
|
1422
|
+
padding: "0 1px",
|
1423
|
+
cursor: "pointer"
|
1424
|
+
}
|
1425
|
+
});
|
1426
|
+
|
1427
|
+
/**
|
1428
|
+
A highlight style associates CSS styles with higlighting
|
1429
|
+
[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
|
1430
|
+
*/
|
1431
|
+
class HighlightStyle {
|
1432
|
+
constructor(
|
1433
|
+
/**
|
1434
|
+
The tag styles used to create this highlight style.
|
1435
|
+
*/
|
1436
|
+
specs, options) {
|
1437
|
+
this.specs = specs;
|
1438
|
+
let modSpec;
|
1439
|
+
function def(spec) {
|
1440
|
+
let cls = StyleModule.newName();
|
1441
|
+
(modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
|
1442
|
+
return cls;
|
1443
|
+
}
|
1444
|
+
const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
|
1445
|
+
const scopeOpt = options.scope;
|
1446
|
+
this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
|
1447
|
+
: scopeOpt ? (type) => type == scopeOpt : undefined;
|
1448
|
+
this.style = tagHighlighter(specs.map(style => ({
|
1449
|
+
tag: style.tag,
|
1450
|
+
class: style.class || def(Object.assign({}, style, { tag: null }))
|
1451
|
+
})), {
|
1452
|
+
all,
|
1453
|
+
}).style;
|
1454
|
+
this.module = modSpec ? new StyleModule(modSpec) : null;
|
1455
|
+
this.themeType = options.themeType;
|
1456
|
+
}
|
1457
|
+
/**
|
1458
|
+
Create a highlighter style that associates the given styles to
|
1459
|
+
the given tags. The specs must be objects that hold a style tag
|
1460
|
+
or array of tags in their `tag` property, and either a single
|
1461
|
+
`class` property providing a static CSS class (for highlighter
|
1462
|
+
that rely on external styling), or a
|
1463
|
+
[`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
|
1464
|
+
set of CSS properties (which define the styling for those tags).
|
1465
|
+
|
1466
|
+
The CSS rules created for a highlighter will be emitted in the
|
1467
|
+
order of the spec's properties. That means that for elements that
|
1468
|
+
have multiple tags associated with them, styles defined further
|
1469
|
+
down in the list will have a higher CSS precedence than styles
|
1470
|
+
defined earlier.
|
1471
|
+
*/
|
1472
|
+
static define(specs, options) {
|
1473
|
+
return new HighlightStyle(specs, options || {});
|
1474
|
+
}
|
1475
|
+
}
|
1476
|
+
const highlighterFacet = /*@__PURE__*/Facet.define();
|
1477
|
+
const fallbackHighlighter = /*@__PURE__*/Facet.define({
|
1478
|
+
combine(values) { return values.length ? [values[0]] : null; }
|
1479
|
+
});
|
1480
|
+
function getHighlighters(state) {
|
1481
|
+
let main = state.facet(highlighterFacet);
|
1482
|
+
return main.length ? main : state.facet(fallbackHighlighter);
|
1483
|
+
}
|
1484
|
+
/**
|
1485
|
+
Wrap a highlighter in an editor extension that uses it to apply
|
1486
|
+
syntax highlighting to the editor content.
|
1487
|
+
|
1488
|
+
When multiple (non-fallback) styles are provided, the styling
|
1489
|
+
applied is the union of the classes they emit.
|
1490
|
+
*/
|
1491
|
+
function syntaxHighlighting(highlighter, options) {
|
1492
|
+
let ext = [treeHighlighter], themeType;
|
1493
|
+
if (highlighter instanceof HighlightStyle) {
|
1494
|
+
if (highlighter.module)
|
1495
|
+
ext.push(EditorView.styleModule.of(highlighter.module));
|
1496
|
+
themeType = highlighter.themeType;
|
1497
|
+
}
|
1498
|
+
if (options === null || options === void 0 ? void 0 : options.fallback)
|
1499
|
+
ext.push(fallbackHighlighter.of(highlighter));
|
1500
|
+
else if (themeType)
|
1501
|
+
ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
|
1502
|
+
return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
|
1503
|
+
}));
|
1504
|
+
else
|
1505
|
+
ext.push(highlighterFacet.of(highlighter));
|
1506
|
+
return ext;
|
1507
|
+
}
|
1508
|
+
class TreeHighlighter {
|
1509
|
+
constructor(view) {
|
1510
|
+
this.markCache = Object.create(null);
|
1511
|
+
this.tree = syntaxTree(view.state);
|
1512
|
+
this.decorations = this.buildDeco(view, getHighlighters(view.state));
|
1513
|
+
this.decoratedTo = view.viewport.to;
|
1514
|
+
}
|
1515
|
+
update(update) {
|
1516
|
+
let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
|
1517
|
+
let styleChange = highlighters != getHighlighters(update.startState);
|
1518
|
+
let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
|
1519
|
+
if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
|
1520
|
+
this.decorations = this.decorations.map(update.changes);
|
1521
|
+
this.decoratedTo = decoratedToMapped;
|
1522
|
+
}
|
1523
|
+
else if (tree != this.tree || update.viewportChanged || styleChange) {
|
1524
|
+
this.tree = tree;
|
1525
|
+
this.decorations = this.buildDeco(update.view, highlighters);
|
1526
|
+
this.decoratedTo = viewport.to;
|
1527
|
+
}
|
1528
|
+
}
|
1529
|
+
buildDeco(view, highlighters) {
|
1530
|
+
if (!highlighters || !this.tree.length)
|
1531
|
+
return Decoration.none;
|
1532
|
+
let builder = new RangeSetBuilder();
|
1533
|
+
for (let { from, to } of view.visibleRanges) {
|
1534
|
+
highlightTree(this.tree, highlighters, (from, to, style) => {
|
1535
|
+
builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
|
1536
|
+
}, from, to);
|
1537
|
+
}
|
1538
|
+
return builder.finish();
|
1539
|
+
}
|
1540
|
+
}
|
1541
|
+
const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
|
1542
|
+
decorations: v => v.decorations
|
1543
|
+
}));
|
1544
|
+
/**
|
1545
|
+
A default highlight style (works well with light themes).
|
1546
|
+
*/
|
1547
|
+
const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
|
1548
|
+
{ tag: tags.meta,
|
1549
|
+
color: "#404740" },
|
1550
|
+
{ tag: tags.link,
|
1551
|
+
textDecoration: "underline" },
|
1552
|
+
{ tag: tags.heading,
|
1553
|
+
textDecoration: "underline",
|
1554
|
+
fontWeight: "bold" },
|
1555
|
+
{ tag: tags.emphasis,
|
1556
|
+
fontStyle: "italic" },
|
1557
|
+
{ tag: tags.strong,
|
1558
|
+
fontWeight: "bold" },
|
1559
|
+
{ tag: tags.strikethrough,
|
1560
|
+
textDecoration: "line-through" },
|
1561
|
+
{ tag: tags.keyword,
|
1562
|
+
color: "#708" },
|
1563
|
+
{ tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
|
1564
|
+
color: "#219" },
|
1565
|
+
{ tag: [tags.literal, tags.inserted],
|
1566
|
+
color: "#164" },
|
1567
|
+
{ tag: [tags.string, tags.deleted],
|
1568
|
+
color: "#a11" },
|
1569
|
+
{ tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
|
1570
|
+
color: "#e40" },
|
1571
|
+
{ tag: /*@__PURE__*/tags.definition(tags.variableName),
|
1572
|
+
color: "#00f" },
|
1573
|
+
{ tag: /*@__PURE__*/tags.local(tags.variableName),
|
1574
|
+
color: "#30a" },
|
1575
|
+
{ tag: [tags.typeName, tags.namespace],
|
1576
|
+
color: "#085" },
|
1577
|
+
{ tag: tags.className,
|
1578
|
+
color: "#167" },
|
1579
|
+
{ tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
|
1580
|
+
color: "#256" },
|
1581
|
+
{ tag: /*@__PURE__*/tags.definition(tags.propertyName),
|
1582
|
+
color: "#00c" },
|
1583
|
+
{ tag: tags.comment,
|
1584
|
+
color: "#940" },
|
1585
|
+
{ tag: tags.invalid,
|
1586
|
+
color: "#f00" }
|
1587
|
+
]);
|
1588
|
+
|
1589
|
+
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
1590
|
+
"&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
|
1591
|
+
"&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
|
1592
|
+
});
|
1593
|
+
const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
|
1594
|
+
const bracketMatchingConfig = /*@__PURE__*/Facet.define({
|
1595
|
+
combine(configs) {
|
1596
|
+
return combineConfig(configs, {
|
1597
|
+
afterCursor: true,
|
1598
|
+
brackets: DefaultBrackets,
|
1599
|
+
maxScanDistance: DefaultScanDist,
|
1600
|
+
renderMatch: defaultRenderMatch
|
1601
|
+
});
|
1602
|
+
}
|
1603
|
+
});
|
1604
|
+
const matchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-nonmatchingBracket" });
|
1605
|
+
function defaultRenderMatch(match) {
|
1606
|
+
let decorations = [];
|
1607
|
+
let mark = match.matched ? matchingMark : nonmatchingMark;
|
1608
|
+
decorations.push(mark.range(match.start.from, match.start.to));
|
1609
|
+
if (match.end)
|
1610
|
+
decorations.push(mark.range(match.end.from, match.end.to));
|
1611
|
+
return decorations;
|
1612
|
+
}
|
1613
|
+
const bracketMatchingState = /*@__PURE__*/StateField.define({
|
1614
|
+
create() { return Decoration.none; },
|
1615
|
+
update(deco, tr) {
|
1616
|
+
if (!tr.docChanged && !tr.selection)
|
1617
|
+
return deco;
|
1618
|
+
let decorations = [];
|
1619
|
+
let config = tr.state.facet(bracketMatchingConfig);
|
1620
|
+
for (let range of tr.state.selection.ranges) {
|
1621
|
+
if (!range.empty)
|
1622
|
+
continue;
|
1623
|
+
let match = matchBrackets(tr.state, range.head, -1, config)
|
1624
|
+
|| (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))
|
1625
|
+
|| (config.afterCursor &&
|
1626
|
+
(matchBrackets(tr.state, range.head, 1, config) ||
|
1627
|
+
(range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));
|
1628
|
+
if (match)
|
1629
|
+
decorations = decorations.concat(config.renderMatch(match, tr.state));
|
1630
|
+
}
|
1631
|
+
return Decoration.set(decorations, true);
|
1632
|
+
},
|
1633
|
+
provide: f => EditorView.decorations.from(f)
|
1634
|
+
});
|
1635
|
+
const bracketMatchingUnique = [
|
1636
|
+
bracketMatchingState,
|
1637
|
+
baseTheme
|
1638
|
+
];
|
1639
|
+
/**
|
1640
|
+
Create an extension that enables bracket matching. Whenever the
|
1641
|
+
cursor is next to a bracket, that bracket and the one it matches
|
1642
|
+
are highlighted. Or, when no matching bracket is found, another
|
1643
|
+
highlighting style is used to indicate this.
|
1644
|
+
*/
|
1645
|
+
function bracketMatching(config = {}) {
|
1646
|
+
return [bracketMatchingConfig.of(config), bracketMatchingUnique];
|
1647
|
+
}
|
1648
|
+
/**
|
1649
|
+
When larger syntax nodes, such as HTML tags, are marked as
|
1650
|
+
opening/closing, it can be a bit messy to treat the whole node as
|
1651
|
+
a matchable bracket. This node prop allows you to define, for such
|
1652
|
+
a node, a ‘handle’—the part of the node that is highlighted, and
|
1653
|
+
that the cursor must be on to activate highlighting in the first
|
1654
|
+
place.
|
1655
|
+
*/
|
1656
|
+
const bracketMatchingHandle = /*@__PURE__*/new NodeProp();
|
1657
|
+
function matchingNodes(node, dir, brackets) {
|
1658
|
+
let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);
|
1659
|
+
if (byProp)
|
1660
|
+
return byProp;
|
1661
|
+
if (node.name.length == 1) {
|
1662
|
+
let index = brackets.indexOf(node.name);
|
1663
|
+
if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
|
1664
|
+
return [brackets[index + dir]];
|
1665
|
+
}
|
1666
|
+
return null;
|
1667
|
+
}
|
1668
|
+
function findHandle(node) {
|
1669
|
+
let hasHandle = node.type.prop(bracketMatchingHandle);
|
1670
|
+
return hasHandle ? hasHandle(node.node) : node;
|
1671
|
+
}
|
1672
|
+
/**
|
1673
|
+
Find the matching bracket for the token at `pos`, scanning
|
1674
|
+
direction `dir`. Only the `brackets` and `maxScanDistance`
|
1675
|
+
properties are used from `config`, if given. Returns null if no
|
1676
|
+
bracket was found at `pos`, or a match result otherwise.
|
1677
|
+
*/
|
1678
|
+
function matchBrackets(state, pos, dir, config = {}) {
|
1679
|
+
let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
|
1680
|
+
let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);
|
1681
|
+
for (let cur = node; cur; cur = cur.parent) {
|
1682
|
+
let matches = matchingNodes(cur.type, dir, brackets);
|
1683
|
+
if (matches && cur.from < cur.to) {
|
1684
|
+
let handle = findHandle(cur);
|
1685
|
+
if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))
|
1686
|
+
return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);
|
1687
|
+
}
|
1688
|
+
}
|
1689
|
+
return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
|
1690
|
+
}
|
1691
|
+
function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {
|
1692
|
+
let parent = token.parent, firstToken = { from: handle.from, to: handle.to };
|
1693
|
+
let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
|
1694
|
+
if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
|
1695
|
+
do {
|
1696
|
+
if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
|
1697
|
+
if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
|
1698
|
+
let endHandle = findHandle(cursor);
|
1699
|
+
return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };
|
1700
|
+
}
|
1701
|
+
else if (matchingNodes(cursor.type, dir, brackets)) {
|
1702
|
+
depth++;
|
1703
|
+
}
|
1704
|
+
else if (matchingNodes(cursor.type, -dir, brackets)) {
|
1705
|
+
if (depth == 0) {
|
1706
|
+
let endHandle = findHandle(cursor);
|
1707
|
+
return {
|
1708
|
+
start: firstToken,
|
1709
|
+
end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,
|
1710
|
+
matched: false
|
1711
|
+
};
|
1712
|
+
}
|
1713
|
+
depth--;
|
1714
|
+
}
|
1715
|
+
}
|
1716
|
+
} while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
|
1717
|
+
return { start: firstToken, matched: false };
|
1718
|
+
}
|
1719
|
+
function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
|
1720
|
+
let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
|
1721
|
+
let bracket = brackets.indexOf(startCh);
|
1722
|
+
if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
|
1723
|
+
return null;
|
1724
|
+
let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
|
1725
|
+
let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
|
1726
|
+
for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
|
1727
|
+
let text = iter.value;
|
1728
|
+
if (dir < 0)
|
1729
|
+
distance += text.length;
|
1730
|
+
let basePos = pos + distance * dir;
|
1731
|
+
for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
|
1732
|
+
let found = brackets.indexOf(text[pos]);
|
1733
|
+
if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)
|
1734
|
+
continue;
|
1735
|
+
if ((found % 2 == 0) == (dir > 0)) {
|
1736
|
+
depth++;
|
1737
|
+
}
|
1738
|
+
else if (depth == 1) { // Closing
|
1739
|
+
return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
|
1740
|
+
}
|
1741
|
+
else {
|
1742
|
+
depth--;
|
1743
|
+
}
|
1744
|
+
}
|
1745
|
+
if (dir > 0)
|
1746
|
+
distance += text.length;
|
1747
|
+
}
|
1748
|
+
return iter.done ? { start: startToken, matched: false } : null;
|
1749
|
+
}
|
1750
|
+
const noTokens = /*@__PURE__*/Object.create(null);
|
1751
|
+
const typeArray = [NodeType.none];
|
1752
|
+
const warned = [];
|
1753
|
+
// Cache of node types by name and tags
|
1754
|
+
const byTag = /*@__PURE__*/Object.create(null);
|
1755
|
+
const defaultTable = /*@__PURE__*/Object.create(null);
|
1756
|
+
for (let [legacyName, name] of [
|
1757
|
+
["variable", "variableName"],
|
1758
|
+
["variable-2", "variableName.special"],
|
1759
|
+
["string-2", "string.special"],
|
1760
|
+
["def", "variableName.definition"],
|
1761
|
+
["tag", "tagName"],
|
1762
|
+
["attribute", "attributeName"],
|
1763
|
+
["type", "typeName"],
|
1764
|
+
["builtin", "variableName.standard"],
|
1765
|
+
["qualifier", "modifier"],
|
1766
|
+
["error", "invalid"],
|
1767
|
+
["header", "heading"],
|
1768
|
+
["property", "propertyName"]
|
1769
|
+
])
|
1770
|
+
defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);
|
1771
|
+
function warnForPart(part, msg) {
|
1772
|
+
if (warned.indexOf(part) > -1)
|
1773
|
+
return;
|
1774
|
+
warned.push(part);
|
1775
|
+
console.warn(msg);
|
1776
|
+
}
|
1777
|
+
function createTokenType(extra, tagStr) {
|
1778
|
+
let tags$1 = [];
|
1779
|
+
for (let name of tagStr.split(" ")) {
|
1780
|
+
let found = [];
|
1781
|
+
for (let part of name.split(".")) {
|
1782
|
+
let value = (extra[part] || tags[part]);
|
1783
|
+
if (!value) {
|
1784
|
+
warnForPart(part, `Unknown highlighting tag ${part}`);
|
1785
|
+
}
|
1786
|
+
else if (typeof value == "function") {
|
1787
|
+
if (!found.length)
|
1788
|
+
warnForPart(part, `Modifier ${part} used at start of tag`);
|
1789
|
+
else
|
1790
|
+
found = found.map(value);
|
1791
|
+
}
|
1792
|
+
else {
|
1793
|
+
if (found.length)
|
1794
|
+
warnForPart(part, `Tag ${part} used as modifier`);
|
1795
|
+
else
|
1796
|
+
found = Array.isArray(value) ? value : [value];
|
1797
|
+
}
|
1798
|
+
}
|
1799
|
+
for (let tag of found)
|
1800
|
+
tags$1.push(tag);
|
1801
|
+
}
|
1802
|
+
if (!tags$1.length)
|
1803
|
+
return 0;
|
1804
|
+
let name = tagStr.replace(/ /g, "_"), key = name + " " + tags$1.map(t => t.id);
|
1805
|
+
let known = byTag[key];
|
1806
|
+
if (known)
|
1807
|
+
return known.id;
|
1808
|
+
let type = byTag[key] = NodeType.define({
|
1809
|
+
id: typeArray.length,
|
1810
|
+
name,
|
1811
|
+
props: [styleTags({ [name]: tags$1 })]
|
1812
|
+
});
|
1813
|
+
typeArray.push(type);
|
1814
|
+
return type.id;
|
1815
|
+
}
|
1816
|
+
({
|
1817
|
+
rtl: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
|
1818
|
+
ltr: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR })});
|
1819
|
+
|
1820
|
+
export { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageSupport, ParseContext, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, 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 };
|
1821
|
+
//# sourceMappingURL=index.js.map
|