mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-28 15:49:23 +08:00
clean up
This commit is contained in:
parent
c9da3ab269
commit
2a706fd3d2
@ -1,28 +0,0 @@
|
||||
import { toggleMark as originalToggleMark } from 'prosemirror-commands'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command } from '../Editor'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import markIsActive from '../utils/markIsActive'
|
||||
|
||||
type ToggleMarkCommand = (typeOrName: string | MarkType, attrs?: {}) => Command
|
||||
|
||||
declare module '../Editor' {
|
||||
interface Commands {
|
||||
toggleMark: ToggleMarkCommand,
|
||||
}
|
||||
}
|
||||
|
||||
export const toggleMark: ToggleMarkCommand = (typeOrName, attrs) => ({ state, dispatch, commands }) => {
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
|
||||
const hasMarkWithDifferentAttributes = attrs
|
||||
&& markIsActive(state, type)
|
||||
&& !markIsActive(state, type, attrs)
|
||||
|
||||
if (hasMarkWithDifferentAttributes) {
|
||||
// @ts-ignore
|
||||
return commands.updateMark(type, attrs)
|
||||
}
|
||||
|
||||
return originalToggleMark(type, attrs)(state, dispatch)
|
||||
}
|
Loading…
Reference in New Issue
Block a user