mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-18 03:20:03 +08:00
feat(editor): 增加FloatBox的beforeClose函数
This commit is contained in:
parent
cae928f7f9
commit
7ce60b223e
@ -33,12 +33,21 @@ interface Rect {
|
||||
height: number | string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{ visible: boolean; position?: Position; rect?: Rect; title?: string }>(), {
|
||||
visible: false,
|
||||
title: '',
|
||||
position: () => ({ left: 0, top: 0 }),
|
||||
rect: () => ({ width: 'auto', height: 'auto' }),
|
||||
});
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
position?: Position;
|
||||
rect?: Rect;
|
||||
title?: string;
|
||||
beforeClose?: (done: (cancel?: boolean) => void) => void;
|
||||
}>(),
|
||||
{
|
||||
visible: false,
|
||||
title: '',
|
||||
position: () => ({ left: 0, top: 0 }),
|
||||
rect: () => ({ width: 'auto', height: 'auto' }),
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [boolean];
|
||||
@ -125,8 +134,18 @@ onBeforeUnmount(() => {
|
||||
destroyMoveable();
|
||||
});
|
||||
|
||||
const hide = (cancel?: boolean) => {
|
||||
if (cancel !== false) {
|
||||
emit('update:visible', false);
|
||||
}
|
||||
};
|
||||
|
||||
const closeHandler = () => {
|
||||
emit('update:visible', false);
|
||||
if (typeof props.beforeClose === 'function') {
|
||||
props.beforeClose(hide);
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
};
|
||||
|
||||
const nextZIndex = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user