/** * @description code 菜单 panel tab 配置 * @author lkw */ import Editor from '../../editor/index' import { PanelConf } from '../menu-constructors/Panel' import { getRandom } from '../../utils/util' import $, { DomElement } from '../../utils/dom-core' import isActive from './is-active' export default function (editor: Editor, text: string, languageType: string): PanelConf { // panel 中需要用到的id const inputIFrameId = getRandom('input-iframe') const languageId = getRandom('select') const btnOkId = getRandom('btn-ok') /** * 插入链接 * @param text 文字 * @param code 链接 */ function insertCode(text: string): void { // 选区处于链接中,则选中整个菜单,再执行 insertHTML let active = isActive(editor) if (active) { selectCodeElem() } editor.cmd.do('insertHTML', text) const $code = editor.selection.getSelectionStartElem() const $codeElem = $code?.getNodeTop(editor) // 通过dom操作添加换行标签 // @ts-ignore $('
${formatCode}`
// @ts-ignore
insertCode(codeDom)
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true
},
},
],
}, // tab end
], // tabs end
}
return conf
}