init: the first public commit for AFFiNE

This commit is contained in:
DarkSky committed 2022-07-22 15:49:21 +08:00
commit e3e3741393
1451 files changed
+108124

No files matched your search

@@ -0,0 +1,42 @@
import { ClipboardParse } from '@toeverything/components/editor-core';
import { createEditor } from '@toeverything/components/affine-editor';
import { fileExporter } from './file-exporter';
interface CreateClipboardParseProps {
workspaceId: string;
rootBlockId: string;
}
const createClipboardParse = ({
workspaceId,
rootBlockId,
}: CreateClipboardParseProps) => {
const editor = createEditor(workspaceId);
editor.setRootBlockId(rootBlockId);
return new ClipboardParse(editor);
};
interface ExportHandlerProps extends CreateClipboardParseProps {
title: string;
}
export const exportHtml = async ({
workspaceId,
rootBlockId,
title,
}: ExportHandlerProps) => {
const clipboardParse = createClipboardParse({ workspaceId, rootBlockId });
const htmlContent = await clipboardParse.page2html();
fileExporter.exportHtml(title, htmlContent);
};
export const exportMarkdown = async ({
workspaceId,
rootBlockId,
title,
}: ExportHandlerProps) => {
const clipboardParse = createClipboardParse({ workspaceId, rootBlockId });
const htmlContent = await clipboardParse.page2html();
fileExporter.exportMarkdown(title, htmlContent);
};