commit 92afd05a0c53ba344335ff8f74a934ca019fe06a parent 489a8cefec6d0a37e786f238bbd7b4015a8a6805 Author: Henry Unite <unitehenry@gmail.com> Date: Tue, 8 Sep 2020 09:46:39 -0400 better clear format Diffstat:
| M | src/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 =>