Skip to content
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

Ensure that multi-range selections are handled in deleteContent(), insertContent() and modifySelection() #6328

Closed
jodator opened this issue Feb 25, 2020 · 6 comments
Labels
package:engine resolution:expired This issue was closed due to lack of feedback. status:stale type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@jodator
Copy link
Contributor

jodator commented Feb 25, 2020

📝 Provide a description of the improvement

EDIT: Read @Reinmar's comment and following discussion first.

The scope of this ticket was narrowed to handling multi-range selections in the base methods in the engine.


ATM the model.deleteContent() (EDIT: and the two other methods as well) is not aware of multi-range selection. For this I had to manually handle clearing the table cell contents for the clipboard "cut" (ref PR: ckeditor/ckeditor5-table#254).

This could be handled by the model.deleteContent() so it would iterate over each range from the selection. Handled by the Clipboard plugin here: https://github.com/ckeditor/ckeditor5-clipboard/blob/b1b956716e81f45ce34bcfae1bb13f3348078c21/src/clipboard.js#L130-L132 and by the TableClipboard plugin here: https://github.com/ckeditor/ckeditor5-table/blob/8e0a92215e4368ec6e7b2ec5fb857bea53a74975/src/tableclipboard.js#L102-L105.


If you'd like to see this improvement implemented, add a 👍 reaction to this post.

@jodator jodator added type:improvement This issue reports a possible enhancement of an existing feature. package:clipboard package:engine package:table labels Feb 25, 2020
@Reinmar Reinmar changed the title Handle multi-range selection in model.deleteContent() Handle multi-range selection in deleteContent(), insertContent() and modifySelection() Feb 26, 2020
@Reinmar
Copy link
Member

Reinmar commented Feb 26, 2020

Note: Standard implementation of those 3 methods may not be completely optimal for table cases. Those implementations should be rudimental and simple.

Then, we can extend the behaviour of those methods (they are firing events) from the table selection plugins.

For instance, this should probably be the default behaviour:

  • deleteContent:
    1. run the current behaviour of this function but for each range separately,
    2. place the selection (collapsed) in place of the first/last range (depending on whether this was forward or backward deletion).
  • insertContent:
    1. deleteContent() to create a collapsed selection (with a single range)
    2. run the standard logic
  • modifySelection (may work this way already):
    1. ignore all ranges but first
    2. do the standard thing

Now, those implementations will not satisfy table scenarios. There, we need better handling:

  • deleteContent
    1. clear content of each selected cell
    2. place the collapsed selection in first/last of them
  • insertContent
    1. run deleteContent to make the selection collapsed
    2. do the standard thing

It may happen that it's possible for now to work only on the second half of this problem, skipping the default implementations. If that's possible, we should do exactly that and avoid touching the engine at all now.

@jodator
Copy link
Contributor Author

jodator commented Feb 27, 2020

@Reinmar you're right. The delete content decoration fixed the typing and delete bugs. While I'm working on it the other thing occurred. To have a nice UX I think that we also need to decorate delete command (to place the collapsed selection in first/last of cells).

Anyway, both fixes are short so they should be available soon.

@jodator
Copy link
Contributor Author

jodator commented Feb 28, 2020

Linked issue: #3115.

@Reinmar
Copy link
Member

Reinmar commented Feb 28, 2020

I extracted the part about making ckeditor5-table work with methods, not commands to #6356.

The remaining thing here will be to ensure that the base methods in ckeditor5-engine do support multi-range selections in a non-crashy way.

@Reinmar Reinmar changed the title Handle multi-range selection in deleteContent(), insertContent() and modifySelection() Ensure that multi-range selections are handled in deleteContent(), insertContent() and modifySelection() Feb 28, 2020
@Reinmar Reinmar removed this from the iteration 30 milestone Feb 28, 2020
@Reinmar Reinmar modified the milestones: nice-to-have, next Mar 9, 2020
@Reinmar Reinmar modified the milestones: next, iteration 31 Apr 6, 2020
@Reinmar Reinmar added this to the nice-to-have milestone Apr 6, 2020
@pomek pomek removed this from the nice-to-have milestone Feb 21, 2022
@CKEditorBot
Copy link
Collaborator

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

@CKEditorBot
Copy link
Collaborator

We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

@CKEditorBot CKEditorBot added the resolution:expired This issue was closed due to lack of feedback. label Nov 12, 2023
@CKEditorBot CKEditorBot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine resolution:expired This issue was closed due to lack of feedback. status:stale type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests

5 participants