contentful / rich-text

Libraries for handling and rendering Rich Text 📄
MIT License
548 stars 108 forks source link

React renderer doesn't handle arabic right to left in tables #440

Open yulius-take2 opened 1 year ago

yulius-take2 commented 1 year ago

When the React renderer draws a table, it doesn't draw the table right to left properly based on the content.

Example can be seen at the bottom of the page. https://www.take2games.com/data-request/ar

image

yulius-take2 commented 1 year ago

Here's the workaround. The css to handle this should really be in the renderer I think.

import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
import { css } from '@emotion/core';

const cssRichTextMarkdown = css`
  :dir(rtl) {
    th,
    td {
      text-align: right;
      direction: rtl;
    }
  }
`;

function ReactRichText({richText}) {
  return <div css={cssRichTextMarkdown}>{documentToReactComponents(richText)}</div>;
}