From 5515405df5d2ca9a66512aba65be7fe064aa68ab Mon Sep 17 00:00:00 2001 From: Carla Lara Date: Wed, 2 Jul 2025 13:41:34 +0200 Subject: [PATCH] fix: Froala title buttons calculation --- demos/html/froala/index.html | 2 +- packages/froala/wiris.src.js | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/demos/html/froala/index.html b/demos/html/froala/index.html index 7ee63dafa..659083ac2 100644 --- a/demos/html/froala/index.html +++ b/demos/html/froala/index.html @@ -4,7 +4,7 @@ Demo Froala on HTML - + diff --git a/packages/froala/wiris.src.js b/packages/froala/wiris.src.js index 784f3f9bd..9e9617351 100644 --- a/packages/froala/wiris.src.js +++ b/packages/froala/wiris.src.js @@ -106,23 +106,37 @@ export class FroalaIntegration extends IntegrationModel { const chemTypeId = `wirisChemistry-${editor.id}`; // Hide MathType toolbar button if is disabled by config. - if (!Configuration.get("editorEnabled")) { + if (Configuration.get("editorEnabled")) { + // Translate the button title + const mathButton = document.getElementById(mathTypeId); + + if (!mathButton) { + return + } + + mathButton.title = StringManager.get("insert_math", editor.opts.language); + } + else { FroalaEditor.ICONS.wirisEditor = null; FroalaEditor.COMMANDS.wirisEditor = null; document.getElementById(mathTypeId).classList.add("fr-hidden"); - } else { - // Translate the button title - document.getElementById(mathTypeId).title = StringManager.get("insert_math", editor.opts.language); } // Hide ChemType toolbar button if is disabled by config. - if (!Configuration.get("chemEnabled")) { + if (Configuration.get("chemEnabled")) { + // Translate the button title + const chemButton = document.getElementById(chemTypeId); + + if (!chemButton) { + return + } + + chemButton.title = StringManager.get("insert_chem", editor.opts.language); + } + else { FroalaEditor.ICONS.wirisChemistry = null; FroalaEditor.COMMANDS.wirisChemistry = null; document.getElementById(chemTypeId).classList.add("fr-hidden"); - } else { - // Translate the button title - document.getElementById(chemTypeId).title = StringManager.get("insert_chem", editor.opts.language); } }