import { MarkType } from 'prosemirror-model' ; import { EditorState , Transaction } from 'prosemirror-state' ; import { Command , toggleMark } from 'prosemirror-commands' ; import { applyMark } from 'ngx-editor/commands' ; import { isMarkActive } from 'ngx-editor/helpers' ; class Mark { name : string ; constructor ( name ) { this . name = name ; } apply ( ) { return ( state , dispatch ? ) : boolean => { const { schema } = state ; const type = schema . marks [ this . name ] ; if ( ! type ) { return false ; } return applyMark ( type ) ( state , dispatch ) ; } ; } toggle ( ) { return ( state , dispatch ? ) : boolean => { const { schema } = state ; const type = schema . marks [ this . name ] ; if ( ! type ) { return false ; } return toggleMark ( type ) ( state , dispatch ) ; } ; } isActive ( state ) { const { schema } = state ; const type = schema . marks [ this . name ] ; if ( ! type ) { return false ; } return isMarkActive ( state , type ) ; } canExecute ( state ) { return this . toggle ( ) ( state ) ; } } export default Mark ;