@uiw/react-codemirror 4.19.9 → 4.19.10
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 +1 -2
- package/cjs/index.js.map +33 -4
- package/cjs/theme/light.js.map +5 -2
- package/cjs/useCodeMirror.js.map +29 -1
- package/cjs/utils.js.map +3 -2
- package/dist/mdeditor.js +603 -345
- package/dist/mdeditor.min.js +1 -1
- package/esm/index.js +1 -2
- package/esm/index.js.map +7 -3
- package/esm/useCodeMirror.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +1 -1
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
"forwardRef",
|
|
7
7
|
"useImperativeHandle",
|
|
8
8
|
"useCodeMirror",
|
|
9
|
+
"jsx",
|
|
10
|
+
"_jsx",
|
|
9
11
|
"ReactCodeMirror",
|
|
10
12
|
"props",
|
|
11
13
|
"ref",
|
|
@@ -33,21 +35,23 @@
|
|
|
33
35
|
"root",
|
|
34
36
|
"initialState",
|
|
35
37
|
"other",
|
|
38
|
+
"_objectWithoutPropertiesLoose",
|
|
39
|
+
"_excluded",
|
|
36
40
|
"editor",
|
|
37
41
|
"state",
|
|
38
42
|
"view",
|
|
39
43
|
"container",
|
|
40
|
-
"setContainer",
|
|
41
44
|
"current",
|
|
42
45
|
"Error",
|
|
43
46
|
"defaultClassNames",
|
|
47
|
+
"_extends",
|
|
44
48
|
"displayName"
|
|
45
49
|
],
|
|
46
50
|
"sources": [
|
|
47
51
|
"../src/index.tsx"
|
|
48
52
|
],
|
|
49
53
|
"sourcesContent": [
|
|
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' | 'none' | 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
|
|
54
|
+
"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' | 'none' | 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 } = 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
55
|
],
|
|
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,
|
|
56
|
+
"mappings": ";;;AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,UAAU,EAAEC,mBAAmB,QAAQ,OAAO;AAItE,SAASC,aAAa,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGhD,cAAc,wCAAwC;AACtD,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AA6EvB,IAAMC,eAAe,gBAAGL,UAAU,CAA2C,CAACM,KAAK,EAAEC,GAAG,KAAK;EAC3F,IAAM;MACJC,SAAS;MACTC,KAAK,GAAG,EAAE;MACVC,SAAS;MACTC,UAAU,GAAG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AAA;IAAKlC,GAAG,EAAE2B,MAAO;IAAC1B,SAAS,OAAKgC,iBAAiB,IAAGhC,SAAS,SAAOA,SAAS,GAAK,EAAE;EAAG,GAAKuB,KAAK,EAAQ;AAClH,CAAC,CAAC;AAEF1B,eAAe,CAACqC,WAAW,GAAG,YAAY;AAE1C,eAAerC,eAAe"
|
|
53
57
|
}
|
package/esm/useCodeMirror.js.map
CHANGED
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"sourcesContent": [
|
|
92
92
|
"import { useEffect, useState } from 'react';\nimport { Annotation, 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\nconst External = Annotation.define<boolean>();\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 (\n vu.docChanged &&\n typeof onChange === 'function' &&\n // Fix echoing of the remote changes:\n // If transaction is market as remote we don't have to call `onChange` handler again\n !vu.transactions.some((tr) => tr.annotation(External))\n ) {\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 case 'none':\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 if (value === undefined) {\n return;\n }\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 annotations: [External.of(true)],\n });\n }\n }, [value, view]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
93
93
|
],
|
|
94
|
-
"mappings": "AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AACxE,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;AAGvC,IAAMC,QAAQ,GAAGV,UAAU,CAACW,MAAM,EAAW;AAM7C,OAAO,SAASC,
|
|
94
|
+
"mappings": "AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AACxE,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;AAGvC,IAAMC,QAAQ,GAAGV,UAAU,CAACW,MAAM,EAAW;AAM7C,OAAO,SAASC,aA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AAC,IAAI,CAAC;MACjC,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACjC,KAAK,EAAEwB,IAAI,CAAC,CAAC;EAEjB,OAAO;IAAEE,KAAK;IAAEC,QAAQ;IAAEH,IAAI;IAAEC,OAAO;IAAEH,SAAS;IAAEC;EAAa,CAAC;AACpE"
|
|
95
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-codemirror",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.10",
|
|
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.19.
|
|
43
|
+
"@uiw/codemirror-extensions-basic-setup": "4.19.10",
|
|
44
44
|
"codemirror": "^6.0.0"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
package/src/index.tsx
CHANGED
|
@@ -112,7 +112,7 @@ const ReactCodeMirror = forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((pr
|
|
|
112
112
|
...other
|
|
113
113
|
} = props;
|
|
114
114
|
const editor = useRef<HTMLDivElement>(null);
|
|
115
|
-
const { state, view, container
|
|
115
|
+
const { state, view, container } = useCodeMirror({
|
|
116
116
|
container: editor.current,
|
|
117
117
|
root,
|
|
118
118
|
value,
|