@maily-to/core 2.0.0-beta.8 → 2.0.0-beta.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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Tooltip, A as ProtectVariableTrigger, B as MIN_SPACER_HEIGHT, F as addColumn, H as SPACING_PRESETS, I as getColumnWidths, K as filterVariableSuggestions, L as removeColumn, R as updateColumnWidth, U as VariableExtension, V as SPACER_SPACING, W as getVariableSuggestions, X as getNodeTheme, Y as getNodeStyleState, Z as getShellNodes, at as FLOATING_ELEMENT_HEIGHT, ct as clearInitialNodeSelection, dt as useOnSelectionUpdate, et as TooltipArrow, ft as useFloatingStore, g as VisuallyHidden, ht as useValueAsRef, i as mergeExtensions, it as TooltipTrigger, j as VISIBILITY_SUPPORTED_TYPES, lt as FLOATING_ELEMENT_IDS, mt as ArrowIcon, n as useMailyEditor, nt as TooltipPositioner, ot as FLOATING_ELEMENT_PADDING, pt as useEditorInstance, q as Document, r as getNormalizedHtml, rt as TooltipProvider, st as FloatingElement, t as DEFAULT_EXTENSIONS, tt as TooltipPopup, ut as FLOATING_ELEMENT_ORDER, z as MAX_SPACER_HEIGHT } from "./use-maily-editor-xVILP7H8.mjs";
1
+ import { $ as Tooltip, A as ProtectVariableTrigger, B as MIN_SPACER_HEIGHT, F as addColumn, H as SPACING_PRESETS, I as getColumnWidths, K as filterVariableSuggestions, L as removeColumn, R as updateColumnWidth, U as VariableExtension, V as SPACER_SPACING, W as getVariableSuggestions, X as getNodeTheme, Y as getNodeStyleState, Z as getShellNodes, at as FLOATING_ELEMENT_HEIGHT, ct as clearInitialNodeSelection, dt as useOnSelectionUpdate, et as TooltipArrow, ft as useFloatingStore, g as VisuallyHidden, ht as useValueAsRef, i as mergeExtensions, it as TooltipTrigger, j as VISIBILITY_SUPPORTED_TYPES, lt as FLOATING_ELEMENT_IDS, mt as ArrowIcon, n as useMailyEditor, nt as TooltipPositioner, ot as FLOATING_ELEMENT_PADDING, pt as useEditorInstance, q as Document, r as getNormalizedHtml, rt as TooltipProvider, st as FloatingElement, t as DEFAULT_EXTENSIONS, tt as TooltipPopup, ut as FLOATING_ELEMENT_ORDER, z as MAX_SPACER_HEIGHT } from "./use-maily-editor-idL0RNsG.mjs";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { ColorPicker as ColorPicker$1 } from "cromia";
4
4
  import { Fragment, createContext, forwardRef, use, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
@@ -2258,7 +2258,8 @@ function useUploadStatus(editor, src) {
2258
2258
  }
2259
2259
  function ImageView(props) {
2260
2260
  const { editor, getPos, node, updateAttributes } = props;
2261
- const { align, alt, src, width } = node.attrs;
2261
+ const { align, alt, src, width, style } = node.attrs;
2262
+ const { width: _width, maxWidth: _maxWidth, height: _height, ...authoredStyle } = (0, _maily_to_shared.parseInlineStyles)(style ?? "");
2262
2263
  const isSrcVariable = !!src && (0, _maily_to_shared.hasVariableInText)(src);
2263
2264
  const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
2264
2265
  const { containerRef, handleResize, imageWrapperRef, isResizing, setShouldShowDragHandles, shouldShowDragHandles } = useImageResizeController({
@@ -2311,7 +2312,8 @@ function ImageView(props) {
2311
2312
  contentEditable: false,
2312
2313
  "data-mly-image": "",
2313
2314
  draggable: editor.isEditable,
2314
- src
2315
+ src,
2316
+ style: authoredStyle
2315
2317
  }), shouldShowDragHandles || isResizing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageHandle, {
2316
2318
  handle: "left",
2317
2319
  onPointerDown: (event) => handlePointerDown("left", event)
@@ -2795,38 +2795,52 @@ function useUploadStatus(editor, src) {
2795
2795
  return status ?? IMAGE_UPLOAD_STATUSES.LOADED;
2796
2796
  }
2797
2797
  function ImageView(props) {
2798
- const $ = (0, react_compiler_runtime.c)(60);
2798
+ const $ = (0, react_compiler_runtime.c)(65);
2799
2799
  const { editor, getPos, node, updateAttributes } = props;
2800
- const { align, alt, src, width } = node.attrs;
2801
- let t0;
2802
- if ($[0] !== src) {
2803
- t0 = !!src && (0, _maily_to_shared.hasVariableInText)(src);
2804
- $[0] = src;
2805
- $[1] = t0;
2806
- } else t0 = $[1];
2807
- const isSrcVariable = t0;
2808
- const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
2800
+ const { align, alt, src, width, style } = node.attrs;
2801
+ const t0 = style ?? "";
2809
2802
  let t1;
2810
- if ($[2] !== updateAttributes) {
2811
- t1 = (committed) => updateAttributes({ width: `${committed}%` });
2812
- $[2] = updateAttributes;
2813
- $[3] = t1;
2814
- } else t1 = $[3];
2815
- const t2 = t1;
2803
+ if ($[0] !== t0) {
2804
+ t1 = (0, _maily_to_shared.parseInlineStyles)(t0);
2805
+ $[0] = t0;
2806
+ $[1] = t1;
2807
+ } else t1 = $[1];
2808
+ let authoredStyle;
2809
+ if ($[2] !== t1) {
2810
+ const { width: _width, maxWidth: _maxWidth, height: _height, ...t2 } = t1;
2811
+ authoredStyle = t2;
2812
+ $[2] = t1;
2813
+ $[3] = authoredStyle;
2814
+ } else authoredStyle = $[3];
2815
+ let t2;
2816
+ if ($[4] !== src) {
2817
+ t2 = !!src && (0, _maily_to_shared.hasVariableInText)(src);
2818
+ $[4] = src;
2819
+ $[5] = t2;
2820
+ } else t2 = $[5];
2821
+ const isSrcVariable = t2;
2822
+ const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
2816
2823
  let t3;
2817
- if ($[4] !== align || $[5] !== t2) {
2818
- t3 = {
2824
+ if ($[6] !== updateAttributes) {
2825
+ t3 = (committed) => updateAttributes({ width: `${committed}%` });
2826
+ $[6] = updateAttributes;
2827
+ $[7] = t3;
2828
+ } else t3 = $[7];
2829
+ const t4 = t3;
2830
+ let t5;
2831
+ if ($[8] !== align || $[9] !== t4) {
2832
+ t5 = {
2819
2833
  align,
2820
- onWidthCommitted: t2
2834
+ onWidthCommitted: t4
2821
2835
  };
2822
- $[4] = align;
2823
- $[5] = t2;
2824
- $[6] = t3;
2825
- } else t3 = $[6];
2826
- const { containerRef, handleResize, imageWrapperRef, isResizing, setShouldShowDragHandles, shouldShowDragHandles } = useImageResizeController(t3);
2827
- let t4;
2828
- if ($[7] !== handleResize || $[8] !== imageWrapperRef) {
2829
- t4 = (handle, event) => {
2836
+ $[8] = align;
2837
+ $[9] = t4;
2838
+ $[10] = t5;
2839
+ } else t5 = $[10];
2840
+ const { containerRef, handleResize, imageWrapperRef, isResizing, setShouldShowDragHandles, shouldShowDragHandles } = useImageResizeController(t5);
2841
+ let t6;
2842
+ if ($[11] !== handleResize || $[12] !== imageWrapperRef) {
2843
+ t6 = (handle, event) => {
2830
2844
  const imageWrapper = imageWrapperRef.current;
2831
2845
  if (!imageWrapper) return;
2832
2846
  event.preventDefault();
@@ -2836,88 +2850,89 @@ function ImageView(props) {
2836
2850
  initialWidth: imageWrapper.clientWidth
2837
2851
  });
2838
2852
  };
2839
- $[7] = handleResize;
2840
- $[8] = imageWrapperRef;
2841
- $[9] = t4;
2842
- } else t4 = $[9];
2843
- const handlePointerDown = t4;
2844
- let t5;
2845
- if ($[10] !== editor || $[11] !== getPos || $[12] !== node.nodeSize) {
2846
- t5 = (file) => {
2853
+ $[11] = handleResize;
2854
+ $[12] = imageWrapperRef;
2855
+ $[13] = t6;
2856
+ } else t6 = $[13];
2857
+ const handlePointerDown = t6;
2858
+ let t7;
2859
+ if ($[14] !== editor || $[15] !== getPos || $[16] !== node.nodeSize) {
2860
+ t7 = (file) => {
2847
2861
  const pos = getPos();
2848
2862
  if (pos == null) return;
2849
2863
  editor.view.dispatch(editor.state.tr.delete(pos, pos + node.nodeSize));
2850
2864
  uploadImageFile(editor, file, pos);
2851
2865
  };
2852
- $[10] = editor;
2853
- $[11] = getPos;
2854
- $[12] = node.nodeSize;
2855
- $[13] = t5;
2856
- } else t5 = $[13];
2857
- const handleFileSelect = t5;
2866
+ $[14] = editor;
2867
+ $[15] = getPos;
2868
+ $[16] = node.nodeSize;
2869
+ $[17] = t7;
2870
+ } else t7 = $[17];
2871
+ const handleFileSelect = t7;
2858
2872
  const isLoaded = status === IMAGE_UPLOAD_STATUSES.LOADED;
2859
- const t6 = editor.isEditable && isLoaded;
2860
- const t7 = editor.isEditable && isLoaded;
2861
- let t8;
2862
- if ($[14] !== editor.isEditable || $[15] !== setShouldShowDragHandles) {
2863
- t8 = () => setShouldShowDragHandles(editor.isEditable);
2864
- $[14] = editor.isEditable;
2865
- $[15] = setShouldShowDragHandles;
2866
- $[16] = t8;
2867
- } else t8 = $[16];
2868
- let t9;
2869
- if ($[17] !== setShouldShowDragHandles) {
2870
- t9 = () => setShouldShowDragHandles(false);
2871
- $[17] = setShouldShowDragHandles;
2872
- $[18] = t9;
2873
- } else t9 = $[18];
2873
+ const t8 = editor.isEditable && isLoaded;
2874
+ const t9 = editor.isEditable && isLoaded;
2874
2875
  let t10;
2875
- if ($[19] !== width) {
2876
- t10 = { width };
2877
- $[19] = width;
2876
+ if ($[18] !== editor.isEditable || $[19] !== setShouldShowDragHandles) {
2877
+ t10 = () => setShouldShowDragHandles(editor.isEditable);
2878
+ $[18] = editor.isEditable;
2879
+ $[19] = setShouldShowDragHandles;
2878
2880
  $[20] = t10;
2879
2881
  } else t10 = $[20];
2880
2882
  let t11;
2881
- if ($[21] !== isSrcVariable) {
2882
- t11 = isSrcVariable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageVariableState, {}) : null;
2883
- $[21] = isSrcVariable;
2883
+ if ($[21] !== setShouldShowDragHandles) {
2884
+ t11 = () => setShouldShowDragHandles(false);
2885
+ $[21] = setShouldShowDragHandles;
2884
2886
  $[22] = t11;
2885
2887
  } else t11 = $[22];
2886
2888
  let t12;
2887
- if ($[23] !== editor.isEditable || $[24] !== handleFileSelect || $[25] !== isSrcVariable || $[26] !== status) {
2888
- t12 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.IDLE ? editor.isEditable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImagePlaceholder, { onFileSelect: handleFileSelect }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageIdleState, {}) : null;
2889
- $[23] = editor.isEditable;
2890
- $[24] = handleFileSelect;
2891
- $[25] = isSrcVariable;
2892
- $[26] = status;
2893
- $[27] = t12;
2894
- } else t12 = $[27];
2889
+ if ($[23] !== width) {
2890
+ t12 = { width };
2891
+ $[23] = width;
2892
+ $[24] = t12;
2893
+ } else t12 = $[24];
2895
2894
  let t13;
2896
- if ($[28] !== alt || $[29] !== isSrcVariable || $[30] !== src || $[31] !== status) {
2897
- t13 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.LOADING ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageLoadingState, {
2895
+ if ($[25] !== isSrcVariable) {
2896
+ t13 = isSrcVariable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageVariableState, {}) : null;
2897
+ $[25] = isSrcVariable;
2898
+ $[26] = t13;
2899
+ } else t13 = $[26];
2900
+ let t14;
2901
+ if ($[27] !== editor.isEditable || $[28] !== handleFileSelect || $[29] !== isSrcVariable || $[30] !== status) {
2902
+ t14 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.IDLE ? editor.isEditable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImagePlaceholder, { onFileSelect: handleFileSelect }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageIdleState, {}) : null;
2903
+ $[27] = editor.isEditable;
2904
+ $[28] = handleFileSelect;
2905
+ $[29] = isSrcVariable;
2906
+ $[30] = status;
2907
+ $[31] = t14;
2908
+ } else t14 = $[31];
2909
+ let t15;
2910
+ if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !== src || $[35] !== status) {
2911
+ t15 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.LOADING ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageLoadingState, {
2898
2912
  alt,
2899
2913
  src
2900
2914
  }) : null;
2901
- $[28] = alt;
2902
- $[29] = isSrcVariable;
2903
- $[30] = src;
2904
- $[31] = status;
2905
- $[32] = t13;
2906
- } else t13 = $[32];
2907
- let t14;
2908
- if ($[33] !== status) {
2909
- t14 = status === IMAGE_UPLOAD_STATUSES.ERROR ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageErrorState, {}) : null;
2910
- $[33] = status;
2911
- $[34] = t14;
2912
- } else t14 = $[34];
2913
- let t15;
2914
- if ($[35] !== alt || $[36] !== editor.isEditable || $[37] !== handlePointerDown || $[38] !== isLoaded || $[39] !== isResizing || $[40] !== isSrcVariable || $[41] !== shouldShowDragHandles || $[42] !== src) {
2915
- t15 = !isSrcVariable && isLoaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2915
+ $[32] = alt;
2916
+ $[33] = isSrcVariable;
2917
+ $[34] = src;
2918
+ $[35] = status;
2919
+ $[36] = t15;
2920
+ } else t15 = $[36];
2921
+ let t16;
2922
+ if ($[37] !== status) {
2923
+ t16 = status === IMAGE_UPLOAD_STATUSES.ERROR ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageErrorState, {}) : null;
2924
+ $[37] = status;
2925
+ $[38] = t16;
2926
+ } else t16 = $[38];
2927
+ let t17;
2928
+ if ($[39] !== alt || $[40] !== authoredStyle || $[41] !== editor.isEditable || $[42] !== handlePointerDown || $[43] !== isLoaded || $[44] !== isResizing || $[45] !== isSrcVariable || $[46] !== shouldShowDragHandles || $[47] !== src) {
2929
+ t17 = !isSrcVariable && isLoaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2916
2930
  alt: alt ?? void 0,
2917
2931
  contentEditable: false,
2918
2932
  "data-mly-image": "",
2919
2933
  draggable: editor.isEditable,
2920
- src
2934
+ src,
2935
+ style: authoredStyle
2921
2936
  }), shouldShowDragHandles || isResizing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageHandle, {
2922
2937
  handle: "left",
2923
2938
  onPointerDown: (event_0) => handlePointerDown("left", event_0)
@@ -2925,61 +2940,62 @@ function ImageView(props) {
2925
2940
  handle: "right",
2926
2941
  onPointerDown: (event_1) => handlePointerDown("right", event_1)
2927
2942
  })] }) : null] }) : null;
2928
- $[35] = alt;
2929
- $[36] = editor.isEditable;
2930
- $[37] = handlePointerDown;
2931
- $[38] = isLoaded;
2932
- $[39] = isResizing;
2933
- $[40] = isSrcVariable;
2934
- $[41] = shouldShowDragHandles;
2935
- $[42] = src;
2936
- $[43] = t15;
2937
- } else t15 = $[43];
2938
- let t16;
2939
- if ($[44] !== align || $[45] !== imageWrapperRef || $[46] !== t10 || $[47] !== t11 || $[48] !== t12 || $[49] !== t13 || $[50] !== t14 || $[51] !== t15) {
2940
- t16 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2943
+ $[39] = alt;
2944
+ $[40] = authoredStyle;
2945
+ $[41] = editor.isEditable;
2946
+ $[42] = handlePointerDown;
2947
+ $[43] = isLoaded;
2948
+ $[44] = isResizing;
2949
+ $[45] = isSrcVariable;
2950
+ $[46] = shouldShowDragHandles;
2951
+ $[47] = src;
2952
+ $[48] = t17;
2953
+ } else t17 = $[48];
2954
+ let t18;
2955
+ if ($[49] !== align || $[50] !== imageWrapperRef || $[51] !== t12 || $[52] !== t13 || $[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17) {
2956
+ t18 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2941
2957
  "data-align": align,
2942
2958
  "data-mly-image-wrapper": "",
2943
2959
  ref: imageWrapperRef,
2944
- style: t10,
2960
+ style: t12,
2945
2961
  children: [
2946
- t11,
2947
- t12,
2948
2962
  t13,
2949
2963
  t14,
2950
- t15
2964
+ t15,
2965
+ t16,
2966
+ t17
2951
2967
  ]
2952
2968
  });
2953
- $[44] = align;
2954
- $[45] = imageWrapperRef;
2955
- $[46] = t10;
2956
- $[47] = t11;
2957
- $[48] = t12;
2958
- $[49] = t13;
2959
- $[50] = t14;
2960
- $[51] = t15;
2961
- $[52] = t16;
2962
- } else t16 = $[52];
2963
- let t17;
2964
- if ($[53] !== containerRef || $[54] !== t16 || $[55] !== t6 || $[56] !== t7 || $[57] !== t8 || $[58] !== t9) {
2965
- t17 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, {
2966
- "data-drag-handle": t6,
2969
+ $[49] = align;
2970
+ $[50] = imageWrapperRef;
2971
+ $[51] = t12;
2972
+ $[52] = t13;
2973
+ $[53] = t14;
2974
+ $[54] = t15;
2975
+ $[55] = t16;
2976
+ $[56] = t17;
2977
+ $[57] = t18;
2978
+ } else t18 = $[57];
2979
+ let t19;
2980
+ if ($[58] !== containerRef || $[59] !== t10 || $[60] !== t11 || $[61] !== t18 || $[62] !== t8 || $[63] !== t9) {
2981
+ t19 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, {
2982
+ "data-drag-handle": t8,
2967
2983
  "data-mly-image-view": "",
2968
- draggable: t7,
2969
- onMouseEnter: t8,
2970
- onMouseLeave: t9,
2984
+ draggable: t9,
2985
+ onMouseEnter: t10,
2986
+ onMouseLeave: t11,
2971
2987
  ref: containerRef,
2972
- children: t16
2988
+ children: t18
2973
2989
  });
2974
- $[53] = containerRef;
2975
- $[54] = t16;
2976
- $[55] = t6;
2977
- $[56] = t7;
2978
- $[57] = t8;
2979
- $[58] = t9;
2980
- $[59] = t17;
2981
- } else t17 = $[59];
2982
- return t17;
2990
+ $[58] = containerRef;
2991
+ $[59] = t10;
2992
+ $[60] = t11;
2993
+ $[61] = t18;
2994
+ $[62] = t8;
2995
+ $[63] = t9;
2996
+ $[64] = t19;
2997
+ } else t19 = $[64];
2998
+ return t19;
2983
2999
  }
2984
3000
  //#endregion
2985
3001
  //#region src/extensions/image/image.ts