forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetecting.ts
More file actions
63 lines (55 loc) · 1.6 KB
/
detecting.ts
File metadata and controls
63 lines (55 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Node as ShellNode } from './node';
import {
Detecting as InnerDetecting,
IDocumentModel as InnerDocumentModel,
INode as InnerNode,
} from '@alilc/lowcode-designer';
import { documentSymbol, detectingSymbol } from '../symbols';
import { IPublicModelDetecting, IPublicModelNode, IPublicTypeDisposable } from '@alilc/lowcode-types';
export class Detecting implements IPublicModelDetecting {
private readonly [documentSymbol]: InnerDocumentModel;
private readonly [detectingSymbol]: InnerDetecting;
constructor(document: InnerDocumentModel) {
this[documentSymbol] = document;
this[detectingSymbol] = document.designer?.detecting;
}
/**
* 控制大纲树 hover 时是否出现悬停效果
*/
get enable(): boolean {
return this[detectingSymbol].enable;
}
/**
* 当前 hover 的节点
*/
get current() {
return ShellNode.create(this[detectingSymbol].current);
}
/**
* hover 指定节点
* @param id 节点 id
*/
capture(id: string) {
this[detectingSymbol].capture(this[documentSymbol].getNode(id));
}
/**
* hover 离开指定节点
* @param id 节点 id
*/
release(id: string) {
this[detectingSymbol].release(this[documentSymbol].getNode(id));
}
/**
* 清空 hover 态
*/
leave() {
this[detectingSymbol].leave(this[documentSymbol]);
}
onDetectingChange(fn: (node: IPublicModelNode | null) => void): IPublicTypeDisposable {
const innerFn = (innerNode: InnerNode) => {
const shellNode = ShellNode.create(innerNode);
fn(shellNode);
};
return this[detectingSymbol].onDetectingChange(innerFn);
}
}