Download & Extend

Properly handle language direction

Project:Wysiwyg
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Dear friends,

As shown in the screen shot, the installation is Hebrew and so is the language chosen for FCKeditor but inside the editing iframe, there's

<html dir="ltr">

I think it should be expected that the directionality would be determined by Drupal's current directionality, or that there will be some clear way of defining directionality.

Many blessings.

AttachmentSize
screen_shot.png145.92 KB

Comments

#1

Component:Code» Editor - FCKeditor
Status:active» postponed (maintainer needs more info)

Please research whether FCKeditor supports a directionality setting and which values it accepts.

#2

Dear sun,

Here it is: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/C...

I'm not a developer but I am a semi-frustrated RTL user. Perhaps it should be configured using the same code for the directionality of the page, using

$language->dir

?

Many blessings.

#3

On second thought, in determining the directionality one should also consider the current language in regards to the content translation module.

#4

Title:dir="ltr" while should be rtl» Properly handle language direction
Version:6.x-1.1» 6.x-2.x-dev
Component:Editor - FCKeditor» Code
Category:bug report» feature request
Status:postponed (maintainer needs more info)» active

You're right. And that's not going to be an easy task. Because we only process a textarea, and have no idea to which object/content and language it belongs.

#5

Status:active» needs review

Here's a patch that changes the directionality of the editor based on the current active language.
Note: this does not use the language selected in the editor profile, rather the currently active language on the site. On a site with multiple languages it is important to have this flexibility.

AttachmentSize
457620-ckeditor-direction.patch 901 bytes

#6

Would that not mean that if I edit a Hebrew text when I have English set as my language, it would be going from left to right instead of right to left in the editor?

#7

@TwoD: Correct. Still, this is better than nothing.

#8

@sun -
I would like to thank you for the great wysiwyg module. I am new to Drupal (this is my first comment) and after reading around quite a bit have just tried wysiwyg+ckeditor.

I am a user working on my own community website, not a developer, so I cant tell if this is easy or not...

It looks like the "style" button provides RTL/LTR functions through a dropdown list. I wonder if it's possible to have them as simple buttons (not related to other style options). Attached are the icons of r2l & l2r of ms-office. This is the way users are used to and expect to see them in the toolbar.

I am not sure if this paper helps, but it won't harm - http://www.w3.org/International/tutorials/bidi-xhtml/

AttachmentSize
r2l.gif 357 bytes
l2r.gif 362 bytes

#9

@mauran, this issue is about automatically figuring out what to initially tell the editors about the general directional flow of the content being edited.
Ie, should the <html>/<body> tag in the editor's editing area have the dir="rtl" attribute or not when first loaded?

If you want to provide an additional button to let users change/override the direction for certain elements, you probably need a plugin written to do just that for the editor you're using.

#10

@TwoD -

Thanks, but I am not sure I understand what you said.

You are right about the idea - it is indeed to let users mix RTL & LTR paragraphs.

I am puzzled about the plugin part - why there is a need for a plugin if CKeditor already provides the RTL/LTR ability?

I am not sure how hard it is to provide RTL/LTR buttons instead of through the "style" dropdown element, but I am pretty sure that there is no need for a plugin. Please correct me if I am wrong.

#11

You need the plugin to have a place to call the CKEditor API functions - used to create the new toolbar buttons - from safely. The actual commands/functionality called when clicking the buttons might be possible to borrow from the Style dropdown plugin, but there's no reliable way to create buttons without a new plugin. Once you've got a plugin which creates the buttons, you can implement hook_wysiwyg_plugin() to describe the plugin to Wysiwyg module and say from where it can be loaded, the names of the buttons it provides (to allow enabling under "Buttons and Plugins" on the editor profile) etc. The hook is used to avoid having to manipulate CKEditor's or Wysiwyg's own files.

#12

Thanks TwoD -

This is a bit over my knowledge, but if you are so kind as to guide me here, I am willing to dive into it. It'll feel very good to cope with it on my own, but I really need directions on this.

#13

I'm afraid a plugin authoring tutorial is too off topic here, but the official CKEditor documentation/forum would be a good place to start. Once you have a working plugin ('outside' Drupal & Wysiwyg module), look in the file wysiwyg.api.php for info on how to implement hook_wysiwyg_plugin() to make it work via Wysiwyg.