@doist/typist 10.0.0-next.1 → 10.0.0

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.
Files changed (237) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/typist-editor.d.ts +126 -123
  3. package/dist/components/typist-editor.d.ts.map +1 -1
  4. package/dist/components/typist-editor.helper.d.ts +8 -11
  5. package/dist/components/typist-editor.helper.d.ts.map +1 -1
  6. package/dist/components/typist-editor.helper.js +21 -19
  7. package/dist/components/typist-editor.helper.js.map +1 -0
  8. package/dist/components/typist-editor.js +133 -135
  9. package/dist/components/typist-editor.js.map +1 -0
  10. package/dist/constants/common.js +9 -5
  11. package/dist/constants/common.js.map +1 -0
  12. package/dist/constants/extension-priorities.d.ts +3 -1
  13. package/dist/constants/extension-priorities.d.ts.map +1 -1
  14. package/dist/constants/extension-priorities.js +34 -30
  15. package/dist/constants/extension-priorities.js.map +1 -0
  16. package/dist/constants/regular-expressions.js +14 -10
  17. package/dist/constants/regular-expressions.js.map +1 -0
  18. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts +12 -9
  19. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts.map +1 -1
  20. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js +16 -19
  21. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js.map +1 -0
  22. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts +12 -9
  23. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -1
  24. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js +25 -28
  25. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js.map +1 -0
  26. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts +24 -22
  27. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts.map +1 -1
  28. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js +34 -36
  29. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js.map +1 -0
  30. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts +23 -20
  31. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -1
  32. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +15 -8
  33. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js.map +1 -0
  34. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js +22 -18
  35. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js.map +1 -0
  36. package/dist/extensions/core/view-event-handlers.d.ts +14 -13
  37. package/dist/extensions/core/view-event-handlers.d.ts.map +1 -1
  38. package/dist/extensions/core/view-event-handlers.js +33 -31
  39. package/dist/extensions/core/view-event-handlers.js.map +1 -0
  40. package/dist/extensions/plain-text/paste-multiline-text.js +45 -59
  41. package/dist/extensions/plain-text/paste-multiline-text.js.map +1 -0
  42. package/dist/extensions/plain-text/plain-text-document.d.ts +7 -7
  43. package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -1
  44. package/dist/extensions/plain-text/plain-text-document.js +14 -13
  45. package/dist/extensions/plain-text/plain-text-document.js.map +1 -0
  46. package/dist/extensions/plain-text/plain-text-kit.d.ts +35 -33
  47. package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -1
  48. package/dist/extensions/plain-text/plain-text-kit.js +33 -48
  49. package/dist/extensions/plain-text/plain-text-kit.js.map +1 -0
  50. package/dist/extensions/plain-text/plain-text-paragraph.d.ts +2 -9
  51. package/dist/extensions/plain-text/plain-text-paragraph.js +11 -11
  52. package/dist/extensions/plain-text/plain-text-paragraph.js.map +1 -0
  53. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js +37 -81
  54. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js.map +1 -0
  55. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js +32 -42
  56. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js.map +1 -0
  57. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +24 -37
  58. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js.map +1 -0
  59. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js +21 -13
  60. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js.map +1 -0
  61. package/dist/extensions/rich-text/bold-and-italics.js +42 -40
  62. package/dist/extensions/rich-text/bold-and-italics.js.map +1 -0
  63. package/dist/extensions/rich-text/curvenote-codemark.js +16 -14
  64. package/dist/extensions/rich-text/curvenote-codemark.js.map +1 -0
  65. package/dist/extensions/rich-text/paste-emojis.js +20 -22
  66. package/dist/extensions/rich-text/paste-emojis.js.map +1 -0
  67. package/dist/extensions/rich-text/paste-markdown.js +46 -86
  68. package/dist/extensions/rich-text/paste-markdown.js.map +1 -0
  69. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts +10 -9
  70. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts.map +1 -1
  71. package/dist/extensions/rich-text/rich-text-bullet-list.js +42 -56
  72. package/dist/extensions/rich-text/rich-text-bullet-list.js.map +1 -0
  73. package/dist/extensions/rich-text/rich-text-code.js +34 -34
  74. package/dist/extensions/rich-text/rich-text-code.js.map +1 -0
  75. package/dist/extensions/rich-text/rich-text-document.d.ts +7 -7
  76. package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -1
  77. package/dist/extensions/rich-text/rich-text-document.js +14 -13
  78. package/dist/extensions/rich-text/rich-text-document.js.map +1 -0
  79. package/dist/extensions/rich-text/rich-text-heading.d.ts +5 -4
  80. package/dist/extensions/rich-text/rich-text-heading.d.ts.map +1 -1
  81. package/dist/extensions/rich-text/rich-text-heading.js +25 -25
  82. package/dist/extensions/rich-text/rich-text-heading.js.map +1 -0
  83. package/dist/extensions/rich-text/rich-text-image.d.ts +53 -52
  84. package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
  85. package/dist/extensions/rich-text/rich-text-image.js +88 -105
  86. package/dist/extensions/rich-text/rich-text-image.js.map +1 -0
  87. package/dist/extensions/rich-text/rich-text-kit.d.ts +127 -125
  88. package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
  89. package/dist/extensions/rich-text/rich-text-kit.js +73 -135
  90. package/dist/extensions/rich-text/rich-text-kit.js.map +1 -0
  91. package/dist/extensions/rich-text/rich-text-link.d.ts +5 -4
  92. package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
  93. package/dist/extensions/rich-text/rich-text-link.js +82 -90
  94. package/dist/extensions/rich-text/rich-text-link.js.map +1 -0
  95. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts +10 -9
  96. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts.map +1 -1
  97. package/dist/extensions/rich-text/rich-text-ordered-list.js +42 -56
  98. package/dist/extensions/rich-text/rich-text-ordered-list.js.map +1 -0
  99. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts +5 -4
  100. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts.map +1 -1
  101. package/dist/extensions/rich-text/rich-text-strikethrough.js +10 -10
  102. package/dist/extensions/rich-text/rich-text-strikethrough.js.map +1 -0
  103. package/dist/extensions/shared/copy-markdown-source.js +22 -31
  104. package/dist/extensions/shared/copy-markdown-source.js.map +1 -0
  105. package/dist/extensions/shared/paste-html-table-as-string.js +47 -60
  106. package/dist/extensions/shared/paste-html-table-as-string.js.map +1 -0
  107. package/dist/extensions/shared/paste-singleline-text.js +31 -39
  108. package/dist/extensions/shared/paste-singleline-text.js.map +1 -0
  109. package/dist/factories/create-suggestion-extension.d.ts +74 -74
  110. package/dist/factories/create-suggestion-extension.d.ts.map +1 -1
  111. package/dist/factories/create-suggestion-extension.js +139 -161
  112. package/dist/factories/create-suggestion-extension.js.map +1 -0
  113. package/dist/helpers/dom.js +9 -5
  114. package/dist/helpers/dom.js.map +1 -0
  115. package/dist/helpers/schema.d.ts +5 -3
  116. package/dist/helpers/schema.d.ts.map +1 -1
  117. package/dist/helpers/schema.js +25 -21
  118. package/dist/helpers/schema.js.map +1 -0
  119. package/dist/helpers/serializer.js +24 -28
  120. package/dist/helpers/serializer.js.map +1 -0
  121. package/dist/helpers/unified.js +24 -17
  122. package/dist/helpers/unified.js.map +1 -0
  123. package/dist/hooks/use-editor.js +50 -53
  124. package/dist/hooks/use-editor.js.map +1 -0
  125. package/dist/index.d.ts +25 -31
  126. package/dist/index.js +24 -24
  127. package/dist/serializers/html/html.d.ts +12 -10
  128. package/dist/serializers/html/html.d.ts.map +1 -1
  129. package/dist/serializers/html/html.js +67 -127
  130. package/dist/serializers/html/html.js.map +1 -0
  131. package/dist/serializers/html/plugins/rehype-code-block.js +17 -17
  132. package/dist/serializers/html/plugins/rehype-code-block.js.map +1 -0
  133. package/dist/serializers/html/plugins/rehype-image.js +20 -30
  134. package/dist/serializers/html/plugins/rehype-image.js.map +1 -0
  135. package/dist/serializers/html/plugins/rehype-suggestions.js +31 -32
  136. package/dist/serializers/html/plugins/rehype-suggestions.js.map +1 -0
  137. package/dist/serializers/html/plugins/rehype-task-list.js +31 -32
  138. package/dist/serializers/html/plugins/rehype-task-list.js.map +1 -0
  139. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts +4 -1
  140. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
  141. package/dist/serializers/html/plugins/remark-autolink-literal.js +25 -21
  142. package/dist/serializers/html/plugins/remark-autolink-literal.js.map +1 -0
  143. package/dist/serializers/html/plugins/remark-disable-constructs.js +21 -41
  144. package/dist/serializers/html/plugins/remark-disable-constructs.js.map +1 -0
  145. package/dist/serializers/html/plugins/remark-strikethrough.d.ts +5 -2
  146. package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
  147. package/dist/serializers/html/plugins/remark-strikethrough.js +25 -21
  148. package/dist/serializers/html/plugins/remark-strikethrough.js.map +1 -0
  149. package/dist/serializers/markdown/markdown.d.ts +13 -12
  150. package/dist/serializers/markdown/markdown.d.ts.map +1 -1
  151. package/dist/serializers/markdown/markdown.js +78 -154
  152. package/dist/serializers/markdown/markdown.js.map +1 -0
  153. package/dist/serializers/markdown/plugins/image.js +27 -24
  154. package/dist/serializers/markdown/plugins/image.js.map +1 -0
  155. package/dist/serializers/markdown/plugins/list-item.js +32 -37
  156. package/dist/serializers/markdown/plugins/list-item.js.map +1 -0
  157. package/dist/serializers/markdown/plugins/paragraph.js +19 -19
  158. package/dist/serializers/markdown/plugins/paragraph.js.map +1 -0
  159. package/dist/serializers/markdown/plugins/strikethrough.js +23 -19
  160. package/dist/serializers/markdown/plugins/strikethrough.js.map +1 -0
  161. package/dist/serializers/markdown/plugins/suggestion.js +21 -19
  162. package/dist/serializers/markdown/plugins/suggestion.js.map +1 -0
  163. package/dist/serializers/markdown/plugins/task-item.js +31 -35
  164. package/dist/serializers/markdown/plugins/task-item.js.map +1 -0
  165. package/dist/utilities/can-insert-node-at.d.ts +12 -5
  166. package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
  167. package/dist/utilities/can-insert-node-at.js +10 -8
  168. package/dist/utilities/can-insert-node-at.js.map +1 -0
  169. package/dist/utilities/can-insert-suggestion.d.ts +11 -5
  170. package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
  171. package/dist/utilities/can-insert-suggestion.js +15 -12
  172. package/dist/utilities/can-insert-suggestion.js.map +1 -0
  173. package/package.json +4 -3
  174. package/dist/constants/common.d.ts +0 -10
  175. package/dist/constants/common.d.ts.map +0 -1
  176. package/dist/constants/regular-expressions.d.ts +0 -18
  177. package/dist/constants/regular-expressions.d.ts.map +0 -1
  178. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts +0 -9
  179. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts.map +0 -1
  180. package/dist/extensions/plain-text/paste-multiline-text.d.ts +0 -10
  181. package/dist/extensions/plain-text/paste-multiline-text.d.ts.map +0 -1
  182. package/dist/extensions/plain-text/plain-text-paragraph.d.ts.map +0 -1
  183. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts +0 -9
  184. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts.map +0 -1
  185. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts +0 -9
  186. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts.map +0 -1
  187. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts +0 -9
  188. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +0 -1
  189. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts +0 -8
  190. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts.map +0 -1
  191. package/dist/extensions/rich-text/bold-and-italics.d.ts +0 -8
  192. package/dist/extensions/rich-text/bold-and-italics.d.ts.map +0 -1
  193. package/dist/extensions/rich-text/curvenote-codemark.d.ts +0 -11
  194. package/dist/extensions/rich-text/curvenote-codemark.d.ts.map +0 -1
  195. package/dist/extensions/rich-text/paste-emojis.d.ts +0 -9
  196. package/dist/extensions/rich-text/paste-emojis.d.ts.map +0 -1
  197. package/dist/extensions/rich-text/paste-markdown.d.ts +0 -11
  198. package/dist/extensions/rich-text/paste-markdown.d.ts.map +0 -1
  199. package/dist/extensions/rich-text/rich-text-code.d.ts +0 -17
  200. package/dist/extensions/rich-text/rich-text-code.d.ts.map +0 -1
  201. package/dist/extensions/shared/copy-markdown-source.d.ts +0 -20
  202. package/dist/extensions/shared/copy-markdown-source.d.ts.map +0 -1
  203. package/dist/extensions/shared/paste-html-table-as-string.d.ts +0 -20
  204. package/dist/extensions/shared/paste-html-table-as-string.d.ts.map +0 -1
  205. package/dist/extensions/shared/paste-singleline-text.d.ts +0 -10
  206. package/dist/extensions/shared/paste-singleline-text.d.ts.map +0 -1
  207. package/dist/helpers/dom.d.ts +0 -8
  208. package/dist/helpers/dom.d.ts.map +0 -1
  209. package/dist/helpers/serializer.d.ts +0 -21
  210. package/dist/helpers/serializer.d.ts.map +0 -1
  211. package/dist/helpers/unified.d.ts +0 -21
  212. package/dist/helpers/unified.d.ts.map +0 -1
  213. package/dist/hooks/use-editor.d.ts +0 -19
  214. package/dist/hooks/use-editor.d.ts.map +0 -1
  215. package/dist/index.d.ts.map +0 -1
  216. package/dist/serializers/html/plugins/rehype-code-block.d.ts +0 -10
  217. package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +0 -1
  218. package/dist/serializers/html/plugins/rehype-image.d.ts +0 -11
  219. package/dist/serializers/html/plugins/rehype-image.d.ts.map +0 -1
  220. package/dist/serializers/html/plugins/rehype-suggestions.d.ts +0 -10
  221. package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +0 -1
  222. package/dist/serializers/html/plugins/rehype-task-list.d.ts +0 -7
  223. package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +0 -1
  224. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts +0 -11
  225. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +0 -1
  226. package/dist/serializers/markdown/plugins/image.d.ts +0 -12
  227. package/dist/serializers/markdown/plugins/image.d.ts.map +0 -1
  228. package/dist/serializers/markdown/plugins/list-item.d.ts +0 -14
  229. package/dist/serializers/markdown/plugins/list-item.d.ts.map +0 -1
  230. package/dist/serializers/markdown/plugins/paragraph.d.ts +0 -13
  231. package/dist/serializers/markdown/plugins/paragraph.d.ts.map +0 -1
  232. package/dist/serializers/markdown/plugins/strikethrough.d.ts +0 -13
  233. package/dist/serializers/markdown/plugins/strikethrough.d.ts.map +0 -1
  234. package/dist/serializers/markdown/plugins/suggestion.d.ts +0 -11
  235. package/dist/serializers/markdown/plugins/suggestion.d.ts.map +0 -1
  236. package/dist/serializers/markdown/plugins/task-item.d.ts +0 -14
  237. package/dist/serializers/markdown/plugins/task-item.d.ts.map +0 -1
@@ -1,66 +1,52 @@
1
- /* eslint-disable no-console */
2
- import { Extension } from '@tiptap/core';
3
- import { Fragment, Slice } from '@tiptap/pm/model';
4
- import { Plugin, PluginKey } from '@tiptap/pm/state';
5
- import { ClipboardDataType } from '../../constants/common';
6
- import { REGEX_LINE_BREAKS } from '../../constants/regular-expressions';
1
+ import { REGEX_LINE_BREAKS } from "../../constants/regular-expressions.js";
2
+ import { ClipboardDataType } from "../../constants/common.js";
3
+ import { Extension } from "@tiptap/core";
4
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
5
+ import { Fragment, Slice } from "@tiptap/pm/model";
6
+ //#region src/extensions/plain-text/paste-multiline-text.ts
7
7
  /**
8
- * Handles a text input or paste event, and replaces all found line breaks with paragraph nodes.
9
- *
10
- * @param view The current editor view to process.
11
- * @param text The multiline text input to parse.
12
- */
8
+ * Handles a text input or paste event, and replaces all found line breaks with paragraph nodes.
9
+ *
10
+ * @param view The current editor view to process.
11
+ * @param text The multiline text input to parse.
12
+ */
13
13
  function handleTextInputOrPaste(view, text) {
14
- const { schema } = view.state;
15
- const { tr } = view.state;
16
- const textLines = text.split(REGEX_LINE_BREAKS);
17
- // Do not handle the event without a multiline input
18
- // (i.e. when the user is only typing)
19
- if (textLines.length === 1) {
20
- return false;
21
- }
22
- // Build an array of paragraphs nodes (including empty ones)
23
- const paragraphNodes = textLines.map((textLine) => {
24
- if (textLine.length === 0) {
25
- return schema.nodes.paragraph.create();
26
- }
27
- return schema.nodes.paragraph.create(null, schema.text(textLine));
28
- });
29
- // Inserts the new paragraph nodes at the current cursor position
30
- // (takes into account if a selection needs to be replaced)
31
- view.dispatch(tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(paragraphNodes))).scrollIntoView());
32
- // Suppress the default handling behaviour
33
- return true;
14
+ const { schema } = view.state;
15
+ const { tr } = view.state;
16
+ const textLines = text.split(REGEX_LINE_BREAKS);
17
+ if (textLines.length === 1) return false;
18
+ const paragraphNodes = textLines.map((textLine) => {
19
+ if (textLine.length === 0) return schema.nodes.paragraph.create();
20
+ return schema.nodes.paragraph.create(null, schema.text(textLine));
21
+ });
22
+ view.dispatch(tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(paragraphNodes))).scrollIntoView());
23
+ return true;
34
24
  }
35
25
  /**
36
- * The `MultilineDocumentPaste` extension preserves paragraphs (including empty ones) when
37
- * copying-and-pasting text into the editor, or when inputting multiline text with some sort of
38
- * automatic text insertion shortcut. This custom extension is required for a plain-text editor
39
- * configured with `multiline: true`, so that multiline clipboard text is pasted correctly.
40
- */
26
+ * The `MultilineDocumentPaste` extension preserves paragraphs (including empty ones) when
27
+ * copying-and-pasting text into the editor, or when inputting multiline text with some sort of
28
+ * automatic text insertion shortcut. This custom extension is required for a plain-text editor
29
+ * configured with `multiline: true`, so that multiline clipboard text is pasted correctly.
30
+ */
41
31
  const PasteMultilineText = Extension.create({
42
- name: 'pasteMultilineText',
43
- addProseMirrorPlugins() {
44
- return [
45
- new Plugin({
46
- key: new PluginKey('pasteMultilineText'),
47
- props: {
48
- handleTextInput(view, _, __, inputText) {
49
- return handleTextInputOrPaste(view, inputText);
50
- },
51
- handlePaste(view, event) {
52
- const clipboardText = event.clipboardData
53
- ?.getData(ClipboardDataType.Text)
54
- .trim();
55
- // Do not handle the event if the clipboard doesn't contain text
56
- if (!clipboardText) {
57
- return false;
58
- }
59
- return handleTextInputOrPaste(view, clipboardText);
60
- },
61
- },
62
- }),
63
- ];
64
- },
32
+ name: "pasteMultilineText",
33
+ addProseMirrorPlugins() {
34
+ return [new Plugin({
35
+ key: new PluginKey("pasteMultilineText"),
36
+ props: {
37
+ handleTextInput(view, _, __, inputText) {
38
+ return handleTextInputOrPaste(view, inputText);
39
+ },
40
+ handlePaste(view, event) {
41
+ const clipboardText = event.clipboardData?.getData(ClipboardDataType.Text).trim();
42
+ if (!clipboardText) return false;
43
+ return handleTextInputOrPaste(view, clipboardText);
44
+ }
45
+ }
46
+ })];
47
+ }
65
48
  });
49
+ //#endregion
66
50
  export { PasteMultilineText };
51
+
52
+ //# sourceMappingURL=paste-multiline-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-multiline-text.js","names":[],"sources":["../../../src/extensions/plain-text/paste-multiline-text.ts"],"sourcesContent":["/* eslint-disable no-console */\n\nimport { Extension } from '@tiptap/core'\nimport { Fragment, Slice } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { ClipboardDataType } from '../../constants/common'\nimport { REGEX_LINE_BREAKS } from '../../constants/regular-expressions'\n\nimport type { Schema } from '@tiptap/pm/model'\nimport type { EditorView } from '@tiptap/pm/view'\n\n/**\n * Handles a text input or paste event, and replaces all found line breaks with paragraph nodes.\n *\n * @param view The current editor view to process.\n * @param text The multiline text input to parse.\n */\nfunction handleTextInputOrPaste(view: EditorView, text: string): boolean {\n const { schema } = view.state as { schema: Schema }\n const { tr } = view.state\n\n const textLines = text.split(REGEX_LINE_BREAKS)\n\n // Do not handle the event without a multiline input\n // (i.e. when the user is only typing)\n if (textLines.length === 1) {\n return false\n }\n\n // Build an array of paragraphs nodes (including empty ones)\n const paragraphNodes = textLines.map((textLine) => {\n if (textLine.length === 0) {\n return schema.nodes.paragraph.create()\n }\n\n return schema.nodes.paragraph.create(null, schema.text(textLine))\n })\n\n // Inserts the new paragraph nodes at the current cursor position\n // (takes into account if a selection needs to be replaced)\n view.dispatch(\n tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(paragraphNodes))).scrollIntoView(),\n )\n\n // Suppress the default handling behaviour\n return true\n}\n\n/**\n * The `MultilineDocumentPaste` extension preserves paragraphs (including empty ones) when\n * copying-and-pasting text into the editor, or when inputting multiline text with some sort of\n * automatic text insertion shortcut. This custom extension is required for a plain-text editor\n * configured with `multiline: true`, so that multiline clipboard text is pasted correctly.\n */\nconst PasteMultilineText = Extension.create({\n name: 'pasteMultilineText',\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('pasteMultilineText'),\n props: {\n handleTextInput(view: EditorView, _, __, inputText) {\n return handleTextInputOrPaste(view, inputText)\n },\n handlePaste(view: EditorView, event) {\n const clipboardText = event.clipboardData\n ?.getData(ClipboardDataType.Text)\n .trim()\n\n // Do not handle the event if the clipboard doesn't contain text\n if (!clipboardText) {\n return false\n }\n\n return handleTextInputOrPaste(view, clipboardText)\n },\n },\n }),\n ]\n },\n})\n\nexport { PasteMultilineText }\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,uBAAuB,MAAkB,MAAuB;CACrE,MAAM,EAAE,WAAW,KAAK;CACxB,MAAM,EAAE,OAAO,KAAK;CAEpB,MAAM,YAAY,KAAK,MAAM,kBAAkB;AAI/C,KAAI,UAAU,WAAW,EACrB,QAAO;CAIX,MAAM,iBAAiB,UAAU,KAAK,aAAa;AAC/C,MAAI,SAAS,WAAW,EACpB,QAAO,OAAO,MAAM,UAAU,QAAQ;AAG1C,SAAO,OAAO,MAAM,UAAU,OAAO,MAAM,OAAO,KAAK,SAAS,CAAC;GACnE;AAIF,MAAK,SACD,GAAG,iBAAiB,MAAM,QAAQ,SAAS,UAAU,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAC1F;AAGD,QAAO;;;;;;;;AASX,MAAM,qBAAqB,UAAU,OAAO;CACxC,MAAM;CACN,wBAAwB;AACpB,SAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,qBAAqB;GACxC,OAAO;IACH,gBAAgB,MAAkB,GAAG,IAAI,WAAW;AAChD,YAAO,uBAAuB,MAAM,UAAU;;IAElD,YAAY,MAAkB,OAAO;KACjC,MAAM,gBAAgB,MAAM,eACtB,QAAQ,kBAAkB,KAAK,CAChC,MAAM;AAGX,SAAI,CAAC,cACD,QAAO;AAGX,YAAO,uBAAuB,MAAM,cAAc;;IAEzD;GACJ,CAAC,CACL;;CAER,CAAC"}
@@ -1,17 +1,17 @@
1
+ //#region src/extensions/plain-text/plain-text-document.d.ts
1
2
  /**
2
3
  * The options available to customize the `PlainTextDocument` extension.
3
4
  */
4
5
  type PlainTextDocumentOptions = {
5
- /**
6
- * Indicates whether the document accepts multiple lines of input or only a single line.
7
- */
8
- multiline: boolean;
6
+ /**
7
+ * Indicates whether the document accepts multiple lines of input or only a single line.
8
+ */
9
+ multiline: boolean;
9
10
  };
10
11
  /**
11
12
  * Custom extension that extends the built-in `Document` extension to define a schema for multiline
12
13
  * or singleline plain-text documents (as opposed to the multiple block nodes by default).
13
14
  */
14
- declare const PlainTextDocument: import("@tiptap/core").Node<PlainTextDocumentOptions, any>;
15
- export { PlainTextDocument };
16
- export type { PlainTextDocumentOptions };
15
+ //#endregion
16
+ export { type PlainTextDocumentOptions };
17
17
  //# sourceMappingURL=plain-text-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plain-text-document.d.ts","sourceRoot":"","sources":["../../../src/extensions/plain-text/plain-text-document.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,QAAA,MAAM,iBAAiB,4DAUrB,CAAA;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B,YAAY,EAAE,wBAAwB,EAAE,CAAA"}
1
+ {"version":3,"file":"plain-text-document.d.ts","names":[],"sources":["../../../src/extensions/plain-text/plain-text-document.ts"],"mappings":";;;;KAKK,wBAAA;EAAwB;;;EAIzB,SAAA;AAAA"}
@@ -1,17 +1,18 @@
1
- import { Document } from '@tiptap/extension-document';
1
+ import { Document } from "@tiptap/extension-document";
2
+ //#region src/extensions/plain-text/plain-text-document.ts
2
3
  /**
3
- * Custom extension that extends the built-in `Document` extension to define a schema for multiline
4
- * or singleline plain-text documents (as opposed to the multiple block nodes by default).
5
- */
4
+ * Custom extension that extends the built-in `Document` extension to define a schema for multiline
5
+ * or singleline plain-text documents (as opposed to the multiple block nodes by default).
6
+ */
6
7
  const PlainTextDocument = Document.extend({
7
- addOptions() {
8
- return {
9
- multiline: true,
10
- };
11
- },
12
- content() {
13
- // ref: https://tiptap.dev/api/schema#content
14
- return `paragraph${this.options.multiline ? '+' : ''}`;
15
- },
8
+ addOptions() {
9
+ return { multiline: true };
10
+ },
11
+ content() {
12
+ return `paragraph${this.options.multiline ? "+" : ""}`;
13
+ }
16
14
  });
15
+ //#endregion
17
16
  export { PlainTextDocument };
17
+
18
+ //# sourceMappingURL=plain-text-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain-text-document.js","names":[],"sources":["../../../src/extensions/plain-text/plain-text-document.ts"],"sourcesContent":["import { Document } from '@tiptap/extension-document'\n\n/**\n * The options available to customize the `PlainTextDocument` extension.\n */\ntype PlainTextDocumentOptions = {\n /**\n * Indicates whether the document accepts multiple lines of input or only a single line.\n */\n multiline: boolean\n}\n\n/**\n * Custom extension that extends the built-in `Document` extension to define a schema for multiline\n * or singleline plain-text documents (as opposed to the multiple block nodes by default).\n */\nconst PlainTextDocument = Document.extend<PlainTextDocumentOptions>({\n addOptions() {\n return {\n multiline: true,\n }\n },\n content() {\n // ref: https://tiptap.dev/api/schema#content\n return `paragraph${this.options.multiline ? '+' : ''}`\n },\n})\n\nexport { PlainTextDocument }\n\nexport type { PlainTextDocumentOptions }\n"],"mappings":";;;;;;AAgBA,MAAM,oBAAoB,SAAS,OAAiC;CAChE,aAAa;AACT,SAAO,EACH,WAAW,MACd;;CAEL,UAAU;AAEN,SAAO,YAAY,KAAK,QAAQ,YAAY,MAAM;;CAEzD,CAAC"}
@@ -1,39 +1,41 @@
1
- import { Extension } from '@tiptap/core';
2
- import { HistoryOptions } from '@tiptap/extension-history';
3
- import type { PlainTextDocumentOptions } from './plain-text-document';
4
- import type { PlainTextParagraphOptions } from './plain-text-paragraph';
1
+ import { PlainTextDocumentOptions } from "./plain-text-document.js";
2
+ import { ParagraphOptions } from "./plain-text-paragraph.js";
3
+ import { Extension } from "@tiptap/core";
4
+ import { HistoryOptions } from "@tiptap/extension-history";
5
+
6
+ //#region src/extensions/plain-text/plain-text-kit.d.ts
5
7
  /**
6
8
  * The options available to customize the `PlainTextKit` extension.
7
9
  */
8
10
  type PlainTextKitOptions = {
9
- /**
10
- * Set options for the `Document` extension, or `false` to disable.
11
- */
12
- document: Partial<PlainTextDocumentOptions> | false;
13
- /**
14
- * Set options for the `History` extension, or `false` to disable.
15
- */
16
- history: Partial<HistoryOptions> | false;
17
- /**
18
- * Set options for the `Paragraph` extension, or `false` to disable.
19
- */
20
- paragraph: Partial<PlainTextParagraphOptions> | false;
21
- /**
22
- * Set to `false` to disable the `PasteHTMLTableAsString` extension.
23
- */
24
- pasteHTMLTableAsString: false;
25
- /**
26
- * Set to `false` to disable the `Text` extension.
27
- */
28
- text: false;
29
- /**
30
- * Set to `false` to disable the `Typography` extension.
31
- */
32
- typography: false;
33
- /**
34
- * Set to `false` to disable the `SmartMarkdownTyping` extension.
35
- */
36
- smartMarkdownTyping: false;
11
+ /**
12
+ * Set options for the `Document` extension, or `false` to disable.
13
+ */
14
+ document: Partial<PlainTextDocumentOptions> | false;
15
+ /**
16
+ * Set options for the `History` extension, or `false` to disable.
17
+ */
18
+ history: Partial<HistoryOptions> | false;
19
+ /**
20
+ * Set options for the `Paragraph` extension, or `false` to disable.
21
+ */
22
+ paragraph: Partial<ParagraphOptions> | false;
23
+ /**
24
+ * Set to `false` to disable the `PasteHTMLTableAsString` extension.
25
+ */
26
+ pasteHTMLTableAsString: false;
27
+ /**
28
+ * Set to `false` to disable the `Text` extension.
29
+ */
30
+ text: false;
31
+ /**
32
+ * Set to `false` to disable the `Typography` extension.
33
+ */
34
+ typography: false;
35
+ /**
36
+ * Set to `false` to disable the `SmartMarkdownTyping` extension.
37
+ */
38
+ smartMarkdownTyping: false;
37
39
  };
38
40
  /**
39
41
  * The `PlainTextKit` extension is a collection of the minimal required extensions to have a basic
@@ -41,6 +43,6 @@ type PlainTextKitOptions = {
41
43
  * implementation, allowing almost every extension to be customized or disabled.
42
44
  */
43
45
  declare const PlainTextKit: Extension<PlainTextKitOptions, any>;
46
+ //#endregion
44
47
  export { PlainTextKit };
45
- export type { PlainTextKitOptions };
46
48
  //# sourceMappingURL=plain-text-kit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plain-text-kit.d.ts","sourceRoot":"","sources":["../../../src/extensions/plain-text/plain-text-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAW,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAcnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAEvE;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,KAAK,CAAA;IAEnD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,KAAK,CAAA;IAExC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,KAAK,CAAA;IAErD;;OAEG;IACH,sBAAsB,EAAE,KAAK,CAAA;IAE7B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IAEX;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IAEjB;;OAEG;IACH,mBAAmB,EAAE,KAAK,CAAA;CAC7B,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,YAAY,qCA8ChB,CAAA;AAEF,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,YAAY,EAAE,mBAAmB,EAAE,CAAA"}
1
+ {"version":3,"file":"plain-text-kit.d.ts","names":[],"sources":["../../../src/extensions/plain-text/plain-text-kit.ts"],"mappings":";;;;;;;;AAgBuE;KAKlE,mBAAA;;;;EAID,QAAA,EAAU,OAAA,CAAQ,wBAAA;EAKT;;;EAAT,OAAA,EAAS,OAAA,CAAQ,cAAA;EAKC;;;EAAlB,SAAA,EAAW,OAAA,CAAQ,gBAAA;EALnB;;;EAUA,sBAAA;EALW;;;EAUX,IAAA;EAKA;;;EAAA,UAAA;EAaE;;;EARF,mBAAA;AAAA;;;;;;cAQE,YAAA,EAAY,SAAA,CAAA,mBAAA"}
@@ -1,52 +1,37 @@
1
- import { Extension } from '@tiptap/core';
2
- import { History } from '@tiptap/extension-history';
3
- import { Text } from '@tiptap/extension-text';
4
- import { Typography } from '@tiptap/extension-typography';
5
- import { CopyMarkdownSource } from '../shared/copy-markdown-source';
6
- import { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string';
7
- import { PasteSinglelineText } from '../shared/paste-singleline-text';
8
- import { SmartMarkdownTyping } from './smart-markdown-typing/smart-markdown-typing';
9
- import { PasteMultilineText } from './paste-multiline-text';
10
- import { PlainTextDocument } from './plain-text-document';
11
- import { PlainTextParagraph } from './plain-text-paragraph';
1
+ import { CopyMarkdownSource } from "../shared/copy-markdown-source.js";
2
+ import { PasteHTMLTableAsString } from "../shared/paste-html-table-as-string.js";
3
+ import { PasteSinglelineText } from "../shared/paste-singleline-text.js";
4
+ import { SmartMarkdownTyping } from "./smart-markdown-typing/smart-markdown-typing.js";
5
+ import { PasteMultilineText } from "./paste-multiline-text.js";
6
+ import { PlainTextDocument } from "./plain-text-document.js";
7
+ import { PlainTextParagraph } from "./plain-text-paragraph.js";
8
+ import { Extension } from "@tiptap/core";
9
+ import { History } from "@tiptap/extension-history";
10
+ import { Text } from "@tiptap/extension-text";
11
+ import { Typography } from "@tiptap/extension-typography";
12
+ //#region src/extensions/plain-text/plain-text-kit.ts
12
13
  /**
13
- * The `PlainTextKit` extension is a collection of the minimal required extensions to have a basic
14
- * plain-text editor working. This extension is based on the official `StarterKit` extension
15
- * implementation, allowing almost every extension to be customized or disabled.
16
- */
14
+ * The `PlainTextKit` extension is a collection of the minimal required extensions to have a basic
15
+ * plain-text editor working. This extension is based on the official `StarterKit` extension
16
+ * implementation, allowing almost every extension to be customized or disabled.
17
+ */
17
18
  const PlainTextKit = Extension.create({
18
- name: 'plainTextKit',
19
- addExtensions() {
20
- const extensions = [];
21
- if (this.options.document !== false) {
22
- extensions.push(PlainTextDocument.configure(this.options?.document),
23
- // Supports copying the underlying Markdown source to the clipboard
24
- CopyMarkdownSource,
25
- // Supports pasting plain-text into both a singleline and multiline editor
26
- this.options?.document?.multiline === false
27
- ? PasteSinglelineText
28
- : PasteMultilineText);
29
- if (this.options?.pasteHTMLTableAsString !== false) {
30
- // Supports pasting tables (from spreadsheets and websites) into the editor
31
- extensions.push(PasteHTMLTableAsString);
32
- }
33
- }
34
- if (this.options.history !== false) {
35
- extensions.push(History.configure(this.options?.history));
36
- }
37
- if (this.options.paragraph !== false) {
38
- extensions.push(PlainTextParagraph.configure(this.options?.paragraph));
39
- }
40
- if (this.options.text !== false) {
41
- extensions.push(Text);
42
- }
43
- if (this.options.typography !== false) {
44
- extensions.push(Typography);
45
- }
46
- if (this.options.smartMarkdownTyping !== false) {
47
- extensions.push(SmartMarkdownTyping);
48
- }
49
- return extensions;
50
- },
19
+ name: "plainTextKit",
20
+ addExtensions() {
21
+ const extensions = [];
22
+ if (this.options.document !== false) {
23
+ extensions.push(PlainTextDocument.configure(this.options?.document), CopyMarkdownSource, this.options?.document?.multiline === false ? PasteSinglelineText : PasteMultilineText);
24
+ if (this.options?.pasteHTMLTableAsString !== false) extensions.push(PasteHTMLTableAsString);
25
+ }
26
+ if (this.options.history !== false) extensions.push(History.configure(this.options?.history));
27
+ if (this.options.paragraph !== false) extensions.push(PlainTextParagraph.configure(this.options?.paragraph));
28
+ if (this.options.text !== false) extensions.push(Text);
29
+ if (this.options.typography !== false) extensions.push(Typography);
30
+ if (this.options.smartMarkdownTyping !== false) extensions.push(SmartMarkdownTyping);
31
+ return extensions;
32
+ }
51
33
  });
34
+ //#endregion
52
35
  export { PlainTextKit };
36
+
37
+ //# sourceMappingURL=plain-text-kit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain-text-kit.js","names":[],"sources":["../../../src/extensions/plain-text/plain-text-kit.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { History, HistoryOptions } from '@tiptap/extension-history'\nimport { Text } from '@tiptap/extension-text'\nimport { Typography } from '@tiptap/extension-typography'\n\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 { SmartMarkdownTyping } from './smart-markdown-typing/smart-markdown-typing'\nimport { PasteMultilineText } from './paste-multiline-text'\nimport { PlainTextDocument } from './plain-text-document'\nimport { PlainTextParagraph } from './plain-text-paragraph'\n\nimport type { Extensions } from '@tiptap/core'\nimport type { PlainTextDocumentOptions } from './plain-text-document'\nimport type { PlainTextParagraphOptions } from './plain-text-paragraph'\n\n/**\n * The options available to customize the `PlainTextKit` extension.\n */\ntype PlainTextKitOptions = {\n /**\n * Set options for the `Document` extension, or `false` to disable.\n */\n document: Partial<PlainTextDocumentOptions> | 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 `Paragraph` extension, or `false` to disable.\n */\n paragraph: Partial<PlainTextParagraphOptions> | false\n\n /**\n * Set to `false` to disable the `PasteHTMLTableAsString` extension.\n */\n pasteHTMLTableAsString: 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 * Set to `false` to disable the `SmartMarkdownTyping` extension.\n */\n smartMarkdownTyping: false\n}\n\n/**\n * The `PlainTextKit` extension is a collection of the minimal required extensions to have a basic\n * plain-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 PlainTextKit = Extension.create<PlainTextKitOptions>({\n name: 'plainTextKit',\n addExtensions() {\n const extensions: Extensions = []\n\n if (this.options.document !== false) {\n extensions.push(\n PlainTextDocument.configure(this.options?.document),\n\n // Supports copying the underlying Markdown source to the clipboard\n CopyMarkdownSource,\n\n // Supports pasting plain-text into both a singleline and multiline editor\n this.options?.document?.multiline === false\n ? PasteSinglelineText\n : PasteMultilineText,\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.history !== false) {\n extensions.push(History.configure(this.options?.history))\n }\n\n if (this.options.paragraph !== false) {\n extensions.push(PlainTextParagraph.configure(this.options?.paragraph))\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 if (this.options.smartMarkdownTyping !== false) {\n extensions.push(SmartMarkdownTyping)\n }\n\n return extensions\n },\n})\n\nexport { PlainTextKit }\n\nexport type { PlainTextKitOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;AA+DA,MAAM,eAAe,UAAU,OAA4B;CACvD,MAAM;CACN,gBAAgB;EACZ,MAAM,aAAyB,EAAE;AAEjC,MAAI,KAAK,QAAQ,aAAa,OAAO;AACjC,cAAW,KACP,kBAAkB,UAAU,KAAK,SAAS,SAAS,EAGnD,oBAGA,KAAK,SAAS,UAAU,cAAc,QAChC,sBACA,mBACT;AAED,OAAI,KAAK,SAAS,2BAA2B,MAEzC,YAAW,KAAK,uBAAuB;;AAI/C,MAAI,KAAK,QAAQ,YAAY,MACzB,YAAW,KAAK,QAAQ,UAAU,KAAK,SAAS,QAAQ,CAAC;AAG7D,MAAI,KAAK,QAAQ,cAAc,MAC3B,YAAW,KAAK,mBAAmB,UAAU,KAAK,SAAS,UAAU,CAAC;AAG1E,MAAI,KAAK,QAAQ,SAAS,MACtB,YAAW,KAAK,KAAK;AAGzB,MAAI,KAAK,QAAQ,eAAe,MAC5B,YAAW,KAAK,WAAW;AAG/B,MAAI,KAAK,QAAQ,wBAAwB,MACrC,YAAW,KAAK,oBAAoB;AAGxC,SAAO;;CAEd,CAAC"}
@@ -1,9 +1,2 @@
1
- import { ParagraphOptions } from '@tiptap/extension-paragraph';
2
- /**
3
- * Custom extension that extends the built-in `Paragraph` extension to add an additional keyboard
4
- * shortcut to insert a newline (needed to behave more closely to the `<textarea>` component).
5
- */
6
- declare const PlainTextParagraph: import("@tiptap/core").Node<ParagraphOptions, any>;
7
- export { PlainTextParagraph };
8
- export type { ParagraphOptions as PlainTextParagraphOptions };
9
- //# sourceMappingURL=plain-text-paragraph.d.ts.map
1
+ import { ParagraphOptions as ParagraphOptions$1 } from "@tiptap/extension-paragraph";
2
+ export { ParagraphOptions$1 as ParagraphOptions };
@@ -1,13 +1,13 @@
1
- import { Paragraph } from '@tiptap/extension-paragraph';
1
+ import { Paragraph } from "@tiptap/extension-paragraph";
2
+ //#region src/extensions/plain-text/plain-text-paragraph.ts
2
3
  /**
3
- * Custom extension that extends the built-in `Paragraph` extension to add an additional keyboard
4
- * shortcut to insert a newline (needed to behave more closely to the `<textarea>` component).
5
- */
6
- const PlainTextParagraph = Paragraph.extend({
7
- addKeyboardShortcuts() {
8
- return {
9
- 'Shift-Enter': () => this.editor.commands.enter(),
10
- };
11
- },
12
- });
4
+ * Custom extension that extends the built-in `Paragraph` extension to add an additional keyboard
5
+ * shortcut to insert a newline (needed to behave more closely to the `<textarea>` component).
6
+ */
7
+ const PlainTextParagraph = Paragraph.extend({ addKeyboardShortcuts() {
8
+ return { "Shift-Enter": () => this.editor.commands.enter() };
9
+ } });
10
+ //#endregion
13
11
  export { PlainTextParagraph };
12
+
13
+ //# sourceMappingURL=plain-text-paragraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain-text-paragraph.js","names":[],"sources":["../../../src/extensions/plain-text/plain-text-paragraph.ts"],"sourcesContent":["import { Paragraph, ParagraphOptions } from '@tiptap/extension-paragraph'\n\n/**\n * Custom extension that extends the built-in `Paragraph` extension to add an additional keyboard\n * shortcut to insert a newline (needed to behave more closely to the `<textarea>` component).\n */\nconst PlainTextParagraph = Paragraph.extend<ParagraphOptions>({\n addKeyboardShortcuts() {\n return {\n 'Shift-Enter': () => this.editor.commands.enter(),\n }\n },\n})\n\nexport { PlainTextParagraph }\n\nexport type { ParagraphOptions as PlainTextParagraphOptions }\n"],"mappings":";;;;;;AAMA,MAAM,qBAAqB,UAAU,OAAyB,EAC1D,uBAAuB;AACnB,QAAO,EACH,qBAAqB,KAAK,OAAO,SAAS,OAAO,EACpD;GAER,CAAC"}
@@ -1,89 +1,45 @@
1
- import { Plugin, PluginKey } from '@tiptap/pm/state';
2
- import { isMultilineDocument } from '../../../../helpers/schema';
1
+ import { isMultilineDocument } from "../../../../helpers/schema.js";
2
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
3
+ //#region src/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.ts
3
4
  /**
4
- * A list of the allowed keys that might trigger smart typing.
5
- */
6
- const ALLOWED_KEYS = ['Enter', 'Tab'];
5
+ * A list of the allowed keys that might trigger smart typing.
6
+ */
7
+ const ALLOWED_KEYS = ["Enter", "Tab"];
7
8
  /**
8
- * The standard and task list item regex for smart typing triggers.
9
- */
9
+ * The standard and task list item regex for smart typing triggers.
10
+ */
10
11
  const REGEX_LIST_ITEM = /^( *(?:(?:\*|-)(?: \[[ x]\])?|\d+\.) )[^\n]*$/i;
11
12
  /**
12
- * A string with the minimum required spaces to properly indent list items.
13
- */
14
- const INDENT_SPACES = ' ';
13
+ * A string with the minimum required spaces to properly indent list items.
14
+ */
15
+ const INDENT_SPACES = " ";
15
16
  /**
16
- * This plugin provides a more plesant typing experience for both standard and task lists, adding
17
- * the list marker automatically when pressing the `Enter` key, and it also supports list items
18
- * indentation with the `Tab` and `Shift+Tab` keys, forward and backward, respectively.
19
- */
17
+ * This plugin provides a more plesant typing experience for both standard and task lists, adding
18
+ * the list marker automatically when pressing the `Enter` key, and it also supports list items
19
+ * indentation with the `Tab` and `Shift+Tab` keys, forward and backward, respectively.
20
+ */
20
21
  const smartLists = new Plugin({
21
- key: new PluginKey('smartLists'),
22
- props: {
23
- handleKeyDown(view, event) {
24
- const { schema } = view.state;
25
- const { selection, tr } = view.state;
26
- // Do not handle the event if not in a multiline document
27
- if (!isMultilineDocument(schema)) {
28
- return false;
29
- }
30
- // Do not handle the event if allowed keys were not pressed
31
- if (!ALLOWED_KEYS.includes(event.key)) {
32
- return false;
33
- }
34
- const match = selection.$from.nodeBefore?.text?.match(REGEX_LIST_ITEM);
35
- // Do not handle the event if a list/task item was not found
36
- if (!match) {
37
- return false;
38
- }
39
- // Insert a new list marker with `Enter`?
40
- if (event.key === 'Enter') {
41
- // If the whole match is different from the first group match, the list item is not
42
- // empty, and a new list marker is inserted; If they are equal, the list item is
43
- // empty, and the list marker is deleted
44
- if (match[0] !== match[1]) {
45
- // Attempt to parse the first group match as an ordered list item marker
46
- const orderedListItemMarkerIndex = parseInt(match[1], 10);
47
- // Increment the ordered list item marker by 1 if it's a number, otherwise
48
- // use the first group match as the list item marker
49
- const nextListItemMarker = orderedListItemMarkerIndex
50
- ? `${orderedListItemMarkerIndex + 1}. `
51
- : // Make sure the next task item marker is unchecked
52
- match[1].replace(/\[x\]/i, '[ ]');
53
- view.dispatch(tr
54
- .replaceSelectionWith(schema.node('paragraph', {}, schema.text(nextListItemMarker)))
55
- .scrollIntoView());
56
- }
57
- else {
58
- view.dispatch(tr.delete(selection.from - match[1].length, selection.to));
59
- }
60
- }
61
- // Indent the list item with `Tab` or `Shift+Tab`?
62
- else if (event.key === 'Tab') {
63
- // If the whole match is different from the first group match, the text cursor is
64
- // not at the beginning of the list item (i.e., `* |<Text>`, where the pipe is), and
65
- // the event is not handled (for now this restriction is disabled)
66
- // if (match[0] !== match[1]) {
67
- // return false
68
- // }
69
- // Indent the list item forward or backward?
70
- if (!event.shiftKey) {
71
- // Indent the list item forward
72
- view.dispatch(tr
73
- .insertText(INDENT_SPACES, selection.from - match[0].length)
74
- .scrollIntoView());
75
- }
76
- else {
77
- // Indent the list item backward if the whole match starts with a whitespace,
78
- // otherwise do nothing as the list item is already at the start of the line
79
- if (match[0].startsWith(INDENT_SPACES)) {
80
- view.dispatch(tr.delete(selection.from - match[0].length, selection.to - match[0].length + INDENT_SPACES.length));
81
- }
82
- }
83
- }
84
- // Suppress the default handling behaviour
85
- return true;
86
- },
87
- },
22
+ key: new PluginKey("smartLists"),
23
+ props: { handleKeyDown(view, event) {
24
+ const { schema } = view.state;
25
+ const { selection, tr } = view.state;
26
+ if (!isMultilineDocument(schema)) return false;
27
+ if (!ALLOWED_KEYS.includes(event.key)) return false;
28
+ const match = selection.$from.nodeBefore?.text?.match(REGEX_LIST_ITEM);
29
+ if (!match) return false;
30
+ if (event.key === "Enter") if (match[0] !== match[1]) {
31
+ const orderedListItemMarkerIndex = parseInt(match[1], 10);
32
+ const nextListItemMarker = orderedListItemMarkerIndex ? `${orderedListItemMarkerIndex + 1}. ` : match[1].replace(/\[x\]/i, "[ ]");
33
+ view.dispatch(tr.replaceSelectionWith(schema.node("paragraph", {}, schema.text(nextListItemMarker))).scrollIntoView());
34
+ } else view.dispatch(tr.delete(selection.from - match[1].length, selection.to));
35
+ else if (event.key === "Tab") {
36
+ if (!event.shiftKey) view.dispatch(tr.insertText(INDENT_SPACES, selection.from - match[0].length).scrollIntoView());
37
+ else if (match[0].startsWith(INDENT_SPACES)) view.dispatch(tr.delete(selection.from - match[0].length, selection.to - match[0].length + 4));
38
+ }
39
+ return true;
40
+ } }
88
41
  });
42
+ //#endregion
89
43
  export { smartLists };
44
+
45
+ //# sourceMappingURL=smart-lists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-lists.js","names":[],"sources":["../../../../../src/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.ts"],"sourcesContent":["import { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { isMultilineDocument } from '../../../../helpers/schema'\n\nimport type { Schema } from '@tiptap/pm/model'\nimport type { EditorView } from '@tiptap/pm/view'\n\n/**\n * A list of the allowed keys that might trigger smart typing.\n */\nconst ALLOWED_KEYS = ['Enter', 'Tab']\n\n/**\n * The standard and task list item regex for smart typing triggers.\n */\nconst REGEX_LIST_ITEM = /^( *(?:(?:\\*|-)(?: \\[[ x]\\])?|\\d+\\.) )[^\\n]*$/i\n\n/**\n * A string with the minimum required spaces to properly indent list items.\n */\nconst INDENT_SPACES = ' '\n\n/**\n * This plugin provides a more plesant typing experience for both standard and task lists, adding\n * the list marker automatically when pressing the `Enter` key, and it also supports list items\n * indentation with the `Tab` and `Shift+Tab` keys, forward and backward, respectively.\n */\nconst smartLists = new Plugin({\n key: new PluginKey('smartLists'),\n props: {\n handleKeyDown(view: EditorView, event) {\n const { schema } = view.state as { schema: Schema }\n const { selection, tr } = view.state\n\n // Do not handle the event if not in a multiline document\n if (!isMultilineDocument(schema)) {\n return false\n }\n\n // Do not handle the event if allowed keys were not pressed\n if (!ALLOWED_KEYS.includes(event.key)) {\n return false\n }\n\n const match = selection.$from.nodeBefore?.text?.match(REGEX_LIST_ITEM)\n\n // Do not handle the event if a list/task item was not found\n if (!match) {\n return false\n }\n\n // Insert a new list marker with `Enter`?\n if (event.key === 'Enter') {\n // If the whole match is different from the first group match, the list item is not\n // empty, and a new list marker is inserted; If they are equal, the list item is\n // empty, and the list marker is deleted\n if (match[0] !== match[1]) {\n // Attempt to parse the first group match as an ordered list item marker\n const orderedListItemMarkerIndex = parseInt(match[1], 10)\n\n // Increment the ordered list item marker by 1 if it's a number, otherwise\n // use the first group match as the list item marker\n const nextListItemMarker = orderedListItemMarkerIndex\n ? `${orderedListItemMarkerIndex + 1}. `\n : // Make sure the next task item marker is unchecked\n match[1].replace(/\\[x\\]/i, '[ ]')\n\n view.dispatch(\n tr\n .replaceSelectionWith(\n schema.node('paragraph', {}, schema.text(nextListItemMarker)),\n )\n .scrollIntoView(),\n )\n } else {\n view.dispatch(tr.delete(selection.from - match[1].length, selection.to))\n }\n }\n // Indent the list item with `Tab` or `Shift+Tab`?\n else if (event.key === 'Tab') {\n // If the whole match is different from the first group match, the text cursor is\n // not at the beginning of the list item (i.e., `* |<Text>`, where the pipe is), and\n // the event is not handled (for now this restriction is disabled)\n // if (match[0] !== match[1]) {\n // return false\n // }\n\n // Indent the list item forward or backward?\n if (!event.shiftKey) {\n // Indent the list item forward\n view.dispatch(\n tr\n .insertText(INDENT_SPACES, selection.from - match[0].length)\n .scrollIntoView(),\n )\n } else {\n // Indent the list item backward if the whole match starts with a whitespace,\n // otherwise do nothing as the list item is already at the start of the line\n if (match[0].startsWith(INDENT_SPACES)) {\n view.dispatch(\n tr.delete(\n selection.from - match[0].length,\n selection.to - match[0].length + INDENT_SPACES.length,\n ),\n )\n }\n }\n }\n\n // Suppress the default handling behaviour\n return true\n },\n },\n})\n\nexport { smartLists }\n"],"mappings":";;;;;;AAUA,MAAM,eAAe,CAAC,SAAS,MAAM;;;;AAKrC,MAAM,kBAAkB;;;;AAKxB,MAAM,gBAAgB;;;;;;AAOtB,MAAM,aAAa,IAAI,OAAO;CAC1B,KAAK,IAAI,UAAU,aAAa;CAChC,OAAO,EACH,cAAc,MAAkB,OAAO;EACnC,MAAM,EAAE,WAAW,KAAK;EACxB,MAAM,EAAE,WAAW,OAAO,KAAK;AAG/B,MAAI,CAAC,oBAAoB,OAAO,CAC5B,QAAO;AAIX,MAAI,CAAC,aAAa,SAAS,MAAM,IAAI,CACjC,QAAO;EAGX,MAAM,QAAQ,UAAU,MAAM,YAAY,MAAM,MAAM,gBAAgB;AAGtE,MAAI,CAAC,MACD,QAAO;AAIX,MAAI,MAAM,QAAQ,QAId,KAAI,MAAM,OAAO,MAAM,IAAI;GAEvB,MAAM,6BAA6B,SAAS,MAAM,IAAI,GAAG;GAIzD,MAAM,qBAAqB,6BACrB,GAAG,6BAA6B,EAAE,MAElC,MAAM,GAAG,QAAQ,UAAU,MAAM;AAEvC,QAAK,SACD,GACK,qBACG,OAAO,KAAK,aAAa,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,CAChE,CACA,gBAAgB,CACxB;QAED,MAAK,SAAS,GAAG,OAAO,UAAU,OAAO,MAAM,GAAG,QAAQ,UAAU,GAAG,CAAC;WAIvE,MAAM,QAAQ;OASf,CAAC,MAAM,SAEP,MAAK,SACD,GACK,WAAW,eAAe,UAAU,OAAO,MAAM,GAAG,OAAO,CAC3D,gBAAgB,CACxB;YAIG,MAAM,GAAG,WAAW,cAAc,CAClC,MAAK,SACD,GAAG,OACC,UAAU,OAAO,MAAM,GAAG,QAC1B,UAAU,KAAK,MAAM,GAAG,SAAS,EACpC,CACJ;;AAMb,SAAO;IAEd;CACJ,CAAC"}