Ticket #1308 (closed Bug: fixed)

Opened 7 years ago

Last modified 7 years ago

Paragraph justification should not have default values

Reported by: fredck Owned by:
Priority: Normal Milestone: FCKeditor 2.5 Beta
Component: General Version:
Keywords: Discussion Cc:

Description

This ticket is not here to define our definitive approach for it, but to open a discussion around this argument.

With the recent rework made for the paragraph alignment features, we have also introduced an "automatic default" for the alignment buttons. It means that if the content is LTR, the left align button will be enabled by default. In RTL instead, the right align button will be highlighted instead.

It sounded nice in the beginning, but now I'm a little bit worried about it. Let me bring some thoughts so we can discuss about it.

Let's suppose we have the following HTML:

<p>This is a test.</p>

Looking at it as is, what is the alignment of this paragraph? "None", is the only correct answer. But FCKeditor says it is "Left Aligned" if LTR or "Right Aligned" if "RTL".

The document direction setting in FCKeditor are there just to help reflecting the final result we'll have when loading the contents at the target web site. But the fact is that the direction information is not in any way saved along with the HTML produced with the editor.

Now... what if I want to "force" the paragraph to be left aligned, even if the document is LTR. Here is a simple sample:

<td align="center">
  <p>This is a test.</p>
</td>

Here the editor is saying that my <p> is left aligned, which is not true. It is actually has no alignment specified, so it simply inherits it. But I can't make it left aligned, because the editor is saying that it is already to the left. There is a hack for it: align to right, and then to left.

Those are just some issues that came to my mind. I know MS Word has this default behavior, but is also true that MS Word is not made to produce pieces of content to be injected, as FCKeditor does. Who knows how creatively will the content be used by our developers base.

Maybe I'm wrong, so please correct me in this case.

Attachments

getStyleExperiment.html (1.1 KB) - added by martinkou 7 years ago.
Getting paragraph alignment by getComputedStyle() and currentStyle attribute

Change History

comment:1 Changed 7 years ago by fredck

  • Milestone set to FCKeditor 2.5

comment:2 Changed 7 years ago by martinkou

A rationale for the automatic default alignment display is the rule of least astonishment - a user who have been using desktop word processors are used to seeing an alignment button highlighted to reflect how his paragraph is aligned visually. When the same user is using FCKeditor, he would expect the same behavior. So in my eyes, having the automatic default alignment display is a small usability feature.

The problem I see here, is whether the feature can be implemented correctly. Currently, the block alignment checking is done by checking for the align attribute, inline CSS properties, and associated CSS classes, in the nearest selected block. For many cases, the current alignment detection logic would detect the wrong alignment, like your given case, and things like these:

<style>
.classA {text-align: right;}
#idA {text-align: justify;}
</style>
...
<td class="classA">
  <p>This is a right justified paragraph</p>
</td>
<td id="idA">
  <p>This is a full justified paragraph</p>
</td>

I've found a way to retrieve the visual text alignment directly, however. It works for even the traditional align attribute. We can use the getComputedStyle() method in Gecko, Opera and Safari, and the currentStyle attribute in IE.

I've created a test case for this. Similar logic is being used in the drag resize table plugin right now, so I'm pretty confident it will be ok.

Changed 7 years ago by martinkou

Getting paragraph alignment by getComputedStyle() and currentStyle attribute

comment:3 Changed 7 years ago by fredck

Your proposal seams to be good Martin. Let's see the results of it.

comment:4 Changed 7 years ago by martinkou

  • Status changed from new to closed
  • Resolution set to fixed

Fixed with [958].

Click here for more info about our SVN system.

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy