@willbooster/monaco-react 1.0.3 → 1.0.5
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 +4 -3
- package/dist/DiffEditor/DiffEditor.cjs +3 -0
- package/dist/DiffEditor/DiffEditor.cjs.map +1 -0
- package/dist/DiffEditor/DiffEditor.d.ts +5 -0
- package/dist/DiffEditor/DiffEditor.d.ts.map +1 -0
- package/dist/DiffEditor/DiffEditor.js +3 -0
- package/dist/DiffEditor/DiffEditor.js.map +1 -0
- package/dist/DiffEditor/index.cjs +2 -0
- package/dist/DiffEditor/index.cjs.map +1 -0
- package/dist/DiffEditor/index.d.ts +5 -0
- package/dist/DiffEditor/index.d.ts.map +1 -0
- package/dist/DiffEditor/index.js +2 -0
- package/dist/DiffEditor/index.js.map +1 -0
- package/dist/DiffEditor/index.spec.d.ts +2 -0
- package/dist/DiffEditor/index.spec.d.ts.map +1 -0
- package/dist/DiffEditor/types.d.ts +101 -0
- package/dist/DiffEditor/types.d.ts.map +1 -0
- package/dist/Editor/Editor.cjs +3 -0
- package/dist/Editor/Editor.cjs.map +1 -0
- package/dist/Editor/Editor.d.ts +5 -0
- package/dist/Editor/Editor.d.ts.map +1 -0
- package/dist/Editor/Editor.js +3 -0
- package/dist/Editor/Editor.js.map +1 -0
- package/dist/Editor/index.cjs +2 -0
- package/dist/Editor/index.cjs.map +1 -0
- package/dist/Editor/index.d.ts +5 -0
- package/dist/Editor/index.d.ts.map +1 -0
- package/dist/Editor/index.js +2 -0
- package/dist/Editor/index.js.map +1 -0
- package/dist/Editor/index.spec.d.ts +2 -0
- package/dist/Editor/index.spec.d.ts.map +1 -0
- package/dist/Editor/types.d.ts +116 -0
- package/dist/Editor/types.d.ts.map +1 -0
- package/dist/Loading/Loading.cjs +2 -0
- package/dist/Loading/Loading.cjs.map +1 -0
- package/dist/Loading/Loading.d.ts +4 -0
- package/dist/Loading/Loading.d.ts.map +1 -0
- package/dist/Loading/Loading.js +2 -0
- package/dist/Loading/Loading.js.map +1 -0
- package/dist/Loading/index.cjs +2 -0
- package/dist/Loading/index.cjs.map +1 -0
- package/dist/Loading/index.d.ts +3 -0
- package/dist/Loading/index.d.ts.map +1 -0
- package/dist/Loading/index.js +2 -0
- package/dist/Loading/index.js.map +1 -0
- package/dist/Loading/index.spec.d.ts +2 -0
- package/dist/Loading/index.spec.d.ts.map +1 -0
- package/dist/Loading/styles.cjs +2 -0
- package/dist/Loading/styles.cjs.map +1 -0
- package/dist/Loading/styles.d.ts +4 -0
- package/dist/Loading/styles.d.ts.map +1 -0
- package/dist/Loading/styles.js +2 -0
- package/dist/Loading/styles.js.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.cjs +2 -0
- package/dist/MonacoContainer/MonacoContainer.cjs.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.d.ts +5 -0
- package/dist/MonacoContainer/MonacoContainer.d.ts.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.js +2 -0
- package/dist/MonacoContainer/MonacoContainer.js.map +1 -0
- package/dist/MonacoContainer/index.cjs +2 -0
- package/dist/MonacoContainer/index.cjs.map +1 -0
- package/dist/MonacoContainer/index.d.ts +4 -0
- package/dist/MonacoContainer/index.d.ts.map +1 -0
- package/dist/MonacoContainer/index.js +2 -0
- package/dist/MonacoContainer/index.js.map +1 -0
- package/dist/MonacoContainer/index.spec.d.ts +2 -0
- package/dist/MonacoContainer/index.spec.d.ts.map +1 -0
- package/dist/MonacoContainer/styles.cjs +2 -0
- package/dist/MonacoContainer/styles.cjs.map +1 -0
- package/dist/MonacoContainer/styles.d.ts +4 -0
- package/dist/MonacoContainer/styles.d.ts.map +1 -0
- package/dist/MonacoContainer/styles.js +2 -0
- package/dist/MonacoContainer/styles.js.map +1 -0
- package/dist/MonacoContainer/types.d.ts +11 -0
- package/dist/MonacoContainer/types.d.ts.map +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs +2 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs.map +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +2 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/hooks/useMonaco/index.cjs +2 -0
- package/dist/hooks/useMonaco/index.cjs.map +1 -0
- package/dist/hooks/useMonaco/index.d.ts +4 -0
- package/dist/hooks/useMonaco/index.d.ts.map +1 -0
- package/dist/hooks/useMonaco/index.js +2 -0
- package/dist/hooks/useMonaco/index.js.map +1 -0
- package/dist/hooks/useMount/index.cjs +2 -0
- package/dist/hooks/useMount/index.cjs.map +1 -0
- package/dist/hooks/useMount/index.d.ts +4 -0
- package/dist/hooks/useMount/index.d.ts.map +1 -0
- package/dist/hooks/useMount/index.js +2 -0
- package/dist/hooks/useMount/index.js.map +1 -0
- package/dist/hooks/usePrevious/index.cjs +2 -0
- package/dist/hooks/usePrevious/index.cjs.map +1 -0
- package/dist/hooks/usePrevious/index.d.ts +3 -0
- package/dist/hooks/usePrevious/index.d.ts.map +1 -0
- package/dist/hooks/usePrevious/index.js +2 -0
- package/dist/hooks/usePrevious/index.js.map +1 -0
- package/dist/hooks/useUpdate/index.cjs +2 -0
- package/dist/hooks/useUpdate/index.cjs.map +1 -0
- package/dist/hooks/useUpdate/index.d.ts +4 -0
- package/dist/hooks/useUpdate/index.d.ts.map +1 -0
- package/dist/hooks/useUpdate/index.js +2 -0
- package/dist/hooks/useUpdate/index.js.map +1 -0
- package/dist/index.cjs +3 -625
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -231
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -588
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.ts +20 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +9 -14
- package/dist/index.d.cts +0 -231
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/DiffEditor/index.ts","../src/DiffEditor/DiffEditor.tsx","../src/MonacoContainer/index.ts","../src/MonacoContainer/styles.ts","../src/Loading/styles.ts","../src/Loading/Loading.tsx","../src/Loading/index.ts","../src/MonacoContainer/MonacoContainer.tsx","../src/hooks/useMount/index.ts","../src/hooks/useUpdate/index.ts","../src/utils/index.ts","../src/hooks/useMonaco/index.ts","../src/Editor/index.ts","../src/Editor/Editor.tsx","../src/hooks/usePrevious/index.ts"],"sourcesContent":["import loader from '@willbooster/monaco-loader';\nexport { loader };\n\nimport DiffEditor from './DiffEditor';\nexport * from './DiffEditor/types';\nexport { DiffEditor };\n\nimport useMonaco from './hooks/useMonaco';\nexport { useMonaco };\n\nimport Editor from './Editor';\nexport * from './Editor/types';\nexport { Editor };\nexport default Editor;\n\n// Monaco\nimport type * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';\nexport type Monaco = typeof monaco;\n\n// Default themes\nexport type Theme = 'vs-dark' | 'light';\n","import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n","'use client';\n\nimport { useState, useRef, useCallback, useEffect } from 'react';\nimport type { ReactElement } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport MonacoContainer from '../MonacoContainer';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { DiffEditorProps, MonacoDiffEditor } from './types';\nimport type { Monaco } from '..';\n\nfunction DiffEditor({\n original,\n modified,\n language,\n originalLanguage,\n modifiedLanguage,\n originalModelPath,\n modifiedModelPath,\n keepCurrentOriginalModel = false,\n keepCurrentModifiedModel = false,\n theme = 'light',\n loading = 'Loading...',\n options = {},\n height = '100%',\n width = '100%',\n className,\n wrapperProps = {},\n beforeMount = noop,\n onMount = noop,\n}: DiffEditorProps): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isMonacoMounting, setIsMonacoMounting] = useState(true);\n const editorRef = useRef<MonacoDiffEditor | null>(null);\n const monacoRef = useRef<Monaco | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const preventCreation = useRef(false);\n\n useMount(() => {\n const cancelable = loader.init();\n\n cancelable\n .then((monaco) => (monacoRef.current = monaco as Monaco) && setIsMonacoMounting(false))\n .catch((error) => error?.type !== 'cancelation' && console.error('Monaco initialization: error:', error));\n\n return () => (editorRef.current ? disposeEditor() : cancelable.cancel());\n });\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const originalEditor = editorRef.current.getOriginalEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n original || '',\n originalLanguage || language || 'text',\n originalModelPath || ''\n );\n\n if (model !== originalEditor.getModel()) {\n originalEditor.setModel(model);\n }\n }\n },\n [originalModelPath],\n isEditorReady\n );\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const modifiedEditor = editorRef.current.getModifiedEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n modified || '',\n modifiedLanguage || language || 'text',\n modifiedModelPath || ''\n );\n\n if (model !== modifiedEditor.getModel()) {\n modifiedEditor.setModel(model);\n }\n }\n },\n [modifiedModelPath],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const modifiedEditor = editorRef.current!.getModifiedEditor();\n if (modifiedEditor.getOption(monacoRef.current!.editor.EditorOption.readOnly)) {\n modifiedEditor.setValue(modified || '');\n } else {\n if (modified !== modifiedEditor.getValue()) {\n modifiedEditor.executeEdits('', [\n {\n range: modifiedEditor.getModel()!.getFullModelRange(),\n text: modified || '',\n forceMoveMarkers: true,\n },\n ]);\n\n modifiedEditor.pushUndoStop();\n }\n }\n },\n [modified],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.getModel()?.original.setValue(original || '');\n },\n [original],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const { original, modified } = editorRef.current!.getModel()!;\n\n monacoRef.current!.editor.setModelLanguage(original, originalLanguage || language || 'text');\n monacoRef.current!.editor.setModelLanguage(modified, modifiedLanguage || language || 'text');\n },\n [language, originalLanguage, modifiedLanguage],\n isEditorReady\n );\n\n useUpdate(\n () => {\n monacoRef.current?.editor.setTheme(theme);\n },\n [theme],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.updateOptions(options);\n },\n [options],\n isEditorReady\n );\n\n const setModels = useCallback(() => {\n if (!monacoRef.current) return;\n beforeMountRef.current(monacoRef.current);\n const originalModel = getOrCreateModel(\n monacoRef.current,\n original || '',\n originalLanguage || language || 'text',\n originalModelPath || ''\n );\n\n const modifiedModel = getOrCreateModel(\n monacoRef.current,\n modified || '',\n modifiedLanguage || language || 'text',\n modifiedModelPath || ''\n );\n\n editorRef.current?.setModel({\n original: originalModel,\n modified: modifiedModel,\n });\n }, [language, modified, modifiedLanguage, original, originalLanguage, originalModelPath, modifiedModelPath]);\n\n const createEditor = useCallback(() => {\n if (!preventCreation.current && containerRef.current) {\n editorRef.current = monacoRef.current!.editor.createDiffEditor(containerRef.current, {\n automaticLayout: true,\n ...options,\n });\n\n setModels();\n\n monacoRef.current?.editor.setTheme(theme);\n\n setIsEditorReady(true);\n preventCreation.current = true;\n }\n }, [options, theme, setModels]);\n\n useEffect(() => {\n if (isEditorReady) {\n onMountRef.current(editorRef.current!, monacoRef.current!);\n }\n }, [isEditorReady]);\n\n useEffect(() => {\n if (!isMonacoMounting && !isEditorReady) {\n createEditor();\n }\n }, [isMonacoMounting, isEditorReady, createEditor]);\n\n function disposeEditor(): void {\n const editor = editorRef.current;\n const models = editor?.getModel();\n\n // oxlint-disable-next-line unicorn/no-null -- Monaco detaches diff models with null.\n editor?.setModel(null);\n editor?.dispose();\n\n if (!keepCurrentOriginalModel && !models?.original.isDisposed()) {\n models?.original?.dispose();\n }\n\n if (!keepCurrentModifiedModel && !models?.modified.isDisposed()) {\n models?.modified?.dispose();\n }\n\n // oxlint-disable-next-line unicorn/no-null -- React refs use null after unmount.\n editorRef.current = null;\n preventCreation.current = false;\n setIsEditorReady(false);\n }\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={isEditorReady}\n loading={loading}\n _ref={containerRef}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n}\n\nexport default DiffEditor;\n","import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n","import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n wrapper: {\n display: 'flex',\n position: 'relative',\n textAlign: 'initial',\n },\n fullWidth: {\n width: '100%',\n },\n hide: {\n display: 'none',\n },\n};\n\nexport default styles;\n","import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n container: {\n display: 'flex',\n height: '100%',\n width: '100%',\n justifyContent: 'center',\n alignItems: 'center',\n },\n};\n\nexport default styles;\n","import type { PropsWithChildren, ReactElement } from 'react';\n\nimport styles from './styles';\n\nfunction Loading({ children }: PropsWithChildren): ReactElement {\n return <div style={styles.container}>{children}</div>;\n}\n\nexport default Loading;\n","import Loading from './Loading';\n\nexport default Loading;\n","import type { ReactElement } from 'react';\n\nimport styles from './styles';\nimport Loading from '../Loading';\nimport type { ContainerProps } from './types';\n\n// ** forwardref render functions do not support proptypes or defaultprops **\n// one of the reasons why we use a separate prop for passing ref instead of using forwardref\n\nfunction MonacoContainer({\n width,\n height,\n isEditorReady,\n loading,\n _ref,\n className,\n wrapperProps,\n}: ContainerProps): ReactElement {\n return (\n <section style={{ ...styles.wrapper, width, height }} {...wrapperProps}>\n {!isEditorReady && <Loading>{loading}</Loading>}\n <div ref={_ref} style={{ ...styles.fullWidth, ...(!isEditorReady && styles.hide) }} className={className} />\n </section>\n );\n}\n\nexport default MonacoContainer;\n","import { useEffect } from 'react';\nimport type { EffectCallback } from 'react';\n\nfunction useMount(effect: EffectCallback): void {\n useEffect(effect, []);\n}\n\nexport default useMount;\n","import { useEffect, useRef } from 'react';\nimport type { DependencyList, EffectCallback } from 'react';\n\nfunction useUpdate(effect: EffectCallback, deps: DependencyList, applyChanges = true): void {\n const isInitialMount = useRef(true);\n\n useEffect(\n isInitialMount.current || !applyChanges\n ? () => {\n isInitialMount.current = false;\n }\n : effect,\n deps\n );\n}\n\nexport default useUpdate;\n","import type { Monaco } from '..';\nimport type { Uri, editor } from 'monaco-editor/esm/vs/editor/editor.api.js';\n\n/**\n * noop is a helper function that does nothing\n * @returns undefined\n */\nfunction noop(): void {\n /** no-op */\n}\n\n/**\n * getOrCreateModel is a helper function that will return a model if it exists\n * or create a new model if it does not exist.\n * This is useful for when you want to create a model for a file that may or may not exist yet.\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was found or created\n */\nfunction getOrCreateModel(monaco: Monaco, value: string, language: string, path: string): editor.ITextModel {\n return getModel(monaco, path) ?? createModel(monaco, value, language, path);\n}\n\n/**\n * getModel is a helper function that will return a model if it exists\n * or return undefined if it does not exist.\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model that was found or undefined\n */\nfunction getModel(monaco: Monaco, path: string): editor.ITextModel | null {\n return monaco.editor.getModel(createModelUri(monaco, path));\n}\n\n/**\n * createModel is a helper function that will create a new model\n * @param monaco The monaco instance\n * @param value The value of the model\n * @param language The language of the model\n * @param path The path of the model\n * @returns The model that was created\n */\nfunction createModel(monaco: Monaco, value: string, language?: string, path?: string): editor.ITextModel {\n return monaco.editor.createModel(value, language, path ? createModelUri(monaco, path) : undefined);\n}\n\n/**\n * createModelUri is a helper function that will create a new model uri\n * @param monaco The monaco instance\n * @param path The path of the model\n * @returns The model uri that was created\n */\nfunction createModelUri(monaco: Monaco, path: string): Uri {\n return monaco.Uri.parse(path);\n}\n\nexport { noop, getOrCreateModel };\n","import { useState } from 'react';\nimport loader from '@willbooster/monaco-loader';\n\nimport useMount from '../useMount';\nimport type { Monaco } from '../..';\n\nfunction useMonaco(): Monaco | undefined {\n const [monaco, setMonaco] = useState<Monaco | undefined>(loader.__getMonacoInstance() as Monaco | undefined);\n\n useMount(() => {\n let cancelable: ReturnType<typeof loader.init>;\n\n if (!monaco) {\n cancelable = loader.init();\n\n void cancelable\n .then((monaco) => {\n setMonaco(monaco as Monaco);\n return;\n })\n .catch((error: unknown) => {\n if ((error as { type?: unknown })?.type !== 'cancelation') {\n console.error('Monaco initialization: error:', error);\n }\n });\n }\n\n return () => cancelable?.cancel();\n });\n\n return monaco;\n}\n\nexport default useMonaco;\n","import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n","'use client';\n\nimport { useState, useEffect, useRef, useCallback } from 'react';\nimport type { ReactElement } from 'react';\nimport loader from '@willbooster/monaco-loader';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport usePrevious from '../hooks/usePrevious';\nimport type { IDisposable, Uri, editor } from 'monaco-editor/esm/vs/editor/editor.api.js';\nimport { noop, getOrCreateModel } from '../utils';\nimport type { EditorProps } from './types';\nimport type { Monaco } from '..';\nimport MonacoContainer from '../MonacoContainer';\n\nconst viewStates = new Map();\n\nfunction Editor({\n defaultValue,\n defaultLanguage,\n defaultPath,\n value,\n language,\n path,\n /* === */\n theme = 'light',\n line,\n loading = 'Loading...',\n options = {},\n overrideServices = {},\n saveViewState = true,\n keepCurrentModel = false,\n /* === */\n width = '100%',\n height = '100%',\n className,\n wrapperProps = {},\n /* === */\n beforeMount = noop,\n onMount = noop,\n onChange,\n onValidate = noop,\n}: EditorProps): ReactElement {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isMonacoMounting, setIsMonacoMounting] = useState(true);\n const monacoRef = useRef<Monaco | null>(null);\n const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const subscriptionRef = useRef<IDisposable | undefined>(undefined);\n const valueRef = useRef(value);\n const previousPath = usePrevious(path);\n const preventCreation = useRef(false);\n const preventTriggerChangeEvent = useRef<boolean>(false);\n\n useMount(() => {\n const cancelable = loader.init();\n\n cancelable\n .then((monaco) => (monacoRef.current = monaco as Monaco) && setIsMonacoMounting(false))\n .catch((error) => error?.type !== 'cancelation' && console.error('Monaco initialization: error:', error));\n\n return () => (editorRef.current ? disposeEditor() : cancelable.cancel());\n });\n\n useUpdate(\n () => {\n const model = getOrCreateModel(\n monacoRef.current!,\n defaultValue || value || '',\n defaultLanguage || language || '',\n path || defaultPath || ''\n );\n\n if (model !== editorRef.current?.getModel()) {\n if (saveViewState) viewStates.set(previousPath, editorRef.current?.saveViewState());\n editorRef.current?.setModel(model);\n if (saveViewState) editorRef.current?.restoreViewState(viewStates.get(path));\n }\n },\n [path],\n isEditorReady\n );\n\n useUpdate(\n () => {\n editorRef.current?.updateOptions(options);\n },\n [options],\n isEditorReady\n );\n\n useUpdate(\n () => {\n if (!editorRef.current || value === undefined) return;\n if (editorRef.current.getOption(monacoRef.current!.editor.EditorOption.readOnly)) {\n editorRef.current.setValue(value);\n } else if (value !== editorRef.current.getValue()) {\n preventTriggerChangeEvent.current = true;\n editorRef.current.executeEdits('', [\n {\n range: editorRef.current.getModel()!.getFullModelRange(),\n text: value,\n forceMoveMarkers: true,\n },\n ]);\n\n editorRef.current.pushUndoStop();\n preventTriggerChangeEvent.current = false;\n }\n },\n [value],\n isEditorReady\n );\n\n useUpdate(\n () => {\n const model = editorRef.current?.getModel();\n if (isEditorReady && model && language) {\n monacoRef.current?.editor.setModelLanguage(model, language);\n }\n },\n [language, isEditorReady],\n isEditorReady\n );\n\n useUpdate(\n () => {\n // reason for undefined check: https://github.com/suren-atoyan/monaco-react/pull/188\n if (line !== undefined) {\n editorRef.current?.revealLine(line);\n }\n },\n [line],\n isEditorReady\n );\n\n useUpdate(\n () => {\n monacoRef.current?.editor.setTheme(theme);\n },\n [theme],\n isEditorReady\n );\n\n const createEditor = useCallback(() => {\n if (!containerRef.current || !monacoRef.current) return;\n if (!preventCreation.current) {\n beforeMountRef.current(monacoRef.current);\n const autoCreatedModelPath = path || defaultPath;\n\n const defaultModel = getOrCreateModel(\n monacoRef.current,\n value || defaultValue || '',\n defaultLanguage || language || '',\n autoCreatedModelPath || ''\n );\n\n const editor = monacoRef.current.editor.create(\n containerRef.current,\n {\n model: defaultModel,\n automaticLayout: true,\n ...options,\n },\n overrideServices\n );\n editorRef.current = editor;\n\n saveViewState && editor.restoreViewState(viewStates.get(autoCreatedModelPath));\n\n monacoRef.current.editor.setTheme(theme);\n\n if (line !== undefined) {\n editor.revealLine(line);\n }\n\n setIsEditorReady(true);\n preventCreation.current = true;\n }\n }, [\n defaultValue,\n defaultLanguage,\n defaultPath,\n value,\n language,\n path,\n options,\n overrideServices,\n saveViewState,\n theme,\n line,\n ]);\n\n useEffect(() => {\n if (isEditorReady) {\n onMountRef.current(editorRef.current!, monacoRef.current!);\n }\n }, [isEditorReady]);\n\n useEffect(() => {\n !isMonacoMounting && !isEditorReady && createEditor();\n }, [isMonacoMounting, isEditorReady, createEditor]);\n\n // subscription\n // to avoid unnecessary updates (attach - dispose listener) in subscription\n valueRef.current = value;\n\n // onChange\n useEffect(() => {\n if (isEditorReady && onChange) {\n subscriptionRef.current?.dispose();\n subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {\n if (!preventTriggerChangeEvent.current) {\n onChange(editorRef.current!.getValue(), event);\n }\n });\n }\n }, [isEditorReady, onChange]);\n\n // onValidate\n useEffect(() => {\n if (isEditorReady) {\n const changeMarkersListener = monacoRef.current!.editor.onDidChangeMarkers((uris: readonly Uri[]) => {\n const editorUri = editorRef.current!.getModel()?.uri;\n\n if (editorUri) {\n const currentEditorHasMarkerChanges = uris.find((uri: Uri) => uri.path === editorUri.path);\n if (currentEditorHasMarkerChanges) {\n const markers = monacoRef.current!.editor.getModelMarkers({\n resource: editorUri,\n });\n onValidate?.(markers);\n }\n }\n });\n\n return () => {\n changeMarkersListener?.dispose();\n };\n }\n return () => {\n // eslint happy\n };\n }, [isEditorReady, onValidate]);\n\n function disposeEditor(): void {\n subscriptionRef.current?.dispose();\n\n if (keepCurrentModel) {\n saveViewState && viewStates.set(path, editorRef.current!.saveViewState());\n } else {\n editorRef.current!.getModel()?.dispose();\n }\n\n editorRef.current!.dispose();\n\n editorRef.current = null;\n preventCreation.current = false;\n setIsEditorReady(false);\n }\n\n return (\n <MonacoContainer\n width={width}\n height={height}\n isEditorReady={isEditorReady}\n loading={loading}\n _ref={containerRef}\n className={className}\n wrapperProps={wrapperProps}\n />\n );\n}\n\nexport default Editor;\n","import { useEffect, useRef } from 'react';\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nexport default usePrevious;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA,cAAAC;AAAA,EAAA;AAAA,sCAAAC;AAAA,EAAA;AAAA;AAAA;AAAA,IAAAC,wBAAmB;;;ACAnB,IAAAC,gBAAqB;;;ACErB,IAAAC,gBAAyD;AAEzD,2BAAmB;;;ACJnB,mBAAqB;;;ACErB,IAAM,SAAwC;AAAA,EAC5C,SAAS;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACb;AAAA,EACA,WAAW;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,EACX;AACF;AAEA,IAAO,iBAAQ;;;ACdf,IAAMC,UAAwC;AAAA,EAC5C,WAAW;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,YAAY;AAAA,EACd;AACF;AAEA,IAAOC,kBAAQD;;;ACPN;AADT,SAAS,QAAQ,EAAE,SAAS,GAAoC;AAC9D,SAAO,4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BAAuB,QAAQ;AAAA,MACjC;AAAA,IACF;AACA,WAAO,MAAM;AAAA,IAEb;AAAA,EACF,GAAG,CAAC,eAAe,UAAU,CAAC;AAE9B,WAAS,gBAAsB;AAC7B,oBAAgB,SAAS,QAAQ;AAEjC,QAAI,kBAAkB;AACpB,uBAAiB,WAAW,IAAI,MAAM,UAAU,QAAS,cAAc,CAAC;AAAA,IAC1E,OAAO;AACL,gBAAU,QAAS,SAAS,GAAG,QAAQ;AAAA,IACzC;AAEA,cAAU,QAAS,QAAQ;AAE3B,cAAU,UAAU;AACpB,oBAAgB,UAAU;AAC1B,qBAAiB,KAAK;AAAA,EACxB;AAEA,SACE;AAAA,IAACC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,iBAAQ;;;AD7Qf,IAAOC,sBAAQ,oBAAK,cAAM;;;AbO1B,IAAO,gBAAQC;","names":["DiffEditor_default","Editor_default","loader","import_monaco_loader","import_react","import_react","styles","styles_default","styles_default","Loading_default","import_jsx_runtime","Loading_default","MonacoContainer_default","import_react","import_react","import_jsx_runtime","loader","original","modified","MonacoContainer_default","DiffEditor_default","import_react","import_monaco_loader","loader","monaco","import_react","import_react","import_monaco_loader","import_react","import_jsx_runtime","loader","MonacoContainer_default","Editor_default","Editor_default"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,231 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* The modified source (right one) value
|
|
17
|
-
*/
|
|
18
|
-
modified?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Language for the both models - original and modified
|
|
21
|
-
*/
|
|
22
|
-
language?: string;
|
|
23
|
-
/**
|
|
24
|
-
* This prop gives you the opportunity to specify the language of the
|
|
25
|
-
* original source separately, otherwise, it will get the value of the language property
|
|
26
|
-
*/
|
|
27
|
-
originalLanguage?: string;
|
|
28
|
-
/**
|
|
29
|
-
* This prop gives you the opportunity to specify the language of the
|
|
30
|
-
* modified source separately, otherwise, it will get the value of language property
|
|
31
|
-
*/
|
|
32
|
-
modifiedLanguage?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Path for the "original" model
|
|
35
|
-
* Will be passed as a third argument to `.createModel` method
|
|
36
|
-
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(originalModelPath))`
|
|
37
|
-
*/
|
|
38
|
-
originalModelPath?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Path for the "modified" model
|
|
41
|
-
* Will be passed as a third argument to `.createModel` method
|
|
42
|
-
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(modifiedModelPath))`
|
|
43
|
-
*/
|
|
44
|
-
modifiedModelPath?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Indicator whether to dispose the current original model when the DiffEditor is unmounted or not
|
|
47
|
-
* @default false
|
|
48
|
-
*/
|
|
49
|
-
keepCurrentOriginalModel?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Indicator whether to dispose the current modified model when the DiffEditor is unmounted or not
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
keepCurrentModifiedModel?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* The theme for the monaco
|
|
57
|
-
* Available options "vs-dark" | "light"
|
|
58
|
-
* Define new themes by `monaco.editor.defineTheme`
|
|
59
|
-
* @default "light"
|
|
60
|
-
*/
|
|
61
|
-
theme?: Theme | string;
|
|
62
|
-
/**
|
|
63
|
-
* The loading screen before the editor will be mounted
|
|
64
|
-
* @default "loading..."
|
|
65
|
-
*/
|
|
66
|
-
loading?: ReactNode;
|
|
67
|
-
/**
|
|
68
|
-
* IDiffEditorConstructionOptions
|
|
69
|
-
*/
|
|
70
|
-
options?: editor.IDiffEditorConstructionOptions;
|
|
71
|
-
/**
|
|
72
|
-
* Width of the editor wrapper
|
|
73
|
-
* @default "100%"
|
|
74
|
-
*/
|
|
75
|
-
width?: number | string;
|
|
76
|
-
/**
|
|
77
|
-
* Height of the editor wrapper
|
|
78
|
-
* @default "100%"
|
|
79
|
-
*/
|
|
80
|
-
height?: number | string;
|
|
81
|
-
/**
|
|
82
|
-
* Class name for the editor container
|
|
83
|
-
*/
|
|
84
|
-
className?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Props applied to the wrapper element
|
|
87
|
-
*/
|
|
88
|
-
wrapperProps?: object;
|
|
89
|
-
/**
|
|
90
|
-
* Signature: function(monaco: Monaco) => void
|
|
91
|
-
* An event is emitted before the editor is mounted
|
|
92
|
-
* It gets the monaco instance as a first argument
|
|
93
|
-
* Defaults to "noop"
|
|
94
|
-
*/
|
|
95
|
-
beforeMount?: DiffBeforeMount;
|
|
96
|
-
/**
|
|
97
|
-
* Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
|
|
98
|
-
* An event is emitted when the editor is mounted
|
|
99
|
-
* It gets the editor instance as a first argument and the monaco instance as a second
|
|
100
|
-
* Defaults to "noop"
|
|
101
|
-
*/
|
|
102
|
-
onMount?: DiffOnMount;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
declare function DiffEditor({ original, modified, language, originalLanguage, modifiedLanguage, originalModelPath, modifiedModelPath, keepCurrentOriginalModel, keepCurrentModifiedModel, theme, loading, options, height, width, className, wrapperProps, beforeMount, onMount, }: DiffEditorProps): ReactElement;
|
|
106
|
-
|
|
107
|
-
declare const _default$1: react.MemoExoticComponent<typeof DiffEditor>;
|
|
108
|
-
|
|
109
|
-
declare function useMonaco(): Monaco | undefined;
|
|
110
|
-
|
|
111
|
-
type OnMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;
|
|
112
|
-
type BeforeMount = (monaco: Monaco) => void;
|
|
113
|
-
type OnChange = (value: string | undefined, ev: editor.IModelContentChangedEvent) => void;
|
|
114
|
-
type OnValidate = (markers: editor.IMarker[]) => void;
|
|
115
|
-
interface EditorProps {
|
|
116
|
-
/**
|
|
117
|
-
* Default value of the current model
|
|
118
|
-
*/
|
|
119
|
-
defaultValue?: string;
|
|
120
|
-
/**
|
|
121
|
-
* Default language of the current model
|
|
122
|
-
*/
|
|
123
|
-
defaultLanguage?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Default path of the current model
|
|
126
|
-
* Will be passed as the third argument to `.createModel` method
|
|
127
|
-
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
|
|
128
|
-
*/
|
|
129
|
-
defaultPath?: string;
|
|
130
|
-
/**
|
|
131
|
-
* Value of the current model
|
|
132
|
-
*/
|
|
133
|
-
value?: string;
|
|
134
|
-
/**
|
|
135
|
-
* Language of the current model
|
|
136
|
-
*/
|
|
137
|
-
language?: string;
|
|
138
|
-
/**
|
|
139
|
-
* Path of the current model
|
|
140
|
-
* Will be passed as the third argument to `.createModel` method
|
|
141
|
-
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
|
|
142
|
-
*/
|
|
143
|
-
path?: string;
|
|
144
|
-
/**
|
|
145
|
-
* The theme for the monaco
|
|
146
|
-
* Available options "vs-dark" | "light"
|
|
147
|
-
* Define new themes by `monaco.editor.defineTheme`
|
|
148
|
-
* @default "light"
|
|
149
|
-
*/
|
|
150
|
-
theme?: Theme | string;
|
|
151
|
-
/**
|
|
152
|
-
* The line to jump on it
|
|
153
|
-
*/
|
|
154
|
-
line?: number;
|
|
155
|
-
/**
|
|
156
|
-
* The loading screen before the editor will be mounted
|
|
157
|
-
* @default "Loading..."
|
|
158
|
-
*/
|
|
159
|
-
loading?: ReactNode;
|
|
160
|
-
/**
|
|
161
|
-
* IStandaloneEditorConstructionOptions
|
|
162
|
-
*/
|
|
163
|
-
options?: editor.IStandaloneEditorConstructionOptions;
|
|
164
|
-
/**
|
|
165
|
-
* IEditorOverrideServices
|
|
166
|
-
*/
|
|
167
|
-
overrideServices?: editor.IEditorOverrideServices;
|
|
168
|
-
/**
|
|
169
|
-
* Indicator whether to save the models' view states between model changes or not
|
|
170
|
-
* Defaults to true
|
|
171
|
-
*/
|
|
172
|
-
saveViewState?: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Indicator whether to dispose the current model when the Editor is unmounted or not
|
|
175
|
-
* @default false
|
|
176
|
-
*/
|
|
177
|
-
keepCurrentModel?: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Width of the editor wrapper
|
|
180
|
-
* @default "100%"
|
|
181
|
-
*/
|
|
182
|
-
width?: number | string;
|
|
183
|
-
/**
|
|
184
|
-
* Height of the editor wrapper
|
|
185
|
-
* @default "100%"
|
|
186
|
-
*/
|
|
187
|
-
height?: number | string;
|
|
188
|
-
/**
|
|
189
|
-
* Class name for the editor container
|
|
190
|
-
*/
|
|
191
|
-
className?: string;
|
|
192
|
-
/**
|
|
193
|
-
* Props applied to the wrapper element
|
|
194
|
-
*/
|
|
195
|
-
wrapperProps?: object;
|
|
196
|
-
/**
|
|
197
|
-
* Signature: function(monaco: Monaco) => void
|
|
198
|
-
* An event is emitted before the editor is mounted
|
|
199
|
-
* It gets the monaco instance as a first argument
|
|
200
|
-
* Defaults to "noop"
|
|
201
|
-
*/
|
|
202
|
-
beforeMount?: BeforeMount;
|
|
203
|
-
/**
|
|
204
|
-
* Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
|
|
205
|
-
* An event is emitted when the editor is mounted
|
|
206
|
-
* It gets the editor instance as a first argument and the monaco instance as a second
|
|
207
|
-
* Defaults to "noop"
|
|
208
|
-
*/
|
|
209
|
-
onMount?: OnMount;
|
|
210
|
-
/**
|
|
211
|
-
* Signature: function(value: string | undefined, ev: monaco.editor.IModelContentChangedEvent) => void
|
|
212
|
-
* An event is emitted when the content of the current model is changed
|
|
213
|
-
*/
|
|
214
|
-
onChange?: OnChange;
|
|
215
|
-
/**
|
|
216
|
-
* Signature: function(markers: monaco.editor.IMarker[]) => void
|
|
217
|
-
* An event is emitted when the content of the current model is changed
|
|
218
|
-
* and the current model markers are ready
|
|
219
|
-
* Defaults to "noop"
|
|
220
|
-
*/
|
|
221
|
-
onValidate?: OnValidate;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
declare function Editor({ defaultValue, defaultLanguage, defaultPath, value, language, path, theme, line, loading, options, overrideServices, saveViewState, keepCurrentModel, width, height, className, wrapperProps, beforeMount, onMount, onChange, onValidate, }: EditorProps): ReactElement;
|
|
225
|
-
|
|
226
|
-
declare const _default: react.MemoExoticComponent<typeof Editor>;
|
|
227
|
-
|
|
228
|
-
type Monaco = typeof monaco;
|
|
229
|
-
type Theme = 'vs-dark' | 'light';
|
|
230
|
-
|
|
231
|
-
export { type BeforeMount, type DiffBeforeMount, _default$1 as DiffEditor, type DiffEditorProps, type DiffOnMount, _default as Editor, type EditorProps, type Monaco, type MonacoDiffEditor, type OnChange, type OnMount, type OnValidate, type Theme, _default as default, useMonaco };
|
|
1
|
+
import loader from '@willbooster/monaco-loader';
|
|
2
|
+
export { loader };
|
|
3
|
+
import DiffEditor from './DiffEditor';
|
|
4
|
+
export * from './DiffEditor/types';
|
|
5
|
+
export { DiffEditor };
|
|
6
|
+
import useMonaco from './hooks/useMonaco';
|
|
7
|
+
export { useMonaco };
|
|
8
|
+
import Editor from './Editor';
|
|
9
|
+
export * from './Editor/types';
|
|
10
|
+
export { Editor };
|
|
11
|
+
export default Editor;
|
|
12
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
13
|
+
export type Monaco = typeof monaco;
|
|
14
|
+
export type Theme = 'vs-dark' | 'light';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,eAAe,MAAM,CAAC;AAGtB,OAAO,KAAK,KAAK,MAAM,MAAM,2CAA2C,CAAC;AACzE,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAGnC,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC"}
|