rename addMark to setMark
This commit is contained in:
@@ -6,7 +6,7 @@ import getMarkAttributes from '../utils/getMarkAttributes'
|
||||
/**
|
||||
* Add a mark with new attributes.
|
||||
*/
|
||||
export const addMark = (typeOrName: string | MarkType, attributes?: {}): Command => ({ tr, state, dispatch }) => {
|
||||
export const setMark = (typeOrName: string | MarkType, attributes?: {}): Command => ({ tr, state, dispatch }) => {
|
||||
const { selection } = tr
|
||||
const { from, to, empty } = selection
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
@@ -15,7 +15,7 @@ export const toggleMark = (typeOrName: string | MarkType, attributes?: {}): Comm
|
||||
&& !markIsActive(state, type, attributes)
|
||||
|
||||
if (attributes && hasMarkWithDifferentAttributes) {
|
||||
return commands.addMark(type, attributes)
|
||||
return commands.setMark(type, attributes)
|
||||
}
|
||||
|
||||
return originalToggleMark(type, attributes)(state, dispatch)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Extension } from '../Extension'
|
||||
import * as addMark from '../commands/addMark'
|
||||
import * as setMark from '../commands/setMark'
|
||||
import * as blur from '../commands/blur'
|
||||
import * as clearContent from '../commands/clearContent'
|
||||
import * as command from '../commands/command'
|
||||
@@ -34,7 +34,7 @@ import * as wrapInList from '../commands/wrapInList'
|
||||
export const Commands = Extension.create({
|
||||
addCommands() {
|
||||
return {
|
||||
...addMark,
|
||||
...setMark,
|
||||
...blur,
|
||||
...clearContent,
|
||||
...clearNodes,
|
||||
|
||||
Reference in New Issue
Block a user