日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

实战-Ueditor扩展二次开发

發(fā)布時間:2025/3/16 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 实战-Ueditor扩展二次开发 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
第一部分 開發(fā)前期準備? ?

1、UEditor從1.4.1開始,添加對于二次開發(fā)的擴展支持。 ? ?Jeewx擴展二次開發(fā)采用1.4.3.1 Jsp 版本
2、上傳圖片設(shè)置 ? ?簡述: UE做的不夠靈活,不如老版本
? ?[1]?配置文件:ueditor/jsp/config.json ? ?? ? 說明: 所有項目配置訪問前綴
? ?[2]?引入UE依賴的JAR包 ? ?? ? 特殊說明:UE自帶的ueditor-1.1.2.jar有問題,經(jīng)過修改源碼好用。
第二部分 擴展增加按鈕DEMO


??[1] customizeToolbarUIDemo.html頁面 <!DOCTYPE HTML>
<html>
<head>
? ? <title>完整demo</title>
? ? <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
? ? <!--UEditor-->
? ? <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="../lang/zh-cn/zh-cn.js"></script>
? ? <!--添加按鈕-->
? ? <script type="text/javascript" charset="utf-8" src="addCustomizeButton.js"></script>
? ? <style type="text/css">
? ?? ???.clear {
? ?? ?? ?? ?clear: both;
? ?? ???}
? ?? ???div{
? ?? ?? ?? ?width:100%;
? ?? ???}
? ? </style>
</head>
<body>
<div>
? ? <h1>二次開發(fā)demo</h1>
? ? <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</div>
</body>
<script type="text/javascript">
? ? //實例化編輯器
? ? UE.getEditor('editor');
</script>
</html> ???[2] addCustomizeButton.js頁面
UE.registerUI('微信模板', function(editor, uiName) {
? ? //注冊按鈕執(zhí)行時的command命令,使用命令默認就會帶有回退操作
? ? editor.registerCommand(uiName, {
? ?? ???execCommand: function() {
? ?? ?? ?? ?alert('execCommand:' + uiName)
? ?? ???}
? ? });
? ? //創(chuàng)建一個button
? ? var btn = new UE.ui.Button({
? ?? ???//按鈕的名字
? ?? ???name: uiName,
? ?? ???//提示
? ?? ???title: uiName,
? ?? ???//添加額外樣式,指定icon圖標,這里默認使用一個重復(fù)的icon
? ?? ???cssRules: 'background-position: -500px 0;',
? ?? ???//點擊時執(zhí)行的命令
? ?? ???onclick: function() {
? ?? ?? ?? ?//這里可以不用執(zhí)行命令,做你自己的操作也可
? ?? ?? ?? ?editor.execCommand(uiName);
? ?? ???}
? ? });
? ? //當(dāng)點到編輯內(nèi)容上時,按鈕要做的狀態(tài)反射
? ? editor.addListener('selectionchange', function() {
? ?? ???var state = editor.queryCommandState(uiName);
? ?? ???if (state == -1) {
? ?? ?? ?? ?btn.setDisabled(true);
? ?? ?? ?? ?btn.setChecked(false);
? ?? ???} else {
? ?? ?? ?? ?btn.setDisabled(false);
? ?? ?? ?? ?btn.setChecked(state);
? ?? ???}
? ? });
? ? //因為你是添加button,所以需要返回這個button
? ? return btn;
});
第三部分 微信編輯擴展我的素材插件


????[1]修改JSP頁面,引入插件JS
? ?? ???weixin/guanjia/newstemplate/weixinArticle-update.jsp

? ?


[2]插件JS源碼
UE.plugins['weixin_template'] = function () {
? ? var me = this,thePlugins = 'weixin_template';
? ? me.commands[thePlugins] = {
? ?? ???execCommand:function (cmd,uiName) {
? ?? ?? ?? ?? ? var pos='WXNRQ';
? ?? ?? ?? ?if(uiName=='內(nèi)容區(qū)'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXNRQ';//此處編碼要對應(yīng)weixin數(shù)據(jù)字典項
? ?? ???}if(uiName=='關(guān)注引導(dǎo)'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXGZYD';
? ?? ???}else if(uiName=='標題'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXBT';
? ?? ???}else if(uiName=='原文引導(dǎo)'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXYWYD';
? ?? ???}else if(uiName=='分隔線'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXFGX';
? ?? ???}else if(uiName=='互推賬號'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXHTZH';
? ?? ???}else if(uiName=='我的樣式'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXWDYS';
? ?? ???}else if(uiName=='其他'){
? ?? ?? ?? ?? ? pos? ?? ?? ???='WXQT';
? ?? ???}?
? ?? ?? ?? ?var dialog = new UE.ui.Dialog({
? ?? ?? ?? ?? ? iframeUrl:this.options.UEDITOR_HOME_URL + '/demo/weixin.html?type='+pos,
? ?? ?? ?? ?? ? name:thePlugins,
? ?? ?? ?? ?? ? editor:this,
? ?? ?? ?? ?? ? title: '微信圖文模板',
? ?? ?? ?? ?? ? cssRules:"width:740px;height:430px;",
? ?? ?? ?? ?? ? buttons:[
? ?? ?? ?? ?? ? {
? ?? ?? ?? ?? ?? ???className:'edui-okbutton',
? ?? ?? ?? ?? ?? ???label:'確定',
? ?? ?? ?? ?? ?? ???onclick:function () {
? ?? ?? ?? ?? ?? ?? ?? ?dialog.close(true);
? ?? ?? ?? ?? ?? ???}
? ?? ?? ?? ?? ? }]
? ?? ?? ?? ?});
? ?? ?? ?? ?dialog.render();
? ?? ?? ?? ?dialog.open();
? ?? ???}
? ? };
};

function weixinButton(editor,uiName){
? ? //注冊按鈕執(zhí)行時的command命令,使用命令默認就會帶有回退操作
? ? editor.registerCommand(uiName,{
? ?? ???execCommand:function(){
? ?? ?? ?? ?? ? try {
? ?? ?? ?? ?? ?? ?? ?editor.execCommand('weixin_template',uiName);
? ?? ?? ?? ?} catch ( e ) {
? ?? ?? ?? ?? ? alert('打開模板異常'+e);
? ?? ?? ?? ?}
? ?? ???}
? ? });
? ? //創(chuàng)建一個button
? ? var btn = new UE.ui.Button({
? ?? ???//按鈕的名字
? ?? ???name:uiName,
? ?? ???//提示
? ?? ???title:uiName,
? ?? ???//需要添加的額外樣式,指定icon圖標,這里默認使用一個重復(fù)的icon
? ?? ???cssRules :'background-position:-902px -45px;width: 63px!important;',
? ?? ???//點擊時執(zhí)行的命令
? ?? ???onclick:function () {
? ?? ?? ?? ?//這里可以不用執(zhí)行命令,做你自己的操作也可
? ?? ?? ???editor.execCommand(uiName);
? ?? ???}
? ? });
? ? //因為你是添加button,所以需要返回這個button
? ? return btn;
}
UE.registerUI('微信圖文模

總結(jié)

以上是生活随笔為你收集整理的实战-Ueditor扩展二次开发的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。