fix some bugs
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user