@blocknote/xl-docx-exporter
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
30 lines (28 loc) • 742 B
text/typescript
import {
DefaultInlineContentSchema,
DefaultStyleSchema,
InlineContentMapping,
} from "@blocknote/core";
import { ExternalHyperlink, ParagraphChild, TextRun } from "docx";
import type { DOCXExporter } from "../docxExporter.js";
export const docxInlineContentMappingForDefaultSchema: InlineContentMapping<
DefaultInlineContentSchema,
DefaultStyleSchema,
ParagraphChild,
TextRun
> = {
link: (ic, exporter) => {
return new ExternalHyperlink({
children: ic.content.map((content) => {
return (exporter as DOCXExporter<any, any, any>).transformStyledText(
content,
true,
);
}),
link: ic.href,
});
},
text: (ic, t) => {
return t.transformStyledText(ic);
},
};