slate v0.56.0 Release Notes
Release Date: 2019-12-17 // over 4 years ago-
BREAKING
The
format_text
command is split intoadd_mark
andremove_mark
. Although the goal is to keep the number of commands in core to a minimum, having this as a combined command made it very hard to write logic that wanted to guarantee to only ever add or remove a mark from a text node. Now you can be guaranteed that theadd_mark
command will only ever add custom properties to text nodes, and theremove_mark
command will only ever remove them.Previously you would write:
editor.exec({ type: 'format_text', properties: { bold: true }, })
Now you would write:
if (isActive) { editor.exec({ type: 'remove_mark', key: 'bold' }) } else { editor.exec({ type: 'add_mark', key: 'bold', value: true }) }
🤖 Note that the "mark" term does not mean what it meant in
0.47
and earlier. It simply means formatting that is applied at the text level—bold, italic, etc. We need a term for it because it's such a common pattern in richtext editors, and "mark" is often the term that is used. For example the<mark>
tag in HTML.The
Node.text
helper was renamed toNode.string
. This was simply to reduce the confusion between "the text string" and "text nodes". The helper still just returns the concatenated string content of a node.