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

Function insertChild

packages/core/src/document/node/node.ts:845–868  ·  view source on GitHub ↗
(
  container: Node,
  thing: Node | NodeSchema,
  at?: number | null,
  copy?: boolean,
)

Source from the content-addressed store, hash-verified

843}
844
845export const insertChild = (
846 container: Node,
847 thing: Node | NodeSchema,
848 at?: number | null,
849 copy?: boolean,
850): Node | null => {
851 let node: Node | null | undefined
852 let Schema: NodeSchema
853 if (isNode(thing) && copy) {
854 Schema = thing.export()
855 node = container.document?.createNode(Schema)
856 } else if (isNode(thing)) {
857 node = thing
858 } else if (isNodeSchema(thing)) {
859 node = container.document?.createNode(thing)
860 }
861
862 if (isNode(node)) {
863 container.children?.insert(node, at)
864 return node
865 }
866
867 return null
868}
869
870export const insertChildren = (
871 container: Node,

Callers 2

insertNodeMethod · 0.90
insertChildrenFunction · 0.85

Calls 5

isNodeFunction · 0.85
isNodeSchemaFunction · 0.85
createNodeMethod · 0.80
exportMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected