@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,74 @@
|
|
|
1
|
+
import { jsx as t, jsxs as S, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y, useCallback as C } from "react";
|
|
3
|
+
import { parseShortcutKeys as I } from "../../../lib/tiptap-utils.js";
|
|
4
|
+
import { useTiptapEditor as K } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { useList as N, LIST_SHORTCUT_KEYS as j } from "./use-list.js";
|
|
6
|
+
import { Button as k } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
import { Badge as v } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
8
|
+
function E({
|
|
9
|
+
type: o,
|
|
10
|
+
shortcutKeys: e = j[o]
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ t(v, { children: I({ shortcutKeys: e }) });
|
|
13
|
+
}
|
|
14
|
+
const R = y(
|
|
15
|
+
({
|
|
16
|
+
editor: o,
|
|
17
|
+
type: e,
|
|
18
|
+
text: r,
|
|
19
|
+
hideWhenUnavailable: c = !1,
|
|
20
|
+
onToggled: u,
|
|
21
|
+
showShortcut: p = !1,
|
|
22
|
+
onClick: a,
|
|
23
|
+
children: m,
|
|
24
|
+
...f
|
|
25
|
+
}, b) => {
|
|
26
|
+
const { editor: h } = K(o), {
|
|
27
|
+
isVisible: g,
|
|
28
|
+
canToggle: i,
|
|
29
|
+
isActive: s,
|
|
30
|
+
handleToggle: n,
|
|
31
|
+
label: l,
|
|
32
|
+
shortcutKeys: T,
|
|
33
|
+
Icon: B
|
|
34
|
+
} = N({
|
|
35
|
+
editor: h,
|
|
36
|
+
type: e,
|
|
37
|
+
hideWhenUnavailable: c,
|
|
38
|
+
onToggled: u
|
|
39
|
+
}), L = C(
|
|
40
|
+
(d) => {
|
|
41
|
+
a?.(d), !d.defaultPrevented && n();
|
|
42
|
+
},
|
|
43
|
+
[n, a]
|
|
44
|
+
);
|
|
45
|
+
return g ? /* @__PURE__ */ t(
|
|
46
|
+
k,
|
|
47
|
+
{
|
|
48
|
+
type: "button",
|
|
49
|
+
"data-style": "ghost",
|
|
50
|
+
"data-active-state": s ? "on" : "off",
|
|
51
|
+
role: "button",
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
disabled: !i,
|
|
54
|
+
"data-disabled": !i,
|
|
55
|
+
"aria-label": l,
|
|
56
|
+
"aria-pressed": s,
|
|
57
|
+
tooltip: l,
|
|
58
|
+
onClick: L,
|
|
59
|
+
...f,
|
|
60
|
+
ref: b,
|
|
61
|
+
children: m ?? /* @__PURE__ */ S(x, { children: [
|
|
62
|
+
/* @__PURE__ */ t(B, { className: "tiptap-button-icon" }),
|
|
63
|
+
r && /* @__PURE__ */ t("span", { className: "tiptap-button-text", children: r }),
|
|
64
|
+
p && /* @__PURE__ */ t(E, { type: e, shortcutKeys: T })
|
|
65
|
+
] })
|
|
66
|
+
}
|
|
67
|
+
) : null;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
R.displayName = "ListButton";
|
|
71
|
+
export {
|
|
72
|
+
R as ListButton,
|
|
73
|
+
E as ListShortcutBadge
|
|
74
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export type ListType = "bulletList" | "orderedList" | "taskList";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the list functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseListConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* The type of list to toggle.
|
|
13
|
+
*/
|
|
14
|
+
type: ListType;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the button should hide when list is not available.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
hideWhenUnavailable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback function called after a successful toggle.
|
|
22
|
+
*/
|
|
23
|
+
onToggled?: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const listIcons: {
|
|
26
|
+
bulletList: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
27
|
+
orderedList: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
28
|
+
taskList: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
29
|
+
};
|
|
30
|
+
export declare const listLabels: Record<ListType, string>;
|
|
31
|
+
export declare const LIST_SHORTCUT_KEYS: Record<ListType, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a list can be toggled in the current editor state
|
|
34
|
+
*/
|
|
35
|
+
export declare function canToggleList(editor: Editor | null, type: ListType, turnInto?: boolean): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if list is currently active
|
|
38
|
+
*/
|
|
39
|
+
export declare function isListActive(editor: Editor | null, type: ListType): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Toggles list in the editor
|
|
42
|
+
*/
|
|
43
|
+
export declare function toggleList(editor: Editor | null, type: ListType): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Determines if the list button should be shown
|
|
46
|
+
*/
|
|
47
|
+
export declare function shouldShowButton(props: {
|
|
48
|
+
editor: Editor | null;
|
|
49
|
+
type: ListType;
|
|
50
|
+
hideWhenUnavailable: boolean;
|
|
51
|
+
}): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom hook that provides list functionality for Tiptap editor
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* // Simple usage
|
|
58
|
+
* function MySimpleListButton() {
|
|
59
|
+
* const { isVisible, handleToggle, isActive } = useList({ type: "bulletList" })
|
|
60
|
+
*
|
|
61
|
+
* if (!isVisible) return null
|
|
62
|
+
*
|
|
63
|
+
* return <button onClick={handleToggle}>Bullet List</button>
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Advanced usage with configuration
|
|
67
|
+
* function MyAdvancedListButton() {
|
|
68
|
+
* const { isVisible, handleToggle, label, isActive } = useList({
|
|
69
|
+
* type: "orderedList",
|
|
70
|
+
* editor: myEditor,
|
|
71
|
+
* hideWhenUnavailable: true,
|
|
72
|
+
* onToggled: () => console.log('List toggled!')
|
|
73
|
+
* })
|
|
74
|
+
*
|
|
75
|
+
* if (!isVisible) return null
|
|
76
|
+
*
|
|
77
|
+
* return (
|
|
78
|
+
* <MyButton
|
|
79
|
+
* onClick={handleToggle}
|
|
80
|
+
* aria-label={label}
|
|
81
|
+
* aria-pressed={isActive}
|
|
82
|
+
* >
|
|
83
|
+
* Toggle List
|
|
84
|
+
* </MyButton>
|
|
85
|
+
* )
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function useList(config: UseListConfig): {
|
|
90
|
+
isVisible: boolean;
|
|
91
|
+
isActive: boolean;
|
|
92
|
+
handleToggle: () => boolean;
|
|
93
|
+
canToggle: boolean;
|
|
94
|
+
label: string;
|
|
95
|
+
shortcutKeys: string;
|
|
96
|
+
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>;
|
|
97
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { useState as b, useEffect as p, useCallback as k } from "react";
|
|
2
|
+
import "@tiptap/react";
|
|
3
|
+
import { TextSelection as L, NodeSelection as g } from "prosemirror-state";
|
|
4
|
+
import { useTiptapEditor as v } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { ListIcon as T } from "../../tiptap-icons/list-icon.js";
|
|
6
|
+
import { ListOrderedIcon as S } from "../../tiptap-icons/list-ordered-icon.js";
|
|
7
|
+
import { ListTodoIcon as I } from "../../tiptap-icons/list-todo-icon.js";
|
|
8
|
+
import { isNodeInSchema as h, isNodeTypeSelected as C, selectionWithinConvertibleTypes as E, findNodePosition as N, isValidPosition as w } from "../../../lib/tiptap-utils.js";
|
|
9
|
+
const A = {
|
|
10
|
+
bulletList: T,
|
|
11
|
+
orderedList: S,
|
|
12
|
+
taskList: I
|
|
13
|
+
}, B = {
|
|
14
|
+
bulletList: "Bullet List",
|
|
15
|
+
orderedList: "Ordered List",
|
|
16
|
+
taskList: "Task List"
|
|
17
|
+
}, O = {
|
|
18
|
+
bulletList: "mod+shift+8",
|
|
19
|
+
orderedList: "mod+shift+7",
|
|
20
|
+
taskList: "mod+shift+9"
|
|
21
|
+
};
|
|
22
|
+
function d(t, i, e = !0) {
|
|
23
|
+
if (!t || !t.isEditable || !h(i, t) || C(t, ["image"]))
|
|
24
|
+
return !1;
|
|
25
|
+
if (!e)
|
|
26
|
+
switch (i) {
|
|
27
|
+
case "bulletList":
|
|
28
|
+
return t.can().toggleBulletList();
|
|
29
|
+
case "orderedList":
|
|
30
|
+
return t.can().toggleOrderedList();
|
|
31
|
+
case "taskList":
|
|
32
|
+
return t.can().toggleList("taskList", "taskItem");
|
|
33
|
+
default:
|
|
34
|
+
return !1;
|
|
35
|
+
}
|
|
36
|
+
if (!E(t, [
|
|
37
|
+
"paragraph",
|
|
38
|
+
"heading",
|
|
39
|
+
"bulletList",
|
|
40
|
+
"orderedList",
|
|
41
|
+
"taskList",
|
|
42
|
+
"blockquote",
|
|
43
|
+
"codeBlock"
|
|
44
|
+
]))
|
|
45
|
+
return !1;
|
|
46
|
+
switch (i) {
|
|
47
|
+
case "bulletList":
|
|
48
|
+
return t.can().toggleBulletList() || t.can().clearNodes();
|
|
49
|
+
case "orderedList":
|
|
50
|
+
return t.can().toggleOrderedList() || t.can().clearNodes();
|
|
51
|
+
case "taskList":
|
|
52
|
+
return t.can().toggleList("taskList", "taskItem") || t.can().clearNodes();
|
|
53
|
+
default:
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function U(t, i) {
|
|
58
|
+
if (!t || !t.isEditable) return !1;
|
|
59
|
+
switch (i) {
|
|
60
|
+
case "bulletList":
|
|
61
|
+
return t.isActive("bulletList");
|
|
62
|
+
case "orderedList":
|
|
63
|
+
return t.isActive("orderedList");
|
|
64
|
+
case "taskList":
|
|
65
|
+
return t.isActive("taskList");
|
|
66
|
+
default:
|
|
67
|
+
return !1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function x(t, i) {
|
|
71
|
+
if (!t || !t.isEditable || !d(t, i)) return !1;
|
|
72
|
+
try {
|
|
73
|
+
const e = t.view;
|
|
74
|
+
let l = e.state, a = l.tr;
|
|
75
|
+
if (l.selection.empty || l.selection instanceof L) {
|
|
76
|
+
const n = N({
|
|
77
|
+
editor: t,
|
|
78
|
+
node: l.selection.$anchor.node(1)
|
|
79
|
+
})?.pos;
|
|
80
|
+
if (!w(n)) return !1;
|
|
81
|
+
a = a.setSelection(g.create(l.doc, n)), e.dispatch(a), l = e.state;
|
|
82
|
+
}
|
|
83
|
+
const s = l.selection;
|
|
84
|
+
let o = t.chain().focus();
|
|
85
|
+
if (s instanceof g) {
|
|
86
|
+
const n = s.node.firstChild?.firstChild, c = s.node.lastChild?.lastChild, u = n ? s.from + n.nodeSize : s.from + 1, f = c ? s.to - c.nodeSize : s.to - 1, r = l.doc.resolve(u), m = l.doc.resolve(f);
|
|
87
|
+
o = o.setTextSelection(L.between(r, m)).clearNodes();
|
|
88
|
+
}
|
|
89
|
+
if (t.isActive(i))
|
|
90
|
+
o.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();
|
|
91
|
+
else {
|
|
92
|
+
const c = {
|
|
93
|
+
bulletList: () => o.toggleBulletList(),
|
|
94
|
+
orderedList: () => o.toggleOrderedList(),
|
|
95
|
+
taskList: () => o.toggleList("taskList", "taskItem")
|
|
96
|
+
}[i];
|
|
97
|
+
if (!c) return !1;
|
|
98
|
+
c().run();
|
|
99
|
+
}
|
|
100
|
+
return t.chain().focus().selectTextblockEnd().run(), !0;
|
|
101
|
+
} catch {
|
|
102
|
+
return !1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function y(t) {
|
|
106
|
+
const { editor: i, type: e, hideWhenUnavailable: l } = t;
|
|
107
|
+
return !i || !i.isEditable || !h(e, i) ? !1 : l && !i.isActive("code") ? d(i, e) : !0;
|
|
108
|
+
}
|
|
109
|
+
function F(t) {
|
|
110
|
+
const {
|
|
111
|
+
editor: i,
|
|
112
|
+
type: e,
|
|
113
|
+
hideWhenUnavailable: l = !1,
|
|
114
|
+
onToggled: a
|
|
115
|
+
} = t, { editor: s } = v(i), [o, n] = b(!0), c = d(s, e), u = U(s, e);
|
|
116
|
+
p(() => {
|
|
117
|
+
if (!s) return;
|
|
118
|
+
const r = () => {
|
|
119
|
+
n(y({ editor: s, type: e, hideWhenUnavailable: l }));
|
|
120
|
+
};
|
|
121
|
+
return r(), s.on("selectionUpdate", r), () => {
|
|
122
|
+
s.off("selectionUpdate", r);
|
|
123
|
+
};
|
|
124
|
+
}, [s, e, l]);
|
|
125
|
+
const f = k(() => {
|
|
126
|
+
if (!s) return !1;
|
|
127
|
+
const r = x(s, e);
|
|
128
|
+
return r && a?.(), r;
|
|
129
|
+
}, [s, e, a]);
|
|
130
|
+
return {
|
|
131
|
+
isVisible: o,
|
|
132
|
+
isActive: u,
|
|
133
|
+
handleToggle: f,
|
|
134
|
+
canToggle: c,
|
|
135
|
+
label: B[e],
|
|
136
|
+
shortcutKeys: O[e],
|
|
137
|
+
Icon: A[e]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
O as LIST_SHORTCUT_KEYS,
|
|
142
|
+
d as canToggleList,
|
|
143
|
+
U as isListActive,
|
|
144
|
+
A as listIcons,
|
|
145
|
+
B as listLabels,
|
|
146
|
+
y as shouldShowButton,
|
|
147
|
+
x as toggleList,
|
|
148
|
+
F as useList
|
|
149
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './list-dropdown-menu';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { ListType } from '../list-button';
|
|
3
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
4
|
+
export interface ListDropdownMenuProps extends Omit<ButtonProps, "type"> {
|
|
5
|
+
/**
|
|
6
|
+
* The Tiptap editor instance.
|
|
7
|
+
*/
|
|
8
|
+
editor?: Editor;
|
|
9
|
+
/**
|
|
10
|
+
* The list types to display in the dropdown.
|
|
11
|
+
*/
|
|
12
|
+
types?: ListType[];
|
|
13
|
+
/**
|
|
14
|
+
* Whether the dropdown should be hidden when no list types are available
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
hideWhenUnavailable?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Callback for when the dropdown opens or closes
|
|
20
|
+
*/
|
|
21
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to render the dropdown menu in a portal
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
portal?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function ListDropdownMenu({ editor: providedEditor, types, hideWhenUnavailable, onOpenChange, portal, ...props }: ListDropdownMenuProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
export default ListDropdownMenu;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useCallback as C } from "react";
|
|
3
|
+
import "@tiptap/react";
|
|
4
|
+
import { useTiptapEditor as g } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { ChevronDownIcon as D } from "../../tiptap-icons/chevron-down-icon.js";
|
|
6
|
+
import { useListDropdownMenu as y } from "./use-list-dropdown-menu.js";
|
|
7
|
+
import { ListButton as M } from "../list-button/list-button.js";
|
|
8
|
+
import { DropdownMenu as x, DropdownMenuTrigger as I, DropdownMenuContent as B, DropdownMenuItem as O } from "../../tiptap-ui-primitive/dropdown-menu/dropdown-menu.js";
|
|
9
|
+
import { Button as T, ButtonGroup as v } from "../../tiptap-ui-primitive/button/button.js";
|
|
10
|
+
import { Card as j, CardBody as k } from "../../tiptap-ui-primitive/card/card.js";
|
|
11
|
+
function J({
|
|
12
|
+
editor: s,
|
|
13
|
+
types: a = ["bulletList", "orderedList", "taskList"],
|
|
14
|
+
hideWhenUnavailable: l = !1,
|
|
15
|
+
onOpenChange: r,
|
|
16
|
+
portal: d = !1,
|
|
17
|
+
...p
|
|
18
|
+
}) {
|
|
19
|
+
const { editor: o } = g(s), [u, m] = L(!1), { filteredLists: c, canToggle: i, isActive: f, isVisible: h, Icon: b } = y({
|
|
20
|
+
editor: o,
|
|
21
|
+
types: a,
|
|
22
|
+
hideWhenUnavailable: l
|
|
23
|
+
}), w = C(
|
|
24
|
+
(e) => {
|
|
25
|
+
m(e), r?.(e);
|
|
26
|
+
},
|
|
27
|
+
[r]
|
|
28
|
+
);
|
|
29
|
+
return !h || !o || !o.isEditable ? null : /* @__PURE__ */ n(x, { open: u, onOpenChange: w, children: [
|
|
30
|
+
/* @__PURE__ */ t(I, { asChild: !0, children: /* @__PURE__ */ n(
|
|
31
|
+
T,
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
"data-style": "ghost",
|
|
35
|
+
"data-active-state": f ? "on" : "off",
|
|
36
|
+
role: "button",
|
|
37
|
+
tabIndex: -1,
|
|
38
|
+
disabled: !i,
|
|
39
|
+
"data-disabled": !i,
|
|
40
|
+
"aria-label": "List options",
|
|
41
|
+
tooltip: "List",
|
|
42
|
+
...p,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ t(b, { className: "tiptap-button-icon" }),
|
|
45
|
+
/* @__PURE__ */ t(D, { className: "tiptap-button-dropdown-small" })
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
) }),
|
|
49
|
+
/* @__PURE__ */ t(B, { align: "start", portal: d, children: /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(k, { children: /* @__PURE__ */ t(v, { children: c.map((e) => /* @__PURE__ */ t(O, { asChild: !0, children: /* @__PURE__ */ t(
|
|
50
|
+
M,
|
|
51
|
+
{
|
|
52
|
+
editor: o,
|
|
53
|
+
type: e.type,
|
|
54
|
+
text: e.label,
|
|
55
|
+
showTooltip: !1
|
|
56
|
+
}
|
|
57
|
+
) }, e.type)) }) }) }) })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
J as ListDropdownMenu,
|
|
62
|
+
J as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { ListType } from '../list-button';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the list dropdown menu functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseListDropdownMenuConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* The list types to display in the dropdown.
|
|
13
|
+
* @default ["bulletList", "orderedList", "taskList"]
|
|
14
|
+
*/
|
|
15
|
+
types?: ListType[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether the dropdown should be hidden when no list types are available
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hideWhenUnavailable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ListOption {
|
|
23
|
+
label: string;
|
|
24
|
+
type: ListType;
|
|
25
|
+
icon: React.ElementType;
|
|
26
|
+
}
|
|
27
|
+
export declare const listOptions: ListOption[];
|
|
28
|
+
export declare function canToggleAnyList(editor: Editor | null, listTypes: ListType[]): boolean;
|
|
29
|
+
export declare function isAnyListActive(editor: Editor | null, listTypes: ListType[]): boolean;
|
|
30
|
+
export declare function getFilteredListOptions(availableTypes: ListType[]): typeof listOptions;
|
|
31
|
+
export declare function shouldShowListDropdown(params: {
|
|
32
|
+
editor: Editor | null;
|
|
33
|
+
listTypes: ListType[];
|
|
34
|
+
hideWhenUnavailable: boolean;
|
|
35
|
+
listInSchema: boolean;
|
|
36
|
+
canToggleAny: boolean;
|
|
37
|
+
}): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the currently active list type from the available types
|
|
40
|
+
*/
|
|
41
|
+
export declare function getActiveListType(editor: Editor | null, availableTypes: ListType[]): ListType | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Custom hook that provides list dropdown menu functionality for Tiptap editor
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* // Simple usage
|
|
48
|
+
* function MyListDropdown() {
|
|
49
|
+
* const {
|
|
50
|
+
* isVisible,
|
|
51
|
+
* activeType,
|
|
52
|
+
* isAnyActive,
|
|
53
|
+
* canToggleAny,
|
|
54
|
+
* filteredLists,
|
|
55
|
+
* } = useListDropdownMenu()
|
|
56
|
+
*
|
|
57
|
+
* if (!isVisible) return null
|
|
58
|
+
*
|
|
59
|
+
* return (
|
|
60
|
+
* <DropdownMenu>
|
|
61
|
+
* // dropdown content
|
|
62
|
+
* </DropdownMenu>
|
|
63
|
+
* )
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Advanced usage with configuration
|
|
67
|
+
* function MyAdvancedListDropdown() {
|
|
68
|
+
* const {
|
|
69
|
+
* isVisible,
|
|
70
|
+
* activeType,
|
|
71
|
+
* } = useListDropdownMenu({
|
|
72
|
+
* editor: myEditor,
|
|
73
|
+
* types: ["bulletList", "orderedList"],
|
|
74
|
+
* hideWhenUnavailable: true,
|
|
75
|
+
* })
|
|
76
|
+
*
|
|
77
|
+
* // component implementation
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function useListDropdownMenu(config?: UseListDropdownMenuConfig): {
|
|
82
|
+
isVisible: boolean;
|
|
83
|
+
activeType: ListType | undefined;
|
|
84
|
+
isActive: boolean;
|
|
85
|
+
canToggle: boolean;
|
|
86
|
+
types: ListType[];
|
|
87
|
+
filteredLists: ListOption[];
|
|
88
|
+
label: string;
|
|
89
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
90
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useState as y, useMemo as b, useEffect as g } from "react";
|
|
2
|
+
import { useTiptapEditor as v } from "../../../hooks/use-tiptap-editor.js";
|
|
3
|
+
import { ListIcon as u } from "../../tiptap-icons/list-icon.js";
|
|
4
|
+
import { ListOrderedIcon as A } from "../../tiptap-icons/list-ordered-icon.js";
|
|
5
|
+
import { ListTodoIcon as h } from "../../tiptap-icons/list-todo-icon.js";
|
|
6
|
+
import { isNodeInSchema as T } from "../../../lib/tiptap-utils.js";
|
|
7
|
+
import { canToggleList as I, isListActive as d, listIcons as E } from "../list-button/use-list.js";
|
|
8
|
+
const S = [
|
|
9
|
+
{
|
|
10
|
+
label: "Bullet List",
|
|
11
|
+
type: "bulletList",
|
|
12
|
+
icon: u
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Ordered List",
|
|
16
|
+
type: "orderedList",
|
|
17
|
+
icon: A
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "Task List",
|
|
21
|
+
type: "taskList",
|
|
22
|
+
icon: h
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
function U(t, i) {
|
|
26
|
+
return !t || !t.isEditable ? !1 : i.some((e) => I(t, e));
|
|
27
|
+
}
|
|
28
|
+
function O(t, i) {
|
|
29
|
+
return !t || !t.isEditable ? !1 : i.some((e) => d(t, e));
|
|
30
|
+
}
|
|
31
|
+
function k(t) {
|
|
32
|
+
return S.filter(
|
|
33
|
+
(i) => !i.type || t.includes(i.type)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function w(t) {
|
|
37
|
+
const { editor: i, hideWhenUnavailable: e, listInSchema: o, canToggleAny: s } = t;
|
|
38
|
+
return !o || !i ? !1 : e && !i.isActive("code") ? s : !0;
|
|
39
|
+
}
|
|
40
|
+
function D(t, i) {
|
|
41
|
+
if (!(!t || !t.isEditable))
|
|
42
|
+
return i.find((e) => d(t, e));
|
|
43
|
+
}
|
|
44
|
+
function j(t) {
|
|
45
|
+
const {
|
|
46
|
+
editor: i,
|
|
47
|
+
types: e = ["bulletList", "orderedList", "taskList"],
|
|
48
|
+
hideWhenUnavailable: o = !1
|
|
49
|
+
} = t || {}, { editor: s } = v(i), [p, L] = y(!1), c = e.some((n) => T(n, s)), l = b(() => k(e), [e]), r = U(s, e), m = O(s, e), a = D(s, e), f = l.find((n) => n.type === a);
|
|
50
|
+
return g(() => {
|
|
51
|
+
if (!s) return;
|
|
52
|
+
const n = () => {
|
|
53
|
+
L(
|
|
54
|
+
w({
|
|
55
|
+
editor: s,
|
|
56
|
+
hideWhenUnavailable: o,
|
|
57
|
+
listInSchema: c,
|
|
58
|
+
canToggleAny: r
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
return n(), s.on("selectionUpdate", n), () => {
|
|
63
|
+
s.off("selectionUpdate", n);
|
|
64
|
+
};
|
|
65
|
+
}, [r, s, o, c, e]), {
|
|
66
|
+
isVisible: p,
|
|
67
|
+
activeType: a,
|
|
68
|
+
isActive: m,
|
|
69
|
+
canToggle: r,
|
|
70
|
+
types: e,
|
|
71
|
+
filteredLists: l,
|
|
72
|
+
label: "List",
|
|
73
|
+
Icon: f ? E[f.type] : u
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
U as canToggleAnyList,
|
|
78
|
+
D as getActiveListType,
|
|
79
|
+
k as getFilteredListOptions,
|
|
80
|
+
O as isAnyListActive,
|
|
81
|
+
S as listOptions,
|
|
82
|
+
w as shouldShowListDropdown,
|
|
83
|
+
j as useListDropdownMenu
|
|
84
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MarkButton as t, MarkShortcutBadge as a } from "./mark-button.js";
|
|
2
|
+
import { MARK_SHORTCUT_KEYS as k, canToggleMark as M, getFormattedMarkName as g, isMarkActive as m, markIcons as u, shouldShowButton as c, toggleMark as n, useMark as s } from "./use-mark.js";
|
|
3
|
+
export {
|
|
4
|
+
k as MARK_SHORTCUT_KEYS,
|
|
5
|
+
t as MarkButton,
|
|
6
|
+
a as MarkShortcutBadge,
|
|
7
|
+
M as canToggleMark,
|
|
8
|
+
g as getFormattedMarkName,
|
|
9
|
+
m as isMarkActive,
|
|
10
|
+
u as markIcons,
|
|
11
|
+
c as shouldShowButton,
|
|
12
|
+
n as toggleMark,
|
|
13
|
+
s as useMark
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Mark, UseMarkConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface MarkButtonProps extends Omit<ButtonProps, "type">, UseMarkConfig {
|
|
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 MarkShortcutBadge({ type, shortcutKeys, }: {
|
|
15
|
+
type: Mark;
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for toggling marks in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* For custom button implementations, use the `useMark` hook instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MarkButton: import('react').ForwardRefExoticComponent<MarkButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|