@uiw/react-codemirror 4.11.4 → 4.12.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/README.md +61 -3
- package/cjs/index.d.ts +8 -1
- package/cjs/index.js +4 -2
- package/cjs/index.js.map +3 -2
- package/cjs/useCodeMirror.js +5 -4
- package/cjs/useCodeMirror.js.map +7 -2
- package/dist/mdeditor.js +191 -97
- package/dist/mdeditor.min.js +1 -1
- package/esm/index.d.ts +8 -1
- package/esm/index.js +5 -3
- package/esm/index.js.map +3 -2
- package/esm/useCodeMirror.js +5 -3
- package/esm/useCodeMirror.js.map +7 -2
- package/package.json +2 -2
- package/src/index.tsx +10 -1
- package/src/useCodeMirror.ts +6 -2
package/README.md
CHANGED
|
@@ -47,10 +47,14 @@ npm install @uiw/react-codemirror --save
|
|
|
47
47
|
| `@uiw/codemirror-extensions-color` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-color) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-color) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/color) |
|
|
48
48
|
| `@uiw/codemirror-extensions-events` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-events) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-events) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/events) |
|
|
49
49
|
| `@uiw/codemirror-extensions-hyper-link` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-hyper-link) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-hyper-link) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/hyper-link) |
|
|
50
|
+
| `@uiw/codemirror-extensions-langs` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-langs) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-langs) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/languages) |
|
|
50
51
|
| `@uiw/codemirror-extensions-line-numbers-relative` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-line-numbers-relative) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-line-numbers-relative) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/line-numbers-relative) |
|
|
52
|
+
| `@uiw/codemirror-extensions-mentions` | [](https://www.npmjs.com/package/@uiw/codemirror-extensions-mentions) [](https://www.npmjs.com/package/@uiw/codemirror-extensions-mentions) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/extensions/mentions) |
|
|
51
53
|
| `@uiw/codemirror-themes` | [](https://www.npmjs.com/package/@uiw/codemirror-themes) [](https://www.npmjs.com/package/@uiw/codemirror-themes) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/doc) |
|
|
52
54
|
| `@uiw/codemirror-theme-abcdef` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-abcdef) [](https://www.npmjs.com/package/@uiw/codemirror-theme-abcdef) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/abcdef) |
|
|
53
55
|
| `@uiw/codemirror-theme-androidstudio` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-androidstudio) [](https://www.npmjs.com/package/@uiw/codemirror-theme-androidstudio) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/androidstudio) |
|
|
56
|
+
| `@uiw/codemirror-theme-atomone` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-atomone) [](https://www.npmjs.com/package/@uiw/codemirror-theme-atomone) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/atomone) |
|
|
57
|
+
| `@uiw/codemirror-theme-bbedit` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-bbedit) [](https://www.npmjs.com/package/@uiw/codemirror-theme-bbedit) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/bbedit) |
|
|
54
58
|
| `@uiw/codemirror-theme-bespin` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-bespin) [](https://www.npmjs.com/package/@uiw/codemirror-theme-bespin) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/bespin) |
|
|
55
59
|
| `@uiw/codemirror-theme-duotone` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-duotone) [](https://www.npmjs.com/package/@uiw/codemirror-theme-duotone) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/duotone/light) |
|
|
56
60
|
| `@uiw/codemirror-theme-dracula` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-dracula) [](https://www.npmjs.com/package/@uiw/codemirror-theme-dracula) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/dracula) |
|
|
@@ -167,17 +171,21 @@ export default function App() {
|
|
|
167
171
|
[](https://codesandbox.io/embed/react-codemirror-example-codemirror-6-hook-yr4vg?fontsize=14&hidenavigation=1&theme=dark)
|
|
168
172
|
|
|
169
173
|
```jsx
|
|
170
|
-
import { useEffect, useRef } from 'react';
|
|
174
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
171
175
|
import { useCodeMirror } from '@uiw/react-codemirror';
|
|
172
176
|
import { javascript } from '@codemirror/lang-javascript';
|
|
173
177
|
|
|
174
178
|
const code = "console.log('hello world!');\n\n\n";
|
|
179
|
+
// Define the extensions outside the component for the best performance.
|
|
180
|
+
// If you need dynamic extensions, use React.useMemo to minimize reference changes
|
|
181
|
+
// which cause costly re-renders.
|
|
182
|
+
const extensions = [javascript()];
|
|
175
183
|
|
|
176
184
|
export default function App() {
|
|
177
185
|
const editor = useRef();
|
|
178
186
|
const { setContainer } = useCodeMirror({
|
|
179
187
|
container: editor.current,
|
|
180
|
-
extensions
|
|
188
|
+
extensions,
|
|
181
189
|
value: code,
|
|
182
190
|
});
|
|
183
191
|
|
|
@@ -200,6 +208,8 @@ import CodeMirror from '@uiw/react-codemirror';
|
|
|
200
208
|
import { javascript } from '@codemirror/lang-javascript';
|
|
201
209
|
import { okaidia } from '@uiw/codemirror-theme-okaidia';
|
|
202
210
|
|
|
211
|
+
const extensions = [javascript({ jsx: true })];
|
|
212
|
+
|
|
203
213
|
export default function App() {
|
|
204
214
|
return (
|
|
205
215
|
<CodeMirror
|
|
@@ -249,6 +259,7 @@ const myTheme = createTheme({
|
|
|
249
259
|
{ tag: t.attributeName, color: '#5c6166' },
|
|
250
260
|
],
|
|
251
261
|
});
|
|
262
|
+
const extensions = [javascript({ jsx: true })];
|
|
252
263
|
|
|
253
264
|
export default function App() {
|
|
254
265
|
const onChange = React.useCallback((value, viewUpdate) => {
|
|
@@ -259,13 +270,53 @@ export default function App() {
|
|
|
259
270
|
value="console.log('hello world!');"
|
|
260
271
|
height="200px"
|
|
261
272
|
theme={myTheme}
|
|
262
|
-
extensions={
|
|
273
|
+
extensions={extensions}
|
|
263
274
|
onChange={onChange}
|
|
264
275
|
/>
|
|
265
276
|
);
|
|
266
277
|
}
|
|
267
278
|
```
|
|
268
279
|
|
|
280
|
+
## Use `initialState` to restore state from JSON-serialized representation
|
|
281
|
+
|
|
282
|
+
CodeMirror allows to serialize editor state to JSON representation with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function for persistency or other needs. This JSON representation can be later used to recreate ReactCodeMirror component with the same internal state.
|
|
283
|
+
|
|
284
|
+
For example, this is how undo history can be saved in the local storage, so that it remains after the page reloads
|
|
285
|
+
|
|
286
|
+
```jsx
|
|
287
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
288
|
+
import { historyField } from '@codemirror/commands';
|
|
289
|
+
|
|
290
|
+
// When custom fields should be serialized, you can pass them in as an object mapping property names to fields.
|
|
291
|
+
// See [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) documentation for more details
|
|
292
|
+
const stateFields = { history: historyField };
|
|
293
|
+
|
|
294
|
+
export function EditorWithInitialState() {
|
|
295
|
+
const serializedState = localStorage.getItem('myEditorState');
|
|
296
|
+
const value = localStorage.getItem('myValue') || '';
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<CodeMirror
|
|
300
|
+
value={value}
|
|
301
|
+
initialState={
|
|
302
|
+
serializedState
|
|
303
|
+
? {
|
|
304
|
+
json: JSON.parse(serializedState || ''),
|
|
305
|
+
fields: stateFields,
|
|
306
|
+
}
|
|
307
|
+
: undefined
|
|
308
|
+
}
|
|
309
|
+
onChange={(value, viewUpdate) => {
|
|
310
|
+
localStorage.setItem('myValue', value);
|
|
311
|
+
|
|
312
|
+
const state = viewUpdate.state.toJSON(stateFields);
|
|
313
|
+
localStorage.setItem('myEditorState', JSON.stringify(state));
|
|
314
|
+
}}
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
269
320
|
## Props
|
|
270
321
|
|
|
271
322
|
<!--rehype:style=background-color: #ffe564; display: inline-block; border-bottom: 0; padding: 3px 12px;-->
|
|
@@ -353,6 +404,13 @@ export interface ReactCodeMirrorProps
|
|
|
353
404
|
* Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)
|
|
354
405
|
*/
|
|
355
406
|
root?: ShadowRoot | Document;
|
|
407
|
+
/**
|
|
408
|
+
* Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function
|
|
409
|
+
*/
|
|
410
|
+
initialState?: {
|
|
411
|
+
json: any;
|
|
412
|
+
fields?: Record<'string', StateField<any>>;
|
|
413
|
+
};
|
|
356
414
|
}
|
|
357
415
|
export interface ReactCodeMirrorRef {
|
|
358
416
|
editor?: HTMLDivElement | null;
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { EditorState, EditorStateConfig, Extension } from '@codemirror/state';
|
|
2
|
+
import { EditorState, EditorStateConfig, Extension, StateField } from '@codemirror/state';
|
|
3
3
|
import { EditorView, ViewUpdate } from '@codemirror/view';
|
|
4
4
|
import { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup';
|
|
5
5
|
import { Statistics } from './utils';
|
|
@@ -64,6 +64,13 @@ export interface ReactCodeMirrorProps extends Omit<EditorStateConfig, 'doc' | 'e
|
|
|
64
64
|
* Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)
|
|
65
65
|
*/
|
|
66
66
|
root?: ShadowRoot | Document;
|
|
67
|
+
/**
|
|
68
|
+
* Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function
|
|
69
|
+
*/
|
|
70
|
+
initialState?: {
|
|
71
|
+
json: any;
|
|
72
|
+
fields?: Record<string, StateField<any>>;
|
|
73
|
+
};
|
|
67
74
|
}
|
|
68
75
|
export interface ReactCodeMirrorRef {
|
|
69
76
|
editor?: HTMLDivElement | null;
|
package/cjs/index.js
CHANGED
|
@@ -61,7 +61,7 @@ Object.keys(_utils).forEach(function (key) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
-
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onStatistics", "onCreateEditor", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root"];
|
|
64
|
+
var _excluded = ["className", "value", "selection", "extensions", "onChange", "onStatistics", "onCreateEditor", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root", "initialState"];
|
|
65
65
|
var ReactCodeMirror = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
66
66
|
var className = props.className,
|
|
67
67
|
_props$value = props.value,
|
|
@@ -88,6 +88,7 @@ var ReactCodeMirror = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
88
88
|
editable = props.editable,
|
|
89
89
|
readOnly = props.readOnly,
|
|
90
90
|
root = props.root,
|
|
91
|
+
initialState = props.initialState,
|
|
91
92
|
other = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
92
93
|
var editor = (0, _react.useRef)(null);
|
|
93
94
|
|
|
@@ -113,7 +114,8 @@ var ReactCodeMirror = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
113
114
|
onStatistics: onStatistics,
|
|
114
115
|
onCreateEditor: onCreateEditor,
|
|
115
116
|
onUpdate: onUpdate,
|
|
116
|
-
extensions: extensions
|
|
117
|
+
extensions: extensions,
|
|
118
|
+
initialState: initialState
|
|
117
119
|
}),
|
|
118
120
|
state = _useCodeMirror.state,
|
|
119
121
|
view = _useCodeMirror.view,
|
package/cjs/index.js.map
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"editable",
|
|
28
28
|
"readOnly",
|
|
29
29
|
"root",
|
|
30
|
+
"initialState",
|
|
30
31
|
"other",
|
|
31
32
|
"editor",
|
|
32
33
|
"useRef",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"../src/index.tsx"
|
|
46
47
|
],
|
|
47
48
|
"sourcesContent": [
|
|
48
|
-
"import React, { useRef, forwardRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } 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\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 ...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 });\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"
|
|
49
|
+
"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"
|
|
49
50
|
],
|
|
50
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;AADA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;
|
|
51
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;AADA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AA6EA,IAAMA,eAAe,gBAAG,IAAAC,iBAAA,EAAqD,UAACC,KAAD,EAAQC,GAAR,EAAgB;EAC3F,IACEC,SADF,GAyBIF,KAzBJ,C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AO7B,KAAP,KAAiB,QAArB,EAA+B;IAC7B,MAAM,IAAIgC,KAAJ,wEAAwDhC,KAAxD,GAAN;EACD;;EAED,IAAMiC,iBAAiB,GAAG,OAAOzB,KAAP,KAAiB,QAAjB,sBAAwCA,KAAxC,IAAkD,UAA5E;EACA,oBAAO;IAAK,GAAG,EAAEe,MAAV;IAAkB,SAAS,YAAKU,iBAAL,SAAyBlC,SAAS,cAAOA,SAAP,IAAqB,EAAvD;EAA3B,GAA4FuB,KAA5F,EAAP;AACD,CApEuB,CAAxB;AAsEA3B,eAAe,CAACuC,WAAhB,GAA8B,YAA9B;eAEevC,e"
|
|
51
52
|
}
|
package/cjs/useCodeMirror.js
CHANGED
|
@@ -57,7 +57,8 @@ function useCodeMirror(props) {
|
|
|
57
57
|
defaultIndentWithTab = _props$indentWithTab === void 0 ? true : _props$indentWithTab,
|
|
58
58
|
_props$basicSetup = props.basicSetup,
|
|
59
59
|
defaultBasicSetup = _props$basicSetup === void 0 ? true : _props$basicSetup,
|
|
60
|
-
root = props.root
|
|
60
|
+
root = props.root,
|
|
61
|
+
initialState = props.initialState;
|
|
61
62
|
|
|
62
63
|
var _useState = (0, _react.useState)(),
|
|
63
64
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -152,12 +153,12 @@ function useCodeMirror(props) {
|
|
|
152
153
|
getExtensions = getExtensions.concat(extensions);
|
|
153
154
|
(0, _react.useEffect)(function () {
|
|
154
155
|
if (container && !state) {
|
|
155
|
-
var
|
|
156
|
+
var config = {
|
|
156
157
|
doc: value,
|
|
157
158
|
selection: selection,
|
|
158
159
|
extensions: getExtensions
|
|
159
|
-
}
|
|
160
|
-
|
|
160
|
+
};
|
|
161
|
+
var stateCurrent = initialState ? _state.EditorState.fromJSON(initialState.json, config, initialState.fields) : _state.EditorState.create(config);
|
|
161
162
|
setState(stateCurrent);
|
|
162
163
|
|
|
163
164
|
if (!view) {
|
package/cjs/useCodeMirror.js.map
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"basicSetup",
|
|
28
28
|
"defaultBasicSetup",
|
|
29
29
|
"root",
|
|
30
|
+
"initialState",
|
|
30
31
|
"useState",
|
|
31
32
|
"container",
|
|
32
33
|
"setContainer",
|
|
@@ -54,7 +55,11 @@
|
|
|
54
55
|
"EditorState",
|
|
55
56
|
"concat",
|
|
56
57
|
"useEffect",
|
|
58
|
+
"config",
|
|
57
59
|
"stateCurrent",
|
|
60
|
+
"fromJSON",
|
|
61
|
+
"json",
|
|
62
|
+
"fields",
|
|
58
63
|
"create",
|
|
59
64
|
"viewCurrent",
|
|
60
65
|
"parent",
|
|
@@ -76,7 +81,7 @@
|
|
|
76
81
|
"../src/useCodeMirror.ts"
|
|
77
82
|
],
|
|
78
83
|
"sourcesContent": [
|
|
79
|
-
"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 } = 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
|
|
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"
|
|
80
85
|
],
|
|
81
|
-
"mappings": ";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOO,SAASA,aAAT,CAAuBC,KAAvB,EAA6C;EAClD,IACEC,KADF,
|
|
86
|
+
"mappings": ";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOO,SAASA,aAAT,CAAuBC,KAAvB,EAA6C;EAClD,IACEC,KADF,GAuBID,KAvBJ,CACEC,KADF;EAAA,IAEEC,SAFF,GAuBIF,KAvBJ,CAEEE,SAFF;EAAA,IAGEC,QAHF,GAuBIH,KAvBJ,CAGEG,QAHF;EAAA,IAIEC,YAJF,GAuBIJ,KAvBJ,CAIEI,YAJF;EAAA,IAKEC,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