| 40 | } |
| 41 | |
| 42 | export default class TreeNode { |
| 43 | readonly pluginContext: IOutlinePanelPluginContext; |
| 44 | event = new EventEmitter(); |
| 45 | |
| 46 | private _node: IPublicModelNode; |
| 47 | |
| 48 | readonly tree: Tree; |
| 49 | |
| 50 | private _filterResult: FilterResult = { |
| 51 | filterWorking: false, |
| 52 | matchChild: false, |
| 53 | matchSelf: false, |
| 54 | keywords: '', |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * 默认为折叠状态 |
| 59 | * 在初始化根节点时,设置为展开状态 |
| 60 | */ |
| 61 | private _expanded = false; |
| 62 | |
| 63 | id = uniqueId('treeNode'); |
| 64 | |
| 65 | get nodeId(): string { |
| 66 | return this.node.id; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * 是否可以展开 |
| 71 | */ |
| 72 | get expandable(): boolean { |
| 73 | if (this.locked) return false; |
| 74 | return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null; |
| 75 | } |
| 76 | |
| 77 | get expanded(): boolean { |
| 78 | return this.isRoot(true) || (this.expandable && this._expanded); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * 插入"线"位置信息 |
| 83 | */ |
| 84 | get dropDetail(): IPublicTypeLocationChildrenDetail | undefined | null { |
| 85 | const loc = this.pluginContext.project.getCurrentDocument()?.dropLocation; |
| 86 | return loc && this.isResponseDropping() && isLocationChildrenDetail(loc.detail) ? loc.detail : null; |
| 87 | } |
| 88 | |
| 89 | get depth(): number { |
| 90 | return this.node.zLevel; |
| 91 | } |
| 92 | |
| 93 | get detecting() { |
| 94 | const doc = this.pluginContext.project.currentDocument; |
| 95 | return !!(doc?.isDetectingNode(this.node)); |
| 96 | } |
| 97 | |
| 98 | get hidden(): boolean { |
| 99 | const cv = this.node.isConditionalVisible(); |
nothing calls this directly
no test coverage detected
searching dependent graphs…