This commit is contained in:
Hans Pagel
2020-10-27 20:36:29 +01:00
parent da3618ec6f
commit 59dbe41620

View File

@@ -3,6 +3,7 @@ import { MarkType } from 'prosemirror-model'
import { Command } from '../Editor' import { Command } from '../Editor'
import { createExtension } from '../Extension' import { createExtension } from '../Extension'
import getMarkType from '../utils/getMarkType' import getMarkType from '../utils/getMarkType'
import markIsActive from '../utils/markIsActive'
export const ToggleMark = createExtension({ export const ToggleMark = createExtension({
addCommands() { addCommands() {
@@ -10,6 +11,17 @@ export const ToggleMark = createExtension({
toggleMark: (typeOrName: string | MarkType): Command => ({ state, dispatch }) => { toggleMark: (typeOrName: string | MarkType): Command => ({ state, dispatch }) => {
const type = getMarkType(typeOrName, state.schema) const type = getMarkType(typeOrName, state.schema)
/* TODO:
const hasMarkWithDifferentAttributes = attrs
&& markIsActive(state, type)
&& !markIsActive(state, type, attrs)
if (hasMarkWithDifferentAttributes) {
// @ts-ignore
return commands.updateMark(type, attrs)
}
*/
return originalToggleMark(type)(state, dispatch) return originalToggleMark(type)(state, dispatch)
}, },
} }