@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,138 +1,136 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import { isMultilineDocument, isPlainTextDocument } from "../helpers/schema.js";
|
|
2
|
+
import { getHTMLSerializerInstance } from "../serializers/html/html.js";
|
|
3
|
+
import { ExtraEditorCommands } from "../extensions/core/extra-editor-commands/extra-editor-commands.js";
|
|
4
|
+
import { ViewEventHandlers } from "../extensions/core/view-event-handlers.js";
|
|
5
|
+
import { useEditor } from "../hooks/use-editor.js";
|
|
6
|
+
import { getMarkdownSerializerInstance } from "../serializers/markdown/markdown.js";
|
|
7
|
+
import { getAllNodesAttributesByType, resolveContentSelection } from "./typist-editor.helper.js";
|
|
8
|
+
import { forwardRef, useCallback, useImperativeHandle, useMemo } from "react";
|
|
9
|
+
import { getSchema } from "@tiptap/core";
|
|
10
|
+
import { Placeholder } from "@tiptap/extension-placeholder";
|
|
11
|
+
import { EditorContent } from "@tiptap/react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/typist-editor.tsx
|
|
13
14
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const TypistEditor = forwardRef(function TypistEditor({ autoFocus, className, content =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
getAllNodesAttributesByType(nodeType) {
|
|
132
|
-
return getAllNodesAttributesByType(editor.state.doc, nodeType);
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}, [editor, markdownSerializer]);
|
|
136
|
-
return _jsx(EditorContent, { className: className, editor: editor });
|
|
15
|
+
* The `TypistEditor` component represents a plain-text or a rich-text editing control, built on
|
|
16
|
+
* top of the amazing [Tiptap](https://tiptap.dev/) library.
|
|
17
|
+
*/
|
|
18
|
+
const TypistEditor = forwardRef(function TypistEditor({ autoFocus, className, content = "", contentSelection, editable = true, extensions, placeholder, onBeforeCreate, onCreate, onUpdate, onSelectionUpdate, onTransaction, onFocus, onBlur, onDestroy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onClick, onKeyDown }, ref) {
|
|
19
|
+
const allExtensions = useMemo(function initializeExtensions() {
|
|
20
|
+
return [
|
|
21
|
+
...placeholder ? [Placeholder.configure({ placeholder })] : [],
|
|
22
|
+
ExtraEditorCommands,
|
|
23
|
+
ViewEventHandlers.configure({
|
|
24
|
+
onClick,
|
|
25
|
+
onKeyDown
|
|
26
|
+
}),
|
|
27
|
+
...extensions
|
|
28
|
+
];
|
|
29
|
+
}, [
|
|
30
|
+
extensions,
|
|
31
|
+
onClick,
|
|
32
|
+
onKeyDown,
|
|
33
|
+
placeholder
|
|
34
|
+
]);
|
|
35
|
+
const schema = useMemo(function generateProseMirrorSchema() {
|
|
36
|
+
return getSchema(allExtensions);
|
|
37
|
+
}, [allExtensions]);
|
|
38
|
+
const htmlSerializer = useMemo(function initializeHTMLSerializer() {
|
|
39
|
+
return getHTMLSerializerInstance(schema);
|
|
40
|
+
}, [schema]);
|
|
41
|
+
const markdownSerializer = useMemo(function initializeMarkdownSerializer() {
|
|
42
|
+
return getMarkdownSerializerInstance(schema);
|
|
43
|
+
}, [schema]);
|
|
44
|
+
const htmlContent = useMemo(function generateHTMLContent() {
|
|
45
|
+
return htmlSerializer.serialize(content);
|
|
46
|
+
}, [content, htmlSerializer]);
|
|
47
|
+
const ariaAttributes = useMemo(function initializeAriaAttributes() {
|
|
48
|
+
return {
|
|
49
|
+
"aria-readonly": String(!editable),
|
|
50
|
+
"aria-multiline": String(isMultilineDocument(schema)),
|
|
51
|
+
...ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {},
|
|
52
|
+
...ariaLabel ? { "aria-label": ariaLabel } : {},
|
|
53
|
+
...ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {}
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
ariaDescribedBy,
|
|
57
|
+
ariaLabel,
|
|
58
|
+
ariaLabelledBy,
|
|
59
|
+
editable,
|
|
60
|
+
schema
|
|
61
|
+
]);
|
|
62
|
+
const handleCreate = useCallback(function handleCreate(props) {
|
|
63
|
+
const { view } = props.editor;
|
|
64
|
+
if (autoFocus && contentSelection) view.dispatch(view.state.tr.setSelection(resolveContentSelection(view.state.doc, contentSelection)).scrollIntoView());
|
|
65
|
+
onCreate?.(props);
|
|
66
|
+
}, [
|
|
67
|
+
autoFocus,
|
|
68
|
+
contentSelection,
|
|
69
|
+
onCreate
|
|
70
|
+
]);
|
|
71
|
+
const editor = useEditor({
|
|
72
|
+
autofocus: autoFocus ? "end" : false,
|
|
73
|
+
content: htmlContent,
|
|
74
|
+
editable,
|
|
75
|
+
editorProps: { attributes: {
|
|
76
|
+
"data-typist-editor": "true",
|
|
77
|
+
...isPlainTextDocument(schema) ? { "data-plain-text": "true" } : { "data-rich-text": "true" },
|
|
78
|
+
role: "textbox",
|
|
79
|
+
...ariaAttributes
|
|
80
|
+
} },
|
|
81
|
+
extensions: allExtensions,
|
|
82
|
+
parseOptions: { preserveWhitespace: isPlainTextDocument(schema) },
|
|
83
|
+
...onBeforeCreate ? { onBeforeCreate } : {},
|
|
84
|
+
onCreate: handleCreate,
|
|
85
|
+
...onUpdate ? { onUpdate(props) {
|
|
86
|
+
onUpdate({
|
|
87
|
+
...props,
|
|
88
|
+
getMarkdown() {
|
|
89
|
+
return markdownSerializer.serialize(props.editor.getHTML());
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} } : {},
|
|
93
|
+
...onSelectionUpdate ? { onSelectionUpdate } : {},
|
|
94
|
+
...onTransaction ? { onTransaction } : {},
|
|
95
|
+
...onFocus ? { onFocus } : {},
|
|
96
|
+
...onBlur ? { onBlur } : {},
|
|
97
|
+
...onDestroy ? { onDestroy } : {}
|
|
98
|
+
}, [
|
|
99
|
+
allExtensions,
|
|
100
|
+
ariaAttributes,
|
|
101
|
+
autoFocus,
|
|
102
|
+
editable,
|
|
103
|
+
handleCreate,
|
|
104
|
+
htmlContent,
|
|
105
|
+
markdownSerializer,
|
|
106
|
+
onBeforeCreate,
|
|
107
|
+
onBlur,
|
|
108
|
+
onDestroy,
|
|
109
|
+
onFocus,
|
|
110
|
+
onSelectionUpdate,
|
|
111
|
+
onTransaction,
|
|
112
|
+
onUpdate,
|
|
113
|
+
schema
|
|
114
|
+
]);
|
|
115
|
+
useImperativeHandle(ref, function exposeHelperFunctionsToParent() {
|
|
116
|
+
return {
|
|
117
|
+
getEditor() {
|
|
118
|
+
return editor;
|
|
119
|
+
},
|
|
120
|
+
getMarkdown() {
|
|
121
|
+
return markdownSerializer.serialize(editor.getHTML());
|
|
122
|
+
},
|
|
123
|
+
getAllNodesAttributesByType(nodeType) {
|
|
124
|
+
return getAllNodesAttributesByType(editor.state.doc, nodeType);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}, [editor, markdownSerializer]);
|
|
128
|
+
return /* @__PURE__ */ jsx(EditorContent, {
|
|
129
|
+
className,
|
|
130
|
+
editor
|
|
131
|
+
});
|
|
137
132
|
});
|
|
133
|
+
//#endregion
|
|
138
134
|
export { TypistEditor };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=typist-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typist-editor.js","names":[],"sources":["../../src/components/typist-editor.tsx"],"sourcesContent":["import { forwardRef, useCallback, useImperativeHandle, useMemo } from 'react'\n\nimport { getSchema } from '@tiptap/core'\nimport { Placeholder } from '@tiptap/extension-placeholder'\nimport { EditorContent } from '@tiptap/react'\n\nimport { ExtraEditorCommands } from '../extensions/core/extra-editor-commands/extra-editor-commands'\nimport { ViewEventHandlers, ViewEventHandlersOptions } from '../extensions/core/view-event-handlers'\nimport { isMultilineDocument, isPlainTextDocument } from '../helpers/schema'\nimport { useEditor } from '../hooks/use-editor'\nimport { getHTMLSerializerInstance } from '../serializers/html/html'\nimport { getMarkdownSerializerInstance } from '../serializers/markdown/markdown'\n\nimport { getAllNodesAttributesByType, resolveContentSelection } from './typist-editor.helper'\n\nimport type { Editor as CoreEditor, EditorEvents, Extensions } from '@tiptap/core'\nimport type { Selection } from '@tiptap/pm/state'\n\n/**\n * The forwarded ref that describes the helper methods that the `TypistEditor` parent component\n * will have access to.\n */\ntype TypistEditorRef = {\n /**\n * Returns the `Editor` instance associated to the `TypistEditor` component.\n */\n getEditor: () => CoreEditor\n\n /**\n * Returns the current editor document output as Markdown.\n */\n getMarkdown: () => string\n\n /**\n * Returns the attributes of a given node type for all the nodes in the editor document.\n */\n getAllNodesAttributesByType: (\n nodeType: string,\n ) => ReturnType<typeof getAllNodesAttributesByType>\n}\n\n/**\n * The properties that describe the `beforeCreate` editor event.\n */\ntype BeforeCreateProps = EditorEvents['beforeCreate']\n\n/**\n * The properties that describe the `create` editor event.\n */\ntype CreateProps = EditorEvents['create']\n\n/**\n * The properties that describe the `update` editor event.\n */\ntype UpdateProps = EditorEvents['update'] & Pick<TypistEditorRef, 'getMarkdown'>\n\n/**\n * The properties that describe the `selectionUpdate` editor event.\n */\ntype SelectionUpdateProps = EditorEvents['selectionUpdate']\n\n/**\n * The properties that describe the `transaction` editor event.\n */\ntype TransacationProps = EditorEvents['transaction']\n\n/**\n * The properties that describe the `focus` editor event.\n */\ntype FocusProps = EditorEvents['focus']\n\n/**\n * The properties that describe the `blur` editor event.\n */\ntype BlurProps = EditorEvents['blur']\n\n/**\n * The properties that describe the `destroy` editor event.\n */\ntype DestroyProps = EditorEvents['destroy']\n\n/**\n * The properties available to represent an instance of the `TypistEditor` component, including\n * the supported WAI-ARIA 1.1 attributes.\n */\ntype TypistEditorProps = {\n /**\n * Auto focus the editor to the end of the document on initialization.\n */\n autoFocus?: boolean\n\n /**\n * The CSS class for the container surrounding the editor DOM element.\n */\n className?: string\n\n /**\n * The initial Markdown content for the editor.\n */\n content?: string\n\n /**\n * The initial content selection (only applied if `autoFocus` is `true`).\n */\n contentSelection?: Selection\n\n /**\n * Determines if users can write into the editor.\n */\n editable?: boolean\n\n /**\n * The list of required extensions to initialize the editor.\n *\n * You may consider wrapping this prop with `useMemo` to prevent unnecessary re-renders.\n */\n extensions: Extensions\n\n /**\n * A short hint that gives users an idea what can be entered in the editor.\n */\n placeholder?: string\n\n /**\n * The event handler that is fired before the editor view is created.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onBeforeCreate?: (props: BeforeCreateProps) => void\n\n /**\n * The event handler that is fired when the editor view is ready.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onCreate?: (props: CreateProps) => void\n\n /**\n * The event handler that is fired when the editor content has changed.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onUpdate?: (props: UpdateProps) => void\n\n /**\n * The event handler that is fired when the editor selection has changed.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onSelectionUpdate?: (props: SelectionUpdateProps) => void\n\n /**\n * The event handler that is fired when the editor state has changed.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onTransaction?: (props: TransacationProps) => void\n\n /**\n * The event handler that is fired when the editor view gains focus.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onFocus?: (props: FocusProps) => void\n\n /**\n * The event handler that is fired when the editor view loses focus.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onBlur?: (props: BlurProps) => void\n\n /**\n * The event handler that is fired when the editor view is being destroyed.\n *\n * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders.\n */\n onDestroy?: (props: DestroyProps) => void\n\n /**\n * Identifies the element (or elements) that describes the object.\n *\n * @see aria-labelledby\n */\n 'aria-describedby'?: React.AriaAttributes['aria-describedby']\n\n /**\n * Defines a string value that labels the current element.\n *\n * @see aria-labelledby.\n */\n 'aria-label'?: React.AriaAttributes['aria-label']\n\n /**\n * Identifies the element (or elements) that labels the current element.\n *\n * @see aria-describedby.\n */\n 'aria-labelledby'?: React.AriaAttributes['aria-labelledby']\n\n /**\n * The event handler that processes `click` events in the editor.\n */\n onClick?: ViewEventHandlersOptions['onClick']\n\n /**\n * The event handler that processes `keydown` events in the editor.\n */\n onKeyDown?: ViewEventHandlersOptions['onKeyDown']\n}\n\n/**\n * The `TypistEditor` component represents a plain-text or a rich-text editing control, built on\n * top of the amazing [Tiptap](https://tiptap.dev/) library.\n */\nconst TypistEditor = forwardRef<TypistEditorRef, TypistEditorProps>(function TypistEditor(\n {\n autoFocus,\n className,\n content = '',\n contentSelection,\n editable = true,\n extensions,\n placeholder,\n onBeforeCreate,\n onCreate,\n onUpdate,\n onSelectionUpdate,\n onTransaction,\n onFocus,\n onBlur,\n onDestroy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n onClick,\n onKeyDown,\n },\n ref,\n) {\n const allExtensions = useMemo(\n function initializeExtensions() {\n return [\n ...(placeholder\n ? [\n Placeholder.configure({\n placeholder,\n }),\n ]\n : []),\n ExtraEditorCommands,\n ViewEventHandlers.configure({\n onClick,\n onKeyDown,\n }),\n // Always register external extensions at the end so they get a higher priority and\n // are loaded earlier (necessary to override behaviors from built-in extensions)\n ...extensions,\n ]\n },\n [extensions, onClick, onKeyDown, placeholder],\n )\n\n const schema = useMemo(\n function generateProseMirrorSchema() {\n return getSchema(allExtensions)\n },\n [allExtensions],\n )\n\n const htmlSerializer = useMemo(\n function initializeHTMLSerializer() {\n return getHTMLSerializerInstance(schema)\n },\n [schema],\n )\n\n const markdownSerializer = useMemo(\n function initializeMarkdownSerializer() {\n return getMarkdownSerializerInstance(schema)\n },\n [schema],\n )\n\n const htmlContent = useMemo(\n function generateHTMLContent() {\n return htmlSerializer.serialize(content)\n },\n [content, htmlSerializer],\n )\n\n const ariaAttributes = useMemo(\n function initializeAriaAttributes() {\n return {\n 'aria-readonly': String(!editable),\n 'aria-multiline': String(isMultilineDocument(schema)),\n ...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy ? { 'aria-labelledby': ariaLabelledBy } : {}),\n }\n },\n [ariaDescribedBy, ariaLabel, ariaLabelledBy, editable, schema],\n )\n\n const handleCreate = useCallback(\n function handleCreate(props: CreateProps) {\n const { view } = props.editor\n\n // Apply a selection to the document if one was given and `autoFocus` is `true`\n if (autoFocus && contentSelection) {\n view.dispatch(\n view.state.tr\n .setSelection(resolveContentSelection(view.state.doc, contentSelection))\n .scrollIntoView(),\n )\n }\n\n // Invoke the user `onCreate` handle after all internal initializations\n onCreate?.(props)\n },\n [autoFocus, contentSelection, onCreate],\n )\n\n const editor = useEditor(\n {\n autofocus: autoFocus ? 'end' : false,\n content: htmlContent,\n editable,\n editorProps: {\n attributes: {\n 'data-typist-editor': 'true',\n ...(isPlainTextDocument(schema)\n ? { 'data-plain-text': 'true' }\n : { 'data-rich-text': 'true' }),\n role: 'textbox',\n ...ariaAttributes,\n },\n },\n extensions: allExtensions,\n parseOptions: {\n preserveWhitespace: isPlainTextDocument(schema),\n },\n ...(onBeforeCreate ? { onBeforeCreate } : {}),\n onCreate: handleCreate,\n ...(onUpdate\n ? {\n onUpdate(props) {\n onUpdate({\n ...props,\n getMarkdown() {\n return markdownSerializer.serialize(props.editor.getHTML())\n },\n })\n },\n }\n : {}),\n ...(onSelectionUpdate ? { onSelectionUpdate } : {}),\n ...(onTransaction ? { onTransaction } : {}),\n ...(onFocus ? { onFocus } : {}),\n ...(onBlur ? { onBlur } : {}),\n ...(onDestroy ? { onDestroy } : {}),\n },\n [\n allExtensions,\n ariaAttributes,\n autoFocus,\n editable,\n handleCreate,\n htmlContent,\n markdownSerializer,\n onBeforeCreate,\n onBlur,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n schema,\n ],\n )\n\n useImperativeHandle(\n ref,\n function exposeHelperFunctionsToParent() {\n return {\n getEditor() {\n return editor\n },\n getMarkdown() {\n return markdownSerializer.serialize(editor.getHTML())\n },\n getAllNodesAttributesByType(nodeType) {\n return getAllNodesAttributesByType(editor.state.doc, nodeType)\n },\n }\n },\n [editor, markdownSerializer],\n )\n\n return <EditorContent className={className} editor={editor} />\n})\n\nexport { TypistEditor }\n\nexport type {\n BeforeCreateProps,\n BlurProps,\n CreateProps,\n DestroyProps,\n FocusProps,\n SelectionUpdateProps,\n TransacationProps,\n TypistEditorProps,\n TypistEditorRef,\n UpdateProps,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuNA,MAAM,eAAe,WAA+C,SAAS,aACzE,EACI,WACA,WACA,UAAU,IACV,kBACA,WAAW,MACX,YACA,aACA,gBACA,UACA,UACA,mBACA,eACA,SACA,QACA,WACA,oBAAoB,iBACpB,cAAc,WACd,mBAAmB,gBACnB,SACA,aAEJ,KACF;CACE,MAAM,gBAAgB,QAClB,SAAS,uBAAuB;AAC5B,SAAO;GACH,GAAI,cACE,CACI,YAAY,UAAU,EAClB,aACH,CAAC,CACL,GACD,EAAE;GACR;GACA,kBAAkB,UAAU;IACxB;IACA;IACH,CAAC;GAGF,GAAG;GACN;IAEL;EAAC;EAAY;EAAS;EAAW;EAAY,CAChD;CAED,MAAM,SAAS,QACX,SAAS,4BAA4B;AACjC,SAAO,UAAU,cAAc;IAEnC,CAAC,cAAc,CAClB;CAED,MAAM,iBAAiB,QACnB,SAAS,2BAA2B;AAChC,SAAO,0BAA0B,OAAO;IAE5C,CAAC,OAAO,CACX;CAED,MAAM,qBAAqB,QACvB,SAAS,+BAA+B;AACpC,SAAO,8BAA8B,OAAO;IAEhD,CAAC,OAAO,CACX;CAED,MAAM,cAAc,QAChB,SAAS,sBAAsB;AAC3B,SAAO,eAAe,UAAU,QAAQ;IAE5C,CAAC,SAAS,eAAe,CAC5B;CAED,MAAM,iBAAiB,QACnB,SAAS,2BAA2B;AAChC,SAAO;GACH,iBAAiB,OAAO,CAAC,SAAS;GAClC,kBAAkB,OAAO,oBAAoB,OAAO,CAAC;GACrD,GAAI,kBAAkB,EAAE,oBAAoB,iBAAiB,GAAG,EAAE;GAClE,GAAI,YAAY,EAAE,cAAc,WAAW,GAAG,EAAE;GAChD,GAAI,iBAAiB,EAAE,mBAAmB,gBAAgB,GAAG,EAAE;GAClE;IAEL;EAAC;EAAiB;EAAW;EAAgB;EAAU;EAAO,CACjE;CAED,MAAM,eAAe,YACjB,SAAS,aAAa,OAAoB;EACtC,MAAM,EAAE,SAAS,MAAM;AAGvB,MAAI,aAAa,iBACb,MAAK,SACD,KAAK,MAAM,GACN,aAAa,wBAAwB,KAAK,MAAM,KAAK,iBAAiB,CAAC,CACvE,gBAAgB,CACxB;AAIL,aAAW,MAAM;IAErB;EAAC;EAAW;EAAkB;EAAS,CAC1C;CAED,MAAM,SAAS,UACX;EACI,WAAW,YAAY,QAAQ;EAC/B,SAAS;EACT;EACA,aAAa,EACT,YAAY;GACR,sBAAsB;GACtB,GAAI,oBAAoB,OAAO,GACzB,EAAE,mBAAmB,QAAQ,GAC7B,EAAE,kBAAkB,QAAQ;GAClC,MAAM;GACN,GAAG;GACN,EACJ;EACD,YAAY;EACZ,cAAc,EACV,oBAAoB,oBAAoB,OAAO,EAClD;EACD,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C,UAAU;EACV,GAAI,WACE,EACI,SAAS,OAAO;AACZ,YAAS;IACL,GAAG;IACH,cAAc;AACV,YAAO,mBAAmB,UAAU,MAAM,OAAO,SAAS,CAAC;;IAElE,CAAC;KAET,GACD,EAAE;EACR,GAAI,oBAAoB,EAAE,mBAAmB,GAAG,EAAE;EAClD,GAAI,gBAAgB,EAAE,eAAe,GAAG,EAAE;EAC1C,GAAI,UAAU,EAAE,SAAS,GAAG,EAAE;EAC9B,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC5B,GAAI,YAAY,EAAE,WAAW,GAAG,EAAE;EACrC,EACD;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACH,CACJ;AAED,qBACI,KACA,SAAS,gCAAgC;AACrC,SAAO;GACH,YAAY;AACR,WAAO;;GAEX,cAAc;AACV,WAAO,mBAAmB,UAAU,OAAO,SAAS,CAAC;;GAEzD,4BAA4B,UAAU;AAClC,WAAO,4BAA4B,OAAO,MAAM,KAAK,SAAS;;GAErE;IAEL,CAAC,QAAQ,mBAAmB,CAC/B;AAED,QAAO,oBAAC,eAAD;EAA0B;EAAmB;EAAU,CAAA;EAChE"}
|
package/dist/constants/common.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
//#region src/constants/common.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
* An enum-like constant for clipboard `DataTransfer.types` that are supported by the editor.
|
|
4
|
+
*/
|
|
4
5
|
const ClipboardDataType = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Text: "text/plain",
|
|
7
|
+
HTML: "text/html",
|
|
8
|
+
VSCode: "vscode-editor-data"
|
|
8
9
|
};
|
|
10
|
+
//#endregion
|
|
9
11
|
export { ClipboardDataType };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../../src/constants/common.ts"],"sourcesContent":["/**\n * An enum-like constant for clipboard `DataTransfer.types` that are supported by the editor.\n */\nconst ClipboardDataType = {\n Text: 'text/plain',\n HTML: 'text/html',\n VSCode: 'vscode-editor-data',\n} as const\n\nexport { ClipboardDataType }\n"],"mappings":";;;;AAGA,MAAM,oBAAoB;CACtB,MAAM;CACN,MAAM;CACN,QAAQ;CACX"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/constants/extension-priorities.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Priority for the extensions created by the suggestion extension factory function. This needs to
|
|
3
4
|
* be higher than most extensions, so that event handlers from the dropdown render function can take
|
|
@@ -40,5 +41,6 @@ declare const BLOCKQUOTE_EXTENSION_PRIORITY = 101;
|
|
|
40
41
|
* the other way around (i.e. prevents `<code><em>code</em></code>` from happening).
|
|
41
42
|
*/
|
|
42
43
|
declare const CODE_EXTENSION_PRIORITY = 99;
|
|
43
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BLOCKQUOTE_EXTENSION_PRIORITY, CODE_EXTENSION_PRIORITY, PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY, PASTE_MARKDOWN_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY };
|
|
44
46
|
//# sourceMappingURL=extension-priorities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-priorities.d.ts","
|
|
1
|
+
{"version":3,"file":"extension-priorities.d.ts","names":[],"sources":["../../src/constants/extension-priorities.ts"],"mappings":";;;;;;cAKM,6BAAA;AAA6B;;;;;AAAA,cAO7B,6CAAA;;;;;AAOiC;cAAjC,iCAAA;;;;AAO8B;;cAA9B,8BAAA;;;AAO4B;;;cAA5B,4BAAA;;AAO6B;;;;cAA7B,6BAAA;;;;;;cAOA,uBAAA"}
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
+
//#region src/constants/extension-priorities.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const SUGGESTION_EXTENSION_PRIORITY =
|
|
3
|
+
* Priority for the extensions created by the suggestion extension factory function. This needs to
|
|
4
|
+
* be higher than most extensions, so that event handlers from the dropdown render function can take
|
|
5
|
+
* precedence over all other event handlers in the chain.
|
|
6
|
+
*/
|
|
7
|
+
const SUGGESTION_EXTENSION_PRIORITY = 1e4;
|
|
7
8
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
* Priority for the `PasteHTMLTableAsString` extension. This needs to be higher than most paste
|
|
10
|
+
* extensions (e.g., `PasteSinglelineText`, `PasteMarkdown`, etc.), so that the extension can first
|
|
11
|
+
* parse HTML tables that might exist in the clipboard data.
|
|
12
|
+
*/
|
|
12
13
|
const PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY = 1005;
|
|
13
14
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
* Priority for the `PasteMarkdown` extension. This needs to be higher than the built-in and
|
|
16
|
+
* official `Link` extension (i.e. `1000`), so that the extension can first parse Markdown links
|
|
17
|
+
* correctly, without having the `Link` extension paste handlers interfering.
|
|
18
|
+
*/
|
|
18
19
|
const PASTE_MARKDOWN_EXTENSION_PRIORITY = 1001;
|
|
19
20
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* Priority for the `SmartMarkdownTyping` extension. This needs to be higher than the
|
|
22
|
+
* `ViewEventHandlers` extension, so that event handlers from the ProseMirror plugins built into the
|
|
23
|
+
* extension can take precedence over the `ViewEventHandlers` extension event handlers.
|
|
24
|
+
*/
|
|
24
25
|
const SMART_MARKDOWN_TYPING_PRIORITY = 110;
|
|
25
26
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
* Priority for the `ViewEventHandlers` extension. This needs to be higher than the default for most
|
|
28
|
+
* of the built-in and official extensions (i.e. `100`), so that the event handlers from the
|
|
29
|
+
* extension can take precedence over the built-in and official extensions event handlers.
|
|
30
|
+
*/
|
|
30
31
|
const VIEW_EVENT_HANDLERS_PRIORITY = 105;
|
|
31
32
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
* Priority for the official `Blockquote` extension. This needs to be higher than the default for
|
|
34
|
+
* most built-in and official extensions (i.e. `100`), so that the keyboard shortcut can take
|
|
35
|
+
* precedence over the `Bold` extension keyboard shortcut.
|
|
36
|
+
*/
|
|
36
37
|
const BLOCKQUOTE_EXTENSION_PRIORITY = 101;
|
|
37
38
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* Priority for the `RichTextCode` extension. This needs to be lower than the default for most
|
|
40
|
+
* built-in and official extensions (i.e. `100`), so that other marks wrap the `Code` mark, and not
|
|
41
|
+
* the other way around (i.e. prevents `<code><em>code</em></code>` from happening).
|
|
42
|
+
*/
|
|
42
43
|
const CODE_EXTENSION_PRIORITY = 99;
|
|
43
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BLOCKQUOTE_EXTENSION_PRIORITY, CODE_EXTENSION_PRIORITY, PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY, PASTE_MARKDOWN_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=extension-priorities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-priorities.js","names":[],"sources":["../../src/constants/extension-priorities.ts"],"sourcesContent":["/**\n * Priority for the extensions created by the suggestion extension factory function. This needs to\n * be higher than most extensions, so that event handlers from the dropdown render function can take\n * precedence over all other event handlers in the chain.\n */\nconst SUGGESTION_EXTENSION_PRIORITY = 10000\n\n/**\n * Priority for the `PasteHTMLTableAsString` extension. This needs to be higher than most paste\n * extensions (e.g., `PasteSinglelineText`, `PasteMarkdown`, etc.), so that the extension can first\n * parse HTML tables that might exist in the clipboard data.\n */\nconst PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY = 1005\n\n/**\n * Priority for the `PasteMarkdown` extension. This needs to be higher than the built-in and\n * official `Link` extension (i.e. `1000`), so that the extension can first parse Markdown links\n * correctly, without having the `Link` extension paste handlers interfering.\n */\nconst PASTE_MARKDOWN_EXTENSION_PRIORITY = 1001\n\n/**\n * Priority for the `SmartMarkdownTyping` extension. This needs to be higher than the\n * `ViewEventHandlers` extension, so that event handlers from the ProseMirror plugins built into the\n * extension can take precedence over the `ViewEventHandlers` extension event handlers.\n */\nconst SMART_MARKDOWN_TYPING_PRIORITY = 110\n\n/**\n * Priority for the `ViewEventHandlers` extension. This needs to be higher than the default for most\n * of the built-in and official extensions (i.e. `100`), so that the event handlers from the\n * extension can take precedence over the built-in and official extensions event handlers.\n */\nconst VIEW_EVENT_HANDLERS_PRIORITY = 105\n\n/**\n * Priority for the official `Blockquote` extension. This needs to be higher than the default for\n * most built-in and official extensions (i.e. `100`), so that the keyboard shortcut can take\n * precedence over the `Bold` extension keyboard shortcut.\n */\nconst BLOCKQUOTE_EXTENSION_PRIORITY = 101\n\n/**\n * Priority for the `RichTextCode` extension. This needs to be lower than the default for most\n * built-in and official extensions (i.e. `100`), so that other marks wrap the `Code` mark, and not\n * the other way around (i.e. prevents `<code><em>code</em></code>` from happening).\n */\nconst CODE_EXTENSION_PRIORITY = 99\n\nexport {\n BLOCKQUOTE_EXTENSION_PRIORITY,\n CODE_EXTENSION_PRIORITY,\n PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY,\n PASTE_MARKDOWN_EXTENSION_PRIORITY,\n SMART_MARKDOWN_TYPING_PRIORITY,\n SUGGESTION_EXTENSION_PRIORITY,\n VIEW_EVENT_HANDLERS_PRIORITY,\n}\n"],"mappings":";;;;;;AAKA,MAAM,gCAAgC;;;;;;AAOtC,MAAM,gDAAgD;;;;;;AAOtD,MAAM,oCAAoC;;;;;;AAO1C,MAAM,iCAAiC;;;;;;AAOvC,MAAM,+BAA+B;;;;;;AAOrC,MAAM,gCAAgC;;;;;;AAOtC,MAAM,0BAA0B"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
//#region src/constants/regular-expressions.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
* A common regular expression for all line termination conventions.
|
|
4
|
+
*/
|
|
4
5
|
const REGEX_LINE_BREAKS = /(?:\r\n|\r|\n)/g;
|
|
5
6
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* A regular expression for standard punctuation characters for US-ASCII plus unicode punctuation.
|
|
8
|
+
*
|
|
9
|
+
* @see https://stackoverflow.com/a/25575009
|
|
10
|
+
*/
|
|
10
11
|
const REGEX_PUNCTUATION = /[\u2000-\u206f\u2e00-\u2e7f'!"#$%&()*+,\-./:;<=>?@\\[\]^_`{|}~]/;
|
|
11
12
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* The perfect URL validation regular expression for Web URLs.
|
|
14
|
+
*
|
|
15
|
+
* @see https://mathiasbynens.be/demo/url-regex
|
|
16
|
+
*/
|
|
16
17
|
const REGEX_WEB_URL = /(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?/i;
|
|
18
|
+
//#endregion
|
|
17
19
|
export { REGEX_LINE_BREAKS, REGEX_PUNCTUATION, REGEX_WEB_URL };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=regular-expressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regular-expressions.js","names":[],"sources":["../../src/constants/regular-expressions.ts"],"sourcesContent":["/**\n * A common regular expression for all line termination conventions.\n */\nconst REGEX_LINE_BREAKS = /(?:\\r\\n|\\r|\\n)/g\n\n/**\n * A regular expression for standard punctuation characters for US-ASCII plus unicode punctuation.\n *\n * @see https://stackoverflow.com/a/25575009\n */\nconst REGEX_PUNCTUATION = /[\\u2000-\\u206f\\u2e00-\\u2e7f'!\"#$%&()*+,\\-./:;<=>?@\\\\[\\]^_`{|}~]/\n\n/**\n * The perfect URL validation regular expression for Web URLs.\n *\n * @see https://mathiasbynens.be/demo/url-regex\n */\nconst REGEX_WEB_URL =\n /(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?/i\n\nexport { REGEX_LINE_BREAKS, REGEX_PUNCTUATION, REGEX_WEB_URL }\n"],"mappings":";;;;AAGA,MAAM,oBAAoB;;;;;;AAO1B,MAAM,oBAAoB;;;;;;AAO1B,MAAM,gBACF"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { RawCommands } from
|
|
1
|
+
import { RawCommands } from "@tiptap/core";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Augment the official `@tiptap/core` module with extra commands so that the compiler knows about
|
|
4
6
|
* them. For this to work externally, a wildcard export needs to be added to the root `index.ts`.
|
|
5
7
|
*/
|
|
6
8
|
declare module '@tiptap/core' {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
createParagraphEnd: {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an empty paragraph at the end of the document.
|
|
13
|
+
*/
|
|
14
|
+
createParagraphEnd: () => ReturnType;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Creates an empty paragraph at the end of the document.
|
|
@@ -19,5 +21,6 @@ declare module '@tiptap/core' {
|
|
|
19
21
|
* last node before creating the paragraph, using the build int fn
|
|
20
22
|
*/
|
|
21
23
|
declare function createParagraphEnd(): ReturnType<RawCommands['createParagraphEnd']>;
|
|
24
|
+
//#endregion
|
|
22
25
|
export { createParagraphEnd };
|
|
23
26
|
//# sourceMappingURL=create-paragraph-end.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-paragraph-end.d.ts","
|
|
1
|
+
{"version":3,"file":"create-paragraph-end.d.ts","names":[],"sources":["../../../../../src/extensions/core/extra-editor-commands/commands/create-paragraph-end.ts"],"mappings":";;;;;AAA0C;;;YAQ5B,QAAA;IACN,kBAAA;MADe;;;MAKX,kBAAA,QAA0B,UAAA;IAAA;EAAA;AAAA;AAAU;;;;;AAAA,iBAUvC,kBAAA,CAAA,GAAsB,UAAA,CAAW,WAAA"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { TextSelection } from
|
|
1
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
2
|
+
//#region src/extensions/core/extra-editor-commands/commands/create-paragraph-end.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
* Creates an empty paragraph at the end of the document.
|
|
5
|
+
*
|
|
6
|
+
* last node before creating the paragraph, using the build int fn
|
|
7
|
+
*/
|
|
7
8
|
function createParagraphEnd() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return true;
|
|
16
|
-
})
|
|
17
|
-
.createParagraphNear()
|
|
18
|
-
.run();
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
9
|
+
return ({ state, tr, chain, dispatch }) => {
|
|
10
|
+
if (dispatch) return chain().command(() => {
|
|
11
|
+
tr.setSelection(TextSelection.create(tr.doc, state.doc.content.size, state.doc.content.size));
|
|
12
|
+
return true;
|
|
13
|
+
}).createParagraphNear().run();
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
22
16
|
}
|
|
17
|
+
//#endregion
|
|
23
18
|
export { createParagraphEnd };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=create-paragraph-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-paragraph-end.js","names":[],"sources":["../../../../../src/extensions/core/extra-editor-commands/commands/create-paragraph-end.ts"],"sourcesContent":["import { RawCommands } from '@tiptap/core'\nimport { TextSelection } from '@tiptap/pm/state'\n\n/**\n * Augment the official `@tiptap/core` module with extra commands so that the compiler knows about\n * them. For this to work externally, a wildcard export needs to be added to the root `index.ts`.\n */\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n createParagraphEnd: {\n /**\n * Creates an empty paragraph at the end of the document.\n */\n createParagraphEnd: () => ReturnType\n }\n }\n}\n\n/**\n * Creates an empty paragraph at the end of the document.\n *\n * last node before creating the paragraph, using the build int fn\n */\nfunction createParagraphEnd(): ReturnType<RawCommands['createParagraphEnd']> {\n return ({ state, tr, chain, dispatch }) => {\n // Check if the transaction should be dispatched\n // ref: https://tiptap.dev/api/commands#dry-run-for-commands\n if (dispatch) {\n return chain()\n .command(() => {\n tr.setSelection(\n TextSelection.create(\n tr.doc,\n state.doc.content.size,\n state.doc.content.size,\n ),\n )\n\n return true\n })\n .createParagraphNear()\n .run()\n }\n\n return true\n }\n}\n\nexport { createParagraphEnd }\n"],"mappings":";;;;;;;AAuBA,SAAS,qBAAoE;AACzE,SAAQ,EAAE,OAAO,IAAI,OAAO,eAAe;AAGvC,MAAI,SACA,QAAO,OAAO,CACT,cAAc;AACX,MAAG,aACC,cAAc,OACV,GAAG,KACH,MAAM,IAAI,QAAQ,MAClB,MAAM,IAAI,QAAQ,KACrB,CACJ;AAED,UAAO;IACT,CACD,qBAAqB,CACrB,KAAK;AAGd,SAAO"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { RawCommands } from
|
|
1
|
+
import { RawCommands } from "@tiptap/core";
|
|
2
|
+
|
|
3
|
+
//#region src/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Augment the official `@tiptap/core` module with extra commands so that the compiler knows about
|
|
4
6
|
* them. For this to work externally, a wildcard export needs to be added to the root `index.ts`.
|
|
5
7
|
*/
|
|
6
8
|
declare module '@tiptap/core' {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
extendWordRange: {
|
|
11
|
+
/**
|
|
12
|
+
* Extends the text selection to the current word.
|
|
13
|
+
*/
|
|
14
|
+
extendWordRange: () => ReturnType;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Extends the text selection to the current word.
|
|
@@ -20,5 +22,6 @@ declare module '@tiptap/core' {
|
|
|
20
22
|
* `setTextSelection` commands.
|
|
21
23
|
*/
|
|
22
24
|
declare function extendWordRange(): ReturnType<RawCommands['extendWordRange']>;
|
|
25
|
+
//#endregion
|
|
23
26
|
export { extendWordRange };
|
|
24
27
|
//# sourceMappingURL=extend-word-range.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-word-range.d.ts","
|
|
1
|
+
{"version":3,"file":"extend-word-range.d.ts","names":[],"sources":["../../../../../src/extensions/core/extra-editor-commands/commands/extend-word-range.ts"],"mappings":";;;;;AAAqE;;;YASvD,QAAA;IACN,eAAA;MADe;;;MAKX,eAAA,QAAuB,UAAA;IAAA;EAAA;AAAA;AAAU;;;;;;AAAA,iBAWpC,eAAA,CAAA,GAAmB,UAAA,CAAW,WAAA"}
|