如何将自定义工具添加到kendo editor toolbar
我想添加拼写检查,媒体管理和剪切,复制,粘贴,从word,复制和一些更多的工具。
我正在MVC应用程序中使用Kendo编辑器.
发布于 2016-03-21 11:53:07
我使用一个自定义工具在应用程序中添加链接引用,方法是从已有的链接引用中搜索链接引用。
在这里,你是从我的源代码中截取的代码
@(Html.Kendo()
.Editor()
.Name("Content")
.Tools(tools => tools
.Clear()
.Bold().Italic().Underline().Strikethrough()
.JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
.InsertUnorderedList().InsertOrderedList()
.Outdent().Indent()
.CreateLink().Unlink()
.InsertImage()
.SubScript()
.SuperScript()
.TableEditing()
.ViewHtml()
.Formatting()
.CleanFormatting()
.FontName()
.FontSize()
.FontColor()
.BackColor()
.CustomButton(cb => cb
.Name("Add link to article")
.ToolTip("Add link to article")
.Exec("execFunction")
))
.Encode(false)
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/Uploads/Images/{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
.Thumbnail("Thumbnail", "ImageBrowser")))
这些是我对编辑器的配置。我想你只对.CustomButton感兴趣(cb => cb.Name /这是必要的/ cb.Exec /还有蜜饯/。在Exec中,传递在单击按钮时应该执行的JS函数的名称。您可以将JS连接到控制器,而不是使用ajax连接。我会和你分享我的。
function execFunction(e) {
$.get('/Articles/BuildLinkView', null, function(data) {
$('#addLinkHolder').html(data);
$('#addLinkHolder').css('display', 'table-cell');
});
}
当你把它绑定到控制器上时,你可以用它做任何你想做的事。
我希望这能解决你的问题。如果没有,请提供更多信息。
https://stackoverflow.com/questions/31873943
复制相似问题