refactoring
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import markIsActive from '../helpers/markIsActive'
|
||||
import isMarkActive from '../helpers/isMarkActive'
|
||||
|
||||
/**
|
||||
* Toggle a mark on and off.
|
||||
*/
|
||||
export const toggleMark = (typeOrName: string | MarkType, attributes?: {}): Command => ({ state, commands }) => {
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
const isActive = markIsActive(state, type, attributes)
|
||||
const isActive = isMarkActive(state, type, attributes)
|
||||
|
||||
if (isActive) {
|
||||
return commands.unsetMark(type)
|
||||
|
||||
Reference in New Issue
Block a user