|
|
@ -19,6 +19,7 @@ class TextEditor extends EventEmitter {
|
|
|
|
document.getElementById("edit").addEventListener("input", (e) => {
|
|
|
|
document.getElementById("edit").addEventListener("input", (e) => {
|
|
|
|
let result_element = document.querySelector("#highlight-content");
|
|
|
|
let result_element = document.querySelector("#highlight-content");
|
|
|
|
this.textEditor = textEditor;
|
|
|
|
this.textEditor = textEditor;
|
|
|
|
|
|
|
|
|
|
|
|
// Update code
|
|
|
|
// Update code
|
|
|
|
let text = e.target.value;
|
|
|
|
let text = e.target.value;
|
|
|
|
result_element.innerHTML = text
|
|
|
|
result_element.innerHTML = text
|
|
|
@ -27,7 +28,7 @@ class TextEditor extends EventEmitter {
|
|
|
|
let editorHeight = document.getElementById("highlight").offsetHeight;
|
|
|
|
let editorHeight = document.getElementById("highlight").offsetHeight;
|
|
|
|
document.getElementById("edit-post-wrapper").style.height =
|
|
|
|
document.getElementById("edit-post-wrapper").style.height =
|
|
|
|
editorHeight + "px";
|
|
|
|
editorHeight + "px";
|
|
|
|
e.target.style.height = editorHeight + "px";
|
|
|
|
e.target.style.height = editorHeight + 30 + "px"; //TODO: yeah, it's ugly but it works for now, fix soon
|
|
|
|
// Syntax Highlight
|
|
|
|
// Syntax Highlight
|
|
|
|
Prism.highlightElement(result_element);
|
|
|
|
Prism.highlightElement(result_element);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -92,7 +93,7 @@ class TextEditor extends EventEmitter {
|
|
|
|
let len = this.textEditor.value.length;
|
|
|
|
let len = this.textEditor.value.length;
|
|
|
|
let start = this.textEditor.selectionStart;
|
|
|
|
let start = this.textEditor.selectionStart;
|
|
|
|
let end = this.textEditor.selectionEnd;
|
|
|
|
let end = this.textEditor.selectionEnd;
|
|
|
|
let insert = "![image alt text](" + data + " 'image title')";
|
|
|
|
let insert = "![image alt text](" + data + ")";
|
|
|
|
|
|
|
|
|
|
|
|
this.textEditor.value =
|
|
|
|
this.textEditor.value =
|
|
|
|
this.textEditor.value.substring(0, start) +
|
|
|
|
this.textEditor.value.substring(0, start) +
|
|
|
|