@trycourier/react-designer 0.0.0-canary-20251211163746 → 0.0.0-canary-20251219131027

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.
Files changed (62) hide show
  1. package/README.md +244 -2
  2. package/dist/cjs/index.js +70 -56
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +74 -18
  5. package/dist/components/BrandEditor/Editor/Editor.d.ts +16 -1
  6. package/dist/components/Providers/api/template.d.ts +28 -1
  7. package/dist/components/Providers/store.d.ts +6 -0
  8. package/dist/components/Providers/useBrandActions.d.ts +1 -1
  9. package/dist/components/Providers/useTemplateActions.d.ts +6 -4
  10. package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +3 -2
  11. package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +2 -1
  12. package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
  13. package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBar.d.ts +6 -3
  14. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
  15. package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
  16. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +3 -2
  17. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
  18. package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/SideBar.d.ts +2 -3
  19. package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
  20. package/dist/components/TemplateEditor/Channels/Push/PushLayout.d.ts +1 -1
  21. package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
  22. package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
  23. package/dist/components/TemplateEditor/Channels/Slack/SideBar/SideBar.d.ts +2 -3
  24. package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +3 -2
  25. package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
  26. package/dist/components/TemplateEditor/Channels/useChannels.d.ts +8 -0
  27. package/dist/components/TemplateEditor/TemplateEditor.d.ts +16 -1
  28. package/dist/components/TemplateEditor/hooks/usePragmaticDnd.d.ts +3 -2
  29. package/dist/components/TemplateEditor/hooks/useSyncEditorItems.d.ts +2 -1
  30. package/dist/components/TemplateEditor/index.d.ts +2 -14
  31. package/dist/components/TemplateEditor/store.d.ts +131 -0
  32. package/dist/components/extensions/Blockquote/Blockquote.types.d.ts +2 -2
  33. package/dist/components/extensions/Button/Button.types.d.ts +12 -12
  34. package/dist/components/extensions/Column/Column.types.d.ts +6 -6
  35. package/dist/components/extensions/Divider/Divider.types.d.ts +1 -1
  36. package/dist/components/extensions/ImageBlock/ImageBlock.types.d.ts +4 -4
  37. package/dist/components/extensions/TextBlock/TextBlock.types.d.ts +4 -4
  38. package/dist/components/extensions/Variable/Variable.d.ts +14 -1
  39. package/dist/components/extensions/Variable/Variable.types.d.ts +37 -0
  40. package/dist/components/extensions/Variable/VariableSuggestions.d.ts +7 -0
  41. package/dist/components/extensions/Variable/index.d.ts +1 -0
  42. package/dist/components/extensions/Variable/suggestion.d.ts +2 -0
  43. package/dist/components/extensions/extension-kit.d.ts +7 -2
  44. package/dist/components/extensions/index.d.ts +1 -1
  45. package/dist/components/hooks/index.d.ts +1 -0
  46. package/dist/components/hooks/useBlockConfig.d.ts +110 -0
  47. package/dist/components/ui/Blocks/CustomCodeBlock/index.d.ts +1 -1
  48. package/dist/components/ui/VariableEditor/VariableAutocomplete.d.ts +16 -0
  49. package/dist/components/ui/VariableEditor/VariableEditorToolbar.d.ts +15 -0
  50. package/dist/components/ui/VariableEditor/VariableInput.d.ts +2 -0
  51. package/dist/components/ui/VariableEditor/VariableTextarea.d.ts +2 -0
  52. package/dist/components/ui/VariableEditor/index.d.ts +2 -0
  53. package/dist/esm/index.js +70 -56
  54. package/dist/esm/index.js.map +4 -4
  55. package/dist/esm/styles.css +74 -18
  56. package/dist/index.d.ts +14 -0
  57. package/dist/lib/utils/index.d.ts +1 -0
  58. package/dist/styles.css +74 -18
  59. package/dist/types/elemental.schema.d.ts +3 -3
  60. package/dist/types/index.d.ts +1 -0
  61. package/dist/types/validation.types.d.ts +53 -0
  62. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import type { ElementalContent } from "@/types/elemental.types";
2
+ import type { VariableValidationConfig } from "@/types/validation.types";
2
3
  import type { Editor } from "@tiptap/react";
3
4
  export declare const subjectAtom: import("jotai").PrimitiveAtom<string | null> & {
4
5
  init: string | null;
@@ -29,6 +30,15 @@ export declare const isSidebarExpandedAtom: import("jotai").PrimitiveAtom<boolea
29
30
  export declare const variableValuesAtom: import("jotai").PrimitiveAtom<Record<string, string>> & {
30
31
  init: Record<string, string>;
31
32
  };
33
+ export declare const availableVariablesAtom: import("jotai").PrimitiveAtom<Record<string, unknown>> & {
34
+ init: Record<string, unknown>;
35
+ };
36
+ export declare const disableVariablesAutocompleteAtom: import("jotai").PrimitiveAtom<boolean> & {
37
+ init: boolean;
38
+ };
39
+ export declare const variableValidationAtom: import("jotai").PrimitiveAtom<VariableValidationConfig | undefined> & {
40
+ init: VariableValidationConfig | undefined;
41
+ };
32
42
  export declare const isDraggingAtom: import("jotai").PrimitiveAtom<boolean> & {
33
43
  init: boolean;
34
44
  };
@@ -45,3 +55,124 @@ export declare const flushFunctionsAtom: import("jotai").WritableAtom<Map<string
45
55
  fn?: FlushFunction;
46
56
  }], void>;
47
57
  export declare const flushAllPendingUpdates: (flushFunctions: Map<string, FlushFunction>) => void;
58
+ /**
59
+ * Available block element types that can be used in the sidebar
60
+ */
61
+ export type BlockElementType = "heading" | "text" | "image" | "spacer" | "divider" | "button" | "customCode" | "column" | "blockquote";
62
+ /**
63
+ * Attributes that can be set as defaults or in presets for blocks.
64
+ * Types match the actual TipTap node attribute types for each extension.
65
+ */
66
+ export interface BlockAttributes {
67
+ /** Background color (string, e.g., "#ffffff" or "transparent") */
68
+ backgroundColor?: string;
69
+ /** Border color */
70
+ borderColor?: string;
71
+ /** Border width in pixels */
72
+ borderWidth?: number;
73
+ /** Border radius in pixels */
74
+ borderRadius?: number;
75
+ /** Vertical padding in pixels */
76
+ paddingVertical?: number;
77
+ /** Horizontal padding in pixels */
78
+ paddingHorizontal?: number;
79
+ /** Text alignment */
80
+ textAlign?: "left" | "center" | "right" | "justify";
81
+ /** Button label text */
82
+ label?: string;
83
+ /** Button link URL */
84
+ link?: string;
85
+ /** Button alignment */
86
+ alignment?: "left" | "center" | "right";
87
+ /** Button padding in pixels */
88
+ padding?: number;
89
+ /** Font weight */
90
+ fontWeight?: "normal" | "bold";
91
+ /** Font style */
92
+ fontStyle?: "normal" | "italic";
93
+ /** Underline text */
94
+ isUnderline?: boolean;
95
+ /** Strikethrough text */
96
+ isStrike?: boolean;
97
+ /** @deprecated Text color - legacy property */
98
+ textColor?: string;
99
+ /** Divider color */
100
+ color?: string;
101
+ /** Divider line thickness in pixels */
102
+ size?: number;
103
+ /** Divider corner radius */
104
+ radius?: number;
105
+ /** Divider variant type */
106
+ variant?: "divider" | "spacer";
107
+ /** Image source path/URL */
108
+ sourcePath?: string;
109
+ /** Image alt text */
110
+ alt?: string;
111
+ /** Image width as ratio (0-1, where 1 = 100%) */
112
+ width?: number;
113
+ /** HTML code content */
114
+ code?: string;
115
+ /** Number of columns (1-4) */
116
+ columnsCount?: number;
117
+ /** Left border width for blockquote */
118
+ borderLeftWidth?: number;
119
+ [key: string]: unknown;
120
+ }
121
+ /**
122
+ * A block preset is a pre-configured variant of an existing block type.
123
+ * For example, a "Portal Button" preset is a button with specific href and label.
124
+ */
125
+ export interface BlockPreset {
126
+ /** The base block type this preset is built on */
127
+ type: BlockElementType;
128
+ /** Unique identifier for this preset */
129
+ key: string;
130
+ /** Display label in the sidebar */
131
+ label: string;
132
+ /** Optional custom icon (React node) */
133
+ icon?: React.ReactNode;
134
+ /** Pre-configured attributes for this preset */
135
+ attributes: BlockAttributes;
136
+ }
137
+ /**
138
+ * A reference to a preset in the visible blocks list
139
+ */
140
+ export interface PresetReference {
141
+ /** The base block type */
142
+ type: BlockElementType;
143
+ /** The preset key */
144
+ preset: string;
145
+ }
146
+ /**
147
+ * A visible block item can be either:
148
+ * - A built-in block type string (e.g., "text", "button")
149
+ * - A preset reference (e.g., { type: "button", preset: "portal" })
150
+ */
151
+ export type VisibleBlockItem = BlockElementType | PresetReference;
152
+ /**
153
+ * Type guard to check if a VisibleBlockItem is a PresetReference
154
+ */
155
+ export declare const isPresetReference: (item: VisibleBlockItem) => item is PresetReference;
156
+ /**
157
+ * Default block elements available in the sidebar
158
+ */
159
+ export declare const DEFAULT_VISIBLE_BLOCKS: VisibleBlockItem[];
160
+ /**
161
+ * Atom to store visible blocks in the sidebar (and their order)
162
+ */
163
+ export declare const visibleBlocksAtom: import("jotai").PrimitiveAtom<VisibleBlockItem[]> & {
164
+ init: VisibleBlockItem[];
165
+ };
166
+ /**
167
+ * Atom to store default attributes for each block type
168
+ * When a new block is created, these defaults are applied
169
+ */
170
+ export declare const blockDefaultsAtom: import("jotai").PrimitiveAtom<Partial<Record<BlockElementType, BlockAttributes>>> & {
171
+ init: Partial<Record<BlockElementType, BlockAttributes>>;
172
+ };
173
+ /**
174
+ * Atom to store registered block presets
175
+ */
176
+ export declare const blockPresetsAtom: import("jotai").PrimitiveAtom<BlockPreset[]> & {
177
+ init: BlockPreset[];
178
+ };
@@ -8,16 +8,16 @@ export declare const blockquoteSchema: z.ZodObject<{
8
8
  id: z.ZodOptional<z.ZodString>;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  backgroundColor: string;
11
+ borderColor: string;
11
12
  paddingVertical: number;
12
13
  paddingHorizontal: number;
13
- borderColor: string;
14
14
  borderLeftWidth: number;
15
15
  id?: string | undefined;
16
16
  }, {
17
17
  backgroundColor: string;
18
+ borderColor: string;
18
19
  paddingVertical: number;
19
20
  paddingHorizontal: number;
20
- borderColor: string;
21
21
  borderLeftWidth: number;
22
22
  id?: string | undefined;
23
23
  }>;
@@ -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
- fontStyle: "italic" | "normal";
22
- fontWeight: "bold" | "normal";
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
- fontStyle: "italic" | "normal";
35
- fontWeight: "bold" | "normal";
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[];
@@ -9,8 +9,8 @@ export declare const dividerSchema: z.ZodObject<{
9
9
  padding: number;
10
10
  color: string;
11
11
  size: number;
12
- variant: "divider" | "spacer";
13
12
  radius: number;
13
+ variant: "divider" | "spacer";
14
14
  }, {
15
15
  padding: number;
16
16
  color: string;
@@ -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;
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ interface VariableSuggestionsProps {
2
+ items: string[];
3
+ command: (item: string) => void;
4
+ selected: number;
5
+ }
6
+ export declare const VariableSuggestions: React.FC<VariableSuggestionsProps>;
7
+ export {};
@@ -1,3 +1,4 @@
1
1
  export * from "./Variable";
2
2
  export * from "./Variable.types";
3
3
  export * from "./VariablePaste";
4
+ export * from "./VariableSuggestions";
@@ -0,0 +1,2 @@
1
+ import type { SuggestionOptions } from "@tiptap/suggestion";
2
+ export declare const suggestion: Partial<SuggestionOptions>;
@@ -1,6 +1,11 @@
1
1
  import type { Node } from "@tiptap/pm/model";
2
- export declare const ExtensionKit: (options?: {
2
+ export interface ExtensionKitOptions {
3
3
  setSelectedNode?: (node: Node) => void;
4
4
  shouldHandleClick?: () => boolean;
5
- }) => (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any>)[];
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;
@@ -27,4 +27,4 @@ export { Paragraph } from "./Paragraph";
27
27
  export { Selection } from "./Selection";
28
28
  export { SlashMenu } from "./SlashMenu";
29
29
  export { UniqueId } from "./UniqueId";
30
- export { VariableNode, VariableInputRule, VariablePaste } from "./Variable";
30
+ export { VariableNode, VariableInputRule, VariablePaste, Variable, VariableTypeHandler, } from "./Variable";
@@ -1,2 +1,3 @@
1
1
  export * from "./useNodeAttributes";
2
2
  export * from "./useVariables";
3
+ export * from "./useBlockConfig";
@@ -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 { CustomCodeBlock } from "./CustomCodeBlock";
1
+ export * from "./CustomCodeBlock";
@@ -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>;
@@ -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";