Skip to content

Commit

Permalink
增加社交账号插件;js引入增加版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
hbh112233abc committed Aug 30, 2020
1 parent 336f921 commit 3204b8a
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 13 deletions.
13 changes: 13 additions & 0 deletions assets/ueditor.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/ueditor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>完整demo</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="ueditor.all.js"> </script>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
Expand Down Expand Up @@ -172,4 +172,4 @@ <h1>完整demo</h1>
}
</script>
</body>
</html>
</html>
91 changes: 91 additions & 0 deletions assets/ueditor/ueditor.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -28804,6 +28804,38 @@ UE.ui = baidu.editor.ui = {};
return ui;
};

editorui.social = function (editor,list,title) {
title = editor.options.labelMap['social'] || editor.getLang("labelMap.social") || '';
list = list || editor.options['social'] || [];
if (!list.length) return;
var ui = new editorui.Combox({
editor: editor,
items: list,
title: title,
initValue: title,
onselect: function (t, index) {
editor.execCommand('social', this.items[index]);
},
onbuttonclick: function () {
this.showPopup();
}
});
editorui.buttons['social'] = ui;
editor.addListener('selectionchange', function (type, causeByUi, uiReady) {
if (!uiReady) {
var state = editor.queryCommandState('social');
if (state == -1) {
ui.setDisabled(true);
} else {
ui.setDisabled(false);
ui.setValue(editor.queryCommandValue('social'));
}
}

});
return ui;
};

editorui.paragraph = function (editor, list, title) {
title = editor.options.labelMap['paragraph'] || editor.getLang("labelMap.paragraph") || '';
list = editor.options['paragraph'] || [];
Expand Down Expand Up @@ -30098,6 +30130,65 @@ UE.registerUI('autosave', function(editor) {

});

/**
* 社交标签
* 用于插入社交相关账号信息
*/
UE.plugins['social'] = function(){ 
var me=this; 
me.setOpt('social',[
{label:'昵称',value:'hbh',type:'text'},
{label:'微信',value:'huangbinghe',type:'text'},
{label:'手机号',value:'1875920xx63',type:'tel'},
{label:'邮箱',value:'hbh112233abc@163.com',type:'mail'},
{label:'二维码',value:'https://p.ssl.qhimg.com/d/inn/0444533a/Snip20160525_6.png',type:'img'},
]);
//注册鼠标和键盘事件 
me.addListener('mousedown',function(){}); 
me.addListener('keydown',function(type,evt){}); 
me.addListener('mouseup',function(){}); 

me.commands['social'] = {
//查询当前命令状态 
queryCommandState: function(cmdName){
// console.log('query cmd state:',cmdName);
},
//命令执行主体 
execCommand: function(cmdName,item){
// console.log(item);
var html = '<p>';
switch(item.type){
case 'text':
html += '<span style="'+(item.style || '')+'">'+item.value+'</span>';
break;
case 'url':
html += '<a href="'+item.value+'" style="'+(item.style || '')+'">'+item.label+'</a>';
break;
case 'tel':
html += '<a href="tel:'+item.value+'" style="'+(item.style || '')+'">'+item.value+'</a>';
break;
case 'sms':
html += '<a href="sms:' + item.value + '" style="' + (item.style || '') + '">' + item.value + '</a>';
break;
case 'mail':
html += '<a href="mailto:' + item.value + '" style="' + (item.style || '') + '">' + item.value + '</a>';
break;
case 'img':
html += '<img src="' + item.value + '" style="' + (item.style || '') + '">';
break;
default:
html += item.value;
break;
}
html += '</p>';
me.execCommand('insertHtml',html);
},
//获取命令执行结果 
queryCommandValue: function(cmdName){
return me.options.labelMap['social'] || me.getLang("labelMap.social") || '社交账号';
}, 
}
}; 


})();
10 changes: 6 additions & 4 deletions assets/ueditor/ueditor.all.min.js

Large diffs are not rendered by default.

34 changes: 32 additions & 2 deletions assets/ueditor/ueditor.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
['fullscreen','source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
'directionalityltr', 'directionalityrtl', 'indent', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo','insertaudio', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'pagebreak', 'template', 'background', '|',
'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'insertaudio', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'social','pagebreak', 'template', 'background', '|',
'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
'print', 'preview', 'searchreplace', 'help', 'drafts'
Expand All @@ -55,8 +55,38 @@
'anchor' : '',
'vaecolor' : '自定义字体颜色',
'insertaudio' : '音频',
'social' : '社交账号',
}

//社交账号
// ,social: [{
// label: '昵称',
// value: 'hbh',
// type: 'text'
// },
// {
// label: '微信',
// value: 'huangbinghe',
// type: 'text'
// },
// {
// label: '手机号',
// value: '13950804693',
// type: 'tel'
// },
// {
// label: '邮箱',
// value: 'hbh112233abc@163.com',
// type: 'mail'
// },
// {
// label: '二维码',
// value: 'https://p.ssl.qhimg.com/d/inn/0444533a/Snip20160525_6.png',
// type: 'img',
// style: "width:50px;height:50px"
// },
// ]

//禁用div转p标签
,allowDivTransToP:false

Expand Down
Loading

0 comments on commit 3204b8a

Please sign in to comment.