Skip to content

Commit

Permalink
fix: editor endless loop (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
lusons authored May 29, 2024
1 parent afc3531 commit 3479732
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/react/src/WithoutCoreEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,23 @@ export const WithoutCoreEditor = forwardRef<
emits.mounted(shikitor)
}, [ref])

const { vRef: valueRef } = useDefault(value, defaultValue, v => {
const vRefHandle = useCallback((v: string) => {
const shikitor = shikitorRef.current
if (!shikitor) return

shikitor.value = v
})
const { vRef: optionsRef } = useDefault(options, defaultOptions, opts => {
}, [])

const { vRef: valueRef } = useDefault(value, defaultValue, vRefHandle)

const optionRefHandle = useCallback((opts: Omit<ShikitorOptions, "plugins">) => {
const shikitor = shikitorRef.current
if (!shikitor) return

shikitor.updateOptions(old => ({ ...old, ...opts }))
})
}, [])

const { vRef: optionsRef } = useDefault(options, defaultOptions, optionRefHandle)

useEffect(() => {
if (!eleRef.current) return
Expand Down

0 comments on commit 3479732

Please sign in to comment.