Skip to content

Commit

Permalink
Fixed bug in source mode when autosize was calculated only after click
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Mar 12, 2018
1 parent 16fa487 commit ff91810
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit ff91810

Please sign in to comment.