* Move a node and optionally change direction. * @param {string} node_id * @param {string=} before_id - The ID of the node before which to place the moved node. Special values: "_first_", "_last_" * @param {string=} parent_id * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number
(node_id, before_id, parent_id, direction)
| 754 | * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1). Only effective for second-level nodes (children of root). If not provided, direction will be determined automatically. |
| 755 | */ |
| 756 | move_node(node_id, before_id, parent_id, direction) { |
| 757 | if (this.get_editable()) { |
| 758 | var node = this.get_node(node_id); |
| 759 | var updated_node = this.mind.move_node(node, before_id, parent_id, direction); |
| 760 | if (!!updated_node) { |
| 761 | this.view.update_node(updated_node); |
| 762 | this.layout.layout(); |
| 763 | this.view.show(false); |
| 764 | this.invoke_event_handle(EventType.edit, { |
| 765 | evt: 'move_node', |
| 766 | data: [node_id, before_id, parent_id, direction], |
| 767 | node: node_id, |
| 768 | }); |
| 769 | } |
| 770 | } else { |
| 771 | logger.error('fail, this mind map is not editable'); |
| 772 | return; |
| 773 | } |
| 774 | } |
| 775 | /** |
| 776 | * @param {string | import('./jsmind.node.js').Node} node |
| 777 | * @returns {void} |
no test coverage detected