mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-03 21:35:19 +03:00
fix(core): sidebar extension sometimes not show (#5513)
This commit is contained in:
parent
b0716ae721
commit
b86a5a2830
@ -9,15 +9,7 @@ import { fontStyleOptions } from '@toeverything/infra/atom';
|
||||
import clsx from 'clsx';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import type { CSSProperties } from 'react';
|
||||
import {
|
||||
memo,
|
||||
Suspense,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { memo, Suspense, useCallback, useMemo } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import { type PageMode, pageSettingFamily } from '../atoms';
|
||||
@ -96,14 +88,14 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({
|
||||
[isPublic, switchToEdgelessMode, pageId, switchToPageMode]
|
||||
);
|
||||
|
||||
const [editor, setEditor] = useState<AffineEditorContainer>();
|
||||
const [, setActiveBlocksuiteEditor] = useActiveBlocksuiteEditor();
|
||||
const blockId = useRouterHash();
|
||||
|
||||
const onLoadEditor = useCallback(
|
||||
(editor: AffineEditorContainer) => {
|
||||
// debug current detail editor
|
||||
globalThis.currentEditor = editor;
|
||||
setEditor(editor);
|
||||
setActiveBlocksuiteEditor(editor);
|
||||
const disposableGroup = new DisposableGroup();
|
||||
disposableGroup.add(
|
||||
page.slots.blockUpdated.once(() => {
|
||||
@ -121,18 +113,9 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({
|
||||
disposableGroup.dispose();
|
||||
};
|
||||
},
|
||||
[onLoad, page]
|
||||
[onLoad, page, setActiveBlocksuiteEditor]
|
||||
);
|
||||
|
||||
const [, setActiveBlocksuiteEditor] = useActiveBlocksuiteEditor();
|
||||
const editorRef = useRef<AffineEditorContainer | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (editor) {
|
||||
setActiveBlocksuiteEditor(editorRef.current);
|
||||
}
|
||||
}, [editor, setActiveBlocksuiteEditor]);
|
||||
|
||||
return (
|
||||
<Editor
|
||||
className={clsx(styles.editor, {
|
||||
@ -149,7 +132,6 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({
|
||||
onModeChange={setEditorMode}
|
||||
defaultSelectedBlockId={blockId}
|
||||
onLoadEditor={onLoadEditor}
|
||||
ref={editorRef}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user