November Happy Hour will be moved to Thursday December 5th.

Add, modify or override InitOptions for TinyMCE

Vote:
 

What's an easy way to affect these options for editor instances for a property in Edit mode?

public static IDictionary<string, object> CreateDefaultInitOptions()
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary["mode"] = "exact";
dictionary["dialog_type"] = "window";
dictionary["convert_urls"] = false;
dictionary["entities"] = "160,nbsp";
dictionary["theme_advanced_blockformats"] = "p,h1,h2,h3,h4,h5,h6";
dictionary["theme_advanced_layout_manager"] = "RowLayout";
dictionary["theme_advanced_container_editorcontainer"] = "mceEditor";
dictionary["theme_advanced_container_statusBar"] = "mceElementpath";
dictionary["theme_advanced_containers_default_align"] = "left";
dictionary["theme_advanced_resizing"] = true;
dictionary["theme_advanced_resizing_use_cookie"] = false;
dictionary["theme_advanced_path"] = true;
dictionary["theme_advanced_statusbar_location"] = "bottom";
dictionary["theme_advanced_containers"] = "editorcontainer,statusBar";
dictionary["language"] = false;
dictionary["theme"] = "advanced";
dictionary["skin"] = "default";
dictionary["content_css"] = string.Empty;
return dictionary;
}

Been reflecting but can't seem to find the right spot when I don't have the control-markup at hand. We wan't to change skin and add valid_elements and some other options.

#39513
May 19, 2010 9:55
Vote:
 

The way this is supposed to be done is using a plugin with a plug-in attribute with these settings. Here you can find some information http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-6-RC1/Adding-a-TinyMCE-Plug-in/ Note the EditorInitConfigurationOptions attribute property. 

That means you set up a property on the plugin attribute with a string (JSON notation) with all the editor properties you want to be set. with some properties there is some functionality for merging the result (like extended_valid_elements) but most should just replace. You might get some conflict warnings and such too I think. 

And if you want the settings for some properties and for some not you just use the property settings functionality to enable your plugin on some properties.

 

#39548
Edited, May 20, 2010 12:25
Vote:
 

Thanks! Seems to work great.

I put a working plugin code example on my blog:
http://krompaco.nu/alter-default-initoptions-for-tinymce-in-episerver-6/

#39553
May 20, 2010 16:19
Vote:
 

JSON-deserializing fails when you try to add more advanced config such as:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/class_filter

Invalid JSON primitive: function. System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()

Have tried multiptle ways of escaping the function without any luck...

#39644
May 26, 2010 17:23
Vote:
 

Yes I can see that that might be a problem.

The thing you might be able to do is inserting the function itself elsewhere like

var myFilterFunction = function()... (for test just create it in some system.js or something)

and then in the JSON just enter myFilterFunction. Then you would not need all that code in the JSON string.

But anyhow this might be considred a bug so opening a support ticket to episerver support might be a good thing too.

#39646
May 26, 2010 17:36
Vote:
 

You should be able to add the class_filter setting from your plugin doing something like this:

(function() {
    tinymce.create('tinymce.plugins.classFilter', {

        init: function(ed, url) {
            ed.settings.class_filter = function(cls, rule) {
                if (cls !== 'test') { return true; }
                else { return false; }
            };
        }
        
    });

    tinymce.PluginManager.add('classFilter', tinymce.plugins.classFilter);
})();

and then registering it as AlwaysEnabled:

[TinyMCEPluginNonVisual(AlwaysEnabled = true, PlugInName = "classFilter")]
public class ClassFilter
{
}
 
#49524
Mar 22, 2011 13:54
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.