import { Boot, IButtonMenu, IDomEditor } from '@wangeditor/editor'

export default class ExtVideo implements IButtonMenu{
	key = 'extVideo'
	title = '插入视频'
	tag: 'button' = 'button'
	iconSvg = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z\"></path></svg>"

	// 执行逻辑
	exec(editor: IDomEditor, value?: any) {
		const fn = editor.getConfig()?.MENU_CONF?.extVideo?.callback
		if (fn) fn()
	}

	// 是否高亮
	isActive(editor: IDomEditor): boolean {
		return false
	}

	getValue(editor: IDomEditor): string | boolean {
		return undefined;
	}

	isDisabled(editor: IDomEditor): boolean {
		return false;
	}
}

// 注册菜单
Boot.registerMenu({
	key: 'extVideo',
	factory(): IButtonMenu {
		return new ExtVideo()
	}
})
