you could add a custom action, maybe a checkbox.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="MyRibbons.RibbonScript"
ScriptSrc="~SiteCollection/_layouts/MyRibbonsScript.js"
Location="ScriptLink">
</CustomAction>
<CustomAction Id="MyRibbons.LinkBehavior" Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Link.Link.Behavior.Controls._children">
<CheckBox Command="MyRibbons.CheckBoxCommand" QueryCommand="MyRibbons.CheckBoxQueryCommand"
LabelText="Add a class"
Id="MyRibbons.AddClass"
Sequence="30"
Alt="Add class"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="MyRibbons.CheckBoxCommand"
CommandAction="javascript:handleCommand();" />
<CommandUIHandler Command="MyRibbons.CheckBoxQueryCommand"
CommandAction="javascript:handleCommand();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
In the executed javascript you can do following:
handleCommand: function (commandId, properties, sequence) {
switch (commandId) {
case 'MyRibbons.CheckBoxCommand':
RTE.SnapshotManager.takeSnapshot(); // make a snapshot for the RTE history
var range = RTE.Cursor.get_range(); // get the current selected range from RTE
var $element = $(range.$3_0); // select the element
if (properties.On) {
$element.addClass('customclass'); // manipulate the element
}
range.deleteContent(); // delete the range content
range.insertBefore($element[i]); // insert your new element
RTE.Cursor.update(); // update RTE
break;
case 'MyRibbons.CheckBoxQueryCommand':
if (!this.checkBoxDefaultSet) {
properties.On = true;
this.checkBoxDefaultSet = true;
}
break;
}
},
checkBoxDefaultSet: false,
You're right, it's very bad documented by M$.
I got it from here:
http://www.wictorwilen.se/post/sharepoint-2010-ribbon-controls-part-6-the-checkbox-control.aspx and here
http://blog.andersdissing.com/2011/11/playing-with-sharepoint-rich-text.html
Good luck :)