From ff91810a67e96aab5a1679b417c5383395787094 Mon Sep 17 00:00:00 2001 From: Chupurnov Valeriy Date: Mon, 12 Mar 2018 13:28:14 +0500 Subject: [PATCH] Fixed bug in source mode when autosize was calculated only after click --- src/plugins/source.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/source.ts b/src/plugins/source.ts index 297481ce3..9c4645b37 100644 --- a/src/plugins/source.ts +++ b/src/plugins/source.ts @@ -150,10 +150,10 @@ export class source extends Component { } }; - private autosize = () => { + private autosize = debounce(() => { this.mirror.style.height = 'auto'; this.mirror.style.height = this.mirror.scrollHeight + 'px'; - }; + }, this.jodit.options.observer.timeout); private getNormalPosition = (pos: number, str: string): number => { let start: number = pos; @@ -183,7 +183,8 @@ export class source extends Component { editor.events .on(this.mirror, 'mousedown keydown touchstart input', debounce(this.toWYSIWYG, editor.options.observer.timeout)) - .on(this.mirror, 'change keydown mousedown touchstart input', debounce(this.autosize, editor.options.observer.timeout)) + .on(this.mirror, 'change keydown mousedown touchstart input', this.autosize) + .on('afterSetMode', this.autosize) .on(this.mirror, 'mousedown focus', (e: Event) => { editor.events.fire(e.type, e); });