Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Add subscript and superscript feature #74

Closed
wants to merge 7 commits into from
Closed

Conversation

idleb
Copy link

@idleb idleb commented Aug 29, 2018

I noticed that basic-styles look as if coreStyles in CKEditor4, but I didn't find subscript and superscript features, so I added them like CKEditor4

@coveralls
Copy link

coveralls commented Aug 29, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 35eb821 on idleb:master into 53ffd41 on ckeditor:master.

@ma2ciek
Copy link
Contributor

ma2ciek commented Aug 29, 2018

Hi @idleb!

Thanks for the PR.

Could you tell us:

  • What are your use cases for this feature?
  • Why do you think this feature is important?

We usually start by creating issues, so we can deeply discuss use cases for every feature and code change in our codebase. Note, that CKE4 and CKE5 are different editors, they have a little bit different usage and their features don't match 1-1.

In the past, we considered <sub> and <sup> elements being not necessary (see ckeditor/editor-recommendations#5). But I see that the W3C recommendations for this script might have changed as the links in the above ticket are inactive. Now there's only a link to both features ( https://www.w3.org/TR/html5/textlevel-semantics.html#the-sub-and-sup-elements) with the following information:

In general, authors should use these elements only if the absence of those elements would change the meaning of the content.

@idleb
Copy link
Author

idleb commented Aug 30, 2018

Hi @ma2ciek ,I just saw that about <sub> and <sup> issues.

First, I am migrating from CKEditor4, and latest editor used this features for mathematical equation. because our product usually was used by teachers in school, e.g. print test paper. So we need these styles.

I think use sub and sup is more easily, but you are right about it's not a general function. Maybe, I should implement them in a new package.

@idleb idleb closed this Aug 30, 2018
@Reinmar
Copy link
Member

Reinmar commented Aug 30, 2018

I don't see it a problem that Editor Recommendations don't consider sub/sup as semantic enough. ER didn't mean to define the set of features that we can never exceed. It was meant to define a basic set of "Article" oriented features. We already extended that set because there are other use cases than creating articles in CKEditor 5.

BTW, even in this package we have underline and code (and they are not covered by ER). We can easily have sub/sup too.

So, I'd really like to see a progress with sub/sup. @idleb, if you could reopen the PR, that'd be cool. It adds a very basic sub/sup functionality and that's ok for now.

But, I agree with @ma2ciek on one thing – we need to discuss how this feature should be provided. There are things like... can text be in <sub> and <sup> at the same time? If yes, which of these elements comes first (which one is outside)? How to implement it to achieve such behaviour (I can tell that it won't be that easy if these attrs are to be ordered)?

@idleb
Copy link
Author

idleb commented Aug 31, 2018

@Reinmar ,I am glad you asked me to reopen the PR, this feature is very basic. I don't consider about text is in and at the same time, which one is outside depend on how user typesetting.

@idleb idleb reopened this Aug 31, 2018
@Reinmar Reinmar changed the title add subscript and superscript feature Add subscript and superscript feature Aug 31, 2018
@Reinmar
Copy link
Member

Reinmar commented Aug 31, 2018

OK, I reported the ticket about the behaviour of this feature: https://github.com/ckeditor/ckeditor5-basic-styles/issues/75

@Reinmar Reinmar requested a review from ma2ciek August 31, 2018 15:59
const t = editor.t;

// Add subscript button to feature components.
editor.ui.componentFactory.add( SUB, locale => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI item should be named subscript, not sub.

} );

// Create sub command.
editor.commands.add( SUB, new AttributeCommand( editor, SUB ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subscript command should be named subscript, not sub.

} );

// Create super command.
editor.commands.add( SUPER, new AttributeCommand( editor, SUPER ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );

// Execute command.
this.listenTo( view, 'execute', () => editor.execute( SUPER ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@ma2ciek
Copy link
Contributor

ma2ciek commented Sep 10, 2018

Hi again, @idleb.

Sorry for the late review.

I've tested it and it works fine, good job 👍. With the current implementation, you can have both subscript and superscript, but for now, it's ok.

Two things are missing now:

It'd be great if you could add these missing things and change the naming of UI items and commands that are mentioned in the review.

And the last thing - do you have permissions to use these icons? Did you create them or found them somewhere?

@idleb
Copy link
Author

idleb commented Oct 12, 2018

Hello, I updated you mentioned in the review, the feature name, contexts.json and manual test.

About these icons, they was used temporary, I found them from otherwhere. I would need a SVG icon for the default theme.

@Reinmar Reinmar closed this in #80 Nov 13, 2018
Reinmar added a commit that referenced this pull request Nov 13, 2018
Feature: Introduced the `Superscript` and the `Subscript` features. Closes #76. Closes #74.

Thanks to @idleb!
@Reinmar
Copy link
Member

Reinmar commented Nov 13, 2018

We merge the feature in #80. Thank you, @idleb!

@kylane
Copy link

kylane commented Nov 13, 2018

Thanks guys!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants