-
Notifications
You must be signed in to change notification settings - Fork 40
T/404: Better handling of block filler. #1779
Conversation
So for PFO some tests fail because: <p>
<span><img src="..."></span><span style='mso-spacerun:yes'> </span>foo
</p> is expected to be: <image src="foo.jpg"></image>
<paragraph>foo</paragraph> which is IMO wrong as this should have space inserted before |
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 left a comment in #404. I think that this algorithm must work differently.
@Reinmar OK the code is fixed and we should be able to: editor.setData( '<p><strong>a</strong> <i>f</i></p>' ); The PR in PFO was also updated to reflect latest findings about tests and the PFO internals. In one test I had to add space between blocks ( |
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.
As commented.
src/view/filler.js
Outdated
} | ||
|
||
// Name of DOM nodes that are considered a block. | ||
const blockElements = [ 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ]; |
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 I don't like that this duplicates the code from a DomConverter
- maybe we should intorduce isBlockElement()
in ckeditor5-utisl/dom? That this could be unified there.
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 should use the same block elements array which is defined in DomConverter
. The idea is that it can be extended by someone else if needed. So, we need to find a way to make filler.js
us that property.
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.
One option would be to have a module here (in the engine) which exports a table.
This module would be imported by both domconverter.js
and filler.js
. The instance of this array would be shared by those modules. So, if you'd extend DomConverter.blockElementNames
that'd also extend the value used by the filler.js
module.
The downside of this would be that this would become a singleton. All editor instances would share this table. In fact, that'd mean that if you'd like to extend this array in your plugin's code (cause it adds some new element support to the editor), if you'd run 10 editors on one page, this element would be added 10 times. That's quite ugly.
So, I'd rather go in a different direction – e.g. move isBlockFiller()
to DomConverter
. Perhaps it doesn't make sense to have this as contextless util. Maybe it needs to be a part of bigger context.
@Reinmar I've rewritten the checks as we talked. Requires:
|
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.
The solution looks fine. The only place where we need to find some solution is how we share the block element names with DomConverter
. Unfortunately, we need some central, publicly available place for that.
Co-Authored-By: Piotrek Koszuliński <[email protected]>
Co-Authored-By: Piotrek Koszuliński <[email protected]>
It makes sense to tie the I've refactored the code so now you can check if a node is a block filler on the |
# Conflicts: # tests/view/renderer.js
FYI: I've just removed entire |
Added them in #1808. |
Suggested merge commit message (convention)
Fix: Remove only real block fillers on DOM to view conversion. Closes ckeditor/ckeditor5#3704.
Additional information
ATM this PR fixes all the issues addressed with handling
in the data. I'm not however 100% satisfied with this solution because of a need to handle<br data-cke-filler="true">
in editing differently than
in data pipeline.For editing pipeline the
isBlockFiller()
is pretty straight forward as we checknode.isEqualNode()
wchich compares two DOM nodes by theirs attributes. However for
we compareText
elements by string equality. In
case we need to detect if the block filler belongs to data or is it negligible in given context.The other solution that came to my mind is to allow passing a
isBlockFiller()
check toDOMConverter
along withblockFiller
option thus explicitly changing theDOMConverter
for editing and data pipelines. The drawback is that you have to remember to pass this method when not using deafult block filler (<br>
).<b>&npbsp</b>
and<b>foo</b> <i>bar</i>
cases but this is to be extended before merging.ps.:
Some tests in PFO are failing - I'll be investigating this.I've added a sub-pr for PFO: ckeditor/ckeditor5-paste-from-office#81 (branch
t/ckeditor5-engine/404
.Requires: ckeditor/ckeditor5-utils#302.