-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font options are not toggleable any longer #615
Conversation
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.
Looks good, some minor changes needed.
Have you used langtool to generate language files? I don't see any new entry in meta language files.
plugins/font/plugin.js
Outdated
this.startGroup( lang.panelTitle ); | ||
|
||
for ( var i = 0; i < names.length; i++ ) { | ||
var name = names[ i ]; | ||
// Add `(Default)` item as first element on the drop down list. |
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.
// Add
(Default)
item as a first element on the drop down list.
plugins/font/plugin.js
Outdated
endBoundary, | ||
node, | ||
bm, | ||
defaultValue = 'cke-default'; |
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.
Same default value is already defined in an init
method, maybe it could be extracted somewhere to be more "global"? Especially that it is used also in other places (tests).
plugins/format/plugin.js
Outdated
|
||
editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style ); | ||
// Always aply style, do not allow on toggle it by clicking on list item (#584). |
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.
// Always apply style, do not allow on toggle it by clicking on list item (#584).
plugins/format/plugin.js
Outdated
|
||
editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style ); | ||
// Always aply style, do not allow on toggle it by clicking on list item (#584). | ||
editor.applyStyle( style ); |
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.
By default all format tags are block elements so reapplying them to partial selection doesn't do anything. However, if you change the config like:
config.format_p = { element: 'span', attributes: { 'class': 'normalPara' } };
You can apply it to partial selection despite the fact it was already applied (so it creates nested tags). This is an edge case IMHO but still we should handle this. You could just check if style is active (as before style.checkActive( elementPath, editor )
) and apply it only if it is not already there.
tests/plugins/font/font.js
Outdated
@@ -170,6 +172,43 @@ | |||
'<p>x<span style="font-size:12px"><em>foo</em></span><em><span style="font-size:24px">bar</span></em>x@</p>' ); | |||
}, | |||
|
|||
// #584 |
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.
Is there any test checking if second click (reapplying) of the same font/size doesn't change the 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.
I see there is on in a format
plugin. Still those are separate plugin with different code so it should be tested for both.
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: wysiwygarea, toolbar, font, elementspath, sourcearea | ||
|
||
1. Select text |
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.
Each list item should end with .
. Select some text
sounds a little better.
I hope it is fixed now :) |
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.
@@ -81,3 +81,4 @@ common.keyboard.36 = Label for the "Home" key. | |||
common.keyboard.46 = Label for the "Delete" key. | |||
common.keyboard.224 = Label for the "Command" key. | |||
common.keyboardShortcut = ARIA message for keyboard shortcuts. | |||
common.optionDefault = "(Default)" option for drop-down menues of text styling, which removes specific style. |
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.
Maybe something like:
Label for "(Default)" option in drop-down text-styling menus. Using such option restores default styling.
plugins/font/plugin.js
Outdated
this.startGroup( lang.panelTitle ); | ||
|
||
for ( var i = 0; i < names.length; i++ ) { | ||
var name = names[ i ]; | ||
// Add `(Default)` item as a first element on the drop down list. |
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.
Use consistent naming: drop-down.
tests/plugins/font/font.js
Outdated
this.assertCombo( 'Font', 'cke-default', false, bot, '<p>foo@</p>' ); | ||
}, | ||
|
||
'test reaaply this same font size twice': function() { |
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.
reapply
tests/plugins/font/font.js
Outdated
|
||
}, | ||
|
||
'test reaaply this same font family twice': function() { |
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.
reapply
@bender-ckeditor-plugins: wysiwygarea, toolbar, font, elementspath, sourcearea | ||
|
||
1. Select some text. | ||
1. Change `font size`, (e.g. `24`). |
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.
Redundant comma after size
:
- Change
font size
, (e.g.24
).
@bender-ckeditor-plugins: wysiwygarea, toolbar, format, elementspath, sourcearea | ||
|
||
1. Select text | ||
1. Try to apply multiple times this same format to one selection (different than normal). |
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.
Try to apply same format (other than
Normal
) multiple times.
?
1. Select text | ||
1. Try to apply multiple times this same format to one selection (different than normal). | ||
|
||
**Expected:** Choosen format should remain this same all the time. |
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.
should remain
thisthe same all the time.
|
||
**Expected:** Choosen format should remain this same all the time. | ||
|
||
**Unexpected:** Text format toggle between styled and unstyled (Normal) one. |
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.
toggles
tests/plugins/format/plugin.js
Outdated
@@ -25,5 +25,29 @@ bender.test( { | |||
bot.setHtmlWithSelection( '<fieldset><legend>^foo</legend><form>bar</form></fieldset>' ); | |||
var name = 'Format', combo = ed.ui.get( name ); | |||
assert.areSame( CKEDITOR.TRISTATE_DISABLED, combo._.state, 'check state disabled when not in context' ); | |||
}, | |||
|
|||
// Drop down format menu should not have possibility to toggle option (#584). |
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.
Drop-down
tests/plugins/format/plugin.js
Outdated
combo = editor.ui.get( name ); | ||
|
||
bot.setHtmlWithSelection( '<p>^foo</p>' ); | ||
// apply format 1st time |
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.
Use full sentences, e.g. Apply format 1st time.
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.
Earlier mentioned tests (despite the fact it was adjusted) seems to still be unstable on IE8. When run in group it seems to fail in most cases. When only test suite is run it fails like 50% of times. When the test itself is run it sometimes fails. Seems like some issue with focus, if I click inside a browser window before running in most cases it works.
I see this test was based on an existing one, but the former one seems to work fine. Maybe it affects the second test somehow?
plugins/format/plugin.js
Outdated
@@ -67,7 +67,10 @@ CKEDITOR.plugins.add( 'format', { | |||
var style = styles[ value ], | |||
elementPath = editor.elementPath(); | |||
|
|||
editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style ); | |||
// Always apply style, do not allow on toggle it by clicking on list item (#584). |
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.
Always apply style, do not allow to toggle it by clicking on corresponding list item (#584).
?
tests/plugins/font/font.js
Outdated
@@ -35,8 +48,10 @@ | |||
|
|||
this.wait( function() { | |||
// Click again to exit the style. | |||
// Since 4.8.0 2nd click into this same menu item do not unselect 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.
Since 4.8.0, 2nd click on the same menu item does not unselect it.
tests/plugins/font/font.js
Outdated
@@ -35,8 +48,10 @@ | |||
|
|||
this.wait( function() { | |||
// Click again to exit the style. | |||
// Since 4.8.0 2nd click into this same menu item do not unselect it. | |||
// It is required to click into '(Default)' option to reset style (#584). |
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 required to click on the '(Default)' option to reset style (#584).
tests/plugins/format/plugin.js
Outdated
bot.combo( name, function( combo ) { | ||
assert.areSame( CKEDITOR.TRISTATE_ON, combo.getState(), 'check state ON when opened' ); | ||
combo.onClick( 'h1' ); | ||
assert.areSame( '<h1>f^oo</h1>', bot.htmlWithSelection(), 'applied h1 block style' ); |
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.
applied h1 block style
h1
was not applied here as it was already there. The test (and assert) check if h1
is not removed when applied second time, so maybe preserved h1 block style or something similar?
It seems that sometimes IE8 on some system can have strange behaviour. I removed checking if the format panel is opened and left only checking styles if it's properly applied. |
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.
LGTM!
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
yes
This PR contains
What changes did you make?
(Default)
option to font size and font family name, which remove formating from selectionDefault
tolang.common
fileclose #584