Opened 12 years ago

Last modified 4 years ago

#864 assigned New Feature

Make subscript/superscript switchable

Reported by: virtimus@… Owned by: Szymon Cofalik
Priority: Normal Milestone:
Component: General Version:
Keywords: IBM SF Cc: Frederico Caldeira Knabben, Joe Kavanagh, dchojna@…, lynne_kues@…, camden.michael@…

Description (last modified by Martin Kou)

I've observed strange behaviour when switching between subscript/superscript (concerns situations when both are switched on). Added this to fcknamedcommand (start of execute function):

if (((this.Name=='Subscript') &&
(!FCK.EditorDocument.queryCommandState('Subscript')))
|| ((this.Name=='Superscript') &&
(!FCK.EditorDocument.queryCommandState('Superscript')))) {
FCK.ExecuteNamedCommand('RemoveFormat');
}

and voila - subscript/superscript works fine ...


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1428321&group_id=75348&atid=543656

Attachments (1)

864.patch (2.5 KB) - added by Sa'ar Zac Elias 8 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 12 years ago by Martin Kou

Cc: Frederico Caldeira Knabben added
Description: modified (diff)
Reporter: changed from Martin Kou to virtimus@…

Well... actually it is not an error to have such situation. Many will tell you that this is necessary. For example:

x<sup>B<sub>1</sub></sup>

The above is ok. Actually there is a limitation in the editor as it is not able to include a subscript inside another subscript!

But ok, we are not proposing a formula editor here... maybe the "switchable" approach is better?! Any thoughts?

I'm moving it to the Features Requests therefore.


Moved from SF. Original poster: fredck

comment:2 Changed 11 years ago by Wojciech Olchawa

Keywords: Discussion added

comment:3 Changed 9 years ago by Alfonso Martínez de Lizarrondo

Cc: Joe Kavanagh dchojna@… added
Keywords: IBM added

#5083 has been marked as dup

comment:4 in reply to:  1 Changed 9 years ago by Joe Kavanagh

If the user clicks the subscript button, then the superscript button, while the same text is selected the result is: <sup><sub>text</sub></sup>. In this scenario can the sub element be removed, and the subscript button deselected.

comment:5 Changed 9 years ago by Lynne Kues

Cc: lynne_kues@… added

comment:6 Changed 9 years ago by Lynne Kues

This issue has been raised against the editor in our product. The expected user behavior is that subscript/superscript should be mutually exclusive. That is, if I format the text as subscript, then change to superscript, <sub> should be replaced with <sup>, as indicated in the above comment by JoeK.

comment:7 Changed 8 years ago by Michael Camden

Cc: camden.michael@… added

comment:8 Changed 8 years ago by Garry Yao

Status: newpending

Can you cite any editor that have sub/sup exclusive?

comment:9 Changed 8 years ago by Frederico Caldeira Knabben

Keywords: Discussion removed
Status: pendingconfirmed

I think MS Word is a good example for it.

Considering the limitation precisely described at martinkou's comments, this request is definitely valid.

comment:10 in reply to:  9 ; Changed 8 years ago by Garry Yao

Replying to fredck:

I think MS Word is a good example for it.

I don't understand, MS Word has exactly inclusive sub/sup.

comment:11 in reply to:  10 Changed 8 years ago by Frederico Caldeira Knabben

Replying to garry.yao:

Replying to fredck:

I think MS Word is a good example for it.

I don't understand, MS Word has exactly inclusive sub/sup.

In my installation (Word 2007), sub and sub are mutually exclusive. In any case, that's just an example, not a rule to be followed.

There are some facts that justify making it mutually exclusive, other than MS Word:

  • This is not a formula editor. There are other tools and plugins that provide this feature in the right way.
  • The current "feature" is incomplete. If it's possible to have a sub inside a sup, it should be possible to have sub inside another sub, but it's not possible.
  • Another issue with the current "feature" is that is should make validations to make it possible to have sub inside sup. Currently, it's possible to have things like the following, which gives a pretty bad output:
x<sup><sub>2</sub></sup>

comment:12 Changed 8 years ago by Garry Yao

Well the problem is that current (inclusive) feature is a super set of the proposed feature, as you can always achieve the exclusion via toggle previous one + apply new one.

As you pointed out we're not going to into the formula world it should be a worry of having an incomplete feature.

Changed 8 years ago by Sa'ar Zac Elias

Attachment: 864.patch added

comment:13 Changed 8 years ago by Sa'ar Zac Elias

Owner: set to Sa'ar Zac Elias
Status: confirmedreview

Proposing a new "toggles" field, that removes the conflicting style if applied on the current selection.

comment:14 Changed 8 years ago by Frederico Caldeira Knabben

Status: reviewreview_failed

We don't need a change in the API adding new parameters to pass the toggles thing. We can simply have this in the style definition, much like the overrides entry. In this way we can define styles that get removed by the style application.

Additionally, the "toggles" name is not appropriate, as it refers to a visual action. Better to simply call it "removes", having the same implementation as "overrides".

---

Finally, just to make it reported, after patch, with the following HTML:

<p>x<sup>1234</sup></p>
  1. Select "234".
  2. Click the "Subscript" button.
  3. Without changing the selection, click "Superscript".

Nothing happens... as js error is thrown.

comment:15 Changed 4 years ago by Nilay Mandal

I ran into the same situation and found the below workaround for switching the buttons:

$(".cke").find(".cke_buttonsubscript").unbind("click").bind("click", function(e){

if($(this).parents(".cke").find(".cke_buttonsuperscript").hasClass("cke_button_on")) {

$(this).parents(".cke").find(".cke_buttonsuperscript").click();

}

});

$(".cke").find(".cke_buttonsuperscript").unbind("click").bind("click", function(e){

if($(this).parents(".cke").find(".cke_buttonsubscript").hasClass("cke_button_on")) {

$(this).parents(".cke").find(".cke_buttonsubscript").click();

}

});

Last edited 4 years ago by Nilay Mandal (previous) (diff)

comment:16 Changed 4 years ago by Szymon Cofalik

Owner: changed from Sa'ar Zac Elias to Szymon Cofalik
Status: review_failedassigned
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy