mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix: cannot read properties of undefined editor.host (#7333)
Fix issue [BS-657](https://linear.app/affine-design/issue/BS-657). Unable to obtain `editor.host` synchronously on `editor` reference callback. Maybe we should have a separate host reference callback. @pengx17 
This commit is contained in:
@@ -72,19 +72,21 @@ export function DocPeekPreview({
|
|||||||
const [resolvedMode, setResolvedMode] = useState<DocMode | undefined>(mode);
|
const [resolvedMode, setResolvedMode] = useState<DocMode | undefined>(mode);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (editor && resolvedMode === 'edgeless') {
|
requestAnimationFrame(() => {
|
||||||
editor.host
|
if (editor && editor.host && resolvedMode === 'edgeless') {
|
||||||
.closest('[data-testid="peek-view-modal-animation-container"]')
|
editor.host
|
||||||
?.addEventListener(
|
.closest('[data-testid="peek-view-modal-animation-container"]')
|
||||||
'animationend',
|
?.addEventListener(
|
||||||
() => {
|
'animationend',
|
||||||
fitViewport(editor, xywh);
|
() => {
|
||||||
},
|
fitViewport(editor, xywh);
|
||||||
{
|
},
|
||||||
once: true,
|
{
|
||||||
}
|
once: true,
|
||||||
);
|
}
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}, [editor, resolvedMode, xywh]);
|
}, [editor, resolvedMode, xywh]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user