Files
architype/EditorGroup.js

40 lines
946 B
JavaScript
Raw Normal View History

class EditorGroup extends EditorSublistBase {
constructor(id, entries) {
super(id, '□', 'group', [
2019-07-10 08:14:53 +00:00
[EditorNode, [1, Number.POSITIVE_INFINITY]],
[EditorLabel, [0, 1]],
]);
if (entries && entries.length) {
for (let entry of entries) {
this.nodes_.addNodeAfter(entry.getLabel());
}
} else {
this.nodes_.addNodeAfter();
}
2019-07-03 01:42:17 +00:00
}
serialize() {
return super.serialize({
2019-07-03 01:42:17 +00:00
type: 'group',
2019-07-10 08:14:53 +00:00
members: this.nodes_.serialize(EditorNode),
});
2019-07-03 01:42:17 +00:00
}
getNodes() {
2019-07-10 08:14:53 +00:00
return this.nodes_.getEntries(EditorNode);
2019-07-03 01:42:17 +00:00
}
static unserialize(ser) {
let group = new EditorGroup(ser.id);
2019-07-03 01:42:17 +00:00
group.nodes_.clear();
2019-07-10 21:35:03 +00:00
if (ser.label != null) {
group.setLabel(ser.label, ser.labelObj.id);
group.getLabelObj().setHighlight(ser.labelObj.highlight);
2019-07-10 21:35:03 +00:00
}
2019-07-10 23:46:25 +00:00
group.setHighlight(ser.highlight);
2019-07-03 01:42:17 +00:00
group.nodes_.unserialize(ser.members);
return group.getElement();
}
}