11import $ from 'jquery' ;
22import Component from '@ember/component' ;
3- import { debounce } from '@ember/runloop' ;
43import { observer , computed } from '@ember/object' ;
54import { v4 } from 'ember-uuid' ;
65import { isTesting } from 'open-event-frontend/utils/testing' ;
76
87export default Component . extend ( {
98
10- editor : null ,
9+ editor : null ,
10+ timeoutFunc : null ,
1111
1212 // Ensure any changes to the parser rules are set in the sanitizer @ services/sanitizer.js
1313 standardParserRules : {
@@ -37,6 +37,7 @@ export default Component.extend({
3737 valueObserver : observer ( 'value' , function ( ) {
3838 if ( this . editor && this . editor . getValue ( ) !== this . value ) {
3939 this . editor . setValue ( this . value ) ;
40+ this . editor . focus ( true ) ;
4041 }
4142 } ) ,
4243
@@ -61,11 +62,11 @@ export default Component.extend({
6162 } ) ;
6263
6364 const updateValue = ( ) => {
64- debounce ( this , ( ) => {
65+ if ( this . timeoutFunc ) {
66+ clearTimeout ( this . timeoutFunc ) ;
67+ }
68+ this . timeoutFunc = setTimeout ( ( ) => {
6569 let value = String ( this . editor . getValue ( ) ) . replace ( / ( < b r > ) * $ / g, '' ) . replace ( / & n b s p ; / g, ' ' ) ;
66- // if (navigator.userAgent.indexOf('Firefox') !== -1) {
67- // value = value + '<br>';
68- // }
6970 let trimmedValue = new String ( '' ) ;
7071 let i = value . length ;
7172 while ( i -- ) {
@@ -75,7 +76,7 @@ export default Component.extend({
7576 }
7677 value = trimmedValue ;
7778 this . setProperties ( { _value : value , value } ) ;
78- } , 200 ) ;
79+ } , 500 ) ;
7980 } ;
8081
8182 this . editor . on ( 'interaction' , updateValue ) ;
0 commit comments