From aed6f45b58d4fb853a4253c881f990d6b3c7438c Mon Sep 17 00:00:00 2001 From: Estrada Matthieu Date: Thu, 4 Jul 2019 12:55:38 +0200 Subject: [PATCH] add eraser button to remove all format Ref #145 --- src/pell.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pell.js b/src/pell.js index c5a1bf2..3796045 100644 --- a/src/pell.js +++ b/src/pell.js @@ -88,6 +88,19 @@ const defaultActions = { const url = window.prompt('Enter the image URL') if (url) exec('insertImage', url) } + }, + eraser: { + icon: '✗', + title: 'Clear', + result: () => { + if (window.getSelection().toString()) { + let linesToDelete = window.getSelection().toString().split('\n').join('
'); + window.pell.exec(formatBlock, '
'); + document.execCommand('insertHTML', false, '
' + linesToDelete + '
'); + } else { + window.pell.exec(formatBlock, '
') + } + } } }