@trycourier/react-designer 0.2.0 → 0.3.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.
Files changed (115) hide show
  1. package/README.md +150 -49
  2. package/dist/cjs/index.js +70 -47
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +1592 -497
  5. package/dist/components/BrandEditor/BrandEditor.d.ts +1 -0
  6. package/dist/components/BrandEditor/Editor/BrandFooter/BrandFooter.d.ts +1 -1
  7. package/dist/components/BrandEditor/Editor/Editor.d.ts +1 -0
  8. package/dist/components/Providers/api/template.d.ts +33 -1
  9. package/dist/components/Providers/store.d.ts +6 -0
  10. package/dist/components/Providers/useBrandActions.d.ts +1 -1
  11. package/dist/components/Providers/useTemplateActions.d.ts +4 -2
  12. package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +5 -6
  13. package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +1 -1
  14. package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
  15. package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBar.d.ts +9 -3
  16. package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBarSortableItemWrapper/SideBarSortableItemWrapper.d.ts +4 -18
  17. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
  18. package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
  19. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +5 -3
  20. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsEditor.d.ts +1 -1
  21. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
  22. package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/SideBar.d.ts +5 -3
  23. package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
  24. package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
  25. package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
  26. package/dist/components/TemplateEditor/Channels/Slack/SideBar/SideBar.d.ts +5 -3
  27. package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +5 -3
  28. package/dist/components/TemplateEditor/Channels/Slack/SlackEditor.d.ts +1 -1
  29. package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
  30. package/dist/components/TemplateEditor/Channels/useChannels.d.ts +1 -1
  31. package/dist/components/TemplateEditor/TemplateEditor.d.ts +2 -1
  32. package/dist/components/TemplateEditor/hooks/index.d.ts +1 -0
  33. package/dist/components/TemplateEditor/hooks/useDebouncedFlush.d.ts +10 -0
  34. package/dist/components/TemplateEditor/hooks/useDndRef.d.ts +18 -0
  35. package/dist/components/TemplateEditor/hooks/useEditorDnd.d.ts +12 -16
  36. package/dist/components/TemplateEditor/hooks/usePragmaticDnd.d.ts +22 -0
  37. package/dist/components/TemplateEditor/hooks/useSyncEditorItems.d.ts +3 -2
  38. package/dist/components/TemplateEditor/index.d.ts +4 -1
  39. package/dist/components/TemplateEditor/store.d.ts +140 -0
  40. package/dist/components/extensions/Blockquote/Blockquote.types.d.ts +2 -2
  41. package/dist/components/extensions/Button/Button.types.d.ts +18 -24
  42. package/dist/components/extensions/Button/ButtonComponent.d.ts +1 -0
  43. package/dist/components/extensions/ButtonRow/ButtonRowComponent.d.ts +5 -1
  44. package/dist/components/extensions/Column/Column.d.ts +11 -0
  45. package/dist/components/extensions/Column/Column.types.d.ts +44 -0
  46. package/dist/components/extensions/Column/ColumnComponent.d.ts +9 -0
  47. package/dist/components/extensions/Column/ColumnForm.d.ts +8 -0
  48. package/dist/components/extensions/Column/index.d.ts +5 -0
  49. package/dist/components/extensions/ColumnCell/ColumnCell.d.ts +10 -0
  50. package/dist/components/extensions/ColumnCell/ColumnCellComponent.d.ts +2 -0
  51. package/dist/components/extensions/ColumnCell/index.d.ts +2 -0
  52. package/dist/components/extensions/ColumnRow/ColumnRow.d.ts +10 -0
  53. package/dist/components/extensions/ColumnRow/ColumnRowComponent.d.ts +2 -0
  54. package/dist/components/extensions/ColumnRow/index.d.ts +2 -0
  55. package/dist/components/extensions/ImageBlock/ImageBlock.types.d.ts +2 -6
  56. package/dist/components/extensions/Selection/Selection.d.ts +1 -0
  57. package/dist/components/extensions/TextBlock/TextBlock.types.d.ts +4 -12
  58. package/dist/components/extensions/Variable/Variable.d.ts +14 -2
  59. package/dist/components/extensions/Variable/Variable.types.d.ts +33 -18
  60. package/dist/components/extensions/Variable/VariableIcon.d.ts +5 -1
  61. package/dist/components/extensions/extension-kit.d.ts +1 -1
  62. package/dist/components/extensions/index.d.ts +4 -1
  63. package/dist/components/hooks/index.d.ts +2 -0
  64. package/dist/components/hooks/useBlockConfig.d.ts +110 -0
  65. package/dist/components/hooks/useVariables.d.ts +40 -0
  66. package/dist/components/ui/Blocks/ColumnBlock/ColumnBlock.d.ts +3 -0
  67. package/dist/components/ui/Blocks/ColumnBlock/index.d.ts +1 -0
  68. package/dist/components/ui/Blocks/CustomCodeBlock/index.d.ts +1 -1
  69. package/dist/components/ui/Blocks/index.d.ts +1 -0
  70. package/dist/components/ui/ContentIcon/ContentIcon.d.ts +1 -0
  71. package/dist/components/ui/DraggableItem/DraggableItem.d.ts +16 -0
  72. package/dist/components/ui/DraggableItem/index.d.ts +1 -0
  73. package/dist/components/ui/DropIndicatorPlaceholder/DropIndicatorPlaceholder.d.ts +5 -0
  74. package/dist/components/ui/DropIndicatorPlaceholder/index.d.ts +1 -0
  75. package/dist/components/ui/FormHeader/FormHeader.d.ts +2 -1
  76. package/dist/components/ui/MainLayout/MainLayout.d.ts +1 -1
  77. package/dist/components/ui/SortableItemWrapper/SortableItemWrapper.d.ts +11 -8
  78. package/dist/components/ui/TextInput/TextInput.d.ts +0 -1
  79. package/dist/components/ui/TextMenu/config.d.ts +16 -0
  80. package/dist/components/ui/TextMenu/hooks/useConditionalRules.d.ts +18 -0
  81. package/dist/components/ui/TextMenu/hooks/useTextmenuCommands.d.ts +15 -1
  82. package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +35 -0
  83. package/dist/components/ui/VariableEditor/VariableEditorToolbar.d.ts +15 -0
  84. package/dist/components/ui/VariableEditor/VariableInput.d.ts +13 -0
  85. package/dist/components/ui/VariableEditor/VariableTextarea.d.ts +11 -0
  86. package/dist/components/ui/VariableEditor/index.d.ts +8 -0
  87. package/dist/components/ui/VariableEditor/shared.d.ts +47 -0
  88. package/dist/components/ui-kit/Icon/EmailIcon.d.ts +3 -0
  89. package/dist/components/ui-kit/Icon/MSTeamsIcon.d.ts +1 -1
  90. package/dist/components/ui-kit/Icon/PushIcon.d.ts +1 -1
  91. package/dist/components/ui-kit/Icon/VariableIcon.d.ts +1 -1
  92. package/dist/components/ui-kit/Icon/index.d.ts +1 -0
  93. package/dist/components/ui-kit/ThemeProvider/ThemeProvider.d.ts +1 -1
  94. package/dist/components/ui-kit/Toggle/Toggle.d.ts +2 -2
  95. package/dist/components/ui-kit/ToggleGroup/ToggleGroup.d.ts +2 -2
  96. package/dist/components/utils/extractVariablesFromContent.d.ts +13 -0
  97. package/dist/components/utils/index.d.ts +1 -0
  98. package/dist/components/utils/multipleContainersKeyboardCoordinates.d.ts +1 -2
  99. package/dist/components/utils/validateVariableName.d.ts +9 -0
  100. package/dist/esm/index.js +70 -47
  101. package/dist/esm/index.js.map +4 -4
  102. package/dist/esm/styles.css +1592 -497
  103. package/dist/hooks/useAutoSave.d.ts +2 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/lib/utils/image.d.ts +5 -0
  106. package/dist/styles.css +1592 -497
  107. package/dist/types/elemental.schema.d.ts +3 -3
  108. package/dist/types/elemental.types.d.ts +48 -4
  109. package/package.json +7 -6
  110. package/dist/cjs/index.css +0 -2
  111. package/dist/cjs/index.css.map +0 -7
  112. package/dist/components/extensions/Variable/VariableSuggestions.d.ts +0 -7
  113. package/dist/components/extensions/Variable/suggestion.d.ts +0 -2
  114. package/dist/esm/index.css +0 -2
  115. package/dist/esm/index.css.map +0 -7
@@ -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 };
@@ -0,0 +1,40 @@
1
+ import type { ChannelType } from "@/store";
2
+ export interface UseVariablesResult {
3
+ /**
4
+ * All available variables from the editor configuration
5
+ */
6
+ availableVariables: string[];
7
+ /**
8
+ * Variables that are actually used in the channel's content
9
+ */
10
+ usedVariables: string[];
11
+ /**
12
+ * Current variable values (for preview/testing)
13
+ */
14
+ variableValues: Record<string, string>;
15
+ /**
16
+ * Update a variable's value
17
+ */
18
+ addVariableValue: (key: string, value: string) => void;
19
+ /**
20
+ * Clear all variable values (reset to empty object)
21
+ */
22
+ clearAllVariableValues: () => void;
23
+ }
24
+ /**
25
+ * Hook to access and manage variables for a specific channel
26
+ *
27
+ * @param channelType - The channel to get variables for (e.g., 'email', 'sms', 'slack')
28
+ * @returns Object containing available variables, used variables, current values, and update function
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * const { availableVariables, usedVariables, variableValues, addVariableValue } = useVariables('email');
33
+ *
34
+ * // availableVariables = ['user.name', 'user.email', 'orderTotal']
35
+ * // usedVariables = ['user.name', 'orderTotal']
36
+ *
37
+ * addVariableValue('user.name', 'John Doe');
38
+ * ```
39
+ */
40
+ export declare const useVariables: (channelType?: ChannelType) => UseVariablesResult;
@@ -0,0 +1,3 @@
1
+ import { type BlockBaseProps } from "../Block";
2
+ export declare const ColumnBlockIcon: () => import("react/jsx-runtime").JSX.Element;
3
+ export declare const ColumnBlock: ({ draggable }: Pick<BlockBaseProps, "draggable">) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./ColumnBlock";
@@ -1 +1 @@
1
- export { CustomCodeBlock } from "./CustomCodeBlock";
1
+ export * from "./CustomCodeBlock";
@@ -1,6 +1,7 @@
1
1
  export * from "./Block";
2
2
  export * from "./BlockquoteBlock";
3
3
  export * from "./ButtonBlock";
4
+ export * from "./ColumnBlock";
4
5
  export * from "./CustomCodeBlock";
5
6
  export * from "./DividerBlock";
6
7
  export * from "./HeadingBlock";
@@ -6,3 +6,4 @@ export declare const ImageElementIcon: ({ ...props }: IconProps) => import("reac
6
6
  export declare const DividerElementIcon: ({ ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export declare const VariableElementIcon: ({ ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
8
8
  export declare const CustomCodeElementIcon: ({ ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const ColumnElementIcon: ({ ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ type UniqueIdentifier = string | number;
3
+ interface DraggableItemProps {
4
+ id: UniqueIdentifier;
5
+ children: React.ReactNode;
6
+ dragType?: string;
7
+ type?: "sidebar" | "editor";
8
+ index?: number;
9
+ className?: string;
10
+ disabled?: boolean;
11
+ onDragStart?: () => void;
12
+ onDragEnd?: () => void;
13
+ renderDragPreview?: () => React.ReactElement;
14
+ }
15
+ export declare const DraggableItem: ({ id, children, dragType, type, index, className, disabled, onDragStart, onDragEnd, renderDragPreview, }: DraggableItemProps) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { DraggableItem } from "./DraggableItem";
@@ -0,0 +1,5 @@
1
+ interface DropIndicatorPlaceholderProps {
2
+ type?: string | null;
3
+ }
4
+ export declare const DropIndicatorPlaceholder: React.FC<DropIndicatorPlaceholderProps>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export { DropIndicatorPlaceholder } from "./DropIndicatorPlaceholder";
@@ -1,5 +1,6 @@
1
1
  interface FormHeaderProps {
2
- type: "text" | "image" | "spacer" | "divider" | "button" | "blockquote" | "heading" | "customCode";
2
+ type: "text" | "image" | "spacer" | "divider" | "button" | "blockquote" | "heading" | "customCode" | "column";
3
+ label?: string;
3
4
  }
4
5
  export declare const FormHeader: ({ type }: FormHeaderProps) => import("react/jsx-runtime").JSX.Element;
5
6
  export {};
@@ -6,6 +6,6 @@ export interface MainLayoutProps extends HTMLAttributes<HTMLDivElement> {
6
6
  isLoading?: boolean;
7
7
  SideBar?: React.ReactNode;
8
8
  Header?: React.ReactNode;
9
- dataMode?: "light" | "dark";
9
+ colorScheme?: "light" | "dark";
10
10
  }
11
11
  export declare const MainLayout: import("react").ForwardRefExoticComponent<MainLayoutProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,26 +1,29 @@
1
- import type { DraggableSyntheticListeners } from "@dnd-kit/core";
2
- import type { Transform } from "@dnd-kit/utilities";
3
1
  import type { Editor, NodeViewWrapperProps } from "@tiptap/react";
4
- import React from "react";
2
+ import React, { type HTMLAttributes } from "react";
3
+ import { type Edge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
5
4
  export interface SortableItemWrapperProps extends NodeViewWrapperProps {
6
5
  children: React.ReactNode;
7
6
  id: string;
8
7
  className?: string;
9
8
  editor: Editor;
9
+ getPos?: (() => number) | boolean;
10
10
  }
11
- export declare const SortableItemWrapper: ({ children, id, className, ...props }: SortableItemWrapperProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const SortableItemWrapper: ({ children, id, className, editor, getPos: _getPos, ...props }: SortableItemWrapperProps) => import("react/jsx-runtime").JSX.Element;
12
12
  export interface SortableItemProps {
13
13
  children: React.ReactNode;
14
14
  id?: string;
15
15
  dragOverlay?: boolean;
16
16
  disabled?: boolean;
17
17
  dragging?: boolean;
18
- handleProps?: Record<string, unknown>;
18
+ closestEdge?: Edge | null;
19
+ dragType?: string | null;
20
+ handleRef?: React.RefObject<HTMLButtonElement>;
21
+ contentRef?: React.RefObject<HTMLDivElement>;
19
22
  fadeIn?: boolean;
20
- transform?: Transform | null;
21
- listeners?: DraggableSyntheticListeners;
22
- transition?: string | null;
23
23
  className?: string;
24
24
  editor: Editor;
25
25
  }
26
+ export interface NodeViewWrapperComponentProps extends HTMLAttributes<HTMLDivElement> {
27
+ dragging?: never;
28
+ }
26
29
  export declare const SortableItem: React.ForwardRefExoticComponent<SortableItemProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  export interface TextInputProps extends Omit<React.ComponentProps<"input">, "as" | "onChange"> {
3
3
  as?: "Input" | "Textarea";
4
- variables?: string[];
5
4
  autoResize?: boolean;
6
5
  onChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
7
6
  onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
@@ -2,6 +2,21 @@ export type TextMenuItemState = "enabled" | "disabled" | "hidden";
2
2
  export interface TextMenuItem {
3
3
  state: TextMenuItemState;
4
4
  }
5
+ export interface ConditionalRule {
6
+ id: string;
7
+ trigger: {
8
+ type: "node";
9
+ name: string;
10
+ active: boolean;
11
+ };
12
+ conditions: {
13
+ activeItems: Array<keyof TextMenuConfig>;
14
+ };
15
+ action: {
16
+ type: "toggle_off";
17
+ targets: Array<keyof TextMenuConfig>;
18
+ };
19
+ }
5
20
  export interface TextMenuConfig {
6
21
  contentType?: TextMenuItem;
7
22
  bold?: TextMenuItem;
@@ -15,6 +30,7 @@ export interface TextMenuConfig {
15
30
  quote?: TextMenuItem;
16
31
  link?: TextMenuItem;
17
32
  variable?: TextMenuItem;
33
+ conditionalRules?: ConditionalRule[];
18
34
  }
19
35
  export declare const defaultTextMenuConfig: TextMenuConfig;
20
36
  export declare const getTextMenuConfigForNode: (nodeName: string, hasTextSelection?: boolean) => TextMenuConfig;
@@ -0,0 +1,18 @@
1
+ import type { Editor } from "@tiptap/react";
2
+ import type { TextMenuConfig } from "../config";
3
+ interface TextMenuStates {
4
+ isBold: boolean;
5
+ isItalic: boolean;
6
+ isUnderline: boolean;
7
+ isStrike: boolean;
8
+ isQuote: boolean;
9
+ isAlignLeft: boolean;
10
+ isAlignCenter: boolean;
11
+ isAlignRight: boolean;
12
+ isAlignJustify: boolean;
13
+ isLink: boolean;
14
+ }
15
+ export declare const useConditionalRules: (config: TextMenuConfig | undefined, editor: Editor | null, states: TextMenuStates | undefined) => {
16
+ getRuleForItem: (itemKey: keyof TextMenuConfig) => import("../config").ConditionalRule | undefined;
17
+ } | null;
18
+ export {};
@@ -1,5 +1,18 @@
1
1
  import type { Editor } from "@tiptap/react";
2
- export declare const useTextmenuCommands: (editor: Editor) => {
2
+ import type { TextMenuConfig } from "../config";
3
+ interface TextMenuStates {
4
+ isBold: boolean;
5
+ isItalic: boolean;
6
+ isUnderline: boolean;
7
+ isStrike: boolean;
8
+ isQuote: boolean;
9
+ isAlignLeft: boolean;
10
+ isAlignCenter: boolean;
11
+ isAlignRight: boolean;
12
+ isAlignJustify: boolean;
13
+ isLink: boolean;
14
+ }
15
+ export declare const useTextmenuCommands: (editor: Editor, config?: TextMenuConfig, states?: TextMenuStates) => {
3
16
  onBold: () => boolean;
4
17
  onItalic: () => boolean;
5
18
  onStrike: () => boolean;
@@ -12,3 +25,4 @@ export declare const useTextmenuCommands: (editor: Editor) => {
12
25
  onQuote: () => void;
13
26
  resetButtonFormatting: () => boolean;
14
27
  };
28
+ export {};
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ export declare const MAX_VARIABLE_LENGTH = 50;
3
+ export declare const MAX_DISPLAY_LENGTH = 24;
4
+ export interface VariableColors {
5
+ bgColor: string;
6
+ borderColor: string;
7
+ iconColor: string;
8
+ textColor: string;
9
+ }
10
+ export interface VariableChipBaseProps {
11
+ /** The variable name/id */
12
+ variableId: string;
13
+ /** Whether the variable is currently invalid */
14
+ isInvalid: boolean;
15
+ /** Called when attributes should be updated */
16
+ onUpdateAttributes: (attrs: {
17
+ id: string;
18
+ isInvalid: boolean;
19
+ }) => void;
20
+ /** Called when the node should be deleted */
21
+ onDelete: () => void;
22
+ /** Icon component to render */
23
+ icon: React.ReactNode;
24
+ /** Optional value to display (e.g., for variables with known values) */
25
+ value?: string;
26
+ /** Whether to use single-click (true) or double-click (false) to edit */
27
+ singleClickToEdit?: boolean;
28
+ /** Additional class names for the outer span */
29
+ className?: string;
30
+ /** Override text color (e.g., for button context) */
31
+ textColorOverride?: string;
32
+ /** Custom color getter function (kept for API compatibility, colors handled by CSS) */
33
+ getColors?: (isInvalid: boolean, hasValue: boolean) => VariableColors;
34
+ }
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>;
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import { type VariableEditorBaseProps } from "./shared";
3
+ export interface VariableInputProps extends VariableEditorBaseProps {
4
+ /** Whether the input is read-only */
5
+ readOnly?: boolean;
6
+ /** Whether to show the variable toolbar */
7
+ showToolbar?: boolean;
8
+ }
9
+ /**
10
+ * A single-line input that renders {{variable}} patterns as styled chips.
11
+ * Uses a minimal TipTap editor under the hood for rich content rendering.
12
+ */
13
+ export declare const VariableInput: React.ForwardRefExoticComponent<VariableInputProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { type VariableEditorBaseProps } from "./shared";
3
+ export interface VariableTextareaProps extends VariableEditorBaseProps {
4
+ /** Whether to show the variable toolbar */
5
+ showToolbar?: boolean;
6
+ }
7
+ /**
8
+ * A textarea-like input that renders {{variable}} patterns as styled chips.
9
+ * Uses a minimal TipTap editor under the hood for rich content rendering.
10
+ */
11
+ export declare const VariableTextarea: React.ForwardRefExoticComponent<VariableTextareaProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,8 @@
1
+ export { VariableTextarea } from "./VariableTextarea";
2
+ export type { VariableTextareaProps } from "./VariableTextarea";
3
+ export { VariableInput } from "./VariableInput";
4
+ export type { VariableInputProps } from "./VariableInput";
5
+ export { VariableEditorToolbar } from "./VariableEditorToolbar";
6
+ export type { VariableEditorToolbarProps } from "./VariableEditorToolbar";
7
+ export { parseStringToContent, contentToString, SimpleVariableNode, SimpleVariableView, VariableChipIcon, } from "./shared";
8
+ export type { VariableEditorBaseProps } from "./shared";
@@ -0,0 +1,47 @@
1
+ import { Node } from "@tiptap/core";
2
+ import type { Content, JSONContent } from "@tiptap/core";
3
+ import type { NodeViewProps } from "@tiptap/react";
4
+ import * as React from "react";
5
+ /**
6
+ * Simple variable icon for the chip
7
+ */
8
+ export declare const VariableChipIcon: React.FC<{
9
+ color?: string;
10
+ }>;
11
+ /**
12
+ * Standalone variable view component with editing support
13
+ * Used in VariableInput and VariableTextarea components
14
+ */
15
+ export declare const SimpleVariableView: React.FC<NodeViewProps>;
16
+ /**
17
+ * Custom VariableNode that uses SimpleVariableView
18
+ * Used in VariableInput and VariableTextarea components
19
+ */
20
+ export declare const SimpleVariableNode: Node<any, any>;
21
+ /**
22
+ * Parses a string with {{variable}} syntax into TipTap JSON content
23
+ */
24
+ export declare function parseStringToContent(text: string): Content;
25
+ /**
26
+ * Converts TipTap JSON content back to string with {{variable}} syntax
27
+ */
28
+ export declare function contentToString(doc: JSONContent): string;
29
+ /**
30
+ * Base props shared between VariableInput and VariableTextarea
31
+ */
32
+ export interface VariableEditorBaseProps {
33
+ /** The current value with {{variable}} syntax */
34
+ value?: string;
35
+ /** Called when the value changes */
36
+ onChange?: (value: string) => void;
37
+ /** Placeholder text */
38
+ placeholder?: string;
39
+ /** Additional CSS classes */
40
+ className?: string;
41
+ /** Whether the input is disabled */
42
+ disabled?: boolean;
43
+ /** Called when the input gains focus */
44
+ onFocus?: () => void;
45
+ /** Called when the input loses focus */
46
+ onBlur?: () => void;
47
+ }
@@ -0,0 +1,3 @@
1
+ import type { IconProps } from "./Icon";
2
+ export declare const EmailIcon: ({ color, width, height, viewBox, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default EmailIcon;
@@ -1,3 +1,3 @@
1
1
  import type { IconProps } from "./Icon";
2
- export declare const MSTeamsIcon: ({ color, width, height, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MSTeamsIcon: ({ color, width, height, viewBox, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default MSTeamsIcon;
@@ -1,3 +1,3 @@
1
1
  import type { IconProps } from "./Icon";
2
- export declare const PushIcon: ({ color, width, height, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const PushIcon: ({ width, height, viewBox, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default PushIcon;
@@ -1,3 +1,3 @@
1
1
  import type { IconProps } from "./Icon";
2
- export declare const VariableIcon: ({ color, active, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const VariableIcon: ({ width, height, ...props }: IconProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default VariableIcon;
@@ -13,6 +13,7 @@ export { DesktopIcon } from "./DesktopIcon";
13
13
  export { DistributeIcon } from "./DistributeIcon";
14
14
  export { DownIcon } from "./DownIcon";
15
15
  export { DuplicateIcon } from "./DuplicateIcon";
16
+ export { EmailIcon } from "./EmailIcon";
16
17
  export { ExpandIcon } from "./ExpandIcon";
17
18
  export { FacebookIcon } from "./FacebookIcon";
18
19
  export { FontSizeIcon } from "./FontSizeIcon";
@@ -3,7 +3,7 @@ import type { Theme } from "./ThemeProvider.types";
3
3
  interface ThemeProviderProps {
4
4
  children: ReactNode;
5
5
  theme?: Theme | string;
6
- dataMode?: "light" | "dark";
6
+ colorScheme?: "light" | "dark";
7
7
  className?: string;
8
8
  }
9
9
  export declare const ThemeProvider: import("react").ForwardRefExoticComponent<ThemeProviderProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,11 +2,11 @@ import * as React from "react";
2
2
  import * as TogglePrimitive from "@radix-ui/react-toggle";
3
3
  import { type VariantProps } from "class-variance-authority";
4
4
  declare const toggleVariants: (props?: ({
5
- variant?: "default" | "outline" | null | undefined;
5
+ variant?: "outline" | "default" | null | undefined;
6
6
  size?: "default" | "sm" | "lg" | null | undefined;
7
7
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
8
8
  declare const Toggle: React.ForwardRefExoticComponent<Omit<TogglePrimitive.ToggleProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
9
- variant?: "default" | "outline" | null | undefined;
9
+ variant?: "outline" | "default" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
12
12
  export { Toggle, toggleVariants };
@@ -2,11 +2,11 @@ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  import * as React from "react";
4
4
  declare const ToggleGroup: React.ForwardRefExoticComponent<((Omit<ToggleGroupPrimitive.ToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<ToggleGroupPrimitive.ToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & VariantProps<(props?: ({
5
- variant?: "default" | "outline" | null | undefined;
5
+ variant?: "outline" | "default" | null | undefined;
6
6
  size?: "default" | "sm" | "lg" | null | undefined;
7
7
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string>) & React.RefAttributes<HTMLDivElement>>;
8
8
  declare const ToggleGroupItem: React.ForwardRefExoticComponent<Omit<ToggleGroupPrimitive.ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
9
- variant?: "default" | "outline" | null | undefined;
9
+ variant?: "outline" | "default" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
12
12
  export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,13 @@
1
+ import type { ElementalNode } from "../../types/elemental.types";
2
+ /**
3
+ * Extracts all variable names used in the content in the format {{variableName}}
4
+ * Supports nested dot notation like {{user.profile.name}}
5
+ *
6
+ * Extracts variables from:
7
+ * - Text content (content properties)
8
+ * - Element attributes (href, src, alt_text, etc.)
9
+ * - Channel raw properties (subject, title, text)
10
+ * - Conditional logic (if, loop properties)
11
+ * - Localized content and attributes
12
+ */
13
+ export declare const extractVariablesFromContent: (elements?: ElementalNode[]) => string[];
@@ -5,3 +5,4 @@ export * from "./generateNodeIds";
5
5
  export * from "./createOrDuplicateNode";
6
6
  export * from "./multipleContainersKeyboardCoordinates";
7
7
  export * from "./safeGetPos";
8
+ export * from "./validateVariableName";
@@ -1,2 +1 @@
1
- import type { KeyboardCoordinateGetter } from "@dnd-kit/core";
2
- export declare const coordinateGetter: KeyboardCoordinateGetter;
1
+ export declare const coordinateGetter: () => undefined;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Validates a variable name according to JSON property name rules
3
+ * Valid: user.firstName, company.address.street, _private, user123
4
+ * Invalid: user. firstName (space), user. (trailing dot), user..name (double dot), 123invalid (starts with digit)
5
+ *
6
+ * @param variableName - The variable name to validate (without curly braces)
7
+ * @returns true if the variable name is valid, false otherwise
8
+ */
9
+ export declare function isValidVariableName(variableName: string): boolean;