@trycourier/react-designer 0.0.0-canary-20251210164636 → 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.
- package/README.md +244 -2
- package/dist/cjs/index.js +70 -56
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/styles.css +182 -37
- 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/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 +1 -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/VariableEditor/VariableAutocomplete.d.ts +16 -0
- package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +1 -1
- 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 +70 -56
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/styles.css +182 -37
- package/dist/index.d.ts +14 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/styles.css +182 -37
- package/dist/types/elemental.schema.d.ts +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/validation.types.d.ts +53 -0
- package/package.json +1 -1
|
@@ -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,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>;
|
|
@@ -29,7 +29,7 @@ export interface VariableChipBaseProps {
|
|
|
29
29
|
className?: string;
|
|
30
30
|
/** Override text color (e.g., for button context) */
|
|
31
31
|
textColorOverride?: string;
|
|
32
|
-
/** Custom color getter function */
|
|
32
|
+
/** Custom color getter function (kept for API compatibility, colors handled by CSS) */
|
|
33
33
|
getColors?: (isInvalid: boolean, hasValue: boolean) => VariableColors;
|
|
34
34
|
}
|
|
35
35
|
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";
|