@trycourier/react-designer 0.5.0 → 0.6.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 (49) hide show
  1. package/README.md +70 -0
  2. package/dist/cjs/index.js +66 -60
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +105 -36
  5. package/dist/components/Providers/TemplateProvider.d.ts +2 -0
  6. package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +3 -1
  7. package/dist/components/TemplateEditor/Channels/Inbox/InboxEditor.d.ts +3 -1
  8. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +6 -1
  9. package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsEditor.d.ts +3 -1
  10. package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/MSTeamsSideBarItemDetails.d.ts +8 -0
  11. package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/index.d.ts +1 -0
  12. package/dist/components/TemplateEditor/Channels/MSTeams/index.d.ts +1 -1
  13. package/dist/components/TemplateEditor/Channels/Push/PushEditor.d.ts +3 -1
  14. package/dist/components/TemplateEditor/Channels/SMS/SMSEditor.d.ts +3 -1
  15. package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +6 -1
  16. package/dist/components/TemplateEditor/Channels/Slack/SlackEditor.d.ts +3 -1
  17. package/dist/components/TemplateEditor/VariableViewModeSync.d.ts +24 -0
  18. package/dist/components/TemplateEditor/index.d.ts +1 -1
  19. package/dist/components/TemplateEditor/store.d.ts +16 -1
  20. package/dist/components/extensions/Button/Button.d.ts +0 -3
  21. package/dist/components/extensions/Button/ButtonComponent.d.ts +2 -3
  22. package/dist/components/extensions/Button/buttonUtils.d.ts +13 -0
  23. package/dist/components/extensions/HardBreak/HardBreak.d.ts +12 -0
  24. package/dist/components/extensions/HardBreak/index.d.ts +1 -0
  25. package/dist/components/extensions/List/List.d.ts +0 -1
  26. package/dist/components/extensions/List/List.types.d.ts +0 -10
  27. package/dist/components/extensions/List/ListForm.d.ts +6 -1
  28. package/dist/components/extensions/Variable/index.d.ts +2 -0
  29. package/dist/components/extensions/Variable/variable-storage.types.d.ts +26 -0
  30. package/dist/components/extensions/Variable/variable-storage.utils.d.ts +72 -0
  31. package/dist/components/extensions/extension-kit.d.ts +17 -0
  32. package/dist/components/extensions/index.d.ts +1 -1
  33. package/dist/components/ui/TextMenu/hooks/useTextmenuCommands.d.ts +0 -1
  34. package/dist/components/ui-kit/Button/Button.d.ts +1 -1
  35. package/dist/components/ui-kit/Toggle/Toggle.d.ts +2 -2
  36. package/dist/components/ui-kit/ToggleGroup/ToggleGroup.d.ts +2 -2
  37. package/dist/components/utils/shadowDomDndFix.d.ts +47 -0
  38. package/dist/esm/index.js +66 -60
  39. package/dist/esm/index.js.map +4 -4
  40. package/dist/esm/styles.css +105 -36
  41. package/dist/hooks/useAutoSave.d.ts +1 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/lib/testHelpers.d.ts +21 -1
  44. package/dist/lib/utils/convertElementalToTiptap/convertElementalToTiptap.d.ts +6 -1
  45. package/dist/lib/utils/getTitle/index.d.ts +1 -1
  46. package/dist/lib/utils/getTitle/preserveStorageFormat.d.ts +7 -0
  47. package/dist/styles.css +105 -36
  48. package/dist/types/elemental.types.d.ts +0 -4
  49. package/package.json +6 -1
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Custom HardBreak extension that extends the default TipTap HardBreak.
3
+ *
4
+ * This extension modifies the DOM rendering to include a zero-width space
5
+ * after the <br> element. This helps with cursor visibility when the cursor
6
+ * is positioned right after a hardBreak (e.g., before an inline node like a variable).
7
+ *
8
+ * Without this, the browser has no text node to anchor the cursor, making it invisible
9
+ * even though ProseMirror knows the correct cursor position.
10
+ */
11
+ export declare const HardBreak: import("@tiptap/core").Node<import("@tiptap/extension-hard-break").HardBreakOptions, any>;
12
+ export default HardBreak;
@@ -0,0 +1 @@
1
+ export { HardBreak } from "./HardBreak";
@@ -4,7 +4,6 @@ declare module "@tiptap/core" {
4
4
  interface Commands<ReturnType> {
5
5
  list: {
6
6
  setList: (props?: Partial<ListProps>) => ReturnType;
7
- toggleList: () => ReturnType;
8
7
  toggleOrderedList: () => ReturnType;
9
8
  toggleUnorderedList: () => ReturnType;
10
9
  };
@@ -2,20 +2,14 @@ import { z } from "zod";
2
2
  export declare const listSchema: z.ZodObject<{
3
3
  id: z.ZodOptional<z.ZodString>;
4
4
  listType: z.ZodEnum<["ordered", "unordered"]>;
5
- borderColor: z.ZodString;
6
- borderWidth: z.ZodNumber;
7
5
  paddingVertical: z.ZodNumber;
8
6
  paddingHorizontal: z.ZodNumber;
9
7
  }, "strip", z.ZodTypeAny, {
10
- borderColor: string;
11
- borderWidth: number;
12
8
  paddingVertical: number;
13
9
  paddingHorizontal: number;
14
10
  listType: "ordered" | "unordered";
15
11
  id?: string | undefined;
16
12
  }, {
17
- borderColor: string;
18
- borderWidth: number;
19
13
  paddingVertical: number;
20
14
  paddingHorizontal: number;
21
15
  listType: "ordered" | "unordered";
@@ -26,10 +20,6 @@ export interface ListProps {
26
20
  listType: "ordered" | "unordered";
27
21
  /** Unique identifier for the list node */
28
22
  id?: string;
29
- /** Border color for list markers (bullets/numbers) */
30
- borderColor?: string;
31
- /** Border width in pixels */
32
- borderWidth?: number;
33
23
  /** Vertical padding in pixels */
34
24
  paddingVertical?: number;
35
25
  /** Horizontal padding in pixels */
@@ -4,6 +4,11 @@ interface ListFormProps {
4
4
  element?: ProseMirrorNode;
5
5
  editor: Editor | null;
6
6
  hideCloseButton?: boolean;
7
+ /**
8
+ * When true, only shows the list type toggle (ordered/unordered).
9
+ * Used for channels like Slack and MS Teams that don't support styling options.
10
+ */
11
+ minimalMode?: boolean;
7
12
  }
8
- export declare const ListForm: ({ element, editor, hideCloseButton }: ListFormProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ export declare const ListForm: ({ element, editor, hideCloseButton, minimalMode, }: ListFormProps) => import("react/jsx-runtime").JSX.Element | null;
9
14
  export {};
@@ -2,3 +2,5 @@ export * from "./Variable";
2
2
  export * from "./Variable.types";
3
3
  export * from "./VariablePaste";
4
4
  export * from "./VariableSuggestions";
5
+ export type { VariableStorage } from "./variable-storage.types";
6
+ export { getVariableViewMode, setVariableViewMode, getVariableStorage, initializeVariableStorage, hasVariableStorage, } from "./variable-storage.utils";
@@ -0,0 +1,26 @@
1
+ import type { VariableViewMode } from "../../TemplateEditor/store";
2
+ /**
3
+ * Type definition for the Variable extension storage in TipTap editor.
4
+ * This storage is used to maintain variable-related state across the editor instance.
5
+ *
6
+ * Usage:
7
+ * ```typescript
8
+ * import type { VariableStorage, EditorWithVariableStorage } from './variable-storage.types';
9
+ * import { getVariableViewMode, setVariableViewMode } from './variable-storage.utils';
10
+ *
11
+ * // Access storage
12
+ * const editor: EditorWithVariableStorage = ...;
13
+ * const viewMode = getVariableViewMode(editor);
14
+ *
15
+ * // Update storage
16
+ * setVariableViewMode(editor, 'wysiwyg');
17
+ * ```
18
+ */
19
+ export interface VariableStorage {
20
+ /**
21
+ * Controls how variables are displayed in the editor:
22
+ * - 'show-variables': Display as interactive chip components with icons
23
+ * - 'wysiwyg': Display as plain text values (preview mode)
24
+ */
25
+ variableViewMode: VariableViewMode;
26
+ }
@@ -0,0 +1,72 @@
1
+ import type { Editor } from "@tiptap/core";
2
+ import type { VariableViewMode } from "../../TemplateEditor/store";
3
+ import { type VariableStorage } from "./variable-storage.types";
4
+ /**
5
+ * Gets the variable view mode from the editor storage.
6
+ * Safely handles cases where storage or variable storage is not initialized.
7
+ *
8
+ * @param editor - The TipTap editor instance
9
+ * @param fallback - Fallback value if storage is not available (default: "show-variables")
10
+ * @returns The current variable view mode
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const editor = useCurrentEditor();
15
+ * const viewMode = getVariableViewMode(editor);
16
+ * ```
17
+ */
18
+ export declare function getVariableViewMode(editor: Editor | null | undefined, fallback?: VariableViewMode): VariableViewMode;
19
+ /**
20
+ * Sets the variable view mode in the editor storage.
21
+ * Safely handles cases where storage or variable storage is not initialized.
22
+ *
23
+ * @param editor - The TipTap editor instance
24
+ * @param mode - The new variable view mode to set
25
+ * @returns true if the mode was set successfully, false otherwise
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const editor = useCurrentEditor();
30
+ * setVariableViewMode(editor, 'wysiwyg');
31
+ * ```
32
+ */
33
+ export declare function setVariableViewMode(editor: Editor | null | undefined, mode: VariableViewMode): boolean;
34
+ /**
35
+ * Gets the entire variable storage object from the editor.
36
+ * Safely handles cases where storage is not initialized.
37
+ *
38
+ * @param editor - The TipTap editor instance
39
+ * @returns The variable storage object, or undefined if not available
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const editor = useCurrentEditor();
44
+ * const storage = getVariableStorage(editor);
45
+ * if (storage) {
46
+ * console.log('View mode:', storage.variableViewMode);
47
+ * }
48
+ * ```
49
+ */
50
+ export declare function getVariableStorage(editor: Editor | null | undefined): VariableStorage | undefined;
51
+ /**
52
+ * Initializes the variable storage on an editor instance.
53
+ * Should be called in the Variable extension's addStorage() method.
54
+ *
55
+ * @param defaultViewMode - The default variable view mode (default: "show-variables")
56
+ * @returns The initial storage object
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // In Variable extension
61
+ * addStorage() {
62
+ * return initializeVariableStorage();
63
+ * }
64
+ * ```
65
+ */
66
+ export declare function initializeVariableStorage(defaultViewMode?: VariableViewMode): VariableStorage;
67
+ /**
68
+ * Type guard to check if an object has variable storage
69
+ */
70
+ export declare function hasVariableStorage(storage: unknown): storage is {
71
+ variable: VariableStorage;
72
+ };
@@ -1,4 +1,14 @@
1
1
  import type { Node } from "@tiptap/pm/model";
2
+ export interface RichTextMarksConfig {
3
+ /** Controls bold mark behavior: 'disabled' to disable, 'default' or undefined to enable */
4
+ bold?: "disabled" | "default";
5
+ /** Controls italic mark behavior: 'disabled' to disable, 'default' or undefined to enable */
6
+ italic?: "disabled" | "default";
7
+ /** Controls underline mark behavior: 'disabled' to disable, 'default' or undefined to enable */
8
+ underline?: "disabled" | "default";
9
+ /** Controls strike mark behavior: 'disabled' to disable, 'default' or undefined to enable */
10
+ strike?: "disabled" | "default";
11
+ }
2
12
  export interface ExtensionKitOptions {
3
13
  setSelectedNode?: (node: Node) => void;
4
14
  shouldHandleClick?: () => boolean;
@@ -6,6 +16,13 @@ export interface ExtensionKitOptions {
6
16
  variables?: Record<string, unknown>;
7
17
  /** When true, disables variable autocomplete and allows typing any variable */
8
18
  disableVariablesAutocomplete?: boolean;
19
+ /**
20
+ * Controls rich text formatting marks (bold, italic, underline, strike).
21
+ * - `'plain-text'`: Disables all rich text marks (for SMS, Push, In-App)
22
+ * - Object with mark configurations: Enables granular control per mark
23
+ * - `undefined`: All marks enabled (default)
24
+ */
25
+ textMarks?: "plain-text" | RichTextMarksConfig;
9
26
  }
10
27
  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>)[];
11
28
  export default ExtensionKit;
@@ -1,6 +1,6 @@
1
1
  export { Color } from "@tiptap/extension-color";
2
2
  export { Dropcursor } from "@tiptap/extension-dropcursor";
3
- export { HardBreak } from "@tiptap/extension-hard-break";
3
+ export { HardBreak } from "./HardBreak";
4
4
  export { History } from "@tiptap/extension-history";
5
5
  export { Placeholder } from "@tiptap/extension-placeholder";
6
6
  export { TextAlign } from "@tiptap/extension-text-align";
@@ -27,6 +27,5 @@ export declare const useTextmenuCommands: (editor: Editor, config?: TextMenuConf
27
27
  onQuote: () => void;
28
28
  onOrderedList: () => void;
29
29
  onUnorderedList: () => void;
30
- resetButtonFormatting: () => boolean;
31
30
  };
32
31
  export {};
@@ -3,7 +3,7 @@ import type { ButtonHTMLAttributes } from "react";
3
3
  export type ButtonVariant = "primary" | "secondary" | "tertiary" | "quaternary" | "outline" | "ghost" | "link";
4
4
  export type ButtonSize = "medium" | "small" | "icon" | "iconSmall";
5
5
  export declare const buttonVariants: (props?: ({
6
- variant?: "link" | "primary" | "secondary" | "tertiary" | "quaternary" | "outline" | "ghost" | null | undefined;
6
+ variant?: "link" | "primary" | "secondary" | "tertiary" | "quaternary" | "ghost" | "outline" | null | undefined;
7
7
  size?: "icon" | "small" | "medium" | "iconSmall" | null | undefined;
8
8
  active?: boolean | null | undefined;
9
9
  disabled?: boolean | null | undefined;
@@ -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?: "outline" | "default" | null | undefined;
5
+ variant?: "default" | "outline" | 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?: "outline" | "default" | null | undefined;
9
+ variant?: "default" | "outline" | 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?: "outline" | "default" | null | undefined;
5
+ variant?: "default" | "outline" | 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?: "outline" | "default" | null | undefined;
9
+ variant?: "default" | "outline" | 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,47 @@
1
+ /**
2
+ * Shadow DOM Drag-and-Drop Fix for pragmatic-drag-and-drop
3
+ *
4
+ * This utility fixes the known incompatibility between pragmatic-drag-and-drop
5
+ * and Shadow DOM. The library uses `event.target` to look up draggable elements
6
+ * in a registry, but Shadow DOM re-targets events to the shadow host when they
7
+ * cross the shadow boundary, breaking the registry lookup.
8
+ *
9
+ * Solution: Monkey-patch `Event.prototype.target` to return the actual element
10
+ * from `composedPath()[0]` for drag events originating from the shadow DOM.
11
+ *
12
+ * **Known Limitation**: The `dragHandle` option in pragmatic-drag-and-drop does
13
+ * not work correctly with this fix. Elements will be draggable from anywhere,
14
+ * not just from the designated drag handle. This is due to how pragmatic-drag-and-drop
15
+ * internally validates handle interactions.
16
+ *
17
+ * @see https://github.com/atlassian/pragmatic-drag-and-drop/issues/15
18
+ * @see https://github.com/atlassian/pragmatic-drag-and-drop/issues/116
19
+ */
20
+ /**
21
+ * Applies a fix for drag-and-drop events inside a Shadow DOM.
22
+ *
23
+ * This function monkey-patches `Event.prototype.target` to return the actual
24
+ * element from `composedPath()[0]` for drag and pointer events that originate
25
+ * from within the specified shadow root.
26
+ *
27
+ * **Important**: This is a global patch that affects all drag events while active.
28
+ * Call the returned cleanup function when the shadow DOM is unmounted.
29
+ *
30
+ * **Known Limitation**: Drag handles (`dragHandle` option) do not work correctly
31
+ * with this fix. Elements will be draggable from anywhere on the element.
32
+ *
33
+ * @param shadowRoot - The shadow root to apply the fix to
34
+ * @returns A cleanup function to restore the original behavior
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * useEffect(() => {
39
+ * const shadowRoot = containerRef.current?.shadowRoot;
40
+ * if (shadowRoot) {
41
+ * const cleanup = applyShadowDomDndFix(shadowRoot);
42
+ * return cleanup;
43
+ * }
44
+ * }, []);
45
+ * ```
46
+ */
47
+ export declare function applyShadowDomDndFix(shadowRoot: ShadowRoot): () => void;