monto-email-builder 1.3.1 → 1.4.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.
@@ -1,7 +1,19 @@
1
+ import React from 'react';
1
2
  import { SxProps, Theme } from '@mui/material';
2
3
  import { Language } from '../i18n';
4
+ import { type HtmlEditorVariableInput, type HtmlEditorVariableItem, type HtmlEditorVariableValidationResult } from './variables';
3
5
  export type HtmlEditorMode = 'split' | 'code' | 'preview';
4
6
  export type HtmlEditorDevice = 'desktop' | 'mobile';
7
+ export type HtmlEditorRightTab = 'preview' | 'variables';
8
+ export type { HtmlEditorVariableInput, HtmlEditorVariableItem, HtmlEditorVariableValidationResult, };
9
+ export interface HtmlEditorRef {
10
+ getValue: () => string;
11
+ getPreviewHtml: () => string;
12
+ scanVariables: () => HtmlEditorVariableItem[];
13
+ getVariables: (callback?: (items: HtmlEditorVariableItem[]) => void) => HtmlEditorVariableItem[];
14
+ validateVariables: () => HtmlEditorVariableValidationResult;
15
+ showVariables: () => void;
16
+ }
5
17
  export interface HtmlEditorProps {
6
18
  /**
7
19
  * HTML 代码内容
@@ -50,6 +62,25 @@ export interface HtmlEditorProps {
50
62
  * 若本地已有 localStorage 则优先用 localStorage;未传时默认 'dracula'
51
63
  */
52
64
  initialTheme?: string;
65
+ /**
66
+ * 初始右侧面板 tab
67
+ * @default 'preview'
68
+ */
69
+ initialRightTab?: HtmlEditorRightTab;
70
+ /**
71
+ * 已有模板变量默认值。保存时可通过 ref.validateVariables() 扫描当前 HTML 并合并这些默认值。
72
+ */
73
+ variables?: HtmlEditorVariableInput[];
74
+ /**
75
+ * 变量变更回调
76
+ */
77
+ onVariablesChange?: (variables: HtmlEditorVariableItem[]) => void;
78
+ /**
79
+ * 保存校验时是否要求用户变量填写默认值
80
+ * @default true
81
+ */
82
+ requireVariableDefaults?: boolean;
53
83
  }
54
- export default function HtmlEditor({ value, onChange, language, initialMode, initialDevice, codeEditorHeight, previewHeight, sx, showToolbar, initialTheme, }: HtmlEditorProps): import("react/jsx-runtime").JSX.Element;
84
+ declare const ForwardedHtmlEditor: React.ForwardRefExoticComponent<HtmlEditorProps & React.RefAttributes<HtmlEditorRef>>;
85
+ export default ForwardedHtmlEditor;
55
86
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/HtmlEditor/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAA2D,OAAO,EAAE,KAAK,EAA2B,MAAM,eAAe,CAAC;AAOjI,OAAO,EAAE,QAAQ,EAAK,MAAM,SAAS,CAAC;AAUtC,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AA8DpD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,QAAe,EACf,WAAqB,EACrB,aAAyB,EACzB,gBAAyB,EACzB,aAAsB,EACtB,EAAE,EAC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G;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE,KAAK,IAAI,CAAC;IAClE;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAi1BD,QAAA,MAAM,mBAAmB,uFAAyD,CAAC;AAGnF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type VariableGroup, type VariableKind } from '../documents/blocks/Text/variableCatalog';
2
+ export type HtmlEditorVariableType = 'user' | 'system';
3
+ export type HtmlEditorVariableItem = {
4
+ id: number;
5
+ variable: string;
6
+ type: HtmlEditorVariableType;
7
+ attribute: string;
8
+ default: string;
9
+ };
10
+ export type HtmlEditorVariableInput = Partial<HtmlEditorVariableItem> & {
11
+ Variable?: string;
12
+ Type?: HtmlEditorVariableType;
13
+ Attribute?: string;
14
+ Default?: string;
15
+ key?: string;
16
+ value?: string;
17
+ };
18
+ export type HtmlEditorVariableValidationResult = {
19
+ valid: boolean;
20
+ variables: HtmlEditorVariableItem[];
21
+ missing: HtmlEditorVariableItem[];
22
+ };
23
+ export declare const HTML_EDITOR_VARIABLE_GROUPS: VariableGroup[];
24
+ export declare const HTML_EDITOR_UNSUBSCRIBE_LINK_VARIABLE = "unsubscribe_link";
25
+ export declare function parseHtmlEditorVariableToken(token: string | null | undefined): {
26
+ attribute: string;
27
+ type: HtmlEditorVariableType;
28
+ } | null;
29
+ export declare function normalizeHtmlEditorVariables(variables: ReadonlyArray<HtmlEditorVariableInput> | null | undefined): HtmlEditorVariableItem[];
30
+ export declare function scanHtmlEditorVariables(source: string): HtmlEditorVariableItem[];
31
+ export declare function mergeScannedHtmlEditorVariables(scanned: ReadonlyArray<HtmlEditorVariableItem>, current: ReadonlyArray<HtmlEditorVariableItem>): HtmlEditorVariableItem[];
32
+ export declare function applyHtmlEditorVariableDefaults(source: string, variables: ReadonlyArray<HtmlEditorVariableItem>): string;
33
+ export declare function createHtmlEditorVariable(name: string, kind: VariableKind, defaultValue?: string): HtmlEditorVariableItem | null;
34
+ export declare function isHtmlEditorBuiltinVariableName(name: string): boolean;
35
+ export declare function getHtmlEditorVariableInsertText(name: string, kind: VariableKind): string;
36
+ //# sourceMappingURL=variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/HtmlEditor/variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,0CAA0C,CAAC;AAElD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvD,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM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2
2
  newDocument: "New Blank Document",
3
3
  useBuiltInTemplates: "Use Built-in Templates",
4
4
  emailBuilder: "Monto Email Builder",
@@ -21,7 +21,7 @@ const c = {
21
21
  undoTooltip: "Undo (Ctrl/Cmd + Z)",
22
22
  redo: "Redo",
23
23
  redoTooltip: "Redo (Ctrl/Cmd + Shift + Z)"
24
- }, d = {
24
+ }, c = {
25
25
  welcomeEmail: "Marketing Template",
26
26
  oneTimePasscode: "One-time passcode (OTP)",
27
27
  resetPassword: "Reset password",
@@ -57,7 +57,7 @@ const c = {
57
57
  uploading: "Uploading...",
58
58
  uploadHandlerNotConfigured: "Please configure imageUploadHandler to enable local upload",
59
59
  placeholder: "Add an image"
60
- }, g = {
60
+ }, b = {
61
61
  title: "Video block",
62
62
  name: "Video",
63
63
  sourceUrl: "Video URL",
@@ -78,7 +78,7 @@ const c = {
78
78
  loop: "Loop",
79
79
  muted: "Muted",
80
80
  controls: "Show controls"
81
- }, h = {
81
+ }, g = {
82
82
  title: "Columns block",
83
83
  name: "Columns",
84
84
  layout: "Layout",
@@ -96,7 +96,7 @@ const c = {
96
96
  confirmChangeMessage: "Changing the column layout will delete data in some columns. This action cannot be undone. Are you sure you want to continue?",
97
97
  cancel: "Cancel",
98
98
  confirm: "Confirm"
99
- }, b = {
99
+ }, h = {
100
100
  global: "Global",
101
101
  backdropColor: "Backdrop color",
102
102
  canvasColor: "Canvas color",
@@ -105,7 +105,7 @@ const c = {
105
105
  pageWidth: "Page width",
106
106
  fontFamily: "Font family",
107
107
  textColor: "Text color"
108
- }, k = {
108
+ }, y = {
109
109
  title: "Text block",
110
110
  name: "Text",
111
111
  content: "Content",
@@ -172,7 +172,7 @@ const c = {
172
172
  customVariableNameInvalid: "Only letters, numbers, and underscores allowed, starting with a letter or underscore",
173
173
  customVariableNameDuplicate: "Variable name already exists"
174
174
  }
175
- }, C = {
175
+ }, k = {
176
176
  title: "Button block",
177
177
  name: "Button",
178
178
  text: "Text",
@@ -191,7 +191,7 @@ const c = {
191
191
  stylePill: "Pill",
192
192
  textColor: "Text color",
193
193
  buttonColor: "Button color"
194
- }, y = {
194
+ }, v = {
195
195
  title: "Heading block",
196
196
  name: "Heading",
197
197
  content: "Content",
@@ -205,7 +205,7 @@ const c = {
205
205
  shapeRounded: "Rounded",
206
206
  imageUrl: "Image URL",
207
207
  altText: "Alt text"
208
- }, v = {
208
+ }, C = {
209
209
  title: "Divider block",
210
210
  name: "Divider",
211
211
  color: "Color",
@@ -234,7 +234,7 @@ const c = {
234
234
  iconUrl: "Link URL",
235
235
  placeholder: "Click the right panel to add social media icons",
236
236
  addAnother: "Add another social link"
237
- }, R = {
237
+ }, x = {
238
238
  backgroundColor: "Background color",
239
239
  borderColor: "Border color",
240
240
  borderRadius: "Border radius",
@@ -258,7 +258,7 @@ const c = {
258
258
  both: "Both",
259
259
  default: "Default",
260
260
  formatGroup: "Style"
261
- }, U = {
261
+ }, R = {
262
262
  mode: {
263
263
  split: "Split view",
264
264
  code: "Code only",
@@ -277,28 +277,42 @@ const c = {
277
277
  previewOnly: "Preview only",
278
278
  desktopView: "Desktop view",
279
279
  mobileView: "Mobile view"
280
+ },
281
+ tabs: {
282
+ preview: "Preview",
283
+ variables: "Settings"
284
+ },
285
+ variables: {
286
+ title: "Variables",
287
+ scan: "Scan variables",
288
+ scanHint: "Insert variables here and set their default values.",
289
+ help: "You can type {{variable_name}} directly in the code, then click Save in the code panel to scan variables and set default values in one place. You can also insert variables from Settings and enter their defaults here.",
290
+ detected: "Detected variables",
291
+ defaultHelp: "Please enter a default value to ensure that the content displays correctly even if the variable is missing.",
292
+ empty: "No variables yet. Click Save in the code panel to scan, or insert one from the catalog above.",
293
+ systemDefault: "System variables do not need defaults"
280
294
  }
281
- }, V = {
282
- common: c,
283
- samples: d,
295
+ }, A = {
296
+ common: d,
297
+ samples: c,
284
298
  inspector: u,
285
299
  tabs: m,
286
300
  image: p,
287
- video: g,
288
- columns: h,
289
- emailLayout: b,
290
- text: k,
291
- button: C,
292
- heading: y,
301
+ video: b,
302
+ columns: g,
303
+ emailLayout: h,
304
+ text: y,
305
+ button: k,
306
+ heading: v,
293
307
  avatar: f,
294
- divider: v,
308
+ divider: C,
295
309
  container: S,
296
310
  spacer: w,
297
311
  html: T,
298
312
  socials: L,
299
- style: R,
300
- htmlEditor: U
301
- }, x = {
313
+ style: x,
314
+ htmlEditor: R
315
+ }, V = {
302
316
  newDocument: "新建空白文档",
303
317
  useBuiltInTemplates: "使用内置模板",
304
318
  emailBuilder: "Monto 邮件编辑器",
@@ -321,7 +335,7 @@ const c = {
321
335
  undoTooltip: "撤销 (Ctrl/Cmd + Z)",
322
336
  redo: "重做",
323
337
  redoTooltip: "重做 (Ctrl/Cmd + Shift + Z)"
324
- }, B = {
338
+ }, U = {
325
339
  welcomeEmail: "营销模板",
326
340
  oneTimePasscode: "一次性密码 (OTP)",
327
341
  resetPassword: "重置密码",
@@ -331,17 +345,17 @@ const c = {
331
345
  postMetrics: "指标报告",
332
346
  respondToMessage: "回复询问",
333
347
  quickStart: "快速开始"
334
- }, M = {
348
+ }, B = {
335
349
  styles: "样式",
336
350
  inspect: "检查",
337
351
  clickBlockToInspect: "点击一个块进行检查。",
338
352
  blockNotFound: "未找到 id 为 {{id}} 的块。点击一个块以重置。"
339
- }, A = {
353
+ }, N = {
340
354
  edit: "编辑",
341
355
  preview: "预览",
342
356
  htmlOutput: "HTML 输出",
343
357
  jsonOutput: "JSON 输出"
344
- }, I = {
358
+ }, M = {
345
359
  title: "图片块",
346
360
  name: "图片",
347
361
  sourceUrl: "图片地址",
@@ -357,7 +371,7 @@ const c = {
357
371
  uploading: "上传中...",
358
372
  uploadHandlerNotConfigured: "请配置 imageUploadHandler 以启用本地上传功能",
359
373
  placeholder: "添加图片"
360
- }, N = {
374
+ }, I = {
361
375
  title: "视频块",
362
376
  name: "视频",
363
377
  sourceUrl: "视频地址",
@@ -396,7 +410,7 @@ const c = {
396
410
  confirmChangeMessage: "切换分栏布局将删除部分列中的数据,此操作不可撤销。确定要继续吗?",
397
411
  cancel: "取消",
398
412
  confirm: "确定"
399
- }, z = {
413
+ }, E = {
400
414
  global: "全局",
401
415
  backdropColor: "背景颜色",
402
416
  canvasColor: "画布颜色",
@@ -405,7 +419,7 @@ const c = {
405
419
  pageWidth: "页面宽度",
406
420
  fontFamily: "字体",
407
421
  textColor: "文字颜色"
408
- }, E = {
422
+ }, _ = {
409
423
  title: "文本块",
410
424
  name: "文本",
411
425
  content: "内容",
@@ -491,12 +505,12 @@ const c = {
491
505
  stylePill: "胶囊",
492
506
  textColor: "文字颜色",
493
507
  buttonColor: "按钮颜色"
494
- }, D = {
508
+ }, z = {
495
509
  title: "标题块",
496
510
  name: "标题",
497
511
  content: "内容",
498
512
  level: "级别"
499
- }, O = {
513
+ }, D = {
500
514
  title: "头像块",
501
515
  size: "尺寸",
502
516
  shape: "形状",
@@ -505,23 +519,23 @@ const c = {
505
519
  shapeRounded: "圆角",
506
520
  imageUrl: "图片地址",
507
521
  altText: "替代文本"
508
- }, $ = {
522
+ }, K = {
509
523
  title: "分割线块",
510
524
  name: "分割线",
511
525
  color: "颜色",
512
526
  height: "高度"
513
- }, W = {
527
+ }, O = {
514
528
  title: "容器块",
515
529
  name: "容器"
516
- }, F = {
530
+ }, $ = {
517
531
  title: "间距块",
518
532
  name: "间距",
519
533
  height: "高度"
520
- }, q = {
534
+ }, W = {
521
535
  title: "HTML块",
522
536
  name: "HTML",
523
537
  content: "内容"
524
- }, J = {
538
+ }, F = {
525
539
  title: "社媒块",
526
540
  name: "社媒",
527
541
  selectPlatforms: "社媒选择",
@@ -534,7 +548,7 @@ const c = {
534
548
  iconUrl: "跳转链接",
535
549
  placeholder: "点击右侧面板添加社媒图标",
536
550
  addAnother: "新增社媒"
537
- }, j = {
551
+ }, q = {
538
552
  backgroundColor: "背景颜色",
539
553
  borderColor: "边框颜色",
540
554
  borderRadius: "圆角",
@@ -558,7 +572,7 @@ const c = {
558
572
  both: "两者",
559
573
  default: "默认",
560
574
  formatGroup: "样式"
561
- }, Z = {
575
+ }, J = {
562
576
  mode: {
563
577
  split: "左右栏",
564
578
  code: "仅代码",
@@ -577,65 +591,151 @@ const c = {
577
591
  previewOnly: "仅预览",
578
592
  desktopView: "桌面视图",
579
593
  mobileView: "移动视图"
594
+ },
595
+ tabs: {
596
+ preview: "预览",
597
+ variables: "设置"
598
+ },
599
+ variables: {
600
+ title: "变量",
601
+ scan: "扫描变量",
602
+ scanHint: "可以从这里插入变量并设置默认值。",
603
+ help: "你可以在代码中直接输入 {{变量名}},然后点击左侧代码区的保存按钮扫描变量并统一设置默认值;也可以在设置页直接插入变量,再填写默认值。",
604
+ detected: "已识别变量",
605
+ defaultHelp: "请为变量输入默认值,确保变量缺失时内容仍能正确显示。",
606
+ empty: "暂无变量。点击左侧代码区的保存按钮扫描,或从上方变量目录插入。",
607
+ systemDefault: "系统变量无需默认值"
580
608
  }
581
- }, G = {
582
- common: x,
583
- samples: B,
584
- inspector: M,
585
- tabs: A,
586
- image: I,
587
- video: N,
609
+ }, Y = {
610
+ common: V,
611
+ samples: U,
612
+ inspector: B,
613
+ tabs: N,
614
+ image: M,
615
+ video: I,
588
616
  columns: P,
589
- emailLayout: z,
590
- text: E,
617
+ emailLayout: E,
618
+ text: _,
591
619
  button: H,
592
- heading: D,
593
- avatar: O,
594
- divider: $,
595
- container: W,
596
- spacer: F,
597
- html: q,
598
- socials: J,
599
- style: j,
600
- htmlEditor: Z
601
- }, X = {
602
- zh: G,
603
- en: V
620
+ heading: z,
621
+ avatar: D,
622
+ divider: K,
623
+ container: O,
624
+ spacer: $,
625
+ html: W,
626
+ socials: F,
627
+ style: q,
628
+ htmlEditor: J
629
+ }, Z = {
630
+ zh: Y,
631
+ en: A
604
632
  };
605
- function Q(t, e, n) {
606
- const i = n ?? Y(), r = t.split(".");
607
- let o = X[i];
608
- for (const a of r)
609
- if (o && typeof o == "object" && a in o)
610
- o = o[a];
633
+ function Q(a, e, o) {
634
+ const l = o ?? j(), s = a.split(".");
635
+ let n = Z[l];
636
+ for (const t of s)
637
+ if (n && typeof n == "object" && t in n)
638
+ n = n[t];
611
639
  else
612
- return t;
613
- return typeof o != "string" ? t : e ? o.replace(/\{\{(\w+)\}\}/g, (a, s) => {
614
- var l;
615
- return ((l = e[s]) == null ? void 0 : l.toString()) ?? a;
616
- }) : o;
640
+ return a;
641
+ return typeof n != "string" ? a : e ? n.replace(/\{\{(\w+)\}\}/g, (t, i) => {
642
+ var r;
643
+ return ((r = e[i]) == null ? void 0 : r.toString()) ?? t;
644
+ }) : n;
617
645
  }
618
- function Y() {
646
+ function j() {
619
647
  if (typeof window > "u")
620
648
  return "en";
621
- const t = localStorage.getItem("app-language");
622
- return t && (t === "zh" || t === "en") ? t : navigator.language.toLowerCase().startsWith("zh") ? "zh" : "en";
649
+ const a = localStorage.getItem("app-language");
650
+ return a && (a === "zh" || a === "en") ? a : navigator.language.toLowerCase().startsWith("zh") ? "zh" : "en";
623
651
  }
624
- function K(t) {
625
- typeof window < "u" && localStorage.setItem("app-language", t);
652
+ function ee(a) {
653
+ typeof window < "u" && localStorage.setItem("app-language", a);
626
654
  }
627
- function _(t) {
628
- let e = t, n = 0;
629
- for (; e && typeof e == "object" && "default" in e && n < 5; ) {
630
- const i = e.default;
631
- if (!i || i === e) break;
632
- e = i, n += 1;
655
+ function te(a) {
656
+ let e = a, o = 0;
657
+ for (; e && typeof e == "object" && "default" in e && o < 5; ) {
658
+ const l = e.default;
659
+ if (!l || l === e) break;
660
+ e = l, o += 1;
633
661
  }
634
662
  return typeof e == "function" || typeof e == "string" || e && typeof e == "object" && "$$typeof" in e ? e : "span";
635
663
  }
664
+ const G = /^[A-Za-z_][A-Za-z0-9_]*$/, X = [
665
+ {
666
+ id: "contacts",
667
+ items: [
668
+ { name: "first_name", labelKey: "text.variables.firstName", kind: "user" },
669
+ { name: "last_name", labelKey: "text.variables.lastName", kind: "user" },
670
+ { name: "middle_name", labelKey: "text.variables.middleName", kind: "user" }
671
+ ]
672
+ },
673
+ {
674
+ id: "email",
675
+ items: [
676
+ { name: "email", labelKey: "text.variables.email", kind: "user" },
677
+ { name: "alternative_email", labelKey: "text.variables.alternativeEmail", kind: "user" }
678
+ ]
679
+ },
680
+ {
681
+ id: "organization",
682
+ items: [
683
+ { name: "company", labelKey: "text.variables.company", kind: "user" },
684
+ { name: "address_line_1", labelKey: "text.variables.addressLine1", kind: "user" },
685
+ { name: "address_line_2", labelKey: "text.variables.addressLine2", kind: "user" },
686
+ { name: "country", labelKey: "text.variables.country", kind: "user" },
687
+ { name: "city", labelKey: "text.variables.city", kind: "user" },
688
+ { name: "state", labelKey: "text.variables.state", kind: "user" },
689
+ { name: "postal_code", labelKey: "text.variables.postalCode", kind: "user" },
690
+ { name: "recipient_company", labelKey: "text.variables.recipientCompany", kind: "user" },
691
+ { name: "recipient_address_line_1", labelKey: "text.variables.recipientAddressLine1", kind: "user" },
692
+ { name: "recipient_address_line_2", labelKey: "text.variables.recipientAddressLine2", kind: "user" },
693
+ { name: "recipient_country", labelKey: "text.variables.recipientCountry", kind: "user" },
694
+ { name: "recipient_city", labelKey: "text.variables.recipientCity", kind: "user" },
695
+ { name: "recipient_state", labelKey: "text.variables.recipientState", kind: "user" },
696
+ { name: "recipient_postal_code", labelKey: "text.variables.recipientPostalCode", kind: "user" }
697
+ ]
698
+ },
699
+ {
700
+ id: "date",
701
+ items: [
702
+ { name: "birthday", labelKey: "text.variables.birthday", kind: "user" },
703
+ { name: "send_date", labelKey: "text.variables.currentDate", kind: "builtin" },
704
+ { name: "send_year", labelKey: "text.variables.currentYear", kind: "builtin" },
705
+ { name: "send_month", labelKey: "text.variables.currentMonthName", kind: "builtin" },
706
+ { name: "send_weekday", labelKey: "text.variables.currentWeekday", kind: "builtin" }
707
+ ]
708
+ },
709
+ {
710
+ id: "links",
711
+ items: [{ name: "unsubscribe_link", labelKey: "text.variables.unsubscribeLink", kind: "user" }]
712
+ }
713
+ ];
714
+ function ae(a) {
715
+ const e = a.baseGroups ?? X, o = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
716
+ for (const t of e)
717
+ for (const i of t.items)
718
+ i.kind === "user" ? o.add(i.name) : l.add(i.name);
719
+ const s = Array.isArray(a.contactAttributes) ? a.contactAttributes : [];
720
+ for (const t of s) {
721
+ const i = t == null ? void 0 : t.Enable;
722
+ if (i === 0 || i === !1) continue;
723
+ const r = typeof (t == null ? void 0 : t.AttrField) == "string" ? t.AttrField.trim() : "";
724
+ r && o.add(r);
725
+ }
726
+ const n = Array.isArray(a.customVariables) ? a.customVariables : [];
727
+ for (const t of n) {
728
+ const i = typeof (t == null ? void 0 : t.name) == "string" ? t.name.trim() : "";
729
+ i && G.test(i) && o.add(i);
730
+ }
731
+ return { allowedUser: o, allowedBuiltin: l };
732
+ }
636
733
  export {
637
- Y as g,
638
- _ as r,
639
- K as s,
734
+ X as B,
735
+ G as V,
736
+ ae as b,
737
+ j as g,
738
+ te as r,
739
+ ee as s,
640
740
  Q as t
641
741
  };
@@ -13,19 +13,19 @@ declare const EmailLayoutPropsSchema: z.ZodObject<{
13
13
  width?: number | null | undefined;
14
14
  borderColor?: string | null | undefined;
15
15
  borderRadius?: number | null | undefined;
16
+ textColor?: string | null | undefined;
16
17
  childrenIds?: string[] | null | undefined;
17
18
  backdropColor?: string | null | undefined;
18
19
  canvasColor?: string | null | undefined;
19
- textColor?: string | null | undefined;
20
20
  }, {
21
21
  fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
22
22
  width?: number | null | undefined;
23
23
  borderColor?: string | null | undefined;
24
24
  borderRadius?: number | null | undefined;
25
+ textColor?: string | null | undefined;
25
26
  childrenIds?: string[] | null | undefined;
26
27
  backdropColor?: string | null | undefined;
27
28
  canvasColor?: string | null | undefined;
28
- textColor?: string | null | undefined;
29
29
  }>;
30
30
  export default EmailLayoutPropsSchema;
31
31
  export type EmailLayoutProps = z.infer<typeof EmailLayoutPropsSchema>;
@@ -1066,19 +1066,19 @@ export declare const EditorBlock: ({ type, data }: import("monto-email-document-
1066
1066
  width?: number | null | undefined;
1067
1067
  borderColor?: string | null | undefined;
1068
1068
  borderRadius?: number | null | undefined;
1069
+ textColor?: string | null | undefined;
1069
1070
  childrenIds?: string[] | null | undefined;
1070
1071
  backdropColor?: string | null | undefined;
1071
1072
  canvasColor?: string | null | undefined;
1072
- textColor?: string | null | undefined;
1073
1073
  }, {
1074
1074
  fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
1075
1075
  width?: number | null | undefined;
1076
1076
  borderColor?: string | null | undefined;
1077
1077
  borderRadius?: number | null | undefined;
1078
+ textColor?: string | null | undefined;
1078
1079
  childrenIds?: string[] | null | undefined;
1079
1080
  backdropColor?: string | null | undefined;
1080
1081
  canvasColor?: string | null | undefined;
1081
- textColor?: string | null | undefined;
1082
1082
  }>;
1083
1083
  Spacer: z.ZodObject<{
1084
1084
  props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -2351,19 +2351,19 @@ export declare const EditorBlockSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"ty
2351
2351
  width?: number | null | undefined;
2352
2352
  borderColor?: string | null | undefined;
2353
2353
  borderRadius?: number | null | undefined;
2354
+ textColor?: string | null | undefined;
2354
2355
  childrenIds?: string[] | null | undefined;
2355
2356
  backdropColor?: string | null | undefined;
2356
2357
  canvasColor?: string | null | undefined;
2357
- textColor?: string | null | undefined;
2358
2358
  }, {
2359
2359
  fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
2360
2360
  width?: number | null | undefined;
2361
2361
  borderColor?: string | null | undefined;
2362
2362
  borderRadius?: number | null | undefined;
2363
+ textColor?: string | null | undefined;
2363
2364
  childrenIds?: string[] | null | undefined;
2364
2365
  backdropColor?: string | null | undefined;
2365
2366
  canvasColor?: string | null | undefined;
2366
- textColor?: string | null | undefined;
2367
2367
  }>;
2368
2368
  Spacer: z.ZodObject<{
2369
2369
  props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -3636,19 +3636,19 @@ export declare const EditorConfigurationSchema: z.ZodRecord<z.ZodString, z.ZodEf
3636
3636
  width?: number | null | undefined;
3637
3637
  borderColor?: string | null | undefined;
3638
3638
  borderRadius?: number | null | undefined;
3639
+ textColor?: string | null | undefined;
3639
3640
  childrenIds?: string[] | null | undefined;
3640
3641
  backdropColor?: string | null | undefined;
3641
3642
  canvasColor?: string | null | undefined;
3642
- textColor?: string | null | undefined;
3643
3643
  }, {
3644
3644
  fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
3645
3645
  width?: number | null | undefined;
3646
3646
  borderColor?: string | null | undefined;
3647
3647
  borderRadius?: number | null | undefined;
3648
+ textColor?: string | null | undefined;
3648
3649
  childrenIds?: string[] | null | undefined;
3649
3650
  backdropColor?: string | null | undefined;
3650
3651
  canvasColor?: string | null | undefined;
3651
- textColor?: string | null | undefined;
3652
3652
  }>;
3653
3653
  Spacer: z.ZodObject<{
3654
3654
  props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -5,6 +5,6 @@
5
5
  * 使用方式:import { HtmlEditor } from 'monto-email-builder/html-editor'
6
6
  */
7
7
  export { default as HtmlEditor } from './HtmlEditor';
8
- export type { HtmlEditorProps, HtmlEditorMode, HtmlEditorDevice } from './HtmlEditor';
8
+ export type { HtmlEditorDevice, HtmlEditorMode, HtmlEditorProps, HtmlEditorRef, HtmlEditorRightTab, HtmlEditorVariableInput, HtmlEditorVariableItem, HtmlEditorVariableValidationResult, } from './HtmlEditor';
9
9
  export { default } from './HtmlEditor';
10
10
  //# sourceMappingURL=html-editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-editor.d.ts","sourceRoot":"","sources":["../src/html-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"html-editor.d.ts","sourceRoot":"","sources":["../src/html-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,GACnC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}