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