refactoring

This commit is contained in:
Philipp Kühn
2020-12-01 09:11:58 +01:00
parent 81c0d02f5d
commit f556f00518
8 changed files with 43 additions and 33 deletions

View File

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