-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorNode.js
More file actions
48 lines (41 loc) · 1020 Bytes
/
EditorNode.js
File metadata and controls
48 lines (41 loc) · 1020 Bytes
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
class EditorNode extends EditorInputBase {
constructor(id, label) {
super(id, label);
this.elem_.classList.add('node');
this.input_.placeholder = 'node name';
}
serialize() {
return super.serialize({
type: 'node',
});
}
isSoft() {
// Nested nodes are presumed to be references to other nodes if they exist
for (let iter = this.elem_.parentElement; iter; iter = iter.parentElement) {
if (iter.xArchObj) {
return true;
}
}
return false;
}
updateLabel() {
if (this.ctrlKey_) {
this.elem_.dispatchEvent(new CustomEvent(
'updateNodesRequest',
{
bubbles: true,
detail: {
oldLabel: this.lastLabel_,
newLabel: this.getLabel(),
},
}));
}
super.updateLabel();
}
static unserialize(ser) {
let node = new EditorNode(ser.id);
node.setLabel(ser.label);
node.setHighlight(ser.highlight);
return node.getElement();
}
}