我想使用KendoUI编辑器基本上只允许用户将文本格式化为段落。可能允许加粗和下划线。
我正在努力解决两件事:
谢谢!
答案 0 :(得分:8)
对于粘贴唯一的文本,您可以定义一个粘贴处理程序,删除除文本之外的所有内容。这很简单:
$("#editor").kendoEditor({
paste: function (ev) {
ev.html = $(ev.html).text();
}
});
paste
处理程序接收一个事件,该事件在html
中被解析的文本。我们可以使用jQuery仅使用$(ev.html).text()
要删除快捷方式,并且我可以使用最新的Kendo UI版本进行测试,如果只定义所需的工具,则只有那些快捷方式处于活动状态。所以,如果你说的话:
$("#editor").kendoEditor({
tools: [
"italic"
],
paste: function (ev) {
ev.html = $(ev.html).text();
}
});
只有italic
个快捷方式<ctrl>+i
可用。如果您将tools
数组保留为空,则表示您没有任何数据。
答案 1 :(得分:1)
现在可以使用for /L %%j in (1,1,%n%) do (
:: subproject dir, relative to the sandobox dir
call set SUBPROJECT_DIR=%%ADRESS_ARRAY[%%j]%%
:: sandbox name
call set SANDBOX_NAME=C:\%SANDBOX_FOLDER_NAME%\%%SUBPROJECT_DIR%%\project.pj
:: name of sandbox folder
call set SANDBOX_DIR=C:\%SANDBOX_FOLDER_NAME%\%%SUBPROJECT_DIR%%
:: name of presentation to be copied
call set PRESENTATION_NAME=%%NAME_ARRAY[%%j]%%
:: check out file
call si co --sandbox=%%SANDBOX_NAME%% --changePackageId=:none --hostname=%SERVERNAME% --port=%PORTNAME% %%SANDBOX_DIR%%\%%PRESENTATION_NAME%%
:: Copying new files (Option /xo of robocopy)
call robocopy x: %%SANDBOX_DIR%% %%PRESENTATION_NAME%%
:: check in modified file
call si ci --sandbox=%%SANDBOX_NAME%% --changePackageId=:none --hostname=%SERVERNAME% --port=%PORTNAME% --description="Automated weekly update." %%SANDBOX_DIR%%\%%PRESENTATION_NAME%%
)
选项轻松实现此目的。
见这里:http://docs.telerik.com/kendo-ui/controls/editors/editor/pasting
答案 2 :(得分:0)
Kendo MVC也为此目的进行了扩展。用法示例:
.PasteCleanup(x => x.KeepNewLines(false))
false
在这种情况下意味着您要清除除换行以外的所有内容。
答案 3 :(得分:0)
对我来说这是完整的解决方案
pasteCleanup: {
custom: function (html)
{
html = html.replace(/<\s*br\/*>/gi, '');
html = html.replace(/<\s*a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 (Link - $1) ");
html = html.replace(/<\s*\/*.+?>/ig, '');
html = html.replace(/ {2,}/gi, '');
html = html.replace(/\n+\s*/gi, '');
html = html.replace(" ", '');
html = html.replace(/<.*?>/g, '');
return html;
}
}