mail-editor-pancake 0.2.4 → 0.2.7
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/package.json +1 -1
- package/packages/blocks/dist/index.js +126 -126
- package/packages/blocks/dist/index.js.map +1 -1
- package/packages/blocks/src/button.ts +9 -3
- package/packages/core/dist/index.d.ts +55 -0
- package/packages/core/dist/index.js +2414 -2144
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/style.css +1 -1
- package/packages/core/src/editor/Canvas.ts +8 -10
- package/packages/core/src/editor/Editor.ts +1 -0
- package/packages/core/src/editor/InlineEditor.ts +141 -74
- package/packages/core/src/editor/LeftPanel.ts +41 -7
- package/packages/core/src/editor/RightPanel.ts +31 -3
- package/packages/core/src/editor/styles.css +4 -0
- package/packages/core/src/i18n/index.ts +4 -0
- package/packages/core/src/index.ts +6 -0
- package/packages/core/src/renderer/index.ts +2 -0
- package/packages/core/src/renderer/mjml.ts +16 -7
- package/packages/core/src/types.ts +14 -0
- package/packages/core/src/utils/columnWidths.ts +157 -0
- package/packages/core/src/utils/dynamicVariantHtml.ts +2 -7
- package/packages/core/src/utils/html.ts +31 -0
- package/packages/core/src/utils/link.ts +51 -0
- package/packages/core/src/utils/paletteDrop.ts +46 -0
- package/packages/core/src/utils/richTextStyle.ts +197 -0
|
@@ -65,6 +65,13 @@ export declare interface BlockDefinition<P extends object = Record<string, unkno
|
|
|
65
65
|
* 在用户提交时按 `mode` 写回 props(rich:清理后的 innerHTML;html:原始 innerHTML;plain:textContent)。
|
|
66
66
|
*/
|
|
67
67
|
inlineEditable?: InlineEditableConfig<P>;
|
|
68
|
+
/**
|
|
69
|
+
* 左栏拖入层级:
|
|
70
|
+
* - `section`:自带布局(如双列卡组),与布局卡片同组,只能落在 Section 之间,不能落进 Column;
|
|
71
|
+
* - `block`:落在 Column 内(默认)。
|
|
72
|
+
* 缺省时按 `expandPaletteDrop` 结果自动判定(多列布局 / 多列分发即视为 `section`)。
|
|
73
|
+
*/
|
|
74
|
+
paletteDropLevel?: 'block' | 'section';
|
|
68
75
|
/**
|
|
69
76
|
* 从左栏拖入时在目标列(或自动包裹的单列 Section)中一次性插入多个块,
|
|
70
77
|
* 用于「组合模板」:画布内仅为通用 image/text 等,便于逐项修改。
|
|
@@ -100,6 +107,13 @@ export declare interface BlockSchemaField {
|
|
|
100
107
|
step?: number;
|
|
101
108
|
placeholder?: string;
|
|
102
109
|
help?: string;
|
|
110
|
+
/**
|
|
111
|
+
* 输入即时校验:返回文案则在字段下方红字提示,返回 null 表示通过。
|
|
112
|
+
* 只提示、不阻塞保存(运营可能故意留占位链接或使用短链)。
|
|
113
|
+
* `type: 'url'` 未设置时使用内核默认规则(见 `isRenderableHref`),
|
|
114
|
+
* 拦截 `#`、`1234`、缺协议的域名等会被 Outlook 网页端清除的链接。
|
|
115
|
+
*/
|
|
116
|
+
validate?: (value: string) => string | null;
|
|
103
117
|
/** 为 true 时右栏显示「继承全局」开关:开=留空跟随邮件全局,关=写入当前全局值为块级固定值 */
|
|
104
118
|
inheritGlobal?: boolean;
|
|
105
119
|
}
|
|
@@ -521,10 +535,26 @@ declare interface InlineEditableConfig<P extends object = Record<string, unknown
|
|
|
521
535
|
placeholder?: string;
|
|
522
536
|
}
|
|
523
537
|
|
|
538
|
+
/** 右栏链接字段默认校验:空值放行(允许暂不填),填了但不可跳转则给提示 */
|
|
539
|
+
export declare function invalidHrefMessage(raw: unknown, t: (key: string) => string): string | null;
|
|
540
|
+
|
|
524
541
|
export declare function isDynamicVariantSection(section: Section): boolean;
|
|
525
542
|
|
|
526
543
|
export declare function isMultiColumnLayout(layout: SectionLayout): layout is MultiColumnLayout;
|
|
527
544
|
|
|
545
|
+
/**
|
|
546
|
+
* 邮件链接可用性判定。
|
|
547
|
+
*
|
|
548
|
+
* Outlook 网页端(outlook.com / OWA)会清洗「不可跳转」的 href:空值、`#`、
|
|
549
|
+
* 纯数字 / 相对路径(如 `1234`)、以及非标准协议(javascript:、data: 等)。
|
|
550
|
+
* 被清洗后 `<a>` 会连同内容一起消失,表现为按钮 / 图标「元素在但看不见」。
|
|
551
|
+
*
|
|
552
|
+
* 两个用途:
|
|
553
|
+
* 1. 右栏 `type: 'url'` 字段的默认校验,输入即时提示;
|
|
554
|
+
* 2. 渲染层兜底:不可跳转时不输出 href(如 MJML 会退化为 `<p>`,样式保留、仅不可点)。
|
|
555
|
+
*/
|
|
556
|
+
export declare function isRenderableHref(raw: unknown): boolean;
|
|
557
|
+
|
|
528
558
|
/**
|
|
529
559
|
* 富文本是否「完全无内容」。
|
|
530
560
|
* 空格、 、换行(<br>)均视为有效内容;仅空串或空标签壳子算空。
|
|
@@ -758,6 +788,25 @@ export declare interface OpenImageGalleryModalOptions {
|
|
|
758
788
|
permissions?: ImageAssetPermissions;
|
|
759
789
|
}
|
|
760
790
|
|
|
791
|
+
/**
|
|
792
|
+
* palette 拖入语义的判定。
|
|
793
|
+
*
|
|
794
|
+
* 画布是四层模型(Section → Column → Block),左栏也分两组:
|
|
795
|
+
* - `sections`:布局卡片,落在 Section 之间;
|
|
796
|
+
* - `blocks`:组件卡片,落在 Column 内。
|
|
797
|
+
*
|
|
798
|
+
* 自带布局的组件(如一次生成双列 Section 的卡组)实际会新建 Section,
|
|
799
|
+
* 若仍归到 `blocks`,拖拽时会显示「可放进列内」的占位,松手却落到该 Section 之后,
|
|
800
|
+
* 与预期不符。这里统一判定,让它与布局卡片同组,拖拽表现与布局一致。
|
|
801
|
+
*/
|
|
802
|
+
/** 拖入结果是否自带 Section 布局(多列布局 / 多列分发) */
|
|
803
|
+
export declare function paletteDropHasSectionLayout(drop: PaletteDropResult): boolean;
|
|
804
|
+
|
|
805
|
+
/** 该 palette 卡片是否按「布局」处理:只能落在 Section 之间,不能落进 Column */
|
|
806
|
+
export declare function paletteDropIsSectionLevel(def: BlockDefinition, registry: Registry, opts?: {
|
|
807
|
+
enableDynamicVariantKey?: boolean;
|
|
808
|
+
}): boolean;
|
|
809
|
+
|
|
761
810
|
/** 左栏组合拖入:可附带新建 Section 的 attrs、布局和按列分发的 Block。 */
|
|
762
811
|
export declare interface PaletteDropResult {
|
|
763
812
|
/** 单列组合或落入既有列时插入的 Block。 */
|
|
@@ -869,6 +918,9 @@ export declare interface ResolvedAssetPermission {
|
|
|
869
918
|
tip: string;
|
|
870
919
|
}
|
|
871
920
|
|
|
921
|
+
/** 可跳转则原样返回,否则返回空串,由调用方降级为不可点元素 */
|
|
922
|
+
export declare function resolveHref(raw: unknown): string;
|
|
923
|
+
|
|
872
924
|
/** 锁定块在画布上的渲染结果:preview 为 WYSIWYG HTML,source 为无法解析时的源码回退。 */
|
|
873
925
|
export declare function resolveLockedMjmlCanvasContent(lockedMjml: string, padding: BlockPaddingBox): {
|
|
874
926
|
mode: 'preview';
|
|
@@ -878,6 +930,9 @@ export declare function resolveLockedMjmlCanvasContent(lockedMjml: string, paddi
|
|
|
878
930
|
source: string;
|
|
879
931
|
};
|
|
880
932
|
|
|
933
|
+
/** 解析 palette 拖入结果:未声明 `expandPaletteDrop` 时按单块处理 */
|
|
934
|
+
export declare function resolvePaletteDropResult(def: BlockDefinition, registry: Registry): PaletteDropResult;
|
|
935
|
+
|
|
881
936
|
export declare interface Section {
|
|
882
937
|
id: string;
|
|
883
938
|
type: 'section';
|