@pixpilot/shadcn-ui 0.42.0 → 0.44.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/{tags-input.cjs → TagsInput.cjs} +1 -1
- package/dist/{tags-input.d.cts → TagsInput.d.cts} +1 -1
- package/dist/{tags-input.d.ts → TagsInput.d.ts} +1 -1
- package/dist/{tags-input.js → TagsInput.js} +1 -1
- package/dist/dialog/Dialog.d.cts +4 -4
- package/dist/dialog/Dialog.d.ts +4 -4
- package/dist/file-upload/FileUpload.d.cts +2 -2
- package/dist/file-upload/FileUpload.d.ts +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/input/Input.d.cts +2 -2
- package/dist/rich-text-editor/RichTextEditor.cjs +13 -7
- package/dist/rich-text-editor/RichTextEditor.d.cts +4 -0
- package/dist/rich-text-editor/RichTextEditor.d.ts +4 -0
- package/dist/rich-text-editor/RichTextEditor.js +12 -7
- package/package.json +2 -1
|
@@ -10,7 +10,7 @@ react = require_rolldown_runtime.__toESM(react);
|
|
|
10
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
11
|
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
12
12
|
|
|
13
|
-
//#region src/
|
|
13
|
+
//#region src/TagsInput.tsx
|
|
14
14
|
const EMPTY_ARRAY = [];
|
|
15
15
|
const EMPTY_OPTIONS = [];
|
|
16
16
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandOptionListItem } from "./CommandOptionList.cjs";
|
|
2
2
|
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/TagsInput.d.ts
|
|
5
5
|
interface TagsInputProps {
|
|
6
6
|
value?: Array<string | number>;
|
|
7
7
|
onChange?: (value: Array<string | number>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandOptionListItem } from "./CommandOptionList.js";
|
|
2
2
|
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/TagsInput.d.ts
|
|
5
5
|
interface TagsInputProps {
|
|
6
6
|
value?: Array<string | number>;
|
|
7
7
|
onChange?: (value: Array<string | number>) => void;
|
|
@@ -6,7 +6,7 @@ import { Command, Popover, PopoverContent, PopoverTrigger, TagsInputInLineClear,
|
|
|
6
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
|
-
//#region src/
|
|
9
|
+
//#region src/TagsInput.tsx
|
|
10
10
|
const EMPTY_ARRAY = [];
|
|
11
11
|
const EMPTY_OPTIONS = [];
|
|
12
12
|
/**
|
package/dist/dialog/Dialog.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import * as _radix_ui_react_dialog0 from "@radix-ui/react-dialog";
|
|
4
4
|
|
|
@@ -9,14 +9,14 @@ declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<_radix_ui_re
|
|
|
9
9
|
declare function DialogHeader({
|
|
10
10
|
className,
|
|
11
11
|
...props
|
|
12
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
12
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime6.JSX.Element;
|
|
13
13
|
declare function DialogBody({
|
|
14
14
|
className,
|
|
15
15
|
...props
|
|
16
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
16
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime6.JSX.Element;
|
|
17
17
|
declare function DialogFooter({
|
|
18
18
|
className,
|
|
19
19
|
...props
|
|
20
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
20
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime6.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { DialogBody, DialogContent, DialogFooter, DialogHeader };
|
package/dist/dialog/Dialog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
import * as _radix_ui_react_dialog0 from "@radix-ui/react-dialog";
|
|
4
4
|
|
|
5
5
|
//#region src/dialog/Dialog.d.ts
|
|
@@ -9,14 +9,14 @@ declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<_radix_ui_re
|
|
|
9
9
|
declare function DialogHeader({
|
|
10
10
|
className,
|
|
11
11
|
...props
|
|
12
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
12
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime7.JSX.Element;
|
|
13
13
|
declare function DialogBody({
|
|
14
14
|
className,
|
|
15
15
|
...props
|
|
16
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
16
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime7.JSX.Element;
|
|
17
17
|
declare function DialogFooter({
|
|
18
18
|
className,
|
|
19
19
|
...props
|
|
20
|
-
}: React$1.HTMLAttributes<HTMLDivElement>):
|
|
20
|
+
}: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime7.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { DialogBody, DialogContent, DialogFooter, DialogHeader };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileUploadProps } from "./types/index.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime11 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_runtime11.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { FileUpload };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileUploadProps } from "./types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 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_runtime6.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { FileUpload };
|
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ const require_TabsContext = require('./tabs/TabsContext.cjs');
|
|
|
56
56
|
const require_TabsList = require('./tabs/TabsList.cjs');
|
|
57
57
|
const require_TabsTrigger = require('./tabs/TabsTrigger.cjs');
|
|
58
58
|
require('./tabs/index.cjs');
|
|
59
|
-
const
|
|
59
|
+
const require_TagsInput = require('./TagsInput.cjs');
|
|
60
60
|
const require_ThemeProvider = require('./theme-provider/ThemeProvider.cjs');
|
|
61
61
|
require('./theme-provider/index.cjs');
|
|
62
62
|
const require_ThemeModeDropdown = require('./theme-toggle/ThemeModeDropdown.cjs');
|
|
@@ -122,7 +122,7 @@ exports.TabsContent = __pixpilot_shadcn.TabsContent;
|
|
|
122
122
|
exports.TabsContext = require_TabsContext.TabsContext;
|
|
123
123
|
exports.TabsList = require_TabsList.TabsList;
|
|
124
124
|
exports.TabsTrigger = require_TabsTrigger.TabsTrigger;
|
|
125
|
-
exports.TagsInput =
|
|
125
|
+
exports.TagsInput = require_TagsInput.TagsInput;
|
|
126
126
|
exports.ThemeModeDropdown = require_ThemeModeDropdown.ThemeModeDropdown;
|
|
127
127
|
exports.ThemeModeSwitchInside = require_ThemeModeSwitchInside.ThemeModeSwitchInside;
|
|
128
128
|
exports.ThemeModeSwitchOutside = require_ThemeModeSwitchOutside.ThemeModeSwitchOutside;
|
package/dist/index.d.cts
CHANGED
|
@@ -60,7 +60,7 @@ import { TabsContext, TabsContextValue, useTabsContext } from "./tabs/TabsContex
|
|
|
60
60
|
import { TabsList, TabsListProps } from "./tabs/TabsList.cjs";
|
|
61
61
|
import { TabsTrigger, TabsTriggerProps } from "./tabs/TabsTrigger.cjs";
|
|
62
62
|
import "./tabs/index.cjs";
|
|
63
|
-
import { TagsInput, TagsInputProps } from "./
|
|
63
|
+
import { TagsInput, TagsInputProps } from "./TagsInput.cjs";
|
|
64
64
|
import { ThemeProvider, ThemeProviderProps } from "./theme-provider/ThemeProvider.cjs";
|
|
65
65
|
import { useTheme } from "./theme-provider/index.cjs";
|
|
66
66
|
import { ThemeModeDropdown, ThemeModeDropdownProps } from "./theme-toggle/ThemeModeDropdown.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ import { TabsContext, TabsContextValue, useTabsContext } from "./tabs/TabsContex
|
|
|
62
62
|
import { TabsList, TabsListProps } from "./tabs/TabsList.js";
|
|
63
63
|
import { TabsTrigger, TabsTriggerProps } from "./tabs/TabsTrigger.js";
|
|
64
64
|
import "./tabs/index.js";
|
|
65
|
-
import { TagsInput, TagsInputProps } from "./
|
|
65
|
+
import { TagsInput, TagsInputProps } from "./TagsInput.js";
|
|
66
66
|
import { ThemeProvider, ThemeProviderProps } from "./theme-provider/ThemeProvider.js";
|
|
67
67
|
import { useTheme } from "./theme-provider/index.js";
|
|
68
68
|
import { ThemeModeDropdown, ThemeModeDropdownProps } from "./theme-toggle/ThemeModeDropdown.js";
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ import { TabsContext, useTabsContext } from "./tabs/TabsContext.js";
|
|
|
57
57
|
import { TabsList } from "./tabs/TabsList.js";
|
|
58
58
|
import { TabsTrigger } from "./tabs/TabsTrigger.js";
|
|
59
59
|
import "./tabs/index.js";
|
|
60
|
-
import { TagsInput } from "./
|
|
60
|
+
import { TagsInput } from "./TagsInput.js";
|
|
61
61
|
import { ThemeProvider } from "./theme-provider/ThemeProvider.js";
|
|
62
62
|
import { useTheme } from "./theme-provider/index.js";
|
|
63
63
|
import { ThemeModeDropdown } from "./theme-toggle/ThemeModeDropdown.js";
|
package/dist/input/Input.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime9 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_runtime9.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { Input, InputProps$1 as InputProps };
|
|
@@ -8,6 +8,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
8
8
|
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
9
9
|
let __tiptap_extension_link = require("@tiptap/extension-link");
|
|
10
10
|
__tiptap_extension_link = require_rolldown_runtime.__toESM(__tiptap_extension_link);
|
|
11
|
+
let __tiptap_extension_placeholder = require("@tiptap/extension-placeholder");
|
|
12
|
+
__tiptap_extension_placeholder = require_rolldown_runtime.__toESM(__tiptap_extension_placeholder);
|
|
11
13
|
let __tiptap_extension_text_align = require("@tiptap/extension-text-align");
|
|
12
14
|
__tiptap_extension_text_align = require_rolldown_runtime.__toESM(__tiptap_extension_text_align);
|
|
13
15
|
let __tiptap_react = require("@tiptap/react");
|
|
@@ -40,7 +42,7 @@ const defaultToolbarItems = [
|
|
|
40
42
|
"codeBlock"
|
|
41
43
|
];
|
|
42
44
|
function useEditorProps(slots, customEditorProps) {
|
|
43
|
-
const defaultEditorProps = react.default.useMemo(() => ({ 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", "[&_a]:text-blue-500 [&_a]:hover:text-blue-600 [&_a]:cursor-pointer [&_a]:underline [&_a]:underline-offset-2 ", "[&_*:last-child]:mb-0", slots?.content?.className) } }), [slots]);
|
|
45
|
+
const defaultEditorProps = react.default.useMemo(() => ({ 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", "[&_a]:text-blue-500 [&_a]:hover:text-blue-600 [&_a]:cursor-pointer [&_a]:underline [&_a]:underline-offset-2 ", "[&_*:last-child]:mb-0", "[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.is-editor-empty:first-child::before]:float-left [&_.is-editor-empty:first-child::before]:text-muted-foreground [&_.is-editor-empty:first-child::before]:pointer-events-none [&_.is-editor-empty:first-child::before]:h-0", slots?.content?.className) } }), [slots]);
|
|
44
46
|
return react.default.useMemo(() => ({
|
|
45
47
|
...defaultEditorProps,
|
|
46
48
|
...customEditorProps,
|
|
@@ -51,7 +53,7 @@ function useEditorProps(slots, customEditorProps) {
|
|
|
51
53
|
}
|
|
52
54
|
}), [defaultEditorProps, customEditorProps]);
|
|
53
55
|
}
|
|
54
|
-
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false, tooltipMode = "native" }) => {
|
|
56
|
+
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false, tooltipMode = "native", placeholder }) => {
|
|
55
57
|
const [renderTick, forceRender] = react.default.useReducer((x) => x + 1, 0);
|
|
56
58
|
const mergedEditorProps = useEditorProps(slots, customEditorProps);
|
|
57
59
|
const onChangeRef = react.default.useRef(onChange);
|
|
@@ -60,11 +62,15 @@ const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, edita
|
|
|
60
62
|
onChangeRef.current?.(props.editor.getHTML());
|
|
61
63
|
}, []);
|
|
62
64
|
const editorInstance = (0, __tiptap_react.useEditor)({
|
|
63
|
-
extensions: react.default.useMemo(() =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
extensions: react.default.useMemo(() => {
|
|
66
|
+
const baseExtensions = [
|
|
67
|
+
__tiptap_starter_kit.default,
|
|
68
|
+
__tiptap_extension_link.default,
|
|
69
|
+
__tiptap_extension_text_align.default.configure({ types: ["heading", "paragraph"] })
|
|
70
|
+
];
|
|
71
|
+
if (placeholder != null) baseExtensions.push(__tiptap_extension_placeholder.default.configure({ placeholder }));
|
|
72
|
+
return baseExtensions.concat(extensions);
|
|
73
|
+
}, [extensions, placeholder]),
|
|
68
74
|
content: value,
|
|
69
75
|
editable,
|
|
70
76
|
onUpdate: handleChange,
|
|
@@ -82,6 +82,10 @@ interface RichTextEditorProps {
|
|
|
82
82
|
* @default 'native'
|
|
83
83
|
*/
|
|
84
84
|
tooltipMode?: ToolbarButtonTooltipMode;
|
|
85
|
+
/**
|
|
86
|
+
* Placeholder text to show when the editor is empty
|
|
87
|
+
*/
|
|
88
|
+
placeholder?: string;
|
|
85
89
|
}
|
|
86
90
|
declare const RichTextEditor: React.FC<RichTextEditorProps>;
|
|
87
91
|
//#endregion
|
|
@@ -82,6 +82,10 @@ interface RichTextEditorProps {
|
|
|
82
82
|
* @default 'native'
|
|
83
83
|
*/
|
|
84
84
|
tooltipMode?: ToolbarButtonTooltipMode;
|
|
85
|
+
/**
|
|
86
|
+
* Placeholder text to show when the editor is empty
|
|
87
|
+
*/
|
|
88
|
+
placeholder?: string;
|
|
85
89
|
}
|
|
86
90
|
declare const RichTextEditor: React.FC<RichTextEditorProps>;
|
|
87
91
|
//#endregion
|
|
@@ -3,6 +3,7 @@ import { cn } from "@pixpilot/shadcn";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import Link from "@tiptap/extension-link";
|
|
6
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
6
7
|
import TextAlign from "@tiptap/extension-text-align";
|
|
7
8
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
8
9
|
import StarterKit from "@tiptap/starter-kit";
|
|
@@ -32,7 +33,7 @@ const defaultToolbarItems = [
|
|
|
32
33
|
"codeBlock"
|
|
33
34
|
];
|
|
34
35
|
function useEditorProps(slots, customEditorProps) {
|
|
35
|
-
const defaultEditorProps = React.useMemo(() => ({ 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", "[&_a]:text-blue-500 [&_a]:hover:text-blue-600 [&_a]:cursor-pointer [&_a]:underline [&_a]:underline-offset-2 ", "[&_*:last-child]:mb-0", slots?.content?.className) } }), [slots]);
|
|
36
|
+
const defaultEditorProps = React.useMemo(() => ({ 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", "[&_a]:text-blue-500 [&_a]:hover:text-blue-600 [&_a]:cursor-pointer [&_a]:underline [&_a]:underline-offset-2 ", "[&_*:last-child]:mb-0", "[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.is-editor-empty:first-child::before]:float-left [&_.is-editor-empty:first-child::before]:text-muted-foreground [&_.is-editor-empty:first-child::before]:pointer-events-none [&_.is-editor-empty:first-child::before]:h-0", slots?.content?.className) } }), [slots]);
|
|
36
37
|
return React.useMemo(() => ({
|
|
37
38
|
...defaultEditorProps,
|
|
38
39
|
...customEditorProps,
|
|
@@ -43,7 +44,7 @@ function useEditorProps(slots, customEditorProps) {
|
|
|
43
44
|
}
|
|
44
45
|
}), [defaultEditorProps, customEditorProps]);
|
|
45
46
|
}
|
|
46
|
-
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false, tooltipMode = "native" }) => {
|
|
47
|
+
const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, editable = true, slots, showToolbar = true, toolbarItems = defaultToolbarItems, editorProps: customEditorProps, immediatelyRender = false, tooltipMode = "native", placeholder }) => {
|
|
47
48
|
const [renderTick, forceRender] = React.useReducer((x) => x + 1, 0);
|
|
48
49
|
const mergedEditorProps = useEditorProps(slots, customEditorProps);
|
|
49
50
|
const onChangeRef = React.useRef(onChange);
|
|
@@ -52,11 +53,15 @@ const RichTextEditor = ({ value, onChange, extensions = defaultExtensions, edita
|
|
|
52
53
|
onChangeRef.current?.(props.editor.getHTML());
|
|
53
54
|
}, []);
|
|
54
55
|
const editorInstance = useEditor({
|
|
55
|
-
extensions: React.useMemo(() =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
extensions: React.useMemo(() => {
|
|
57
|
+
const baseExtensions = [
|
|
58
|
+
StarterKit,
|
|
59
|
+
Link,
|
|
60
|
+
TextAlign.configure({ types: ["heading", "paragraph"] })
|
|
61
|
+
];
|
|
62
|
+
if (placeholder != null) baseExtensions.push(Placeholder.configure({ placeholder }));
|
|
63
|
+
return baseExtensions.concat(extensions);
|
|
64
|
+
}, [extensions, placeholder]),
|
|
60
65
|
content: value,
|
|
61
66
|
editable,
|
|
62
67
|
onUpdate: handleChange,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/shadcn-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.44.0",
|
|
5
5
|
"description": "Custom UI components and utilities built with shadcn/ui.",
|
|
6
6
|
"author": "m.doaie <m.doaie@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@tanstack/react-virtual": "^3.13.18",
|
|
38
38
|
"@tiptap/core": "^3.16.0",
|
|
39
39
|
"@tiptap/extension-link": "^3.16.0",
|
|
40
|
+
"@tiptap/extension-placeholder": "^3.17.1",
|
|
40
41
|
"@tiptap/extension-text-align": "^3.16.0",
|
|
41
42
|
"@tiptap/react": "^3.16.0",
|
|
42
43
|
"@tiptap/starter-kit": "^3.16.0",
|