react-tiptap-base-editor 1.0.0
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 +69 -0
- package/dist/components/tiptap-icons/align-center-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-center-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/align-justify-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-justify-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/align-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-left-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/align-right-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-right-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/arrow-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/arrow-left-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/ban-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/ban-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/blockquote-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/blockquote-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/bold-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/bold-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/chevron-down-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/chevron-down-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/close-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/close-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/code-block-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/code-block-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/code2-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/code2-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/corner-down-left-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/external-link-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/external-link-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-five-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-five-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-four-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-four-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-one-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-one-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-six-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-six-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-three-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-three-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/heading-two-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-two-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/highlighter-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/highlighter-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/image-plus-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/image-plus-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/italic-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/italic-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/link-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/link-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/list-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/list-ordered-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-ordered-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/list-todo-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-todo-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/moon-star-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/moon-star-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/redo2-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/redo2-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/strike-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/strike-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/subscript-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/subscript-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/sun-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/sun-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/superscript-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/superscript-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/trash-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/trash-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/underline-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/underline-icon.d.ts.map +1 -0
- package/dist/components/tiptap-icons/undo2-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/undo2-icon.d.ts.map +1 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +3 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts.map +1 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.d.ts +59 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.d.ts.map +1 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node.d.ts +71 -0
- package/dist/components/tiptap-node/image-upload-node/image-upload-node.d.ts.map +1 -0
- package/dist/components/tiptap-node/image-upload-node/index.d.ts +2 -0
- package/dist/components/tiptap-node/image-upload-node/index.d.ts.map +1 -0
- package/dist/components/tiptap-templates/simple/simple-editor.d.ts +10 -0
- package/dist/components/tiptap-templates/simple/simple-editor.d.ts.map +1 -0
- package/dist/components/tiptap-templates/simple/theme-toggle.d.ts +2 -0
- package/dist/components/tiptap-templates/simple/theme-toggle.d.ts.map +1 -0
- package/dist/components/tiptap-ui/blockquote-button/blockquote-button.d.ts +24 -0
- package/dist/components/tiptap-ui/blockquote-button/blockquote-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/blockquote-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/blockquote-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/blockquote-button/use-blockquote.d.ts +82 -0
- package/dist/components/tiptap-ui/blockquote-button/use-blockquote.d.ts.map +1 -0
- package/dist/components/tiptap-ui/code-block-button/code-block-button.d.ts +24 -0
- package/dist/components/tiptap-ui/code-block-button/code-block-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/code-block-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/code-block-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/code-block-button/use-code-block.d.ts +89 -0
- package/dist/components/tiptap-ui/code-block-button/use-code-block.d.ts.map +1 -0
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts +25 -0
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/color-highlight-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/color-highlight-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts +61 -0
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts.map +1 -0
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts +27 -0
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts.map +1 -0
- package/dist/components/tiptap-ui/color-highlight-popover/index.d.ts +2 -0
- package/dist/components/tiptap-ui/color-highlight-popover/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-button/heading-button.d.ts +25 -0
- package/dist/components/tiptap-ui/heading-button/heading-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/heading-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-button/use-heading.d.ts +110 -0
- package/dist/components/tiptap-ui/heading-button/use-heading.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +22 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/index.d.ts +3 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +75 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts.map +1 -0
- package/dist/components/tiptap-ui/image-upload-button/image-upload-button.d.ts +24 -0
- package/dist/components/tiptap-ui/image-upload-button/image-upload-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/image-upload-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/image-upload-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.d.ts +86 -0
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.d.ts.map +1 -0
- package/dist/components/tiptap-ui/link-popover/index.d.ts +3 -0
- package/dist/components/tiptap-ui/link-popover/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/link-popover/link-popover.d.ts +59 -0
- package/dist/components/tiptap-ui/link-popover/link-popover.d.ts.map +1 -0
- package/dist/components/tiptap-ui/link-popover/use-link-popover.d.ts +119 -0
- package/dist/components/tiptap-ui/link-popover/use-link-popover.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/list-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-button/list-button.d.ts +25 -0
- package/dist/components/tiptap-ui/list-button/list-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-button/use-list.d.ts +99 -0
- package/dist/components/tiptap-ui/list-button/use-list.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/index.d.ts +2 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts +30 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts.map +1 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +92 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts.map +1 -0
- package/dist/components/tiptap-ui/mark-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/mark-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/mark-button/mark-button.d.ts +25 -0
- package/dist/components/tiptap-ui/mark-button/mark-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/mark-button/use-mark.d.ts +106 -0
- package/dist/components/tiptap-ui/mark-button/use-mark.d.ts.map +1 -0
- package/dist/components/tiptap-ui/text-align-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/text-align-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/text-align-button/text-align-button.d.ts +32 -0
- package/dist/components/tiptap-ui/text-align-button/text-align-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/text-align-button/use-text-align.d.ts +104 -0
- package/dist/components/tiptap-ui/text-align-button/use-text-align.d.ts.map +1 -0
- package/dist/components/tiptap-ui/undo-redo-button/index.d.ts +3 -0
- package/dist/components/tiptap-ui/undo-redo-button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +25 -0
- package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts.map +1 -0
- package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +92 -0
- package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/badge/badge.d.ts +13 -0
- package/dist/components/tiptap-ui-primitive/badge/badge.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/badge/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/badge/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/button/button.d.ts +19 -0
- package/dist/components/tiptap-ui-primitive/button/button.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/button/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/button/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/card/card.d.ts +12 -0
- package/dist/components/tiptap-ui-primitive/card/card.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/card/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/card/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +19 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/input/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/input/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/input/input.d.ts +6 -0
- package/dist/components/tiptap-ui-primitive/input/input.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/popover/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/popover/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/popover/popover.d.ts +8 -0
- package/dist/components/tiptap-ui-primitive/popover/popover.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/separator/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/separator/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/separator/separator.d.ts +9 -0
- package/dist/components/tiptap-ui-primitive/separator/separator.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/spacer/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/spacer/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/spacer/spacer.d.ts +8 -0
- package/dist/components/tiptap-ui-primitive/spacer/spacer.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/toolbar/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/toolbar/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.d.ts +11 -0
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/tooltip/index.d.ts +2 -0
- package/dist/components/tiptap-ui-primitive/tooltip/index.d.ts.map +1 -0
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +31 -0
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts.map +1 -0
- package/dist/hooks/use-composed-ref.d.ts +5 -0
- package/dist/hooks/use-composed-ref.d.ts.map +1 -0
- package/dist/hooks/use-cursor-visibility.d.ts +21 -0
- package/dist/hooks/use-cursor-visibility.d.ts.map +1 -0
- package/dist/hooks/use-element-rect.d.ts +37 -0
- package/dist/hooks/use-element-rect.d.ts.map +1 -0
- package/dist/hooks/use-menu-navigation.d.ts +54 -0
- package/dist/hooks/use-menu-navigation.d.ts.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-scrolling.d.ts +9 -0
- package/dist/hooks/use-scrolling.d.ts.map +1 -0
- package/dist/hooks/use-throttled-callback.d.ts +20 -0
- package/dist/hooks/use-throttled-callback.d.ts.map +1 -0
- package/dist/hooks/use-tiptap-editor.d.ts +18 -0
- package/dist/hooks/use-tiptap-editor.d.ts.map +1 -0
- package/dist/hooks/use-unmount.d.ts +8 -0
- package/dist/hooks/use-unmount.d.ts.map +1 -0
- package/dist/hooks/use-window-size.d.ts +36 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5929 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/tiptap-utils.d.ts +123 -0
- package/dist/lib/tiptap-utils.d.ts.map +1 -0
- package/dist/styles/index.css +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Editor } from "@tiptap/react";
|
|
3
|
+
import { type Level } from "@/components/tiptap-ui/heading-button";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the heading dropdown menu functionality
|
|
6
|
+
*/
|
|
7
|
+
export interface UseHeadingDropdownMenuConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The Tiptap editor instance.
|
|
10
|
+
*/
|
|
11
|
+
editor?: Editor | null;
|
|
12
|
+
/**
|
|
13
|
+
* Available heading levels to show in the dropdown
|
|
14
|
+
* @default [1, 2, 3, 4, 5, 6]
|
|
15
|
+
*/
|
|
16
|
+
levels?: Level[];
|
|
17
|
+
/**
|
|
18
|
+
* Whether the dropdown should hide when headings are not available.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
hideWhenUnavailable?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the currently active heading level from the available levels
|
|
25
|
+
*/
|
|
26
|
+
export declare function getActiveHeadingLevel(editor: Editor | null, levels?: Level[]): Level | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Custom hook that provides heading dropdown menu functionality for Tiptap editor
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Simple usage
|
|
33
|
+
* function MyHeadingDropdown() {
|
|
34
|
+
* const {
|
|
35
|
+
* isVisible,
|
|
36
|
+
* activeLevel,
|
|
37
|
+
* isAnyHeadingActive,
|
|
38
|
+
* canToggle,
|
|
39
|
+
* levels,
|
|
40
|
+
* } = useHeadingDropdownMenu()
|
|
41
|
+
*
|
|
42
|
+
* if (!isVisible) return null
|
|
43
|
+
*
|
|
44
|
+
* return (
|
|
45
|
+
* <DropdownMenu>
|
|
46
|
+
* // dropdown content
|
|
47
|
+
* </DropdownMenu>
|
|
48
|
+
* )
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* // Advanced usage with configuration
|
|
52
|
+
* function MyAdvancedHeadingDropdown() {
|
|
53
|
+
* const {
|
|
54
|
+
* isVisible,
|
|
55
|
+
* activeLevel,
|
|
56
|
+
* } = useHeadingDropdownMenu({
|
|
57
|
+
* editor: myEditor,
|
|
58
|
+
* levels: [1, 2, 3],
|
|
59
|
+
* hideWhenUnavailable: true,
|
|
60
|
+
* })
|
|
61
|
+
*
|
|
62
|
+
* // component implementation
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function useHeadingDropdownMenu(config?: UseHeadingDropdownMenuConfig): {
|
|
67
|
+
isVisible: boolean;
|
|
68
|
+
activeLevel: Level | undefined;
|
|
69
|
+
isActive: boolean;
|
|
70
|
+
canToggle: boolean;
|
|
71
|
+
levels: Level[];
|
|
72
|
+
label: string;
|
|
73
|
+
Icon: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=use-heading-dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-heading-dropdown-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAS3C,OAAO,EAEL,KAAK,KAAK,EAIX,MAAM,uCAAuC,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,GAAE,KAAK,EAAuB,GACnC,KAAK,GAAG,SAAS,CAGnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,4BAA4B;;;;;;;;EAyC3E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { UseImageUploadConfig } from "@/components/tiptap-ui/image-upload-button";
|
|
3
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
4
|
+
export interface ImageUploadButtonProps extends Omit<ButtonProps, "type">, UseImageUploadConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Optional text to display alongside the icon.
|
|
7
|
+
*/
|
|
8
|
+
text?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional show shortcut keys in the button.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
showShortcut?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function ImageShortcutBadge({ shortcutKeys, }: {
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for uploading/inserting images in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* For custom button implementations, use the `useImage` hook instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ImageUploadButton: React.ForwardRefExoticComponent<ImageUploadButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
24
|
+
//# sourceMappingURL=image-upload-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-upload-button.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/image-upload-button/image-upload-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AAOtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAI1E,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAC/B,oBAAoB;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,YAAwC,GACzC,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,2CAEA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kGAuE7B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/image-upload-button/index.tsx"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Editor } from "@tiptap/react";
|
|
3
|
+
export declare const IMAGE_UPLOAD_SHORTCUT_KEY = "mod+shift+i";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the image upload functionality
|
|
6
|
+
*/
|
|
7
|
+
export interface UseImageUploadConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The Tiptap editor instance.
|
|
10
|
+
*/
|
|
11
|
+
editor?: Editor | null;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the button should hide when insertion is not available.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
hideWhenUnavailable?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Callback function called after a successful image insertion.
|
|
19
|
+
*/
|
|
20
|
+
onInserted?: () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks if image can be inserted in the current editor state
|
|
24
|
+
*/
|
|
25
|
+
export declare function canInsertImage(editor: Editor | null): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if image is currently active
|
|
28
|
+
*/
|
|
29
|
+
export declare function isImageActive(editor: Editor | null): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Inserts an image in the editor
|
|
32
|
+
*/
|
|
33
|
+
export declare function insertImage(editor: Editor | null): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Determines if the image button should be shown
|
|
36
|
+
*/
|
|
37
|
+
export declare function shouldShowButton(props: {
|
|
38
|
+
editor: Editor | null;
|
|
39
|
+
hideWhenUnavailable: boolean;
|
|
40
|
+
}): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Custom hook that provides image functionality for Tiptap editor
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // Simple usage - no params needed
|
|
47
|
+
* function MySimpleImageButton() {
|
|
48
|
+
* const { isVisible, handleImage } = useImage()
|
|
49
|
+
*
|
|
50
|
+
* if (!isVisible) return null
|
|
51
|
+
*
|
|
52
|
+
* return <button onClick={handleImage}>Add Image</button>
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // Advanced usage with configuration
|
|
56
|
+
* function MyAdvancedImageButton() {
|
|
57
|
+
* const { isVisible, handleImage, label, isActive } = useImage({
|
|
58
|
+
* editor: myEditor,
|
|
59
|
+
* hideWhenUnavailable: true,
|
|
60
|
+
* onInserted: () => console.log('Image inserted!')
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* if (!isVisible) return null
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <MyButton
|
|
67
|
+
* onClick={handleImage}
|
|
68
|
+
* aria-pressed={isActive}
|
|
69
|
+
* aria-label={label}
|
|
70
|
+
* >
|
|
71
|
+
* Add Image
|
|
72
|
+
* </MyButton>
|
|
73
|
+
* )
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function useImageUpload(config?: UseImageUploadConfig): {
|
|
78
|
+
isVisible: boolean;
|
|
79
|
+
isActive: boolean;
|
|
80
|
+
handleImage: () => boolean;
|
|
81
|
+
canInsert: boolean;
|
|
82
|
+
label: string;
|
|
83
|
+
shortcutKeys: string;
|
|
84
|
+
Icon: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=use-image-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-image-upload.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/image-upload-button/use-image-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAe3C,eAAO,MAAM,yBAAyB,gBAAgB,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CACxB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAS7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAG5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAe1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,mBAAmB,EAAE,OAAO,CAAA;CAC7B,GAAG,OAAO,CAWV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB;;;;;;;;EA6D3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/link-popover/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Editor } from "@tiptap/react";
|
|
3
|
+
import type { UseLinkPopoverConfig } from "@/components/tiptap-ui/link-popover";
|
|
4
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
5
|
+
export interface LinkMainProps {
|
|
6
|
+
/**
|
|
7
|
+
* The URL to set for the link.
|
|
8
|
+
*/
|
|
9
|
+
url: string;
|
|
10
|
+
/**
|
|
11
|
+
* Function to update the URL state.
|
|
12
|
+
*/
|
|
13
|
+
setUrl: React.Dispatch<React.SetStateAction<string | null>>;
|
|
14
|
+
/**
|
|
15
|
+
* Function to set the link in the editor.
|
|
16
|
+
*/
|
|
17
|
+
setLink: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Function to remove the link from the editor.
|
|
20
|
+
*/
|
|
21
|
+
removeLink: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Function to open the link.
|
|
24
|
+
*/
|
|
25
|
+
openLink: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the link is currently active in the editor.
|
|
28
|
+
*/
|
|
29
|
+
isActive: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface LinkPopoverProps extends Omit<ButtonProps, "type">, UseLinkPopoverConfig {
|
|
32
|
+
/**
|
|
33
|
+
* Callback for when the popover opens or closes.
|
|
34
|
+
*/
|
|
35
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to automatically open the popover when a link is active.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
autoOpenOnLinkActive?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Link button component for triggering the link popover
|
|
44
|
+
*/
|
|
45
|
+
export declare const LinkButton: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
46
|
+
/**
|
|
47
|
+
* Link content component for standalone use
|
|
48
|
+
*/
|
|
49
|
+
export declare const LinkContent: React.FC<{
|
|
50
|
+
editor?: Editor | null;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Link popover component for Tiptap editors.
|
|
54
|
+
*
|
|
55
|
+
* For custom popover implementations, use the `useLinkPopover` hook instead.
|
|
56
|
+
*/
|
|
57
|
+
export declare const LinkPopover: React.ForwardRefExoticComponent<LinkPopoverProps & React.RefAttributes<HTMLButtonElement>>;
|
|
58
|
+
export default LinkPopover;
|
|
59
|
+
//# sourceMappingURL=link-popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-popover.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/link-popover/link-popover.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAa3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAI/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAe1E,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAA;IAC3D;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAC/B,oBAAoB;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,uFAkBtB,CAAA;AA2FD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAMA,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,4FAmGvB,CAAA;AAID,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Editor } from "@tiptap/react";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the link popover functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseLinkPopoverConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to hide the link popover when not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called when the link is set.
|
|
18
|
+
*/
|
|
19
|
+
onSetLink?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for the link handler functionality
|
|
23
|
+
*/
|
|
24
|
+
export interface LinkHandlerProps {
|
|
25
|
+
/**
|
|
26
|
+
* The Tiptap editor instance.
|
|
27
|
+
*/
|
|
28
|
+
editor: Editor | null;
|
|
29
|
+
/**
|
|
30
|
+
* Callback function called when the link is set.
|
|
31
|
+
*/
|
|
32
|
+
onSetLink?: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a link can be set in the current editor state
|
|
36
|
+
*/
|
|
37
|
+
export declare function canSetLink(editor: Editor | null): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if a link is currently active in the editor
|
|
40
|
+
*/
|
|
41
|
+
export declare function isLinkActive(editor: Editor | null): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Determines if the link button should be shown
|
|
44
|
+
*/
|
|
45
|
+
export declare function shouldShowLinkButton(props: {
|
|
46
|
+
editor: Editor | null;
|
|
47
|
+
hideWhenUnavailable: boolean;
|
|
48
|
+
}): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Custom hook for handling link operations in a Tiptap editor
|
|
51
|
+
*/
|
|
52
|
+
export declare function useLinkHandler(props: LinkHandlerProps): {
|
|
53
|
+
url: string;
|
|
54
|
+
setUrl: React.Dispatch<React.SetStateAction<string | null>>;
|
|
55
|
+
setLink: () => void;
|
|
56
|
+
removeLink: () => void;
|
|
57
|
+
openLink: (target?: string, features?: string) => void;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Custom hook for link popover state management
|
|
61
|
+
*/
|
|
62
|
+
export declare function useLinkState(props: {
|
|
63
|
+
editor: Editor | null;
|
|
64
|
+
hideWhenUnavailable: boolean;
|
|
65
|
+
}): {
|
|
66
|
+
isVisible: boolean;
|
|
67
|
+
canSet: boolean;
|
|
68
|
+
isActive: boolean;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Main hook that provides link popover functionality for Tiptap editor
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* // Simple usage
|
|
76
|
+
* function MyLinkButton() {
|
|
77
|
+
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover()
|
|
78
|
+
*
|
|
79
|
+
* if (!isVisible) return null
|
|
80
|
+
*
|
|
81
|
+
* return <button disabled={!canSet}>Link</button>
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* // Advanced usage with configuration
|
|
85
|
+
* function MyAdvancedLinkButton() {
|
|
86
|
+
* const { isVisible, canSet, isActive, Icon, label } = useLinkPopover({
|
|
87
|
+
* editor: myEditor,
|
|
88
|
+
* hideWhenUnavailable: true,
|
|
89
|
+
* onSetLink: () => console.log('Link set!')
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
92
|
+
* if (!isVisible) return null
|
|
93
|
+
*
|
|
94
|
+
* return (
|
|
95
|
+
* <MyButton
|
|
96
|
+
* disabled={!canSet}
|
|
97
|
+
* aria-label={label}
|
|
98
|
+
* aria-pressed={isActive}
|
|
99
|
+
* >
|
|
100
|
+
* <Icon />
|
|
101
|
+
* {label}
|
|
102
|
+
* </MyButton>
|
|
103
|
+
* )
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function useLinkPopover(config?: UseLinkPopoverConfig): {
|
|
108
|
+
url: string;
|
|
109
|
+
setUrl: React.Dispatch<React.SetStateAction<string | null>>;
|
|
110
|
+
setLink: () => void;
|
|
111
|
+
removeLink: () => void;
|
|
112
|
+
openLink: (target?: string, features?: string) => void;
|
|
113
|
+
isVisible: boolean;
|
|
114
|
+
canSet: boolean;
|
|
115
|
+
isActive: boolean;
|
|
116
|
+
label: string;
|
|
117
|
+
Icon: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=use-link-popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-link-popover.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/link-popover/use-link-popover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAW3C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAG3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,mBAAmB,EAAE,OAAO,CAAA;CAC7B,GAAG,OAAO,CAcV;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB;;;;;wBA+DzC,MAAM,aAAuB,MAAM;EAkB/C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,mBAAmB,EAAE,OAAO,CAAA;CAC7B;;;;EAkCA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB;;;;;wBAnG/C,MAAM,aAAuB,MAAM;;;;;;EA8H/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/list-button/index.tsx"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
import type { ListType, UseListConfig } from "@/components/tiptap-ui/list-button";
|
|
4
|
+
export interface ListButtonProps extends Omit<ButtonProps, "type">, UseListConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Optional text to display alongside the icon.
|
|
7
|
+
*/
|
|
8
|
+
text?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional show shortcut keys in the button.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
showShortcut?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function ListShortcutBadge({ type, shortcutKeys, }: {
|
|
16
|
+
type: ListType;
|
|
17
|
+
shortcutKeys?: string;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* Button component for toggling lists in a Tiptap editor.
|
|
21
|
+
*
|
|
22
|
+
* For custom button implementations, use the `useList` hook instead.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ListButton: React.ForwardRefExoticComponent<ListButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
//# sourceMappingURL=list-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-button.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/list-button/list-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAK1E,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAGjF,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAC/B,aAAa;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,YAAuC,GACxC,EAAE;IACD,IAAI,EAAE,QAAQ,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,2CAEA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,2FAwEtB,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Editor } from "@tiptap/react";
|
|
3
|
+
export type ListType = "bulletList" | "orderedList" | "taskList";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the list functionality
|
|
6
|
+
*/
|
|
7
|
+
export interface UseListConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The Tiptap editor instance.
|
|
10
|
+
*/
|
|
11
|
+
editor?: Editor | null;
|
|
12
|
+
/**
|
|
13
|
+
* The type of list to toggle.
|
|
14
|
+
*/
|
|
15
|
+
type: ListType;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the button should hide when list is not available.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hideWhenUnavailable?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Callback function called after a successful toggle.
|
|
23
|
+
*/
|
|
24
|
+
onToggled?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const listIcons: {
|
|
27
|
+
bulletList: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
28
|
+
orderedList: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
29
|
+
taskList: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
30
|
+
};
|
|
31
|
+
export declare const listLabels: Record<ListType, string>;
|
|
32
|
+
export declare const LIST_SHORTCUT_KEYS: Record<ListType, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a list can be toggled in the current editor state
|
|
35
|
+
*/
|
|
36
|
+
export declare function canToggleList(editor: Editor | null, type: ListType, turnInto?: boolean): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if list is currently active
|
|
39
|
+
*/
|
|
40
|
+
export declare function isListActive(editor: Editor | null, type: ListType): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Toggles list in the editor
|
|
43
|
+
*/
|
|
44
|
+
export declare function toggleList(editor: Editor | null, type: ListType): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Determines if the list button should be shown
|
|
47
|
+
*/
|
|
48
|
+
export declare function shouldShowButton(props: {
|
|
49
|
+
editor: Editor | null;
|
|
50
|
+
type: ListType;
|
|
51
|
+
hideWhenUnavailable: boolean;
|
|
52
|
+
}): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Custom hook that provides list functionality for Tiptap editor
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* // Simple usage
|
|
59
|
+
* function MySimpleListButton() {
|
|
60
|
+
* const { isVisible, handleToggle, isActive } = useList({ type: "bulletList" })
|
|
61
|
+
*
|
|
62
|
+
* if (!isVisible) return null
|
|
63
|
+
*
|
|
64
|
+
* return <button onClick={handleToggle}>Bullet List</button>
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* // Advanced usage with configuration
|
|
68
|
+
* function MyAdvancedListButton() {
|
|
69
|
+
* const { isVisible, handleToggle, label, isActive } = useList({
|
|
70
|
+
* type: "orderedList",
|
|
71
|
+
* editor: myEditor,
|
|
72
|
+
* hideWhenUnavailable: true,
|
|
73
|
+
* onToggled: () => console.log('List toggled!')
|
|
74
|
+
* })
|
|
75
|
+
*
|
|
76
|
+
* if (!isVisible) return null
|
|
77
|
+
*
|
|
78
|
+
* return (
|
|
79
|
+
* <MyButton
|
|
80
|
+
* onClick={handleToggle}
|
|
81
|
+
* aria-label={label}
|
|
82
|
+
* aria-pressed={isActive}
|
|
83
|
+
* >
|
|
84
|
+
* Toggle List
|
|
85
|
+
* </MyButton>
|
|
86
|
+
* )
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function useList(config: UseListConfig): {
|
|
91
|
+
isVisible: boolean;
|
|
92
|
+
isActive: boolean;
|
|
93
|
+
handleToggle: () => boolean;
|
|
94
|
+
canToggle: boolean;
|
|
95
|
+
label: string;
|
|
96
|
+
shortcutKeys: string;
|
|
97
|
+
Icon: React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element> | React.MemoExoticComponent<({ className, ...props }: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=use-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-list.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/list-button/use-list.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAmB3C,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,UAAU,CAAA;AAEhE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,eAAO,MAAM,SAAS;;;;CAIrB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAI/C,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAIvD,CAAA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,IAAI,EAAE,QAAQ,EACd,QAAQ,GAAE,OAAc,GACvB,OAAO,CAmCT;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAa3E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAsEzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,QAAQ,CAAA;IACd,mBAAmB,EAAE,OAAO,CAAA;CAC7B,GAAG,OAAO,CAWV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,aAAa;;;;;;;;EAgD5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/list-dropdown-menu/index.tsx"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Editor } from "@tiptap/react";
|
|
2
|
+
import { type ListType } from "@/components/tiptap-ui/list-button";
|
|
3
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
4
|
+
export interface ListDropdownMenuProps extends Omit<ButtonProps, "type"> {
|
|
5
|
+
/**
|
|
6
|
+
* The Tiptap editor instance.
|
|
7
|
+
*/
|
|
8
|
+
editor?: Editor;
|
|
9
|
+
/**
|
|
10
|
+
* The list types to display in the dropdown.
|
|
11
|
+
*/
|
|
12
|
+
types?: ListType[];
|
|
13
|
+
/**
|
|
14
|
+
* Whether the dropdown should be hidden when no list types are available
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
hideWhenUnavailable?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Callback for when the dropdown opens or closes
|
|
20
|
+
*/
|
|
21
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to render the dropdown menu in a portal
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
portal?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function ListDropdownMenu({ editor: providedEditor, types, hideWhenUnavailable, onOpenChange, portal, ...props }: ListDropdownMenuProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
export default ListDropdownMenu;
|
|
30
|
+
//# sourceMappingURL=list-dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-dropdown-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAS3C,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAK9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAU1E,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;IACtE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAClB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EAAE,cAAc,EACtB,KAAiD,EACjD,mBAA2B,EAC3B,YAAY,EACZ,MAAc,EACd,GAAG,KAAK,EACT,EAAE,qBAAqB,kDA+DvB;AAED,eAAe,gBAAgB,CAAA"}
|