@wecode-team/we0-cms 1.1.33 → 1.1.34
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/dist/components/tiptap-extension/node-background-extension.d.ts +23 -0
- package/dist/components/tiptap-icons/align-center-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-justify-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/align-right-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/arrow-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/ban-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/blockquote-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/bold-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/check-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/chevron-down-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/close-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/code-block-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/code2-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/external-link-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-five-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-four-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-one-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-six-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-three-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/heading-two-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/highlighter-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/image-plus-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/italic-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/link-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-ordered-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/list-todo-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/moon-star-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/redo2-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/strike-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/subscript-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/sun-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/superscript-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/trash-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/underline-icon.d.ts +3 -0
- package/dist/components/tiptap-icons/undo2-icon.d.ts +3 -0
- package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -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.d.ts +69 -0
- package/dist/components/tiptap-node/image-upload-node/index.d.ts +1 -0
- package/dist/components/tiptap-templates/simple/simple-editor.d.ts +19 -0
- package/dist/components/tiptap-templates/simple/theme-toggle.d.ts +1 -0
- package/dist/components/tiptap-ui/blockquote-button/blockquote-button.d.ts +22 -0
- package/dist/components/tiptap-ui/blockquote-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/blockquote-button/use-blockquote.d.ts +80 -0
- package/dist/components/tiptap-ui/code-block-button/code-block-button.d.ts +22 -0
- package/dist/components/tiptap-ui/code-block-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/code-block-button/use-code-block.d.ts +87 -0
- package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts +46 -0
- package/dist/components/tiptap-ui/color-highlight-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts +93 -0
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts +35 -0
- package/dist/components/tiptap-ui/color-highlight-popover/index.d.ts +1 -0
- package/dist/components/tiptap-ui/heading-button/heading-button.d.ts +23 -0
- package/dist/components/tiptap-ui/heading-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/heading-button/use-heading.d.ts +108 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +19 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/index.d.ts +2 -0
- package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
- package/dist/components/tiptap-ui/image-upload-button/image-upload-button.d.ts +29 -0
- package/dist/components/tiptap-ui/image-upload-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/image-upload-button/use-image-upload.d.ts +84 -0
- package/dist/components/tiptap-ui/link-popover/index.d.ts +2 -0
- package/dist/components/tiptap-ui/link-popover/link-popover.d.ts +58 -0
- package/dist/components/tiptap-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/components/tiptap-ui/list-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/list-button/list-button.d.ts +23 -0
- package/dist/components/tiptap-ui/list-button/use-list.d.ts +97 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts +28 -0
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +90 -0
- package/dist/components/tiptap-ui/mark-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/mark-button/mark-button.d.ts +23 -0
- package/dist/components/tiptap-ui/mark-button/use-mark.d.ts +104 -0
- package/dist/components/tiptap-ui/text-align-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/text-align-button/text-align-button.d.ts +30 -0
- package/dist/components/tiptap-ui/text-align-button/use-text-align.d.ts +102 -0
- package/dist/components/tiptap-ui/undo-redo-button/index.d.ts +2 -0
- package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
- package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
- package/dist/components/tiptap-ui-primitive/badge/badge.d.ts +11 -0
- package/dist/components/tiptap-ui-primitive/badge/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/button/button.d.ts +16 -0
- package/dist/components/tiptap-ui-primitive/button/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/button-group/button-group.d.ts +11 -0
- package/dist/components/tiptap-ui-primitive/button-group/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/card/card.d.ts +10 -0
- package/dist/components/tiptap-ui-primitive/card/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +29 -0
- package/dist/components/tiptap-ui-primitive/dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/input/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/input/input.d.ts +3 -0
- package/dist/components/tiptap-ui-primitive/popover/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/popover/popover.d.ts +6 -0
- package/dist/components/tiptap-ui-primitive/separator/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/separator/separator.d.ts +6 -0
- package/dist/components/tiptap-ui-primitive/spacer/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/spacer/spacer.d.ts +5 -0
- package/dist/components/tiptap-ui-primitive/toolbar/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/toolbar/toolbar.d.ts +9 -0
- package/dist/components/tiptap-ui-primitive/tooltip/index.d.ts +1 -0
- package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +29 -0
- package/dist/hooks/use-composed-ref.d.ts +3 -0
- package/dist/hooks/use-cursor-visibility.d.ts +20 -0
- package/dist/hooks/use-element-rect.d.ts +35 -0
- package/dist/hooks/use-is-breakpoint.d.ts +9 -0
- package/dist/hooks/use-menu-navigation.d.ts +52 -0
- package/dist/hooks/use-scrolling.d.ts +8 -0
- package/dist/hooks/use-throttled-callback.d.ts +18 -0
- package/dist/hooks/use-tiptap-editor.d.ts +6 -0
- package/dist/hooks/use-unmount.d.ts +7 -0
- package/dist/hooks/use-window-size.d.ts +35 -0
- package/dist/index.css +2 -2
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/tiptap-utils.d.ts +173 -0
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { UseColorHighlightConfig } from "@/components/tiptap-ui/color-highlight-button";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
import "@/components/tiptap-ui/color-highlight-button/color-highlight-button.scss";
|
|
4
|
+
export interface ColorHighlightButtonProps extends Omit<ButtonProps, "type">, UseColorHighlightConfig {
|
|
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 ColorHighlightShortcutBadge({ shortcutKeys, }: {
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for applying color highlights in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* Supports two highlighting modes:
|
|
22
|
+
* - "mark": Uses the highlight mark extension (default)
|
|
23
|
+
* - "node": Uses the node background extension
|
|
24
|
+
*
|
|
25
|
+
* For custom button implementations, use the `useColorHighlight` hook instead.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* // Mark-based highlighting (default)
|
|
30
|
+
* <ColorHighlightButton highlightColor="yellow" />
|
|
31
|
+
*
|
|
32
|
+
* // Node-based background coloring
|
|
33
|
+
* <ColorHighlightButton
|
|
34
|
+
* highlightColor="var(--tt-color-highlight-blue)"
|
|
35
|
+
* mode="node"
|
|
36
|
+
* />
|
|
37
|
+
*
|
|
38
|
+
* // With custom callback
|
|
39
|
+
* <ColorHighlightButton
|
|
40
|
+
* highlightColor="red"
|
|
41
|
+
* mode="mark"
|
|
42
|
+
* onApplied={({ color, mode }) => console.log(`Applied ${color} in ${mode} mode`)}
|
|
43
|
+
* />
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const ColorHighlightButton: import("react").ForwardRefExoticComponent<ColorHighlightButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type Editor } from "@tiptap/react";
|
|
2
|
+
export declare const COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
3
|
+
export declare const HIGHLIGHT_COLORS: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
colorValue: string;
|
|
7
|
+
border: string;
|
|
8
|
+
}[];
|
|
9
|
+
export type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];
|
|
10
|
+
export type HighlightMode = "mark" | "node";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the color highlight functionality
|
|
13
|
+
*/
|
|
14
|
+
export interface UseColorHighlightConfig {
|
|
15
|
+
/**
|
|
16
|
+
* The Tiptap editor instance.
|
|
17
|
+
*/
|
|
18
|
+
editor?: Editor | null;
|
|
19
|
+
/**
|
|
20
|
+
* The color to apply when toggling the highlight.
|
|
21
|
+
*/
|
|
22
|
+
highlightColor?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional label to display alongside the icon.
|
|
25
|
+
*/
|
|
26
|
+
label?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the button should hide when the mark is not available.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
hideWhenUnavailable?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The highlighting mode to use.
|
|
34
|
+
* - "mark": Uses the highlight mark extension (default)
|
|
35
|
+
* - "node": Uses the node background extension
|
|
36
|
+
* @default "mark"
|
|
37
|
+
*/
|
|
38
|
+
mode?: HighlightMode;
|
|
39
|
+
/**
|
|
40
|
+
* When true, uses the actual color value (colorValue) instead of CSS variable (value).
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
useColorValue?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Called when the highlight is applied.
|
|
46
|
+
*/
|
|
47
|
+
onApplied?: ({ color, label, mode, }: {
|
|
48
|
+
color: string;
|
|
49
|
+
label: string;
|
|
50
|
+
mode: HighlightMode;
|
|
51
|
+
}) => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function pickHighlightColorsByValue(values: string[]): {
|
|
54
|
+
label: string;
|
|
55
|
+
value: string;
|
|
56
|
+
colorValue: string;
|
|
57
|
+
border: string;
|
|
58
|
+
}[];
|
|
59
|
+
/**
|
|
60
|
+
* Gets the appropriate color value based on configuration
|
|
61
|
+
*/
|
|
62
|
+
export declare function getHighlightColorValue(color: string, useColorValue?: boolean): string;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if highlight can be applied based on the mode and current editor state
|
|
65
|
+
*/
|
|
66
|
+
export declare function canColorHighlight(editor: Editor | null, mode?: HighlightMode): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if highlight is currently active
|
|
69
|
+
*/
|
|
70
|
+
export declare function isColorHighlightActive(editor: Editor | null, highlightColor?: string, mode?: HighlightMode): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Removes highlight based on the mode
|
|
73
|
+
*/
|
|
74
|
+
export declare function removeHighlight(editor: Editor | null, mode?: HighlightMode): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Determines if the highlight button should be shown
|
|
77
|
+
*/
|
|
78
|
+
export declare function shouldShowButton(props: {
|
|
79
|
+
editor: Editor | null;
|
|
80
|
+
hideWhenUnavailable: boolean;
|
|
81
|
+
mode: HighlightMode;
|
|
82
|
+
}): boolean;
|
|
83
|
+
export declare function useColorHighlight(config: UseColorHighlightConfig): {
|
|
84
|
+
isVisible: boolean;
|
|
85
|
+
isActive: boolean;
|
|
86
|
+
handleColorHighlight: () => boolean;
|
|
87
|
+
handleRemoveHighlight: () => boolean;
|
|
88
|
+
canColorHighlight: boolean;
|
|
89
|
+
label: string;
|
|
90
|
+
shortcutKeys: string;
|
|
91
|
+
Icon: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
92
|
+
mode: HighlightMode;
|
|
93
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Editor } from "@tiptap/react";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
import type { HighlightColor, UseColorHighlightConfig } from "@/components/tiptap-ui/color-highlight-button";
|
|
4
|
+
export interface ColorHighlightPopoverContentProps {
|
|
5
|
+
/**
|
|
6
|
+
* The Tiptap editor instance.
|
|
7
|
+
*/
|
|
8
|
+
editor?: Editor | null;
|
|
9
|
+
/**
|
|
10
|
+
* Optional colors to use in the highlight popover.
|
|
11
|
+
* If not provided, defaults to a predefined set of colors.
|
|
12
|
+
*/
|
|
13
|
+
colors?: HighlightColor[];
|
|
14
|
+
/**
|
|
15
|
+
* When true, uses the actual color value (colorValue) instead of CSS variable (value).
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
useColorValue?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ColorHighlightPopoverProps extends Omit<ButtonProps, "type">, Pick<UseColorHighlightConfig, "editor" | "hideWhenUnavailable" | "onApplied"> {
|
|
21
|
+
/**
|
|
22
|
+
* Optional colors to use in the highlight popover.
|
|
23
|
+
* If not provided, defaults to a predefined set of colors.
|
|
24
|
+
*/
|
|
25
|
+
colors?: HighlightColor[];
|
|
26
|
+
/**
|
|
27
|
+
* When true, uses the actual color value (colorValue) instead of CSS variable (value).
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
useColorValue?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const ColorHighlightPopoverButton: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export declare function ColorHighlightPopoverContent({ editor, colors, useColorValue, }: ColorHighlightPopoverContentProps): import("react").JSX.Element;
|
|
34
|
+
export declare function ColorHighlightPopover({ editor: providedEditor, colors, hideWhenUnavailable, useColorValue, onApplied, ...props }: ColorHighlightPopoverProps): import("react").JSX.Element | null;
|
|
35
|
+
export default ColorHighlightPopover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./color-highlight-popover";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Level, UseHeadingConfig } from "@/components/tiptap-ui/heading-button";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
export interface HeadingButtonProps extends Omit<ButtonProps, "type">, UseHeadingConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Optional text to display alongside the icon.
|
|
6
|
+
*/
|
|
7
|
+
text?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Optional show shortcut keys in the button.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
showShortcut?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function HeadingShortcutBadge({ level, shortcutKeys, }: {
|
|
15
|
+
level: Level;
|
|
16
|
+
shortcutKeys?: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Button component for toggling heading in a Tiptap editor.
|
|
20
|
+
*
|
|
21
|
+
* For custom button implementations, use the `useHeading` hook instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HeadingButton: import("react").ForwardRefExoticComponent<HeadingButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type Editor } from "@tiptap/react";
|
|
2
|
+
export type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the heading functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseHeadingConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* The heading level.
|
|
13
|
+
*/
|
|
14
|
+
level: Level;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the button should hide when heading is not available.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
hideWhenUnavailable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback function called after a successful heading toggle.
|
|
22
|
+
*/
|
|
23
|
+
onToggled?: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const headingIcons: {
|
|
26
|
+
1: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
27
|
+
2: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
28
|
+
3: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
29
|
+
4: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
30
|
+
5: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
31
|
+
6: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
32
|
+
};
|
|
33
|
+
export declare const HEADING_SHORTCUT_KEYS: Record<Level, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if heading can be toggled in the current editor state
|
|
36
|
+
*/
|
|
37
|
+
export declare function canToggle(editor: Editor | null, level?: Level, turnInto?: boolean): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if heading is currently active
|
|
40
|
+
*/
|
|
41
|
+
export declare function isHeadingActive(editor: Editor | null, level?: Level | Level[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Toggles heading in the editor
|
|
44
|
+
*/
|
|
45
|
+
export declare function toggleHeading(editor: Editor | null, level: Level | Level[]): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Determines if the heading button should be shown
|
|
48
|
+
*/
|
|
49
|
+
export declare function shouldShowButton(props: {
|
|
50
|
+
editor: Editor | null;
|
|
51
|
+
level?: Level | Level[];
|
|
52
|
+
hideWhenUnavailable: boolean;
|
|
53
|
+
}): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Custom hook that provides heading functionality for Tiptap editor
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // Simple usage
|
|
60
|
+
* function MySimpleHeadingButton() {
|
|
61
|
+
* const { isVisible, isActive, handleToggle, Icon } = useHeading({ level: 1 })
|
|
62
|
+
*
|
|
63
|
+
* if (!isVisible) return null
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <button
|
|
67
|
+
* onClick={handleToggle}
|
|
68
|
+
* aria-pressed={isActive}
|
|
69
|
+
* >
|
|
70
|
+
* <Icon />
|
|
71
|
+
* Heading 1
|
|
72
|
+
* </button>
|
|
73
|
+
* )
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // Advanced usage with configuration
|
|
77
|
+
* function MyAdvancedHeadingButton() {
|
|
78
|
+
* const { isVisible, isActive, handleToggle, label, Icon } = useHeading({
|
|
79
|
+
* level: 2,
|
|
80
|
+
* editor: myEditor,
|
|
81
|
+
* hideWhenUnavailable: true,
|
|
82
|
+
* onToggled: (isActive) => console.log('Heading toggled:', isActive)
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* if (!isVisible) return null
|
|
86
|
+
*
|
|
87
|
+
* return (
|
|
88
|
+
* <MyButton
|
|
89
|
+
* onClick={handleToggle}
|
|
90
|
+
* aria-label={label}
|
|
91
|
+
* aria-pressed={isActive}
|
|
92
|
+
* >
|
|
93
|
+
* <Icon />
|
|
94
|
+
* Toggle Heading 2
|
|
95
|
+
* </MyButton>
|
|
96
|
+
* )
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function useHeading(config: UseHeadingConfig): {
|
|
101
|
+
isVisible: boolean;
|
|
102
|
+
isActive: boolean;
|
|
103
|
+
handleToggle: () => boolean;
|
|
104
|
+
canToggle: boolean;
|
|
105
|
+
label: string;
|
|
106
|
+
shortcutKeys: string;
|
|
107
|
+
Icon: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element> | import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element> | import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element> | import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element> | import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element> | import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
108
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UseHeadingDropdownMenuConfig } from "@/components/tiptap-ui/heading-dropdown-menu";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
export interface HeadingDropdownMenuProps extends Omit<ButtonProps, "type">, UseHeadingDropdownMenuConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Callback for when the dropdown opens or closes
|
|
6
|
+
*/
|
|
7
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the dropdown should use a modal
|
|
10
|
+
*/
|
|
11
|
+
modal?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Dropdown menu component for selecting heading levels in a Tiptap editor.
|
|
15
|
+
*
|
|
16
|
+
* For custom dropdown implementations, use the `useHeadingDropdownMenu` hook instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HeadingDropdownMenu: import("react").ForwardRefExoticComponent<HeadingDropdownMenuProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
export default HeadingDropdownMenu;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
import { type Level } from "@/components/tiptap-ui/heading-button";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the heading dropdown menu functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseHeadingDropdownMenuConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Available heading levels to show in the dropdown
|
|
13
|
+
* @default [1, 2, 3, 4, 5, 6]
|
|
14
|
+
*/
|
|
15
|
+
levels?: Level[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether the dropdown should hide when headings are not available.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hideWhenUnavailable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the currently active heading level from the available levels
|
|
24
|
+
*/
|
|
25
|
+
export declare function getActiveHeadingLevel(editor: Editor | null, levels?: Level[]): Level | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Custom hook that provides heading dropdown menu functionality for Tiptap editor
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Simple usage
|
|
32
|
+
* function MyHeadingDropdown() {
|
|
33
|
+
* const {
|
|
34
|
+
* isVisible,
|
|
35
|
+
* activeLevel,
|
|
36
|
+
* isAnyHeadingActive,
|
|
37
|
+
* canToggle,
|
|
38
|
+
* levels,
|
|
39
|
+
* } = useHeadingDropdownMenu()
|
|
40
|
+
*
|
|
41
|
+
* if (!isVisible) return null
|
|
42
|
+
*
|
|
43
|
+
* return (
|
|
44
|
+
* <DropdownMenu>
|
|
45
|
+
* // dropdown content
|
|
46
|
+
* </DropdownMenu>
|
|
47
|
+
* )
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* // Advanced usage with configuration
|
|
51
|
+
* function MyAdvancedHeadingDropdown() {
|
|
52
|
+
* const {
|
|
53
|
+
* isVisible,
|
|
54
|
+
* activeLevel,
|
|
55
|
+
* } = useHeadingDropdownMenu({
|
|
56
|
+
* editor: myEditor,
|
|
57
|
+
* levels: [1, 2, 3],
|
|
58
|
+
* hideWhenUnavailable: true,
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
61
|
+
* // component implementation
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useHeadingDropdownMenu(config?: UseHeadingDropdownMenuConfig): {
|
|
66
|
+
isVisible: boolean;
|
|
67
|
+
activeLevel: Level | undefined;
|
|
68
|
+
isActive: boolean;
|
|
69
|
+
canToggle: boolean;
|
|
70
|
+
levels: Level[];
|
|
71
|
+
label: string;
|
|
72
|
+
Icon: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
73
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { UseImageUploadConfig } from "@/components/tiptap-ui/image-upload-button";
|
|
2
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
3
|
+
type IconProps = React.SVGProps<SVGSVGElement>;
|
|
4
|
+
type IconComponent = ({ className, ...props }: IconProps) => React.ReactElement;
|
|
5
|
+
export interface ImageUploadButtonProps extends Omit<ButtonProps, "type">, UseImageUploadConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Optional text to display alongside the icon.
|
|
8
|
+
*/
|
|
9
|
+
text?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional show shortcut keys in the button.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
showShortcut?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Optional custom icon component to render instead of the default.
|
|
17
|
+
*/
|
|
18
|
+
icon?: React.MemoExoticComponent<IconComponent> | React.FC<IconProps>;
|
|
19
|
+
}
|
|
20
|
+
export declare function ImageShortcutBadge({ shortcutKeys, }: {
|
|
21
|
+
shortcutKeys?: string;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Button component for uploading/inserting images in a Tiptap editor.
|
|
25
|
+
*
|
|
26
|
+
* For custom button implementations, use the `useImage` hook instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ImageUploadButton: import("react").ForwardRefExoticComponent<ImageUploadButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type Editor } from "@tiptap/react";
|
|
2
|
+
export declare const IMAGE_UPLOAD_SHORTCUT_KEY = "mod+shift+i";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the image upload functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseImageUploadConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Tiptap editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button should hide when insertion is not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called after a successful image insertion.
|
|
18
|
+
*/
|
|
19
|
+
onInserted?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if image can be inserted in the current editor state
|
|
23
|
+
*/
|
|
24
|
+
export declare function canInsertImage(editor: Editor | null): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if image is currently active
|
|
27
|
+
*/
|
|
28
|
+
export declare function isImageActive(editor: Editor | null): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Inserts an image in the editor
|
|
31
|
+
*/
|
|
32
|
+
export declare function insertImage(editor: Editor | null): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Determines if the image button should be shown
|
|
35
|
+
*/
|
|
36
|
+
export declare function shouldShowButton(props: {
|
|
37
|
+
editor: Editor | null;
|
|
38
|
+
hideWhenUnavailable: boolean;
|
|
39
|
+
}): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook that provides image functionality for Tiptap editor
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // Simple usage - no params needed
|
|
46
|
+
* function MySimpleImageButton() {
|
|
47
|
+
* const { isVisible, handleImage } = useImage()
|
|
48
|
+
*
|
|
49
|
+
* if (!isVisible) return null
|
|
50
|
+
*
|
|
51
|
+
* return <button onClick={handleImage}>Add Image</button>
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Advanced usage with configuration
|
|
55
|
+
* function MyAdvancedImageButton() {
|
|
56
|
+
* const { isVisible, handleImage, label, isActive } = useImage({
|
|
57
|
+
* editor: myEditor,
|
|
58
|
+
* hideWhenUnavailable: true,
|
|
59
|
+
* onInserted: () => console.log('Image inserted!')
|
|
60
|
+
* })
|
|
61
|
+
*
|
|
62
|
+
* if (!isVisible) return null
|
|
63
|
+
*
|
|
64
|
+
* return (
|
|
65
|
+
* <MyButton
|
|
66
|
+
* onClick={handleImage}
|
|
67
|
+
* aria-pressed={isActive}
|
|
68
|
+
* aria-label={label}
|
|
69
|
+
* >
|
|
70
|
+
* Add Image
|
|
71
|
+
* </MyButton>
|
|
72
|
+
* )
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function useImageUpload(config?: UseImageUploadConfig): {
|
|
77
|
+
isVisible: boolean;
|
|
78
|
+
isActive: boolean;
|
|
79
|
+
handleImage: () => boolean;
|
|
80
|
+
canInsert: boolean;
|
|
81
|
+
label: string;
|
|
82
|
+
shortcutKeys: string;
|
|
83
|
+
Icon: import("react").MemoExoticComponent<({ className, ...props }: Omit<import("react").SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
84
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
import type { UseLinkPopoverConfig } from "@/components/tiptap-ui/link-popover";
|
|
3
|
+
import type { ButtonProps } from "@/components/tiptap-ui-primitive/button";
|
|
4
|
+
import "./link-popover.scss";
|
|
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: import("react").ForwardRefExoticComponent<ButtonProps & import("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: import("react").ForwardRefExoticComponent<LinkPopoverProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
58
|
+
export default LinkPopover;
|