simplifying editor refresh for now, still kind of weird

This commit is contained in:
Ro 2019-02-23 22:07:14 -05:00
parent 59c46f64e2
commit 0ed2f1ace7
7 changed files with 6 additions and 22 deletions

View file

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

View file

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

File diff suppressed because one or more lines are too long

View file

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

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
| S
button#edit-link.content-editor-btn-icon.editor-button(title="insert link")
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")
| H1
button#edit-header2.content-editor-btn-text.editor-button(title="header 2")

View file

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