All blog posts, code samples and downloads licensed under Apache License 2.0.
Close

Triggering a custom save button from CKEditor save toolbar button

Oliver Busse on 08/24/2014 17:01:33 CEDT, filed under XSP 

Create a custom control with the code below and place it onto your XPage where you have the CKEditor (richtext control). Adapt the button's id to your own save button's id.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
	<xp:scriptBlock id="scriptBlock1" type="text/javascript">
		<xp:this.value><![CDATA[dojo.addOnLoad( function() {
	CKEDITOR.plugins.registered['save'] = {
		init : function(editor) {
			var command = editor.addCommand('save', {
				modes : {
					wysiwyg : 1,
					source : 1
				},
				exec : function(editor) { 
					dojo.byId("#{id:btnSave}").click();
				}
			});
			editor.ui.addButton('Save', {
				label : 'Save',
				command : 'save'
			});
		}
	}
});]]></xp:this.value>
	</xp:scriptBlock>
</xp:view>

Tagged with dojo javascript xsp xpages