@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.
Files changed (236) hide show
  1. package/dist/components/typist-editor.d.ts +126 -123
  2. package/dist/components/typist-editor.d.ts.map +1 -1
  3. package/dist/components/typist-editor.helper.d.ts +8 -11
  4. package/dist/components/typist-editor.helper.d.ts.map +1 -1
  5. package/dist/components/typist-editor.helper.js +21 -19
  6. package/dist/components/typist-editor.helper.js.map +1 -0
  7. package/dist/components/typist-editor.js +133 -135
  8. package/dist/components/typist-editor.js.map +1 -0
  9. package/dist/constants/common.js +9 -5
  10. package/dist/constants/common.js.map +1 -0
  11. package/dist/constants/extension-priorities.d.ts +3 -1
  12. package/dist/constants/extension-priorities.d.ts.map +1 -1
  13. package/dist/constants/extension-priorities.js +34 -30
  14. package/dist/constants/extension-priorities.js.map +1 -0
  15. package/dist/constants/regular-expressions.js +14 -10
  16. package/dist/constants/regular-expressions.js.map +1 -0
  17. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts +12 -9
  18. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts.map +1 -1
  19. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js +16 -19
  20. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js.map +1 -0
  21. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts +12 -9
  22. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -1
  23. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js +25 -28
  24. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js.map +1 -0
  25. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts +24 -22
  26. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts.map +1 -1
  27. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js +34 -36
  28. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js.map +1 -0
  29. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts +23 -20
  30. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -1
  31. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +15 -8
  32. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js.map +1 -0
  33. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js +22 -18
  34. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js.map +1 -0
  35. package/dist/extensions/core/view-event-handlers.d.ts +14 -13
  36. package/dist/extensions/core/view-event-handlers.d.ts.map +1 -1
  37. package/dist/extensions/core/view-event-handlers.js +33 -31
  38. package/dist/extensions/core/view-event-handlers.js.map +1 -0
  39. package/dist/extensions/plain-text/paste-multiline-text.js +45 -59
  40. package/dist/extensions/plain-text/paste-multiline-text.js.map +1 -0
  41. package/dist/extensions/plain-text/plain-text-document.d.ts +7 -7
  42. package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -1
  43. package/dist/extensions/plain-text/plain-text-document.js +14 -13
  44. package/dist/extensions/plain-text/plain-text-document.js.map +1 -0
  45. package/dist/extensions/plain-text/plain-text-kit.d.ts +35 -33
  46. package/dist/extensions/plain-text/plain-text-kit.d.ts.map +1 -1
  47. package/dist/extensions/plain-text/plain-text-kit.js +33 -48
  48. package/dist/extensions/plain-text/plain-text-kit.js.map +1 -0
  49. package/dist/extensions/plain-text/plain-text-paragraph.d.ts +2 -9
  50. package/dist/extensions/plain-text/plain-text-paragraph.js +11 -11
  51. package/dist/extensions/plain-text/plain-text-paragraph.js.map +1 -0
  52. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js +37 -81
  53. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js.map +1 -0
  54. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js +32 -42
  55. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js.map +1 -0
  56. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +24 -37
  57. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js.map +1 -0
  58. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js +21 -13
  59. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js.map +1 -0
  60. package/dist/extensions/rich-text/bold-and-italics.js +42 -40
  61. package/dist/extensions/rich-text/bold-and-italics.js.map +1 -0
  62. package/dist/extensions/rich-text/curvenote-codemark.js +16 -14
  63. package/dist/extensions/rich-text/curvenote-codemark.js.map +1 -0
  64. package/dist/extensions/rich-text/paste-emojis.js +20 -22
  65. package/dist/extensions/rich-text/paste-emojis.js.map +1 -0
  66. package/dist/extensions/rich-text/paste-markdown.js +46 -86
  67. package/dist/extensions/rich-text/paste-markdown.js.map +1 -0
  68. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts +10 -9
  69. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts.map +1 -1
  70. package/dist/extensions/rich-text/rich-text-bullet-list.js +42 -56
  71. package/dist/extensions/rich-text/rich-text-bullet-list.js.map +1 -0
  72. package/dist/extensions/rich-text/rich-text-code.js +34 -34
  73. package/dist/extensions/rich-text/rich-text-code.js.map +1 -0
  74. package/dist/extensions/rich-text/rich-text-document.d.ts +7 -7
  75. package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -1
  76. package/dist/extensions/rich-text/rich-text-document.js +14 -13
  77. package/dist/extensions/rich-text/rich-text-document.js.map +1 -0
  78. package/dist/extensions/rich-text/rich-text-heading.d.ts +5 -4
  79. package/dist/extensions/rich-text/rich-text-heading.d.ts.map +1 -1
  80. package/dist/extensions/rich-text/rich-text-heading.js +25 -25
  81. package/dist/extensions/rich-text/rich-text-heading.js.map +1 -0
  82. package/dist/extensions/rich-text/rich-text-image.d.ts +53 -52
  83. package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
  84. package/dist/extensions/rich-text/rich-text-image.js +88 -105
  85. package/dist/extensions/rich-text/rich-text-image.js.map +1 -0
  86. package/dist/extensions/rich-text/rich-text-kit.d.ts +127 -125
  87. package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
  88. package/dist/extensions/rich-text/rich-text-kit.js +73 -135
  89. package/dist/extensions/rich-text/rich-text-kit.js.map +1 -0
  90. package/dist/extensions/rich-text/rich-text-link.d.ts +5 -4
  91. package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
  92. package/dist/extensions/rich-text/rich-text-link.js +82 -90
  93. package/dist/extensions/rich-text/rich-text-link.js.map +1 -0
  94. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts +10 -9
  95. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts.map +1 -1
  96. package/dist/extensions/rich-text/rich-text-ordered-list.js +42 -56
  97. package/dist/extensions/rich-text/rich-text-ordered-list.js.map +1 -0
  98. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts +5 -4
  99. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts.map +1 -1
  100. package/dist/extensions/rich-text/rich-text-strikethrough.js +10 -10
  101. package/dist/extensions/rich-text/rich-text-strikethrough.js.map +1 -0
  102. package/dist/extensions/shared/copy-markdown-source.js +22 -31
  103. package/dist/extensions/shared/copy-markdown-source.js.map +1 -0
  104. package/dist/extensions/shared/paste-html-table-as-string.js +47 -60
  105. package/dist/extensions/shared/paste-html-table-as-string.js.map +1 -0
  106. package/dist/extensions/shared/paste-singleline-text.js +31 -39
  107. package/dist/extensions/shared/paste-singleline-text.js.map +1 -0
  108. package/dist/factories/create-suggestion-extension.d.ts +74 -74
  109. package/dist/factories/create-suggestion-extension.d.ts.map +1 -1
  110. package/dist/factories/create-suggestion-extension.js +139 -161
  111. package/dist/factories/create-suggestion-extension.js.map +1 -0
  112. package/dist/helpers/dom.js +9 -5
  113. package/dist/helpers/dom.js.map +1 -0
  114. package/dist/helpers/schema.d.ts +5 -3
  115. package/dist/helpers/schema.d.ts.map +1 -1
  116. package/dist/helpers/schema.js +25 -21
  117. package/dist/helpers/schema.js.map +1 -0
  118. package/dist/helpers/serializer.js +24 -28
  119. package/dist/helpers/serializer.js.map +1 -0
  120. package/dist/helpers/unified.js +24 -17
  121. package/dist/helpers/unified.js.map +1 -0
  122. package/dist/hooks/use-editor.js +50 -53
  123. package/dist/hooks/use-editor.js.map +1 -0
  124. package/dist/index.d.ts +25 -31
  125. package/dist/index.js +24 -24
  126. package/dist/serializers/html/html.d.ts +12 -10
  127. package/dist/serializers/html/html.d.ts.map +1 -1
  128. package/dist/serializers/html/html.js +67 -127
  129. package/dist/serializers/html/html.js.map +1 -0
  130. package/dist/serializers/html/plugins/rehype-code-block.js +17 -17
  131. package/dist/serializers/html/plugins/rehype-code-block.js.map +1 -0
  132. package/dist/serializers/html/plugins/rehype-image.js +20 -30
  133. package/dist/serializers/html/plugins/rehype-image.js.map +1 -0
  134. package/dist/serializers/html/plugins/rehype-suggestions.js +31 -32
  135. package/dist/serializers/html/plugins/rehype-suggestions.js.map +1 -0
  136. package/dist/serializers/html/plugins/rehype-task-list.js +31 -32
  137. package/dist/serializers/html/plugins/rehype-task-list.js.map +1 -0
  138. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts +4 -1
  139. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
  140. package/dist/serializers/html/plugins/remark-autolink-literal.js +25 -21
  141. package/dist/serializers/html/plugins/remark-autolink-literal.js.map +1 -0
  142. package/dist/serializers/html/plugins/remark-disable-constructs.js +21 -41
  143. package/dist/serializers/html/plugins/remark-disable-constructs.js.map +1 -0
  144. package/dist/serializers/html/plugins/remark-strikethrough.d.ts +5 -2
  145. package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
  146. package/dist/serializers/html/plugins/remark-strikethrough.js +25 -21
  147. package/dist/serializers/html/plugins/remark-strikethrough.js.map +1 -0
  148. package/dist/serializers/markdown/markdown.d.ts +13 -12
  149. package/dist/serializers/markdown/markdown.d.ts.map +1 -1
  150. package/dist/serializers/markdown/markdown.js +78 -154
  151. package/dist/serializers/markdown/markdown.js.map +1 -0
  152. package/dist/serializers/markdown/plugins/image.js +27 -24
  153. package/dist/serializers/markdown/plugins/image.js.map +1 -0
  154. package/dist/serializers/markdown/plugins/list-item.js +32 -37
  155. package/dist/serializers/markdown/plugins/list-item.js.map +1 -0
  156. package/dist/serializers/markdown/plugins/paragraph.js +19 -19
  157. package/dist/serializers/markdown/plugins/paragraph.js.map +1 -0
  158. package/dist/serializers/markdown/plugins/strikethrough.js +23 -19
  159. package/dist/serializers/markdown/plugins/strikethrough.js.map +1 -0
  160. package/dist/serializers/markdown/plugins/suggestion.js +21 -19
  161. package/dist/serializers/markdown/plugins/suggestion.js.map +1 -0
  162. package/dist/serializers/markdown/plugins/task-item.js +31 -35
  163. package/dist/serializers/markdown/plugins/task-item.js.map +1 -0
  164. package/dist/utilities/can-insert-node-at.d.ts +12 -5
  165. package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
  166. package/dist/utilities/can-insert-node-at.js +10 -8
  167. package/dist/utilities/can-insert-node-at.js.map +1 -0
  168. package/dist/utilities/can-insert-suggestion.d.ts +11 -5
  169. package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
  170. package/dist/utilities/can-insert-suggestion.js +15 -12
  171. package/dist/utilities/can-insert-suggestion.js.map +1 -0
  172. package/package.json +26 -13
  173. package/dist/constants/common.d.ts +0 -10
  174. package/dist/constants/common.d.ts.map +0 -1
  175. package/dist/constants/regular-expressions.d.ts +0 -18
  176. package/dist/constants/regular-expressions.d.ts.map +0 -1
  177. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts +0 -9
  178. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.d.ts.map +0 -1
  179. package/dist/extensions/plain-text/paste-multiline-text.d.ts +0 -10
  180. package/dist/extensions/plain-text/paste-multiline-text.d.ts.map +0 -1
  181. package/dist/extensions/plain-text/plain-text-paragraph.d.ts.map +0 -1
  182. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts +0 -9
  183. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.d.ts.map +0 -1
  184. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts +0 -9
  185. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.d.ts.map +0 -1
  186. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts +0 -9
  187. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +0 -1
  188. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts +0 -8
  189. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.d.ts.map +0 -1
  190. package/dist/extensions/rich-text/bold-and-italics.d.ts +0 -8
  191. package/dist/extensions/rich-text/bold-and-italics.d.ts.map +0 -1
  192. package/dist/extensions/rich-text/curvenote-codemark.d.ts +0 -11
  193. package/dist/extensions/rich-text/curvenote-codemark.d.ts.map +0 -1
  194. package/dist/extensions/rich-text/paste-emojis.d.ts +0 -9
  195. package/dist/extensions/rich-text/paste-emojis.d.ts.map +0 -1
  196. package/dist/extensions/rich-text/paste-markdown.d.ts +0 -11
  197. package/dist/extensions/rich-text/paste-markdown.d.ts.map +0 -1
  198. package/dist/extensions/rich-text/rich-text-code.d.ts +0 -17
  199. package/dist/extensions/rich-text/rich-text-code.d.ts.map +0 -1
  200. package/dist/extensions/shared/copy-markdown-source.d.ts +0 -20
  201. package/dist/extensions/shared/copy-markdown-source.d.ts.map +0 -1
  202. package/dist/extensions/shared/paste-html-table-as-string.d.ts +0 -20
  203. package/dist/extensions/shared/paste-html-table-as-string.d.ts.map +0 -1
  204. package/dist/extensions/shared/paste-singleline-text.d.ts +0 -10
  205. package/dist/extensions/shared/paste-singleline-text.d.ts.map +0 -1
  206. package/dist/helpers/dom.d.ts +0 -8
  207. package/dist/helpers/dom.d.ts.map +0 -1
  208. package/dist/helpers/serializer.d.ts +0 -21
  209. package/dist/helpers/serializer.d.ts.map +0 -1
  210. package/dist/helpers/unified.d.ts +0 -21
  211. package/dist/helpers/unified.d.ts.map +0 -1
  212. package/dist/hooks/use-editor.d.ts +0 -19
  213. package/dist/hooks/use-editor.d.ts.map +0 -1
  214. package/dist/index.d.ts.map +0 -1
  215. package/dist/serializers/html/plugins/rehype-code-block.d.ts +0 -10
  216. package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +0 -1
  217. package/dist/serializers/html/plugins/rehype-image.d.ts +0 -11
  218. package/dist/serializers/html/plugins/rehype-image.d.ts.map +0 -1
  219. package/dist/serializers/html/plugins/rehype-suggestions.d.ts +0 -10
  220. package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +0 -1
  221. package/dist/serializers/html/plugins/rehype-task-list.d.ts +0 -7
  222. package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +0 -1
  223. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts +0 -11
  224. package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +0 -1
  225. package/dist/serializers/markdown/plugins/image.d.ts +0 -12
  226. package/dist/serializers/markdown/plugins/image.d.ts.map +0 -1
  227. package/dist/serializers/markdown/plugins/list-item.d.ts +0 -14
  228. package/dist/serializers/markdown/plugins/list-item.d.ts.map +0 -1
  229. package/dist/serializers/markdown/plugins/paragraph.d.ts +0 -13
  230. package/dist/serializers/markdown/plugins/paragraph.d.ts.map +0 -1
  231. package/dist/serializers/markdown/plugins/strikethrough.d.ts +0 -13
  232. package/dist/serializers/markdown/plugins/strikethrough.d.ts.map +0 -1
  233. package/dist/serializers/markdown/plugins/suggestion.d.ts +0 -11
  234. package/dist/serializers/markdown/plugins/suggestion.d.ts.map +0 -1
  235. package/dist/serializers/markdown/plugins/task-item.d.ts +0 -14
  236. package/dist/serializers/markdown/plugins/task-item.d.ts.map +0 -1
@@ -1,49 +1,39 @@
1
- import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state';
1
+ import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
2
+ //#region src/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.ts
2
3
  /**
3
- * An object holding the acceptable wrapping symbols. The key represents the trigger character, and
4
- * the character to be added before the selection, while the value represents the character to be
5
- * added after the selection.
6
- */
4
+ * An object holding the acceptable wrapping symbols. The key represents the trigger character, and
5
+ * the character to be added before the selection, while the value represents the character to be
6
+ * added after the selection.
7
+ */
7
8
  const WRAPPING_SYMBOLS = {
8
- '*': '*',
9
- _: '_',
10
- '~': '~',
11
- '"': '"',
12
- "'": "'",
13
- '`': '`',
14
- '(': ')',
15
- '[': ']',
16
- '{': '}',
17
- '<': '>',
9
+ "*": "*",
10
+ _: "_",
11
+ "~": "~",
12
+ "\"": "\"",
13
+ "'": "'",
14
+ "`": "`",
15
+ "(": ")",
16
+ "[": "]",
17
+ "{": "}",
18
+ "<": ">"
18
19
  };
19
20
  /**
20
- * This plugin wraps a selection with matching symbols based on the typed character, wrapping the
21
- * selection with the corresponding opening and closing bracket symbols when appropriate. This
22
- * plugin does not have support for multiple selection ranges.
23
- */
21
+ * This plugin wraps a selection with matching symbols based on the typed character, wrapping the
22
+ * selection with the corresponding opening and closing bracket symbols when appropriate. This
23
+ * plugin does not have support for multiple selection ranges.
24
+ */
24
25
  const smartSelectWrap = new Plugin({
25
- key: new PluginKey('smartSelectWrap'),
26
- props: {
27
- handleTextInput(view, from, to, symbol) {
28
- const { selection, tr } = view.state;
29
- // Do not handle the event if the selection is empty
30
- if (selection.empty) {
31
- return false;
32
- }
33
- const wrappingSymbol = WRAPPING_SYMBOLS[symbol];
34
- // Do not handle the event if no wrapping symbol was typed
35
- if (wrappingSymbol === undefined) {
36
- return false;
37
- }
38
- // Insert wrapping symbols around the selected text
39
- view.dispatch(tr
40
- .insertText(symbol, from, from)
41
- .insertText(wrappingSymbol, to + 1, to + 1)
42
- .setSelection(TextSelection.create(tr.doc, from + 1, to + 1))
43
- .scrollIntoView());
44
- // Suppress the default handling behaviour
45
- return true;
46
- },
47
- },
26
+ key: new PluginKey("smartSelectWrap"),
27
+ props: { handleTextInput(view, from, to, symbol) {
28
+ const { selection, tr } = view.state;
29
+ if (selection.empty) return false;
30
+ const wrappingSymbol = WRAPPING_SYMBOLS[symbol];
31
+ if (wrappingSymbol === void 0) return false;
32
+ view.dispatch(tr.insertText(symbol, from, from).insertText(wrappingSymbol, to + 1, to + 1).setSelection(TextSelection.create(tr.doc, from + 1, to + 1)).scrollIntoView());
33
+ return true;
34
+ } }
48
35
  });
36
+ //#endregion
49
37
  export { smartSelectWrap };
38
+
39
+ //# sourceMappingURL=smart-select-wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-select-wrap.js","names":[],"sources":["../../../../../src/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.ts"],"sourcesContent":["import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state'\n\nimport type { EditorView } from '@tiptap/pm/view'\n\n/**\n * An object holding the acceptable wrapping symbols. The key represents the trigger character, and\n * the character to be added before the selection, while the value represents the character to be\n * added after the selection.\n */\nconst WRAPPING_SYMBOLS: Record<string, string> = {\n '*': '*',\n _: '_',\n '~': '~',\n '\"': '\"',\n \"'\": \"'\",\n '`': '`',\n '(': ')',\n '[': ']',\n '{': '}',\n '<': '>',\n}\n\n/**\n * This plugin wraps a selection with matching symbols based on the typed character, wrapping the\n * selection with the corresponding opening and closing bracket symbols when appropriate. This\n * plugin does not have support for multiple selection ranges.\n */\nconst smartSelectWrap = new Plugin({\n key: new PluginKey('smartSelectWrap'),\n props: {\n handleTextInput(view: EditorView, from, to, symbol) {\n const { selection, tr } = view.state\n\n // Do not handle the event if the selection is empty\n if (selection.empty) {\n return false\n }\n\n const wrappingSymbol = WRAPPING_SYMBOLS[symbol]\n\n // Do not handle the event if no wrapping symbol was typed\n if (wrappingSymbol === undefined) {\n return false\n }\n\n // Insert wrapping symbols around the selected text\n view.dispatch(\n tr\n .insertText(symbol, from, from)\n .insertText(wrappingSymbol, to + 1, to + 1)\n .setSelection(TextSelection.create(tr.doc, from + 1, to + 1))\n .scrollIntoView(),\n )\n\n // Suppress the default handling behaviour\n return true\n },\n },\n})\n\nexport { smartSelectWrap }\n"],"mappings":";;;;;;;AASA,MAAM,mBAA2C;CAC7C,KAAK;CACL,GAAG;CACH,KAAK;CACL,MAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACR;;;;;;AAOD,MAAM,kBAAkB,IAAI,OAAO;CAC/B,KAAK,IAAI,UAAU,kBAAkB;CACrC,OAAO,EACH,gBAAgB,MAAkB,MAAM,IAAI,QAAQ;EAChD,MAAM,EAAE,WAAW,OAAO,KAAK;AAG/B,MAAI,UAAU,MACV,QAAO;EAGX,MAAM,iBAAiB,iBAAiB;AAGxC,MAAI,mBAAmB,KAAA,EACnB,QAAO;AAIX,OAAK,SACD,GACK,WAAW,QAAQ,MAAM,KAAK,CAC9B,WAAW,gBAAgB,KAAK,GAAG,KAAK,EAAE,CAC1C,aAAa,cAAc,OAAO,GAAG,KAAK,OAAO,GAAG,KAAK,EAAE,CAAC,CAC5D,gBAAgB,CACxB;AAGD,SAAO;IAEd;CACJ,CAAC"}
@@ -1,43 +1,30 @@
1
- import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state';
2
- import { ClipboardDataType } from '../../../../constants/common';
3
- import { REGEX_WEB_URL } from '../../../../constants/regular-expressions';
1
+ import { REGEX_WEB_URL } from "../../../../constants/regular-expressions.js";
2
+ import { ClipboardDataType } from "../../../../constants/common.js";
3
+ import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
4
+ //#region src/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.ts
4
5
  /**
5
- * The perfect URL validation regular expression for exact Web URLs (matches a
6
- * URL from the beginning to the end without allowing for partial matches).
7
- */
6
+ * The perfect URL validation regular expression for exact Web URLs (matches a
7
+ * URL from the beginning to the end without allowing for partial matches).
8
+ */
8
9
  const REGEX_WEB_URL_EXACT = new RegExp(`^${REGEX_WEB_URL.source}$`, REGEX_WEB_URL.flags);
9
10
  /**
10
- * This plugin replaces a selection with the pasted URL using proper link syntax; unless the
11
- * selection is itself a URL, which in that case the selection will just be replaced by the pasted
12
- * URL. This plugin does not have support for multiple selection ranges.
13
- */
11
+ * This plugin replaces a selection with the pasted URL using proper link syntax; unless the
12
+ * selection is itself a URL, which in that case the selection will just be replaced by the pasted
13
+ * URL. This plugin does not have support for multiple selection ranges.
14
+ */
14
15
  const smartUrlPasting = new Plugin({
15
- key: new PluginKey('smartUrlPasting'),
16
- props: {
17
- handlePaste(view, event) {
18
- const { selection, tr } = view.state;
19
- // Do not handle the event if the selection is empty
20
- if (selection.empty) {
21
- return false;
22
- }
23
- // Do not handle the event if the selected text is already a URL
24
- if (REGEX_WEB_URL_EXACT.test(selection.$head.parent.textContent)) {
25
- return false;
26
- }
27
- const clipboardText = event.clipboardData?.getData(ClipboardDataType.Text).trim();
28
- // Do not handle the event if the clipboard text is not a URL
29
- if (!clipboardText || !REGEX_WEB_URL_EXACT.test(clipboardText)) {
30
- return false;
31
- }
32
- // Apply the Markdown link syntax to the selected and clipboard text pair
33
- view.dispatch(tr
34
- .insertText('[', selection.from, selection.from)
35
- .insertText(`](${clipboardText})`, selection.to + 1, selection.to + 1)
36
- .setSelection(TextSelection.create(tr.doc, selection.from + 1, selection.to + 1))
37
- .scrollIntoView());
38
- // Suppress the default handling behaviour
39
- return true;
40
- },
41
- },
16
+ key: new PluginKey("smartUrlPasting"),
17
+ props: { handlePaste(view, event) {
18
+ const { selection, tr } = view.state;
19
+ if (selection.empty) return false;
20
+ if (REGEX_WEB_URL_EXACT.test(selection.$head.parent.textContent)) return false;
21
+ const clipboardText = event.clipboardData?.getData(ClipboardDataType.Text).trim();
22
+ if (!clipboardText || !REGEX_WEB_URL_EXACT.test(clipboardText)) return false;
23
+ view.dispatch(tr.insertText("[", selection.from, selection.from).insertText(`](${clipboardText})`, selection.to + 1, selection.to + 1).setSelection(TextSelection.create(tr.doc, selection.from + 1, selection.to + 1)).scrollIntoView());
24
+ return true;
25
+ } }
42
26
  });
27
+ //#endregion
43
28
  export { smartUrlPasting };
29
+
30
+ //# sourceMappingURL=smart-url-pasting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-url-pasting.js","names":[],"sources":["../../../../../src/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.ts"],"sourcesContent":["import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state'\n\nimport { ClipboardDataType } from '../../../../constants/common'\nimport { REGEX_WEB_URL } from '../../../../constants/regular-expressions'\n\nimport type { EditorView } from '@tiptap/pm/view'\n\n/**\n * The perfect URL validation regular expression for exact Web URLs (matches a\n * URL from the beginning to the end without allowing for partial matches).\n */\nconst REGEX_WEB_URL_EXACT = new RegExp(`^${REGEX_WEB_URL.source}$`, REGEX_WEB_URL.flags)\n\n/**\n * This plugin replaces a selection with the pasted URL using proper link syntax; unless the\n * selection is itself a URL, which in that case the selection will just be replaced by the pasted\n * URL. This plugin does not have support for multiple selection ranges.\n */\nconst smartUrlPasting = new Plugin({\n key: new PluginKey('smartUrlPasting'),\n props: {\n handlePaste(view: EditorView, event) {\n const { selection, tr } = view.state\n\n // Do not handle the event if the selection is empty\n if (selection.empty) {\n return false\n }\n\n // Do not handle the event if the selected text is already a URL\n if (REGEX_WEB_URL_EXACT.test(selection.$head.parent.textContent)) {\n return false\n }\n\n const clipboardText = event.clipboardData?.getData(ClipboardDataType.Text).trim()\n\n // Do not handle the event if the clipboard text is not a URL\n if (!clipboardText || !REGEX_WEB_URL_EXACT.test(clipboardText)) {\n return false\n }\n\n // Apply the Markdown link syntax to the selected and clipboard text pair\n view.dispatch(\n tr\n .insertText('[', selection.from, selection.from)\n .insertText(`](${clipboardText})`, selection.to + 1, selection.to + 1)\n .setSelection(\n TextSelection.create(tr.doc, selection.from + 1, selection.to + 1),\n )\n .scrollIntoView(),\n )\n\n // Suppress the default handling behaviour\n return true\n },\n },\n})\n\nexport { smartUrlPasting }\n"],"mappings":";;;;;;;;AAWA,MAAM,sBAAsB,IAAI,OAAO,IAAI,cAAc,OAAO,IAAI,cAAc,MAAM;;;;;;AAOxF,MAAM,kBAAkB,IAAI,OAAO;CAC/B,KAAK,IAAI,UAAU,kBAAkB;CACrC,OAAO,EACH,YAAY,MAAkB,OAAO;EACjC,MAAM,EAAE,WAAW,OAAO,KAAK;AAG/B,MAAI,UAAU,MACV,QAAO;AAIX,MAAI,oBAAoB,KAAK,UAAU,MAAM,OAAO,YAAY,CAC5D,QAAO;EAGX,MAAM,gBAAgB,MAAM,eAAe,QAAQ,kBAAkB,KAAK,CAAC,MAAM;AAGjF,MAAI,CAAC,iBAAiB,CAAC,oBAAoB,KAAK,cAAc,CAC1D,QAAO;AAIX,OAAK,SACD,GACK,WAAW,KAAK,UAAU,MAAM,UAAU,KAAK,CAC/C,WAAW,KAAK,cAAc,IAAI,UAAU,KAAK,GAAG,UAAU,KAAK,EAAE,CACrE,aACG,cAAc,OAAO,GAAG,KAAK,UAAU,OAAO,GAAG,UAAU,KAAK,EAAE,CACrE,CACA,gBAAgB,CACxB;AAGD,SAAO;IAEd;CACJ,CAAC"}
@@ -1,17 +1,25 @@
1
- import { Extension } from '@tiptap/core';
2
- import { SMART_MARKDOWN_TYPING_PRIORITY } from '../../../constants/extension-priorities';
3
- import { smartLists } from './plugins/smart-lists';
4
- import { smartSelectWrap } from './plugins/smart-select-wrap';
5
- import { smartUrlPasting } from './plugins/smart-url-pasting';
1
+ import "../../../constants/extension-priorities.js";
2
+ import { smartLists } from "./plugins/smart-lists.js";
3
+ import { smartSelectWrap } from "./plugins/smart-select-wrap.js";
4
+ import { smartUrlPasting } from "./plugins/smart-url-pasting.js";
5
+ import { Extension } from "@tiptap/core";
6
+ //#region src/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.ts
6
7
  /**
7
- * The `SmartMarkdownTyping` extension is a collection of ProseMirror plugins that attempts to mimic
8
- * a smart GitHub like typing experience, and is only meant to be used with a plain-text editor.
9
- */
8
+ * The `SmartMarkdownTyping` extension is a collection of ProseMirror plugins that attempts to mimic
9
+ * a smart GitHub like typing experience, and is only meant to be used with a plain-text editor.
10
+ */
10
11
  const SmartMarkdownTyping = Extension.create({
11
- name: 'smartMarkdownTyping',
12
- priority: SMART_MARKDOWN_TYPING_PRIORITY,
13
- addProseMirrorPlugins() {
14
- return [smartLists, smartSelectWrap, smartUrlPasting];
15
- },
12
+ name: "smartMarkdownTyping",
13
+ priority: 110,
14
+ addProseMirrorPlugins() {
15
+ return [
16
+ smartLists,
17
+ smartSelectWrap,
18
+ smartUrlPasting
19
+ ];
20
+ }
16
21
  });
22
+ //#endregion
17
23
  export { SmartMarkdownTyping };
24
+
25
+ //# sourceMappingURL=smart-markdown-typing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-markdown-typing.js","names":[],"sources":["../../../../src/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\n\nimport { SMART_MARKDOWN_TYPING_PRIORITY } from '../../../constants/extension-priorities'\n\nimport { smartLists } from './plugins/smart-lists'\nimport { smartSelectWrap } from './plugins/smart-select-wrap'\nimport { smartUrlPasting } from './plugins/smart-url-pasting'\n\n/**\n * The `SmartMarkdownTyping` extension is a collection of ProseMirror plugins that attempts to mimic\n * a smart GitHub like typing experience, and is only meant to be used with a plain-text editor.\n */\nconst SmartMarkdownTyping = Extension.create({\n name: 'smartMarkdownTyping',\n priority: SMART_MARKDOWN_TYPING_PRIORITY,\n addProseMirrorPlugins() {\n return [smartLists, smartSelectWrap, smartUrlPasting]\n },\n})\n\nexport { SmartMarkdownTyping }\n"],"mappings":";;;;;;;;;;AAYA,MAAM,sBAAsB,UAAU,OAAO;CACzC,MAAM;CACN,UAAA;CACA,wBAAwB;AACpB,SAAO;GAAC;GAAY;GAAiB;GAAgB;;CAE5D,CAAC"}
@@ -1,52 +1,54 @@
1
- import { Mark, markInputRule, markPasteRule } from '@tiptap/core';
1
+ import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
2
+ //#region src/extensions/rich-text/bold-and-italics.ts
2
3
  /**
3
- * The "star" (i.e. `***`) input regex for Markdown text marked with bold and italics.
4
- */
4
+ * The "star" (i.e. `***`) input regex for Markdown text marked with bold and italics.
5
+ */
5
6
  const starInputRegex = /(?:^|\s)(\*\*\*(?!\s+\*\*\*)((?:[^*]+))\*\*\*(?!\s+\*\*\*))$/;
6
7
  /**
7
- * The "star" (i.e. `***`) paste regex for Markdown text marked with bold and italics.
8
- */
8
+ * The "star" (i.e. `***`) paste regex for Markdown text marked with bold and italics.
9
+ */
9
10
  const starPasteRegex = /(?:^|\s)(\*\*\*(?!\s+\*\*\*)((?:[^*]+))\*\*\*(?!\s+\*\*\*))/g;
10
11
  /**
11
- * The "underscore" (i.e. `___`) input regex for Markdown text marked with bold and italics.
12
- */
12
+ * The "underscore" (i.e. `___`) input regex for Markdown text marked with bold and italics.
13
+ */
13
14
  const underscoreInputRegex = /(?:^|\s)(___(?!\s+___)((?:[^_]+))___(?!\s+___))$/;
14
15
  /**
15
- * The "underscore" (i.e. `___`) paste regex for Markdown text marked with bold and italics.
16
- */
16
+ * The "underscore" (i.e. `___`) paste regex for Markdown text marked with bold and italics.
17
+ */
17
18
  const underscorePasteRegex = /(?:^|\s)(___(?!\s+___)((?:[^_]+))___(?!\s+___))/g;
18
19
  /**
19
- * The `BoldAndItalics` extension adds the ability to use the `***` and `___` Markdown shortcuts
20
- * when typing and pasting into the editor.
21
- */
20
+ * The `BoldAndItalics` extension adds the ability to use the `***` and `___` Markdown shortcuts
21
+ * when typing and pasting into the editor.
22
+ */
22
23
  const BoldAndItalics = Mark.create({
23
- name: 'boldAndItalics',
24
- renderHTML({ HTMLAttributes }) {
25
- return ['strong', ['em', HTMLAttributes, 0]];
26
- },
27
- addInputRules() {
28
- return [
29
- markInputRule({
30
- find: starInputRegex,
31
- type: this.type,
32
- }),
33
- markInputRule({
34
- find: underscoreInputRegex,
35
- type: this.type,
36
- }),
37
- ];
38
- },
39
- addPasteRules() {
40
- return [
41
- markPasteRule({
42
- find: starPasteRegex,
43
- type: this.type,
44
- }),
45
- markPasteRule({
46
- find: underscorePasteRegex,
47
- type: this.type,
48
- }),
49
- ];
50
- },
24
+ name: "boldAndItalics",
25
+ renderHTML({ HTMLAttributes }) {
26
+ return ["strong", [
27
+ "em",
28
+ HTMLAttributes,
29
+ 0
30
+ ]];
31
+ },
32
+ addInputRules() {
33
+ return [markInputRule({
34
+ find: starInputRegex,
35
+ type: this.type
36
+ }), markInputRule({
37
+ find: underscoreInputRegex,
38
+ type: this.type
39
+ })];
40
+ },
41
+ addPasteRules() {
42
+ return [markPasteRule({
43
+ find: starPasteRegex,
44
+ type: this.type
45
+ }), markPasteRule({
46
+ find: underscorePasteRegex,
47
+ type: this.type
48
+ })];
49
+ }
51
50
  });
51
+ //#endregion
52
52
  export { BoldAndItalics };
53
+
54
+ //# sourceMappingURL=bold-and-italics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bold-and-italics.js","names":[],"sources":["../../../src/extensions/rich-text/bold-and-italics.ts"],"sourcesContent":["import { Mark, markInputRule, markPasteRule } from '@tiptap/core'\n\n/**\n * The \"star\" (i.e. `***`) input regex for Markdown text marked with bold and italics.\n */\nconst starInputRegex = /(?:^|\\s)(\\*\\*\\*(?!\\s+\\*\\*\\*)((?:[^*]+))\\*\\*\\*(?!\\s+\\*\\*\\*))$/\n\n/**\n * The \"star\" (i.e. `***`) paste regex for Markdown text marked with bold and italics.\n */\nconst starPasteRegex = /(?:^|\\s)(\\*\\*\\*(?!\\s+\\*\\*\\*)((?:[^*]+))\\*\\*\\*(?!\\s+\\*\\*\\*))/g\n\n/**\n * The \"underscore\" (i.e. `___`) input regex for Markdown text marked with bold and italics.\n */\nconst underscoreInputRegex = /(?:^|\\s)(___(?!\\s+___)((?:[^_]+))___(?!\\s+___))$/\n\n/**\n * The \"underscore\" (i.e. `___`) paste regex for Markdown text marked with bold and italics.\n */\nconst underscorePasteRegex = /(?:^|\\s)(___(?!\\s+___)((?:[^_]+))___(?!\\s+___))/g\n\n/**\n * The `BoldAndItalics` extension adds the ability to use the `***` and `___` Markdown shortcuts\n * when typing and pasting into the editor.\n */\nconst BoldAndItalics = Mark.create({\n name: 'boldAndItalics',\n renderHTML({ HTMLAttributes }) {\n return ['strong', ['em', HTMLAttributes, 0]]\n },\n addInputRules() {\n return [\n markInputRule({\n find: starInputRegex,\n type: this.type,\n }),\n markInputRule({\n find: underscoreInputRegex,\n type: this.type,\n }),\n ]\n },\n addPasteRules() {\n return [\n markPasteRule({\n find: starPasteRegex,\n type: this.type,\n }),\n markPasteRule({\n find: underscorePasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n\nexport { BoldAndItalics }\n"],"mappings":";;;;;AAKA,MAAM,iBAAiB;;;;AAKvB,MAAM,iBAAiB;;;;AAKvB,MAAM,uBAAuB;;;;AAK7B,MAAM,uBAAuB;;;;;AAM7B,MAAM,iBAAiB,KAAK,OAAO;CAC/B,MAAM;CACN,WAAW,EAAE,kBAAkB;AAC3B,SAAO,CAAC,UAAU;GAAC;GAAM;GAAgB;GAAE,CAAC;;CAEhD,gBAAgB;AACZ,SAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,EACF,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,CACL;;CAEL,gBAAgB;AACZ,SAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,EACF,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,CACL;;CAER,CAAC"}
@@ -1,18 +1,20 @@
1
- import { Extension } from '@tiptap/core';
2
- import codemark from 'prosemirror-codemark';
1
+ import { Extension } from "@tiptap/core";
2
+ import codemark from "prosemirror-codemark";
3
+ //#region src/extensions/rich-text/curvenote-codemark.ts
3
4
  /**
4
- * The `CurvenoteCodemark` extension adds a plugin for ProseMirror that makes it easier to handle,
5
- * and navigate inline code marks. The plugin creates a fake cursor (if necessary) to show if the
6
- * next character to be typed will or will not be inside the inline code mark.
7
- *
8
- * @see https://github.com/curvenote/prosemirror-codemark
9
- */
5
+ * The `CurvenoteCodemark` extension adds a plugin for ProseMirror that makes it easier to handle,
6
+ * and navigate inline code marks. The plugin creates a fake cursor (if necessary) to show if the
7
+ * next character to be typed will or will not be inside the inline code mark.
8
+ *
9
+ * @see https://github.com/curvenote/prosemirror-codemark
10
+ */
10
11
  const CurvenoteCodemark = Extension.create({
11
- name: 'curvenoteCodemark',
12
- addProseMirrorPlugins() {
13
- return codemark({
14
- markType: this.editor.schema.marks.code,
15
- });
16
- },
12
+ name: "curvenoteCodemark",
13
+ addProseMirrorPlugins() {
14
+ return codemark({ markType: this.editor.schema.marks.code });
15
+ }
17
16
  });
17
+ //#endregion
18
18
  export { CurvenoteCodemark };
19
+
20
+ //# sourceMappingURL=curvenote-codemark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curvenote-codemark.js","names":[],"sources":["../../../src/extensions/rich-text/curvenote-codemark.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport codemark from 'prosemirror-codemark'\n\n/**\n * The `CurvenoteCodemark` extension adds a plugin for ProseMirror that makes it easier to handle,\n * and navigate inline code marks. The plugin creates a fake cursor (if necessary) to show if the\n * next character to be typed will or will not be inside the inline code mark.\n *\n * @see https://github.com/curvenote/prosemirror-codemark\n */\nconst CurvenoteCodemark = Extension.create({\n name: 'curvenoteCodemark',\n addProseMirrorPlugins() {\n return codemark({\n markType: this.editor.schema.marks.code,\n })\n },\n})\n\nexport { CurvenoteCodemark }\n"],"mappings":";;;;;;;;;;AAUA,MAAM,oBAAoB,UAAU,OAAO;CACvC,MAAM;CACN,wBAAwB;AACpB,SAAO,SAAS,EACZ,UAAU,KAAK,OAAO,OAAO,MAAM,MACtC,CAAC;;CAET,CAAC"}
@@ -1,28 +1,26 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import emojiRegex from 'emoji-regex';
4
- // Regular expression to match all emoji symbols and sequences (including textual representations)
1
+ import { Extension } from "@tiptap/core";
2
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
3
+ import emojiRegex from "emoji-regex";
4
+ //#region src/extensions/rich-text/paste-emojis.ts
5
5
  const baseEmojiRegExp = emojiRegex();
6
- // Regular expression to match `<img>` tags with emoji unicode characters in the `alt` attribute
7
6
  const imgWithEmojiRegExp = new RegExp(`<img[^>]+alt="(${baseEmojiRegExp.source})"[^>]+/?>`, baseEmojiRegExp.flags);
8
7
  /**
9
- * The `PasteEmojis` extension adds the ability to paste HTML image emojis as unicode characters
10
- * into the editor, ignoring the HTML image source. This extension works by replacing all `<img>`
11
- * tags with the emoji unicode character, if one is found in the `alt` attribute.
12
- */
8
+ * The `PasteEmojis` extension adds the ability to paste HTML image emojis as unicode characters
9
+ * into the editor, ignoring the HTML image source. This extension works by replacing all `<img>`
10
+ * tags with the emoji unicode character, if one is found in the `alt` attribute.
11
+ */
13
12
  const PasteEmojis = Extension.create({
14
- name: 'pasteEmojis',
15
- addProseMirrorPlugins() {
16
- return [
17
- new Plugin({
18
- key: new PluginKey('pasteEmojis'),
19
- props: {
20
- transformPastedHTML(html) {
21
- return html.replace(imgWithEmojiRegExp, (_, alt) => alt);
22
- },
23
- },
24
- }),
25
- ];
26
- },
13
+ name: "pasteEmojis",
14
+ addProseMirrorPlugins() {
15
+ return [new Plugin({
16
+ key: new PluginKey("pasteEmojis"),
17
+ props: { transformPastedHTML(html) {
18
+ return html.replace(imgWithEmojiRegExp, (_, alt) => alt);
19
+ } }
20
+ })];
21
+ }
27
22
  });
23
+ //#endregion
28
24
  export { PasteEmojis };
25
+
26
+ //# sourceMappingURL=paste-emojis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-emojis.js","names":[],"sources":["../../../src/extensions/rich-text/paste-emojis.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport emojiRegex from 'emoji-regex'\n\n// Regular expression to match all emoji symbols and sequences (including textual representations)\nconst baseEmojiRegExp = emojiRegex()\n\n// Regular expression to match `<img>` tags with emoji unicode characters in the `alt` attribute\nconst imgWithEmojiRegExp = new RegExp(\n `<img[^>]+alt=\"(${baseEmojiRegExp.source})\"[^>]+/?>`,\n baseEmojiRegExp.flags,\n)\n\n/**\n * The `PasteEmojis` extension adds the ability to paste HTML image emojis as unicode characters\n * into the editor, ignoring the HTML image source. This extension works by replacing all `<img>`\n * tags with the emoji unicode character, if one is found in the `alt` attribute.\n */\nconst PasteEmojis = Extension.create({\n name: 'pasteEmojis',\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('pasteEmojis'),\n props: {\n transformPastedHTML(html) {\n return html.replace(imgWithEmojiRegExp, (_, alt: string) => alt)\n },\n },\n }),\n ]\n },\n})\n\nexport { PasteEmojis }\n"],"mappings":";;;;AAKA,MAAM,kBAAkB,YAAY;AAGpC,MAAM,qBAAqB,IAAI,OAC3B,kBAAkB,gBAAgB,OAAO,aACzC,gBAAgB,MACnB;;;;;;AAOD,MAAM,cAAc,UAAU,OAAO;CACjC,MAAM;CACN,wBAAwB;AACpB,SAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,cAAc;GACjC,OAAO,EACH,oBAAoB,MAAM;AACtB,WAAO,KAAK,QAAQ,qBAAqB,GAAG,QAAgB,IAAI;MAEvE;GACJ,CAAC,CACL;;CAER,CAAC"}
@@ -1,90 +1,50 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Fragment, Slice } from '@tiptap/pm/model';
3
- import { Plugin, PluginKey } from '@tiptap/pm/state';
4
- import * as linkify from 'linkifyjs';
5
- import { ClipboardDataType } from '../../constants/common';
6
- import { PASTE_MARKDOWN_EXTENSION_PRIORITY } from '../../constants/extension-priorities';
7
- import { REGEX_PUNCTUATION } from '../../constants/regular-expressions';
1
+ import { PASTE_MARKDOWN_EXTENSION_PRIORITY } from "../../constants/extension-priorities.js";
2
+ import { REGEX_PUNCTUATION } from "../../constants/regular-expressions.js";
3
+ import { ClipboardDataType } from "../../constants/common.js";
4
+ import { Extension } from "@tiptap/core";
5
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
6
+ import { Fragment, Slice } from "@tiptap/pm/model";
7
+ import * as linkify from "linkifyjs";
8
+ //#region src/extensions/rich-text/paste-markdown.ts
8
9
  /**
9
- * The `PasteMarkdown` extension adds the ability to paste Markdown as HTML into the editor,
10
- * providing full rich-text support to the pasted content. The pasting behavior was inspired from
11
- * the GitLab implementation, and adapted to our requirements.
12
- *
13
- * @see https://gitlab.com/gitlab-org/gitlab/-/blob/v14.10.0-ee/app/assets/javascripts/content_editor/extensions/paste_markdown.js
14
- */
10
+ * The `PasteMarkdown` extension adds the ability to paste Markdown as HTML into the editor,
11
+ * providing full rich-text support to the pasted content. The pasting behavior was inspired from
12
+ * the GitLab implementation, and adapted to our requirements.
13
+ *
14
+ * @see https://gitlab.com/gitlab-org/gitlab/-/blob/v14.10.0-ee/app/assets/javascripts/content_editor/extensions/paste_markdown.js
15
+ */
15
16
  const PasteMarkdown = Extension.create({
16
- name: 'pasteMarkdown',
17
- priority: PASTE_MARKDOWN_EXTENSION_PRIORITY,
18
- addProseMirrorPlugins() {
19
- const { editor } = this;
20
- return [
21
- new Plugin({
22
- key: new PluginKey('pasteMarkdown'),
23
- props: {
24
- clipboardTextParser(text) {
25
- // Override the default parser behavior of splitting text into lines (which
26
- // does not match the CommonMark spec for handling break lines), and instead
27
- // return a document slice with a single text node containing the whole
28
- // clipboard text, so that we can rely on the slice on `handlePaste` below)
29
- return Slice.maxOpen(Fragment.from(editor.schema.text(text)));
30
- },
31
- handlePaste(_, event, slice) {
32
- const isInsideCodeBlockNode = editor.state.selection.$from.parent.type.name === 'codeBlock';
33
- // The clipboard contains text if the slice content size is greater than
34
- // zero, otherwise it contains other data types (like files or images)
35
- const clipboardContainsText = Boolean(slice.content.size);
36
- // Do not handle the paste event if the user is pasting inside a code block
37
- // or if the clipboard does not contain text
38
- if (isInsideCodeBlockNode || !clipboardContainsText) {
39
- return false;
40
- }
41
- // Get the clipboard text from the slice content instead of getting it from
42
- // the clipboard data because the pasted content could have already been
43
- // transformed by other ProseMirror plugins
44
- const textContent = slice.content.textBetween(0, slice.content.size, '\n');
45
- // Do not handle the paste event if the clipboard text is only a link (in
46
- // this case we want the built-in handlers in Tiptap to handle the event)
47
- if (linkify.test(textContent)) {
48
- return false;
49
- }
50
- const clipboardContainsHTML = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.HTML));
51
- // Unfortunately, the VS Code clipboard data type is not supported by
52
- // Firefox or Safari, which means that copy/paste experience from VS Code
53
- // into the editor with either of those browsers is subpar:
54
- // * The Markdown syntax is not fully converted to rich-text
55
- // * Code is not detected nor converted to a code-block
56
- const clipboardContainsVSCodeMetadata = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.VSCode));
57
- const clipboardContainsHTMLFromUnknownSource = clipboardContainsHTML && !clipboardContainsVSCodeMetadata;
58
- const vsCodeClipboardMetadata = clipboardContainsVSCodeMetadata
59
- ? JSON.parse(event.clipboardData?.getData(ClipboardDataType.VSCode) ||
60
- '{}')
61
- : {};
62
- const clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown = clipboardContainsVSCodeMetadata &&
63
- // If `mode` from the VS Code metadata is `null` it probably means that
64
- // the user has the VS Code `editor.copyWithSyntaxHighlighting` setting
65
- // set to `false`, thus returning plain-text
66
- vsCodeClipboardMetadata.mode !== null &&
67
- vsCodeClipboardMetadata.mode !== 'markdown';
68
- // Do not handle the paste event if the clipboard contains HTML from an
69
- // unknown source (e.g., Google Drive, Dropbox Paper, etc.) or from VS Code
70
- // that it's NOT plain-text or Markdown (e.g., Python, TypeScript, etc.)
71
- if (clipboardContainsHTMLFromUnknownSource ||
72
- clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown) {
73
- return false;
74
- }
75
- // Escape all backslash characters that precede any punctuation marks, to
76
- // prevent the backslash itself from being interpreted as an escape sequence
77
- // for the subsequent character.
78
- const escapedTextContent = textContent.replace(new RegExp(`(\\\\${REGEX_PUNCTUATION.source})`, 'g'), '\\$1');
79
- // Send the clipboard text through the HTML serializer to convert potential
80
- // Markdown into HTML, and then insert it into the editor
81
- editor.commands.insertMarkdownContent(escapedTextContent);
82
- // Suppress the default handling behaviour
83
- return true;
84
- },
85
- },
86
- }),
87
- ];
88
- },
17
+ name: "pasteMarkdown",
18
+ priority: PASTE_MARKDOWN_EXTENSION_PRIORITY,
19
+ addProseMirrorPlugins() {
20
+ const { editor } = this;
21
+ return [new Plugin({
22
+ key: new PluginKey("pasteMarkdown"),
23
+ props: {
24
+ clipboardTextParser(text) {
25
+ return Slice.maxOpen(Fragment.from(editor.schema.text(text)));
26
+ },
27
+ handlePaste(_, event, slice) {
28
+ const isInsideCodeBlockNode = editor.state.selection.$from.parent.type.name === "codeBlock";
29
+ const clipboardContainsText = Boolean(slice.content.size);
30
+ if (isInsideCodeBlockNode || !clipboardContainsText) return false;
31
+ const textContent = slice.content.textBetween(0, slice.content.size, "\n");
32
+ if (linkify.test(textContent)) return false;
33
+ const clipboardContainsHTML = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.HTML));
34
+ const clipboardContainsVSCodeMetadata = Boolean(event.clipboardData?.types.some((type) => type === ClipboardDataType.VSCode));
35
+ const clipboardContainsHTMLFromUnknownSource = clipboardContainsHTML && !clipboardContainsVSCodeMetadata;
36
+ const vsCodeClipboardMetadata = clipboardContainsVSCodeMetadata ? JSON.parse(event.clipboardData?.getData(ClipboardDataType.VSCode) || "{}") : {};
37
+ const clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown = clipboardContainsVSCodeMetadata && vsCodeClipboardMetadata.mode !== null && vsCodeClipboardMetadata.mode !== "markdown";
38
+ if (clipboardContainsHTMLFromUnknownSource || clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown) return false;
39
+ const escapedTextContent = textContent.replace(new RegExp(`(\\\\${REGEX_PUNCTUATION.source})`, "g"), "\\$1");
40
+ editor.commands.insertMarkdownContent(escapedTextContent);
41
+ return true;
42
+ }
43
+ }
44
+ })];
45
+ }
89
46
  });
47
+ //#endregion
90
48
  export { PasteMarkdown };
49
+
50
+ //# sourceMappingURL=paste-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-markdown.js","names":[],"sources":["../../../src/extensions/rich-text/paste-markdown.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Fragment, Slice } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport * as linkify from 'linkifyjs'\n\nimport { ClipboardDataType } from '../../constants/common'\nimport { PASTE_MARKDOWN_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\nimport { REGEX_PUNCTUATION } from '../../constants/regular-expressions'\n\n/**\n * A partial type for the the clipboard metadata coming from VS Code.\n *\n * @see https://github.com/microsoft/vscode/blob/1.66.2/src/vs/editor/browser/controller/textAreaInput.ts\n */\ntype VSCodeClipboardMetadata = {\n mode?: string\n}\n\n/**\n * The `PasteMarkdown` extension adds the ability to paste Markdown as HTML into the editor,\n * providing full rich-text support to the pasted content. The pasting behavior was inspired from\n * the GitLab implementation, and adapted to our requirements.\n *\n * @see https://gitlab.com/gitlab-org/gitlab/-/blob/v14.10.0-ee/app/assets/javascripts/content_editor/extensions/paste_markdown.js\n */\nconst PasteMarkdown = Extension.create({\n name: 'pasteMarkdown',\n priority: PASTE_MARKDOWN_EXTENSION_PRIORITY,\n addProseMirrorPlugins() {\n const { editor } = this\n\n return [\n new Plugin({\n key: new PluginKey('pasteMarkdown'),\n props: {\n clipboardTextParser(text) {\n // Override the default parser behavior of splitting text into lines (which\n // does not match the CommonMark spec for handling break lines), and instead\n // return a document slice with a single text node containing the whole\n // clipboard text, so that we can rely on the slice on `handlePaste` below)\n return Slice.maxOpen(Fragment.from(editor.schema.text(text)))\n },\n handlePaste(_, event, slice) {\n const isInsideCodeBlockNode =\n editor.state.selection.$from.parent.type.name === 'codeBlock'\n\n // The clipboard contains text if the slice content size is greater than\n // zero, otherwise it contains other data types (like files or images)\n const clipboardContainsText = Boolean(slice.content.size)\n\n // Do not handle the paste event if the user is pasting inside a code block\n // or if the clipboard does not contain text\n if (isInsideCodeBlockNode || !clipboardContainsText) {\n return false\n }\n\n // Get the clipboard text from the slice content instead of getting it from\n // the clipboard data because the pasted content could have already been\n // transformed by other ProseMirror plugins\n const textContent = slice.content.textBetween(0, slice.content.size, '\\n')\n\n // Do not handle the paste event if the clipboard text is only a link (in\n // this case we want the built-in handlers in Tiptap to handle the event)\n if (linkify.test(textContent)) {\n return false\n }\n\n const clipboardContainsHTML = Boolean(\n event.clipboardData?.types.some(\n (type) => type === ClipboardDataType.HTML,\n ),\n )\n\n // Unfortunately, the VS Code clipboard data type is not supported by\n // Firefox or Safari, which means that copy/paste experience from VS Code\n // into the editor with either of those browsers is subpar:\n // * The Markdown syntax is not fully converted to rich-text\n // * Code is not detected nor converted to a code-block\n const clipboardContainsVSCodeMetadata = Boolean(\n event.clipboardData?.types.some(\n (type) => type === ClipboardDataType.VSCode,\n ),\n )\n\n const clipboardContainsHTMLFromUnknownSource =\n clipboardContainsHTML && !clipboardContainsVSCodeMetadata\n\n const vsCodeClipboardMetadata: VSCodeClipboardMetadata =\n clipboardContainsVSCodeMetadata\n ? (JSON.parse(\n event.clipboardData?.getData(ClipboardDataType.VSCode) ||\n '{}',\n ) as VSCodeClipboardMetadata)\n : {}\n\n const clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown =\n clipboardContainsVSCodeMetadata &&\n // If `mode` from the VS Code metadata is `null` it probably means that\n // the user has the VS Code `editor.copyWithSyntaxHighlighting` setting\n // set to `false`, thus returning plain-text\n vsCodeClipboardMetadata.mode !== null &&\n vsCodeClipboardMetadata.mode !== 'markdown'\n\n // Do not handle the paste event if the clipboard contains HTML from an\n // unknown source (e.g., Google Drive, Dropbox Paper, etc.) or from VS Code\n // that it's NOT plain-text or Markdown (e.g., Python, TypeScript, etc.)\n if (\n clipboardContainsHTMLFromUnknownSource ||\n clipboardContainsHTMLFromVSCodeOtherThanTextOrMarkdown\n ) {\n return false\n }\n\n // Escape all backslash characters that precede any punctuation marks, to\n // prevent the backslash itself from being interpreted as an escape sequence\n // for the subsequent character.\n const escapedTextContent = textContent.replace(\n new RegExp(`(\\\\\\\\${REGEX_PUNCTUATION.source})`, 'g'),\n '\\\\$1',\n )\n\n // Send the clipboard text through the HTML serializer to convert potential\n // Markdown into HTML, and then insert it into the editor\n editor.commands.insertMarkdownContent(escapedTextContent)\n\n // Suppress the default handling behaviour\n return true\n },\n },\n }),\n ]\n },\n})\n\nexport { PasteMarkdown }\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAM,gBAAgB,UAAU,OAAO;CACnC,MAAM;CACN,UAAU;CACV,wBAAwB;EACpB,MAAM,EAAE,WAAW;AAEnB,SAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,gBAAgB;GACnC,OAAO;IACH,oBAAoB,MAAM;AAKtB,YAAO,MAAM,QAAQ,SAAS,KAAK,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC;;IAEjE,YAAY,GAAG,OAAO,OAAO;KACzB,MAAM,wBACF,OAAO,MAAM,UAAU,MAAM,OAAO,KAAK,SAAS;KAItD,MAAM,wBAAwB,QAAQ,MAAM,QAAQ,KAAK;AAIzD,SAAI,yBAAyB,CAAC,sBAC1B,QAAO;KAMX,MAAM,cAAc,MAAM,QAAQ,YAAY,GAAG,MAAM,QAAQ,MAAM,KAAK;AAI1E,SAAI,QAAQ,KAAK,YAAY,CACzB,QAAO;KAGX,MAAM,wBAAwB,QAC1B,MAAM,eAAe,MAAM,MACtB,SAAS,SAAS,kBAAkB,KACxC,CACJ;KAOD,MAAM,kCAAkC,QACpC,MAAM,eAAe,MAAM,MACtB,SAAS,SAAS,kBAAkB,OACxC,CACJ;KAED,MAAM,yCACF,yBAAyB,CAAC;KAE9B,MAAM,0BACF,kCACO,KAAK,MACF,MAAM,eAAe,QAAQ,kBAAkB,OAAO,IAClD,KACP,GACD,EAAE;KAEZ,MAAM,yDACF,mCAIA,wBAAwB,SAAS,QACjC,wBAAwB,SAAS;AAKrC,SACI,0CACA,uDAEA,QAAO;KAMX,MAAM,qBAAqB,YAAY,QACnC,IAAI,OAAO,QAAQ,kBAAkB,OAAO,IAAI,IAAI,EACpD,OACH;AAID,YAAO,SAAS,sBAAsB,mBAAmB;AAGzD,YAAO;;IAEd;GACJ,CAAC,CACL;;CAER,CAAC"}
@@ -1,20 +1,21 @@
1
- import type { BulletListOptions } from '@tiptap/extension-bullet-list';
1
+ import { BulletListOptions } from "@tiptap/extension-bullet-list";
2
+
3
+ //#region src/extensions/rich-text/rich-text-bullet-list.d.ts
2
4
  /**
3
5
  * The options available to customize the `RichTextBulletList` extension.
4
6
  */
5
7
  type RichTextBulletListOptions = {
6
- /**
7
- * Replace hard breaks in the selection with paragraphs before toggling the selection into a
8
- * bullet list. By default, hard breaks are not replaced.
9
- */
10
- smartToggle: boolean;
8
+ /**
9
+ * Replace hard breaks in the selection with paragraphs before toggling the selection into a
10
+ * bullet list. By default, hard breaks are not replaced.
11
+ */
12
+ smartToggle: boolean;
11
13
  } & BulletListOptions;
12
14
  /**
13
15
  * Custom extension that extends the built-in `BulletList` extension to add an option for smart
14
16
  * toggling, which takes into account hard breaks in the selection, and converts them into
15
17
  * paragraphs before toggling the selection into a bullet list.
16
18
  */
17
- declare const RichTextBulletList: import("@tiptap/core").Node<RichTextBulletListOptions, any>;
18
- export { RichTextBulletList };
19
- export type { RichTextBulletListOptions };
19
+ //#endregion
20
+ export { type RichTextBulletListOptions };
20
21
  //# sourceMappingURL=rich-text-bullet-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-bullet-list.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-bullet-list.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEtE;;GAEG;AACH,KAAK,yBAAyB,GAAG;IAC7B;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAA;CACvB,GAAG,iBAAiB,CAAA;AAErB;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,6DA+DtB,CAAA;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAE7B,YAAY,EAAE,yBAAyB,EAAE,CAAA"}
1
+ {"version":3,"file":"rich-text-bullet-list.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-bullet-list.ts"],"mappings":";;;;;;KAUK,yBAAA;EAAyB;;;;EAK1B,WAAA;AAAA,IACA,iBAAA"}