mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
chore: bump blocksuite (#4801)
This commit is contained in:
@@ -18,6 +18,7 @@ export type EditorProps = {
|
||||
page: Page;
|
||||
mode: 'page' | 'edgeless';
|
||||
onInit: (page: Page, editor: Readonly<EditorContainer>) => void;
|
||||
onModeChange?: (mode: 'page' | 'edgeless') => void;
|
||||
setBlockHub?: (blockHub: BlockHub | null) => void;
|
||||
onLoad?: (page: Page, editor: EditorContainer) => () => void;
|
||||
style?: CSSProperties;
|
||||
@@ -36,7 +37,7 @@ declare global {
|
||||
}
|
||||
|
||||
const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
const { onLoad, page, mode, style } = props;
|
||||
const { onLoad, onModeChange, page, mode, style } = props;
|
||||
if (!page.loaded) {
|
||||
use(page.waitForLoaded());
|
||||
}
|
||||
@@ -59,17 +60,26 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (editor.page && onLoad) {
|
||||
const disposes = [] as ((() => void) | undefined)[];
|
||||
disposes.push(onLoad?.(page, editor));
|
||||
return () => {
|
||||
disposes
|
||||
.filter((dispose): dispose is () => void => !!dispose)
|
||||
.forEach(dispose => dispose());
|
||||
};
|
||||
const disposes = [] as ((() => void) | undefined)[];
|
||||
|
||||
if (editor) {
|
||||
const dipose = editor.slots.pageModeSwitched.on(mode => {
|
||||
onModeChange?.(mode);
|
||||
});
|
||||
|
||||
disposes.push(() => dipose.dispose());
|
||||
}
|
||||
return;
|
||||
}, [editor, editor.page, page, onLoad]);
|
||||
|
||||
if (editor.page && onLoad) {
|
||||
disposes.push(onLoad?.(page, editor));
|
||||
}
|
||||
|
||||
return () => {
|
||||
disposes
|
||||
.filter((dispose): dispose is () => void => !!dispose)
|
||||
.forEach(dispose => dispose());
|
||||
};
|
||||
}, [editor, editor.page, page, onLoad, onModeChange]);
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user