import { EditorState , Plugin , PluginKey , Transaction } from 'prosemirror-state' ; const editablePlugin = ( editable = true ) : Plugin => { return new Plugin ( { key : new PluginKey ( 'editable' ) , state : { init ( ) { return editable ; } , apply ( tr , previousVal ) { return tr . getMeta ( 'UPDATE_EDITABLE' ) ?? previousVal ; } } , props : { editable ( state ) { return this . getState ( state ) ; } , attributes ( state ) { const isEnabled = this . getState ( state ) ; if ( isEnabled ) { return null ; } return { class : 'NgxEditor__Content--Disabled' } ; } } } ) ; } ; export default editablePlugin ;