import Ribbon from './Ribbon' ; import { Editor , EditorPlugin } from 'roosterjs-editor-core' ; import { PluginEvent , PluginEventType } from 'roosterjs-editor-types' ; const log = require ( 'debug' ) ( 'rooster:ribbon' ) ; export default class RibbonPlugin implements EditorPlugin { editor : Editor ; ribbon : Ribbon ; getName ( ) { return 'Ribbon' ; } initialize ( editor ) { log ( 'initialize' , editor ) ; this . editor = editor ; } dispose ( ) { log ( 'dispose' ) ; this . editor = null ; } getEditor ( ) { return this . editor ; } refCallback = ( ref ) => { this . ribbon = ref ; } ; onPluginEvent ( event ) { if ( this . ribbon && ( event . eventType == PluginEventType . KeyUp || event . eventType == PluginEventType . MouseUp || event . eventType == PluginEventType . ContentChanged ) ) { this . ribbon . forceUpdate ( ) ; } } }