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 { theme } = useTheme();
|
||||||
const $viewer = useRef(null);
|
const $viewer = useRef(null);
|
||||||
const $container = useRef<HTMLElement>();
|
const $container = useRef<HTMLElement>();
|
||||||
const doRenderRef = useRef<() => void>();
|
|
||||||
const isEditorReady = useEditorReady(editor, () => {
|
const isEditorReady = useEditorReady(editor, () => {
|
||||||
doRenderRef.current && doRenderRef.current();
|
render($container.current);
|
||||||
});
|
});
|
||||||
const [bgColor, setBgColor] = useState('var(--semi-color-fill-0)');
|
const [bgColor, setBgColor] = useState('var(--semi-color-fill-0)');
|
||||||
const bgColorOpacity = useMemo(() => {
|
const bgColorOpacity = useMemo(() => {
|
||||||
|
@ -79,26 +78,20 @@ export const FlowWrapper = ({ editor, node, updateAttributes }) => {
|
||||||
|
|
||||||
const render = useCallback(
|
const render = useCallback(
|
||||||
(div) => {
|
(div) => {
|
||||||
const doRender = (div) => {
|
|
||||||
if (!div) return;
|
|
||||||
// @ts-ignore
|
|
||||||
const DrawioViewer = window.GraphViewer;
|
|
||||||
if (DrawioViewer) {
|
|
||||||
div.innerHTML = '';
|
|
||||||
DrawioViewer.createViewerForElement(div, (viewer) => {
|
|
||||||
$viewer.current = viewer;
|
|
||||||
const background = viewer?.graph?.background;
|
|
||||||
background && setBgColor(background);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
doRenderRef.current = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isEditorReady) {
|
if (!isEditorReady) {
|
||||||
doRenderRef.current = () => doRender(div);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
doRender(div);
|
|
||||||
|
if (!div) return;
|
||||||
|
// @ts-ignore
|
||||||
|
const DrawioViewer = window.GraphViewer;
|
||||||
|
if (DrawioViewer) {
|
||||||
|
div.innerHTML = '';
|
||||||
|
DrawioViewer.createViewerForElement(div, (viewer) => {
|
||||||
|
$viewer.current = viewer;
|
||||||
|
const background = viewer?.graph?.background;
|
||||||
|
background && setBgColor(background);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[isEditorReady]
|
[isEditorReady]
|
||||||
|
|
Loading…
Reference in New Issue