@doist/typist 9.0.3 → 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 +26 -13
- 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,139 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
1
|
+
import "../../constants/extension-priorities.js";
|
|
2
|
+
import { CopyMarkdownSource } from "../shared/copy-markdown-source.js";
|
|
3
|
+
import { PasteHTMLTableAsString } from "../shared/paste-html-table-as-string.js";
|
|
4
|
+
import { PasteSinglelineText } from "../shared/paste-singleline-text.js";
|
|
5
|
+
import { BoldAndItalics } from "./bold-and-italics.js";
|
|
6
|
+
import { CurvenoteCodemark } from "./curvenote-codemark.js";
|
|
7
|
+
import { PasteEmojis } from "./paste-emojis.js";
|
|
8
|
+
import { PasteMarkdown } from "./paste-markdown.js";
|
|
9
|
+
import { RichTextBulletList } from "./rich-text-bullet-list.js";
|
|
10
|
+
import { RichTextCode } from "./rich-text-code.js";
|
|
11
|
+
import { RichTextDocument } from "./rich-text-document.js";
|
|
12
|
+
import { RichTextHeading } from "./rich-text-heading.js";
|
|
13
|
+
import { RichTextImage } from "./rich-text-image.js";
|
|
14
|
+
import { RichTextLink } from "./rich-text-link.js";
|
|
15
|
+
import { RichTextOrderedList } from "./rich-text-ordered-list.js";
|
|
16
|
+
import { RichTextStrikethrough } from "./rich-text-strikethrough.js";
|
|
17
|
+
import { Extension } from "@tiptap/core";
|
|
18
|
+
import { History } from "@tiptap/extension-history";
|
|
19
|
+
import { Text } from "@tiptap/extension-text";
|
|
20
|
+
import { Typography } from "@tiptap/extension-typography";
|
|
21
|
+
import { Paragraph } from "@tiptap/extension-paragraph";
|
|
22
|
+
import { Blockquote } from "@tiptap/extension-blockquote";
|
|
23
|
+
import { Bold } from "@tiptap/extension-bold";
|
|
24
|
+
import { CodeBlock } from "@tiptap/extension-code-block";
|
|
25
|
+
import { Dropcursor } from "@tiptap/extension-dropcursor";
|
|
26
|
+
import { Gapcursor } from "@tiptap/extension-gapcursor";
|
|
27
|
+
import { HardBreak } from "@tiptap/extension-hard-break";
|
|
28
|
+
import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
|
|
29
|
+
import { Italic } from "@tiptap/extension-italic";
|
|
30
|
+
import { ListItem } from "@tiptap/extension-list-item";
|
|
31
|
+
import { ListKeymap } from "@tiptap/extension-list-keymap";
|
|
32
|
+
//#region src/extensions/rich-text/rich-text-kit.ts
|
|
32
33
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
* The `RichTextKit` extension is a collection of the minimal required extensions to have a full
|
|
35
|
+
* WYSIWYG text editor working. This extension is based on the official `StarterKit` extension
|
|
36
|
+
* implementation, allowing almost every extension to be customized or disabled.
|
|
37
|
+
*/
|
|
37
38
|
const RichTextKit = Extension.create({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
extensions.push(PasteMarkdown);
|
|
73
|
-
}
|
|
74
|
-
if (this.options?.document?.multiline === false &&
|
|
75
|
-
this.options?.pasteSinglelineText !== false) {
|
|
76
|
-
// Supports pasting multiple lines into a singleline editor, by joining all the
|
|
77
|
-
// pasted lines together
|
|
78
|
-
extensions.push(PasteSinglelineText);
|
|
79
|
-
}
|
|
80
|
-
if (this.options?.pasteHTMLTableAsString !== false) {
|
|
81
|
-
// Supports pasting tables (from spreadsheets and websites) into the editor
|
|
82
|
-
extensions.push(PasteHTMLTableAsString);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (this.options.dropCursor !== false) {
|
|
86
|
-
extensions.push(Dropcursor.configure(this.options?.dropCursor));
|
|
87
|
-
}
|
|
88
|
-
if (this.options.gapCursor !== false) {
|
|
89
|
-
extensions.push(Gapcursor);
|
|
90
|
-
}
|
|
91
|
-
if (this.options.hardBreak !== false) {
|
|
92
|
-
extensions.push(HardBreak.configure(this.options?.hardBreak));
|
|
93
|
-
}
|
|
94
|
-
if (this.options.heading !== false) {
|
|
95
|
-
extensions.push(RichTextHeading.configure(this.options?.heading));
|
|
96
|
-
}
|
|
97
|
-
if (this.options.history !== false) {
|
|
98
|
-
extensions.push(History.configure(this.options?.history));
|
|
99
|
-
}
|
|
100
|
-
if (this.options.horizontalRule !== false) {
|
|
101
|
-
extensions.push(HorizontalRule.configure(this.options?.horizontalRule));
|
|
102
|
-
}
|
|
103
|
-
if (this.options.image !== false) {
|
|
104
|
-
extensions.push(RichTextImage.configure(this.options?.image));
|
|
105
|
-
}
|
|
106
|
-
if (this.options.italic !== false) {
|
|
107
|
-
extensions.push(Italic.configure(this.options?.italic));
|
|
108
|
-
}
|
|
109
|
-
if (this.options.bold !== false && this.options.italic !== false) {
|
|
110
|
-
extensions.push(BoldAndItalics);
|
|
111
|
-
}
|
|
112
|
-
if (this.options.link !== false) {
|
|
113
|
-
extensions.push(RichTextLink.configure(this.options?.link));
|
|
114
|
-
}
|
|
115
|
-
if (this.options.listItem !== false) {
|
|
116
|
-
extensions.push(ListItem.configure(this.options?.listItem));
|
|
117
|
-
}
|
|
118
|
-
if (this.options.listKeymap !== false) {
|
|
119
|
-
extensions.push(ListKeymap.configure(this.options?.listKeymap));
|
|
120
|
-
}
|
|
121
|
-
if (this.options.orderedList !== false) {
|
|
122
|
-
extensions.push(RichTextOrderedList.configure(this.options?.orderedList));
|
|
123
|
-
}
|
|
124
|
-
if (this.options.paragraph !== false) {
|
|
125
|
-
extensions.push(Paragraph.configure(this.options?.paragraph));
|
|
126
|
-
}
|
|
127
|
-
if (this.options.strike !== false) {
|
|
128
|
-
extensions.push(RichTextStrikethrough.configure(this.options?.strike));
|
|
129
|
-
}
|
|
130
|
-
if (this.options.text !== false) {
|
|
131
|
-
extensions.push(Text);
|
|
132
|
-
}
|
|
133
|
-
if (this.options.typography !== false) {
|
|
134
|
-
extensions.push(Typography);
|
|
135
|
-
}
|
|
136
|
-
return extensions;
|
|
137
|
-
},
|
|
39
|
+
name: "richTextKit",
|
|
40
|
+
addExtensions() {
|
|
41
|
+
const extensions = [];
|
|
42
|
+
if (this.options.blockquote !== false) extensions.push(Blockquote.extend({ priority: 101 }).configure(this.options?.blockquote));
|
|
43
|
+
if (this.options.bold !== false) extensions.push(Bold.configure(this.options?.bold));
|
|
44
|
+
if (this.options.bulletList !== false) extensions.push(RichTextBulletList.configure(this.options?.bulletList));
|
|
45
|
+
if (this.options.code !== false) extensions.push(RichTextCode.configure(this.options?.code), CurvenoteCodemark);
|
|
46
|
+
if (this.options.codeBlock !== false) extensions.push(CodeBlock.configure(this.options?.codeBlock));
|
|
47
|
+
if (this.options.document !== false) {
|
|
48
|
+
extensions.push(RichTextDocument.configure(this.options?.document), CopyMarkdownSource.configure({ keyboardShortcut: "Mod-Shift-c" }));
|
|
49
|
+
if (this.options?.pasteEmojis !== false) extensions.push(PasteEmojis);
|
|
50
|
+
if (this.options?.pasteMarkdown !== false) extensions.push(PasteMarkdown);
|
|
51
|
+
if (this.options?.document?.multiline === false && this.options?.pasteSinglelineText !== false) extensions.push(PasteSinglelineText);
|
|
52
|
+
if (this.options?.pasteHTMLTableAsString !== false) extensions.push(PasteHTMLTableAsString);
|
|
53
|
+
}
|
|
54
|
+
if (this.options.dropCursor !== false) extensions.push(Dropcursor.configure(this.options?.dropCursor));
|
|
55
|
+
if (this.options.gapCursor !== false) extensions.push(Gapcursor);
|
|
56
|
+
if (this.options.hardBreak !== false) extensions.push(HardBreak.configure(this.options?.hardBreak));
|
|
57
|
+
if (this.options.heading !== false) extensions.push(RichTextHeading.configure(this.options?.heading));
|
|
58
|
+
if (this.options.history !== false) extensions.push(History.configure(this.options?.history));
|
|
59
|
+
if (this.options.horizontalRule !== false) extensions.push(HorizontalRule.configure(this.options?.horizontalRule));
|
|
60
|
+
if (this.options.image !== false) extensions.push(RichTextImage.configure(this.options?.image));
|
|
61
|
+
if (this.options.italic !== false) extensions.push(Italic.configure(this.options?.italic));
|
|
62
|
+
if (this.options.bold !== false && this.options.italic !== false) extensions.push(BoldAndItalics);
|
|
63
|
+
if (this.options.link !== false) extensions.push(RichTextLink.configure(this.options?.link));
|
|
64
|
+
if (this.options.listItem !== false) extensions.push(ListItem.configure(this.options?.listItem));
|
|
65
|
+
if (this.options.listKeymap !== false) extensions.push(ListKeymap.configure(this.options?.listKeymap));
|
|
66
|
+
if (this.options.orderedList !== false) extensions.push(RichTextOrderedList.configure(this.options?.orderedList));
|
|
67
|
+
if (this.options.paragraph !== false) extensions.push(Paragraph.configure(this.options?.paragraph));
|
|
68
|
+
if (this.options.strike !== false) extensions.push(RichTextStrikethrough.configure(this.options?.strike));
|
|
69
|
+
if (this.options.text !== false) extensions.push(Text);
|
|
70
|
+
if (this.options.typography !== false) extensions.push(Typography);
|
|
71
|
+
return extensions;
|
|
72
|
+
}
|
|
138
73
|
});
|
|
74
|
+
//#endregion
|
|
139
75
|
export { RichTextKit };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=rich-text-kit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-kit.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-kit.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Blockquote } from '@tiptap/extension-blockquote'\nimport { Bold } from '@tiptap/extension-bold'\nimport { CodeBlock } from '@tiptap/extension-code-block'\nimport { Dropcursor } from '@tiptap/extension-dropcursor'\nimport { Gapcursor } from '@tiptap/extension-gapcursor'\nimport { HardBreak } from '@tiptap/extension-hard-break'\nimport { History } from '@tiptap/extension-history'\nimport { HorizontalRule } from '@tiptap/extension-horizontal-rule'\nimport { Italic } from '@tiptap/extension-italic'\nimport { ListItem } from '@tiptap/extension-list-item'\nimport { ListKeymap } from '@tiptap/extension-list-keymap'\nimport { Paragraph } from '@tiptap/extension-paragraph'\nimport { Text } from '@tiptap/extension-text'\nimport { Typography } from '@tiptap/extension-typography'\n\nimport { BLOCKQUOTE_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\nimport { CopyMarkdownSource } from '../shared/copy-markdown-source'\nimport { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string'\nimport { PasteSinglelineText } from '../shared/paste-singleline-text'\n\nimport { BoldAndItalics } from './bold-and-italics'\nimport { CurvenoteCodemark } from './curvenote-codemark'\nimport { PasteEmojis } from './paste-emojis'\nimport { PasteMarkdown } from './paste-markdown'\nimport { RichTextBulletList } from './rich-text-bullet-list'\nimport { RichTextCode } from './rich-text-code'\nimport { RichTextDocument } from './rich-text-document'\nimport { RichTextHeading, RichTextHeadingOptions } from './rich-text-heading'\nimport { RichTextImage } from './rich-text-image'\nimport { RichTextLink } from './rich-text-link'\nimport { RichTextOrderedList } from './rich-text-ordered-list'\nimport { RichTextStrikethrough } from './rich-text-strikethrough'\n\nimport type { Extensions } from '@tiptap/core'\nimport type { BlockquoteOptions } from '@tiptap/extension-blockquote'\nimport type { BoldOptions } from '@tiptap/extension-bold'\nimport type { CodeOptions } from '@tiptap/extension-code'\nimport type { CodeBlockOptions } from '@tiptap/extension-code-block'\nimport type { DropcursorOptions } from '@tiptap/extension-dropcursor'\nimport type { HardBreakOptions } from '@tiptap/extension-hard-break'\nimport type { HistoryOptions } from '@tiptap/extension-history'\nimport type { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule'\nimport type { ItalicOptions } from '@tiptap/extension-italic'\nimport type { ListItemOptions } from '@tiptap/extension-list-item'\nimport type { ListKeymapOptions } from '@tiptap/extension-list-keymap'\nimport type { ParagraphOptions } from '@tiptap/extension-paragraph'\nimport type { RichTextBulletListOptions } from './rich-text-bullet-list'\nimport type { RichTextDocumentOptions } from './rich-text-document'\nimport type { RichTextImageOptions } from './rich-text-image'\nimport type { RichTextLinkOptions } from './rich-text-link'\nimport type { RichTextOrderedListOptions } from './rich-text-ordered-list'\nimport type { RichTextStrikethroughOptions } from './rich-text-strikethrough'\n\n/**\n * The options available to customize the `RichTextKit` extension.\n */\ntype RichTextKitOptions = {\n /**\n * Set options for the `Blockquote` extension, or `false` to disable.\n */\n blockquote: Partial<BlockquoteOptions> | false\n\n /**\n * Set options for the `Bold` extension, or `false` to disable.\n */\n bold: Partial<BoldOptions> | false\n\n /**\n * Set options for the `BulletList` extension, or `false` to disable.\n */\n bulletList: Partial<RichTextBulletListOptions> | false\n\n /**\n * Set options for the `Code` extension, or `false` to disable.\n */\n code: Partial<CodeOptions> | false\n\n /**\n * Set options for the `CodeBlock` extension, or `false` to disable.\n */\n codeBlock: Partial<CodeBlockOptions> | false\n\n /**\n * Set options for the `Document` extension, or `false` to disable.\n */\n document: Partial<RichTextDocumentOptions> | false\n\n /**\n * Set options for the `Dropcursor` extension, or `false` to disable.\n */\n dropCursor: Partial<DropcursorOptions> | false\n\n /**\n * Set to `false` to disable the `Gapcursor` extension.\n */\n gapCursor: false\n\n /**\n * Set options for the `HardBreak` extension, or `false` to disable.\n */\n hardBreak: Partial<HardBreakOptions> | false\n\n /**\n * Set options for the `Heading` extension, or `false` to disable.\n */\n heading: Partial<RichTextHeadingOptions> | false\n\n /**\n * Set options for the `History` extension, or `false` to disable.\n */\n history: Partial<HistoryOptions> | false\n\n /**\n * Set options for the `HorizontalRule` extension, or `false` to disable.\n */\n horizontalRule: Partial<HorizontalRuleOptions> | false\n\n /**\n * Set options for the `Image` extension, or `false` to disable.\n */\n image: Partial<RichTextImageOptions> | false\n\n /**\n * Set options for the `Italic` extension, or `false` to disable.\n */\n italic: Partial<ItalicOptions> | false\n\n /**\n * Set options for the `Link` extension, or `false` to disable.\n */\n link: Partial<RichTextLinkOptions> | false\n\n /**\n * Set options for the `ListItem` extension, or `false` to disable.\n */\n listItem: Partial<ListItemOptions> | false\n\n /**\n * Set options for the `ListKeymap` extension, or `false` to disable.\n */\n listKeymap: Partial<ListKeymapOptions> | false\n\n /**\n * Set options for the `OrderedList` extension, or `false` to disable.\n */\n orderedList: Partial<RichTextOrderedListOptions> | false\n\n /**\n * Set options for the `Paragraph` extension, or `false` to disable.\n */\n paragraph: Partial<ParagraphOptions> | false\n\n /**\n * Set to `false` to disable the `PasteEmojis` extension.\n */\n pasteEmojis: false\n\n /**\n * Set to `false` to disable the `PasteMarkdown` extension.\n */\n pasteMarkdown: false\n\n /**\n * Set to `false` to disable the `PasteSinglelineText` extension.\n */\n pasteSinglelineText: false\n\n /**\n * Set to `false` to disable the `PasteHTMLTableAsString` extension.\n */\n pasteHTMLTableAsString: false\n\n /**\n * Set options for the `Strike` extension, or `false` to disable.\n */\n strike: Partial<RichTextStrikethroughOptions> | false\n\n /**\n * Set to `false` to disable the `Text` extension.\n */\n text: false\n\n /**\n * Set to `false` to disable the `Typography` extension.\n */\n typography: false\n}\n\n/**\n * The `RichTextKit` extension is a collection of the minimal required extensions to have a full\n * WYSIWYG text editor working. This extension is based on the official `StarterKit` extension\n * implementation, allowing almost every extension to be customized or disabled.\n */\nconst RichTextKit = Extension.create<RichTextKitOptions>({\n name: 'richTextKit',\n addExtensions() {\n const extensions: Extensions = []\n\n if (this.options.blockquote !== false) {\n extensions.push(\n Blockquote.extend({\n priority: BLOCKQUOTE_EXTENSION_PRIORITY,\n }).configure(this.options?.blockquote),\n )\n }\n\n if (this.options.bold !== false) {\n extensions.push(Bold.configure(this.options?.bold))\n }\n\n if (this.options.bulletList !== false) {\n extensions.push(RichTextBulletList.configure(this.options?.bulletList))\n }\n\n if (this.options.code !== false) {\n extensions.push(\n RichTextCode.configure(this.options?.code),\n\n // Enhances the Code extension capabilities with additional features\n CurvenoteCodemark,\n )\n }\n\n if (this.options.codeBlock !== false) {\n extensions.push(CodeBlock.configure(this.options?.codeBlock))\n }\n\n if (this.options.document !== false) {\n extensions.push(\n RichTextDocument.configure(this.options?.document),\n\n // Supports copying the underlying Markdown source to the clipboard\n CopyMarkdownSource.configure({\n keyboardShortcut: 'Mod-Shift-c',\n }),\n )\n\n if (this.options?.pasteEmojis !== false) {\n // Supports pasting HTML image emojis as unicode characters\n extensions.push(PasteEmojis)\n }\n\n if (this.options?.pasteMarkdown !== false) {\n // Supports pasting Markdown content as HTML into the editor\n extensions.push(PasteMarkdown)\n }\n\n if (\n this.options?.document?.multiline === false &&\n this.options?.pasteSinglelineText !== false\n ) {\n // Supports pasting multiple lines into a singleline editor, by joining all the\n // pasted lines together\n extensions.push(PasteSinglelineText)\n }\n\n if (this.options?.pasteHTMLTableAsString !== false) {\n // Supports pasting tables (from spreadsheets and websites) into the editor\n extensions.push(PasteHTMLTableAsString)\n }\n }\n\n if (this.options.dropCursor !== false) {\n extensions.push(Dropcursor.configure(this.options?.dropCursor))\n }\n\n if (this.options.gapCursor !== false) {\n extensions.push(Gapcursor)\n }\n\n if (this.options.hardBreak !== false) {\n extensions.push(HardBreak.configure(this.options?.hardBreak))\n }\n\n if (this.options.heading !== false) {\n extensions.push(RichTextHeading.configure(this.options?.heading))\n }\n\n if (this.options.history !== false) {\n extensions.push(History.configure(this.options?.history))\n }\n\n if (this.options.horizontalRule !== false) {\n extensions.push(HorizontalRule.configure(this.options?.horizontalRule))\n }\n\n if (this.options.image !== false) {\n extensions.push(RichTextImage.configure(this.options?.image))\n }\n\n if (this.options.italic !== false) {\n extensions.push(Italic.configure(this.options?.italic))\n }\n\n if (this.options.bold !== false && this.options.italic !== false) {\n extensions.push(BoldAndItalics)\n }\n\n if (this.options.link !== false) {\n extensions.push(RichTextLink.configure(this.options?.link))\n }\n\n if (this.options.listItem !== false) {\n extensions.push(ListItem.configure(this.options?.listItem))\n }\n\n if (this.options.listKeymap !== false) {\n extensions.push(ListKeymap.configure(this.options?.listKeymap))\n }\n\n if (this.options.orderedList !== false) {\n extensions.push(RichTextOrderedList.configure(this.options?.orderedList))\n }\n\n if (this.options.paragraph !== false) {\n extensions.push(Paragraph.configure(this.options?.paragraph))\n }\n\n if (this.options.strike !== false) {\n extensions.push(RichTextStrikethrough.configure(this.options?.strike))\n }\n\n if (this.options.text !== false) {\n extensions.push(Text)\n }\n\n if (this.options.typography !== false) {\n extensions.push(Typography)\n }\n\n return extensions\n },\n})\n\nexport { RichTextKit }\n\nexport type { RichTextKitOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,MAAM,cAAc,UAAU,OAA2B;CACrD,MAAM;CACN,gBAAgB;EACZ,MAAM,aAAyB,EAAE;AAEjC,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KACP,WAAW,OAAO,EACd,UAAA,KACH,CAAC,CAAC,UAAU,KAAK,SAAS,WAAW,CACzC;AAGL,MAAI,KAAK,QAAQ,SAAS,MACtB,YAAW,KAAK,KAAK,UAAU,KAAK,SAAS,KAAK,CAAC;AAGvD,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KAAK,mBAAmB,UAAU,KAAK,SAAS,WAAW,CAAC;AAG3E,MAAI,KAAK,QAAQ,SAAS,MACtB,YAAW,KACP,aAAa,UAAU,KAAK,SAAS,KAAK,EAG1C,kBACH;AAGL,MAAI,KAAK,QAAQ,cAAc,MAC3B,YAAW,KAAK,UAAU,UAAU,KAAK,SAAS,UAAU,CAAC;AAGjE,MAAI,KAAK,QAAQ,aAAa,OAAO;AACjC,cAAW,KACP,iBAAiB,UAAU,KAAK,SAAS,SAAS,EAGlD,mBAAmB,UAAU,EACzB,kBAAkB,eACrB,CAAC,CACL;AAED,OAAI,KAAK,SAAS,gBAAgB,MAE9B,YAAW,KAAK,YAAY;AAGhC,OAAI,KAAK,SAAS,kBAAkB,MAEhC,YAAW,KAAK,cAAc;AAGlC,OACI,KAAK,SAAS,UAAU,cAAc,SACtC,KAAK,SAAS,wBAAwB,MAItC,YAAW,KAAK,oBAAoB;AAGxC,OAAI,KAAK,SAAS,2BAA2B,MAEzC,YAAW,KAAK,uBAAuB;;AAI/C,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KAAK,WAAW,UAAU,KAAK,SAAS,WAAW,CAAC;AAGnE,MAAI,KAAK,QAAQ,cAAc,MAC3B,YAAW,KAAK,UAAU;AAG9B,MAAI,KAAK,QAAQ,cAAc,MAC3B,YAAW,KAAK,UAAU,UAAU,KAAK,SAAS,UAAU,CAAC;AAGjE,MAAI,KAAK,QAAQ,YAAY,MACzB,YAAW,KAAK,gBAAgB,UAAU,KAAK,SAAS,QAAQ,CAAC;AAGrE,MAAI,KAAK,QAAQ,YAAY,MACzB,YAAW,KAAK,QAAQ,UAAU,KAAK,SAAS,QAAQ,CAAC;AAG7D,MAAI,KAAK,QAAQ,mBAAmB,MAChC,YAAW,KAAK,eAAe,UAAU,KAAK,SAAS,eAAe,CAAC;AAG3E,MAAI,KAAK,QAAQ,UAAU,MACvB,YAAW,KAAK,cAAc,UAAU,KAAK,SAAS,MAAM,CAAC;AAGjE,MAAI,KAAK,QAAQ,WAAW,MACxB,YAAW,KAAK,OAAO,UAAU,KAAK,SAAS,OAAO,CAAC;AAG3D,MAAI,KAAK,QAAQ,SAAS,SAAS,KAAK,QAAQ,WAAW,MACvD,YAAW,KAAK,eAAe;AAGnC,MAAI,KAAK,QAAQ,SAAS,MACtB,YAAW,KAAK,aAAa,UAAU,KAAK,SAAS,KAAK,CAAC;AAG/D,MAAI,KAAK,QAAQ,aAAa,MAC1B,YAAW,KAAK,SAAS,UAAU,KAAK,SAAS,SAAS,CAAC;AAG/D,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KAAK,WAAW,UAAU,KAAK,SAAS,WAAW,CAAC;AAGnE,MAAI,KAAK,QAAQ,gBAAgB,MAC7B,YAAW,KAAK,oBAAoB,UAAU,KAAK,SAAS,YAAY,CAAC;AAG7E,MAAI,KAAK,QAAQ,cAAc,MAC3B,YAAW,KAAK,UAAU,UAAU,KAAK,SAAS,UAAU,CAAC;AAGjE,MAAI,KAAK,QAAQ,WAAW,MACxB,YAAW,KAAK,sBAAsB,UAAU,KAAK,SAAS,OAAO,CAAC;AAG1E,MAAI,KAAK,QAAQ,SAAS,MACtB,YAAW,KAAK,KAAK;AAGzB,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KAAK,WAAW;AAG/B,SAAO;;CAEd,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LinkOptions } from "@tiptap/extension-link";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/rich-text/rich-text-link.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* The options available to customize the `RichTextLink` extension.
|
|
4
6
|
*/
|
|
@@ -8,7 +10,6 @@ type RichTextLinkOptions = LinkOptions;
|
|
|
8
10
|
* for converting the Markdown link syntax (i.e. `[Doist](https://doist.com)`) into links, and also
|
|
9
11
|
* adds support for the `title` attribute.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
export type { RichTextLinkOptions };
|
|
13
|
+
//#endregion
|
|
14
|
+
export { type RichTextLinkOptions };
|
|
14
15
|
//# sourceMappingURL=rich-text-link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-link.d.ts","
|
|
1
|
+
{"version":3,"file":"rich-text-link.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"mappings":";;;;;;KA6DK,mBAAA,GAAsB,WAAA"}
|
|
@@ -1,104 +1,96 @@
|
|
|
1
|
-
import { InputRule, markInputRule, markPasteRule
|
|
2
|
-
import { Link } from
|
|
1
|
+
import { InputRule, PasteRule, markInputRule, markPasteRule } from "@tiptap/core";
|
|
2
|
+
import { Link } from "@tiptap/extension-link";
|
|
3
|
+
//#region src/extensions/rich-text/rich-text-link.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* The input regex for Markdown links with title support, and multiple quotation marks (required
|
|
6
|
+
* in case the `Typography` extension is being included).
|
|
7
|
+
*/
|
|
7
8
|
const inputRegex = /(?:^|\s)\[([^\]]*)?\]\((\S+)(?: ["“](.+)["”])?\)$/i;
|
|
8
9
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* The paste regex for Markdown links with title support, and multiple quotation marks (required
|
|
11
|
+
* in case the `Typography` extension is being included).
|
|
12
|
+
*/
|
|
12
13
|
const pasteRegex = /(?:^|\s)\[([^\]]*)?\]\((\S+)(?: ["“](.+)["”])?\)/gi;
|
|
13
14
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
* Input rule built specifically for the `Link` extension, which ignores the auto-linked URL in
|
|
16
|
+
* parentheses (e.g., `(https://doist.dev)`).
|
|
17
|
+
*
|
|
18
|
+
* @see https://github.com/ueberdosis/tiptap/discussions/1865
|
|
19
|
+
*/
|
|
19
20
|
function linkInputRule(config) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const defaultMarkInputRule = markInputRule(config);
|
|
22
|
+
return new InputRule({
|
|
23
|
+
find: config.find,
|
|
24
|
+
handler(props) {
|
|
25
|
+
const { tr } = props.state;
|
|
26
|
+
defaultMarkInputRule.handler(props);
|
|
27
|
+
tr.setMeta("preventAutolink", true);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
* Paste rule built specifically for the `Link` extension, which ignores the auto-linked URL in
|
|
33
|
+
* parentheses (e.g., `(https://doist.dev)`). This extension was inspired from the multiple
|
|
34
|
+
* implementations found in a Tiptap discussion at GitHub.
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/ueberdosis/tiptap/discussions/1865
|
|
37
|
+
*/
|
|
37
38
|
function linkPasteRule(config) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const defaultMarkPasteRule = markPasteRule(config);
|
|
40
|
+
return new PasteRule({
|
|
41
|
+
find: config.find,
|
|
42
|
+
handler(props) {
|
|
43
|
+
const { tr } = props.state;
|
|
44
|
+
defaultMarkPasteRule.handler(props);
|
|
45
|
+
tr.setMeta("preventAutolink", true);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
* Custom extension that extends the built-in `Link` extension to add additional input/paste rules
|
|
51
|
+
* for converting the Markdown link syntax (i.e. `[Doist](https://doist.com)`) into links, and also
|
|
52
|
+
* adds support for the `title` attribute.
|
|
53
|
+
*/
|
|
53
54
|
const RichTextLink = Link.extend({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// We need to use `pop()` to remove the last capture groups from the match to
|
|
92
|
-
// satisfy Tiptap's `markInputRule` expectation of having the content as the last
|
|
93
|
-
// capture group in the match (this makes the attribute order important)
|
|
94
|
-
getAttributes(match) {
|
|
95
|
-
return {
|
|
96
|
-
title: match.pop()?.trim(),
|
|
97
|
-
href: match.pop()?.trim(),
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
];
|
|
102
|
-
},
|
|
55
|
+
inclusive: false,
|
|
56
|
+
addOptions() {
|
|
57
|
+
return {
|
|
58
|
+
...this.parent?.(),
|
|
59
|
+
openOnClick: "whenNotEditable"
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
addAttributes() {
|
|
63
|
+
return {
|
|
64
|
+
...this.parent?.(),
|
|
65
|
+
title: { default: null }
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
addInputRules() {
|
|
69
|
+
return [linkInputRule({
|
|
70
|
+
find: inputRegex,
|
|
71
|
+
type: this.type,
|
|
72
|
+
getAttributes(match) {
|
|
73
|
+
return {
|
|
74
|
+
title: match.pop()?.trim(),
|
|
75
|
+
href: match.pop()?.trim()
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
})];
|
|
79
|
+
},
|
|
80
|
+
addPasteRules() {
|
|
81
|
+
return [linkPasteRule({
|
|
82
|
+
find: pasteRegex,
|
|
83
|
+
type: this.type,
|
|
84
|
+
getAttributes(match) {
|
|
85
|
+
return {
|
|
86
|
+
title: match.pop()?.trim(),
|
|
87
|
+
href: match.pop()?.trim()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
})];
|
|
91
|
+
}
|
|
103
92
|
});
|
|
93
|
+
//#endregion
|
|
104
94
|
export { RichTextLink };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=rich-text-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-link.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"sourcesContent":["import { InputRule, markInputRule, markPasteRule, PasteRule } from '@tiptap/core'\nimport { Link } from '@tiptap/extension-link'\n\nimport type { LinkOptions } from '@tiptap/extension-link'\n\n/**\n * The input regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst inputRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)$/i\n\n/**\n * The paste regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst pasteRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)/gi\n\n/**\n * Input rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`).\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkInputRule(config: Parameters<typeof markInputRule>[0]) {\n const defaultMarkInputRule = markInputRule(config)\n\n return new InputRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkInputRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * Paste rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`). This extension was inspired from the multiple\n * implementations found in a Tiptap discussion at GitHub.\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkPasteRule(config: Parameters<typeof markPasteRule>[0]) {\n const defaultMarkPasteRule = markPasteRule(config)\n\n return new PasteRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkPasteRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * The options available to customize the `RichTextLink` extension.\n */\ntype RichTextLinkOptions = LinkOptions\n\n/**\n * Custom extension that extends the built-in `Link` extension to add additional input/paste rules\n * for converting the Markdown link syntax (i.e. `[Doist](https://doist.com)`) into links, and also\n * adds support for the `title` attribute.\n */\nconst RichTextLink = Link.extend<RichTextLinkOptions>({\n inclusive: false,\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: 'whenNotEditable',\n }\n },\n addAttributes() {\n return {\n ...this.parent?.(),\n title: {\n default: null,\n },\n }\n },\n addInputRules() {\n return [\n linkInputRule({\n find: inputRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markPasteRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n addPasteRules() {\n return [\n linkPasteRule({\n find: pasteRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markInputRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n})\n\nexport { RichTextLink }\n\nexport type { RichTextLinkOptions }\n"],"mappings":";;;;;;;AASA,MAAM,aAAa;;;;;AAMnB,MAAM,aAAa;;;;;;;AAQnB,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,OAAO;AAElD,QAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;AAErB,wBAAqB,QAAQ,MAAM;AACnC,MAAG,QAAQ,mBAAmB,KAAK;;EAE1C,CAAC;;;;;;;;;AAUN,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,OAAO;AAElD,QAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;AAErB,wBAAqB,QAAQ,MAAM;AACnC,MAAG,QAAQ,mBAAmB,KAAK;;EAE1C,CAAC;;;;;;;AAaN,MAAM,eAAe,KAAK,OAA4B;CAClD,WAAW;CACX,aAAa;AACT,SAAO;GACH,GAAG,KAAK,UAAU;GAClB,aAAa;GAChB;;CAEL,gBAAgB;AACZ,SAAO;GACH,GAAG,KAAK,UAAU;GAClB,OAAO,EACH,SAAS,MACZ;GACJ;;CAEL,gBAAgB;AACZ,SAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;AACjB,WAAO;KACH,OAAO,MAAM,KAAK,EAAE,MAAM;KAC1B,MAAM,MAAM,KAAK,EAAE,MAAM;KAC5B;;GAER,CAAC,CACL;;CAEL,gBAAgB;AACZ,SAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;AACjB,WAAO;KACH,OAAO,MAAM,KAAK,EAAE,MAAM;KAC1B,MAAM,MAAM,KAAK,EAAE,MAAM;KAC5B;;GAER,CAAC,CACL;;CAER,CAAC"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { OrderedListOptions } from "@tiptap/extension-ordered-list";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/rich-text/rich-text-ordered-list.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* The options available to customize the `RichTextOrderedList` extension.
|
|
4
6
|
*/
|
|
5
7
|
type RichTextOrderedListOptions = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Replace hard breaks in the selection with paragraphs before toggling the selection into a
|
|
10
|
+
* bullet list. By default, hard breaks are not replaced.
|
|
11
|
+
*/
|
|
12
|
+
smartToggle: boolean;
|
|
11
13
|
} & OrderedListOptions;
|
|
12
14
|
/**
|
|
13
15
|
* Custom extension that extends the built-in `OrderedList` extension to add an option for smart
|
|
14
16
|
* toggling, which takes into account hard breaks in the selection, and converts them into
|
|
15
17
|
* paragraphs before toggling the selection into a bullet list.
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
export type { RichTextOrderedListOptions };
|
|
19
|
+
//#endregion
|
|
20
|
+
export { type RichTextOrderedListOptions };
|
|
20
21
|
//# sourceMappingURL=rich-text-ordered-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-ordered-list.d.ts","
|
|
1
|
+
{"version":3,"file":"rich-text-ordered-list.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-ordered-list.ts"],"mappings":";;;;;;KAUK,0BAAA;EAA0B;;;;EAK3B,WAAA;AAAA,IACA,kBAAA"}
|
|
@@ -1,60 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TextStyle } from
|
|
4
|
-
import {
|
|
1
|
+
import { Fragment, Slice } from "@tiptap/pm/model";
|
|
2
|
+
import { ListItem } from "@tiptap/extension-list-item";
|
|
3
|
+
import { TextStyle } from "@tiptap/extension-text-style";
|
|
4
|
+
import { OrderedList } from "@tiptap/extension-ordered-list";
|
|
5
|
+
//#region src/extensions/rich-text/rich-text-ordered-list.ts
|
|
5
6
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* Custom extension that extends the built-in `OrderedList` extension to add an option for smart
|
|
8
|
+
* toggling, which takes into account hard breaks in the selection, and converts them into
|
|
9
|
+
* paragraphs before toggling the selection into a bullet list.
|
|
10
|
+
*/
|
|
10
11
|
const RichTextOrderedList = OrderedList.extend({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
schema.nodes.paragraph.create(),
|
|
42
|
-
schema.nodes.paragraph.create(),
|
|
43
|
-
])));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Toggle the selection into a bullet list, optionally keeping attributes
|
|
47
|
-
// (this is a verbatim copy of the built-in `toggleBulletList` command)
|
|
48
|
-
if (options.keepAttributes) {
|
|
49
|
-
return chain()
|
|
50
|
-
.toggleList(name, options.itemTypeName, options.keepMarks)
|
|
51
|
-
.updateAttributes(ListItem.name, editor.getAttributes(TextStyle.name))
|
|
52
|
-
.run();
|
|
53
|
-
}
|
|
54
|
-
return commands.toggleList(name, options.itemTypeName, options.keepMarks);
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
},
|
|
12
|
+
addOptions() {
|
|
13
|
+
return {
|
|
14
|
+
...this.parent?.(),
|
|
15
|
+
smartToggle: false
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
addCommands() {
|
|
19
|
+
const { editor, name, options } = this;
|
|
20
|
+
return {
|
|
21
|
+
...this.parent?.(),
|
|
22
|
+
toggleOrderedList() {
|
|
23
|
+
return ({ commands, state, tr, chain }) => {
|
|
24
|
+
if (options.smartToggle) {
|
|
25
|
+
const { schema } = state;
|
|
26
|
+
const { selection } = tr;
|
|
27
|
+
const { $from, $to } = selection;
|
|
28
|
+
const hardBreakPositions = [];
|
|
29
|
+
tr.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
30
|
+
if (node.type.name === "hardBreak") hardBreakPositions.push(pos);
|
|
31
|
+
});
|
|
32
|
+
hardBreakPositions.reverse().forEach((pos) => {
|
|
33
|
+
tr.replace(pos, pos + 1, Slice.maxOpen(Fragment.fromArray([schema.nodes.paragraph.create(), schema.nodes.paragraph.create()])));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (options.keepAttributes) return chain().toggleList(name, options.itemTypeName, options.keepMarks).updateAttributes(ListItem.name, editor.getAttributes(TextStyle.name)).run();
|
|
37
|
+
return commands.toggleList(name, options.itemTypeName, options.keepMarks);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
59
42
|
});
|
|
43
|
+
//#endregion
|
|
60
44
|
export { RichTextOrderedList };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=rich-text-ordered-list.js.map
|