添加视频浮动菜单功能
This commit is contained in:
@@ -42,6 +42,7 @@ import Toc from "../extensions/Toc.ts";
|
||||
import { BubbleMenuPluginOptions, BubbleMenuPlugin } from "../components/menus/bubble/BubbleMenuPlugin.ts";
|
||||
import { TextSelectionBubbleMenu } from "../components/menus/bubble/TextSelectionBubbleMenu.ts";
|
||||
import { ImageBubbleMenu } from "../components/menus/bubble/ImageBubbleMenu.ts";
|
||||
import { VideoBubbleMenu } from "../components/menus/bubble/VideoBubbleMenu.ts";
|
||||
|
||||
/**
|
||||
* 创建浮动菜单功能
|
||||
@@ -134,6 +135,33 @@ const createImageBubbleMenu = (uaiEditor: UAIEditor) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建视频内容的浮动菜单
|
||||
* @param uaiEditor
|
||||
* @returns
|
||||
*/
|
||||
const createVideoBubbleMenu = (uaiEditor: UAIEditor) => {
|
||||
const container = new VideoBubbleMenu(uaiEditor);
|
||||
|
||||
return createBubbleMenu("videoBubbleMenu", {
|
||||
pluginKey: 'videoBubbleMenu',
|
||||
element: container,
|
||||
tippyOptions: {
|
||||
appendTo: uaiEditor.editor.editorContainer,
|
||||
arrow: false,
|
||||
interactive: true,
|
||||
hideOnClick: false,
|
||||
placement: 'top',
|
||||
},
|
||||
shouldShow: ({ editor }) => {
|
||||
if (!editor.isEditable) {
|
||||
return false;
|
||||
}
|
||||
return editor.isActive("video")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义编辑器的所有自定义扩展组件
|
||||
* @param uaiEditor
|
||||
@@ -211,6 +239,7 @@ export const allExtensions = (uaiEditor: UAIEditor, _options: UAIEditorOptions):
|
||||
Video,
|
||||
createTextSelectionBubbleMenu(uaiEditor),
|
||||
createImageBubbleMenu(uaiEditor),
|
||||
createVideoBubbleMenu(uaiEditor),
|
||||
];
|
||||
|
||||
return extensions;
|
||||
|
||||
Reference in New Issue
Block a user