@dooherceg/tiptap-controlled-editor-with-table 0.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.
- package/README.md +63 -0
- package/dist/Combination-CO0ZtURs.js +1333 -0
- package/dist/assets/badge.css +1 -0
- package/dist/assets/button.css +1 -0
- package/dist/assets/card.css +1 -0
- package/dist/assets/color-highlight-button.css +1 -0
- package/dist/assets/dropdown-menu.css +1 -0
- package/dist/assets/image-upload-node.css +1 -0
- package/dist/assets/input.css +1 -0
- package/dist/assets/popover.css +1 -0
- package/dist/assets/separator.css +1 -0
- package/dist/assets/simple-editor.css +1 -0
- package/dist/assets/toolbar.css +1 -0
- package/dist/assets/tooltip.css +1 -0
- package/dist/components/tiptap-icons/add-table-column-after-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/add-table-column-after-icon.js +26 -0
- package/dist/components/tiptap-icons/add-table-column-before-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/add-table-column-before-icon.js +26 -0
- package/dist/components/tiptap-icons/add-table-row-after-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/add-table-row-after-icon.js +26 -0
- package/dist/components/tiptap-icons/add-table-row-before-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/add-table-row-before-icon.js +26 -0
- package/dist/components/tiptap-icons/align-center-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-center-icon.js +47 -0
- package/dist/components/tiptap-icons/align-justify-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-justify-icon.js +47 -0
- package/dist/components/tiptap-icons/align-left-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/align-left-icon.js +49 -0
- package/dist/components/tiptap-icons/align-right-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/align-right-icon.js +49 -0
- package/dist/components/tiptap-icons/arrow-left-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/arrow-left-icon.js +27 -0
- package/dist/components/tiptap-icons/ban-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/ban-icon.js +29 -0
- package/dist/components/tiptap-icons/blockquote-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/blockquote-icon.js +58 -0
- package/dist/components/tiptap-icons/bold-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/bold-icon.js +29 -0
- package/dist/components/tiptap-icons/chevron-down-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/chevron-down-icon.js +27 -0
- package/dist/components/tiptap-icons/close-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/close-icon.js +27 -0
- package/dist/components/tiptap-icons/code-block-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/code-block-icon.js +49 -0
- package/dist/components/tiptap-icons/code2-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/code2-icon.js +43 -0
- package/dist/components/tiptap-icons/corner-down-left-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/corner-down-left-icon.js +29 -0
- package/dist/components/tiptap-icons/delete-table-column-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/delete-table-column-icon.js +26 -0
- package/dist/components/tiptap-icons/delete-table-row-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/delete-table-row-icon.js +33 -0
- package/dist/components/tiptap-icons/external-link-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/external-link-icon.js +36 -0
- package/dist/components/tiptap-icons/heading-five-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-five-icon.js +36 -0
- package/dist/components/tiptap-icons/heading-four-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-four-icon.js +36 -0
- package/dist/components/tiptap-icons/heading-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-icon.js +27 -0
- package/dist/components/tiptap-icons/heading-one-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-one-icon.js +36 -0
- package/dist/components/tiptap-icons/heading-six-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-six-icon.js +38 -0
- package/dist/components/tiptap-icons/heading-three-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-three-icon.js +47 -0
- package/dist/components/tiptap-icons/heading-two-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/heading-two-icon.js +36 -0
- package/dist/components/tiptap-icons/highlighter-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/highlighter-icon.js +29 -0
- package/dist/components/tiptap-icons/image-plus-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/image-plus-icon.js +29 -0
- package/dist/components/tiptap-icons/italic-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/italic-icon.js +27 -0
- package/dist/components/tiptap-icons/link-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/link-icon.js +36 -0
- package/dist/components/tiptap-icons/list-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/list-icon.js +76 -0
- package/dist/components/tiptap-icons/list-ordered-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/list-ordered-icon.js +76 -0
- package/dist/components/tiptap-icons/list-todo-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/list-todo-icon.js +67 -0
- package/dist/components/tiptap-icons/merge-table-cells-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/merge-table-cells-icon.js +26 -0
- package/dist/components/tiptap-icons/moon-star-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/moon-star-icon.js +38 -0
- package/dist/components/tiptap-icons/redo2-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/redo2-icon.js +29 -0
- package/dist/components/tiptap-icons/remove-table-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/remove-table-icon.js +26 -0
- package/dist/components/tiptap-icons/split-table-cells-icon copy.d.ts +1 -0
- package/dist/components/tiptap-icons/split-table-cells-icon copy.js +30 -0
- package/dist/components/tiptap-icons/strike-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/strike-icon.js +36 -0
- package/dist/components/tiptap-icons/subscript-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/subscript-icon.js +49 -0
- package/dist/components/tiptap-icons/sun-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/sun-icon.js +87 -0
- package/dist/components/tiptap-icons/superscript-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/superscript-icon.js +49 -0
- package/dist/components/tiptap-icons/table-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/table-icon.js +24 -0
- package/dist/components/tiptap-icons/trash-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/trash-icon.js +29 -0
- package/dist/components/tiptap-icons/underline-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/underline-icon.js +29 -0
- package/dist/components/tiptap-icons/undo2-icon.d.ts +1 -0
- package/dist/components/tiptap-icons/undo2-icon.js +29 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js +67 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.d.ts +58 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.js +77 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node.d.ts +68 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node.js +329 -0
- package/dist/components/tiptap-node/image-upload-node/index.d.ts +1 -0
- package/dist/components/tiptap-node/image-upload-node/index.js +4 -0
- package/dist/components/tiptap-templates/simple/simple-editor.d.ts +8 -0
- package/dist/components/tiptap-templates/simple/simple-editor.js +1956 -0
- package/dist/components/tiptap-templates/simple/theme-toggle.d.ts +1 -0
- package/dist/components/tiptap-templates/simple/theme-toggle.js +28 -0
- package/dist/components/tiptap-ui/blockquote-button/blockquote-button.d.ts +22 -0
- package/dist/components/tiptap-ui/blockquote-button/blockquote-button.js +71 -0
- package/dist/components/tiptap-ui/blockquote-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/blockquote-button/index.js +11 -0
- package/dist/components/tiptap-ui/blockquote-button/use-blockquote.d.ts +80 -0
- package/dist/components/tiptap-ui/blockquote-button/use-blockquote.js +82 -0
- package/dist/components/tiptap-ui/code-block-button/code-block-button.d.ts +22 -0
- package/dist/components/tiptap-ui/code-block-button/code-block-button.js +71 -0
- package/dist/components/tiptap-ui/code-block-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/code-block-button/index.js +11 -0
- package/dist/components/tiptap-ui/code-block-button/use-code-block.d.ts +87 -0
- package/dist/components/tiptap-ui/code-block-button/use-code-block.js +83 -0
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts +45 -0
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.js +89 -0
- package/dist/components/tiptap-ui/color-highlight-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/color-highlight-button/index.js +14 -0
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts +82 -0
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.js +176 -0
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts +25 -0
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.js +136 -0
- package/dist/components/tiptap-ui/color-highlight-popover/index.d.ts +1 -0
- package/dist/components/tiptap-ui/color-highlight-popover/index.js +6 -0
- package/dist/components/tiptap-ui/heading-button/heading-button.d.ts +23 -0
- package/dist/components/tiptap-ui/heading-button/heading-button.js +74 -0
- package/dist/components/tiptap-ui/heading-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/heading-button/index.js +13 -0
- package/dist/components/tiptap-ui/heading-button/use-heading.d.ts +108 -0
- package/dist/components/tiptap-ui/heading-button/use-heading.js +112 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +20 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js +67 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/index.d.ts +2 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/index.js +7 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.js +38 -0
- package/dist/components/tiptap-ui/image-upload-button/image-upload-button.d.ts +29 -0
- package/dist/components/tiptap-ui/image-upload-button/image-upload-button.js +72 -0
- package/dist/components/tiptap-ui/image-upload-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/image-upload-button/index.js +12 -0
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.d.ts +84 -0
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.js +76 -0
- package/dist/components/tiptap-ui/insert-table-button/insert-table-button.d.ts +4 -0
- package/dist/components/tiptap-ui/insert-table-button/insert-table-button.js +41 -0
- package/dist/components/tiptap-ui/link-popover/index.d.ts +2 -0
- package/dist/components/tiptap-ui/link-popover/index.js +13 -0
- package/dist/components/tiptap-ui/link-popover/link-popover.d.ts +57 -0
- package/dist/components/tiptap-ui/link-popover/link-popover.js +193 -0
- package/dist/components/tiptap-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/components/tiptap-ui/link-popover/use-link-popover.js +103 -0
- package/dist/components/tiptap-ui/list-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/list-button/index.js +14 -0
- package/dist/components/tiptap-ui/list-button/list-button.d.ts +23 -0
- package/dist/components/tiptap-ui/list-button/list-button.js +74 -0
- package/dist/components/tiptap-ui/list-button/use-list.d.ts +97 -0
- package/dist/components/tiptap-ui/list-button/use-list.js +149 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/index.js +4 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts +29 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.js +63 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +90 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.js +84 -0
- package/dist/components/tiptap-ui/mark-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/mark-button/index.js +14 -0
- package/dist/components/tiptap-ui/mark-button/mark-button.d.ts +23 -0
- package/dist/components/tiptap-ui/mark-button/mark-button.js +74 -0
- package/dist/components/tiptap-ui/mark-button/use-mark.d.ts +104 -0
- package/dist/components/tiptap-ui/mark-button/use-mark.js +84 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-column-after-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-column-after-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-column-before-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-column-before-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-row-after-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-row-after-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-row-before-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/add-row-before-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/delete-column-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/delete-column-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/delete-row-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/delete-row-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/get-table-node-and-pos.d.ts +6 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/get-table-node-and-pos.js +15 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/merge-cells-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/merge-cells-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/remove-table-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/remove-table-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/split-table-cells-button.d.ts +4 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/split-table-cells-button.js +7 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/table-actions-toolbar.d.ts +2 -0
- package/dist/components/tiptap-ui/table-actions-toolbar/table-actions-toolbar.js +75 -0
- package/dist/components/tiptap-ui/text-align-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/text-align-button/index.js +15 -0
- package/dist/components/tiptap-ui/text-align-button/text-align-button.d.ts +30 -0
- package/dist/components/tiptap-ui/text-align-button/text-align-button.js +81 -0
- package/dist/components/tiptap-ui/text-align-button/use-text-align.d.ts +101 -0
- package/dist/components/tiptap-ui/text-align-button/use-text-align.js +84 -0
- package/dist/components/tiptap-ui/undo-redo-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/undo-redo-button/index.js +13 -0
- package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
- package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.js +70 -0
- package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
- package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.js +67 -0
- package/dist/components/tiptap-ui-primitive/badge/badge.d.ts +8 -0
- package/dist/components/tiptap-ui-primitive/badge/badge.js +30 -0
- package/dist/components/tiptap-ui-primitive/badge/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/badge/index.js +4 -0
- package/dist/components/tiptap-ui-primitive/button/button.d.ts +14 -0
- package/dist/components/tiptap-ui-primitive/button/button.js +69 -0
- package/dist/components/tiptap-ui-primitive/button/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/button/index.js +6 -0
- package/dist/components/tiptap-ui-primitive/card/card.d.ts +9 -0
- package/dist/components/tiptap-ui-primitive/card/card.js +62 -0
- package/dist/components/tiptap-ui-primitive/card/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/card/index.js +9 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +16 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.js +1028 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/index.js +13 -0
- package/dist/components/tiptap-ui-primitive/input/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/input/index.js +5 -0
- package/dist/components/tiptap-ui-primitive/input/input.d.ts +3 -0
- package/dist/components/tiptap-ui-primitive/input/input.js +16 -0
- package/dist/components/tiptap-ui-primitive/popover/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/popover/index.js +6 -0
- package/dist/components/tiptap-ui-primitive/popover/popover.d.ts +5 -0
- package/dist/components/tiptap-ui-primitive/popover/popover.js +244 -0
- package/dist/components/tiptap-ui-primitive/separator/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/separator/index.js +4 -0
- package/dist/components/tiptap-ui-primitive/separator/separator.d.ts +6 -0
- package/dist/components/tiptap-ui-primitive/separator/separator.js +22 -0
- package/dist/components/tiptap-ui-primitive/spacer/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/spacer/index.js +4 -0
- package/dist/components/tiptap-ui-primitive/spacer/spacer.d.ts +6 -0
- package/dist/components/tiptap-ui-primitive/spacer/spacer.js +20 -0
- package/dist/components/tiptap-ui-primitive/toolbar/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/toolbar/index.js +6 -0
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.d.ts +8 -0
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.js +83 -0
- package/dist/components/tiptap-ui-primitive/tooltip/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/tooltip/index.js +6 -0
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +28 -0
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.js +1374 -0
- package/dist/floating-ui.react-dom-DgOuULHo.js +1334 -0
- package/dist/hooks/use-composed-ref.d.ts +3 -0
- package/dist/hooks/use-composed-ref.js +16 -0
- package/dist/hooks/use-cursor-visibility.d.ts +20 -0
- package/dist/hooks/use-cursor-visibility.js +31 -0
- package/dist/hooks/use-element-rect.d.ts +35 -0
- package/dist/hooks/use-element-rect.js +79 -0
- package/dist/hooks/use-menu-navigation.d.ts +52 -0
- package/dist/hooks/use-menu-navigation.js +68 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +13 -0
- package/dist/hooks/use-scrolling.d.ts +8 -0
- package/dist/hooks/use-scrolling.js +17 -0
- package/dist/hooks/use-throttled-callback.d.ts +18 -0
- package/dist/hooks/use-throttled-callback.js +116 -0
- package/dist/hooks/use-tiptap-editor.d.ts +17 -0
- package/dist/hooks/use-tiptap-editor.js +25 -0
- package/dist/hooks/use-unmount.d.ts +7 -0
- package/dist/hooks/use-unmount.js +14 -0
- package/dist/hooks/use-window-size.d.ts +35 -0
- package/dist/hooks/use-window-size.js +33 -0
- package/dist/index-Bqw9S4qP.js +238 -0
- package/dist/lib/tiptap-utils.d.ts +160 -0
- package/dist/lib/tiptap-utils.js +229 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +4 -0
- package/package.json +67 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState as b, useEffect as I, useCallback as g } from "react";
|
|
2
|
+
import { f as U } from "../../../index-Bqw9S4qP.js";
|
|
3
|
+
import "@tiptap/react";
|
|
4
|
+
import { useTiptapEditor as h } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { useIsMobile as E } from "../../../hooks/use-mobile.js";
|
|
6
|
+
import { isExtensionAvailable as c } from "../../../lib/tiptap-utils.js";
|
|
7
|
+
import { ImagePlusIcon as v } from "../../tiptap-icons/image-plus-icon.js";
|
|
8
|
+
const u = "mod+shift+i";
|
|
9
|
+
function a(e) {
|
|
10
|
+
return !e || !e.isEditable || !c(e, "imageUpload") ? !1 : e.can().insertContent({ type: "imageUpload" });
|
|
11
|
+
}
|
|
12
|
+
function A(e) {
|
|
13
|
+
return !e || !e.isEditable ? !1 : e.isActive("imageUpload");
|
|
14
|
+
}
|
|
15
|
+
function C(e) {
|
|
16
|
+
if (!e || !e.isEditable || !a(e)) return !1;
|
|
17
|
+
try {
|
|
18
|
+
return e.chain().focus().insertContent({
|
|
19
|
+
type: "imageUpload"
|
|
20
|
+
}).run();
|
|
21
|
+
} catch {
|
|
22
|
+
return !1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function y(e) {
|
|
26
|
+
const { editor: i, hideWhenUnavailable: s } = e;
|
|
27
|
+
return !i || !i.isEditable || !c(i, "imageUpload") ? !1 : s && !i.isActive("code") ? a(i) : !0;
|
|
28
|
+
}
|
|
29
|
+
function K(e) {
|
|
30
|
+
const {
|
|
31
|
+
editor: i,
|
|
32
|
+
hideWhenUnavailable: s = !1,
|
|
33
|
+
onInserted: r
|
|
34
|
+
} = e || {}, { editor: t } = h(i), m = E(), [o, d] = b(!0), l = a(t), p = A(t);
|
|
35
|
+
I(() => {
|
|
36
|
+
if (!t) return;
|
|
37
|
+
const n = () => {
|
|
38
|
+
d(y({ editor: t, hideWhenUnavailable: s }));
|
|
39
|
+
};
|
|
40
|
+
return n(), t.on("selectionUpdate", n), () => {
|
|
41
|
+
t.off("selectionUpdate", n);
|
|
42
|
+
};
|
|
43
|
+
}, [t, s]);
|
|
44
|
+
const f = g(() => {
|
|
45
|
+
if (!t) return !1;
|
|
46
|
+
const n = C(t);
|
|
47
|
+
return n && r?.(), n;
|
|
48
|
+
}, [t, r]);
|
|
49
|
+
return U(
|
|
50
|
+
u,
|
|
51
|
+
(n) => {
|
|
52
|
+
n.preventDefault(), f();
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
enabled: o && l,
|
|
56
|
+
enableOnContentEditable: !m,
|
|
57
|
+
enableOnFormTags: !0
|
|
58
|
+
}
|
|
59
|
+
), {
|
|
60
|
+
isVisible: o,
|
|
61
|
+
isActive: p,
|
|
62
|
+
handleImage: f,
|
|
63
|
+
canInsert: l,
|
|
64
|
+
label: "Add image",
|
|
65
|
+
shortcutKeys: u,
|
|
66
|
+
Icon: v
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
u as IMAGE_UPLOAD_SHORTCUT_KEY,
|
|
71
|
+
a as canInsertImage,
|
|
72
|
+
C as insertImage,
|
|
73
|
+
A as isImageActive,
|
|
74
|
+
y as shouldShowButton,
|
|
75
|
+
K as useImageUpload
|
|
76
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
2
|
+
type InsertTableButtonProps = Omit<ButtonProps, "type">;
|
|
3
|
+
export declare const InsertTableButton: import('react').ForwardRefExoticComponent<InsertTableButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { TableIcon as p } from "../../tiptap-icons/table-icon.js";
|
|
3
|
+
import { useTiptapEditor as f } from "../../../hooks/use-tiptap-editor.js";
|
|
4
|
+
import { forwardRef as d, useState as c, useEffect as m } from "react";
|
|
5
|
+
import { getTableNodeAndPos as b } from "../table-actions-toolbar/get-table-node-and-pos.js";
|
|
6
|
+
import { Button as u } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
const h = d(({ ...e }, r) => {
|
|
8
|
+
const { editor: t } = f(), [a, o] = c(!1);
|
|
9
|
+
return m(() => {
|
|
10
|
+
if (!t) return;
|
|
11
|
+
const s = () => {
|
|
12
|
+
const i = t.isActive("table"), l = b(t);
|
|
13
|
+
o(!!(i && l));
|
|
14
|
+
};
|
|
15
|
+
return t.on("selectionUpdate", s), () => {
|
|
16
|
+
t.off("selectionUpdate", s);
|
|
17
|
+
};
|
|
18
|
+
}, [t]), /* @__PURE__ */ n(
|
|
19
|
+
u,
|
|
20
|
+
{
|
|
21
|
+
type: "button",
|
|
22
|
+
"data-style": "ghost",
|
|
23
|
+
role: "button",
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
disabled: a,
|
|
26
|
+
tooltip: "Insert Table",
|
|
27
|
+
...e,
|
|
28
|
+
style: {
|
|
29
|
+
display: "flex",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
gap: "4px",
|
|
32
|
+
...e.style
|
|
33
|
+
},
|
|
34
|
+
ref: r,
|
|
35
|
+
children: /* @__PURE__ */ n(p, { className: "tiptap-button-icon" })
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
h as InsertTableButton
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LinkButton as e, LinkContent as t, LinkPopover as i } from "./link-popover.js";
|
|
2
|
+
import { canSetLink as L, isLinkActive as r, shouldShowLinkButton as u, useLinkHandler as s, useLinkPopover as p, useLinkState as a } from "./use-link-popover.js";
|
|
3
|
+
export {
|
|
4
|
+
e as LinkButton,
|
|
5
|
+
t as LinkContent,
|
|
6
|
+
i as LinkPopover,
|
|
7
|
+
L as canSetLink,
|
|
8
|
+
r as isLinkActive,
|
|
9
|
+
u as shouldShowLinkButton,
|
|
10
|
+
s as useLinkHandler,
|
|
11
|
+
p as useLinkPopover,
|
|
12
|
+
a as useLinkState
|
|
13
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { UseLinkPopoverConfig } from '.';
|
|
3
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
4
|
+
export interface LinkMainProps {
|
|
5
|
+
/**
|
|
6
|
+
* The URL to set for the link.
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
/**
|
|
10
|
+
* Function to update the URL state.
|
|
11
|
+
*/
|
|
12
|
+
setUrl: React.Dispatch<React.SetStateAction<string | null>>;
|
|
13
|
+
/**
|
|
14
|
+
* Function to set the link in the editor.
|
|
15
|
+
*/
|
|
16
|
+
setLink: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Function to remove the link from the editor.
|
|
19
|
+
*/
|
|
20
|
+
removeLink: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Function to open the link.
|
|
23
|
+
*/
|
|
24
|
+
openLink: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the link is currently active in the editor.
|
|
27
|
+
*/
|
|
28
|
+
isActive: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface LinkPopoverProps extends Omit<ButtonProps, "type">, UseLinkPopoverConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Callback for when the popover opens or closes.
|
|
33
|
+
*/
|
|
34
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to automatically open the popover when a link is active.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
autoOpenOnLinkActive?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Link button component for triggering the link popover
|
|
43
|
+
*/
|
|
44
|
+
export declare const LinkButton: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
/**
|
|
46
|
+
* Link content component for standalone use
|
|
47
|
+
*/
|
|
48
|
+
export declare const LinkContent: React.FC<{
|
|
49
|
+
editor?: Editor | null;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Link popover component for Tiptap editors.
|
|
53
|
+
*
|
|
54
|
+
* For custom popover implementations, use the `useLinkPopover` hook instead.
|
|
55
|
+
*/
|
|
56
|
+
export declare const LinkPopover: import('react').ForwardRefExoticComponent<LinkPopoverProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
57
|
+
export default LinkPopover;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as L, useState as T, useCallback as h, useEffect as j } from "react";
|
|
3
|
+
import { useIsMobile as K } from "../../../hooks/use-mobile.js";
|
|
4
|
+
import { useTiptapEditor as O } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { CornerDownLeftIcon as R } from "../../tiptap-icons/corner-down-left-icon.js";
|
|
6
|
+
import { ExternalLinkIcon as F } from "../../tiptap-icons/external-link-icon.js";
|
|
7
|
+
import { LinkIcon as U } from "../../tiptap-icons/link-icon.js";
|
|
8
|
+
import { TrashIcon as V } from "../../tiptap-icons/trash-icon.js";
|
|
9
|
+
import { useLinkPopover as g } from "./use-link-popover.js";
|
|
10
|
+
import { InputGroup as q, Input as H } from "../../tiptap-ui-primitive/input/input.js";
|
|
11
|
+
import { Button as u, ButtonGroup as C } from "../../tiptap-ui-primitive/button/button.js";
|
|
12
|
+
import { Popover as J, PopoverTrigger as Q, PopoverContent as W } from "../../tiptap-ui-primitive/popover/popover.js";
|
|
13
|
+
import { Card as X, CardBody as Y, CardItemGroup as Z } from "../../tiptap-ui-primitive/card/card.js";
|
|
14
|
+
import { Separator as _ } from "../../tiptap-ui-primitive/separator/separator.js";
|
|
15
|
+
const v = L(
|
|
16
|
+
({ className: o, children: e, ...n }, r) => /* @__PURE__ */ t(
|
|
17
|
+
u,
|
|
18
|
+
{
|
|
19
|
+
type: "button",
|
|
20
|
+
className: o,
|
|
21
|
+
"data-style": "ghost",
|
|
22
|
+
role: "button",
|
|
23
|
+
tabIndex: -1,
|
|
24
|
+
"aria-label": "Link",
|
|
25
|
+
tooltip: "Link",
|
|
26
|
+
ref: r,
|
|
27
|
+
...n,
|
|
28
|
+
children: e || /* @__PURE__ */ t(U, { className: "tiptap-button-icon" })
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
v.displayName = "LinkButton";
|
|
33
|
+
const I = ({
|
|
34
|
+
url: o,
|
|
35
|
+
setUrl: e,
|
|
36
|
+
setLink: n,
|
|
37
|
+
removeLink: r,
|
|
38
|
+
openLink: p,
|
|
39
|
+
isActive: i
|
|
40
|
+
}) => {
|
|
41
|
+
const d = K(), m = (a) => {
|
|
42
|
+
a.key === "Enter" && (a.preventDefault(), n());
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ t(
|
|
45
|
+
X,
|
|
46
|
+
{
|
|
47
|
+
style: {
|
|
48
|
+
...d ? { boxShadow: "none", border: 0 } : {}
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ t(
|
|
51
|
+
Y,
|
|
52
|
+
{
|
|
53
|
+
style: {
|
|
54
|
+
...d ? { padding: 0 } : {}
|
|
55
|
+
},
|
|
56
|
+
children: /* @__PURE__ */ b(Z, { orientation: "horizontal", children: [
|
|
57
|
+
/* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(
|
|
58
|
+
H,
|
|
59
|
+
{
|
|
60
|
+
type: "url",
|
|
61
|
+
placeholder: "Paste a link...",
|
|
62
|
+
value: o,
|
|
63
|
+
onChange: (a) => e(a.target.value),
|
|
64
|
+
onKeyDown: m,
|
|
65
|
+
autoFocus: !0,
|
|
66
|
+
autoComplete: "off",
|
|
67
|
+
autoCorrect: "off",
|
|
68
|
+
autoCapitalize: "off"
|
|
69
|
+
}
|
|
70
|
+
) }),
|
|
71
|
+
/* @__PURE__ */ t(C, { orientation: "horizontal", children: /* @__PURE__ */ t(
|
|
72
|
+
u,
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
onClick: n,
|
|
76
|
+
title: "Apply link",
|
|
77
|
+
disabled: !o && !i,
|
|
78
|
+
"data-style": "ghost",
|
|
79
|
+
children: /* @__PURE__ */ t(R, { className: "tiptap-button-icon" })
|
|
80
|
+
}
|
|
81
|
+
) }),
|
|
82
|
+
/* @__PURE__ */ t(_, {}),
|
|
83
|
+
/* @__PURE__ */ b(C, { orientation: "horizontal", children: [
|
|
84
|
+
/* @__PURE__ */ t(
|
|
85
|
+
u,
|
|
86
|
+
{
|
|
87
|
+
type: "button",
|
|
88
|
+
onClick: p,
|
|
89
|
+
title: "Open in new window",
|
|
90
|
+
disabled: !o && !i,
|
|
91
|
+
"data-style": "ghost",
|
|
92
|
+
children: /* @__PURE__ */ t(F, { className: "tiptap-button-icon" })
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ t(
|
|
96
|
+
u,
|
|
97
|
+
{
|
|
98
|
+
type: "button",
|
|
99
|
+
onClick: r,
|
|
100
|
+
title: "Remove link",
|
|
101
|
+
disabled: !o && !i,
|
|
102
|
+
"data-style": "ghost",
|
|
103
|
+
children: /* @__PURE__ */ t(V, { className: "tiptap-button-icon" })
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] })
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}, mt = ({ editor: o }) => {
|
|
113
|
+
const e = g({
|
|
114
|
+
editor: o
|
|
115
|
+
});
|
|
116
|
+
return /* @__PURE__ */ t(I, { ...e });
|
|
117
|
+
}, $ = L(
|
|
118
|
+
({
|
|
119
|
+
editor: o,
|
|
120
|
+
hideWhenUnavailable: e = !1,
|
|
121
|
+
onSetLink: n,
|
|
122
|
+
onOpenChange: r,
|
|
123
|
+
autoOpenOnLinkActive: p = !0,
|
|
124
|
+
onClick: i,
|
|
125
|
+
children: d,
|
|
126
|
+
...m
|
|
127
|
+
}, a) => {
|
|
128
|
+
const { editor: P } = O(o), [f, c] = T(!1), {
|
|
129
|
+
isVisible: w,
|
|
130
|
+
canSet: k,
|
|
131
|
+
isActive: l,
|
|
132
|
+
url: N,
|
|
133
|
+
setUrl: x,
|
|
134
|
+
setLink: y,
|
|
135
|
+
removeLink: B,
|
|
136
|
+
openLink: S,
|
|
137
|
+
label: z,
|
|
138
|
+
Icon: D
|
|
139
|
+
} = g({
|
|
140
|
+
editor: P,
|
|
141
|
+
hideWhenUnavailable: e,
|
|
142
|
+
onSetLink: n
|
|
143
|
+
}), E = h(
|
|
144
|
+
(s) => {
|
|
145
|
+
c(s), r?.(s);
|
|
146
|
+
},
|
|
147
|
+
[r]
|
|
148
|
+
), G = h(() => {
|
|
149
|
+
y(), c(!1);
|
|
150
|
+
}, [y]), M = h(
|
|
151
|
+
(s) => {
|
|
152
|
+
i?.(s), !s.defaultPrevented && c(!f);
|
|
153
|
+
},
|
|
154
|
+
[i, f]
|
|
155
|
+
);
|
|
156
|
+
return j(() => {
|
|
157
|
+
p && l && c(!0);
|
|
158
|
+
}, [p, l]), w ? /* @__PURE__ */ b(J, { open: f, onOpenChange: E, children: [
|
|
159
|
+
/* @__PURE__ */ t(Q, { asChild: !0, children: /* @__PURE__ */ t(
|
|
160
|
+
v,
|
|
161
|
+
{
|
|
162
|
+
disabled: !k,
|
|
163
|
+
"data-active-state": l ? "on" : "off",
|
|
164
|
+
"data-disabled": !k,
|
|
165
|
+
"aria-label": z,
|
|
166
|
+
"aria-pressed": l,
|
|
167
|
+
onClick: M,
|
|
168
|
+
...m,
|
|
169
|
+
ref: a,
|
|
170
|
+
children: d ?? /* @__PURE__ */ t(D, { className: "tiptap-button-icon" })
|
|
171
|
+
}
|
|
172
|
+
) }),
|
|
173
|
+
/* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(
|
|
174
|
+
I,
|
|
175
|
+
{
|
|
176
|
+
url: N,
|
|
177
|
+
setUrl: x,
|
|
178
|
+
setLink: G,
|
|
179
|
+
removeLink: B,
|
|
180
|
+
openLink: S,
|
|
181
|
+
isActive: l
|
|
182
|
+
}
|
|
183
|
+
) })
|
|
184
|
+
] }) : null;
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
$.displayName = "LinkPopover";
|
|
188
|
+
export {
|
|
189
|
+
v as LinkButton,
|
|
190
|
+
mt as LinkContent,
|
|
191
|
+
$ as LinkPopover,
|
|
192
|
+
$ as default
|
|
193
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the link popover functionality
|
|
4
|
+
*/
|
|
5
|
+
export interface UseLinkPopoverConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The Tiptap editor instance.
|
|
8
|
+
*/
|
|
9
|
+
editor?: Editor | null;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to hide the link popover when not available.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
hideWhenUnavailable?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Callback function called when the link is set.
|
|
17
|
+
*/
|
|
18
|
+
onSetLink?: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for the link handler functionality
|
|
22
|
+
*/
|
|
23
|
+
export interface LinkHandlerProps {
|
|
24
|
+
/**
|
|
25
|
+
* The Tiptap editor instance.
|
|
26
|
+
*/
|
|
27
|
+
editor: Editor | null;
|
|
28
|
+
/**
|
|
29
|
+
* Callback function called when the link is set.
|
|
30
|
+
*/
|
|
31
|
+
onSetLink?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a link can be set in the current editor state
|
|
35
|
+
*/
|
|
36
|
+
export declare function canSetLink(editor: Editor | null): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a link is currently active in the editor
|
|
39
|
+
*/
|
|
40
|
+
export declare function isLinkActive(editor: Editor | null): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Determines if the link button should be shown
|
|
43
|
+
*/
|
|
44
|
+
export declare function shouldShowLinkButton(props: {
|
|
45
|
+
editor: Editor | null;
|
|
46
|
+
hideWhenUnavailable: boolean;
|
|
47
|
+
}): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom hook for handling link operations in a Tiptap editor
|
|
50
|
+
*/
|
|
51
|
+
export declare function useLinkHandler(props: LinkHandlerProps): {
|
|
52
|
+
url: string;
|
|
53
|
+
setUrl: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
54
|
+
setLink: () => void;
|
|
55
|
+
removeLink: () => void;
|
|
56
|
+
openLink: (target?: string, features?: string) => void;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Custom hook for link popover state management
|
|
60
|
+
*/
|
|
61
|
+
export declare function useLinkState(props: {
|
|
62
|
+
editor: Editor | null;
|
|
63
|
+
hideWhenUnavailable: boolean;
|
|
64
|
+
}): {
|
|
65
|
+
isVisible: boolean;
|
|
66
|
+
canSet: boolean;
|
|
67
|
+
isActive: boolean;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Main hook that provides link popover functionality for Tiptap editor
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* // Simple usage
|
|
75
|
+
* function MyLinkButton() {
|
|
76
|
+
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover()
|
|
77
|
+
*
|
|
78
|
+
* if (!isVisible) return null
|
|
79
|
+
*
|
|
80
|
+
* return <button disabled={!canSet}>Link</button>
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* // Advanced usage with configuration
|
|
84
|
+
* function MyAdvancedLinkButton() {
|
|
85
|
+
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover({
|
|
86
|
+
* editor: myEditor,
|
|
87
|
+
* hideWhenUnavailable: true,
|
|
88
|
+
* onSetLink: () => console.log('Link set!')
|
|
89
|
+
* })
|
|
90
|
+
*
|
|
91
|
+
* if (!isVisible) return null
|
|
92
|
+
*
|
|
93
|
+
* return (
|
|
94
|
+
* <MyButton
|
|
95
|
+
* disabled={!canSet}
|
|
96
|
+
* aria-label={label}
|
|
97
|
+
* aria-pressed={isActive}
|
|
98
|
+
* >
|
|
99
|
+
* <Icon />
|
|
100
|
+
* {label}
|
|
101
|
+
* </MyButton>
|
|
102
|
+
* )
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function useLinkPopover(config?: UseLinkPopoverConfig): {
|
|
107
|
+
url: string;
|
|
108
|
+
setUrl: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
109
|
+
setLink: () => void;
|
|
110
|
+
removeLink: () => void;
|
|
111
|
+
openLink: (target?: string, features?: string) => void;
|
|
112
|
+
isVisible: boolean;
|
|
113
|
+
canSet: boolean;
|
|
114
|
+
isActive: boolean;
|
|
115
|
+
label: string;
|
|
116
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
117
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useState as d, useEffect as k, useCallback as f } from "react";
|
|
2
|
+
import { useTiptapEditor as L } from "../../../hooks/use-tiptap-editor.js";
|
|
3
|
+
import { LinkIcon as m } from "../../tiptap-icons/link-icon.js";
|
|
4
|
+
import { sanitizeUrl as S, isNodeTypeSelected as b, isMarkInSchema as v } from "../../../lib/tiptap-utils.js";
|
|
5
|
+
function p(n) {
|
|
6
|
+
return !n || !n.isEditable || b(n, ["image"], !0) ? !1 : n.can().setMark("link");
|
|
7
|
+
}
|
|
8
|
+
function h(n) {
|
|
9
|
+
return !n || !n.isEditable ? !1 : n.isActive("link");
|
|
10
|
+
}
|
|
11
|
+
function U(n) {
|
|
12
|
+
const { editor: e, hideWhenUnavailable: o } = n;
|
|
13
|
+
return !v("link", e) || !e ? !1 : o && !e.isActive("code") ? p(e) : !0;
|
|
14
|
+
}
|
|
15
|
+
function A(n) {
|
|
16
|
+
const { editor: e, onSetLink: o } = n, [t, i] = d(null);
|
|
17
|
+
k(() => {
|
|
18
|
+
if (!e) return;
|
|
19
|
+
const { href: r } = e.getAttributes("link");
|
|
20
|
+
h(e) && t === null && i(r || "");
|
|
21
|
+
}, [e, t]), k(() => {
|
|
22
|
+
if (!e) return;
|
|
23
|
+
const r = () => {
|
|
24
|
+
const { href: u } = e.getAttributes("link");
|
|
25
|
+
i(u || "");
|
|
26
|
+
};
|
|
27
|
+
return e.on("selectionUpdate", r), () => {
|
|
28
|
+
e.off("selectionUpdate", r);
|
|
29
|
+
};
|
|
30
|
+
}, [e]);
|
|
31
|
+
const l = f(() => {
|
|
32
|
+
if (!t || !e) return;
|
|
33
|
+
const { selection: r } = e.state, u = r.empty;
|
|
34
|
+
let s = e.chain().focus();
|
|
35
|
+
s = s.extendMarkRange("link").setLink({ href: t }), u && (s = s.insertContent({ type: "text", text: t })), s.run(), i(null), o?.();
|
|
36
|
+
}, [e, o, t]), a = f(() => {
|
|
37
|
+
e && (e.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink", !0).run(), i(""));
|
|
38
|
+
}, [e]), c = f(
|
|
39
|
+
(r = "_blank", u = "noopener,noreferrer") => {
|
|
40
|
+
if (!t) return;
|
|
41
|
+
const s = S(t, window.location.href);
|
|
42
|
+
s !== "#" && window.open(s, r, u);
|
|
43
|
+
},
|
|
44
|
+
[t]
|
|
45
|
+
);
|
|
46
|
+
return {
|
|
47
|
+
url: t || "",
|
|
48
|
+
setUrl: i,
|
|
49
|
+
setLink: l,
|
|
50
|
+
removeLink: a,
|
|
51
|
+
openLink: c
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function E(n) {
|
|
55
|
+
const { editor: e, hideWhenUnavailable: o = !1 } = n, t = p(e), i = h(e), [l, a] = d(!1);
|
|
56
|
+
return k(() => {
|
|
57
|
+
if (!e) return;
|
|
58
|
+
const c = () => {
|
|
59
|
+
a(
|
|
60
|
+
U({
|
|
61
|
+
editor: e,
|
|
62
|
+
hideWhenUnavailable: o
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
return c(), e.on("selectionUpdate", c), () => {
|
|
67
|
+
e.off("selectionUpdate", c);
|
|
68
|
+
};
|
|
69
|
+
}, [e, o]), {
|
|
70
|
+
isVisible: l,
|
|
71
|
+
canSet: t,
|
|
72
|
+
isActive: i
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function M(n) {
|
|
76
|
+
const {
|
|
77
|
+
editor: e,
|
|
78
|
+
hideWhenUnavailable: o = !1,
|
|
79
|
+
onSetLink: t
|
|
80
|
+
} = n || {}, { editor: i } = L(e), { isVisible: l, canSet: a, isActive: c } = E({
|
|
81
|
+
editor: i,
|
|
82
|
+
hideWhenUnavailable: o
|
|
83
|
+
}), r = A({
|
|
84
|
+
editor: i,
|
|
85
|
+
onSetLink: t
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
isVisible: l,
|
|
89
|
+
canSet: a,
|
|
90
|
+
isActive: c,
|
|
91
|
+
label: "Link",
|
|
92
|
+
Icon: m,
|
|
93
|
+
...r
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
p as canSetLink,
|
|
98
|
+
h as isLinkActive,
|
|
99
|
+
U as shouldShowLinkButton,
|
|
100
|
+
A as useLinkHandler,
|
|
101
|
+
M as useLinkPopover,
|
|
102
|
+
E as useLinkState
|
|
103
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ListButton as o, ListShortcutBadge as i } from "./list-button.js";
|
|
2
|
+
import { LIST_SHORTCUT_KEYS as L, canToggleList as l, isListActive as g, listIcons as r, listLabels as u, shouldShowButton as S, toggleList as c, useList as n } from "./use-list.js";
|
|
3
|
+
export {
|
|
4
|
+
L as LIST_SHORTCUT_KEYS,
|
|
5
|
+
o as ListButton,
|
|
6
|
+
i as ListShortcutBadge,
|
|
7
|
+
l as canToggleList,
|
|
8
|
+
g as isListActive,
|
|
9
|
+
r as listIcons,
|
|
10
|
+
u as listLabels,
|
|
11
|
+
S as shouldShowButton,
|
|
12
|
+
c as toggleList,
|
|
13
|
+
n as useList
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
2
|
+
import { ListType, UseListConfig } from '.';
|
|
3
|
+
export interface ListButtonProps extends Omit<ButtonProps, "type">, UseListConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Optional text to display alongside the icon.
|
|
6
|
+
*/
|
|
7
|
+
text?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Optional show shortcut keys in the button.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
showShortcut?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function ListShortcutBadge({ type, shortcutKeys, }: {
|
|
15
|
+
type: ListType;
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for toggling lists in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* For custom button implementations, use the `useList` hook instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ListButton: import('react').ForwardRefExoticComponent<ListButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|