-
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
Add preserving custom colors feature #3784
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.
I took first look at this PR, but before we go with a full review, let's resolve issues on how the feature should work, as I'm not sure if specification fully covered use cases.
I have some doubts about the current color matching algorithm, but I may have a bit different view of how this feature could work. Overall, it seems nicely match colors from editor content + colors matched from the color dialog. However, it's a bit hard to find out from UX how the whole feature works and I'm not sure if we didn't slightly miss the point of the feature usability.
The main doubt is about what's more important for a user: match available colors in current editor content or show the latest chosen color in the quick access panel.
It's somehow more convenient from my perspective that this feature:
- Finds out all available content colors on the first color button opening to fill empty quick access panel as at this point I didn't choose anything manually. Sort them in some smart order e.g. from the start of the content.
Content colors:
red | blue | yellow | green
- If I have chosen color manually it's moved at the beginning of the quick access color row. The last color is removed if there is no space left. It doesn't matter if color is chosen from a color dialog or just predefined panel color - at this point, a quick access row is treated as the color history. I know specs tell that we don't want duplicate colors, but if we don't, it breaks feature flow and makes it less user-friendly. You shouldn't really find out how things works, it should just 'click' on the first peek.
Chosen black:
black | red | blue | yellow
- If I choose the same color twice, it's moved at the beginning, but the rest of the colors stays at their position (-1 because the color from the end has been moved, but nothing removed).
Chosen yellow
yellow | black | red | blue
Of course, currently, we have 2 separate rows, one for document content colors and the second for colors chosen from the color dialog. However, after some clicking, I'm not sure about UX and if it's worth to separate both features 🤔 Maybe additional config option for more color rows could cover cases where someone would like to have a "bigger picture".
Also, please take a look at what's going on with CI.
I have some additional feedback regarding @jacekbogdanski #3784 (review). The initial specs was about having one custom colors row, you have decide to split it to two - which I'm fine with as long as it works intuitively. Content colors rowContent colors - seems to be showing colors used in the content. The problem here is that, both custom colors from the content appears there (so pasted from Word or added manually via source mode) and colors picked from color panel/dialog too 🤔 So these are just all colors used but sorted in order based on their appearance in the content. So from my perspective, it should only show colors which were not picked manually from color panel or dialog - only these which appeared there other ways (paste, etc). And as mentioned in #1795 as we treat them as content colors these should be sorted by number of appearances:
and if the number is the same I would be for sorting them in order of appearance in the content (we didn't covered this in #1795). Custom colors rowI know those are only colors picked from dialog, however it seems unintuitive for me as picking color from dialog or panel has the same effect - the dialog is just an extension of the panel with more colors so these should be treated the same way. Also since colors added from dialog also appear in the content, they are also shown in the Content colors row which might be confusing 🤔 Getting back to @jacekbogdanski #3784 (review) it seems to be in tact with what we drafted as sepcs some time ago here - #1795 (comment) and so:
Agree. The only thing I'm not sure and is different in the initial specs is:
The idea was here that you can open color panel and apply some color (or even just open/close), then paste some colorful content and then open color panel again - shouldn't we fill empty color slots with the colors that appeared in the content?
Color should be moved to the beginning when picked (from panel, dialog or even or custom colors row) as mentioned. What about duplicating colors? Can't we just move picked color to the beginning and left the empty slot on the end (or fill with white or next content color available)?
Not sure what's the difference between this point and previous one 🤔 @jacekbogdanski Consider your scenario wit a little different set of colors:
wouldn't it be simpler with just two steps:
|
@Dumluregn can you add a shot summary what we agreed on during F2F talk? |
Sure:
|
I think we agreed on config option for number of custom colors rows? @jacekbogdanski? The rest of the summary looks good 👍 |
Hm you may be right. I edited the summary. |
Yes, could be useful to preserve more colors from content if needed. |
One more thing I think we agreed to do was to ask some non-tech or UI people to test the solution. |
Yeah, but let's create the solution first 😄 |
Failing CI can be fixed by rebasing after #3744. |
445f68d
to
50c4750
Compare
Rebased into the latest upstream. |
a19cd53
to
8f06cb0
Compare
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.
Smaller issues
- Failing test on Chrome:
- There are multiple errors when running unit tests in dev console:
- There is no need to overuse config.colorButton_colorsPerRow configuration option in manual tests. We just need one single manual test dedicated to this option to make sure that history row is correctly updated depending on the available colors.
Proposed architecture
I see that you tried to update current implementation with a more OOP approach, so 👍 It seems like we could even more clean up this code by introducing more component-based implementation. Overall, we should try to go with a similar class structure to:
in its a basic form of public/internal API. I created a very simple structure using mostly pseudo code here: t/1795...t/1795b - please, take a look, maybe it will give you some clues about how we could improve the code. Mostly, it's just about moving proposed functions into these 3 classes and hiding logic inside smaller components. We will be able to save DOM elements references in that case, which should improve performance, readability and hide function signatures with too many arguments.
The current implementation of the colorbutton should also reuse ColorBox
and ColorRow
to generate panel HTML.
Of course, if you find out it too time-consuming, tell so we can find some golden mean.
@jacekbogdanski do you want me to rebase this PR onto latest |
There are some merge conflicts, so yes please @Dumluregn |
Rebased onto latest |
CI failed because some code was lost during rebase, so please pull this branch again. |
Co-authored-by: Jacek Bogdański <jacekbogd@gmail.com>
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.
Good job @Dumluregn 🎉 We are ready to merge 🔥
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
What is the proposed changelog entry for this pull request?
What changes did you make?
Features
Implementation is mainly based on conclusions listed here, but during development I made one significant change - in palette there are two separate sections for
Content Colors
(colors found in the editor content - checked on everycolorbutton
panel open) andCustom Colors
(colors picked from color dialog). Without this division the palette was changing unintuitive when e.g. some parts of coloured text were deleted.Thanks to that it was also possible to implement both features independently, so theoretically this PR could be divided into two if it's easier to work with for reviewer.
Unit tests
bender-tags
or not), for now I just added references for the whole files as it was quicker way. If we determine that adding tags for each test is better, of course I'll change it.Text Color
andBackground Color
buttons and the only difference between them is that they should track colors independently, so only tests checking setup are doubled - the core features are tested only forText Color
. If this is insufficient, of course I'll change it.Manual tests
PS
and in this format the color will not be displayed in palette (which makes sense with because default ACF settings don't allow this construction).
As for now this feature only finds colors expressed in hex code attached to spans through
style
attribute, like here:But I just realised that the below snippet is also fine for ACF:
so probably it should work too, and now it doesn't... So I'll fix that after the first review :)
Which issues your PR resolves?
Closes #1795.
Closes #3783.