mail-editor-pancake 0.2.3 → 0.2.6
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 +60 -1
- package/packages/core/dist/index.js +1845 -1606
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/style.css +1 -1
- package/packages/core/src/editor/Canvas.ts +9 -11
- package/packages/core/src/editor/Editor.ts +23 -3
- package/packages/core/src/editor/InlineEditor.ts +186 -64
- package/packages/core/src/editor/LeftPanel.ts +41 -7
- package/packages/core/src/editor/RichTextToolbar.ts +16 -2
- package/packages/core/src/editor/RightPanel.ts +31 -12
- package/packages/core/src/editor/styles.css +4 -0
- package/packages/core/src/i18n/index.ts +4 -2
- 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 +19 -1
- package/packages/core/src/utils/columnWidths.ts +151 -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
|
@@ -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
|
}
|
|
@@ -396,8 +410,12 @@ export declare interface GalleryItem {
|
|
|
396
410
|
export declare function getSectionDynamicVariantKey(section: Section): string | undefined;
|
|
397
411
|
|
|
398
412
|
export declare interface GlobalStyles {
|
|
413
|
+
/**
|
|
414
|
+
* 邮件背景色:导出时写入 `<mj-body background-color>`,画布内容纸取同一值。
|
|
415
|
+
* 旧字段 `contentBackgroundColor`(内容背景)已废弃并合并到此处,
|
|
416
|
+
* 由 `createDefaultDoc` 在读入旧文档时迁移。
|
|
417
|
+
*/
|
|
399
418
|
backgroundColor: string;
|
|
400
|
-
contentBackgroundColor: string;
|
|
401
419
|
fontFamily: string;
|
|
402
420
|
fontSize: string;
|
|
403
421
|
/** 全局字重:数值档 300 | 400 | 500 | 600 | 700(兼容读写 normal / bold 等别名) */
|
|
@@ -517,10 +535,26 @@ declare interface InlineEditableConfig<P extends object = Record<string, unknown
|
|
|
517
535
|
placeholder?: string;
|
|
518
536
|
}
|
|
519
537
|
|
|
538
|
+
/** 右栏链接字段默认校验:空值放行(允许暂不填),填了但不可跳转则给提示 */
|
|
539
|
+
export declare function invalidHrefMessage(raw: unknown, t: (key: string) => string): string | null;
|
|
540
|
+
|
|
520
541
|
export declare function isDynamicVariantSection(section: Section): boolean;
|
|
521
542
|
|
|
522
543
|
export declare function isMultiColumnLayout(layout: SectionLayout): layout is MultiColumnLayout;
|
|
523
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
|
+
|
|
524
558
|
/**
|
|
525
559
|
* 富文本是否「完全无内容」。
|
|
526
560
|
* 空格、 、换行(<br>)均视为有效内容;仅空串或空标签壳子算空。
|
|
@@ -754,6 +788,25 @@ export declare interface OpenImageGalleryModalOptions {
|
|
|
754
788
|
permissions?: ImageAssetPermissions;
|
|
755
789
|
}
|
|
756
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
|
+
|
|
757
810
|
/** 左栏组合拖入:可附带新建 Section 的 attrs、布局和按列分发的 Block。 */
|
|
758
811
|
export declare interface PaletteDropResult {
|
|
759
812
|
/** 单列组合或落入既有列时插入的 Block。 */
|
|
@@ -865,6 +918,9 @@ export declare interface ResolvedAssetPermission {
|
|
|
865
918
|
tip: string;
|
|
866
919
|
}
|
|
867
920
|
|
|
921
|
+
/** 可跳转则原样返回,否则返回空串,由调用方降级为不可点元素 */
|
|
922
|
+
export declare function resolveHref(raw: unknown): string;
|
|
923
|
+
|
|
868
924
|
/** 锁定块在画布上的渲染结果:preview 为 WYSIWYG HTML,source 为无法解析时的源码回退。 */
|
|
869
925
|
export declare function resolveLockedMjmlCanvasContent(lockedMjml: string, padding: BlockPaddingBox): {
|
|
870
926
|
mode: 'preview';
|
|
@@ -874,6 +930,9 @@ export declare function resolveLockedMjmlCanvasContent(lockedMjml: string, paddi
|
|
|
874
930
|
source: string;
|
|
875
931
|
};
|
|
876
932
|
|
|
933
|
+
/** 解析 palette 拖入结果:未声明 `expandPaletteDrop` 时按单块处理 */
|
|
934
|
+
export declare function resolvePaletteDropResult(def: BlockDefinition, registry: Registry): PaletteDropResult;
|
|
935
|
+
|
|
877
936
|
export declare interface Section {
|
|
878
937
|
id: string;
|
|
879
938
|
type: 'section';
|