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

Tiny MCE default buttons

Vote:
 

Hi all,

I have to specify the list of available buttons by default, using code. (A similar result can be obtained by performing a sequence of actions in the admin panel: Admin\Page type\Page with XHTML string field\select field with XHTML string type\Custom settings\Use custom settings\{add/delete some buttons}). For example to add a "HTML" button and remove the "Undo" button.

Thanks for your time

#74682
Sep 04, 2013 21:36
Vote:
 

Don't have any exact code at the moment, but for some inspiration you could create an EditorDescriptor based on the class EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.XhtmlStringEditorDescriptor found in EPiServer.Cms.Shell.UI.dll (usually found in the Modules-path among your VPP) for some inspiration.

You should be able to populate the TinyMCESettings object with buttons or other settings programmatically.

This is the default behaviour of XhtmlStringEditorDescriptor:

    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
    {
      base.ModifyMetadata(metadata, attributes);
      TinyMCESettings settings = (TinyMCESettings) ((PropertyData) metadata.Model).GetSetting(typeof (TinyMCESettings));
      ExtendedMetadata mostContentMetadata = ExtendedMetadataExtensions.FindTopMostContentMetadata(metadata);
      IContent content = mostContentMetadata != null ? mostContentMetadata.Model as IContent : (IContent) null;
      TinyMCEInitOptions tinyMceInitOptions = new TinyMCEInitOptions(TinyMCEInitOptions.InitType.EditMode, settings, content);
      if (metadata.IsReadOnly)
      {
        tinyMceInitOptions.InitOptions["readonly"] = (object) true;
        tinyMceInitOptions.InitOptions["body_class"] = (object) "mceReadOnly";
      }
      metadata.EditorConfiguration.Add("width", tinyMceInitOptions.InitOptions["width"]);
      metadata.EditorConfiguration.Add("height", tinyMceInitOptions.InitOptions["height"]);
      metadata.EditorConfiguration.Add("settings", (object) tinyMceInitOptions.InitOptions);
    }

    

#74685
Sep 04, 2013 22:48
Vote:
 

While TinyMCE allows setting default buttons in code this way, the official response from the dev team (as of April 2013, anyway) is that EPiServer CMS 7 does not fully support this functionality. You can find some example code in this thread: http://world.episerver.com/Forum/Developer-forum/EPiServer-7-Preview/Thread-Container/2012/8/Customizing-the-TinyMCE-editor/.

Instead, you might consider setting default available buttons through the property settings in admin mode, as described in Mark Everard's blog post

More info on configuring TinyMCE (such as adding your own TinyMCE editor buttons) in EPiServer CMS 7 documentation

 

 

#74686
Sep 04, 2013 22:55
Vote:
 

What they discourage from in that post is to have a TinyMCE plugin that tampers with the TinyMCE settings.

My interpretation of the question was that these settings was only to be set on specific properties with as little manual settings as possible.
Hence my suggestion about EditorDescriptor which returns the the tinymce settings as if you would have created some settings as an administrator.

We had that in PageTypeBuilder though PTB added it directly to the database as a setting instead of adding it while loading the TinyMCE property.

#74687
Sep 04, 2013 23:10
Vote:
 

Dear Alf Nilsson,

I decided to try to implement the proposed solution and episerver
did not find a module by assembly EPiServer.Cms.Shell.UI.ObjectEditing. I use episerver 7 patch 3 MVC project. Can you tell me what to put for solutions to solve this problem with dll. I would appreciate your help.

 

#74693
Edited, Sep 05, 2013 8:25
Vote:
 

Hi,

This .dll file is not found in the bin-foder. It is a part of the UI and can be located inside the ModulesRepository in your VPP. In my case it is located in VPP\ModulesRepository\Shell.2.0.86\lib\EPiServer.Shell.UI.dll but it depends on which version of the EPiServer 7 user interface you have installed.

I recommend that you don't refer it in your .csproj, instead open it with your favourite decompiling tool such as Reflector, DotPeek, ILSpy or similar and look at the code for some inspiration how you can instantiate your hard coded TinyMCESettings.

Otherwise the concept with EditorDescriptors and UIHints are the same as always.

#74705
Sep 05, 2013 9:52
Vote:
 

Hi,

I found a couple of articles with a description of what I want. But I did not find the interface IUpdateGlobalPropertySettings.

 

Articles:

http://joelabrahamsson.com/page-type-builder-2-preview-1-released/

http://krompaco.nu/2012/09/page-type-builder-and-tinymce-global-settings/

 

How add global settings to the Tiny MCE in EPiServer 7?

 

Best regards,

Pavel

#75009
Sep 14, 2013 18:21
Vote:
 

Those articles concern PageTypeBuilder which is a tool for episerver 5 and 6 created by Joel Abrahamsson.

PageTypeBuilder does not exist in EPiServer since similar functionality is built in to EPiServer 7. Though some functions such as creating Property Settings is not included.

#75010
Sep 14, 2013 18:25
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.