superlistapp / super_editor

A Flutter toolkit for building document editors and readers
https://superlist.com/SuperEditor/
MIT License
1.64k stars 239 forks source link

[SuperEditor] - Make DocumentNodes immutable #2166

Open matthew-carroll opened 2 months ago

matthew-carroll commented 2 months ago

SuperEditor has moved to an edit pipeline through an Editor. As a result, it's never acceptable to alter a Document or DocumentNode directly. Changes need to happen within EditCommands.

To enforce this, we should make DocumentNodes immutable.

This change still doesn't solve the problem that AttributedText is also immutable, but this will bring us one step closer to correct immutability.

matthew-carroll commented 1 month ago

Note, we've had a couple undo/redo bugs logged whose root cause was the retention of mutable document nodes:

By making document nodes immutable, we prevent all such issues from happening in the future.