@@ -482,7 +482,6 @@ var codeInput = {
482482 * to syntax-highlight it. */
483483
484484 needsHighlight = false ; // Just inputted
485- handleEventsFromTextarea = true ; // Turn to false when unusual internal events are called on the textarea
486485 originalAriaDescription ;
487486
488487 /**
@@ -523,14 +522,6 @@ var codeInput = {
523522
524523 this . syncSize ( ) ;
525524
526- // If editing here, scroll to the caret by focusing, though this shouldn't count as a focus event
527- if ( this . textareaElement === document . activeElement ) {
528- this . handleEventsFromTextarea = false ;
529- this . textareaElement . blur ( ) ;
530- this . textareaElement . focus ( ) ;
531- this . handleEventsFromTextarea = true ;
532- }
533-
534525 this . pluginEvt ( "afterHighlight" ) ;
535526 }
536527
@@ -646,9 +637,7 @@ var codeInput = {
646637 this . classList . add ( "code-input_mouse-focused" ) ;
647638 } ) ;
648639 textarea . addEventListener ( "blur" , ( ) => {
649- if ( this . handleEventsFromTextarea ) {
650- this . classList . remove ( "code-input_mouse-focused" ) ;
651- }
640+ this . classList . remove ( "code-input_mouse-focused" ) ;
652641 } ) ;
653642
654643 this . innerHTML = "" ; // Clear Content
@@ -874,22 +863,20 @@ var codeInput = {
874863 this . boundEventCallbacks [ listener ] = boundCallback ;
875864
876865 if ( codeInput . textareaSyncEvents . includes ( type ) ) {
877- // Synchronise with textarea, only when handleEventsFromTextarea is true
878- // This callback is modified to only run when the handleEventsFromTextarea is set.
879- let conditionalBoundCallback = function ( evt ) { if ( this . handleEventsFromTextarea ) boundCallback ( evt ) ; } . bind ( this ) ;
880- this . boundEventCallbacks [ listener ] = conditionalBoundCallback ;
866+ // Synchronise with textarea
867+ this . boundEventCallbacks [ listener ] = boundCallback ;
881868
882869 if ( options === undefined ) {
883870 if ( this . textareaElement == null ) {
884871 this . addEventListener ( "code-input_load" , ( ) => { this . textareaElement . addEventListener ( type , boundCallback ) ; } ) ;
885872 } else {
886- this . textareaElement . addEventListener ( type , conditionalBoundCallback ) ;
873+ this . textareaElement . addEventListener ( type , boundCallback ) ;
887874 }
888875 } else {
889876 if ( this . textareaElement == null ) {
890877 this . addEventListener ( "code-input_load" , ( ) => { this . textareaElement . addEventListener ( type , boundCallback , options ) ; } ) ;
891878 } else {
892- this . textareaElement . addEventListener ( type , conditionalBoundCallback , options ) ;
879+ this . textareaElement . addEventListener ( type , boundCallback , options ) ;
893880 }
894881 }
895882 } else {
@@ -949,10 +936,12 @@ var codeInput = {
949936 if ( val === null || val === undefined ) {
950937 val = "" ;
951938 }
939+
952940 // Save in editable textarea element
953941 this . textareaElement . value = val ;
954942 // Trigger highlight
955943 this . scheduleHighlight ( ) ;
944+
956945 return val ;
957946 }
958947
0 commit comments