planet-editor 0.1.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/LICENSE +24 -0
- package/README.md +129 -0
- package/THIRD-PARTY-LICENSES.md +76 -0
- package/dist/lib/components/planet-extension/node-background-extension.d.ts +23 -0
- package/dist/lib/components/planet-extension/search-extension.d.ts +39 -0
- package/dist/lib/components/planet-icons/align-center-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-justify-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/align-right-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/arrow-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/ban-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/blockquote-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/bold-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/check-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/chevron-down-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/close-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/code-block-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/code2-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/external-link-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-five-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-four-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-one-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-six-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-three-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/heading-two-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/highlighter-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/image-plus-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/italic-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/line-numbers-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/link-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-ordered-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/list-todo-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/moon-star-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/redo2-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/search-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/strike-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/subscript-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/sun-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/superscript-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/table-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/trash-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/underline-icon.d.ts +3 -0
- package/dist/lib/components/planet-icons/undo2-icon.d.ts +3 -0
- package/dist/lib/components/planet-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -0
- package/dist/lib/components/planet-node/image-node/resizable-image-extension.d.ts +10 -0
- package/dist/lib/components/planet-node/image-node/resizable-image-node-view.d.ts +7 -0
- package/dist/lib/components/planet-node/image-upload-node/image-upload-node-extension.d.ts +58 -0
- package/dist/lib/components/planet-node/image-upload-node/image-upload-node.d.ts +68 -0
- package/dist/lib/components/planet-node/image-upload-node/index.d.ts +1 -0
- package/dist/lib/components/planet-templates/simple/data/content.json.d.ts +479 -0
- package/dist/lib/components/planet-templates/simple/simple-editor.d.ts +31 -0
- package/dist/lib/components/planet-templates/simple/theme-toggle.d.ts +1 -0
- package/dist/lib/components/planet-ui/blockquote-button/blockquote-button.d.ts +22 -0
- package/dist/lib/components/planet-ui/blockquote-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/blockquote-button/use-blockquote.d.ts +80 -0
- package/dist/lib/components/planet-ui/code-block-button/code-block-button.d.ts +22 -0
- package/dist/lib/components/planet-ui/code-block-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/code-block-button/use-code-block.d.ts +87 -0
- package/dist/lib/components/planet-ui/color-highlight-button/color-highlight-button.d.ts +45 -0
- package/dist/lib/components/planet-ui/color-highlight-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/color-highlight-button/use-color-highlight.d.ts +93 -0
- package/dist/lib/components/planet-ui/color-highlight-popover/color-highlight-popover.d.ts +35 -0
- package/dist/lib/components/planet-ui/color-highlight-popover/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/font-size-dropdown-menu/font-size-dropdown-menu.d.ts +10 -0
- package/dist/lib/components/planet-ui/font-size-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/heading-button/heading-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/heading-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/heading-button/use-heading.d.ts +108 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +19 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
- package/dist/lib/components/planet-ui/image-upload-button/image-upload-button.d.ts +29 -0
- package/dist/lib/components/planet-ui/image-upload-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/image-upload-button/use-image-upload.d.ts +84 -0
- package/dist/lib/components/planet-ui/link-popover/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/link-popover/link-popover.d.ts +57 -0
- package/dist/lib/components/planet-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/lib/components/planet-ui/list-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/list-button/list-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/list-button/use-list.d.ts +97 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/list-dropdown-menu.d.ts +28 -0
- package/dist/lib/components/planet-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +90 -0
- package/dist/lib/components/planet-ui/mark-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/mark-button/mark-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/mark-button/use-mark.d.ts +104 -0
- package/dist/lib/components/planet-ui/search-bar/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/search-bar/search-bar.d.ts +11 -0
- package/dist/lib/components/planet-ui/table-dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui/table-dropdown-menu/table-dropdown-menu.d.ts +11 -0
- package/dist/lib/components/planet-ui/text-align-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/text-align-button/text-align-button.d.ts +30 -0
- package/dist/lib/components/planet-ui/text-align-button/use-text-align.d.ts +101 -0
- package/dist/lib/components/planet-ui/undo-redo-button/index.d.ts +2 -0
- package/dist/lib/components/planet-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
- package/dist/lib/components/planet-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
- package/dist/lib/components/planet-ui-primitive/badge/badge.d.ts +8 -0
- package/dist/lib/components/planet-ui-primitive/badge/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/button/button.d.ts +14 -0
- package/dist/lib/components/planet-ui-primitive/button/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/button-group/button-group.d.ts +10 -0
- package/dist/lib/components/planet-ui-primitive/button-group/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/card/card.d.ts +9 -0
- package/dist/lib/components/planet-ui-primitive/card/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/dropdown-menu/dropdown-menu.d.ts +28 -0
- package/dist/lib/components/planet-ui-primitive/dropdown-menu/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/input/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/input/input.d.ts +2 -0
- package/dist/lib/components/planet-ui-primitive/popover/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/popover/popover.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/separator/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/separator/separator.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/spacer/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/spacer/spacer.d.ts +5 -0
- package/dist/lib/components/planet-ui-primitive/toolbar/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/toolbar/toolbar.d.ts +8 -0
- package/dist/lib/components/planet-ui-primitive/tooltip/index.d.ts +1 -0
- package/dist/lib/components/planet-ui-primitive/tooltip/tooltip.d.ts +28 -0
- package/dist/lib/favicon.svg +1 -0
- package/dist/lib/hooks/use-composed-ref.d.ts +3 -0
- package/dist/lib/hooks/use-cursor-visibility.d.ts +20 -0
- package/dist/lib/hooks/use-element-rect.d.ts +35 -0
- package/dist/lib/hooks/use-is-breakpoint.d.ts +9 -0
- package/dist/lib/hooks/use-line-numbers.d.ts +15 -0
- package/dist/lib/hooks/use-menu-navigation.d.ts +52 -0
- package/dist/lib/hooks/use-planet-editor.d.ts +6 -0
- package/dist/lib/hooks/use-scrolling.d.ts +8 -0
- package/dist/lib/hooks/use-throttled-callback.d.ts +18 -0
- package/dist/lib/hooks/use-unmount.d.ts +7 -0
- package/dist/lib/hooks/use-window-size.d.ts +35 -0
- package/dist/lib/icons.svg +24 -0
- package/dist/lib/images/planet-ui-placeholder-image.svg +10 -0
- package/dist/lib/index.js +5102 -0
- package/dist/lib/lib/index.d.ts +2 -0
- package/dist/lib/lib/planet-utils.d.ts +173 -0
- package/dist/lib/lib/upload.d.ts +10 -0
- package/dist/lib/styles.css +2 -0
- package/dist/web-component/favicon.svg +1 -0
- package/dist/web-component/icons.svg +24 -0
- package/dist/web-component/images/planet-ui-placeholder-image.svg +10 -0
- package/dist/web-component/planet-editor.css +2 -0
- package/dist/web-component/planet-editor.html +224 -0
- package/dist/web-component/planet-editor.js +203 -0
- package/package.json +101 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseCodeBlockConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../planet-ui-primitive/button';
|
|
3
|
+
export interface CodeBlockButtonProps extends Omit<ButtonProps, "type">, UseCodeBlockConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Optional text to display alongside the icon.
|
|
6
|
+
*/
|
|
7
|
+
text?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Optional show shortcut keys in the button.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
showShortcut?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function CodeBlockShortcutBadge({ shortcutKeys, }: {
|
|
15
|
+
shortcutKeys?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Button component for toggling code block in a Planet editor.
|
|
19
|
+
*
|
|
20
|
+
* For custom button implementations, use the `useCodeBlock` hook instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CodeBlockButton: import('react').ForwardRefExoticComponent<CodeBlockButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Editor } from '../../../planet-core/react';
|
|
2
|
+
export declare const CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the code block functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseCodeBlockConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Planet editor instance.
|
|
9
|
+
*/
|
|
10
|
+
editor?: Editor | null;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button should hide when code block is not available.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
hideWhenUnavailable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called after a successful code block toggle.
|
|
18
|
+
*/
|
|
19
|
+
onToggled?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if code block can be toggled in the current editor state
|
|
23
|
+
*/
|
|
24
|
+
export declare function canToggle(editor: Editor | null, turnInto?: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Toggles code block in the editor
|
|
27
|
+
*/
|
|
28
|
+
export declare function toggleCodeBlock(editor: Editor | null): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Determines if the code block button should be shown
|
|
31
|
+
*/
|
|
32
|
+
export declare function shouldShowButton(props: {
|
|
33
|
+
editor: Editor | null;
|
|
34
|
+
hideWhenUnavailable: boolean;
|
|
35
|
+
}): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Custom hook that provides code block functionality for Planet editor
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Simple usage - no params needed
|
|
42
|
+
* function MySimpleCodeBlockButton() {
|
|
43
|
+
* const { isVisible, isActive, handleToggle } = useCodeBlock()
|
|
44
|
+
*
|
|
45
|
+
* if (!isVisible) return null
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <button
|
|
49
|
+
* onClick={handleToggle}
|
|
50
|
+
* aria-pressed={isActive}
|
|
51
|
+
* >
|
|
52
|
+
* Code Block
|
|
53
|
+
* </button>
|
|
54
|
+
* )
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Advanced usage with configuration
|
|
58
|
+
* function MyAdvancedCodeBlockButton() {
|
|
59
|
+
* const { isVisible, isActive, handleToggle, label } = useCodeBlock({
|
|
60
|
+
* editor: myEditor,
|
|
61
|
+
* hideWhenUnavailable: true,
|
|
62
|
+
* onToggled: (isActive) => console.log('Code block toggled:', isActive)
|
|
63
|
+
* })
|
|
64
|
+
*
|
|
65
|
+
* if (!isVisible) return null
|
|
66
|
+
*
|
|
67
|
+
* return (
|
|
68
|
+
* <MyButton
|
|
69
|
+
* onClick={handleToggle}
|
|
70
|
+
* aria-label={label}
|
|
71
|
+
* aria-pressed={isActive}
|
|
72
|
+
* >
|
|
73
|
+
* Toggle Code Block
|
|
74
|
+
* </MyButton>
|
|
75
|
+
* )
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function useCodeBlock(config?: UseCodeBlockConfig): {
|
|
80
|
+
isVisible: boolean;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
handleToggle: () => boolean;
|
|
83
|
+
canToggle: boolean;
|
|
84
|
+
label: string;
|
|
85
|
+
shortcutKeys: string;
|
|
86
|
+
Icon: import('react').MemoExoticComponent<({ className, ...props }: Omit<import('react').SVGProps<SVGSVGElement>, "ref">) => import("react").JSX.Element>;
|
|
87
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { UseColorHighlightConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../planet-ui-primitive/button';
|
|
3
|
+
export interface ColorHighlightButtonProps extends Omit<ButtonProps, "type">, UseColorHighlightConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Optional text to display alongside the icon.
|
|
6
|
+
*/
|
|
7
|
+
text?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Optional show shortcut keys in the button.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
showShortcut?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function ColorHighlightShortcutBadge({ shortcutKeys, }: {
|
|
15
|
+
shortcutKeys?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Button component for applying color highlights in a Planet editor.
|
|
19
|
+
*
|
|
20
|
+
* Supports two highlighting modes:
|
|
21
|
+
* - "mark": Uses the highlight mark extension (default)
|
|
22
|
+
* - "node": Uses the node background extension
|
|
23
|
+
*
|
|
24
|
+
* For custom button implementations, use the `useColorHighlight` hook instead.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Mark-based highlighting (default)
|
|
29
|
+
* <ColorHighlightButton highlightColor="yellow" />
|
|
30
|
+
*
|
|
31
|
+
* // Node-based background coloring
|
|
32
|
+
* <ColorHighlightButton
|
|
33
|
+
* highlightColor="var(--tt-color-highlight-blue)"
|
|
34
|
+
* mode="node"
|
|
35
|
+
* />
|
|
36
|
+
*
|
|
37
|
+
* // With custom callback
|
|
38
|
+
* <ColorHighlightButton
|
|
39
|
+
* highlightColor="red"
|
|
40
|
+
* mode="mark"
|
|
41
|
+
* onApplied={({ color, mode }) => console.log(`Applied ${color} in ${mode} mode`)}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const ColorHighlightButton: import('react').ForwardRefExoticComponent<ColorHighlightButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Editor } from '../../../planet-core/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 Planet 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 { Editor } from '../../../planet-core/react';
|
|
2
|
+
import { ButtonProps } from '../../planet-ui-primitive/button';
|
|
3
|
+
import { HighlightColor, UseColorHighlightConfig } from '../color-highlight-button';
|
|
4
|
+
export interface ColorHighlightPopoverContentProps {
|
|
5
|
+
/**
|
|
6
|
+
* The Planet 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,10 @@
|
|
|
1
|
+
import { Editor } from '../../../planet-core/react';
|
|
2
|
+
export interface FontSizeDropdownMenuProps {
|
|
3
|
+
editor?: Editor;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Toolbar dropdown for setting the font size. Pick a preset or type a custom
|
|
7
|
+
* value (in px) in the input at the top and press Enter to apply.
|
|
8
|
+
*/
|
|
9
|
+
export declare function FontSizeDropdownMenu({ editor: providedEditor, }: FontSizeDropdownMenuProps): import("react").JSX.Element | null;
|
|
10
|
+
export default FontSizeDropdownMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FontSizeDropdownMenu } from './font-size-dropdown-menu';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Level, UseHeadingConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../planet-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 Planet 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 { Editor } from '../../../planet-core/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 Planet 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 Planet 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 { UseHeadingDropdownMenuConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../planet-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 Planet 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 { Editor } from '../../../planet-core/react';
|
|
2
|
+
import { Level } from '../heading-button';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the heading dropdown menu functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface UseHeadingDropdownMenuConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The Planet 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 Planet 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 { UseImageUploadConfig } from '.';
|
|
2
|
+
import { ButtonProps } from '../../planet-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 Planet 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 { Editor } from '../../../planet-core/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 Planet 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 Planet 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
|
+
};
|