Files
site-builder/craft/src/panels/topbar/ExportCommand.tsx
T

29 lines
948 B
TypeScript
Raw Normal View History

import React from 'react';
import { useRegisterCommands } from '../../editor/commands';
import { useEditorConfig } from '../../state/EditorConfigContext';
import { useSiteExport } from '../../hooks/useSiteExport';
/**
* Registers `site.download-zip` ("Download site (.zip)") in WHP mode -- it then shows
* in the top-bar ⋯ menu and the Cmd+K palette. Renders nothing; mounted once in
* CanvasOverlays. Standalone mode registers nothing.
*/
export const ExportCommand: React.FC = () => {
const { isWHP } = useEditorConfig();
const { downloadZip } = useSiteExport();
useRegisterCommands(
isWHP
? [{
id: 'site.download-zip',
title: 'Download site (.zip)',
group: 'site',
keywords: ['export', 'zip', 'backup', 'download', 'archive'],
when: () => isWHP,
run: async () => { await downloadZip(); },
}]
: [],
[isWHP, downloadZip],
);
return null;
};