|
@@ -153,12 +153,12 @@ export class Tree {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 查找ID节点
|
|
// 查找ID节点
|
|
|
- find(ID: string): TreeNode | None {
|
|
|
|
|
- return this.IDMap[ID];
|
|
|
|
|
|
|
+ find(ID: string): TreeNode | null {
|
|
|
|
|
+ return this.IDMap[ID] || null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 查找ID节点的父节点
|
|
// 查找ID节点的父节点
|
|
|
- findParent(ID: string): TreeNode | None {
|
|
|
|
|
|
|
+ findParent(ID: string): TreeNode | null {
|
|
|
const node = this.find(ID);
|
|
const node = this.find(ID);
|
|
|
if (!node) {
|
|
if (!node) {
|
|
|
return null;
|
|
return null;
|
|
@@ -167,7 +167,7 @@ export class Tree {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 查找ID节点的下一个节点
|
|
// 查找ID节点的下一个节点
|
|
|
- findNext(ID: string): TreeNode | None {
|
|
|
|
|
|
|
+ findNext(ID: string): TreeNode | null {
|
|
|
const node = this.find(ID);
|
|
const node = this.find(ID);
|
|
|
if (!node) {
|
|
if (!node) {
|
|
|
return null;
|
|
return null;
|
|
@@ -177,11 +177,11 @@ export class Tree {
|
|
|
if (nodeIndex < 0) {
|
|
if (nodeIndex < 0) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- return nodes[nodeIndex + 1];
|
|
|
|
|
|
|
+ return nodes[nodeIndex + 1] || null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 查找ID节点的上一个节点
|
|
// 查找ID节点的上一个节点
|
|
|
- findPrev(ID: string): TreeNode | None {
|
|
|
|
|
|
|
+ findPrev(ID: string): TreeNode | null {
|
|
|
const node = this.find(ID);
|
|
const node = this.find(ID);
|
|
|
if (!node) {
|
|
if (!node) {
|
|
|
return null;
|
|
return null;
|
|
@@ -191,7 +191,7 @@ export class Tree {
|
|
|
if (nodeIndex < 0) {
|
|
if (nodeIndex < 0) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- return nodes[nodeIndex - 1];
|
|
|
|
|
|
|
+ return nodes[nodeIndex - 1] || null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 查询ID节点的子节点
|
|
// 查询ID节点的子节点
|
|
@@ -250,7 +250,7 @@ export class Tree {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 从节点块中获取相同深度的节点
|
|
// 从节点块中获取相同深度的节点
|
|
|
- sameDepthNodes(nodes: TreeNode[], depth: number | None): TreeNode[] {
|
|
|
|
|
|
|
+ sameDepthNodes(nodes: TreeNode[], depth?: number): TreeNode[] {
|
|
|
if (!depth) {
|
|
if (!depth) {
|
|
|
depth = nodes[0].getCtx().depth();
|
|
depth = nodes[0].getCtx().depth();
|
|
|
}
|
|
}
|
|
@@ -557,7 +557,7 @@ export class Tree {
|
|
|
next: TreeNode | None
|
|
next: TreeNode | None
|
|
|
): UpdateData[] {
|
|
): UpdateData[] {
|
|
|
const updateData: UpdateData[] = [];
|
|
const updateData: UpdateData[] = [];
|
|
|
- let prev: TreeNode | None;
|
|
|
|
|
|
|
+ let prev: TreeNode | null;
|
|
|
if (next) {
|
|
if (next) {
|
|
|
prev = next.getCtx().prev();
|
|
prev = next.getCtx().prev();
|
|
|
} else {
|
|
} else {
|