CK 编辑器中的文本方向

发布于 2024-09-07 07:07:46 字数 29 浏览 3 评论 0原文

如何在加载编辑器上设置文本方向 [rtl]?

How can I set text direction [rtl] on load editor?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

一抹苦笑 2024-09-14 07:07:46

根据文档,这应该可以做到:

CKEDITOR.config CKSource 手册中的 .contentsLangDirection

示例取自此处:

config.contentsLangDirection = 'rtl';

According to the docs, this should do it:

CKEDITOR.config.contentsLangDirection in the CKSource manual

Example taken from there:

config.contentsLangDirection = 'rtl';
对你而言 2024-09-14 07:07:46

另一种方法是直接从视图文件中执行此操作,使用 Replace() 方法的好处是您可以为每个视图使用不同的方向和样式。

CKEDITOR.replace( 'article_area', {
    contentsLangDirection: 'rtl'
} );

通过使用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.

CKEDITOR.replace( 'article_area', {
    contentsLangDirection: 'rtl'
} );

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

残月升风 2024-09-14 07:07:46

如果您使用 CKEditor 版本 5,配置块如下:

language: {
  ui: 'en',
  content: 'ar'
}

在本例中,编辑器本身将保留英语(标题和方向),内容将以阿拉伯语编辑(因此从右到左)。

我选择这个示例是为了说明可以为这两个目的使用不同的语言(假设您使用文本编辑器构建 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:

language: {
  ui: 'en',
  content: 'ar'
}

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

小镇女孩 2024-09-14 07:07:46

CKEDITOR.replace('editor1', {
language: 'es',
removeButtons: 'PasteFromWord'
});

CKEDITOR.replace('editor1', {
language: 'es',
removeButtons: 'PasteFromWord'
});

孤蝉 2024-09-14 07:07:46

只需更改 CkEditor 内的 ContentsLangDirection="Rtl" ,如下所示

<CKEditor:CKEditorControl ID="CKEdMainPageDescriptionWebsiteMobileappAr" BasePath="ckeditor/" runat="server" Width="100%" Toolbar="Basic"  ContentsLangDirection="Rtl"
                                        ToolbarBasic="|Bold|Italic|Underline|Strike|-|NumberedList|BulletedList|Outdent|Indent|-|JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock|
                                            |Styles|-|Format|-|Font|-|FontSize|
                                          /
                                        |Link|Unlink|-|TextColor|-|Undo|Redo|Cut|Copy|Paste|PasteText|PasteFromWord|"> </CKEditor:CKEditorControl>

just change the ContentsLangDirection="Rtl" inside the CkEditor like below

<CKEditor:CKEditorControl ID="CKEdMainPageDescriptionWebsiteMobileappAr" BasePath="ckeditor/" runat="server" Width="100%" Toolbar="Basic"  ContentsLangDirection="Rtl"
                                        ToolbarBasic="|Bold|Italic|Underline|Strike|-|NumberedList|BulletedList|Outdent|Indent|-|JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock|
                                            |Styles|-|Format|-|Font|-|FontSize|
                                          /
                                        |Link|Unlink|-|TextColor|-|Undo|Redo|Cut|Copy|Paste|PasteText|PasteFromWord|"> </CKEditor:CKEditorControl>
吃→可爱长大的 2024-09-14 07:07:46

从版本 5 开始,可以通过更改语言设置来设置方向。您可以查看更多详细信息 这里

As of version 5, the direction can be set by changing language settings. You can see more details here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文