CK 编辑器中的文本方向
如何在加载编辑器上设置文本方向 [rtl]?
How can I set text direction [rtl] on load editor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在加载编辑器上设置文本方向 [rtl]?
How can I set text direction [rtl] on load editor?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
根据文档,这应该可以做到:
CKEDITOR.config CKSource 手册中的 .contentsLangDirection
示例取自此处:
According to the docs, this should do it:
CKEDITOR.config.contentsLangDirection
in the CKSource manualExample taken from there:
另一种方法是直接从视图文件中执行此操作,使用 Replace() 方法的好处是您可以为每个视图使用不同的方向和样式。
通过使用replace(),您还可以执行其他过滤操作,例如允许/禁止标签以及从编辑器中删除按钮。有关详细说明,请访问:
http://ckeditor.com/ckeditor_4.1rc/samples/datafiltering .html
Another way to do it is directly from your view file, the benefit of using replace() method is that you can use different direction and style for each of your view.
By using replace() you can also do other filtering stuff like allowing/disallowing tags and removing buttons from the editor. for a detailed description visit:
http://ckeditor.com/ckeditor_4.1rc/samples/datafiltering.html
如果您使用 CKEditor 版本 5,配置块如下:
在本例中,编辑器本身将保留英语(标题和方向),内容将以阿拉伯语编辑(因此从右到左)。
我选择这个示例是为了说明可以为这两个目的使用不同的语言(假设您使用文本编辑器构建 CMS,并且管理员希望为不同的网站内容添加阿拉伯语或希伯来语翻译,但以英语与编辑器本身进行交互) 。但是您也可以设置 ui: 'ar' 以便也镜像编辑器本身(请注意,要执行此操作,我认为您必须以多种方式之一捆绑语言,请参阅链接以下供参考)。
对双向文本的支持似乎很好(也就是用阿拉伯语输入一些内容,然后输入英语,只有当您输入英语时,它才会自动切换到从左到右)。
参考:
https://ckeditor.com/blog/CKEditor-5-v12.4.0-with-image-resizing-to-do-lists-RTL-language-support-and-more/
和链接的
https://ckeditor.com/ docs/ckeditor5/latest/features/ui-language.html#righttoleft-rtl-languages-support
If you use CKEditor version 5, the config block is like:
Where in this example, the editor itself will remain in english (both headings and orientation) and the content will be edited in arabic (therefore right to left).
I chose this example to illustrate that it's possible to use different languages for these two purposes (say if you build a CMS with the text editor and admins want to add arabic or hebrew translations for different site content but interact with the editor itself in english). But you could also set
ui: 'ar'
in order to mirror the editor itself as well (note that to do this I think you have to bundle in the languages in one of several ways, see the links below for reference).The support for bidirectional text seems to be good (aka type something in Arabic and then type in english and it automatically switches to left-to-right only while you type in english).
References:
https://ckeditor.com/blog/CKEditor-5-v12.4.0-with-image-resizing-to-do-lists-RTL-language-support-and-more/
and the linked
https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html#righttoleft-rtl-languages-support
CKEDITOR.replace('editor1', {
language: 'es',
removeButtons: 'PasteFromWord'
});
CKEDITOR.replace('editor1', {
language: 'es',
removeButtons: 'PasteFromWord'
});
只需更改 CkEditor 内的 ContentsLangDirection="Rtl" ,如下所示
just change the ContentsLangDirection="Rtl" inside the CkEditor like below
从版本 5 开始,可以通过更改语言设置来设置方向。您可以查看更多详细信息 这里。
As of version 5, the direction can be set by changing language settings. You can see more details here.