@pixpilot/shadcn-ui 0.32.0 → 0.34.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/dist/file-upload/FileUpload.d.cts +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/input/Input.d.cts +2 -2
- package/dist/rich-text-editor/RichTextEditor.cjs +26 -31
- package/dist/rich-text-editor/RichTextEditor.d.cts +39 -12
- package/dist/rich-text-editor/RichTextEditor.d.ts +39 -12
- package/dist/rich-text-editor/RichTextEditor.js +25 -30
- package/dist/rich-text-editor/ToolbarButton.cjs +50 -0
- package/dist/rich-text-editor/ToolbarButton.js +46 -0
- package/dist/rich-text-editor/index.d.cts +1 -1
- package/dist/rich-text-editor/index.d.ts +1 -1
- package/dist/rich-text-editor/{predefined-toolbar-options.cjs → predefined-toolbar-items.cjs} +3 -3
- package/dist/rich-text-editor/{predefined-toolbar-options.js → predefined-toolbar-items.js} +3 -3
- package/dist/theme-toggle/ThemeModeDropdown.d.ts +2 -2
- package/dist/theme-toggle/ThemeModeSwitchInside.d.ts +2 -2
- package/dist/theme-toggle/ThemeModeSwitchOutside.d.ts +2 -2
- package/dist/theme-toggle/ThemeModeToggleButton.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileUploadProps } from "./types/index.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/file-upload/FileUpload.d.ts
|
|
5
|
-
declare function FileUpload(props: FileUploadProps):
|
|
5
|
+
declare function FileUpload(props: FileUploadProps): react_jsx_runtime7.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { FileUpload };
|
package/dist/index.d.cts
CHANGED
|
@@ -40,7 +40,7 @@ import "./layout/index.cjs";
|
|
|
40
40
|
import { LoaderProps, LoadingOverlay } from "./LoadingOverlay.cjs";
|
|
41
41
|
import { Pagination, PaginationProps } from "./pagination/Pagination.cjs";
|
|
42
42
|
import "./pagination/index.cjs";
|
|
43
|
-
import { RichTextEditor, RichTextEditorProps,
|
|
43
|
+
import { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems } from "./rich-text-editor/RichTextEditor.cjs";
|
|
44
44
|
import "./rich-text-editor/index.cjs";
|
|
45
45
|
import { ScaledPreview, ScaledPreviewProps, ScaledPreviewSize } from "./ScaledPreview.cjs";
|
|
46
46
|
import { Select, SelectOption } from "./Select.cjs";
|
|
@@ -67,4 +67,4 @@ import { DEFAULT_ALERT_DURATION, ToastMessage, toast, toastError, toastInfo, toa
|
|
|
67
67
|
import { Toaster } from "./toast/ToastProvider.cjs";
|
|
68
68
|
import "./toast/index.cjs";
|
|
69
69
|
import { cn } from "@pixpilot/shadcn";
|
|
70
|
-
export { AbsoluteFill, Alert, AlertBaseProps, AlertProps, AlertVariant, AvatarUpload, AvatarUploadProps, BaseTabsTriggerProps, Button, ButtonLoaderProps, ButtonProps, CircleLoader, CircleLoaderProps, CloseButtonAbsolute, CloseButtonRounded, CloseButtonRoundedProps, ColorPicker, ColorPickerBase, ColorPickerBaseProps, ColorPickerBaseSection, ColorPickerProps, ColorSelect, ColorSelectOption, BaseColorSelectProps as ColorSelectProps, Combobox, ConfirmationDialogProps, ContentCard, DEFAULT_ALERT_DURATION, DatePicker, DatePickerProps, DialogProvider, DialogProviderProps, type FileMetadata, FileUpload, FileUploadBaseProps, FileUploadInline, FileUploadInlineBaseProps, FileUploadInlineProps, type FileUploadProgressCallBacks, type FileUploadProps, IconPicker, IconPickerProps, IconPickerVariant, IconProvider, IconProviderLoader, IconProviderProps, Input, InputProps, Layout, LayoutFooter, LayoutFooterProps, LayoutHeader, LayoutHeaderProps, LayoutMain, LayoutMainProps, LayoutProps, LoaderProps, LoadingOverlay, MultiFileUploadProps, OnChangeMultipleFiles, OnChangeSingleFile, Pagination, PaginationProps, PopoverCloseButtonProps, PresetColor, RichTextEditor, RichTextEditorProps, ScaledPreview, ScaledPreviewProps, ScaledPreviewSize, Select, SelectOption, SingleFileUploadProps, Slider, SliderInput, SliderInputProps, SliderProps, SliderSelect, SliderSelectOption, SliderSelectProps, SliderSelectValue, Tabs, TabsContent, TabsContext, TabsContextValue, TabsList, TabsListProps, TabsTrigger, TabsTriggerProps, TabsVariant, TagsInput, TagsInputProps, ThemeModeDropdown, ThemeModeDropdownProps, ThemeModeSwitchInside, ThemeModeSwitchInsideProps, ThemeModeSwitchInsideSize, ThemeModeSwitchOutside, ThemeModeSwitchOutsideProps, ThemeModeToggleButton, ThemeModeToggleButtonProps, ThemeProvider, ThemeProviderProps, ToastMessage, Toaster,
|
|
70
|
+
export { AbsoluteFill, Alert, AlertBaseProps, AlertProps, AlertVariant, AvatarUpload, AvatarUploadProps, BaseTabsTriggerProps, Button, ButtonLoaderProps, ButtonProps, CircleLoader, CircleLoaderProps, CloseButtonAbsolute, CloseButtonRounded, CloseButtonRoundedProps, ColorPicker, ColorPickerBase, ColorPickerBaseProps, ColorPickerBaseSection, ColorPickerProps, ColorSelect, ColorSelectOption, BaseColorSelectProps as ColorSelectProps, Combobox, ConfirmationDialogProps, ContentCard, DEFAULT_ALERT_DURATION, DatePicker, DatePickerProps, DialogProvider, DialogProviderProps, type FileMetadata, FileUpload, FileUploadBaseProps, FileUploadInline, FileUploadInlineBaseProps, FileUploadInlineProps, type FileUploadProgressCallBacks, type FileUploadProps, IconPicker, IconPickerProps, IconPickerVariant, IconProvider, IconProviderLoader, IconProviderProps, Input, InputProps, Layout, LayoutFooter, LayoutFooterProps, LayoutHeader, LayoutHeaderProps, LayoutMain, LayoutMainProps, LayoutProps, LoaderProps, LoadingOverlay, MultiFileUploadProps, OnChangeMultipleFiles, OnChangeSingleFile, Pagination, PaginationProps, PopoverCloseButtonProps, PresetColor, RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ScaledPreview, ScaledPreviewProps, ScaledPreviewSize, Select, SelectOption, SingleFileUploadProps, Slider, SliderInput, SliderInputProps, SliderProps, SliderSelect, SliderSelectOption, SliderSelectProps, SliderSelectValue, Tabs, TabsContent, TabsContext, TabsContextValue, TabsList, TabsListProps, TabsTrigger, TabsTriggerProps, TabsVariant, TagsInput, TagsInputProps, ThemeModeDropdown, ThemeModeDropdownProps, ThemeModeSwitchInside, ThemeModeSwitchInsideProps, ThemeModeSwitchInsideSize, ThemeModeSwitchOutside, ThemeModeSwitchOutsideProps, ThemeModeToggleButton, ThemeModeToggleButtonProps, ThemeProvider, ThemeProviderProps, ToastMessage, Toaster, ToolbarItems, cn, showConfirmDialog, toast, toastError, toastInfo, toastSuccess, toastWarning, useMediaQuery, useSelectKeyboard, useTabsContext, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ import "./layout/index.js";
|
|
|
42
42
|
import { LoaderProps, LoadingOverlay } from "./LoadingOverlay.js";
|
|
43
43
|
import { Pagination, PaginationProps } from "./pagination/Pagination.js";
|
|
44
44
|
import "./pagination/index.js";
|
|
45
|
-
import { RichTextEditor, RichTextEditorProps,
|
|
45
|
+
import { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems } from "./rich-text-editor/RichTextEditor.js";
|
|
46
46
|
import "./rich-text-editor/index.js";
|
|
47
47
|
import { ScaledPreview, ScaledPreviewProps, ScaledPreviewSize } from "./ScaledPreview.js";
|
|
48
48
|
import { Select, SelectOption } from "./Select.js";
|
|
@@ -69,4 +69,4 @@ import { DEFAULT_ALERT_DURATION, ToastMessage, toast, toastError, toastInfo, toa
|
|
|
69
69
|
import { Toaster } from "./toast/ToastProvider.js";
|
|
70
70
|
import "./toast/index.js";
|
|
71
71
|
import { cn } from "@pixpilot/shadcn";
|
|
72
|
-
export { AbsoluteFill, Alert, AlertBaseProps, AlertProps, AlertVariant, AvatarUpload, AvatarUploadProps, BaseTabsTriggerProps, Button, ButtonLoaderProps, ButtonProps, CircleLoader, CircleLoaderProps, CloseButtonAbsolute, CloseButtonRounded, CloseButtonRoundedProps, ColorPicker, ColorPickerBase, ColorPickerBaseProps, ColorPickerBaseSection, ColorPickerProps, ColorSelect, ColorSelectOption, BaseColorSelectProps as ColorSelectProps, Combobox, ConfirmationDialogProps, ContentCard, DEFAULT_ALERT_DURATION, DatePicker, DatePickerProps, DialogProvider, DialogProviderProps, type FileMetadata, FileUpload, FileUploadBaseProps, FileUploadInline, FileUploadInlineBaseProps, FileUploadInlineProps, type FileUploadProgressCallBacks, type FileUploadProps, IconPicker, IconPickerProps, IconPickerVariant, IconProvider, IconProviderLoader, IconProviderProps, Input, InputProps, Layout, LayoutFooter, LayoutFooterProps, LayoutHeader, LayoutHeaderProps, LayoutMain, LayoutMainProps, LayoutProps, LoaderProps, LoadingOverlay, MultiFileUploadProps, OnChangeMultipleFiles, OnChangeSingleFile, Pagination, PaginationProps, PopoverCloseButtonProps, PresetColor, RichTextEditor, RichTextEditorProps, ScaledPreview, ScaledPreviewProps, ScaledPreviewSize, Select, SelectOption, SingleFileUploadProps, Slider, SliderInput, SliderInputProps, SliderProps, SliderSelect, SliderSelectOption, SliderSelectProps, SliderSelectValue, Tabs, TabsContent, TabsContext, TabsContextValue, TabsList, TabsListProps, TabsTrigger, TabsTriggerProps, TabsVariant, TagsInput, TagsInputProps, ThemeModeDropdown, ThemeModeDropdownProps, ThemeModeSwitchInside, ThemeModeSwitchInsideProps, ThemeModeSwitchInsideSize, ThemeModeSwitchOutside, ThemeModeSwitchOutsideProps, ThemeModeToggleButton, ThemeModeToggleButtonProps, ThemeProvider, ThemeProviderProps, ToastMessage, Toaster,
|
|
72
|
+
export { AbsoluteFill, Alert, AlertBaseProps, AlertProps, AlertVariant, AvatarUpload, AvatarUploadProps, BaseTabsTriggerProps, Button, ButtonLoaderProps, ButtonProps, CircleLoader, CircleLoaderProps, CloseButtonAbsolute, CloseButtonRounded, CloseButtonRoundedProps, ColorPicker, ColorPickerBase, ColorPickerBaseProps, ColorPickerBaseSection, ColorPickerProps, ColorSelect, ColorSelectOption, BaseColorSelectProps as ColorSelectProps, Combobox, ConfirmationDialogProps, ContentCard, DEFAULT_ALERT_DURATION, DatePicker, DatePickerProps, DialogProvider, DialogProviderProps, type FileMetadata, FileUpload, FileUploadBaseProps, FileUploadInline, FileUploadInlineBaseProps, FileUploadInlineProps, type FileUploadProgressCallBacks, type FileUploadProps, IconPicker, IconPickerProps, IconPickerVariant, IconProvider, IconProviderLoader, IconProviderProps, Input, InputProps, Layout, LayoutFooter, LayoutFooterProps, LayoutHeader, LayoutHeaderProps, LayoutMain, LayoutMainProps, LayoutProps, LoaderProps, LoadingOverlay, MultiFileUploadProps, OnChangeMultipleFiles, OnChangeSingleFile, Pagination, PaginationProps, PopoverCloseButtonProps, PresetColor, RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ScaledPreview, ScaledPreviewProps, ScaledPreviewSize, Select, SelectOption, SingleFileUploadProps, Slider, SliderInput, SliderInputProps, SliderProps, SliderSelect, SliderSelectOption, SliderSelectProps, SliderSelectValue, Tabs, TabsContent, TabsContext, TabsContextValue, TabsList, TabsListProps, TabsTrigger, TabsTriggerProps, TabsVariant, TagsInput, TagsInputProps, ThemeModeDropdown, ThemeModeDropdownProps, ThemeModeSwitchInside, ThemeModeSwitchInsideProps, ThemeModeSwitchInsideSize, ThemeModeSwitchOutside, ThemeModeSwitchOutsideProps, ThemeModeToggleButton, ThemeModeToggleButtonProps, ThemeProvider, ThemeProviderProps, ToastMessage, Toaster, ToolbarItems, cn, showConfirmDialog, toast, toastError, toastInfo, toastSuccess, toastWarning, useMediaQuery, useSelectKeyboard, useTabsContext, useTheme };
|
package/dist/input/Input.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import { InputProps } from "@pixpilot/shadcn";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
|
|
@@ -10,6 +10,6 @@ type InputProps$1 = InputProps & {
|
|
|
10
10
|
prefixClassName?: string;
|
|
11
11
|
suffixClassName?: string;
|
|
12
12
|
};
|
|
13
|
-
declare function Input(props: InputProps$1):
|
|
13
|
+
declare function Input(props: InputProps$1): react_jsx_runtime6.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { Input, InputProps$1 as InputProps };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_predefined_toolbar_items = require('./predefined-toolbar-items.cjs');
|
|
3
|
+
const require_ToolbarButton = require('./ToolbarButton.cjs');
|
|
3
4
|
let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
4
5
|
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
5
6
|
let react = require("react");
|
|
@@ -12,23 +13,8 @@ let __tiptap_starter_kit = require("@tiptap/starter-kit");
|
|
|
12
13
|
__tiptap_starter_kit = require_rolldown_runtime.__toESM(__tiptap_starter_kit);
|
|
13
14
|
|
|
14
15
|
//#region src/rich-text-editor/RichTextEditor.tsx
|
|
15
|
-
const ToolbarButton = ({ onClick, isActive, disabled, children, tooltip }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TooltipTrigger, {
|
|
16
|
-
asChild: true,
|
|
17
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
18
|
-
type: "button",
|
|
19
|
-
variant: isActive ? "default" : "ghost",
|
|
20
|
-
size: "sm",
|
|
21
|
-
onMouseDown: (event) => {
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
},
|
|
24
|
-
onClick,
|
|
25
|
-
disabled,
|
|
26
|
-
className: "h-8 w-8 p-0",
|
|
27
|
-
children
|
|
28
|
-
})
|
|
29
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TooltipContent, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: tooltip }) })] });
|
|
30
16
|
const defaultExtensions = [];
|
|
31
|
-
const
|
|
17
|
+
const defaultToolbarItems = [
|
|
32
18
|
"bold",
|
|
33
19
|
"italic",
|
|
34
20
|
"underline",
|
|
@@ -45,9 +31,9 @@ const defaultToolbarOptions = [
|
|
|
45
31
|
"blockquote",
|
|
46
32
|
"codeBlock"
|
|
47
33
|
];
|
|
48
|
-
const RichTextEditor = ({
|
|
34
|
+
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false }) => {
|
|
49
35
|
const [, forceRender] = react.default.useReducer((x) => x + 1, 0);
|
|
50
|
-
const defaultEditorProps = { attributes: { class: (0, __pixpilot_shadcn.cn)("min-h-[200px] p-4 text-sm leading-relaxed focus:outline-none", "[&_h1]:text-3xl [&_h1]:font-bold [&_h1]:leading-tight [&_h1]:
|
|
36
|
+
const defaultEditorProps = { attributes: { class: (0, __pixpilot_shadcn.cn)("min-h-[200px] p-4 text-sm leading-relaxed focus:outline-none", "[&_h1]:text-3xl [&_h1]:font-bold [&_h1]:leading-tight [&_h1]:mt-8 [&_h1]:mb-4 [&_h1:first-child]:mt-0", "[&_h2]:text-2xl [&_h2]:font-bold [&_h2]:leading-tight [&_h2]:mt-6 [&_h2]:mb-3 [&_h2:first-child]:mt-0", "[&_h3]:text-xl [&_h3]:font-bold [&_h3]:leading-tight [&_h3]:mt-4 [&_h3]:mb-2 [&_h3:first-child]:mt-0", "[&_p]:mb-3", "[&_ul]:list-disc [&_ul]:pl-6 [&_ul]:mb-3", "[&_ol]:list-decimal [&_ol]:pl-6 [&_ol]:mb-3", "[&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4 [&_blockquote]:mb-4 [&_blockquote]:italic [&_blockquote:first-child]:mt-0", "[&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[0.875em] [&_code]:font-mono", "[&_pre]:bg-muted [&_pre]:p-4 [&_pre]:rounded [&_pre]:overflow-x-auto [&_pre]:font-mono [&_pre]:mb-4", "[&_*:last-child]:mb-0", slots?.content?.className) } };
|
|
51
37
|
const mergedEditorProps = {
|
|
52
38
|
...defaultEditorProps,
|
|
53
39
|
...customEditorProps,
|
|
@@ -59,11 +45,12 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
59
45
|
};
|
|
60
46
|
const editorInstance = (0, __tiptap_react.useEditor)({
|
|
61
47
|
extensions: [__tiptap_starter_kit.default].concat(extensions),
|
|
62
|
-
content,
|
|
48
|
+
content: value,
|
|
63
49
|
editable,
|
|
64
50
|
onUpdate: ({ editor: updatedEditor }) => {
|
|
65
51
|
onChange?.(updatedEditor.getHTML());
|
|
66
52
|
},
|
|
53
|
+
immediatelyRender,
|
|
67
54
|
editorProps: mergedEditorProps
|
|
68
55
|
});
|
|
69
56
|
react.default.useEffect(() => {
|
|
@@ -83,9 +70,9 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
83
70
|
};
|
|
84
71
|
}, [editorInstance]);
|
|
85
72
|
if (editorInstance == null) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
86
|
-
className: (0, __pixpilot_shadcn.cn)("border rounded-md bg-background", className),
|
|
87
|
-
children: [showToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "flex flex-wrap items-center gap-1 border-b p-2 h-10" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
88
|
-
className: "min-h-[200px] p-4 text-sm leading-relaxed",
|
|
73
|
+
className: (0, __pixpilot_shadcn.cn)("border rounded-md bg-background", slots?.root?.className),
|
|
74
|
+
children: [showToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: (0, __pixpilot_shadcn.cn)("flex flex-wrap items-center gap-1 border-b p-2 h-10", slots?.toolbar?.className) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
75
|
+
className: (0, __pixpilot_shadcn.cn)("min-h-[200px] p-4 text-sm leading-relaxed", slots?.content?.className),
|
|
89
76
|
children: "Loading editor..."
|
|
90
77
|
})]
|
|
91
78
|
});
|
|
@@ -97,32 +84,40 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
97
84
|
const renderToolbar = () => {
|
|
98
85
|
if (!showToolbar) return null;
|
|
99
86
|
const isEditorFocused = editorInstance.isFocused;
|
|
87
|
+
let separatorCount = 0;
|
|
88
|
+
let customCount = 0;
|
|
100
89
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
101
|
-
className: "flex flex-wrap items-center gap-1 border-b p-2",
|
|
102
|
-
children:
|
|
103
|
-
if (option === "|")
|
|
90
|
+
className: (0, __pixpilot_shadcn.cn)("flex flex-wrap items-center gap-1 border-b p-2", slots?.toolbar?.className),
|
|
91
|
+
children: toolbarItems.map((option) => {
|
|
92
|
+
if (option === "|") {
|
|
93
|
+
separatorCount += 1;
|
|
94
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: (0, __pixpilot_shadcn.cn)("mx-1 h-6 w-px bg-border", slots?.toolbar?.separator?.className) }, `separator-${separatorCount}`);
|
|
95
|
+
}
|
|
104
96
|
if (typeof option === "string") {
|
|
105
|
-
const predefinedOption =
|
|
97
|
+
const predefinedOption = require_predefined_toolbar_items.predefinedToolbarItems[option];
|
|
106
98
|
if (!predefinedOption) return null;
|
|
107
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
99
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ToolbarButton.ToolbarButton, {
|
|
108
100
|
onClick: () => handleCommand(() => predefinedOption.onClick(editorInstance)),
|
|
109
101
|
isActive: isEditorFocused && (predefinedOption.isActive?.(editorInstance) ?? false),
|
|
110
102
|
tooltip: predefinedOption.tooltip,
|
|
103
|
+
className: slots?.toolbar?.button?.className,
|
|
111
104
|
children: predefinedOption.icon
|
|
112
105
|
}, option);
|
|
113
106
|
}
|
|
114
107
|
const customOption = option;
|
|
115
|
-
|
|
108
|
+
customCount += 1;
|
|
109
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ToolbarButton.ToolbarButton, {
|
|
116
110
|
onClick: () => handleCommand(() => customOption.onClick(editorInstance)),
|
|
117
111
|
isActive: isEditorFocused && (customOption.isActive?.(editorInstance) ?? false),
|
|
118
112
|
tooltip: customOption.tooltip,
|
|
113
|
+
className: slots?.toolbar?.button?.className,
|
|
119
114
|
children: customOption.icon
|
|
120
|
-
}, `custom-${
|
|
115
|
+
}, `custom-${customCount}-${customOption.tooltip}`);
|
|
121
116
|
})
|
|
122
117
|
});
|
|
123
118
|
};
|
|
124
119
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
125
|
-
className: (0, __pixpilot_shadcn.cn)("border rounded-md bg-background", className),
|
|
120
|
+
className: (0, __pixpilot_shadcn.cn)("border rounded-md bg-background", slots?.root?.className),
|
|
126
121
|
children: [renderToolbar(), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__tiptap_react.EditorContent, { editor: editorInstance })]
|
|
127
122
|
});
|
|
128
123
|
};
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Editor, Extension } from "@tiptap/core";
|
|
3
|
+
import { UseEditorOptions } from "@tiptap/react";
|
|
3
4
|
|
|
4
5
|
//#region src/rich-text-editor/RichTextEditor.d.ts
|
|
5
6
|
type EditorProps = Editor['options']['editorProps'];
|
|
6
|
-
type
|
|
7
|
+
type ToolbarItems = string | '|' | {
|
|
7
8
|
icon: React.ReactNode;
|
|
8
9
|
tooltip: string;
|
|
9
10
|
onClick: (editor: any) => void;
|
|
10
11
|
isActive?: (editor: any) => boolean;
|
|
11
12
|
};
|
|
13
|
+
interface RichTextEditorSlots {
|
|
14
|
+
root?: {
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
toolbar?: {
|
|
18
|
+
className?: string;
|
|
19
|
+
button?: {
|
|
20
|
+
className?: string;
|
|
21
|
+
};
|
|
22
|
+
separator?: {
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
content?: {
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
12
30
|
interface RichTextEditorProps {
|
|
13
31
|
/**
|
|
14
|
-
* The
|
|
32
|
+
* The HTML value of the editor.
|
|
33
|
+
* TipTap uses `content` internally, but this component follows React input conventions.
|
|
15
34
|
*/
|
|
16
|
-
|
|
35
|
+
value?: string;
|
|
17
36
|
/**
|
|
18
37
|
* Callback when the content changes
|
|
19
38
|
*/
|
|
@@ -28,28 +47,36 @@ interface RichTextEditorProps {
|
|
|
28
47
|
*/
|
|
29
48
|
editable?: boolean;
|
|
30
49
|
/**
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
50
|
+
* Slots for styling different parts of the editor.
|
|
51
|
+
*
|
|
52
|
+
* - `slots.root.className`: outer container
|
|
53
|
+
* - `slots.toolbar.className`: toolbar wrapper
|
|
54
|
+
* - `slots.toolbar.button.className`: each toolbar button
|
|
55
|
+
* - `slots.toolbar.separator.className`: separators (`|`)
|
|
56
|
+
* - `slots.content.className`: editor content area (merged into TipTap `editorProps.attributes.class`)
|
|
36
57
|
*/
|
|
37
|
-
|
|
58
|
+
slots?: RichTextEditorSlots;
|
|
38
59
|
/**
|
|
39
60
|
* Whether to show the toolbar
|
|
40
61
|
* @default true
|
|
41
62
|
*/
|
|
42
63
|
showToolbar?: boolean;
|
|
43
64
|
/**
|
|
44
|
-
* Array of toolbar
|
|
65
|
+
* Array of toolbar items to display. If provided, only these items will be shown.
|
|
45
66
|
* Can be strings for predefined commands or objects for custom buttons.
|
|
46
67
|
*/
|
|
47
|
-
|
|
68
|
+
toolbarItems?: ToolbarItems[];
|
|
48
69
|
/**
|
|
49
70
|
* Custom editor props to pass to the editor
|
|
50
71
|
*/
|
|
51
72
|
editorProps?: EditorProps;
|
|
73
|
+
/**
|
|
74
|
+
* If true, the editor will render immediately on mount.
|
|
75
|
+
* This can help with SSR or hydration issues in some cases.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
immediatelyRender?: UseEditorOptions['immediatelyRender'];
|
|
52
79
|
}
|
|
53
80
|
declare const RichTextEditor: React.FC<RichTextEditorProps>;
|
|
54
81
|
//#endregion
|
|
55
|
-
export { RichTextEditor, RichTextEditorProps,
|
|
82
|
+
export { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems };
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { UseEditorOptions } from "@tiptap/react";
|
|
2
3
|
import { Editor, Extension } from "@tiptap/core";
|
|
3
4
|
|
|
4
5
|
//#region src/rich-text-editor/RichTextEditor.d.ts
|
|
5
6
|
type EditorProps = Editor['options']['editorProps'];
|
|
6
|
-
type
|
|
7
|
+
type ToolbarItems = string | '|' | {
|
|
7
8
|
icon: React.ReactNode;
|
|
8
9
|
tooltip: string;
|
|
9
10
|
onClick: (editor: any) => void;
|
|
10
11
|
isActive?: (editor: any) => boolean;
|
|
11
12
|
};
|
|
13
|
+
interface RichTextEditorSlots {
|
|
14
|
+
root?: {
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
toolbar?: {
|
|
18
|
+
className?: string;
|
|
19
|
+
button?: {
|
|
20
|
+
className?: string;
|
|
21
|
+
};
|
|
22
|
+
separator?: {
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
content?: {
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
12
30
|
interface RichTextEditorProps {
|
|
13
31
|
/**
|
|
14
|
-
* The
|
|
32
|
+
* The HTML value of the editor.
|
|
33
|
+
* TipTap uses `content` internally, but this component follows React input conventions.
|
|
15
34
|
*/
|
|
16
|
-
|
|
35
|
+
value?: string;
|
|
17
36
|
/**
|
|
18
37
|
* Callback when the content changes
|
|
19
38
|
*/
|
|
@@ -28,28 +47,36 @@ interface RichTextEditorProps {
|
|
|
28
47
|
*/
|
|
29
48
|
editable?: boolean;
|
|
30
49
|
/**
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
50
|
+
* Slots for styling different parts of the editor.
|
|
51
|
+
*
|
|
52
|
+
* - `slots.root.className`: outer container
|
|
53
|
+
* - `slots.toolbar.className`: toolbar wrapper
|
|
54
|
+
* - `slots.toolbar.button.className`: each toolbar button
|
|
55
|
+
* - `slots.toolbar.separator.className`: separators (`|`)
|
|
56
|
+
* - `slots.content.className`: editor content area (merged into TipTap `editorProps.attributes.class`)
|
|
36
57
|
*/
|
|
37
|
-
|
|
58
|
+
slots?: RichTextEditorSlots;
|
|
38
59
|
/**
|
|
39
60
|
* Whether to show the toolbar
|
|
40
61
|
* @default true
|
|
41
62
|
*/
|
|
42
63
|
showToolbar?: boolean;
|
|
43
64
|
/**
|
|
44
|
-
* Array of toolbar
|
|
65
|
+
* Array of toolbar items to display. If provided, only these items will be shown.
|
|
45
66
|
* Can be strings for predefined commands or objects for custom buttons.
|
|
46
67
|
*/
|
|
47
|
-
|
|
68
|
+
toolbarItems?: ToolbarItems[];
|
|
48
69
|
/**
|
|
49
70
|
* Custom editor props to pass to the editor
|
|
50
71
|
*/
|
|
51
72
|
editorProps?: EditorProps;
|
|
73
|
+
/**
|
|
74
|
+
* If true, the editor will render immediately on mount.
|
|
75
|
+
* This can help with SSR or hydration issues in some cases.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
immediatelyRender?: UseEditorOptions['immediatelyRender'];
|
|
52
79
|
}
|
|
53
80
|
declare const RichTextEditor: React.FC<RichTextEditorProps>;
|
|
54
81
|
//#endregion
|
|
55
|
-
export { RichTextEditor, RichTextEditorProps,
|
|
82
|
+
export { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems };
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { predefinedToolbarItems } from "./predefined-toolbar-items.js";
|
|
2
|
+
import { ToolbarButton } from "./ToolbarButton.js";
|
|
3
|
+
import { cn } from "@pixpilot/shadcn";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
6
7
|
import StarterKit from "@tiptap/starter-kit";
|
|
7
8
|
|
|
8
9
|
//#region src/rich-text-editor/RichTextEditor.tsx
|
|
9
|
-
const ToolbarButton = ({ onClick, isActive, disabled, children, tooltip }) => /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
10
|
-
asChild: true,
|
|
11
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
12
|
-
type: "button",
|
|
13
|
-
variant: isActive ? "default" : "ghost",
|
|
14
|
-
size: "sm",
|
|
15
|
-
onMouseDown: (event) => {
|
|
16
|
-
event.preventDefault();
|
|
17
|
-
},
|
|
18
|
-
onClick,
|
|
19
|
-
disabled,
|
|
20
|
-
className: "h-8 w-8 p-0",
|
|
21
|
-
children
|
|
22
|
-
})
|
|
23
|
-
}), /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltip }) })] });
|
|
24
10
|
const defaultExtensions = [];
|
|
25
|
-
const
|
|
11
|
+
const defaultToolbarItems = [
|
|
26
12
|
"bold",
|
|
27
13
|
"italic",
|
|
28
14
|
"underline",
|
|
@@ -39,9 +25,9 @@ const defaultToolbarOptions = [
|
|
|
39
25
|
"blockquote",
|
|
40
26
|
"codeBlock"
|
|
41
27
|
];
|
|
42
|
-
const RichTextEditor = ({
|
|
28
|
+
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false }) => {
|
|
43
29
|
const [, forceRender] = React.useReducer((x) => x + 1, 0);
|
|
44
|
-
const defaultEditorProps = { attributes: { class: cn("min-h-[200px] p-4 text-sm leading-relaxed focus:outline-none", "[&_h1]:text-3xl [&_h1]:font-bold [&_h1]:leading-tight [&_h1]:
|
|
30
|
+
const defaultEditorProps = { attributes: { class: cn("min-h-[200px] p-4 text-sm leading-relaxed focus:outline-none", "[&_h1]:text-3xl [&_h1]:font-bold [&_h1]:leading-tight [&_h1]:mt-8 [&_h1]:mb-4 [&_h1:first-child]:mt-0", "[&_h2]:text-2xl [&_h2]:font-bold [&_h2]:leading-tight [&_h2]:mt-6 [&_h2]:mb-3 [&_h2:first-child]:mt-0", "[&_h3]:text-xl [&_h3]:font-bold [&_h3]:leading-tight [&_h3]:mt-4 [&_h3]:mb-2 [&_h3:first-child]:mt-0", "[&_p]:mb-3", "[&_ul]:list-disc [&_ul]:pl-6 [&_ul]:mb-3", "[&_ol]:list-decimal [&_ol]:pl-6 [&_ol]:mb-3", "[&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4 [&_blockquote]:mb-4 [&_blockquote]:italic [&_blockquote:first-child]:mt-0", "[&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[0.875em] [&_code]:font-mono", "[&_pre]:bg-muted [&_pre]:p-4 [&_pre]:rounded [&_pre]:overflow-x-auto [&_pre]:font-mono [&_pre]:mb-4", "[&_*:last-child]:mb-0", slots?.content?.className) } };
|
|
45
31
|
const mergedEditorProps = {
|
|
46
32
|
...defaultEditorProps,
|
|
47
33
|
...customEditorProps,
|
|
@@ -53,11 +39,12 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
53
39
|
};
|
|
54
40
|
const editorInstance = useEditor({
|
|
55
41
|
extensions: [StarterKit].concat(extensions),
|
|
56
|
-
content,
|
|
42
|
+
content: value,
|
|
57
43
|
editable,
|
|
58
44
|
onUpdate: ({ editor: updatedEditor }) => {
|
|
59
45
|
onChange?.(updatedEditor.getHTML());
|
|
60
46
|
},
|
|
47
|
+
immediatelyRender,
|
|
61
48
|
editorProps: mergedEditorProps
|
|
62
49
|
});
|
|
63
50
|
React.useEffect(() => {
|
|
@@ -77,9 +64,9 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
77
64
|
};
|
|
78
65
|
}, [editorInstance]);
|
|
79
66
|
if (editorInstance == null) return /* @__PURE__ */ jsxs("div", {
|
|
80
|
-
className: cn("border rounded-md bg-background", className),
|
|
81
|
-
children: [showToolbar && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1 border-b p-2 h-10" }), /* @__PURE__ */ jsx("div", {
|
|
82
|
-
className: "min-h-[200px] p-4 text-sm leading-relaxed",
|
|
67
|
+
className: cn("border rounded-md bg-background", slots?.root?.className),
|
|
68
|
+
children: [showToolbar && /* @__PURE__ */ jsx("div", { className: cn("flex flex-wrap items-center gap-1 border-b p-2 h-10", slots?.toolbar?.className) }), /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: cn("min-h-[200px] p-4 text-sm leading-relaxed", slots?.content?.className),
|
|
83
70
|
children: "Loading editor..."
|
|
84
71
|
})]
|
|
85
72
|
});
|
|
@@ -91,32 +78,40 @@ const RichTextEditor = ({ content, onChange, extensions = defaultExtensions, edi
|
|
|
91
78
|
const renderToolbar = () => {
|
|
92
79
|
if (!showToolbar) return null;
|
|
93
80
|
const isEditorFocused = editorInstance.isFocused;
|
|
81
|
+
let separatorCount = 0;
|
|
82
|
+
let customCount = 0;
|
|
94
83
|
return /* @__PURE__ */ jsx("div", {
|
|
95
|
-
className: "flex flex-wrap items-center gap-1 border-b p-2",
|
|
96
|
-
children:
|
|
97
|
-
if (option === "|")
|
|
84
|
+
className: cn("flex flex-wrap items-center gap-1 border-b p-2", slots?.toolbar?.className),
|
|
85
|
+
children: toolbarItems.map((option) => {
|
|
86
|
+
if (option === "|") {
|
|
87
|
+
separatorCount += 1;
|
|
88
|
+
return /* @__PURE__ */ jsx("div", { className: cn("mx-1 h-6 w-px bg-border", slots?.toolbar?.separator?.className) }, `separator-${separatorCount}`);
|
|
89
|
+
}
|
|
98
90
|
if (typeof option === "string") {
|
|
99
|
-
const predefinedOption =
|
|
91
|
+
const predefinedOption = predefinedToolbarItems[option];
|
|
100
92
|
if (!predefinedOption) return null;
|
|
101
93
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
102
94
|
onClick: () => handleCommand(() => predefinedOption.onClick(editorInstance)),
|
|
103
95
|
isActive: isEditorFocused && (predefinedOption.isActive?.(editorInstance) ?? false),
|
|
104
96
|
tooltip: predefinedOption.tooltip,
|
|
97
|
+
className: slots?.toolbar?.button?.className,
|
|
105
98
|
children: predefinedOption.icon
|
|
106
99
|
}, option);
|
|
107
100
|
}
|
|
108
101
|
const customOption = option;
|
|
102
|
+
customCount += 1;
|
|
109
103
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
110
104
|
onClick: () => handleCommand(() => customOption.onClick(editorInstance)),
|
|
111
105
|
isActive: isEditorFocused && (customOption.isActive?.(editorInstance) ?? false),
|
|
112
106
|
tooltip: customOption.tooltip,
|
|
107
|
+
className: slots?.toolbar?.button?.className,
|
|
113
108
|
children: customOption.icon
|
|
114
|
-
}, `custom-${
|
|
109
|
+
}, `custom-${customCount}-${customOption.tooltip}`);
|
|
115
110
|
})
|
|
116
111
|
});
|
|
117
112
|
};
|
|
118
113
|
return /* @__PURE__ */ jsxs("div", {
|
|
119
|
-
className: cn("border rounded-md bg-background", className),
|
|
114
|
+
className: cn("border rounded-md bg-background", slots?.root?.className),
|
|
120
115
|
children: [renderToolbar(), /* @__PURE__ */ jsx(EditorContent, { editor: editorInstance })]
|
|
121
116
|
});
|
|
122
117
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
3
|
+
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
8
|
+
|
|
9
|
+
//#region src/rich-text-editor/ToolbarButton.tsx
|
|
10
|
+
function isSvgMarkupString(value) {
|
|
11
|
+
if (typeof value !== "string") return false;
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
return trimmed.startsWith("<svg") && trimmed.endsWith("</svg>");
|
|
14
|
+
}
|
|
15
|
+
function svgMarkupToMaskUrl(svgMarkup) {
|
|
16
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svgMarkup).replace(/'/gu, "%27").replace(/"/gu, "%22")}")`;
|
|
17
|
+
}
|
|
18
|
+
const ToolbarButton = ({ onClick, isActive, disabled, className, children, tooltip }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TooltipTrigger, {
|
|
19
|
+
asChild: true,
|
|
20
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Button, {
|
|
21
|
+
type: "button",
|
|
22
|
+
variant: isActive ? "default" : "ghost",
|
|
23
|
+
size: "sm",
|
|
24
|
+
onMouseDown: (event) => {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
},
|
|
27
|
+
onClick,
|
|
28
|
+
disabled,
|
|
29
|
+
className: (0, __pixpilot_shadcn.cn)("h-8 w-8 p-0", className),
|
|
30
|
+
children: isSvgMarkupString(children) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
31
|
+
"data-slot": "svg-mask",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
className: "inline-block h-4 w-4",
|
|
34
|
+
style: {
|
|
35
|
+
backgroundColor: "currentColor",
|
|
36
|
+
WebkitMaskImage: svgMarkupToMaskUrl(children),
|
|
37
|
+
maskImage: svgMarkupToMaskUrl(children),
|
|
38
|
+
WebkitMaskRepeat: "no-repeat",
|
|
39
|
+
maskRepeat: "no-repeat",
|
|
40
|
+
WebkitMaskPosition: "center",
|
|
41
|
+
maskPosition: "center",
|
|
42
|
+
WebkitMaskSize: "contain",
|
|
43
|
+
maskSize: "contain"
|
|
44
|
+
}
|
|
45
|
+
}) : children
|
|
46
|
+
})
|
|
47
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.TooltipContent, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: tooltip }) })] });
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.ToolbarButton = ToolbarButton;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Button, Tooltip, TooltipContent, TooltipTrigger, cn } from "@pixpilot/shadcn";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/rich-text-editor/ToolbarButton.tsx
|
|
6
|
+
function isSvgMarkupString(value) {
|
|
7
|
+
if (typeof value !== "string") return false;
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
return trimmed.startsWith("<svg") && trimmed.endsWith("</svg>");
|
|
10
|
+
}
|
|
11
|
+
function svgMarkupToMaskUrl(svgMarkup) {
|
|
12
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svgMarkup).replace(/'/gu, "%27").replace(/"/gu, "%22")}")`;
|
|
13
|
+
}
|
|
14
|
+
const ToolbarButton = ({ onClick, isActive, disabled, className, children, tooltip }) => /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
15
|
+
asChild: true,
|
|
16
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
17
|
+
type: "button",
|
|
18
|
+
variant: isActive ? "default" : "ghost",
|
|
19
|
+
size: "sm",
|
|
20
|
+
onMouseDown: (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
},
|
|
23
|
+
onClick,
|
|
24
|
+
disabled,
|
|
25
|
+
className: cn("h-8 w-8 p-0", className),
|
|
26
|
+
children: isSvgMarkupString(children) ? /* @__PURE__ */ jsx("span", {
|
|
27
|
+
"data-slot": "svg-mask",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
className: "inline-block h-4 w-4",
|
|
30
|
+
style: {
|
|
31
|
+
backgroundColor: "currentColor",
|
|
32
|
+
WebkitMaskImage: svgMarkupToMaskUrl(children),
|
|
33
|
+
maskImage: svgMarkupToMaskUrl(children),
|
|
34
|
+
WebkitMaskRepeat: "no-repeat",
|
|
35
|
+
maskRepeat: "no-repeat",
|
|
36
|
+
WebkitMaskPosition: "center",
|
|
37
|
+
maskPosition: "center",
|
|
38
|
+
WebkitMaskSize: "contain",
|
|
39
|
+
maskSize: "contain"
|
|
40
|
+
}
|
|
41
|
+
}) : children
|
|
42
|
+
})
|
|
43
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: tooltip }) })] });
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ToolbarButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { RichTextEditor, RichTextEditorProps,
|
|
1
|
+
import { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems } from "./RichTextEditor.cjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { RichTextEditor, RichTextEditorProps,
|
|
1
|
+
import { RichTextEditor, RichTextEditorProps, RichTextEditorSlots, ToolbarItems } from "./RichTextEditor.js";
|
package/dist/rich-text-editor/{predefined-toolbar-options.cjs → predefined-toolbar-items.cjs}
RENAMED
|
@@ -4,8 +4,8 @@ lucide_react = require_rolldown_runtime.__toESM(lucide_react);
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
6
6
|
|
|
7
|
-
//#region src/rich-text-editor/predefined-toolbar-
|
|
8
|
-
const
|
|
7
|
+
//#region src/rich-text-editor/predefined-toolbar-items.tsx
|
|
8
|
+
const predefinedToolbarItems = {
|
|
9
9
|
bold: {
|
|
10
10
|
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Bold, { className: "h-4 w-4" }),
|
|
11
11
|
tooltip: "Bold",
|
|
@@ -81,4 +81,4 @@ const predefinedToolbarOptions = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
|
-
exports.
|
|
84
|
+
exports.predefinedToolbarItems = predefinedToolbarItems;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Bold, Code, Code2, Heading1, Heading2, Heading3, Italic, List, ListOrdered, Quote, Strikethrough, Underline } from "lucide-react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
//#region src/rich-text-editor/predefined-toolbar-
|
|
5
|
-
const
|
|
4
|
+
//#region src/rich-text-editor/predefined-toolbar-items.tsx
|
|
5
|
+
const predefinedToolbarItems = {
|
|
6
6
|
bold: {
|
|
7
7
|
icon: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" }),
|
|
8
8
|
tooltip: "Bold",
|
|
@@ -78,4 +78,4 @@ const predefinedToolbarOptions = {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
|
-
export {
|
|
81
|
+
export { predefinedToolbarItems };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/theme-toggle/ThemeModeDropdown.d.ts
|
|
4
4
|
interface ThemeModeDropdownProps {
|
|
@@ -17,7 +17,7 @@ interface ThemeModeDropdownProps {
|
|
|
17
17
|
* Provides Light / Dark / System options.
|
|
18
18
|
* Pure component - requires themeValue and onChange props.
|
|
19
19
|
*/
|
|
20
|
-
declare function ThemeModeDropdown(props: ThemeModeDropdownProps):
|
|
20
|
+
declare function ThemeModeDropdown(props: ThemeModeDropdownProps): react_jsx_runtime9.JSX.Element;
|
|
21
21
|
declare namespace ThemeModeDropdown {
|
|
22
22
|
var displayName: string;
|
|
23
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/theme-toggle/ThemeModeSwitchInside.d.ts
|
|
4
4
|
type ThemeModeSwitchInsideSize = 'sm' | 'md' | 'lg';
|
|
@@ -25,7 +25,7 @@ interface ThemeModeSwitchInsideProps {
|
|
|
25
25
|
* Icons are embedded within the switch control.
|
|
26
26
|
* Pure component - requires value and onChange props.
|
|
27
27
|
*/
|
|
28
|
-
declare function ThemeModeSwitchInside(props: ThemeModeSwitchInsideProps):
|
|
28
|
+
declare function ThemeModeSwitchInside(props: ThemeModeSwitchInsideProps): react_jsx_runtime10.JSX.Element;
|
|
29
29
|
declare namespace ThemeModeSwitchInside {
|
|
30
30
|
var displayName: string;
|
|
31
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/theme-toggle/ThemeModeSwitchOutside.d.ts
|
|
4
4
|
interface ThemeModeSwitchOutsideProps {
|
|
@@ -22,7 +22,7 @@ interface ThemeModeSwitchOutsideProps {
|
|
|
22
22
|
* Icons flank the switch control on either side.
|
|
23
23
|
* Pure component - requires value and onChange props.
|
|
24
24
|
*/
|
|
25
|
-
declare function ThemeModeSwitchOutside(props: ThemeModeSwitchOutsideProps):
|
|
25
|
+
declare function ThemeModeSwitchOutside(props: ThemeModeSwitchOutsideProps): react_jsx_runtime11.JSX.Element;
|
|
26
26
|
declare namespace ThemeModeSwitchOutside {
|
|
27
27
|
var displayName: string;
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/theme-toggle/ThemeModeToggleButton.d.ts
|
|
4
4
|
interface ThemeModeToggleButtonProps {
|
|
@@ -13,7 +13,7 @@ interface ThemeModeToggleButtonProps {
|
|
|
13
13
|
* Light/Dark toggle button.
|
|
14
14
|
* Pure component - toggles between light and dark.
|
|
15
15
|
*/
|
|
16
|
-
declare function ThemeModeToggleButton(props: ThemeModeToggleButtonProps):
|
|
16
|
+
declare function ThemeModeToggleButton(props: ThemeModeToggleButtonProps): react_jsx_runtime12.JSX.Element;
|
|
17
17
|
declare namespace ThemeModeToggleButton {
|
|
18
18
|
var displayName: string;
|
|
19
19
|
}
|
package/package.json
CHANGED