mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
feat: bump blocksuite (#5194)
Co-authored-by: AyushAgrawal-A2 <ayushagl06@gmail.com>
This commit is contained in:
@@ -2,10 +2,8 @@ import './page-detail-editor.css';
|
||||
|
||||
import { PageNotFoundError } from '@affine/env/constant';
|
||||
import type { LayoutNode } from '@affine/sdk/entry';
|
||||
import { rootBlockHubAtom } from '@affine/workspace/atom';
|
||||
import type { BlockHub } from '@blocksuite/blocks';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import { assertExists, DisposableGroup } from '@blocksuite/global/utils';
|
||||
import type { EditorContainer } from '@blocksuite/presets';
|
||||
import type { Page, Workspace } from '@blocksuite/store';
|
||||
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
|
||||
import { useBlockSuiteWorkspacePage } from '@toeverything/hooks/use-block-suite-workspace-page';
|
||||
@@ -16,7 +14,7 @@ import {
|
||||
} from '@toeverything/infra/__internal__/plugin';
|
||||
import { contentLayoutAtom, getCurrentStore } from '@toeverything/infra/atom';
|
||||
import clsx from 'clsx';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import type { CSSProperties, ReactElement } from 'react';
|
||||
import {
|
||||
memo,
|
||||
@@ -59,33 +57,6 @@ function useRouterHash() {
|
||||
return useLocation().hash.substring(1);
|
||||
}
|
||||
|
||||
function useCreateAndSetRootBlockHub(
|
||||
editor?: EditorContainer,
|
||||
showBlockHub?: boolean
|
||||
) {
|
||||
const setBlockHub = useSetAtom(rootBlockHubAtom);
|
||||
useEffect(() => {
|
||||
let canceled = false;
|
||||
let blockHub: BlockHub | undefined;
|
||||
if (editor && showBlockHub) {
|
||||
editor
|
||||
.createBlockHub()
|
||||
.then(bh => {
|
||||
if (canceled) {
|
||||
return;
|
||||
}
|
||||
blockHub = bh;
|
||||
setBlockHub(blockHub);
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
return () => {
|
||||
canceled = true;
|
||||
blockHub?.remove();
|
||||
};
|
||||
}, [editor, showBlockHub, setBlockHub]);
|
||||
}
|
||||
|
||||
const EditorWrapper = memo(function EditorWrapper({
|
||||
workspace,
|
||||
pageId,
|
||||
@@ -142,11 +113,9 @@ const EditorWrapper = memo(function EditorWrapper({
|
||||
[isPublic, switchToEdgelessMode, pageId, switchToPageMode]
|
||||
);
|
||||
|
||||
const [editor, setEditor] = useState<EditorContainer>();
|
||||
const [, setEditor] = useState<EditorContainer>();
|
||||
const blockId = useRouterHash();
|
||||
|
||||
useCreateAndSetRootBlockHub(editor, !meta.trash);
|
||||
|
||||
const onLoadEditor = useCallback(
|
||||
(editor: EditorContainer) => {
|
||||
// debug current detail editor
|
||||
|
||||
Reference in New Issue
Block a user