mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-26 16:44:22 +02:00
Fix removing marks generate useless operations (#2946)
This commit is contained in:
committed by
Ian Storm Taylor
parent
4369f3fc2f
commit
b6a99ce752
@@ -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.
|
||||||
|
33
packages/slate/test/history/undo/toggle-mark.js
Normal file
33
packages/slate/test/history/undo/toggle-mark.js
Normal 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>
|
||||||
|
)
|
Reference in New Issue
Block a user