From 336ebd2e81081f3b69da06927a8224d599b0968f Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Sat, 30 Sep 2023 03:08:51 +0200 Subject: [PATCH] feat: Introduce tiptap mime type based modes with default extensions. DRAFT /1 NOTE: this would contradict the current mode where only what is defined in the toolbar is actually allowed as HTML. this is limiting! better, we define a default set of extension per mime type. this can then also be imported in the tiptap collaboration server to construct a valid representation of the content and be able to store that from there back to the backend. --- src/config.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/config.js diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..144b55e --- /dev/null +++ b/src/config.js @@ -0,0 +1,61 @@ +import ExtBlockquote from "@tiptap/extension-blockquote"; +import ExtBold from "@tiptap/extension-bold"; +import ExtBulletList from "@tiptap/extension-bullet-list"; +import ExtCode from "@tiptap/extension-code"; +import ExtCodeBlock from "@tiptap/extension-code-block"; +import ExtDocument from "@tiptap/extension-document"; +import ExtEmbed from "./extensions/embed"; +import ExtFigcaption from "./extensions/figcaption"; +import ExtFigure from "./extensions/figure"; +import ExtHardBreak from "@tiptap/extension-hard-break"; +import ExtHeading from "./extensions/heading"; +import ExtHorizontalRule from "@tiptap/extension-horizontal-rule"; +import ExtImageFigure from "./extensions/image-figure"; +import ExtImageInline from "./extensions/image-inline"; +import ExtItalic from "@tiptap/extension-italic"; +import ExtLink from "./extensions/link"; +import ExtListItem from "@tiptap/extension-list-item"; +import ExtOrderedList from "@tiptap/extension-ordered-list"; +import ExtParagraph from "@tiptap/extension-paragraph"; +import ExtStrike from "@tiptap/extension-strike"; +import ExtTable from "@tiptap/extension-table"; +import ExtTableCell from "@tiptap/extension-table-cell"; +import ExtTableHeader from "@tiptap/extension-table-header"; +import ExtTableRow from "@tiptap/extension-table-row"; +import ExtText from "@tiptap/extension-text"; + +// source extension? + +export const modes = { + "text/html": [ + ExtBlockquote, + ExtBold, + ExtBulletList, + ExtCode, + ExtCodeBlock, + ExtDocument, + ExtEmbed, + ExtFigcaption, + ExtFigure, + ExtHardBreak, + ExtHeading, + ExtHorizontalRule, + ExtImageFigure, + ExtImageInline, + ExtItalic, + ExtLink, + ExtListItem, + ExtOrderedList, + ExtParagraph, + ExtStrike, + ExtTable, + ExtTableCell, + ExtTableHeader, + ExtTableRow, + ExtText, + ], + "text/plain": [ExtDocument], + "text/markdown": [ExtDocument], +}; + +export default { modes };