ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.97k stars 3.25k forks source link

Toggling mark on a selection that only partly had it then undoing produces wrong results #767

Closed mernen closed 7 years ago

mernen commented 7 years ago
  1. Open the example at http://slatejs.org
  2. Select the “editable rich text” passage
  3. Press the Bold button. The “rich” word loses its bold formatting
  4. Press Ctrl/Cmd-Z

Expected: “rich” should get its formatting back, the other words should remain unchanged.

Actual: the entire selection becomes bold.

ianstormtaylor commented 7 years ago

This is due to the current implementation of the add_mark and remove_mark operations. Right now they create an inverse that adds/removes completely. When really they should be creating many operations, for each range that doesn't currently have the mark attached.