Skip to content
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

Added possibility to use custom icons in buttons #1531

Merged
merged 13 commits into from
Feb 6, 2018
Merged

Added possibility to use custom icons in buttons #1531

merged 13 commits into from
Feb 6, 2018

Conversation

f1ames
Copy link
Contributor

@f1ames f1ames commented Jan 30, 2018

What is the purpose of this pull request?

New Feature

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

Added possibility to use custom icons in buttons as described in #1530.

The only problem here was that there already had benn an undocumented definition.icon property which was used to display icon defined by another plugin.
This caused definition.icon property to be more complex and docs get a little more complex too (well, there wasn't any before).
Still, this behaviour has been preserved and plays nicely with the new one. I also added tests covering both behaviours.

Closes #1530.

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

More like thoughts than real issues.

assertIcon(
{ extraPlugins: 'link' },
'Link',
isDev ? /plugins\/link\/icons\/link\.png/gi : /plugins\/icons\.png/gi
Copy link
Member

Choose a reason for hiding this comment

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

All these assertions for standard icons differ only with plugin name. Maybe it could be simplified?

@@ -0,0 +1,225 @@
/* bender-tags: editor */
Copy link
Member

Choose a reason for hiding this comment

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

There is no test for adding custom icon for standard buttons (e.g. Bold). It should be possible by overwriting button.icon property before rendering.

/* bender-tags: editor */
/* bender-ckeditor-plugins: button,toolbar */

var editorCounter = 0,
Copy link
Member

Choose a reason for hiding this comment

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

Won't it be better to encapsulate such variables inside IIFE?

);
},

'test default button icon (hidpi)': function() {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, personally I'd simplify tests and encapsulate switching between standard/hidpi inside createIconTest or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is problematic due to a fact how icons are registered. Icon is registered on plugin init so when plugin is loaded on standard resolution standard icons are initialized. Then switching to HiDPI and creating new editor (with same plugin) would not reregister the icons so the standard one is still in use.

This is the reason standard an HiDPI tests use different plugins. This is also a reason why generating two tests (standard one and HiDPI) from one editor config doesn't make sense thus auto generation doesn't make much sense (since you have to pass two different set of settings).

I refactored the tests creation to be more automated, however still standard and HiDPI tests are not generated form one set of settings.

@f1ames f1ames force-pushed the t/1530 branch 2 times, most recently from 5b56ee3 to d02bfcf Compare February 2, 2018 13:57
@f1ames f1ames requested a review from Comandeer February 2, 2018 13:59
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

Tests are failing on built version
screen shot 2018-02-02 at 16 20 32

@f1ames
Copy link
Contributor Author

f1ames commented Feb 2, 2018

😭 Strangely, it should have standard (not HiDPI) set of icons... Probably for built version, setting manually CKEDITOR.env.hidpi works different (or not at all) than in dev one.

@f1ames
Copy link
Contributor Author

f1ames commented Feb 5, 2018

The cause of failing tests is the way how tests are run with build version, check this comment for more details - b2d9f31#diff-6dfbc137c0c9a9951601ec7b03d6033aR17.

@f1ames f1ames requested a review from Comandeer February 5, 2018 10:12
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

Actually there is one more thing that I find troublesome: blue icons in manual test… TBH icons are so small that I can't recognise if icons are blue or black. Maybe red icons would be better?

Everything else is fine 👍

@f1ames
Copy link
Contributor Author

f1ames commented Feb 5, 2018

Change sample icons color to red.


Also I found one issue. After the bc3293f change, where iconPath was used as iconName for custom icons, it generated invalid CSS class names:

screen shot 2018-02-05 at 17 12 51

as class is based on iconName which had iconPath value. I updated the code so the iconPath and iconName are now properly used, see 4820163.

@f1ames f1ames requested a review from Comandeer February 5, 2018 16:38
@Comandeer
Copy link
Member

Actually this is valid CSS class, that could be represented by escape sequence. What's more, it's also valid HTML class.

E.g. trust_me/I'm.engineer is valid HTML class, which could be represented by .trust_me\/I\'m\.engineer in CSS. It's interpreted correctly even in IE8.

So this change wasn't necessary, but at least we have nicer classes now ;)

@Comandeer Comandeer deleted the t/1530 branch February 6, 2018 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants