| 17 | } |
| 18 | |
| 19 | const Tree = (props: { |
| 20 | node?: IPublicModelNode | null; |
| 21 | children?: React.ReactNode; |
| 22 | options: IOptions; |
| 23 | }) => { |
| 24 | const { node } = props; |
| 25 | |
| 26 | if (!node) { |
| 27 | return ( |
| 28 | <div className="engine-context-menu-tree-wrap">{ props.children }</div> |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | const { common } = props.options.pluginContext || {}; |
| 33 | const { intl } = common?.utils || {}; |
| 34 | const indent = node.zLevel * 8 + 32; |
| 35 | const style = { |
| 36 | paddingLeft: indent, |
| 37 | marginLeft: -indent, |
| 38 | marginRight: -10, |
| 39 | paddingRight: 10, |
| 40 | }; |
| 41 | |
| 42 | return ( |
| 43 | <Tree {...props} node={node.parent} > |
| 44 | <div |
| 45 | className="engine-context-menu-title" |
| 46 | onClick={() => { |
| 47 | props.options.destroy?.(); |
| 48 | node.select(); |
| 49 | }} |
| 50 | style={style} |
| 51 | > |
| 52 | {props.options.nodes?.[0].id === node.id ? (<Icon className="engine-context-menu-tree-selecte-icon" size="small" type="success" />) : null} |
| 53 | {intl(node.title)} |
| 54 | </div> |
| 55 | <div |
| 56 | className="engine-context-menu-tree-children" |
| 57 | > |
| 58 | { props.children } |
| 59 | </div> |
| 60 | </Tree> |
| 61 | ); |
| 62 | }; |
| 63 | |
| 64 | let destroyFn: Function | undefined; |
| 65 | |