/** * @description video 菜单 panel tab 配置 * @author tonghan */ import Editor from '../../editor/index' import { PanelConf, PanelTabConf } from '../menu-constructors/Panel' import { getRandom } from '../../utils/util' import $ from '../../utils/dom-core' import UploadVideo from './upload-video' import { EMPTY_P } from '../../utils/const' export default function (editor: Editor, video: string): PanelConf { const config = editor.config const uploadVideo = new UploadVideo(editor) // panel 中需要用到的id const inputIFrameId = getRandom('input-iframe') const btnOkId = getRandom('btn-ok') const inputUploadId = getRandom('input-upload') const btnStartId = getRandom('btn-local-ok') /** * 插入链接 * @param iframe html标签 */ function insertVideo(video: string): void { editor.cmd.do('insertHTML', video + EMPTY_P) // video添加后的回调 editor.config.onlineVideoCallback(video) } /** * 校验在线视频链接 * @param video 在线视频链接 */ function checkOnlineVideo(video: string): boolean { // 查看开发者自定义配置的返回值 const check = editor.config.onlineVideoCheck(video) if (check === true) { return true } if (typeof check === 'string') { //用户未能通过开发者的校验,开发者希望我们提示这一字符串 editor.config.customAlert(check, 'error') } return false } // tabs配置 // const fileMultipleAttr = config.uploadVideoMaxLength === 1 ? '' : 'multiple="multiple"' const tabsConf: PanelTabConf[] = [ { // tab 的标题 title: editor.i18next.t('menus.panelMenus.video.上传视频'), tpl: `