diff --git a/packages/slate/src/commands/by-path.js b/packages/slate/src/commands/by-path.js index 56ddfaacc..4d08472b9 100644 --- a/packages/slate/src/commands/by-path.js +++ b/packages/slate/src/commands/by-path.js @@ -237,6 +237,10 @@ Commands.removeMarksByPath = (editor, path, offset, length, marks) => { const { document } = value const node = document.assertNode(path) + if (marks.intersect(node.marks).isEmpty()) { + return + } + editor.withoutNormalizing(() => { // If it ends before the end of the node, we'll need to split to create a new // text with different marks. diff --git a/packages/slate/test/history/undo/toggle-mark.js b/packages/slate/test/history/undo/toggle-mark.js new file mode 100644 index 000000000..ac08ecf5c --- /dev/null +++ b/packages/slate/test/history/undo/toggle-mark.js @@ -0,0 +1,33 @@ +/** @jsx h */ + +import h from '../../helpers/h' + +export default function(editor) { + editor.addMark('bold') + editor.flush().removeMark('bold') + editor.flush().undo() +} + +export const input = ( + + + + one two three + + + +) + +export const output = ( + + + + one{' '} + + two + + three + + + +)