mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor: remove NoSsr on top level (#1951)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
'use client';
|
||||
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
@@ -11,7 +10,9 @@ import { BlockSuiteEditor } from '../../blocksuite/block-suite-editor';
|
||||
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
|
||||
'test',
|
||||
_ => undefined,
|
||||
Generator.AutoIncrement
|
||||
{
|
||||
idGenerator: Generator.AutoIncrement,
|
||||
}
|
||||
);
|
||||
|
||||
const page = blockSuiteWorkspace.createPage('page0');
|
||||
|
||||
@@ -89,8 +89,8 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({
|
||||
<Wrapper marginBottom="42px">{t('Publishing Description')}</Wrapper>
|
||||
<Button
|
||||
data-testid="publish-to-web-button"
|
||||
onClick={() => {
|
||||
publishWorkspace(true);
|
||||
onClick={async () => {
|
||||
await publishWorkspace(true);
|
||||
}}
|
||||
type="light"
|
||||
shape="circle"
|
||||
|
||||
@@ -5,12 +5,13 @@ import { useBlockSuiteWorkspacePageTitle } from '@toeverything/hooks/use-blocksu
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import Head from 'next/head';
|
||||
import type React from 'react';
|
||||
import { lazy, startTransition, Suspense, useCallback } from 'react';
|
||||
import { startTransition, useCallback } from 'react';
|
||||
|
||||
import { currentEditorAtom, workspacePreferredModeAtom } from '../atoms';
|
||||
import { usePageMeta } from '../hooks/use-page-meta';
|
||||
import type { AffineOfficialWorkspace } from '../shared';
|
||||
import { PageNotFoundError } from './affine/affine-error-eoundary';
|
||||
import { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor';
|
||||
import { WorkspaceHeader } from './blocksuite/workspace-header';
|
||||
|
||||
export type PageDetailEditorProps = {
|
||||
@@ -23,12 +24,6 @@ export type PageDetailEditorProps = {
|
||||
header?: React.ReactNode;
|
||||
};
|
||||
|
||||
const Editor = lazy(() =>
|
||||
import('./blocksuite/block-suite-editor').then(module => ({
|
||||
default: module.BlockSuiteEditor,
|
||||
}))
|
||||
);
|
||||
|
||||
export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
|
||||
workspace,
|
||||
pageId,
|
||||
@@ -64,34 +59,32 @@ export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
|
||||
>
|
||||
{header}
|
||||
</WorkspaceHeader>
|
||||
<Suspense>
|
||||
<Editor
|
||||
style={{
|
||||
height: 'calc(100% - 52px)',
|
||||
}}
|
||||
key={pageId}
|
||||
mode={isPublic ? 'page' : currentMode}
|
||||
page={page}
|
||||
onInit={useCallback(
|
||||
(page: Page, editor: Readonly<EditorContainer>) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onInit(page, editor);
|
||||
},
|
||||
[onInit, setEditor]
|
||||
)}
|
||||
onLoad={useCallback(
|
||||
(page: Page, editor: EditorContainer) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onLoad?.(page, editor);
|
||||
},
|
||||
[onLoad, setEditor]
|
||||
)}
|
||||
/>
|
||||
</Suspense>
|
||||
<Editor
|
||||
style={{
|
||||
height: 'calc(100% - 52px)',
|
||||
}}
|
||||
key={`${workspace.flavour}-${workspace.id}-${[pageId]}`}
|
||||
mode={isPublic ? 'page' : currentMode}
|
||||
page={page}
|
||||
onInit={useCallback(
|
||||
(page: Page, editor: Readonly<EditorContainer>) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onInit(page, editor);
|
||||
},
|
||||
[onInit, setEditor]
|
||||
)}
|
||||
onLoad={useCallback(
|
||||
(page: Page, editor: EditorContainer) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onLoad?.(page, editor);
|
||||
},
|
||||
[onLoad, setEditor]
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user