Skip to content

Commit

Permalink
check for tinymce fields
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Oct 4, 2024
1 parent 60a0424 commit 002236b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/plone/app/multilingual/browser/javascript/babel_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@

const gtranslate_enabled = document.getElementById("gtranslate_service_available");

var target_el = dest_field.querySelector('textarea,input');
const target_tiny = tinymce.get(target_el.id);

// Add the google translation field
if (
gtranslate_enabled.value === "True" &&
dest_field.querySelectorAll('.text-widget, .textarea-widget, .richTextWidget').length &&
gtranslate_enabled.value === "True" && (
// it is either a text widget, a text area or rich widget
dest_field.querySelectorAll('.text-widget, .textarea-widget, .richTextWidget').length ||
// or it is a tinymce richtextfield without wrapping CSS class
target_tiny !== null
) &&
!orig_field.querySelector(".translator-widget")
) {
const translator_widget = document.createElement("div");
Expand Down Expand Up @@ -94,9 +101,6 @@
const json = await response.json();
var text_target = json.data;

var target_el = dest_field.querySelector('textarea,input');
const target_tiny = tinymce.get(target_el.id);

if (target_tiny) {
// a TinyMCE editor is present
await target_tiny.setContent(text_target);
Expand Down

0 comments on commit 002236b

Please sign in to comment.