@doist/typist 10.0.0-next.1 → 10.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/typist-editor.d.ts +126 -123
- package/dist/components/typist-editor.d.ts.map +1 -1
- package/dist/components/typist-editor.helper.d.ts +8 -11
- package/dist/components/typist-editor.helper.d.ts.map +1 -1
- package/dist/components/typist-editor.helper.js +21 -19
- package/dist/components/typist-editor.helper.js.map +1 -0
- package/dist/components/typist-editor.js +133 -135
- package/dist/components/typist-editor.js.map +1 -0
- package/dist/constants/common.js +9 -5
- package/dist/constants/common.js.map +1 -0
- package/dist/constants/extension-priorities.d.ts +3 -1
- package/dist/constants/extension-priorities.d.ts.map +1 -1
- package/dist/constants/extension-priorities.js +34 -30
- package/dist/constants/extension-priorities.js.map +1 -0
- package/dist/constants/regular-expressions.js +14 -10
- package/dist/constants/regular-expressions.js.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts +12 -9
- package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts.map +1 -1
- package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js +16 -19
- package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts +12 -9
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -1
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js +25 -28
- package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts +24 -22
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts.map +1 -1
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js +34 -36
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js.map +1 -0
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts +23 -20
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -1
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +15 -8
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js.map +1 -0
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js +22 -18
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js.map +1 -0
- package/dist/extensions/core/view-event-handlers.d.ts +14 -13
- package/dist/extensions/core/view-event-handlers.d.ts.map +1 -1
- package/dist/extensions/core/view-event-handlers.js +33 -31
- package/dist/extensions/core/view-event-handlers.js.map +1 -0
- package/dist/extensions/plain-text/paste-multiline-text.js +45 -59
- package/dist/extensions/plain-text/paste-multiline-text.js.map +1 -0
- package/dist/extensions/plain-text/plain-text-document.d.ts +7 -7
- package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -1
- package/dist/extensions/plain-text/plain-text-document.js +14 -13
- package/dist/extensions/plain-text/plain-text-document.js.map +1 -0
- package/dist/extensions/plain-text/plain-text-kit.d.ts +35 -33
- package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -1
- package/dist/extensions/plain-text/plain-text-kit.js +33 -48
- package/dist/extensions/plain-text/plain-text-kit.js.map +1 -0
- package/dist/extensions/plain-text/plain-text-paragraph.d.ts +2 -9
- package/dist/extensions/plain-text/plain-text-paragraph.js +11 -11
- package/dist/extensions/plain-text/plain-text-paragraph.js.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js +37 -81
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js +32 -42
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +24 -37
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js.map +1 -0
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js +21 -13
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js.map +1 -0
- package/dist/extensions/rich-text/bold-and-italics.js +42 -40
- package/dist/extensions/rich-text/bold-and-italics.js.map +1 -0
- package/dist/extensions/rich-text/curvenote-codemark.js +16 -14
- package/dist/extensions/rich-text/curvenote-codemark.js.map +1 -0
- package/dist/extensions/rich-text/paste-emojis.js +20 -22
- package/dist/extensions/rich-text/paste-emojis.js.map +1 -0
- package/dist/extensions/rich-text/paste-markdown.js +46 -86
- package/dist/extensions/rich-text/paste-markdown.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-bullet-list.d.ts +10 -9
- package/dist/extensions/rich-text/rich-text-bullet-list.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-bullet-list.js +42 -56
- package/dist/extensions/rich-text/rich-text-bullet-list.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-code.js +34 -34
- package/dist/extensions/rich-text/rich-text-code.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-document.d.ts +7 -7
- package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-document.js +14 -13
- package/dist/extensions/rich-text/rich-text-document.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-heading.d.ts +5 -4
- package/dist/extensions/rich-text/rich-text-heading.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-heading.js +25 -25
- package/dist/extensions/rich-text/rich-text-heading.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-image.d.ts +53 -52
- package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-image.js +88 -105
- package/dist/extensions/rich-text/rich-text-image.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-kit.d.ts +127 -125
- package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-kit.js +73 -135
- package/dist/extensions/rich-text/rich-text-kit.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-link.d.ts +5 -4
- package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-link.js +82 -90
- package/dist/extensions/rich-text/rich-text-link.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-ordered-list.d.ts +10 -9
- package/dist/extensions/rich-text/rich-text-ordered-list.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-ordered-list.js +42 -56
- package/dist/extensions/rich-text/rich-text-ordered-list.js.map +1 -0
- package/dist/extensions/rich-text/rich-text-strikethrough.d.ts +5 -4
- package/dist/extensions/rich-text/rich-text-strikethrough.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-strikethrough.js +10 -10
- package/dist/extensions/rich-text/rich-text-strikethrough.js.map +1 -0
- package/dist/extensions/shared/copy-markdown-source.js +22 -31
- package/dist/extensions/shared/copy-markdown-source.js.map +1 -0
- package/dist/extensions/shared/paste-html-table-as-string.js +47 -60
- package/dist/extensions/shared/paste-html-table-as-string.js.map +1 -0
- package/dist/extensions/shared/paste-singleline-text.js +31 -39
- package/dist/extensions/shared/paste-singleline-text.js.map +1 -0
- package/dist/factories/create-suggestion-extension.d.ts +74 -74
- package/dist/factories/create-suggestion-extension.d.ts.map +1 -1
- package/dist/factories/create-suggestion-extension.js +139 -161
- package/dist/factories/create-suggestion-extension.js.map +1 -0
- package/dist/helpers/dom.js +9 -5
- package/dist/helpers/dom.js.map +1 -0
- package/dist/helpers/schema.d.ts +5 -3
- package/dist/helpers/schema.d.ts.map +1 -1
- package/dist/helpers/schema.js +25 -21
- package/dist/helpers/schema.js.map +1 -0
- package/dist/helpers/serializer.js +24 -28
- package/dist/helpers/serializer.js.map +1 -0
- package/dist/helpers/unified.js +24 -17
- package/dist/helpers/unified.js.map +1 -0
- package/dist/hooks/use-editor.js +50 -53
- package/dist/hooks/use-editor.js.map +1 -0
- package/dist/index.d.ts +25 -31
- package/dist/index.js +24 -24
- package/dist/serializers/html/html.d.ts +12 -10
- package/dist/serializers/html/html.d.ts.map +1 -1
- package/dist/serializers/html/html.js +67 -127
- package/dist/serializers/html/html.js.map +1 -0
- package/dist/serializers/html/plugins/rehype-code-block.js +17 -17
- package/dist/serializers/html/plugins/rehype-code-block.js.map +1 -0
- package/dist/serializers/html/plugins/rehype-image.js +20 -30
- package/dist/serializers/html/plugins/rehype-image.js.map +1 -0
- package/dist/serializers/html/plugins/rehype-suggestions.js +31 -32
- package/dist/serializers/html/plugins/rehype-suggestions.js.map +1 -0
- package/dist/serializers/html/plugins/rehype-task-list.js +31 -32
- package/dist/serializers/html/plugins/rehype-task-list.js.map +1 -0
- package/dist/serializers/html/plugins/remark-autolink-literal.d.ts +4 -1
- package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
- package/dist/serializers/html/plugins/remark-autolink-literal.js +25 -21
- package/dist/serializers/html/plugins/remark-autolink-literal.js.map +1 -0
- package/dist/serializers/html/plugins/remark-disable-constructs.js +21 -41
- package/dist/serializers/html/plugins/remark-disable-constructs.js.map +1 -0
- package/dist/serializers/html/plugins/remark-strikethrough.d.ts +5 -2
- package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
- package/dist/serializers/html/plugins/remark-strikethrough.js +25 -21
- package/dist/serializers/html/plugins/remark-strikethrough.js.map +1 -0
- package/dist/serializers/markdown/markdown.d.ts +13 -12
- package/dist/serializers/markdown/markdown.d.ts.map +1 -1
- package/dist/serializers/markdown/markdown.js +78 -154
- package/dist/serializers/markdown/markdown.js.map +1 -0
- package/dist/serializers/markdown/plugins/image.js +27 -24
- package/dist/serializers/markdown/plugins/image.js.map +1 -0
- package/dist/serializers/markdown/plugins/list-item.js +32 -37
- package/dist/serializers/markdown/plugins/list-item.js.map +1 -0
- package/dist/serializers/markdown/plugins/paragraph.js +19 -19
- package/dist/serializers/markdown/plugins/paragraph.js.map +1 -0
- package/dist/serializers/markdown/plugins/strikethrough.js +23 -19
- package/dist/serializers/markdown/plugins/strikethrough.js.map +1 -0
- package/dist/serializers/markdown/plugins/suggestion.js +21 -19
- package/dist/serializers/markdown/plugins/suggestion.js.map +1 -0
- package/dist/serializers/markdown/plugins/task-item.js +31 -35
- package/dist/serializers/markdown/plugins/task-item.js.map +1 -0
- package/dist/utilities/can-insert-node-at.d.ts +12 -5
- package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
- package/dist/utilities/can-insert-node-at.js +10 -8
- package/dist/utilities/can-insert-node-at.js.map +1 -0
- package/dist/utilities/can-insert-suggestion.d.ts +11 -5
- package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
- package/dist/utilities/can-insert-suggestion.js +15 -12
- package/dist/utilities/can-insert-suggestion.js.map +1 -0
- package/package.json +4 -3
- package/dist/constants/common.d.ts +0 -10
- package/dist/constants/common.d.ts.map +0 -1
- package/dist/constants/regular-expressions.d.ts +0 -18
- package/dist/constants/regular-expressions.d.ts.map +0 -1
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts +0 -9
- package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts.map +0 -1
- package/dist/extensions/plain-text/paste-multiline-text.d.ts +0 -10
- package/dist/extensions/plain-text/paste-multiline-text.d.ts.map +0 -1
- package/dist/extensions/plain-text/plain-text-paragraph.d.ts.map +0 -1
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts +0 -9
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts.map +0 -1
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts +0 -9
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts.map +0 -1
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts +0 -9
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +0 -1
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts +0 -8
- package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts.map +0 -1
- package/dist/extensions/rich-text/bold-and-italics.d.ts +0 -8
- package/dist/extensions/rich-text/bold-and-italics.d.ts.map +0 -1
- package/dist/extensions/rich-text/curvenote-codemark.d.ts +0 -11
- package/dist/extensions/rich-text/curvenote-codemark.d.ts.map +0 -1
- package/dist/extensions/rich-text/paste-emojis.d.ts +0 -9
- package/dist/extensions/rich-text/paste-emojis.d.ts.map +0 -1
- package/dist/extensions/rich-text/paste-markdown.d.ts +0 -11
- package/dist/extensions/rich-text/paste-markdown.d.ts.map +0 -1
- package/dist/extensions/rich-text/rich-text-code.d.ts +0 -17
- package/dist/extensions/rich-text/rich-text-code.d.ts.map +0 -1
- package/dist/extensions/shared/copy-markdown-source.d.ts +0 -20
- package/dist/extensions/shared/copy-markdown-source.d.ts.map +0 -1
- package/dist/extensions/shared/paste-html-table-as-string.d.ts +0 -20
- package/dist/extensions/shared/paste-html-table-as-string.d.ts.map +0 -1
- package/dist/extensions/shared/paste-singleline-text.d.ts +0 -10
- package/dist/extensions/shared/paste-singleline-text.d.ts.map +0 -1
- package/dist/helpers/dom.d.ts +0 -8
- package/dist/helpers/dom.d.ts.map +0 -1
- package/dist/helpers/serializer.d.ts +0 -21
- package/dist/helpers/serializer.d.ts.map +0 -1
- package/dist/helpers/unified.d.ts +0 -21
- package/dist/helpers/unified.d.ts.map +0 -1
- package/dist/hooks/use-editor.d.ts +0 -19
- package/dist/hooks/use-editor.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/serializers/html/plugins/rehype-code-block.d.ts +0 -10
- package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +0 -1
- package/dist/serializers/html/plugins/rehype-image.d.ts +0 -11
- package/dist/serializers/html/plugins/rehype-image.d.ts.map +0 -1
- package/dist/serializers/html/plugins/rehype-suggestions.d.ts +0 -10
- package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +0 -1
- package/dist/serializers/html/plugins/rehype-task-list.d.ts +0 -7
- package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +0 -1
- package/dist/serializers/html/plugins/remark-disable-constructs.d.ts +0 -11
- package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/image.d.ts +0 -12
- package/dist/serializers/markdown/plugins/image.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/list-item.d.ts +0 -14
- package/dist/serializers/markdown/plugins/list-item.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/paragraph.d.ts +0 -13
- package/dist/serializers/markdown/plugins/paragraph.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/strikethrough.d.ts +0 -13
- package/dist/serializers/markdown/plugins/strikethrough.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/suggestion.d.ts +0 -11
- package/dist/serializers/markdown/plugins/suggestion.d.ts.map +0 -1
- package/dist/serializers/markdown/plugins/task-item.d.ts +0 -14
- package/dist/serializers/markdown/plugins/task-item.d.ts.map +0 -1
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { visit } from
|
|
3
|
-
import {
|
|
1
|
+
import { isHastElementNode } from "../../../helpers/unified.js";
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
import { remove } from "unist-util-remove";
|
|
4
|
+
//#region src/serializers/html/plugins/rehype-image.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
* A rehype plugin to remove the wrapping paragraph from images and to remove all inline images if
|
|
7
|
+
* the editor was configured without inline image support (Tiptap default).
|
|
8
|
+
*
|
|
9
|
+
* @param schema The editor schema to be used for nodes and marks detection.
|
|
10
|
+
*/
|
|
10
11
|
function rehypeImage(schema) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const areAllChildrenImages = node.children.every((c) => isHastElementNode(c, 'img'));
|
|
20
|
-
// Replace the paragraph with the image children if all children are images, or
|
|
21
|
-
// remove all images from the paragraph if it contains non-image children since the
|
|
22
|
-
// editor does not support inline images
|
|
23
|
-
if (areAllChildrenImages) {
|
|
24
|
-
parent.children.splice(index, 1, ...node.children);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
remove(node, (n) => isHastElementNode(n, 'img'));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return tree;
|
|
32
|
-
};
|
|
12
|
+
if (schema.nodes.image ? schema.nodes.image.spec.inline : false) return (tree) => tree;
|
|
13
|
+
return (...[tree]) => {
|
|
14
|
+
visit(tree, "element", (node, index, parent) => {
|
|
15
|
+
if (isHastElementNode(node, "p")) if (node.children.every((c) => isHastElementNode(c, "img"))) parent.children.splice(index, 1, ...node.children);
|
|
16
|
+
else remove(node, (n) => isHastElementNode(n, "img"));
|
|
17
|
+
});
|
|
18
|
+
return tree;
|
|
19
|
+
};
|
|
33
20
|
}
|
|
21
|
+
//#endregion
|
|
34
22
|
export { rehypeImage };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=rehype-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-image.js","names":[],"sources":["../../../../src/serializers/html/plugins/rehype-image.ts"],"sourcesContent":["import { remove } from 'unist-util-remove'\nimport { visit } from 'unist-util-visit'\n\nimport { isHastElementNode } from '../../../helpers/unified'\n\nimport type { Schema } from '@tiptap/pm/model'\nimport type { Node as HastNode, Parent as HastParent } from 'hast'\nimport type { Transformer } from 'unified'\n\n/**\n * A rehype plugin to remove the wrapping paragraph from images and to remove all inline images if\n * the editor was configured without inline image support (Tiptap default).\n *\n * @param schema The editor schema to be used for nodes and marks detection.\n */\nfunction rehypeImage(schema: Schema): Transformer {\n const allowInlineImages = schema.nodes.image ? schema.nodes.image.spec.inline : false\n\n // Return the tree as-is if the editor does not support inline images\n if (allowInlineImages) {\n return (tree) => tree\n }\n\n return (...[tree]: Parameters<Transformer>): ReturnType<Transformer> => {\n visit(tree, 'element', (node: HastNode, index: number, parent: HastParent) => {\n if (isHastElementNode(node, 'p')) {\n const areAllChildrenImages = node.children.every((c) => isHastElementNode(c, 'img'))\n\n // Replace the paragraph with the image children if all children are images, or\n // remove all images from the paragraph if it contains non-image children since the\n // editor does not support inline images\n if (areAllChildrenImages) {\n parent.children.splice(index, 1, ...node.children)\n } else {\n remove(node, (n) => isHastElementNode(n, 'img'))\n }\n }\n })\n\n return tree\n }\n}\n\nexport { rehypeImage }\n"],"mappings":";;;;;;;;;;AAeA,SAAS,YAAY,QAA6B;AAI9C,KAH0B,OAAO,MAAM,QAAQ,OAAO,MAAM,MAAM,KAAK,SAAS,MAI5E,SAAQ,SAAS;AAGrB,SAAQ,GAAG,CAAC,UAA4D;AACpE,QAAM,MAAM,YAAY,MAAgB,OAAe,WAAuB;AAC1E,OAAI,kBAAkB,MAAM,IAAI,CAM5B,KAL6B,KAAK,SAAS,OAAO,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAMhF,QAAO,SAAS,OAAO,OAAO,GAAG,GAAG,KAAK,SAAS;OAElD,QAAO,OAAO,MAAM,kBAAkB,GAAG,MAAM,CAAC;IAG1D;AAEF,SAAO"}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { buildSuggestionSchemaPartialRegex } from
|
|
3
|
-
import {
|
|
1
|
+
import { isHastElementNode, isHastTextNode } from "../../../helpers/unified.js";
|
|
2
|
+
import { buildSuggestionSchemaPartialRegex } from "../../../helpers/serializer.js";
|
|
3
|
+
import { visit } from "unist-util-visit";
|
|
4
|
+
//#region src/serializers/html/plugins/rehype-suggestions.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* A rehype plugin to add support for suggestions nodes (e.g., `@username` or `#channel).
|
|
7
|
+
*
|
|
8
|
+
* @param schema The editor schema to be used for suggestion nodes detection.
|
|
9
|
+
*/
|
|
9
10
|
function rehypeSuggestions(schema) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return tree;
|
|
34
|
-
};
|
|
11
|
+
const suggestionSchemaPartialRegex = buildSuggestionSchemaPartialRegex(schema);
|
|
12
|
+
if (!suggestionSchemaPartialRegex) return (tree) => tree;
|
|
13
|
+
return (...[tree]) => {
|
|
14
|
+
const suggestionSchemaRegex = new RegExp(`^${suggestionSchemaPartialRegex}`);
|
|
15
|
+
visit(tree, "element", (node) => {
|
|
16
|
+
if (isHastElementNode(node, "a") && suggestionSchemaRegex.test(String(node.properties?.href))) {
|
|
17
|
+
const [, schema, id] = /^([a-z-]+):\/\/(\S+)$/i.exec(String(node.properties?.href)) || [];
|
|
18
|
+
if (schema && id && isHastTextNode(node.children[0])) {
|
|
19
|
+
node.tagName = "span";
|
|
20
|
+
node.properties = {
|
|
21
|
+
[`data-${schema}`]: "",
|
|
22
|
+
"data-id": id,
|
|
23
|
+
"data-label": node.children[0].value
|
|
24
|
+
};
|
|
25
|
+
node.children = [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return tree;
|
|
30
|
+
};
|
|
35
31
|
}
|
|
32
|
+
//#endregion
|
|
36
33
|
export { rehypeSuggestions };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=rehype-suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-suggestions.js","names":[],"sources":["../../../../src/serializers/html/plugins/rehype-suggestions.ts"],"sourcesContent":["import { visit } from 'unist-util-visit'\n\nimport { buildSuggestionSchemaPartialRegex } from '../../../helpers/serializer'\nimport { isHastElementNode, isHastTextNode } from '../../../helpers/unified'\n\nimport type { Schema } from '@tiptap/pm/model'\nimport type { Node as HastNode } from 'hast'\nimport type { Transformer } from 'unified'\n\n/**\n * A rehype plugin to add support for suggestions nodes (e.g., `@username` or `#channel).\n *\n * @param schema The editor schema to be used for suggestion nodes detection.\n */\nfunction rehypeSuggestions(schema: Schema): Transformer {\n const suggestionSchemaPartialRegex = buildSuggestionSchemaPartialRegex(schema)\n\n // Return the tree as-is if the editor does not support suggestions\n if (!suggestionSchemaPartialRegex) {\n return (tree: HastNode) => tree\n }\n\n return (...[tree]: Parameters<Transformer>): ReturnType<Transformer> => {\n const suggestionSchemaRegex = new RegExp(`^${suggestionSchemaPartialRegex}`)\n\n visit(tree, 'element', (node: HastNode) => {\n if (\n isHastElementNode(node, 'a') &&\n suggestionSchemaRegex.test(String(node.properties?.href))\n ) {\n const [, schema, id] =\n /^([a-z-]+):\\/\\/(\\S+)$/i.exec(String(node.properties?.href)) || []\n\n // Replace the link element with a span containing the suggestion attributes\n if (schema && id && isHastTextNode(node.children[0])) {\n node.tagName = 'span'\n node.properties = {\n [`data-${schema}`]: '',\n 'data-id': id,\n 'data-label': node.children[0].value,\n }\n node.children = []\n }\n }\n })\n\n return tree\n }\n}\n\nexport { rehypeSuggestions }\n"],"mappings":";;;;;;;;;AAcA,SAAS,kBAAkB,QAA6B;CACpD,MAAM,+BAA+B,kCAAkC,OAAO;AAG9E,KAAI,CAAC,6BACD,SAAQ,SAAmB;AAG/B,SAAQ,GAAG,CAAC,UAA4D;EACpE,MAAM,wBAAwB,IAAI,OAAO,IAAI,+BAA+B;AAE5E,QAAM,MAAM,YAAY,SAAmB;AACvC,OACI,kBAAkB,MAAM,IAAI,IAC5B,sBAAsB,KAAK,OAAO,KAAK,YAAY,KAAK,CAAC,EAC3D;IACE,MAAM,GAAG,QAAQ,MACb,yBAAyB,KAAK,OAAO,KAAK,YAAY,KAAK,CAAC,IAAI,EAAE;AAGtE,QAAI,UAAU,MAAM,eAAe,KAAK,SAAS,GAAG,EAAE;AAClD,UAAK,UAAU;AACf,UAAK,aAAa;OACb,QAAQ,WAAW;MACpB,WAAW;MACX,cAAc,KAAK,SAAS,GAAG;MAClC;AACD,UAAK,WAAW,EAAE;;;IAG5B;AAEF,SAAO"}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isHastElementNode, isHastTextNode } from "../../../helpers/unified.js";
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
//#region src/serializers/html/plugins/rehype-task-list.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
* A rehype plugin to add support for Tiptap task lists (i.e., `* [ ] Task`).
|
|
6
|
+
*/
|
|
6
7
|
function rehypeTaskList() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return tree;
|
|
34
|
-
};
|
|
8
|
+
return (...[tree]) => {
|
|
9
|
+
visit(tree, "element", (node) => {
|
|
10
|
+
if (isHastElementNode(node, "ul")) {
|
|
11
|
+
if (node.children.every((c) => isHastElementNode(c, "li") && isHastTextNode(c.children[0]) && /^\[[ x]\] /i.test(c.children[0].value))) {
|
|
12
|
+
node.properties = {
|
|
13
|
+
...node.properties,
|
|
14
|
+
"data-type": "taskList"
|
|
15
|
+
};
|
|
16
|
+
node.children.forEach((c) => {
|
|
17
|
+
if (isHastElementNode(c, "li") && isHastTextNode(c.children[0])) {
|
|
18
|
+
c.properties = {
|
|
19
|
+
...c.properties,
|
|
20
|
+
"data-type": "taskItem",
|
|
21
|
+
"data-checked": String(/^\[x\]/i.test(c.children[0].value))
|
|
22
|
+
};
|
|
23
|
+
c.children[0].value = c.children[0].value.substring(4).trim();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return tree;
|
|
30
|
+
};
|
|
35
31
|
}
|
|
32
|
+
//#endregion
|
|
36
33
|
export { rehypeTaskList };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=rehype-task-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehype-task-list.js","names":[],"sources":["../../../../src/serializers/html/plugins/rehype-task-list.ts"],"sourcesContent":["import { visit } from 'unist-util-visit'\n\nimport { isHastElementNode, isHastTextNode } from '../../../helpers/unified'\n\nimport type { Node as HastNode } from 'hast'\nimport type { Transformer } from 'unified'\n\n/**\n * A rehype plugin to add support for Tiptap task lists (i.e., `* [ ] Task`).\n */\nfunction rehypeTaskList(): Transformer {\n return (...[tree]: Parameters<Transformer>): ReturnType<Transformer> => {\n visit(tree, 'element', (node: HastNode) => {\n if (isHastElementNode(node, 'ul')) {\n const areAllChildrenTaskItems = node.children.every(\n (c) =>\n isHastElementNode(c, 'li') &&\n isHastTextNode(c.children[0]) &&\n /^\\[[ x]\\] /i.test(c.children[0].value),\n )\n\n // Add the required attributes to the list and list items if all children are tasks,\n // removing the `[ ] ` or `[x] ` at the beginning of the task item text\n if (areAllChildrenTaskItems) {\n node.properties = {\n ...node.properties,\n 'data-type': 'taskList',\n }\n\n node.children.forEach((c) => {\n if (isHastElementNode(c, 'li') && isHastTextNode(c.children[0])) {\n c.properties = {\n ...c.properties,\n 'data-type': 'taskItem',\n 'data-checked': String(/^\\[x\\]/i.test(c.children[0].value)),\n }\n\n c.children[0].value = c.children[0].value.substring(4).trim()\n }\n })\n }\n }\n })\n\n return tree\n }\n}\n\nexport { rehypeTaskList }\n"],"mappings":";;;;;;AAUA,SAAS,iBAA8B;AACnC,SAAQ,GAAG,CAAC,UAA4D;AACpE,QAAM,MAAM,YAAY,SAAmB;AACvC,OAAI,kBAAkB,MAAM,KAAK;QACG,KAAK,SAAS,OACzC,MACG,kBAAkB,GAAG,KAAK,IAC1B,eAAe,EAAE,SAAS,GAAG,IAC7B,cAAc,KAAK,EAAE,SAAS,GAAG,MAAM,CAC9C,EAI4B;AACzB,UAAK,aAAa;MACd,GAAG,KAAK;MACR,aAAa;MAChB;AAED,UAAK,SAAS,SAAS,MAAM;AACzB,UAAI,kBAAkB,GAAG,KAAK,IAAI,eAAe,EAAE,SAAS,GAAG,EAAE;AAC7D,SAAE,aAAa;QACX,GAAG,EAAE;QACL,aAAa;QACb,gBAAgB,OAAO,UAAU,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;QAC9D;AAED,SAAE,SAAS,GAAG,QAAQ,EAAE,SAAS,GAAG,MAAM,UAAU,EAAE,CAAC,MAAM;;OAEnE;;;IAGZ;AAEF,SAAO"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Processor } from "unified";
|
|
2
|
+
|
|
3
|
+
//#region src/serializers/html/plugins/remark-autolink-literal.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* A remark plugin to add support for the autolink literals extension extension from the GitHub
|
|
4
6
|
* Flavored Markdown (GFM) specification.
|
|
@@ -13,5 +15,6 @@ import type { Processor } from 'unified';
|
|
|
13
15
|
* @param options Configuration options for the plugin.
|
|
14
16
|
*/
|
|
15
17
|
declare function remarkAutolinkLiteral(this: Processor): void;
|
|
18
|
+
//#endregion
|
|
16
19
|
export { remarkAutolinkLiteral };
|
|
17
20
|
//# sourceMappingURL=remark-autolink-literal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-autolink-literal.d.ts","
|
|
1
|
+
{"version":3,"file":"remark-autolink-literal.d.ts","names":[],"sources":["../../../../src/serializers/html/plugins/remark-autolink-literal.ts"],"mappings":";;;;;AAMwC;;;;;;;;;;;iBAe/B,qBAAA,CAAsB,IAAA,EAAM,SAAA"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { gfmAutolinkLiteralFromMarkdown, gfmAutolinkLiteralToMarkdown
|
|
2
|
-
import { gfmAutolinkLiteral } from
|
|
1
|
+
import { gfmAutolinkLiteralFromMarkdown, gfmAutolinkLiteralToMarkdown } from "mdast-util-gfm-autolink-literal";
|
|
2
|
+
import { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
|
|
3
|
+
//#region src/serializers/html/plugins/remark-autolink-literal.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
* A remark plugin to add support for the autolink literals extension extension from the GitHub
|
|
6
|
+
* Flavored Markdown (GFM) specification.
|
|
7
|
+
*
|
|
8
|
+
* This is an standalone plugin which makes use of both the `mdast-util-gfm-autolink-literal` and
|
|
9
|
+
* `micromark-extension-gfm-autolink-literal` packages, and the implementation is inspired by the
|
|
10
|
+
* third-party `remark-gfm` plugin.
|
|
11
|
+
*
|
|
12
|
+
* The reason why we don't use `remark-gfm` directly is because we don't want to support all other
|
|
13
|
+
* GFM features (footnotes, tables, tagfilter, and tasklists).
|
|
14
|
+
*
|
|
15
|
+
* @param options Configuration options for the plugin.
|
|
16
|
+
*/
|
|
16
17
|
function remarkAutolinkLiteral() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const data = this.data();
|
|
19
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
20
|
+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
21
|
+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
22
|
+
micromarkExtensions.push(gfmAutolinkLiteral());
|
|
23
|
+
fromMarkdownExtensions.push(gfmAutolinkLiteralFromMarkdown());
|
|
24
|
+
toMarkdownExtensions.push(gfmAutolinkLiteralToMarkdown());
|
|
24
25
|
}
|
|
26
|
+
//#endregion
|
|
25
27
|
export { remarkAutolinkLiteral };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=remark-autolink-literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-autolink-literal.js","names":[],"sources":["../../../../src/serializers/html/plugins/remark-autolink-literal.ts"],"sourcesContent":["import {\n gfmAutolinkLiteralFromMarkdown,\n gfmAutolinkLiteralToMarkdown,\n} from 'mdast-util-gfm-autolink-literal'\nimport { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal'\n\nimport type { Processor } from 'unified'\n\n/**\n * A remark plugin to add support for the autolink literals extension extension from the GitHub\n * Flavored Markdown (GFM) specification.\n *\n * This is an standalone plugin which makes use of both the `mdast-util-gfm-autolink-literal` and\n * `micromark-extension-gfm-autolink-literal` packages, and the implementation is inspired by the\n * third-party `remark-gfm` plugin.\n *\n * The reason why we don't use `remark-gfm` directly is because we don't want to support all other\n * GFM features (footnotes, tables, tagfilter, and tasklists).\n *\n * @param options Configuration options for the plugin.\n */\nfunction remarkAutolinkLiteral(this: Processor) {\n const data = this.data()\n\n const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = [])\n const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = [])\n\n micromarkExtensions.push(gfmAutolinkLiteral())\n fromMarkdownExtensions.push(gfmAutolinkLiteralFromMarkdown())\n toMarkdownExtensions.push(gfmAutolinkLiteralToMarkdown())\n}\n\nexport { remarkAutolinkLiteral }\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,SAAS,wBAAuC;CAC5C,MAAM,OAAO,KAAK,MAAM;CAExB,MAAM,sBAAsB,KAAK,wBAAwB,KAAK,sBAAsB,EAAE;CACtF,MAAM,yBAAyB,KAAK,2BAA2B,KAAK,yBAAyB,EAAE;CAC/F,MAAM,uBAAuB,KAAK,yBAAyB,KAAK,uBAAuB,EAAE;AAEzF,qBAAoB,KAAK,oBAAoB,CAAC;AAC9C,wBAAuB,KAAK,gCAAgC,CAAC;AAC7D,sBAAqB,KAAK,8BAA8B,CAAC"}
|
|
@@ -1,45 +1,25 @@
|
|
|
1
|
+
//#region src/serializers/html/plugins/remark-disable-constructs.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
* A remark plugin to disable multiple language constructs based on the availability of marks and/or
|
|
4
|
+
* nodes in the given editor schema.
|
|
5
|
+
*
|
|
6
|
+
* @param schema The editor schema to be used for nodes and marks detection.
|
|
7
|
+
*/
|
|
7
8
|
function remarkDisableConstructs(schema) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
disabledConstructs.push('codeText');
|
|
21
|
-
}
|
|
22
|
-
if (!schema.nodes.codeBlock) {
|
|
23
|
-
disabledConstructs.push('codeFenced', 'codeIndented');
|
|
24
|
-
}
|
|
25
|
-
if (!schema.nodes.heading) {
|
|
26
|
-
disabledConstructs.push('headingAtx');
|
|
27
|
-
}
|
|
28
|
-
if (!schema.nodes.horizontalRule) {
|
|
29
|
-
disabledConstructs.push('thematicBreak');
|
|
30
|
-
}
|
|
31
|
-
if (!schema.nodes.image) {
|
|
32
|
-
disabledConstructs.push('labelStartImage');
|
|
33
|
-
}
|
|
34
|
-
if (!schema.marks.link) {
|
|
35
|
-
disabledConstructs.push('labelStartLink');
|
|
36
|
-
}
|
|
37
|
-
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
38
|
-
// https://github.com/micromark/micromark#case-turn-off-constructs
|
|
39
|
-
micromarkExtensions.push({
|
|
40
|
-
disable: {
|
|
41
|
-
null: disabledConstructs,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
9
|
+
const data = this.data();
|
|
10
|
+
const disabledConstructs = [];
|
|
11
|
+
if (!schema.nodes.blockquote) disabledConstructs.push("blockQuote");
|
|
12
|
+
if (!schema.marks.bold || !schema.marks.italic) disabledConstructs.push("attention");
|
|
13
|
+
if (!schema.nodes.bulletList || !schema.nodes.orderedList) disabledConstructs.push("list");
|
|
14
|
+
if (!schema.marks.code) disabledConstructs.push("codeText");
|
|
15
|
+
if (!schema.nodes.codeBlock) disabledConstructs.push("codeFenced", "codeIndented");
|
|
16
|
+
if (!schema.nodes.heading) disabledConstructs.push("headingAtx");
|
|
17
|
+
if (!schema.nodes.horizontalRule) disabledConstructs.push("thematicBreak");
|
|
18
|
+
if (!schema.nodes.image) disabledConstructs.push("labelStartImage");
|
|
19
|
+
if (!schema.marks.link) disabledConstructs.push("labelStartLink");
|
|
20
|
+
(data.micromarkExtensions || (data.micromarkExtensions = [])).push({ disable: { null: disabledConstructs } });
|
|
44
21
|
}
|
|
22
|
+
//#endregion
|
|
45
23
|
export { remarkDisableConstructs };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=remark-disable-constructs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-disable-constructs.js","names":[],"sources":["../../../../src/serializers/html/plugins/remark-disable-constructs.ts"],"sourcesContent":["import type { Schema } from '@tiptap/pm/model'\nimport type { Processor } from 'unified'\n\n/**\n * A remark plugin to disable multiple language constructs based on the availability of marks and/or\n * nodes in the given editor schema.\n *\n * @param schema The editor schema to be used for nodes and marks detection.\n */\nfunction remarkDisableConstructs(this: Processor, schema: Schema) {\n const data = this.data()\n\n const disabledConstructs: string[] = []\n\n if (!schema.nodes.blockquote) {\n disabledConstructs.push('blockQuote')\n }\n\n if (!schema.marks.bold || !schema.marks.italic) {\n disabledConstructs.push('attention')\n }\n\n if (!schema.nodes.bulletList || !schema.nodes.orderedList) {\n disabledConstructs.push('list')\n }\n\n if (!schema.marks.code) {\n disabledConstructs.push('codeText')\n }\n\n if (!schema.nodes.codeBlock) {\n disabledConstructs.push('codeFenced', 'codeIndented')\n }\n\n if (!schema.nodes.heading) {\n disabledConstructs.push('headingAtx')\n }\n\n if (!schema.nodes.horizontalRule) {\n disabledConstructs.push('thematicBreak')\n }\n\n if (!schema.nodes.image) {\n disabledConstructs.push('labelStartImage')\n }\n\n if (!schema.marks.link) {\n disabledConstructs.push('labelStartLink')\n }\n\n const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = [])\n\n // https://github.com/micromark/micromark#case-turn-off-constructs\n micromarkExtensions.push({\n disable: {\n null: disabledConstructs,\n },\n })\n}\n\nexport { remarkDisableConstructs }\n"],"mappings":";;;;;;;AASA,SAAS,wBAAyC,QAAgB;CAC9D,MAAM,OAAO,KAAK,MAAM;CAExB,MAAM,qBAA+B,EAAE;AAEvC,KAAI,CAAC,OAAO,MAAM,WACd,oBAAmB,KAAK,aAAa;AAGzC,KAAI,CAAC,OAAO,MAAM,QAAQ,CAAC,OAAO,MAAM,OACpC,oBAAmB,KAAK,YAAY;AAGxC,KAAI,CAAC,OAAO,MAAM,cAAc,CAAC,OAAO,MAAM,YAC1C,oBAAmB,KAAK,OAAO;AAGnC,KAAI,CAAC,OAAO,MAAM,KACd,oBAAmB,KAAK,WAAW;AAGvC,KAAI,CAAC,OAAO,MAAM,UACd,oBAAmB,KAAK,cAAc,eAAe;AAGzD,KAAI,CAAC,OAAO,MAAM,QACd,oBAAmB,KAAK,aAAa;AAGzC,KAAI,CAAC,OAAO,MAAM,eACd,oBAAmB,KAAK,gBAAgB;AAG5C,KAAI,CAAC,OAAO,MAAM,MACd,oBAAmB,KAAK,kBAAkB;AAG9C,KAAI,CAAC,OAAO,MAAM,KACd,oBAAmB,KAAK,iBAAiB;AAM7C,EAH4B,KAAK,wBAAwB,KAAK,sBAAsB,EAAE,GAGlE,KAAK,EACrB,SAAS,EACL,MAAM,oBACT,EACJ,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Processor } from "unified";
|
|
2
|
+
import { Options } from "micromark-extension-gfm-strikethrough";
|
|
3
|
+
|
|
4
|
+
//#region src/serializers/html/plugins/remark-strikethrough.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* A remark plugin to add support for the strikethrough extension from the GitHub Flavored Markdown
|
|
5
7
|
* (GFM) specification.
|
|
@@ -14,5 +16,6 @@ import type { Processor } from 'unified';
|
|
|
14
16
|
* @param options Configuration options for the plugin.
|
|
15
17
|
*/
|
|
16
18
|
declare function remarkStrikethrough(this: Processor, options?: Options): void;
|
|
19
|
+
//#endregion
|
|
17
20
|
export { remarkStrikethrough };
|
|
18
21
|
//# sourceMappingURL=remark-strikethrough.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-strikethrough.d.ts","
|
|
1
|
+
{"version":3,"file":"remark-strikethrough.d.ts","names":[],"sources":["../../../../src/serializers/html/plugins/remark-strikethrough.ts"],"mappings":";;;;;;AAOwC;;;;;;;;;;;iBAe/B,mBAAA,CAAoB,IAAA,EAAM,SAAA,EAAW,OAAA,GAAS,OAAA"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown
|
|
2
|
-
import { gfmStrikethrough } from
|
|
1
|
+
import { gfmStrikethroughFromMarkdown, gfmStrikethroughToMarkdown } from "mdast-util-gfm-strikethrough";
|
|
2
|
+
import { gfmStrikethrough } from "micromark-extension-gfm-strikethrough";
|
|
3
|
+
//#region src/serializers/html/plugins/remark-strikethrough.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
* A remark plugin to add support for the strikethrough extension from the GitHub Flavored Markdown
|
|
6
|
+
* (GFM) specification.
|
|
7
|
+
*
|
|
8
|
+
* This is an standalone plugin which makes use of both the `mdast-util-gfm-strikethrough` and
|
|
9
|
+
* `micromark-extension-gfm-strikethrough` packages, and the implementation is inspired by the
|
|
10
|
+
* third-party `remark-gfm` plugin.
|
|
11
|
+
*
|
|
12
|
+
* The reason why we don't use `remark-gfm` directly is because we don't want to support all other
|
|
13
|
+
* GFM features (footnotes, tables, tagfilter, and tasklists).
|
|
14
|
+
*
|
|
15
|
+
* @param options Configuration options for the plugin.
|
|
16
|
+
*/
|
|
16
17
|
function remarkStrikethrough(options = {}) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const data = this.data();
|
|
19
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
20
|
+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
21
|
+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
22
|
+
micromarkExtensions.push(gfmStrikethrough(options));
|
|
23
|
+
fromMarkdownExtensions.push(gfmStrikethroughFromMarkdown());
|
|
24
|
+
toMarkdownExtensions.push(gfmStrikethroughToMarkdown());
|
|
24
25
|
}
|
|
26
|
+
//#endregion
|
|
25
27
|
export { remarkStrikethrough };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=remark-strikethrough.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-strikethrough.js","names":[],"sources":["../../../../src/serializers/html/plugins/remark-strikethrough.ts"],"sourcesContent":["import {\n gfmStrikethroughFromMarkdown,\n gfmStrikethroughToMarkdown,\n} from 'mdast-util-gfm-strikethrough'\nimport { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough'\n\nimport type { Options } from 'micromark-extension-gfm-strikethrough'\nimport type { Processor } from 'unified'\n\n/**\n * A remark plugin to add support for the strikethrough extension from the GitHub Flavored Markdown\n * (GFM) specification.\n *\n * This is an standalone plugin which makes use of both the `mdast-util-gfm-strikethrough` and\n * `micromark-extension-gfm-strikethrough` packages, and the implementation is inspired by the\n * third-party `remark-gfm` plugin.\n *\n * The reason why we don't use `remark-gfm` directly is because we don't want to support all other\n * GFM features (footnotes, tables, tagfilter, and tasklists).\n *\n * @param options Configuration options for the plugin.\n */\nfunction remarkStrikethrough(this: Processor, options: Options = {}) {\n const data = this.data()\n\n const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = [])\n const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = [])\n\n micromarkExtensions.push(gfmStrikethrough(options))\n fromMarkdownExtensions.push(gfmStrikethroughFromMarkdown())\n toMarkdownExtensions.push(gfmStrikethroughToMarkdown())\n}\n\nexport { remarkStrikethrough }\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAS,oBAAqC,UAAmB,EAAE,EAAE;CACjE,MAAM,OAAO,KAAK,MAAM;CAExB,MAAM,sBAAsB,KAAK,wBAAwB,KAAK,sBAAsB,EAAE;CACtF,MAAM,yBAAyB,KAAK,2BAA2B,KAAK,yBAAyB,EAAE;CAC/F,MAAM,uBAAuB,KAAK,yBAAyB,KAAK,uBAAuB,EAAE;AAEzF,qBAAoB,KAAK,iBAAiB,QAAQ,CAAC;AACnD,wBAAuB,KAAK,8BAA8B,CAAC;AAC3D,sBAAqB,KAAK,4BAA4B,CAAC"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Schema } from "@tiptap/pm/model";
|
|
2
|
+
|
|
3
|
+
//#region src/serializers/markdown/markdown.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* The return type for the `createMarkdownSerializer` function.
|
|
4
6
|
*/
|
|
5
7
|
type MarkdownSerializerReturnType = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Serializes an input HTML string to an output Markdown string.
|
|
10
|
+
*
|
|
11
|
+
* @param html The HTML string to serialize.
|
|
12
|
+
*
|
|
13
|
+
* @returns The serialized Markdown.
|
|
14
|
+
*/
|
|
15
|
+
serialize: (html: string) => string;
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* The bullet list marker for both standard and task list items.
|
|
17
19
|
*/
|
|
18
|
-
declare const BULLET_LIST_MARKER = "-";
|
|
19
20
|
/**
|
|
20
21
|
* Create an HTML to Markdown serializer with the Turndown library for both a rich-text editor, and
|
|
21
22
|
* a plain-text editor. The editor schema is used to detect which nodes and marks are available in
|
|
@@ -38,6 +39,6 @@ declare function createMarkdownSerializer(schema: Schema): MarkdownSerializerRet
|
|
|
38
39
|
* @returns The Markdown serializer instance for the given editor schema.
|
|
39
40
|
*/
|
|
40
41
|
declare function getMarkdownSerializerInstance(schema: Schema): MarkdownSerializerReturnType;
|
|
41
|
-
|
|
42
|
-
export
|
|
42
|
+
//#endregion
|
|
43
|
+
export { createMarkdownSerializer, getMarkdownSerializerInstance };
|
|
43
44
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","names":[],"sources":["../../../src/serializers/markdown/markdown.ts"],"mappings":";;;;;AAY8C;KAKzC,4BAAA;;;;AAqBmB;;;;EAbpB,SAAA,GAAY,IAAA;AAAA;;;;;;;;;;;;;;;;;iBAwEP,wBAAA,CAAyB,MAAA,EAAQ,MAAA,GAAS,4BAAA;;;;;;;;iBA8G1C,6BAAA,CAA8B,MAAA,EAAQ,MAAA,GAAM,4BAAA"}
|