CodeMirrorWikiEditor: add missing hook and fix reference to textarea

This fixes integration with some consumers of the
'ext.CodeMirror.switch' hook, such as Extension:Disambiguator.
The jQuery element passed to the hook is around the CodeMirror DOM
element which has the jQuery.textSelection() API registered to it.

Bug: T317243
Follow-Up: I2239d2449b2db3b638551f847eb4eff1aafa6276
Change-Id: Iec368613da3c69df52ce5e7ca441c31172cdc5de
This commit is contained in:
MusikAnimal 2023-10-10 16:11:15 -04:00
parent 39ed5a05fc
commit 06829a5a0a
3 changed files with 5 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -84,6 +84,8 @@ export default class CodeMirrorWikiEditor extends CodeMirror {
if ( hasFocus ) {
this.view.focus();
}
mw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );
}
/**
@ -172,7 +174,7 @@ export default class CodeMirrorWikiEditor extends CodeMirror {
this.$textarea.prop( 'selectionStart', Math.min( from, to ) )
.prop( 'selectionEnd', Math.max( to, from ) );
this.$textarea.scrollTop( scrollTop );
mw.hook( 'ext.CodeMirror.switch' ).fire( false, this.$textbox1 );
mw.hook( 'ext.CodeMirror.switch' ).fire( false, this.$textarea );
} else {
this.enableCodeMirror();
this.setCodeMirrorPreference( true );