@kontakto/email-template-editor 2.2.1 → 2.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, { CSSProperties } from 'react';
2
2
  import { z } from 'zod';
3
+ import Handlebars from 'handlebars';
3
4
  import * as _mui_material_styles from '@mui/material/styles';
4
5
  import { Theme } from '@mui/material/styles';
5
6
 
@@ -2160,6 +2161,20 @@ declare function buildBlockConfigurationSchema<T extends BaseZodDictionary>(bloc
2160
2161
  */
2161
2162
  declare function buildBlockConfigurationDictionary<T extends BaseZodDictionary>(blocks: DocumentBlocksDictionary<T>): DocumentBlocksDictionary<T>;
2162
2163
 
2164
+ /**
2165
+ * A fresh Handlebars environment scoped to the editor. Pre-registered with
2166
+ * `formatDate` and `formatNumber` helpers. Kept isolated from the global
2167
+ * `Handlebars` default instance so registrations here don't leak into the
2168
+ * consumer's own environment (and vice versa).
2169
+ */
2170
+ declare const editorHandlebars: typeof Handlebars;
2171
+ type HandlebarsContext = Record<string, unknown>;
2172
+ /**
2173
+ * Compile `source` as a Handlebars template and render it with `context`.
2174
+ * Uses the scoped {@link editorHandlebars} instance.
2175
+ */
2176
+ declare function evaluateHandlebars(source: string, context: HandlebarsContext): string;
2177
+
2163
2178
  /**
2164
2179
  * Reader component - responsible for rendering an email document
2165
2180
  *
@@ -4446,19 +4461,27 @@ declare function Reader({ document, rootBlockId }: TReaderProps): React.JSX.Elem
4446
4461
  * suitable for sending as an email. It adds the DOCTYPE and wraps everything
4447
4462
  * in basic HTML/body tags.
4448
4463
  *
4464
+ * When `variables` is provided, the rendered HTML is evaluated as a
4465
+ * Handlebars template — conditionals, loops, subpath access, and the
4466
+ * built-in `formatDate` / `formatNumber` helpers all resolve against the
4467
+ * given context. Without `variables`, the output keeps raw `{{name}}`
4468
+ * placeholders in place (the save-time, send-later shape).
4469
+ *
4449
4470
  * @param document The email document structure to render
4450
- * @param options Options including the rootBlockId to start rendering from
4471
+ * @param options Options including the rootBlockId to start rendering from, and optional Handlebars context
4451
4472
  * @returns A complete HTML string representation of the email
4452
4473
  */
4453
4474
  type TOptions$1 = {
4454
4475
  rootBlockId: string;
4476
+ variables?: HandlebarsContext;
4455
4477
  };
4456
- declare function renderToStaticMarkup(document: TReaderDocument, { rootBlockId }: TOptions$1): string;
4478
+ declare function renderToStaticMarkup(document: TReaderDocument, { rootBlockId, variables }: TOptions$1): string;
4457
4479
 
4458
4480
  type TOptions = {
4459
4481
  rootBlockId: string;
4482
+ variables?: HandlebarsContext;
4460
4483
  };
4461
- declare function renderToText(document: TReaderDocument, { rootBlockId }: TOptions): string;
4484
+ declare function renderToText(document: TReaderDocument, { rootBlockId, variables }: TOptions): string;
4462
4485
 
4463
4486
  declare const ColumnsContainerPropsSchema: z.ZodObject<{
4464
4487
  style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -6064,9 +6087,14 @@ interface EmailEditorProps {
6064
6087
  */
6065
6088
  copyTemplate?: (templateName: string, content: any) => void;
6066
6089
  /**
6067
- * Callback to rename a template by ID. Receives the new slug.
6090
+ * Callback to update a template's details. Receives the new slug and an
6091
+ * optional options bag with the full new tag list. Called from the
6092
+ * drawer's Edit-details dialog — the `tags` array replaces the existing
6093
+ * tag list when provided.
6068
6094
  */
6069
- renameTemplate?: (templateId: string, newSlug: string) => void | Promise<void>;
6095
+ renameTemplate?: (templateId: string, newSlug: string, opts?: {
6096
+ tags?: string[];
6097
+ }) => void | Promise<void>;
6070
6098
  /**
6071
6099
  * Callback to promote/demote a row between `template` and `sample`.
6072
6100
  * When omitted, promote/demote menu items are hidden.
@@ -6104,4 +6132,4 @@ interface EmailEditorProps {
6104
6132
  }
6105
6133
  declare const EmailEditor: React.ForwardRefExoticComponent<EmailEditorProps & React.RefAttributes<EmailEditorRef>>;
6106
6134
 
6107
- export { Avatar, AvatarProps, AvatarPropsDefaults, AvatarPropsSchema, BlockConfiguration, Button, ButtonProps, ButtonPropsDefaults, ButtonPropsSchema, ColumnsContainer, ColumnsContainerProps$1 as ColumnsContainerProps, ColumnsContainerPropsSchema$1 as ColumnsContainerPropsSchema, ColumnsContainerReader, Container, ContainerProps$1 as ContainerProps, ContainerPropsSchema$1 as ContainerPropsSchema, ContainerReader, Divider, DividerProps, DividerPropsDefaults, DividerPropsSchema, DocumentBlocksDictionary, EmailEditor, type EmailEditorContextType, type EmailEditorProps, EmailEditorProvider, type EmailEditorProviderProps, type EmailEditorRef, EmailLayoutPropsSchema, EmailLayoutReader, EmailMarkdown, Heading, HeadingProps, HeadingPropsDefaults, HeadingPropsSchema, Html, HtmlProps, HtmlPropsSchema, Image, type ImageCallbacks, ImageProps, ImagePropsSchema, type LibraryImage, Reader, ReaderBlock, ReaderBlockSchema, ReaderDocumentSchema, type SavePayload, Signature, SignatureProps, SignaturePropsDefaults, SignaturePropsSchema, Spacer, SpacerProps, SpacerPropsDefaults, SpacerPropsSchema, type TReaderBlock, type TReaderBlockProps, type TReaderDocument, type TReaderProps, type TemplateKind, type TemplateListItem, TemplateVariableSchema, Text, TextProps, TextPropsDefaults, TextPropsSchema, type UploadedImage, buildBlockComponent, buildBlockConfigurationDictionary, buildBlockConfigurationSchema, htmlToEditorConfig, renderToStaticMarkup, renderToText, THEME as theme, useEmailEditor };
6135
+ export { Avatar, AvatarProps, AvatarPropsDefaults, AvatarPropsSchema, BlockConfiguration, Button, ButtonProps, ButtonPropsDefaults, ButtonPropsSchema, ColumnsContainer, ColumnsContainerProps$1 as ColumnsContainerProps, ColumnsContainerPropsSchema$1 as ColumnsContainerPropsSchema, ColumnsContainerReader, Container, ContainerProps$1 as ContainerProps, ContainerPropsSchema$1 as ContainerPropsSchema, ContainerReader, Divider, DividerProps, DividerPropsDefaults, DividerPropsSchema, DocumentBlocksDictionary, EmailEditor, type EmailEditorContextType, type EmailEditorProps, EmailEditorProvider, type EmailEditorProviderProps, type EmailEditorRef, EmailLayoutPropsSchema, EmailLayoutReader, EmailMarkdown, type HandlebarsContext, Heading, HeadingProps, HeadingPropsDefaults, HeadingPropsSchema, Html, HtmlProps, HtmlPropsSchema, Image, type ImageCallbacks, ImageProps, ImagePropsSchema, type LibraryImage, Reader, ReaderBlock, ReaderBlockSchema, ReaderDocumentSchema, type SavePayload, Signature, SignatureProps, SignaturePropsDefaults, SignaturePropsSchema, Spacer, SpacerProps, SpacerPropsDefaults, SpacerPropsSchema, type TReaderBlock, type TReaderBlockProps, type TReaderDocument, type TReaderProps, type TemplateKind, type TemplateListItem, TemplateVariableSchema, Text, TextProps, TextPropsDefaults, TextPropsSchema, type UploadedImage, buildBlockComponent, buildBlockConfigurationDictionary, buildBlockConfigurationSchema, editorHandlebars, evaluateHandlebars, htmlToEditorConfig, renderToStaticMarkup, renderToText, THEME as theme, useEmailEditor };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, { CSSProperties } from 'react';
2
2
  import { z } from 'zod';
3
+ import Handlebars from 'handlebars';
3
4
  import * as _mui_material_styles from '@mui/material/styles';
4
5
  import { Theme } from '@mui/material/styles';
5
6
 
@@ -2160,6 +2161,20 @@ declare function buildBlockConfigurationSchema<T extends BaseZodDictionary>(bloc
2160
2161
  */
2161
2162
  declare function buildBlockConfigurationDictionary<T extends BaseZodDictionary>(blocks: DocumentBlocksDictionary<T>): DocumentBlocksDictionary<T>;
2162
2163
 
2164
+ /**
2165
+ * A fresh Handlebars environment scoped to the editor. Pre-registered with
2166
+ * `formatDate` and `formatNumber` helpers. Kept isolated from the global
2167
+ * `Handlebars` default instance so registrations here don't leak into the
2168
+ * consumer's own environment (and vice versa).
2169
+ */
2170
+ declare const editorHandlebars: typeof Handlebars;
2171
+ type HandlebarsContext = Record<string, unknown>;
2172
+ /**
2173
+ * Compile `source` as a Handlebars template and render it with `context`.
2174
+ * Uses the scoped {@link editorHandlebars} instance.
2175
+ */
2176
+ declare function evaluateHandlebars(source: string, context: HandlebarsContext): string;
2177
+
2163
2178
  /**
2164
2179
  * Reader component - responsible for rendering an email document
2165
2180
  *
@@ -4446,19 +4461,27 @@ declare function Reader({ document, rootBlockId }: TReaderProps): React.JSX.Elem
4446
4461
  * suitable for sending as an email. It adds the DOCTYPE and wraps everything
4447
4462
  * in basic HTML/body tags.
4448
4463
  *
4464
+ * When `variables` is provided, the rendered HTML is evaluated as a
4465
+ * Handlebars template — conditionals, loops, subpath access, and the
4466
+ * built-in `formatDate` / `formatNumber` helpers all resolve against the
4467
+ * given context. Without `variables`, the output keeps raw `{{name}}`
4468
+ * placeholders in place (the save-time, send-later shape).
4469
+ *
4449
4470
  * @param document The email document structure to render
4450
- * @param options Options including the rootBlockId to start rendering from
4471
+ * @param options Options including the rootBlockId to start rendering from, and optional Handlebars context
4451
4472
  * @returns A complete HTML string representation of the email
4452
4473
  */
4453
4474
  type TOptions$1 = {
4454
4475
  rootBlockId: string;
4476
+ variables?: HandlebarsContext;
4455
4477
  };
4456
- declare function renderToStaticMarkup(document: TReaderDocument, { rootBlockId }: TOptions$1): string;
4478
+ declare function renderToStaticMarkup(document: TReaderDocument, { rootBlockId, variables }: TOptions$1): string;
4457
4479
 
4458
4480
  type TOptions = {
4459
4481
  rootBlockId: string;
4482
+ variables?: HandlebarsContext;
4460
4483
  };
4461
- declare function renderToText(document: TReaderDocument, { rootBlockId }: TOptions): string;
4484
+ declare function renderToText(document: TReaderDocument, { rootBlockId, variables }: TOptions): string;
4462
4485
 
4463
4486
  declare const ColumnsContainerPropsSchema: z.ZodObject<{
4464
4487
  style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -6064,9 +6087,14 @@ interface EmailEditorProps {
6064
6087
  */
6065
6088
  copyTemplate?: (templateName: string, content: any) => void;
6066
6089
  /**
6067
- * Callback to rename a template by ID. Receives the new slug.
6090
+ * Callback to update a template's details. Receives the new slug and an
6091
+ * optional options bag with the full new tag list. Called from the
6092
+ * drawer's Edit-details dialog — the `tags` array replaces the existing
6093
+ * tag list when provided.
6068
6094
  */
6069
- renameTemplate?: (templateId: string, newSlug: string) => void | Promise<void>;
6095
+ renameTemplate?: (templateId: string, newSlug: string, opts?: {
6096
+ tags?: string[];
6097
+ }) => void | Promise<void>;
6070
6098
  /**
6071
6099
  * Callback to promote/demote a row between `template` and `sample`.
6072
6100
  * When omitted, promote/demote menu items are hidden.
@@ -6104,4 +6132,4 @@ interface EmailEditorProps {
6104
6132
  }
6105
6133
  declare const EmailEditor: React.ForwardRefExoticComponent<EmailEditorProps & React.RefAttributes<EmailEditorRef>>;
6106
6134
 
6107
- export { Avatar, AvatarProps, AvatarPropsDefaults, AvatarPropsSchema, BlockConfiguration, Button, ButtonProps, ButtonPropsDefaults, ButtonPropsSchema, ColumnsContainer, ColumnsContainerProps$1 as ColumnsContainerProps, ColumnsContainerPropsSchema$1 as ColumnsContainerPropsSchema, ColumnsContainerReader, Container, ContainerProps$1 as ContainerProps, ContainerPropsSchema$1 as ContainerPropsSchema, ContainerReader, Divider, DividerProps, DividerPropsDefaults, DividerPropsSchema, DocumentBlocksDictionary, EmailEditor, type EmailEditorContextType, type EmailEditorProps, EmailEditorProvider, type EmailEditorProviderProps, type EmailEditorRef, EmailLayoutPropsSchema, EmailLayoutReader, EmailMarkdown, Heading, HeadingProps, HeadingPropsDefaults, HeadingPropsSchema, Html, HtmlProps, HtmlPropsSchema, Image, type ImageCallbacks, ImageProps, ImagePropsSchema, type LibraryImage, Reader, ReaderBlock, ReaderBlockSchema, ReaderDocumentSchema, type SavePayload, Signature, SignatureProps, SignaturePropsDefaults, SignaturePropsSchema, Spacer, SpacerProps, SpacerPropsDefaults, SpacerPropsSchema, type TReaderBlock, type TReaderBlockProps, type TReaderDocument, type TReaderProps, type TemplateKind, type TemplateListItem, TemplateVariableSchema, Text, TextProps, TextPropsDefaults, TextPropsSchema, type UploadedImage, buildBlockComponent, buildBlockConfigurationDictionary, buildBlockConfigurationSchema, htmlToEditorConfig, renderToStaticMarkup, renderToText, THEME as theme, useEmailEditor };
6135
+ export { Avatar, AvatarProps, AvatarPropsDefaults, AvatarPropsSchema, BlockConfiguration, Button, ButtonProps, ButtonPropsDefaults, ButtonPropsSchema, ColumnsContainer, ColumnsContainerProps$1 as ColumnsContainerProps, ColumnsContainerPropsSchema$1 as ColumnsContainerPropsSchema, ColumnsContainerReader, Container, ContainerProps$1 as ContainerProps, ContainerPropsSchema$1 as ContainerPropsSchema, ContainerReader, Divider, DividerProps, DividerPropsDefaults, DividerPropsSchema, DocumentBlocksDictionary, EmailEditor, type EmailEditorContextType, type EmailEditorProps, EmailEditorProvider, type EmailEditorProviderProps, type EmailEditorRef, EmailLayoutPropsSchema, EmailLayoutReader, EmailMarkdown, type HandlebarsContext, Heading, HeadingProps, HeadingPropsDefaults, HeadingPropsSchema, Html, HtmlProps, HtmlPropsSchema, Image, type ImageCallbacks, ImageProps, ImagePropsSchema, type LibraryImage, Reader, ReaderBlock, ReaderBlockSchema, ReaderDocumentSchema, type SavePayload, Signature, SignatureProps, SignaturePropsDefaults, SignaturePropsSchema, Spacer, SpacerProps, SpacerPropsDefaults, SpacerPropsSchema, type TReaderBlock, type TReaderBlockProps, type TReaderDocument, type TReaderProps, type TemplateKind, type TemplateListItem, TemplateVariableSchema, Text, TextProps, TextPropsDefaults, TextPropsSchema, type UploadedImage, buildBlockComponent, buildBlockConfigurationDictionary, buildBlockConfigurationSchema, editorHandlebars, evaluateHandlebars, htmlToEditorConfig, renderToStaticMarkup, renderToText, THEME as theme, useEmailEditor };