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