mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
fix(core): shared page's present button not working (#6117)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Scrollable } from '@affine/component';
|
import { Scrollable } from '@affine/component';
|
||||||
import { useCurrentLoginStatus } from '@affine/core/hooks/affine/use-current-login-status';
|
import { useCurrentLoginStatus } from '@affine/core/hooks/affine/use-current-login-status';
|
||||||
|
import { useActiveBlocksuiteEditor } from '@affine/core/hooks/use-block-suite-editor';
|
||||||
import { usePageDocumentTitle } from '@affine/core/hooks/use-global-state';
|
import { usePageDocumentTitle } from '@affine/core/hooks/use-global-state';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { fetchWithTraceReport } from '@affine/graphql';
|
import { fetchWithTraceReport } from '@affine/graphql';
|
||||||
@@ -8,7 +9,10 @@ import {
|
|||||||
AffineCloudBlobStorage,
|
AffineCloudBlobStorage,
|
||||||
StaticBlobStorage,
|
StaticBlobStorage,
|
||||||
} from '@affine/workspace-impl';
|
} from '@affine/workspace-impl';
|
||||||
|
import { noop } from '@blocksuite/global/utils';
|
||||||
import { Logo1Icon } from '@blocksuite/icons';
|
import { Logo1Icon } from '@blocksuite/icons';
|
||||||
|
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||||
|
import type { Doc as BlockSuiteDoc } from '@blocksuite/store';
|
||||||
import type { Doc } from '@toeverything/infra';
|
import type { Doc } from '@toeverything/infra';
|
||||||
import {
|
import {
|
||||||
EmptyBlobStorage,
|
EmptyBlobStorage,
|
||||||
@@ -25,8 +29,7 @@ import {
|
|||||||
WorkspaceManager,
|
WorkspaceManager,
|
||||||
WorkspaceScope,
|
WorkspaceScope,
|
||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import { noop } from 'foxact/noop';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import type { LoaderFunction } from 'react-router-dom';
|
import type { LoaderFunction } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
isRouteErrorResponse,
|
isRouteErrorResponse,
|
||||||
@@ -131,6 +134,7 @@ export const Component = () => {
|
|||||||
const currentWorkspace = useService(CurrentWorkspaceService);
|
const currentWorkspace = useService(CurrentWorkspaceService);
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
const [page, setPage] = useState<Doc | null>(null);
|
const [page, setPage] = useState<Doc | null>(null);
|
||||||
|
const [_, setActiveBlocksuiteEditor] = useActiveBlocksuiteEditor();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// create a workspace for share page
|
// create a workspace for share page
|
||||||
@@ -187,6 +191,14 @@ export const Component = () => {
|
|||||||
usePageDocumentTitle(pageTitle);
|
usePageDocumentTitle(pageTitle);
|
||||||
const loginStatus = useCurrentLoginStatus();
|
const loginStatus = useCurrentLoginStatus();
|
||||||
|
|
||||||
|
const onEditorLoad = useCallback(
|
||||||
|
(_: BlockSuiteDoc, editor: AffineEditorContainer) => {
|
||||||
|
setActiveBlocksuiteEditor(editor);
|
||||||
|
return noop;
|
||||||
|
},
|
||||||
|
[setActiveBlocksuiteEditor]
|
||||||
|
);
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -209,7 +221,7 @@ export const Component = () => {
|
|||||||
publishMode={publishMode}
|
publishMode={publishMode}
|
||||||
docCollection={page.blockSuiteDoc.collection}
|
docCollection={page.blockSuiteDoc.collection}
|
||||||
pageId={page.id}
|
pageId={page.id}
|
||||||
onLoad={() => noop}
|
onLoad={onEditorLoad}
|
||||||
/>
|
/>
|
||||||
{publishMode === 'page' ? <ShareFooter /> : null}
|
{publishMode === 'page' ? <ShareFooter /> : null}
|
||||||
</Scrollable.Viewport>
|
</Scrollable.Viewport>
|
||||||
|
|||||||
Reference in New Issue
Block a user