@trycourier/react-designer 0.6.0 → 0.7.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 (31) hide show
  1. package/README.md +5 -3
  2. package/dist/cjs/index.js +58 -57
  3. package/dist/cjs/index.js.map +4 -4
  4. package/dist/cjs/styles.css +496 -235
  5. package/dist/components/BrandEditor/Editor/BrandFooter/BrandFooter.d.ts +3 -1
  6. package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +3 -0
  7. package/dist/components/TemplateEditor/Layout/Layout.d.ts +1 -0
  8. package/dist/components/TemplateEditor/TemplateEditor.d.ts +2 -0
  9. package/dist/components/TemplateEditor/VariableViewModeSync.d.ts +3 -0
  10. package/dist/components/TemplateEditor/index.d.ts +1 -0
  11. package/dist/components/TemplateEditor/store.d.ts +3 -0
  12. package/dist/components/extensions/Blockquote/Blockquote.d.ts +4 -0
  13. package/dist/components/extensions/Button/Button.types.d.ts +8 -4
  14. package/dist/components/extensions/ImageBlock/components/ImageBlockView.d.ts +1 -3
  15. package/dist/components/extensions/MessagingChannelPaste/MessagingChannelPaste.d.ts +11 -0
  16. package/dist/components/extensions/MessagingChannelPaste/index.d.ts +2 -0
  17. package/dist/components/extensions/Variable/Variable.d.ts +5 -0
  18. package/dist/components/ui/TextMenu/components/ContentTypePicker.d.ts +1 -1
  19. package/dist/components/ui/TextMenu/hooks/useTextmenuStates.d.ts +1 -0
  20. package/dist/components/ui/VariableEditor/VariableChipBase.d.ts +8 -0
  21. package/dist/components/ui/VariableEditor/VariableInput.d.ts +18 -0
  22. package/dist/esm/index.js +58 -57
  23. package/dist/esm/index.js.map +4 -4
  24. package/dist/esm/styles.css +496 -235
  25. package/dist/index.d.ts +2 -0
  26. package/dist/lib/constants/block-defaults.d.ts +43 -0
  27. package/dist/lib/constants/email-editor-tiptap-styles.d.ts +62 -0
  28. package/dist/lib/index.d.ts +1 -0
  29. package/dist/styles.css +496 -235
  30. package/dist/types/elemental.types.d.ts +3 -2
  31. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
+ import { type VariableViewMode } from "@/components/TemplateEditor/store";
1
2
  import type { Transaction } from "@tiptap/pm/state";
2
3
  import type { Editor } from "@tiptap/react";
3
4
  interface BrandFooterProps {
4
5
  value?: string | null;
5
6
  variables?: Record<string, unknown>;
6
7
  readOnly?: boolean;
8
+ variableViewMode?: VariableViewMode;
7
9
  facebookLink?: string;
8
10
  linkedinLink?: string;
9
11
  instagramLink?: string;
@@ -14,5 +16,5 @@ interface BrandFooterProps {
14
16
  transaction: Transaction;
15
17
  }) => void;
16
18
  }
17
- export declare const BrandFooter: import("react").MemoExoticComponent<({ facebookLink, linkedinLink, instagramLink, mediumLink, xLink, readOnly, value, onUpdate, }: BrandFooterProps) => import("react/jsx-runtime").JSX.Element>;
19
+ export declare const BrandFooter: import("react").MemoExoticComponent<({ facebookLink, linkedinLink, instagramLink, mediumLink, xLink, readOnly, value, variableViewMode, onUpdate, }: BrandFooterProps) => import("react/jsx-runtime").JSX.Element>;
18
20
  export {};
@@ -7,6 +7,9 @@ import type { AnyExtension, Editor } from "@tiptap/react";
7
7
  import type { HTMLAttributes } from "react";
8
8
  import type { TemplateEditorProps } from "../../TemplateEditor";
9
9
  export declare const defaultInboxContent: ElementalNode[];
10
+ export declare const getOrCreateInboxElement: (templateEditorContent: {
11
+ elements: ElementalNode[];
12
+ } | null | undefined) => ElementalNode;
10
13
  export declare const InboxConfig: TextMenuConfig;
11
14
  interface InboxEditorContentProps {
12
15
  value?: TiptapDoc;
@@ -6,5 +6,6 @@ export declare const ChannelRootContainer: import("react").ForwardRefExoticCompo
6
6
  export declare const EditorSidebar: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
7
7
  previewMode?: "desktop" | "mobile" | undefined;
8
8
  skipExpanded?: boolean;
9
+ collapsed?: boolean;
9
10
  width?: string;
10
11
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -12,6 +12,8 @@ export interface TemplateEditorProps extends Omit<HTMLAttributes<HTMLDivElement>
12
12
  /**
13
13
  * Variables available for autocomplete suggestions.
14
14
  * When provided, typing {{ will show a dropdown with matching variables.
15
+ * When not provided (undefined), all variable functionality is disabled:
16
+ * the variable toolbar button is hidden and typing {{ will not create variable chips.
15
17
  */
16
18
  variables?: Record<string, unknown>;
17
19
  /**
@@ -7,6 +7,9 @@ interface VariableViewModeSyncProps {
7
7
  * Syncs the variableViewMode prop to editor storage and dispatches a transaction
8
8
  * to notify VariableView components to re-render.
9
9
  *
10
+ * Also syncs the variablesEnabled state to the VariableInputRule extension storage,
11
+ * disabling the {{ input rule when the variables prop is not provided.
12
+ *
10
13
  * This component should be placed inside an EditorProvider.
11
14
  */
12
15
  export declare const VariableViewModeSync: ({ variableViewMode }: VariableViewModeSyncProps) => null;
@@ -14,5 +14,6 @@ export declare const InboxChannel: import("react").MemoExoticComponent<import("r
14
14
  export declare const MSTeamsChannel: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("./Channels").MSTeamsProps & import("react").RefAttributes<HTMLDivElement>>>;
15
15
  export declare const SlackChannel: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("./Channels").SlackProps & import("react").RefAttributes<HTMLDivElement>>>;
16
16
  export { ChannelRootContainer, EditorSidebar } from "./Layout";
17
+ export { isSidebarExpandedAtom } from "./store";
17
18
  export { InboxEditor, MSTeamsEditor, PushEditor, SlackEditor, SMSEditor } from "./Channels";
18
19
  export { useDebouncedFlush } from "./hooks/useDebouncedFlush";
@@ -30,6 +30,9 @@ export declare const isSidebarExpandedAtom: import("jotai").PrimitiveAtom<boolea
30
30
  export declare const variableValuesAtom: import("jotai").PrimitiveAtom<Record<string, string>> & {
31
31
  init: Record<string, string>;
32
32
  };
33
+ export declare const variablesEnabledAtom: import("jotai").PrimitiveAtom<boolean> & {
34
+ init: boolean;
35
+ };
33
36
  export declare const availableVariablesAtom: import("jotai").PrimitiveAtom<Record<string, unknown>> & {
34
37
  init: Record<string, unknown>;
35
38
  };
@@ -1,4 +1,8 @@
1
+ import { PluginKey } from "@tiptap/pm/state";
1
2
  import type { BlockquoteProps } from "./Blockquote.types";
3
+ import { QUOTE_TEXT_STYLE, QUOTE_TEXT_STYLE_VARIANTS } from "@/lib/constants/email-editor-tiptap-styles";
4
+ export { QUOTE_TEXT_STYLE, QUOTE_TEXT_STYLE_VARIANTS };
5
+ export declare const BlockquotePastePluginKey: PluginKey<any>;
2
6
  export declare const defaultBlockquoteProps: BlockquoteProps;
3
7
  export declare const Blockquote: import("@tiptap/core").Node<import("@tiptap/extension-blockquote").BlockquoteOptions, any>;
4
8
  export default Blockquote;
@@ -5,7 +5,8 @@ export declare const buttonSchema: z.ZodObject<{
5
5
  alignment: z.ZodEnum<["left", "center", "right"]>;
6
6
  backgroundColor: z.ZodString;
7
7
  borderRadius: z.ZodNumber;
8
- padding: z.ZodNumber;
8
+ paddingVertical: z.ZodNumber;
9
+ paddingHorizontal: z.ZodNumber;
9
10
  fontWeight: z.ZodEnum<["normal", "bold"]>;
10
11
  fontStyle: z.ZodEnum<["normal", "italic"]>;
11
12
  isUnderline: z.ZodBoolean;
@@ -15,9 +16,10 @@ export declare const buttonSchema: z.ZodObject<{
15
16
  }, "strip", z.ZodTypeAny, {
16
17
  backgroundColor: string;
17
18
  borderRadius: number;
19
+ paddingVertical: number;
20
+ paddingHorizontal: number;
18
21
  label: string;
19
22
  alignment: "left" | "center" | "right";
20
- padding: number;
21
23
  fontWeight: "normal" | "bold";
22
24
  fontStyle: "normal" | "italic";
23
25
  isUnderline: boolean;
@@ -28,9 +30,10 @@ export declare const buttonSchema: z.ZodObject<{
28
30
  }, {
29
31
  backgroundColor: string;
30
32
  borderRadius: number;
33
+ paddingVertical: number;
34
+ paddingHorizontal: number;
31
35
  label: string;
32
36
  alignment: "left" | "center" | "right";
33
- padding: number;
34
37
  fontWeight: "normal" | "bold";
35
38
  fontStyle: "normal" | "italic";
36
39
  isUnderline: boolean;
@@ -45,7 +48,8 @@ export interface ButtonProps {
45
48
  alignment: "left" | "center" | "right";
46
49
  backgroundColor: string;
47
50
  borderRadius: number;
48
- padding: number;
51
+ paddingVertical: number;
52
+ paddingHorizontal: number;
49
53
  fontWeight: "normal" | "bold";
50
54
  fontStyle: "normal" | "italic";
51
55
  isUnderline: boolean;
@@ -1,4 +1,4 @@
1
- import type { Editor, NodeViewProps } from "@tiptap/react";
1
+ import type { NodeViewProps } from "@tiptap/react";
2
2
  import React from "react";
3
3
  import type { ImageBlockProps } from "../ImageBlock.types";
4
4
  export declare const ImageBlockComponent: React.FC<ImageBlockProps & {
@@ -7,7 +7,5 @@ export declare const ImageBlockComponent: React.FC<ImageBlockProps & {
7
7
  draggable?: boolean;
8
8
  onFileSelect?: (file: File) => void;
9
9
  width: number;
10
- imageNaturalWidth: number;
11
- editor?: Editor;
12
10
  }>;
13
11
  export declare const ImageBlockView: (props: NodeViewProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Extension } from "@tiptap/core";
2
+ export interface MessagingChannelPasteOptions {
3
+ /** Convert all headings to this level, or "strip" to convert headings to paragraphs. */
4
+ headingBehavior: {
5
+ level: number;
6
+ } | "strip";
7
+ /** Node type names that should be silently dropped on paste (e.g. "button" for Teams). */
8
+ blockedNodeTypes?: string[];
9
+ }
10
+ export declare const MessagingChannelPaste: Extension<MessagingChannelPasteOptions, any>;
11
+ export default MessagingChannelPaste;
@@ -0,0 +1,2 @@
1
+ export { MessagingChannelPaste } from "./MessagingChannelPaste";
2
+ export type { MessagingChannelPasteOptions } from "./MessagingChannelPaste";
@@ -4,6 +4,11 @@ export declare const VariableNode: Node<VariableNodeOptions, any>;
4
4
  /**
5
5
  * Extension that inserts an empty variable chip when user types {{
6
6
  * This is used when autocomplete is disabled (disableVariablesAutocomplete=true)
7
+ *
8
+ * Storage:
9
+ * - `disabled`: When true, typing {{ will not create variable chips.
10
+ * Set this from React via `editor.storage.variableInputRule.disabled = true`
11
+ * when the `variables` prop is not provided to TemplateEditor.
7
12
  */
8
13
  export declare const VariableInputRule: Extension<any, any>;
9
14
  /**
@@ -19,4 +19,4 @@ export interface ContentTypePickerProps {
19
19
  options: ContentPickerOptions;
20
20
  containerRef?: RefObject<HTMLDivElement>;
21
21
  }
22
- export declare const ContentTypePicker: ({ options, containerRef }: ContentTypePickerProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const ContentTypePicker: ({ options, containerRef }: ContentTypePickerProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -12,6 +12,7 @@ export declare const useTextmenuStates: (editor: Editor | null) => {
12
12
  isOrderedList: boolean;
13
13
  isUnorderedList: boolean;
14
14
  isLink: boolean;
15
+ isHeading: boolean;
15
16
  shouldShow: ({ editor }: {
16
17
  editor: Editor;
17
18
  }) => boolean;
@@ -33,5 +33,13 @@ export interface VariableChipBaseProps {
33
33
  getColors?: (isInvalid: boolean, hasValue: boolean) => VariableColors;
34
34
  /** Whether the chip is read-only (prevents editing) */
35
35
  readOnly?: boolean;
36
+ /** Formatting styles derived from TipTap marks (bold, italic, underline, strikethrough) */
37
+ formattingStyle?: React.CSSProperties;
38
+ /** Whether the chip is within the current text selection */
39
+ isSelected?: boolean;
40
+ /** Called when the chip is clicked for selection (not editing) */
41
+ onSelect?: () => void;
42
+ /** Called after editing is committed (suggestion selected or blur confirmed) to restore editor focus */
43
+ onCommit?: () => void;
36
44
  }
37
45
  export declare const VariableChipBase: React.FC<VariableChipBaseProps>;
@@ -1,5 +1,23 @@
1
1
  import * as React from "react";
2
2
  import { type VariableEditorBaseProps } from "./shared";
3
+ /**
4
+ * Determines if a click landed in the empty space of a VariableInput and returns
5
+ * the correct target position to place the caret, or null if no correction is needed.
6
+ *
7
+ * This handles two cases where the browser's native click handler misplaces the caret
8
+ * inside a flex-layout ProseMirror editor with non-editable variable chip nodes:
9
+ *
10
+ * Case 1 (depth === 0): posAtCoords returned {inside: -1}, meaning the click didn't
11
+ * land inside any node. The resolved position is at the doc level.
12
+ *
13
+ * Case 2 (depth > 0, clickX past content): posAtCoords returned a paragraph-level
14
+ * position, but the click coordinates are past the visible content's right edge.
15
+ * Common when content ends with a variable chip.
16
+ */
17
+ export declare function resolveEmptySpaceClick(posDepth: number, pos: number, paragraphContentSize: number, clickX: number, endCoordsRight: number | null): {
18
+ targetPos: number;
19
+ bias: -1 | 1;
20
+ } | null;
3
21
  export interface VariableInputProps extends VariableEditorBaseProps {
4
22
  /** Whether the input is read-only */
5
23
  readOnly?: boolean;