minor fixes
This commit is contained in:
parent
9350aee23f
commit
c39eaf6e93
|
@ -55,22 +55,20 @@ const createEditorState = (
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProseMirror = (props: Props) => {
|
export const ProseMirror = (props: Props) => {
|
||||||
const editorRef = {} as HTMLDivElement
|
let editorRef: HTMLDivElement
|
||||||
const editorView = () => untrack(() => unwrap(props.editorView))
|
const editorView = () => untrack(() => unwrap(props.editorView))
|
||||||
|
|
||||||
const dispatchTransaction = (tr: Transaction) => {
|
const dispatchTransaction = (tr: Transaction) => {
|
||||||
if (!editorView()) return
|
if (!editorView()) return
|
||||||
|
|
||||||
const newState = editorView().state.apply(tr)
|
const newState = editorView().state.apply(tr)
|
||||||
|
|
||||||
editorView().updateState(newState)
|
editorView().updateState(newState)
|
||||||
|
|
||||||
if (!tr.docChanged) return
|
if (!tr.docChanged) return
|
||||||
|
|
||||||
props.onChange(newState)
|
props.onChange(newState)
|
||||||
}
|
}
|
||||||
|
|
||||||
const rerender = (state: [any, ProseMirrorExtension[]]) => {
|
// eslint-disable-next-line solid/reactivity
|
||||||
|
createEffect(
|
||||||
|
(state: [EditorState, ProseMirrorExtension[]]) => {
|
||||||
const [prevText, prevExtensions] = state
|
const [prevText, prevExtensions] = state
|
||||||
const text = unwrap(props.text) as EditorState
|
const text = unwrap(props.text) as EditorState
|
||||||
const extensions: ProseMirrorExtension[] = unwrap(props.extensions)
|
const extensions: ProseMirrorExtension[] = unwrap(props.extensions)
|
||||||
|
@ -105,10 +103,9 @@ export const ProseMirror = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [text, extensions]
|
return [text, extensions]
|
||||||
}
|
},
|
||||||
|
[props.text, props.extensions]
|
||||||
// eslint-disable-next-line solid/reactivity
|
)
|
||||||
createEffect(rerender as any, [props.text, props.extensions])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
Loading…
Reference in New Issue
Block a user