MCPcopy
hub / github.com/marktext/marktext / insertInto

Method insertInto

packages/muya/src/block/base/treeNode.ts:223–235  ·  view source on GitHub ↗
(parent: Parent, refBlock: Nullable<Parent> = null)

Source from the content-addressed store, hash-verified

221 }
222
223 insertInto(parent: Parent, refBlock: Nullable<Parent> = null) {
224 if (this.parent === parent && this.next === refBlock)
225 return;
226
227 if (this.parent)
228 this.parent.removeChild(this);
229
230 // `parent.insertBefore` takes a Parent (the tree's internal linked
231 // list operates on Parent), but TreeNode.insertInto is also called
232 // from Content subclasses which extend TreeNode, not Parent.
233 // eslint-disable-next-line no-restricted-syntax
234 parent.insertBefore(this as unknown as Parent, refBlock);
235 }
236
237 /**
238 * Remove the current block in the block tree.

Callers 2

orderIfNecessaryMethod · 0.80

Calls 2

removeChildMethod · 0.80
insertBeforeMethod · 0.45

Tested by

no test coverage detected