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