Skip to content

Commit

Permalink
fix(editor): 组件树右键菜单支持多选
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jun 26, 2023
1 parent 91e4680 commit 1660e94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/editor/src/layouts/sidebar/LayerMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const props = defineProps<{
const services = inject<Services>('services');
const menu = ref<InstanceType<typeof ContentMenu>>();
const node = computed(() => services?.editorService.get('node'));
const nodes = computed(() => services?.editorService.get('nodes'));
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
const isPage = computed(() => node.value?.type === NodeType.PAGE);
const componentList = computed(() => services?.componentListService.getList() || []);
Expand Down Expand Up @@ -82,7 +83,7 @@ const menuData = computed<(MenuButton | MenuComponent)[]>(() => [
type: 'button',
text: '新增',
icon: markRaw(Plus),
display: () => node.value?.items,
display: () => node.value?.items && nodes.value?.length === 1,
items: getSubMenuData.value,
},
{
Expand All @@ -91,7 +92,7 @@ const menuData = computed<(MenuButton | MenuComponent)[]>(() => [
icon: markRaw(CopyDocument),
display: () => !isRoot.value,
handler: () => {
node.value && services?.editorService.copy(node.value);
node.value && services?.editorService.copy(nodes.value || []);
},
},
{
Expand All @@ -100,7 +101,7 @@ const menuData = computed<(MenuButton | MenuComponent)[]>(() => [
icon: markRaw(Delete),
display: () => !isRoot.value && !isPage.value,
handler: () => {
node.value && services?.editorService.remove(node.value);
node.value && services?.editorService.remove(nodes.value || []);
},
},
...props.layerContentMenu,
Expand Down
6 changes: 5 additions & 1 deletion packages/editor/src/layouts/sidebar/LayerPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ const clickHandler = (data: MNode): void => {
// 右键菜单
const contextmenu = async (event: MouseEvent, data: MNode): Promise<void> => {
event.preventDefault();
await select(data);
if (nodes.value.length < 2) {
await select(data);
}
menu.value?.show(event);
};
</script>

0 comments on commit 1660e94

Please sign in to comment.