@doist/typist 12.0.0 → 13.0.1

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 (96) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/typist-editor.d.ts +1 -2
  3. package/dist/components/typist-editor.d.ts.map +1 -1
  4. package/dist/components/typist-editor.helper.d.ts.map +1 -1
  5. package/dist/components/typist-editor.helper.js.map +1 -1
  6. package/dist/components/typist-editor.js.map +1 -1
  7. package/dist/constants/common.js.map +1 -1
  8. package/dist/constants/extension-priorities.d.ts.map +1 -1
  9. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.d.ts.map +1 -1
  10. package/dist/extensions/core/extra-editor-commands/commands/create-paragraph-end.js.map +1 -1
  11. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.d.ts.map +1 -1
  12. package/dist/extensions/core/extra-editor-commands/commands/extend-word-range.js.map +1 -1
  13. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.d.ts.map +1 -1
  14. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js +12 -1
  15. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content-at.js.map +1 -1
  16. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.d.ts.map +1 -1
  17. package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js.map +1 -1
  18. package/dist/extensions/core/extra-editor-commands/extra-editor-commands.js.map +1 -1
  19. package/dist/extensions/core/view-event-handlers.d.ts +1 -1
  20. package/dist/extensions/core/view-event-handlers.d.ts.map +1 -1
  21. package/dist/extensions/core/view-event-handlers.js.map +1 -1
  22. package/dist/extensions/plain-text/paste-multiline-text.js.map +1 -1
  23. package/dist/extensions/plain-text/plain-text-document.d.ts +1 -1
  24. package/dist/extensions/plain-text/plain-text-document.d.ts.map +1 -1
  25. package/dist/extensions/plain-text/plain-text-document.js.map +1 -1
  26. package/dist/extensions/plain-text/plain-text-kit.js.map +1 -1
  27. package/dist/extensions/plain-text/plain-text-paragraph.js.map +1 -1
  28. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-lists.js.map +1 -1
  29. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-select-wrap.js.map +1 -1
  30. package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js.map +1 -1
  31. package/dist/extensions/plain-text/smart-markdown-typing/smart-markdown-typing.js.map +1 -1
  32. package/dist/extensions/rich-text/bold-and-italics.js.map +1 -1
  33. package/dist/extensions/rich-text/curvenote-codemark.js.map +1 -1
  34. package/dist/extensions/rich-text/paste-emojis.js.map +1 -1
  35. package/dist/extensions/rich-text/paste-markdown.js.map +1 -1
  36. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts +1 -1
  37. package/dist/extensions/rich-text/rich-text-bullet-list.d.ts.map +1 -1
  38. package/dist/extensions/rich-text/rich-text-bullet-list.js.map +1 -1
  39. package/dist/extensions/rich-text/rich-text-code.js.map +1 -1
  40. package/dist/extensions/rich-text/rich-text-document.d.ts +1 -1
  41. package/dist/extensions/rich-text/rich-text-document.d.ts.map +1 -1
  42. package/dist/extensions/rich-text/rich-text-document.js.map +1 -1
  43. package/dist/extensions/rich-text/rich-text-heading.d.ts +1 -1
  44. package/dist/extensions/rich-text/rich-text-heading.d.ts.map +1 -1
  45. package/dist/extensions/rich-text/rich-text-heading.js.map +1 -1
  46. package/dist/extensions/rich-text/rich-text-image.d.ts +1 -1
  47. package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
  48. package/dist/extensions/rich-text/rich-text-image.js.map +1 -1
  49. package/dist/extensions/rich-text/rich-text-kit.d.ts.map +1 -1
  50. package/dist/extensions/rich-text/rich-text-kit.js.map +1 -1
  51. package/dist/extensions/rich-text/rich-text-link.d.ts +1 -1
  52. package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
  53. package/dist/extensions/rich-text/rich-text-link.js.map +1 -1
  54. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts +1 -1
  55. package/dist/extensions/rich-text/rich-text-ordered-list.d.ts.map +1 -1
  56. package/dist/extensions/rich-text/rich-text-ordered-list.js.map +1 -1
  57. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts +1 -1
  58. package/dist/extensions/rich-text/rich-text-strikethrough.d.ts.map +1 -1
  59. package/dist/extensions/rich-text/rich-text-strikethrough.js.map +1 -1
  60. package/dist/extensions/shared/copy-markdown-source.js.map +1 -1
  61. package/dist/extensions/shared/paste-html-table-as-string.js.map +1 -1
  62. package/dist/extensions/shared/paste-singleline-text.js.map +1 -1
  63. package/dist/factories/create-suggestion-extension.d.ts.map +1 -1
  64. package/dist/factories/create-suggestion-extension.js.map +1 -1
  65. package/dist/helpers/dom.js.map +1 -1
  66. package/dist/helpers/schema.d.ts.map +1 -1
  67. package/dist/helpers/schema.js.map +1 -1
  68. package/dist/helpers/serializer.js.map +1 -1
  69. package/dist/helpers/unified.js.map +1 -1
  70. package/dist/hooks/use-editor.js.map +1 -1
  71. package/dist/serializers/html/html.d.ts.map +1 -1
  72. package/dist/serializers/html/html.js.map +1 -1
  73. package/dist/serializers/html/plugins/rehype-code-block.js.map +1 -1
  74. package/dist/serializers/html/plugins/rehype-image.js.map +1 -1
  75. package/dist/serializers/html/plugins/rehype-suggestions.js.map +1 -1
  76. package/dist/serializers/html/plugins/rehype-task-list.js.map +1 -1
  77. package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
  78. package/dist/serializers/html/plugins/remark-autolink-literal.js.map +1 -1
  79. package/dist/serializers/html/plugins/remark-disable-constructs.js.map +1 -1
  80. package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
  81. package/dist/serializers/html/plugins/remark-strikethrough.js.map +1 -1
  82. package/dist/serializers/markdown/markdown.d.ts.map +1 -1
  83. package/dist/serializers/markdown/markdown.js.map +1 -1
  84. package/dist/serializers/markdown/plugins/image.js.map +1 -1
  85. package/dist/serializers/markdown/plugins/list-item.js +0 -1
  86. package/dist/serializers/markdown/plugins/list-item.js.map +1 -1
  87. package/dist/serializers/markdown/plugins/paragraph.js.map +1 -1
  88. package/dist/serializers/markdown/plugins/strikethrough.js.map +1 -1
  89. package/dist/serializers/markdown/plugins/suggestion.js.map +1 -1
  90. package/dist/serializers/markdown/plugins/task-item.js +0 -1
  91. package/dist/serializers/markdown/plugins/task-item.js.map +1 -1
  92. package/dist/utilities/can-insert-node-at.d.ts.map +1 -1
  93. package/dist/utilities/can-insert-node-at.js.map +1 -1
  94. package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
  95. package/dist/utilities/can-insert-suggestion.js.map +1 -1
  96. package/package.json +14 -14
@@ -1 +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;EAEnB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,gBAAgB;GACnC,OAAO;IACH,oBAAoB,MAAM;KAKtB,OAAO,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;KAIzD,IAAI,yBAAyB,CAAC,uBAC1B,OAAO;KAMX,MAAM,cAAc,MAAM,QAAQ,YAAY,GAAG,MAAM,QAAQ,MAAM,KAAK;KAI1E,IAAI,QAAQ,KAAK,YAAY,EACzB,OAAO;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;KAKrC,IACI,0CACA,wDAEA,OAAO;KAMX,MAAM,qBAAqB,YAAY,QACnC,IAAI,OAAO,QAAQ,kBAAkB,OAAO,IAAI,IAAI,EACpD,OACH;KAID,OAAO,SAAS,sBAAsB,mBAAmB;KAGzD,OAAO;;IAEd;GACJ,CAAC,CACL;;CAER,CAAC"}
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;EAEnB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,eAAe;GAClC,OAAO;IACH,oBAAoB,MAAM;KAKtB,OAAO,MAAM,QAAQ,SAAS,KAAK,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC;IAChE;IACA,YAAY,GAAG,OAAO,OAAO;KACzB,MAAM,wBACF,OAAO,MAAM,UAAU,MAAM,OAAO,KAAK,SAAS;KAItD,MAAM,wBAAwB,QAAQ,MAAM,QAAQ,IAAI;KAIxD,IAAI,yBAAyB,CAAC,uBAC1B,OAAO;KAMX,MAAM,cAAc,MAAM,QAAQ,YAAY,GAAG,MAAM,QAAQ,MAAM,IAAI;KAIzE,IAAI,QAAQ,KAAK,WAAW,GACxB,OAAO;KAGX,MAAM,wBAAwB,QAC1B,MAAM,eAAe,MAAM,MACtB,SAAS,SAAS,kBAAkB,IACzC,CACJ;KAOA,MAAM,kCAAkC,QACpC,MAAM,eAAe,MAAM,MACtB,SAAS,SAAS,kBAAkB,MACzC,CACJ;KAEA,MAAM,yCACF,yBAAyB,CAAC;KAE9B,MAAM,0BACF,kCACO,KAAK,MACF,MAAM,eAAe,QAAQ,kBAAkB,MAAM,KACjD,IACR,IACA,CAAC;KAEX,MAAM,yDACF,mCAIA,wBAAwB,SAAS,QACjC,wBAAwB,SAAS;KAKrC,IACI,0CACA,wDAEA,OAAO;KAMX,MAAM,qBAAqB,YAAY,QACnC,IAAI,OAAO,QAAQ,kBAAkB,OAAO,IAAI,GAAG,GACnD,MACJ;KAIA,OAAO,SAAS,sBAAsB,kBAAkB;KAGxD,OAAO;IACX;GACJ;EACJ,CAAC,CACL;CACJ;AACJ,CAAC"}
@@ -17,5 +17,5 @@ type RichTextBulletListOptions = {
17
17
  * paragraphs before toggling the selection into a bullet list.
18
18
  */
19
19
  //#endregion
20
- export { type RichTextBulletListOptions };
20
+ export type { RichTextBulletListOptions };
21
21
  //# sourceMappingURL=rich-text-bullet-list.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"rich-text-bullet-list.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-bullet-list.ts"],"mappings":";;;;;AAKsE;KAKjE,yBAAA;;;AAMgB;;EADjB,WAAA;AAAA,IACA,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-bullet-list.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-bullet-list.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-bullet-list'\nimport { ListItem } from '@tiptap/extension-list-item'\nimport { TextStyle } from '@tiptap/extension-text-style'\nimport { Fragment, Slice } from '@tiptap/pm/model'\n\nimport type { BulletListOptions } from '@tiptap/extension-bullet-list'\n\n/**\n * The options available to customize the `RichTextBulletList` extension.\n */\ntype RichTextBulletListOptions = {\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} & BulletListOptions\n\n/**\n * Custom extension that extends the built-in `BulletList` 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 RichTextBulletList = BulletList.extend<RichTextBulletListOptions>({\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 toggleBulletList() {\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.toReversed().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 { RichTextBulletList }\n\nexport type { RichTextBulletListOptions }\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,qBAAqB,WAAW,OAAkC;CACpE,aAAa;EACT,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,aAAa;GAChB;;CAGL,cAAc;EACV,MAAM,EAAE,QAAQ,MAAM,YAAY;EAElC,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,mBAAmB;IACf,QAAQ,EAAE,UAAU,OAAO,IAAI,YAAY;KAEvC,IAAI,QAAQ,aAAa;MACrB,MAAM,EAAE,WAAW;MACnB,MAAM,EAAE,cAAc;MACtB,MAAM,EAAE,OAAO,QAAQ;MAEvB,MAAM,qBAA+B,EAAE;MAGvC,GAAG,IAAI,aAAa,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ;OACnD,IAAI,KAAK,KAAK,SAAS,aACnB,mBAAmB,KAAK,IAAI;QAElC;MAMF,mBAAmB,YAAY,CAAC,SAAS,QAAQ;OAC7C,GAAG,QACC,KACA,MAAM,GACN,MAAM,QACF,SAAS,UAAU,CACf,OAAO,MAAM,UAAU,QAAQ,EAC/B,OAAO,MAAM,UAAU,QAAQ,CAClC,CAAC,CACL,CACJ;QACH;;KAMN,IAAI,QAAQ,gBACR,OAAO,OAAO,CACT,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU,CACzD,iBAAiB,SAAS,MAAM,OAAO,cAAc,UAAU,KAAK,CAAC,CACrE,KAAK;KAGd,OAAO,SAAS,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU;;;GAGpF;;CAER,CAAC"}
1
+ {"version":3,"file":"rich-text-bullet-list.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-bullet-list.ts"],"sourcesContent":["import { BulletList } from '@tiptap/extension-bullet-list'\nimport { ListItem } from '@tiptap/extension-list-item'\nimport { TextStyle } from '@tiptap/extension-text-style'\nimport { Fragment, Slice } from '@tiptap/pm/model'\n\nimport type { BulletListOptions } from '@tiptap/extension-bullet-list'\n\n/**\n * The options available to customize the `RichTextBulletList` extension.\n */\ntype RichTextBulletListOptions = {\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} & BulletListOptions\n\n/**\n * Custom extension that extends the built-in `BulletList` 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 RichTextBulletList = BulletList.extend<RichTextBulletListOptions>({\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 toggleBulletList() {\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.toReversed().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 { RichTextBulletList }\n\nexport type { RichTextBulletListOptions }\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,qBAAqB,WAAW,OAAkC;CACpE,aAAa;EACT,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,aAAa;EACjB;CACJ;CAEA,cAAc;EACV,MAAM,EAAE,QAAQ,MAAM,YAAY;EAElC,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,mBAAmB;IACf,QAAQ,EAAE,UAAU,OAAO,IAAI,YAAY;KAEvC,IAAI,QAAQ,aAAa;MACrB,MAAM,EAAE,WAAW;MACnB,MAAM,EAAE,cAAc;MACtB,MAAM,EAAE,OAAO,QAAQ;MAEvB,MAAM,qBAA+B,CAAC;MAGtC,GAAG,IAAI,aAAa,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ;OACnD,IAAI,KAAK,KAAK,SAAS,aACnB,mBAAmB,KAAK,GAAG;MAEnC,CAAC;MAMD,mBAAmB,WAAW,CAAC,CAAC,SAAS,QAAQ;OAC7C,GAAG,QACC,KACA,MAAM,GACN,MAAM,QACF,SAAS,UAAU,CACf,OAAO,MAAM,UAAU,OAAO,GAC9B,OAAO,MAAM,UAAU,OAAO,CAClC,CAAC,CACL,CACJ;MACJ,CAAC;KACL;KAKA,IAAI,QAAQ,gBACR,OAAO,MAAM,CAAC,CACT,WAAW,MAAM,QAAQ,cAAc,QAAQ,SAAS,CAAC,CACzD,iBAAiB,SAAS,MAAM,OAAO,cAAc,UAAU,IAAI,CAAC,CAAC,CACrE,IAAI;KAGb,OAAO,SAAS,WAAW,MAAM,QAAQ,cAAc,QAAQ,SAAS;IAC5E;GACJ;EACJ;CACJ;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-code.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-code.ts"],"sourcesContent":["import { markInputRule, markPasteRule } from '@tiptap/core'\nimport { Code } from '@tiptap/extension-code'\n\nimport { CODE_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\n\nimport type { CodeOptions } from '@tiptap/extension-code'\n\n/**\n * The options available to customize the `RichTextCode` extension.\n */\ntype RichTextCodeOptions = CodeOptions\n\n/**\n * The original input regex for Markdown inline code (i.e. `<code>code</code>`) to prevent the issue\n * introduced in this PR: https://github.com/ueberdosis/tiptap/pull/4468#issuecomment-2575093998\n */\nconst inputRegex = /(?:^|\\s)(`(?!\\s+`)((?:[^`]+))`(?!\\s+`))$/\n\n/**\n * The original paste regex for Markdown inline code (i.e. `<code>code</code>`) to prevent the issue\n * introduced in this PR: https://github.com/ueberdosis/tiptap/pull/4468#issuecomment-2575093998\n */\nconst pasteRegex = /(?:^|\\s)(`(?!\\s+`)((?:[^`]+))`(?!\\s+`))/g\n\n/**\n * Custom extension that extends the built-in `Code` extension to allow all marks (e.g., Bold,\n * Italic, and Strikethrough) to coexist with the `Code` mark (as opposed to disallowing all any\n * other mark by default).\n *\n * @see https://tiptap.dev/api/schema#excludes\n * @see https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n */\nconst RichTextCode = Code.extend<RichTextCodeOptions>({\n priority: CODE_EXTENSION_PRIORITY,\n excludes: Code.name,\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n\nexport { RichTextCode }\n\nexport type { RichTextCodeOptions }\n"],"mappings":";;;;;;;;AAgBA,MAAM,aAAa;;;;;AAMnB,MAAM,aAAa;;;;;;;;;AAUnB,MAAM,eAAe,KAAK,OAA4B;CAClD,UAAA;CACA,UAAU,KAAK;CACf,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,CACL;;CAEL,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GACd,CAAC,CACL;;CAER,CAAC"}
1
+ {"version":3,"file":"rich-text-code.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-code.ts"],"sourcesContent":["import { markInputRule, markPasteRule } from '@tiptap/core'\nimport { Code } from '@tiptap/extension-code'\n\nimport { CODE_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\n\nimport type { CodeOptions } from '@tiptap/extension-code'\n\n/**\n * The options available to customize the `RichTextCode` extension.\n */\ntype RichTextCodeOptions = CodeOptions\n\n/**\n * The original input regex for Markdown inline code (i.e. `<code>code</code>`) to prevent the issue\n * introduced in this PR: https://github.com/ueberdosis/tiptap/pull/4468#issuecomment-2575093998\n */\nconst inputRegex = /(?:^|\\s)(`(?!\\s+`)((?:[^`]+))`(?!\\s+`))$/\n\n/**\n * The original paste regex for Markdown inline code (i.e. `<code>code</code>`) to prevent the issue\n * introduced in this PR: https://github.com/ueberdosis/tiptap/pull/4468#issuecomment-2575093998\n */\nconst pasteRegex = /(?:^|\\s)(`(?!\\s+`)((?:[^`]+))`(?!\\s+`))/g\n\n/**\n * Custom extension that extends the built-in `Code` extension to allow all marks (e.g., Bold,\n * Italic, and Strikethrough) to coexist with the `Code` mark (as opposed to disallowing all any\n * other mark by default).\n *\n * @see https://tiptap.dev/api/schema#excludes\n * @see https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n */\nconst RichTextCode = Code.extend<RichTextCodeOptions>({\n priority: CODE_EXTENSION_PRIORITY,\n excludes: Code.name,\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n\nexport { RichTextCode }\n\nexport type { RichTextCodeOptions }\n"],"mappings":";;;;;;;;AAgBA,MAAM,aAAa;;;;;AAMnB,MAAM,aAAa;;;;;;;;;AAUnB,MAAM,eAAe,KAAK,OAA4B;CAClD,UAAA;CACA,UAAU,KAAK;CACf,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;EACf,CAAC,CACL;CACJ;CACA,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;EACf,CAAC,CACL;CACJ;AACJ,CAAC"}
@@ -13,5 +13,5 @@ type RichTextDocumentOptions = {
13
13
  * or singleline rich-text documents (as opposed to the multiple block nodes by default).
14
14
  */
15
15
  //#endregion
16
- export { type RichTextDocumentOptions };
16
+ export type { RichTextDocumentOptions };
17
17
  //# sourceMappingURL=rich-text-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-document.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-document.ts"],"mappings":";;;;KAKK,uBAAA;EAAuB;;;EAIxB,SAAA;AAAA"}
1
+ {"version":3,"file":"rich-text-document.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-document.ts"],"mappings":";;;;KAKK,uBAAA;EAIQ;AAAA;;EAAT,SAAS;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-document.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-document.ts"],"sourcesContent":["import { Document } from '@tiptap/extension-document'\n\n/**\n * The options available to customize the `RichTextDocumentOptions` extension.\n */\ntype RichTextDocumentOptions = {\n /**\n * Indicates whether the document accepts multiple lines of input or only a single line.\n */\n multiline: boolean\n}\n\n/**\n * Custom extension that extends the built-in `Document` extension to define a schema for multiline\n * or singleline rich-text documents (as opposed to the multiple block nodes by default).\n */\nconst RichTextDocument = Document.extend<RichTextDocumentOptions>({\n addOptions() {\n return {\n multiline: true,\n }\n },\n content() {\n // ref: https://tiptap.dev/api/schema#content\n return `block${this.options.multiline ? '+' : ''}`\n },\n})\n\nexport { RichTextDocument }\n\nexport type { RichTextDocumentOptions }\n"],"mappings":";;;;;;AAgBA,MAAM,mBAAmB,SAAS,OAAgC;CAC9D,aAAa;EACT,OAAO,EACH,WAAW,MACd;;CAEL,UAAU;EAEN,OAAO,QAAQ,KAAK,QAAQ,YAAY,MAAM;;CAErD,CAAC"}
1
+ {"version":3,"file":"rich-text-document.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-document.ts"],"sourcesContent":["import { Document } from '@tiptap/extension-document'\n\n/**\n * The options available to customize the `RichTextDocumentOptions` extension.\n */\ntype RichTextDocumentOptions = {\n /**\n * Indicates whether the document accepts multiple lines of input or only a single line.\n */\n multiline: boolean\n}\n\n/**\n * Custom extension that extends the built-in `Document` extension to define a schema for multiline\n * or singleline rich-text documents (as opposed to the multiple block nodes by default).\n */\nconst RichTextDocument = Document.extend<RichTextDocumentOptions>({\n addOptions() {\n return {\n multiline: true,\n }\n },\n content() {\n // ref: https://tiptap.dev/api/schema#content\n return `block${this.options.multiline ? '+' : ''}`\n },\n})\n\nexport { RichTextDocument }\n\nexport type { RichTextDocumentOptions }\n"],"mappings":";;;;;;AAgBA,MAAM,mBAAmB,SAAS,OAAgC;CAC9D,aAAa;EACT,OAAO,EACH,WAAW,KACf;CACJ;CACA,UAAU;EAEN,OAAO,QAAQ,KAAK,QAAQ,YAAY,MAAM;CAClD;AACJ,CAAC"}
@@ -17,5 +17,5 @@ type RichTextHeadingOptions = HeadingOptions;
17
17
  * @see https://github.com/ueberdosis/tiptap/pull/6832
18
18
  */
19
19
  //#endregion
20
- export { type RichTextHeadingOptions };
20
+ export type { RichTextHeadingOptions };
21
21
  //# sourceMappingURL=rich-text-heading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-heading.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-heading.ts"],"mappings":";;;;;;KAQK,sBAAA,GAAyB,cAAA"}
1
+ {"version":3,"file":"rich-text-heading.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-heading.ts"],"mappings":";;;;;AAG+D;KAK1D,sBAAA,GAAyB,cAAc;;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-heading.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-heading.ts"],"sourcesContent":["import { Heading } from '@tiptap/extension-heading'\nimport { textblockTypeInputRule } from '@tiptap/react'\n\nimport type { HeadingOptions } from '@tiptap/extension-heading'\n\n/**\n * The options available to customize the `RichTextHeading` extension.\n */\ntype RichTextHeadingOptions = HeadingOptions\n\n/**\n * Custom extension that extends the built-in `Heading` extension to override the input rule for\n * headings to trigger only on space (e.g., `## `), preventing conflicts with suggestion extensions\n * that use `#` as their trigger character.\n *\n * This was properly fixed in Tiptap v3 where input rules respect extension priorities, making this\n * extension likely unnecessary after migrating.\n *\n * @see https://github.com/ueberdosis/tiptap/issues/2570\n * @see https://github.com/ueberdosis/tiptap/pull/6832\n */\nconst RichTextHeading = Heading.extend<RichTextHeadingOptions>({\n addInputRules() {\n return this.options.levels.map((level: number) => {\n return textblockTypeInputRule({\n find: new RegExp(`^(#{1,${level}}) $`),\n type: this.type,\n getAttributes: {\n level,\n },\n })\n })\n },\n})\n\nexport { RichTextHeading }\n\nexport type { RichTextHeadingOptions }\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,kBAAkB,QAAQ,OAA+B,EAC3D,gBAAgB;CACZ,OAAO,KAAK,QAAQ,OAAO,KAAK,UAAkB;EAC9C,OAAO,uBAAuB;GAC1B,MAAM,IAAI,OAAO,SAAS,MAAM,MAAM;GACtC,MAAM,KAAK;GACX,eAAe,EACX,OACH;GACJ,CAAC;GACJ;GAET,CAAC"}
1
+ {"version":3,"file":"rich-text-heading.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-heading.ts"],"sourcesContent":["import { Heading } from '@tiptap/extension-heading'\nimport { textblockTypeInputRule } from '@tiptap/react'\n\nimport type { HeadingOptions } from '@tiptap/extension-heading'\n\n/**\n * The options available to customize the `RichTextHeading` extension.\n */\ntype RichTextHeadingOptions = HeadingOptions\n\n/**\n * Custom extension that extends the built-in `Heading` extension to override the input rule for\n * headings to trigger only on space (e.g., `## `), preventing conflicts with suggestion extensions\n * that use `#` as their trigger character.\n *\n * This was properly fixed in Tiptap v3 where input rules respect extension priorities, making this\n * extension likely unnecessary after migrating.\n *\n * @see https://github.com/ueberdosis/tiptap/issues/2570\n * @see https://github.com/ueberdosis/tiptap/pull/6832\n */\nconst RichTextHeading = Heading.extend<RichTextHeadingOptions>({\n addInputRules() {\n return this.options.levels.map((level: number) => {\n return textblockTypeInputRule({\n find: new RegExp(`^(#{1,${level}}) $`),\n type: this.type,\n getAttributes: {\n level,\n },\n })\n })\n },\n})\n\nexport { RichTextHeading }\n\nexport type { RichTextHeadingOptions }\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,kBAAkB,QAAQ,OAA+B,EAC3D,gBAAgB;CACZ,OAAO,KAAK,QAAQ,OAAO,KAAK,UAAkB;EAC9C,OAAO,uBAAuB;GAC1B,MAAM,IAAI,OAAO,SAAS,MAAM,KAAK;GACrC,MAAM,KAAK;GACX,eAAe,EACX,MACJ;EACJ,CAAC;CACL,CAAC;AACL,EACJ,CAAC"}
@@ -72,5 +72,5 @@ type RichTextImageOptions = {
72
72
  * and also adds the ability to pass aditional metadata about an image attachment upload.
73
73
  */
74
74
  //#endregion
75
- export { type RichTextImageAttributes, type RichTextImageOptions };
75
+ export type { RichTextImageAttributes, RichTextImageOptions };
76
76
  //# sourceMappingURL=rich-text-image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-image.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"mappings":";;;;;;KAUK,uBAAA;EAAuB;;;EAIxB,QAAA;IAiBa;;;IAbT,YAAA;IAaA;;;IARA,cAAA;IAKA;;;IAAA,cAAA;EAAA;AAAA,IAEJ,IAAA,CAAK,gBAAA,WACL,IAAA,CAAK,OAAA,CAAQ,gBAAA;;;AAAgB;;;YAOnB,QAAA;IACN,aAAA;MAU4B;;;MANxB,WAAA,GAAc,UAAA,EAAY,uBAAA,KAA4B,UAAA;MAO9C;;;MAFR,WAAA,GACI,UAAA,EAAY,OAAA,CAAQ,uBAAA,IAChB,QAAA,CAAS,IAAA,CAAK,uBAAA,mBACjB,UAAA;IAAA;EAAA;AAAA;;;;KAQZ,oBAAA;EAXO;;;EAeR,sBAAA;EAbyB;;;;EAmBzB,MAAA;EAlBuB;;AAAA;EAuBvB,cAAA,EAAgB,MAAA;;;;EAKhB,iBAAA,GAAoB,KAAA,CAAM,aAAA,CAAc,kBAAA;EAKd;;;EAA1B,gBAAA,IAAoB,IAAA,EAAM,IAAA;AAAA"}
1
+ {"version":3,"file":"rich-text-image.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"mappings":";;;;;AAKuD;KAKlD,uBAAA;;;;EAID,QAAA;IAiBK;;;IAbD,YAAA;IAJJ;;;IASI,cAAA;IAOJ;;;IAFI,cAAA;EAAA;AAAA,IAEJ,IAAA,CAAK,gBAAA,WACL,IAAA,CAAK,OAAA,CAAQ,gBAAA;AAAgB;AAAA;;;AAAA;EAAA,UAOnB,QAAA;IACN,aAAA;MAUoB;;;MANhB,WAAA,GAAc,UAAA,EAAY,uBAAA,KAA4B,UAAA;MAQjD;;;MAHL,WAAA,GACI,UAAA,EAAY,OAAA,CAAQ,uBAAA,IAChB,QAAA,CAAS,IAAA,CAAK,uBAAA,mBACjB,UAAA;IAAA;EAAA;AAAA;;;;KAQZ,oBAAA;EAVuB;;;EAcxB,sBAAA;EAb8B;;;;EAmB9B,MAAA;EAlBuB;AAAA;;EAuBvB,cAAA,EAAgB,MAAA;EAAA;;;EAKhB,iBAAA,GAAoB,KAAA,CAAM,aAAA,CAAc,kBAAA;EAKV;;;EAA9B,gBAAA,IAAoB,IAAA,EAAM,IAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-image.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"sourcesContent":["import { Image } from '@tiptap/extension-image'\nimport { Plugin, PluginKey, Selection } from '@tiptap/pm/state'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\n\nimport type { NodeView } from '@tiptap/pm/view'\nimport type { ReactNodeViewProps } from '@tiptap/react'\n\n/**\n * The properties that describe `RichTextImage` node attributes.\n */\ntype RichTextImageAttributes = {\n /**\n * Additional metadata about an image attachment upload.\n */\n metadata?: {\n /**\n * A unique ID for the image attachment.\n */\n attachmentId: string\n\n /**\n * Specifies if the image attachment failed to upload.\n */\n isUploadFailed: boolean\n\n /**\n * The upload progress for the image attachment.\n */\n uploadProgress: number\n }\n} & Pick<HTMLImageElement, 'src'> &\n Pick<Partial<HTMLImageElement>, 'alt' | 'title'>\n\n/**\n * Augment the official `@tiptap/core` module with extra commands, relevant for this extension, so\n * that the compiler knows about them.\n */\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n richTextImage: {\n /**\n * Inserts an image into the editor with the given attributes.\n */\n insertImage: (attributes: RichTextImageAttributes) => ReturnType\n\n /**\n * Updates the attributes for an existing image in the editor.\n */\n updateImage: (\n attributes: Partial<RichTextImageAttributes> &\n Required<Pick<RichTextImageAttributes, 'metadata'>>,\n ) => ReturnType\n }\n }\n}\n\n/**\n * The options available to customize the `RichTextImage` extension.\n */\ntype RichTextImageOptions = {\n /**\n * A list of accepted MIME types for images pasting.\n */\n acceptedImageMimeTypes: string[]\n\n /**\n * Renders the image node inline (e.g., <p><img src=\"doist.jpg\"></p>). By default images are on\n * the same level as paragraphs.\n */\n inline: boolean\n\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: Record<string, string>\n\n /**\n * A React component to render inside the interactive node view.\n */\n NodeViewComponent?: React.ComponentType<ReactNodeViewProps>\n\n /**\n * The event handler that is fired when an image file is pasted.\n */\n onImageFilePaste?: (file: File) => void\n}\n\n/**\n * Custom extension that extends the built-in `Image` extension to add support for image pasting,\n * and also adds the ability to pass aditional metadata about an image attachment upload.\n */\nconst RichTextImage = Image.extend<RichTextImageOptions>({\n draggable: true,\n addOptions() {\n return {\n ...this.parent?.(),\n acceptedImageMimeTypes: ['image/gif', 'image/jpeg', 'image/jpg', 'image/png'],\n NodeViewComponent: undefined,\n }\n },\n addAttributes() {\n return {\n ...this.parent?.(),\n metadata: {\n default: null,\n rendered: false,\n },\n }\n },\n addCommands() {\n const { name: nodeTypeName } = this\n\n return {\n ...this.parent?.(),\n insertImage(attributes) {\n return ({ editor, commands }) => {\n const selectionAtEnd = Selection.atEnd(editor.state.doc)\n\n return commands.insertContent([\n {\n type: nodeTypeName,\n attrs: attributes,\n },\n // Insert a blank paragraph after the image when at the end of the document\n ...(editor.state.selection.to === selectionAtEnd.to\n ? [{ type: 'paragraph' }]\n : []),\n ])\n }\n },\n updateImage(attributes) {\n return ({ commands }) => {\n return commands.command(({ tr }) => {\n tr.doc.descendants((node, position) => {\n const { metadata } = node.attrs as {\n metadata: RichTextImageAttributes['metadata']\n }\n\n // Update the image attributes to the corresponding node\n if (\n node.type.name === nodeTypeName &&\n metadata?.attachmentId === attributes.metadata?.attachmentId\n ) {\n tr.setNodeMarkup(position, node.type, {\n ...node.attrs,\n ...attributes,\n })\n }\n })\n\n return true\n })\n }\n },\n }\n },\n addNodeView() {\n const { NodeViewComponent } = this.options\n\n // Do not add a node view if component was not specified\n if (!NodeViewComponent) {\n return () => ({}) as NodeView\n }\n\n // Render the node view with the provided React component\n return ReactNodeViewRenderer(NodeViewComponent, {\n as: 'div',\n className: `Typist-${this.type.name}`,\n })\n },\n addProseMirrorPlugins() {\n const { acceptedImageMimeTypes, onImageFilePaste } = this.options\n\n return [\n new Plugin({\n key: new PluginKey(this.name),\n props: {\n handlePaste(_, event) {\n // Do not handle the event if we don't have a callback\n if (!onImageFilePaste) {\n return false\n }\n\n const pastedFiles = Array.from(event.clipboardData?.files || [])\n\n // Do not handle the event if no files were pasted\n if (pastedFiles.length === 0) {\n return false\n }\n\n let wasPasteHandled = false\n\n // Invoke the callback for every pasted file that is an accepted image type\n pastedFiles.forEach((pastedFile) => {\n if (acceptedImageMimeTypes.includes(pastedFile.type)) {\n onImageFilePaste(pastedFile)\n wasPasteHandled = true\n }\n })\n\n // Suppress the default handling behaviour if at least one image was handled\n return wasPasteHandled\n },\n },\n }),\n ]\n },\n})\n\nexport { RichTextImage }\n\nexport type { RichTextImageAttributes, RichTextImageOptions }\n"],"mappings":";;;;;;;;AA2FA,MAAM,gBAAgB,MAAM,OAA6B;CACrD,WAAW;CACX,aAAa;EACT,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,wBAAwB;IAAC;IAAa;IAAc;IAAa;IAAY;GAC7E,mBAAmB,KAAA;GACtB;;CAEL,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,UAAU;IACN,SAAS;IACT,UAAU;IACb;GACJ;;CAEL,cAAc;EACV,MAAM,EAAE,MAAM,iBAAiB;EAE/B,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,YAAY,YAAY;IACpB,QAAQ,EAAE,QAAQ,eAAe;KAC7B,MAAM,iBAAiB,UAAU,MAAM,OAAO,MAAM,IAAI;KAExD,OAAO,SAAS,cAAc,CAC1B;MACI,MAAM;MACN,OAAO;MACV,EAED,GAAI,OAAO,MAAM,UAAU,OAAO,eAAe,KAC3C,CAAC,EAAE,MAAM,aAAa,CAAC,GACvB,EAAE,CACX,CAAC;;;GAGV,YAAY,YAAY;IACpB,QAAQ,EAAE,eAAe;KACrB,OAAO,SAAS,SAAS,EAAE,SAAS;MAChC,GAAG,IAAI,aAAa,MAAM,aAAa;OACnC,MAAM,EAAE,aAAa,KAAK;OAK1B,IACI,KAAK,KAAK,SAAS,gBACnB,UAAU,iBAAiB,WAAW,UAAU,cAEhD,GAAG,cAAc,UAAU,KAAK,MAAM;QAClC,GAAG,KAAK;QACR,GAAG;QACN,CAAC;QAER;MAEF,OAAO;OACT;;;GAGb;;CAEL,cAAc;EACV,MAAM,EAAE,sBAAsB,KAAK;EAGnC,IAAI,CAAC,mBACD,cAAc,EAAE;EAIpB,OAAO,sBAAsB,mBAAmB;GAC5C,IAAI;GACJ,WAAW,UAAU,KAAK,KAAK;GAClC,CAAC;;CAEN,wBAAwB;EACpB,MAAM,EAAE,wBAAwB,qBAAqB,KAAK;EAE1D,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,KAAK,KAAK;GAC7B,OAAO,EACH,YAAY,GAAG,OAAO;IAElB,IAAI,CAAC,kBACD,OAAO;IAGX,MAAM,cAAc,MAAM,KAAK,MAAM,eAAe,SAAS,EAAE,CAAC;IAGhE,IAAI,YAAY,WAAW,GACvB,OAAO;IAGX,IAAI,kBAAkB;IAGtB,YAAY,SAAS,eAAe;KAChC,IAAI,uBAAuB,SAAS,WAAW,KAAK,EAAE;MAClD,iBAAiB,WAAW;MAC5B,kBAAkB;;MAExB;IAGF,OAAO;MAEd;GACJ,CAAC,CACL;;CAER,CAAC"}
1
+ {"version":3,"file":"rich-text-image.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"sourcesContent":["import { Image } from '@tiptap/extension-image'\nimport { Plugin, PluginKey, Selection } from '@tiptap/pm/state'\nimport { ReactNodeViewRenderer } from '@tiptap/react'\n\nimport type { NodeView } from '@tiptap/pm/view'\nimport type { ReactNodeViewProps } from '@tiptap/react'\n\n/**\n * The properties that describe `RichTextImage` node attributes.\n */\ntype RichTextImageAttributes = {\n /**\n * Additional metadata about an image attachment upload.\n */\n metadata?: {\n /**\n * A unique ID for the image attachment.\n */\n attachmentId: string\n\n /**\n * Specifies if the image attachment failed to upload.\n */\n isUploadFailed: boolean\n\n /**\n * The upload progress for the image attachment.\n */\n uploadProgress: number\n }\n} & Pick<HTMLImageElement, 'src'> &\n Pick<Partial<HTMLImageElement>, 'alt' | 'title'>\n\n/**\n * Augment the official `@tiptap/core` module with extra commands, relevant for this extension, so\n * that the compiler knows about them.\n */\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n richTextImage: {\n /**\n * Inserts an image into the editor with the given attributes.\n */\n insertImage: (attributes: RichTextImageAttributes) => ReturnType\n\n /**\n * Updates the attributes for an existing image in the editor.\n */\n updateImage: (\n attributes: Partial<RichTextImageAttributes> &\n Required<Pick<RichTextImageAttributes, 'metadata'>>,\n ) => ReturnType\n }\n }\n}\n\n/**\n * The options available to customize the `RichTextImage` extension.\n */\ntype RichTextImageOptions = {\n /**\n * A list of accepted MIME types for images pasting.\n */\n acceptedImageMimeTypes: string[]\n\n /**\n * Renders the image node inline (e.g., <p><img src=\"doist.jpg\"></p>). By default images are on\n * the same level as paragraphs.\n */\n inline: boolean\n\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: Record<string, string>\n\n /**\n * A React component to render inside the interactive node view.\n */\n NodeViewComponent?: React.ComponentType<ReactNodeViewProps>\n\n /**\n * The event handler that is fired when an image file is pasted.\n */\n onImageFilePaste?: (file: File) => void\n}\n\n/**\n * Custom extension that extends the built-in `Image` extension to add support for image pasting,\n * and also adds the ability to pass aditional metadata about an image attachment upload.\n */\nconst RichTextImage = Image.extend<RichTextImageOptions>({\n draggable: true,\n addOptions() {\n return {\n ...this.parent?.(),\n acceptedImageMimeTypes: ['image/gif', 'image/jpeg', 'image/jpg', 'image/png'],\n NodeViewComponent: undefined,\n }\n },\n addAttributes() {\n return {\n ...this.parent?.(),\n metadata: {\n default: null,\n rendered: false,\n },\n }\n },\n addCommands() {\n const { name: nodeTypeName } = this\n\n return {\n ...this.parent?.(),\n insertImage(attributes) {\n return ({ editor, commands }) => {\n const selectionAtEnd = Selection.atEnd(editor.state.doc)\n\n return commands.insertContent([\n {\n type: nodeTypeName,\n attrs: attributes,\n },\n // Insert a blank paragraph after the image when at the end of the document\n ...(editor.state.selection.to === selectionAtEnd.to\n ? [{ type: 'paragraph' }]\n : []),\n ])\n }\n },\n updateImage(attributes) {\n return ({ commands }) => {\n return commands.command(({ tr }) => {\n tr.doc.descendants((node, position) => {\n const { metadata } = node.attrs as {\n metadata: RichTextImageAttributes['metadata']\n }\n\n // Update the image attributes to the corresponding node\n if (\n node.type.name === nodeTypeName &&\n metadata?.attachmentId === attributes.metadata?.attachmentId\n ) {\n tr.setNodeMarkup(position, node.type, {\n ...node.attrs,\n ...attributes,\n })\n }\n })\n\n return true\n })\n }\n },\n }\n },\n addNodeView() {\n const { NodeViewComponent } = this.options\n\n // Do not add a node view if component was not specified\n if (!NodeViewComponent) {\n return () => ({}) as NodeView\n }\n\n // Render the node view with the provided React component\n return ReactNodeViewRenderer(NodeViewComponent, {\n as: 'div',\n className: `Typist-${this.type.name}`,\n })\n },\n addProseMirrorPlugins() {\n const { acceptedImageMimeTypes, onImageFilePaste } = this.options\n\n return [\n new Plugin({\n key: new PluginKey(this.name),\n props: {\n handlePaste(_, event) {\n // Do not handle the event if we don't have a callback\n if (!onImageFilePaste) {\n return false\n }\n\n const pastedFiles = Array.from(event.clipboardData?.files || [])\n\n // Do not handle the event if no files were pasted\n if (pastedFiles.length === 0) {\n return false\n }\n\n let wasPasteHandled = false\n\n // Invoke the callback for every pasted file that is an accepted image type\n pastedFiles.forEach((pastedFile) => {\n if (acceptedImageMimeTypes.includes(pastedFile.type)) {\n onImageFilePaste(pastedFile)\n wasPasteHandled = true\n }\n })\n\n // Suppress the default handling behaviour if at least one image was handled\n return wasPasteHandled\n },\n },\n }),\n ]\n },\n})\n\nexport { RichTextImage }\n\nexport type { RichTextImageAttributes, RichTextImageOptions }\n"],"mappings":";;;;;;;;AA2FA,MAAM,gBAAgB,MAAM,OAA6B;CACrD,WAAW;CACX,aAAa;EACT,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,wBAAwB;IAAC;IAAa;IAAc;IAAa;GAAW;GAC5E,mBAAmB,KAAA;EACvB;CACJ;CACA,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,UAAU;IACN,SAAS;IACT,UAAU;GACd;EACJ;CACJ;CACA,cAAc;EACV,MAAM,EAAE,MAAM,iBAAiB;EAE/B,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,YAAY,YAAY;IACpB,QA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OAAA,CAAQ,4BAAA;EApBhB;;;EAyBA,IAAA;EALA;;;EAUA,UAAA;AAAA;;AAAU;AAAA;;;cAQR,WAAA,EAAW,SAAA,CAAA,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-kit.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-kit.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Blockquote } from '@tiptap/extension-blockquote'\nimport { Bold } from '@tiptap/extension-bold'\nimport { CodeBlock } from '@tiptap/extension-code-block'\nimport { Dropcursor } from '@tiptap/extension-dropcursor'\nimport { Gapcursor } from '@tiptap/extension-gapcursor'\nimport { HardBreak } from '@tiptap/extension-hard-break'\nimport { History } from '@tiptap/extension-history'\nimport { HorizontalRule } from '@tiptap/extension-horizontal-rule'\nimport { Italic } from '@tiptap/extension-italic'\nimport { ListItem } from '@tiptap/extension-list-item'\nimport { ListKeymap } from '@tiptap/extension-list-keymap'\nimport { Paragraph } from '@tiptap/extension-paragraph'\nimport { Text } from '@tiptap/extension-text'\nimport { Typography } from '@tiptap/extension-typography'\n\nimport { BLOCKQUOTE_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\nimport { CopyMarkdownSource } from '../shared/copy-markdown-source'\nimport { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string'\nimport { PasteSinglelineText } from '../shared/paste-singleline-text'\n\nimport { BoldAndItalics } from './bold-and-italics'\nimport { CurvenoteCodemark } from './curvenote-codemark'\nimport { PasteEmojis } from './paste-emojis'\nimport { PasteMarkdown } from './paste-markdown'\nimport { RichTextBulletList } from './rich-text-bullet-list'\nimport { RichTextCode } from './rich-text-code'\nimport { RichTextDocument } from './rich-text-document'\nimport { RichTextHeading, RichTextHeadingOptions } from './rich-text-heading'\nimport { RichTextImage } from './rich-text-image'\nimport { RichTextLink } from './rich-text-link'\nimport { RichTextOrderedList } from './rich-text-ordered-list'\nimport { RichTextStrikethrough } from './rich-text-strikethrough'\n\nimport type { Extensions } from '@tiptap/core'\nimport type { BlockquoteOptions } from '@tiptap/extension-blockquote'\nimport type { BoldOptions } from '@tiptap/extension-bold'\nimport type { CodeOptions } from '@tiptap/extension-code'\nimport type { CodeBlockOptions } from '@tiptap/extension-code-block'\nimport type { DropcursorOptions } from '@tiptap/extension-dropcursor'\nimport type { HardBreakOptions } from '@tiptap/extension-hard-break'\nimport type { HistoryOptions } from '@tiptap/extension-history'\nimport type { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule'\nimport type { ItalicOptions } from '@tiptap/extension-italic'\nimport type { ListItemOptions } from '@tiptap/extension-list-item'\nimport type { ListKeymapOptions } from '@tiptap/extension-list-keymap'\nimport type { ParagraphOptions } from '@tiptap/extension-paragraph'\nimport type { RichTextBulletListOptions } from './rich-text-bullet-list'\nimport type { RichTextDocumentOptions } from './rich-text-document'\nimport type { RichTextImageOptions } from './rich-text-image'\nimport type { RichTextLinkOptions } from './rich-text-link'\nimport type { RichTextOrderedListOptions } from './rich-text-ordered-list'\nimport type { RichTextStrikethroughOptions } from './rich-text-strikethrough'\n\n/**\n * The options available to customize the `RichTextKit` extension.\n */\ntype RichTextKitOptions = {\n /**\n * Set options for the `Blockquote` extension, or `false` to disable.\n */\n blockquote: Partial<BlockquoteOptions> | false\n\n /**\n * Set options for the `Bold` extension, or `false` to disable.\n */\n bold: Partial<BoldOptions> | false\n\n /**\n * Set options for the `BulletList` extension, or `false` to disable.\n */\n bulletList: Partial<RichTextBulletListOptions> | false\n\n /**\n * Set options for the `Code` extension, or `false` to disable.\n */\n code: Partial<CodeOptions> | false\n\n /**\n * Set options for the `CodeBlock` extension, or `false` to disable.\n */\n codeBlock: Partial<CodeBlockOptions> | false\n\n /**\n * Set options for the `Document` extension, or `false` to disable.\n */\n document: Partial<RichTextDocumentOptions> | false\n\n /**\n * Set options for the `Dropcursor` extension, or `false` to disable.\n */\n dropCursor: Partial<DropcursorOptions> | false\n\n /**\n * Set to `false` to disable the `Gapcursor` extension.\n */\n gapCursor: false\n\n /**\n * Set options for the `HardBreak` extension, or `false` to disable.\n */\n hardBreak: Partial<HardBreakOptions> | false\n\n /**\n * Set options for the `Heading` extension, or `false` to disable.\n */\n heading: Partial<RichTextHeadingOptions> | false\n\n /**\n * Set options for the `History` extension, or `false` to disable.\n */\n history: Partial<HistoryOptions> | false\n\n /**\n * Set options for the `HorizontalRule` extension, or `false` to disable.\n */\n horizontalRule: Partial<HorizontalRuleOptions> | false\n\n /**\n * Set options for the `Image` extension, or `false` to disable.\n */\n image: Partial<RichTextImageOptions> | false\n\n /**\n * Set options for the `Italic` extension, or `false` to disable.\n */\n italic: Partial<ItalicOptions> | false\n\n /**\n * Set options for the `Link` extension, or `false` to disable.\n */\n link: Partial<RichTextLinkOptions> | false\n\n /**\n * Set options for the `ListItem` extension, or `false` to disable.\n */\n listItem: Partial<ListItemOptions> | false\n\n /**\n * Set options for the `ListKeymap` extension, or `false` to disable.\n */\n listKeymap: Partial<ListKeymapOptions> | false\n\n /**\n * Set options for the `OrderedList` extension, or `false` to disable.\n */\n orderedList: Partial<RichTextOrderedListOptions> | false\n\n /**\n * Set options for the `Paragraph` extension, or `false` to disable.\n */\n paragraph: Partial<ParagraphOptions> | false\n\n /**\n * Set to `false` to disable the `PasteEmojis` extension.\n */\n pasteEmojis: false\n\n /**\n * Set to `false` to disable the `PasteMarkdown` extension.\n */\n pasteMarkdown: false\n\n /**\n * Set to `false` to disable the `PasteSinglelineText` extension.\n */\n pasteSinglelineText: false\n\n /**\n * Set to `false` to disable the `PasteHTMLTableAsString` extension.\n */\n pasteHTMLTableAsString: false\n\n /**\n * Set options for the `Strike` extension, or `false` to disable.\n */\n strike: Partial<RichTextStrikethroughOptions> | false\n\n /**\n * Set to `false` to disable the `Text` extension.\n */\n text: false\n\n /**\n * Set to `false` to disable the `Typography` extension.\n */\n typography: false\n}\n\n/**\n * The `RichTextKit` extension is a collection of the minimal required extensions to have a full\n * WYSIWYG text editor working. This extension is based on the official `StarterKit` extension\n * implementation, allowing almost every extension to be customized or disabled.\n */\nconst RichTextKit = Extension.create<RichTextKitOptions>({\n name: 'richTextKit',\n addExtensions() {\n const extensions: Extensions = []\n\n if (this.options.blockquote !== false) {\n extensions.push(\n Blockquote.extend({\n priority: BLOCKQUOTE_EXTENSION_PRIORITY,\n }).configure(this.options?.blockquote),\n )\n }\n\n if (this.options.bold !== false) {\n extensions.push(Bold.configure(this.options?.bold))\n }\n\n if (this.options.bulletList !== false) {\n extensions.push(RichTextBulletList.configure(this.options?.bulletList))\n }\n\n if (this.options.code !== false) {\n extensions.push(\n RichTextCode.configure(this.options?.code),\n\n // Enhances the Code extension capabilities with additional features\n CurvenoteCodemark,\n )\n }\n\n if (this.options.codeBlock !== false) {\n extensions.push(CodeBlock.configure(this.options?.codeBlock))\n }\n\n if (this.options.document !== false) {\n extensions.push(\n RichTextDocument.configure(this.options?.document),\n\n // Supports copying the underlying Markdown source to the clipboard\n CopyMarkdownSource.configure({\n keyboardShortcut: 'Mod-Shift-c',\n }),\n )\n\n if (this.options?.pasteEmojis !== false) {\n // Supports pasting HTML image emojis as unicode characters\n extensions.push(PasteEmojis)\n }\n\n if (this.options?.pasteMarkdown !== false) {\n // Supports pasting Markdown content as HTML into the editor\n extensions.push(PasteMarkdown)\n }\n\n if (\n this.options?.document?.multiline === false &&\n this.options?.pasteSinglelineText !== false\n ) {\n // Supports pasting multiple lines into a singleline editor, by joining all the\n // pasted lines together\n extensions.push(PasteSinglelineText)\n }\n\n if (this.options?.pasteHTMLTableAsString !== false) {\n // Supports pasting tables (from spreadsheets and websites) into the editor\n extensions.push(PasteHTMLTableAsString)\n }\n }\n\n if (this.options.dropCursor !== false) {\n extensions.push(Dropcursor.configure(this.options?.dropCursor))\n }\n\n if (this.options.gapCursor !== false) {\n extensions.push(Gapcursor)\n }\n\n if (this.options.hardBreak !== false) {\n extensions.push(HardBreak.configure(this.options?.hardBreak))\n }\n\n if (this.options.heading !== false) {\n extensions.push(RichTextHeading.configure(this.options?.heading))\n }\n\n if (this.options.history !== false) {\n extensions.push(History.configure(this.options?.history))\n }\n\n if (this.options.horizontalRule !== false) {\n extensions.push(HorizontalRule.configure(this.options?.horizontalRule))\n }\n\n if (this.options.image !== false) {\n extensions.push(RichTextImage.configure(this.options?.image))\n }\n\n if (this.options.italic !== false) {\n extensions.push(Italic.configure(this.options?.italic))\n }\n\n if (this.options.bold !== false && this.options.italic !== false) {\n extensions.push(BoldAndItalics)\n }\n\n if (this.options.link !== false) {\n extensions.push(RichTextLink.configure(this.options?.link))\n }\n\n if (this.options.listItem !== false) {\n extensions.push(ListItem.configure(this.options?.listItem))\n }\n\n if (this.options.listKeymap !== false) {\n extensions.push(ListKeymap.configure(this.options?.listKeymap))\n }\n\n if (this.options.orderedList !== false) {\n extensions.push(RichTextOrderedList.configure(this.options?.orderedList))\n }\n\n if (this.options.paragraph !== false) {\n extensions.push(Paragraph.configure(this.options?.paragraph))\n }\n\n if (this.options.strike !== false) {\n extensions.push(RichTextStrikethrough.configure(this.options?.strike))\n }\n\n if (this.options.text !== false) {\n extensions.push(Text)\n }\n\n if (this.options.typography !== false) {\n extensions.push(Typography)\n }\n\n return extensions\n },\n})\n\nexport { RichTextKit }\n\nexport type { RichTextKitOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,MAAM,cAAc,UAAU,OAA2B;CACrD,MAAM;CACN,gBAAgB;EACZ,MAAM,aAAyB,EAAE;EAEjC,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KACP,WAAW,OAAO,EACd,UAAA,KACH,CAAC,CAAC,UAAU,KAAK,SAAS,WAAW,CACzC;EAGL,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KAAK,KAAK,UAAU,KAAK,SAAS,KAAK,CAAC;EAGvD,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,mBAAmB,UAAU,KAAK,SAAS,WAAW,CAAC;EAG3E,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KACP,aAAa,U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SAAS,SAAS,KAAK,QAAQ,WAAW,OACvD,WAAW,KAAK,eAAe;EAGnC,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KAAK,aAAa,UAAU,KAAK,SAAS,KAAK,CAAC;EAG/D,IAAI,KAAK,QAAQ,aAAa,OAC1B,WAAW,KAAK,SAAS,UAAU,KAAK,SAAS,SAAS,CAAC;EAG/D,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,WAAW,UAAU,KAAK,SAAS,WAAW,CAAC;EAGnE,IAAI,KAAK,QAAQ,gBAAgB,OAC7B,WAAW,KAAK,oBAAoB,UAAU,KAAK,SAAS,YAAY,CAAC;EAG7E,IAAI,KAAK,QAAQ,cAAc,OAC3B,WAAW,KAAK,UAAU,UAAU,KAAK,SAAS,UAAU,CAAC;EAGjE,IAAI,KAAK,QAAQ,WAAW,OACxB,WAAW,KAAK,sBAAsB,UAAU,KAAK,SAAS,OAAO,CAAC;EAG1E,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KAAK,KAAK;EAGzB,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,WAAW;EAG/B,OAAO;;CAEd,CAAC"}
1
+ {"version":3,"file":"rich-text-kit.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-kit.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Blockquote } from '@tiptap/extension-blockquote'\nimport { Bold } from '@tiptap/extension-bold'\nimport { CodeBlock } from '@tiptap/extension-code-block'\nimport { Dropcursor } from '@tiptap/extension-dropcursor'\nimport { Gapcursor } from '@tiptap/extension-gapcursor'\nimport { HardBreak } from '@tiptap/extension-hard-break'\nimport { History } from '@tiptap/extension-history'\nimport { HorizontalRule } from '@tiptap/extension-horizontal-rule'\nimport { Italic } from '@tiptap/extension-italic'\nimport { ListItem } from '@tiptap/extension-list-item'\nimport { ListKeymap } from '@tiptap/extension-list-keymap'\nimport { Paragraph } from '@tiptap/extension-paragraph'\nimport { Text } from '@tiptap/extension-text'\nimport { Typography } from '@tiptap/extension-typography'\n\nimport { BLOCKQUOTE_EXTENSION_PRIORITY } from '../../constants/extension-priorities'\nimport { CopyMarkdownSource } from '../shared/copy-markdown-source'\nimport { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string'\nimport { PasteSinglelineText } from '../shared/paste-singleline-text'\n\nimport { BoldAndItalics } from './bold-and-italics'\nimport { CurvenoteCodemark } from './curvenote-codemark'\nimport { PasteEmojis } from './paste-emojis'\nimport { PasteMarkdown } from './paste-markdown'\nimport { RichTextBulletList } from './rich-text-bullet-list'\nimport { RichTextCode } from './rich-text-code'\nimport { RichTextDocument } from './rich-text-document'\nimport { RichTextHeading, RichTextHeadingOptions } from './rich-text-heading'\nimport { RichTextImage } from './rich-text-image'\nimport { RichTextLink } from './rich-text-link'\nimport { RichTextOrderedList } from './rich-text-ordered-list'\nimport { RichTextStrikethrough } from './rich-text-strikethrough'\n\nimport type { Extensions } from '@tiptap/core'\nimport type { BlockquoteOptions } from '@tiptap/extension-blockquote'\nimport type { BoldOptions } from '@tiptap/extension-bold'\nimport type { CodeOptions } from '@tiptap/extension-code'\nimport type { CodeBlockOptions } from '@tiptap/extension-code-block'\nimport type { DropcursorOptions } from '@tiptap/extension-dropcursor'\nimport type { HardBreakOptions } from '@tiptap/extension-hard-break'\nimport type { HistoryOptions } from '@tiptap/extension-history'\nimport type { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule'\nimport type { ItalicOptions } from '@tiptap/extension-italic'\nimport type { ListItemOptions } from '@tiptap/extension-list-item'\nimport type { ListKeymapOptions } from '@tiptap/extension-list-keymap'\nimport type { ParagraphOptions } from '@tiptap/extension-paragraph'\nimport type { RichTextBulletListOptions } from './rich-text-bullet-list'\nimport type { RichTextDocumentOptions } from './rich-text-document'\nimport type { RichTextImageOptions } from './rich-text-image'\nimport type { RichTextLinkOptions } from './rich-text-link'\nimport type { RichTextOrderedListOptions } from './rich-text-ordered-list'\nimport type { RichTextStrikethroughOptions } from './rich-text-strikethrough'\n\n/**\n * The options available to customize the `RichTextKit` extension.\n */\ntype RichTextKitOptions = {\n /**\n * Set options for the `Blockquote` extension, or `false` to disable.\n */\n blockquote: Partial<BlockquoteOptions> | false\n\n /**\n * Set options for the `Bold` extension, or `false` to disable.\n */\n bold: Partial<BoldOptions> | false\n\n /**\n * Set options for the `BulletList` extension, or `false` to disable.\n */\n bulletList: Partial<RichTextBulletListOptions> | false\n\n /**\n * Set options for the `Code` extension, or `false` to disable.\n */\n code: Partial<CodeOptions> | false\n\n /**\n * Set options for the `CodeBlock` extension, or `false` to disable.\n */\n codeBlock: Partial<CodeBlockOptions> | false\n\n /**\n * Set options for the `Document` extension, or `false` to disable.\n */\n document: Partial<RichTextDocumentOptions> | false\n\n /**\n * Set options for the `Dropcursor` extension, or `false` to disable.\n */\n dropCursor: Partial<DropcursorOptions> | false\n\n /**\n * Set to `false` to disable the `Gapcursor` extension.\n */\n gapCursor: false\n\n /**\n * Set options for the `HardBreak` extension, or `false` to disable.\n */\n hardBreak: Partial<HardBreakOptions> | false\n\n /**\n * Set options for the `Heading` extension, or `false` to disable.\n */\n heading: Partial<RichTextHeadingOptions> | false\n\n /**\n * Set options for the `History` extension, or `false` to disable.\n */\n history: Partial<HistoryOptions> | false\n\n /**\n * Set options for the `HorizontalRule` extension, or `false` to disable.\n */\n horizontalRule: Partial<HorizontalRuleOptions> | false\n\n /**\n * Set options for the `Image` extension, or `false` to disable.\n */\n image: Partial<RichTextImageOptions> | false\n\n /**\n * Set options for the `Italic` extension, or `false` to disable.\n */\n italic: Partial<ItalicOptions> | false\n\n /**\n * Set options for the `Link` extension, or `false` to disable.\n */\n link: Partial<RichTextLinkOptions> | false\n\n /**\n * Set options for the `ListItem` extension, or `false` to disable.\n */\n listItem: Partial<ListItemOptions> | false\n\n /**\n * Set options for the `ListKeymap` extension, or `false` to disable.\n */\n listKeymap: Partial<ListKeymapOptions> | false\n\n /**\n * Set options for the `OrderedList` extension, or `false` to disable.\n */\n orderedList: Partial<RichTextOrderedListOptions> | false\n\n /**\n * Set options for the `Paragraph` extension, or `false` to disable.\n */\n paragraph: Partial<ParagraphOptions> | false\n\n /**\n * Set to `false` to disable the `PasteEmojis` extension.\n */\n pasteEmojis: false\n\n /**\n * Set to `false` to disable the `PasteMarkdown` extension.\n */\n pasteMarkdown: false\n\n /**\n * Set to `false` to disable the `PasteSinglelineText` extension.\n */\n pasteSinglelineText: false\n\n /**\n * Set to `false` to disable the `PasteHTMLTableAsString` extension.\n */\n pasteHTMLTableAsString: false\n\n /**\n * Set options for the `Strike` extension, or `false` to disable.\n */\n strike: Partial<RichTextStrikethroughOptions> | false\n\n /**\n * Set to `false` to disable the `Text` extension.\n */\n text: false\n\n /**\n * Set to `false` to disable the `Typography` extension.\n */\n typography: false\n}\n\n/**\n * The `RichTextKit` extension is a collection of the minimal required extensions to have a full\n * WYSIWYG text editor working. This extension is based on the official `StarterKit` extension\n * implementation, allowing almost every extension to be customized or disabled.\n */\nconst RichTextKit = Extension.create<RichTextKitOptions>({\n name: 'richTextKit',\n addExtensions() {\n const extensions: Extensions = []\n\n if (this.options.blockquote !== false) {\n extensions.push(\n Blockquote.extend({\n priority: BLOCKQUOTE_EXTENSION_PRIORITY,\n }).configure(this.options?.blockquote),\n )\n }\n\n if (this.options.bold !== false) {\n extensions.push(Bold.configure(this.options?.bold))\n }\n\n if (this.options.bulletList !== false) {\n extensions.push(RichTextBulletList.configure(this.options?.bulletList))\n }\n\n if (this.options.code !== false) {\n extensions.push(\n RichTextCode.configure(this.options?.code),\n\n // Enhances the Code extension capabilities with additional features\n CurvenoteCodemark,\n )\n }\n\n if (this.options.codeBlock !== false) {\n extensions.push(CodeBlock.configure(this.options?.codeBlock))\n }\n\n if (this.options.document !== false) {\n extensions.push(\n RichTextDocument.configure(this.options?.document),\n\n // Supports copying the underlying Markdown source to the clipboard\n CopyMarkdownSource.configure({\n keyboardShortcut: 'Mod-Shift-c',\n }),\n )\n\n if (this.options?.pasteEmojis !== false) {\n // Supports pasting HTML image emojis as unicode characters\n extensions.push(PasteEmojis)\n }\n\n if (this.options?.pasteMarkdown !== false) {\n // Supports pasting Markdown content as HTML into the editor\n extensions.push(PasteMarkdown)\n }\n\n if (\n this.options?.document?.multiline === false &&\n this.options?.pasteSinglelineText !== false\n ) {\n // Supports pasting multiple lines into a singleline editor, by joining all the\n // pasted lines together\n extensions.push(PasteSinglelineText)\n }\n\n if (this.options?.pasteHTMLTableAsString !== false) {\n // Supports pasting tables (from spreadsheets and websites) into the editor\n extensions.push(PasteHTMLTableAsString)\n }\n }\n\n if (this.options.dropCursor !== false) {\n extensions.push(Dropcursor.configure(this.options?.dropCursor))\n }\n\n if (this.options.gapCursor !== false) {\n extensions.push(Gapcursor)\n }\n\n if (this.options.hardBreak !== false) {\n extensions.push(HardBreak.configure(this.options?.hardBreak))\n }\n\n if (this.options.heading !== false) {\n extensions.push(RichTextHeading.configure(this.options?.heading))\n }\n\n if (this.options.history !== false) {\n extensions.push(History.configure(this.options?.history))\n }\n\n if (this.options.horizontalRule !== false) {\n extensions.push(HorizontalRule.configure(this.options?.horizontalRule))\n }\n\n if (this.options.image !== false) {\n extensions.push(RichTextImage.configure(this.options?.image))\n }\n\n if (this.options.italic !== false) {\n extensions.push(Italic.configure(this.options?.italic))\n }\n\n if (this.options.bold !== false && this.options.italic !== false) {\n extensions.push(BoldAndItalics)\n }\n\n if (this.options.link !== false) {\n extensions.push(RichTextLink.configure(this.options?.link))\n }\n\n if (this.options.listItem !== false) {\n extensions.push(ListItem.configure(this.options?.listItem))\n }\n\n if (this.options.listKeymap !== false) {\n extensions.push(ListKeymap.configure(this.options?.listKeymap))\n }\n\n if (this.options.orderedList !== false) {\n extensions.push(RichTextOrderedList.configure(this.options?.orderedList))\n }\n\n if (this.options.paragraph !== false) {\n extensions.push(Paragraph.configure(this.options?.paragraph))\n }\n\n if (this.options.strike !== false) {\n extensions.push(RichTextStrikethrough.configure(this.options?.strike))\n }\n\n if (this.options.text !== false) {\n extensions.push(Text)\n }\n\n if (this.options.typography !== false) {\n extensions.push(Typography)\n }\n\n return extensions\n },\n})\n\nexport { RichTextKit }\n\nexport type { RichTextKitOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,MAAM,cAAc,UAAU,OAA2B;CACrD,MAAM;CACN,gBAAgB;EACZ,MAAM,aAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KACP,WAAW,OAAO,EACd,UAAA,IACJ,CAAC,CAAC,CAAC,UAAU,KAAK,SAAS,UAAU,CACzC;EAGJ,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KAAK,KAAK,UAAU,KAAK,SAAS,IAAI,CAAC;EAGtD,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,mBAAmB,UAAU,KAAK,SAAS,UAAU,CAAC;EAG1E,IAAI,KAAK,QAAQ,SAAS,OACtB,WAAW,KACP,aAAa,UAAU,KAAK,SAAS,IAAI,GAGzC,iBACJ;EAGJ,IAAI,KAAK,QAAQ,cAAc,OAC3B,WAAW,KAAK,UAAU,UAAU,KAAK,SAAS,SAAS,CAAC;EAGhE,IAAI,KAAK,QAAQ,aAAa,OAAO;GACjC,WAAW,KACP,iBAAiB,UAAU,KAAK,SAAS,QAAQ,GAGjD,mBAAmB,UAAU,EACzB,kBAAkB,cACtB,CAAC,CACL;GAEA,IAAI,KAAK,SAAS,gBAAgB,OAE9B,WAAW,KAAK,WAAW;GAG/B,IAAI,KAAK,SAAS,kBAAkB,OAEhC,WAAW,KAAK,aAAa;GAGjC,IACI,KAAK,SAAS,UAAU,cAAc,SACtC,KAAK,SAAS,wBAAwB,OAItC,WAAW,KAAK,mBAAmB;GAGvC,IAAI,KAAK,SAAS,2BAA2B,OAEzC,WAAW,KAAK,sBAAsB;EAE9C;EAEA,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,WAAW,UAAU,KAAK,SAAS,UAAU,CAAC;EA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tB,WAAW,KAAK,IAAI;EAGxB,IAAI,KAAK,QAAQ,eAAe,OAC5B,WAAW,KAAK,UAAU;EAG9B,OAAO;CACX;AACJ,CAAC"}
@@ -11,5 +11,5 @@ type RichTextLinkOptions = LinkOptions;
11
11
  * adds support for the `title` attribute.
12
12
  */
13
13
  //#endregion
14
- export { type RichTextLinkOptions };
14
+ export type { RichTextLinkOptions };
15
15
  //# sourceMappingURL=rich-text-link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-link.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"mappings":";;;;;;KA6DK,mBAAA,GAAsB,WAAA"}
1
+ {"version":3,"file":"rich-text-link.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"mappings":";;;;;AAGyD;KA0DpD,mBAAA,GAAsB,WAAW;;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-link.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"sourcesContent":["import { InputRule, markInputRule, markPasteRule, PasteRule } from '@tiptap/core'\nimport { Link } from '@tiptap/extension-link'\n\nimport type { LinkOptions } from '@tiptap/extension-link'\n\n/**\n * The input regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst inputRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)$/i\n\n/**\n * The paste regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst pasteRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)/gi\n\n/**\n * Input rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`).\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkInputRule(config: Parameters<typeof markInputRule>[0]) {\n const defaultMarkInputRule = markInputRule(config)\n\n return new InputRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkInputRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * Paste rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`). This extension was inspired from the multiple\n * implementations found in a Tiptap discussion at GitHub.\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkPasteRule(config: Parameters<typeof markPasteRule>[0]) {\n const defaultMarkPasteRule = markPasteRule(config)\n\n return new PasteRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkPasteRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * The options available to customize the `RichTextLink` extension.\n */\ntype RichTextLinkOptions = LinkOptions\n\n/**\n * Custom extension that extends the built-in `Link` extension to add additional input/paste rules\n * for converting the Markdown link syntax (i.e. `[Doist](https://doist.com)`) into links, and also\n * adds support for the `title` attribute.\n */\nconst RichTextLink = Link.extend<RichTextLinkOptions>({\n inclusive: false,\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: 'whenNotEditable',\n }\n },\n addAttributes() {\n return {\n ...this.parent?.(),\n title: {\n default: null,\n },\n }\n },\n addInputRules() {\n return [\n linkInputRule({\n find: inputRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markPasteRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n addPasteRules() {\n return [\n linkPasteRule({\n find: pasteRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markInputRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n})\n\nexport { RichTextLink }\n\nexport type { RichTextLinkOptions }\n"],"mappings":";;;;;;;AASA,MAAM,aAAa;;;;;AAMnB,MAAM,aAAa;;;;;;;AAQnB,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,OAAO;CAElD,OAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;GAErB,qBAAqB,QAAQ,MAAM;GACnC,GAAG,QAAQ,mBAAmB,KAAK;;EAE1C,CAAC;;;;;;;;;AAUN,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,OAAO;CAElD,OAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;GAErB,qBAAqB,QAAQ,MAAM;GACnC,GAAG,QAAQ,mBAAmB,KAAK;;EAE1C,CAAC;;;;;;;AAaN,MAAM,eAAe,KAAK,OAA4B;CAClD,WAAW;CACX,aAAa;EACT,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,aAAa;GAChB;;CAEL,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,OAAO,EACH,SAAS,MACZ;GACJ;;CAEL,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;IACjB,OAAO;KACH,OAAO,MAAM,KAAK,EAAE,MAAM;KAC1B,MAAM,MAAM,KAAK,EAAE,MAAM;KAC5B;;GAER,CAAC,CACL;;CAEL,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;IACjB,OAAO;KACH,OAAO,MAAM,KAAK,EAAE,MAAM;KAC1B,MAAM,MAAM,KAAK,EAAE,MAAM;KAC5B;;GAER,CAAC,CACL;;CAER,CAAC"}
1
+ {"version":3,"file":"rich-text-link.js","names":[],"sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"sourcesContent":["import { InputRule, markInputRule, markPasteRule, PasteRule } from '@tiptap/core'\nimport { Link } from '@tiptap/extension-link'\n\nimport type { LinkOptions } from '@tiptap/extension-link'\n\n/**\n * The input regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst inputRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)$/i\n\n/**\n * The paste regex for Markdown links with title support, and multiple quotation marks (required\n * in case the `Typography` extension is being included).\n */\nconst pasteRegex = /(?:^|\\s)\\[([^\\]]*)?\\]\\((\\S+)(?: [\"“](.+)[\"”])?\\)/gi\n\n/**\n * Input rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`).\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkInputRule(config: Parameters<typeof markInputRule>[0]) {\n const defaultMarkInputRule = markInputRule(config)\n\n return new InputRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkInputRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * Paste rule built specifically for the `Link` extension, which ignores the auto-linked URL in\n * parentheses (e.g., `(https://doist.dev)`). This extension was inspired from the multiple\n * implementations found in a Tiptap discussion at GitHub.\n *\n * @see https://github.com/ueberdosis/tiptap/discussions/1865\n */\nfunction linkPasteRule(config: Parameters<typeof markPasteRule>[0]) {\n const defaultMarkPasteRule = markPasteRule(config)\n\n return new PasteRule({\n find: config.find,\n handler(props) {\n const { tr } = props.state\n\n defaultMarkPasteRule.handler(props)\n tr.setMeta('preventAutolink', true)\n },\n })\n}\n\n/**\n * The options available to customize the `RichTextLink` extension.\n */\ntype RichTextLinkOptions = LinkOptions\n\n/**\n * Custom extension that extends the built-in `Link` extension to add additional input/paste rules\n * for converting the Markdown link syntax (i.e. `[Doist](https://doist.com)`) into links, and also\n * adds support for the `title` attribute.\n */\nconst RichTextLink = Link.extend<RichTextLinkOptions>({\n inclusive: false,\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: 'whenNotEditable',\n }\n },\n addAttributes() {\n return {\n ...this.parent?.(),\n title: {\n default: null,\n },\n }\n },\n addInputRules() {\n return [\n linkInputRule({\n find: inputRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markPasteRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n addPasteRules() {\n return [\n linkPasteRule({\n find: pasteRegex,\n type: this.type,\n\n // We need to use `pop()` to remove the last capture groups from the match to\n // satisfy Tiptap's `markInputRule` expectation of having the content as the last\n // capture group in the match (this makes the attribute order important)\n getAttributes(match) {\n return {\n title: match.pop()?.trim(),\n href: match.pop()?.trim(),\n }\n },\n }),\n ]\n },\n})\n\nexport { RichTextLink }\n\nexport type { RichTextLinkOptions }\n"],"mappings":";;;;;;;AASA,MAAM,aAAa;;;;;AAMnB,MAAM,aAAa;;;;;;;AAQnB,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,MAAM;CAEjD,OAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;GAErB,qBAAqB,QAAQ,KAAK;GAClC,GAAG,QAAQ,mBAAmB,IAAI;EACtC;CACJ,CAAC;AACL;;;;;;;;AASA,SAAS,cAAc,QAA6C;CAChE,MAAM,uBAAuB,cAAc,MAAM;CAEjD,OAAO,IAAI,UAAU;EACjB,MAAM,OAAO;EACb,QAAQ,OAAO;GACX,MAAM,EAAE,OAAO,MAAM;GAErB,qBAAqB,QAAQ,KAAK;GAClC,GAAG,QAAQ,mBAAmB,IAAI;EACtC;CACJ,CAAC;AACL;;;;;;AAYA,MAAM,eAAe,KAAK,OAA4B;CAClD,WAAW;CACX,aAAa;EACT,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,aAAa;EACjB;CACJ;CACA,gBAAgB;EACZ,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,OAAO,EACH,SAAS,KACb;EACJ;CACJ;CACA,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;IACjB,OAAO;KACH,OAAO,MAAM,IAAI,CAAC,EAAE,KAAK;KACzB,MAAM,MAAM,IAAI,CAAC,EAAE,KAAK;IAC5B;GACJ;EACJ,CAAC,CACL;CACJ;CACA,gBAAgB;EACZ,OAAO,CACH,cAAc;GACV,MAAM;GACN,MAAM,KAAK;GAKX,cAAc,OAAO;IACjB,OAAO;KACH,OAAO,MAAM,IAAI,CAAC,EAAE,KAAK;KACzB,MAAM,MAAM,IAAI,CAAC,EAAE,KAAK;IAC5B;GACJ;EACJ,CAAC,CACL;CACJ;AACJ,CAAC"}
@@ -17,5 +17,5 @@ type RichTextOrderedListOptions = {
17
17
  * paragraphs before toggling the selection into a bullet list.
18
18
  */
19
19
  //#endregion
20
- export { type RichTextOrderedListOptions };
20
+ export type { RichTextOrderedListOptions };
21
21
  //# sourceMappingURL=rich-text-ordered-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-ordered-list.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-ordered-list.ts"],"mappings":";;;;;;KAUK,0BAAA;EAA0B;;;;EAK3B,WAAA;AAAA,IACA,kBAAA"}
1
+ {"version":3,"file":"rich-text-ordered-list.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-ordered-list.ts"],"mappings":";;;;;AAKwE;KAKnE,0BAAA;;;AAMiB;;EADlB,WAAA;AAAA,IACA,kBAAkB"}
@@ -1 +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.toReversed().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;EACT,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,aAAa;GAChB;;CAGL,cAAc;EACV,MAAM,EAAE,QAAQ,MAAM,YAAY;EAElC,OAAO;GACH,GAAG,KAAK,UAAU;GAClB,oBAAoB;IAChB,QAAQ,EAAE,UAAU,OAAO,IAAI,YAAY;KAEvC,IAAI,QAAQ,aAAa;MACrB,MAAM,EAAE,WAAW;MACnB,MAAM,EAAE,cAAc;MACtB,MAAM,EAAE,OAAO,QAAQ;MAEvB,MAAM,qBAA+B,EAAE;MAGvC,GAAG,IAAI,aAAa,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ;OACnD,IAAI,KAAK,KAAK,SAAS,aACnB,mBAAmB,KAAK,IAAI;QAElC;MAMF,mBAAmB,YAAY,CAAC,SAAS,QAAQ;OAC7C,GAAG,QACC,KACA,MAAM,GACN,MAAM,QACF,SAAS,UAAU,CACf,OAAO,MAAM,UAAU,QAAQ,EAC/B,OAAO,MAAM,UAAU,QAAQ,CAClC,CAAC,CACL,CACJ;QACH;;KAMN,IAAI,QAAQ,gBACR,OAAO,OAAO,CACT,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU,CACzD,iBAAiB,SAAS,MAAM,OAAO,cAAc,UAAU,KAAK,CAAC,CACrE,KAAK;KAGd,OAAO,SAAS,WAAW,MAAM,QAAQ,cAAc,QAAQ,UAAU;;;GAGpF;;CAER,CAAC"}
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.toReversed().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;EACT,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,aAAa;EACjB;CACJ;CAEA,cAAc;EACV,MAAM,EAAE,QAAQ,MAAM,YAAY;EAElC,OAAO;GACH,GAAG,KAAK,SAAS;GACjB,oBAAoB;IAChB,QAAQ,EAAE,UAAU,OAAO,IAAI,YAAY;KAEvC,IAAI,QAAQ,aAAa;MACrB,MAAM,EAAE,WAAW;MACnB,MAAM,EAAE,cAAc;MACtB,MAAM,EAAE,OAAO,QAAQ;MAEvB,MAAM,qBAA+B,CAAC;MAGtC,GAAG,IAAI,aAAa,MAAM,KAAK,IAAI,MAAM,MAAM,QAAQ;OACnD,IAAI,KAAK,KAAK,SAAS,aACnB,mBAAmB,KAAK,GAAG;MAEnC,CAAC;MAMD,mBAAmB,WAAW,CAAC,CAAC,SAAS,QAAQ;OAC7C,GAAG,QACC,KACA,MAAM,GACN,MAAM,QACF,SAAS,UAAU,CACf,OAAO,MAAM,UAAU,OAAO,GAC9B,OAAO,MAAM,UAAU,OAAO,CAClC,CAAC,CACL,CACJ;MACJ,CAAC;KACL;KAKA,IAAI,QAAQ,gBACR,OAAO,MAAM,CAAC,CACT,WAAW,MAAM,QAAQ,cAAc,QAAQ,SAAS,CAAC,CACzD,iBAAiB,SAAS,MAAM,OAAO,cAAc,UAAU,IAAI,CAAC,CAAC,CACrE,IAAI;KAGb,OAAO,SAAS,WAAW,MAAM,QAAQ,cAAc,QAAQ,SAAS;IAC5E;GACJ;EACJ;CACJ;AACJ,CAAC"}
@@ -9,5 +9,5 @@ type RichTextStrikethroughOptions = StrikeOptions;
9
9
  * Custom extension that extends the built-in `Strike` extension to overwrite the default keyboard.
10
10
  */
11
11
  //#endregion
12
- export { type RichTextStrikethroughOptions };
12
+ export type { RichTextStrikethroughOptions };
13
13
  //# sourceMappingURL=rich-text-strikethrough.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"rich-text-strikethrough.d.ts","names":[],"sources":["../../../src/extensions/rich-text/rich-text-strikethrough.ts"],"mappings":";;;;;AAE6D;KAKxD,4BAAA,GAA+B,aAAa;;;AAAA"}
@@ -1 +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;CACnB,OAAO,EACH,qBAAqB,KAAK,OAAO,SAAS,cAAc,EAC3D;GAER,CAAC"}
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;CACnB,OAAO,EACH,qBAAqB,KAAK,OAAO,SAAS,aAAa,EAC3D;AACJ,EACJ,CAAC"}
@@ -1 +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;EACT,OAAO,EACH,kBAAkB,SACrB;;CAEL,uBAAuB;EACnB,OAAO,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;GAGD,WAAW,WACL,UAAU,gBAAgB,CAE3B,WAAW,KAAA,EAAU,CAErB,YAAY,KAAA,EAAU;GAG3B,OAAO;KAEd;;CAER,CAAC"}
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;EACT,OAAO,EACH,kBAAkB,QACtB;CACJ;CACA,uBAAuB;EACnB,OAAO,GACF,KAAK,QAAQ,oBAAoB,EAAE,aAAa;GAE7C,MAAM,gBAAgB,OAAO,MAAM,IAAI,IACnC,OAAO,MAAM,UAAU,MACvB,OAAO,MAAM,UAAU,EAC3B;GAGA,MAAM,kBAAkB,8BAA8B,OAAO,MAAM,CAAC,CAAC,UACjE,oBAAoB,cAAc,SAAS,OAAO,MAAM,CAC5D;GAGA,WAAW,WACL,UAAU,eAAe,CAAC,CAE3B,WAAW,KAAA,CAAS,CAAC,CAErB,YAAY,KAAA,CAAS;GAG1B,OAAO;EACX,EACJ;CACJ;AACJ,CAAC"}
@@ -1 +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 cellParagraphs = cell.querySelectorAll('p')\n\n for (const p of Array.from(cellParagraphs)) {\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;CAE7C,IAAI,OAAO,WAAW,GAClB,OAAO;CAGX,KAAK,MAAM,SAAS,MAAM,KAAK,OAAO,EAAE;EACpC,IAAI,CAAC,MAAM,MACP;EAIJ,MAAM,aAAa,MAAM,KAAK,MAAM,KAAK,CACpC,KAAK,QACF,MAAM,KAAK,IAAI,MAAM,CAChB,KAAK,SAAS;GAEX,MAAM,iBAAiB,KAAK,iBAAiB,IAAI;GAEjD,KAAK,MAAM,KAAK,MAAM,KAAK,eAAe,EACtC,EAAE,YAAY,GAAG,MAAM,KAAK,EAAE,WAAW,CAAC;GAG9C,OAAO,KAAK;IACd,CACD,KAAK,IAAI,CACjB,CACA,QAAQ,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CACtC,KAAK,QAAQ;GACV,MAAM,IAAI,SAAS,cAAc,IAAI;GACrC,EAAE,YAAY;GACd,OAAO;IACT;EAEN,MAAM,YAAY,GAAG,WAAW;;CAGpC,OAAO,KAAK;;;;;;;;;;;;;;AAehB,MAAM,yBAAyB,UAAU,OAAO;CAC5C,MAAM;CACN,UAAU;CACV,wBAAwB;EACpB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,yBAAyB;GAC5C,OAAO,EACH,qBACH;GACJ,CAAC,CACL;;CAER,CAAC"}
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 cellParagraphs = cell.querySelectorAll('p')\n\n for (const p of Array.from(cellParagraphs)) {\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,IAAI;CACpC,MAAM,SAAS,KAAK,iBAAiB,OAAO;CAE5C,IAAI,OAAO,WAAW,GAClB,OAAO;CAGX,KAAK,MAAM,SAAS,MAAM,KAAK,MAAM,GAAG;EACpC,IAAI,CAAC,MAAM,MACP;EAIJ,MAAM,aAAa,MAAM,KAAK,MAAM,IAAI,CAAC,CACpC,KAAK,QACF,MAAM,KAAK,IAAI,KAAK,CAAC,CAChB,KAAK,SAAS;GAEX,MAAM,iBAAiB,KAAK,iBAAiB,GAAG;GAEhD,KAAK,MAAM,KAAK,MAAM,KAAK,cAAc,GACrC,EAAE,YAAY,GAAG,MAAM,KAAK,EAAE,UAAU,CAAC;GAG7C,OAAO,KAAK;EAChB,CAAC,CAAC,CACD,KAAK,GAAG,CACjB,CAAC,CACA,QAAQ,QAAQ,IAAI,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CACtC,KAAK,QAAQ;GACV,MAAM,IAAI,SAAS,cAAc,GAAG;GACpC,EAAE,YAAY;GACd,OAAO;EACX,CAAC;EAEL,MAAM,YAAY,GAAG,UAAU;CACnC;CAEA,OAAO,KAAK;AAChB;;;;;;;;;;;;;AAcA,MAAM,yBAAyB,UAAU,OAAO;CAC5C,MAAM;CACN,UAAU;CACV,wBAAwB;EACpB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,wBAAwB;GAC3C,OAAO,EACH,oBACJ;EACJ,CAAC,CACL;CACJ;AACJ,CAAC"}
@@ -1 +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;EACpB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,sBAAsB;GACzC,OAAO;IACH,oBAAoB,MAAM,MAAM;KAC5B,MAAM,cAAc,mBAAmB,KAAK;KAE5C,YAAY,YAAY,YAAY,UAE/B,QAAQ,SAAS,IAAI,CAErB,QAAQ,uBAAuB,MAAM;KAE1C,OAAO,oBAAoB,KAAK,MAAM,OAAO,GACvC,OAAO,YAAY,UAAU,GAC7B,YAAY;;IAEtB,oBAAoB,MAAM;KACtB,OACI,KAEK,QAAQ,mBAAmB,IAAI,CAE/B,QAAQ,QAAQ,IAAI;;IAGpC;GACJ,CAAC,CACL;;CAER,CAAC"}
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;EACpB,OAAO,CACH,IAAI,OAAO;GACP,KAAK,IAAI,UAAU,qBAAqB;GACxC,OAAO;IACH,oBAAoB,MAAM,MAAM;KAC5B,MAAM,cAAc,mBAAmB,IAAI;KAE3C,YAAY,YAAY,YAAY,UAE/B,QAAQ,SAAS,GAAG,CAAC,CAErB,QAAQ,uBAAuB,KAAK;KAEzC,OAAO,oBAAoB,KAAK,MAAM,MAAM,IACtC,OAAO,YAAY,SAAS,IAC5B,YAAY;IACtB;IACA,oBAAoB,MAAM;KACtB,OACI,KAEK,QAAQ,mBAAmB,GAAG,CAAC,CAE/B,QAAQ,QAAQ,GAAG;IAEhC;GACJ;EACJ,CAAC,CACL;CACJ;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-suggestion-extension.d.ts","names":[],"sources":["../../src/factories/create-suggestion-extension.ts"],"mappings":";;;;;;;AAemE;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,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,KAAA,EAAO,sBAA0B;AAAA;;AAAA;AAAA;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;AAAA;;;;;;;;;;;;;AAMS;AAAA;;iBA2B/E,yBAAA;EAAA,CAEA,EAAA,EAAI,wBAAA;AAAA,IACL,wBAAA,EAEJ,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-suggestion-extension.js","names":["TiptapSuggestion"],"sources":["../../src/factories/create-suggestion-extension.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport { Suggestion as TiptapSuggestion } from '@tiptap/suggestion'\nimport { camelCase, kebabCase } from 'lodash-es'\n\nimport { SUGGESTION_EXTENSION_PRIORITY } from '../constants/extension-priorities'\nimport { DEFAULT_SUGGESTION_TRIGGER_CHAR } from '../constants/suggestions'\nimport { canInsertNodeAt } from '../utilities/can-insert-node-at'\nimport { canInsertSuggestion } from '../utilities/can-insert-suggestion'\n\nimport type {\n SuggestionKeyDownProps as CoreSuggestionKeyDownProps,\n SuggestionOptions as CoreSuggestionOptions,\n SuggestionProps as CoreSuggestionProps,\n} from '@tiptap/suggestion'\nimport type { ConditionalKeys, RequireAtLeastOne } from 'type-fest'\n\n/**\n * A type that describes the suggestion node attributes.\n */\ntype SuggestionNodeAttributes = {\n /**\n * The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.\n */\n id: number | string\n\n /**\n * The suggestion node label to be rendered by the editor as a `data-label` attribute and the\n * display text itself.\n */\n label: string\n}\n\n/**\n * A type that describes the minimal props that an autocomplete dropdown must receive.\n */\ntype SuggestionRendererProps<TSuggestionItem> = {\n /**\n * The list of suggestion items to be rendered by the autocomplete dropdown.\n */\n items: CoreSuggestionProps<TSuggestionItem>['items']\n\n /**\n * The function that must be invoked when a suggestion item is selected.\n */\n command: CoreSuggestionProps<TSuggestionItem, SuggestionNodeAttributes>['command']\n}\n\n/**\n * A type that describes the forwarded ref that an autocomplete dropdown must implement with\n * `useImperativeHandle` to handle `keydown` events in the dropdown render function.\n */\ntype SuggestionRendererRef = {\n onKeyDown: (props: CoreSuggestionKeyDownProps) => boolean\n}\n\n/**\n * The options available to customize the extension created by the factory function.\n */\ntype SuggestionOptions<TSuggestionItem> = {\n /**\n * The character that triggers the autocomplete dropdown.\n */\n triggerChar: string\n\n /**\n * Allows or disallows spaces in suggested items.\n */\n allowSpaces: CoreSuggestionOptions['allowSpaces']\n\n /**\n * The prefix characters that are allowed to trigger a suggestion.\n */\n allowedPrefixes: CoreSuggestionOptions['allowedPrefixes']\n\n /**\n * Trigger the autocomplete dropdown at the start of a line only.\n */\n startOfLine: CoreSuggestionOptions['startOfLine']\n\n /**\n * Define how the suggestion item `aria-label` attribute should be rendered.\n */\n renderAriaLabel?: (attrs: SuggestionNodeAttributes) => string\n\n /**\n * A render function for the autocomplete dropdown.\n */\n dropdownRenderFn?: CoreSuggestionOptions<TSuggestionItem>['render']\n\n /**\n * The event handler that is fired when the search string has changed.\n */\n onSearchChange?: (\n query: string,\n storage: SuggestionStorage<TSuggestionItem>,\n ) => TSuggestionItem[] | Promise<TSuggestionItem[]>\n\n /**\n * The event handler that is fired when a suggestion item is selected.\n */\n onItemSelect?: (item: TSuggestionItem) => void\n}\n\n/**\n * The storage holding the suggestion items original array, and a collection indexed by the item id.\n */\ntype SuggestionStorage<TSuggestionItem> = Readonly<{\n /**\n * The original array of suggestion items.\n */\n items: TSuggestionItem[]\n\n /**\n * A collection of suggestion items indexed by the item id.\n */\n itemsById: { readonly [id: SuggestionNodeAttributes['id']]: TSuggestionItem | undefined }\n}>\n\n/**\n * The return type for a suggestion extension created by the factory function.\n */\ntype SuggestionExtensionResult<TSuggestionItem> = Node<SuggestionOptions<TSuggestionItem>>\n\n/**\n * A factory function responsible for creating different types of suggestion extensions with\n * flexibility and customizability in mind.\n *\n * Extensions created by this factory function render editor nodes with internal `data-id` and\n * `data-label` attributes (as a way to save and restore the editor nodes data) based on properties\n * of the same name (minus the `data-` prefix) from the source item type. However, in the event of\n * unmatched properties between the internal attributes and the source item type, you should\n * specify the source item type, and use the optional `attributesMapping` option to map the\n * source properties to the internal `data-id` and `data-label` attributes.\n *\n * This factory function also stores the suggestion items internally in the editor storage (as-is,\n * and indexed by an identifier), as a way to make sure that if a previously referenced suggestion\n * changes its label, the editor will always render the most up-to-date label for the suggestion by\n * reading it from the storage. An example use case for this is when a user mention is added to the\n * editor, and the user changed its name afterwards, the editor will always render the most\n * up-to-date user name for the mention.\n *\n * @param type A unique identifier for the suggestion extension type.\n * @param items An array of suggestion items to be stored in the editor storage.\n * @param attributesMapping An object to map the `data-id` and `data-label` attributes with the\n * source item type properties.\n *\n * @returns A new suggestion extension tailored to a specific use case.\n */\nfunction createSuggestionExtension<\n TSuggestionItem extends {\n [id: SuggestionNodeAttributes['id']]: unknown\n } = SuggestionNodeAttributes,\n>(\n type: string,\n items: TSuggestionItem[] = [],\n\n // This type makes sure that if a generic type variable is specified, the `attributesMapping`\n // is also defined (and vice versa) along with making sure that at least one attribute is\n // specified, and that all constraints are satisfied.\n ...attributesMapping: TSuggestionItem extends SuggestionNodeAttributes\n ? []\n : [\n RequireAtLeastOne<{\n id: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['id']>\n label: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['label']>\n }>,\n ]\n): SuggestionExtensionResult<TSuggestionItem> {\n // Normalize the node type and add the `Suggestion` suffix so that it can be easily identified\n // when parsing the editor schema programatically (useful for Markdown/HTML serialization)\n const nodeType = `${camelCase(type)}Suggestion`\n\n // Normalize the node type to kebab-case to be used as a `data-*` HTML attribute\n const attributeType = kebabCase(type)\n\n // Get the specified attributes, if available, or use the defaults\n const idAttribute = String(attributesMapping[0]?.id ?? 'id')\n const labelAttribute = String(attributesMapping[0]?.label ?? 'label')\n\n // Create a personalized suggestion extension\n return Node.create<SuggestionOptions<TSuggestionItem>, SuggestionStorage<TSuggestionItem>>({\n name: nodeType,\n priority: SUGGESTION_EXTENSION_PRIORITY,\n inline: true,\n group: 'inline',\n selectable: false,\n atom: true,\n addOptions() {\n return {\n triggerChar: DEFAULT_SUGGESTION_TRIGGER_CHAR,\n // Disable option by default until the following Tiptap issue is fixed:\n // https://github.com/ueberdosis/tiptap/issues/2159\n allowSpaces: false,\n allowedPrefixes: [' '],\n startOfLine: false,\n }\n },\n addStorage() {\n return {\n items,\n itemsById: Object.fromEntries(\n items.map((item) => [String(item[idAttribute]), item]),\n ),\n }\n },\n // Expose the trigger character in the node spec so it can be read from the schema by\n // serializers and renderers that need to reconstruct the visible text for a suggestion\n // (e.g., `@username`, `#channel`), without depending on the editor instance.\n extendNodeSchema(extension) {\n return {\n triggerChar: extension.options.triggerChar,\n }\n },\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: (element) => element.getAttribute('data-id'),\n renderHTML: (attributes) => ({\n 'data-id': String(attributes.id),\n }),\n },\n label: {\n default: null,\n parseHTML: (element: Element) => {\n const id = String(element.getAttribute('data-id'))\n const item = this.storage.itemsById[id]\n\n // Attempt to read the item label from the storage first (as a way to make\n // sure that a previously referenced suggestion always renders the most\n // up-to-date label for the suggestion), and fallback to the `data-label`\n // attribute if the item is not found in the storage\n const labelValue =\n item?.[labelAttribute] ?? element.getAttribute('data-label')\n return typeof labelValue === 'string' ? labelValue : ''\n },\n renderHTML: (attributes) => ({\n 'data-label': String(attributes.label),\n }),\n },\n }\n },\n parseHTML() {\n return [{ tag: `span[data-${attributeType}]` }]\n },\n renderHTML({ node, HTMLAttributes }) {\n return [\n 'span',\n mergeAttributes(\n {\n [`data-${attributeType}`]: '',\n 'aria-label': this.options.renderAriaLabel?.({\n id: String(node.attrs.id),\n label: String(node.attrs.label),\n }),\n },\n HTMLAttributes,\n ),\n `${String(this.options.triggerChar)}${String(node.attrs.label)}`,\n ]\n },\n renderText({ node }) {\n return `${String(this.options.triggerChar)}${String(node.attrs.label)}`\n },\n addProseMirrorPlugins() {\n const {\n options: {\n triggerChar,\n allowSpaces,\n allowedPrefixes,\n startOfLine,\n onSearchChange,\n onItemSelect,\n dropdownRenderFn,\n },\n storage,\n } = this\n\n return [\n TiptapSuggestion<TSuggestionItem, SuggestionNodeAttributes>({\n pluginKey: new PluginKey(nodeType),\n editor: this.editor,\n char: triggerChar,\n allowedPrefixes,\n allowSpaces,\n startOfLine,\n items({ query, editor }) {\n return (\n onSearchChange?.(\n query,\n editor.storage[nodeType] as SuggestionStorage<TSuggestionItem>,\n ) || []\n )\n },\n allow({ editor, range, state }) {\n return (\n canInsertNodeAt({ editor, nodeType, range }) &&\n canInsertSuggestion({ editor, state })\n )\n },\n command({ editor, range, props }) {\n const nodeAfter = editor.view.state.selection.$to.nodeAfter\n const overrideSpace = nodeAfter?.text?.startsWith(' ')\n\n if (overrideSpace) {\n range.to += 1\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeType,\n attrs: props,\n },\n {\n type: 'text',\n text: ' ',\n },\n ])\n .run()\n\n const item = storage.itemsById[props.id]\n\n if (item) {\n onItemSelect?.(item)\n }\n },\n render: dropdownRenderFn,\n }),\n ]\n },\n })\n}\n\nexport { createSuggestionExtension }\n\nexport type {\n SuggestionExtensionResult,\n SuggestionOptions,\n SuggestionRendererProps,\n SuggestionRendererRef,\n SuggestionStorage,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,SAAS,0BAKL,MACA,QAA2B,EAAE,EAK7B,GAAG,mBAQuC;CAG1C,MAAM,WAAW,GAAG,UAAU,KAAK,CAAC;CAGpC,MAAM,gBAAgB,UAAU,KAAK;CAGrC,MAAM,cAAc,OAAO,kBAAkB,IAAI,MAAM,KAAK;CAC5D,MAAM,iBAAiB,OAAO,kBAAkB,IAAI,SAAS,QAAQ;CAGrE,OAAO,KAAK,OAA+E;EACvF,MAAM;EACN,UAAU;EACV,QAAQ;EACR,OAAO;EACP,YAAY;EACZ,MAAM;EACN,aAAa;GACT,OAAO;IACH,aAAA;IAGA,aAAa;IACb,iBAAiB,CAAC,IAAI;IACtB,aAAa;IAChB;;EAEL,aAAa;GACT,OAAO;IACH;IACA,WAAW,OAAO,YACd,MAAM,KAAK,SAAS,CAAC,OAAO,KAAK,aAAa,EAAE,KAAK,CAAC,CACzD;IACJ;;EAKL,iBAAiB,WAAW;GACxB,OAAO,EACH,aAAa,UAAU,QAAQ,aAClC;;EAEL,gBAAgB;GACZ,OAAO;IACH,IAAI;KACA,SAAS;KACT,YAAY,YAAY,QAAQ,aAAa,UAAU;KACvD,aAAa,gBAAgB,EACzB,WAAW,OAAO,WAAW,GAAG,EACnC;KACJ;IACD,OAAO;KACH,SAAS;KACT,YAAY,YAAqB;MAC7B,MAAM,KAAK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gBAAgB,OAAO,CACpB;MACI,MAAM;MACN,OAAO;MACV,EACD;MACI,MAAM;MACN,MAAM;MACT,CACJ,CAAC,CACD,KAAK;KAEV,MAAM,OAAO,QAAQ,UAAU,MAAM;KAErC,IAAI,MACA,eAAe,KAAK;;IAG5B,QAAQ;IACX,CAAC,CACL;;EAER,CAAC"}
1
+ {"version":3,"file":"create-suggestion-extension.js","names":["TiptapSuggestion"],"sources":["../../src/factories/create-suggestion-extension.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport { Suggestion as TiptapSuggestion } from '@tiptap/suggestion'\nimport { camelCase, kebabCase } from 'lodash-es'\n\nimport { SUGGESTION_EXTENSION_PRIORITY } from '../constants/extension-priorities'\nimport { DEFAULT_SUGGESTION_TRIGGER_CHAR } from '../constants/suggestions'\nimport { canInsertNodeAt } from '../utilities/can-insert-node-at'\nimport { canInsertSuggestion } from '../utilities/can-insert-suggestion'\n\nimport type {\n SuggestionKeyDownProps as CoreSuggestionKeyDownProps,\n SuggestionOptions as CoreSuggestionOptions,\n SuggestionProps as CoreSuggestionProps,\n} from '@tiptap/suggestion'\nimport type { ConditionalKeys, RequireAtLeastOne } from 'type-fest'\n\n/**\n * A type that describes the suggestion node attributes.\n */\ntype SuggestionNodeAttributes = {\n /**\n * The suggestion node unique identifier to be rendered by the editor as a `data-id` attribute.\n */\n id: number | string\n\n /**\n * The suggestion node label to be rendered by the editor as a `data-label` attribute and the\n * display text itself.\n */\n label: string\n}\n\n/**\n * A type that describes the minimal props that an autocomplete dropdown must receive.\n */\ntype SuggestionRendererProps<TSuggestionItem> = {\n /**\n * The list of suggestion items to be rendered by the autocomplete dropdown.\n */\n items: CoreSuggestionProps<TSuggestionItem>['items']\n\n /**\n * The function that must be invoked when a suggestion item is selected.\n */\n command: CoreSuggestionProps<TSuggestionItem, SuggestionNodeAttributes>['command']\n}\n\n/**\n * A type that describes the forwarded ref that an autocomplete dropdown must implement with\n * `useImperativeHandle` to handle `keydown` events in the dropdown render function.\n */\ntype SuggestionRendererRef = {\n onKeyDown: (props: CoreSuggestionKeyDownProps) => boolean\n}\n\n/**\n * The options available to customize the extension created by the factory function.\n */\ntype SuggestionOptions<TSuggestionItem> = {\n /**\n * The character that triggers the autocomplete dropdown.\n */\n triggerChar: string\n\n /**\n * Allows or disallows spaces in suggested items.\n */\n allowSpaces: CoreSuggestionOptions['allowSpaces']\n\n /**\n * The prefix characters that are allowed to trigger a suggestion.\n */\n allowedPrefixes: CoreSuggestionOptions['allowedPrefixes']\n\n /**\n * Trigger the autocomplete dropdown at the start of a line only.\n */\n startOfLine: CoreSuggestionOptions['startOfLine']\n\n /**\n * Define how the suggestion item `aria-label` attribute should be rendered.\n */\n renderAriaLabel?: (attrs: SuggestionNodeAttributes) => string\n\n /**\n * A render function for the autocomplete dropdown.\n */\n dropdownRenderFn?: CoreSuggestionOptions<TSuggestionItem>['render']\n\n /**\n * The event handler that is fired when the search string has changed.\n */\n onSearchChange?: (\n query: string,\n storage: SuggestionStorage<TSuggestionItem>,\n ) => TSuggestionItem[] | Promise<TSuggestionItem[]>\n\n /**\n * The event handler that is fired when a suggestion item is selected.\n */\n onItemSelect?: (item: TSuggestionItem) => void\n}\n\n/**\n * The storage holding the suggestion items original array, and a collection indexed by the item id.\n */\ntype SuggestionStorage<TSuggestionItem> = Readonly<{\n /**\n * The original array of suggestion items.\n */\n items: TSuggestionItem[]\n\n /**\n * A collection of suggestion items indexed by the item id.\n */\n itemsById: { readonly [id: SuggestionNodeAttributes['id']]: TSuggestionItem | undefined }\n}>\n\n/**\n * The return type for a suggestion extension created by the factory function.\n */\ntype SuggestionExtensionResult<TSuggestionItem> = Node<SuggestionOptions<TSuggestionItem>>\n\n/**\n * A factory function responsible for creating different types of suggestion extensions with\n * flexibility and customizability in mind.\n *\n * Extensions created by this factory function render editor nodes with internal `data-id` and\n * `data-label` attributes (as a way to save and restore the editor nodes data) based on properties\n * of the same name (minus the `data-` prefix) from the source item type. However, in the event of\n * unmatched properties between the internal attributes and the source item type, you should\n * specify the source item type, and use the optional `attributesMapping` option to map the\n * source properties to the internal `data-id` and `data-label` attributes.\n *\n * This factory function also stores the suggestion items internally in the editor storage (as-is,\n * and indexed by an identifier), as a way to make sure that if a previously referenced suggestion\n * changes its label, the editor will always render the most up-to-date label for the suggestion by\n * reading it from the storage. An example use case for this is when a user mention is added to the\n * editor, and the user changed its name afterwards, the editor will always render the most\n * up-to-date user name for the mention.\n *\n * @param type A unique identifier for the suggestion extension type.\n * @param items An array of suggestion items to be stored in the editor storage.\n * @param attributesMapping An object to map the `data-id` and `data-label` attributes with the\n * source item type properties.\n *\n * @returns A new suggestion extension tailored to a specific use case.\n */\nfunction createSuggestionExtension<\n TSuggestionItem extends {\n [id: SuggestionNodeAttributes['id']]: unknown\n } = SuggestionNodeAttributes,\n>(\n type: string,\n items: TSuggestionItem[] = [],\n\n // This type makes sure that if a generic type variable is specified, the `attributesMapping`\n // is also defined (and vice versa) along with making sure that at least one attribute is\n // specified, and that all constraints are satisfied.\n ...attributesMapping: TSuggestionItem extends SuggestionNodeAttributes\n ? []\n : [\n RequireAtLeastOne<{\n id: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['id']>\n label: ConditionalKeys<TSuggestionItem, SuggestionNodeAttributes['label']>\n }>,\n ]\n): SuggestionExtensionResult<TSuggestionItem> {\n // Normalize the node type and add the `Suggestion` suffix so that it can be easily identified\n // when parsing the editor schema programatically (useful for Markdown/HTML serialization)\n const nodeType = `${camelCase(type)}Suggestion`\n\n // Normalize the node type to kebab-case to be used as a `data-*` HTML attribute\n const attributeType = kebabCase(type)\n\n // Get the specified attributes, if available, or use the defaults\n const idAttribute = String(attributesMapping[0]?.id ?? 'id')\n const labelAttribute = String(attributesMapping[0]?.label ?? 'label')\n\n // Create a personalized suggestion extension\n return Node.create<SuggestionOptions<TSuggestionItem>, SuggestionStorage<TSuggestionItem>>({\n name: nodeType,\n priority: SUGGESTION_EXTENSION_PRIORITY,\n inline: true,\n group: 'inline',\n selectable: false,\n atom: true,\n addOptions() {\n return {\n triggerChar: DEFAULT_SUGGESTION_TRIGGER_CHAR,\n // Disable option by default until the following Tiptap issue is fixed:\n // https://github.com/ueberdosis/tiptap/issues/2159\n allowSpaces: false,\n allowedPrefixes: [' '],\n startOfLine: false,\n }\n },\n addStorage() {\n return {\n items,\n itemsById: Object.fromEntries(\n items.map((item) => [String(item[idAttribute]), item]),\n ),\n }\n },\n // Expose the trigger character in the node spec so it can be read from the schema by\n // serializers and renderers that need to reconstruct the visible text for a suggestion\n // (e.g., `@username`, `#channel`), without depending on the editor instance.\n extendNodeSchema(extension) {\n return {\n triggerChar: extension.options.triggerChar,\n }\n },\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: (element) => element.getAttribute('data-id'),\n renderHTML: (attributes) => ({\n 'data-id': String(attributes.id),\n }),\n },\n label: {\n default: null,\n parseHTML: (element: Element) => {\n const id = String(element.getAttribute('data-id'))\n const item = this.storage.itemsById[id]\n\n // Attempt to read the item label from the storage first (as a way to make\n // sure that a previously referenced suggestion always renders the most\n // up-to-date label for the suggestion), and fallback to the `data-label`\n // attribute if the item is not found in the storage\n const labelValue =\n item?.[labelAttribute] ?? element.getAttribute('data-label')\n return typeof labelValue === 'string' ? labelValue : ''\n },\n renderHTML: (attributes) => ({\n 'data-label': String(attributes.label),\n }),\n },\n }\n },\n parseHTML() {\n return [{ tag: `span[data-${attributeType}]` }]\n },\n renderHTML({ node, HTMLAttributes }) {\n return [\n 'span',\n mergeAttributes(\n {\n [`data-${attributeType}`]: '',\n 'aria-label': this.options.renderAriaLabel?.({\n id: String(node.attrs.id),\n label: String(node.attrs.label),\n }),\n },\n HTMLAttributes,\n ),\n `${String(this.options.triggerChar)}${String(node.attrs.label)}`,\n ]\n },\n renderText({ node }) {\n return `${String(this.options.triggerChar)}${String(node.attrs.label)}`\n },\n addProseMirrorPlugins() {\n const {\n options: {\n triggerChar,\n allowSpaces,\n allowedPrefixes,\n startOfLine,\n onSearchChange,\n onItemSelect,\n dropdownRenderFn,\n },\n storage,\n } = this\n\n return [\n TiptapSuggestion<TSuggestionItem, SuggestionNodeAttributes>({\n pluginKey: new PluginKey(nodeType),\n editor: this.editor,\n char: triggerChar,\n allowedPrefixes,\n allowSpaces,\n startOfLine,\n items({ query, editor }) {\n return (\n onSearchChange?.(\n query,\n editor.storage[nodeType] as SuggestionStorage<TSuggestionItem>,\n ) || []\n )\n },\n allow({ editor, range, state }) {\n return (\n canInsertNodeAt({ editor, nodeType, range }) &&\n canInsertSuggestion({ editor, state })\n )\n },\n command({ editor, range, props }) {\n const nodeAfter = editor.view.state.selection.$to.nodeAfter\n const overrideSpace = nodeAfter?.text?.startsWith(' ')\n\n if (overrideSpace) {\n range.to += 1\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeType,\n attrs: props,\n },\n {\n type: 'text',\n text: ' ',\n },\n ])\n .run()\n\n const item = storage.itemsById[props.id]\n\n if (item) {\n onItemSelect?.(item)\n }\n },\n render: dropdownRenderFn,\n }),\n ]\n },\n })\n}\n\nexport { createSuggestionExtension }\n\nexport type {\n SuggestionExtensionResult,\n SuggestionOptions,\n SuggestionRendererProps,\n SuggestionRendererRef,\n SuggestionStorage,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,SAAS,0BAKL,MACA,QAA2B,CAAC,GAK5B,GAAG,mBAQuC;CAG1C,MAAM,WAAW,GAAG,UAAU,IAAI,EAAE;CAGpC,MAAM,gBAAgB,UAAU,IAAI;CAGpC,MAAM,cAAc,OAAO,kBAAkB,EAAE,EAAE,MAAM,IAAI;CAC3D,MAAM,iBAAiB,OAAO,kBAAkB,EAAE,EAAE,SAAS,OAAO;CAGpE,OAAO,KAAK,OAA+E;EACvF,MAAM;EACN,UAAU;EACV,QAAQ;EACR,OAAO;EACP,YAAY;EACZ,MAAM;EACN,aAAa;GACT,OAAO;IACH,aAAA;IAGA,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GAEJ,OAAO,CACHA,WAA4D;IACxD,WAAW,IAAI,UAAU,QAAQ;IACjC,QAAQ,KAAK;IACb,MAAM;IACN;IACA;IACA;IACA,MAAM,EAAE,OAAO,UAAU;KACrB,OACI,iBACI,OACA,OAAO,QAAQ,SACnB,KAAK,CAAC;IAEd;IACA,MAAM,EAAE,QAAQ,OAAO,SAAS;KAC5B,OACI,gBAAgB;MAAE;MAAQ;MAAU;KAAM,CAAC,KAC3C,oBAAoB;MAAE;MAAQ;KAAM,CAAC;IAE7C;IACA,QAAQ,EAAE,QAAQ,OAAO,SAAS;KAI9B,IAHkB,OAAO,KAAK,MAAM,UAAU,IAAI,WACjB,MAAM,WAAW,GAAG,GAGjD,MAAM,MAAM;KAGhB,OACK,MAAM,CAAC,CACP,MAAM,CAAC,CACP,gBAAgB,OAAO,CACpB;MACI,MAAM;MACN,OAAO;KACX,GACA;MACI,MAAM;MACN,MAAM;KACV,CACJ,CAAC,CAAC,CACD,IAAI;KAET,MAAM,OAAO,QAAQ,UAAU,MAAM;KAErC,IAAI,MACA,eAAe,IAAI;IAE3B;IACA,QAAQ;GACZ,CAAC,CACL;EACJ;CACJ,CAAC;AACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","names":[],"sources":["../../src/helpers/dom.ts"],"sourcesContent":["/**\n * Parse a given HTML string and returns the `HTMLElement` for the document body.\n *\n * @param html The HTML string to parse.\n */\nfunction parseHtmlToElement(html: string) {\n return new DOMParser().parseFromString(html, 'text/html').body\n}\n\nexport { parseHtmlToElement }\n"],"mappings":";;;;;;AAKA,SAAS,mBAAmB,MAAc;CACtC,OAAO,IAAI,WAAW,CAAC,gBAAgB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"dom.js","names":[],"sources":["../../src/helpers/dom.ts"],"sourcesContent":["/**\n * Parse a given HTML string and returns the `HTMLElement` for the document body.\n *\n * @param html The HTML string to parse.\n */\nfunction parseHtmlToElement(html: string) {\n return new DOMParser().parseFromString(html, 'text/html').body\n}\n\nexport { parseHtmlToElement }\n"],"mappings":";;;;;;AAKA,SAAS,mBAAmB,MAAc;CACtC,OAAO,IAAI,UAAU,CAAC,CAAC,gBAAgB,MAAM,WAAW,CAAC,CAAC;AAC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;AAA8C;;;;;iBASrC,mBAAA,CAAoB,MAAA,EAAQ,MAAA;;;;;;;;iBAW5B,mBAAA,CAAoB,MAAA,EAAQ,MAAA"}
1
+ {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/helpers/schema.ts"],"mappings":";;;;;AAA8C;;;;AASH;iBAAlC,mBAAA,CAAoB,MAAc,EAAN,MAAM;;;;AAWA;;;;iBAAlC,mBAAA,CAAoB,MAAc,EAAN,MAAM"}