striven-editor

Maintained and contributed to an open source WYSIWYG editor as an internship project that made it to production and was adopted by the company I was working at.
git clone https://unitehenry.com/git/striven-editor.git
Log | Files | Refs | README | LICENSE

commit 557243de4be55b09a9b529d0d214d86af87debb5
parent e64f22e449a47f0891831ecab2a416e3c665e010
Author: Sanjog <sanjogsharma@gmail.com>
Date:   Fri, 28 Aug 2020 09:48:33 -0400

Merge pull request #95 from unitehenry/list-fix

Editor should start numbering & bulleting without having to highlight
Diffstat:
Msrc/striveneditor.js | 27+++++++++++++++++++++++++++
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)