@maily-to/core 0.0.23 → 0.0.25

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.
@@ -648,8 +648,8 @@ function LinkCardComponent(props) {
648
648
  NodeViewWrapper,
649
649
  {
650
650
  className: `react-component ${props.selected && "ProseMirror-selectednode"}`,
651
- draggable: "true",
652
- "data-drag-handle": "",
651
+ draggable: editor.isEditable,
652
+ "data-drag-handle": editor.isEditable,
653
653
  children: /* @__PURE__ */ jsxs(Popover, { open: props.selected, children: [
654
654
  /* @__PURE__ */ jsx4(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx4(
655
655
  "div",
@@ -666,7 +666,8 @@ function LinkCardComponent(props) {
666
666
  {
667
667
  src: image2,
668
668
  alt: "link-card",
669
- className: "mly-no-prose !mly-mb-0 mly-h-full mly-w-full mly-rounded-t-lg"
669
+ className: "mly-no-prose !mly-mb-0 mly-h-full mly-w-full mly-rounded-t-lg",
670
+ draggable: editor.isEditable
670
671
  }
671
672
  ) }),
672
673
  /* @__PURE__ */ jsx4("div", { className: "mly-flex mly-items-stretch mly-p-3", children: /* @__PURE__ */ jsxs("div", { className: cn("mly-flex mly-flex-col"), children: [
@@ -1131,8 +1132,8 @@ function ForView(props) {
1131
1132
  return /* @__PURE__ */ jsxs2(
1132
1133
  NodeViewWrapper2,
1133
1134
  {
1134
- draggable: "true",
1135
- "data-drag-handle": "",
1135
+ draggable: editor.isEditable,
1136
+ "data-drag-handle": editor.isEditable,
1136
1137
  "data-type": "for",
1137
1138
  className: "mly-relative",
1138
1139
  children: [
@@ -1789,12 +1790,23 @@ function VariableView(props) {
1789
1790
  className: "react-component mly-inline-block mly-leading-none",
1790
1791
  draggable: "false",
1791
1792
  children: /* @__PURE__ */ jsxs5(Popover, { children: [
1792
- /* @__PURE__ */ jsx17(PopoverTrigger, { children: renderVariable({
1793
- variable: { name: id, required, valid: true },
1794
- fallback,
1795
- editor,
1796
- from: "content-variable"
1797
- }) }),
1793
+ /* @__PURE__ */ jsx17(
1794
+ PopoverTrigger,
1795
+ {
1796
+ onClick: (e) => {
1797
+ if (!editor.isEditable) {
1798
+ e.preventDefault();
1799
+ return;
1800
+ }
1801
+ },
1802
+ children: renderVariable({
1803
+ variable: { name: id, required, valid: true },
1804
+ fallback,
1805
+ editor,
1806
+ from: "content-variable"
1807
+ })
1808
+ }
1809
+ ),
1798
1810
  /* @__PURE__ */ jsx17(
1799
1811
  PopoverContent,
1800
1812
  {
@@ -1886,10 +1898,12 @@ var DefaultRenderVariable = (props) => {
1886
1898
 
1887
1899
  // src/editor/provider.tsx
1888
1900
  import { jsx as jsx18 } from "react/jsx-runtime";
1901
+ var DEFAULT_PLACEHOLDER_URL = "maily.to/";
1889
1902
  var DEFAULT_VARIABLE_TRIGGER_CHAR = "@";
1890
1903
  var DEFAULT_VARIABLES = [];
1891
1904
  var DEFAULT_RENDER_VARIABLE_FUNCTION = DefaultRenderVariable;
1892
1905
  var MailyContext = createContext({
1906
+ placeholderUrl: DEFAULT_PLACEHOLDER_URL,
1893
1907
  variableTriggerCharacter: DEFAULT_VARIABLE_TRIGGER_CHAR,
1894
1908
  variables: DEFAULT_VARIABLES,
1895
1909
  blocks: DEFAULT_SLASH_COMMANDS,
@@ -2169,7 +2183,8 @@ function LinkInputPopover(props) {
2169
2183
  const {
2170
2184
  variables = [],
2171
2185
  variableTriggerCharacter = DEFAULT_VARIABLE_TRIGGER_CHAR,
2172
- renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION
2186
+ renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION,
2187
+ placeholderUrl = DEFAULT_PLACEHOLDER_URL
2173
2188
  } = useMailyContext();
2174
2189
  const autoCompleteOptions = useMemo2(() => {
2175
2190
  const withoutTrigger = defaultUrlWithoutProtocol.replace(
@@ -2289,7 +2304,7 @@ function LinkInputPopover(props) {
2289
2304
  },
2290
2305
  autoCompleteOptions,
2291
2306
  ref: linkInputRef,
2292
- placeholder: "maily.to/",
2307
+ placeholder: placeholderUrl,
2293
2308
  className: "-mly-ms-px mly-block mly-h-8 mly-w-52 mly-rounded-lg mly-rounded-s-none mly-border mly-border-gray-300 mly-px-2 mly-py-1.5 mly-pr-6 mly-text-sm mly-shadow-sm mly-outline-none placeholder:mly-text-gray-400",
2294
2309
  triggerChar: variableTriggerCharacter,
2295
2310
  onSelectOption: (value) => {
@@ -2500,7 +2515,8 @@ function ButtonLabelInput(props) {
2500
2515
  const {
2501
2516
  variables = [],
2502
2517
  variableTriggerCharacter = DEFAULT_VARIABLE_TRIGGER_CHAR,
2503
- renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION
2518
+ renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION,
2519
+ placeholderUrl = DEFAULT_PLACEHOLDER_URL
2504
2520
  } = useMailyContext();
2505
2521
  const autoCompleteOptions = useMemo4(() => {
2506
2522
  const withoutTrigger = value.replace(
@@ -2544,7 +2560,7 @@ function ButtonLabelInput(props) {
2544
2560
  },
2545
2561
  autoCompleteOptions,
2546
2562
  ref: linkInputRef,
2547
- placeholder: "maily.to/",
2563
+ placeholder: placeholderUrl,
2548
2564
  className: "mly-h-7 mly-w-40 mly-rounded-md mly-px-2 mly-pr-6 mly-text-sm mly-text-midnight-gray hover:mly-bg-soft-gray focus:mly-bg-soft-gray focus:mly-outline-none",
2549
2565
  triggerChar: variableTriggerCharacter,
2550
2566
  onSelectOption: (value2) => {
@@ -2561,6 +2577,7 @@ function ButtonLabelInput(props) {
2561
2577
  }
2562
2578
 
2563
2579
  // src/editor/nodes/button/button-view.tsx
2580
+ import { useMemo as useMemo5 } from "react";
2564
2581
  import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
2565
2582
  function ButtonView(props) {
2566
2583
  const { node, editor, getPos, updateAttributes: updateAttributes2 } = props;
@@ -2574,26 +2591,52 @@ function ButtonView(props) {
2574
2591
  textColor,
2575
2592
  url: externalLink,
2576
2593
  showIfKey = "",
2577
- isUrlVariable
2594
+ isUrlVariable,
2595
+ paddingTop,
2596
+ paddingRight,
2597
+ paddingBottom,
2598
+ paddingLeft
2578
2599
  } = node.attrs;
2579
2600
  const { renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
2601
+ const sizes = useMemo5(
2602
+ () => ({
2603
+ small: {
2604
+ paddingX: 24,
2605
+ paddingY: 6
2606
+ },
2607
+ medium: {
2608
+ paddingX: 32,
2609
+ paddingY: 10
2610
+ },
2611
+ large: {
2612
+ paddingX: 40,
2613
+ paddingY: 14
2614
+ }
2615
+ }),
2616
+ []
2617
+ );
2618
+ const size = useMemo5(() => {
2619
+ var _a;
2620
+ return (_a = Object.entries(sizes).find(
2621
+ ([, { paddingX, paddingY }]) => paddingRight === paddingX && paddingTop === paddingY
2622
+ )) == null ? void 0 : _a[0];
2623
+ }, [paddingRight, paddingTop, sizes]);
2580
2624
  return /* @__PURE__ */ jsx25(
2581
2625
  NodeViewWrapper4,
2582
2626
  {
2583
- draggable: "true",
2584
- "data-drag-handle": "",
2627
+ draggable: editor.isEditable,
2628
+ "data-drag-handle": editor.isEditable,
2585
2629
  "data-type": "button",
2586
2630
  style: {
2587
2631
  textAlign: alignment
2588
2632
  },
2589
- children: /* @__PURE__ */ jsxs12(Popover, { open: props.selected, children: [
2633
+ children: /* @__PURE__ */ jsxs12(Popover, { open: props.selected && editor.isEditable, children: [
2590
2634
  /* @__PURE__ */ jsx25(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(
2591
2635
  "button",
2592
2636
  {
2593
2637
  className: cn(
2594
2638
  "mly-inline-flex mly-items-center mly-justify-center mly-rounded-md mly-text-sm mly-font-medium mly-ring-offset-white mly-transition-colors disabled:mly-pointer-events-none disabled:mly-opacity-50",
2595
- "mly-h-10 mly-px-4 mly-py-2",
2596
- "mly-px-[32px] mly-py-[20px] mly-font-semibold mly-no-underline",
2639
+ "mly-font-semibold mly-no-underline",
2597
2640
  {
2598
2641
  "!mly-rounded-full": _radius === "round",
2599
2642
  "!mly-rounded-md": _radius === "smooth",
@@ -2609,10 +2652,17 @@ function ButtonView(props) {
2609
2652
  borderColor: buttonColor,
2610
2653
  // decrease the border color opacity to 80%
2611
2654
  // so that it's not too prominent
2612
- "--button-var-border-color": `${textColor}80`
2655
+ "--button-var-border-color": `${textColor}80`,
2656
+ paddingTop,
2657
+ paddingRight,
2658
+ paddingBottom,
2659
+ paddingLeft
2613
2660
  },
2614
2661
  onClick: (e) => {
2615
2662
  e.preventDefault();
2663
+ if (!editor.isEditable) {
2664
+ return;
2665
+ }
2616
2666
  const pos = getPos();
2617
2667
  editor.commands.setNodeSelection(pos);
2618
2668
  },
@@ -2685,6 +2735,28 @@ function ButtonView(props) {
2685
2735
  tooltip: "Style",
2686
2736
  className: "mly-capitalize"
2687
2737
  }
2738
+ ),
2739
+ /* @__PURE__ */ jsx25(
2740
+ Select,
2741
+ {
2742
+ label: "Size",
2743
+ value: size,
2744
+ options: [
2745
+ { value: "small", label: "Small" },
2746
+ { value: "medium", label: "Medium" },
2747
+ { value: "large", label: "Large" }
2748
+ ],
2749
+ onValueChange: (value) => {
2750
+ const { paddingX, paddingY } = sizes[value];
2751
+ updateAttributes2({
2752
+ paddingTop: paddingY,
2753
+ paddingRight: paddingX,
2754
+ paddingBottom: paddingY,
2755
+ paddingLeft: paddingX
2756
+ });
2757
+ },
2758
+ tooltip: "Size"
2759
+ }
2688
2760
  )
2689
2761
  ] }),
2690
2762
  /* @__PURE__ */ jsx25(Divider, {}),
@@ -2823,6 +2895,10 @@ var DEFAULT_BUTTON_VARIANT = "filled";
2823
2895
  var DEFAULT_BUTTON_BORDER_RADIUS = "smooth";
2824
2896
  var DEFAULT_BUTTON_BACKGROUND_COLOR = "#000000";
2825
2897
  var DEFAULT_BUTTON_TEXT_COLOR = "#ffffff";
2898
+ var DEFAULT_BUTTON_PADDING_TOP = 10;
2899
+ var DEFAULT_BUTTON_PADDING_RIGHT = 32;
2900
+ var DEFAULT_BUTTON_PADDING_BOTTOM = 10;
2901
+ var DEFAULT_BUTTON_PADDING_LEFT = 32;
2826
2902
  var allowedButtonVariant = ["filled", "outline"];
2827
2903
  var allowedButtonBorderRadius = ["sharp", "smooth", "round"];
2828
2904
  var ButtonExtension = Node9.create({
@@ -2953,6 +3029,62 @@ var ButtonExtension = Node9.create({
2953
3029
  "data-show-if-key": attributes.showIfKey
2954
3030
  };
2955
3031
  }
3032
+ },
3033
+ paddingTop: {
3034
+ default: DEFAULT_BUTTON_PADDING_TOP,
3035
+ parseHTML: (element) => {
3036
+ return parseInt(
3037
+ element.getAttribute("data-padding-top") || DEFAULT_BUTTON_PADDING_TOP.toString(),
3038
+ 10
3039
+ );
3040
+ },
3041
+ renderHTML: (attributes) => {
3042
+ return {
3043
+ "data-padding-top": attributes.paddingTop
3044
+ };
3045
+ }
3046
+ },
3047
+ paddingRight: {
3048
+ default: DEFAULT_BUTTON_PADDING_RIGHT,
3049
+ parseHTML: (element) => {
3050
+ return parseInt(
3051
+ element.getAttribute("data-padding-right") || DEFAULT_BUTTON_PADDING_RIGHT.toString(),
3052
+ 10
3053
+ );
3054
+ },
3055
+ renderHTML: (attributes) => {
3056
+ return {
3057
+ "data-padding-right": attributes.paddingRight
3058
+ };
3059
+ }
3060
+ },
3061
+ paddingBottom: {
3062
+ default: DEFAULT_BUTTON_PADDING_BOTTOM,
3063
+ parseHTML: (element) => {
3064
+ return parseInt(
3065
+ element.getAttribute("data-padding-bottom") || DEFAULT_BUTTON_PADDING_BOTTOM.toString(),
3066
+ 10
3067
+ );
3068
+ },
3069
+ renderHTML: (attributes) => {
3070
+ return {
3071
+ "data-padding-bottom": attributes.paddingBottom
3072
+ };
3073
+ }
3074
+ },
3075
+ paddingLeft: {
3076
+ default: DEFAULT_BUTTON_PADDING_LEFT,
3077
+ parseHTML: (element) => {
3078
+ return parseInt(
3079
+ element.getAttribute("data-padding-left") || DEFAULT_BUTTON_PADDING_LEFT.toString(),
3080
+ 10
3081
+ );
3082
+ },
3083
+ renderHTML: (attributes) => {
3084
+ return {
3085
+ "data-padding-left": attributes.paddingLeft
3086
+ };
3087
+ }
2956
3088
  }
2957
3089
  };
2958
3090
  },
@@ -3023,7 +3155,7 @@ import { Fragment as Fragment3, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-r
3023
3155
  var MIN_WIDTH = 20;
3024
3156
  var MAX_WIDTH = 600;
3025
3157
  function ImageView(props) {
3026
- const { node, updateAttributes: updateAttributes2, selected } = props;
3158
+ const { node, updateAttributes: updateAttributes2, selected, editor } = props;
3027
3159
  const [status, setStatus] = useState6("idle");
3028
3160
  const wrapperRef = useRef7(null);
3029
3161
  const imgRef = useRef7(null);
@@ -3139,8 +3271,8 @@ function ImageView(props) {
3139
3271
  NodeViewWrapper5,
3140
3272
  {
3141
3273
  as: "div",
3142
- draggable: true,
3143
- "data-drag-handle": true,
3274
+ draggable: editor.isEditable,
3275
+ "data-drag-handle": editor.isEditable,
3144
3276
  style: __spreadValues(__spreadProps(__spreadValues({}, hasImageSrc && status === "loaded" ? __spreadValues({
3145
3277
  width: `${width}px`,
3146
3278
  height: `${height}px`
@@ -3169,10 +3301,11 @@ function ImageView(props) {
3169
3301
  style: __spreadProps(__spreadValues({}, resizingStyle), {
3170
3302
  cursor: "default",
3171
3303
  marginBottom: 0
3172
- })
3304
+ }),
3305
+ draggable: editor.isEditable
3173
3306
  })
3174
3307
  ),
3175
- selected && /* @__PURE__ */ jsxs13(Fragment3, { children: [
3308
+ selected && editor.isEditable && /* @__PURE__ */ jsxs13(Fragment3, { children: [
3176
3309
  [
3177
3310
  { left: 0, top: 0, height: "100%", width: "1px" },
3178
3311
  { right: 0, top: 0, height: "100%", width: "1px" },
@@ -3235,7 +3368,7 @@ function ImageStatusLabel(props) {
3235
3368
  // src/editor/nodes/logo/logo-view.tsx
3236
3369
  import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
3237
3370
  function LogoView(props) {
3238
- const { node } = props;
3371
+ const { node, editor } = props;
3239
3372
  const [status, setStatus] = useState7("idle");
3240
3373
  let {
3241
3374
  alignment = "center",
@@ -3268,8 +3401,8 @@ function LogoView(props) {
3268
3401
  NodeViewWrapper6,
3269
3402
  {
3270
3403
  as: "div",
3271
- draggable: true,
3272
- "data-drag-handle": true,
3404
+ draggable: editor.isEditable,
3405
+ "data-drag-handle": editor.isEditable,
3273
3406
  style: {
3274
3407
  overflow: "hidden",
3275
3408
  position: "relative",
@@ -3296,7 +3429,8 @@ function LogoView(props) {
3296
3429
  center: { marginLeft: "auto", marginRight: "auto" },
3297
3430
  left: { marginRight: "auto" },
3298
3431
  right: { marginLeft: "auto" }
3299
- }[alignment] || {})
3432
+ }[alignment] || {}),
3433
+ draggable: editor.isEditable
3300
3434
  }
3301
3435
  )
3302
3436
  ]
@@ -3528,6 +3662,54 @@ var LinkExtension = TiptapLink.extend({
3528
3662
  }
3529
3663
  });
3530
3664
 
3665
+ // src/editor/nodes/heading/heading.ts
3666
+ import TiptapHeading from "@tiptap/extension-heading";
3667
+ var HeadingExtension = TiptapHeading.extend({
3668
+ addAttributes() {
3669
+ var _a;
3670
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
3671
+ showIfKey: {
3672
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
3673
+ parseHTML: (element) => {
3674
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
3675
+ },
3676
+ renderHTML(attributes) {
3677
+ if (!attributes.showIfKey) {
3678
+ return {};
3679
+ }
3680
+ return {
3681
+ "data-show-if-key": attributes.showIfKey
3682
+ };
3683
+ }
3684
+ }
3685
+ });
3686
+ }
3687
+ });
3688
+
3689
+ // src/editor/nodes/paragraph/paragraph.ts
3690
+ import TiptapParagraph from "@tiptap/extension-paragraph";
3691
+ var ParagraphExtension = TiptapParagraph.extend({
3692
+ addAttributes() {
3693
+ var _a;
3694
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
3695
+ showIfKey: {
3696
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
3697
+ parseHTML: (element) => {
3698
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
3699
+ },
3700
+ renderHTML(attributes) {
3701
+ if (!attributes.showIfKey) {
3702
+ return {};
3703
+ }
3704
+ return {
3705
+ "data-show-if-key": attributes.showIfKey
3706
+ };
3707
+ }
3708
+ }
3709
+ });
3710
+ }
3711
+ });
3712
+
3531
3713
  // src/editor/extensions/maily-kit.tsx
3532
3714
  var MailyKit = Extension.create({
3533
3715
  name: "maily-kit",
@@ -3549,12 +3731,6 @@ var MailyKit = Extension.create({
3549
3731
  content: "(block|columns)+"
3550
3732
  }),
3551
3733
  StarterKit.configure({
3552
- heading: {
3553
- levels: [1, 2, 3],
3554
- HTMLAttributes: {
3555
- class: "mly-relative"
3556
- }
3557
- },
3558
3734
  code: {
3559
3735
  HTMLAttributes: {
3560
3736
  class: "mly-px-1 mly-relative mly-py-0.5 mly-bg-[#efefef] mly-text-sm mly-rounded-md mly-tracking-normal mly-font-normal"
@@ -3565,11 +3741,6 @@ var MailyKit = Extension.create({
3565
3741
  class: "mly-not-prose mly-border-l-4 mly-border-gray-300 mly-pl-4 mly-mt-4 mly-mb-4 mly-relative"
3566
3742
  }
3567
3743
  },
3568
- paragraph: {
3569
- HTMLAttributes: {
3570
- class: "mly-relative"
3571
- }
3572
- },
3573
3744
  bulletList: {
3574
3745
  HTMLAttributes: {
3575
3746
  class: "mly-relative"
@@ -3580,6 +3751,8 @@ var MailyKit = Extension.create({
3580
3751
  class: "mly-relative"
3581
3752
  }
3582
3753
  },
3754
+ heading: false,
3755
+ paragraph: false,
3583
3756
  horizontalRule: false,
3584
3757
  dropcursor: false,
3585
3758
  document: false
@@ -3615,6 +3788,17 @@ var MailyKit = Extension.create({
3615
3788
  color: "#555",
3616
3789
  width: 3,
3617
3790
  class: "ProseMirror-dropcursor"
3791
+ }),
3792
+ HeadingExtension.configure({
3793
+ levels: [1, 2, 3],
3794
+ HTMLAttributes: {
3795
+ class: "mly-relative"
3796
+ }
3797
+ }),
3798
+ ParagraphExtension.configure({
3799
+ HTMLAttributes: {
3800
+ class: "mly-relative"
3801
+ }
3618
3802
  })
3619
3803
  ];
3620
3804
  if (this.options.linkCard !== false) {
@@ -4133,6 +4317,10 @@ export {
4133
4317
  DEFAULT_BUTTON_ALIGNMENT,
4134
4318
  DEFAULT_BUTTON_BACKGROUND_COLOR,
4135
4319
  DEFAULT_BUTTON_BORDER_RADIUS,
4320
+ DEFAULT_BUTTON_PADDING_BOTTOM,
4321
+ DEFAULT_BUTTON_PADDING_LEFT,
4322
+ DEFAULT_BUTTON_PADDING_RIGHT,
4323
+ DEFAULT_BUTTON_PADDING_TOP,
4136
4324
  DEFAULT_BUTTON_TEXT_COLOR,
4137
4325
  DEFAULT_BUTTON_VARIANT,
4138
4326
  DEFAULT_COLUMNS_GAP,