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

Add the strikethrough feature. #58

Merged
merged 16 commits into from
Dec 5, 2017

Conversation

Natim
Copy link

@Natim Natim commented Nov 17, 2017

Following discussions in mozilla/notes#397 I am adding the prelimilary work around the strikethrough feature. I would need a SVG icon for the default theme.

@Natim
Copy link
Author

Natim commented Nov 17, 2017

By the way feel free to send me the CLA I would be glad to sign it.

src/strike.js Outdated
*/

/**
* @module notes/ckeditor-build/strike
Copy link
Author

Choose a reason for hiding this comment

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

This should change.

*/

/**
* @module notes/ckeditor-build/strikeengine
Copy link
Author

Choose a reason for hiding this comment

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

This should change.

@Reinmar
Copy link
Member

Reinmar commented Nov 17, 2017

Thanks!

To merge it, we'll also need an:

  • automated tests (see tests/),
  • adding underline to the manual test (see tests/manual/),

You can read about our test environment or, since this is a simple feature, just copy&paste&hopeThatItWorks :).

src/strike.js Outdated
const editor = this.editor;
const t = editor.t;
const command = editor.commands.get( 'strike' );
const keystroke = 'CTRL+E';
Copy link
Author

Choose a reason for hiding this comment

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

Please advice of a good keystroke for that feature. I tried CTRL+ALT+S but it doesn't seems to work.

Copy link
Member

Choose a reason for hiding this comment

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

cc @Comandeer

I don't know why ctrl+alt+s didn't work so maybe there's some problem with https://github.com/ckeditor/ckeditor5-utils/blob/master/src/keyboard.js#L81 ;|

Copy link
Member

Choose a reason for hiding this comment

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

Editor Recommendations does not define shortcut for strikethorugh, however it's probably good to stick to what Word does as it's a de facto standard: Cmd + Shift + X in Office 365 on macOS.

Choose a reason for hiding this comment

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

@Reinmar @Comandeer what font do y'all use for icons?

Copy link
Author

Choose a reason for hiding this comment

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

Can I use Cmd+Shift+X in the keystroke var here? Will the editor understand Cmd or should I use Meta?

Copy link
Author

Choose a reason for hiding this comment

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

Right now typing Cmd key remove the selected content.

Choose a reason for hiding this comment

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

@Natim Should be Meta I think

Copy link
Author

Choose a reason for hiding this comment

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

@Reinmar
Copy link
Member

Reinmar commented Nov 17, 2017

By the way feel free to send me the CLA I would be glad to sign it;

It should be sent automatically. Let us know if you don't get it.

@Natim
Copy link
Author

Natim commented Nov 17, 2017

Folks I am going to be off for the next 12 hours, feel free to take over the branch if you want to update the icon or the key stroke. Tests were passing with CTRL+E.

I would be glad to take your reviews as well.

@oleq
Copy link
Member

oleq commented Nov 20, 2017

I pushed an improved strike icon. Please note that it will be refactored in ckeditor/ckeditor5#645 anyway.

image

@Natim
Copy link
Author

Natim commented Nov 20, 2017

Nice thanks !! Any idea of how to fix the shortcut? Should I remove it for now?

@Reinmar
Copy link
Member

Reinmar commented Nov 20, 2017

I've been a bit unsure about the view element name – whether it should be s or del but I can see that in Editor Recommendations we agreed that s makes most sense and it's also the most commonly used: ckeditor/editor-recommendations#3.

@Reinmar
Copy link
Member

Reinmar commented Nov 20, 2017

Nice thanks !! Any idea of how to fix the shortcut? Should I remove it for now?

We need to make cmd+shift+x work. So if you previously had a problem with cmd+alt+a, then there are two options now:

  • switching to cmd+shift+x will work just fine out of the box because the problem was caused by the browser not letting us handle cmd+alt+a,
  • there's some problem with utils/keyboard.js which is not able to handle a keystroke with two modifiers for some reason (in which case we need to look into that).

src/strike.js Outdated
import strikeIcon from '../theme/icons/strike.svg';

/**
* The strike feature. It introduces the Strike button and the <kbd>Ctrl+E</kbd> keystroke.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the keystroke to currently used one.

src/strike.js Outdated
const editor = this.editor;
const t = editor.t;
const command = editor.commands.get( 'strike' );
const keystroke = 'Cmd+Shift+X';
Copy link
Contributor

Choose a reason for hiding this comment

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

It is working for me without any problems (maybe OS is blocking it on your machine?). Please use CTRL+SHIFT+X (uppercase and CTRL instead of CMD). It will be consistent with the way we define it in other features. Note that this will also work with command key as we internally handle that.

Copy link
Author

@Natim Natim Nov 20, 2017

Choose a reason for hiding this comment

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

I don't think CMD and CTRL are the same key, one is Ctrl the other one is Meta isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

They are not same key, we just treat them that way, and you just need to define keystroke for CTRL and it will be handled correctly on Mac. Please see: http://ckeditor.github.io/editor-recommendations/general-policies/#ctrl-vs-cmd.

src/strike.js Outdated
const view = new ButtonView( locale );

view.set( {
label: t( 'Strike' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add Strike to the lang/contexts.json. This will give a context to the translators.

Copy link
Author

Choose a reason for hiding this comment

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

Done

* underline "instance",
* code "is an".
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also update tests/manual/basic-styles.html to reflect these changes.

Copy link
Author

Choose a reason for hiding this comment

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

Done

tests/strike.js Outdated

it( 'should set editor keystroke', () => {
const spy = sinon.spy( editor, 'execute' );
const keyEventData = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails. It uses alt key instead of shift key. After unifying keystroke to CTRL+SHIFT+X, keyEventData should look like this:

const keyEventData = {
	keyCode: keyCodes.x,
	shiftKey: true,
	ctrlKey: true,
	preventDefault: sinon.spy(),
	stopPropagation: sinon.spy()
};

Copy link
Author

Choose a reason for hiding this comment

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

It isn't Ctrl but Cmd as far as I am aware

Copy link
Author

Choose a reason for hiding this comment

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

Done

@szymonkups
Copy link
Contributor

Do we want the feature to be named "Strike" and not "Strikethrough"?

@Natim
Copy link
Author

Natim commented Nov 20, 2017

Do we want the feature to be named "Strike" and not "Strikethrough"?

I initially named it Strikethrough but renamed it when I saw that in CKeditor 4 it was called Strike.

@wwalc
Copy link
Member

wwalc commented Nov 20, 2017

I'd go with Strikethrough as the feature itself will render <s>, not the <strike> element (as one would suspect). This is also the name of the feature that we use in the Editor Recommendations project, so sticking to strike seems to be kinda a lack of consequence.

@Natim
Copy link
Author

Natim commented Nov 20, 2017

Ok I will make the change then 👍

@@ -0,0 +1,68 @@
/**
* @license Copyright (c) 2017, CKSource - Rémy Hubscher. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not modifying standard header for each developer. "CKSource - Frederico Knabben" it's our company full name. We really appreciate your contribution, it will be noted in GitHub history and our change log, but we cannot change copyright information - this is also why we needed CLA to be signed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Natim - are you ok with me modifying headers back to original state and merging this PR?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry I forgot about that, it should be fixed now.

@@ -0,0 +1 @@
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M8.396 10.861c1.83.02 3.66.038 5.489.014.311.54.466 1.147.466 1.823 0 .944-.373 1.834-1.119 2.671-.745.837-1.94 1.255-3.584 1.255a6.429 6.429 0 0 1-2.291-.429l-.366-.137a2.901 2.901 0 0 0-.246-.059 1.113 1.113 0 0 0-.201-.023c-.195 0-.329.056-.402.169a1.704 1.704 0 0 0-.192.479h-.538v-4.629h.538c.305 1.394.796 2.408 1.475 3.041s1.456.949 2.333.949c.852 0 1.458-.217 1.817-.653.359-.435.539-.893.539-1.374 0-.56-.189-1.016-.566-1.369-.25-.232-.752-.533-1.507-.904l-1.214-.603a15.578 15.578 0 0 1-.431-.221zm2.881-2.034l.535.264c.459.228.85.473 1.172.736H6.806a4.395 4.395 0 0 1-.527-.516 2.98 2.98 0 0 1-.334-.484h5.332zm2.526-1.379h-.521a5.656 5.656 0 0 0-1.319-2.438c-.63-.682-1.395-1.023-2.296-1.023-.633 0-1.134.172-1.502.516a1.653 1.653 0 0 0-.553 1.256c0 .59.174 1.032.521 1.324.194.169.523.385.987.645-1.177.006-2.355.023-3.532.053a4.065 4.065 0 0 1-.048-.634c0-.913.327-1.766.981-2.557.654-.791 1.657-1.187 3.009-1.187a6.46 6.46 0 0 1 1.995.31c.642.207 1.009.311 1.1.311.207 0 .35-.059.429-.178a1.53 1.53 0 0 0 .192-.47h.557v4.072z" fill="#454545"/><path fill="#454545" d="M4 8.827h12v1H4z"/></svg>

Choose a reason for hiding this comment

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

@Natim just to confirm this is a different icon now right? not the one you got from the internet? 😄

Copy link
Author

Choose a reason for hiding this comment

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

Yes that's @oleq one.

@vladikoff
Copy link

CI fail with:

Chrome 62.0.3202 (Linux 0.0.0) ERROR
  Uncaught Error: Cannot find module "../src/strike"
  at tests/strikethrough.js:53179
Chrome 62.0.3202 (Linux 0.0.0): Executed 0 of 0 ERROR (1.17 secs / 0 secs)
Coverage report saved in '/home/travis/build/ckeditor/ckeditor5-basic-styles/coverage'.

const editor = this.editor;
const t = editor.t;
const command = editor.commands.get( 'strikethrough' );
const keystroke = 'CTRL+SHIFT+X';

Choose a reason for hiding this comment

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

"""
Firefox: Set direction using the CTRL/CMD+SHIFT+X keyboard shortcut, which cycles through LTR and RTL. It does not set the value of the element's dir attribute, and is thus invisible to scripts.
"""

From https://www.w3.org/International/questions/qa-html-dir

We somehow got into this issue here: mozilla/notes#409

view.set( {
label: t( 'Strikethrough' ),
icon: strikethroughIcon,
keystroke,
Copy link

@vladikoff vladikoff Nov 21, 2017

Choose a reason for hiding this comment

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

It our version the tooltip does not show "X" in the tooltip? is this also affected by this?

image

Copy link
Member

Choose a reason for hiding this comment

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

@vladikoff I check that out and I found out it's a bug https://github.com/ckeditor/ckeditor5-utils/issues/206.

Copy link
Member

Choose a reason for hiding this comment

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

@szymonkups Could you check if ckeditor/ckeditor5-utils#207 fixes the issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

@oleq - checked, tested and merged :)

@szymonkups szymonkups merged commit 78719c9 into ckeditor:master Dec 5, 2017
@vladikoff
Copy link

Awesome!!

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

Successfully merging this pull request may close these issues.

7 participants