Teamsite’s TinyMCE considered very useful, with this hack

I’ve blogged before on how disappointed I was with Interwoven’s implementation of TinyMCE. I now found a way to circumvent the problems with it. This trick (or rather a full-blown hack) will enable you to use all of the configuration-options offered by TinyMCE.

But, WARNING, WARNING, this hack comes with a clear price:
- it comes with no support, not from Interwoven, neither from me.
- future patches can/will be overwrite your changes in dc-editor.js

 The hack involves making changes to two files:

Changes to dc-editor.js:
1. Open [iw-home] httpd/webapps/content_center/datacapture/dc_editor.js in an editor
2. Locate the function ‘IWTinyMCEEditor.prototype.initialize’
3. Add this code to the bottom of this function:

//custom: custom addition 1

custom_tinymce_additional_configuration(tinymce, editorConfig);

//custom: end of custom addition 1

4. add this code right BELOW this function:

//custom addition 2 (1 line only):

var custom_tinymce_included = true; //to signal that the custom code is include in this file

Changes to custom_config.js:
1. Open [iw-home] httpd/iw/tinymce/config/custom_config.js
2. Add this code to the file (location does not matter, bottom is most appropriate):

//custom: custom code begin

//test to see if our custom code is included in the dc-editor.js file:

if (typeof custom_tinymce_included == 'undefined') {

alert('ERROR: custom-tinymce code is missing from dc_editor.js!!! Please contact your admin.');

}

//the function that does all the hard work and that should be called from dc-editor.js

function custom_tinymce_additional_configuration(tinymce, editorConfig) {

//a hash that sets all the default configuration-values

var defaultConfig = {

/*the key/values as set by interwoven:*/

debug: false, //not sure of the effect of this, use with care!

//mode: "exact", //DO NOT SET THIS

//textarea_trigger: "tinymce", //DO NOT SET THIS

//language: "en", //language pack is managed by the java-code via property; can not be set via custom-config

theme: "advanced",

//init_instance_callback: "parent.getDCFrame().IWTinyMCEEditor.instanceInit", //DO NOT SET THESE

//handle_event_callback: "parent.getDCFrame().IWTinyMCEEditor.handleEvent", //DO NOT SET THESE

plugins : "table,iwlink,iwimg,searchreplace,iespell,paste,contextmenu,zoom,insertdatetime,emotions",

theme_advanced_toolbar_location: "top",

theme_advanced_toolbar_align: "left",

theme_advanced_path_location: "bottom",

/*

theme_advanced_b***ons1 : "whitespace,styleselect,formatselect,fontselect,fontsizeselect,forecolor,|,bold,italic,underline",

theme_advanced_b***ons2 : "bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pasteword,search,|,undo,redo,|,iespell,anchor,link,unlink",

theme_advanced_b***ons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap,|,image,table,help,code",

theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3",

table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",

table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",

table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",

*/

//theme_advanced_b***ons1 : b***onRow1, //DO NOT SET THESE

//theme_advanced_b***ons2 : b***onRow2, //DO NOT SET THESE

//theme_advanced_b***ons3 : b***onRow3, //DO NOT SET THESE

//theme_advanced_styles : themeStyles, //DO NOT SET THESE

//table_styles : tableStyles, //DO NOT SET THESE

//table_cell_styles : tableCellStyles, //DO NOT SET THESE

//table_row_styles : tableRowStyles, //DO NOT SET THESE

content_css : "/iw/tinymce/config/custom_content.css",

paste_create_paragraphs : false,

paste_use_dialog : true,

/*the key/values from the 'general' options (see: /iw/tinymce/docs/reference_configuration.html)*/

//ask: //not very useful for templating

//elements: "", //DO NOT SET THIS

doc_language: "en",

directionality : "ltr",

//auto_reset_designmode : true, //not useful for templating

//auto_focus : "mce_editor_2", //not useful for teamplating??

//nowrap: false, //no wrap seems a little buggy....

b***on_tile_map: false, //untested

//auto_resize : true //experimental

//browsers : "msie,gecko" //not useful for templating

//dialog_type : "modal" //not useful for templating

/*the key/values from the 'cleanup/output' options (see: /iw/tinymce/docs/reference_configuration.html)*/

cleanup: true, //untested

//valid_elements : "" //better not to touch, use extended_valid_elements instead

extended_valid_elements: "",

invalid_elements: "",

trim_span_elements:true,

//verify_css_classes : true //not useful for templating

verify_html : true,

preformatted : false,

//encoding : "xml" //not useful/dangerous for templating

auto_cleanup_word : false,

cleanup_on_startup : false,

fix_content_duplication : true,

//inline_styles : true //experimental

convert_newlines_to_brs : false,

force_br_newlines : false,

force_p_newlines : true,

//entities : "" //better leave untouched

entity_encoding : "named",

//remove_linebreaks : false //not useful for templating

/* all other options are skipped here */

/* a dummy to end the hash without a , */

xxxx: 'yyyy'

};

//defaultConfig = {};

//loop over the hash set above

for (var prop in defaultConfig) {

//newvalue: if set in param then use this else use value from hash above

var newValue = editorConfig.getConfigItem(prop) != "" ? editorConfig.getConfigItem(prop) : defaultConfig[prop];

//set the value

tinymce.settings[prop] = newValue;

}

}

//custom: custom code end

Now you can make your custom configuration of TinyMce in the Teamsite way. Fi:

IWTinyMCECustomConfig("config-id", "directionality", "rtl");

Note that this code will give an alert to the end-user if your dc-editor.js is overwritten. Further, in IE6 (oh, not yet IE again!), if you have more then 1 textarea with different configuration-names, not all options work a required.

The above has been tested on Teamsite 6.7.1 (at solaris). Later Service Packs and versions have modified TinyMce implementations.

Good luck with it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s