mirror of https://github.com/fantasticit/think.git
tiptap: fix render flow
This commit is contained in:
parent
35ca6cba61
commit
36102b9c82
|
@ -23,9 +23,8 @@ export const FlowWrapper = ({ editor, node, updateAttributes }) => {
|
|||
const { theme } = useTheme();
|
||||
const $viewer = useRef(null);
|
||||
const $container = useRef<HTMLElement>();
|
||||
const doRenderRef = useRef<() => void>();
|
||||
const isEditorReady = useEditorReady(editor, () => {
|
||||
doRenderRef.current && doRenderRef.current();
|
||||
render($container.current);
|
||||
});
|
||||
const [bgColor, setBgColor] = useState('var(--semi-color-fill-0)');
|
||||
const bgColorOpacity = useMemo(() => {
|
||||
|
@ -79,7 +78,10 @@ export const FlowWrapper = ({ editor, node, updateAttributes }) => {
|
|||
|
||||
const render = useCallback(
|
||||
(div) => {
|
||||
const doRender = (div) => {
|
||||
if (!isEditorReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!div) return;
|
||||
// @ts-ignore
|
||||
const DrawioViewer = window.GraphViewer;
|
||||
|
@ -91,15 +93,6 @@ export const FlowWrapper = ({ editor, node, updateAttributes }) => {
|
|||
background && setBgColor(background);
|
||||
});
|
||||
}
|
||||
doRenderRef.current = null;
|
||||
};
|
||||
|
||||
if (!isEditorReady) {
|
||||
doRenderRef.current = () => doRender(div);
|
||||
return;
|
||||
} else {
|
||||
doRender(div);
|
||||
}
|
||||
},
|
||||
[isEditorReady]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue