-
Notifications
You must be signed in to change notification settings - Fork 9
Add the strikethrough feature. #58
Add the strikethrough feature. #58
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should change.
src/strikeengine.js
Outdated
*/ | ||
|
||
/** | ||
* @module notes/ckeditor-build/strikeengine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should change.
Thanks! To merge it, we'll also need an:
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ;|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be sent automatically. Let us know if you don't get it. |
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 I would be glad to take your reviews as well. |
I pushed an improved strike icon. Please note that it will be refactored in ckeditor/ckeditor5#645 anyway. |
Nice thanks !! Any idea of how to fix the shortcut? Should I remove it for now? |
I've been a bit unsure about the view element name – whether it should be |
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:
|
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. |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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' ), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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". |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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()
};
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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. |
I'd go with |
Ok I will make the change then 👍 |
src/strikethrough.js
Outdated
@@ -0,0 +1,68 @@ | |||
/** | |||
* @license Copyright (c) 2017, CKSource - Rémy Hubscher. All rights reserved. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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? 😄
There was a problem hiding this comment.
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.
CI fail with:
|
const editor = this.editor; | ||
const t = editor.t; | ||
const command = editor.commands.get( 'strikethrough' ); | ||
const keystroke = 'CTRL+SHIFT+X'; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
Awesome!! |
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.