flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Move readOnly back to QuillEditor (revert)?

Open EchoEllet opened this issue 11 months ago • 4 comments

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.

EchoEllet avatar Jan 19 '25 06:01 EchoEllet

Using a function to change the read-only variable would be the best and clean

abhishek-m-raj avatar Mar 07 '25 07:03 abhishek-m-raj

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.

EchoEllet avatar Mar 24 '25 09:03 EchoEllet

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.

balint-kada avatar Apr 16 '25 11:04 balint-kada

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.

EchoEllet avatar Apr 16 '25 11:04 EchoEllet