@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,3 @@
|
|
|
1
|
+
type UserRef<T> = ((instance: T | null) => void) | React.RefObject<T | null> | null | undefined;
|
|
2
|
+
export declare const useComposedRef: <T extends HTMLElement>(libRef: React.RefObject<T | null>, userRef: UserRef<T>) => (instance: T | null) => void;
|
|
3
|
+
export default useComposedRef;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useRef as u, useCallback as e } from "react";
|
|
2
|
+
const o = (t, n) => {
|
|
3
|
+
typeof t == "function" ? t(n) : t && typeof t == "object" && "current" in t && (t.current = n);
|
|
4
|
+
}, s = (t, n) => {
|
|
5
|
+
const r = u(null);
|
|
6
|
+
return e(
|
|
7
|
+
(c) => {
|
|
8
|
+
t && "current" in t && (t.current = c), r.current && o(r.current, null), r.current = n, n && o(n, c);
|
|
9
|
+
},
|
|
10
|
+
[t, n]
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
s as default,
|
|
15
|
+
s as useComposedRef
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export interface CursorVisibilityOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The Tiptap editor instance
|
|
5
|
+
*/
|
|
6
|
+
editor?: Editor | null;
|
|
7
|
+
/**
|
|
8
|
+
* Reference to the toolbar element that may obscure the cursor
|
|
9
|
+
*/
|
|
10
|
+
overlayHeight?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook that ensures the cursor remains visible when typing in a Tiptap editor.
|
|
14
|
+
* Automatically scrolls the window when the cursor would be hidden by the toolbar.
|
|
15
|
+
*
|
|
16
|
+
* @param options.editor The Tiptap editor instance
|
|
17
|
+
* @param options.overlayHeight Toolbar height to account for
|
|
18
|
+
* @returns The bounding rect of the body
|
|
19
|
+
*/
|
|
20
|
+
export declare function useCursorVisibility({ editor, overlayHeight, }: CursorVisibilityOptions): import('./use-element-rect').RectState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useWindowSize as f } from "./use-window-size.js";
|
|
2
|
+
import { useBodyRect as h } from "./use-element-rect.js";
|
|
3
|
+
import { useEffect as b } from "react";
|
|
4
|
+
function S({
|
|
5
|
+
editor: t,
|
|
6
|
+
overlayHeight: s = 0
|
|
7
|
+
}) {
|
|
8
|
+
const { height: o } = f(), r = h({
|
|
9
|
+
enabled: !0,
|
|
10
|
+
throttleMs: 100,
|
|
11
|
+
useResizeObserver: !0
|
|
12
|
+
});
|
|
13
|
+
return b(() => {
|
|
14
|
+
(() => {
|
|
15
|
+
if (!t) return;
|
|
16
|
+
const { state: c, view: i } = t;
|
|
17
|
+
if (!i.hasFocus()) return;
|
|
18
|
+
const { from: n } = c.selection, e = i.coordsAtPos(n);
|
|
19
|
+
if (o < r.height && e && o - e.top < s) {
|
|
20
|
+
const u = Math.max(o / 2, s), l = window.scrollY, a = e.top + l - u;
|
|
21
|
+
window.scrollTo({
|
|
22
|
+
top: Math.max(0, a),
|
|
23
|
+
behavior: "smooth"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
})();
|
|
27
|
+
}, [t, s, o, r.height]), r;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
S as useCursorVisibility
|
|
31
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type RectState = Omit<DOMRect, "toJSON">;
|
|
2
|
+
export interface ElementRectOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The element to track. Can be an Element, ref, or selector string.
|
|
5
|
+
* Defaults to document.body if not provided.
|
|
6
|
+
*/
|
|
7
|
+
element?: Element | React.RefObject<Element> | string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to enable rect tracking
|
|
10
|
+
*/
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Throttle delay in milliseconds for rect updates
|
|
14
|
+
*/
|
|
15
|
+
throttleMs?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to use ResizeObserver for more accurate tracking
|
|
18
|
+
*/
|
|
19
|
+
useResizeObserver?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Custom hook that tracks an element's bounding rectangle and updates on resize, scroll, etc.
|
|
23
|
+
*
|
|
24
|
+
* @param options Configuration options for element rect tracking
|
|
25
|
+
* @returns The current bounding rectangle of the element
|
|
26
|
+
*/
|
|
27
|
+
export declare function useElementRect({ element, enabled, throttleMs, useResizeObserver, }?: ElementRectOptions): RectState;
|
|
28
|
+
/**
|
|
29
|
+
* Convenience hook for tracking document.body rect
|
|
30
|
+
*/
|
|
31
|
+
export declare function useBodyRect(options?: Omit<ElementRectOptions, "element">): RectState;
|
|
32
|
+
/**
|
|
33
|
+
* Convenience hook for tracking a ref element's rect
|
|
34
|
+
*/
|
|
35
|
+
export declare function useRefRect<T extends Element>(ref: React.RefObject<T>, options?: Omit<ElementRectOptions, "element">): RectState;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState as g, useCallback as m, useEffect as v } from "react";
|
|
2
|
+
import { useThrottledCallback as R } from "./use-throttled-callback.js";
|
|
3
|
+
const d = {
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0,
|
|
6
|
+
width: 0,
|
|
7
|
+
height: 0,
|
|
8
|
+
top: 0,
|
|
9
|
+
right: 0,
|
|
10
|
+
bottom: 0,
|
|
11
|
+
left: 0
|
|
12
|
+
}, a = typeof window > "u", y = !a && typeof ResizeObserver < "u", f = () => !a;
|
|
13
|
+
function h({
|
|
14
|
+
element: e,
|
|
15
|
+
enabled: r = !0,
|
|
16
|
+
throttleMs: w = 100,
|
|
17
|
+
useResizeObserver: l = !0
|
|
18
|
+
} = {}) {
|
|
19
|
+
const [p, i] = g(d), o = m(() => !r || !f() ? null : e ? typeof e == "string" ? document.querySelector(e) : "current" in e ? e.current : e : document.body, [e, r]), s = R(
|
|
20
|
+
() => {
|
|
21
|
+
if (!r || !f()) return;
|
|
22
|
+
const n = o();
|
|
23
|
+
if (!n) {
|
|
24
|
+
i(d);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const t = n.getBoundingClientRect();
|
|
28
|
+
i({
|
|
29
|
+
x: t.x,
|
|
30
|
+
y: t.y,
|
|
31
|
+
width: t.width,
|
|
32
|
+
height: t.height,
|
|
33
|
+
top: t.top,
|
|
34
|
+
right: t.right,
|
|
35
|
+
bottom: t.bottom,
|
|
36
|
+
left: t.left
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
w,
|
|
40
|
+
[r, o],
|
|
41
|
+
{ leading: !0, trailing: !0 }
|
|
42
|
+
);
|
|
43
|
+
return v(() => {
|
|
44
|
+
if (!r || !f()) {
|
|
45
|
+
i(d);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const n = o();
|
|
49
|
+
if (!n) return;
|
|
50
|
+
s();
|
|
51
|
+
const t = [];
|
|
52
|
+
if (l && y) {
|
|
53
|
+
const c = new ResizeObserver(() => {
|
|
54
|
+
window.requestAnimationFrame(s);
|
|
55
|
+
});
|
|
56
|
+
c.observe(n), t.push(() => c.disconnect());
|
|
57
|
+
}
|
|
58
|
+
const u = () => s();
|
|
59
|
+
return window.addEventListener("scroll", u, { passive: !0 }), window.addEventListener("resize", u, { passive: !0 }), t.push(() => {
|
|
60
|
+
window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
|
|
61
|
+
}), () => {
|
|
62
|
+
t.forEach((c) => c()), i(d);
|
|
63
|
+
};
|
|
64
|
+
}, [r, o, s, l]), p;
|
|
65
|
+
}
|
|
66
|
+
function z(e = {}) {
|
|
67
|
+
return h({
|
|
68
|
+
...e,
|
|
69
|
+
element: f() ? document.body : null
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function S(e, r = {}) {
|
|
73
|
+
return h({ ...r, element: e });
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
z as useBodyRect,
|
|
77
|
+
h as useElementRect,
|
|
78
|
+
S as useRefRect
|
|
79
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
type Orientation = "horizontal" | "vertical" | "both";
|
|
3
|
+
interface MenuNavigationOptions<T> {
|
|
4
|
+
/**
|
|
5
|
+
* The Tiptap editor instance, if using with a Tiptap editor.
|
|
6
|
+
*/
|
|
7
|
+
editor?: Editor | null;
|
|
8
|
+
/**
|
|
9
|
+
* Reference to the container element for handling keyboard events.
|
|
10
|
+
*/
|
|
11
|
+
containerRef?: React.RefObject<HTMLElement | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Search query that affects the selected item.
|
|
14
|
+
*/
|
|
15
|
+
query?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Array of items to navigate through.
|
|
18
|
+
*/
|
|
19
|
+
items: T[];
|
|
20
|
+
/**
|
|
21
|
+
* Callback fired when an item is selected.
|
|
22
|
+
*/
|
|
23
|
+
onSelect?: (item: T) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback fired when the menu should close.
|
|
26
|
+
*/
|
|
27
|
+
onClose?: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* The navigation orientation of the menu.
|
|
30
|
+
* @default "vertical"
|
|
31
|
+
*/
|
|
32
|
+
orientation?: Orientation;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to automatically select the first item when the menu opens.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
autoSelectFirstItem?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hook that implements keyboard navigation for dropdown menus and command palettes.
|
|
41
|
+
*
|
|
42
|
+
* Handles arrow keys, tab, home/end, enter for selection, and escape to close.
|
|
43
|
+
* Works with both Tiptap editors and regular DOM elements.
|
|
44
|
+
*
|
|
45
|
+
* @param options - Configuration options for the menu navigation
|
|
46
|
+
* @returns Object containing the selected index and a setter function
|
|
47
|
+
*/
|
|
48
|
+
export declare function useMenuNavigation<T>({ editor, containerRef, query, items, onSelect, onClose, orientation, autoSelectFirstItem, }: MenuNavigationOptions<T>): {
|
|
49
|
+
selectedIndex: number | undefined;
|
|
50
|
+
setSelectedIndex: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useState as D, useEffect as v } from "react";
|
|
2
|
+
function E({
|
|
3
|
+
editor: a,
|
|
4
|
+
containerRef: s,
|
|
5
|
+
query: d,
|
|
6
|
+
items: r,
|
|
7
|
+
onSelect: h,
|
|
8
|
+
onClose: g,
|
|
9
|
+
orientation: u = "vertical",
|
|
10
|
+
autoSelectFirstItem: c = !0
|
|
11
|
+
}) {
|
|
12
|
+
const [n, t] = D(
|
|
13
|
+
c ? 0 : -1
|
|
14
|
+
);
|
|
15
|
+
return v(() => {
|
|
16
|
+
const i = (e) => {
|
|
17
|
+
if (!r.length) return !1;
|
|
18
|
+
const o = () => t((l) => l === -1 ? 0 : (l + 1) % r.length), p = () => t((l) => l === -1 ? r.length - 1 : (l - 1 + r.length) % r.length);
|
|
19
|
+
switch (e.key) {
|
|
20
|
+
case "ArrowUp":
|
|
21
|
+
return u === "horizontal" ? !1 : (e.preventDefault(), p(), !0);
|
|
22
|
+
case "ArrowDown":
|
|
23
|
+
return u === "horizontal" ? !1 : (e.preventDefault(), o(), !0);
|
|
24
|
+
case "ArrowLeft":
|
|
25
|
+
return u === "vertical" ? !1 : (e.preventDefault(), p(), !0);
|
|
26
|
+
case "ArrowRight":
|
|
27
|
+
return u === "vertical" ? !1 : (e.preventDefault(), o(), !0);
|
|
28
|
+
case "Tab":
|
|
29
|
+
return e.preventDefault(), e.shiftKey ? p() : o(), !0;
|
|
30
|
+
case "Home":
|
|
31
|
+
return e.preventDefault(), t(0), !0;
|
|
32
|
+
case "End":
|
|
33
|
+
return e.preventDefault(), t(r.length - 1), !0;
|
|
34
|
+
case "Enter":
|
|
35
|
+
return e.isComposing ? !1 : (e.preventDefault(), n !== -1 && r[n] && h?.(r[n]), !0);
|
|
36
|
+
case "Escape":
|
|
37
|
+
return e.preventDefault(), g?.(), !0;
|
|
38
|
+
default:
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
let f = null;
|
|
43
|
+
if (a ? f = a.view.dom : s?.current && (f = s.current), f)
|
|
44
|
+
return f.addEventListener("keydown", i, !0), () => {
|
|
45
|
+
f?.removeEventListener(
|
|
46
|
+
"keydown",
|
|
47
|
+
i,
|
|
48
|
+
!0
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
}, [
|
|
52
|
+
a,
|
|
53
|
+
s,
|
|
54
|
+
r,
|
|
55
|
+
n,
|
|
56
|
+
h,
|
|
57
|
+
g,
|
|
58
|
+
u
|
|
59
|
+
]), v(() => {
|
|
60
|
+
d && t(c ? 0 : -1);
|
|
61
|
+
}, [d, c]), {
|
|
62
|
+
selectedIndex: r.length ? n : void 0,
|
|
63
|
+
setSelectedIndex: t
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
E as useMenuNavigation
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(breakpoint?: number): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useState as s, useEffect as d } from "react";
|
|
2
|
+
function c(e = 768) {
|
|
3
|
+
const [o, n] = s(void 0);
|
|
4
|
+
return d(() => {
|
|
5
|
+
const t = window.matchMedia(`(max-width: ${e - 1}px)`), i = () => {
|
|
6
|
+
n(window.innerWidth < e);
|
|
7
|
+
};
|
|
8
|
+
return t.addEventListener("change", i), n(window.innerWidth < e), () => t.removeEventListener("change", i);
|
|
9
|
+
}, [e]), !!o;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
c as useIsMobile
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
type ScrollTarget = RefObject<HTMLElement> | Window | null | undefined;
|
|
3
|
+
interface UseScrollingOptions {
|
|
4
|
+
debounce?: number;
|
|
5
|
+
fallbackToDocument?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function useScrolling(target?: ScrollTarget, options?: UseScrollingOptions): boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useState as v, useEffect as E } from "react";
|
|
2
|
+
function b(e, S = {}) {
|
|
3
|
+
const { debounce: u = 150, fallbackToDocument: f = !0 } = S, [o, t] = v(!1);
|
|
4
|
+
return E(() => {
|
|
5
|
+
const l = e && typeof Window < "u" && e instanceof Window ? e : e?.current ?? window, n = f && l === window && typeof document < "u" ? document : l, m = (i, r, d) => i.addEventListener(r, d, { passive: !0 }), a = (i, r, d) => i.removeEventListener(r, d);
|
|
6
|
+
let c;
|
|
7
|
+
const s = l === window && "onscrollend" in window, w = () => {
|
|
8
|
+
o || t(!0), s || (clearTimeout(c), c = setTimeout(() => t(!1), u));
|
|
9
|
+
}, p = () => t(!1);
|
|
10
|
+
return m(n, "scroll", w), s && m(n, "scrollend", p), () => {
|
|
11
|
+
a(n, "scroll", w), s && a(n, "scrollend", p), clearTimeout(c);
|
|
12
|
+
};
|
|
13
|
+
}, [e, u, f, o]), o;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
b as useScrolling
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ThrottleSettings {
|
|
2
|
+
leading?: boolean | undefined;
|
|
3
|
+
trailing?: boolean | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A hook that returns a throttled callback function.
|
|
7
|
+
*
|
|
8
|
+
* @param fn The function to throttle
|
|
9
|
+
* @param wait The time in ms to wait before calling the function
|
|
10
|
+
* @param dependencies The dependencies to watch for changes
|
|
11
|
+
* @param options The throttle options
|
|
12
|
+
*/
|
|
13
|
+
export declare function useThrottledCallback<T extends (...args: any[]) => any>(fn: T, wait?: number, dependencies?: React.DependencyList, options?: ThrottleSettings): {
|
|
14
|
+
(this: ThisParameterType<T>, ...args: Parameters<T>): ReturnType<T>;
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
flush: () => void;
|
|
17
|
+
};
|
|
18
|
+
export default useThrottledCallback;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useMemo as V } from "react";
|
|
2
|
+
import { useUnmount as Y } from "./use-unmount.js";
|
|
3
|
+
var T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
4
|
+
function Z(o) {
|
|
5
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
6
|
+
}
|
|
7
|
+
var S, W;
|
|
8
|
+
function ee() {
|
|
9
|
+
if (W) return S;
|
|
10
|
+
W = 1;
|
|
11
|
+
var o = "Expected a function", g = NaN, j = "[object Symbol]", v = /^\s+|\s+$/g, b = /^[-+]0x[0-9a-f]+$/i, F = /^0b[01]+$/i, N = /^0o[0-7]+$/i, R = parseInt, $ = typeof T == "object" && T && T.Object === Object && T, w = typeof self == "object" && self && self.Object === Object && self, A = $ || w || Function("return this")(), B = Object.prototype, P = B.toString, q = Math.max, D = Math.min, O = function() {
|
|
12
|
+
return A.Date.now();
|
|
13
|
+
};
|
|
14
|
+
function G(e, n, r) {
|
|
15
|
+
var a, f, h, c, i, l, s = 0, _ = !1, d = !1, I = !0;
|
|
16
|
+
if (typeof e != "function")
|
|
17
|
+
throw new TypeError(o);
|
|
18
|
+
n = k(n) || 0, y(r) && (_ = !!r.leading, d = "maxWait" in r, h = d ? q(k(r.maxWait) || 0, n) : h, I = "trailing" in r ? !!r.trailing : I);
|
|
19
|
+
function x(t) {
|
|
20
|
+
var u = a, m = f;
|
|
21
|
+
return a = f = void 0, s = t, c = e.apply(m, u), c;
|
|
22
|
+
}
|
|
23
|
+
function z(t) {
|
|
24
|
+
return s = t, i = setTimeout(p, n), _ ? x(t) : c;
|
|
25
|
+
}
|
|
26
|
+
function J(t) {
|
|
27
|
+
var u = t - l, m = t - s, M = n - u;
|
|
28
|
+
return d ? D(M, h - m) : M;
|
|
29
|
+
}
|
|
30
|
+
function L(t) {
|
|
31
|
+
var u = t - l, m = t - s;
|
|
32
|
+
return l === void 0 || u >= n || u < 0 || d && m >= h;
|
|
33
|
+
}
|
|
34
|
+
function p() {
|
|
35
|
+
var t = O();
|
|
36
|
+
if (L(t))
|
|
37
|
+
return C(t);
|
|
38
|
+
i = setTimeout(p, J(t));
|
|
39
|
+
}
|
|
40
|
+
function C(t) {
|
|
41
|
+
return i = void 0, I && a ? x(t) : (a = f = void 0, c);
|
|
42
|
+
}
|
|
43
|
+
function K() {
|
|
44
|
+
i !== void 0 && clearTimeout(i), s = 0, a = l = f = i = void 0;
|
|
45
|
+
}
|
|
46
|
+
function Q() {
|
|
47
|
+
return i === void 0 ? c : C(O());
|
|
48
|
+
}
|
|
49
|
+
function E() {
|
|
50
|
+
var t = O(), u = L(t);
|
|
51
|
+
if (a = arguments, f = this, l = t, u) {
|
|
52
|
+
if (i === void 0)
|
|
53
|
+
return z(l);
|
|
54
|
+
if (d)
|
|
55
|
+
return i = setTimeout(p, n), x(l);
|
|
56
|
+
}
|
|
57
|
+
return i === void 0 && (i = setTimeout(p, n)), c;
|
|
58
|
+
}
|
|
59
|
+
return E.cancel = K, E.flush = Q, E;
|
|
60
|
+
}
|
|
61
|
+
function U(e, n, r) {
|
|
62
|
+
var a = !0, f = !0;
|
|
63
|
+
if (typeof e != "function")
|
|
64
|
+
throw new TypeError(o);
|
|
65
|
+
return y(r) && (a = "leading" in r ? !!r.leading : a, f = "trailing" in r ? !!r.trailing : f), G(e, n, {
|
|
66
|
+
leading: a,
|
|
67
|
+
maxWait: n,
|
|
68
|
+
trailing: f
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function y(e) {
|
|
72
|
+
var n = typeof e;
|
|
73
|
+
return !!e && (n == "object" || n == "function");
|
|
74
|
+
}
|
|
75
|
+
function H(e) {
|
|
76
|
+
return !!e && typeof e == "object";
|
|
77
|
+
}
|
|
78
|
+
function X(e) {
|
|
79
|
+
return typeof e == "symbol" || H(e) && P.call(e) == j;
|
|
80
|
+
}
|
|
81
|
+
function k(e) {
|
|
82
|
+
if (typeof e == "number")
|
|
83
|
+
return e;
|
|
84
|
+
if (X(e))
|
|
85
|
+
return g;
|
|
86
|
+
if (y(e)) {
|
|
87
|
+
var n = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
88
|
+
e = y(n) ? n + "" : n;
|
|
89
|
+
}
|
|
90
|
+
if (typeof e != "string")
|
|
91
|
+
return e === 0 ? e : +e;
|
|
92
|
+
e = e.replace(v, "");
|
|
93
|
+
var r = F.test(e);
|
|
94
|
+
return r || N.test(e) ? R(e.slice(2), r ? 2 : 8) : b.test(e) ? g : +e;
|
|
95
|
+
}
|
|
96
|
+
return S = U, S;
|
|
97
|
+
}
|
|
98
|
+
var te = ee();
|
|
99
|
+
const ne = /* @__PURE__ */ Z(te), re = {
|
|
100
|
+
leading: !1,
|
|
101
|
+
trailing: !0
|
|
102
|
+
};
|
|
103
|
+
function ae(o, g = 250, j = [], v = re) {
|
|
104
|
+
const b = V(
|
|
105
|
+
() => ne(o, g, v),
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
j
|
|
108
|
+
);
|
|
109
|
+
return Y(() => {
|
|
110
|
+
b.cancel();
|
|
111
|
+
}), b;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
ae as default,
|
|
115
|
+
ae as useThrottledCallback
|
|
116
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that provides access to a Tiptap editor instance.
|
|
4
|
+
*
|
|
5
|
+
* Accepts an optional editor instance directly, or falls back to retrieving
|
|
6
|
+
* the editor from the Tiptap context if available. This allows components
|
|
7
|
+
* to work both when given an editor directly and when used within a Tiptap
|
|
8
|
+
* editor context.
|
|
9
|
+
*
|
|
10
|
+
* @param providedEditor - Optional editor instance to use instead of the context editor
|
|
11
|
+
* @returns The provided editor or the editor from context, whichever is available
|
|
12
|
+
*/
|
|
13
|
+
export declare function useTiptapEditor(providedEditor?: Editor | null): {
|
|
14
|
+
editor: Editor | null;
|
|
15
|
+
editorState?: Editor["state"];
|
|
16
|
+
canCommand?: Editor["can"];
|
|
17
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCurrentEditor as i, useEditorState as d } from "@tiptap/react";
|
|
2
|
+
import { useMemo as n } from "react";
|
|
3
|
+
function s(r) {
|
|
4
|
+
const { editor: o } = i(), e = n(
|
|
5
|
+
() => r || o,
|
|
6
|
+
[r, o]
|
|
7
|
+
);
|
|
8
|
+
return d({
|
|
9
|
+
editor: e,
|
|
10
|
+
selector(t) {
|
|
11
|
+
return t.editor ? {
|
|
12
|
+
editor: t.editor,
|
|
13
|
+
editorState: t.editor.state,
|
|
14
|
+
canCommand: t.editor.can
|
|
15
|
+
} : {
|
|
16
|
+
editor: null,
|
|
17
|
+
editorState: void 0,
|
|
18
|
+
canCommand: void 0
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}) || { editor: null };
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
s as useTiptapEditor
|
|
25
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface WindowSizeState {
|
|
2
|
+
/**
|
|
3
|
+
* The width of the window's visual viewport in pixels.
|
|
4
|
+
*/
|
|
5
|
+
width: number;
|
|
6
|
+
/**
|
|
7
|
+
* The height of the window's visual viewport in pixels.
|
|
8
|
+
*/
|
|
9
|
+
height: number;
|
|
10
|
+
/**
|
|
11
|
+
* The distance from the top of the visual viewport to the top of the layout viewport.
|
|
12
|
+
* Particularly useful for handling mobile keyboard appearance.
|
|
13
|
+
*/
|
|
14
|
+
offsetTop: number;
|
|
15
|
+
/**
|
|
16
|
+
* The distance from the left of the visual viewport to the left of the layout viewport.
|
|
17
|
+
*/
|
|
18
|
+
offsetLeft: number;
|
|
19
|
+
/**
|
|
20
|
+
* The scale factor of the visual viewport.
|
|
21
|
+
* This is useful for scaling elements based on the current zoom level.
|
|
22
|
+
*/
|
|
23
|
+
scale: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook that tracks the window's visual viewport dimensions, position, and provides
|
|
27
|
+
* a CSS transform for positioning elements.
|
|
28
|
+
*
|
|
29
|
+
* Uses the Visual Viewport API to get accurate measurements, especially important
|
|
30
|
+
* for mobile devices where virtual keyboards can change the visible area.
|
|
31
|
+
* Only updates state when values actually change to optimize performance.
|
|
32
|
+
*
|
|
33
|
+
* @returns An object containing viewport properties and a CSS transform string
|
|
34
|
+
*/
|
|
35
|
+
export declare function useWindowSize(): WindowSizeState;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState as d, useEffect as h } from "react";
|
|
2
|
+
import { useThrottledCallback as c } from "./use-throttled-callback.js";
|
|
3
|
+
function p() {
|
|
4
|
+
const [w, u] = d({
|
|
5
|
+
width: 0,
|
|
6
|
+
height: 0,
|
|
7
|
+
offsetTop: 0,
|
|
8
|
+
offsetLeft: 0,
|
|
9
|
+
scale: 0
|
|
10
|
+
}), i = c(() => {
|
|
11
|
+
if (typeof window > "u") return;
|
|
12
|
+
const e = window.visualViewport;
|
|
13
|
+
if (!e) return;
|
|
14
|
+
const {
|
|
15
|
+
width: o = 0,
|
|
16
|
+
height: n = 0,
|
|
17
|
+
offsetTop: f = 0,
|
|
18
|
+
offsetLeft: s = 0,
|
|
19
|
+
scale: r = 0
|
|
20
|
+
} = e;
|
|
21
|
+
u((t) => o === t.width && n === t.height && f === t.offsetTop && s === t.offsetLeft && r === t.scale ? t : { width: o, height: n, offsetTop: f, offsetLeft: s, scale: r });
|
|
22
|
+
}, 200);
|
|
23
|
+
return h(() => {
|
|
24
|
+
const e = window.visualViewport;
|
|
25
|
+
if (e)
|
|
26
|
+
return e.addEventListener("resize", i), i(), () => {
|
|
27
|
+
e.removeEventListener("resize", i);
|
|
28
|
+
};
|
|
29
|
+
}, [i]), w;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
p as useWindowSize
|
|
33
|
+
};
|