mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-04-21 03:48:03 +00:00
feat(editor): 添加 stage beforeDblclick 钩子,支持拦截默认双击行为
在 StageOptions 和 EditorProps 中新增 beforeDblclick 配置项, 该函数返回 false 或 Promise<false> 时将阻止 stage 默认的双击处理逻辑。 Made-with: Cursor
This commit is contained in:
parent
f583c7daec
commit
334569e2d7
@ -207,6 +207,7 @@ const stageOptions: StageOptions = {
|
||||
renderType: props.renderType,
|
||||
guidesOptions: props.guidesOptions,
|
||||
disabledMultiSelect: props.disabledMultiSelect,
|
||||
beforeDblclick: props.beforeDblclick,
|
||||
};
|
||||
|
||||
stageOverlayService.set('stageOptions', stageOptions);
|
||||
|
||||
@ -98,6 +98,8 @@ export interface EditorProps {
|
||||
isContainer?: (el: HTMLElement) => boolean | Promise<boolean>;
|
||||
/** 用于自定义组件树与画布的右键菜单 */
|
||||
customContentMenu?: CustomContentMenuFunction;
|
||||
/** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
|
||||
beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
|
||||
extendFormState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
||||
/** 页面顺序拖拽配置参数 */
|
||||
pageBarSortOptions?: PageBarSortOptions;
|
||||
|
||||
@ -164,10 +164,16 @@ watchEffect(() => {
|
||||
});
|
||||
|
||||
stage.on('dblclick', async (event: MouseEvent) => {
|
||||
if (props.stageOptions.beforeDblclick) {
|
||||
const result = await props.stageOptions.beforeDblclick(event);
|
||||
if (result === false) return;
|
||||
}
|
||||
|
||||
const el = (await stage?.actionManager?.getElementFromPoint(event)) || null;
|
||||
if (!el) return;
|
||||
|
||||
const id = getIdFromEl()(el);
|
||||
|
||||
if (id) {
|
||||
const node = editorService.getNodeById(id);
|
||||
if (node?.type === 'page-fragment-container' && node.pageFragmentId) {
|
||||
|
||||
@ -164,6 +164,8 @@ export interface StageOptions {
|
||||
disabledMultiSelect?: boolean;
|
||||
disabledRule?: boolean;
|
||||
zoom?: number;
|
||||
/** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
|
||||
beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
|
||||
}
|
||||
|
||||
export interface StoreState {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user