在導入ueEditor的js後另建一個js,執行以下代碼
// 註冊插件
UE.registerUI('報名表單插入', function (editor, uiName) {
//註冊按鈕執行時的command命令,使用命令默認就會帶有回退操作
editor.registerCommand(uiName, {
execCommand: function () {
var html = "<html code........>" // html代碼片段
editor.execCommand('insertHtml', html); // 執行的操作,這裏是插入剛纔的html代碼
}
});
//創建一個button,就是在工具欄上顯示的
var btn = new UE.ui.Button({
//按鈕的名字
name: uiName,
//提示
title: uiName,
//添加額外樣式,指定icon圖標,這裏默認使用一個重複的icon
cssRules: 'background-position:-53px -75px',
//點擊時執行的命令
onclick: function () {
editor.execCommand(uiName);
}
});
return btn;
});