This commit is contained in:
parent
b000ae0a51
commit
df82f2444f
@ -9,10 +9,16 @@ export class WysiwygComponent implements OnInit {
|
||||
@ViewChild('editable') editable;
|
||||
@Input() readonly = false;
|
||||
@Input() set contents(val: string) {
|
||||
if ( this.isFocused ) {
|
||||
if ( this.editingContents !== val ) {
|
||||
this.editingContents = val;
|
||||
}
|
||||
} else {
|
||||
if ( this.currentContents !== val ) {
|
||||
this.currentContents = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get contents(): string {
|
||||
return this.currentContents;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user