mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +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
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
AppSidebarFallback,
|
||||
appSidebarResizingAtom,
|
||||
} from '@affine/component/app-sidebar';
|
||||
import { RootBlockHub } from '@affine/component/block-hub';
|
||||
import {
|
||||
type DraggableTitleCellData,
|
||||
PageListDragOverlay,
|
||||
@@ -305,7 +304,6 @@ export const WorkspaceLayoutInner = ({
|
||||
children
|
||||
)}
|
||||
<ToolContainer inTrashPage={inTrashPage}>
|
||||
<RootBlockHub />
|
||||
<HelpIsland showList={pageId ? undefined : showList} />
|
||||
</ToolContainer>
|
||||
</MainContainer>
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
import { WorkspaceSubPath } from '@affine/env/workspace';
|
||||
import { globalBlockSuiteSchema } from '@affine/workspace/manager';
|
||||
import { SyncEngineStep } from '@affine/workspace/providers';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { EditorContainer } from '@blocksuite/presets';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import {
|
||||
contentLayoutAtom,
|
||||
|
||||
@@ -45,9 +45,13 @@ export const loader: LoaderFunction = async args => {
|
||||
return redirect('/404');
|
||||
}
|
||||
|
||||
if (!args.params.pageId) {
|
||||
if (args.params.pageId) {
|
||||
localStorage.setItem('last_page_id', args.params.pageId);
|
||||
rootStore.set(currentPageIdAtom, args.params.pageId);
|
||||
} else {
|
||||
rootStore.set(currentPageIdAtom, null);
|
||||
}
|
||||
|
||||
const [workspaceAtom] = getBlockSuiteWorkspaceAtom(currentMetadata.id);
|
||||
workspaceLoaderLogger.info('get cloud workspace atom');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user