@trycourier/react-designer 0.0.0-canary-20251211163746 → 0.0.0-canary-20251229151230
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/README.md +244 -2
- package/dist/cjs/index.js +71 -56
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/styles.css +292 -161
- package/dist/components/BrandEditor/Editor/Editor.d.ts +16 -1
- package/dist/components/Providers/api/template.d.ts +28 -1
- package/dist/components/Providers/store.d.ts +6 -0
- package/dist/components/Providers/useBrandActions.d.ts +1 -1
- package/dist/components/Providers/useTemplateActions.d.ts +6 -4
- package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +2 -1
- package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBar.d.ts +6 -3
- package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/SideBar.d.ts +2 -3
- package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Push/PushLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Slack/SideBar/SideBar.d.ts +2 -3
- package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/useChannels.d.ts +8 -0
- package/dist/components/TemplateEditor/TemplateEditor.d.ts +16 -1
- package/dist/components/TemplateEditor/hooks/usePragmaticDnd.d.ts +3 -2
- package/dist/components/TemplateEditor/hooks/useSyncEditorItems.d.ts +2 -1
- package/dist/components/TemplateEditor/index.d.ts +2 -14
- package/dist/components/TemplateEditor/store.d.ts +131 -0
- package/dist/components/extensions/Blockquote/Blockquote.types.d.ts +2 -2
- package/dist/components/extensions/Button/Button.types.d.ts +12 -12
- package/dist/components/extensions/Column/Column.types.d.ts +6 -6
- package/dist/components/extensions/Divider/Divider.types.d.ts +1 -1
- package/dist/components/extensions/ImageBlock/ImageBlock.types.d.ts +4 -4
- package/dist/components/extensions/List/List.d.ts +15 -0
- package/dist/components/extensions/List/List.types.d.ts +9 -0
- package/dist/components/extensions/List/ListComponent.d.ts +9 -0
- package/dist/components/extensions/List/ListForm.d.ts +8 -0
- package/dist/components/extensions/List/index.d.ts +3 -0
- package/dist/components/extensions/ListItem/ListItem.d.ts +34 -0
- package/dist/components/extensions/ListItem/ListItem.types.d.ts +7 -0
- package/dist/components/extensions/ListItem/ListItemComponent.d.ts +7 -0
- package/dist/components/extensions/ListItem/index.d.ts +2 -0
- package/dist/components/extensions/TextBlock/TextBlock.types.d.ts +4 -4
- package/dist/components/extensions/Variable/Variable.d.ts +14 -1
- package/dist/components/extensions/Variable/Variable.types.d.ts +37 -0
- package/dist/components/extensions/Variable/VariableSuggestions.d.ts +7 -0
- package/dist/components/extensions/Variable/index.d.ts +1 -0
- package/dist/components/extensions/Variable/suggestion.d.ts +2 -0
- package/dist/components/extensions/extension-kit.d.ts +7 -2
- package/dist/components/extensions/index.d.ts +3 -1
- package/dist/components/hooks/index.d.ts +1 -0
- package/dist/components/hooks/useBlockConfig.d.ts +110 -0
- package/dist/components/ui/Blocks/CustomCodeBlock/index.d.ts +1 -1
- package/dist/components/ui/Blocks/ListBlock/ListBlock.d.ts +3 -0
- package/dist/components/ui/Blocks/ListBlock/index.d.ts +1 -0
- package/dist/components/ui/Blocks/index.d.ts +1 -0
- package/dist/components/ui/FormHeader/FormHeader.d.ts +1 -1
- package/dist/components/ui/VariableEditor/VariableAutocomplete.d.ts +16 -0
- package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +2 -0
- package/dist/components/ui/VariableEditor/VariableEditorToolbar.d.ts +15 -0
- package/dist/components/ui/VariableEditor/VariableInput.d.ts +2 -0
- package/dist/components/ui/VariableEditor/VariableTextarea.d.ts +2 -0
- package/dist/components/ui/VariableEditor/index.d.ts +2 -0
- package/dist/esm/index.js +71 -56
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/styles.css +292 -161
- package/dist/index.d.ts +14 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/styles.css +292 -161
- package/dist/types/elemental.schema.d.ts +3 -3
- package/dist/types/elemental.types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/validation.types.d.ts +53 -0
- package/package.json +1 -1
|
@@ -13,31 +13,31 @@ export declare const buttonSchema: z.ZodObject<{
|
|
|
13
13
|
textColor: z.ZodOptional<z.ZodString>;
|
|
14
14
|
borderColor: z.ZodOptional<z.ZodString>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
padding: number;
|
|
17
|
-
label: string;
|
|
18
16
|
backgroundColor: string;
|
|
19
|
-
alignment: "left" | "center" | "right";
|
|
20
17
|
borderRadius: number;
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
label: string;
|
|
19
|
+
alignment: "left" | "center" | "right";
|
|
20
|
+
padding: number;
|
|
21
|
+
fontWeight: "normal" | "bold";
|
|
22
|
+
fontStyle: "normal" | "italic";
|
|
23
23
|
isUnderline: boolean;
|
|
24
24
|
isStrike: boolean;
|
|
25
25
|
link?: string | undefined;
|
|
26
|
-
textColor?: string | undefined;
|
|
27
26
|
borderColor?: string | undefined;
|
|
27
|
+
textColor?: string | undefined;
|
|
28
28
|
}, {
|
|
29
|
-
padding: number;
|
|
30
|
-
label: string;
|
|
31
29
|
backgroundColor: string;
|
|
32
|
-
alignment: "left" | "center" | "right";
|
|
33
30
|
borderRadius: number;
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
label: string;
|
|
32
|
+
alignment: "left" | "center" | "right";
|
|
33
|
+
padding: number;
|
|
34
|
+
fontWeight: "normal" | "bold";
|
|
35
|
+
fontStyle: "normal" | "italic";
|
|
36
36
|
isUnderline: boolean;
|
|
37
37
|
isStrike: boolean;
|
|
38
38
|
link?: string | undefined;
|
|
39
|
-
textColor?: string | undefined;
|
|
40
39
|
borderColor?: string | undefined;
|
|
40
|
+
textColor?: string | undefined;
|
|
41
41
|
}>;
|
|
42
42
|
export interface ButtonProps {
|
|
43
43
|
label: string;
|
|
@@ -20,22 +20,22 @@ export declare const columnSchema: z.ZodObject<{
|
|
|
20
20
|
}>, "many">>;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
22
|
backgroundColor: string;
|
|
23
|
-
paddingVertical: number;
|
|
24
|
-
paddingHorizontal: number;
|
|
25
|
-
borderWidth: number;
|
|
26
23
|
borderColor: string;
|
|
24
|
+
borderWidth: number;
|
|
27
25
|
borderRadius: number;
|
|
26
|
+
paddingVertical: number;
|
|
27
|
+
paddingHorizontal: number;
|
|
28
28
|
columnsCount: number;
|
|
29
29
|
cells?: {
|
|
30
30
|
elements: any[];
|
|
31
31
|
}[] | undefined;
|
|
32
32
|
}, {
|
|
33
33
|
backgroundColor?: string | undefined;
|
|
34
|
-
paddingVertical?: number | undefined;
|
|
35
|
-
paddingHorizontal?: number | undefined;
|
|
36
|
-
borderWidth?: number | undefined;
|
|
37
34
|
borderColor?: string | undefined;
|
|
35
|
+
borderWidth?: number | undefined;
|
|
38
36
|
borderRadius?: number | undefined;
|
|
37
|
+
paddingVertical?: number | undefined;
|
|
38
|
+
paddingHorizontal?: number | undefined;
|
|
39
39
|
columnsCount?: number | undefined;
|
|
40
40
|
cells?: {
|
|
41
41
|
elements: any[];
|
|
@@ -10,21 +10,21 @@ export declare const imageBlockSchema: z.ZodObject<{
|
|
|
10
10
|
isUploading: z.ZodOptional<z.ZodBoolean>;
|
|
11
11
|
imageNaturalWidth: z.ZodNumber;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
width: number;
|
|
14
|
-
borderWidth: number;
|
|
15
13
|
borderColor: string;
|
|
14
|
+
borderWidth: number;
|
|
16
15
|
alignment: "left" | "center" | "right";
|
|
17
16
|
sourcePath: string;
|
|
17
|
+
width: number;
|
|
18
18
|
imageNaturalWidth: number;
|
|
19
19
|
link?: string | undefined;
|
|
20
20
|
alt?: string | undefined;
|
|
21
21
|
isUploading?: boolean | undefined;
|
|
22
22
|
}, {
|
|
23
|
-
width: number;
|
|
24
|
-
borderWidth: number;
|
|
25
23
|
borderColor: string;
|
|
24
|
+
borderWidth: number;
|
|
26
25
|
alignment: "left" | "center" | "right";
|
|
27
26
|
sourcePath: string;
|
|
27
|
+
width: number;
|
|
28
28
|
imageNaturalWidth: number;
|
|
29
29
|
link?: string | undefined;
|
|
30
30
|
alt?: string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
import type { ListProps } from "./List.types";
|
|
3
|
+
declare module "@tiptap/core" {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
list: {
|
|
6
|
+
setList: (props?: Partial<ListProps>) => ReturnType;
|
|
7
|
+
toggleList: () => ReturnType;
|
|
8
|
+
toggleOrderedList: () => ReturnType;
|
|
9
|
+
toggleBulletList: () => ReturnType;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const defaultListProps: ListProps;
|
|
14
|
+
export declare const List: Node<any, any>;
|
|
15
|
+
export default List;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ListProps {
|
|
2
|
+
/** Whether the list is ordered (numbered) or unordered (bulleted) */
|
|
3
|
+
listType: "ordered" | "unordered";
|
|
4
|
+
/** Unique identifier for the list node */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Locale-specific content overrides */
|
|
7
|
+
locales?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare const defaultListProps: ListProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type NodeViewProps } from "@tiptap/react";
|
|
2
|
+
/**
|
|
3
|
+
* List NodeView component that renders the list.
|
|
4
|
+
*
|
|
5
|
+
* Uses SortableItemWrapper for proper drag-and-drop reordering,
|
|
6
|
+
* selection styling, and action buttons (duplicate, delete).
|
|
7
|
+
*/
|
|
8
|
+
export declare const ListComponentNode: (props: NodeViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default ListComponentNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
import type { Node } from "@tiptap/pm/model";
|
|
3
|
+
interface ListFormProps {
|
|
4
|
+
element: Node;
|
|
5
|
+
editor: Editor | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const ListForm: ({ element, editor }: ListFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export default ListForm;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
import type { ListItemProps } from "./ListItem.types";
|
|
3
|
+
declare module "@tiptap/core" {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
listItem: {
|
|
6
|
+
/** Split the list item at the current cursor position */
|
|
7
|
+
splitListItem: (typeOrName: string) => ReturnType;
|
|
8
|
+
/** Lift the list item out of the list (outdent) */
|
|
9
|
+
liftListItem: (typeOrName: string) => ReturnType;
|
|
10
|
+
/** Sink the list item into a nested list (indent) */
|
|
11
|
+
sinkListItem: (typeOrName: string) => ReturnType;
|
|
12
|
+
/** Wrap selection in a list */
|
|
13
|
+
wrapInList: (typeOrName: string, attrs?: Record<string, unknown>) => ReturnType;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const defaultListItemProps: ListItemProps;
|
|
18
|
+
/**
|
|
19
|
+
* Custom ListItem extension with prosemirror-schema-list commands.
|
|
20
|
+
*
|
|
21
|
+
* Provides commands:
|
|
22
|
+
* - splitListItem: Split list item at cursor (creates new bullet)
|
|
23
|
+
* - liftListItem: Lift list item out of list (outdent)
|
|
24
|
+
* - sinkListItem: Sink list item into nested list (indent)
|
|
25
|
+
* - wrapInList: Wrap selection in a list
|
|
26
|
+
*
|
|
27
|
+
* Keyboard shortcuts:
|
|
28
|
+
* - Enter: Split list item (handled in List extension)
|
|
29
|
+
* - Tab: Sink list item (handled in List extension)
|
|
30
|
+
* - Shift-Tab: Lift list item (handled in List extension)
|
|
31
|
+
* - Shift-Enter: Add a hard break (new line within the paragraph)
|
|
32
|
+
*/
|
|
33
|
+
export declare const ListItem: Node<any, any>;
|
|
34
|
+
export default ListItem;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type NodeViewProps } from "@tiptap/react";
|
|
2
|
+
/**
|
|
3
|
+
* Simple ListItem NodeView that renders as a standard <li> element.
|
|
4
|
+
* Uses NodeViewContent to allow prosemirror to manage the content.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ListItemComponentNode: (props: NodeViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default ListItemComponentNode;
|
|
@@ -10,19 +10,19 @@ export declare const textBlockSchema: z.ZodObject<{
|
|
|
10
10
|
id: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
12
|
backgroundColor: string;
|
|
13
|
+
borderColor: string;
|
|
14
|
+
borderWidth: number;
|
|
13
15
|
paddingVertical: number;
|
|
14
16
|
paddingHorizontal: number;
|
|
15
|
-
borderWidth: number;
|
|
16
|
-
borderColor: string;
|
|
17
17
|
textAlign: "left" | "center" | "right" | "justify";
|
|
18
18
|
selected: boolean;
|
|
19
19
|
id?: string | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
backgroundColor: string;
|
|
22
|
+
borderColor: string;
|
|
23
|
+
borderWidth: number;
|
|
22
24
|
paddingVertical: number;
|
|
23
25
|
paddingHorizontal: number;
|
|
24
|
-
borderWidth: number;
|
|
25
|
-
borderColor: string;
|
|
26
26
|
id?: string | undefined;
|
|
27
27
|
textAlign?: "left" | "center" | "right" | "justify" | undefined;
|
|
28
28
|
selected?: boolean | undefined;
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { Extension, Node } from "@tiptap/core";
|
|
2
|
-
import type { VariableNodeOptions } from "./Variable.types";
|
|
2
|
+
import type { VariableNodeOptions, VariableOptions } from "./Variable.types";
|
|
3
3
|
export declare const VariableNode: Node<VariableNodeOptions, any>;
|
|
4
4
|
/**
|
|
5
5
|
* Extension that inserts an empty variable chip when user types {{
|
|
6
|
+
* This is used when autocomplete is disabled (disableVariablesAutocomplete=true)
|
|
6
7
|
*/
|
|
7
8
|
export declare const VariableInputRule: Extension<any, any>;
|
|
9
|
+
/**
|
|
10
|
+
* Extension that provides variable autocomplete suggestions.
|
|
11
|
+
* When user types {{, shows a dropdown with available variables.
|
|
12
|
+
* Pass `variables` option to configure available variables.
|
|
13
|
+
* Pass `disableSuggestions: true` to disable autocomplete (falls back to VariableInputRule behavior).
|
|
14
|
+
*/
|
|
15
|
+
export declare const Variable: Extension<VariableOptions, any>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated This extension has been removed. Variable conversion now happens via VariableInputRule or Variable.
|
|
18
|
+
* This is a no-op extension provided for backwards compatibility and will be removed in a future major version.
|
|
19
|
+
*/
|
|
20
|
+
export declare const VariableTypeHandler: Extension<any, any>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Editor, Range } from "@tiptap/core";
|
|
2
|
+
import type { SuggestionOptions, SuggestionProps } from "@tiptap/suggestion";
|
|
1
3
|
export interface VariableNodeOptions {
|
|
2
4
|
HTMLAttributes?: Record<string, unknown>;
|
|
3
5
|
}
|
|
@@ -5,3 +7,38 @@ export interface VariableNodeAttributes {
|
|
|
5
7
|
id: string;
|
|
6
8
|
isInvalid: boolean;
|
|
7
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Options for the Variable suggestion extension that provides autocomplete.
|
|
12
|
+
*/
|
|
13
|
+
export interface VariableOptions {
|
|
14
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
15
|
+
suggestion?: Partial<SuggestionOptions>;
|
|
16
|
+
/** Variables available for autocomplete suggestions */
|
|
17
|
+
variables?: Record<string, unknown>;
|
|
18
|
+
/** When true, disables the autocomplete dropdown */
|
|
19
|
+
disableSuggestions?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface VariableCommandProps {
|
|
22
|
+
editor: Editor;
|
|
23
|
+
range: Range;
|
|
24
|
+
props: string;
|
|
25
|
+
}
|
|
26
|
+
export interface VariableSuggestionProps {
|
|
27
|
+
editor: Editor;
|
|
28
|
+
range: Range;
|
|
29
|
+
clientRect: () => DOMRect | null;
|
|
30
|
+
items: string[];
|
|
31
|
+
command: (props: {
|
|
32
|
+
editor: Editor;
|
|
33
|
+
range: Range;
|
|
34
|
+
props: string;
|
|
35
|
+
}) => void;
|
|
36
|
+
selected: number;
|
|
37
|
+
}
|
|
38
|
+
export interface VariableSuggestionsProps extends SuggestionProps {
|
|
39
|
+
items: string[];
|
|
40
|
+
command: (item: string) => void;
|
|
41
|
+
editor: Editor;
|
|
42
|
+
query: string;
|
|
43
|
+
selected: number;
|
|
44
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Node } from "@tiptap/pm/model";
|
|
2
|
-
export
|
|
2
|
+
export interface ExtensionKitOptions {
|
|
3
3
|
setSelectedNode?: (node: Node) => void;
|
|
4
4
|
shouldHandleClick?: () => boolean;
|
|
5
|
-
|
|
5
|
+
/** Variables available for autocomplete suggestions */
|
|
6
|
+
variables?: Record<string, unknown>;
|
|
7
|
+
/** When true, disables variable autocomplete and allows typing any variable */
|
|
8
|
+
disableVariablesAutocomplete?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const ExtensionKit: (options?: ExtensionKitOptions) => (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any>)[];
|
|
6
11
|
export default ExtensionKit;
|
|
@@ -23,8 +23,10 @@ export { FixedChannelSelection } from "./FixedChannelSelection";
|
|
|
23
23
|
export { Heading } from "./Heading";
|
|
24
24
|
export { ImageBlock } from "./ImageBlock";
|
|
25
25
|
export { Link } from "./Link";
|
|
26
|
+
export { List } from "./List";
|
|
27
|
+
export { ListItem } from "./ListItem";
|
|
26
28
|
export { Paragraph } from "./Paragraph";
|
|
27
29
|
export { Selection } from "./Selection";
|
|
28
30
|
export { SlashMenu } from "./SlashMenu";
|
|
29
31
|
export { UniqueId } from "./UniqueId";
|
|
30
|
-
export { VariableNode, VariableInputRule, VariablePaste } from "./Variable";
|
|
32
|
+
export { VariableNode, VariableInputRule, VariablePaste, Variable, VariableTypeHandler, } from "./Variable";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type BlockElementType, type BlockAttributes, type BlockPreset, type VisibleBlockItem, type PresetReference } from "../TemplateEditor/store";
|
|
2
|
+
export interface UseBlockConfigResult {
|
|
3
|
+
/**
|
|
4
|
+
* Currently visible blocks in the sidebar.
|
|
5
|
+
* Can include both built-in block types and preset references.
|
|
6
|
+
*/
|
|
7
|
+
visibleBlocks: VisibleBlockItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Set which blocks are visible in the sidebar (and their order).
|
|
10
|
+
* Use strings for built-in blocks and { type, preset } for presets.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* setVisibleBlocks([
|
|
14
|
+
* 'text',
|
|
15
|
+
* { type: 'button', preset: 'portal' }, // preset between text and image
|
|
16
|
+
* 'image',
|
|
17
|
+
* 'button',
|
|
18
|
+
* ]);
|
|
19
|
+
*/
|
|
20
|
+
setVisibleBlocks: (blocks: VisibleBlockItem[]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Reset visible blocks to defaults
|
|
23
|
+
*/
|
|
24
|
+
resetVisibleBlocks: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* Default visible blocks for reference
|
|
27
|
+
*/
|
|
28
|
+
defaultVisibleBlocks: VisibleBlockItem[];
|
|
29
|
+
/**
|
|
30
|
+
* Set default attributes for a block type.
|
|
31
|
+
* These defaults are applied when creating new blocks of this type.
|
|
32
|
+
*/
|
|
33
|
+
setDefaults: (type: BlockElementType, defaults: BlockAttributes) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Get default attributes for a block type
|
|
36
|
+
*/
|
|
37
|
+
getDefaults: (type: BlockElementType) => BlockAttributes | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Clear defaults for a block type (revert to built-in defaults)
|
|
40
|
+
*/
|
|
41
|
+
clearDefaults: (type: BlockElementType) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Register a block preset (pre-configured variant of a block type)
|
|
44
|
+
*/
|
|
45
|
+
registerPreset: (preset: BlockPreset) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Unregister a preset by type and key
|
|
48
|
+
*/
|
|
49
|
+
unregisterPreset: (type: BlockElementType, key: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered presets
|
|
52
|
+
*/
|
|
53
|
+
presets: BlockPreset[];
|
|
54
|
+
/**
|
|
55
|
+
* Get presets for a specific block type
|
|
56
|
+
*/
|
|
57
|
+
getPresetsForType: (type: BlockElementType) => BlockPreset[];
|
|
58
|
+
/**
|
|
59
|
+
* Insert a block at the end of the document.
|
|
60
|
+
* If presetKey is provided, uses the preset's attributes.
|
|
61
|
+
* Otherwise, uses the type's defaults (if set).
|
|
62
|
+
*/
|
|
63
|
+
insertBlock: (type: BlockElementType, presetKey?: string) => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Hook to configure and manage block elements in the editor.
|
|
67
|
+
*
|
|
68
|
+
* This hook provides a comprehensive API for:
|
|
69
|
+
* - Controlling which blocks appear in the sidebar and their order
|
|
70
|
+
* - Setting default attributes for block types
|
|
71
|
+
* - Creating and managing block presets (pre-configured variants)
|
|
72
|
+
* - Programmatically inserting blocks
|
|
73
|
+
*
|
|
74
|
+
* @returns Object containing all block configuration functions and state
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* const {
|
|
79
|
+
* visibleBlocks,
|
|
80
|
+
* setVisibleBlocks,
|
|
81
|
+
* setDefaults,
|
|
82
|
+
* registerPreset,
|
|
83
|
+
* insertBlock,
|
|
84
|
+
* } = useBlockConfig();
|
|
85
|
+
*
|
|
86
|
+
* // Register a preset first
|
|
87
|
+
* registerPreset({
|
|
88
|
+
* type: 'button',
|
|
89
|
+
* key: 'portal',
|
|
90
|
+
* label: 'Go to Portal',
|
|
91
|
+
* attributes: { href: 'https://portal.example.com', content: 'Go to Portal' }
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Control which blocks appear in sidebar (including presets)
|
|
95
|
+
* setVisibleBlocks([
|
|
96
|
+
* 'text',
|
|
97
|
+
* { type: 'button', preset: 'portal' }, // Preset between text and image
|
|
98
|
+
* 'image',
|
|
99
|
+
* 'button',
|
|
100
|
+
* ]);
|
|
101
|
+
*
|
|
102
|
+
* // Set defaults for all new buttons
|
|
103
|
+
* setDefaults('button', { borderRadius: '4px', backgroundColor: '#007bff' });
|
|
104
|
+
*
|
|
105
|
+
* // Insert a block programmatically
|
|
106
|
+
* insertBlock('button', 'portal');
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare const useBlockConfig: () => UseBlockConfigResult;
|
|
110
|
+
export type { BlockElementType, BlockAttributes, BlockPreset, VisibleBlockItem, PresetReference };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./CustomCodeBlock";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ListBlock";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface FormHeaderProps {
|
|
2
|
-
type: "text" | "image" | "spacer" | "divider" | "button" | "blockquote" | "heading" | "customCode" | "column";
|
|
2
|
+
type: "text" | "image" | "spacer" | "divider" | "button" | "blockquote" | "heading" | "customCode" | "column" | "list";
|
|
3
3
|
label?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare const FormHeader: ({ type }: FormHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface VariableAutocompleteProps {
|
|
3
|
+
/** List of variable suggestions to show */
|
|
4
|
+
items: string[];
|
|
5
|
+
/** Called when an item is selected */
|
|
6
|
+
onSelect: (item: string) => void;
|
|
7
|
+
/** Currently selected index */
|
|
8
|
+
selectedIndex: number;
|
|
9
|
+
/** Reference element to position the dropdown near */
|
|
10
|
+
anchorRef: React.RefObject<HTMLElement>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Autocomplete dropdown for variable suggestions.
|
|
14
|
+
* Shows a list of available variables that can be selected.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VariableAutocomplete: React.FC<VariableAutocompleteProps>;
|
|
@@ -31,5 +31,7 @@ export interface VariableChipBaseProps {
|
|
|
31
31
|
textColorOverride?: string;
|
|
32
32
|
/** Custom color getter function (kept for API compatibility, colors handled by CSS) */
|
|
33
33
|
getColors?: (isInvalid: boolean, hasValue: boolean) => VariableColors;
|
|
34
|
+
/** Whether the chip is read-only (prevents editing) */
|
|
35
|
+
readOnly?: boolean;
|
|
34
36
|
}
|
|
35
37
|
export declare const VariableChipBase: React.FC<VariableChipBaseProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
export interface VariableEditorToolbarProps {
|
|
3
|
+
editor: Editor | null;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A minimal bubble menu for VariableInput and VariableTextarea
|
|
8
|
+
* that shows only the variable insertion button.
|
|
9
|
+
* Reuses the existing TextMenu component with a variable-only config.
|
|
10
|
+
*
|
|
11
|
+
* Important: This component keeps the BubbleMenu mounted and controls
|
|
12
|
+
* visibility through shouldShow callback to avoid DOM cleanup issues
|
|
13
|
+
* when the editor's editable state changes.
|
|
14
|
+
*/
|
|
15
|
+
export declare const VariableEditorToolbar: React.FC<VariableEditorToolbarProps>;
|
|
@@ -3,6 +3,8 @@ import { type VariableEditorBaseProps } from "./shared";
|
|
|
3
3
|
export interface VariableInputProps extends VariableEditorBaseProps {
|
|
4
4
|
/** Whether the input is read-only */
|
|
5
5
|
readOnly?: boolean;
|
|
6
|
+
/** Whether to show the variable toolbar */
|
|
7
|
+
showToolbar?: boolean;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* A single-line input that renders {{variable}} patterns as styled chips.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariableEditorBaseProps } from "./shared";
|
|
3
3
|
export interface VariableTextareaProps extends VariableEditorBaseProps {
|
|
4
|
+
/** Whether to show the variable toolbar */
|
|
5
|
+
showToolbar?: boolean;
|
|
4
6
|
}
|
|
5
7
|
/**
|
|
6
8
|
* A textarea-like input that renders {{variable}} patterns as styled chips.
|
|
@@ -2,5 +2,7 @@ export { VariableTextarea } from "./VariableTextarea";
|
|
|
2
2
|
export type { VariableTextareaProps } from "./VariableTextarea";
|
|
3
3
|
export { VariableInput } from "./VariableInput";
|
|
4
4
|
export type { VariableInputProps } from "./VariableInput";
|
|
5
|
+
export { VariableEditorToolbar } from "./VariableEditorToolbar";
|
|
6
|
+
export type { VariableEditorToolbarProps } from "./VariableEditorToolbar";
|
|
5
7
|
export { parseStringToContent, contentToString, SimpleVariableNode, SimpleVariableView, VariableChipIcon, } from "./shared";
|
|
6
8
|
export type { VariableEditorBaseProps } from "./shared";
|