1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-26 08:34:28 +02:00

Fix removing marks generate useless operations (#2946)

This commit is contained in:
Charley DAVID
2019-08-19 18:12:55 +02:00
committed by Ian Storm Taylor
parent 4369f3fc2f
commit b6a99ce752
2 changed files with 37 additions and 0 deletions

View File

@@ -237,6 +237,10 @@ Commands.removeMarksByPath = (editor, path, offset, length, marks) => {
const { document } = value const { document } = value
const node = document.assertNode(path) const node = document.assertNode(path)
if (marks.intersect(node.marks).isEmpty()) {
return
}
editor.withoutNormalizing(() => { editor.withoutNormalizing(() => {
// If it ends before the end of the node, we'll need to split to create a new // If it ends before the end of the node, we'll need to split to create a new
// text with different marks. // text with different marks.

View File

@@ -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 = (
<value>
<document>
<paragraph>
one <anchor />two<focus /> three
</paragraph>
</document>
</value>
)
export const output = (
<value>
<document>
<paragraph>
one{' '}
<b>
<anchor />two
</b>
<focus /> three
</paragraph>
</document>
</value>
)