@uiw/react-codemirror 4.12.4 → 4.13.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.js +56 -71
- package/cjs/index.js.map +1 -1
- package/cjs/theme/light.js +0 -3
- package/cjs/theme/light.js.map +1 -1
- package/cjs/useCodeMirror.js +45 -78
- package/cjs/useCodeMirror.js.map +1 -1
- package/cjs/utils.js +0 -2
- package/cjs/utils.js.map +1 -1
- package/dist/mdeditor.js +89 -85
- package/dist/mdeditor.min.js +1 -1
- package/esm/index.js +27 -28
- package/esm/index.js.map +1 -1
- package/esm/theme/light.js.map +1 -1
- package/esm/useCodeMirror.js +2 -18
- package/esm/useCodeMirror.js.map +1 -1
- package/esm/utils.js.map +1 -1
- package/package.json +2 -2
package/esm/index.js
CHANGED
|
@@ -9,32 +9,31 @@ export * from './useCodeMirror';
|
|
|
9
9
|
export * from './utils';
|
|
10
10
|
var ReactCodeMirror = /*#__PURE__*/forwardRef((props, ref) => {
|
|
11
11
|
var {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
className,
|
|
13
|
+
value = '',
|
|
14
|
+
selection,
|
|
15
|
+
extensions = [],
|
|
16
|
+
onChange,
|
|
17
|
+
onStatistics,
|
|
18
|
+
onCreateEditor,
|
|
19
|
+
onUpdate,
|
|
20
|
+
autoFocus,
|
|
21
|
+
theme = 'light',
|
|
22
|
+
height,
|
|
23
|
+
minHeight,
|
|
24
|
+
maxHeight,
|
|
25
|
+
width,
|
|
26
|
+
minWidth,
|
|
27
|
+
maxWidth,
|
|
28
|
+
basicSetup,
|
|
29
|
+
placeholder,
|
|
30
|
+
indentWithTab,
|
|
31
|
+
editable,
|
|
32
|
+
readOnly,
|
|
33
|
+
root,
|
|
34
|
+
initialState
|
|
35
|
+
} = props,
|
|
36
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
38
37
|
var editor = useRef(null);
|
|
39
38
|
var {
|
|
40
39
|
state,
|
|
@@ -70,12 +69,12 @@ var ReactCodeMirror = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
70
69
|
editor: editor.current,
|
|
71
70
|
state: state,
|
|
72
71
|
view: view
|
|
73
|
-
}), [editor, container, state, view]);
|
|
72
|
+
}), [editor, container, state, view]);
|
|
74
73
|
|
|
74
|
+
// check type of value
|
|
75
75
|
if (typeof value !== 'string') {
|
|
76
76
|
throw new Error("value must be typeof string but got " + typeof value);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
78
|
var defaultClassNames = typeof theme === 'string' ? "cm-theme-" + theme : 'cm-theme';
|
|
80
79
|
return /*#__PURE__*/_jsx("div", _extends({
|
|
81
80
|
ref: editor,
|
package/esm/index.js.map
CHANGED
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"sourcesContent": [
|
|
50
50
|
"import React, { useRef, forwardRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension, StateField } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup';\nimport { useCodeMirror } from './useCodeMirror';\nimport { Statistics } from './utils';\n\nexport * from '@uiw/codemirror-extensions-basic-setup';\nexport * from './useCodeMirror';\nexport * from './utils';\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 | BasicSetupOptions;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default false\n */\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 /** Some data on the statistics editor. */\n onStatistics?(data: Statistics): void;\n /** Fired whenever any state change occurs within the editor, including non-document changes like lint results. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /** The first time the editor executes the event. */\n onCreateEditor?(view: EditorView, state: EditorState): 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 * Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function\n */\n initialState?: {\n json: any;\n fields?: Record<string, StateField<any>>;\n };\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onStatistics,\n onCreateEditor,\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 initialState,\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 onStatistics,\n onCreateEditor,\n onUpdate,\n extensions,\n initialState,\n });\n\n useImperativeHandle(ref, () => ({ editor: editor.current, state: state, view: view }), [\n editor,\n container,\n state,\n view,\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"
|
|
51
51
|
],
|
|
52
|
-
"mappings": ";;;AAAA,OAAOA,
|
|
52
|
+
"mappings": ";;;AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,UAAU,EAAEC,mBAAmB,QAAQ,OAAO;AAItE,SAASC,aAAa,QAAQ,iBAAiB;AAAC;AAGhD,cAAc,wCAAwC;AACtD,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AA6EvB,IAAMC,eAAe,gBAAGH,UAAU,CAA2C,CAACI,KAAK,EAAEC,GAAG,KAAK;EAC3F,IAAM;MACJC,SAAS;MACTC,KAAK,GAAG,EAAE;MACVC,SAAS;MACTC,UA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AAO;IAAC,SAAS,OAAKO,iBAAiB,IAAG/B,SAAS,SAAOA,SAAS,GAAK,EAAE;EAAG,GAAKuB,KAAK,EAAQ;AAClH,CAAC,CAAC;AAEF1B,eAAe,CAACmC,WAAW,GAAG,YAAY;AAE1C,eAAenC,eAAe"
|
|
53
53
|
}
|
package/esm/theme/light.js.map
CHANGED
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"sourcesContent": [
|
|
14
14
|
"import { EditorView } from '@codemirror/view';\n\nexport const defaultLightThemeOption = EditorView.theme(\n {\n '&': {\n backgroundColor: '#fff',\n },\n },\n {\n dark: false,\n },\n);\n"
|
|
15
15
|
],
|
|
16
|
-
"mappings": "AAAA,SAASA,
|
|
16
|
+
"mappings": "AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,OAAO,IAAMC,uBAAuB,GAAGD,UAAU,CAACE,KAAK,CACrD;EACE,GAAG,EAAE;IACHC,eAAe,EAAE;EACnB;AACF,CAAC,EACD;EACEC,IAAI,EAAE;AACR,CAAC,CACF"
|
|
17
17
|
}
|
package/esm/useCodeMirror.js
CHANGED
|
@@ -53,20 +53,15 @@ export function useCodeMirror(props) {
|
|
|
53
53
|
var updateListener = EditorView.updateListener.of(vu => {
|
|
54
54
|
if (vu.docChanged && typeof onChange === 'function') {
|
|
55
55
|
var doc = vu.state.doc;
|
|
56
|
-
|
|
57
56
|
var _value = doc.toString();
|
|
58
|
-
|
|
59
57
|
onChange(_value, vu);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
onStatistics && onStatistics(getStatistics(vu));
|
|
63
60
|
});
|
|
64
61
|
var getExtensions = [updateListener, defaultThemeOption];
|
|
65
|
-
|
|
66
62
|
if (defaultIndentWithTab) {
|
|
67
63
|
getExtensions.unshift(keymap.of([indentWithTab]));
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
if (defaultBasicSetup) {
|
|
71
66
|
if (typeof defaultBasicSetup === 'boolean') {
|
|
72
67
|
getExtensions.unshift(basicSetup());
|
|
@@ -74,37 +69,29 @@ export function useCodeMirror(props) {
|
|
|
74
69
|
getExtensions.unshift(basicSetup(defaultBasicSetup));
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
|
|
78
72
|
if (placeholderStr) {
|
|
79
73
|
getExtensions.unshift(placeholder(placeholderStr));
|
|
80
74
|
}
|
|
81
|
-
|
|
82
75
|
switch (theme) {
|
|
83
76
|
case 'light':
|
|
84
77
|
getExtensions.push(defaultLightThemeOption);
|
|
85
78
|
break;
|
|
86
|
-
|
|
87
79
|
case 'dark':
|
|
88
80
|
getExtensions.push(oneDark);
|
|
89
81
|
break;
|
|
90
|
-
|
|
91
82
|
default:
|
|
92
83
|
getExtensions.push(theme);
|
|
93
84
|
break;
|
|
94
85
|
}
|
|
95
|
-
|
|
96
86
|
if (editable === false) {
|
|
97
87
|
getExtensions.push(EditorView.editable.of(false));
|
|
98
88
|
}
|
|
99
|
-
|
|
100
89
|
if (readOnly) {
|
|
101
90
|
getExtensions.push(EditorState.readOnly.of(true));
|
|
102
91
|
}
|
|
103
|
-
|
|
104
92
|
if (onUpdate && typeof onUpdate === 'function') {
|
|
105
93
|
getExtensions.push(EditorView.updateListener.of(onUpdate));
|
|
106
94
|
}
|
|
107
|
-
|
|
108
95
|
getExtensions = getExtensions.concat(extensions);
|
|
109
96
|
useEffect(() => {
|
|
110
97
|
if (container && !state) {
|
|
@@ -115,7 +102,6 @@ export function useCodeMirror(props) {
|
|
|
115
102
|
};
|
|
116
103
|
var stateCurrent = initialState ? EditorState.fromJSON(initialState.json, config, initialState.fields) : EditorState.create(config);
|
|
117
104
|
setState(stateCurrent);
|
|
118
|
-
|
|
119
105
|
if (!view) {
|
|
120
106
|
var viewCurrent = new EditorView({
|
|
121
107
|
state: stateCurrent,
|
|
@@ -126,7 +112,6 @@ export function useCodeMirror(props) {
|
|
|
126
112
|
onCreateEditor && onCreateEditor(viewCurrent, stateCurrent);
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
|
-
|
|
130
115
|
return () => {
|
|
131
116
|
if (view) {
|
|
132
117
|
setState(undefined);
|
|
@@ -151,12 +136,11 @@ export function useCodeMirror(props) {
|
|
|
151
136
|
view.dispatch({
|
|
152
137
|
effects: StateEffect.reconfigure.of(getExtensions)
|
|
153
138
|
});
|
|
154
|
-
}
|
|
155
|
-
|
|
139
|
+
}
|
|
140
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
156
141
|
}, [theme, extensions, height, minHeight, maxHeight, width, minWidth, maxWidth, placeholderStr, editable, readOnly, defaultIndentWithTab, defaultBasicSetup, onChange, onUpdate]);
|
|
157
142
|
useEffect(() => {
|
|
158
143
|
var currentValue = view ? view.state.doc.toString() : '';
|
|
159
|
-
|
|
160
144
|
if (view && value !== currentValue) {
|
|
161
145
|
view.dispatch({
|
|
162
146
|
changes: {
|
package/esm/useCodeMirror.js.map
CHANGED
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"sourcesContent": [
|
|
84
84
|
"import { useEffect, useState } from 'react';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { basicSetup } from '@uiw/codemirror-extensions-basic-setup';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { getStatistics } from './utils';\nimport { ReactCodeMirrorProps } from '.';\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 onStatistics,\n onCreateEditor,\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 initialState,\n } = props;\n const [container, setContainer] = useState<HTMLDivElement>();\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultLightThemeOption = EditorView.theme(\n {\n '&': {\n backgroundColor: '#fff',\n },\n },\n {\n dark: false,\n },\n );\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 onStatistics && onStatistics(getStatistics(vu));\n });\n\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n if (typeof defaultBasicSetup === 'boolean') {\n getExtensions.unshift(basicSetup());\n } else {\n getExtensions.unshift(basicSetup(defaultBasicSetup));\n }\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 config = {\n doc: value,\n selection,\n extensions: getExtensions,\n };\n const stateCurrent = initialState\n ? EditorState.fromJSON(initialState.json, config, initialState.fields)\n : EditorState.create(config);\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n onCreateEditor && onCreateEditor(viewCurrent, stateCurrent);\n }\n }\n return () => {\n if (view) {\n setState(undefined);\n setView(undefined);\n }\n };\n }, [container, state]);\n\n useEffect(() => setContainer(props.container!), [props.container]);\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 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 minWidth,\n maxWidth,\n placeholderStr,\n editable,\n readOnly,\n defaultIndentWithTab,\n defaultBasicSetup,\n onChange,\n onUpdate,\n ]);\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 return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
85
85
|
],
|
|
86
|
-
"mappings": "AAAA,SAASA,
|
|
86
|
+
"mappings": "AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAC5D,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,UAAU,EAAEC,MAAM,EAAcC,WAAW,QAAQ,kBAAkB;AAC9E,SAASC,UAAU,QAAQ,wCAAwC;AACnE,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,aAAa,QAAQ,SAAS;AAOvC,OAAO,SAASC,aAAa,CAACC,KAAoB,EAAE;EAClD,IAAM;IACJC,KAAK;IACLC,SAAS;IACTC,QAAQ;IACRC,YAAY;IACZC,cAAc;IACdC,QAAQ;IACRC,UAAU,GAAG,EAAE;IACfC,SAAS;IACTC,KAAK,GAAG,OAAO;IACfC,MAAM,GAAG,EAAE;IACXC,SAAS,GAAG,EAAE;IACdC,SAAS,GAAG,EAAE;IACdjB,WAAW,EAAEkB,cAAc,GAAG,EAAE;IAChCC,KAAK,GAAG,EA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,QAAQ,CAAC;QAAEC,OAAO,EAAEhE,WAAW,CAACiE,WAAW,CAACtB,EAAE,CAACK,aAAa;MAAE,CAAC,CAAC;IACvE;IACA;EACF,CAAC,EAAE,CACD9B,KAAK,EACLF,UAAU,EACVG,MAAM,EACNC,SAAS,EACTC,SAAS,EACTE,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRH,cAAc,EACdI,QAAQ,EACRC,QAAQ,EACRC,oBAAoB,EACpBC,iBAAiB,EACjBjB,QAAQ,EACRG,QAAQ,CACT,CAAC;EAEFlB,SAAS,CAAC,MAAM;IACd,IAAMqE,YAAY,GAAGhC,IAAI,GAAGA,IAAI,CAACE,KAAK,CAACU,GAAG,CAACC,QAAQ,EAAE,GAAG,EAAE;IAC1D,IAAIb,IAAI,IAAIxB,KAAK,KAAKwD,YAAY,EAAE;MAClChC,IAAI,CAAC6B,QAAQ,CAAC;QACZI,OAAO,EAAE;UAAEC,IAAI,EAAE,CAAC;UAAEC,EAAE,EAAEH,YAAY,CAACI,MAAM;UAAEC,MAAM,EAAE7D,KAAK,IAAI;QAAG;MACnE,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACA,KAAK,EAAEwB,IAAI,CAAC,CAAC;EAEjB,OAAO;IAAEE,KAAK;IAAEC,QAAQ;IAAEH,IAAI;IAAEC,OAAO;IAAEH,SAAS;IAAEC;EAAa,CAAC;AACpE"
|
|
87
87
|
}
|
package/esm/utils.js.map
CHANGED
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sourcesContent": [
|
|
36
36
|
"import { EditorSelection, SelectionRange, Line } from '@codemirror/state';\nimport { ViewUpdate } from '@codemirror/view';\n\nexport interface Statistics {\n /** total length of the document */\n length: number;\n /** Get the number of lines in the editor. */\n lineCount: number;\n /** Get the currently line description around the given position. */\n line: Line;\n /** Get the proper [line-break](https://codemirror.net/docs/ref/#state.EditorState^lineSeparator) string for this state. */\n lineBreak: string;\n /** Returns true when the editor is [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only. */\n readOnly: boolean;\n /** The size (in columns) of a tab in the document, determined by the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet. */\n tabSize: number;\n /** Cursor Position */\n selection: EditorSelection;\n /** Make sure the selection only has one range. */\n selectionAsSingle: SelectionRange;\n /** Retrieves a list of all current selections. */\n ranges: readonly SelectionRange[];\n /** Get the currently selected code. */\n selectionCode: string;\n /**\n * The length of the given array should be the same as the number of active selections.\n * Replaces the content of the selections with the strings in the array.\n */\n selections: string[];\n /** Return true if any text is selected. */\n selectedText: boolean;\n}\n\nexport const getStatistics = (view: ViewUpdate): Statistics => {\n return {\n line: view.state.doc.lineAt(view.state.selection.main.from),\n lineCount: view.state.doc.lines,\n lineBreak: view.state.lineBreak,\n length: view.state.doc.length,\n readOnly: view.state.readOnly,\n tabSize: view.state.tabSize,\n selection: view.state.selection,\n selectionAsSingle: view.state.selection.asSingle().main,\n ranges: view.state.selection.ranges,\n selectionCode: view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to),\n selections: view.state.selection.ranges.map((r) => view.state.sliceDoc(r.from, r.to)),\n selectedText: view.state.selection.ranges.some((r) => !r.empty),\n };\n};\n"
|
|
37
37
|
],
|
|
38
|
-
"mappings": "AAiCA,OAAO,IAAMA,aAAa,GAAIC,
|
|
38
|
+
"mappings": "AAiCA,OAAO,IAAMA,aAAa,GAAIC,IAAgB,IAAiB;EAC7D,OAAO;IACLC,IAAI,EAAED,IAAI,CAACE,KAAK,CAACC,GAAG,CAACC,MAAM,CAACJ,IAAI,CAACE,KAAK,CAACG,SAAS,CAACC,IAAI,CAACC,IAAI,CAAC;IAC3DC,SAAS,EAAER,IAAI,CAACE,KAAK,CAACC,GAAG,CAACM,KAAK;IAC/BC,SAAS,EAAEV,IAAI,CAACE,KAAK,CAACQ,SAAS;IAC/BC,MAAM,EAAEX,IAAI,CAACE,KAAK,CAACC,GAAG,CAACQ,MAAM;IAC7BC,QAAQ,EAAEZ,IAAI,CAACE,KAAK,CAACU,QAAQ;IAC7BC,OAAO,EAAEb,IAAI,CAACE,KAAK,CAACW,OAAO;IAC3BR,SAAS,EAAEL,IAAI,CAACE,KAAK,CAACG,SAAS;IAC/BS,iBAAiB,EAAEd,IAAI,CAACE,KAAK,CAACG,SAAS,CAACU,QAAQ,EAAE,CAACT,IAAI;IACvDU,MAAM,EAAEhB,IAAI,CAACE,KAAK,CAACG,SAAS,CAACW,MAAM;IACnCC,aAAa,EAAEjB,IAAI,CAACE,KAAK,CAACgB,QAAQ,CAAClB,IAAI,CAACE,KAAK,CAACG,SAAS,CAACC,IAAI,CAACC,IAAI,EAAEP,IAAI,CAACE,KAAK,CAACG,SAAS,CAACC,IAAI,CAACa,EAAE,CAAC;IAChGC,UAAU,EAAEpB,IAAI,CAACE,KAAK,CAACG,SAAS,CAACW,MAAM,CAACK,GAAG,CAAEC,CAAC,IAAKtB,IAAI,CAACE,KAAK,CAACgB,QAAQ,CAACI,CAAC,CAACf,IAAI,EAAEe,CAAC,CAACH,EAAE,CAAC,CAAC;IACrFI,YAAY,EAAEvB,IAAI,CAACE,KAAK,CAACG,SAAS,CAACW,MAAM,CAACQ,IAAI,CAAEF,CAAC,IAAK,CAACA,CAAC,CAACG,KAAK;EAChE,CAAC;AACH,CAAC"
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-codemirror",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "CodeMirror component for React.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-codemirror",
|
|
6
6
|
"author": "kenny wong <wowohoo@qq.com>",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@codemirror/commands": "^6.1.0",
|
|
41
41
|
"@codemirror/state": "^6.1.1",
|
|
42
42
|
"@codemirror/theme-one-dark": "^6.0.0",
|
|
43
|
-
"@uiw/codemirror-extensions-basic-setup": "4.
|
|
43
|
+
"@uiw/codemirror-extensions-basic-setup": "4.13.0",
|
|
44
44
|
"codemirror": "^6.0.0"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|