manager.registerUI("inserttable", function (wdeditor, name) { var editor = wdeditor.getUeditor(); var tablePopup = new baidu.editor.ui.Popup({ editor: editor, content: '', className: 'edui-bubble', _deletetable: function () { this.hide(); wdeditor.execCommand("deletetable"); }, _insertrow: function (name) { this.hide(); wdeditor.execCommand("insertrow"); }, _deleterow: function (name) { this.hide(); wdeditor.execCommand("deleterow"); }, _insertcol: function (name) { this.hide(); wdeditor.execCommand("insertcol"); }, _deletecol: function (name) { this.hide(); wdeditor.execCommand("deletecol"); }, _mergecells: function (name) { this.hide(); wdeditor.execCommand("mergecells"); }, _deleterow: function (name) { this.hide(); wdeditor.execCommand("deleterow"); }, _mergeright: function (name) { this.hide(); wdeditor.execCommand("mergeright"); }, _mergedown: function (name) { this.hide(); wdeditor.execCommand("mergedown"); }, _splittocells: function (name) { this.hide(); wdeditor.execCommand("splittocells"); }, queryAutoHide: function (el) { if (el && el.ownerDocument == editor.document) { if (el.tagName.toLowerCase() == 'table' || baidu.editor.dom.domUtils.findParentByTagName(el, 'a', true)) { return el !== popup.anchorEl; } } return baidu.editor.ui.Popup.prototype.queryAutoHide .call(this, el); } }); tablePopup.render(); // 删除表格 插入行 插入列 删除行 删除列 合并选中 右合并 下合并 拆分 var tableCmds = [['deletetable', '删除表格','icon-deleteTable'], ['insertrow', '插入行','icon-insertRow'], ['insertcol', '插入列','icon-insertCol'], ['deleterow', '删除行','icon-deleteRow'], ['deletecol', '删除列','icon-deleteCol'], ['mergecells', '合并选中','icon-mergeCells'], ['mergeright', '右合并','icon-mergeRight'], ['mergedown', '下合并','icon-mergeDown'], ['splittocells', '拆分','icon-splitToCells']]; var tableBtnStr = '
'; var btn = new EditorManager.Button({ type: "button", name: "inserttable", className: "icon-table", text: "", title: "表格", onpicktable: function (t, numCols, numRows) { wdeditor.execCommand('InsertTable', { numRows: numRows, numCols: numCols, border: 1 }); }, setSelectionChange: function () { var this_ = this; wdeditor.addListener("selectionchange", function () { this_.setDisable(wdeditor.queryCommandState("inserttable") == -1); var evt = event; var sel = wdeditor.getUeditor().selection; var el = $(sel.getStart(), sel.document.defaultView).parents("table")[0]; if (el) { var html = '