Ck/12467 inser content does not insert markers
Suggested merge commit message (convention)
Other (engine): The functionality of the insertContent method has been extended by handling markers. Closes #12467.
Additional information
This improvement has been implemented to allow Import from Word plugin to work correctly.
@scofalik all done (I hope so...). You can review it again.
I forgot to mention that the issue with merging $marker element is still existing. We need to figure out how to fix it.
@scofalik it's ready to review. However, there are still issues that we discussed and will be fixed in the following tasks:
- We use
affectedRangeto calculate starting and ending markers' positions. It causes that sometimes markers are created in the wrong place (like inserting imageBlock inside paragraph):
// <paragraph>Fo[]o</paragraph>
// {<imageBlock></imageBlock>}
//
// <paragraph>Fo{</paragraph><imageBlock></imageBlock><paragraph>}o</paragraph>
- Sometimes, when we set the custom selection the resulting insertion is wrong (it's not connected to markers):
setData( model, '<imageBlock></imageBlock>[]<imageBlock></imageBlock>' );
insertHelper( '<imageBlock></imageBlock>', null, [ 1 ] );
expect( getData( model ) ).to.equal( '[<imageBlock></imageBlock>]<imageBlock></imageBlock><imageBlock></imageBlock>' );
Regarding your previous post:
- Please create an issue to improve current solution. Title: "
insertContent()should not depend on affected range when inserting markers". - I think this happens because in
setData()(or rather: just after) the selection is autofixed to[<imageBlock></imageBlock>]<imageBlock></imageBlock>. After you insert between the paragraphs, it does not affect document selection in any way. Since you passed the selection by hand toinsertContent(),insertContent()does not change the document selection either. So, everything looks good here, after all.
What about a case where marker starts in filtered content but ends in non-filtered content (and vice versa)?
@scofalik you can take a look at it again.
@arkflpc Could you look at it from TS perspective?