@veevarts/design-system 0.1.17 → 0.1.19
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/index.cjs +106 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17284 -153
- package/dist/patterns/RichText/RichText.d.ts +105 -0
- package/dist/patterns/RichText/RichText.test.d.ts +1 -0
- package/dist/patterns/RichText/TipTapArea/TipTapArea.d.ts +60 -0
- package/dist/patterns/RichText/commands/index.d.ts +5 -0
- package/dist/patterns/RichText/commands/registry.d.ts +14 -0
- package/dist/patterns/RichText/config/colors.d.ts +39 -0
- package/dist/patterns/RichText/config/defaults.d.ts +34 -0
- package/dist/patterns/RichText/config/icons.d.ts +26 -0
- package/dist/patterns/RichText/config/index.d.ts +7 -0
- package/dist/patterns/RichText/core/TipTapEditor.d.ts +7 -0
- package/dist/patterns/RichText/core/TipTapEditor.test.d.ts +1 -0
- package/dist/patterns/RichText/examples/ControlledExample.d.ts +1 -0
- package/dist/patterns/RichText/examples/FormWithValidationExample.d.ts +1 -0
- package/dist/patterns/RichText/extensions/index.d.ts +22 -0
- package/dist/patterns/RichText/extensions/registry.d.ts +19 -0
- package/dist/patterns/RichText/index.d.ts +11 -0
- package/dist/patterns/RichText/presets.d.ts +36 -0
- package/dist/patterns/RichText/toolbar/Toolbar.d.ts +34 -0
- package/dist/patterns/RichText/toolbar/ToolbarDivider.d.ts +15 -0
- package/dist/patterns/RichText/toolbar/ToolbarSection.d.ts +29 -0
- package/dist/patterns/RichText/toolbar/components/ColorPalette.d.ts +28 -0
- package/dist/patterns/RichText/toolbar/components/ColorPicker.d.ts +29 -0
- package/dist/patterns/RichText/toolbar/components/CustomColorInput.d.ts +28 -0
- package/dist/patterns/RichText/toolbar/components/HeadingDropdown.d.ts +21 -0
- package/dist/patterns/RichText/toolbar/components/ListDropdown.d.ts +20 -0
- package/dist/patterns/RichText/toolbar/components/ToolbarButton.d.ts +40 -0
- package/dist/patterns/RichText/toolbar/components/ZoomControls.d.ts +35 -0
- package/dist/patterns/RichText/toolbar/components/index.d.ts +17 -0
- package/dist/patterns/RichText/toolbar/hooks/index.d.ts +6 -0
- package/dist/patterns/RichText/toolbar/hooks/useToolbarCommands.d.ts +14 -0
- package/dist/patterns/RichText/toolbar/hooks/useToolbarState.d.ts +14 -0
- package/dist/patterns/RichText/toolbar/hooks/useZoomState.d.ts +21 -0
- package/dist/patterns/RichText/toolbar/index.d.ts +12 -0
- package/dist/patterns/RichText/toolbar/sections/TextFormattingSection.d.ts +7 -0
- package/dist/patterns/RichText/types/commands.d.ts +68 -0
- package/dist/patterns/RichText/types/extensions.d.ts +71 -0
- package/dist/patterns/RichText/types/index.d.ts +14 -0
- package/dist/patterns/RichText/types/marks.d.ts +86 -0
- package/dist/patterns/RichText/types/modifiers.d.ts +125 -0
- package/dist/patterns/RichText/types/nodes.d.ts +80 -0
- package/dist/patterns/RichText/types/props.d.ts +151 -0
- package/dist/patterns/RichText/types/toolbar.d.ts +88 -0
- package/dist/patterns/Stepper/Stepper.d.ts +2 -2
- package/dist/patterns/index.d.ts +2 -0
- package/package.json +15 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RichTextAreaProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @module RichTextArea
|
|
4
|
+
* @description A powerful WYSIWYG rich text editor built on TipTap/ProseMirror.
|
|
5
|
+
*
|
|
6
|
+
* The RichTextArea component provides a flexible and customizable rich text editing experience,
|
|
7
|
+
* allowing users to format content with various modifiers like bold, italic, headings, lists, and more.
|
|
8
|
+
* It's built with a modular architecture, type-safe modifiers, and integrates with HeroUI components.
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*
|
|
12
|
+
* @features
|
|
13
|
+
* - **Modular architecture**: Easily enable/disable formatting options (modifiers).
|
|
14
|
+
* - **Type-safe modifiers**: Ensures correct usage and configuration of formatting tools.
|
|
15
|
+
* - **Extensible**: Built on TipTap, allowing for custom extensions and functionality.
|
|
16
|
+
* - **Controlled & uncontrolled modes**: Supports both controlled and uncontrolled usage patterns.
|
|
17
|
+
* - **Customizable UI**: Integrates with HeroUI for consistent styling and theming.
|
|
18
|
+
* - **Word and character count**: Optional display of content statistics.
|
|
19
|
+
* - **Zoom controls**: Adjust editor font size for better readability.
|
|
20
|
+
*
|
|
21
|
+
* @accessibility
|
|
22
|
+
* - Semantic HTML structure for editor content.
|
|
23
|
+
* - Keyboard navigation support for toolbar and editor content.
|
|
24
|
+
* - ARIA attributes for enhanced screen reader compatibility (inherited from TipTap/ProseMirror).
|
|
25
|
+
*
|
|
26
|
+
* @performance
|
|
27
|
+
* - Lazy loading of animations (if applicable, though not directly in this wrapper).
|
|
28
|
+
* - Efficient rendering due to TipTap's ProseMirror foundation.
|
|
29
|
+
* - Memoization for extension creation and other heavy computations.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Basic usage with default modifiers
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <RichTextArea
|
|
35
|
+
* label="Content"
|
|
36
|
+
* placeholder="Start typing..."
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // With specific modifiers
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <RichTextArea
|
|
44
|
+
* modifiers={['bold', 'italic', { type: 'heading', level: 2 }, 'bulletList']}
|
|
45
|
+
* label="Blog Post"
|
|
46
|
+
* placeholder="Write your blog post here..."
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Using a preset (e.g., for a blog)
|
|
52
|
+
* ```tsx
|
|
53
|
+
* import { RICH_TEXT_PRESETS } from '@veevarts/design-system';
|
|
54
|
+
*
|
|
55
|
+
* <RichTextArea
|
|
56
|
+
* modifiers={RICH_TEXT_PRESETS.blog}
|
|
57
|
+
* label="Article Body"
|
|
58
|
+
* placeholder="Compose your article..."
|
|
59
|
+
* />
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Controlled component
|
|
64
|
+
* ```tsx
|
|
65
|
+
* import React, { useState } from 'react';
|
|
66
|
+
* import { RichTextArea } from '@veevarts/design-system';
|
|
67
|
+
*
|
|
68
|
+
* function MyControlledEditor() {
|
|
69
|
+
* const [content, setContent] = useState('<p>Hello <strong>world</strong>!</p>');
|
|
70
|
+
*
|
|
71
|
+
* return (
|
|
72
|
+
* <RichTextArea
|
|
73
|
+
* content={content}
|
|
74
|
+
* onContentChange={(editorContent) => setContent(editorContent.html)}
|
|
75
|
+
* label="Controlled Content"
|
|
76
|
+
* />
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // With word and character count
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <RichTextArea
|
|
85
|
+
* label="Description"
|
|
86
|
+
* showWordCount
|
|
87
|
+
* showCharacterCount
|
|
88
|
+
* minRows={5}
|
|
89
|
+
* />
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Read-only mode
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <RichTextArea
|
|
96
|
+
* isReadOnly
|
|
97
|
+
* initialContent="<p>This is <strong>read-only</strong> content.</p>"
|
|
98
|
+
* label="Preview"
|
|
99
|
+
* />
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @see {@link RichTextAreaProps} for all available props
|
|
103
|
+
* @see {@link https://tiptap.dev/docs/editor/api/editor Tiptap Editor API} for underlying editor functionality
|
|
104
|
+
*/
|
|
105
|
+
export declare const RichTextArea: import('react').ForwardRefExoticComponent<Omit<RichTextAreaProps, "ref"> & import('react').RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { default as React, ComponentProps } from 'react';
|
|
2
|
+
import { Textarea } from '@heroui/react';
|
|
3
|
+
export type TextareaHeightChangeMeta = {
|
|
4
|
+
rowHeight: number;
|
|
5
|
+
};
|
|
6
|
+
export interface RichTextAreaProps extends Omit<ComponentProps<typeof Textarea>, 'children'> {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the textarea should automatically grow vertically to accomodate content.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
disableAutosize?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Minimum number of rows to show for textarea
|
|
14
|
+
* @default 3
|
|
15
|
+
*/
|
|
16
|
+
minRows?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of rows up to which the textarea can grow
|
|
19
|
+
* @default 8
|
|
20
|
+
*/
|
|
21
|
+
maxRows?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Reuse previously computed measurements when computing height of textarea.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
cacheMeasurements?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Function invoked on textarea height change, with height as first argument.
|
|
29
|
+
* The second function argument is an object containing additional information that
|
|
30
|
+
* might be useful for custom behaviors. Current options include `{ rowHeight: number }`.
|
|
31
|
+
*
|
|
32
|
+
* @param height - The height of the textarea
|
|
33
|
+
* @param meta - Additional information about the height change
|
|
34
|
+
*/
|
|
35
|
+
onHeightChange?: (height: number, meta: TextareaHeightChangeMeta) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Active formatting modifiers to show in toolbar
|
|
38
|
+
*/
|
|
39
|
+
activeModifiers?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Show character count below editor
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
showCharacterCount?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Show word count below editor
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
showWordCount?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Maximum character limit
|
|
52
|
+
*/
|
|
53
|
+
maxCharacters?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Maximum word limit
|
|
56
|
+
*/
|
|
57
|
+
maxWords?: number;
|
|
58
|
+
}
|
|
59
|
+
export declare const TipTapArea: React.ForwardRefExoticComponent<Omit<RichTextAreaProps, "ref"> & React.RefAttributes<unknown>>;
|
|
60
|
+
export default TipTapArea;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandRegistry } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Complete command registry
|
|
4
|
+
* Each modifier maps to execute, canExecute, and isActive functions
|
|
5
|
+
*/
|
|
6
|
+
export declare const commandRegistry: CommandRegistry;
|
|
7
|
+
/**
|
|
8
|
+
* Get command definition for a modifier type
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCommand(modifierType: string): import('.').CommandDefinition | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a command exists for a modifier type
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasCommand(modifierType: string): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Color Configuration
|
|
3
|
+
*
|
|
4
|
+
* Predefined color palettes for text color and highlight/background.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Text color palette
|
|
8
|
+
* Professional color set for text formatting
|
|
9
|
+
*/
|
|
10
|
+
export declare const TEXT_COLORS: readonly ["#000000", "#374151", "#6B7280", "#EF4444", "#F59E0B", "#10B981", "#3B82F6", "#8B5CF6", "#EC4899", "#14B8A6", "#F97316", "#A855F7"];
|
|
11
|
+
/**
|
|
12
|
+
* Highlight/background color palette
|
|
13
|
+
* Light colors suitable for text highlighting
|
|
14
|
+
*/
|
|
15
|
+
export declare const HIGHLIGHT_COLORS: readonly ["#FEF3C7", "#DBEAFE", "#D1FAE5", "#FCE7F3", "#E0E7FF", "#FED7AA", "#F3E8FF", "#CCFBF1", "#FEE2E2", "#E5E7EB", "#FAE8FF", "#BFDBFE"];
|
|
16
|
+
/**
|
|
17
|
+
* Type-safe text color
|
|
18
|
+
*/
|
|
19
|
+
export type TextColor = (typeof TEXT_COLORS)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Type-safe highlight color
|
|
22
|
+
*/
|
|
23
|
+
export type HighlightColor = (typeof HIGHLIGHT_COLORS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* Check if a color is in the text colors palette
|
|
26
|
+
*/
|
|
27
|
+
export declare function isTextColor(color: string): color is TextColor;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a color is in the highlight colors palette
|
|
30
|
+
*/
|
|
31
|
+
export declare function isHighlightColor(color: string): color is HighlightColor;
|
|
32
|
+
/**
|
|
33
|
+
* Validate hex color format
|
|
34
|
+
*/
|
|
35
|
+
export declare function isValidHexColor(color: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get contrasting text color (black or white) for a background color
|
|
38
|
+
*/
|
|
39
|
+
export declare function getContrastColor(hexColor: string): '#000000' | '#FFFFFF';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ModifierIdentifier } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Default editor props
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_EDITOR_PROPS: {
|
|
6
|
+
readonly adapter: "tiptap";
|
|
7
|
+
readonly variant: "bordered";
|
|
8
|
+
readonly minRows: 3;
|
|
9
|
+
readonly maxRows: 8;
|
|
10
|
+
readonly disableAutosize: false;
|
|
11
|
+
readonly showToolbar: true;
|
|
12
|
+
readonly showCharacterCount: false;
|
|
13
|
+
readonly showWordCount: false;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Default modifiers (minimal editing capability)
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_MODIFIERS: ModifierIdentifier[];
|
|
19
|
+
/**
|
|
20
|
+
* Zoom configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare const ZOOM_CONFIG: {
|
|
23
|
+
readonly min: 50;
|
|
24
|
+
readonly max: 200;
|
|
25
|
+
readonly step: 10;
|
|
26
|
+
readonly default: 100;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Editor height configuration (pixels per row)
|
|
30
|
+
*/
|
|
31
|
+
export declare const EDITOR_HEIGHT_CONFIG: {
|
|
32
|
+
readonly lineHeight: 24;
|
|
33
|
+
readonly toolbarHeight: 60;
|
|
34
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LucideIcon } from 'lucide-react';
|
|
2
|
+
import { ModifierType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Icon map for all modifier types
|
|
5
|
+
*/
|
|
6
|
+
export declare const MODIFIER_ICONS: Record<ModifierType, LucideIcon>;
|
|
7
|
+
/**
|
|
8
|
+
* Alignment-specific icons
|
|
9
|
+
*/
|
|
10
|
+
export declare const ALIGNMENT_ICONS: {
|
|
11
|
+
readonly left: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
12
|
+
readonly center: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
13
|
+
readonly right: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
14
|
+
readonly justify: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Zoom control icons
|
|
18
|
+
*/
|
|
19
|
+
export declare const ZOOM_ICONS: {
|
|
20
|
+
readonly in: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
21
|
+
readonly out: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Get icon for a modifier type
|
|
25
|
+
*/
|
|
26
|
+
export declare function getModifierIcon(modifier: ModifierType): LucideIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Configuration Exports
|
|
3
|
+
*/
|
|
4
|
+
export { TEXT_COLORS, HIGHLIGHT_COLORS, isTextColor, isHighlightColor, isValidHexColor, getContrastColor, } from './colors';
|
|
5
|
+
export type { TextColor, HighlightColor } from './colors';
|
|
6
|
+
export { DEFAULT_EDITOR_PROPS, DEFAULT_MODIFIERS, ZOOM_CONFIG, EDITOR_HEIGHT_CONFIG } from './defaults';
|
|
7
|
+
export { MODIFIER_ICONS, ALIGNMENT_ICONS, ZOOM_ICONS, getModifierIcon } from './icons';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TipTapEditorProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* TipTap Editor Component (Refactored)
|
|
5
|
+
*/
|
|
6
|
+
export declare const TipTapEditor: React.ForwardRefExoticComponent<Omit<TipTapEditorProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
7
|
+
export default TipTapEditor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ControlledExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FormWithValidationExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Extensions } from '@tiptap/react';
|
|
2
|
+
import { ModifierIdentifier, ModifierType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates TipTap extensions array from modifier identifiers
|
|
5
|
+
*
|
|
6
|
+
* @param modifiers - Array of modifier identifiers to enable
|
|
7
|
+
* @returns Configured array of TipTap extensions
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const extensions = createExtensions(['bold', 'italic', { type: 'heading', level: 2 }]);
|
|
11
|
+
*/
|
|
12
|
+
export declare function createExtensions(modifiers: ModifierIdentifier[]): Extensions;
|
|
13
|
+
/**
|
|
14
|
+
* Get all available modifier types that have extensions installed
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAvailableModifiers(): ModifierType[];
|
|
17
|
+
/**
|
|
18
|
+
* Check if a modifier is available (extension installed)
|
|
19
|
+
*/
|
|
20
|
+
export declare function isModifierAvailable(modifierType: ModifierType): boolean;
|
|
21
|
+
export { getExtensionConfig, hasExtension } from './registry';
|
|
22
|
+
export { extensionRegistry, helperExtensions } from './registry';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ExtensionRegistry } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Complete extension registry
|
|
4
|
+
* Maps each modifier type to its TipTap extension configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare const extensionRegistry: ExtensionRegistry;
|
|
7
|
+
/**
|
|
8
|
+
* Helper extensions that are always required
|
|
9
|
+
* These are fundamental to the editor but not exposed as modifiers
|
|
10
|
+
*/
|
|
11
|
+
export declare const helperExtensions: (import('@tiptap/core').Node<any, any> | import('@tiptap/core').Extension<any, any> | import('@tiptap/core').Mark<import('@tiptap/extension-text-style').TextStyleOptions, any>)[];
|
|
12
|
+
/**
|
|
13
|
+
* Get extension config for a modifier type
|
|
14
|
+
*/
|
|
15
|
+
export declare function getExtensionConfig(modifierType: string): import('../types').ExtensionConfig<any> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a modifier has an extension configured
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasExtension(modifierType: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Public API Exports
|
|
3
|
+
*/
|
|
4
|
+
export { RichTextArea } from './RichText';
|
|
5
|
+
export type { RichTextAreaProps, EditorContentProps, EditorCounterProps, TipTapEditorProps } from './types';
|
|
6
|
+
export { RICH_TEXT_PRESETS, getPreset } from './presets';
|
|
7
|
+
export type { PresetName } from './presets';
|
|
8
|
+
export type { ModifierIdentifier, ModifierType, HeadingLevel, TextAlignment, HeadingModifier, TextAlignModifier, TextColorModifier, HighlightModifier, LinkModifier, EditorContent, } from './types';
|
|
9
|
+
export { isHeadingModifier, isTextAlignModifier, isTextColorModifier, isHighlightModifier, isLinkModifier, getModifierType, } from './types';
|
|
10
|
+
export { TEXT_COLORS, HIGHLIGHT_COLORS } from './config';
|
|
11
|
+
export type { TextColor, HighlightColor } from './config';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ModifierIdentifier } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Preset configurations for common editor use cases
|
|
4
|
+
*/
|
|
5
|
+
export declare const RICH_TEXT_PRESETS: {
|
|
6
|
+
/**
|
|
7
|
+
* Simple editor with basic formatting
|
|
8
|
+
* Includes: bold, italic, lists, undo/redo
|
|
9
|
+
*/
|
|
10
|
+
readonly simple: ModifierIdentifier[];
|
|
11
|
+
/**
|
|
12
|
+
* Blog post editor with essential formatting
|
|
13
|
+
* Includes: text formatting, headings (H2, H3), alignment, lists, links, quotes, undo/redo
|
|
14
|
+
*/
|
|
15
|
+
readonly blog: ModifierIdentifier[];
|
|
16
|
+
/**
|
|
17
|
+
* Documentation editor with ALL features
|
|
18
|
+
* Includes: all formatting options (same as full preset)
|
|
19
|
+
*/
|
|
20
|
+
readonly documentation: ModifierIdentifier[];
|
|
21
|
+
/**
|
|
22
|
+
* Comment editor with minimal formatting
|
|
23
|
+
* Includes: bold, italic, link, undo/redo
|
|
24
|
+
*/
|
|
25
|
+
readonly comment: ModifierIdentifier[];
|
|
26
|
+
/**
|
|
27
|
+
* Full editor with all features
|
|
28
|
+
* Includes: all formatting options
|
|
29
|
+
*/
|
|
30
|
+
readonly full: ModifierIdentifier[];
|
|
31
|
+
};
|
|
32
|
+
export type PresetName = keyof typeof RICH_TEXT_PRESETS;
|
|
33
|
+
/**
|
|
34
|
+
* Get preset configuration by name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPreset(name: PresetName): ModifierIdentifier[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { ModifierIdentifier } from '../types';
|
|
3
|
+
export interface ToolbarProps {
|
|
4
|
+
/**
|
|
5
|
+
* TipTap editor instance
|
|
6
|
+
*/
|
|
7
|
+
editor: Editor | null;
|
|
8
|
+
/**
|
|
9
|
+
* Active modifiers
|
|
10
|
+
*/
|
|
11
|
+
modifiers: ModifierIdentifier[];
|
|
12
|
+
/**
|
|
13
|
+
* Current zoom level
|
|
14
|
+
*/
|
|
15
|
+
zoom?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Callback when zoom changes
|
|
18
|
+
*/
|
|
19
|
+
onZoomChange?: (zoom: number) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether toolbar should stick to top
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
sticky?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Custom class name
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Main toolbar component
|
|
32
|
+
* Renders all toolbar sections based on active modifiers
|
|
33
|
+
*/
|
|
34
|
+
export declare function Toolbar({ editor, modifiers, zoom, onZoomChange, sticky, className }: ToolbarProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Toolbar Divider Component
|
|
3
|
+
*
|
|
4
|
+
* Visual separator between toolbar sections.
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolbarDividerProps {
|
|
7
|
+
/**
|
|
8
|
+
* Custom class name
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Vertical divider for toolbar sections
|
|
14
|
+
*/
|
|
15
|
+
export declare function ToolbarDivider({ className }: ToolbarDividerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface ToolbarSectionProps {
|
|
3
|
+
/**
|
|
4
|
+
* Section content (toolbar buttons)
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Section identifier (for accessibility)
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional section label (for screen readers)
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom class name
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to wrap buttons in a ButtonGroup
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
useButtonGroup?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Toolbar section component
|
|
27
|
+
* Groups related buttons together
|
|
28
|
+
*/
|
|
29
|
+
export declare function ToolbarSection({ children, id, label, className, useButtonGroup }: ToolbarSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Color Palette Component
|
|
3
|
+
*
|
|
4
|
+
* Grid of color circles for quick color selection.
|
|
5
|
+
*/
|
|
6
|
+
export interface ColorPaletteProps {
|
|
7
|
+
/**
|
|
8
|
+
* Array of hex color codes to display
|
|
9
|
+
*/
|
|
10
|
+
colors: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Currently selected color (optional)
|
|
13
|
+
*/
|
|
14
|
+
selectedColor?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Callback when a color is selected
|
|
17
|
+
*/
|
|
18
|
+
onColorSelect: (color: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Number of columns in the grid
|
|
21
|
+
* @default 4
|
|
22
|
+
*/
|
|
23
|
+
columns?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Color palette with circular color swatches
|
|
27
|
+
*/
|
|
28
|
+
export declare function ColorPalette({ colors, selectedColor, onColorSelect, columns }: ColorPaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export interface ColorPickerProps {
|
|
3
|
+
/**
|
|
4
|
+
* TipTap editor instance
|
|
5
|
+
*/
|
|
6
|
+
editor: Editor;
|
|
7
|
+
/**
|
|
8
|
+
* Color type (text color or highlight)
|
|
9
|
+
*/
|
|
10
|
+
type: 'textColor' | 'highlight';
|
|
11
|
+
/**
|
|
12
|
+
* Whether to allow custom color input
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
allowCustomColor?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Button label
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the button is disabled
|
|
22
|
+
*/
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hybrid color picker component
|
|
27
|
+
* Combines predefined palette with custom color input
|
|
28
|
+
*/
|
|
29
|
+
export declare function ColorPicker({ editor, type, allowCustomColor, label, isDisabled }: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich Text Editor - Custom Color Input Component
|
|
3
|
+
*
|
|
4
|
+
* Input field for entering custom hex color codes.
|
|
5
|
+
*/
|
|
6
|
+
export interface CustomColorInputProps {
|
|
7
|
+
/**
|
|
8
|
+
* Current color value
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
/**
|
|
12
|
+
* Callback when value changes
|
|
13
|
+
*/
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Callback when color is applied
|
|
17
|
+
*/
|
|
18
|
+
onApply: (color: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Placeholder text
|
|
21
|
+
* @default '#000000'
|
|
22
|
+
*/
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Custom color input with hex validation
|
|
27
|
+
*/
|
|
28
|
+
export declare function CustomColorInput({ value, onChange, onApply, placeholder }: CustomColorInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { HeadingLevel } from '../../types';
|
|
3
|
+
export interface HeadingDropdownProps {
|
|
4
|
+
/**
|
|
5
|
+
* TipTap editor instance
|
|
6
|
+
*/
|
|
7
|
+
editor: Editor;
|
|
8
|
+
/**
|
|
9
|
+
* Available heading levels to show
|
|
10
|
+
* @default [1, 2, 3, 4, 5, 6]
|
|
11
|
+
*/
|
|
12
|
+
levels?: HeadingLevel[];
|
|
13
|
+
/**
|
|
14
|
+
* Whether the dropdown is disabled
|
|
15
|
+
*/
|
|
16
|
+
isDisabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Heading level selector dropdown
|
|
20
|
+
*/
|
|
21
|
+
export declare function HeadingDropdown({ editor, levels, isDisabled }: HeadingDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export interface ListDropdownProps {
|
|
3
|
+
/**
|
|
4
|
+
* TipTap editor instance
|
|
5
|
+
*/
|
|
6
|
+
editor: Editor;
|
|
7
|
+
/**
|
|
8
|
+
* Available list types to show
|
|
9
|
+
* @default ['bulletList', 'orderedList', 'taskList']
|
|
10
|
+
*/
|
|
11
|
+
types?: Array<'bulletList' | 'orderedList' | 'taskList'>;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the dropdown is disabled
|
|
14
|
+
*/
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* List type selector dropdown
|
|
19
|
+
*/
|
|
20
|
+
export declare function ListDropdown({ editor, types, isDisabled, }: ListDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LucideIcon } from 'lucide-react';
|
|
2
|
+
export interface ToolbarButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* Icon component to display
|
|
5
|
+
*/
|
|
6
|
+
icon: LucideIcon;
|
|
7
|
+
/**
|
|
8
|
+
* Button label (used for tooltip and accessibility)
|
|
9
|
+
*/
|
|
10
|
+
label: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button represents an active state
|
|
13
|
+
*/
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the button is disabled
|
|
17
|
+
*/
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Click handler
|
|
21
|
+
*/
|
|
22
|
+
onClick: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Optional keyboard shortcut to display in tooltip
|
|
25
|
+
*/
|
|
26
|
+
shortcut?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Icon size in pixels
|
|
29
|
+
* @default 16
|
|
30
|
+
*/
|
|
31
|
+
iconSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Custom class name
|
|
34
|
+
*/
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Standard toolbar button component
|
|
39
|
+
*/
|
|
40
|
+
export declare function ToolbarButton({ icon: Icon, label, isActive, isDisabled, onClick, shortcut, iconSize, className, }: ToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|