import { Editor , EditorPlugin } from "roosterjs-editor-core" ; import { BeforePasteEvent , PasteOption , PluginEvent , PluginEventType } from "roosterjs-editor-types" ; export default class IgnorePasteImagePlugin implements EditorPlugin { private editor : Editor ; private static InternalInstance = new IgnorePasteImagePlugin ( ) ; private constructor ( ) { } public static get Instance ( ) : IgnorePasteImagePlugin { return IgnorePasteImagePlugin . InternalInstance ; } public getName ( ) { return 'IgnorePasteImage' ; } public initialize ( editor ) { this . editor = editor ; } public dispose ( ) { if ( this . editor ) { this . editor = null ; } } public onPluginEvent ( event ) { if ( event . eventType !== PluginEventType . BeforePaste ) { return ; } const beforePasteEvent = event as BeforePasteEvent ; if ( beforePasteEvent . pasteOption !== PasteOption . PasteImage ) { return ; } const editor = this . getEditor ( ) ; if ( ! editor ) { return ; } beforePasteEvent . pasteOption = PasteOption . PasteText ; } public getEditor ( ) { return this . editor ; } }