fix some bugs

This commit is contained in:
Philipp Kühn
2020-11-06 00:13:18 +01:00
parent e4eed4ea09
commit dc62ac1326
5 changed files with 28 additions and 23 deletions

View File

@@ -4,16 +4,16 @@ import { Command } from '../Editor'
import getMarkType from '../utils/getMarkType'
import markIsActive from '../utils/markIsActive'
export default (typeOrName: string | MarkType, attrs?: {}): Command => ({ state, dispatch, commands }) => {
export default (typeOrName: string | MarkType, attributes?: {}): Command => ({ state, dispatch, commands }) => {
const type = getMarkType(typeOrName, state.schema)
const hasMarkWithDifferentAttributes = attrs
const hasMarkWithDifferentAttributes = attributes
&& markIsActive(state, type)
&& !markIsActive(state, type, attrs)
&& !markIsActive(state, type, attributes)
if (attrs && hasMarkWithDifferentAttributes) {
return commands.updateMarkAttributes(type, attrs)
if (attributes && hasMarkWithDifferentAttributes) {
return commands.updateMarkAttributes(type, attributes)
}
return toggleMark(type)(state, dispatch)
return toggleMark(type, attributes)(state, dispatch)
}