01.code/LanweiUI/UEditor/_src/plugins/font.js
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
///import core
///import plugins\removeformat.js
///commands 字体颜色,背景色,字号,字体,下划线,删除线
///commandsName ForeColor,BackColor,FontSize,FontFamily,Underline,StrikeThrough
///commandsTitle 字体颜色,背景色,字号,字体,下划线,删除线
/**
* @description 字体
* @name baidu.editor.execCommand
* @param {String} cmdName 执行的功能名称
* @param {String} value 传入的值
*/
UE.plugins['font'] = function() {
var me = this,
fonts = {
'forecolor':'color',
'backcolor':'background-color',
'fontsize':'font-size',
'fontfamily':'font-family',
'underline':'text-decoration',
'strikethrough':'text-decoration'
};
me.setOpt({
'fontfamily':[
['宋体',['宋体', 'SimSun']],
['楷体',['楷体', '楷体_GB2312', 'SimKai']],
['黑体',['黑体', 'SimHei']],
['隶书',['隶书', 'SimLi']],
['andale mono',['andale mono']],
['arial',['arial', 'helvetica', 'sans-serif']],
['arial black',['arial black', 'avant garde']],
['comic sans ms',['comic sans ms']],
['impact',['impact', 'chicago']],
['times new roman',['times new roman']]
],
'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
});
for ( var p in fonts ) {
(function( cmd, style ) {
UE.commands[cmd] = {
execCommand : function( cmdName, value ) {
value = value || (this.queryCommandState(cmdName) ? 'none' : cmdName == 'underline' ? 'underline' : 'line-through');
var me = this,
range = this.selection.getRange(),
text;
if ( value == 'default' ) {
if(range.collapsed){
text = me.document.createTextNode('font');
range.insertNode(text).select()
}
me.execCommand( 'removeFormat', 'span,a', style);
if(text){
range.setStartBefore(text).setCursor();
domUtils.remove(text)
}
后面还有 117 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
