MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / insert

Method insert

packages/core/src/document/node/node.ts:514–521  ·  view source on GitHub ↗

* insert a node at a specific position or a reference node

(node: Node, ref?: Node | number, useMutator = true)

Source from the content-addressed store, hash-verified

512 * insert a node at a specific position or a reference node
513 */
514 insert(node: Node, ref?: Node | number, useMutator = true) {
515 if (ref !== undefined && typeof ref === 'number') {
516 const nodeInstance = ensureNode(node, this.document)
517 this.children?.internalInsert(nodeInstance, ref, useMutator)
518 } else {
519 this.insertAfter(node, ref as Node, useMutator)
520 }
521 }
522
523 /**
524 * insert a node before a reference node(in current node's children)

Callers 2

insertChildFunction · 0.45
valueFunction · 0.45

Calls 3

insertAfterMethod · 0.95
ensureNodeFunction · 0.85
internalInsertMethod · 0.80

Tested by

no test coverage detected