Skip to content

Commit

Permalink
Update private/js/tiptap_plugins/cms.toolbar.js
Browse files Browse the repository at this point in the history
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
fsbraun and sourcery-ai[bot] authored Dec 26, 2024
1 parent 90f93a9 commit edafb88
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions private/js/tiptap_plugins/cms.toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,28 +499,27 @@ function _updateToolbar(editor, toolbar) {
}
for (const button of toolbar.querySelectorAll(selector)) {
const {action} = button.dataset;
if (action) {
if (TiptapToolbar[action]) {
const toolbarItem = window.cms_editor_plugin._getRepresentation(action);
try {
button.disabled = !toolbarItem?.enabled(editor, button);
try {
if (toolbarItem?.active(editor, button)) {
button.classList.add('active');
} else {
button.classList.remove('active');
}
if (TiptapToolbar[action].attributes) {
populateForm(button, TiptapToolbar[action].attributes(editor), toolbarItem.form);
}
} catch (e) {
}
} catch (e) {
console.warn(e);
button.remove();
}
}
if (action && TiptapToolbar[action]) {
const toolbarItem = window.cms_editor_plugin._getRepresentation(action);
try {
button.disabled = !toolbarItem?.enabled(editor, button);
try {
if (toolbarItem?.active(editor, button)) {
button.classList.add('active');
} else {
button.classList.remove('active');
}
if (TiptapToolbar[action].attributes) {
populateForm(button, TiptapToolbar[action].attributes(editor), toolbarItem.form);
}
} catch (e) {
}
} catch (e) {
console.warn(e);
button.remove();
}
}

}
editor.options.el.dataset.selecting = 'false';
}
Expand Down

0 comments on commit edafb88

Please sign in to comment.