-
-
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
Editor#isReadOnly should work like disabling commands (blockable multiple times by different features) #10496
Comments
I wonder if we could somehow avoid breaking changes on this one but I don't think that's possible. The only level of backward compatibility would be to clear all registered locks on doing BTW, to be consistent with what we did already we should go with |
Maybe we could provide a mixin that could handle that for other classes as well. This is a common pattern in our code. |
We can also leave setting Although personally, I am against such things, for multiple reasons: first, it creates hidden problems, second it will have to be done at some point anyway, third it makes our code messy, fourth it discourages users to update their code ("okay, I'll fix it later" -> forgetting that there's something to fix -> looking way back in the changelog what changed after the deprecated code is removed). |
Feature (core): Introduced locking mechanism for `Editor#isReadOnly`. Read-only mode can now be separately enabled and disabled by multiple features, which allows for a proper control without conflicts between features. Closes #10496. Other (core): `Editor#isReadOnly` is now a read-only property. MAJOR BREAKING CHANGE: The `Editor#isReadOnly` property is now read-only. From now, this property is controlled by `Editor#enableReadOnlyMode( lockId )` and `Editor#disableReadOnlyMode( lockId )`, which allow controlling the `Editor#isReadOnly` state by more than one feature without collisions. See the migration guide to learn more.
Why does the We should have only two methods:
Then, if we think that the "toggle" method is needed, it should be implemented as a new thing: |
It was to simplify the most common usage:
I agree that it looked better when the method was called |
We stick to enableReadOnlyMode + disableReadOnlyMode. But enableReadOnlyMode will not have this second parameter that confused some of us. |
Other: Aligned the CKEditor 5 Inspector API to use the new lock mechanism when enabling/disabling the read-only mode. MAJOR BREAKING CHANGE: Due to introducing the lock mechanism for the `Editor#isReadOnly` property, the inspector uses the new way of enabling the read-only mode in the editor. It requires an instance of CKEditor 5 in version 34 or higher. See ckeditor/ckeditor5#10496.
Other: Aligned the `<CKEditor>` component API to use the new lock mechanism when enabling/disabling the read-only mode. MAJOR BREAKING CHANGE: Due to introducing the lock mechanism for the `Editor#isReadOnly` property, the `<CKEditor>` component uses the new way of enabling the read-only mode in the editor. The component requires an instance of CKEditor 5 in version 34 or higher. See ckeditor/ckeditor5#10496.
Other: Aligned the `<CKEditor>` component API to use the new lock mechanism when enabling/disabling the read-only mode. MAJOR BREAKING CHANGE: Due to introducing the lock mechanism for the `Editor#isReadOnly` property, the `<CKEditor>` component uses the new way of enabling the read-only mode in the editor. The component requires an instance of CKEditor 5 in version 34 or higher. See ckeditor/ckeditor5#10496.
Other: Upgraded the CKEditor 5 packages to their latest versions. Closes #304. Other: Aligned the `<CKEditor>` component API to use the new lock mechanism when enabling/disabling the read-only mode. MAJOR BREAKING CHANGE: Due to introducing the lock mechanism for the `Editor#isReadOnly` property, the `<CKEditor>` component uses the new way of enabling the read-only mode in the editor. The component requires an instance of CKEditor 5 in version 34 or higher. See ckeditor/ckeditor5#10496.
Other: Aligned the `<CKEditor>` component API to use the new lock mechanism when enabling/disabling the read-only mode. MAJOR BREAKING CHANGE: Due to introducing the lock mechanism for the `Editor#isReadOnly` property, the `<CKEditor>` component uses the new way of enabling the read-only mode in the editor. The component requires an instance of CKEditor 5 in version 34 or higher. See ckeditor/ckeditor5#10496.
📝 Provide a description of the improvement
At the moment,
Editor#isReadOnly
is a simple property that can be set to eithertrue
orfalse
. This is limiting and leads to incorrect code.Consider two mechanisms (features), that may want to set editor to readonly mode. At the beginning, both of them may decide that "there's some kind of error" and switch editor to read-only. But then, one problem is solved, so one of the mechanisms switches back
isReadOnly
totrue
. This is incorrect, because the other mechanism still wants to block the editor.This is the same situation as with commands, where multiple features may want to set a command as disabled.
My proposal is to:
Editor#isReadOnly
to ... wait for it ... readonly property.Editor#setReadOnly( id:String|Symbol )
andEditor#unsetReadOnly( id )
or (unlockReadOnly( id )
) -- similarly as in commands,Editor#isReadOnly
.One note is that
Editor#isReadOnly
could also be directly linked with document editing permission. Maybe document editing permission should be the only thing that actually changesEditor#isReadOnly
and it should be dynamically affected by other mechanisms/features? However, I don't think that this really makes sense. For example, consider losing connection to Cloud Services. In such situation, we switch the editor to read-only. I don't think that it would make sense to switch user permission to "cannot edit" in this situation.The text was updated successfully, but these errors were encountered: