@go-mailer/easy-email-extensions 5.0.4 → 5.0.5

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.
@@ -0,0 +1,48 @@
1
+ import { EditorContent } from '@go-mailer/easy-email-editor';
2
+ export interface AIBlockSummary {
3
+ /** Dot-path index into the email JSON tree, e.g. `"content.children.[0].children.[1]"`. */
4
+ idx: string;
5
+ /** MJML block type string, e.g. `"advanced_text"`, `"advanced_image"`. */
6
+ type: string;
7
+ /** Human-readable title if set on the block. */
8
+ title?: string;
9
+ /** Plain text extracted from HTML content fields (text blocks). */
10
+ plainText: string;
11
+ /** Alt text for image blocks, empty for others. */
12
+ alt: string;
13
+ /** Href for button/link blocks, empty for others. */
14
+ href: string;
15
+ }
16
+ export interface AIEmailContext extends EditorContent {
17
+ /** Flat list of every block in the email with key content fields. */
18
+ blockSummaries: AIBlockSummary[];
19
+ /** Plain text of the entire email (all text blocks concatenated). */
20
+ emailPlainText: string;
21
+ /** Plain text of the currently focused block only. */
22
+ focusBlockPlainText: string;
23
+ /** The text the user has highlighted in the canvas right now. */
24
+ selectedText: string;
25
+ }
26
+ /**
27
+ * Returns a comprehensive snapshot of the current editor state, designed to
28
+ * be passed to an AI assistant. The returned object includes:
29
+ *
30
+ * - `emailTemplate` — full JSON tree (`IEmailTemplate`)
31
+ * - `focusIdx` — dot-path of the selected block
32
+ * - `focusBlock` — the selected block node
33
+ * - `focusBlockPlainText` — plain text extracted from the selected block
34
+ * - `selection` — `{ text, blockIdx }` for the highlighted text
35
+ * - `selectedText` — convenience alias for `selection.text`
36
+ * - `blockSummaries` — flat list of all blocks with extracted content
37
+ * - `emailPlainText` — full email as plain text (all blocks joined)
38
+ *
39
+ * Mount this inside `<EmailEditorProvider>`. The return value is memoized
40
+ * and only recalculates when relevant state changes.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const ctx = useAIContext();
45
+ * // Pass ctx to your AI panel, or send ctx.emailPlainText to your LLM API.
46
+ * ```
47
+ */
48
+ export declare function useAIContext(): AIEmailContext;
package/lib/index.d.ts CHANGED
@@ -17,3 +17,5 @@ export { getContextMergeTags } from './utils/getContextMergeTags';
17
17
  export { getIconNameByBlockType, setIconsMap } from './utils/getIconNameByBlockType';
18
18
  export { getBlockTitle } from './utils/getBlockTitle';
19
19
  export { MjmlToJson } from './utils/MjmlToJson';
20
+ export { useAIContext } from './hooks/useAIContext';
21
+ export type { AIEmailContext, AIBlockSummary } from './hooks/useAIContext';
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { e as Align, A as AttributePanel, f as AttributesPanelWrapper, ae as AutoCompleteField, l as Background, o as BackgroundColor, d as BlockAttributeConfigurationManager, B as BlockLayer, O as BlockMarketManager, Q as BlockMaskWrapper, r as Border, u as BorderColor, x as BorderStyle, z as BorderWidth, ah as CheckboxField, I as ClassName, h as CollapseWrapper, C as Color, al as ColorPickerField, i as Condition, j as ContainerBackgroundColor, D as Decoration, P as DefaultPageConfigPanel, p as Direction, aj as EditGridTabField, ai as EditTabField, a0 as ExtensionContext, a1 as ExtensionProvider, F as FontFamily, v as FontSize, y as FontStyle, E as FontWeight, _ as GoMailerLayout, H as Height, ab as ImageUploaderField, ak as InlineTextField, a5 as InputWithUnitField, U as InteractivePrompt, L as LetterSpacing, m as LineHeight, q as Link, t as Margin, $ as MergeTagBadgePrompt, w as MergeTags, M as MjmlToJson, N as NavbarLinkPadding, a8 as NumberField, G as Padding, J as PresetColorsProvider, a3 as RICH_TEXT_TOOL_BAR, af as RadioGroupField, an as RichTextField, a6 as SearchField, ac as SelectField, S as SelectionRangeProvider, ao as ShadowDom, K as ShortcutToolbar, X as SimpleLayout, a9 as SliderField, R as SourceCodePanel, Y as StandardLayout, ag as SwitchField, T as TextAlign, a7 as TextAreaField, k as TextDecoration, a4 as TextField, n as TextTransform, ad as TreeSelectField, Z as TwoColumnLayout, aa as UploadField, V as VerticalAlign, W as Width, am as enhancer, b as getBlockTitle, g as getContextMergeTags, a as getIconNameByBlockType, s as setIconsMap, a2 as useExtensionProps } from "./index2.js";
1
+ export { e as Align, A as AttributePanel, f as AttributesPanelWrapper, af as AutoCompleteField, l as Background, o as BackgroundColor, d as BlockAttributeConfigurationManager, B as BlockLayer, Q as BlockMarketManager, R as BlockMaskWrapper, r as Border, v as BorderColor, y as BorderStyle, E as BorderWidth, ai as CheckboxField, J as ClassName, h as CollapseWrapper, C as Color, am as ColorPickerField, i as Condition, j as ContainerBackgroundColor, D as Decoration, P as DefaultPageConfigPanel, p as Direction, ak as EditGridTabField, aj as EditTabField, a1 as ExtensionContext, a2 as ExtensionProvider, F as FontFamily, w as FontSize, z as FontStyle, G as FontWeight, $ as GoMailerLayout, H as Height, ac as ImageUploaderField, al as InlineTextField, a6 as InputWithUnitField, X as InteractivePrompt, L as LetterSpacing, m as LineHeight, q as Link, t as Margin, a0 as MergeTagBadgePrompt, x as MergeTags, M as MjmlToJson, N as NavbarLinkPadding, a9 as NumberField, I as Padding, K as PresetColorsProvider, a4 as RICH_TEXT_TOOL_BAR, ag as RadioGroupField, ao as RichTextField, a7 as SearchField, ad as SelectField, S as SelectionRangeProvider, ap as ShadowDom, O as ShortcutToolbar, Y as SimpleLayout, aa as SliderField, U as SourceCodePanel, Z as StandardLayout, ah as SwitchField, T as TextAlign, a8 as TextAreaField, k as TextDecoration, a5 as TextField, n as TextTransform, ae as TreeSelectField, _ as TwoColumnLayout, ab as UploadField, V as VerticalAlign, W as Width, an as enhancer, b as getBlockTitle, g as getContextMergeTags, a as getIconNameByBlockType, s as setIconsMap, u as useAIContext, a3 as useExtensionProps } from "./index2.js";
2
2
  import "react";
3
3
  import "@go-mailer/easy-email-editor";
4
4
  import "@go-mailer/easy-email-core";