MCPcopy Create free account
hub / github.com/hizzgdev/jsmind / insert_node_before

Method insert_node_before

src/jsmind.js:619–642  ·  view source on GitHub ↗

* Insert a node before target node. * @param {string | import('./jsmind.node.js').Node} node_before * @param {string} node_id * @param {string} topic * @param {Record =} data * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node

(node_before, node_id, topic, data, direction)

Source from the content-addressed store, hash-verified

617 * @returns {import('./jsmind.node.js').Node|null}
618 */
619 insert_node_before(node_before, node_id, topic, data, direction) {
620 if (this.get_editable()) {
621 var the_node_before = this.get_node(node_before);
622 var dir = Direction.of(direction);
623 if (dir === undefined) {
624 dir = this.layout.calculate_next_child_direction(the_node_before.parent);
625 }
626 var node = this.mind.insert_node_before(the_node_before, node_id, topic, data, dir);
627 if (!!node) {
628 this.view.add_node(node);
629 this.layout.layout();
630 this.view.show(false);
631 this.invoke_event_handle(EventType.edit, {
632 evt: 'insert_node_before',
633 data: [the_node_before.id, node_id, topic, data, dir],
634 node: node_id,
635 });
636 }
637 return node;
638 } else {
639 logger.error('fail, this mind map is not editable');
640 return null;
641 }
642 }
643 /**
644 * Insert a node after target node.
645 * @param {string | import('./jsmind.node.js').Node} node_after

Callers 6

testDirectionTypesFunction · 0.95
jsmind.jsFile · 0.45
jsmind.test.jsFile · 0.45

Calls 7

get_editableMethod · 0.95
get_nodeMethod · 0.95
invoke_event_handleMethod · 0.95
layoutMethod · 0.80
add_nodeMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected