Confluence Docs 3.0 : Editor Plugins This page last changed on Nov 03, 2008 by smaddox.
| Editor plugin modules are available in Confluence 2.5 and later versions
Editor plugin modules allow you to implement Wysiwyg editors for editing Confluence pages. Currently, Confluence only supports the use of one wysiwg editor during editing even if there are multiple editor plugins enabled. It is not guaranteed that any one editor will be used over another, hence it is recommended that only one editor is enabled at a time. For more information about plugins in general, read Confluence Plugin Guide. To learn how to install and configure plugins (including macros), read Installing and Configuring Plugins Manually. For an introduction to writing your own plugins, read Writing Confluence Plugins ## Editor Plugin Module The following is a snippet of `atlassian-plugin.xml` from the TinyMCE Editor:
    <atlassian-plugin key="com.atlassian.confluence.extra.tinymceplugin" name="TinyMCE Editor Plugin">
        <plugin-info>
            <description>TinyMCE Editor Plugin for Confluence</description>
            <version>${project.version}</version>
            <vendor name="Atlassian" url="http://www.atlassian.com"/>
        </plugin-info>
        ...
        <editor name="tinymceeditor" class="com.atlassian.confluence.extra.tinymceplugin.TinyMceEditor" key="tinymceeditor">
            <description>TinyMCE Editor</description>
        </editor>
        ...
    </atlassian-plugin>
The class attribute defines the Java class for which the editor will interact with Confluence. This class must implement `com.atlassian.confluence.plugin.editor`. ## Editor Interface All editors must implement the following interface:
    package com.atlassian.confluence.plugin.editor;

    /**
     * This interface allows Wysiwyg editors to be plugged in to Confluence.
     */
    public interface Editor
    {
        /**
         * Returns javascript functions to allow thw wiki-textarea.vm to interface with the editor.
         *
         * The Javascript returned must define the functions:
         *
         * onShowEditor() -- this is called just after the DIV containing the editor is made visible. It is a hook where you
         *      can place any special code needed at this point.
         * onHideEditor() -- this is called just before the DIV containing the editor is hidden. It is a hook where you
         *      can place any special code needed at this point.
         * setEditorValue(newValue) -- put the text in newValue into the editor. This is called when the editor needs new
         *      content -- it is *not* called to set the initial content. That should be done either by providing the
         *      editor with the content as part of the initial HTML, or by calling javascript from editorOnLoad().
         * allowModeChange() -- return true if the editor is in a state where changes from rich text to markup and vice versa are allowed.
         * getEditorHTML() -- return the current HTML contents of the editor. This *must* return a JavaScript string,
         *      not a JavaObject wrapping a java.lang.String!
         * editorOnLoad() -- called in the page's onLoad handler, place any initialization needed at this point here.
         * editorHasContentChanged() -- return true if the contents of the editor has been modified by the user since
         *      the last time editorResetContentChanged().
         * editorResetContentChanged() -- called to reset the contents change indicator
         *
         * These methods won't be called when the editor is not visible.
         *
         * The javascript must be surrounded by a <script> element.
         * @return a String containing a velocity template
         */
        String getJavascriptTemplate();

        /**
         * Returns the div contents to display the editor itself.
         * @return a String containing a velocity template
         */
        String getDivContentsTemplate();

        /**
         * Return true if the user agent string indicates a browser which is supported by this editor
         * @param userAgent
         * @return true if this editor is supported
         */
        boolean supportedUserAgent(String userAgent);

        /**
         * Perform any necessary escaping of the HTML rendered by Confluence. The AbstractPreviewPageAction.getWysiwygContent()
         *      method uses this method to escape the rendered HTML.
         */
        String escapeHtml(String html);

        /**
         * Return a string of CSS which will be appended to the standard stylesheet if it is requested from /styles/wysiwyg-action
         *
         * Note that it is up to the editor implementation to retrieve this stylesheet and apply it to the editor contents --
         * the page containing the editor is styled with the normal stylesheet.
         */
        String getEditorSpecificCss();
    }
For an example, you can view the source for the TinyMCE Plugin.

Document generated by Confluence on Nov 05, 2009 23:34