@npm-questionpro/wick-ui-editor 2.1.1 → 2.1.2
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/WuContentEditor.d.ts +47 -0
- package/dist/html/WuHtmlSource.d.ts +3 -0
- package/dist/html/index.d.ts +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/internal/Button.d.ts +7 -0
- package/dist/internal/Dropdown.d.ts +22 -0
- package/dist/internal/Input.d.ts +5 -0
- package/dist/internal/Item.d.ts +6 -0
- package/dist/internal/Modal.d.ts +13 -0
- package/dist/internal/Switch.d.ts +8 -0
- package/dist/internal/Toolbar.d.ts +35 -0
- package/dist/internal/extensions/Alignment.d.ts +2 -0
- package/dist/internal/extensions/BgColor.d.ts +2 -0
- package/dist/internal/extensions/Block.d.ts +2 -0
- package/dist/internal/extensions/Blockquote.d.ts +2 -0
- package/dist/internal/extensions/Bold.d.ts +2 -0
- package/dist/internal/extensions/ClearFormat.d.ts +2 -0
- package/dist/internal/extensions/CodeLine.d.ts +1 -0
- package/dist/internal/extensions/EmbedImage.d.ts +2 -0
- package/dist/internal/extensions/EmbedLink.d.ts +2 -0
- package/dist/internal/extensions/EmbedTable.d.ts +2 -0
- package/dist/internal/extensions/Family.d.ts +2 -0
- package/dist/internal/extensions/HtmlSource.d.ts +2 -0
- package/dist/internal/extensions/Italic.d.ts +2 -0
- package/dist/internal/extensions/List.d.ts +2 -0
- package/dist/internal/extensions/Size.d.ts +2 -0
- package/dist/internal/extensions/Strikethrough.d.ts +2 -0
- package/dist/internal/extensions/Subscript.d.ts +2 -0
- package/dist/internal/extensions/Superscript.d.ts +2 -0
- package/dist/internal/extensions/TextColor.d.ts +2 -0
- package/dist/internal/extensions/Underline.d.ts +2 -0
- package/dist/internal/extensions/index.d.ts +2 -0
- package/dist/utils/cx.d.ts +1 -0
- package/dist/utils/icons.d.ts +33 -0
- package/dist/utils/sanitize.d.ts +8 -0
- package/dist/utils/useToolbar.d.ts +22 -0
- package/package.json +4 -4
- package/dist/html.d.ts +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IToolbarExtensionKey } from './internal/Toolbar';
|
|
3
|
+
/** Props received by the injected HTML Source view (see the `./html` subpath export). */
|
|
4
|
+
export interface IWuHtmlSourceProps {
|
|
5
|
+
/** Initial raw HTML to populate the source view. */
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
/** Fires on every keystroke with the current raw HTML. */
|
|
8
|
+
onUpdate?: (content: string) => void;
|
|
9
|
+
/** When `true`, the textarea is disabled. */
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IWuContentEditorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
/** Initial HTML content (auto-sanitized on mount). */
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
/** Fires on every editor change with the sanitized HTML output. */
|
|
16
|
+
onUpdate?: (content: string) => void;
|
|
17
|
+
/** Extra font-family names appended to the font-family picker. */
|
|
18
|
+
customFonts?: string[];
|
|
19
|
+
/** Sticky toolbar placement relative to the content area. @default 'top' */
|
|
20
|
+
toolbarPosition?: 'top' | 'bottom';
|
|
21
|
+
/** Additional React nodes appended inside the toolbar. */
|
|
22
|
+
customToolbarChildren?: React.ReactNode;
|
|
23
|
+
/** Subset of toolbar items to render; defaults to all items. */
|
|
24
|
+
toolbarItems?: IToolbarExtensionKey[];
|
|
25
|
+
/** Hides the toolbar entirely. */
|
|
26
|
+
hideToolbar?: boolean;
|
|
27
|
+
/** Disables editing; content is display-only. */
|
|
28
|
+
readonly?: boolean;
|
|
29
|
+
/** Moves focus into the editor on mount. */
|
|
30
|
+
autoFocus?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* HTML Source view component, e.g. `WuHtmlSource` from
|
|
33
|
+
* `@npm-questionpro/wick-ui-editor/html`. When omitted, HTML Source Mode
|
|
34
|
+
* and its toolbar button are disabled.
|
|
35
|
+
*/
|
|
36
|
+
htmlSource?: React.ComponentType<IWuHtmlSourceProps>;
|
|
37
|
+
/** Controlled HTML Source Mode state. Only meaningful when `htmlSource` is provided. */
|
|
38
|
+
isHtml?: boolean;
|
|
39
|
+
/** Setter for controlled `isHtml`. Only meaningful when `htmlSource` is provided. */
|
|
40
|
+
setIsHtml?: (isHtml: boolean) => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Rich-text editing surface with a configurable toolbar, backed by TipTap.
|
|
44
|
+
*
|
|
45
|
+
* @summary content creation — reach for this when users need to compose or edit formatted HTML content
|
|
46
|
+
*/
|
|
47
|
+
export declare function WuContentEditor({ defaultValue, onUpdate, className, toolbarPosition, customToolbarChildren, toolbarItems, hideToolbar, readonly, autoFocus, customFonts, htmlSource: HtmlSourceView, isHtml: isHtmlProp, setIsHtml: setIsHtmlProp, ...props }: IWuContentEditorProps): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { }
|
|
1
|
+
export { WuContentEditor } from './WuContentEditor';
|
|
2
|
+
export type { IWuContentEditorProps, IWuHtmlSourceProps } from './WuContentEditor';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
variant?: 'primary' | 'secondary';
|
|
4
|
+
color?: 'primary' | 'error';
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Button: React.ForwardRefExoticComponent<IButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IDropdownItemProps {
|
|
3
|
+
id: string;
|
|
4
|
+
icon?: React.ReactElement;
|
|
5
|
+
label?: string;
|
|
6
|
+
event: () => boolean | void;
|
|
7
|
+
tooltip?: string;
|
|
8
|
+
active?: boolean;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
interface IDropdownProps {
|
|
12
|
+
trigger: React.ReactElement;
|
|
13
|
+
triggerTitle?: string;
|
|
14
|
+
active?: boolean;
|
|
15
|
+
items: IDropdownItemProps[];
|
|
16
|
+
align?: 'start' | 'center' | 'end';
|
|
17
|
+
direction?: 'inline' | 'block';
|
|
18
|
+
}
|
|
19
|
+
export declare const DropdownPopup: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export declare const DropdownItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export declare function Dropdown({ trigger, triggerTitle, active, items, align, direction, }: IDropdownProps): React.JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IButtonProps } from './Button';
|
|
3
|
+
interface IModalProps {
|
|
4
|
+
Trigger: React.ReactElement;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
maxWidth?: string;
|
|
7
|
+
footer?: React.ReactNode;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function Modal({ Trigger, children, maxWidth, onOpenChange, footer }: IModalProps): React.JSX.Element;
|
|
11
|
+
type IModalCloseProps = Omit<IButtonProps, 'ref'>;
|
|
12
|
+
export declare function ModalClose({ children, variant, color, icon, ...rest }: IModalCloseProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
declare const TOOLBAR_EXTENSIONS: {
|
|
3
|
+
block: import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
fontFamily: import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
fontSize: import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
bold: import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
italic: import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
underline: import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
strike: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
color: import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
bgColor: import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
list: import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
alignment: import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
image: import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
link: import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
table: import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
blockquote: import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
superscript: import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
subscript: import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
codeline: import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
clear: import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
'|': import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
html: import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
};
|
|
25
|
+
export type IToolbarExtensionKey = keyof typeof TOOLBAR_EXTENSIONS;
|
|
26
|
+
export interface IToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
27
|
+
editor: Editor;
|
|
28
|
+
customFonts?: string[];
|
|
29
|
+
items?: IToolbarExtensionKey[];
|
|
30
|
+
isHtml: boolean;
|
|
31
|
+
setIsHtml: (isHtml: boolean) => void;
|
|
32
|
+
htmlSourceEnabled: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const Toolbar: React.FC<IToolbarProps>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CodeLine: React.FC;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cx(...parts: Array<string | false | null | undefined>): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type IIconProps = React.SVGProps<SVGSVGElement>;
|
|
3
|
+
export declare const BoldIcon: React.FC<IIconProps>;
|
|
4
|
+
export declare const ItalicIcon: React.FC<IIconProps>;
|
|
5
|
+
export declare const UnderlineIcon: React.FC<IIconProps>;
|
|
6
|
+
export declare const StrikethroughIcon: React.FC<IIconProps>;
|
|
7
|
+
export declare const TextColorIcon: React.FC<IIconProps>;
|
|
8
|
+
export declare const BgColorIcon: React.FC<IIconProps>;
|
|
9
|
+
export declare const QuoteIcon: React.FC<IIconProps>;
|
|
10
|
+
export declare const CodeIcon: React.FC<IIconProps>;
|
|
11
|
+
export declare const HtmlIcon: React.FC<IIconProps>;
|
|
12
|
+
export declare const DataObjectIcon: React.FC<IIconProps>;
|
|
13
|
+
export declare const SubscriptIcon: React.FC<IIconProps>;
|
|
14
|
+
export declare const SuperscriptIcon: React.FC<IIconProps>;
|
|
15
|
+
export declare const ImageIcon: React.FC<IIconProps>;
|
|
16
|
+
export declare const LinkIcon: React.FC<IIconProps>;
|
|
17
|
+
export declare const TableIcon: React.FC<IIconProps>;
|
|
18
|
+
export declare const ClearFormatIcon: React.FC<IIconProps>;
|
|
19
|
+
export declare const AlignLeftIcon: React.FC<IIconProps>;
|
|
20
|
+
export declare const AlignCenterIcon: React.FC<IIconProps>;
|
|
21
|
+
export declare const AlignRightIcon: React.FC<IIconProps>;
|
|
22
|
+
export declare const AlignJustifyIcon: React.FC<IIconProps>;
|
|
23
|
+
export declare const ParagraphIcon: React.FC<IIconProps>;
|
|
24
|
+
export declare const H1Icon: React.FC<IIconProps>;
|
|
25
|
+
export declare const H2Icon: React.FC<IIconProps>;
|
|
26
|
+
export declare const H3Icon: React.FC<IIconProps>;
|
|
27
|
+
export declare const H4Icon: React.FC<IIconProps>;
|
|
28
|
+
export declare const ListBulletedIcon: React.FC<IIconProps>;
|
|
29
|
+
export declare const ListNumberedIcon: React.FC<IIconProps>;
|
|
30
|
+
export declare const ChecklistIcon: React.FC<IIconProps>;
|
|
31
|
+
export declare const AddIcon: React.FC<IIconProps>;
|
|
32
|
+
export declare const CloseIcon: React.FC<IIconProps>;
|
|
33
|
+
export declare const DeleteIcon: React.FC<IIconProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface IToolbarContextProps {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
customFonts?: string[];
|
|
6
|
+
isHtml: boolean;
|
|
7
|
+
setIsHtml: (isHtml: boolean) => void;
|
|
8
|
+
/** Whether an HTML source view is provided via the `htmlSource` prop. */
|
|
9
|
+
htmlSourceEnabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToolbarContext: React.Context<IToolbarContextProps | null>;
|
|
12
|
+
interface IToolbarProviderProps {
|
|
13
|
+
editor: Editor;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
customFonts?: string[];
|
|
16
|
+
isHtml: boolean;
|
|
17
|
+
setIsHtml: (isHtml: boolean) => void;
|
|
18
|
+
htmlSourceEnabled: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const ToolbarProvider: ({ editor, children, customFonts, isHtml, setIsHtml, htmlSourceEnabled, }: IToolbarProviderProps) => React.JSX.Element;
|
|
21
|
+
export declare const useToolbar: () => IToolbarContextProps;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npm-questionpro/wick-ui-editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Wick Editor is a powerful and intuitive content editing component built with React. It provides a rich set of features for creating and managing content, making it ideal for applications that require dynamic and interactive content creation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"import": "./dist/wick-ui-editor/es/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./html": {
|
|
32
|
-
"types": "./dist/html.d.ts",
|
|
32
|
+
"types": "./dist/html/index.d.ts",
|
|
33
33
|
"import": "./dist/wick-ui-editor/es/html.js"
|
|
34
34
|
},
|
|
35
35
|
"./dist/style.css": "./dist/style.css"
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"vite-plugin-dts": "^4.5.4",
|
|
99
99
|
"vitest": "^4.1.8",
|
|
100
100
|
"@npm-questionpro/wick-ui-eslint-config": "1.0.0",
|
|
101
|
-
"@npm-questionpro/wick-ui-lib": "2.1.
|
|
101
|
+
"@npm-questionpro/wick-ui-lib": "2.1.2",
|
|
102
102
|
"@wick-ui/tsconfig": "1.0.0"
|
|
103
103
|
},
|
|
104
104
|
"scripts": {
|
|
105
|
-
"build": "tsc --noEmit && vite build",
|
|
105
|
+
"build": "tsc --noEmit && vite build && tsc -p tsconfig.types.json",
|
|
106
106
|
"lint": "eslint ./src --fix",
|
|
107
107
|
"lint:ci": "tsc --noEmit && eslint --max-warnings 0 ./src",
|
|
108
108
|
"test": "vitest run",
|
package/dist/html.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { }
|