-
Notifications
You must be signed in to change notification settings - Fork 40
I/3287: Styles normalization (part of table styles) #1807
Conversation
So after ~58 commits this PR has:
|
~59th commit: year bump :P |
Welcome back, i/3287! 🤚 |
|
@Reinmar done. |
I get the above red tests in ckeditor5-indent for this setup:
|
@Reinmar That's right I didn't check the Indent package. After digging up I've fixed their test on Now back to your comment about consumables - when fixing this PR I've forgotten about that case so I've just removed that code which did 2 things:
The point 2. does look like too much but point 1 looks useful for conversion helpers. How to repair this?
Right now the logic for creating view consumable names gets the style names from view element and uses only them. In other words, testing for consuming ps.: this might be a follow-up as |
We've had a F2F discussion with @jodator and @scofalik and decided that:
|
@Reinmar I've gone with a previous logic but re-implemented with an ability to "enable" it in view consumable. The idea of consuming "also" works the same (I've restored previous tests). The only different thing which I've done in my commit is that I've restored the previous "consumeAlso" logic without |
I created a followup for the border processor as I don't like how it works: ckeditor/ckeditor5#6090. Not necessarily it29 material though. |
I found a quite big problem with our style processor singleton: ckeditor/ckeditor5-utils#312 (comment) and I'm having troubles figuring out what we could do with it. |
Extracted that to ckeditor/ckeditor5#6091. Other than that, I think we're good to merge these 4 PRs. |
Tests: Align tests to the changes in styles normalization. See ckeditor/ckeditor5-engine#1807.
Internal: Remove obsolete converter after introducing style normalization. See ckeditor/ckeditor5-engine#1807.
Tests: Align tests to the changes in style normalization. See ckeditor/ckeditor5-engine#1807.
Suggested merge commit message (convention)
Feature: Introduce CSS style normalization for conversion. Closes ckeditor/ckeditor5#6047.
This is a sub PR for table styles: ckeditor/ckeditor5-table#224.
PR constallation
font
: I/3287: Align code to styles normalization ckeditor5-font#57indent
: I/3287: Align code to styles normalization ckeditor5-indent#21utils
: Use other style in normalizeHtml tests. ckeditor5-utils#312Description
This PR comes as an outcome for works to enable table styles (mainly
border
shorthand) management. What we have lacked before was a better way of converting fromstyle
attribute entries because of CSS shorthand values.Proposed solution.
Styles
class that handles style normalization on write and on reading.styles.setStyle( 'border:1px solid blue;margin: 1px' )
styles.insertProperty( 'border', '1px solid blue' )
by writing shorthand or longhand valuesstyle
attribute or singe value. The output is standardized and predictable.Style
instance internally inview/Element
instead of simpleMap
.StylesConverter
that provides a single entry point for defining normalization, extraction and inlining the styles.normalize:css-property-name
, to normalize a single entryreduce:css-property-name
, to get "reduced" form to use as inline style (other ideainline:css-property-name
extract:css-property-name
this event is used to extract some form of normalized value - againborder
here:Border stored as
{ color: { top, right, bottom, left }, style: { ... }, width: { ... } }
but for inline style is extracted asborder-top
,border-left
, etc - which combines all of them. Another case is extractingborer-top-color
longhand property. This is and edge-case (I didn't analyze other CSS properties) as most of the implemented properties are two-level values.consumeAlso
mapping (should be moved somewhere fromViewConsumable
). It solves the problem of consuming single entry from a shorthand. The first example is indented block converter which consumes onlymargin-left
(in LTR, I'll skip all the RTL variants) so IMO themargin
style should be consumed also butmargin-right
,margin-top
andmargin-bottom
should be available for other converters to process. Similarly, if some converter consumesmargin
allmargin-
longhands should be consumed.font
shorthand (... )What this solves?
The main idea is that inline style can be written in many, many ways — especially the
border
shorthand sets 12 longhand properties (border-top-color
,border-left-width
, etc). Also, at least for the border, there are another 7 shorthands:border-top
,border-right
, ... andborder-color
,border-style
,border-width
which overlaps each other. Writing converters for each possible combination would result in around 20 converters (12 longhands, 8 shorthands) that could interfere with each other. This isn't a problem for styles coming from CKEditor as we always control this. The problem occurs if the styles come from other editors, pages, etc - there are various ways of writing the same and we can solve most of them by normalizing incoming styles.Also it should parse shorthand properly as, ie for border shorthand the order of values doesn't matter so:
border: 1px solid blue
===border:solid blue 1px
===border: blue 1px solid
.Anather thing is to simplify converters - especially the partial ones (
margin-right
).