Fixes #37
continuous-integration/drone/push Build is passing Details

master
Garrett Mills 4 years ago
parent b000ae0a51
commit df82f2444f
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

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

Loading…
Cancel
Save