Skip to content

Conversation

vietlx426
Copy link

Hi @srobotta Currently after selecting text in TinyMCE and applying a language through the Language button, the multilang content is not properly saved to the server, causing a disconnect between what's displayed in the editor and what's actually stored.

Steps to reproduce:

  1. Navigate to any activity
  2. On activity settings page -> TinyMCE box -> Type any word-> select the word
  3. Click on Language button
  4. Choose any language from the list
  5. Save the changes and check the activity page
image

Result :
image

Root Cause: The root cause of this issue is when we save a form that contains multilang content, the multilang2 plugin listens to the submit event and calls removeVisualStyling(). This function processes the editor content by converting TinyMCE's visual placeholder tags.
The problem is that after removeVisualStyling() modifies the editor content, the plugin doesn't sync these changes back to the underlying form field. So while the editor display shows the processed content, the form still submits the original unprocessed content to the server.

Solution: Add editor.save() call after removeVisualStyling() to force TinyMCE to sync the modified editor content back to the actual form field that gets submitted to the server.
Could you please review my PR?

@srobotta
Copy link
Collaborator

srobotta commented Oct 8, 2025

Hi @vietlx426,

I am a bit reluctant to include this PR because I don't quite understand, why the plugin should call editor.save().
When you submit a form, the onSubmit event of the TinyMCE is triggered. The removeVisualStyling() function is listening on that event and changes the content i.e. remove the colors from the {mlang} tags. Other plugins might do the same by changing the editor content. The final action after all the event listeners have been executed, the current editor content should be synced.
If there is a bug in the multilang plugin, I would expect more people about complaining that the visual styles are not removed. Therefore, I assume that another plugin on your installation is causing the problem and then maybe this somehow prevents other plugins (including the multilang2) from working correctly.
Can you please give me more info on what you have installed? In your screenshot, I see a quote icon. Is that another Tiny plugin? Which Moodle version are you using?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants