-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support editor functions after reattach to DOM #4601
Conversation
@ckeditor/qa-team Hello there 👋 Note that it won't work for IE below There is a manual test with some additional plugins ( |
I've tested this feature using provided manual test and everything seems to work correctly 👍 I did not find anything broken during my testing. |
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 for the solution, it looks much clearer now with mutationObserver
(no custom attributes on iframe native element, yay!). It looks to work just like before 👍🏻
Besides inline comments, I'd like to ask for explicit tests for the cases that were failing in the previous version of the solution, so the embed test and an image with undo test (and BTW I see the second one is still failing - could you relate to it since you didn't in the original PR?).
@Dumluregn - ready for review.
I try to fix this additional step in history - but without success... TBH I was able to fix it, but at the same time |
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.
Just some small refactors left.
Besides that - on IE11 I've encountered an error after each toggle:
Looks like Bender issue TBH 🤔 could you verify if it's reproducible outside of testing environment? I didn't experience any influence on editor (all tests pass), but in manual descriptions we write that any error causes the test to fail, so we should take some action.
Rebase on newest major |
Definitely, it's related to our solution. Because in unit tests which expect empty editor (so didn't call restore logic) this issue doesn't appear for me in IE11. All other units from Interesting... I used the debugger and go line, by line... This error appears after this line: ckeditor4/plugins/wysiwygarea/plugin.js Line 478 in bc88d4e
And this is the source of our error :] This block code comes from ckeditor4/plugins/wysiwygarea/plugin.js Lines 435 to 444 in bc88d4e
The easiest way is to just suppress the error by adding
So it could be a solution for now. It doesn't break anything (at least for now 🙈 ) and this is happening only for IE11 is iframe reloading case - so eventually damage seems to be low? |
@Dumluregn - ready for review.
|
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've encountered an issue with undo history which occurs on all browsers and is rather simple to reproduce, so we have to take care of it.
- Open any manual test.
- Toggle source mode.
- Toggle editor (detach+reattach).
- Use
bold
button.
Editor doesn't record any undo step. Even if it looks like it does (after you type anything), you can't access it.
Other than that - mostly small ammendments.
This reverts commit b481033.
It throws permission denied while you are trying to access it
@Comandeer - ready for another review.
|
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! 🎉
I've just updated API docs for CKEDITOR.editor#getSelection()
(it seems that we have them wrong for years 🙈) and simplify it a little bit (replaced editable.editor.status
with this.status
).
I've also added additional changelog entry for the change in CKEDITOR.editor#getSelection()
under API Changes.
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
Did you follow the CKEditor 4 code style guide?
Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.
What is the proposed changelog entry for this pull request?
What changes did you make?
MutationObserver
to detect whenever the editor is attached to DOM again.load
event. So only for IE, there is an extra flag used to mark, that editable should be recreated.iframe
element during editabledetach
process. Used only internally in recreating.detachableParent
) which allows pass native DOM object which should be observed for detach / attach changeseditor.status
(recreating
) which prevents null references in recreating the processWe won't be able to support IE below
11
, because ofMutationObserver
usage. However, it's mostly for integrations, which doesn't support IE below11
.Three units test are passing regardless of this fix:
They confirm if iframe reloading still makes the editor empty. Also, they show that an invalid configuration still leads to an empty editor.
Fix two tests that create query strings for
querySelector()
with restricted characters (IE):Which issues does your PR resolve?
Closes #4462