) {
const node = treeNode?.node;
@@ -100,7 +100,11 @@ export default class TreeTitle extends PureComponent<{
});
});
}
-
+ deleteClick = () => {
+ const { treeNode } = this.props;
+ const { node } = treeNode;
+ treeNode.deleteNode(node);
+ };
render() {
const { treeNode, isModal } = this.props;
const { pluginContext } = treeNode;
@@ -131,6 +135,7 @@ export default class TreeTitle extends PureComponent<{
const shouldShowHideBtn = isCNode && isNodeParent && !isModal && couldHide;
const shouldShowLockBtn = config.get('enableCanvasLock', false) && isContainer && isCNode && isNodeParent && ((couldLock && !node.isLocked) || (couldUnlock && node.isLocked));
const shouldEditBtn = isCNode && isNodeParent;
+ const shouldDeleteBtn = isCNode && isNodeParent && node?.canPerformAction('remove');
return (
{shouldShowHideBtn && }
{shouldShowLockBtn && }
- {shouldEditBtn && }
+ {shouldEditBtn && }
+ {shouldDeleteBtn && }
+
+ );
+ }
+}
+class DeleteBtn extends PureComponent<{
+ treeNode: TreeNode;
+ onClick: () => void;
+}> {
+ render() {
+ const { intl, common } = this.props.treeNode.pluginContext;
+ const { Tip } = common.editorCabin;
+ return (
+
+
+ {/* @ts-ignore */}
+ {intl('Delete')}
);
}
@@ -297,7 +322,6 @@ class ExpandBtn extends PureComponent<{
expanded: boolean;
expandable: boolean;
}> {
-
render() {
const { treeNode, expanded, expandable } = this.props;
if (!expandable) {