-
Notifications
You must be signed in to change notification settings - Fork 6
I/5840: Safe fixes to enforcing restricted editing restrictions #7
Conversation
# Conflicts: # tests/manual/restrictedediting.html
@Mgsy, could you check how it works? Please take into consideration that it's just part of the changes needed to finish this. |
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.
From a code perspective, I've got just this one comment.
src/restrictededitingmodeediting.js
Outdated
const allowedToDelete = marker.getRange().getIntersection( selection.getFirstRange() ); | ||
|
||
// Shrink the selection to the range inside exception marker. | ||
selection.setTo( allowedToDelete ); |
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 don't think that you should be modifying the selection passed to the command. Instead, override args[ 0 ]
with a new selection instance.
Also, DocumentSelection
doesn't even have setTo()
. Please add a test for that – I think it would crash.
Steps to reproduce
Current resultThe editor crashes. GIFError
Browser: All browsers |
Guess you're right @Reinmar : #7 (comment) 😉 |
@FilipTokarski, can you test this PR in Firefox and Safari? I'll take Chrome and Edge. |
@Reinmar the problem with This works with The problem is that That's why this hack on hack must use |
When using spellchecker some words are moved outside the exception marker. It seems to happen more often when spellchecker is suggesting longer words and happens both at the begginning and at the end of the exception marker. Steps to reproduce:
NOTE: It happens only on some words, seems a bit random. |
I've noticed similar thing on the left side of the marker. I've hoped that the right sign will behave the same 😞 I'll look into it. |
@FilipTokarski / @Mgsy - could one of you re-test the current solution? I think that I've fixed the spell-checking bug on the exception field boundary. It looks like a problematic case was when the spellchecking occurred on the boundary:
fixing "ugabuga" to "bugaboo" (whatever Chrome thinks that it should be 🤷♂️) was
The second example in the screencast is basically the same bug but RE "fixed" the restricted editing exception only by 1 character and not by the whole change. |
@jodator, I actually changed my mind regarding overriding the selection. Since this is We should, however, make sure to not change the behaviour of whether the reference is kept. IDK how it works right now but if we operate on the exact same instance of selection that was passed to Does it make more sense now? |
BTW, I'd like to add that if we'll struggle with handling those commands by overriding the selection, we may consider reverting "invalid" changes in post fixers. By invalid, I mean changes that violate the restrictions. Reverting them will not create the best UX, but should be easier and solve the issue. After all, the scenarios that we're fixing right now are not the most common ones so they don't have to be perfect as long as the restrictions are enforced. |
I checked it on all browsers and it seems to be working ok now |
@Mgsy can we ask you guys to check this one more time. The change is minimal but can have other side effects. Hopefully, this is the last iteration for this PR 🤞. |
LGTM |
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 👌
Thanks, guys! |
Suggested merge commit message (convention)
Fix: Restricted editing boundaries should not be crossed by delete content and input command. Closes ckeditor/ckeditor5#5840.
Additional information
model.deleteContent()
used by delete command with a "word" modifier (ctrl + del)Fixed by changing
selection
argument passed todeleteContent
method (using decorator)model.insertContent()
which was triggered by native spell check (in Firefox)Fixed by a decorator for
InputCommand.execute()
that blocksexecute()
for ranges that crosses one exception marker.