@blocknote/xl-email-exporter 0.44.2 → 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.
@@ -250,9 +250,14 @@ export class ReactEmailExporter<
250
250
  const children = await this.transformBlocks(b.children, nestingLevel + 1);
251
251
  const self = (await this.mapBlock(b as any, nestingLevel, 0)) as any;
252
252
  const style = this.blocknoteDefaultPropsToReactEmailStyle(b.props as any);
253
+
253
254
  ret.push(
254
255
  <React.Fragment key={b.id}>
255
- <Section style={style}>{self}</Section>
256
+ {Object.entries(style).length > 0 ? (
257
+ <div style={style}>{self}</div> // TODO: maybe nicer to set style on child element instead of wrapping in a div?
258
+ ) : (
259
+ self
260
+ )}
256
261
  {children.length > 0 && (
257
262
  <div style={{ marginLeft: "24px" }}>{children}</div>
258
263
  )}
@@ -310,7 +315,15 @@ export class ReactEmailExporter<
310
315
  (({ children }: { children: React.ReactNode }) => (
311
316
  <React.Fragment>{children}</React.Fragment>
312
317
  ));
313
- return renderEmail(
318
+ const needsPolyfill = !globalThis.ReadableByteStreamController;
319
+ if (needsPolyfill) {
320
+ // needed for safari compatibility;
321
+ // https://github.com/resend/react-email/blob/f02e21e998d507aa3fdfbb7b8639f915b8df6cb5/apps/docs/utilities/render.mdx#3-convert-to-html
322
+ (globalThis as any).ReadableByteStreamController = (
323
+ await import("web-streams-polyfill")
324
+ ).default.ReadableByteStreamController;
325
+ }
326
+ const ret = await renderEmail(
314
327
  <Html>
315
328
  <Head>{options?.head}</Head>
316
329
  <Body
@@ -335,13 +348,18 @@ export class ReactEmailExporter<
335
348
  </Body>
336
349
  </Html>,
337
350
  );
351
+ if (needsPolyfill) {
352
+ delete (globalThis as any).ReadableByteStreamController;
353
+ }
354
+ return ret;
338
355
  }
339
356
 
340
357
  protected blocknoteDefaultPropsToReactEmailStyle(
341
358
  props: Partial<DefaultProps>,
342
- ): any {
343
- return {
344
- textAlign: props.textAlignment,
359
+ ): CSSProperties {
360
+ const style: CSSProperties = {
361
+ textAlign:
362
+ props.textAlignment === "left" ? undefined : props.textAlignment,
345
363
  backgroundColor:
346
364
  props.backgroundColor === "default" || !props.backgroundColor
347
365
  ? undefined
@@ -357,5 +375,8 @@ export class ReactEmailExporter<
357
375
  ? "center"
358
376
  : undefined,
359
377
  };
378
+ return Object.fromEntries(
379
+ Object.entries(style).filter(([_, value]) => value !== undefined),
380
+ );
360
381
  }
361
382
  }
@@ -48,5 +48,5 @@ export declare class ReactEmailExporter<B extends BlockSchema, S extends StyleSc
48
48
  */
49
49
  bodyStyles?: CSSProperties;
50
50
  }): Promise<string>;
51
- protected blocknoteDefaultPropsToReactEmailStyle(props: Partial<DefaultProps>): any;
51
+ protected blocknoteDefaultPropsToReactEmailStyle(props: Partial<DefaultProps>): CSSProperties;
52
52
  }