Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lachlann 344 posts 626 karma points
    Oct 09, 2009 @ 17:46
    Lachlann
    0

    Custom Tiny MCE 3 plugin

    Hi there.

    I am looking into writing my own plugin for tinyMCE 3 (for use within umbraco 4). I have read the  wiki but found it a little confusing.

    As a first step i am looking to insert a function into the tinyMCE toolbar which does somethign simple like alert("button clicked"); Could anyone point me in right direction, im just looking for the steps i need to go through to A: add the button in to the toolbar B:link this into a javascript function which calls an alert.

    Thanks

  • Elena 8 posts 29 karma points
    Oct 13, 2009 @ 23:04
    Elena
    0

    try something like this - just put it in the server side event code

       private void JavaAlert(string Message){

        Message = string.Format("<script>alert('{0}');</script>", Message);

        System.Web.HttpContext.Current.Response.Write(Message);

    }

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 13, 2009 @ 23:55
    Aaron Powell
    0

    I found that writing a tinyMCE plugin was a pain in the ass, but here's some pointers:

    • you need to define your plugin in the /config/tinyMCEConfig.config file. This is where you tell it what icon you want, what's the alias and what's the "command" (the command is the folder name of your plugin). These are in the <command /> blocks, just copy an existing one and change it for your needs
    • Put your plugin into /umbraco_client/tinymce3/plugins/<command name>
    • All your JavaScript logic needs to be in editor_plugin.js (well, at least the start point, it can call out to other JS files, but make sure you manually import them using some kind of loader so they are scoped in the tinyMCE iframe!)
    • You've got to change the Data Type in Umbraco for TinyMCE to allow your button to show on the toolbar
    • You can define custom parameters/ global variables to be passed into plugins using the <customConfig /> node in the tinyMCE config file

    Hopefully that gives you a starting point. For how to setup the JavaScript plugin file I suggest you refer to the tinyMCE docs, they'll be more useful that I can put into a post :)

Please Sign in or register to post replies

Write your reply to:

Draft