@@ -55,7 +55,7 @@ export interface Editor extends Receiver<EventMap>, CommonEditor {
5555 readonly currentMode : EditorMode ;
5656 readonly toolbarVisible : boolean ;
5757
58- setEditorMode ( mode : EditorMode ) : void ;
58+ setEditorMode ( mode : EditorMode , opts ?: SetEditorModeOptions ) : void ;
5959
6060 moveCursor ( position : 'start' | 'end' | { line : number } ) : void ;
6161
@@ -91,7 +91,7 @@ export interface EditorInt
9191
9292 changeEditorMode ( opts : ChangeEditorModeOptions ) : void ;
9393
94- setEditorMode ( mode : EditorMode ) : void ;
94+ setEditorMode ( mode : EditorMode , opts ?: SetEditorModeOptions ) : void ;
9595
9696 moveCursor ( position : 'start' | 'end' | { line : number } ) : void ;
9797
@@ -102,10 +102,13 @@ export interface EditorInt
102102 destroy ( ) : void ;
103103}
104104
105+ type SetEditorModeOptions = Pick < ChangeEditorModeOptions , 'emit' > ;
106+
105107/** @internal */
106108type ChangeEditorModeOptions = {
107109 mode : EditorMode ;
108110 reason : 'error-boundary' | 'settings' | 'manually' ;
111+ emit ?: boolean ;
109112} ;
110113
111114export type MarkupConfig = {
@@ -367,15 +370,15 @@ export class EditorImpl extends SafeEventEmitter<EventMapInt> implements EditorI
367370 this . #wysiwygEditor = undefined ;
368371 }
369372
370- setEditorMode ( mode : EditorMode ) : void {
371- this . changeEditorMode ( { mode, reason : 'manually' } ) ;
373+ setEditorMode ( mode : EditorMode , opts ?: SetEditorModeOptions ) : void {
374+ this . changeEditorMode ( { mode, reason : 'manually' , emit : opts ?. emit } ) ;
372375 }
373376
374- changeEditorMode ( opts : ChangeEditorModeOptions ) : void {
377+ changeEditorMode ( { emit = true , ... opts } : ChangeEditorModeOptions ) : void {
375378 if ( this . #editorMode === opts . mode ) return ;
376379 this . currentMode = opts . mode ;
377380 this . emit ( 'rerender' , null ) ;
378- if ( opts . reason !== 'error-boundary' ) {
381+ if ( emit ) {
379382 this . emit ( 'change-editor-mode' , opts ) ;
380383 }
381384 }
0 commit comments