@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,89 @@
|
|
|
1
|
+
import { jsx as o, jsxs as S, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useCallback as I, useMemo as K } from "react";
|
|
3
|
+
import { parseShortcutKeys as N } from "../../../lib/tiptap-utils.js";
|
|
4
|
+
import { useTiptapEditor as O } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { useColorHighlight as R, COLOR_HIGHLIGHT_SHORTCUT_KEY as _ } from "./use-color-highlight.js";
|
|
6
|
+
import { Button as j } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
import { Badge as v } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
8
|
+
import '../../../assets/color-highlight-button.css';function E({
|
|
9
|
+
shortcutKeys: e = _
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ o(v, { children: N({ shortcutKeys: e }) });
|
|
12
|
+
}
|
|
13
|
+
const G = x(
|
|
14
|
+
({
|
|
15
|
+
editor: e,
|
|
16
|
+
highlightColor: t,
|
|
17
|
+
text: r,
|
|
18
|
+
hideWhenUnavailable: h = !1,
|
|
19
|
+
mode: u = "mark",
|
|
20
|
+
onApplied: p,
|
|
21
|
+
showShortcut: m = !1,
|
|
22
|
+
onClick: i,
|
|
23
|
+
children: g,
|
|
24
|
+
style: a,
|
|
25
|
+
...f
|
|
26
|
+
}, b) => {
|
|
27
|
+
const { editor: H } = O(e), {
|
|
28
|
+
isVisible: y,
|
|
29
|
+
canColorHighlight: l,
|
|
30
|
+
isActive: s,
|
|
31
|
+
handleColorHighlight: n,
|
|
32
|
+
label: d,
|
|
33
|
+
shortcutKeys: C
|
|
34
|
+
} = R({
|
|
35
|
+
editor: H,
|
|
36
|
+
highlightColor: t,
|
|
37
|
+
label: r || `Toggle highlight (${t})`,
|
|
38
|
+
hideWhenUnavailable: h,
|
|
39
|
+
mode: u,
|
|
40
|
+
onApplied: p
|
|
41
|
+
}), B = I(
|
|
42
|
+
(c) => {
|
|
43
|
+
i?.(c), !c.defaultPrevented && n();
|
|
44
|
+
},
|
|
45
|
+
[n, i]
|
|
46
|
+
), T = K(
|
|
47
|
+
() => ({
|
|
48
|
+
...a,
|
|
49
|
+
"--highlight-color": t
|
|
50
|
+
}),
|
|
51
|
+
[t, a]
|
|
52
|
+
);
|
|
53
|
+
return y ? /* @__PURE__ */ o(
|
|
54
|
+
j,
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
"data-style": "ghost",
|
|
58
|
+
"data-active-state": s ? "on" : "off",
|
|
59
|
+
role: "button",
|
|
60
|
+
tabIndex: -1,
|
|
61
|
+
disabled: !l,
|
|
62
|
+
"data-disabled": !l,
|
|
63
|
+
"aria-label": d,
|
|
64
|
+
"aria-pressed": s,
|
|
65
|
+
tooltip: d,
|
|
66
|
+
onClick: B,
|
|
67
|
+
style: T,
|
|
68
|
+
...f,
|
|
69
|
+
ref: b,
|
|
70
|
+
children: g ?? /* @__PURE__ */ S(k, { children: [
|
|
71
|
+
/* @__PURE__ */ o(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
className: "tiptap-button-highlight",
|
|
75
|
+
style: { "--highlight-color": t }
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
r && /* @__PURE__ */ o("span", { className: "tiptap-button-text", children: r }),
|
|
79
|
+
m && /* @__PURE__ */ o(E, { shortcutKeys: C })
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
) : null;
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
G.displayName = "ColorHighlightButton";
|
|
86
|
+
export {
|
|
87
|
+
G as ColorHighlightButton,
|
|
88
|
+
E as ColorHighlightShortcutBadge
|
|
89
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColorHighlightButton as i, ColorHighlightShortcutBadge as t } from "./color-highlight-button.js";
|
|
2
|
+
import { COLOR_HIGHLIGHT_SHORTCUT_KEY as l, HIGHLIGHT_COLORS as H, canColorHighlight as r, isColorHighlightActive as C, pickHighlightColorsByValue as e, removeHighlight as u, shouldShowButton as O, useColorHighlight as c } from "./use-color-highlight.js";
|
|
3
|
+
export {
|
|
4
|
+
l as COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
5
|
+
i as ColorHighlightButton,
|
|
6
|
+
t as ColorHighlightShortcutBadge,
|
|
7
|
+
H as HIGHLIGHT_COLORS,
|
|
8
|
+
r as canColorHighlight,
|
|
9
|
+
C as isColorHighlightActive,
|
|
10
|
+
e as pickHighlightColorsByValue,
|
|
11
|
+
u as removeHighlight,
|
|
12
|
+
O as shouldShowButton,
|
|
13
|
+
c as useColorHighlight
|
|
14
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
3
|
+
export declare const HIGHLIGHT_COLORS: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
border: string;
|
|
7
|
+
}[];
|
|
8
|
+
export type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];
|
|
9
|
+
export type HighlightMode = "mark" | "node";
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for the color highlight functionality
|
|
12
|
+
*/
|
|
13
|
+
export interface UseColorHighlightConfig {
|
|
14
|
+
/**
|
|
15
|
+
* The Tiptap editor instance.
|
|
16
|
+
*/
|
|
17
|
+
editor?: Editor | null;
|
|
18
|
+
/**
|
|
19
|
+
* The color to apply when toggling the highlight.
|
|
20
|
+
*/
|
|
21
|
+
highlightColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional label to display alongside the icon.
|
|
24
|
+
*/
|
|
25
|
+
label?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the button should hide when the mark is not available.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
hideWhenUnavailable?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The highlighting mode to use.
|
|
33
|
+
* - "mark": Uses the highlight mark extension (default)
|
|
34
|
+
* - "node": Uses the node background extension
|
|
35
|
+
* @default "mark"
|
|
36
|
+
*/
|
|
37
|
+
mode?: HighlightMode;
|
|
38
|
+
/**
|
|
39
|
+
* Called when the highlight is applied.
|
|
40
|
+
*/
|
|
41
|
+
onApplied?: ({ color, label, mode, }: {
|
|
42
|
+
color: string;
|
|
43
|
+
label: string;
|
|
44
|
+
mode: HighlightMode;
|
|
45
|
+
}) => void;
|
|
46
|
+
}
|
|
47
|
+
export declare function pickHighlightColorsByValue(values: string[]): {
|
|
48
|
+
label: string;
|
|
49
|
+
value: string;
|
|
50
|
+
border: string;
|
|
51
|
+
}[];
|
|
52
|
+
/**
|
|
53
|
+
* Checks if highlight can be applied based on the mode and current editor state
|
|
54
|
+
*/
|
|
55
|
+
export declare function canColorHighlight(editor: Editor | null, mode?: HighlightMode): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if highlight is currently active
|
|
58
|
+
*/
|
|
59
|
+
export declare function isColorHighlightActive(editor: Editor | null, highlightColor?: string, mode?: HighlightMode): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Removes highlight based on the mode
|
|
62
|
+
*/
|
|
63
|
+
export declare function removeHighlight(editor: Editor | null, mode?: HighlightMode): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Determines if the highlight button should be shown
|
|
66
|
+
*/
|
|
67
|
+
export declare function shouldShowButton(props: {
|
|
68
|
+
editor: Editor | null;
|
|
69
|
+
hideWhenUnavailable: boolean;
|
|
70
|
+
mode: HighlightMode;
|
|
71
|
+
}): boolean;
|
|
72
|
+
export declare function useColorHighlight(config: UseColorHighlightConfig): {
|
|
73
|
+
isVisible: boolean;
|
|
74
|
+
isActive: boolean;
|
|
75
|
+
handleColorHighlight: () => any;
|
|
76
|
+
handleRemoveHighlight: () => boolean;
|
|
77
|
+
canColorHighlight: boolean;
|
|
78
|
+
label: string;
|
|
79
|
+
shortcutKeys: string;
|
|
80
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
81
|
+
mode: HighlightMode;
|
|
82
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import "@tiptap/react";
|
|
2
|
+
import { useState as C, useEffect as y, useCallback as f } from "react";
|
|
3
|
+
import { f as M } from "../../../index-Bqw9S4qP.js";
|
|
4
|
+
import { useIsMobile as E } from "../../../hooks/use-mobile.js";
|
|
5
|
+
import { useTiptapEditor as w } from "../../../hooks/use-tiptap-editor.js";
|
|
6
|
+
import { isMarkInSchema as d, isNodeTypeSelected as B, isExtensionAvailable as v } from "../../../lib/tiptap-utils.js";
|
|
7
|
+
import { HighlighterIcon as I } from "../../tiptap-icons/highlighter-icon.js";
|
|
8
|
+
const b = "mod+shift+h", S = [
|
|
9
|
+
{
|
|
10
|
+
label: "Default background",
|
|
11
|
+
value: "var(--tt-bg-color)",
|
|
12
|
+
border: "var(--tt-bg-color-contrast)"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Gray background",
|
|
16
|
+
value: "var(--tt-color-highlight-gray)",
|
|
17
|
+
border: "var(--tt-color-highlight-gray-contrast)"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "Brown background",
|
|
21
|
+
value: "var(--tt-color-highlight-brown)",
|
|
22
|
+
border: "var(--tt-color-highlight-brown-contrast)"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Orange background",
|
|
26
|
+
value: "var(--tt-color-highlight-orange)",
|
|
27
|
+
border: "var(--tt-color-highlight-orange-contrast)"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: "Yellow background",
|
|
31
|
+
value: "var(--tt-color-highlight-yellow)",
|
|
32
|
+
border: "var(--tt-color-highlight-yellow-contrast)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Green background",
|
|
36
|
+
value: "var(--tt-color-highlight-green)",
|
|
37
|
+
border: "var(--tt-color-highlight-green-contrast)"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: "Blue background",
|
|
41
|
+
value: "var(--tt-color-highlight-blue)",
|
|
42
|
+
border: "var(--tt-color-highlight-blue-contrast)"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "Purple background",
|
|
46
|
+
value: "var(--tt-color-highlight-purple)",
|
|
47
|
+
border: "var(--tt-color-highlight-purple-contrast)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "Pink background",
|
|
51
|
+
value: "var(--tt-color-highlight-pink)",
|
|
52
|
+
border: "var(--tt-color-highlight-pink-contrast)"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "Red background",
|
|
56
|
+
value: "var(--tt-color-highlight-red)",
|
|
57
|
+
border: "var(--tt-color-highlight-red-contrast)"
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
function x(t) {
|
|
61
|
+
const r = new Map(
|
|
62
|
+
S.map((l) => [l.value, l])
|
|
63
|
+
);
|
|
64
|
+
return t.map((l) => r.get(l)).filter((l) => !!l);
|
|
65
|
+
}
|
|
66
|
+
function s(t, r = "mark") {
|
|
67
|
+
if (!t || !t.isEditable) return !1;
|
|
68
|
+
if (r === "mark")
|
|
69
|
+
return !d("highlight", t) || B(t, ["image"]) ? !1 : t.can().setMark("highlight");
|
|
70
|
+
if (!v(t, ["nodeBackground"])) return !1;
|
|
71
|
+
try {
|
|
72
|
+
return t.can().toggleNodeBackgroundColor("test");
|
|
73
|
+
} catch {
|
|
74
|
+
return !1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function T(t, r, l = "mark") {
|
|
78
|
+
if (!t || !t.isEditable) return !1;
|
|
79
|
+
if (l === "mark")
|
|
80
|
+
return r ? t.isActive("highlight", { color: r }) : t.isActive("highlight");
|
|
81
|
+
if (!r) return !1;
|
|
82
|
+
try {
|
|
83
|
+
const { state: i } = t, { selection: h } = i, a = h.$anchor;
|
|
84
|
+
for (let n = a.depth; n >= 0; n--) {
|
|
85
|
+
const e = a.node(n);
|
|
86
|
+
if (e && e.attrs?.backgroundColor === r)
|
|
87
|
+
return !0;
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
} catch {
|
|
91
|
+
return !1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function O(t, r = "mark") {
|
|
95
|
+
return !t || !t.isEditable || !s(t, r) ? !1 : r === "mark" ? t.chain().focus().unsetMark("highlight").run() : t.chain().focus().unsetNodeBackgroundColor().run();
|
|
96
|
+
}
|
|
97
|
+
function A(t) {
|
|
98
|
+
const { editor: r, hideWhenUnavailable: l, mode: i } = t;
|
|
99
|
+
if (!r || !r.isEditable) return !1;
|
|
100
|
+
if (i === "mark") {
|
|
101
|
+
if (!d("highlight", r)) return !1;
|
|
102
|
+
} else if (!v(r, ["nodeBackground"])) return !1;
|
|
103
|
+
return l && !r.isActive("code") ? s(r, i) : !0;
|
|
104
|
+
}
|
|
105
|
+
function D(t) {
|
|
106
|
+
const {
|
|
107
|
+
editor: r,
|
|
108
|
+
label: l,
|
|
109
|
+
highlightColor: i,
|
|
110
|
+
hideWhenUnavailable: h = !1,
|
|
111
|
+
mode: a = "mark",
|
|
112
|
+
onApplied: n
|
|
113
|
+
} = t, { editor: e } = w(r), k = E(), [g, m] = C(!0), c = s(e, a), p = T(e, i, a);
|
|
114
|
+
y(() => {
|
|
115
|
+
if (!e) return;
|
|
116
|
+
const o = () => {
|
|
117
|
+
m(A({ editor: e, hideWhenUnavailable: h, mode: a }));
|
|
118
|
+
};
|
|
119
|
+
return o(), e.on("selectionUpdate", o), () => {
|
|
120
|
+
e.off("selectionUpdate", o);
|
|
121
|
+
};
|
|
122
|
+
}, [e, h, a]);
|
|
123
|
+
const u = f(() => {
|
|
124
|
+
if (!e || !c || !i || !l)
|
|
125
|
+
return !1;
|
|
126
|
+
if (a === "mark") {
|
|
127
|
+
if (e.state.storedMarks) {
|
|
128
|
+
const o = e.schema.marks.highlight;
|
|
129
|
+
o && e.view.dispatch(
|
|
130
|
+
e.state.tr.removeStoredMark(o)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return setTimeout(() => {
|
|
134
|
+
const o = e.chain().focus().toggleMark("highlight", { color: i }).run();
|
|
135
|
+
return o && n?.({ color: i, label: l, mode: a }), o;
|
|
136
|
+
}, 0), !0;
|
|
137
|
+
} else {
|
|
138
|
+
const o = e.chain().focus().toggleNodeBackgroundColor(i).run();
|
|
139
|
+
return o && n?.({ color: i, label: l, mode: a }), o;
|
|
140
|
+
}
|
|
141
|
+
}, [c, i, e, l, n, a]), H = f(() => {
|
|
142
|
+
const o = O(e, a);
|
|
143
|
+
return o && n?.({ color: "", label: "Remove highlight", mode: a }), o;
|
|
144
|
+
}, [e, n, a]);
|
|
145
|
+
return M(
|
|
146
|
+
b,
|
|
147
|
+
(o) => {
|
|
148
|
+
o.preventDefault(), u();
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
enabled: g && c,
|
|
152
|
+
enableOnContentEditable: !k,
|
|
153
|
+
enableOnFormTags: !0
|
|
154
|
+
}
|
|
155
|
+
), {
|
|
156
|
+
isVisible: g,
|
|
157
|
+
isActive: p,
|
|
158
|
+
handleColorHighlight: u,
|
|
159
|
+
handleRemoveHighlight: H,
|
|
160
|
+
canColorHighlight: c,
|
|
161
|
+
label: l || "Highlight",
|
|
162
|
+
shortcutKeys: b,
|
|
163
|
+
Icon: I,
|
|
164
|
+
mode: a
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
b as COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
169
|
+
S as HIGHLIGHT_COLORS,
|
|
170
|
+
s as canColorHighlight,
|
|
171
|
+
T as isColorHighlightActive,
|
|
172
|
+
x as pickHighlightColorsByValue,
|
|
173
|
+
O as removeHighlight,
|
|
174
|
+
A as shouldShowButton,
|
|
175
|
+
D as useColorHighlight
|
|
176
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
import { HighlightColor, UseColorHighlightConfig } from '../color-highlight-button';
|
|
4
|
+
export interface ColorHighlightPopoverContentProps {
|
|
5
|
+
/**
|
|
6
|
+
* The Tiptap editor instance.
|
|
7
|
+
*/
|
|
8
|
+
editor?: Editor | null;
|
|
9
|
+
/**
|
|
10
|
+
* Optional colors to use in the highlight popover.
|
|
11
|
+
* If not provided, defaults to a predefined set of colors.
|
|
12
|
+
*/
|
|
13
|
+
colors?: HighlightColor[];
|
|
14
|
+
}
|
|
15
|
+
export interface ColorHighlightPopoverProps extends Omit<ButtonProps, "type">, Pick<UseColorHighlightConfig, "editor" | "hideWhenUnavailable" | "onApplied"> {
|
|
16
|
+
/**
|
|
17
|
+
* Optional colors to use in the highlight popover.
|
|
18
|
+
* If not provided, defaults to a predefined set of colors.
|
|
19
|
+
*/
|
|
20
|
+
colors?: HighlightColor[];
|
|
21
|
+
}
|
|
22
|
+
export declare const ColorHighlightPopoverButton: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
export declare function ColorHighlightPopoverContent({ editor, colors, }: ColorHighlightPopoverContentProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function ColorHighlightPopover({ editor: providedEditor, colors, hideWhenUnavailable, onApplied, ...props }: ColorHighlightPopoverProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
export default ColorHighlightPopover;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as t, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useRef as I, useMemo as y, useState as x } from "react";
|
|
3
|
+
import "@tiptap/react";
|
|
4
|
+
import { useMenuNavigation as B } from "../../../hooks/use-menu-navigation.js";
|
|
5
|
+
import { useIsMobile as P } from "../../../hooks/use-mobile.js";
|
|
6
|
+
import { useTiptapEditor as R } from "../../../hooks/use-tiptap-editor.js";
|
|
7
|
+
import { BanIcon as S } from "../../tiptap-icons/ban-icon.js";
|
|
8
|
+
import { HighlighterIcon as N } from "../../tiptap-icons/highlighter-icon.js";
|
|
9
|
+
import { useColorHighlight as m, pickHighlightColorsByValue as f } from "../color-highlight-button/use-color-highlight.js";
|
|
10
|
+
import { Card as w, CardBody as M, CardItemGroup as k } from "../../tiptap-ui-primitive/card/card.js";
|
|
11
|
+
import { Button as b, ButtonGroup as d } from "../../tiptap-ui-primitive/button/button.js";
|
|
12
|
+
import { ColorHighlightButton as z } from "../color-highlight-button/color-highlight-button.js";
|
|
13
|
+
import { Popover as O, PopoverTrigger as j, PopoverContent as E } from "../../tiptap-ui-primitive/popover/popover.js";
|
|
14
|
+
import { Separator as G } from "../../tiptap-ui-primitive/separator/separator.js";
|
|
15
|
+
const v = H(({ className: l, children: o, ...r }, a) => /* @__PURE__ */ t(
|
|
16
|
+
b,
|
|
17
|
+
{
|
|
18
|
+
type: "button",
|
|
19
|
+
className: l,
|
|
20
|
+
"data-style": "ghost",
|
|
21
|
+
"data-appearance": "default",
|
|
22
|
+
role: "button",
|
|
23
|
+
tabIndex: -1,
|
|
24
|
+
"aria-label": "Highlight text",
|
|
25
|
+
tooltip: "Highlight",
|
|
26
|
+
ref: a,
|
|
27
|
+
...r,
|
|
28
|
+
children: o ?? /* @__PURE__ */ t(N, { className: "tiptap-button-icon" })
|
|
29
|
+
}
|
|
30
|
+
));
|
|
31
|
+
v.displayName = "ColorHighlightPopoverButton";
|
|
32
|
+
function T({
|
|
33
|
+
editor: l,
|
|
34
|
+
colors: o = f([
|
|
35
|
+
"var(--tt-color-highlight-green)",
|
|
36
|
+
"var(--tt-color-highlight-blue)",
|
|
37
|
+
"var(--tt-color-highlight-red)",
|
|
38
|
+
"var(--tt-color-highlight-purple)",
|
|
39
|
+
"var(--tt-color-highlight-yellow)"
|
|
40
|
+
])
|
|
41
|
+
}) {
|
|
42
|
+
const { handleRemoveHighlight: r } = m({ editor: l }), a = P(), h = I(null), g = y(
|
|
43
|
+
() => [...o, { label: "Remove highlight", value: "none" }],
|
|
44
|
+
[o]
|
|
45
|
+
), { selectedIndex: n } = B({
|
|
46
|
+
containerRef: h,
|
|
47
|
+
items: g,
|
|
48
|
+
orientation: "both",
|
|
49
|
+
onSelect: (e) => {
|
|
50
|
+
if (!h.current) return !1;
|
|
51
|
+
const i = h.current.querySelector(
|
|
52
|
+
'[data-highlighted="true"]'
|
|
53
|
+
);
|
|
54
|
+
return i && i.click(), e.value === "none" && r(), !0;
|
|
55
|
+
},
|
|
56
|
+
autoSelectFirstItem: !1
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ t(
|
|
59
|
+
w,
|
|
60
|
+
{
|
|
61
|
+
ref: h,
|
|
62
|
+
tabIndex: 0,
|
|
63
|
+
style: a ? { boxShadow: "none", border: 0 } : {},
|
|
64
|
+
children: /* @__PURE__ */ t(M, { style: a ? { padding: 0 } : {}, children: /* @__PURE__ */ u(k, { orientation: "horizontal", children: [
|
|
65
|
+
/* @__PURE__ */ t(d, { orientation: "horizontal", children: o.map((e, i) => /* @__PURE__ */ t(
|
|
66
|
+
z,
|
|
67
|
+
{
|
|
68
|
+
editor: l,
|
|
69
|
+
highlightColor: e.value,
|
|
70
|
+
tooltip: e.label,
|
|
71
|
+
"aria-label": `${e.label} highlight color`,
|
|
72
|
+
tabIndex: i === n ? 0 : -1,
|
|
73
|
+
"data-highlighted": n === i
|
|
74
|
+
},
|
|
75
|
+
e.value
|
|
76
|
+
)) }),
|
|
77
|
+
/* @__PURE__ */ t(G, {}),
|
|
78
|
+
/* @__PURE__ */ t(d, { orientation: "horizontal", children: /* @__PURE__ */ t(
|
|
79
|
+
b,
|
|
80
|
+
{
|
|
81
|
+
onClick: r,
|
|
82
|
+
"aria-label": "Remove highlight",
|
|
83
|
+
tooltip: "Remove highlight",
|
|
84
|
+
tabIndex: n === o.length ? 0 : -1,
|
|
85
|
+
type: "button",
|
|
86
|
+
role: "menuitem",
|
|
87
|
+
"data-style": "ghost",
|
|
88
|
+
"data-highlighted": n === o.length,
|
|
89
|
+
children: /* @__PURE__ */ t(S, { className: "tiptap-button-icon" })
|
|
90
|
+
}
|
|
91
|
+
) })
|
|
92
|
+
] }) })
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function Z({
|
|
97
|
+
editor: l,
|
|
98
|
+
colors: o = f([
|
|
99
|
+
"var(--tt-color-highlight-green)",
|
|
100
|
+
"var(--tt-color-highlight-blue)",
|
|
101
|
+
"var(--tt-color-highlight-red)",
|
|
102
|
+
"var(--tt-color-highlight-purple)",
|
|
103
|
+
"var(--tt-color-highlight-yellow)"
|
|
104
|
+
]),
|
|
105
|
+
hideWhenUnavailable: r = !1,
|
|
106
|
+
onApplied: a,
|
|
107
|
+
...h
|
|
108
|
+
}) {
|
|
109
|
+
const { editor: g } = R(l), [n, e] = x(!1), { isVisible: i, canColorHighlight: p, isActive: s, label: c, Icon: C } = m({
|
|
110
|
+
editor: g,
|
|
111
|
+
hideWhenUnavailable: r,
|
|
112
|
+
onApplied: a
|
|
113
|
+
});
|
|
114
|
+
return i ? /* @__PURE__ */ u(O, { open: n, onOpenChange: e, children: [
|
|
115
|
+
/* @__PURE__ */ t(j, { asChild: !0, children: /* @__PURE__ */ t(
|
|
116
|
+
v,
|
|
117
|
+
{
|
|
118
|
+
disabled: !p,
|
|
119
|
+
"data-active-state": s ? "on" : "off",
|
|
120
|
+
"data-disabled": !p,
|
|
121
|
+
"aria-pressed": s,
|
|
122
|
+
"aria-label": c,
|
|
123
|
+
tooltip: c,
|
|
124
|
+
...h,
|
|
125
|
+
children: /* @__PURE__ */ t(C, { className: "tiptap-button-icon" })
|
|
126
|
+
}
|
|
127
|
+
) }),
|
|
128
|
+
/* @__PURE__ */ t(E, { "aria-label": "Highlight colors", children: /* @__PURE__ */ t(T, { editor: g, colors: o }) })
|
|
129
|
+
] }) : null;
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
Z as ColorHighlightPopover,
|
|
133
|
+
v as ColorHighlightPopoverButton,
|
|
134
|
+
T as ColorHighlightPopoverContent,
|
|
135
|
+
Z as default
|
|
136
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './color-highlight-popover';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Level, UseHeadingConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface HeadingButtonProps extends Omit<ButtonProps, "type">, UseHeadingConfig {
|
|
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 HeadingShortcutBadge({ level, shortcutKeys, }: {
|
|
15
|
+
level: Level;
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for toggling heading in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* For custom button implementations, use the `useHeading` hook instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HeadingButton: import('react').ForwardRefExoticComponent<HeadingButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as t, jsxs as T, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useCallback as S } 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 { useHeading as I, HEADING_SHORTCUT_KEYS as K } from "./use-heading.js";
|
|
6
|
+
import { Button as j } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
import { Badge as k } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
8
|
+
function A({
|
|
9
|
+
level: a,
|
|
10
|
+
shortcutKeys: e = K[a]
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ t(k, { children: C({ shortcutKeys: e }) });
|
|
13
|
+
}
|
|
14
|
+
const R = N(
|
|
15
|
+
({
|
|
16
|
+
editor: a,
|
|
17
|
+
level: e,
|
|
18
|
+
text: o,
|
|
19
|
+
hideWhenUnavailable: c = !1,
|
|
20
|
+
onToggled: p,
|
|
21
|
+
showShortcut: u = !1,
|
|
22
|
+
onClick: r,
|
|
23
|
+
children: m,
|
|
24
|
+
...f
|
|
25
|
+
}, g) => {
|
|
26
|
+
const { editor: b } = E(a), {
|
|
27
|
+
isVisible: h,
|
|
28
|
+
canToggle: i,
|
|
29
|
+
isActive: n,
|
|
30
|
+
handleToggle: s,
|
|
31
|
+
label: d,
|
|
32
|
+
Icon: H,
|
|
33
|
+
shortcutKeys: y
|
|
34
|
+
} = I({
|
|
35
|
+
editor: b,
|
|
36
|
+
level: e,
|
|
37
|
+
hideWhenUnavailable: c,
|
|
38
|
+
onToggled: p
|
|
39
|
+
}), B = S(
|
|
40
|
+
(l) => {
|
|
41
|
+
r?.(l), !l.defaultPrevented && s();
|
|
42
|
+
},
|
|
43
|
+
[s, r]
|
|
44
|
+
);
|
|
45
|
+
return h ? /* @__PURE__ */ t(
|
|
46
|
+
j,
|
|
47
|
+
{
|
|
48
|
+
type: "button",
|
|
49
|
+
"data-style": "ghost",
|
|
50
|
+
"data-active-state": n ? "on" : "off",
|
|
51
|
+
role: "button",
|
|
52
|
+
tabIndex: -1,
|
|
53
|
+
disabled: !i,
|
|
54
|
+
"data-disabled": !i,
|
|
55
|
+
"aria-label": d,
|
|
56
|
+
"aria-pressed": n,
|
|
57
|
+
tooltip: d,
|
|
58
|
+
onClick: B,
|
|
59
|
+
...f,
|
|
60
|
+
ref: g,
|
|
61
|
+
children: m ?? /* @__PURE__ */ T(x, { children: [
|
|
62
|
+
/* @__PURE__ */ t(H, { className: "tiptap-button-icon" }),
|
|
63
|
+
o && /* @__PURE__ */ t("span", { className: "tiptap-button-text", children: o }),
|
|
64
|
+
u && /* @__PURE__ */ t(A, { level: e, shortcutKeys: y })
|
|
65
|
+
] })
|
|
66
|
+
}
|
|
67
|
+
) : null;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
R.displayName = "HeadingButton";
|
|
71
|
+
export {
|
|
72
|
+
R as HeadingButton,
|
|
73
|
+
A as HeadingShortcutBadge
|
|
74
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HeadingButton as g, HeadingShortcutBadge as n } from "./heading-button.js";
|
|
2
|
+
import { HEADING_SHORTCUT_KEYS as a, canToggle as d, headingIcons as i, isHeadingActive as H, shouldShowButton as r, toggleHeading as u, useHeading as c } from "./use-heading.js";
|
|
3
|
+
export {
|
|
4
|
+
a as HEADING_SHORTCUT_KEYS,
|
|
5
|
+
g as HeadingButton,
|
|
6
|
+
n as HeadingShortcutBadge,
|
|
7
|
+
d as canToggle,
|
|
8
|
+
i as headingIcons,
|
|
9
|
+
H as isHeadingActive,
|
|
10
|
+
r as shouldShowButton,
|
|
11
|
+
u as toggleHeading,
|
|
12
|
+
c as useHeading
|
|
13
|
+
};
|