import * as React from 'react' ; import SidePanePlugin from '../SidePanePlugin' ; import { Editor } from 'roosterjs-editor-core' ; import { SidePaneElement , SidePaneElementProps } from './SidePaneElement' ; interface SidePaneComponent < P extends SidePaneElementProps > extends React . Component < P , any > , SidePaneElement { } export default abstract class SidePanePluginImpl < T extends SidePaneComponent < P > , P extends SidePaneElementProps > implements SidePanePlugin { protected editor : Editor ; private component = React . createRef < T > ( ) ; constructor ( private readonly componentCtor , private readonly pluginName , private readonly title ) { } getName ( ) { return this . pluginName ; } initialize ( editor ) { this . editor = editor ; } dispose ( ) { this . editor = null ; } getTitle ( ) { return this . title ; } renderSidePane ( updateHash ) { return React . createElement < P > ( this . componentCtor , { ... this . getComponentProps ( { updateHash , } ) , ref : this . component , } ) ; } setHashPath ( path ) { if ( this . component . current && this . component . current . setHashPath ) { this . component . current . setHashPath ( path ) ; } } protected abstract getComponentProps ( baseProps ) ; protected getComponent ( callback ) { if ( this . component . current ) { callback ( this . component . current ) ; } } }