@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 @@
|
|
|
1
|
+
export declare function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { MoonStarIcon as c } from "../../tiptap-icons/moon-star-icon.js";
|
|
3
|
+
import { SunIcon as s } from "../../tiptap-icons/sun-icon.js";
|
|
4
|
+
import { useState as m, useEffect as a } from "react";
|
|
5
|
+
import { Button as i } from "../../tiptap-ui-primitive/button/button.js";
|
|
6
|
+
function f() {
|
|
7
|
+
const [t, o] = m(!1);
|
|
8
|
+
return a(() => {
|
|
9
|
+
const e = window.matchMedia("(prefers-color-scheme: dark)"), n = () => o(e.matches);
|
|
10
|
+
return e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
11
|
+
}, []), a(() => {
|
|
12
|
+
const e = !!document.querySelector('meta[name="color-scheme"][content="dark"]') || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
13
|
+
o(e);
|
|
14
|
+
}, []), a(() => {
|
|
15
|
+
document.documentElement.classList.toggle("dark", t);
|
|
16
|
+
}, [t]), /* @__PURE__ */ r(
|
|
17
|
+
i,
|
|
18
|
+
{
|
|
19
|
+
onClick: () => o((e) => !e),
|
|
20
|
+
"aria-label": `Switch to ${t ? "light" : "dark"} mode`,
|
|
21
|
+
"data-style": "ghost",
|
|
22
|
+
children: t ? /* @__PURE__ */ r(c, { className: "tiptap-button-icon" }) : /* @__PURE__ */ r(s, { className: "tiptap-button-icon" })
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
f as ThemeToggle
|
|
28
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseBlockquoteConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface BlockquoteButtonProps extends Omit<ButtonProps, "type">, UseBlockquoteConfig {
|
|
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 BlockquoteShortcutBadge({ shortcutKeys, }: {
|
|
15
|
+
shortcutKeys?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Button component for toggling blockquote in a Tiptap editor.
|
|
19
|
+
*
|
|
20
|
+
* For custom button implementations, use the `useBlockquote` hook instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare const BlockquoteButton: import('react').ForwardRefExoticComponent<BlockquoteButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as t, jsxs as T, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y, useCallback as x } from "react";
|
|
3
|
+
import { useTiptapEditor as C } from "../../../hooks/use-tiptap-editor.js";
|
|
4
|
+
import { parseShortcutKeys as K } from "../../../lib/tiptap-utils.js";
|
|
5
|
+
import { useBlockquote as E, BLOCKQUOTE_SHORTCUT_KEY as N } from "./use-blockquote.js";
|
|
6
|
+
import { Badge as O } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
7
|
+
import { Button as S } from "../../tiptap-ui-primitive/button/button.js";
|
|
8
|
+
function j({
|
|
9
|
+
shortcutKeys: o = N
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ t(O, { children: K({ shortcutKeys: o }) });
|
|
12
|
+
}
|
|
13
|
+
const v = y(
|
|
14
|
+
({
|
|
15
|
+
editor: o,
|
|
16
|
+
text: e,
|
|
17
|
+
hideWhenUnavailable: n = !1,
|
|
18
|
+
onToggled: c,
|
|
19
|
+
showShortcut: u = !1,
|
|
20
|
+
onClick: r,
|
|
21
|
+
children: d,
|
|
22
|
+
...p
|
|
23
|
+
}, m) => {
|
|
24
|
+
const { editor: f } = C(o), {
|
|
25
|
+
isVisible: b,
|
|
26
|
+
canToggle: a,
|
|
27
|
+
isActive: i,
|
|
28
|
+
handleToggle: l,
|
|
29
|
+
label: B,
|
|
30
|
+
shortcutKeys: h,
|
|
31
|
+
Icon: g
|
|
32
|
+
} = E({
|
|
33
|
+
editor: f,
|
|
34
|
+
hideWhenUnavailable: n,
|
|
35
|
+
onToggled: c
|
|
36
|
+
}), k = x(
|
|
37
|
+
(s) => {
|
|
38
|
+
r?.(s), !s.defaultPrevented && l();
|
|
39
|
+
},
|
|
40
|
+
[l, r]
|
|
41
|
+
);
|
|
42
|
+
return b ? /* @__PURE__ */ t(
|
|
43
|
+
S,
|
|
44
|
+
{
|
|
45
|
+
type: "button",
|
|
46
|
+
"data-style": "ghost",
|
|
47
|
+
"data-active-state": i ? "on" : "off",
|
|
48
|
+
role: "button",
|
|
49
|
+
tabIndex: -1,
|
|
50
|
+
disabled: !a,
|
|
51
|
+
"data-disabled": !a,
|
|
52
|
+
"aria-label": B,
|
|
53
|
+
"aria-pressed": i,
|
|
54
|
+
tooltip: "Blockquote",
|
|
55
|
+
onClick: k,
|
|
56
|
+
...p,
|
|
57
|
+
ref: m,
|
|
58
|
+
children: d ?? /* @__PURE__ */ T(q, { children: [
|
|
59
|
+
/* @__PURE__ */ t(g, { className: "tiptap-button-icon" }),
|
|
60
|
+
e && /* @__PURE__ */ t("span", { className: "tiptap-button-text", children: e }),
|
|
61
|
+
u && /* @__PURE__ */ t(j, { shortcutKeys: h })
|
|
62
|
+
] })
|
|
63
|
+
}
|
|
64
|
+
) : null;
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
v.displayName = "BlockquoteButton";
|
|
68
|
+
export {
|
|
69
|
+
v as BlockquoteButton,
|
|
70
|
+
j as BlockquoteShortcutBadge
|
|
71
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlockquoteButton as e, BlockquoteShortcutBadge as u } from "./blockquote-button.js";
|
|
2
|
+
import { BLOCKQUOTE_SHORTCUT_KEY as l, canToggleBlockquote as c, shouldShowButton as g, toggleBlockquote as k, useBlockquote as q } from "./use-blockquote.js";
|
|
3
|
+
export {
|
|
4
|
+
l as BLOCKQUOTE_SHORTCUT_KEY,
|
|
5
|
+
e as BlockquoteButton,
|
|
6
|
+
u as BlockquoteShortcutBadge,
|
|
7
|
+
c as canToggleBlockquote,
|
|
8
|
+
g as shouldShowButton,
|
|
9
|
+
k as toggleBlockquote,
|
|
10
|
+
q as useBlockquote
|
|
11
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const BLOCKQUOTE_SHORTCUT_KEY = "mod+shift+b";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the blockquote functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseBlockquoteConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button should hide when blockquote is not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called after a successful toggle.
|
|
18
|
+
*/
|
|
19
|
+
onToggled?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if blockquote can be toggled in the current editor state
|
|
23
|
+
*/
|
|
24
|
+
export declare function canToggleBlockquote(editor: Editor | null, turnInto?: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Toggles blockquote formatting for a specific node or the current selection
|
|
27
|
+
*/
|
|
28
|
+
export declare function toggleBlockquote(editor: Editor | null): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Determines if the blockquote button should be shown
|
|
31
|
+
*/
|
|
32
|
+
export declare function shouldShowButton(props: {
|
|
33
|
+
editor: Editor | null;
|
|
34
|
+
hideWhenUnavailable: boolean;
|
|
35
|
+
}): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Custom hook that provides blockquote functionality for Tiptap editor
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Simple usage - no params needed
|
|
42
|
+
* function MySimpleBlockquoteButton() {
|
|
43
|
+
* const { isVisible, handleToggle, isActive } = useBlockquote()
|
|
44
|
+
*
|
|
45
|
+
* if (!isVisible) return null
|
|
46
|
+
*
|
|
47
|
+
* return <button onClick={handleToggle}>Blockquote</button>
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* // Advanced usage with configuration
|
|
51
|
+
* function MyAdvancedBlockquoteButton() {
|
|
52
|
+
* const { isVisible, handleToggle, label, isActive } = useBlockquote({
|
|
53
|
+
* editor: myEditor,
|
|
54
|
+
* hideWhenUnavailable: true,
|
|
55
|
+
* onToggled: () => console.log('Blockquote toggled!')
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* if (!isVisible) return null
|
|
59
|
+
*
|
|
60
|
+
* return (
|
|
61
|
+
* <MyButton
|
|
62
|
+
* onClick={handleToggle}
|
|
63
|
+
* aria-label={label}
|
|
64
|
+
* aria-pressed={isActive}
|
|
65
|
+
* >
|
|
66
|
+
* Toggle Blockquote
|
|
67
|
+
* </MyButton>
|
|
68
|
+
* )
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function useBlockquote(config?: UseBlockquoteConfig): {
|
|
73
|
+
isVisible: boolean;
|
|
74
|
+
isActive: boolean;
|
|
75
|
+
handleToggle: () => boolean;
|
|
76
|
+
canToggle: boolean;
|
|
77
|
+
label: string;
|
|
78
|
+
shortcutKeys: string;
|
|
79
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
80
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useState as k, useEffect as m, useCallback as q } from "react";
|
|
2
|
+
import { TextSelection as d, NodeSelection as h } from "prosemirror-state";
|
|
3
|
+
import { useTiptapEditor as v } from "../../../hooks/use-tiptap-editor.js";
|
|
4
|
+
import { BlockquoteIcon as T } from "../../tiptap-icons/blockquote-icon.js";
|
|
5
|
+
import { isNodeInSchema as b, isNodeTypeSelected as S, selectionWithinConvertibleTypes as C, findNodePosition as E, isValidPosition as B } from "../../../lib/tiptap-utils.js";
|
|
6
|
+
const U = "mod+shift+b";
|
|
7
|
+
function u(e, n = !0) {
|
|
8
|
+
return !e || !e.isEditable || !b("blockquote", e) || S(e, ["image"]) ? !1 : n ? C(e, [
|
|
9
|
+
"paragraph",
|
|
10
|
+
"heading",
|
|
11
|
+
"bulletList",
|
|
12
|
+
"orderedList",
|
|
13
|
+
"taskList",
|
|
14
|
+
"blockquote",
|
|
15
|
+
"codeBlock"
|
|
16
|
+
]) ? e.can().toggleWrap("blockquote") || e.can().clearNodes() : !1 : e.can().toggleWrap("blockquote");
|
|
17
|
+
}
|
|
18
|
+
function N(e) {
|
|
19
|
+
if (!e || !e.isEditable || !u(e)) return !1;
|
|
20
|
+
try {
|
|
21
|
+
const n = e.view;
|
|
22
|
+
let o = n.state, i = o.tr;
|
|
23
|
+
if (o.selection.empty || o.selection instanceof d) {
|
|
24
|
+
const c = E({
|
|
25
|
+
editor: e,
|
|
26
|
+
node: o.selection.$anchor.node(1)
|
|
27
|
+
})?.pos;
|
|
28
|
+
if (!B(c)) return !1;
|
|
29
|
+
i = i.setSelection(h.create(o.doc, c)), n.dispatch(i), o = n.state;
|
|
30
|
+
}
|
|
31
|
+
const t = o.selection;
|
|
32
|
+
let l = e.chain().focus();
|
|
33
|
+
if (t instanceof h) {
|
|
34
|
+
const c = t.node.firstChild?.firstChild, r = t.node.lastChild?.lastChild, a = c ? t.from + c.nodeSize : t.from + 1, s = r ? t.to - r.nodeSize : t.to - 1, p = o.doc.resolve(a), g = o.doc.resolve(s);
|
|
35
|
+
l = l.setTextSelection(d.between(p, g)).clearNodes();
|
|
36
|
+
}
|
|
37
|
+
return (e.isActive("blockquote") ? l.lift("blockquote") : l.wrapIn("blockquote")).run(), e.chain().focus().selectTextblockEnd().run(), !0;
|
|
38
|
+
} catch {
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function w(e) {
|
|
43
|
+
const { editor: n, hideWhenUnavailable: o } = e;
|
|
44
|
+
return !n || !n.isEditable || !b("blockquote", n) ? !1 : o && !n.isActive("code") ? u(n) : !0;
|
|
45
|
+
}
|
|
46
|
+
function L(e) {
|
|
47
|
+
const {
|
|
48
|
+
editor: n,
|
|
49
|
+
hideWhenUnavailable: o = !1,
|
|
50
|
+
onToggled: i
|
|
51
|
+
} = e || {}, { editor: t } = v(n), [l, f] = k(!0), c = u(t), r = t?.isActive("blockquote") || !1;
|
|
52
|
+
m(() => {
|
|
53
|
+
if (!t) return;
|
|
54
|
+
const s = () => {
|
|
55
|
+
f(w({ editor: t, hideWhenUnavailable: o }));
|
|
56
|
+
};
|
|
57
|
+
return s(), t.on("selectionUpdate", s), () => {
|
|
58
|
+
t.off("selectionUpdate", s);
|
|
59
|
+
};
|
|
60
|
+
}, [t, o]);
|
|
61
|
+
const a = q(() => {
|
|
62
|
+
if (!t) return !1;
|
|
63
|
+
const s = N(t);
|
|
64
|
+
return s && i?.(), s;
|
|
65
|
+
}, [t, i]);
|
|
66
|
+
return {
|
|
67
|
+
isVisible: l,
|
|
68
|
+
isActive: r,
|
|
69
|
+
handleToggle: a,
|
|
70
|
+
canToggle: c,
|
|
71
|
+
label: "Blockquote",
|
|
72
|
+
shortcutKeys: U,
|
|
73
|
+
Icon: T
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
U as BLOCKQUOTE_SHORTCUT_KEY,
|
|
78
|
+
u as canToggleBlockquote,
|
|
79
|
+
w as shouldShowButton,
|
|
80
|
+
N as toggleBlockquote,
|
|
81
|
+
L as useBlockquote
|
|
82
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseCodeBlockConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface CodeBlockButtonProps extends Omit<ButtonProps, "type">, UseCodeBlockConfig {
|
|
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 CodeBlockShortcutBadge({ shortcutKeys, }: {
|
|
15
|
+
shortcutKeys?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Button component for toggling code block in a Tiptap editor.
|
|
19
|
+
*
|
|
20
|
+
* For custom button implementations, use the `useCodeBlock` hook instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CodeBlockButton: import('react').ForwardRefExoticComponent<CodeBlockButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as t, jsxs as k, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as T, useCallback as x } from "react";
|
|
3
|
+
import { useTiptapEditor as K } from "../../../hooks/use-tiptap-editor.js";
|
|
4
|
+
import { parseShortcutKeys as E } from "../../../lib/tiptap-utils.js";
|
|
5
|
+
import { useCodeBlock as N, CODE_BLOCK_SHORTCUT_KEY as O } from "./use-code-block.js";
|
|
6
|
+
import { Button as S } from "../../tiptap-ui-primitive/button/button.js";
|
|
7
|
+
import { Badge as _ } from "../../tiptap-ui-primitive/badge/badge.js";
|
|
8
|
+
function j({
|
|
9
|
+
shortcutKeys: o = O
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ t(_, { children: E({ shortcutKeys: o }) });
|
|
12
|
+
}
|
|
13
|
+
const v = T(
|
|
14
|
+
({
|
|
15
|
+
editor: o,
|
|
16
|
+
text: e,
|
|
17
|
+
hideWhenUnavailable: n = !1,
|
|
18
|
+
onToggled: d,
|
|
19
|
+
showShortcut: c = !1,
|
|
20
|
+
onClick: r,
|
|
21
|
+
children: p,
|
|
22
|
+
...u
|
|
23
|
+
}, m) => {
|
|
24
|
+
const { editor: f } = K(o), {
|
|
25
|
+
isVisible: b,
|
|
26
|
+
canToggle: a,
|
|
27
|
+
isActive: i,
|
|
28
|
+
handleToggle: l,
|
|
29
|
+
label: B,
|
|
30
|
+
shortcutKeys: h,
|
|
31
|
+
Icon: C
|
|
32
|
+
} = N({
|
|
33
|
+
editor: f,
|
|
34
|
+
hideWhenUnavailable: n,
|
|
35
|
+
onToggled: d
|
|
36
|
+
}), g = x(
|
|
37
|
+
(s) => {
|
|
38
|
+
r?.(s), !s.defaultPrevented && l();
|
|
39
|
+
},
|
|
40
|
+
[l, r]
|
|
41
|
+
);
|
|
42
|
+
return b ? /* @__PURE__ */ t(
|
|
43
|
+
S,
|
|
44
|
+
{
|
|
45
|
+
type: "button",
|
|
46
|
+
"data-style": "ghost",
|
|
47
|
+
"data-active-state": i ? "on" : "off",
|
|
48
|
+
role: "button",
|
|
49
|
+
disabled: !a,
|
|
50
|
+
"data-disabled": !a,
|
|
51
|
+
tabIndex: -1,
|
|
52
|
+
"aria-label": B,
|
|
53
|
+
"aria-pressed": i,
|
|
54
|
+
tooltip: "Code Block",
|
|
55
|
+
onClick: g,
|
|
56
|
+
...u,
|
|
57
|
+
ref: m,
|
|
58
|
+
children: p ?? /* @__PURE__ */ k(y, { children: [
|
|
59
|
+
/* @__PURE__ */ t(C, { className: "tiptap-button-icon" }),
|
|
60
|
+
e && /* @__PURE__ */ t("span", { className: "tiptap-button-text", children: e }),
|
|
61
|
+
c && /* @__PURE__ */ t(j, { shortcutKeys: h })
|
|
62
|
+
] })
|
|
63
|
+
}
|
|
64
|
+
) : null;
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
v.displayName = "CodeBlockButton";
|
|
68
|
+
export {
|
|
69
|
+
v as CodeBlockButton,
|
|
70
|
+
j as CodeBlockShortcutBadge
|
|
71
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CodeBlockButton as t, CodeBlockShortcutBadge as B } from "./code-block-button.js";
|
|
2
|
+
import { CODE_BLOCK_SHORTCUT_KEY as C, canToggle as c, shouldShowButton as d, toggleCodeBlock as g, useCodeBlock as r } from "./use-code-block.js";
|
|
3
|
+
export {
|
|
4
|
+
C as CODE_BLOCK_SHORTCUT_KEY,
|
|
5
|
+
t as CodeBlockButton,
|
|
6
|
+
B as CodeBlockShortcutBadge,
|
|
7
|
+
c as canToggle,
|
|
8
|
+
d as shouldShowButton,
|
|
9
|
+
g as toggleCodeBlock,
|
|
10
|
+
r as useCodeBlock
|
|
11
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the code block functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseCodeBlockConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button should hide when code block is not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called after a successful code block toggle.
|
|
18
|
+
*/
|
|
19
|
+
onToggled?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if code block can be toggled in the current editor state
|
|
23
|
+
*/
|
|
24
|
+
export declare function canToggle(editor: Editor | null, turnInto?: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Toggles code block in the editor
|
|
27
|
+
*/
|
|
28
|
+
export declare function toggleCodeBlock(editor: Editor | null): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Determines if the code block button should be shown
|
|
31
|
+
*/
|
|
32
|
+
export declare function shouldShowButton(props: {
|
|
33
|
+
editor: Editor | null;
|
|
34
|
+
hideWhenUnavailable: boolean;
|
|
35
|
+
}): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Custom hook that provides code block functionality for Tiptap editor
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Simple usage - no params needed
|
|
42
|
+
* function MySimpleCodeBlockButton() {
|
|
43
|
+
* const { isVisible, isActive, handleToggle } = useCodeBlock()
|
|
44
|
+
*
|
|
45
|
+
* if (!isVisible) return null
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <button
|
|
49
|
+
* onClick={handleToggle}
|
|
50
|
+
* aria-pressed={isActive}
|
|
51
|
+
* >
|
|
52
|
+
* Code Block
|
|
53
|
+
* </button>
|
|
54
|
+
* )
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Advanced usage with configuration
|
|
58
|
+
* function MyAdvancedCodeBlockButton() {
|
|
59
|
+
* const { isVisible, isActive, handleToggle, label } = useCodeBlock({
|
|
60
|
+
* editor: myEditor,
|
|
61
|
+
* hideWhenUnavailable: true,
|
|
62
|
+
* onToggled: (isActive) => console.log('Code block toggled:', isActive)
|
|
63
|
+
* })
|
|
64
|
+
*
|
|
65
|
+
* if (!isVisible) return null
|
|
66
|
+
*
|
|
67
|
+
* return (
|
|
68
|
+
* <MyButton
|
|
69
|
+
* onClick={handleToggle}
|
|
70
|
+
* aria-label={label}
|
|
71
|
+
* aria-pressed={isActive}
|
|
72
|
+
* >
|
|
73
|
+
* Toggle Code Block
|
|
74
|
+
* </MyButton>
|
|
75
|
+
* )
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function useCodeBlock(config?: UseCodeBlockConfig): {
|
|
80
|
+
isVisible: boolean;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
handleToggle: () => boolean;
|
|
83
|
+
canToggle: boolean;
|
|
84
|
+
label: string;
|
|
85
|
+
shortcutKeys: string;
|
|
86
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
87
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState as k, useEffect as C, useCallback as b } from "react";
|
|
2
|
+
import "@tiptap/react";
|
|
3
|
+
import { TextSelection as u, NodeSelection as g } from "prosemirror-state";
|
|
4
|
+
import { useTiptapEditor as v } from "../../../hooks/use-tiptap-editor.js";
|
|
5
|
+
import { isNodeInSchema as h, isNodeTypeSelected as B, selectionWithinConvertibleTypes as T, findNodePosition as S, isValidPosition as N } from "../../../lib/tiptap-utils.js";
|
|
6
|
+
import { CodeBlockIcon as E } from "../../tiptap-icons/code-block-icon.js";
|
|
7
|
+
const U = "mod+alt+c";
|
|
8
|
+
function d(e, n = !0) {
|
|
9
|
+
return !e || !e.isEditable || !h("codeBlock", e) || B(e, ["image"]) ? !1 : n ? T(e, [
|
|
10
|
+
"paragraph",
|
|
11
|
+
"heading",
|
|
12
|
+
"bulletList",
|
|
13
|
+
"orderedList",
|
|
14
|
+
"taskList",
|
|
15
|
+
"blockquote",
|
|
16
|
+
"codeBlock"
|
|
17
|
+
]) ? e.can().toggleNode("codeBlock", "paragraph") || e.can().clearNodes() : !1 : e.can().toggleNode("codeBlock", "paragraph");
|
|
18
|
+
}
|
|
19
|
+
function y(e) {
|
|
20
|
+
if (!e || !e.isEditable || !d(e)) return !1;
|
|
21
|
+
try {
|
|
22
|
+
const n = e.view;
|
|
23
|
+
let t = n.state, l = t.tr;
|
|
24
|
+
if (t.selection.empty || t.selection instanceof u) {
|
|
25
|
+
const c = S({
|
|
26
|
+
editor: e,
|
|
27
|
+
node: t.selection.$anchor.node(1)
|
|
28
|
+
})?.pos;
|
|
29
|
+
if (!N(c)) return !1;
|
|
30
|
+
l = l.setSelection(g.create(t.doc, c)), n.dispatch(l), t = n.state;
|
|
31
|
+
}
|
|
32
|
+
const o = t.selection;
|
|
33
|
+
let i = e.chain().focus();
|
|
34
|
+
if (o instanceof g) {
|
|
35
|
+
const c = o.node.firstChild?.firstChild, r = o.node.lastChild?.lastChild, a = c ? o.from + c.nodeSize : o.from + 1, s = r ? o.to - r.nodeSize : o.to - 1, p = t.doc.resolve(a), m = t.doc.resolve(s);
|
|
36
|
+
i = i.setTextSelection(u.between(p, m)).clearNodes();
|
|
37
|
+
}
|
|
38
|
+
return (e.isActive("codeBlock") ? i.setNode("paragraph") : i.toggleNode("codeBlock", "paragraph")).run(), e.chain().focus().selectTextblockEnd().run(), !0;
|
|
39
|
+
} catch {
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function w(e) {
|
|
44
|
+
const { editor: n, hideWhenUnavailable: t } = e;
|
|
45
|
+
return !n || !n.isEditable || !h("codeBlock", n) ? !1 : t && !n.isActive("code") ? d(n) : !0;
|
|
46
|
+
}
|
|
47
|
+
function V(e) {
|
|
48
|
+
const {
|
|
49
|
+
editor: n,
|
|
50
|
+
hideWhenUnavailable: t = !1,
|
|
51
|
+
onToggled: l
|
|
52
|
+
} = e || {}, { editor: o } = v(n), [i, f] = k(!0), c = d(o), r = o?.isActive("codeBlock") || !1;
|
|
53
|
+
C(() => {
|
|
54
|
+
if (!o) return;
|
|
55
|
+
const s = () => {
|
|
56
|
+
f(w({ editor: o, hideWhenUnavailable: t }));
|
|
57
|
+
};
|
|
58
|
+
return s(), o.on("selectionUpdate", s), () => {
|
|
59
|
+
o.off("selectionUpdate", s);
|
|
60
|
+
};
|
|
61
|
+
}, [o, t]);
|
|
62
|
+
const a = b(() => {
|
|
63
|
+
if (!o) return !1;
|
|
64
|
+
const s = y(o);
|
|
65
|
+
return s && l?.(), s;
|
|
66
|
+
}, [o, l]);
|
|
67
|
+
return {
|
|
68
|
+
isVisible: i,
|
|
69
|
+
isActive: r,
|
|
70
|
+
handleToggle: a,
|
|
71
|
+
canToggle: c,
|
|
72
|
+
label: "Code Block",
|
|
73
|
+
shortcutKeys: U,
|
|
74
|
+
Icon: E
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
U as CODE_BLOCK_SHORTCUT_KEY,
|
|
79
|
+
d as canToggle,
|
|
80
|
+
w as shouldShowButton,
|
|
81
|
+
y as toggleCodeBlock,
|
|
82
|
+
V as useCodeBlock
|
|
83
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { UseColorHighlightConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../tiptap-ui-primitive/button';
|
|
3
|
+
export interface ColorHighlightButtonProps extends Omit<ButtonProps, "type">, UseColorHighlightConfig {
|
|
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 ColorHighlightShortcutBadge({ shortcutKeys, }: {
|
|
15
|
+
shortcutKeys?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Button component for applying color highlights in a Tiptap editor.
|
|
19
|
+
*
|
|
20
|
+
* Supports two highlighting modes:
|
|
21
|
+
* - "mark": Uses the highlight mark extension (default)
|
|
22
|
+
* - "node": Uses the node background extension
|
|
23
|
+
*
|
|
24
|
+
* For custom button implementations, use the `useColorHighlight` hook instead.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Mark-based highlighting (default)
|
|
29
|
+
* <ColorHighlightButton highlightColor="yellow" />
|
|
30
|
+
*
|
|
31
|
+
* // Node-based background coloring
|
|
32
|
+
* <ColorHighlightButton
|
|
33
|
+
* highlightColor="var(--tt-color-highlight-blue)"
|
|
34
|
+
* mode="node"
|
|
35
|
+
* />
|
|
36
|
+
*
|
|
37
|
+
* // With custom callback
|
|
38
|
+
* <ColorHighlightButton
|
|
39
|
+
* highlightColor="red"
|
|
40
|
+
* mode="mark"
|
|
41
|
+
* onApplied={({ color, mode }) => console.log(`Applied ${color} in ${mode} mode`)}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const ColorHighlightButton: import('react').ForwardRefExoticComponent<ColorHighlightButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|