Opened 11 years ago
Closed 11 years ago
#11027 closed Bug (fixed)
Block commands break on widget
Reported by: | Piotrek Koszuliński | Owned by: | Piotr Jasiun |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.3 |
Component: | General | Version: | |
Keywords: | Cc: |
Description
Follow up for #10822.
Umbrella ticket for issues like:
- List commands sometimes clone contents, so references are lost and widgets are destroyed.
- Block with only non-editable content are not turned into list items.
- Blocks with only non-editable content are not idented.
- Indent on fake selection (e.g. mathjax) throws an error.
- List command on fake selection throw an error.
- Blockquote does not work with non-editable elements.
- Indent stops on first non-editable element.
- Perhaps more...
Change History (17)
comment:1 Changed 11 years ago by
Owner: | set to Piotrek Koszuliński |
---|---|
Status: | new → assigned |
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
I pushed additional commit (plus test) for the error being thrown when applying block commands.
It's a very complicated situation:
- We've got fake selection and it's locked.
- After blockquote is applied it restores the remembered selection.
- This causes another selection.fake() call.
- This causes hideSelection method (from core/selection.js) to be executed.
- It wants to lock a undo manager, because it's going to add a hidden selection container.
- To lock snapshot, undo manager was creating images which store the selection in form of bookmarks2.
- However, it takes the locked (fake) selection and fresh content.
- And the content has been changed in the meantime... Odd thing - why only on Chrome? (tc was not reproducible on FF).
- This means that there's a conflict between selection and contents and that's why createBookmark2 throws an error.
Now, there are two things which should be fixed:
- Undo manager does not have to create full images with selection - it can only create faster contents images. This way, we'll not call createBookmark2 at all. And that's what I pushed in t/11027.
- But... is this situation correct at all? Shouldn't be selection invalidated (reset) before new one is done? On the other hand - it may be possible that lockSnapshot (or other selection&content sensitive method) is called after DOM is changed while selection is fake. Won't it throw errors then?
- Additional question - why second hideSelection call does not create another hidden selection container :|? When is the hiddenContainer for initial selection removed?
comment:4 Changed 11 years ago by
Additional question - why second hideSelection call does not create another hidden selection container :|? When is the hiddenContainer for initial selection removed?
Answer: Because when faking new selection and creating new container for it we use selection.setRanges()
to place the real selection in its container. This causes reset()
which removes old container... I guess it should not be so tangled, so I pushed a commit which adds this.reset()
at the beginning of fake()
method. It also (this commit) fixes the error thrown from createBookmark2, so we've got two patches for this one issue.
Although, I think that there's still a scenario in which it may blow up, but let's not waste time on trying to find it.
comment:5 Changed 11 years ago by
Owner: | Piotrek Koszuliński deleted |
---|---|
Status: | assigned → confirmed |
comment:6 Changed 11 years ago by
Owner: | set to Piotr Jasiun |
---|---|
Status: | confirmed → assigned |
comment:7 Changed 11 years ago by
Status: | assigned → review |
---|
I fixed list issue. Now list operations which use list-array transformation fire domInvalidated
event which call widget.repo.checkWidgets
.
I also extend checkWidgets
function to recreate broken widgets.
Tested with list indent and changing list type and everything seems to be fine now.
Changes in t/11027 and tests in corresponding branch.
comment:8 Changed 11 years ago by
Status: | review → review_failed |
---|
Missing space:
if( !this.getByElement( wrapper ) ) {
Also, getByElement
accepts 2nd argument, which limits check to wrappers, so it's a lot faster.
I don't like the name of the event - domInvalidated
. I cannot say why, but I don't like it :D Something more positive maybe? domReloaded
?
Mentioning in event's docs about widgets does not clarify event's meaning unless someone knows widget architecture. I would simply remove that part.
Why did you put event's docs in widget plugin? It is a core widget.
There are no comments in the code. For example - how would someone know why cke_widget_new
is added?
this.initOn( wrapper.findOne( '.cke_widget_element' ) );
findOne
is not very lightweight method (check its code to learn why), so I would use getFirst( isWidgetElement2 )
:
See similar code in initOnAll
:
this.initOn( newWidgets.getItem( i ).getFirst( isWidgetElement2 ) );
comment:9 Changed 11 years ago by
I don't like the name of the event - domInvalidated. I cannot say why, but I don't like it :D Something more positive maybe? domReloaded?
I just remembered about contentDom
and contentDomUnload
. The new proposed event is similar to them, so in my opinion should start with contentDom
. E.g. contentDomReloaded
.
comment:10 Changed 11 years ago by
Status: | review_failed → review |
---|
- renamed
domInvalidated
tocontentDomInvalidated
, - docs improvements,
- performance improvements.
comment:11 Changed 11 years ago by
Status: | review → review_failed |
---|
- There are no tests for changes in
widgets.repository#checkWidgets
. - Test for widget reloading on lists change should be split into two separate parts:
- tests that list features fires
contentDomInvalidated
, - tests that e.g. after
editable().setHtml( editable.getHtml() )
and firingcontentDomInvalidated
widgets are reloaded.
- tests that list features fires
Also, I changed my mind regarding checkWidgets event. It should be used instead of direct method usage. I think we should keep both checkWidgets and checkSelection events, because the latter one already proved that it's usefull.
comment:12 Changed 11 years ago by
Status: | review_failed → review |
---|
- I've split existing tests and added new ones.
contentDomInvalidated
event now firecheckWidgets
event.
comment:13 Changed 11 years ago by
Status: | review → review_failed |
---|
I cannot find changes in tests repo. Have you pushed them?
comment:15 Changed 11 years ago by
I've added tests for first part of this ticket (blockquote, indent, list and justify).
comment:16 Changed 11 years ago by
Status: | review → review_passed |
---|
comment:17 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
- git:7b210e8
- tests:82fb749
I pushed simple commit to t/11027 which causes that blockquote, indentblock, indentlist, list and justify correctly apply when non-editable content is in selection.
What remains though is: