使用“自定义功能区"操作将内容添加到编辑器 [英] Add content to the editor using Custom Ribbon action
本文介绍了使用“自定义功能区"操作将内容添加到编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I would like to add some html content on to the page editor on click of a ribbon action(while on page edit mode).
我从一个受支持的线程中获得了这段代码,但是不确定如何实现.
I got this pieces of code from one of the supported threads, But not sure how to implement this.
function RTEActions() {
RTE.Cursor.update();
var html = 'testing';
RTE.Selection.getSelectionRange().pasteHtml(html);
}
推荐答案
这是我的测试样本供您参考.
自定义功能区:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="WikiExtensions.Ribbon.EditingTools"
Location="CommandUI.Ribbon"
Sequence="20">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.EditingTools.CPEditTab.Paragraph.Controls._children">
<Button Id="WikiExtensions.Ribbon.InsertCodeBlock"
Alt="Notify hello"
Sequence="5"
Command="WikiExtensions.Command.InsertCodeBlock"
Image16by16="/_layouts/images/NoteBoard_16x16.png"
Image32by32="/_layouts/images/NoteBoard_32x32.png"
Description="Uses the notification area to display a message."
LabelText="Notify hello"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="WikiExtensions.Command.InsertCodeBlock"
CommandAction="javascript:function RTEActions() {
RTE.Cursor.update();
alert('1');
var html = 'testing';
RTE.Selection.getSelectionRange().pasteHtml(html);
}
RTEActions();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
结果:
这篇关于使用“自定义功能区"操作将内容添加到编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文