@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.
@@ -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
  )}
@@ -351,9 +356,10 @@ export class ReactEmailExporter<
351
356
 
352
357
  protected blocknoteDefaultPropsToReactEmailStyle(
353
358
  props: Partial<DefaultProps>,
354
- ): any {
355
- return {
356
- textAlign: props.textAlignment,
359
+ ): CSSProperties {
360
+ const style: CSSProperties = {
361
+ textAlign:
362
+ props.textAlignment === "left" ? undefined : props.textAlignment,
357
363
  backgroundColor:
358
364
  props.backgroundColor === "default" || !props.backgroundColor
359
365
  ? undefined
@@ -369,5 +375,8 @@ export class ReactEmailExporter<
369
375
  ? "center"
370
376
  : undefined,
371
377
  };
378
+ return Object.fromEntries(
379
+ Object.entries(style).filter(([_, value]) => value !== undefined),
380
+ );
372
381
  }
373
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
  }