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 92afd05a0c53ba344335ff8f74a934ca019fe06a
parent 489a8cefec6d0a37e786f238bbd7b4015a8a6805
Author: Henry Unite <unitehenry@gmail.com>
Date:   Tue,  8 Sep 2020 09:46:39 -0400

better clear format

Diffstat:
Msrc/striveneditor.js | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -287,10 +287,19 @@ export default class StrivenEditor { } break; case 'removeFormat': - this.executeCommand('formatBlock', 'p'); + + const range = this.getRange(); + const { tagName } = range.commonAncestorContainer; + + if(tagName && (tagName === 'OL' || tagName === 'UL')) { + range.commonAncestorContainer.innerHTML = range.commonAncestorContainer.textContent; + return; + } - // Remove the format of content - this.executeCommand(command); + const textNode = document.createTextNode( range.toString() ); + range.deleteContents(); + range.insertNode(textNode); + range.selectNodeContents(textNode); // Deactivate all toolbar options this.toolbarOptions.forEach(o =>