This commit is contained in:
parent
b000ae0a51
commit
df82f2444f
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user