commit 0bdabaced5a75713a0cf7482f0f44894f46adcb1
parent 0dea80d48797af55f191874af351fb852f9a1c93
Author: unitehenry <unitehenry@gmail.com>
Date: Tue, 5 Nov 2019 09:45:57 -0500
getActiveOptions
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -254,13 +254,11 @@ export default class StrivenEditor {
// keep enabled options on initial selection
if (!this.body.textContent) {
- this.toolbarOptions.forEach((opt) => {
- if (opt.classList.contains('se-toolbar-option-active')) {
- if (this.browser.isFirefox() || this.browser.isEdge()) {
- document.execCommand(opt.id.split('-')[1]);
- } else {
- document.execCommand(opt.id.split('-')[1], true);
- }
+ this.getActiveOptions().forEach((opt) => {
+ if (this.browser.isFirefox() || this.browser.isEdge()) {
+ document.execCommand(opt);
+ } else {
+ document.execCommand(opt, true);
}
})
}
@@ -1007,7 +1005,7 @@ export default class StrivenEditor {
textDecorationMenu.onclick = () => {
that.closeAllMenus();
-
+
let isOpen = (textDecorationMenu.dataset.open === 'true');
textDecorationMenu.dataset.open = (isOpen ? 'false' : 'true');
isOpen = (textDecorationMenu.dataset.open === 'true');
@@ -1119,6 +1117,12 @@ export default class StrivenEditor {
}).then((res) => res.json())
}
+ getActiveOptions() {
+ return [...this.toolbarOptions]
+ .filter(opt => opt.classList.contains('se-toolbar-option-active'))
+ .map(opt => opt.id.split('-').pop())
+ }
+
validURL(str) {
var pattern = new RegExp(
"^(https?:\\/\\/)?" +