commit c61263491520353db50833f2d2a362c16f016a7f
parent e64f22e449a47f0891831ecab2a416e3c665e010
Author: Henry Unite <unitehenry@gmail.com>
Date: Thu, 27 Aug 2020 17:06:52 -0400
insert list with no range initialized
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -2914,6 +2914,19 @@ export default class StrivenEditor {
}
break;
case 'insertOrderedList':
+ if(!this.range && !this.getContent()) {
+ const list = document.createElement('ol');
+ list.append(document.createElement('li'));
+
+ this.body.append(list);
+
+ const r = new Range();
+ window.getSelection().addRange(r);
+ r.selectNode(list);
+
+ return false;
+ }
+
if (this.browser.isFirefox() || this.browser.isEdge()) {
document.execCommand(command);
} else {
@@ -2921,6 +2934,19 @@ export default class StrivenEditor {
}
break;
case 'insertUnorderedList':
+ if(!this.range && !this.getContent()) {
+ const list = document.createElement('ul');
+ list.append(document.createElement('li'));
+
+ this.body.append(list);
+
+ const r = new Range();
+ window.getSelection().addRange(r);
+ r.selectNode(list);
+
+ return false;
+ }
+
if (this.browser.isFirefox() || this.browser.isEdge()) {
document.execCommand(command);
} else {
@@ -2978,6 +3004,7 @@ export default class StrivenEditor {
}
break;
default:
+ console.log(command);
if (this.browser.isFirefox() || this.browser.isEdge()) {
input
? document.execCommand(command, false, input)