@maily-to/core 0.3.4 → 0.3.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.
@@ -216,6 +216,16 @@ declare module '@tiptap/core' {
216
216
  }
217
217
  declare const ColumnsExtension: Node<any, any>;
218
218
 
219
+ declare const allowedTextDirection: readonly ["ltr", "rtl"];
220
+ type AllowedTextDirection = (typeof allowedTextDirection)[number];
221
+ declare module '@tiptap/core' {
222
+ interface Commands<ReturnType> {
223
+ textDirection: {
224
+ setTextDirection: (direction: AllowedTextDirection) => ReturnType;
225
+ };
226
+ }
227
+ }
228
+
219
229
  interface FooterOptions {
220
230
  HTMLAttributes: Record<string, any>;
221
231
  }
@@ -223,6 +233,7 @@ declare module '@tiptap/core' {
223
233
  interface Commands<ReturnType> {
224
234
  footer: {
225
235
  setFooter: () => ReturnType;
236
+ setFooterTextDirection: (direction: AllowedTextDirection) => ReturnType;
226
237
  };
227
238
  }
228
239
  }
@@ -216,6 +216,16 @@ declare module '@tiptap/core' {
216
216
  }
217
217
  declare const ColumnsExtension: Node<any, any>;
218
218
 
219
+ declare const allowedTextDirection: readonly ["ltr", "rtl"];
220
+ type AllowedTextDirection = (typeof allowedTextDirection)[number];
221
+ declare module '@tiptap/core' {
222
+ interface Commands<ReturnType> {
223
+ textDirection: {
224
+ setTextDirection: (direction: AllowedTextDirection) => ReturnType;
225
+ };
226
+ }
227
+ }
228
+
219
229
  interface FooterOptions {
220
230
  HTMLAttributes: Record<string, any>;
221
231
  }
@@ -223,6 +233,7 @@ declare module '@tiptap/core' {
223
233
  interface Commands<ReturnType> {
224
234
  footer: {
225
235
  setFooter: () => ReturnType;
236
+ setFooterTextDirection: (direction: AllowedTextDirection) => ReturnType;
226
237
  };
227
238
  }
228
239
  }
@@ -239,47 +239,10 @@ import Focus from "@tiptap/extension-focus";
239
239
  import Dropcursor from "@tiptap/extension-dropcursor";
240
240
 
241
241
  // src/editor/nodes/footer.ts
242
- import { mergeAttributes, Node } from "@tiptap/core";
243
- var Footer = Node.create({
244
- name: "footer",
245
- group: "block",
246
- content: "inline*",
247
- addAttributes() {
248
- return {
249
- "maily-component": {
250
- default: "footer",
251
- renderHTML: (attributes) => {
252
- return {
253
- "data-maily-component": attributes["maily-component"]
254
- };
255
- },
256
- parseHTML: (element) => element == null ? void 0 : element.getAttribute("data-maily-component")
257
- }
258
- };
259
- },
260
- addCommands() {
261
- return {
262
- setFooter: () => ({ commands }) => {
263
- return commands.setNode(this.name);
264
- }
265
- };
266
- },
267
- parseHTML() {
268
- return [{ tag: 'small[data-maily-component="footer"]' }];
269
- },
270
- renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
271
- return [
272
- "small",
273
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes2, {
274
- class: "footer mly:block mly:text-[13px] mly:text-slate-500 mly:relative"
275
- }),
276
- 0
277
- ];
278
- }
279
- });
242
+ import { mergeAttributes as mergeAttributes2, Node as Node2 } from "@tiptap/core";
280
243
 
281
- // src/editor/nodes/spacer.ts
282
- import { mergeAttributes as mergeAttributes3, Node as Node3 } from "@tiptap/core";
244
+ // src/editor/nodes/paragraph/paragraph.ts
245
+ import TiptapParagraph from "@tiptap/extension-paragraph";
283
246
 
284
247
  // src/editor/utils/update-attribute.ts
285
248
  function updateAttributes(type, attrs) {
@@ -316,7 +279,7 @@ function updateAttributes(type, attrs) {
316
279
  }
317
280
 
318
281
  // src/editor/nodes/section/section.ts
319
- import { mergeAttributes as mergeAttributes2, Node as Node2 } from "@tiptap/core";
282
+ import { mergeAttributes, Node } from "@tiptap/core";
320
283
  var DEFAULT_SECTION_BACKGROUND_COLOR = "#f7f7f7";
321
284
  var DEFAULT_SECTION_ALIGN = "left";
322
285
  var DEFAULT_SECTION_BORDER_WIDTH = 2;
@@ -331,7 +294,7 @@ var DEFAULT_SECTION_PADDING_RIGHT = 0;
331
294
  var DEFAULT_SECTION_PADDING_BOTTOM = 0;
332
295
  var DEFAULT_SECTION_PADDING_LEFT = 0;
333
296
  var DEFAULT_SECTION_SHOW_IF_KEY = null;
334
- var SectionExtension = Node2.create({
297
+ var SectionExtension = Node.create({
335
298
  name: "section",
336
299
  group: "block",
337
300
  content: "(block|columns)+",
@@ -594,7 +557,7 @@ var SectionExtension = Node2.create({
594
557
  },
595
558
  [
596
559
  "td",
597
- mergeAttributes2(HTMLAttributes2, {
560
+ mergeAttributes(HTMLAttributes2, {
598
561
  "data-type": "section-cell",
599
562
  style: "border-style: solid",
600
563
  class: "mly:w-full mly:[text-align:revert-layer]"
@@ -614,7 +577,116 @@ var SectionExtension = Node2.create({
614
577
  }
615
578
  });
616
579
 
580
+ // src/editor/nodes/paragraph/paragraph.ts
581
+ var DEFAULT_TEXT_DIRECTION = "ltr";
582
+ var ParagraphExtension = TiptapParagraph.extend({
583
+ addAttributes() {
584
+ var _a;
585
+ return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
586
+ textDirection: {
587
+ default: DEFAULT_TEXT_DIRECTION,
588
+ parseHTML: (element) => {
589
+ return element.getAttribute("data-text-direction") || element.getAttribute("dir") || DEFAULT_TEXT_DIRECTION;
590
+ },
591
+ renderHTML(attributes) {
592
+ if (!attributes.textDirection || attributes.textDirection === DEFAULT_TEXT_DIRECTION) {
593
+ return {};
594
+ }
595
+ return {
596
+ "data-text-direction": attributes.textDirection,
597
+ dir: attributes.textDirection
598
+ };
599
+ }
600
+ },
601
+ showIfKey: {
602
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
603
+ parseHTML: (element) => {
604
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
605
+ },
606
+ renderHTML(attributes) {
607
+ if (!attributes.showIfKey) {
608
+ return {};
609
+ }
610
+ return {
611
+ "data-show-if-key": attributes.showIfKey
612
+ };
613
+ }
614
+ }
615
+ });
616
+ },
617
+ addCommands() {
618
+ var _a;
619
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
620
+ setTextDirection: (direction) => ({ commands }) => {
621
+ return commands.updateAttributes(this.name, {
622
+ textDirection: direction
623
+ });
624
+ }
625
+ });
626
+ }
627
+ });
628
+
629
+ // src/editor/nodes/footer.ts
630
+ var Footer = Node2.create({
631
+ name: "footer",
632
+ group: "block",
633
+ content: "inline*",
634
+ addAttributes() {
635
+ return {
636
+ "maily-component": {
637
+ default: "footer",
638
+ renderHTML: (attributes) => {
639
+ return {
640
+ "data-maily-component": attributes["maily-component"]
641
+ };
642
+ },
643
+ parseHTML: (element) => element == null ? void 0 : element.getAttribute("data-maily-component")
644
+ },
645
+ textDirection: {
646
+ default: DEFAULT_TEXT_DIRECTION,
647
+ parseHTML: (element) => {
648
+ return element.getAttribute("data-text-direction") || element.getAttribute("dir") || DEFAULT_TEXT_DIRECTION;
649
+ },
650
+ renderHTML(attributes) {
651
+ if (!attributes.textDirection || attributes.textDirection === DEFAULT_TEXT_DIRECTION) {
652
+ return {};
653
+ }
654
+ return {
655
+ "data-text-direction": attributes.textDirection,
656
+ dir: attributes.textDirection
657
+ };
658
+ }
659
+ }
660
+ };
661
+ },
662
+ addCommands() {
663
+ return {
664
+ setFooter: () => ({ commands }) => {
665
+ return commands.setNode(this.name);
666
+ },
667
+ setFooterTextDirection: (direction) => ({ commands }) => {
668
+ return commands.updateAttributes("footer", {
669
+ textDirection: direction
670
+ });
671
+ }
672
+ };
673
+ },
674
+ parseHTML() {
675
+ return [{ tag: 'small[data-maily-component="footer"]' }];
676
+ },
677
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
678
+ return [
679
+ "small",
680
+ mergeAttributes2(this.options.HTMLAttributes, HTMLAttributes2, {
681
+ class: "footer mly:block mly:text-[13px] mly:text-slate-500 mly:relative"
682
+ }),
683
+ 0
684
+ ];
685
+ }
686
+ });
687
+
617
688
  // src/editor/nodes/spacer.ts
689
+ import { mergeAttributes as mergeAttributes3, Node as Node3 } from "@tiptap/core";
618
690
  var DEFAULT_SPACER_HEIGHT = 8;
619
691
  var Spacer = Node3.create({
620
692
  name: "spacer",
@@ -4498,7 +4570,8 @@ function ImageView(props) {
4498
4570
  newHeight = IMAGE_MAX_HEIGHT;
4499
4571
  }
4500
4572
  if (node.attrs.lockAspectRatio) {
4501
- newHeight = getNewHeight(newWidth, node.attrs.aspectRatio);
4573
+ const aspectRatio = node.attrs.aspectRatio && isFinite(node.attrs.aspectRatio) && node.attrs.aspectRatio > 0 ? node.attrs.aspectRatio : currentWidth / currentHeight;
4574
+ newHeight = getNewHeight(newWidth, aspectRatio);
4502
4575
  }
4503
4576
  setResizingStyle({ width: newWidth, height: newHeight });
4504
4577
  if (!event2.buttons) {
@@ -4674,8 +4747,8 @@ function ImageView(props) {
4674
4747
  "data-drag-handle": editor.isEditable,
4675
4748
  className: cn("mly-image-drop-zone", isDraggingOver && "mly-drag-over"),
4676
4749
  style: __spreadValues(__spreadProps(__spreadValues({}, hasImageSrc && status === "loaded" ? __spreadValues({
4677
- width: width ? `${width}px` : void 0,
4678
- height: height ? `${height}px` : void 0
4750
+ width: width && width !== "auto" ? `${width}px` : void 0,
4751
+ height: height && height !== "auto" ? `${height}px` : void 0
4679
4752
  }, resizingStyle) : {}), {
4680
4753
  overflow: "hidden",
4681
4754
  position: "relative",
@@ -4727,8 +4800,8 @@ function ImageView(props) {
4727
4800
  objectFit: "fill",
4728
4801
  marginBottom: 0,
4729
4802
  borderRadius,
4730
- width: (resizingStyle == null ? void 0 : resizingStyle.width) ? `${resizingStyle.width}px` : width ? `${width}px` : "auto",
4731
- height: (resizingStyle == null ? void 0 : resizingStyle.height) ? `${resizingStyle.height}px` : height ? `${height}px` : "auto"
4803
+ width: (resizingStyle == null ? void 0 : resizingStyle.width) ? `${resizingStyle.width}px` : width && width !== "auto" ? `${width}px` : "auto",
4804
+ height: (resizingStyle == null ? void 0 : resizingStyle.height) ? `${resizingStyle.height}px` : height && height !== "auto" ? `${height}px` : "auto"
4732
4805
  }),
4733
4806
  draggable: editor.isEditable,
4734
4807
  className: cn(
@@ -7862,30 +7935,21 @@ var HeadingExtension = TiptapHeading.extend({
7862
7935
  addAttributes() {
7863
7936
  var _a;
7864
7937
  return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
7865
- showIfKey: {
7866
- default: DEFAULT_SECTION_SHOW_IF_KEY,
7938
+ textDirection: {
7939
+ default: DEFAULT_TEXT_DIRECTION,
7867
7940
  parseHTML: (element) => {
7868
- return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
7941
+ return element.getAttribute("data-text-direction") || element.getAttribute("dir") || DEFAULT_TEXT_DIRECTION;
7869
7942
  },
7870
7943
  renderHTML(attributes) {
7871
- if (!attributes.showIfKey) {
7944
+ if (!attributes.textDirection || attributes.textDirection === DEFAULT_TEXT_DIRECTION) {
7872
7945
  return {};
7873
7946
  }
7874
7947
  return {
7875
- "data-show-if-key": attributes.showIfKey
7948
+ "data-text-direction": attributes.textDirection,
7949
+ dir: attributes.textDirection
7876
7950
  };
7877
7951
  }
7878
- }
7879
- });
7880
- }
7881
- });
7882
-
7883
- // src/editor/nodes/paragraph/paragraph.ts
7884
- import TiptapParagraph from "@tiptap/extension-paragraph";
7885
- var ParagraphExtension = TiptapParagraph.extend({
7886
- addAttributes() {
7887
- var _a;
7888
- return __spreadProps(__spreadValues({}, ((_a = this == null ? void 0 : this.parent) == null ? void 0 : _a.call(this)) || {}), {
7952
+ },
7889
7953
  showIfKey: {
7890
7954
  default: DEFAULT_SECTION_SHOW_IF_KEY,
7891
7955
  parseHTML: (element) => {