contentful / field-editors

React components and extensions for building Contentful entry editor
https://contentful-field-editors.netlify.app/
MIT License
149 stars 114 forks source link

fix(rich-text): respect sdk.field.locale text direction [ZEND-4773] #1624

Closed z0al closed 3 months ago

z0al commented 3 months ago

Slate detects text direction on a block level e.g. paragraph which is fine in most cases but its implementation is naive. For example, if you have an English word at the beginning of a paragraph written mostly in Arabic the whole paragraph would be marked as ltr instead of rtl.

At Contentful, we don't need to guess the direction, we already have the locale information exposed in the Field SDK which is respected in other field editors e.g. SingleLineEditor. This PR brings some of that to RT but it's no where near complete. To fully support RTL we have to adjust the styling of some the elements e.g. blockquotes, tables ..etc.

This fixes the problem at hand and serves as a first step in the right direction.