1 /** 2 * foreColor command. 3 * @author yiminghe@gmail.com 4 */ 5 KISSY.add("editor/plugin/foreColor/cmd", function (S, cmd) { 6 7 var COLOR_STYLES = { 8 element:'span', 9 styles:{ 'color':'#(color)' }, 10 overrides:[ 11 { element:'font', attributes:{ 'color':null } } 12 ], 13 childRule:function (el) { 14 // <span style='color:red'><a href='g.cn'>abcdefg</a></span> 15 // 不起作用 16 return !(el.nodeName() == "a" || el.all("a").length); 17 } 18 }; 19 20 return { 21 init:function (editor) { 22 if (!editor.hasCommand("foreColor")) { 23 editor.addCommand("foreColor", { 24 exec:function (editor, c) { 25 editor.execCommand("save"); 26 cmd.applyColor(editor, c, COLOR_STYLES); 27 editor.execCommand("save"); 28 } 29 }); 30 } 31 } 32 }; 33 34 }, { 35 requires:['../color/cmd'] 36 });