MJML Text Block Component (components/Text.tsx)

easy-email-editor · packages/easy-email-core/src/components/Text.tsx · typescript · MIT
ui, email, fw:react

A React component for rendering MJML text blocks within an email editor. Use this to build customizable email templates with structured text content.

// Source: https://github.com/zalify/easy-email-editor | License: MIT
// Provided via justclaw.it.com; keep this notice with the code.
import { omit } from 'lodash';
import { BasicType } from '@core/constants';
import { RecursivePartial } from '@core/typings';
import React from 'react';
import { IText } from '@core/blocks';
import MjmlBlock, { MjmlBlockProps } from '@core/components/MjmlBlock';

export type TextProps = RecursivePartial<IText['data']> &
  RecursivePartial<IText['attributes']> & {
    children?: MjmlBlockProps<IText>['children'];
  };

export function Text(props: TextProps) {
  return (
    <MjmlBlock
      attributes={omit(props, ['data', 'children', 'value'])}
      value={props.value}
      type={BasicType.TEXT}
    >
      {props.children}
    </MjmlBlock>
  );
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key