manoyanx
manoyanx

Reputation: 181

Enable or Disable the browser spellchecker function of tinyMCE

I have a custom toolbar button, which is used to toggle the browser's spell check. I have set

browser_spellcheck : true

on the editor initialization. I need to turn 'off' the spell check when I press the custom toolbar button I made.

I am aware that we cannot change tinyMCE's init options after initialization. I am looking on a way to achieve my goal of having to toggle the spellchecking function via a toolbar button.

Also, I have already searched the site for similar questions and found this How to toggle browser spellcheck dynamically in tinymce but it currently has no answers. I can't comment on it so I posted a new question.

Upvotes: 1

Views: 1265

Answers (1)

Tiny Lincoln
Tiny Lincoln

Reputation: 1102

You have mentioned:

I am aware that we cannot change tinyMCE's init options after initialization.

...and browser_spellcheck : true is an init option.

Therefore, nothing within TinyMCE itself - including a toolbar button, which is defined upon init - will be able to change that init option, as the option cannot be changed without destroying and re-rendering the editor with new configuration.

If you take this desired functionality outside of TinyMCE, you could potentially create an external button that:

  • Grabs all of the current content of the TinyMCE editor
  • Saves that content
  • Destroys the current editor instance
  • Initializes a new instance with desired configuration changes
  • Reloads the content into the editor

Upvotes: 2

Related Questions