@maily-to/core 2.0.0-beta.18 → 2.0.0-beta.20
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/dist/blocks/index.cjs +1 -1
- package/dist/extensions/index.cjs +16 -46
- package/dist/extensions/index.d.mts +6 -1
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +2 -2
- package/dist/index.cjs +2943 -8136
- package/dist/index.mjs +1 -1
- package/dist/{use-maily-editor-B8nvKyXX.cjs → use-maily-editor-DbMPOkxh.cjs} +150 -16
- package/dist/{use-maily-editor-mwGHSFi6.mjs → use-maily-editor-DrOZ-GOZ.mjs} +245 -91
- package/dist/{use-maily-editor-uwcKnkj2.cjs → use-maily-editor-nTLB-Tv3.cjs} +250 -90
- package/package.json +5 -5
- package/src/styles/index.css +63 -1
|
@@ -2143,6 +2143,52 @@ const ContainerExtension = Node$1.create({
|
|
|
2143
2143
|
}
|
|
2144
2144
|
});
|
|
2145
2145
|
//#endregion
|
|
2146
|
+
//#region src/extensions/div/div.ts
|
|
2147
|
+
const DivExtension = Node$1.create({
|
|
2148
|
+
name: MAILY_NODE_TYPES.DIV,
|
|
2149
|
+
group: "block",
|
|
2150
|
+
content: "block+",
|
|
2151
|
+
defining: true,
|
|
2152
|
+
isolating: true,
|
|
2153
|
+
addKeyboardShortcuts() {
|
|
2154
|
+
return {
|
|
2155
|
+
Enter: ({ editor }) => exitOnTripleEnter({
|
|
2156
|
+
editor,
|
|
2157
|
+
nodeName: this.name
|
|
2158
|
+
}),
|
|
2159
|
+
Backspace: ({ editor }) => {
|
|
2160
|
+
const { $from, empty } = editor.state.selection;
|
|
2161
|
+
if (!empty || $from.parentOffset !== 0) return false;
|
|
2162
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
2163
|
+
const node = $from.node(depth);
|
|
2164
|
+
if (node.type.name !== this.name) continue;
|
|
2165
|
+
const only = node.childCount === 1 ? node.firstChild : null;
|
|
2166
|
+
if (!(only?.isTextblock && only.content.size === 0)) return false;
|
|
2167
|
+
return editor.commands.deleteRange({
|
|
2168
|
+
from: $from.before(depth),
|
|
2169
|
+
to: $from.after(depth)
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
return false;
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
},
|
|
2176
|
+
parseHTML() {
|
|
2177
|
+
return [{ tag: `div[${DATA_NODE_TYPE_KEY}="${MAILY_NODE_TYPES.DIV}"]` }, {
|
|
2178
|
+
tag: `div:not([${DATA_NODE_TYPE_KEY}])`,
|
|
2179
|
+
priority: 40,
|
|
2180
|
+
getAttrs: (element) => element.getAttribute("style") ? null : false
|
|
2181
|
+
}];
|
|
2182
|
+
},
|
|
2183
|
+
renderHTML({ HTMLAttributes }) {
|
|
2184
|
+
return [
|
|
2185
|
+
"div",
|
|
2186
|
+
mergeAttributes({ [DATA_NODE_TYPE_KEY]: MAILY_NODE_TYPES.DIV }, HTMLAttributes),
|
|
2187
|
+
0
|
|
2188
|
+
];
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
//#endregion
|
|
2146
2192
|
//#region src/extensions/footer/footer.ts
|
|
2147
2193
|
const FooterExtension = Node$1.create({
|
|
2148
2194
|
name: MAILY_NODE_TYPES.FOOTER,
|
|
@@ -2174,6 +2220,8 @@ const HorizontalRuleExtension = HorizontalRule.configure({ HTMLAttributes: { [DA
|
|
|
2174
2220
|
//#endregion
|
|
2175
2221
|
//#region src/extensions/html-code-block/html-code-block-view.tsx
|
|
2176
2222
|
const PREVIEW_RESET = `
|
|
2223
|
+
html { overflow: hidden; }
|
|
2224
|
+
body { margin: 0; }
|
|
2177
2225
|
* { font-family: 'Inter', sans-serif; }
|
|
2178
2226
|
blockquote, h1, h2, h3, img, li, ol, p, ul {
|
|
2179
2227
|
margin-top: 0;
|
|
@@ -2199,24 +2247,22 @@ function HtmlCodeBlockView(props) {
|
|
|
2199
2247
|
}
|
|
2200
2248
|
const html = `<style>${t0.join("\n")}</style>${parsed.body.innerHTML}`;
|
|
2201
2249
|
const isEmpty = html === "<style></style>";
|
|
2250
|
+
const [height, setHeight] = useState(0);
|
|
2202
2251
|
let t1;
|
|
2203
|
-
if ($[3]
|
|
2204
|
-
t1 = (
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
container.innerHTML = html;
|
|
2212
|
-
shadow.append(container);
|
|
2252
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2253
|
+
t1 = (event) => {
|
|
2254
|
+
const frameWindow = event.currentTarget.contentWindow;
|
|
2255
|
+
const root = frameWindow?.document.documentElement;
|
|
2256
|
+
if (!frameWindow || !root) return;
|
|
2257
|
+
new frameWindow.ResizeObserver(() => {
|
|
2258
|
+
setHeight(root.offsetHeight);
|
|
2259
|
+
}).observe(root);
|
|
2213
2260
|
};
|
|
2214
|
-
$[3] =
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
const setPreviewElement = t1;
|
|
2261
|
+
$[3] = t1;
|
|
2262
|
+
} else t1 = $[3];
|
|
2263
|
+
const onPreviewLoad = t1;
|
|
2218
2264
|
let t2;
|
|
2219
|
-
if ($[
|
|
2265
|
+
if ($[4] !== activeTab || $[5] !== language) {
|
|
2220
2266
|
t2 = activeTab === HTML_CODE_BLOCK_TABS.CODE && /* @__PURE__ */ jsx("pre", {
|
|
2221
2267
|
"data-mly-html-code-block": "",
|
|
2222
2268
|
children: /* @__PURE__ */ jsx(NodeViewContent, {
|
|
@@ -2224,12 +2270,12 @@ function HtmlCodeBlockView(props) {
|
|
|
2224
2270
|
className: language ? `language-${language}` : void 0
|
|
2225
2271
|
})
|
|
2226
2272
|
});
|
|
2227
|
-
$[
|
|
2228
|
-
$[
|
|
2229
|
-
$[
|
|
2230
|
-
} else t2 = $[
|
|
2273
|
+
$[4] = activeTab;
|
|
2274
|
+
$[5] = language;
|
|
2275
|
+
$[6] = t2;
|
|
2276
|
+
} else t2 = $[6];
|
|
2231
2277
|
let t3;
|
|
2232
|
-
if ($[
|
|
2278
|
+
if ($[7] !== activeTab || $[8] !== height || $[9] !== html || $[10] !== isEmpty || $[11] !== updateAttributes) {
|
|
2233
2279
|
t3 = activeTab === HTML_CODE_BLOCK_TABS.PREVIEW && /* @__PURE__ */ jsx("div", {
|
|
2234
2280
|
contentEditable: false,
|
|
2235
2281
|
"data-empty": isEmpty ? "" : void 0,
|
|
@@ -2237,11 +2283,24 @@ function HtmlCodeBlockView(props) {
|
|
|
2237
2283
|
onClick: () => {
|
|
2238
2284
|
if (isEmpty) updateAttributes({ activeTab: HTML_CODE_BLOCK_TABS.CODE });
|
|
2239
2285
|
},
|
|
2240
|
-
|
|
2286
|
+
children: !isEmpty && /* @__PURE__ */ jsx("iframe", {
|
|
2287
|
+
onLoad: onPreviewLoad,
|
|
2288
|
+
sandbox: "allow-same-origin",
|
|
2289
|
+
srcDoc: `<!DOCTYPE html><style>${PREVIEW_RESET}</style>${html}`,
|
|
2290
|
+
style: {
|
|
2291
|
+
border: 0,
|
|
2292
|
+
display: "block",
|
|
2293
|
+
height,
|
|
2294
|
+
pointerEvents: "none",
|
|
2295
|
+
width: "100%"
|
|
2296
|
+
},
|
|
2297
|
+
title: "HTML preview"
|
|
2298
|
+
})
|
|
2241
2299
|
});
|
|
2242
|
-
$[
|
|
2243
|
-
$[
|
|
2244
|
-
$[
|
|
2300
|
+
$[7] = activeTab;
|
|
2301
|
+
$[8] = height;
|
|
2302
|
+
$[9] = html;
|
|
2303
|
+
$[10] = isEmpty;
|
|
2245
2304
|
$[11] = updateAttributes;
|
|
2246
2305
|
$[12] = t3;
|
|
2247
2306
|
} else t3 = $[12];
|
|
@@ -2381,20 +2440,28 @@ function uploadImageFile(editor, file, position) {
|
|
|
2381
2440
|
URL.revokeObjectURL(blobUrl);
|
|
2382
2441
|
return;
|
|
2383
2442
|
}
|
|
2443
|
+
const { uploads, progress } = editor.storage.imageUpload;
|
|
2384
2444
|
const context = {
|
|
2385
2445
|
position,
|
|
2386
|
-
removeImage: () => removeImageByBlobUrl(editor, blobUrl)
|
|
2446
|
+
removeImage: () => removeImageByBlobUrl(editor, blobUrl),
|
|
2447
|
+
setProgress: (fraction) => {
|
|
2448
|
+
const percent = Math.round(Math.min(Math.max(fraction, 0), 1) * 100);
|
|
2449
|
+
if (!uploads.has(blobUrl) || progress.get(blobUrl) === percent) return;
|
|
2450
|
+
progress.set(blobUrl, percent);
|
|
2451
|
+
notifyUploadStatusChanged(editor);
|
|
2452
|
+
}
|
|
2387
2453
|
};
|
|
2388
|
-
const { uploads } = editor.storage.imageUpload;
|
|
2389
2454
|
uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.LOADING);
|
|
2390
2455
|
notifyUploadStatusChanged(editor);
|
|
2391
2456
|
onImageUpload(file, context).then((url) => {
|
|
2392
2457
|
uploads.delete(blobUrl);
|
|
2458
|
+
progress.delete(blobUrl);
|
|
2393
2459
|
notifyUploadStatusChanged(editor);
|
|
2394
2460
|
updateImageByBlobUrl(editor, blobUrl, { src: url });
|
|
2395
2461
|
URL.revokeObjectURL(blobUrl);
|
|
2396
2462
|
}).catch((error) => {
|
|
2397
2463
|
uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.ERROR);
|
|
2464
|
+
progress.delete(blobUrl);
|
|
2398
2465
|
notifyUploadStatusChanged(editor);
|
|
2399
2466
|
onImageUploadError?.(error, file, context);
|
|
2400
2467
|
URL.revokeObjectURL(blobUrl);
|
|
@@ -2425,7 +2492,10 @@ const ImageUploadExtension = Extension.create({
|
|
|
2425
2492
|
};
|
|
2426
2493
|
},
|
|
2427
2494
|
addStorage() {
|
|
2428
|
-
return {
|
|
2495
|
+
return {
|
|
2496
|
+
uploads: /* @__PURE__ */ new Map(),
|
|
2497
|
+
progress: /* @__PURE__ */ new Map()
|
|
2498
|
+
};
|
|
2429
2499
|
},
|
|
2430
2500
|
addExtensions() {
|
|
2431
2501
|
return [FileHandler.configure({
|
|
@@ -2698,8 +2768,9 @@ function ImageVariableState() {
|
|
|
2698
2768
|
return t0;
|
|
2699
2769
|
}
|
|
2700
2770
|
function ImageLoadingState(props) {
|
|
2701
|
-
const $ = c(
|
|
2702
|
-
const { alt, src } = props;
|
|
2771
|
+
const $ = c(13);
|
|
2772
|
+
const { alt, src, progress } = props;
|
|
2773
|
+
const isUploading = progress !== void 0 && progress < 100;
|
|
2703
2774
|
const t0 = alt ?? void 0;
|
|
2704
2775
|
let t1;
|
|
2705
2776
|
if ($[0] !== src || $[1] !== t0) {
|
|
@@ -2713,34 +2784,57 @@ function ImageLoadingState(props) {
|
|
|
2713
2784
|
$[2] = t1;
|
|
2714
2785
|
} else t1 = $[2];
|
|
2715
2786
|
let t2;
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2787
|
+
if ($[3] !== isUploading || $[4] !== progress) {
|
|
2788
|
+
t2 = progress !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
2789
|
+
"aria-label": "Uploading image",
|
|
2790
|
+
"aria-valuemax": 100,
|
|
2791
|
+
"aria-valuemin": 0,
|
|
2792
|
+
"aria-valuenow": progress,
|
|
2793
|
+
"data-mly-image-progress": "",
|
|
2794
|
+
"data-state": isUploading ? "uploading" : "done",
|
|
2795
|
+
role: "progressbar",
|
|
2796
|
+
style: { "--mly-image-progress": progress / 100 }
|
|
2797
|
+
});
|
|
2798
|
+
$[3] = isUploading;
|
|
2799
|
+
$[4] = progress;
|
|
2800
|
+
$[5] = t2;
|
|
2801
|
+
} else t2 = $[5];
|
|
2802
|
+
const t3 = progress === void 0 ? "center" : "corner";
|
|
2803
|
+
let t4;
|
|
2804
|
+
if ($[6] !== t3) {
|
|
2805
|
+
t4 = /* @__PURE__ */ jsx("span", {
|
|
2806
|
+
"data-mly-image-spinner": "",
|
|
2807
|
+
"data-variant": t3
|
|
2808
|
+
});
|
|
2809
|
+
$[6] = t3;
|
|
2810
|
+
$[7] = t4;
|
|
2811
|
+
} else t4 = $[7];
|
|
2812
|
+
let t5;
|
|
2813
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2814
|
+
t5 = /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
2720
2815
|
role: "status",
|
|
2721
2816
|
children: "Uploading image"
|
|
2722
2817
|
});
|
|
2723
|
-
$[
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
}
|
|
2729
|
-
let t4;
|
|
2730
|
-
if ($[5] !== t1) {
|
|
2731
|
-
t4 = /* @__PURE__ */ jsxs("div", {
|
|
2818
|
+
$[8] = t5;
|
|
2819
|
+
} else t5 = $[8];
|
|
2820
|
+
let t6;
|
|
2821
|
+
if ($[9] !== t1 || $[10] !== t2 || $[11] !== t4) {
|
|
2822
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
2732
2823
|
"aria-busy": "true",
|
|
2733
2824
|
"data-mly-image-loading": "",
|
|
2734
2825
|
children: [
|
|
2735
2826
|
t1,
|
|
2736
2827
|
t2,
|
|
2737
|
-
|
|
2828
|
+
t4,
|
|
2829
|
+
t5
|
|
2738
2830
|
]
|
|
2739
2831
|
});
|
|
2740
|
-
$[
|
|
2741
|
-
$[
|
|
2742
|
-
|
|
2743
|
-
|
|
2832
|
+
$[9] = t1;
|
|
2833
|
+
$[10] = t2;
|
|
2834
|
+
$[11] = t4;
|
|
2835
|
+
$[12] = t6;
|
|
2836
|
+
} else t6 = $[12];
|
|
2837
|
+
return t6;
|
|
2744
2838
|
}
|
|
2745
2839
|
function ImagePlaceholder(props) {
|
|
2746
2840
|
const $ = c(3);
|
|
@@ -2793,8 +2887,28 @@ function useUploadStatus(editor, src) {
|
|
|
2793
2887
|
if (!src) return IMAGE_UPLOAD_STATUSES.IDLE;
|
|
2794
2888
|
return status ?? IMAGE_UPLOAD_STATUSES.LOADED;
|
|
2795
2889
|
}
|
|
2890
|
+
function useUploadProgress(editor, src) {
|
|
2891
|
+
const $ = c(5);
|
|
2892
|
+
let t0;
|
|
2893
|
+
if ($[0] !== src) {
|
|
2894
|
+
t0 = (ctx) => src ? ctx.editor.storage.imageUpload?.progress?.get(src) : void 0;
|
|
2895
|
+
$[0] = src;
|
|
2896
|
+
$[1] = t0;
|
|
2897
|
+
} else t0 = $[1];
|
|
2898
|
+
let t1;
|
|
2899
|
+
if ($[2] !== editor || $[3] !== t0) {
|
|
2900
|
+
t1 = {
|
|
2901
|
+
editor,
|
|
2902
|
+
selector: t0
|
|
2903
|
+
};
|
|
2904
|
+
$[2] = editor;
|
|
2905
|
+
$[3] = t0;
|
|
2906
|
+
$[4] = t1;
|
|
2907
|
+
} else t1 = $[4];
|
|
2908
|
+
return useEditorState(t1);
|
|
2909
|
+
}
|
|
2796
2910
|
function ImageView(props) {
|
|
2797
|
-
const $ = c(
|
|
2911
|
+
const $ = c(66);
|
|
2798
2912
|
const { editor, getPos, node, updateAttributes } = props;
|
|
2799
2913
|
const { align, alt, src, width, style } = node.attrs;
|
|
2800
2914
|
const t0 = style ?? "";
|
|
@@ -2819,6 +2933,7 @@ function ImageView(props) {
|
|
|
2819
2933
|
} else t2 = $[5];
|
|
2820
2934
|
const isSrcVariable = t2;
|
|
2821
2935
|
const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
|
|
2936
|
+
const progress = useUploadProgress(editor, status === IMAGE_UPLOAD_STATUSES.LOADING ? src : void 0);
|
|
2822
2937
|
let t3;
|
|
2823
2938
|
if ($[6] !== updateAttributes) {
|
|
2824
2939
|
t3 = (committed) => updateAttributes({ width: `${committed}%` });
|
|
@@ -2906,25 +3021,27 @@ function ImageView(props) {
|
|
|
2906
3021
|
$[31] = t14;
|
|
2907
3022
|
} else t14 = $[31];
|
|
2908
3023
|
let t15;
|
|
2909
|
-
if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !==
|
|
3024
|
+
if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !== progress || $[35] !== src || $[36] !== status) {
|
|
2910
3025
|
t15 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.LOADING ? /* @__PURE__ */ jsx(ImageLoadingState, {
|
|
2911
3026
|
alt,
|
|
2912
|
-
src
|
|
3027
|
+
src,
|
|
3028
|
+
progress
|
|
2913
3029
|
}) : null;
|
|
2914
3030
|
$[32] = alt;
|
|
2915
3031
|
$[33] = isSrcVariable;
|
|
2916
|
-
$[34] =
|
|
2917
|
-
$[35] =
|
|
2918
|
-
$[36] =
|
|
2919
|
-
|
|
3032
|
+
$[34] = progress;
|
|
3033
|
+
$[35] = src;
|
|
3034
|
+
$[36] = status;
|
|
3035
|
+
$[37] = t15;
|
|
3036
|
+
} else t15 = $[37];
|
|
2920
3037
|
let t16;
|
|
2921
|
-
if ($[
|
|
3038
|
+
if ($[38] !== status) {
|
|
2922
3039
|
t16 = status === IMAGE_UPLOAD_STATUSES.ERROR ? /* @__PURE__ */ jsx(ImageErrorState, {}) : null;
|
|
2923
|
-
$[
|
|
2924
|
-
$[
|
|
2925
|
-
} else t16 = $[
|
|
3040
|
+
$[38] = status;
|
|
3041
|
+
$[39] = t16;
|
|
3042
|
+
} else t16 = $[39];
|
|
2926
3043
|
let t17;
|
|
2927
|
-
if ($[
|
|
3044
|
+
if ($[40] !== alt || $[41] !== authoredStyle || $[42] !== editor.isEditable || $[43] !== handlePointerDown || $[44] !== isLoaded || $[45] !== isResizing || $[46] !== isSrcVariable || $[47] !== shouldShowDragHandles || $[48] !== src) {
|
|
2928
3045
|
t17 = !isSrcVariable && isLoaded ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("img", {
|
|
2929
3046
|
alt: alt ?? void 0,
|
|
2930
3047
|
contentEditable: false,
|
|
@@ -2939,19 +3056,19 @@ function ImageView(props) {
|
|
|
2939
3056
|
handle: "right",
|
|
2940
3057
|
onPointerDown: (event_1) => handlePointerDown("right", event_1)
|
|
2941
3058
|
})] }) : null] }) : null;
|
|
2942
|
-
$[
|
|
2943
|
-
$[
|
|
2944
|
-
$[
|
|
2945
|
-
$[
|
|
2946
|
-
$[
|
|
2947
|
-
$[
|
|
2948
|
-
$[
|
|
2949
|
-
$[
|
|
2950
|
-
$[
|
|
2951
|
-
$[
|
|
2952
|
-
} else t17 = $[
|
|
3059
|
+
$[40] = alt;
|
|
3060
|
+
$[41] = authoredStyle;
|
|
3061
|
+
$[42] = editor.isEditable;
|
|
3062
|
+
$[43] = handlePointerDown;
|
|
3063
|
+
$[44] = isLoaded;
|
|
3064
|
+
$[45] = isResizing;
|
|
3065
|
+
$[46] = isSrcVariable;
|
|
3066
|
+
$[47] = shouldShowDragHandles;
|
|
3067
|
+
$[48] = src;
|
|
3068
|
+
$[49] = t17;
|
|
3069
|
+
} else t17 = $[49];
|
|
2953
3070
|
let t18;
|
|
2954
|
-
if ($[
|
|
3071
|
+
if ($[50] !== align || $[51] !== imageWrapperRef || $[52] !== t12 || $[53] !== t13 || $[54] !== t14 || $[55] !== t15 || $[56] !== t16 || $[57] !== t17) {
|
|
2955
3072
|
t18 = /* @__PURE__ */ jsxs("div", {
|
|
2956
3073
|
"data-align": align,
|
|
2957
3074
|
"data-mly-image-wrapper": "",
|
|
@@ -2965,18 +3082,18 @@ function ImageView(props) {
|
|
|
2965
3082
|
t17
|
|
2966
3083
|
]
|
|
2967
3084
|
});
|
|
2968
|
-
$[
|
|
2969
|
-
$[
|
|
2970
|
-
$[
|
|
2971
|
-
$[
|
|
2972
|
-
$[
|
|
2973
|
-
$[
|
|
2974
|
-
$[
|
|
2975
|
-
$[
|
|
2976
|
-
$[
|
|
2977
|
-
} else t18 = $[
|
|
3085
|
+
$[50] = align;
|
|
3086
|
+
$[51] = imageWrapperRef;
|
|
3087
|
+
$[52] = t12;
|
|
3088
|
+
$[53] = t13;
|
|
3089
|
+
$[54] = t14;
|
|
3090
|
+
$[55] = t15;
|
|
3091
|
+
$[56] = t16;
|
|
3092
|
+
$[57] = t17;
|
|
3093
|
+
$[58] = t18;
|
|
3094
|
+
} else t18 = $[58];
|
|
2978
3095
|
let t19;
|
|
2979
|
-
if ($[
|
|
3096
|
+
if ($[59] !== containerRef || $[60] !== t10 || $[61] !== t11 || $[62] !== t18 || $[63] !== t8 || $[64] !== t9) {
|
|
2980
3097
|
t19 = /* @__PURE__ */ jsx(NodeViewWrapper, {
|
|
2981
3098
|
"data-drag-handle": t8,
|
|
2982
3099
|
"data-mly-image-view": "",
|
|
@@ -2986,14 +3103,14 @@ function ImageView(props) {
|
|
|
2986
3103
|
ref: containerRef,
|
|
2987
3104
|
children: t18
|
|
2988
3105
|
});
|
|
2989
|
-
$[
|
|
2990
|
-
$[
|
|
2991
|
-
$[
|
|
2992
|
-
$[
|
|
2993
|
-
$[
|
|
2994
|
-
$[
|
|
2995
|
-
$[
|
|
2996
|
-
} else t19 = $[
|
|
3106
|
+
$[59] = containerRef;
|
|
3107
|
+
$[60] = t10;
|
|
3108
|
+
$[61] = t11;
|
|
3109
|
+
$[62] = t18;
|
|
3110
|
+
$[63] = t8;
|
|
3111
|
+
$[64] = t9;
|
|
3112
|
+
$[65] = t19;
|
|
3113
|
+
} else t19 = $[65];
|
|
2997
3114
|
return t19;
|
|
2998
3115
|
}
|
|
2999
3116
|
//#endregion
|
|
@@ -3997,6 +4114,7 @@ const STYLE_SUPPORTED_TYPES = [
|
|
|
3997
4114
|
...WRAPPER_TYPES,
|
|
3998
4115
|
MAILY_NODE_TYPES.COLUMNS,
|
|
3999
4116
|
MAILY_NODE_TYPES.COLUMN,
|
|
4117
|
+
MAILY_NODE_TYPES.DIV,
|
|
4000
4118
|
MAILY_NODE_TYPES.PARAGRAPH,
|
|
4001
4119
|
MAILY_NODE_TYPES.HEADING,
|
|
4002
4120
|
MAILY_NODE_TYPES.IMAGE,
|
|
@@ -4223,6 +4341,38 @@ function setCellParagraphs(document) {
|
|
|
4223
4341
|
}
|
|
4224
4342
|
}
|
|
4225
4343
|
}
|
|
4344
|
+
function removeComments(document) {
|
|
4345
|
+
const walker = document.createTreeWalker(document.documentElement, NodeFilter.SHOW_COMMENT);
|
|
4346
|
+
const comments = [];
|
|
4347
|
+
while (walker.nextNode()) comments.push(walker.currentNode);
|
|
4348
|
+
for (const comment of comments) comment.remove();
|
|
4349
|
+
}
|
|
4350
|
+
function isBlankText(node) {
|
|
4351
|
+
return node.nodeName === "BR" || node.nodeType === Node.TEXT_NODE && !node.textContent?.replace(/[\s\u00a0]/g, "");
|
|
4352
|
+
}
|
|
4353
|
+
function setTextDivs(document) {
|
|
4354
|
+
const divs = document.querySelectorAll(`div[style]:not([${DATA_NODE_TYPE_KEY}])`);
|
|
4355
|
+
for (const div of Array.from(divs).reverse()) {
|
|
4356
|
+
const children = Array.from(div.childNodes);
|
|
4357
|
+
if (children.length > 0 && children.every(isBlankText)) {
|
|
4358
|
+
div.replaceChildren();
|
|
4359
|
+
continue;
|
|
4360
|
+
}
|
|
4361
|
+
if (!(children.every(isPhrasing) && div.textContent?.trim())) continue;
|
|
4362
|
+
const paragraph = document.createElement("p");
|
|
4363
|
+
paragraph.setAttribute("style", stringifyInlineStyles(mergeInlineStyles({ margin: "0" }, parseInlineStyles(div.getAttribute("style") ?? ""))));
|
|
4364
|
+
paragraph.append(...children);
|
|
4365
|
+
div.replaceWith(paragraph);
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
function unwrapBodyDiv(document) {
|
|
4369
|
+
const [only, ...rest] = Array.from(document.body.children);
|
|
4370
|
+
if (rest.length > 0 || !(only instanceof HTMLElement) || only.tagName !== "DIV" || only.hasAttribute(DATA_NODE_TYPE_KEY) || only.style.maxWidth || only.style.width || Array.from(only.childNodes).every(isPhrasing)) return;
|
|
4371
|
+
const style = mergeInlineStyles(parseInlineStyles(document.body.getAttribute("style") ?? ""), parseInlineStyles(only.getAttribute("style") ?? ""));
|
|
4372
|
+
const merged = stringifyInlineStyles(style);
|
|
4373
|
+
if (merged) document.body.setAttribute("style", merged);
|
|
4374
|
+
only.replaceWith(...Array.from(only.childNodes));
|
|
4375
|
+
}
|
|
4226
4376
|
function getSoleImage(anchor) {
|
|
4227
4377
|
const images = anchor.querySelectorAll("img");
|
|
4228
4378
|
return images.length === 1 && anchor.textContent?.trim() === "" ? images[0] : null;
|
|
@@ -4295,8 +4445,11 @@ function getNormalizedHtml(html) {
|
|
|
4295
4445
|
if (!parsed.body) return html;
|
|
4296
4446
|
setRuleStyles(parsed);
|
|
4297
4447
|
removeHidden(parsed);
|
|
4448
|
+
removeComments(parsed);
|
|
4449
|
+
unwrapBodyDiv(parsed);
|
|
4298
4450
|
setLinkedImages(parsed);
|
|
4299
4451
|
setVariables(parsed);
|
|
4452
|
+
setTextDivs(parsed);
|
|
4300
4453
|
setCellParagraphs(parsed);
|
|
4301
4454
|
const style = getBodyStyle(parsed);
|
|
4302
4455
|
if (!style) return parsed.body.innerHTML;
|
|
@@ -4341,6 +4494,7 @@ const DEFAULT_EXTENSIONS = [
|
|
|
4341
4494
|
BodyExtension,
|
|
4342
4495
|
ContainerExtension,
|
|
4343
4496
|
SectionExtension,
|
|
4497
|
+
DivExtension,
|
|
4344
4498
|
RepeatExtension,
|
|
4345
4499
|
ColumnsExtension,
|
|
4346
4500
|
ColumnExtension,
|
|
@@ -4532,4 +4686,4 @@ function _temp(extension_0) {
|
|
|
4532
4686
|
return extension_0.name === "collaboration";
|
|
4533
4687
|
}
|
|
4534
4688
|
//#endregion
|
|
4535
|
-
export {
|
|
4689
|
+
export { getThemeCss as $, DEFAULT_REPEAT_EACH as A, MAX_SPACER_HEIGHT as B, DivExtension as C, setStyleDeclarations as D, BoldExtension as E, ColumnExtension as F, getVariableSuggestions as G, SPACER_SPACING as H, addColumn as I, Document$1 as J, VARIABLE_SUGGESTION_POPOVER_ID as K, getColumnWidths as L, VISIBILITY_SUPPORTED_TYPES as M, VisibilityExtension as N, BodyExtension as O, ColumnsExtension as P, getShellNodes as Q, removeColumn as R, FooterExtension as S, ButtonExtension as T, SPACING_PRESETS as U, MIN_SPACER_HEIGHT as V, VariableExtension as W, getNodeStyleState as X, getMergedNodeTheme as Y, getNodeTheme as Z, ALLOWED_IMAGE_MIME_TYPES as _, STYLE_SUPPORTED_TYPES as a, TooltipTrigger as at, HtmlCodeBlockExtension as b, SpacerExtension as c, FloatingElement as ct, SectionExtension as d, FLOATING_ELEMENT_ORDER as dt, Tooltip$1 as et, InlineSpanExtension as f, useOnSelectionUpdate as ft, VisuallyHidden as g, useValueAsRef as gt, ImageState as h, ArrowIcon as ht, mergeExtensions as i, TooltipProvider as it, ProtectVariableTrigger as j, BlockquoteExtension as k, SlashCommandExtension as l, clearInitialNodeSelection as lt, ImageExtension as m, useEditorInstance as mt, useMailyEditor as n, TooltipPopup as nt, StyleExtension as o, FLOATING_ELEMENT_HEIGHT as ot, InlineImageExtension as p, useFloatingStore as pt, filterVariableSuggestions as q, getNormalizedHtml as r, TooltipPositioner as rt, SpanExtension as s, FLOATING_ELEMENT_PADDING as st, DEFAULT_EXTENSIONS as t, TooltipArrow as tt, DEFAULT_SLASH_COMMANDS as u, FLOATING_ELEMENT_IDS as ut, IMAGE_UPLOAD_STATUSES as v, ContainerExtension as w, HorizontalRuleExtension as x, ImageUploadExtension as y, updateColumnWidth as z };
|