<?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xp:this.resources> <xp:script clientSide="false" type="text/javascript"> <xp:this.contents> <![CDATA[ // SSJS to calculate path to the current application... function getDatabasePath(){ var value = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, "/"); value = facesContext.getExternalContext().encodeResourceURL(value); if(!value.endsWith("/")){ value += "/"; } return value; } ]]> </xp:this.contents> </xp:script> <xp:script clientSide="true" type="text/javascript"> <xp:this.contents> <![CDATA[ // intercept nsf resource requests to stop ?t=timestamp being appended by ckeditor // see: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Editor_Core_URLs_Manipulation window.CKEDITOR_GETURL = function(resourceRequest){ if(null != resourceRequest && resourceRequest.indexOf(".nsf") > -1){ return resourceRequest; } } XSP.addOnLoad(function(){ // add the custom extension... CKEDITOR.plugins.add("myExtension", { init: function(editor){ editor.addCommand("MyCommandHandler", { exec: function(editor) { myCommandHandler(editor); } }); editor.ui.addButton("MyCommand", { label: "Run My Command", command: "MyCommandHandler", // resource is within the .nsf... icon: " ${javascript:getDatabasePath()} ".trim() + "icon.png" }); } }); // define the custom command handler... myCommandHandler = function(editor){ if(null != editor){ editor.insertHtml( "<br><p>CKEditor: Invoked myCommandHandler!</p><br>" ); } } }); ]]> </xp:this.contents> </xp:script> </xp:this.resources> <xp:inputRichText id="inputRichText1"> <xp:this.dojoAttributes> <xp:dojoAttribute name="extraPlugins" value="myExtension"> </xp:dojoAttribute> <xp:dojoAttribute name="toolbar"> <xp:this.value> <![CDATA[#{javascript: var customToolbar = "[['Font','FontSize'], \n" + "['Bold','Italic','Underline','Strike'], \n" + "['MyCommand']]"; return customToolbar; }]]> </xp:this.value> </xp:dojoAttribute> </xp:this.dojoAttributes> </xp:inputRichText> </xp:view>