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

Function comparePosition

packages/core/src/document/node/node.ts:818–843  ·  view source on GitHub ↗
(node1: Node, node2: Node)

Source from the content-addressed store, hash-verified

816 * compare the position of two nodes
817 */
818export const comparePosition = (node1: Node, node2: Node): PositionNO => {
819 if (node1 === node2) {
820 return PositionNO.TheSame
821 }
822 const l1 = node1.zLevel
823 const l2 = node2.zLevel
824 if (l1 === l2) {
825 return PositionNO.BeforeOrAfter
826 }
827
828 let p: any
829 if (l1 < l2) {
830 p = getZLevelTop(node2, l1)
831 if (p && p === node1) {
832 return PositionNO.Contains
833 }
834 return PositionNO.BeforeOrAfter
835 }
836
837 p = getZLevelTop(node1, l2)
838 if (p && p === node2) {
839 return PositionNO.ContainedBy
840 }
841
842 return PositionNO.BeforeOrAfter
843}
844
845export const insertChild = (
846 container: Node,

Callers 2

getTopNodesMethod · 0.90
comparePositionMethod · 0.85

Calls 1

getZLevelTopFunction · 0.85

Tested by

no test coverage detected