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

Introduce a way to know whether the selection is in the editor #6485

Closed
scofalik opened this issue Mar 24, 2020 · 0 comments · Fixed by ckeditor/ckeditor5-engine#1833
Closed
Assignees
Labels
package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@scofalik
Copy link
Contributor

scofalik commented Mar 24, 2020

📝 Provide a description of the new feature

There is a difference between an editor being not focused and editor not having a selection inside it. In general, when the editor does not have selection inside it, it is not focused. However, sometimes editor is not focused but still has selection. For example, when you switch a browser tab.

A case for this is an issue that was reported to us by real-time collaboration users. When there are multiple editors on one website, there is a user selection in each of them. This is confusing and doesn't tell where exactly the user is editing.

Unfortunately, using just focus is not the best solution - as I pointed out - for example - the focus is lost when you change browser tab.

Instead, I propose a new flag, which would inform whether the DOM selection is in a given editor. It would be complementary to view.Document#isFocused. It would be set by SelectionObserver which already does some processing of selection change event.

Now, the problem is where we want to add this flag. I see four candidates:

  • view.View#hasDomSelection - View class already has some stuff connected to DOM, for example #domRoots and DomConverter instance. It also keeps Renderer instance (although it is not public). It is easily reachable. It also creates observers, so it makes sense that SelectionObserver would work on it.
  • view.DocumentSelection#isInDom - I propose this because selection is another place where I'd look for a flag like this. I am not sure, however, if parts of the view should keep such information. I am not sure if this is something that selection should know about. I think it should work in the view scope and care just about view things and other, higher-level parts of code should use it and convert it.
  • view.Document#hasDomSelection - I propose it mostly because it already has #isFocused. Honestly, I don't see a reason whether this flag should be here, for the same reasoning as for the selection object.
  • Editor#hasDomSelection - maybe it would be a good place but is hard to reach from the bottom. Plugins have access to the editor but SelectionObserver does not.
@scofalik scofalik added the type:feature This issue reports a feature request (an idea for a new functionality or a missing option). label Mar 24, 2020
@mlewand mlewand added this to the backlog milestone Mar 25, 2020
Reinmar added a commit to ckeditor/ckeditor5-engine that referenced this issue Mar 25, 2020
Feature: Introduced `View#hasDomSelection`. Closes ckeditor/ckeditor5#6485.
@Reinmar Reinmar modified the milestones: backlog, iteration 31 Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants