From 2a706fd3d2427f7dcf43a6bb5531d423fe7b63aa Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Tue, 27 Oct 2020 22:23:37 +0100 Subject: [PATCH] clean up --- packages/core/src/commands/toggleMark.ts | 28 ------------------------ 1 file changed, 28 deletions(-) delete mode 100644 packages/core/src/commands/toggleMark.ts diff --git a/packages/core/src/commands/toggleMark.ts b/packages/core/src/commands/toggleMark.ts deleted file mode 100644 index 4de80b8c4..000000000 --- a/packages/core/src/commands/toggleMark.ts +++ /dev/null @@ -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) -}