-
Notifications
You must be signed in to change notification settings - Fork 6
Fix various issues with todo list converters #154
Conversation
I haven't come up with an idea to use mapper. That's the only reason :P Markers should be rendered after the checkbox element and it's better when attributes don't wrap the checkbox so you change is 👌 I removed "some" code that has become unnecessary after using mapper dce5c7b :D |
src/todolistediting.js
Outdated
|
||
if ( label ) { | ||
if ( label.nextSibling ) { | ||
data.viewPosition = view.createPositionAt( label.nextSibling, 0 ); |
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.
You should ensure that nextSibling is not an UIElement. Selection converter will try to break it (that's why one unit test is red).
UIElement is used to represent a selection of collaborative users, so when two users put selection at the beginning of the totoList
item it's gonna 💥 💥 💥
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.
Thanks for the clarification :) I'm still not used to the markers :/
Again, thanks for the help @oskarwrobel now the todo list should work even better :d . @Mgsy could you verify that this works now? The main disruptor here was any text attribute (bold, link, highlight, etc) at the beginning of the list item. It caused the problems from ckeditor/ckeditor5#2009:
ps.: it fixes also the ckeditor/ckeditor5#1980 :D |
} | ||
|
||
// Map the position to the next sibling (if it is not a marker) - most likely it will be a text node... | ||
if ( label.nextSibling && !label.nextSibling.is( 'uiElement' ) ) { |
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'm afraid checking only the next element won't be enough. There could be more UIElements at the beginning of the list item. You should walk over them and find a node after the last one.
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.
Check the test - it works. We return a position after our UIElement so others are properly (in order of insertion) inserted to the model. For me it is OK.
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.
Yep, you are right. It works fine.
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.
LGTM.
# Conflicts: # src/todolistediting.js # tests/manual/todo-list.js # tests/todolistediting.js
Since I didn't see an explicit test for it and it is breaking our conversion to Markdown todo-lists, is the following output from the nightly todo list as expected? This means that the label does not always wrap all content of the todo list, resulting in two different parsing behaviors for the todo list output in our case.
|
Hm... it seems to be a bug. The label should always be the outermost element. Could you report a separate ticket for it? |
Suggested merge commit message (convention)
Fix: Use model-to-view position mapping in todo list. Closes ckeditor/ckeditor5#2009. Closed ckeditor/ckeditor5#1980.
The todo list converters always assumed that checkbox ui element is the first child
of a list item in the view. This failed with attribute element converters which wrapped
whole list item contents, including the checkbox, with their attribute element
(e.g.
<strong>
). This changed the first child of the list item and caused problemwith typing or changing list type in the editing area. This change makes sure that
position at the begining of a list item from model is mapped after the checkbox
ui element in the view.
Additional information
Notes from draft PR
So I have some questions about this: todo list + markers - why the previous solution didn't just map the positions? Is it because of the markers? After my change, you cannot create a highlight that covers the whole
<li>
- it will be set after the checkbox.Fixing position mapping in helps with:
The problem for the above wast that the converters assumed that the first child was always a
label
for the checkbox but with the text attributes (bold, link) the associated view element was wrapping theli
contents and the ui element (label). Fixing the position mapping so the view position is always set after the ui element keeps the ui element as the first child and other converters also properly render their view (ie only wraps the text of theli
excluding the UI element./cc @oskarwrobel - with a question about the implementation - maybe I'm missing something
/cc @scofalik How this should work with the markers? Or this should the markes be rendered differently on a todo item?