@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-ordered-list.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-ordered-list.ts"],"sourcesContent":["import { ListItem } from '@tiptap/extension-list-item'\nimport { OrderedList } from '@tiptap/extension-ordered-list'\nimport { TextStyle } from '@tiptap/extension-text-style'\nimport { Fragment, Slice } from '@tiptap/pm/model'\n\nimport type { OrderedListOptions } from '@tiptap/extension-ordered-list'\n\n/**\n * The options available to customize the `RichTextOrderedList` extension.\n */\ntype RichTextOrderedListOptions = {\n /**\n * Replace hard breaks in the selection with paragraphs before toggling the selection into a\n * bullet list. By default, hard breaks are not replaced.\n */\n smartToggle: boolean\n} & OrderedListOptions\n\n/**\n * Custom extension that extends the built-in `OrderedList` extension to add an option for smart\n * toggling, which takes into account hard breaks in the selection, and converts them into\n * paragraphs before toggling the selection into a bullet list.\n */\nconst RichTextOrderedList = OrderedList.extend<RichTextOrderedListOptions>({\n addOptions() {\n return {\n ...this.parent?.(),\n smartToggle: false,\n }\n },\n\n addCommands() {\n const { editor, name, options } = this\n\n return {\n ...this.parent?.(),\n toggleOrderedList() {\n return ({ commands, state, tr, chain }) => {\n // Replace hard breaks in the selection with paragraphs before toggling?\n if (options.smartToggle) {\n const { schema } = state\n const { selection } = tr\n const { $from, $to } = selection\n\n const hardBreakPositions: number[] = []\n\n // Find and store the positions of all hard breaks in the selection\n tr.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {\n if (node.type.name === 'hardBreak') {\n hardBreakPositions.push(pos)\n }\n })\n\n // Replace each hard break with a slice that closes and re-opens a paragraph,\n // effectively inserting a \"paragraph break\" in place of a \"hard break\"\n // (this is performed in reverse order to compensate for content shifting that\n // occurs with each replacement, ensuring accurate insertion points)\n hardBreakPositions.reverse().forEach((pos) => {\n tr.replace(\n pos,\n pos + 1,\n Slice.maxOpen(\n Fragment.fromArray([\n schema.nodes.paragraph.create(),\n schema.nodes.paragraph.create(),\n ]),\n ),\n )\n })\n }\n\n // Toggle the selection into a bullet list, optionally keeping attributes\n // (this is a verbatim copy of the built-in `toggleBulletList` command)\n\n if (options.keepAttributes) {\n return chain()\n .toggleList(name, options.itemTypeName, options.keepMarks)\n .updateAttributes(ListItem.name, editor.getAttributes(TextStyle.name))\n .run()\n }\n\n return commands.toggleList(name, options.itemTypeName, options.keepMarks)\n }\n },\n }\n },\n})\n\nexport { RichTextOrderedList }\n\nexport type { RichTextOrderedListOptions }\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,sBAAsB,YAAY,OAAmC;CACvE,aAAa;AACT,SAAO;GACH,GAAG,KAAK,UAAU;GAClB,aAAa;GAChB;;CAGL,cAAc;EACV,MAAM,EAAE,QAAQ,MAAM,YAAY;AAElC,SAAO;GACH,GAAG,KAAK,UAAU;GAClB,oBAAoB;AAChB,YAAQ,EAAE,UAAU,OAAO,IAAI,YAAY;AAEvC,SAAI,QAAQ,aAAa;MACrB,MAAM,EAAE,WAAW;MACnB,MAAM,EAAE,cAAc;MACtB,MAAM,EAAE,OAAO,QAAQ;MAEvB,MAAM,qBAA+B,EAAE;AAGvC,SAAG,IAAI,aAAa,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ;AACnD,WAAI,KAAK,KAAK,SAAS,YACnB,oBAAmB,KAAK,IAAI;QAElC;AAMF,yBAAmB,SAAS,CAAC,SAAS,QAAQ;AAC1C,UAAG,QACC,KACA,MAAM,GACN,MAAM,QACF,SAAS,UAAU,CACf,OAAO,MAAM,UAAU,QAAQ,EAC/B,OAAO,MAAM,UAAU,QAAQ,CAClC,CAAC,CACL,CACJ;QACH;;AAMN,SAAI,QAAQ,eACR,QAAO,OAAO,CACT,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU,CACzD,iBAAiB,SAAS,MAAM,OAAO,cAAc,UAAU,KAAK,CAAC,CACrE,KAAK;AAGd,YAAO,SAAS,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU;;;GAGpF;;CAER,CAAC"}
@@ -1,4 +1,6 @@
1
- import type { StrikeOptions } from '@tiptap/extension-strike';
1
+ import { StrikeOptions } from "@tiptap/extension-strike";
2
+
3
+ //#region src/extensions/rich-text/rich-text-strikethrough.d.ts
2
4
  /**
3
5
  * The options available to customize the `RichTextStrikethrough` extension.
4
6
  */
@@ -6,7 +8,6 @@ type RichTextStrikethroughOptions = StrikeOptions;
6
8
  /**
7
9
  * Custom extension that extends the built-in `Strike` extension to overwrite the default keyboard.
8
10
  */
9
- declare const RichTextStrikethrough: import("@tiptap/core").Mark<StrikeOptions, any>;
10
- export { RichTextStrikethrough };
11
- export type { RichTextStrikethroughOptions };
11
+ //#endregion
12
+ export { type RichTextStrikethroughOptions };
12
13
  //# sourceMappingURL=rich-text-strikethrough.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-strikethrough.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-strikethrough.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D;;GAEG;AACH,KAAK,4BAA4B,GAAG,aAAa,CAAA;AAEjD;;GAEG;AACH,QAAA,MAAM,qBAAqB,iDAMzB,CAAA;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAEhC,YAAY,EAAE,4BAA4B,EAAE,CAAA"}
1
+ {"version":3,"file":"rich-text-strikethrough.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-strikethrough.ts"],"mappings":";;;;;;KAOK,4BAAA,GAA+B,aAAA"}
@@ -1,12 +1,12 @@
1
- import { Strike } from '@tiptap/extension-strike';
1
+ import { Strike } from "@tiptap/extension-strike";
2
+ //#region src/extensions/rich-text/rich-text-strikethrough.ts
2
3
  /**
3
- * Custom extension that extends the built-in `Strike` extension to overwrite the default keyboard.
4
- */
5
- const RichTextStrikethrough = Strike.extend({
6
- addKeyboardShortcuts() {
7
- return {
8
- 'Mod-Shift-x': () => this.editor.commands.toggleStrike(),
9
- };
10
- },
11
- });
4
+ * Custom extension that extends the built-in `Strike` extension to overwrite the default keyboard.
5
+ */
6
+ const RichTextStrikethrough = Strike.extend({ addKeyboardShortcuts() {
7
+ return { "Mod-Shift-x": () => this.editor.commands.toggleStrike() };
8
+ } });
9
+ //#endregion
12
10
  export { RichTextStrikethrough };
11
+
12
+ //# sourceMappingURL=rich-text-strikethrough.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-strikethrough.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-strikethrough.ts"],"sourcesContent":["import { Strike } from '@tiptap/extension-strike'\n\nimport type { StrikeOptions } from '@tiptap/extension-strike'\n\n/**\n * The options available to customize the `RichTextStrikethrough` extension.\n */\ntype RichTextStrikethroughOptions = StrikeOptions\n\n/**\n * Custom extension that extends the built-in `Strike` extension to overwrite the default keyboard.\n */\nconst RichTextStrikethrough = Strike.extend<RichTextStrikethroughOptions>({\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-x': () => this.editor.commands.toggleStrike(),\n }\n },\n})\n\nexport { RichTextStrikethrough }\n\nexport type { RichTextStrikethroughOptions }\n"],"mappings":";;;;;AAYA,MAAM,wBAAwB,OAAO,OAAqC,EACtE,uBAAuB;AACnB,QAAO,EACH,qBAAqB,KAAK,OAAO,SAAS,cAAc,EAC3D;GAER,CAAC"}
@@ -1,35 +1,26 @@
1
- import { Extension, getHTMLFromFragment } from '@tiptap/core';
2
- import { getMarkdownSerializerInstance } from '../../serializers/markdown/markdown';
1
+ import { getMarkdownSerializerInstance } from "../../serializers/markdown/markdown.js";
2
+ import { Extension, getHTMLFromFragment } from "@tiptap/core";
3
+ //#region src/extensions/shared/copy-markdown-source.ts
3
4
  /**
4
- * The `CopyMarkdownSource` extension adds the ability to copy the editor underlying Markdown
5
- * source, and write it to the system clipboard. This extension has full support for both the
6
- * plain-text and rich-text editors, considering that it's powered by the Markdown serializer.
7
- */
5
+ * The `CopyMarkdownSource` extension adds the ability to copy the editor underlying Markdown
6
+ * source, and write it to the system clipboard. This extension has full support for both the
7
+ * plain-text and rich-text editors, considering that it's powered by the Markdown serializer.
8
+ */
8
9
  const CopyMarkdownSource = Extension.create({
9
- name: 'copyMarkdownSource',
10
- addOptions() {
11
- return {
12
- keyboardShortcut: 'Mod-c',
13
- };
14
- },
15
- addKeyboardShortcuts() {
16
- return {
17
- [this.options.keyboardShortcut]: ({ editor }) => {
18
- // Get a fragment of the editor's content based on the selection
19
- const nodeSelection = editor.state.doc.cut(editor.state.selection.from, editor.state.selection.to);
20
- // Serialize the selected content HTML to Markdown
21
- const markdownContent = getMarkdownSerializerInstance(editor.schema).serialize(getHTMLFromFragment(nodeSelection.content, editor.schema));
22
- // Writes the selected Markdown content to the system clipboard
23
- navigator?.clipboard
24
- ?.writeText(markdownContent)
25
- // No need to handle the success of the writeText call
26
- .then(() => undefined)
27
- // No need to handle the failure of the writeText call
28
- .catch(() => undefined);
29
- // Suppress the default handling behaviour
30
- return true;
31
- },
32
- };
33
- },
10
+ name: "copyMarkdownSource",
11
+ addOptions() {
12
+ return { keyboardShortcut: "Mod-c" };
13
+ },
14
+ addKeyboardShortcuts() {
15
+ return { [this.options.keyboardShortcut]: ({ editor }) => {
16
+ const nodeSelection = editor.state.doc.cut(editor.state.selection.from, editor.state.selection.to);
17
+ const markdownContent = getMarkdownSerializerInstance(editor.schema).serialize(getHTMLFromFragment(nodeSelection.content, editor.schema));
18
+ navigator?.clipboard?.writeText(markdownContent).then(() => void 0).catch(() => void 0);
19
+ return true;
20
+ } };
21
+ }
34
22
  });
23
+ //#endregion
35
24
  export { CopyMarkdownSource };
25
+
26
+ //# sourceMappingURL=copy-markdown-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-markdown-source.js","names":[],"sources":["../../../src/extensions/shared/copy-markdown-source.ts"],"sourcesContent":["import { Extension, getHTMLFromFragment } from '@tiptap/core'\n\nimport { getMarkdownSerializerInstance } from '../../serializers/markdown/markdown'\n\n/**\n * The options available to customize the `CopyMarkdownSource` extension.\n */\ntype CopyMarkdownSourceOptions = {\n /**\n * The keyboard shortcut to copy the editor underlying Markdown source to the system clipboard\n * (default: `Mod-c`).\n */\n keyboardShortcut: string\n}\n\n/**\n * The `CopyMarkdownSource` extension adds the ability to copy the editor underlying Markdown\n * source, and write it to the system clipboard. This extension has full support for both the\n * plain-text and rich-text editors, considering that it's powered by the Markdown serializer.\n */\nconst CopyMarkdownSource = Extension.create<CopyMarkdownSourceOptions>({\n name: 'copyMarkdownSource',\n addOptions() {\n return {\n keyboardShortcut: 'Mod-c',\n }\n },\n addKeyboardShortcuts() {\n return {\n [this.options.keyboardShortcut]: ({ editor }) => {\n // Get a fragment of the editor's content based on the selection\n const nodeSelection = editor.state.doc.cut(\n editor.state.selection.from,\n editor.state.selection.to,\n )\n\n // Serialize the selected content HTML to Markdown\n const markdownContent = getMarkdownSerializerInstance(editor.schema).serialize(\n getHTMLFromFragment(nodeSelection.content, editor.schema),\n )\n\n // Writes the selected Markdown content to the system clipboard\n navigator?.clipboard\n ?.writeText(markdownContent)\n // No need to handle the success of the writeText call\n .then(() => undefined)\n // No need to handle the failure of the writeText call\n .catch(() => undefined)\n\n // Suppress the default handling behaviour\n return true\n },\n }\n },\n})\n\nexport { CopyMarkdownSource }\n\nexport type { CopyMarkdownSourceOptions }\n"],"mappings":";;;;;;;;AAoBA,MAAM,qBAAqB,UAAU,OAAkC;CACnE,MAAM;CACN,aAAa;AACT,SAAO,EACH,kBAAkB,SACrB;;CAEL,uBAAuB;AACnB,SAAO,GACF,KAAK,QAAQ,oBAAoB,EAAE,aAAa;GAE7C,MAAM,gBAAgB,OAAO,MAAM,IAAI,IACnC,OAAO,MAAM,UAAU,MACvB,OAAO,MAAM,UAAU,GAC1B;GAGD,MAAM,kBAAkB,8BAA8B,OAAO,OAAO,CAAC,UACjE,oBAAoB,cAAc,SAAS,OAAO,OAAO,CAC5D;AAGD,cAAW,WACL,UAAU,gBAAgB,CAE3B,WAAW,KAAA,EAAU,CAErB,YAAY,KAAA,EAAU;AAG3B,UAAO;KAEd;;CAER,CAAC"}
@@ -1,66 +1,53 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import { PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY } from '../../constants/extension-priorities';
4
- import { parseHtmlToElement } from '../../helpers/dom';
1
+ import { parseHtmlToElement } from "../../helpers/dom.js";
2
+ import { PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY } from "../../constants/extension-priorities.js";
3
+ import { Extension } from "@tiptap/core";
4
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
5
+ //#region src/extensions/shared/paste-html-table-as-string.ts
5
6
  /**
6
- * Transforms pasted HTML by converting tables to paragraphs while preserving surrounding content.
7
- */
7
+ * Transforms pasted HTML by converting tables to paragraphs while preserving surrounding content.
8
+ */
8
9
  function transformPastedHTML(html) {
9
- const body = parseHtmlToElement(html);
10
- const tables = body.querySelectorAll('table');
11
- if (tables.length === 0) {
12
- return html;
13
- }
14
- for (const table of Array.from(tables)) {
15
- if (!table.rows) {
16
- continue;
17
- }
18
- // Convert table rows to paragraphs (using innerHTML to preserve formatting)
19
- const paragraphs = Array.from(table.rows)
20
- .map((row) => Array.from(row.cells)
21
- .map((cell) => {
22
- // Unwrap paragraphs but preserve inline formatting
23
- const paragraphs = cell.querySelectorAll('p');
24
- for (const p of Array.from(paragraphs)) {
25
- p.replaceWith(...Array.from(p.childNodes));
26
- }
27
- return cell.innerHTML;
28
- })
29
- .join(' '))
30
- .filter((row) => row.trim().length > 0)
31
- .map((row) => {
32
- const p = document.createElement('p');
33
- p.innerHTML = row;
34
- return p;
35
- });
36
- table.replaceWith(...paragraphs);
37
- }
38
- return body.innerHTML;
10
+ const body = parseHtmlToElement(html);
11
+ const tables = body.querySelectorAll("table");
12
+ if (tables.length === 0) return html;
13
+ for (const table of Array.from(tables)) {
14
+ if (!table.rows) continue;
15
+ const paragraphs = Array.from(table.rows).map((row) => Array.from(row.cells).map((cell) => {
16
+ const paragraphs = cell.querySelectorAll("p");
17
+ for (const p of Array.from(paragraphs)) p.replaceWith(...Array.from(p.childNodes));
18
+ return cell.innerHTML;
19
+ }).join(" ")).filter((row) => row.trim().length > 0).map((row) => {
20
+ const p = document.createElement("p");
21
+ p.innerHTML = row;
22
+ return p;
23
+ });
24
+ table.replaceWith(...paragraphs);
25
+ }
26
+ return body.innerHTML;
39
27
  }
40
28
  /**
41
- * The `PasteHTMLTableAsString` extension adds the ability to paste a table copied from a spreadsheet
42
- * web app (e.g., Google Sheets, Microsoft Excel), along with tables rendered by GitHub Flavored
43
- * Markdown (GFM), into the editor.
44
- *
45
- * Since Typist does not yet support tables, this extension simply pastes the table as a string of
46
- * paragraphs (one paragraph per row), with each cell separated by a space character. However,
47
- * whenever we do add support for tables, this extension will need to be completely rewritten.
48
- *
49
- * Lastly, please note that formatting is lost when the copied table comes from Google Sheets or
50
- * Microsoft Excel, because unfortunately, these apps style the cell contents using CSS.
51
- */
29
+ * The `PasteHTMLTableAsString` extension adds the ability to paste a table copied from a spreadsheet
30
+ * web app (e.g., Google Sheets, Microsoft Excel), along with tables rendered by GitHub Flavored
31
+ * Markdown (GFM), into the editor.
32
+ *
33
+ * Since Typist does not yet support tables, this extension simply pastes the table as a string of
34
+ * paragraphs (one paragraph per row), with each cell separated by a space character. However,
35
+ * whenever we do add support for tables, this extension will need to be completely rewritten.
36
+ *
37
+ * Lastly, please note that formatting is lost when the copied table comes from Google Sheets or
38
+ * Microsoft Excel, because unfortunately, these apps style the cell contents using CSS.
39
+ */
52
40
  const PasteHTMLTableAsString = Extension.create({
53
- name: 'pasteHTMLTableAsString',
54
- priority: PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY,
55
- addProseMirrorPlugins() {
56
- return [
57
- new Plugin({
58
- key: new PluginKey('pasteHTMLTableAsString'),
59
- props: {
60
- transformPastedHTML,
61
- },
62
- }),
63
- ];
64
- },
41
+ name: "pasteHTMLTableAsString",
42
+ priority: PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY,
43
+ addProseMirrorPlugins() {
44
+ return [new Plugin({
45
+ key: new PluginKey("pasteHTMLTableAsString"),
46
+ props: { transformPastedHTML }
47
+ })];
48
+ }
65
49
  });
66
- export { PasteHTMLTableAsString, transformPastedHTML };
50
+ //#endregion
51
+ export { PasteHTMLTableAsString };
52
+
53
+ //# sourceMappingURL=paste-html-table-as-string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-html-table-as-string.js","names":[],"sources":["../../../src/extensions/shared/paste-html-table-as-string.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\nimport { parseHtmlToElement } from '../../helpers/dom'\n\n/**\n * Transforms pasted HTML by converting tables to paragraphs while preserving surrounding content.\n */\nfunction transformPastedHTML(html: string): string {\n const body = parseHtmlToElement(html)\n const tables = body.querySelectorAll('table')\n\n if (tables.length === 0) {\n return html\n }\n\n for (const table of Array.from(tables)) {\n if (!table.rows) {\n continue\n }\n\n // Convert table rows to paragraphs (using innerHTML to preserve formatting)\n const paragraphs = Array.from(table.rows)\n .map((row) =>\n Array.from(row.cells)\n .map((cell) => {\n // Unwrap paragraphs but preserve inline formatting\n const paragraphs = cell.querySelectorAll('p')\n\n for (const p of Array.from(paragraphs)) {\n p.replaceWith(...Array.from(p.childNodes))\n }\n\n return cell.innerHTML\n })\n .join(' '),\n )\n .filter((row) => row.trim().length > 0)\n .map((row) => {\n const p = document.createElement('p')\n p.innerHTML = row\n return p\n })\n\n table.replaceWith(...paragraphs)\n }\n\n return body.innerHTML\n}\n\n/**\n * The `PasteHTMLTableAsString` extension adds the ability to paste a table copied from a spreadsheet\n * web app (e.g., Google Sheets, Microsoft Excel), along with tables rendered by GitHub Flavored\n * Markdown (GFM), into the editor.\n *\n * Since Typist does not yet support tables, this extension simply pastes the table as a string of\n * paragraphs (one paragraph per row), with each cell separated by a space character. However,\n * whenever we do add support for tables, this extension will need to be completely rewritten.\n *\n * Lastly, please note that formatting is lost when the copied table comes from Google Sheets or\n * Microsoft Excel, because unfortunately, these apps style the cell contents using CSS.\n */\nconst PasteHTMLTableAsString = Extension.create({\n name: 'pasteHTMLTableAsString',\n priority: PASTE_HTML_TABLE_AS_STRING_EXTENSION_PRIORITY,\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('pasteHTMLTableAsString'),\n props: {\n transformPastedHTML,\n },\n }),\n ]\n },\n})\n\nexport { PasteHTMLTableAsString, transformPastedHTML }\n"],"mappings":";;;;;;;;AASA,SAAS,oBAAoB,MAAsB;CAC/C,MAAM,OAAO,mBAAmB,KAAK;CACrC,MAAM,SAAS,KAAK,iBAAiB,QAAQ;AAE7C,KAAI,OAAO,WAAW,EAClB,QAAO;AAGX,MAAK,MAAM,SAAS,MAAM,KAAK,OAAO,EAAE;AACpC,MAAI,CAAC,MAAM,KACP;EAIJ,MAAM,aAAa,MAAM,KAAK,MAAM,KAAK,CACpC,KAAK,QACF,MAAM,KAAK,IAAI,MAAM,CAChB,KAAK,SAAS;GAEX,MAAM,aAAa,KAAK,iBAAiB,IAAI;AAE7C,QAAK,MAAM,KAAK,MAAM,KAAK,WAAW,CAClC,GAAE,YAAY,GAAG,MAAM,KAAK,EAAE,WAAW,CAAC;AAG9C,UAAO,KAAK;IACd,CACD,KAAK,IAAI,CACjB,CACA,QAAQ,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CACtC,KAAK,QAAQ;GACV,MAAM,IAAI,SAAS,cAAc,IAAI;AACrC,KAAE,YAAY;AACd,UAAO;IACT;AAEN,QAAM,YAAY,GAAG,WAAW;;AAGpC,QAAO,KAAK;;;;;;;;;;;;;;AAehB,MAAM,yBAAyB,UAAU,OAAO;CAC5C,MAAM;CACN,UAAU;CACV,wBAAwB;AACpB,SAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,yBAAyB;GAC5C,OAAO,EACH,qBACH;GACJ,CAAC,CACL;;CAER,CAAC"}
@@ -1,43 +1,35 @@
1
- import { Extension } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import { escape } from 'lodash-es';
4
- import { REGEX_LINE_BREAKS } from '../../constants/regular-expressions';
5
- import { parseHtmlToElement } from '../../helpers/dom';
6
- import { isPlainTextDocument } from '../../helpers/schema';
1
+ import { parseHtmlToElement } from "../../helpers/dom.js";
2
+ import { isPlainTextDocument } from "../../helpers/schema.js";
3
+ import { REGEX_LINE_BREAKS } from "../../constants/regular-expressions.js";
4
+ import { Extension } from "@tiptap/core";
5
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
6
+ import { escape } from "lodash-es";
7
+ //#region src/extensions/shared/paste-singleline-text.ts
7
8
  /**
8
- * The `PasteSinglelineText` extension joins all paragraphs into a single fragment when
9
- * copying-and-pasting text into the editor, adding spaces as block separators. This custom
10
- * extension is required for an editor configured with `multiline: false`, so that multiline
11
- * clipboard text is pasted into the singleline editor correctly.
12
- */
9
+ * The `PasteSinglelineText` extension joins all paragraphs into a single fragment when
10
+ * copying-and-pasting text into the editor, adding spaces as block separators. This custom
11
+ * extension is required for an editor configured with `multiline: false`, so that multiline
12
+ * clipboard text is pasted into the singleline editor correctly.
13
+ */
13
14
  const PasteSinglelineText = Extension.create({
14
- name: 'pasteSinglelineText',
15
- addProseMirrorPlugins() {
16
- return [
17
- new Plugin({
18
- key: new PluginKey('pasteSinglelineText'),
19
- props: {
20
- transformPastedHTML(html, view) {
21
- const bodyElement = parseHtmlToElement(html);
22
- bodyElement.innerHTML = bodyElement.innerHTML
23
- // Join break lines with a space character in-between
24
- .replace(/<br>/g, ' ')
25
- // Join paragraphs with a space character in-between
26
- .replace(/<p[^>]*>(.*?)<\/p>/g, '$1 ');
27
- return isPlainTextDocument(view.state.schema)
28
- ? escape(bodyElement.innerText)
29
- : bodyElement.innerHTML;
30
- },
31
- transformPastedText(text) {
32
- return (text
33
- // Join new lines with a space character in-between
34
- .replace(REGEX_LINE_BREAKS, ' ')
35
- // Collapse multiple space characters into one
36
- .replace(/\s+/g, ' '));
37
- },
38
- },
39
- }),
40
- ];
41
- },
15
+ name: "pasteSinglelineText",
16
+ addProseMirrorPlugins() {
17
+ return [new Plugin({
18
+ key: new PluginKey("pasteSinglelineText"),
19
+ props: {
20
+ transformPastedHTML(html, view) {
21
+ const bodyElement = parseHtmlToElement(html);
22
+ bodyElement.innerHTML = bodyElement.innerHTML.replace(/<br>/g, " ").replace(/<p[^>]*>(.*?)<\/p>/g, "$1 ");
23
+ return isPlainTextDocument(view.state.schema) ? escape(bodyElement.innerText) : bodyElement.innerHTML;
24
+ },
25
+ transformPastedText(text) {
26
+ return text.replace(REGEX_LINE_BREAKS, " ").replace(/\s+/g, " ");
27
+ }
28
+ }
29
+ })];
30
+ }
42
31
  });
32
+ //#endregion
43
33
  export { PasteSinglelineText };
34
+
35
+ //# sourceMappingURL=paste-singleline-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-singleline-text.js","names":[],"sources":["../../../src/extensions/shared/paste-singleline-text.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { escape } from 'lodash-es'\n\nimport { REGEX_LINE_BREAKS } from '../../constants/regular-expressions'\nimport { parseHtmlToElement } from '../../helpers/dom'\nimport { isPlainTextDocument } from '../../helpers/schema'\n\n/**\n * The `PasteSinglelineText` extension joins all paragraphs into a single fragment when\n * copying-and-pasting text into the editor, adding spaces as block separators. This custom\n * extension is required for an editor configured with `multiline: false`, so that multiline\n * clipboard text is pasted into the singleline editor correctly.\n */\nconst PasteSinglelineText = Extension.create({\n name: 'pasteSinglelineText',\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('pasteSinglelineText'),\n props: {\n transformPastedHTML(html, view) {\n const bodyElement = parseHtmlToElement(html)\n\n bodyElement.innerHTML = bodyElement.innerHTML\n // Join break lines with a space character in-between\n .replace(/<br>/g, ' ')\n // Join paragraphs with a space character in-between\n .replace(/<p[^>]*>(.*?)<\\/p>/g, '$1 ')\n\n return isPlainTextDocument(view.state.schema)\n ? escape(bodyElement.innerText)\n : bodyElement.innerHTML\n },\n transformPastedText(text) {\n return (\n text\n // Join new lines with a space character in-between\n .replace(REGEX_LINE_BREAKS, ' ')\n // Collapse multiple space characters into one\n .replace(/\\s+/g, ' ')\n )\n },\n },\n }),\n ]\n },\n})\n\nexport { PasteSinglelineText }\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,sBAAsB,UAAU,OAAO;CACzC,MAAM;CACN,wBAAwB;AACpB,SAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,sBAAsB;GACzC,OAAO;IACH,oBAAoB,MAAM,MAAM;KAC5B,MAAM,cAAc,mBAAmB,KAAK;AAE5C,iBAAY,YAAY,YAAY,UAE/B,QAAQ,SAAS,IAAI,CAErB,QAAQ,uBAAuB,MAAM;AAE1C,YAAO,oBAAoB,KAAK,MAAM,OAAO,GACvC,OAAO,YAAY,UAAU,GAC7B,YAAY;;IAEtB,oBAAoB,MAAM;AACtB,YACI,KAEK,QAAQ,mBAAmB,IAAI,CAE/B,QAAQ,QAAQ,IAAI;;IAGpC;GACJ,CAAC,CACL;;CAER,CAAC"}
@@ -1,96 +1,98 @@
1
- import { Node } from '@tiptap/core';
2
- import type { SuggestionKeyDownProps as CoreSuggestionKeyDownProps, SuggestionOptions as CoreSuggestionOptions, SuggestionProps as CoreSuggestionProps } from '@tiptap/suggestion';
3
- import type { ConditionalKeys, RequireAtLeastOne } from 'type-fest';
1
+ import { Node } from "@tiptap/core";
2
+ import { SuggestionKeyDownProps, SuggestionOptions, SuggestionProps } from "@tiptap/suggestion";
3
+ import { ConditionalKeys, RequireAtLeastOne } from "type-fest";
4
+
5
+ //#region src/factories/create-suggestion-extension.d.ts
4
6
  /**
5
7
  * A type that describes the suggestion node attributes.
6
8
  */
7
9
  type SuggestionNodeAttributes = {
8
- /**
9
- * The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.
10
- */
11
- id: number | string;
12
- /**
13
- * The suggestion node label to be rendered by the editor as a `data-label` attribute and the
14
- * display text itself.
15
- */
16
- label: string;
10
+ /**
11
+ * The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.
12
+ */
13
+ id: number | string;
14
+ /**
15
+ * The suggestion node label to be rendered by the editor as a `data-label` attribute and the
16
+ * display text itself.
17
+ */
18
+ label: string;
17
19
  };
18
20
  /**
19
21
  * A type that describes the minimal props that an autocomplete dropdown must receive.
20
22
  */
21
23
  type SuggestionRendererProps<TSuggestionItem> = {
22
- /**
23
- * The list of suggestion items to be rendered by the autocomplete dropdown.
24
- */
25
- items: CoreSuggestionProps<TSuggestionItem>['items'];
26
- /**
27
- * The function that must be invoked when a suggestion item is selected.
28
- */
29
- command: CoreSuggestionProps<TSuggestionItem, SuggestionNodeAttributes>['command'];
24
+ /**
25
+ * The list of suggestion items to be rendered by the autocomplete dropdown.
26
+ */
27
+ items: SuggestionProps<TSuggestionItem>['items'];
28
+ /**
29
+ * The function that must be invoked when a suggestion item is selected.
30
+ */
31
+ command: SuggestionProps<TSuggestionItem, SuggestionNodeAttributes>['command'];
30
32
  };
31
33
  /**
32
34
  * A type that describes the forwarded ref that an autocomplete dropdown must implement with
33
35
  * `useImperativeHandle` to handle `keydown` events in the dropdown render function.
34
36
  */
35
37
  type SuggestionRendererRef = {
36
- onKeyDown: (props: CoreSuggestionKeyDownProps) => boolean;
38
+ onKeyDown: (props: SuggestionKeyDownProps) => boolean;
37
39
  };
38
40
  /**
39
41
  * The options available to customize the extension created by the factory function.
40
42
  */
41
- type SuggestionOptions<TSuggestionItem> = {
42
- /**
43
- * The character that triggers the autocomplete dropdown.
44
- */
45
- triggerChar: string;
46
- /**
47
- * Allows or disallows spaces in suggested items.
48
- */
49
- allowSpaces: CoreSuggestionOptions['allowSpaces'];
50
- /**
51
- * The prefix characters that are allowed to trigger a suggestion.
52
- */
53
- allowedPrefixes: CoreSuggestionOptions['allowedPrefixes'];
54
- /**
55
- * Trigger the autocomplete dropdown at the start of a line only.
56
- */
57
- startOfLine: CoreSuggestionOptions['startOfLine'];
58
- /**
59
- * Define how the suggestion item `aria-label` attribute should be rendered.
60
- */
61
- renderAriaLabel?: (attrs: SuggestionNodeAttributes) => string;
62
- /**
63
- * A render function for the autocomplete dropdown.
64
- */
65
- dropdownRenderFn?: CoreSuggestionOptions<TSuggestionItem>['render'];
66
- /**
67
- * The event handler that is fired when the search string has changed.
68
- */
69
- onSearchChange?: (query: string, storage: SuggestionStorage<TSuggestionItem>) => TSuggestionItem[] | Promise<TSuggestionItem[]>;
70
- /**
71
- * The event handler that is fired when a suggestion item is selected.
72
- */
73
- onItemSelect?: (item: TSuggestionItem) => void;
43
+ type SuggestionOptions$1<TSuggestionItem> = {
44
+ /**
45
+ * The character that triggers the autocomplete dropdown.
46
+ */
47
+ triggerChar: string;
48
+ /**
49
+ * Allows or disallows spaces in suggested items.
50
+ */
51
+ allowSpaces: SuggestionOptions['allowSpaces'];
52
+ /**
53
+ * The prefix characters that are allowed to trigger a suggestion.
54
+ */
55
+ allowedPrefixes: SuggestionOptions['allowedPrefixes'];
56
+ /**
57
+ * Trigger the autocomplete dropdown at the start of a line only.
58
+ */
59
+ startOfLine: SuggestionOptions['startOfLine'];
60
+ /**
61
+ * Define how the suggestion item `aria-label` attribute should be rendered.
62
+ */
63
+ renderAriaLabel?: (attrs: SuggestionNodeAttributes) => string;
64
+ /**
65
+ * A render function for the autocomplete dropdown.
66
+ */
67
+ dropdownRenderFn?: SuggestionOptions<TSuggestionItem>['render'];
68
+ /**
69
+ * The event handler that is fired when the search string has changed.
70
+ */
71
+ onSearchChange?: (query: string, storage: SuggestionStorage<TSuggestionItem>) => TSuggestionItem[] | Promise<TSuggestionItem[]>;
72
+ /**
73
+ * The event handler that is fired when a suggestion item is selected.
74
+ */
75
+ onItemSelect?: (item: TSuggestionItem) => void;
74
76
  };
75
77
  /**
76
78
  * The storage holding the suggestion items original array, and a collection indexed by the item id.
77
79
  */
78
80
  type SuggestionStorage<TSuggestionItem> = Readonly<{
79
- /**
80
- * The original array of suggestion items.
81
- */
82
- items: TSuggestionItem[];
83
- /**
84
- * A collection of suggestion items indexed by the item id.
85
- */
86
- itemsById: {
87
- readonly [id: SuggestionNodeAttributes['id']]: TSuggestionItem | undefined;
88
- };
81
+ /**
82
+ * The original array of suggestion items.
83
+ */
84
+ items: TSuggestionItem[];
85
+ /**
86
+ * A collection of suggestion items indexed by the item id.
87
+ */
88
+ itemsById: {
89
+ readonly [id: SuggestionNodeAttributes['id']]: TSuggestionItem | undefined;
90
+ };
89
91
  }>;
90
92
  /**
91
93
  * The return type for a suggestion extension created by the factory function.
92
94
  */
93
- type SuggestionExtensionResult<TSuggestionItem> = Node<SuggestionOptions<TSuggestionItem>>;
95
+ type SuggestionExtensionResult<TSuggestionItem> = Node<SuggestionOptions$1<TSuggestionItem>>;
94
96
  /**
95
97
  * A factory function responsible for creating different types of suggestion extensions with
96
98
  * flexibility and customizability in mind.
@@ -117,13 +119,11 @@ type SuggestionExtensionResult<TSuggestionItem> = Node<SuggestionOptions<TSugges
117
119
  * @returns A new suggestion extension tailored to a specific use case.
118
120
  */
119
121
  declare function createSuggestionExtension<TSuggestionItem extends {
120
- [id: SuggestionNodeAttributes['id']]: unknown;
121
- } = SuggestionNodeAttributes>(type: string, items?: TSuggestionItem[], ...attributesMapping: TSuggestionItem extends SuggestionNodeAttributes ? [] : [
122
- RequireAtLeastOne<{
123
- id: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['id']>;
124
- label: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['label']>;
125
- }>
126
- ]): SuggestionExtensionResult<TSuggestionItem>;
127
- export { createSuggestionExtension };
128
- export type { SuggestionExtensionResult, SuggestionOptions, SuggestionRendererProps, SuggestionRendererRef, SuggestionStorage, };
122
+ [id: SuggestionNodeAttributes['id']]: unknown;
123
+ } = SuggestionNodeAttributes>(type: string, items?: TSuggestionItem[], ...attributesMapping: TSuggestionItem extends SuggestionNodeAttributes ? [] : [RequireAtLeastOne<{
124
+ id: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['id']>;
125
+ label: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['label']>;
126
+ }>]): SuggestionExtensionResult<TSuggestionItem>;
127
+ //#endregion
128
+ export { type SuggestionExtensionResult, type SuggestionOptions$1 as SuggestionOptions, type SuggestionRendererProps, type SuggestionRendererRef, type SuggestionStorage, createSuggestionExtension };
129
129
  //# sourceMappingURL=create-suggestion-extension.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-suggestion-extension.d.ts","sourceRoot":"","sources":["../../src/factories/create-suggestion-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAA;AASpD,OAAO,KAAK,EACR,sBAAsB,IAAI,0BAA0B,EACpD,iBAAiB,IAAI,qBAAqB,EAC1C,eAAe,IAAI,mBAAmB,EACzC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEnE;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IAEnB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,KAAK,uBAAuB,CAAC,eAAe,IAAI;IAC5C;;OAEG;IACH,KAAK,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAA;IAEpD;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC,SAAS,CAAC,CAAA;CACrF,CAAA;AAED;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,OAAO,CAAA;CAC5D,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,CAAC,eAAe,IAAI;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,WAAW,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAA;IAEjD;;OAEG;IACH,eAAe,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;IAEzD;;OAEG;IACH,WAAW,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAA;IAEjD;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,MAAM,CAAA;IAE7D;;OAEG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAA;IAEnE;;OAEG;IACH,cAAc,CAAC,EAAE,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,iBAAiB,CAAC,eAAe,CAAC,KAC1C,eAAe,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IAEnD;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;CACjD,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,CAAC,eAAe,IAAI,QAAQ,CAAC;IAC/C;;OAEG;IACH,KAAK,EAAE,eAAe,EAAE,CAAA;IAExB;;OAEG;IACH,SAAS,EAAE;QAAE,QAAQ,EAAE,EAAE,EAAE,wBAAwB,CAAC,IAAI,CAAC,GAAG,eAAe,GAAG,SAAS,CAAA;KAAE,CAAA;CAC5F,CAAC,CAAA;AAEF;;GAEG;AACH,KAAK,yBAAyB,CAAC,eAAe,IAAI,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAA;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,yBAAyB,CAC9B,eAAe,SAAS;IACpB,CAAC,EAAE,EAAE,wBAAwB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;CAChD,GAAG,wBAAwB,EAE5B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,eAAe,EAAO,EAK7B,GAAG,iBAAiB,EAAE,eAAe,SAAS,wBAAwB,GAChE,EAAE,GACF;IACI,iBAAiB,CAAC;QACd,EAAE,EAAE,eAAe,CAAC,eAAe,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAA;QACpE,KAAK,EAAE,eAAe,CAAC,eAAe,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAA;KAC7E,CAAC;CACL,GACR,yBAAyB,CAAC,eAAe,CAAC,CAgK5C;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,YAAY,EACR,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GACpB,CAAA"}
1
+ {"version":3,"file":"create-suggestion-extension.d.ts","names":[],"sources":["../../src/factories/create-suggestion-extension.ts"],"mappings":";;;;;;;AAcmE;KAK9D,wBAAA;;;;EAID,EAAA;EAYwB;;;;EANxB,KAAA;AAAA;;;;KAMC,uBAAA;EAID;;;EAAA,KAAA,EAAO,eAAA,CAAoB,eAAA;EAKlB;;;EAAT,OAAA,EAAS,eAAA,CAAoB,eAAA,EAAiB,wBAAA;AAAA;AAAwB;;;;AAAA,KAOrE,qBAAA;EACD,SAAA,GAAY,KAAA,EAAO,sBAAA;AAAA;;;AAA0B;KAM5C,mBAAA;EAAiB;;;EAIlB,WAAA;EAoB0B;;;EAf1B,WAAA,EAAa,iBAAA;EA2BA;;;EAtBb,eAAA,EAAiB,iBAAA;EA4BK;;;EAvBtB,WAAA,EAAa,iBAAA;EAfb;;;EAoBA,eAAA,IAAmB,KAAA,EAAO,wBAAA;EAVT;;;EAejB,gBAAA,GAAmB,iBAAA,CAAsB,eAAA;EALf;;;EAU1B,cAAA,IACI,KAAA,UACA,OAAA,EAAS,iBAAA,CAAkB,eAAA,MAC1B,eAAA,KAAoB,OAAA,CAAQ,eAAA;EARQ;;;EAazC,YAAA,IAAgB,IAAA,EAAM,eAAA;AAAA;;;;KAMrB,iBAAA,oBAAqC,QAAA;EANtC;;;EAUA,KAAA,EAAO,eAAA;EAV8B;AAAA;;EAerC,SAAA;IAAA,UAAuB,EAAA,EAAI,wBAAA,SAAiC,eAAA;EAAA;AAAA;;;;KAM3D,yBAAA,oBAA6C,IAAA,CAAK,mBAAA,CAAkB,eAAA;;;;;;;;;;AANM;;;;;;;;;;;;;;AAMS;;iBA2B/E,yBAAA;EAAA,CAEA,EAAA,EAAI,wBAAA;AAAA,IACL,wBAAA,CAAA,CAEJ,IAAA,UACA,KAAA,GAAO,eAAA,OAKJ,iBAAA,EAAmB,eAAA,SAAwB,wBAAA,SAGpC,iBAAA;EACI,EAAA,EAAI,eAAA,CAAgB,eAAA,EAAiB,wBAAA;EACrC,KAAA,EAAO,eAAA,CAAgB,eAAA,EAAiB,wBAAA;AAAA,MAGvD,yBAAA,CAA0B,eAAA"}