mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix(context-menu): fix context menu bugs
This commit is contained in:
parent
6ded1a6384
commit
8f0291fc3e
@ -17,6 +17,8 @@ export interface IContextMenuActions {
|
|||||||
adjustMenuLayout: IPublicApiMaterial['adjustContextMenuLayout'];
|
adjustMenuLayout: IPublicApiMaterial['adjustContextMenuLayout'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let destroyFn: Function | undefined;
|
||||||
|
|
||||||
export class ContextMenuActions implements IContextMenuActions {
|
export class ContextMenuActions implements IContextMenuActions {
|
||||||
actions: IPublicTypeContextMenuAction[] = [];
|
actions: IPublicTypeContextMenuAction[] = [];
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ export class ContextMenuActions implements IContextMenuActions {
|
|||||||
const { bounds } = designer.project.simulator?.viewport || { bounds: { left: 0, top: 0 } };
|
const { bounds } = designer.project.simulator?.viewport || { bounds: { left: 0, top: 0 } };
|
||||||
const { left: simulatorLeft, top: simulatorTop } = bounds;
|
const { left: simulatorLeft, top: simulatorTop } = bounds;
|
||||||
|
|
||||||
let destroyFn: Function | undefined;
|
destroyFn?.();
|
||||||
|
|
||||||
const destroy = () => {
|
const destroy = () => {
|
||||||
destroyFn?.();
|
destroyFn?.();
|
||||||
|
|||||||
@ -87,6 +87,9 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
|
|||||||
material.addContextMenuOption({
|
material.addContextMenuOption({
|
||||||
name: 'copy',
|
name: 'copy',
|
||||||
title: intl('Copy.1'),
|
title: intl('Copy.1'),
|
||||||
|
condition(nodes) {
|
||||||
|
return nodes.length > 0;
|
||||||
|
},
|
||||||
action(nodes) {
|
action(nodes) {
|
||||||
if (!nodes || nodes.length < 1) {
|
if (!nodes || nodes.length < 1) {
|
||||||
return;
|
return;
|
||||||
@ -159,6 +162,9 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
|
|||||||
material.addContextMenuOption({
|
material.addContextMenuOption({
|
||||||
name: 'delete',
|
name: 'delete',
|
||||||
title: intl('Delete'),
|
title: intl('Delete'),
|
||||||
|
condition(nodes) {
|
||||||
|
return nodes.length > 0;
|
||||||
|
},
|
||||||
action(nodes) {
|
action(nodes) {
|
||||||
nodes.forEach((node) => {
|
nodes.forEach((node) => {
|
||||||
node.remove();
|
node.remove();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
.context-menu-tree-wrap {
|
.context-menu-tree-wrap {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 4px 10px 4px 24px;
|
padding: 4px 10px 4px 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-tree-children {
|
.context-menu-tree-children {
|
||||||
|
|||||||
@ -22,16 +22,8 @@ const Tree = (props: {
|
|||||||
const { node } = props;
|
const { node } = props;
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!node.parent) {
|
|
||||||
return (
|
return (
|
||||||
<div className="context-menu-tree-wrap">
|
<div className="context-menu-tree-wrap">{ props.children }</div>
|
||||||
<div className="context-menu-tree-children">
|
|
||||||
{props.children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user