Forum Discussion

steffenschoene's avatar
4 years ago

TinyMce/Editor on custom textarea

Hi,

I try to use the Khoros TinyMce on a custom textarea element in DOM. I already tried this by using 'window.tinymce.init' or 'window.tinymce.EditorManager.execCommand('mceAddEditor', true, target_element)'.

Both commands ends into a vanilla tinymce instance without the Khoros editor settings. Did anyone figure out how to get the Khoros settings of the TinyMce to initiate a TinyMce on a custom field? The target is to add the textarea by JavaScript and initiate the TinyMce after that.

Greetings 

3 Replies

  • VaibhavC's avatar
    VaibhavC
    Khoros Alumni (Retired)
    4 years ago

    steffenschoene please let me know if I understood the use-case incorrectly:

    You are trying to add a textarea element in the DOM using Javascript and you want to initialise the TinyMCE editor on that textarea.

    As you mentioned, if you use the plain old tinyMce.init() it would just initialise a brand new version of the TinyMCE Editor. However you could try passing in the "selector" field in the init options. Something like: tinyMce.init({ selector: "" }). If you give the selector of an already existing TinyMCE Editor on the page, it could just work.

    Another thing you could try is obtaining the settings from the existing editor (using the global tinyMce on window) and then using it in the init options for the new editor you want.

    Please let me know if this works or if you have any questions.

    Thanks
    Vaibhav

  • MattV's avatar
    MattV
    Khoros Staff
    4 years ago

    I think you're going to have a hard time trying to build a custom editor that works just like the OOB editors.

    The problem is when community loads the OOB editors, it grabs specific configs for that editor from the backend (so the blog editor might have a different backend config from the TKB editor). It also takes into consideration the users HTML permissions to determine which editor tools to load.

    If you're creating the editor on a page that already has an editor, you might have slightly better luck trying to duplicate.