Move readOnly back to QuillEditor (revert)?
The PR #1843 moved the readOnly from the editor config to the controller as a breaking change, so to change it:
_controller.readOnly = true;
instead of:
QuillEditor.basic(
config: const QuillEditorConfig(
readOnly: true,
),
)
The setState is required:
IconButton(
icon: Icon(_controller.readOnly ? Icons.edit : Icons.lock),
tooltip: 'Toggle read-only',
onPressed: () {
setState(() {
_controller.readOnly = !_controller.readOnly;
});
},
)
https://github.com/user-attachments/assets/46b62799-5ffe-40bb-9467-a546f2e5c124
I figure that this approach might not be efficient enough, is a bit confusing, and can cause performance issues (need more consideration and investigation).
Since the QuillController now depends on readOnly (PRs after #1843 used it), we will need to store it as an internal property that will be set when the controller is connected to the QuillEditor (such code definitely needs tests), see related lines.
Using a function to change the read-only variable would be the best and clean
Using a function to change the read-only variable would be the best and clean
While it's cleaner, it has the same behavior as the current.
I've also noticed that if you change readOnly, then all of the custom embeds reload fully, which in some cases results in text jumping all around if the custom embed has a state with no size, could this be fixed @EchoEllet?
It also happens on your video.
I've also noticed that if you change readOnly, then all of the custom embeds reload fully
Yes, this is a high priority bug. Although I'm not sure if it's a regression, the issue was probably already present in previous versions. We will need to file an issue.