rename addMark to setMark

This commit is contained in:
Philipp Kühn
2020-11-18 17:36:00 +01:00
parent 1b45acd5d5
commit e3a3d99c51
11 changed files with 17 additions and 17 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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,