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

Trying to update table cells throws exception

Open CatHood0 opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

The question

While I know I'm the one who created this feature, I did it in a rush and with quite a few bugs in the code. I'm currently fixing most of these so that the tables can be usable by all users.

However, one thing I haven't been able to figure out is how to consistently update the tables once they're already embedded. I tried using the example code in custom_embed_blocks but to no avail. The getEmbedNode method never finds the table.

So far, this is the code that is responsible for updating the tables (it's a bit different as I wanted it to be easier to understand):

void _updateTable() {
final delta = Delta()
   ..insert({'table': _tableModel.toMap()})
   ..insert('\n');
   final block = BlockEmbed.custom( CustomTableEmbed.fromDocument(Document.fromDelta(delta)), );
   final offset = getEmbedNode(widget.controller, widget.controller.selection.start).offset;
       widget.controller.replaceText(offset, 1, block, TextSelection.collapsed(offset: offset));
}

CatHood0 avatar Aug 21 '24 02:08 CatHood0