Kendo UI 编辑器 - 更改字体颜色选择器和背景颜色选择器的默认颜色
Kendo UI Editor - Change default colors of font color picker and background color picker
我正在使用 Kendo UI 编辑器,我想选择在字体和背景调色板中显示的颜色。
或者另一种选择是让用户从自定义颜色选择器中进行选择。
我在论坛上找了例子,但是都是用的老版本的Kendo2012,最新的2016 R3不知道这样的定义:kendo.ui.editor.ColorPicker.fn.options.colors
说是undefined:
Uncaught TypeError: Cannot read property 'fn' of undefined
有办法吗?
我查看了论坛并看到了这个答案,但这不起作用。
kendo.ui.editor.ColorPicker.fn.options.colors = ["c3c3c3", "b97a57", "ffaec9", "ffc90e", "efe4b0", "b5e61d", "99d9ea", "7092be", "c8bfe7"];
更新:修改用户问题
后,解决方案适用于最新版本的kendoUI
我已经在这个博客上讨论了使用最新版本 kendo 的解决方案。请单击下面的 link 以导航至解决方案。
Kendo UI Editor - Change default colors of font color picker and background color picker
简而言之link中的灵魂是这段代码:
<script>
$("#editor").kendoEditor({
tools: [{
name: "backColor",
palette: ["#f0d0c9", "#e2a293", "#d4735e", "#65281a"]
},
{
name: "foreColor",
palette: ["red", "green", "#d47eee", "#65281a"]
}
}]
});
</script>
旧:此解决方案适用于 kendo 2012 版本。
这是工作现场演示 link - Editor color picker
HTML
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.3.1315/js/kendo.all.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<textarea id="textarea" rows="10" cols="30" style="width:100%;height:400px">
<p><img src="http://www.kendoui.com/Image/kendo-logo.png" alt="Editor for ASP.NET MVC logo" style="display:block;margin-left:auto;margin-right:auto;" /></p>
<p>
Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists,
and image handling. The widget <strong>outputs identical HTML</strong> across all major browsers, follows
accessibility standards and provides API for content manipulation.
</p>
<p>Features include:</p>
<ul>
<li>Text formatting & alignment</li>
<li>Bulleted and numbered lists</li>
<li>Hyperlink and image dialogs</li>
<li>Cross-browser support</li>
<li>Identical HTML output across browsers</li>
<li>Gracefully degrades to a <code>textarea</code> when JavaScript is turned off</li>
</ul>
<p>
Read <a href="http://docs.kendoui.com">more details</a> or send us your
<a href="http://www.kendoui.com/forums.aspx">feedback</a>!
</p>
</textarea>
</body>
</html>
JavaScript 文件
kendo.ui.editor.ColorPicker.fn.options.colors = ["c3c3c3"];
$("textarea#editor").kendoEditor();
$('textarea').kendoEditor({
encoded: false,
tools: [
"bold",
"italic",
"underline",
"strikethrough",
"fontName",
"fontSize",
"foreColor",
"backColor",
"justifyLeft",
"justifyCenter",
"justifyRight",
"justifyFull",
"insertUnorderedList",
"insertOrderedList",
"indent",
"outdent",
"formatBlock",
"createLink",
"unlink",
"insertImage",
"viewHtml"
]
});
我正在使用 Kendo UI 编辑器,我想选择在字体和背景调色板中显示的颜色。 或者另一种选择是让用户从自定义颜色选择器中进行选择。
我在论坛上找了例子,但是都是用的老版本的Kendo2012,最新的2016 R3不知道这样的定义:kendo.ui.editor.ColorPicker.fn.options.colors
说是undefined:
Uncaught TypeError: Cannot read property 'fn' of undefined
有办法吗? 我查看了论坛并看到了这个答案,但这不起作用。
kendo.ui.editor.ColorPicker.fn.options.colors = ["c3c3c3", "b97a57", "ffaec9", "ffc90e", "efe4b0", "b5e61d", "99d9ea", "7092be", "c8bfe7"];
更新:修改用户问题
后,解决方案适用于最新版本的kendoUI
我已经在这个博客上讨论了使用最新版本 kendo 的解决方案。请单击下面的 link 以导航至解决方案。
Kendo UI Editor - Change default colors of font color picker and background color picker
简而言之link中的灵魂是这段代码:
<script>
$("#editor").kendoEditor({
tools: [{
name: "backColor",
palette: ["#f0d0c9", "#e2a293", "#d4735e", "#65281a"]
},
{
name: "foreColor",
palette: ["red", "green", "#d47eee", "#65281a"]
}
}]
});
</script>
旧:此解决方案适用于 kendo 2012 版本。
这是工作现场演示 link - Editor color picker
HTML
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.3.1315/js/kendo.all.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<textarea id="textarea" rows="10" cols="30" style="width:100%;height:400px">
<p><img src="http://www.kendoui.com/Image/kendo-logo.png" alt="Editor for ASP.NET MVC logo" style="display:block;margin-left:auto;margin-right:auto;" /></p>
<p>
Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists,
and image handling. The widget <strong>outputs identical HTML</strong> across all major browsers, follows
accessibility standards and provides API for content manipulation.
</p>
<p>Features include:</p>
<ul>
<li>Text formatting & alignment</li>
<li>Bulleted and numbered lists</li>
<li>Hyperlink and image dialogs</li>
<li>Cross-browser support</li>
<li>Identical HTML output across browsers</li>
<li>Gracefully degrades to a <code>textarea</code> when JavaScript is turned off</li>
</ul>
<p>
Read <a href="http://docs.kendoui.com">more details</a> or send us your
<a href="http://www.kendoui.com/forums.aspx">feedback</a>!
</p>
</textarea>
</body>
</html>
JavaScript 文件
kendo.ui.editor.ColorPicker.fn.options.colors = ["c3c3c3"];
$("textarea#editor").kendoEditor();
$('textarea').kendoEditor({
encoded: false,
tools: [
"bold",
"italic",
"underline",
"strikethrough",
"fontName",
"fontSize",
"foreColor",
"backColor",
"justifyLeft",
"justifyCenter",
"justifyRight",
"justifyFull",
"insertUnorderedList",
"insertOrderedList",
"indent",
"outdent",
"formatBlock",
"createLink",
"unlink",
"insertImage",
"viewHtml"
]
});