simplifying editor refresh for now, still kind of weird

sql-version-freeze
Ro 6 years ago
parent 59c46f64e2
commit 0ed2f1ace7

@ -43,8 +43,6 @@ class TextEditor extends EventEmitter
} }
}); });
this.refresh(); this.refresh();
//window.scroll(0,0);
//document.execCommand('insertBrOnReturn', false, true);
} }
//-------------------------- //--------------------------
// methods // methods
@ -57,20 +55,14 @@ class TextEditor extends EventEmitter
{ {
editorButtons[i].addEventListener('click', e => this.handleEditorOption(e), false); editorButtons[i].addEventListener('click', e => this.handleEditorOption(e), false);
} }
this.textEditor.addEventListener('input', f =>
{
self.refresh();
})
} }
refresh() refresh()
{ {
var caret = position(this.textEditor).pos;
var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value; var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
spiffed = spiffed.replace(new RegExp('\r?\n','g'), '<br>'); spiffed = spiffed.replace(new RegExp('\r?\n','g'), '<br>');
var temp = document.createElement("div"); var temp = document.createElement("div");
temp.innerText = spiffed; temp.innerText = spiffed;
this.textEditor.innerHTML = temp.innerText; this.textEditor.innerHTML = temp.innerText;
position(this.textEditor, caret)
this.textEditor.style.maxWidth = '900px'; this.textEditor.style.maxWidth = '900px';
} }
notify(type, data) notify(type, data)
@ -156,6 +148,7 @@ class TextEditor extends EventEmitter
this.emitEvent(EditorEvent.EDITOR_UPDATE); this.emitEvent(EditorEvent.EDITOR_UPDATE);
break break
case "edit-link": case "edit-link":
console.log("PULLED", pulled)
range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)"));
break; break;
case "edit-delete": case "edit-delete":

@ -2353,7 +2353,6 @@ select {
-o-line-break: normal; -o-line-break: normal;
-moz-line-break: normal; -moz-line-break: normal;
display: inline-block; display: inline-block;
overflow-wrap: break-word;
width: 100%; width: 100%;
max-width: 900px; max-width: 900px;
} }

File diff suppressed because one or more lines are too long

@ -7830,9 +7830,7 @@ function (_EventEmitter) {
} }
}); });
_this.refresh(); //window.scroll(0,0); _this.refresh();
//document.execCommand('insertBrOnReturn', false, true);
return _this; return _this;
} //-------------------------- } //--------------------------
@ -7853,21 +7851,15 @@ function (_EventEmitter) {
return _this2.handleEditorOption(e); return _this2.handleEditorOption(e);
}, false); }, false);
} }
this.textEditor.addEventListener('input', function (f) {
self.refresh();
});
} }
}, { }, {
key: "refresh", key: "refresh",
value: function refresh() { value: function refresh() {
var caret = (0, _caretPos.position)(this.textEditor).pos;
var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value; var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
spiffed = spiffed.replace(new RegExp('\r?\n', 'g'), '<br>'); spiffed = spiffed.replace(new RegExp('\r?\n', 'g'), '<br>');
var temp = document.createElement("div"); var temp = document.createElement("div");
temp.innerText = spiffed; temp.innerText = spiffed;
this.textEditor.innerHTML = temp.innerText; this.textEditor.innerHTML = temp.innerText;
(0, _caretPos.position)(this.textEditor, caret);
this.textEditor.style.maxWidth = '900px'; this.textEditor.style.maxWidth = '900px';
} }
}, { }, {
@ -7965,6 +7957,7 @@ function (_EventEmitter) {
break; break;
case "edit-link": case "edit-link":
console.log("PULLED", pulled);
range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)"));
break; break;

File diff suppressed because one or more lines are too long

@ -7,7 +7,7 @@
| S | S
button#edit-link.content-editor-btn-icon.editor-button(title="insert link") button#edit-link.content-editor-btn-icon.editor-button(title="insert link")
svg#edit-link(viewBox="0 0 20 20" class="icons") svg#edit-link(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-link') use#edit-link(xlink:href='/dash/assets/images/sprite.svg#entypo-link')
button#edit-header1.content-editor-btn-text.editor-button(title="header 1") button#edit-header1.content-editor-btn-text.editor-button(title="header 1")
| H1 | H1
button#edit-header2.content-editor-btn-text.editor-button(title="header 2") button#edit-header2.content-editor-btn-text.editor-button(title="header 2")

@ -208,7 +208,6 @@
-o-line-break normal -o-line-break normal
-moz-line-break normal -moz-line-break normal
display inline-block display inline-block
overflow-wrap: break-word
width 100% width 100%
max-width 900px max-width 900px

Loading…
Cancel
Save