-
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
Fix for wrong deletion of mixed text and table content #1882
Conversation
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 fix is working, but is not coherent with native Firefox behavior. Firefox, in case of the second table, move text from/into table:
Not to mention IE/Edge that does not do anything at all ¯_(ツ)_/¯
There is also one more problem: failing test after the changes → http://tests.ckeditor.test:1030/tests/core/editable/keystrokes/keystrokes#tests%2Fcore%2Feditable%2Fkeystrokes%2Fkeystrokes%20test%20handle%20del%20with%20full%20table%20content%20selected
There is also one thing that makes me wonder: why didn't we use editor.extractSelectedHtml
at first place? 🤔
core/editable.js
Outdated
@@ -2528,47 +2528,25 @@ | |||
endPath = range.endPath(), | |||
endBlock = endPath.block; | |||
|
|||
// Selection must be anchored in two different blocks. | |||
if ( !startBlock || !endBlock || startBlock.equals( endBlock ) ) | |||
var selectionInTwoDifferentBlocks = !startBlock || !endBlock || startBlock.equals( endBlock ); |
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 quite sure that when startBlock
equals endBlock
, then selection is contained inside one block.
core/editable.js
Outdated
|
||
// Selection must be anchored in two different blocks | ||
// Boundary block is not in table (block elements are empty there). | ||
if ( selectionInTwoDifferentBlocks && !hasBoundariesInTable ) { |
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 comment condradicts the code. false
is returned if selectionInTwoDifferentBlocks
is true, while comment stands the opposite.
core/editable.js
Outdated
|
||
editor.fire( 'saveSnapshot' ); | ||
|
||
// Remove bogus to avoid duplicated boguses. | ||
var bogus; | ||
if ( ( bogus = startBlock.getBogus() ) ) | ||
if ( ( bogus = startBlock && startBlock.getBogus() ) ) |
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.
That line of code became ugly. Let's separate if
from variable declaration.
…ed if are identical.
…le tests with boguses.
FirefoxI had a look with @msamsel during a f2f talk and the Firefox thing looks clearly like their feature (if you have selected same element on both ends, here paragraph, and delete the content then merge it). We should not worry about that at this point. Edge / IEAs of Edge it is clearly an upstream issue in Edge/IE. Normally I'd say that all we need to do here is report upstream issue and not worry about it, but it will look kind of silly if we say in changelog that we fixed this case, but it does not work in Edge / IE. With above in mind, please:
So this PR should not worry about IE/Edge support, that will be done in a follow-up PR. |
I think because Edge case was extracted to: #1919 Please also remember that main point of this fix was to prevent of removing entire table cells from tables and inserting Another thing is correct behaviour. Jumping content from paragraph below table to its cell seems to be inappropriate. That's why paragraphs remain under table. |
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.
Seems like defining correct behavior is not trivial… I've create native [contenteditable]
demo, which shows following things:
Chrome/Safari
- When deleting from the beginning of the table, content outside the table is not merged with the content from the table.
- When deleting from the end of the table, content outside is merged.
- When overwriting with some letter, the content is merged for selection at the end of the table.
Firefox
- When deleting from table without paragraphs, content outside the table is not merged into it.
- When deleting from table with paragraphs, content outside the table is merged into it.
- When overwriting with some letter, the content is merged in the second table.
So even in Chrome/Safari we end up with inconsistent behavior, as disallowing merge after deleting has totally different behavior than overwriting with new content. IMO it's an issue that should be addressed.
@mlewand could you provide feedback what behaviour should be implemented in CKE4? |
@msamsel @Comandeer There's nothing wrong with unifying the results across the browser.
What is exactly the issue? I have used delbackspacequirks/manual/tables to repro it an Chrome, and it works the same for me in both cases.
I find it to be a positive change not to merge the content in that case.
Same as above. As for Firefox points, is the original issue related to Firefox? Or is the current PR changing Firefox behavior anyhow? |
Note that you could also give a try with |
After f2f talk with @msamsel seems that |
What is the purpose of this pull request?
Bug fix
This PR contains
What changes did you make?
editor.extractSelectedHtml
instead of current logic to remove content from the editor after pressing Backspace or Delete#15
and#16
are changed)Close #541