Skip to content

Commit

Permalink
fix: deal with non-existing button groups in lower ankis
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiesel committed Dec 22, 2023
1 parent c9f5c49 commit 9f51bc6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ function setupMigakuEditor(settings) {
document.querySelectorAll('.editing-area').forEach((field) => field.style.display = 'none');
document.querySelectorAll('.plain-text-badge').forEach((field) => field.style.display = 'none');
document.querySelectorAll('svg#mdi-pin-outline').forEach((field) => field.parentElement.parentElement.parentElement.style.display = 'none');
hiddenButtonCategories.forEach((category) => document.querySelector(`.item#${category}`).style.display = 'none');

hiddenButtonCategories.forEach((category) => {
const button = document.querySelector(`.item#${category}`)
if (button) button.style.display = 'none'
});

for (const field of document.querySelectorAll('.editor-field')) {
field.append(getSelectorField(field, settings))
Expand All @@ -91,7 +95,11 @@ MigakuEditor.resetMigakuEditor = function () {
document.querySelectorAll('.editing-area').forEach((field) => field.style.display = '');
document.querySelectorAll('.plain-text-badge').forEach((field) => field.style.display = '');
document.querySelectorAll('svg#mdi-pin-outline').forEach((field) => field.parentElement.parentElement.parentElement.style.display = '');
hiddenButtonCategories.forEach((category) => document.querySelector(`.item#${category}`).style.display = '');

hiddenButtonCategories.forEach((category) => {
const button = document.querySelector(`.item#${category}`)
if (button) button.style.display = ''
});

document.querySelectorAll('.migaku-field-selector').forEach((selector) => selector.remove());
}
Expand Down

0 comments on commit 9f51bc6

Please sign in to comment.