There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(core): add present to edgeless sharing (#5140)
JimmFly52cfe4521ab5
diff --git a/packages/frontend/core/src/components/cloud/share-header-right-item/index.tsx b/packages/frontend/core/src/components/cloud/share-header-right-item/index.tsxindex 564b657917..35aa14edaa 100644--- a/packages/frontend/core/src/components/cloud/share-header-right-item/index.tsx+++ b/packages/frontend/core/src/components/cloud/share-header-right-item/index.tsx@@ -1,18 +1,28 @@+import type { PageMode } from '../../../atoms';import { useCurrentLoginStatus } from '../../../hooks/affine/use-current-login-status';import { AuthenticatedItem } from './authenticated-item';+import { PresentButton } from './present';+import * as styles from './styles.css';export type ShareHeaderRightItemProps = {workspaceId: string;pageId: string;+ publishMode: PageMode;};const ShareHeaderRightItem = ({ ...props }: ShareHeaderRightItemProps) => {const loginStatus = useCurrentLoginStatus();- if (loginStatus === 'authenticated') {- return <AuthenticatedItem {...props} />;- }+ const { publishMode } = props;+// TODO: Add TOC- return null;+ return (+ <div className={styles.rightItemContainer}>+ {loginStatus === 'authenticated' ? (+ <AuthenticatedItem {...props} />+ ) : null}+ {publishMode === 'edgeless' ? <PresentButton /> : null}+ </div>+ );};export default ShareHeaderRightItem;diff --git a/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx b/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsxnew file mode 100644index 0000000000..563d6a346c--- /dev/null+++ b/packages/frontend/core/src/components/cloud/share-header-right-item/present.tsx@@ -0,0 +1,59 @@+import { Button } from '@affine/component/ui/button';+import { useAFFiNEI18N } from '@affine/i18n/hooks';+import type { SurfaceService } from '@blocksuite/blocks';+import { PresentationIcon } from '@blocksuite/icons';+import { useCallback, useEffect, useState } from 'react';++import * as styles from './styles.css';++export const PresentButton = () => {+ const t = useAFFiNEI18N();+ const [isPresent, setIsPresent] = useState(false);++ const handlePresent = useCallback(() => {+ // TODO: use editor Atom+ const editorRoot = document.querySelector('block-suite-root');+ if (!editorRoot || isPresent) return;++ // TODO: use surfaceService subAtom+ const surfaceService = editorRoot?.spec.getService(+ 'affine:surface'+ ) as SurfaceService;++ surfaceService?.setNavigatorMode(true);+ setIsPresent(true);+ }, [isPresent]);++ useEffect(() => {+ if (!isPresent) return;++ // TODO: use editor Atom+ const editorRoot = document.querySelector('block-suite-root');+ if (!editorRoot) return;++ // TODO: use surfaceService subAtom+ const surfaceService = editorRoot?.spec.getService(+ 'affine:surface'+ ) as SurfaceService;++ surfaceService.slots.edgelessToolUpdated.on(() => {+ setIsPresent(surfaceService?.currentTool?.type === 'frameNavigator');+ });++ return () => {+ surfaceService.slots.edgelessToolUpdated.dispose();+ };+ }, [isPresent]);++ return (+ <Button+ type="primary"+ icon={<PresentationIcon />}+ className={styles.presentButton}+ onClick={handlePresent}+ disabled={isPresent}+ >+ {t['com.affine.share-page.header.present']()}+ </Button>+ );+};diff --git a/packages/frontend/core/src/components/cloud/share-header-right-item/styles.css.ts b/packages/frontend/core/src/components/cloud/share-header-right-item/styles.css.tsindex 3000c5d257..389f92c4f7 100644--- a/packages/frontend/core/src/components/cloud/share-header-right-item/styles.css.ts+++ b/packages/frontend/core/src/components/cloud/share-header-right-item/styles.css.ts@@ -13,3 +13,13 @@ export const iconWrapper = style({},},});+export const rightItemContainer = style({+ display: 'flex',+ alignItems: 'center',+ gap: '8px',+ padding: '0 8px',+});++export const presentButton = style({+ gap: '4px',+});diff --git a/packages/frontend/core/src/pages/share/share-header.tsx b/packages/frontend/core/src/pages/share/share-header.tsxindex 675902637a..bbcf38f4be 100644--- a/packages/frontend/core/src/pages/share/share-header.tsx+++ b/packages/frontend/core/src/pages/share/share-header.tsx@@ -30,7 +30,11 @@ export function ShareHeader({/>}right={- <ShareHeaderRightItem workspaceId={workspace.id} pageId={pageId} />+ <ShareHeaderRightItem+ workspaceId={workspace.id}+ pageId={pageId}+ publishMode={publishMode}+ />}bottomBorder/>diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.jsonindex 3492354538..8d2e58c3fc 100644--- a/packages/frontend/i18n/src/resources/en.json+++ b/packages/frontend/i18n/src/resources/en.json@@ -1004,5 +1004,6 @@"com.affine.history.empty-prompt.title": "Empty","com.affine.history.empty-prompt.description": "This document is such a spring chicken, it hasn't sprouted a single historical sprig yet!","com.affine.history.confirm-restore-modal.restore": "Restore",- "com.affine.history.confirm-restore-modal.hint": "You are about to restore the current version of the page to the latest version available. This action will overwrite any changes made prior to the latest version."+ "com.affine.history.confirm-restore-modal.hint": "You are about to restore the current version of the page to the latest version available. This action will overwrite any changes made prior to the latest version.",+ "com.affine.share-page.header.present": "Present"}