From f7a7c7afea536f718ccfb3e04175534f09f9fdcb Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Wed, 20 Sep 2023 16:10:22 +0800 Subject: [PATCH] Add change handler for Edit Recovery When the Edit Recovery loading process is finished, add an Ace editor change handler so that the Edit Recovery fields are saved whenever there's a change to the CodeEditor data. This is similar to the change made for CodeMirror: I352470752130c7b9b2dfc55a066cecf785d40067 Bug: T344406 Change-Id: I2c7826379108a88be7956d84bbfd3200b5ad542f --- modules/jquery.codeEditor.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/jquery.codeEditor.js b/modules/jquery.codeEditor.js index 59f84e1f..1cd12272 100644 --- a/modules/jquery.codeEditor.js +++ b/modules/jquery.codeEditor.js @@ -400,6 +400,11 @@ mw.hook( 'codeEditor.configure' ).fire( session ); + // Add an Ace change handler to pass changes to Edit Recovery. + mw.hook( 'editRecovery.loadEnd' ).add( function ( data ) { + session.on( 'change', data.fieldChangeHandler ); + } ); + ace.config.loadModule( 'ace/ext/modelist', function ( modelist ) { if ( !modelist || !modelist.modesByName[ lang ] ) { lang = 'text';