Fixes #37
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-11-15 21:00:29 -06:00
parent b000ae0a51
commit df82f2444f
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -9,8 +9,14 @@ export class WysiwygComponent implements OnInit {
@ViewChild('editable') editable;
@Input() readonly = false;
@Input() set contents(val: string) {
if ( this.currentContents !== val ) {
this.currentContents = val;
if ( this.isFocused ) {
if ( this.editingContents !== val ) {
this.editingContents = val;
}
} else {
if ( this.currentContents !== val ) {
this.currentContents = val;
}
}
}
@ -21,6 +27,7 @@ export class WysiwygComponent implements OnInit {
@Output() contentsChanged: EventEmitter<string> = new EventEmitter<string>();
public currentContents = '';
protected editingContents = '';
public isFocused = false;
protected hadOneFocusOut = false;
@ -52,6 +59,7 @@ export class WysiwygComponent implements OnInit {
onFocusIn(event: MouseEvent) {
console.log('on focus in', event);
this.isFocused = !this.readonly;
this.editingContents = this.currentContents;
}
@HostListener('document:keyup.escape', ['$event'])
@ -68,6 +76,7 @@ export class WysiwygComponent implements OnInit {
} else {
this.isFocused = false;
this.hadOneFocusOut = false;
this.currentContents = this.editingContents;
}
}