mail-editor-pancake 0.0.8 → 0.0.9

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.
@@ -76,6 +76,28 @@ export declare interface BlockSchemaField {
76
76
  inheritGlobal?: boolean;
77
77
  }
78
78
 
79
+ export declare interface BodyVariableInsert {
80
+ content: string;
81
+ asHtml: boolean;
82
+ }
83
+
84
+ /** 插入链接 / 图片等元素片段 */
85
+ export declare function buildBodyVariableElementInsert(v: Variable, options?: {
86
+ linkColor?: string;
87
+ token?: string;
88
+ }): BodyVariableInsert;
89
+
90
+ /** @deprecated 使用 buildBodyVariableKeyInsert / buildBodyVariableElementInsert */
91
+ export declare function buildBodyVariableInsert(v: Variable, options?: {
92
+ linkColor?: string;
93
+ token?: string;
94
+ }): BodyVariableInsert;
95
+
96
+ /** 插入变量 key(`{{key}}`) */
97
+ export declare function buildBodyVariableKeyInsert(v: Variable): BodyVariableInsert;
98
+
99
+ export declare function buildLinkVariableHtml(token: string, linkColor: string): string;
100
+
79
101
  export declare interface Column {
80
102
  id: string;
81
103
  attrs: ColumnAttrs;
@@ -89,6 +111,9 @@ declare interface ColumnAttrs {
89
111
 
90
112
  export declare function createSection(layout: SectionLayout): Section;
91
113
 
114
+ /** 无后端 sample 时按 kind / label 生成预览用示例值(仅预览弹窗等场景) */
115
+ export declare function defaultVariableSample(v: Pick<Variable, 'key' | 'label' | 'kind' | 'sample'>): string;
116
+
92
117
  /** 工厂函数,便于外部以函数式风格定义组件。 */
93
118
  export declare function defineBlock<P extends object>(def: BlockDefinition<P>): BlockDefinition<P>;
94
119
 
@@ -383,6 +408,8 @@ export declare class MailEditor {
383
408
  private showLayoutBorders;
384
409
  /** 「重置内容」时恢复的文档快照(与当前画布内容无关) */
385
410
  private presetContentDoc;
411
+ /** 宿主通过 setVariables 注入的列表;setValue 恢复文档后仍会写回,避免被 doc JSON 里的空数组覆盖 */
412
+ private configuredVariables;
386
413
  private systemThemeMq;
387
414
  private readonly _onSystemThemeMqChange;
388
415
  private readonly _onFullscreenChange;
@@ -407,6 +434,19 @@ export declare class MailEditor {
407
434
  setPresetDoc(partial: Partial<EmailDoc>): void;
408
435
  setVariables(vars: Variable[]): void;
409
436
  getVariables(): Variable[];
437
+ private _applyConfiguredVariables;
438
+ /**
439
+ * 插入变量 key(`{{key}}`)。
440
+ * @returns 是否成功插入
441
+ */
442
+ insertVariableKey(v: Variable): boolean;
443
+ /**
444
+ * 插入链接 / 图片变量对应元素(`<a>` / image 块等)。
445
+ * 非 link/image 时退化为 insertVariableKey。
446
+ */
447
+ insertVariableElement(v: Variable): boolean;
448
+ /** 同 {@link insertVariableKey} */
449
+ insertVariable(v: Variable): boolean;
410
450
  /** 当前界面主题(`system` 不解析为 light/dark)。 */
411
451
  getTheme(): EditorTheme;
412
452
  /** 切换界面主题;写入 `data-sm-theme`,顶栏选择器同步。 */
@@ -436,13 +476,14 @@ export declare class MailEditor {
436
476
  private _blurRightPanelIfFocused;
437
477
  /** 提交内联编辑并清空选中,右栏回到文档级面板 */
438
478
  private _focusMailSettings;
439
- private _confirmClearCanvas;
440
- private _confirmResetContent;
441
479
  private _setMode;
442
480
  private _bindKeyboard;
443
481
  private _onChange;
444
482
  private _showVariablePopover;
445
- private _insertVariable;
483
+ private _showToast;
484
+ private _insertImageVariable;
485
+ /** 在焦点处插入文本或 HTML;失败时返回 false */
486
+ private _insertAtFocus;
446
487
  private _showExport;
447
488
  private _showPreview;
448
489
  private _bindFullscreen;
@@ -478,6 +519,9 @@ export declare function mjRawEmailTableWrap(paddingCss: string, cellInnerHtml: s
478
519
  /** 将任意历史写法映射到最近一档(normal→400,bold→700 等) */
479
520
  export declare function normalizeFontWeightStep(raw: string | undefined | null): FontWeightStep;
480
521
 
522
+ /** 规范化 Variable(补 kind、sample) */
523
+ export declare function normalizeVariable(v: Variable): Variable;
524
+
481
525
  /**
482
526
  * 打开内置图库弹层:搜索、分页、选图插入;可选「链接添加」「上传到图库」「删除」由 adapter 决定。
483
527
  */
@@ -643,6 +687,9 @@ export declare class Store {
643
687
  private _notify;
644
688
  }
645
689
 
690
+ /** 从 Mustache token 提取 key,如 `{{username}}` → `username` */
691
+ export declare function tokenToVariableKey(token: string): string;
692
+
646
693
  /** 两列 Section 的列宽比例(左栏拖入默认 `1-1`,右栏可改为 `1-2` / `2-1`) */
647
694
  export declare const TWO_COLUMN_LAYOUTS: readonly ["1-1", "1-2", "2-1"];
648
695
 
@@ -654,6 +701,12 @@ export declare interface Variable {
654
701
  label: string;
655
702
  /** 预览数据,仅设计态预览使用 */
656
703
  sample?: string;
704
+ /** 插入语义:纯文本占位 / 链接片段 / 图片块 */
705
+ kind?: 'text' | 'link' | 'image';
657
706
  }
658
707
 
708
+ export declare type VariableKind = 'text' | 'link' | 'image';
709
+
710
+ export declare function variablePlaceholder(key: string): string;
711
+
659
712
  export { }