-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement is() in model/Selection and model/DocumentSelection #4477
Comments
I couldn't find a ticket but it's been proposed somewhere in the past. I agree that we should implement it. Note that we need it also in the |
Less imports! 👍 I'd propose |
Note that is should be consistent:
or
Since we have Also, I think that we should have just one: However, in most cases, you do not care which one it is since they have the same getter interface. Also, I believe that if you want to change the selection you know which class you have (usually you create the selection and set it in the same place). This is why I think that a single |
👍
I'm not sure here... One doesn't inherit from the other. But @pjasiun made a good point that you can still do: foo.is( 'selection' ) && !foo.is( 'documentSelection' ) if you want to check if it's the base selection. Taken that, I'd agree with @pjasiun on this. |
I reported a followup to review also other objects: https://github.com/ckeditor/ckeditor5-engine/issues/1667. There's more classes which miss this method, plus we should review some |
Feature: Implemented `Selection#is()` and `DocumentSelection#is()` methods in both the model and the view. Closes #1663.
I found out that the only way to check if anything is
(Document)Selection
is byinstanceof
which means additional imports.This is is a problem I discovered when writing a converters guide with quick solutions for various use–cases. The code snippets don't require any imports (plugins defined as functions) and it is possible to use them with pre–build editors, which is very convenient. Forcing people to import means building the editor and seriously hits the DX.
Before:
After:
cc @scofalik @jodator
The text was updated successfully, but these errors were encountered: