@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.
@@ -2175,6 +2175,52 @@ const ContainerExtension = _tiptap_core.Node.create({
2175
2175
  }
2176
2176
  });
2177
2177
  //#endregion
2178
+ //#region src/extensions/div/div.ts
2179
+ const DivExtension = _tiptap_core.Node.create({
2180
+ name: _maily_to_shared.MAILY_NODE_TYPES.DIV,
2181
+ group: "block",
2182
+ content: "block+",
2183
+ defining: true,
2184
+ isolating: true,
2185
+ addKeyboardShortcuts() {
2186
+ return {
2187
+ Enter: ({ editor }) => exitOnTripleEnter({
2188
+ editor,
2189
+ nodeName: this.name
2190
+ }),
2191
+ Backspace: ({ editor }) => {
2192
+ const { $from, empty } = editor.state.selection;
2193
+ if (!empty || $from.parentOffset !== 0) return false;
2194
+ for (let depth = $from.depth; depth > 0; depth -= 1) {
2195
+ const node = $from.node(depth);
2196
+ if (node.type.name !== this.name) continue;
2197
+ const only = node.childCount === 1 ? node.firstChild : null;
2198
+ if (!(only?.isTextblock && only.content.size === 0)) return false;
2199
+ return editor.commands.deleteRange({
2200
+ from: $from.before(depth),
2201
+ to: $from.after(depth)
2202
+ });
2203
+ }
2204
+ return false;
2205
+ }
2206
+ };
2207
+ },
2208
+ parseHTML() {
2209
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.DIV}"]` }, {
2210
+ tag: `div:not([${_maily_to_shared.DATA_NODE_TYPE_KEY}])`,
2211
+ priority: 40,
2212
+ getAttrs: (element) => element.getAttribute("style") ? null : false
2213
+ }];
2214
+ },
2215
+ renderHTML({ HTMLAttributes }) {
2216
+ return [
2217
+ "div",
2218
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.DIV }, HTMLAttributes),
2219
+ 0
2220
+ ];
2221
+ }
2222
+ });
2223
+ //#endregion
2178
2224
  //#region src/extensions/footer/footer.ts
2179
2225
  const FooterExtension = _tiptap_core.Node.create({
2180
2226
  name: _maily_to_shared.MAILY_NODE_TYPES.FOOTER,
@@ -2206,6 +2252,8 @@ const HorizontalRuleExtension = _tiptap_extension_horizontal_rule.HorizontalRule
2206
2252
  //#endregion
2207
2253
  //#region src/extensions/html-code-block/html-code-block-view.tsx
2208
2254
  const PREVIEW_RESET = `
2255
+ html { overflow: hidden; }
2256
+ body { margin: 0; }
2209
2257
  * { font-family: 'Inter', sans-serif; }
2210
2258
  blockquote, h1, h2, h3, img, li, ol, p, ul {
2211
2259
  margin-top: 0;
@@ -2231,24 +2279,22 @@ function HtmlCodeBlockView(props) {
2231
2279
  }
2232
2280
  const html = `<style>${t0.join("\n")}</style>${parsed.body.innerHTML}`;
2233
2281
  const isEmpty = html === "<style></style>";
2282
+ const [height, setHeight] = (0, react.useState)(0);
2234
2283
  let t1;
2235
- if ($[3] !== html) {
2236
- t1 = (element_0) => {
2237
- if (!element_0 || element_0.shadowRoot) return;
2238
- const shadow = element_0.attachShadow({ mode: "open" });
2239
- const sheet = new CSSStyleSheet();
2240
- sheet.replaceSync(PREVIEW_RESET);
2241
- shadow.adoptedStyleSheets = [sheet];
2242
- const container = document.createElement("div");
2243
- container.innerHTML = html;
2244
- shadow.append(container);
2284
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
2285
+ t1 = (event) => {
2286
+ const frameWindow = event.currentTarget.contentWindow;
2287
+ const root = frameWindow?.document.documentElement;
2288
+ if (!frameWindow || !root) return;
2289
+ new frameWindow.ResizeObserver(() => {
2290
+ setHeight(root.offsetHeight);
2291
+ }).observe(root);
2245
2292
  };
2246
- $[3] = html;
2247
- $[4] = t1;
2248
- } else t1 = $[4];
2249
- const setPreviewElement = t1;
2293
+ $[3] = t1;
2294
+ } else t1 = $[3];
2295
+ const onPreviewLoad = t1;
2250
2296
  let t2;
2251
- if ($[5] !== activeTab || $[6] !== language) {
2297
+ if ($[4] !== activeTab || $[5] !== language) {
2252
2298
  t2 = activeTab === _maily_to_shared.HTML_CODE_BLOCK_TABS.CODE && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
2253
2299
  "data-mly-html-code-block": "",
2254
2300
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewContent, {
@@ -2256,12 +2302,12 @@ function HtmlCodeBlockView(props) {
2256
2302
  className: language ? `language-${language}` : void 0
2257
2303
  })
2258
2304
  });
2259
- $[5] = activeTab;
2260
- $[6] = language;
2261
- $[7] = t2;
2262
- } else t2 = $[7];
2305
+ $[4] = activeTab;
2306
+ $[5] = language;
2307
+ $[6] = t2;
2308
+ } else t2 = $[6];
2263
2309
  let t3;
2264
- if ($[8] !== activeTab || $[9] !== isEmpty || $[10] !== setPreviewElement || $[11] !== updateAttributes) {
2310
+ if ($[7] !== activeTab || $[8] !== height || $[9] !== html || $[10] !== isEmpty || $[11] !== updateAttributes) {
2265
2311
  t3 = activeTab === _maily_to_shared.HTML_CODE_BLOCK_TABS.PREVIEW && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2266
2312
  contentEditable: false,
2267
2313
  "data-empty": isEmpty ? "" : void 0,
@@ -2269,11 +2315,24 @@ function HtmlCodeBlockView(props) {
2269
2315
  onClick: () => {
2270
2316
  if (isEmpty) updateAttributes({ activeTab: _maily_to_shared.HTML_CODE_BLOCK_TABS.CODE });
2271
2317
  },
2272
- ref: setPreviewElement
2318
+ children: !isEmpty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
2319
+ onLoad: onPreviewLoad,
2320
+ sandbox: "allow-same-origin",
2321
+ srcDoc: `<!DOCTYPE html><style>${PREVIEW_RESET}</style>${html}`,
2322
+ style: {
2323
+ border: 0,
2324
+ display: "block",
2325
+ height,
2326
+ pointerEvents: "none",
2327
+ width: "100%"
2328
+ },
2329
+ title: "HTML preview"
2330
+ })
2273
2331
  });
2274
- $[8] = activeTab;
2275
- $[9] = isEmpty;
2276
- $[10] = setPreviewElement;
2332
+ $[7] = activeTab;
2333
+ $[8] = height;
2334
+ $[9] = html;
2335
+ $[10] = isEmpty;
2277
2336
  $[11] = updateAttributes;
2278
2337
  $[12] = t3;
2279
2338
  } else t3 = $[12];
@@ -2413,20 +2472,28 @@ function uploadImageFile(editor, file, position) {
2413
2472
  URL.revokeObjectURL(blobUrl);
2414
2473
  return;
2415
2474
  }
2475
+ const { uploads, progress } = editor.storage.imageUpload;
2416
2476
  const context = {
2417
2477
  position,
2418
- removeImage: () => removeImageByBlobUrl(editor, blobUrl)
2478
+ removeImage: () => removeImageByBlobUrl(editor, blobUrl),
2479
+ setProgress: (fraction) => {
2480
+ const percent = Math.round(Math.min(Math.max(fraction, 0), 1) * 100);
2481
+ if (!uploads.has(blobUrl) || progress.get(blobUrl) === percent) return;
2482
+ progress.set(blobUrl, percent);
2483
+ notifyUploadStatusChanged(editor);
2484
+ }
2419
2485
  };
2420
- const { uploads } = editor.storage.imageUpload;
2421
2486
  uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.LOADING);
2422
2487
  notifyUploadStatusChanged(editor);
2423
2488
  onImageUpload(file, context).then((url) => {
2424
2489
  uploads.delete(blobUrl);
2490
+ progress.delete(blobUrl);
2425
2491
  notifyUploadStatusChanged(editor);
2426
2492
  updateImageByBlobUrl(editor, blobUrl, { src: url });
2427
2493
  URL.revokeObjectURL(blobUrl);
2428
2494
  }).catch((error) => {
2429
2495
  uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.ERROR);
2496
+ progress.delete(blobUrl);
2430
2497
  notifyUploadStatusChanged(editor);
2431
2498
  onImageUploadError?.(error, file, context);
2432
2499
  URL.revokeObjectURL(blobUrl);
@@ -2457,7 +2524,10 @@ const ImageUploadExtension = _tiptap_core.Extension.create({
2457
2524
  };
2458
2525
  },
2459
2526
  addStorage() {
2460
- return { uploads: /* @__PURE__ */ new Map() };
2527
+ return {
2528
+ uploads: /* @__PURE__ */ new Map(),
2529
+ progress: /* @__PURE__ */ new Map()
2530
+ };
2461
2531
  },
2462
2532
  addExtensions() {
2463
2533
  return [_tiptap_extension_file_handler.FileHandler.configure({
@@ -2730,8 +2800,9 @@ function ImageVariableState() {
2730
2800
  return t0;
2731
2801
  }
2732
2802
  function ImageLoadingState(props) {
2733
- const $ = (0, react_compiler_runtime.c)(7);
2734
- const { alt, src } = props;
2803
+ const $ = (0, react_compiler_runtime.c)(13);
2804
+ const { alt, src, progress } = props;
2805
+ const isUploading = progress !== void 0 && progress < 100;
2735
2806
  const t0 = alt ?? void 0;
2736
2807
  let t1;
2737
2808
  if ($[0] !== src || $[1] !== t0) {
@@ -2745,34 +2816,57 @@ function ImageLoadingState(props) {
2745
2816
  $[2] = t1;
2746
2817
  } else t1 = $[2];
2747
2818
  let t2;
2748
- let t3;
2749
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
2750
- t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { "data-mly-image-spinner": "" });
2751
- t3 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHidden, {
2819
+ if ($[3] !== isUploading || $[4] !== progress) {
2820
+ t2 = progress !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2821
+ "aria-label": "Uploading image",
2822
+ "aria-valuemax": 100,
2823
+ "aria-valuemin": 0,
2824
+ "aria-valuenow": progress,
2825
+ "data-mly-image-progress": "",
2826
+ "data-state": isUploading ? "uploading" : "done",
2827
+ role: "progressbar",
2828
+ style: { "--mly-image-progress": progress / 100 }
2829
+ });
2830
+ $[3] = isUploading;
2831
+ $[4] = progress;
2832
+ $[5] = t2;
2833
+ } else t2 = $[5];
2834
+ const t3 = progress === void 0 ? "center" : "corner";
2835
+ let t4;
2836
+ if ($[6] !== t3) {
2837
+ t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2838
+ "data-mly-image-spinner": "",
2839
+ "data-variant": t3
2840
+ });
2841
+ $[6] = t3;
2842
+ $[7] = t4;
2843
+ } else t4 = $[7];
2844
+ let t5;
2845
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
2846
+ t5 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHidden, {
2752
2847
  role: "status",
2753
2848
  children: "Uploading image"
2754
2849
  });
2755
- $[3] = t2;
2756
- $[4] = t3;
2757
- } else {
2758
- t2 = $[3];
2759
- t3 = $[4];
2760
- }
2761
- let t4;
2762
- if ($[5] !== t1) {
2763
- t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2850
+ $[8] = t5;
2851
+ } else t5 = $[8];
2852
+ let t6;
2853
+ if ($[9] !== t1 || $[10] !== t2 || $[11] !== t4) {
2854
+ t6 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2764
2855
  "aria-busy": "true",
2765
2856
  "data-mly-image-loading": "",
2766
2857
  children: [
2767
2858
  t1,
2768
2859
  t2,
2769
- t3
2860
+ t4,
2861
+ t5
2770
2862
  ]
2771
2863
  });
2772
- $[5] = t1;
2773
- $[6] = t4;
2774
- } else t4 = $[6];
2775
- return t4;
2864
+ $[9] = t1;
2865
+ $[10] = t2;
2866
+ $[11] = t4;
2867
+ $[12] = t6;
2868
+ } else t6 = $[12];
2869
+ return t6;
2776
2870
  }
2777
2871
  function ImagePlaceholder(props) {
2778
2872
  const $ = (0, react_compiler_runtime.c)(3);
@@ -2825,8 +2919,28 @@ function useUploadStatus(editor, src) {
2825
2919
  if (!src) return IMAGE_UPLOAD_STATUSES.IDLE;
2826
2920
  return status ?? IMAGE_UPLOAD_STATUSES.LOADED;
2827
2921
  }
2922
+ function useUploadProgress(editor, src) {
2923
+ const $ = (0, react_compiler_runtime.c)(5);
2924
+ let t0;
2925
+ if ($[0] !== src) {
2926
+ t0 = (ctx) => src ? ctx.editor.storage.imageUpload?.progress?.get(src) : void 0;
2927
+ $[0] = src;
2928
+ $[1] = t0;
2929
+ } else t0 = $[1];
2930
+ let t1;
2931
+ if ($[2] !== editor || $[3] !== t0) {
2932
+ t1 = {
2933
+ editor,
2934
+ selector: t0
2935
+ };
2936
+ $[2] = editor;
2937
+ $[3] = t0;
2938
+ $[4] = t1;
2939
+ } else t1 = $[4];
2940
+ return (0, _tiptap_react.useEditorState)(t1);
2941
+ }
2828
2942
  function ImageView(props) {
2829
- const $ = (0, react_compiler_runtime.c)(65);
2943
+ const $ = (0, react_compiler_runtime.c)(66);
2830
2944
  const { editor, getPos, node, updateAttributes } = props;
2831
2945
  const { align, alt, src, width, style } = node.attrs;
2832
2946
  const t0 = style ?? "";
@@ -2851,6 +2965,7 @@ function ImageView(props) {
2851
2965
  } else t2 = $[5];
2852
2966
  const isSrcVariable = t2;
2853
2967
  const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
2968
+ const progress = useUploadProgress(editor, status === IMAGE_UPLOAD_STATUSES.LOADING ? src : void 0);
2854
2969
  let t3;
2855
2970
  if ($[6] !== updateAttributes) {
2856
2971
  t3 = (committed) => updateAttributes({ width: `${committed}%` });
@@ -2938,25 +3053,27 @@ function ImageView(props) {
2938
3053
  $[31] = t14;
2939
3054
  } else t14 = $[31];
2940
3055
  let t15;
2941
- if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !== src || $[35] !== status) {
3056
+ if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !== progress || $[35] !== src || $[36] !== status) {
2942
3057
  t15 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.LOADING ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageLoadingState, {
2943
3058
  alt,
2944
- src
3059
+ src,
3060
+ progress
2945
3061
  }) : null;
2946
3062
  $[32] = alt;
2947
3063
  $[33] = isSrcVariable;
2948
- $[34] = src;
2949
- $[35] = status;
2950
- $[36] = t15;
2951
- } else t15 = $[36];
3064
+ $[34] = progress;
3065
+ $[35] = src;
3066
+ $[36] = status;
3067
+ $[37] = t15;
3068
+ } else t15 = $[37];
2952
3069
  let t16;
2953
- if ($[37] !== status) {
3070
+ if ($[38] !== status) {
2954
3071
  t16 = status === IMAGE_UPLOAD_STATUSES.ERROR ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageErrorState, {}) : null;
2955
- $[37] = status;
2956
- $[38] = t16;
2957
- } else t16 = $[38];
3072
+ $[38] = status;
3073
+ $[39] = t16;
3074
+ } else t16 = $[39];
2958
3075
  let t17;
2959
- if ($[39] !== alt || $[40] !== authoredStyle || $[41] !== editor.isEditable || $[42] !== handlePointerDown || $[43] !== isLoaded || $[44] !== isResizing || $[45] !== isSrcVariable || $[46] !== shouldShowDragHandles || $[47] !== src) {
3076
+ if ($[40] !== alt || $[41] !== authoredStyle || $[42] !== editor.isEditable || $[43] !== handlePointerDown || $[44] !== isLoaded || $[45] !== isResizing || $[46] !== isSrcVariable || $[47] !== shouldShowDragHandles || $[48] !== src) {
2960
3077
  t17 = !isSrcVariable && isLoaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2961
3078
  alt: alt ?? void 0,
2962
3079
  contentEditable: false,
@@ -2971,19 +3088,19 @@ function ImageView(props) {
2971
3088
  handle: "right",
2972
3089
  onPointerDown: (event_1) => handlePointerDown("right", event_1)
2973
3090
  })] }) : null] }) : null;
2974
- $[39] = alt;
2975
- $[40] = authoredStyle;
2976
- $[41] = editor.isEditable;
2977
- $[42] = handlePointerDown;
2978
- $[43] = isLoaded;
2979
- $[44] = isResizing;
2980
- $[45] = isSrcVariable;
2981
- $[46] = shouldShowDragHandles;
2982
- $[47] = src;
2983
- $[48] = t17;
2984
- } else t17 = $[48];
3091
+ $[40] = alt;
3092
+ $[41] = authoredStyle;
3093
+ $[42] = editor.isEditable;
3094
+ $[43] = handlePointerDown;
3095
+ $[44] = isLoaded;
3096
+ $[45] = isResizing;
3097
+ $[46] = isSrcVariable;
3098
+ $[47] = shouldShowDragHandles;
3099
+ $[48] = src;
3100
+ $[49] = t17;
3101
+ } else t17 = $[49];
2985
3102
  let t18;
2986
- if ($[49] !== align || $[50] !== imageWrapperRef || $[51] !== t12 || $[52] !== t13 || $[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17) {
3103
+ if ($[50] !== align || $[51] !== imageWrapperRef || $[52] !== t12 || $[53] !== t13 || $[54] !== t14 || $[55] !== t15 || $[56] !== t16 || $[57] !== t17) {
2987
3104
  t18 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2988
3105
  "data-align": align,
2989
3106
  "data-mly-image-wrapper": "",
@@ -2997,18 +3114,18 @@ function ImageView(props) {
2997
3114
  t17
2998
3115
  ]
2999
3116
  });
3000
- $[49] = align;
3001
- $[50] = imageWrapperRef;
3002
- $[51] = t12;
3003
- $[52] = t13;
3004
- $[53] = t14;
3005
- $[54] = t15;
3006
- $[55] = t16;
3007
- $[56] = t17;
3008
- $[57] = t18;
3009
- } else t18 = $[57];
3117
+ $[50] = align;
3118
+ $[51] = imageWrapperRef;
3119
+ $[52] = t12;
3120
+ $[53] = t13;
3121
+ $[54] = t14;
3122
+ $[55] = t15;
3123
+ $[56] = t16;
3124
+ $[57] = t17;
3125
+ $[58] = t18;
3126
+ } else t18 = $[58];
3010
3127
  let t19;
3011
- if ($[58] !== containerRef || $[59] !== t10 || $[60] !== t11 || $[61] !== t18 || $[62] !== t8 || $[63] !== t9) {
3128
+ if ($[59] !== containerRef || $[60] !== t10 || $[61] !== t11 || $[62] !== t18 || $[63] !== t8 || $[64] !== t9) {
3012
3129
  t19 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, {
3013
3130
  "data-drag-handle": t8,
3014
3131
  "data-mly-image-view": "",
@@ -3018,14 +3135,14 @@ function ImageView(props) {
3018
3135
  ref: containerRef,
3019
3136
  children: t18
3020
3137
  });
3021
- $[58] = containerRef;
3022
- $[59] = t10;
3023
- $[60] = t11;
3024
- $[61] = t18;
3025
- $[62] = t8;
3026
- $[63] = t9;
3027
- $[64] = t19;
3028
- } else t19 = $[64];
3138
+ $[59] = containerRef;
3139
+ $[60] = t10;
3140
+ $[61] = t11;
3141
+ $[62] = t18;
3142
+ $[63] = t8;
3143
+ $[64] = t9;
3144
+ $[65] = t19;
3145
+ } else t19 = $[65];
3029
3146
  return t19;
3030
3147
  }
3031
3148
  //#endregion
@@ -4029,6 +4146,7 @@ const STYLE_SUPPORTED_TYPES = [
4029
4146
  ...WRAPPER_TYPES,
4030
4147
  _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
4031
4148
  _maily_to_shared.MAILY_NODE_TYPES.COLUMN,
4149
+ _maily_to_shared.MAILY_NODE_TYPES.DIV,
4032
4150
  _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH,
4033
4151
  _maily_to_shared.MAILY_NODE_TYPES.HEADING,
4034
4152
  _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
@@ -4255,6 +4373,38 @@ function setCellParagraphs(document) {
4255
4373
  }
4256
4374
  }
4257
4375
  }
4376
+ function removeComments(document) {
4377
+ const walker = document.createTreeWalker(document.documentElement, NodeFilter.SHOW_COMMENT);
4378
+ const comments = [];
4379
+ while (walker.nextNode()) comments.push(walker.currentNode);
4380
+ for (const comment of comments) comment.remove();
4381
+ }
4382
+ function isBlankText(node) {
4383
+ return node.nodeName === "BR" || node.nodeType === Node.TEXT_NODE && !node.textContent?.replace(/[\s\u00a0]/g, "");
4384
+ }
4385
+ function setTextDivs(document) {
4386
+ const divs = document.querySelectorAll(`div[style]:not([${_maily_to_shared.DATA_NODE_TYPE_KEY}])`);
4387
+ for (const div of Array.from(divs).reverse()) {
4388
+ const children = Array.from(div.childNodes);
4389
+ if (children.length > 0 && children.every(isBlankText)) {
4390
+ div.replaceChildren();
4391
+ continue;
4392
+ }
4393
+ if (!(children.every(isPhrasing) && div.textContent?.trim())) continue;
4394
+ const paragraph = document.createElement("p");
4395
+ paragraph.setAttribute("style", (0, _maily_to_shared.stringifyInlineStyles)((0, _maily_to_shared.mergeInlineStyles)({ margin: "0" }, (0, _maily_to_shared.parseInlineStyles)(div.getAttribute("style") ?? ""))));
4396
+ paragraph.append(...children);
4397
+ div.replaceWith(paragraph);
4398
+ }
4399
+ }
4400
+ function unwrapBodyDiv(document) {
4401
+ const [only, ...rest] = Array.from(document.body.children);
4402
+ if (rest.length > 0 || !(only instanceof HTMLElement) || only.tagName !== "DIV" || only.hasAttribute(_maily_to_shared.DATA_NODE_TYPE_KEY) || only.style.maxWidth || only.style.width || Array.from(only.childNodes).every(isPhrasing)) return;
4403
+ const style = (0, _maily_to_shared.mergeInlineStyles)((0, _maily_to_shared.parseInlineStyles)(document.body.getAttribute("style") ?? ""), (0, _maily_to_shared.parseInlineStyles)(only.getAttribute("style") ?? ""));
4404
+ const merged = (0, _maily_to_shared.stringifyInlineStyles)(style);
4405
+ if (merged) document.body.setAttribute("style", merged);
4406
+ only.replaceWith(...Array.from(only.childNodes));
4407
+ }
4258
4408
  function getSoleImage(anchor) {
4259
4409
  const images = anchor.querySelectorAll("img");
4260
4410
  return images.length === 1 && anchor.textContent?.trim() === "" ? images[0] : null;
@@ -4327,8 +4477,11 @@ function getNormalizedHtml(html) {
4327
4477
  if (!parsed.body) return html;
4328
4478
  setRuleStyles(parsed);
4329
4479
  removeHidden(parsed);
4480
+ removeComments(parsed);
4481
+ unwrapBodyDiv(parsed);
4330
4482
  setLinkedImages(parsed);
4331
4483
  setVariables(parsed);
4484
+ setTextDivs(parsed);
4332
4485
  setCellParagraphs(parsed);
4333
4486
  const style = getBodyStyle(parsed);
4334
4487
  if (!style) return parsed.body.innerHTML;
@@ -4373,6 +4526,7 @@ const DEFAULT_EXTENSIONS = [
4373
4526
  BodyExtension,
4374
4527
  ContainerExtension,
4375
4528
  SectionExtension,
4529
+ DivExtension,
4376
4530
  RepeatExtension,
4377
4531
  ColumnsExtension,
4378
4532
  ColumnExtension,
@@ -4636,6 +4790,12 @@ Object.defineProperty(exports, "DEFAULT_SLASH_COMMANDS", {
4636
4790
  return DEFAULT_SLASH_COMMANDS;
4637
4791
  }
4638
4792
  });
4793
+ Object.defineProperty(exports, "DivExtension", {
4794
+ enumerable: true,
4795
+ get: function() {
4796
+ return DivExtension;
4797
+ }
4798
+ });
4639
4799
  Object.defineProperty(exports, "Document", {
4640
4800
  enumerable: true,
4641
4801
  get: function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maily-to/core",
3
- "version": "2.0.0-beta.18",
3
+ "version": "2.0.0-beta.20",
4
4
  "private": false,
5
5
  "description": "Powerful editor for creating beautiful, pre-designed, mobile-ready emails.",
6
6
  "keywords": [
@@ -87,7 +87,7 @@
87
87
  "lucide-react": "^1.28.0",
88
88
  "unit-field": "^0.0.3",
89
89
  "zustand": "^5.0.14",
90
- "@maily-to/shared": "2.0.0-beta.18"
90
+ "@maily-to/shared": "2.0.0-beta.20"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@react-email/components": "^1.0.12",
@@ -107,10 +107,10 @@
107
107
  "typescript": "^7.0.2",
108
108
  "vite-plus": "0.3.0",
109
109
  "yjs": "^13.6.33",
110
- "@maily-to/extension-ai-actions": "0.0.1",
111
- "@maily-to/extension-inline-suggestion": "0.0.1",
112
110
  "@maily-to/extension-variable": "0.0.1",
113
- "@maily-to/render": "2.0.0-beta.18",
111
+ "@maily-to/extension-inline-suggestion": "0.0.1",
112
+ "@maily-to/render": "2.0.0-beta.20",
113
+ "@maily-to/extension-ai-actions": "0.0.1",
114
114
  "@maily-to/tsconfig": "0.0.0"
115
115
  },
116
116
  "peerDependencies": {
@@ -410,11 +410,69 @@
410
410
  position: relative;
411
411
  }
412
412
 
413
+ [data-mly-image-loading]::before {
414
+ position: absolute;
415
+ inset: 0;
416
+ background: rgb(0 0 0 / 40%);
417
+ content: '';
418
+ }
419
+
413
420
  [data-mly-image-preview] {
421
+ display: block;
414
422
  width: 100%;
415
423
  max-width: 100%;
416
424
  height: auto;
417
- opacity: 0.4;
425
+ }
426
+
427
+ @property --mly-image-progress {
428
+ syntax: '<number>';
429
+ inherits: false;
430
+ initial-value: 0;
431
+ }
432
+
433
+ [data-mly-image-progress] {
434
+ position: absolute;
435
+ top: 50%;
436
+ left: 50%;
437
+ width: 64px;
438
+ height: 64px;
439
+ margin: -32px 0 0 -32px;
440
+ border-radius: 50%;
441
+ background:
442
+ conic-gradient(
443
+ #fff calc(var(--mly-image-progress) * 360deg),
444
+ transparent 0
445
+ ),
446
+ rgb(255 255 255 / 20%);
447
+ transition:
448
+ --mly-image-progress 0.5s ease-in-out,
449
+ opacity 0.2s ease-out,
450
+ scale 0.2s ease-out;
451
+ }
452
+
453
+ @starting-style {
454
+ [data-mly-image-progress] {
455
+ opacity: 0;
456
+ scale: 0.75;
457
+ }
458
+ }
459
+
460
+ [data-mly-image-progress][data-state='done'] {
461
+ opacity: 0;
462
+ scale: 0.75;
463
+ transition-delay: 0s, 0.3s, 0.3s;
464
+ }
465
+
466
+ [data-mly-image-spinner][data-variant='corner'] {
467
+ top: 10px;
468
+ right: 10px;
469
+ left: auto;
470
+ width: 14px;
471
+ height: 14px;
472
+ margin: 0;
473
+ border-width: 2px;
474
+ border-color: rgb(255 255 255 / 35%);
475
+ border-top-color: #fff;
418
476
  }
419
477
 
420
478
  [data-mly-image-spinner] {
@@ -2538,6 +2596,10 @@ body:has([data-mly-unit-field][data-dragging='true']) * {
2538
2596
  animation: none;
2539
2597
  }
2540
2598
 
2599
+ [data-mly-image-progress] {
2600
+ transition: none;
2601
+ }
2602
+
2541
2603
  [data-mly-suggestion] {
2542
2604
  transition: none;
2543
2605
  }