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