3

I've installed Drupal 8.0.2 in a standard installation process and in English.

I later changed The site's default language to Hebrew (Which is an RTL language) and my content type is now setted to the site's default language - Hebrew. I even determined my user's administration account, called "admin", to Hebrew (a new Drupal 8 feature that let's you pick a specific front-end language to a certain user).

After that I've organized the CKeditor full-profile edit-bar in an RTL manner at it's configuration page (and flushed all caches afterwards):

enter image description here


You saw - I did everything by the book, and yet:

I encounter two issues that comprise my whole problem:

1. The CKeditor edit-bar appears the opposite from how I arranged it (as can be seen one image up).

enter image description here

2. CKeditor input area typing cursor starts in the left instead of the right (I could easily manually flip the Edit-bar but the cursor will still appear in the left).

enter image description here

When I installed a test site in Hebrew from the start (instead of installing first in English and then add Hebrew and make it default), I didn't encounter that problem, and the edit-bar was RTL. I have no clue how to explain this! Maybe you can!

8
  • 1
    I do not understand your first question, for second question, may be this link is helpful, ckeditor.com/forums/CKEditor-3.x/…
    – anru
    Commented Jan 8, 2016 at 9:05
  • also, for CKEditor, you can press right CTRL+Shift, to move cursor to right side
    – anru
    Commented Jan 8, 2016 at 9:07
  • 1. I edited the question (paragraph1). 2. As I already mentioned in the question - Right Ctrl + Shift doesn't move the cursor to the right.
    – user16289
    Commented Jan 8, 2016 at 9:34
  • BTW about the link you gave - Do you know what file it is? I understand it's a function named getAscendant but in what file is it?
    – user16289
    Commented Jan 8, 2016 at 9:37
  • Note that @benos has cross-posted this to the Drupal 8 core issue queue: drupal.org/node/2646434
    – Wim Leers
    Commented Jan 8, 2016 at 15:12

2 Answers 2

13
+100

The default CKEditor text language direction is LTR. To change it to RTL, you can try setting the JS config setting:

config.contentsLangDirection = 'rtl';

Reference: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.contentsLangDirection

In D7, there was a config textarea that can be set:

ckeditor.config.rtl

In D8, you can set the CKEditor config settings in:

hook_editor_js_settings_alter

Something like:

/**
 * Implements hook_editor_js_settings_alter
 */
function MYMODULE_editor_js_settings_alter(array &$settings) {
  foreach ($settings['editor']['formats'] as $name => $value) {
    $settings['editor']['formats'][$name]['editorSettings']['contentsLangDirection'] = 'rtl';
  }
}

More info on creating Drupal 8 modules here: https://www.drupal.org/developing/modules/8

You can also set the config in JS, for example your theme

Something like:

(function ($, Drupal) {
  Drupal.behaviors.customCKEditorConfig = {
    attach: function (context, settings) {
      if (typeof CKEDITOR !== "undefined") {
        CKEDITOR.config.contentsLangDirection = 'rtl';
      }
    }
  }
})(jQuery, Drupal);

More info on adding theme assets here: https://www.drupal.org/theme-guide/8/assets

For your other question on the toolbar button ordering. That appears to work, just make sure you set the toolbar button order on all the "Text formats" that you want to use it with (e.g "Basic HTML", "Restricted HTML" and "Full HTML") in the CKEditor admin settings.

Sample RTL CKEditor input

6
  • Where have you seen this in Drupal 8? I know this conf session from Drupal 7 but not Drupal 8...
    – user16289
    Commented Jan 10, 2016 at 9:11
  • @benos, updated for D8 CKEditor option. Commented Jan 10, 2016 at 9:39
  • Much thanks to you David Tohmas! Even though I did some theming and can understand a small bit of basic PHP code (at least in logic) I am just starting to learn PHP and I don't know what I should do with that hook\core-manipulation... I mean, I don't know how to actually run it. Can you please detail just a bit more where to paste it? Just some preliminary information for people like me which just start to taste this world
    – user16289
    Commented Jan 10, 2016 at 10:07
  • @benos, you're welcome. I updated my answer with another option to set the config using JS. It also includes drupal.org links on module and theme development for reference there. I tested both approaches and they work to set the CKEditor text input to RTL. Wishing you a great 2016. Commented Jan 10, 2016 at 10:17
  • 1
    Fine year with much happiness, good deeds, and prosperity to all of us amen,
    – user16289
    Commented Jan 10, 2016 at 12:08
2

Also CKEditor BiDi Buttons module provides the bi directional text flow buttons, RTL and LTR.

Integrates the CKEditor BiDi plugin with CKEditor for Drupal 8. This plugin provides the bi directional text flow buttons, RTL and LTR .

The CKEditor BiDi plugin makes it possible to change the text direction for an HTML block-level elements like paragraphs and lists. This ability is essential for authoring content in languages that are written Right to Left like those with Arabic and , Hebrew writing systems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.