[英]How can I add new button to highlight text in this useful editor
This is an example that I found http://jsbin.com/awituc/25/edit 这是我找到的示例http://jsbin.com/awituc/25/edit
the question is how to create a new button to add specific color maybe red to the selected text ? 问题是如何创建一个新按钮以向选定的文本添加特定的颜色(可能是红色)?
Solution: http://jsbin.com/awituc/230/edit 解决方案: http : //jsbin.com/awituc/230/edit
Added code to plugin: 向插件添加了代码:
Settings: 设定:
colors: [{ key: "Red", value: "#ff0000" },
{ key: "Green", value: "00ff00" },
{ key: "Blue", value: "#0000ff" }]
can be overridden when initiating plugin: 可以在启动插件时覆盖:
$("textarea").myTextEditor({ colors: [{ key: "yellow", value: "#ffff00" }] });
Dropdown: 落下:
var selectColor = $("<select/>", {
data: {
commandName: "ForeColor"
},
change: execCommand
}).appendTo(buttonPane);
Code that sets color: 设置颜色的代码:
$.each(settings.colors, function (i, v) {
$("<option/>", {
value: v.value,
text: v.key,
style: "color:" + v.value
}).appendTo(selectColor);
});
execCommand reference: execCommand参考:
http://www.developphp.com/view_lesson.php?v=879 http://www.developphp.com/view_lesson.php?v=879
jQuery plugins tutorial: jQuery插件教程:
http://bit.ly/14dXuXL http://bit.ly/14dXuXL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.