# 시험결과분석 54, 66

This commit is contained in:
leejinho 2020-02-12 13:00:43 +09:00
parent 74ba71ceb9
commit dc2c254639

View File

@ -185,10 +185,17 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
img.setAttribute('style', 'max-height:250px; max-width:250px;');
img[ATTR_FILE] = file;
self.insertNode(img);
const empty = document.createElement('div');
empty.innerHTML = '&nbsp;<br/>';
self.insertNode(empty, true);
}
self.fileInput.nativeElement.value = '';
this.fileInput.nativeElement.onchange = undefined;
self.fileInput.nativeElement.onchange = undefined;
self.checkContentLength();
self.changeDetectorRef.detectChanges();
};
}
@ -564,23 +571,27 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
private insertNode(node: Node, removeSelected: boolean = false) {
const selection: Selection = document.getSelection();
const range: Range = selection.getRangeAt(0);
let inEditor = false;
if (removeSelected) {
// onPaste
selection.empty();
inEditor = true;
} else {
inEditor = this.inEditor(selection.anchorNode);
}
if (!!selection && !!selection.anchorNode) {
const range: Range = selection.getRangeAt(0);
if (inEditor) {
range.insertNode(node);
let inEditor = false;
if (removeSelected) {
// onPaste
selection.empty();
inEditor = true;
} else {
inEditor = this.inEditor(selection.anchorNode);
}
if (inEditor) {
range.insertNode(node);
} else {
this.editor.nativeElement.appendChild(node);
}
} else {
this.editor.nativeElement.appendChild(node);
}
selection.empty();
}
private inEditor(el) {