@uiw/react-codemirror 4.5.3 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/index.js.map +3 -2
- package/cjs/useCodeMirror.js +6 -0
- package/cjs/useCodeMirror.js.map +4 -3
- package/dist/codemirror.js +28 -112
- package/dist/codemirror.min.js +1 -1
- package/dist/codemirror.min.js.LICENSE.txt +2 -7
- package/esm/index.d.ts +1 -0
- package/esm/index.js +3 -1
- package/esm/index.js.map +3 -2
- package/esm/useCodeMirror.js +5 -0
- package/esm/useCodeMirror.js.map +3 -2
- package/package.json +12 -11
- package/src/index.tsx +3 -0
- package/src/useCodeMirror.ts +4 -0
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -75,7 +75,7 @@ Object.keys(_state).forEach(function (key) {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "root"];
|
|
78
|
+
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root"];
|
|
79
79
|
|
|
80
80
|
var ReactCodeMirror = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
81
81
|
var className = props.className,
|
|
@@ -99,6 +99,7 @@ var ReactCodeMirror = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
99
99
|
placeholder = props.placeholder,
|
|
100
100
|
indentWithTab = props.indentWithTab,
|
|
101
101
|
editable = props.editable,
|
|
102
|
+
readOnly = props.readOnly,
|
|
102
103
|
root = props.root,
|
|
103
104
|
other = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
104
105
|
var editor = (0, _react.useRef)(null);
|
|
@@ -119,6 +120,7 @@ var ReactCodeMirror = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
119
120
|
placeholder: placeholder,
|
|
120
121
|
indentWithTab: indentWithTab,
|
|
121
122
|
editable: editable,
|
|
123
|
+
readOnly: readOnly,
|
|
122
124
|
selection: selection,
|
|
123
125
|
onChange: onChange,
|
|
124
126
|
onUpdate: onUpdate,
|
package/cjs/index.js.map
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"placeholder",
|
|
28
28
|
"indentWithTab",
|
|
29
29
|
"editable",
|
|
30
|
+
"readOnly",
|
|
30
31
|
"root",
|
|
31
32
|
"other",
|
|
32
33
|
"editor",
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
"defaultClassNames",
|
|
40
41
|
"displayName"
|
|
41
42
|
],
|
|
42
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;AAGA;;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;AAHA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
43
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;AAGA;;AAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;AAHA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAR,CAAZ,CADc,CAEd;AACD,GAHD,EAGG,EAHH,EAhDiG,CAqDjG;;AACA,MAAI,OAAOtB,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAI0B,KAAJ,qEAAwD1B,KAAxD,GAAN;AACD;;AAED,MAAM2B,iBAAiB,GAAG,OAAOrB,KAAP,KAAiB,QAAjB,sBAAwCA,KAAxC,IAAkD,UAA5E;AACA,sBAAO;AAAK,IAAA,GAAG,EAAEc,MAAV;AAAkB,IAAA,SAAS,YAAKO,iBAAL,SAAyB5B,SAAS,cAAOA,SAAP,IAAqB,EAAvD;AAA3B,KAA4FoB,KAA5F,EAAP;AACD,CA5DuB,CAAxB;;AA8DAzB,eAAe,CAACkC,WAAhB,GAA8B,YAA9B;eAEelC,e",
|
|
43
44
|
"sourcesContent": [
|
|
44
|
-
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
|
|
45
|
+
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n readOnly?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
|
|
45
46
|
]
|
|
46
47
|
}
|
package/cjs/useCodeMirror.js
CHANGED
|
@@ -49,6 +49,8 @@ function useCodeMirror(props) {
|
|
|
49
49
|
maxWidth = _props$maxWidth === void 0 ? '' : _props$maxWidth,
|
|
50
50
|
_props$editable = props.editable,
|
|
51
51
|
editable = _props$editable === void 0 ? true : _props$editable,
|
|
52
|
+
_props$readOnly = props.readOnly,
|
|
53
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
52
54
|
_props$indentWithTab = props.indentWithTab,
|
|
53
55
|
defaultIndentWithTab = _props$indentWithTab === void 0 ? true : _props$indentWithTab,
|
|
54
56
|
_props$basicSetup = props.basicSetup,
|
|
@@ -123,6 +125,10 @@ function useCodeMirror(props) {
|
|
|
123
125
|
getExtensions.push(_view.EditorView.editable.of(false));
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
if (readOnly) {
|
|
129
|
+
getExtensions.push(_state.EditorState.readOnly.of(true));
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
if (onUpdate && typeof onUpdate === 'function') {
|
|
127
133
|
getExtensions.push(_view.EditorView.updateListener.of(onUpdate));
|
|
128
134
|
}
|
package/cjs/useCodeMirror.js.map
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"minWidth",
|
|
23
23
|
"maxWidth",
|
|
24
24
|
"editable",
|
|
25
|
+
"readOnly",
|
|
25
26
|
"indentWithTab",
|
|
26
27
|
"defaultIndentWithTab",
|
|
27
28
|
"basicSetup",
|
|
@@ -47,9 +48,9 @@
|
|
|
47
48
|
"push",
|
|
48
49
|
"defaultLightThemeOption",
|
|
49
50
|
"oneDark",
|
|
51
|
+
"EditorState",
|
|
50
52
|
"concat",
|
|
51
53
|
"stateCurrent",
|
|
52
|
-
"EditorState",
|
|
53
54
|
"create",
|
|
54
55
|
"viewCurrent",
|
|
55
56
|
"parent",
|
|
@@ -67,8 +68,8 @@
|
|
|
67
68
|
"StateEffect",
|
|
68
69
|
"reconfigure"
|
|
69
70
|
],
|
|
70
|
-
"mappings": ";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;A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AEC,mBAAYC,WAAZ,CAAwB7B,EAAxB,CAA2BK,aAA3B;AAAX,OAAd;AACD,KAHa,CAId;;AACD,GALD,EAKG,CACD9B,KADC,EAEDF,UAFC,EAGDG,MAHC,EAIDC,SAJC,EAKDC,SALC,EAMDG,KANC,EAODD,cAPC,EAQDE,QARC,EASDC,QATC,EAUDC,QAVC,EAWDG,oBAXC,EAYDE,iBAZC,CALH;AAoBA,SAAO;AAAEM,IAAAA,KAAK,EAALA,KAAF;AAASC,IAAAA,QAAQ,EAARA,QAAT;AAAmBH,IAAAA,IAAI,EAAJA,IAAnB;AAAyBC,IAAAA,OAAO,EAAPA,OAAzB;AAAkCH,IAAAA,SAAS,EAATA,SAAlC;AAA6CC,IAAAA,YAAY,EAAZA;AAA7C,GAAP;AACD",
|
|
71
72
|
"sourcesContent": [
|
|
72
|
-
"import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
73
|
+
"import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n readOnly = false,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n if (readOnly) {\n getExtensions.push(EditorState.readOnly.of(true));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
73
74
|
]
|
|
74
75
|
}
|
package/dist/codemirror.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
exports["@uiw/codemirror"] = factory(require("react"), require("@codemirror/basic-setup"), require("@codemirror/state"), require("@codemirror/theme-one-dark"), require("@codemirror/view"));
|
|
8
8
|
else
|
|
9
9
|
root["@uiw/codemirror"] = factory(root["React"], root["CM"]["@codemirror/basic-setup"], root["CM"]["@codemirror/state"], root["CM"]["@codemirror/theme-one-dark"], root["CM"]["@codemirror/view"]);
|
|
10
|
-
})(self,
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__787__, __WEBPACK_EXTERNAL_MODULE__573__, __WEBPACK_EXTERNAL_MODULE__242__, __WEBPACK_EXTERNAL_MODULE__362__, __WEBPACK_EXTERNAL_MODULE__105__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ "use strict";
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
@@ -2484,6 +2484,7 @@ function enterFragments(mounts, ranges) {
|
|
|
2484
2484
|
|
|
2485
2485
|
|
|
2486
2486
|
|
|
2487
|
+
var _a;
|
|
2487
2488
|
/**
|
|
2488
2489
|
Node prop stored in a grammar's top syntax node to provide the
|
|
2489
2490
|
facet that stores language data for that language.
|
|
@@ -2769,7 +2770,7 @@ class ParseContext {
|
|
|
2769
2770
|
/**
|
|
2770
2771
|
@internal
|
|
2771
2772
|
*/
|
|
2772
|
-
work(
|
|
2773
|
+
work(until, upto) {
|
|
2773
2774
|
if (upto != null && upto >= this.state.doc.length)
|
|
2774
2775
|
upto = undefined;
|
|
2775
2776
|
if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
|
|
@@ -2778,7 +2779,10 @@ class ParseContext {
|
|
|
2778
2779
|
}
|
|
2779
2780
|
return this.withContext(() => {
|
|
2780
2781
|
var _a;
|
|
2781
|
-
|
|
2782
|
+
if (typeof until == "number") {
|
|
2783
|
+
let endTime = Date.now() + until;
|
|
2784
|
+
until = () => Date.now() > endTime;
|
|
2785
|
+
}
|
|
2782
2786
|
if (!this.parse)
|
|
2783
2787
|
this.parse = this.startParse();
|
|
2784
2788
|
if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
|
|
@@ -2796,7 +2800,7 @@ class ParseContext {
|
|
|
2796
2800
|
else
|
|
2797
2801
|
return true;
|
|
2798
2802
|
}
|
|
2799
|
-
if (
|
|
2803
|
+
if (until())
|
|
2800
2804
|
return false;
|
|
2801
2805
|
}
|
|
2802
2806
|
});
|
|
@@ -2951,7 +2955,7 @@ class LanguageState {
|
|
|
2951
2955
|
this.tree = context.tree;
|
|
2952
2956
|
}
|
|
2953
2957
|
apply(tr) {
|
|
2954
|
-
if (!tr.docChanged)
|
|
2958
|
+
if (!tr.docChanged && this.tree == this.context.tree)
|
|
2955
2959
|
return this;
|
|
2956
2960
|
let newCx = this.context.changes(tr.changes, tr.state);
|
|
2957
2961
|
// If the previous parse wasn't done, go forward only up to its
|
|
@@ -2993,6 +2997,8 @@ if (typeof requestIdleCallback != "undefined")
|
|
|
2993
2997
|
}, 100 /* MinPause */);
|
|
2994
2998
|
return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
|
|
2995
2999
|
};
|
|
3000
|
+
const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
|
|
3001
|
+
? () => navigator.scheduling.isInputPending() : null;
|
|
2996
3002
|
const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
|
|
2997
3003
|
constructor(view) {
|
|
2998
3004
|
this.view = view;
|
|
@@ -3035,9 +3041,11 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
|
|
|
3035
3041
|
let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
|
|
3036
3042
|
if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
|
|
3037
3043
|
return;
|
|
3038
|
-
let
|
|
3044
|
+
let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
|
|
3039
3045
|
let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
|
|
3040
|
-
let done = field.context.work(
|
|
3046
|
+
let done = field.context.work(() => {
|
|
3047
|
+
return isInputPending && isInputPending() || Date.now() > endTime;
|
|
3048
|
+
}, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
|
|
3041
3049
|
this.chunkBudget -= Date.now() - now;
|
|
3042
3050
|
if (done || this.chunkBudget <= 0) {
|
|
3043
3051
|
field.context.takeTree();
|
|
@@ -3062,7 +3070,7 @@ const parseWorker = /*@__PURE__*/view_.ViewPlugin.fromClass(class ParseWorker {
|
|
|
3062
3070
|
this.working();
|
|
3063
3071
|
}
|
|
3064
3072
|
isWorking() {
|
|
3065
|
-
return this.working || this.workScheduled > 0;
|
|
3073
|
+
return !!(this.working || this.workScheduled > 0);
|
|
3066
3074
|
}
|
|
3067
3075
|
}, {
|
|
3068
3076
|
eventHandlers: { focus() { this.scheduleWork(); } }
|
|
@@ -3536,7 +3544,7 @@ added at the start of a line.
|
|
|
3536
3544
|
*/
|
|
3537
3545
|
function indentOnInput() {
|
|
3538
3546
|
return EditorState.transactionFilter.of(tr => {
|
|
3539
|
-
if (!tr.docChanged || !tr.isUserEvent("input.type"))
|
|
3547
|
+
if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
|
|
3540
3548
|
return tr;
|
|
3541
3549
|
let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
|
|
3542
3550
|
if (!rules.length)
|
|
@@ -3600,7 +3608,7 @@ function syntaxFolding(state, start, end) {
|
|
|
3600
3608
|
if (found && cur.from < start)
|
|
3601
3609
|
break;
|
|
3602
3610
|
let prop = cur.type.prop(foldNodeProp);
|
|
3603
|
-
if (prop) {
|
|
3611
|
+
if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
|
|
3604
3612
|
let value = prop(cur, state);
|
|
3605
3613
|
if (value && value.from <= end && value.from >= start && value.to > end)
|
|
3606
3614
|
found = value;
|
|
@@ -3608,6 +3616,10 @@ function syntaxFolding(state, start, end) {
|
|
|
3608
3616
|
}
|
|
3609
3617
|
return found;
|
|
3610
3618
|
}
|
|
3619
|
+
function isUnfinished(node) {
|
|
3620
|
+
let ch = node.lastChild;
|
|
3621
|
+
return ch && ch.to == node.to && ch.type.isError;
|
|
3622
|
+
}
|
|
3611
3623
|
/**
|
|
3612
3624
|
Check whether the given line is foldable. First asks any fold
|
|
3613
3625
|
services registered through
|
|
@@ -4614,114 +4626,18 @@ var theme_one_dark_ = __webpack_require__(362);
|
|
|
4614
4626
|
;// CONCATENATED MODULE: ./src/theme/light.ts
|
|
4615
4627
|
var defaultLightThemeOption=view_.EditorView.theme({'&':{backgroundColor:'#fff'}},{dark:false});
|
|
4616
4628
|
;// CONCATENATED MODULE: ./src/useCodeMirror.ts
|
|
4617
|
-
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.container),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){getExtensions.unshift(basic_setup_.basicSetup);}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var stateCurrent=state_.EditorState.create({doc:value,selection:selection,extensions:getExtensions});setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);}}return function(){if(view){setView(undefined);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4629
|
+
function useCodeMirror(props){var value=props.value,selection=props.selection,onChange=props.onChange,onUpdate=props.onUpdate,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,_props$height=props.height,height=_props$height===void 0?'':_props$height,_props$minHeight=props.minHeight,minHeight=_props$minHeight===void 0?'':_props$minHeight,_props$maxHeight=props.maxHeight,maxHeight=_props$maxHeight===void 0?'':_props$maxHeight,_props$placeholder=props.placeholder,placeholderStr=_props$placeholder===void 0?'':_props$placeholder,_props$width=props.width,width=_props$width===void 0?'':_props$width,_props$minWidth=props.minWidth,minWidth=_props$minWidth===void 0?'':_props$minWidth,_props$maxWidth=props.maxWidth,maxWidth=_props$maxWidth===void 0?'':_props$maxWidth,_props$editable=props.editable,editable=_props$editable===void 0?true:_props$editable,_props$readOnly=props.readOnly,readOnly=_props$readOnly===void 0?false:_props$readOnly,_props$indentWithTab=props.indentWithTab,defaultIndentWithTab=_props$indentWithTab===void 0?true:_props$indentWithTab,_props$basicSetup=props.basicSetup,defaultBasicSetup=_props$basicSetup===void 0?true:_props$basicSetup,root=props.root;var _useState=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.container),_useState2=_slicedToArray(_useState,2),container=_useState2[0],setContainer=_useState2[1];var _useState3=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState4=_slicedToArray(_useState3,2),view=_useState4[0],setView=_useState4[1];var _useState5=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(),_useState6=_slicedToArray(_useState5,2),state=_useState6[0],setState=_useState6[1];var defaultThemeOption=view_.EditorView.theme({'&':{height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth}});var updateListener=view_.EditorView.updateListener.of(function(vu){if(vu.docChanged&&typeof onChange==='function'){var doc=vu.state.doc;var _value=doc.toString();onChange(_value,vu);}});var getExtensions=[updateListener,defaultThemeOption];if(defaultIndentWithTab){getExtensions.unshift(view_.keymap.of([indentWithTab]));}if(defaultBasicSetup){getExtensions.unshift(basic_setup_.basicSetup);}if(placeholderStr){getExtensions.unshift((0,view_.placeholder)(placeholderStr));}switch(theme){case'light':getExtensions.push(defaultLightThemeOption);break;case'dark':getExtensions.push(theme_one_dark_.oneDark);break;default:getExtensions.push(theme);break;}if(editable===false){getExtensions.push(view_.EditorView.editable.of(false));}if(readOnly){getExtensions.push(state_.EditorState.readOnly.of(true));}if(onUpdate&&typeof onUpdate==='function'){getExtensions.push(view_.EditorView.updateListener.of(onUpdate));}getExtensions=getExtensions.concat(extensions);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(container&&!state){var stateCurrent=state_.EditorState.create({doc:value,selection:selection,extensions:getExtensions});setState(stateCurrent);if(!view){var viewCurrent=new view_.EditorView({state:stateCurrent,parent:container,root:root});setView(viewCurrent);}}return function(){if(view){setView(undefined);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4618
4630
|
},[container,state]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){return function(){if(view){view.destroy();setView(undefined);}};},[view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(autoFocus&&view){view.focus();}},[autoFocus,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var currentValue=view?view.state.doc.toString():'';if(view&&value!==currentValue){view.dispatch({changes:{from:0,to:currentValue.length,insert:value||''}});}},[value,view]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(view){view.dispatch({effects:state_.StateEffect.reconfigure.of(getExtensions)});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4619
4631
|
},[theme,extensions,height,minHeight,maxHeight,width,placeholderStr,minWidth,maxWidth,editable,defaultIndentWithTab,defaultBasicSetup]);return{state:state,setState:setState,view:view,setView:setView,container:container,setContainer:setContainer};}
|
|
4620
4632
|
|
|
4621
|
-
/***/ }),
|
|
4622
|
-
|
|
4623
|
-
/***/ 323:
|
|
4624
|
-
/***/ ((module) => {
|
|
4625
|
-
|
|
4626
|
-
/*
|
|
4627
|
-
object-assign
|
|
4628
|
-
(c) Sindre Sorhus
|
|
4629
|
-
@license MIT
|
|
4630
|
-
*/
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
/* eslint-disable no-unused-vars */
|
|
4634
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
4635
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
4636
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
4637
|
-
|
|
4638
|
-
function toObject(val) {
|
|
4639
|
-
if (val === null || val === undefined) {
|
|
4640
|
-
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
4641
|
-
}
|
|
4642
|
-
|
|
4643
|
-
return Object(val);
|
|
4644
|
-
}
|
|
4645
|
-
|
|
4646
|
-
function shouldUseNative() {
|
|
4647
|
-
try {
|
|
4648
|
-
if (!Object.assign) {
|
|
4649
|
-
return false;
|
|
4650
|
-
}
|
|
4651
|
-
|
|
4652
|
-
// Detect buggy property enumeration order in older V8 versions.
|
|
4653
|
-
|
|
4654
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
4655
|
-
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
4656
|
-
test1[5] = 'de';
|
|
4657
|
-
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
4658
|
-
return false;
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
4662
|
-
var test2 = {};
|
|
4663
|
-
for (var i = 0; i < 10; i++) {
|
|
4664
|
-
test2['_' + String.fromCharCode(i)] = i;
|
|
4665
|
-
}
|
|
4666
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
4667
|
-
return test2[n];
|
|
4668
|
-
});
|
|
4669
|
-
if (order2.join('') !== '0123456789') {
|
|
4670
|
-
return false;
|
|
4671
|
-
}
|
|
4672
|
-
|
|
4673
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
4674
|
-
var test3 = {};
|
|
4675
|
-
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
4676
|
-
test3[letter] = letter;
|
|
4677
|
-
});
|
|
4678
|
-
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
4679
|
-
'abcdefghijklmnopqrst') {
|
|
4680
|
-
return false;
|
|
4681
|
-
}
|
|
4682
|
-
|
|
4683
|
-
return true;
|
|
4684
|
-
} catch (err) {
|
|
4685
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
4686
|
-
return false;
|
|
4687
|
-
}
|
|
4688
|
-
}
|
|
4689
|
-
|
|
4690
|
-
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
|
4691
|
-
var from;
|
|
4692
|
-
var to = toObject(target);
|
|
4693
|
-
var symbols;
|
|
4694
|
-
|
|
4695
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
4696
|
-
from = Object(arguments[s]);
|
|
4697
|
-
|
|
4698
|
-
for (var key in from) {
|
|
4699
|
-
if (hasOwnProperty.call(from, key)) {
|
|
4700
|
-
to[key] = from[key];
|
|
4701
|
-
}
|
|
4702
|
-
}
|
|
4703
|
-
|
|
4704
|
-
if (getOwnPropertySymbols) {
|
|
4705
|
-
symbols = getOwnPropertySymbols(from);
|
|
4706
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
4707
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
4708
|
-
to[symbols[i]] = from[symbols[i]];
|
|
4709
|
-
}
|
|
4710
|
-
}
|
|
4711
|
-
}
|
|
4712
|
-
}
|
|
4713
|
-
|
|
4714
|
-
return to;
|
|
4715
|
-
};
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
4633
|
/***/ }),
|
|
4719
4634
|
|
|
4720
4635
|
/***/ 638:
|
|
4721
4636
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4722
4637
|
|
|
4723
4638
|
var __webpack_unused_export__;
|
|
4724
|
-
/**
|
|
4639
|
+
/**
|
|
4640
|
+
* @license React
|
|
4725
4641
|
* react-jsx-runtime.production.min.js
|
|
4726
4642
|
*
|
|
4727
4643
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -4729,8 +4645,8 @@ var __webpack_unused_export__;
|
|
|
4729
4645
|
* This source code is licensed under the MIT license found in the
|
|
4730
4646
|
* LICENSE file in the root directory of this source tree.
|
|
4731
4647
|
*/
|
|
4732
|
-
|
|
4733
|
-
function q(c,a,
|
|
4648
|
+
var f=__webpack_require__(787),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
4649
|
+
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__webpack_unused_export__=l;exports.jsx=q;__webpack_unused_export__=q;
|
|
4734
4650
|
|
|
4735
4651
|
|
|
4736
4652
|
/***/ }),
|
|
@@ -4981,7 +4897,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4981
4897
|
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
4982
4898
|
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _codemirror_state__WEBPACK_IMPORTED_MODULE_5__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _codemirror_state__WEBPACK_IMPORTED_MODULE_5__[__WEBPACK_IMPORT_KEY__]
|
|
4983
4899
|
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
4984
|
-
var _excluded=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","root"];var ReactCodeMirror=/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,root=props.root,other=(0,_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(props,_excluded);var editor=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);var _useCodeMirror=(0,_useCodeMirror__WEBPACK_IMPORTED_MODULE_1__/* .useCodeMirror */ .U)({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,selection:selection,onChange:onChange,onUpdate:onUpdate,extensions:extensions}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container,setContainer=_useCodeMirror.setContainer;(0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(ref,function(){return{editor:container,state:state,view:view};},[container,state,view]);(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function(){setContainer(editor.current);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4900
|
+
var _excluded=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"];var ReactCodeMirror=/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,readOnly=props.readOnly,root=props.root,other=(0,_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(props,_excluded);var editor=(0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);var _useCodeMirror=(0,_useCodeMirror__WEBPACK_IMPORTED_MODULE_1__/* .useCodeMirror */ .U)({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,readOnly:readOnly,selection:selection,onChange:onChange,onUpdate:onUpdate,extensions:extensions}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container,setContainer=_useCodeMirror.setContainer;(0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(ref,function(){return{editor:container,state:state,view:view};},[container,state,view]);(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function(){setContainer(editor.current);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4985
4901
|
},[]);// check type of value
|
|
4986
4902
|
if(typeof value!=='string'){throw new Error("value must be typeof string but got ".concat(typeof value));}var defaultClassNames=typeof theme==='string'?"cm-theme-".concat(theme):'cm-theme';return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div",(0,_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z)({ref:editor,className:"".concat(defaultClassNames).concat(className?" ".concat(className):'')},other));});ReactCodeMirror.displayName='CodeMirror';/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ReactCodeMirror);
|
|
4987
4903
|
})();
|
package/dist/codemirror.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see codemirror.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],e):"object"===typeof exports?exports["@uiw/codemirror"]=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):t["@uiw/codemirror"]=e(t.React,t.CM["@codemirror/basic-setup"],t.CM["@codemirror/state"],t.CM["@codemirror/theme-one-dark"],t.CM["@codemirror/view"])}(self,(function(t,e,r,n,i){return(()=>{"use strict";var s={497:(t,e,r)=>{function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s=[],o=!0,h=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(l){h=!0,i=l}finally{try{o||null==r.return||r.return()}finally{if(h)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"===typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.d(e,{U:()=>vt});var s=r(787),o=r(573),h=r(242);let l="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let kt=1;kt<l.length;kt++)l[kt]+=l[kt-1];function u(t){for(let e=1;e<l.length;e+=2)if(l[e]>t)return l[e-1]<=t;return!1}function f(t){return t>=127462&&t<=127487}function a(t,e,r=!0,n=!0){return(r?c:d)(t,e,n)}function c(t,e,r){if(e==t.length)return e;e&&p(t.charCodeAt(e))&&g(t.charCodeAt(e-1))&&e--;let n=m(t,e);for(e+=b(n);e<t.length;){let i=m(t,e);if(8205==n||8205==i||r&&u(i))e+=b(i),n=i;else{if(!f(i))break;{let r=0,n=e-2;for(;n>=0&&f(m(t,n));)r++,n-=2;if(r%2==0)break;e+=2}}}return e}function d(t,e,r){for(;e>0;){let n=c(t,e-2,r);if(n<e)return n;e--}return 0}function p(t){return t>=56320&&t<57344}function g(t){return t>=55296&&t<56320}function m(t,e){let r=t.charCodeAt(e);if(!g(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return p(n)?n-56320+(r-55296<<10)+65536:r}function b(t){return t<65536?1:2}function x(t,e,r=t.length){let n=0;for(let i=0;i<r;)9==t.charCodeAt(i)?(n+=e-n%e,i++):(n++,i=a(t,i));return n}class y{constructor(){}lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,r){let n=[];return this.decompose(0,t,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(e,this.length,n,1),v.from(n,this.length-(e-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let r=[];return this.decompose(t,e,r,0),v.from(r,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),n=new C(this),i=new C(t);for(let s=e,o=e;;){if(n.next(s),i.next(s),s=0,n.lineBreak!=i.lineBreak||n.done!=i.done||n.value!=i.value)return!1;if(o+=n.value.length,n.done||o>=r)return!0}}iter(t=1){return new C(this,t)}iterRange(t,e=this.length){return new O(this,t,e)}iterLines(t,e){let r;if(null==t)r=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;r=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new w(t):v.from(w.split(t,[])):y.empty}}class w extends y{constructor(t,e=function(t){let e=-1;for(let r of t)e+=r.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.text[i],o=n+s.length;if((e?r:o)>=t)return new A(n,o,r,s);n=o+1,r++}}decompose(t,e,r,n){let i=t<=0&&e>=this.length?this:new w(S(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=r.pop(),e=k(i.text,t.text.slice(),0,i.length);if(e.length<=32)r.push(new w(e,t.length+i.length));else{let t=e.length>>1;r.push(new w(e.slice(0,t)),new w(e.slice(t)))}}else r.push(i)}replace(t,e,r){if(!(r instanceof w))return super.replace(t,e,r);let n=k(this.text,k(r.text,S(this.text,0,t)),e),i=this.length+r.length-(e-t);return n.length<=32?new w(n,i):v.from(w.split(n,[]),i)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<=e&&s<this.text.length;s++){let o=this.text[s],h=i+o.length;i>t&&s&&(n+=r),t<h&&e>i&&(n+=o.slice(Math.max(0,t-i),e-i)),i=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let r=[],n=-1;for(let i of t)r.push(i),n+=i.length+1,32==r.length&&(e.push(new w(r,n)),r=[],n=-1);return n>-1&&e.push(new w(r,n)),e}}class v extends y{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.children[i],o=n+s.length,h=r+s.lines-1;if((e?h:o)>=t)return s.lineInner(t,e,r,n);n=o+1,r=h+1}}decompose(t,e,r,n){for(let i=0,s=0;s<=e&&i<this.children.length;i++){let o=this.children[i],h=s+o.length;if(t<=h&&e>=s){let i=n&((s<=t?1:0)|(h>=e?2:0));s>=t&&h<=e&&!i?r.push(o):o.decompose(t-s,e-s,r,i)}s=h+1}}replace(t,e,r){if(r.lines<this.lines)for(let n=0,i=0;n<this.children.length;n++){let s=this.children[n],o=i+s.length;if(t>=i&&e<=o){let h=s.replace(t-i,e-i,r),l=this.lines-s.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let i=this.children.slice();return i[n]=h,new v(i,this.length-(e-t)+r.length)}return super.replace(i,o,h)}i=o+1}return super.replace(t,e,r)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<this.children.length&&s<=e;i++){let o=this.children[i],h=s+o.length;s>t&&i&&(n+=r),t<h&&e>s&&(n+=o.sliceString(t-s,e-s,r)),s=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof v))return 0;let r=0,[n,i,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,i+=e){if(n==s||i==o)return r;let h=this.children[n],l=t.children[i];if(h!=l)return r+h.scanIdentical(l,e);r+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let r=0;for(let c of t)r+=c.lines;if(r<32){let r=[];for(let e of t)e.flatten(r);return new w(r,e)}let n=Math.max(32,r>>5),i=n<<1,s=n>>1,o=[],h=0,l=-1,u=[];function f(t){let e;if(t.lines>i&&t instanceof v)for(let r of t.children)f(r);else t.lines>s&&(h>s||!h)?(a(),o.push(t)):t instanceof w&&h&&(e=u[u.length-1])instanceof w&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,u[u.length-1]=new w(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&a(),h+=t.lines,l+=t.length+1,u.push(t))}function a(){0!=h&&(o.push(1==u.length?u[0]:v.from(u,l)),l=-1,h=u.length=0)}for(let c of t)f(c);return a(),1==o.length?o[0]:new v(o,e)}}function k(t,e,r=0,n=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=n;s++){let h=t[s],l=i+h.length;l>=r&&(l>n&&(h=h.slice(0,n-i)),i<r&&(h=h.slice(r-i)),o?(e[e.length-1]+=h,o=!1):e.push(h)),i=l+1}return e}function S(t,e,r){return k(t,[""],e,r)}y.empty=new w([""],0);class C{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof w?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,n=this.nodes[r],i=this.offsets[r],s=i>>1,o=n instanceof w?n.text.length:n.children.length;if(s==(e>0?o:0)){if(0==r)return this.done=!0,this.value="",this;e>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(e>0?0:1)){if(this.offsets[r]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof w){let i=n.text[s+(e<0?-1:0)];if(this.offsets[r]+=e,i.length>Math.max(0,t))return this.value=0==t?i:e>0?i.slice(t):i.slice(0,i.length-t),this;t-=i.length}else{let i=n.children[s+(e<0?-1:0)];t>i.length?(t-=i.length,this.offsets[r]+=e):(e<0&&this.offsets[r]--,this.nodes.push(i),this.offsets.push(e>0?1:(i instanceof w?i.text.length:i.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class O{constructor(t,e,r){this.value="",this.done=!1,this.cursor=new C(t,e>r?-1:1),this.pos=e>r?t.length:0,this.from=Math.min(e,r),this.to=Math.max(e,r)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let r=e<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=r?n:e<0?n.slice(n.length-r):n.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class _{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:r,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(y.prototype[Symbol.iterator]=function(){return this.iter()},C.prototype[Symbol.iterator]=O.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=function(){return this});class A{constructor(t,e,r,n){this.from=t,this.to=e,this.number=r,this.text=n}get length(){return this.to-this.from}}var j=r(105);const P=1024;let E=0;class N{constructor(t,e){this.from=t,this.to=e}}class B{constructor(t={}){this.id=E++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=I.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}B.closedBy=new B({deserialize:t=>t.split(" ")}),B.openedBy=new B({deserialize:t=>t.split(" ")}),B.group=new B({deserialize:t=>t.split(" ")}),B.contextHash=new B({perNode:!0}),B.lookAhead=new B({perNode:!0}),B.mounted=new B({perNode:!0});const T=Object.create(null);class I{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):T,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new I(t.name||"",e,t.id,r);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(B.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(B.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}I.none=new I("",Object.create(null),0,8);const M=new WeakMap,W=new WeakMap;class z{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(B.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let r of this.children){let t=r.toString();t&&(e&&(e+=","),e+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t,e=0){let r=null!=t&&M.get(this)||this.topNode,n=new J(r);return null!=t&&(n.moveTo(t,e),M.set(this,n._tree)),n}fullCursor(){return new J(this.topNode,1)}get topNode(){return new H(this,0,0,null)}resolve(t,e=0){let r=U(M.get(this)||this.topNode,t,e,!1);return M.set(this,r),r}resolveInner(t,e=0){let r=U(W.get(this)||this.topNode,t,e,!0);return W.set(this,r),r}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t;for(let s=this.cursor(),o=()=>s.node;;){let t=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==e(s.type,s.from,s.to,o))){if(s.firstChild())continue;s.type.isAnonymous||(t=!0)}for(;t&&r&&r(s.type,s.from,s.to,o),t=s.type.isAnonymous,!s.nextSibling();){if(!s.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:K(I.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new z(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new z(I.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=P,reused:s=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(r)?new q(r,r.length):r,l=n.types,u=0,f=0;function a(t,e,r,b,x){let{id:y,start:w,end:v,size:k}=h,S=f;for(;k<0;){if(h.next(),-1==k){let e=s[y];return r.push(e),void b.push(w-t)}if(-3==k)return void(u=y);if(-4==k)return void(f=y);throw new RangeError(`Unrecognized record size: ${k}`)}let C,O,_=l[y],A=w-t;if(v-w<=i&&(O=g(h.pos-e,x))){let e=new Uint16Array(O.size-O.skip),r=h.pos-O.size,i=e.length;for(;h.pos>r;)i=m(O.start,e,i);C=new R(e,v-O.start,n),A=O.start-t}else{let t=h.pos-k;h.next();let e=[],r=[],n=y>=o?y:-1,s=0,l=v;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-i&&(d(e,r,w,s,h.end,l,n,S),s=e.length,l=h.end),h.next()):a(w,t,e,r,n);if(n>=0&&s>0&&s<e.length&&d(e,r,w,s,w,l,n,S),e.reverse(),r.reverse(),n>-1&&s>0){let t=c(_);C=K(_,e,r,0,e.length,0,v-w,t,t)}else C=p(_,e,r,v-w,S-v)}r.push(C),b.push(A)}function c(t){return(e,r,n)=>{let i,s,o=0,h=e.length-1;if(h>=0&&(i=e[h])instanceof z){if(!h&&i.type==t&&i.length==n)return i;(s=i.prop(B.lookAhead))&&(o=r[h]+i.length+s)}return p(t,e,r,n,o)}}function d(t,e,r,i,s,o,h,l){let u=[],f=[];for(;t.length>i;)u.push(t.pop()),f.push(e.pop()+r-s);t.push(p(n.types[h],u,f,o-s,l-o)),e.push(s-r)}function p(t,e,r,n,i=0,s){if(u){let t=[B.contextHash,u];s=s?[t].concat(s):[t]}if(i>25){let t=[B.lookAhead,i];s=s?[t].concat(s):[t]}return new z(t,e,r,n,s)}function g(t,e){let r=h.fork(),n=0,s=0,l=0,u=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=l,l+=4,n+=4,r.next();continue}let h=r.pos-t;if(t<0||h<i||r.start<u)break;let a=r.id>=o?4:0,c=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break t;a+=4}else r.id>=o&&(a+=4);r.next()}s=c,n+=t,l+=a}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=l),f.size>4?f:void 0}function m(t,e,r){let{id:n,start:i,end:s,size:l}=h;if(h.next(),l>=0&&n<o){let o=r;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)r=m(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==l?u=n:-4==l&&(f=n);return r}let b=[],x=[];for(;h.pos>0;)a(t.start||0,t.bufferStart||0,b,x,-1);let y=null!==(e=t.length)&&void 0!==e?e:b.length?x[0]+b[0].length:0;return new z(l[t.topID],b.reverse(),x.reverse(),y)}(t)}}z.empty=new z(I.none,[],[],0);class q{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new q(this.buffer,this.index)}}class R{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return I.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let h=t;h!=e&&!(L(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(t,e,r,n){let i=this.buffer,s=new Uint16Array(e-t);for(let o=t,h=0;o<e;)s[h++]=i[o++],s[h++]=i[o++]-r,s[h++]=i[o++]-r,s[h++]=i[o++]-t;return new R(s,n-r,this.set)}}function L(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function D(t,e){let r=t.childBefore(e);for(;r;){let e=r.lastChild;if(!e||e.to!=r.to)break;e.type.isError&&e.from==e.to?(t=r,r=e.prevSibling):r=e}return t}function U(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof H&&t.index<0?null:t.parent;if(!e)return t;t=e}if(n)for(let s=t,o=s.parent;o;s=o,o=s.parent)s instanceof H&&s.index<0&&(null===(i=o.enter(e,r,!0))||void 0===i?void 0:i.from)!=s.from&&(t=o);for(;;){let i=t.enter(e,r,n);if(!i)return t;t=i}}class H{constructor(t,e,r,n){this.node=t,this._from=e,this.index=r,this._parent=n}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s.node,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],u=h[t]+s._from;if(L(n,r,u,u+l.length))if(l instanceof R){if(2&i)continue;let o=l.findChild(0,l.buffer.length,e,r-u,n);if(o>-1)return new $(new F(s,l,t,u),null,o)}else if(1&i||!l.type.isAnonymous||Z(l)){let o;if(!(1&i)&&l.props&&(o=l.prop(B.mounted))&&!o.overlay)return new H(o.tree,u,t,s);let h=new H(l,u,t,s);return 1&i||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,r,n)}}if(1&i||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent.node.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}enter(t,e,r=!0,n=!0){let i;if(r&&(i=this.node.prop(B.mounted))&&i.overlay){let r=t-this.from;for(let{from:t,to:n}of i.overlay)if((e>0?t<=r:t<r)&&(e<0?n>=r:n>r))return new H(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n?0:2)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new J(this)}get tree(){return this.node}toTree(){return this.node}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}toString(){return this.node.toString()}}function V(t,e,r,n){let i=t.cursor,s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}class F{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class ${constructor(t,e,r){this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new $(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r,n=!0){if(!n)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new $(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new $(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new $(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get cursor(){return new J(this)}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1],o=r.buffer[this.index+2];t.push(r.slice(n,i,s,o)),e.push(0)}return new z(this.type,t,e,this.to-this.from)}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}}class J{constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof H)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}get name(){return this.type.name}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof H?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r.node.children.length;n!=i;n+=t){let t=r.node.children[n];if(1&this.mode||t instanceof R||!t.type.isAnonymous||Z(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)e=new $(this.buffer,e,this.stack[n]);return this.bufferNode=new $(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree.node}}function Z(t){return t.children.some((t=>t instanceof R||!t.type.isAnonymous||Z(t)))}const Y=new WeakMap;function G(t,e){if(!t.isAnonymous||e instanceof R||e.type!=t)return 1;let r=Y.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof z)){r=1;break}r+=G(t,n)}Y.set(e,r)}return r}function K(t,e,r,n,i,s,o,h,l){let u=0;for(let d=n;d<i;d++)u+=G(t,e[d]);let f=Math.ceil(1.5*u/8),a=[],c=[];return function e(r,n,i,o,h){for(let u=i;u<o;){let i=u,d=n[u],p=G(t,r[u]);for(u++;u<o;u++){let e=G(t,r[u]);if(p+e>=f)break;p+=e}if(u==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+h);continue}a.push(r[i])}else{let e=n[u-1]+r[u-1].length-d;a.push(K(t,r,n,i,u,d,e,null,l))}c.push(d+h-s)}}(e,r,n,i,0),(h||l)(a,c,o)}class Q{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new Q(0,t.length,t,0,!1,r)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let u=o<e.length?e[o]:null,f=u?u.fromA:1e9;if(f-h>=r)for(;s&&s.from<f;){let e=s;if(h>=e.from||f<=e.to||l){let t=Math.max(e.from,h)-l,r=Math.min(e.to,f)-l;e=t>=r?null:new Q(t,r,e.tree,e.offset+l,o>0,!!u)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!u)break;h=u.toA,l=u.toA-u.toB}return n}}class X{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new B({perNode:!0});const tt=new B;class et{constructor(t,e,r,n=[]){this.data=t,this.topNode=r,h.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(h.EditorState.prototype,"tree",{get(){return nt(this)}}),this.parser=e,this.extension=[at.of(this),h.EditorState.languageData.of(((t,e,r)=>t.facet(rt(t,e,r))))].concat(n)}isActiveAt(t,e,r=-1){return rt(t,e,r)==this.data}findRegions(t){let e=t.facet(at);if((null===e||void 0===e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(tt)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(B.mounted);if(i){if(i.tree.prop(tt)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof z&&n(i,t.positions[r]+e)}};return n(nt(t),0),r}get allowsNesting(){return!0}}function rt(t,e,r){let n=t.facet(at);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=nt(t).topNode;s;s=s.enter(e,r,!0,!1))i=s.type.prop(tt)||i;return i}et.setState=h.StateEffect.define();function nt(t){let e=t.field(et.state,!1);return e?e.tree:z.empty}class it{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.cursor=t.iter()}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let st=null;class ot{constructor(t,e,r=[],n,i,s,o,h){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new it(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=z.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;let n=Date.now()+t;for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let t=this.parse.advance();if(t){if(this.fragments=this.withoutTempSkipped(Q.addTree(t,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=t,this.parse=null,!(this.treeLen<(null!==e&&void 0!==e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(Date.now()>n)return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Q.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=st;st=this;try{return t()}finally{st=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ht(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=Q.applyChanges(r,e),n=z.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new ot(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:e,to:n}=this.skipped[r];e<t.to&&n>t.from&&(this.fragments=ht(this.fragments,e,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends class{startParse(t,e,r){return"string"==typeof t&&(t=new X(t)),r=r?r.length?r.map((t=>new N(t.from,t.to))):[new N(0,0)]:[new N(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=st;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new z(I.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return st}}function ht(t,e,r){return Q.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class lt{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new lt(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=new ot(t.facet(at).parser,t,[],z.empty,0,{from:0,to:e},[],null);return r.work(20,e)||r.takeTree(),new lt(r)}}et.state=h.StateField.define({create:lt.init,update(t,e){for(let r of e.effects)if(r.is(et.setState))return r.value;return e.startState.facet(at)!=e.state.facet(at)?lt.init(e.state):t.apply(e)}});let ut=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(ut=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const ft=j.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(et.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(et.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=ut(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(et.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Math.min(this.chunkBudget,100,t?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,h=i.context.work(s,n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:et.setState.of(new lt(i.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,j.logException)(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return this.working||this.workScheduled>0}},{eventHandlers:{focus(){this.scheduleWork()}}}),at=h.Facet.define({combine:t=>t.length?t[0]:null,enables:[et.state,ft]});const ct=h.Facet.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function dt(t){let e=t.facet(ct);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function pt(t,e){let r="",n=t.tabSize;if(9==t.facet(ct).charCodeAt(0))for(;e>=n;)r+="\t",e-=n;for(let i=0;i<e;i++)r+=" ";return r}function gt(t,e){let r=-1;return t.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=t.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(e(s,i,n),r=s.number),o=s.to+1}let s=t.changes(i);return{changes:i,range:h.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const mt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(gt(t,((e,r)=>{r.push({from:e.from,insert:t.facet(ct)})})),{userEvent:"input.indent"})),!0),bt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(gt(t,((e,r)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let i=x(n,t.tabSize),s=0,o=pt(t,Math.max(0,i-dt(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),xt={key:"Tab",run:mt,shift:bt};var yt=r(362),wt=j.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function vt(t){var e=t.value,r=t.selection,n=t.onChange,l=t.onUpdate,u=t.extensions,f=void 0===u?[]:u,a=t.autoFocus,c=t.theme,d=void 0===c?"light":c,p=t.height,g=void 0===p?"":p,m=t.minHeight,b=void 0===m?"":m,x=t.maxHeight,y=void 0===x?"":x,w=t.placeholder,v=void 0===w?"":w,k=t.width,S=void 0===k?"":k,C=t.minWidth,O=void 0===C?"":C,_=t.maxWidth,A=void 0===_?"":_,P=t.editable,E=void 0===P||P,N=t.indentWithTab,B=void 0===N||N,T=t.basicSetup,I=void 0===T||T,M=t.root,W=i((0,s.useState)(t.container),2),z=W[0],q=W[1],R=i((0,s.useState)(),2),L=R[0],D=R[1],U=i((0,s.useState)(),2),H=U[0],V=U[1],F=j.EditorView.theme({"&":{height:g,minHeight:b,maxHeight:y,width:S,minWidth:O,maxWidth:A}}),$=[j.EditorView.updateListener.of((function(t){if(t.docChanged&&"function"===typeof n){var e=t.state.doc.toString();n(e,t)}})),F];switch(B&&$.unshift(j.keymap.of([xt])),I&&$.unshift(o.basicSetup),v&&$.unshift((0,j.placeholder)(v)),d){case"light":$.push(wt);break;case"dark":$.push(yt.oneDark);break;default:$.push(d)}return!1===E&&$.push(j.EditorView.editable.of(!1)),l&&"function"===typeof l&&$.push(j.EditorView.updateListener.of(l)),$=$.concat(f),(0,s.useEffect)((function(){if(z&&!H){var t=h.EditorState.create({doc:e,selection:r,extensions:$});if(V(t),!L){var n=new j.EditorView({state:t,parent:z,root:M});D(n)}}return function(){L&&D(void 0)}}),[z,H]),(0,s.useEffect)((function(){return function(){L&&(L.destroy(),D(void 0))}}),[L]),(0,s.useEffect)((function(){a&&L&&L.focus()}),[a,L]),(0,s.useEffect)((function(){var t=L?L.state.doc.toString():"";L&&e!==t&&L.dispatch({changes:{from:0,to:t.length,insert:e||""}})}),[e,L]),(0,s.useEffect)((function(){L&&L.dispatch({effects:h.StateEffect.reconfigure.of($)})}),[d,f,g,b,y,S,v,O,A,E,B,I]),{state:H,setState:V,view:L,setView:D,container:z,setContainer:q}}},323:t=>{var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(t,s){for(var o,h,l=i(t),u=1;u<arguments.length;u++){for(var f in o=Object(arguments[u]))r.call(o,f)&&(l[f]=o[f]);if(e){h=e(o);for(var a=0;a<h.length;a++)n.call(o,h[a])&&(l[h[a]]=o[h[a]])}}return l}},638:(t,e,r)=>{r(323);var n=r(787),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var s=Symbol.for;i=s("react.element"),s("react.fragment")}var o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h=Object.prototype.hasOwnProperty,l={key:!0,ref:!0,__self:!0,__source:!0};function u(t,e,r){var n,s={},u=null,f=null;for(n in void 0!==r&&(u=""+r),void 0!==e.key&&(u=""+e.key),void 0!==e.ref&&(f=e.ref),e)h.call(e,n)&&!l.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===s[n]&&(s[n]=e[n]);return{$$typeof:i,type:t,key:u,ref:f,props:s,_owner:o.current}}e.jsx=u},724:(t,e,r)=>{t.exports=r(638)},787:e=>{e.exports=t},573:t=>{t.exports=e},242:t=>{t.exports=r},362:t=>{t.exports=n},105:t=>{t.exports=i},683:(t,e,r)=>{function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}r.d(e,{Z:()=>s})},925:(t,e,r)=>{function n(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},s=Object.keys(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}r.d(e,{Z:()=>n})}},o={};function h(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return s[t](r,r.exports,h),r.exports}h.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{for(var r in e)h.o(e,r)&&!h.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),h.r=t=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{h.r(l),h.d(l,{default:()=>p,useCodeMirror:()=>i.U});var t=h(683),e=h(925),r=h(787),n=h.n(r),i=h(497),s=h(724),o=h(105),u={};for(const h in o)"default"!==h&&(u[h]=()=>o[h]);h.d(l,u);var f=h(573);u={};for(const h in f)"default"!==h&&(u[h]=()=>f[h]);h.d(l,u);var a=h(242);u={};for(const h in a)"default"!==h&&(u[h]=()=>a[h]);h.d(l,u);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","root"],d=n().forwardRef((function(n,o){var h=n.className,l=n.value,u=void 0===l?"":l,f=n.selection,a=n.extensions,d=void 0===a?[]:a,p=n.onChange,g=n.onUpdate,m=n.autoFocus,b=n.theme,x=void 0===b?"light":b,y=n.height,w=n.minHeight,v=n.maxHeight,k=n.width,S=n.minWidth,C=n.maxWidth,O=n.basicSetup,_=n.placeholder,A=n.indentWithTab,j=n.editable,P=n.root,E=(0,e.Z)(n,c),N=(0,r.useRef)(null),B=(0,i.U)({container:N.current,root:P,value:u,autoFocus:m,theme:x,height:y,minHeight:w,maxHeight:v,width:k,minWidth:S,maxWidth:C,basicSetup:O,placeholder:_,indentWithTab:A,editable:j,selection:f,onChange:p,onUpdate:g,extensions:d}),T=B.state,I=B.view,M=B.container,W=B.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:M,state:T,view:I}}),[M,T,I]),(0,r.useEffect)((function(){W(N.current)}),[]),"string"!==typeof u)throw new Error("value must be typeof string but got ".concat(typeof u));var z="string"===typeof x?"cm-theme-".concat(x):"cm-theme";return(0,s.jsx)("div",(0,t.Z)({ref:N,className:"".concat(z).concat(h?" ".concat(h):"")},E))}));d.displayName="CodeMirror";const p=d})(),l})()}));
|
|
2
|
+
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],e):"object"===typeof exports?exports["@uiw/codemirror"]=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):t["@uiw/codemirror"]=e(t.React,t.CM["@codemirror/basic-setup"],t.CM["@codemirror/state"],t.CM["@codemirror/theme-one-dark"],t.CM["@codemirror/view"])}(self,((t,e,r,n,i)=>(()=>{"use strict";var s={497:(t,e,r)=>{function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s=[],o=!0,h=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(l){h=!0,i=l}finally{try{o||null==r.return||r.return()}finally{if(h)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"===typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.d(e,{U:()=>St});var s=r(787),o=r(573),h=r(242);let l="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let Ct=1;Ct<l.length;Ct++)l[Ct]+=l[Ct-1];function u(t){for(let e=1;e<l.length;e+=2)if(l[e]>t)return l[e-1]<=t;return!1}function f(t){return t>=127462&&t<=127487}function a(t,e,r=!0,n=!0){return(r?c:d)(t,e,n)}function c(t,e,r){if(e==t.length)return e;e&&p(t.charCodeAt(e))&&g(t.charCodeAt(e-1))&&e--;let n=m(t,e);for(e+=x(n);e<t.length;){let i=m(t,e);if(8205==n||8205==i||r&&u(i))e+=x(i),n=i;else{if(!f(i))break;{let r=0,n=e-2;for(;n>=0&&f(m(t,n));)r++,n-=2;if(r%2==0)break;e+=2}}}return e}function d(t,e,r){for(;e>0;){let n=c(t,e-2,r);if(n<e)return n;e--}return 0}function p(t){return t>=56320&&t<57344}function g(t){return t>=55296&&t<56320}function m(t,e){let r=t.charCodeAt(e);if(!g(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return p(n)?n-56320+(r-55296<<10)+65536:r}function x(t){return t<65536?1:2}function b(t,e,r=t.length){let n=0;for(let i=0;i<r;)9==t.charCodeAt(i)?(n+=e-n%e,i++):(n++,i=a(t,i));return n}class y{constructor(){}lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,r){let n=[];return this.decompose(0,t,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(e,this.length,n,1),v.from(n,this.length-(e-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let r=[];return this.decompose(t,e,r,0),v.from(r,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),n=new C(this),i=new C(t);for(let s=e,o=e;;){if(n.next(s),i.next(s),s=0,n.lineBreak!=i.lineBreak||n.done!=i.done||n.value!=i.value)return!1;if(o+=n.value.length,n.done||o>=r)return!0}}iter(t=1){return new C(this,t)}iterRange(t,e=this.length){return new O(this,t,e)}iterLines(t,e){let r;if(null==t)r=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;r=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new w(t):v.from(w.split(t,[])):y.empty}}class w extends y{constructor(t,e=function(t){let e=-1;for(let r of t)e+=r.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.text[i],o=n+s.length;if((e?r:o)>=t)return new A(n,o,r,s);n=o+1,r++}}decompose(t,e,r,n){let i=t<=0&&e>=this.length?this:new w(S(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=r.pop(),e=k(i.text,t.text.slice(),0,i.length);if(e.length<=32)r.push(new w(e,t.length+i.length));else{let t=e.length>>1;r.push(new w(e.slice(0,t)),new w(e.slice(t)))}}else r.push(i)}replace(t,e,r){if(!(r instanceof w))return super.replace(t,e,r);let n=k(this.text,k(r.text,S(this.text,0,t)),e),i=this.length+r.length-(e-t);return n.length<=32?new w(n,i):v.from(w.split(n,[]),i)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<=e&&s<this.text.length;s++){let o=this.text[s],h=i+o.length;i>t&&s&&(n+=r),t<h&&e>i&&(n+=o.slice(Math.max(0,t-i),e-i)),i=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let r=[],n=-1;for(let i of t)r.push(i),n+=i.length+1,32==r.length&&(e.push(new w(r,n)),r=[],n=-1);return n>-1&&e.push(new w(r,n)),e}}class v extends y{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.children[i],o=n+s.length,h=r+s.lines-1;if((e?h:o)>=t)return s.lineInner(t,e,r,n);n=o+1,r=h+1}}decompose(t,e,r,n){for(let i=0,s=0;s<=e&&i<this.children.length;i++){let o=this.children[i],h=s+o.length;if(t<=h&&e>=s){let i=n&((s<=t?1:0)|(h>=e?2:0));s>=t&&h<=e&&!i?r.push(o):o.decompose(t-s,e-s,r,i)}s=h+1}}replace(t,e,r){if(r.lines<this.lines)for(let n=0,i=0;n<this.children.length;n++){let s=this.children[n],o=i+s.length;if(t>=i&&e<=o){let h=s.replace(t-i,e-i,r),l=this.lines-s.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let i=this.children.slice();return i[n]=h,new v(i,this.length-(e-t)+r.length)}return super.replace(i,o,h)}i=o+1}return super.replace(t,e,r)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<this.children.length&&s<=e;i++){let o=this.children[i],h=s+o.length;s>t&&i&&(n+=r),t<h&&e>s&&(n+=o.sliceString(t-s,e-s,r)),s=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof v))return 0;let r=0,[n,i,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,i+=e){if(n==s||i==o)return r;let h=this.children[n],l=t.children[i];if(h!=l)return r+h.scanIdentical(l,e);r+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let r=0;for(let c of t)r+=c.lines;if(r<32){let r=[];for(let e of t)e.flatten(r);return new w(r,e)}let n=Math.max(32,r>>5),i=n<<1,s=n>>1,o=[],h=0,l=-1,u=[];function f(t){let e;if(t.lines>i&&t instanceof v)for(let r of t.children)f(r);else t.lines>s&&(h>s||!h)?(a(),o.push(t)):t instanceof w&&h&&(e=u[u.length-1])instanceof w&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,u[u.length-1]=new w(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&a(),h+=t.lines,l+=t.length+1,u.push(t))}function a(){0!=h&&(o.push(1==u.length?u[0]:v.from(u,l)),l=-1,h=u.length=0)}for(let c of t)f(c);return a(),1==o.length?o[0]:new v(o,e)}}function k(t,e,r=0,n=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=n;s++){let h=t[s],l=i+h.length;l>=r&&(l>n&&(h=h.slice(0,n-i)),i<r&&(h=h.slice(r-i)),o?(e[e.length-1]+=h,o=!1):e.push(h)),i=l+1}return e}function S(t,e,r){return k(t,[""],e,r)}y.empty=new w([""],0);class C{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof w?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,n=this.nodes[r],i=this.offsets[r],s=i>>1,o=n instanceof w?n.text.length:n.children.length;if(s==(e>0?o:0)){if(0==r)return this.done=!0,this.value="",this;e>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(e>0?0:1)){if(this.offsets[r]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof w){let i=n.text[s+(e<0?-1:0)];if(this.offsets[r]+=e,i.length>Math.max(0,t))return this.value=0==t?i:e>0?i.slice(t):i.slice(0,i.length-t),this;t-=i.length}else{let i=n.children[s+(e<0?-1:0)];t>i.length?(t-=i.length,this.offsets[r]+=e):(e<0&&this.offsets[r]--,this.nodes.push(i),this.offsets.push(e>0?1:(i instanceof w?i.text.length:i.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class O{constructor(t,e,r){this.value="",this.done=!1,this.cursor=new C(t,e>r?-1:1),this.pos=e>r?t.length:0,this.from=Math.min(e,r),this.to=Math.max(e,r)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let r=e<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=r?n:e<0?n.slice(n.length-r):n.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class _{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:r,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(y.prototype[Symbol.iterator]=function(){return this.iter()},C.prototype[Symbol.iterator]=O.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=function(){return this});class A{constructor(t,e,r,n){this.from=t,this.to=e,this.number=r,this.text=n}get length(){return this.to-this.from}}var P=r(105);const E=1024;let j=0;class B{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=j++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=I.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}N.closedBy=new N({deserialize:t=>t.split(" ")}),N.openedBy=new N({deserialize:t=>t.split(" ")}),N.group=new N({deserialize:t=>t.split(" ")}),N.contextHash=new N({perNode:!0}),N.lookAhead=new N({perNode:!0}),N.mounted=new N({perNode:!0});const T=Object.create(null);class I{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):T,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new I(t.name||"",e,t.id,r);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(N.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(N.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}I.none=new I("",Object.create(null),0,8);const M=new WeakMap,W=new WeakMap;class z{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(N.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let r of this.children){let t=r.toString();t&&(e&&(e+=","),e+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t,e=0){let r=null!=t&&M.get(this)||this.topNode,n=new J(r);return null!=t&&(n.moveTo(t,e),M.set(this,n._tree)),n}fullCursor(){return new J(this.topNode,1)}get topNode(){return new H(this,0,0,null)}resolve(t,e=0){let r=U(M.get(this)||this.topNode,t,e,!1);return M.set(this,r),r}resolveInner(t,e=0){let r=U(W.get(this)||this.topNode,t,e,!0);return W.set(this,r),r}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t;for(let s=this.cursor(),o=()=>s.node;;){let t=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==e(s.type,s.from,s.to,o))){if(s.firstChild())continue;s.type.isAnonymous||(t=!0)}for(;t&&r&&r(s.type,s.from,s.to,o),t=s.type.isAnonymous,!s.nextSibling();){if(!s.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:K(I.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new z(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new z(I.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=E,reused:s=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(r)?new R(r,r.length):r,l=n.types,u=0,f=0;function a(t,e,r,x,b){let{id:y,start:w,end:v,size:k}=h,S=f;for(;k<0;){if(h.next(),-1==k){let e=s[y];return r.push(e),void x.push(w-t)}if(-3==k)return void(u=y);if(-4==k)return void(f=y);throw new RangeError(`Unrecognized record size: ${k}`)}let C,O,_=l[y],A=w-t;if(v-w<=i&&(O=g(h.pos-e,b))){let e=new Uint16Array(O.size-O.skip),r=h.pos-O.size,i=e.length;for(;h.pos>r;)i=m(O.start,e,i);C=new L(e,v-O.start,n),A=O.start-t}else{let t=h.pos-k;h.next();let e=[],r=[],n=y>=o?y:-1,s=0,l=v;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-i&&(d(e,r,w,s,h.end,l,n,S),s=e.length,l=h.end),h.next()):a(w,t,e,r,n);if(n>=0&&s>0&&s<e.length&&d(e,r,w,s,w,l,n,S),e.reverse(),r.reverse(),n>-1&&s>0){let t=c(_);C=K(_,e,r,0,e.length,0,v-w,t,t)}else C=p(_,e,r,v-w,S-v)}r.push(C),x.push(A)}function c(t){return(e,r,n)=>{let i,s,o=0,h=e.length-1;if(h>=0&&(i=e[h])instanceof z){if(!h&&i.type==t&&i.length==n)return i;(s=i.prop(N.lookAhead))&&(o=r[h]+i.length+s)}return p(t,e,r,n,o)}}function d(t,e,r,i,s,o,h,l){let u=[],f=[];for(;t.length>i;)u.push(t.pop()),f.push(e.pop()+r-s);t.push(p(n.types[h],u,f,o-s,l-o)),e.push(s-r)}function p(t,e,r,n,i=0,s){if(u){let t=[N.contextHash,u];s=s?[t].concat(s):[t]}if(i>25){let t=[N.lookAhead,i];s=s?[t].concat(s):[t]}return new z(t,e,r,n,s)}function g(t,e){let r=h.fork(),n=0,s=0,l=0,u=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=l,l+=4,n+=4,r.next();continue}let h=r.pos-t;if(t<0||h<i||r.start<u)break;let a=r.id>=o?4:0,c=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break t;a+=4}else r.id>=o&&(a+=4);r.next()}s=c,n+=t,l+=a}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=l),f.size>4?f:void 0}function m(t,e,r){let{id:n,start:i,end:s,size:l}=h;if(h.next(),l>=0&&n<o){let o=r;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)r=m(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==l?u=n:-4==l&&(f=n);return r}let x=[],b=[];for(;h.pos>0;)a(t.start||0,t.bufferStart||0,x,b,-1);let y=null!==(e=t.length)&&void 0!==e?e:x.length?b[0]+x[0].length:0;return new z(l[t.topID],x.reverse(),b.reverse(),y)}(t)}}z.empty=new z(I.none,[],[],0);class R{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new R(this.buffer,this.index)}}class L{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return I.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let h=t;h!=e&&!(q(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(t,e,r,n){let i=this.buffer,s=new Uint16Array(e-t);for(let o=t,h=0;o<e;)s[h++]=i[o++],s[h++]=i[o++]-r,s[h++]=i[o++]-r,s[h++]=i[o++]-t;return new L(s,n-r,this.set)}}function q(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function D(t,e){let r=t.childBefore(e);for(;r;){let e=r.lastChild;if(!e||e.to!=r.to)break;e.type.isError&&e.from==e.to?(t=r,r=e.prevSibling):r=e}return t}function U(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof H&&t.index<0?null:t.parent;if(!e)return t;t=e}if(n)for(let s=t,o=s.parent;o;s=o,o=s.parent)s instanceof H&&s.index<0&&(null===(i=o.enter(e,r,!0))||void 0===i?void 0:i.from)!=s.from&&(t=o);for(;;){let i=t.enter(e,r,n);if(!i)return t;t=i}}class H{constructor(t,e,r,n){this.node=t,this._from=e,this.index=r,this._parent=n}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s.node,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],u=h[t]+s._from;if(q(n,r,u,u+l.length))if(l instanceof L){if(2&i)continue;let o=l.findChild(0,l.buffer.length,e,r-u,n);if(o>-1)return new $(new F(s,l,t,u),null,o)}else if(1&i||!l.type.isAnonymous||Z(l)){let o;if(!(1&i)&&l.props&&(o=l.prop(N.mounted))&&!o.overlay)return new H(o.tree,u,t,s);let h=new H(l,u,t,s);return 1&i||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,r,n)}}if(1&i||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent.node.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}enter(t,e,r=!0,n=!0){let i;if(r&&(i=this.node.prop(N.mounted))&&i.overlay){let r=t-this.from;for(let{from:t,to:n}of i.overlay)if((e>0?t<=r:t<r)&&(e<0?n>=r:n>r))return new H(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n?0:2)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new J(this)}get tree(){return this.node}toTree(){return this.node}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}toString(){return this.node.toString()}}function V(t,e,r,n){let i=t.cursor,s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}class F{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class ${constructor(t,e,r){this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new $(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r,n=!0){if(!n)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new $(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new $(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new $(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get cursor(){return new J(this)}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1],o=r.buffer[this.index+2];t.push(r.slice(n,i,s,o)),e.push(0)}return new z(this.type,t,e,this.to-this.from)}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}}class J{constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof H)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}get name(){return this.type.name}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof H?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r.node.children.length;n!=i;n+=t){let t=r.node.children[n];if(1&this.mode||t instanceof L||!t.type.isAnonymous||Z(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)e=new $(this.buffer,e,this.stack[n]);return this.bufferNode=new $(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree.node}}function Z(t){return t.children.some((t=>t instanceof L||!t.type.isAnonymous||Z(t)))}const Y=new WeakMap;function G(t,e){if(!t.isAnonymous||e instanceof L||e.type!=t)return 1;let r=Y.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof z)){r=1;break}r+=G(t,n)}Y.set(e,r)}return r}function K(t,e,r,n,i,s,o,h,l){let u=0;for(let d=n;d<i;d++)u+=G(t,e[d]);let f=Math.ceil(1.5*u/8),a=[],c=[];return function e(r,n,i,o,h){for(let u=i;u<o;){let i=u,d=n[u],p=G(t,r[u]);for(u++;u<o;u++){let e=G(t,r[u]);if(p+e>=f)break;p+=e}if(u==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+h);continue}a.push(r[i])}else{let e=n[u-1]+r[u-1].length-d;a.push(K(t,r,n,i,u,d,e,null,l))}c.push(d+h-s)}}(e,r,n,i,0),(h||l)(a,c,o)}class Q{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new Q(0,t.length,t,0,!1,r)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let u=o<e.length?e[o]:null,f=u?u.fromA:1e9;if(f-h>=r)for(;s&&s.from<f;){let e=s;if(h>=e.from||f<=e.to||l){let t=Math.max(e.from,h)-l,r=Math.min(e.to,f)-l;e=t>=r?null:new Q(t,r,e.tree,e.offset+l,o>0,!!u)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!u)break;h=u.toA,l=u.toA-u.toB}return n}}class X{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new N({perNode:!0});var tt;const et=new N;class rt{constructor(t,e,r,n=[]){this.data=t,this.topNode=r,h.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(h.EditorState.prototype,"tree",{get(){return it(this)}}),this.parser=e,this.extension=[dt.of(this),h.EditorState.languageData.of(((t,e,r)=>t.facet(nt(t,e,r))))].concat(n)}isActiveAt(t,e,r=-1){return nt(t,e,r)==this.data}findRegions(t){let e=t.facet(dt);if((null===e||void 0===e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(et)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(N.mounted);if(i){if(i.tree.prop(et)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof z&&n(i,t.positions[r]+e)}};return n(it(t),0),r}get allowsNesting(){return!0}}function nt(t,e,r){let n=t.facet(dt);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=it(t).topNode;s;s=s.enter(e,r,!0,!1))i=s.type.prop(et)||i;return i}rt.setState=h.StateEffect.define();function it(t){let e=t.field(rt.state,!1);return e?e.tree:z.empty}class st{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.cursor=t.iter()}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let ot=null;class ht{constructor(t,e,r=[],n,i,s,o,h){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new st(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=z.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Q.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!==e&&void 0!==e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Q.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ot;ot=this;try{return t()}finally{ot=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=lt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=Q.applyChanges(r,e),n=z.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new ht(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:e,to:n}=this.skipped[r];e<t.to&&n>t.from&&(this.fragments=lt(this.fragments,e,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends class{startParse(t,e,r){return"string"==typeof t&&(t=new X(t)),r=r?r.length?r.map((t=>new B(t.from,t.to))):[new B(0,0)]:[new B(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=ot;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new z(I.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return ot}}function lt(t,e,r){return Q.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class ut{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new ut(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=new ht(t.facet(dt).parser,t,[],z.empty,0,{from:0,to:e},[],null);return r.work(20,e)||r.takeTree(),new ut(r)}}rt.state=h.StateField.define({create:ut.init,update(t,e){for(let r of e.effects)if(r.is(rt.setState))return r.value;return e.startState.facet(dt)!=e.state.facet(dt)?ut.init(e.state):t.apply(e)}});let ft=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(ft=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const at="undefined"!=typeof navigator&&(null===(tt=navigator.scheduling)||void 0===tt?void 0:tt.isInputPending)?()=>navigator.scheduling.isInputPending():null,ct=P.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(rt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(rt.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=ft(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(rt.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!at?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,h=i.context.work((()=>at&&at()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rt.setState.of(new ut(i.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,P.logException)(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),dt=h.Facet.define({combine:t=>t.length?t[0]:null,enables:[rt.state,ct]});const pt=h.Facet.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function gt(t){let e=t.facet(pt);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function mt(t,e){let r="",n=t.tabSize;if(9==t.facet(pt).charCodeAt(0))for(;e>=n;)r+="\t",e-=n;for(let i=0;i<e;i++)r+=" ";return r}function xt(t,e){let r=-1;return t.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=t.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(e(s,i,n),r=s.number),o=s.to+1}let s=t.changes(i);return{changes:i,range:h.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const bt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xt(t,((e,r)=>{r.push({from:e.from,insert:t.facet(pt)})})),{userEvent:"input.indent"})),!0),yt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xt(t,((e,r)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let i=b(n,t.tabSize),s=0,o=mt(t,Math.max(0,i-gt(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),wt={key:"Tab",run:bt,shift:yt};var vt=r(362),kt=P.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function St(t){var e=t.value,r=t.selection,n=t.onChange,l=t.onUpdate,u=t.extensions,f=void 0===u?[]:u,a=t.autoFocus,c=t.theme,d=void 0===c?"light":c,p=t.height,g=void 0===p?"":p,m=t.minHeight,x=void 0===m?"":m,b=t.maxHeight,y=void 0===b?"":b,w=t.placeholder,v=void 0===w?"":w,k=t.width,S=void 0===k?"":k,C=t.minWidth,O=void 0===C?"":C,_=t.maxWidth,A=void 0===_?"":_,E=t.editable,j=void 0===E||E,B=t.readOnly,N=void 0!==B&&B,T=t.indentWithTab,I=void 0===T||T,M=t.basicSetup,W=void 0===M||M,z=t.root,R=i((0,s.useState)(t.container),2),L=R[0],q=R[1],D=i((0,s.useState)(),2),U=D[0],H=D[1],V=i((0,s.useState)(),2),F=V[0],$=V[1],J=P.EditorView.theme({"&":{height:g,minHeight:x,maxHeight:y,width:S,minWidth:O,maxWidth:A}}),Z=[P.EditorView.updateListener.of((function(t){if(t.docChanged&&"function"===typeof n){var e=t.state.doc.toString();n(e,t)}})),J];switch(I&&Z.unshift(P.keymap.of([wt])),W&&Z.unshift(o.basicSetup),v&&Z.unshift((0,P.placeholder)(v)),d){case"light":Z.push(kt);break;case"dark":Z.push(vt.oneDark);break;default:Z.push(d)}return!1===j&&Z.push(P.EditorView.editable.of(!1)),N&&Z.push(h.EditorState.readOnly.of(!0)),l&&"function"===typeof l&&Z.push(P.EditorView.updateListener.of(l)),Z=Z.concat(f),(0,s.useEffect)((function(){if(L&&!F){var t=h.EditorState.create({doc:e,selection:r,extensions:Z});if($(t),!U){var n=new P.EditorView({state:t,parent:L,root:z});H(n)}}return function(){U&&H(void 0)}}),[L,F]),(0,s.useEffect)((function(){return function(){U&&(U.destroy(),H(void 0))}}),[U]),(0,s.useEffect)((function(){a&&U&&U.focus()}),[a,U]),(0,s.useEffect)((function(){var t=U?U.state.doc.toString():"";U&&e!==t&&U.dispatch({changes:{from:0,to:t.length,insert:e||""}})}),[e,U]),(0,s.useEffect)((function(){U&&U.dispatch({effects:h.StateEffect.reconfigure.of(Z)})}),[d,f,g,x,y,S,v,O,A,j,I,W]),{state:F,setState:$,view:U,setView:H,container:L,setContainer:q}}},638:(t,e,r)=>{var n=r(787),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,h=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(t,e,r){var n,s={},u=null,f=null;for(n in void 0!==r&&(u=""+r),void 0!==e.key&&(u=""+e.key),void 0!==e.ref&&(f=e.ref),e)o.call(e,n)&&!l.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===s[n]&&(s[n]=e[n]);return{$$typeof:i,type:t,key:u,ref:f,props:s,_owner:h.current}}e.jsx=u},724:(t,e,r)=>{t.exports=r(638)},787:e=>{e.exports=t},573:t=>{t.exports=e},242:t=>{t.exports=r},362:t=>{t.exports=n},105:t=>{t.exports=i},683:(t,e,r)=>{function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}r.d(e,{Z:()=>s})},925:(t,e,r)=>{function n(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},s=Object.keys(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}r.d(e,{Z:()=>n})}},o={};function h(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return s[t](r,r.exports,h),r.exports}h.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{for(var r in e)h.o(e,r)&&!h.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),h.r=t=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{h.r(l),h.d(l,{default:()=>p,useCodeMirror:()=>i.U});var t=h(683),e=h(925),r=h(787),n=h.n(r),i=h(497),s=h(724),o=h(105),u={};for(const h in o)"default"!==h&&(u[h]=()=>o[h]);h.d(l,u);var f=h(573);u={};for(const h in f)"default"!==h&&(u[h]=()=>f[h]);h.d(l,u);var a=h(242);u={};for(const h in a)"default"!==h&&(u[h]=()=>a[h]);h.d(l,u);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"],d=n().forwardRef((function(n,o){var h=n.className,l=n.value,u=void 0===l?"":l,f=n.selection,a=n.extensions,d=void 0===a?[]:a,p=n.onChange,g=n.onUpdate,m=n.autoFocus,x=n.theme,b=void 0===x?"light":x,y=n.height,w=n.minHeight,v=n.maxHeight,k=n.width,S=n.minWidth,C=n.maxWidth,O=n.basicSetup,_=n.placeholder,A=n.indentWithTab,P=n.editable,E=n.readOnly,j=n.root,B=(0,e.Z)(n,c),N=(0,r.useRef)(null),T=(0,i.U)({container:N.current,root:j,value:u,autoFocus:m,theme:b,height:y,minHeight:w,maxHeight:v,width:k,minWidth:S,maxWidth:C,basicSetup:O,placeholder:_,indentWithTab:A,editable:P,readOnly:E,selection:f,onChange:p,onUpdate:g,extensions:d}),I=T.state,M=T.view,W=T.container,z=T.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:W,state:I,view:M}}),[W,I,M]),(0,r.useEffect)((function(){z(N.current)}),[]),"string"!==typeof u)throw new Error("value must be typeof string but got ".concat(typeof u));var R="string"===typeof b?"cm-theme-".concat(b):"cm-theme";return(0,s.jsx)("div",(0,t.Z)({ref:N,className:"".concat(R).concat(h?" ".concat(h):"")},B))}));d.displayName="CodeMirror";const p=d})(),l})()));
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "root"];
|
|
3
|
+
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root"];
|
|
4
4
|
import React, { useEffect, useRef, useImperativeHandle } from 'react';
|
|
5
5
|
import { useCodeMirror } from './useCodeMirror';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -28,6 +28,7 @@ var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
28
28
|
placeholder,
|
|
29
29
|
indentWithTab,
|
|
30
30
|
editable,
|
|
31
|
+
readOnly,
|
|
31
32
|
root
|
|
32
33
|
} = props,
|
|
33
34
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
@@ -54,6 +55,7 @@ var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
54
55
|
placeholder,
|
|
55
56
|
indentWithTab,
|
|
56
57
|
editable,
|
|
58
|
+
readOnly,
|
|
57
59
|
selection,
|
|
58
60
|
onChange,
|
|
59
61
|
onUpdate,
|
package/esm/index.js.map
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"placeholder",
|
|
32
32
|
"indentWithTab",
|
|
33
33
|
"editable",
|
|
34
|
+
"readOnly",
|
|
34
35
|
"root",
|
|
35
36
|
"other",
|
|
36
37
|
"editor",
|
|
@@ -43,8 +44,8 @@
|
|
|
43
44
|
"defaultClassNames",
|
|
44
45
|
"displayName"
|
|
45
46
|
],
|
|
46
|
-
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,kBAAd;AACA,cAAc,yBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;
|
|
47
|
+
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,kBAAd;AACA,cAAc,yBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AA8DA,IAAMC,eAAe,gBAAGL,KAAK,CAACM,UAAN,CAA2D,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjG,MAAM;AACJC,IAAAA,SADI;AAEJC,IAAAA,KAAK,GAAG,EAFJ;AAGJC,IAAAA,SA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AAA4BC,IAAAA;AAA5B,GAAP,CAAN,EAAkD,CAACC,SAAD,EAAYF,KAAZ,EAAmBC,IAAnB,CAAlD,CAAnB;AACA/B,EAAAA,SAAS,CAAC,MAAM;AACdiC,IAAAA,YAAY,CAACJ,MAAM,CAACK,OAAR,CAAZ,CADc,CAEd;AACD,GAHQ,EAGN,EAHM,CAAT,CAhDiG,CAqDjG;;AACA,MAAI,OAAOzB,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAI0B,KAAJ,0CAAiD,OAAO1B,KAAxD,CAAN;AACD;;AAED,MAAM2B,iBAAiB,GAAG,OAAOrB,KAAP,KAAiB,QAAjB,iBAAwCA,KAAxC,GAAkD,UAA5E;AACA,sBAAO;AAAK,IAAA,GAAG,EAAEc,MAAV;AAAkB,IAAA,SAAS,OAAKO,iBAAL,IAAyB5B,SAAS,SAAOA,SAAP,GAAqB,EAAvD;AAA3B,KAA4FoB,KAA5F,EAAP;AACD,CA5DuB,CAAxB;AA8DAxB,eAAe,CAACiC,WAAhB,GAA8B,YAA9B;AAEA,eAAejC,eAAf",
|
|
47
48
|
"sourcesContent": [
|
|
48
|
-
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
|
|
49
|
+
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n readOnly?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
|
|
49
50
|
]
|
|
50
51
|
}
|
package/esm/useCodeMirror.js
CHANGED
|
@@ -22,6 +22,7 @@ export function useCodeMirror(props) {
|
|
|
22
22
|
minWidth = '',
|
|
23
23
|
maxWidth = '',
|
|
24
24
|
editable = true,
|
|
25
|
+
readOnly = false,
|
|
25
26
|
indentWithTab: defaultIndentWithTab = true,
|
|
26
27
|
basicSetup: defaultBasicSetup = true,
|
|
27
28
|
root
|
|
@@ -80,6 +81,10 @@ export function useCodeMirror(props) {
|
|
|
80
81
|
getExtensions.push(EditorView.editable.of(false));
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
if (readOnly) {
|
|
85
|
+
getExtensions.push(EditorState.readOnly.of(true));
|
|
86
|
+
}
|
|
87
|
+
|
|
83
88
|
if (onUpdate && typeof onUpdate === 'function') {
|
|
84
89
|
getExtensions.push(EditorView.updateListener.of(onUpdate));
|
|
85
90
|
}
|
package/esm/useCodeMirror.js.map
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"minWidth",
|
|
33
33
|
"maxWidth",
|
|
34
34
|
"editable",
|
|
35
|
+
"readOnly",
|
|
35
36
|
"defaultIndentWithTab",
|
|
36
37
|
"defaultBasicSetup",
|
|
37
38
|
"root",
|
|
@@ -69,8 +70,8 @@
|
|
|
69
70
|
"effects",
|
|
70
71
|
"reconfigure"
|
|
71
72
|
],
|
|
72
|
-
"mappings": "AAAA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,OAApC;AACA,SAASC,UAAT,QAA2B,yBAA3B;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,mBAAzC;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,UAAT,EAAqBC,MAArB,EAAyCC,WAAzC,QAA4D,kBAA5D;AACA,SAASC,OAAT,QAAwB,4BAA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T;AASAlC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIkC,IAAJ,EAAU;AACRA,MAAAA,IAAI,CAACuB,QAAL,CAAc;AAAEM,QAAAA,OAAO,EAAE3D,WAAW,CAAC4D,WAAZ,CAAwBxB,EAAxB,CAA2BK,aAA3B;AAAX,OAAd;AACD,KAHa,CAId;;AACD,GALQ,EAKN,CACD1B,KADC,EAEDF,UAFC,EAGDG,MAHC,EAIDC,SAJC,EAKDC,SALC,EAMDE,KANC,EAODD,cAPC,EAQDE,QARC,EASDC,QATC,EAUDC,QAVC,EAWDE,oBAXC,EAYDC,iBAZC,CALM,CAAT;AAoBA,SAAO;AAAEM,IAAAA,KAAF;AAASC,IAAAA,QAAT;AAAmBH,IAAAA,IAAnB;AAAyBC,IAAAA,OAAzB;AAAkCH,IAAAA,SAAlC;AAA6CC,IAAAA;AAA7C,GAAP;AACD",
|
|
73
74
|
"sourcesContent": [
|
|
74
|
-
"import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
75
|
+
"import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n readOnly = false,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n if (readOnly) {\n getExtensions.push(EditorState.readOnly.of(true));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n return () => {\n if (view) {\n setView(undefined);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => {\n if (autoFocus && view) {\n view.focus();\n }\n }, [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
75
76
|
]
|
|
76
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-codemirror",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "CodeMirror component for React.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-codemirror",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"react-dom": ">=16.8.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@babel/runtime": "
|
|
64
|
+
"@babel/runtime": ">=7.11.0",
|
|
65
65
|
"@codemirror/basic-setup": "^0.19.1",
|
|
66
66
|
"@codemirror/state": "^0.19.9",
|
|
67
67
|
"@codemirror/theme-one-dark": "^0.19.1",
|
|
@@ -86,22 +86,23 @@
|
|
|
86
86
|
"@kkt/ncc": "~1.0.8",
|
|
87
87
|
"@kkt/raw-modules": "~7.1.1",
|
|
88
88
|
"@kkt/scope-plugin-options": "~7.1.1",
|
|
89
|
-
"@
|
|
90
|
-
"@types/react
|
|
89
|
+
"@testing-library/react": "^13.0.0",
|
|
90
|
+
"@types/react": "~18.0.1",
|
|
91
|
+
"@types/react-dom": "~18.0.0",
|
|
91
92
|
"@types/react-test-renderer": "~17.0.1",
|
|
92
|
-
"@uiw/react-github-corners": "~1.5.
|
|
93
|
-
"@uiw/react-markdown-preview": "~4.0.
|
|
94
|
-
"@uiw/react-shields": "~1.1.
|
|
93
|
+
"@uiw/react-github-corners": "~1.5.14",
|
|
94
|
+
"@uiw/react-markdown-preview": "~4.0.5",
|
|
95
|
+
"@uiw/react-shields": "~1.1.3",
|
|
95
96
|
"@uiw/reset.css": "~1.0.5",
|
|
96
97
|
"@wcj/dark-mode": "~1.0.12",
|
|
97
98
|
"code-example": "~3.3.1",
|
|
98
99
|
"husky": "~7.0.4",
|
|
99
100
|
"kkt": "~7.1.5",
|
|
100
101
|
"lint-staged": "~12.3.4",
|
|
101
|
-
"prettier": "~2.
|
|
102
|
-
"react": "~
|
|
103
|
-
"react-dom": "~
|
|
104
|
-
"react-test-renderer": "~
|
|
102
|
+
"prettier": "~2.6.0",
|
|
103
|
+
"react": "~18.0.0",
|
|
104
|
+
"react-dom": "~18.0.0",
|
|
105
|
+
"react-test-renderer": "~18.0.0",
|
|
105
106
|
"tsbb": "~3.7.0"
|
|
106
107
|
},
|
|
107
108
|
"browserslist": {
|
package/src/index.tsx
CHANGED
|
@@ -38,6 +38,7 @@ export interface ReactCodeMirrorProps
|
|
|
38
38
|
* @default true
|
|
39
39
|
*/
|
|
40
40
|
editable?: boolean;
|
|
41
|
+
readOnly?: boolean;
|
|
41
42
|
/**
|
|
42
43
|
* Whether to optional basicSetup by default
|
|
43
44
|
* @default true
|
|
@@ -87,6 +88,7 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
|
|
|
87
88
|
placeholder,
|
|
88
89
|
indentWithTab,
|
|
89
90
|
editable,
|
|
91
|
+
readOnly,
|
|
90
92
|
root,
|
|
91
93
|
...other
|
|
92
94
|
} = props;
|
|
@@ -107,6 +109,7 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
|
|
|
107
109
|
placeholder,
|
|
108
110
|
indentWithTab,
|
|
109
111
|
editable,
|
|
112
|
+
readOnly,
|
|
110
113
|
selection,
|
|
111
114
|
onChange,
|
|
112
115
|
onUpdate,
|
package/src/useCodeMirror.ts
CHANGED
|
@@ -28,6 +28,7 @@ export function useCodeMirror(props: UseCodeMirror) {
|
|
|
28
28
|
minWidth = '',
|
|
29
29
|
maxWidth = '',
|
|
30
30
|
editable = true,
|
|
31
|
+
readOnly = false,
|
|
31
32
|
indentWithTab: defaultIndentWithTab = true,
|
|
32
33
|
basicSetup: defaultBasicSetup = true,
|
|
33
34
|
root,
|
|
@@ -79,6 +80,9 @@ export function useCodeMirror(props: UseCodeMirror) {
|
|
|
79
80
|
if (editable === false) {
|
|
80
81
|
getExtensions.push(EditorView.editable.of(false));
|
|
81
82
|
}
|
|
83
|
+
if (readOnly) {
|
|
84
|
+
getExtensions.push(EditorState.readOnly.of(true));
|
|
85
|
+
}
|
|
82
86
|
|
|
83
87
|
if (onUpdate && typeof onUpdate === 'function') {
|
|
84
88
|
getExtensions.push(EditorView.updateListener.of(onUpdate));
|