@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,108 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the heading functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseHeadingConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* The heading level.
|
|
13
|
+
*/
|
|
14
|
+
level: Level;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the button should hide when heading is not available.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
hideWhenUnavailable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback function called after a successful heading toggle.
|
|
22
|
+
*/
|
|
23
|
+
onToggled?: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const headingIcons: {
|
|
26
|
+
1: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
27
|
+
2: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
28
|
+
3: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
29
|
+
4: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
30
|
+
5: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
31
|
+
6: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
32
|
+
};
|
|
33
|
+
export declare const HEADING_SHORTCUT_KEYS: Record<Level, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if heading can be toggled in the current editor state
|
|
36
|
+
*/
|
|
37
|
+
export declare function canToggle(editor: Editor | null, level?: Level, turnInto?: boolean): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if heading is currently active
|
|
40
|
+
*/
|
|
41
|
+
export declare function isHeadingActive(editor: Editor | null, level?: Level | Level[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Toggles heading in the editor
|
|
44
|
+
*/
|
|
45
|
+
export declare function toggleHeading(editor: Editor | null, level: Level | Level[]): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Determines if the heading button should be shown
|
|
48
|
+
*/
|
|
49
|
+
export declare function shouldShowButton(props: {
|
|
50
|
+
editor: Editor | null;
|
|
51
|
+
level?: Level | Level[];
|
|
52
|
+
hideWhenUnavailable: boolean;
|
|
53
|
+
}): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Custom hook that provides heading functionality for Tiptap editor
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // Simple usage
|
|
60
|
+
* function MySimpleHeadingButton() {
|
|
61
|
+
* const { isVisible, isActive, handleToggle, Icon } = useHeading({ level: 1 })
|
|
62
|
+
*
|
|
63
|
+
* if (!isVisible) return null
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <button
|
|
67
|
+
* onClick={handleToggle}
|
|
68
|
+
* aria-pressed={isActive}
|
|
69
|
+
* >
|
|
70
|
+
* <Icon />
|
|
71
|
+
* Heading 1
|
|
72
|
+
* </button>
|
|
73
|
+
* )
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // Advanced usage with configuration
|
|
77
|
+
* function MyAdvancedHeadingButton() {
|
|
78
|
+
* const { isVisible, isActive, handleToggle, label, Icon } = useHeading({
|
|
79
|
+
* level: 2,
|
|
80
|
+
* editor: myEditor,
|
|
81
|
+
* hideWhenUnavailable: true,
|
|
82
|
+
* onToggled: (isActive) => console.log('Heading toggled:', isActive)
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* if (!isVisible) return null
|
|
86
|
+
*
|
|
87
|
+
* return (
|
|
88
|
+
* <MyButton
|
|
89
|
+
* onClick={handleToggle}
|
|
90
|
+
* aria-label={label}
|
|
91
|
+
* aria-pressed={isActive}
|
|
92
|
+
* >
|
|
93
|
+
* <Icon />
|
|
94
|
+
* Toggle Heading 2
|
|
95
|
+
* </MyButton>
|
|
96
|
+
* )
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function useHeading(config: UseHeadingConfig): {
|
|
101
|
+
isVisible: boolean;
|
|
102
|
+
isActive: boolean;
|
|
103
|
+
handleToggle: () => boolean;
|
|
104
|
+
canToggle: boolean;
|
|
105
|
+
label: string;
|
|
106
|
+
shortcutKeys: string;
|
|
107
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
108
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { useState as S, useEffect as N, useCallback as H } from "react";
|
|
2
|
+
import "@tiptap/react";
|
|
3
|
+
import { TextSelection as h, NodeSelection as m } from "prosemirror-state";
|
|
4
|
+
import { useTiptapEditor as y } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { isNodeInSchema as p, isNodeTypeSelected as I, selectionWithinConvertibleTypes as E, findNodePosition as C, isValidPosition as U } from "../../../lib/tiptap-utils.js";
|
|
6
|
+
import { HeadingOneIcon as k } from "../../tiptap-icons/heading-one-icon.js";
|
|
7
|
+
import { HeadingTwoIcon as w } from "../../tiptap-icons/heading-two-icon.js";
|
|
8
|
+
import { HeadingThreeIcon as x } from "../../tiptap-icons/heading-three-icon.js";
|
|
9
|
+
import { HeadingFourIcon as L } from "../../tiptap-icons/heading-four-icon.js";
|
|
10
|
+
import { HeadingFiveIcon as F } from "../../tiptap-icons/heading-five-icon.js";
|
|
11
|
+
import { HeadingSixIcon as V } from "../../tiptap-icons/heading-six-icon.js";
|
|
12
|
+
const W = {
|
|
13
|
+
1: k,
|
|
14
|
+
2: w,
|
|
15
|
+
3: x,
|
|
16
|
+
4: L,
|
|
17
|
+
5: F,
|
|
18
|
+
6: V
|
|
19
|
+
}, z = {
|
|
20
|
+
1: "ctrl+alt+1",
|
|
21
|
+
2: "ctrl+alt+2",
|
|
22
|
+
3: "ctrl+alt+3",
|
|
23
|
+
4: "ctrl+alt+4",
|
|
24
|
+
5: "ctrl+alt+5",
|
|
25
|
+
6: "ctrl+alt+6"
|
|
26
|
+
};
|
|
27
|
+
function d(e, t, n = !0) {
|
|
28
|
+
return !e || !e.isEditable || !p("heading", e) || I(e, ["image"]) ? !1 : n ? E(e, [
|
|
29
|
+
"paragraph",
|
|
30
|
+
"heading",
|
|
31
|
+
"bulletList",
|
|
32
|
+
"orderedList",
|
|
33
|
+
"taskList",
|
|
34
|
+
"blockquote",
|
|
35
|
+
"codeBlock"
|
|
36
|
+
]) ? t ? e.can().setNode("heading", { level: t }) || e.can().clearNodes() : e.can().setNode("heading") || e.can().clearNodes() : !1 : t ? e.can().setNode("heading", { level: t }) : e.can().setNode("heading");
|
|
37
|
+
}
|
|
38
|
+
function B(e, t) {
|
|
39
|
+
return !e || !e.isEditable ? !1 : Array.isArray(t) ? t.some((n) => e.isActive("heading", { level: n })) : t ? e.isActive("heading", { level: t }) : e.isActive("heading");
|
|
40
|
+
}
|
|
41
|
+
function K(e, t) {
|
|
42
|
+
if (!e || !e.isEditable) return !1;
|
|
43
|
+
const n = Array.isArray(t) ? t : [t], a = n.find((s) => d(e, s));
|
|
44
|
+
if (!a) return !1;
|
|
45
|
+
try {
|
|
46
|
+
const s = e.view;
|
|
47
|
+
let i = s.state, l = i.tr;
|
|
48
|
+
if (i.selection.empty || i.selection instanceof h) {
|
|
49
|
+
const o = C({
|
|
50
|
+
editor: e,
|
|
51
|
+
node: i.selection.$anchor.node(1)
|
|
52
|
+
})?.pos;
|
|
53
|
+
if (!U(o)) return !1;
|
|
54
|
+
l = l.setSelection(m.create(i.doc, o)), s.dispatch(l), i = s.state;
|
|
55
|
+
}
|
|
56
|
+
const r = i.selection;
|
|
57
|
+
let c = e.chain().focus();
|
|
58
|
+
if (r instanceof m) {
|
|
59
|
+
const o = r.node.firstChild?.firstChild, g = r.node.lastChild?.lastChild, v = o ? r.from + o.nodeSize : r.from + 1, A = g ? r.to - g.nodeSize : r.to - 1, T = i.doc.resolve(v), b = i.doc.resolve(A);
|
|
60
|
+
c = c.setTextSelection(h.between(T, b)).clearNodes();
|
|
61
|
+
}
|
|
62
|
+
return (n.some(
|
|
63
|
+
(o) => e.isActive("heading", { level: o })
|
|
64
|
+
) ? c.setNode("paragraph") : c.setNode("heading", { level: a })).run(), e.chain().focus().selectTextblockEnd().run(), !0;
|
|
65
|
+
} catch {
|
|
66
|
+
return !1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function O(e) {
|
|
70
|
+
const { editor: t, level: n, hideWhenUnavailable: a } = e;
|
|
71
|
+
return !t || !t.isEditable || !p("heading", t) ? !1 : a && !t.isActive("code") ? Array.isArray(n) ? n.some((s) => d(t, s)) : d(t, n) : !0;
|
|
72
|
+
}
|
|
73
|
+
function Q(e) {
|
|
74
|
+
const {
|
|
75
|
+
editor: t,
|
|
76
|
+
level: n,
|
|
77
|
+
hideWhenUnavailable: a = !1,
|
|
78
|
+
onToggled: s
|
|
79
|
+
} = e, { editor: i } = y(t), [l, r] = S(!0), c = d(i, n), f = B(i, n);
|
|
80
|
+
N(() => {
|
|
81
|
+
if (!i) return;
|
|
82
|
+
const o = () => {
|
|
83
|
+
r(O({ editor: i, level: n, hideWhenUnavailable: a }));
|
|
84
|
+
};
|
|
85
|
+
return o(), i.on("selectionUpdate", o), () => {
|
|
86
|
+
i.off("selectionUpdate", o);
|
|
87
|
+
};
|
|
88
|
+
}, [i, n, a]);
|
|
89
|
+
const u = H(() => {
|
|
90
|
+
if (!i) return !1;
|
|
91
|
+
const o = K(i, n);
|
|
92
|
+
return o && s?.(), o;
|
|
93
|
+
}, [i, n, s]);
|
|
94
|
+
return {
|
|
95
|
+
isVisible: l,
|
|
96
|
+
isActive: f,
|
|
97
|
+
handleToggle: u,
|
|
98
|
+
canToggle: c,
|
|
99
|
+
label: `Heading ${n}`,
|
|
100
|
+
shortcutKeys: z[n],
|
|
101
|
+
Icon: W[n]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
z as HEADING_SHORTCUT_KEYS,
|
|
106
|
+
d as canToggle,
|
|
107
|
+
W as headingIcons,
|
|
108
|
+
B as isHeadingActive,
|
|
109
|
+
O as shouldShowButton,
|
|
110
|
+
K as toggleHeading,
|
|
111
|
+
Q as useHeading
|
|
112
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UseHeadingDropdownMenuConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface HeadingDropdownMenuProps extends Omit<ButtonProps, "type">, UseHeadingDropdownMenuConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to render the dropdown menu in a portal
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
portal?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Callback for when the dropdown opens or closes
|
|
11
|
+
*/
|
|
12
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dropdown menu component for selecting heading levels in a Tiptap editor.
|
|
16
|
+
*
|
|
17
|
+
* For custom dropdown implementations, use the `useHeadingDropdownMenu` hook instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare const HeadingDropdownMenu: import('react').ForwardRefExoticComponent<HeadingDropdownMenuProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
20
|
+
export default HeadingDropdownMenu;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as b, useState as C, useCallback as D } from "react";
|
|
3
|
+
import { ChevronDownIcon as M } from "../../tiptap-icons/chevron-down-icon.js";
|
|
4
|
+
import { useTiptapEditor as x } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { useHeadingDropdownMenu as H } from "./use-heading-dropdown-menu.js";
|
|
6
|
+
import { DropdownMenu as I, DropdownMenuTrigger as y, DropdownMenuContent as B, DropdownMenuItem as T } from "../../tiptap-ui-primitive/dropdown-menu/dropdown-menu.js";
|
|
7
|
+
import { HeadingButton as N } from "../heading-button/heading-button.js";
|
|
8
|
+
import { Button as O, ButtonGroup as j } from "../../tiptap-ui-primitive/button/button.js";
|
|
9
|
+
import { Card as $, CardBody as k } from "../../tiptap-ui-primitive/card/card.js";
|
|
10
|
+
const A = b(
|
|
11
|
+
({
|
|
12
|
+
editor: s,
|
|
13
|
+
levels: r = [1, 2, 3, 4, 5, 6],
|
|
14
|
+
hideWhenUnavailable: p = !1,
|
|
15
|
+
portal: l = !1,
|
|
16
|
+
onOpenChange: a,
|
|
17
|
+
...u
|
|
18
|
+
}, m) => {
|
|
19
|
+
const { editor: e } = x(s), [c, f] = C(!1), { isVisible: h, isActive: i, canToggle: n, Icon: g } = H({
|
|
20
|
+
editor: e,
|
|
21
|
+
levels: r,
|
|
22
|
+
hideWhenUnavailable: p
|
|
23
|
+
}), w = D(
|
|
24
|
+
(t) => {
|
|
25
|
+
!e || !n || (f(t), a?.(t));
|
|
26
|
+
},
|
|
27
|
+
[n, e, a]
|
|
28
|
+
);
|
|
29
|
+
return h ? /* @__PURE__ */ d(I, { modal: !0, open: c, onOpenChange: w, children: [
|
|
30
|
+
/* @__PURE__ */ o(y, { asChild: !0, children: /* @__PURE__ */ d(
|
|
31
|
+
O,
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
"data-style": "ghost",
|
|
35
|
+
"data-active-state": i ? "on" : "off",
|
|
36
|
+
role: "button",
|
|
37
|
+
tabIndex: -1,
|
|
38
|
+
disabled: !n,
|
|
39
|
+
"data-disabled": !n,
|
|
40
|
+
"aria-label": "Format text as heading",
|
|
41
|
+
"aria-pressed": i,
|
|
42
|
+
tooltip: "Heading",
|
|
43
|
+
...u,
|
|
44
|
+
ref: m,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ o(g, { className: "tiptap-button-icon" }),
|
|
47
|
+
/* @__PURE__ */ o(M, { className: "tiptap-button-dropdown-small" })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
) }),
|
|
51
|
+
/* @__PURE__ */ o(B, { align: "start", portal: l, children: /* @__PURE__ */ o($, { children: /* @__PURE__ */ o(k, { children: /* @__PURE__ */ o(j, { children: r.map((t) => /* @__PURE__ */ o(T, { asChild: !0, children: /* @__PURE__ */ o(
|
|
52
|
+
N,
|
|
53
|
+
{
|
|
54
|
+
editor: e,
|
|
55
|
+
level: t,
|
|
56
|
+
text: `Heading ${t}`,
|
|
57
|
+
showTooltip: !1
|
|
58
|
+
}
|
|
59
|
+
) }, `heading-${t}`)) }) }) }) })
|
|
60
|
+
] }) : null;
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
A.displayName = "HeadingDropdownMenu";
|
|
64
|
+
export {
|
|
65
|
+
A as HeadingDropdownMenu,
|
|
66
|
+
A as default
|
|
67
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HeadingDropdownMenu as n } from "./heading-dropdown-menu.js";
|
|
2
|
+
import { getActiveHeadingLevel as d, useHeadingDropdownMenu as g } from "./use-heading-dropdown-menu.js";
|
|
3
|
+
export {
|
|
4
|
+
n as HeadingDropdownMenu,
|
|
5
|
+
d as getActiveHeadingLevel,
|
|
6
|
+
g as useHeadingDropdownMenu
|
|
7
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { Level } from '../heading-button';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the heading dropdown menu functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseHeadingDropdownMenuConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Available heading levels to show in the dropdown
|
|
13
|
+
* @default [1, 2, 3, 4, 5, 6]
|
|
14
|
+
*/
|
|
15
|
+
levels?: Level[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether the dropdown should hide when headings are not available.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hideWhenUnavailable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the currently active heading level from the available levels
|
|
24
|
+
*/
|
|
25
|
+
export declare function getActiveHeadingLevel(editor: Editor | null, levels?: Level[]): Level | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Custom hook that provides heading dropdown menu functionality for Tiptap editor
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Simple usage
|
|
32
|
+
* function MyHeadingDropdown() {
|
|
33
|
+
* const {
|
|
34
|
+
* isVisible,
|
|
35
|
+
* activeLevel,
|
|
36
|
+
* isAnyHeadingActive,
|
|
37
|
+
* canToggle,
|
|
38
|
+
* levels,
|
|
39
|
+
* } = useHeadingDropdownMenu()
|
|
40
|
+
*
|
|
41
|
+
* if (!isVisible) return null
|
|
42
|
+
*
|
|
43
|
+
* return (
|
|
44
|
+
* <DropdownMenu>
|
|
45
|
+
* // dropdown content
|
|
46
|
+
* </DropdownMenu>
|
|
47
|
+
* )
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* // Advanced usage with configuration
|
|
51
|
+
* function MyAdvancedHeadingDropdown() {
|
|
52
|
+
* const {
|
|
53
|
+
* isVisible,
|
|
54
|
+
* activeLevel,
|
|
55
|
+
* } = useHeadingDropdownMenu({
|
|
56
|
+
* editor: myEditor,
|
|
57
|
+
* levels: [1, 2, 3],
|
|
58
|
+
* hideWhenUnavailable: true,
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
61
|
+
* // component implementation
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useHeadingDropdownMenu(config?: UseHeadingDropdownMenuConfig): {
|
|
66
|
+
isVisible: boolean;
|
|
67
|
+
activeLevel: Level | undefined;
|
|
68
|
+
isActive: boolean;
|
|
69
|
+
canToggle: boolean;
|
|
70
|
+
levels: Level[];
|
|
71
|
+
label: string;
|
|
72
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
73
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState as f, useEffect as g } from "react";
|
|
2
|
+
import { useTiptapEditor as p } from "../../../hooks/use-tiptap-editor.js";
|
|
3
|
+
import { HeadingIcon as v } from "../../tiptap-icons/heading-icon.js";
|
|
4
|
+
import { isHeadingActive as a, canToggle as m, headingIcons as h, shouldShowButton as b } from "../heading-button/use-heading.js";
|
|
5
|
+
function H(n, i = [1, 2, 3, 4, 5, 6]) {
|
|
6
|
+
if (!(!n || !n.isEditable))
|
|
7
|
+
return i.find((t) => a(n, t));
|
|
8
|
+
}
|
|
9
|
+
function U(n) {
|
|
10
|
+
const {
|
|
11
|
+
editor: i,
|
|
12
|
+
levels: t = [1, 2, 3, 4, 5, 6],
|
|
13
|
+
hideWhenUnavailable: r = !1
|
|
14
|
+
} = n || {}, { editor: e } = p(i), [c, l] = f(!0), o = H(e, t), d = a(e), u = m(e);
|
|
15
|
+
return g(() => {
|
|
16
|
+
if (!e) return;
|
|
17
|
+
const s = () => {
|
|
18
|
+
l(
|
|
19
|
+
b({ editor: e, hideWhenUnavailable: r, level: t })
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
return s(), e.on("selectionUpdate", s), () => {
|
|
23
|
+
e.off("selectionUpdate", s);
|
|
24
|
+
};
|
|
25
|
+
}, [e, r, t]), {
|
|
26
|
+
isVisible: c,
|
|
27
|
+
activeLevel: o,
|
|
28
|
+
isActive: d,
|
|
29
|
+
canToggle: u,
|
|
30
|
+
levels: t,
|
|
31
|
+
label: "Heading",
|
|
32
|
+
Icon: o ? h[o] : v
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
H as getActiveHeadingLevel,
|
|
37
|
+
U as useHeadingDropdownMenu
|
|
38
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UseImageUploadConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
type IconProps = React.SVGProps<SVGSVGElement>;
|
|
4
|
+
type IconComponent = ({ className, ...props }: IconProps) => React.ReactElement;
|
|
5
|
+
export interface ImageUploadButtonProps extends Omit<ButtonProps, "type">, UseImageUploadConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Optional text to display alongside the icon.
|
|
8
|
+
*/
|
|
9
|
+
text?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional show shortcut keys in the button.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
showShortcut?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Optional custom icon component to render instead of the default.
|
|
17
|
+
*/
|
|
18
|
+
icon?: React.MemoExoticComponent<IconComponent> | React.FC<IconProps>;
|
|
19
|
+
}
|
|
20
|
+
export declare function ImageShortcutBadge({ shortcutKeys, }: {
|
|
21
|
+
shortcutKeys?: string;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Button component for uploading/inserting images in a Tiptap editor.
|
|
25
|
+
*
|
|
26
|
+
* For custom button implementations, use the `useImage` hook instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ImageUploadButton: import('react').ForwardRefExoticComponent<ImageUploadButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as t, jsxs as U, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as R, useCallback as A } from "react";
|
|
3
|
+
import { parseShortcutKeys as C } from "../../../lib/tiptap-utils.js";
|
|
4
|
+
import { useTiptapEditor as E } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { useImageUpload as K, IMAGE_UPLOAD_SHORTCUT_KEY as N } from "./use-image-upload.js";
|
|
6
|
+
import { Button as S } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
import { Badge as T } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
8
|
+
function _({
|
|
9
|
+
shortcutKeys: e = N
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ t(T, { children: C({ shortcutKeys: e }) });
|
|
12
|
+
}
|
|
13
|
+
const j = R(
|
|
14
|
+
({
|
|
15
|
+
editor: e,
|
|
16
|
+
text: o,
|
|
17
|
+
hideWhenUnavailable: d = !1,
|
|
18
|
+
onInserted: c,
|
|
19
|
+
showShortcut: m = !1,
|
|
20
|
+
onClick: a,
|
|
21
|
+
icon: p,
|
|
22
|
+
children: u,
|
|
23
|
+
...f
|
|
24
|
+
}, b) => {
|
|
25
|
+
const { editor: I } = E(e), {
|
|
26
|
+
isVisible: h,
|
|
27
|
+
canInsert: r,
|
|
28
|
+
handleImage: n,
|
|
29
|
+
label: i,
|
|
30
|
+
isActive: s,
|
|
31
|
+
shortcutKeys: g,
|
|
32
|
+
Icon: y
|
|
33
|
+
} = K({
|
|
34
|
+
editor: I,
|
|
35
|
+
hideWhenUnavailable: d,
|
|
36
|
+
onInserted: c
|
|
37
|
+
}), B = A(
|
|
38
|
+
(l) => {
|
|
39
|
+
a?.(l), !l.defaultPrevented && n();
|
|
40
|
+
},
|
|
41
|
+
[n, a]
|
|
42
|
+
);
|
|
43
|
+
return h ? /* @__PURE__ */ t(
|
|
44
|
+
S,
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
"data-style": "ghost",
|
|
48
|
+
"data-active-state": s ? "on" : "off",
|
|
49
|
+
role: "button",
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
disabled: !r,
|
|
52
|
+
"data-disabled": !r,
|
|
53
|
+
"aria-label": i,
|
|
54
|
+
"aria-pressed": s,
|
|
55
|
+
tooltip: i,
|
|
56
|
+
onClick: B,
|
|
57
|
+
...f,
|
|
58
|
+
ref: b,
|
|
59
|
+
children: u ?? /* @__PURE__ */ U(x, { children: [
|
|
60
|
+
/* @__PURE__ */ t(p ?? y, { className: "tiptap-button-icon" }),
|
|
61
|
+
o && /* @__PURE__ */ t("span", { className: "tiptap-button-text", children: o }),
|
|
62
|
+
m && /* @__PURE__ */ t(_, { shortcutKeys: g })
|
|
63
|
+
] })
|
|
64
|
+
}
|
|
65
|
+
) : null;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
j.displayName = "ImageUploadButton";
|
|
69
|
+
export {
|
|
70
|
+
_ as ImageShortcutBadge,
|
|
71
|
+
j as ImageUploadButton
|
|
72
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ImageShortcutBadge as t, ImageUploadButton as a } from "./image-upload-button.js";
|
|
2
|
+
import { IMAGE_UPLOAD_SHORTCUT_KEY as I, canInsertImage as g, insertImage as r, isImageActive as n, shouldShowButton as s, useImageUpload as u } from "./use-image-upload.js";
|
|
3
|
+
export {
|
|
4
|
+
I as IMAGE_UPLOAD_SHORTCUT_KEY,
|
|
5
|
+
t as ImageShortcutBadge,
|
|
6
|
+
a as ImageUploadButton,
|
|
7
|
+
g as canInsertImage,
|
|
8
|
+
r as insertImage,
|
|
9
|
+
n as isImageActive,
|
|
10
|
+
s as shouldShowButton,
|
|
11
|
+
u as useImageUpload
|
|
12
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const IMAGE_UPLOAD_SHORTCUT_KEY = "mod+shift+i";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the image upload functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseImageUploadConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button should hide when insertion is not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called after a successful image insertion.
|
|
18
|
+
*/
|
|
19
|
+
onInserted?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if image can be inserted in the current editor state
|
|
23
|
+
*/
|
|
24
|
+
export declare function canInsertImage(editor: Editor | null): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if image is currently active
|
|
27
|
+
*/
|
|
28
|
+
export declare function isImageActive(editor: Editor | null): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Inserts an image in the editor
|
|
31
|
+
*/
|
|
32
|
+
export declare function insertImage(editor: Editor | null): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Determines if the image button should be shown
|
|
35
|
+
*/
|
|
36
|
+
export declare function shouldShowButton(props: {
|
|
37
|
+
editor: Editor | null;
|
|
38
|
+
hideWhenUnavailable: boolean;
|
|
39
|
+
}): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook that provides image functionality for Tiptap editor
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // Simple usage - no params needed
|
|
46
|
+
* function MySimpleImageButton() {
|
|
47
|
+
* const { isVisible, handleImage } = useImage()
|
|
48
|
+
*
|
|
49
|
+
* if (!isVisible) return null
|
|
50
|
+
*
|
|
51
|
+
* return <button onClick={handleImage}>Add Image</button>
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Advanced usage with configuration
|
|
55
|
+
* function MyAdvancedImageButton() {
|
|
56
|
+
* const { isVisible, handleImage, label, isActive } = useImage({
|
|
57
|
+
* editor: myEditor,
|
|
58
|
+
* hideWhenUnavailable: true,
|
|
59
|
+
* onInserted: () => console.log('Image inserted!')
|
|
60
|
+
* })
|
|
61
|
+
*
|
|
62
|
+
* if (!isVisible) return null
|
|
63
|
+
*
|
|
64
|
+
* return (
|
|
65
|
+
* <MyButton
|
|
66
|
+
* onClick={handleImage}
|
|
67
|
+
* aria-pressed={isActive}
|
|
68
|
+
* aria-label={label}
|
|
69
|
+
* >
|
|
70
|
+
* Add Image
|
|
71
|
+
* </MyButton>
|
|
72
|
+
* )
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function useImageUpload(config?: UseImageUploadConfig): {
|
|
77
|
+
isVisible: boolean;
|
|
78
|
+
isActive: boolean;
|
|
79
|
+
handleImage: () => boolean;
|
|
80
|
+
canInsert: boolean;
|
|
81
|
+
label: string;
|
|
82
|
+
shortcutKeys: string;
|
|
83
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
84
|
+
};
|