commit 73e0d1830049294d5594f88f285c269b87bf35cf
parent 226fad58e74567bc747c2b9b6b08cbe9f5305233
Author: unitehenry <unitehenry@gmail.com>
Date: Wed, 23 Sep 2020 20:18:33 -0400
tab out blur handle
Diffstat:
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -1140,6 +1140,10 @@ export default class StrivenEditor {
}
}
}
+
+ if(tab && document.activeElement !== se.body && se.body.textContent.trim() === '') {
+ se.clearContent();
+ }
});
const bodyFocus = body.onfocus;
@@ -1189,10 +1193,6 @@ export default class StrivenEditor {
body.onblur = e => {
se.editor.classList.remove('se-focus');
- if(se.body.textContent.trim() === '') {
- se.clearContent();
- }
-
window.removeEventListener('mouseup', execRange);
se.scrollPosition = {
@@ -2891,21 +2891,20 @@ export default class StrivenEditor {
const se = this;
function textDecorationInsert(el) {
- const r = se.getRange();
+ const r = se.range || new Range();
+ se.setRange(r);
+
+ const b = document.createElement(el);
+ const selNode = document.createElement('span');
+ selNode.innerHTML = ' ';
- if(r) {
- const b = document.createElement(el);
- const selNode = document.createElement('span');
- selNode.innerHTML = ' ';
-
- b.append(selNode);
-
- const fc = se.body.firstChild
- fc ? fc.append(b) : se.body.append(b);
+ b.append(selNode);
+
+ const fc = se.body.firstChild;
+ fc ? fc.append(b) : se.body.append(b);
- r.selectNode(selNode);
- r.collapse();
- }
+ r.selectNode(selNode);
+ r.collapse();
}
switch (command) {