mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
chore(core): temporarily hide export png and pdf in edgeless (#5364)
This commit is contained in:
@@ -21,6 +21,7 @@ interface ExportMenuItemProps<T> {
|
||||
|
||||
interface ExportProps {
|
||||
exportHandler: (type: 'pdf' | 'html' | 'png' | 'markdown') => Promise<void>;
|
||||
pageMode?: 'page' | 'edgeless';
|
||||
className?: string;
|
||||
}
|
||||
|
||||
@@ -47,6 +48,7 @@ export function ExportMenuItem<T>({
|
||||
export const ExportMenuItems = ({
|
||||
exportHandler,
|
||||
className = transitionStyle,
|
||||
pageMode = 'page',
|
||||
}: ExportProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const itemMap = useMemo(
|
||||
@@ -94,16 +96,23 @@ export const ExportMenuItems = ({
|
||||
],
|
||||
[className, exportHandler, t]
|
||||
);
|
||||
const items = itemMap.map(({ component: Component, props }) => (
|
||||
<Component key={props.label} {...props} />
|
||||
));
|
||||
const items = itemMap.map(({ component: Component, props }) =>
|
||||
pageMode === 'edgeless' &&
|
||||
(props.type === 'pdf' || props.type === 'png') ? null : (
|
||||
<Component key={props.label} {...props} />
|
||||
)
|
||||
);
|
||||
return items;
|
||||
};
|
||||
|
||||
export const Export = ({ exportHandler, className }: ExportProps) => {
|
||||
export const Export = ({ exportHandler, className, pageMode }: ExportProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const items = (
|
||||
<ExportMenuItems exportHandler={exportHandler} className={className} />
|
||||
<ExportMenuItems
|
||||
exportHandler={exportHandler}
|
||||
className={className}
|
||||
pageMode={pageMode}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<MenuSub
|
||||
|
||||
@@ -4,7 +4,9 @@ import { Divider } from '@affine/component/ui/divider';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { LinkIcon } from '@blocksuite/icons';
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
import { currentModeAtom } from '../../../../atoms/mode';
|
||||
import { useExportPage } from '../../../../hooks/affine/use-export-page';
|
||||
import * as styles from './index.css';
|
||||
import type { ShareMenuProps } from './share-menu';
|
||||
@@ -23,6 +25,7 @@ export const ShareExport = ({
|
||||
urlType: 'workspace',
|
||||
});
|
||||
const exportHandler = useExportPage(currentPage);
|
||||
const currentMode = useAtomValue(currentModeAtom);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -36,6 +39,7 @@ export const ShareExport = ({
|
||||
<ExportMenuItems
|
||||
exportHandler={exportHandler}
|
||||
className={styles.menuItemStyle}
|
||||
pageMode={currentMode}
|
||||
/>
|
||||
</div>
|
||||
{workspace.flavour !== WorkspaceFlavour.LOCAL ? (
|
||||
|
||||
@@ -182,7 +182,7 @@ export const PageHeaderMenuButton = ({ rename, pageId }: PageMenuProps) => {
|
||||
>
|
||||
{t['Import']()}
|
||||
</MenuItem>
|
||||
<Export exportHandler={exportHandler} />
|
||||
<Export exportHandler={exportHandler} pageMode={currentMode} />
|
||||
|
||||
{workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD &&
|
||||
runtimeConfig.enablePageHistory ? (
|
||||
|
||||
@@ -141,7 +141,7 @@ export function useRegisterBlocksuiteEditorCommands(
|
||||
unsubs.push(
|
||||
registerAffineCommand({
|
||||
id: `editor:${mode}-export-to-pdf`,
|
||||
preconditionStrategy,
|
||||
preconditionStrategy: () => mode === 'page' && !trash,
|
||||
category: `editor:${mode}`,
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to PDF'](),
|
||||
@@ -167,7 +167,7 @@ export function useRegisterBlocksuiteEditorCommands(
|
||||
unsubs.push(
|
||||
registerAffineCommand({
|
||||
id: `editor:${mode}-export-to-png`,
|
||||
preconditionStrategy,
|
||||
preconditionStrategy: () => mode === 'page' && !trash,
|
||||
category: `editor:${mode}`,
|
||||
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
|
||||
label: t['Export to PNG'](),
|
||||
|
||||
Reference in New Issue
Block a user