AnsweredAssumed Answered

Modifying / Replacing WYSIWYG-editor in Share

Question asked by huima on Nov 24, 2010
Latest reply on May 11, 2011 by wabson
Hi ya all,

wondered whether anyone has yet replaced TinyMCE with a newer version or even totally different editor, for example with CK editor. We initially thought about it, but decided now to drop it - as we figured out how to do similar things with TinyMCE and did not want to take at this stage the expense of figuring out how to fully integrate the editor with Share.

However with my studying on the subject I learned that it should be doable quite easily - as guys from Alfresco have done magnificent job of using YUI well and provided abstractions - which allow you to use different editors. My thought was that I could replace the current editor by creating own adapter class based on TinyCMS adapter ( found in webframework-commons … less source/web/modules/editors/tiny_mce.js ) and creating own superclass of Alfresco.RichTextEditor YUI widget, which creates my requested kind of editor from RichEditorManager instead of the default one.

We haven't yet tried to upgrade TinyMCE or install new plugins, but would be interested to hear if people have success stories and/or examples of that.

Otherwise modifications to TinyCME seem to be quite easy to do and it is quite easy to get the handle to the TinyMCE editor instance in you client javascript.

Below is an example you can use in form control freemarker templates. It takes the HTML-field id parameter, which is also the name of the editor instance id – and gets the editor, and then commands it to  insert content into the editor.

<a href="javascript:;"
onmousedown="tinyMCE.getInstanceById('${fieldHtmlId}').execCommand('mceInsertContent',false,'<b>Hello world!!</b>');">
[Insert HTML]</a>

Outcomes