提交 eab2fd9a authored 作者: 王鹏飞's avatar 王鹏飞

fix(admin): observe initial toolbar rendering

上级 e3199859
......@@ -37,7 +37,17 @@ export const useToolbarPresentation = ({ toolbarRef, active, editor }) => {
useEffect(() => {
if (!active || !editor) return
const frame = requestAnimationFrame(() => applyToolbarPresentation(toolbarRef.current))
return () => cancelAnimationFrame(frame)
const toolbar = toolbarRef.current
if (!toolbar) return
const apply = () => applyToolbarPresentation(toolbar)
const frame = requestAnimationFrame(apply)
const observer = new MutationObserver(apply)
observer.observe(toolbar, { childList: true, subtree: true })
return () => {
cancelAnimationFrame(frame)
observer.disconnect()
}
}, [active, editor, toolbarRef])
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论