@blocknote/xl-email-exporter 0.45.0 → 0.46.0

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.
@@ -1,8 +1,8 @@
1
1
  import { jsx as n, jsxs as h } from "react/jsx-runtime";
2
- import { mapTableCell as V, Exporter as R, COLORS_DEFAULT as E } from "@blocknote/core";
3
- import { Text as f, Img as A, CodeBlock as D, dracula as F, Heading as W, Link as k, Section as v, Html as Z, Head as z, Body as N, Preview as _, Tailwind as O } from "@react-email/components";
4
- import { render as P } from "@react-email/render";
5
- import I from "react";
2
+ import { mapTableCell as T, Exporter as V, COLORS_DEFAULT as R } from "@blocknote/core";
3
+ import { Text as f, Img as E, CodeBlock as A, dracula as D, Heading as F, Link as I, Section as W, Html as Z, Head as z, Body as O, Preview as j, Tailwind as _ } from "@react-email/components";
4
+ import { render as N } from "@react-email/render";
5
+ import L from "react";
6
6
  const g = {
7
7
  fontSize: 16,
8
8
  lineHeight: 1.5,
@@ -75,7 +75,7 @@ const g = {
75
75
  codeBlock: {
76
76
  style: g
77
77
  }
78
- }, H = (r = m) => ({
78
+ }, k = (r = m) => ({
79
79
  paragraph: (e, t) => {
80
80
  var l;
81
81
  return /* @__PURE__ */ n(
@@ -119,22 +119,22 @@ const g = {
119
119
  );
120
120
  },
121
121
  numberedListItem: (e, t, l) => {
122
- var o;
122
+ var i;
123
123
  return /* @__PURE__ */ n(
124
124
  f,
125
125
  {
126
126
  ...r.numberedListItem,
127
127
  style: {
128
128
  ...m.numberedListItem.style,
129
- ...(o = r.numberedListItem) == null ? void 0 : o.style
129
+ ...(i = r.numberedListItem) == null ? void 0 : i.style
130
130
  },
131
131
  children: t.transformInlineContent(e.content)
132
132
  }
133
133
  );
134
134
  },
135
135
  checkListItem: (e, t) => {
136
- var i, a;
137
- const o = ((i = e.props) == null ? void 0 : i.checked) ? /* @__PURE__ */ h(
136
+ var o, a;
137
+ const i = ((o = e.props) == null ? void 0 : o.checked) ? /* @__PURE__ */ h(
138
138
  "svg",
139
139
  {
140
140
  width: "18",
@@ -197,7 +197,7 @@ const g = {
197
197
  ...(a = r.checkListItem) == null ? void 0 : a.style
198
198
  },
199
199
  children: [
200
- o,
200
+ i,
201
201
  /* @__PURE__ */ n("span", { children: t.transformInlineContent(e.content) })
202
202
  ]
203
203
  }
@@ -206,7 +206,7 @@ const g = {
206
206
  heading: (e, t) => {
207
207
  var l;
208
208
  return /* @__PURE__ */ n(
209
- W,
209
+ F,
210
210
  {
211
211
  as: `h${e.props.level}`,
212
212
  ...r[`heading${e.props.level}`],
@@ -219,19 +219,19 @@ const g = {
219
219
  );
220
220
  },
221
221
  codeBlock: (e) => {
222
- var l, o;
222
+ var l, i;
223
223
  const t = ((l = e.content[0]) == null ? void 0 : l.text) || "";
224
224
  return /* @__PURE__ */ n(
225
- D,
225
+ A,
226
226
  {
227
227
  code: t,
228
228
  fontFamily: "'CommitMono', monospace",
229
229
  language: e.props.language,
230
- theme: F,
230
+ theme: D,
231
231
  ...r.codeBlock,
232
232
  style: {
233
233
  ...m.codeBlock.style,
234
- ...(o = r.codeBlock) == null ? void 0 : o.style
234
+ ...(i = r.codeBlock) == null ? void 0 : i.style
235
235
  }
236
236
  }
237
237
  );
@@ -333,7 +333,7 @@ const g = {
333
333
  ] });
334
334
  },
335
335
  image: (e) => /* @__PURE__ */ n(
336
- A,
336
+ E,
337
337
  {
338
338
  src: e.props.url,
339
339
  width: e.props.previewWidth,
@@ -344,7 +344,7 @@ const g = {
344
344
  const l = e.content;
345
345
  if (!l || typeof l != "object" || !Array.isArray(l.rows))
346
346
  return /* @__PURE__ */ n(f, { ...r.tableError, children: "Table data not available" });
347
- const o = l.headerRows ?? 0, i = l.headerCols ?? 0;
347
+ const i = l.headerRows ?? 0, o = l.headerCols ?? 0;
348
348
  return /* @__PURE__ */ n(
349
349
  "table",
350
350
  {
@@ -359,33 +359,33 @@ const g = {
359
359
  border: 0,
360
360
  cellPadding: 0,
361
361
  cellSpacing: 0,
362
- children: /* @__PURE__ */ n("tbody", { children: l.rows.map((a, p) => /* @__PURE__ */ n("tr", { children: a.cells.map((u, s) => {
363
- var L;
364
- const c = V(u), d = p < o, b = s < i, C = d || b;
362
+ children: /* @__PURE__ */ n("tbody", { children: l.rows.map((a, s) => /* @__PURE__ */ n("tr", { children: a.cells.map((u, c) => {
363
+ var v;
364
+ const d = T(u), p = s < i, b = c < o, C = p || b;
365
365
  return /* @__PURE__ */ n(
366
366
  C ? "th" : "td",
367
367
  {
368
368
  style: {
369
369
  border: "1px solid #ddd",
370
370
  padding: "8px 12px",
371
- background: c.props.backgroundColor !== "default" ? t.options.colors[c.props.backgroundColor].background : "inherit",
371
+ background: d.props.backgroundColor !== "default" ? t.options.colors[d.props.backgroundColor].background : "inherit",
372
372
  fontWeight: C ? "bold" : void 0,
373
- textAlign: c.props.textAlignment || "left",
374
- color: c.props.textColor !== "default" ? t.options.colors[c.props.textColor].text : "inherit",
373
+ textAlign: d.props.textAlignment || "left",
374
+ color: d.props.textColor !== "default" ? t.options.colors[d.props.textColor].text : "inherit",
375
375
  ...m.tableCell.style,
376
- ...(L = r.tableCell) == null ? void 0 : L.style
376
+ ...(v = r.tableCell) == null ? void 0 : v.style
377
377
  },
378
- ...(c.props.colspan || 1) > 1 && {
379
- colSpan: c.props.colspan || 1
378
+ ...(d.props.colspan || 1) > 1 && {
379
+ colSpan: d.props.colspan || 1
380
380
  },
381
- ...(c.props.rowspan || 1) > 1 && {
382
- rowSpan: c.props.rowspan || 1
381
+ ...(d.props.rowspan || 1) > 1 && {
382
+ rowSpan: d.props.rowspan || 1
383
383
  },
384
- children: t.transformInlineContent(c.content)
384
+ children: t.transformInlineContent(d.content)
385
385
  },
386
- "row_" + p + "_col_" + s
386
+ "row_" + s + "_col_" + c
387
387
  );
388
- }) }, "row-" + p)) })
388
+ }) }, "row-" + s)) })
389
389
  }
390
390
  );
391
391
  },
@@ -428,7 +428,7 @@ const g = {
428
428
  }
429
429
  }
430
430
  )
431
- }), j = H();
431
+ }), P = k();
432
432
  function w({
433
433
  url: r,
434
434
  name: e,
@@ -436,7 +436,7 @@ function w({
436
436
  icon: l
437
437
  }) {
438
438
  return /* @__PURE__ */ h(
439
- k,
439
+ I,
440
440
  {
441
441
  href: r,
442
442
  style: {
@@ -476,14 +476,14 @@ function x({
476
476
  }
477
477
  ) : null;
478
478
  }
479
- const S = {
479
+ const H = {
480
480
  link: {}
481
- }, M = (r = S) => ({
482
- link: (e, t) => /* @__PURE__ */ h(k, { href: e.href, ...r.link, children: [
481
+ }, S = (r = H) => ({
482
+ link: (e, t) => /* @__PURE__ */ h(I, { href: e.href, ...r.link, children: [
483
483
  ...e.content.map((l) => t.transformStyledText(l))
484
484
  ] }),
485
485
  text: (e, t) => t.transformStyledText(e)
486
- }), q = M(), B = {}, T = (r = B) => ({
486
+ }), q = S(), M = {}, B = (r = M) => ({
487
487
  bold: (e) => e ? {
488
488
  fontWeight: "bold"
489
489
  } : {},
@@ -506,34 +506,34 @@ const S = {
506
506
  code: (e) => e ? {
507
507
  fontFamily: "GeistMono"
508
508
  } : {}
509
- }), $ = T(), G = {
509
+ }), $ = B(), G = {
510
510
  textStyles: m,
511
- linkStyles: S,
512
- styleTransformStyles: B
511
+ linkStyles: H,
512
+ styleTransformStyles: M
513
513
  }, Y = {
514
- blockMapping: j,
514
+ blockMapping: P,
515
515
  inlineContentMapping: q,
516
516
  styleMapping: $
517
517
  }, ee = (r = G) => ({
518
- blockMapping: H(
518
+ blockMapping: k(
519
519
  r.textStyles
520
520
  ),
521
- inlineContentMapping: M(
521
+ inlineContentMapping: S(
522
522
  r.linkStyles
523
523
  ),
524
- styleMapping: T(
524
+ styleMapping: B(
525
525
  r.styleTransformStyles
526
526
  )
527
527
  });
528
- class te extends R {
528
+ class te extends V {
529
529
  constructor(e, t, l) {
530
- const i = {
530
+ const o = {
531
531
  ...{
532
- colors: E
532
+ colors: R
533
533
  },
534
534
  ...l
535
535
  };
536
- super(e, t, i), this.schema = e;
536
+ super(e, t, o), this.schema = e;
537
537
  }
538
538
  transformStyledText(e) {
539
539
  const t = this.mapStyles(e.styles), l = Object.assign({}, ...t);
@@ -548,78 +548,78 @@ class te extends R {
548
548
  );
549
549
  }
550
550
  async renderGroupedListBlocks(e, t, l) {
551
- const o = e[t].type, i = [];
551
+ const i = e[t].type, o = [];
552
552
  let a = t;
553
- for (let u = 1; a < e.length && e[a].type === o; a++, u++) {
554
- const s = e[a], c = await this.mapBlock(
555
- s,
553
+ for (let u = 1; a < e.length && e[a].type === i; a++, u++) {
554
+ const c = e[a], d = await this.mapBlock(
555
+ c,
556
556
  l,
557
557
  u
558
558
  );
559
- let d = [];
560
- s.children && s.children.length > 0 && (d = await this.renderNestedLists(
561
- s.children,
559
+ let p = [];
560
+ c.children && c.children.length > 0 && (p = await this.renderNestedLists(
561
+ c.children,
562
562
  l + 1,
563
- s.id
564
- )), i.push(
563
+ c.id
564
+ )), o.push(
565
565
  /* @__PURE__ */ h("li", { children: [
566
- c,
567
- d.length > 0 && d
568
- ] }, s.id)
566
+ d,
567
+ p.length > 0 && p
568
+ ] }, c.id)
569
569
  );
570
570
  }
571
- let p;
572
- return o === "bulletListItem" || o === "toggleListItem" ? p = /* @__PURE__ */ n("ul", { className: "mb-2 list-disc pl-6", children: i }, e[t].id + "-ul") : p = /* @__PURE__ */ n(
571
+ let s;
572
+ return i === "bulletListItem" || i === "toggleListItem" ? s = /* @__PURE__ */ n("ul", { className: "mb-2 list-disc pl-6", children: o }, e[t].id + "-ul") : s = /* @__PURE__ */ n(
573
573
  "ol",
574
574
  {
575
575
  className: "mb-2 list-decimal pl-6",
576
576
  start: 1,
577
- children: i
577
+ children: o
578
578
  },
579
579
  e[t].id + "-ol"
580
- ), { element: p, nextIndex: a };
580
+ ), { element: s, nextIndex: a };
581
581
  }
582
582
  async renderNestedLists(e, t, l) {
583
- const o = [];
584
- let i = 0;
585
- for (; i < e.length; ) {
586
- const a = e[i];
583
+ const i = [];
584
+ let o = 0;
585
+ for (; o < e.length; ) {
586
+ const a = e[o];
587
587
  if (a.type === "bulletListItem" || a.type === "numberedListItem") {
588
- const p = a.type, u = [];
589
- let s = i;
590
- for (let c = 1; s < e.length && e[s].type === p; s++, c++) {
591
- const d = e[s], b = await this.mapBlock(
592
- d,
588
+ const s = a.type, u = [];
589
+ let c = o;
590
+ for (let d = 1; c < e.length && e[c].type === s; c++, d++) {
591
+ const p = e[c], b = await this.mapBlock(
592
+ p,
593
593
  t,
594
- c
594
+ d
595
595
  ), C = this.blocknoteDefaultPropsToReactEmailStyle(
596
- d.props
596
+ p.props
597
597
  );
598
598
  let y = [];
599
- d.children && d.children.length > 0 && (d.children[0] && (d.children[0].type === "bulletListItem" || d.children[0].type === "numberedListItem") ? y = await this.renderNestedLists(
600
- d.children,
599
+ p.children && p.children.length > 0 && (p.children[0] && (p.children[0].type === "bulletListItem" || p.children[0].type === "numberedListItem") ? y = await this.renderNestedLists(
600
+ p.children,
601
601
  t + 1,
602
- d.id
602
+ p.id
603
603
  ) : y = await this.transformBlocks(
604
- d.children,
604
+ p.children,
605
605
  t + 1
606
606
  )), u.push(
607
607
  /* @__PURE__ */ h("li", { style: C, children: [
608
608
  b,
609
609
  y.length > 0 && /* @__PURE__ */ n("div", { style: { marginTop: "8px" }, children: y })
610
- ] }, d.id)
610
+ ] }, p.id)
611
611
  );
612
612
  }
613
- p === "bulletListItem" ? o.push(
613
+ s === "bulletListItem" ? i.push(
614
614
  /* @__PURE__ */ n(
615
615
  "ul",
616
616
  {
617
617
  className: "mb-2 list-disc pl-6",
618
618
  children: u
619
619
  },
620
- l + "-ul-nested-" + i
620
+ l + "-ul-nested-" + o
621
621
  )
622
- ) : o.push(
622
+ ) : i.push(
623
623
  /* @__PURE__ */ n(
624
624
  "ol",
625
625
  {
@@ -627,50 +627,50 @@ class te extends R {
627
627
  start: 1,
628
628
  children: u
629
629
  },
630
- l + "-ol-nested-" + i
630
+ l + "-ol-nested-" + o
631
631
  )
632
- ), i = s;
632
+ ), o = c;
633
633
  } else {
634
- const p = await this.transformBlocks([a], t);
635
- o.push(
636
- /* @__PURE__ */ n(v, { style: { marginLeft: "24px" }, children: p }, a.id)
637
- ), i++;
634
+ const s = await this.transformBlocks([a], t);
635
+ i.push(
636
+ /* @__PURE__ */ n(W, { style: { marginLeft: "24px" }, children: s }, a.id)
637
+ ), o++;
638
638
  }
639
639
  }
640
- return o;
640
+ return i;
641
641
  }
642
642
  async transformBlocks(e, t = 0) {
643
643
  const l = [];
644
- let o = 0;
645
- for (; o < e.length; ) {
646
- const i = e[o];
647
- if (i.type === "bulletListItem" || i.type === "numberedListItem" || i.type === "toggleListItem") {
648
- const { element: s, nextIndex: c } = await this.renderGroupedListBlocks(
644
+ let i = 0;
645
+ for (; i < e.length; ) {
646
+ const o = e[i];
647
+ if (o.type === "bulletListItem" || o.type === "numberedListItem" || o.type === "toggleListItem") {
648
+ const { element: c, nextIndex: d } = await this.renderGroupedListBlocks(
649
649
  e,
650
- o,
650
+ i,
651
651
  t
652
652
  );
653
- l.push(s), o = c;
653
+ l.push(c), i = d;
654
654
  continue;
655
655
  }
656
- const a = await this.transformBlocks(i.children, t + 1), p = await this.mapBlock(i, t, 0), u = this.blocknoteDefaultPropsToReactEmailStyle(i.props);
656
+ const a = await this.transformBlocks(o.children, t + 1), s = await this.mapBlock(o, t, 0), u = this.blocknoteDefaultPropsToReactEmailStyle(o.props);
657
657
  l.push(
658
- /* @__PURE__ */ h(I.Fragment, { children: [
659
- /* @__PURE__ */ n(v, { style: u, children: p }),
658
+ /* @__PURE__ */ h(L.Fragment, { children: [
659
+ Object.entries(u).length > 0 ? /* @__PURE__ */ n("div", { style: u, children: s }) : s,
660
660
  a.length > 0 && /* @__PURE__ */ n("div", { style: { marginLeft: "24px" }, children: a })
661
- ] }, i.id)
662
- ), o++;
661
+ ] }, o.id)
662
+ ), i++;
663
663
  }
664
664
  return l;
665
665
  }
666
666
  async toReactEmailDocument(e, t) {
667
- const l = await this.transformBlocks(e), o = (t == null ? void 0 : t.container) || (({ children: p }) => /* @__PURE__ */ n(I.Fragment, { children: p })), i = !globalThis.ReadableByteStreamController;
668
- i && (globalThis.ReadableByteStreamController = (await import("web-streams-polyfill")).default.ReadableByteStreamController);
669
- const a = await P(
667
+ const l = await this.transformBlocks(e), i = (t == null ? void 0 : t.container) || (({ children: s }) => /* @__PURE__ */ n(L.Fragment, { children: s })), o = !globalThis.ReadableByteStreamController;
668
+ o && (globalThis.ReadableByteStreamController = (await import("web-streams-polyfill")).default.ReadableByteStreamController);
669
+ const a = await N(
670
670
  /* @__PURE__ */ h(Z, { children: [
671
671
  /* @__PURE__ */ n(z, { children: t == null ? void 0 : t.head }),
672
672
  /* @__PURE__ */ h(
673
- N,
673
+ O,
674
674
  {
675
675
  style: (t == null ? void 0 : t.bodyStyles) ?? {
676
676
  fontFamily: "'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif",
@@ -679,8 +679,8 @@ class te extends R {
679
679
  color: "#333"
680
680
  },
681
681
  children: [
682
- (t == null ? void 0 : t.preview) && /* @__PURE__ */ n(_, { children: t.preview }),
683
- /* @__PURE__ */ n(O, { children: /* @__PURE__ */ h(o, { children: [
682
+ (t == null ? void 0 : t.preview) && /* @__PURE__ */ n(j, { children: t.preview }),
683
+ /* @__PURE__ */ n(_, { children: /* @__PURE__ */ h(i, { children: [
684
684
  t == null ? void 0 : t.header,
685
685
  l,
686
686
  t == null ? void 0 : t.footer
@@ -690,28 +690,31 @@ class te extends R {
690
690
  )
691
691
  ] })
692
692
  );
693
- return i && delete globalThis.ReadableByteStreamController, a;
693
+ return o && delete globalThis.ReadableByteStreamController, a;
694
694
  }
695
695
  blocknoteDefaultPropsToReactEmailStyle(e) {
696
- var t, l;
697
- return {
698
- textAlign: e.textAlignment,
699
- backgroundColor: e.backgroundColor === "default" || !e.backgroundColor || (t = this.options.colors[e.backgroundColor]) == null ? void 0 : t.background,
700
- color: e.textColor === "default" || !e.textColor || (l = this.options.colors[e.textColor]) == null ? void 0 : l.text,
696
+ var l, i;
697
+ const t = {
698
+ textAlign: e.textAlignment === "left" ? void 0 : e.textAlignment,
699
+ backgroundColor: e.backgroundColor === "default" || !e.backgroundColor || (l = this.options.colors[e.backgroundColor]) == null ? void 0 : l.background,
700
+ color: e.textColor === "default" || !e.textColor || (i = this.options.colors[e.textColor]) == null ? void 0 : i.text,
701
701
  alignItems: e.textAlignment === "right" ? "flex-end" : e.textAlignment === "center" ? "center" : void 0
702
702
  };
703
+ return Object.fromEntries(
704
+ Object.entries(t).filter(([o, a]) => a !== void 0)
705
+ );
703
706
  }
704
707
  }
705
708
  export {
706
709
  te as ReactEmailExporter,
707
- H as createReactEmailBlockMappingForDefaultSchema,
708
- M as createReactEmailInlineContentMappingForDefaultSchema,
709
- T as createReactEmailStyleMappingForDefaultSchema,
710
+ k as createReactEmailBlockMappingForDefaultSchema,
711
+ S as createReactEmailInlineContentMappingForDefaultSchema,
712
+ B as createReactEmailStyleMappingForDefaultSchema,
710
713
  G as defaultReactEmailDefaultSchemaStyles,
711
- S as defaultReactEmailLinkStyles,
712
- B as defaultReactEmailStyleTransformStyles,
714
+ H as defaultReactEmailLinkStyles,
715
+ M as defaultReactEmailStyleTransformStyles,
713
716
  m as defaultReactEmailTextStyles,
714
- j as reactEmailBlockMappingForDefaultSchema,
717
+ P as reactEmailBlockMappingForDefaultSchema,
715
718
  Y as reactEmailDefaultSchemaMappings,
716
719
  ee as reactEmailDefaultSchemaMappingsWithStyles,
717
720
  q as reactEmailInlineContentMappingForDefaultSchema,