29 October 2009

Modifying page editor buttons

What do you do if you wan't to add a button to the page editor default toolbar? I wanted to find out and here is what I found.

Find the page edit buttons:
Core: /sitecore/system/setttings/html editor profiles/rich text default_old/webeditButtons/ (weird that they use default_old but thats what they do - and that took me a while to figure out)

Duplicate an item there and you have a new button. In the datasection on the new item you find 3 options:

Icon - self explanatory
Tooltip - selfexplatory
Click: A call to a javascript function, f.ex.:

Striketrough: javascript:Sitecore.WebEdit.execute("strikeThrough", true, true);
Italic: javascript:Sitecore.WebEdit.execute("Italic", true, true);

Etc. All the standard javascript execute commands should work: (I found a list here from a google search: https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla)

Here is my result adding a strikeThough button:

Settings:
Click field: "javascript:Sitecore.WebEdit.execute("strikeThrough", true, true);"
Icon field: found an strike through icon in the standard sitecore image library.
Tooltip field: "Strike through"


The javascript-file with functions are found here : website/shell/applications/webEdit.js



Regarding calling sitecore functionality. There is only created 2 functions in the js file:

Insert image:
javascript:Sitecore.WebEdit.insertImage($JavascriptParameters)

Insert Link:
javascript:Sitecore.WebEdit.insertLink($JavascriptParameters)

So if you wan't to make something more that that we would have to write new functions for that.

PS: I did this on Sitecore.NET 6.0.0 (rev. 081022) (the nicam demo site)

No comments: