Text Direction

文字方向

Facebook supports dozens of languages, which means that our text inputs need to be flexible enough to handle considerable variety.

Facebook 支持多种语言,这意味着我们的文字输入需要足够灵活,以处理相当多的变化。

For example, we want input behavior for RTL languages such as Arabic and Hebrew to meet users' expectations. We also want to be able to support editor contents with a mixture of LTR and RTL text.

例如,我们希望输入行为是从右向左的语言,比如阿拉伯语和希伯来语,满足用户的期望。我们也希望能够能够支持编辑器内容混合从左向右和从右向左的文字。

To that end, Draft uses a bidi algorithm to determine appropriate text alignment and direction on a per-block basis.

为此,Draft 使用了一个 bidi 算法来决定每一个基础的 block 上合适的文字方向和对齐方向。

Text is rendered with an LTR or RTL direction automatically as the user types. You should not need to do anything to set direction yourself.

文字被自动的通过用户类型,渲染为从左往右或者从右往左方向。你应该不需要做任何事来设置你自己的方向。

Text Alignment

文字对齐方向

While languages are automatically aligned to the left or right during composition, as defined by the content characters, it is also possible for engineers to manually set the text alignment for an editor's contents.

虽然语言在创建时,作为被定义的内容字符,被自动的对齐到左或右。但工程师手动的为编辑器内容设置文字对齐方向也是可能的。

This may be useful, for instance, if an editor requires strictly centered contents, or needs to keep text aligned flush against another UI element.

这很有用,例如,一个编辑器需要严格的居中内容,或者需要保持文字和另一个 UI 元素对齐刷新。

The Editor component therefore provides a textAlignment prop, with a simple set of values: 'left', 'center', and 'right'. Using these values, the contents of your editor will be aligned to the specified direction regardless of language and character set.

Editor 组件因此提供了 textAlignment 属性,包括了一个简单的值集合:“left”“center”“right” 。使用这些值,你的编辑器的内容会被对齐到指定的方向,而忽略语言和字符的设置。

results matching ""

    No results matching ""