Wagtail:如何将 Draftail Editor 的文本方向设置为 RTL
Wagtail : How to set Draftail Editor's text direction to RTL
在 wagtail admin RichTextField() 中,我需要支持 RTL 语言。
我看到 Draftail 它通过 textDirectionality 自我支持。
在 wagtail RichTextField() 中添加 RTL 支持的最佳方法是什么?
Here,wagtail 文档建议使用 register_rich_text_features
钩子来限制编辑器的功能。但是我找不到任何关于向其添加 textDirectionality 的信息。
文本方向将基于编辑器中的字符。所以你不必做任何事情。 Draftail 是 Draft.js 并且 Draft.js 文档说:
textDirectionality?: DraftTextDirectionality
Optionally set the overriding text directionality for this editor. The values include 'RTL' for right-to-left text, like Hebrew or Arabic, and 'LTR' for left-to-right text, like English or Spanish. This directionality will apply to the entire contents, regardless of default text direction for input text.
If this value is not set, text directionality will be based on the characters within the editor, on a per-block basis.
来源:https://draftjs.org/docs/api-reference-editor.html#textdirectionality
我查过了:
目前,除功能外,所有选项都将被忽略。查看 Wagtail 源代码 wagtail/admin/rich_text/editors/draftail/__init__.py:20
class DraftailRichTextArea(widgets.HiddenInput):
...
def __init__(self, *args, **kwargs):
# note: this constructor will receive an 'options' kwarg taken from the WAGTAILADMIN_RICH_TEXT_EDITORS setting,
# but we don't currently recognise any options from there (other than 'features', which is passed here as a separate kwarg)
kwargs.pop('options', None)
self.options = {}
如果您需要更多控制,您可以随时覆盖小部件模板。参见 wagtail/admin/templates/wagtailadmin/widgets/draftail_rich_text_area.html
在 wagtail admin RichTextField() 中,我需要支持 RTL 语言。 我看到 Draftail 它通过 textDirectionality 自我支持。
在 wagtail RichTextField() 中添加 RTL 支持的最佳方法是什么?
Here,wagtail 文档建议使用 register_rich_text_features
钩子来限制编辑器的功能。但是我找不到任何关于向其添加 textDirectionality 的信息。
文本方向将基于编辑器中的字符。所以你不必做任何事情。 Draftail 是 Draft.js 并且 Draft.js 文档说:
textDirectionality?: DraftTextDirectionality
Optionally set the overriding text directionality for this editor. The values include 'RTL' for right-to-left text, like Hebrew or Arabic, and 'LTR' for left-to-right text, like English or Spanish. This directionality will apply to the entire contents, regardless of default text direction for input text.
If this value is not set, text directionality will be based on the characters within the editor, on a per-block basis.
来源:https://draftjs.org/docs/api-reference-editor.html#textdirectionality
我查过了:
目前,除功能外,所有选项都将被忽略。查看 Wagtail 源代码 wagtail/admin/rich_text/editors/draftail/__init__.py:20
class DraftailRichTextArea(widgets.HiddenInput):
...
def __init__(self, *args, **kwargs):
# note: this constructor will receive an 'options' kwarg taken from the WAGTAILADMIN_RICH_TEXT_EDITORS setting,
# but we don't currently recognise any options from there (other than 'features', which is passed here as a separate kwarg)
kwargs.pop('options', None)
self.options = {}
如果您需要更多控制,您可以随时覆盖小部件模板。参见 wagtail/admin/templates/wagtailadmin/widgets/draftail_rich_text_area.html