# 시험결과분석 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.setAttribute('style', 'max-height:250px; max-width:250px;');
img[ATTR_FILE] = file; img[ATTR_FILE] = file;
self.insertNode(img); self.insertNode(img);
const empty = document.createElement('div');
empty.innerHTML = '&nbsp;<br/>';
self.insertNode(empty, true);
} }
self.fileInput.nativeElement.value = ''; 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) { private insertNode(node: Node, removeSelected: boolean = false) {
const selection: Selection = document.getSelection(); const selection: Selection = document.getSelection();
const range: Range = selection.getRangeAt(0);
let inEditor = false; if (!!selection && !!selection.anchorNode) {
if (removeSelected) { const range: Range = selection.getRangeAt(0);
// onPaste
selection.empty();
inEditor = true;
} else {
inEditor = this.inEditor(selection.anchorNode);
}
if (inEditor) { let inEditor = false;
range.insertNode(node); 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 { } else {
this.editor.nativeElement.appendChild(node); this.editor.nativeElement.appendChild(node);
} }
selection.empty();
} }
private inEditor(el) { private inEditor(el) {