Node highlighting

This commit is contained in:
Ian Gulliver
2019-07-10 23:19:39 +00:00
parent 4857bb97cb
commit d52c8206a6
5 changed files with 31 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ class EditorNode extends EditorEntryBase {
return {
type: 'node',
label: this.getLabel(),
highlight: this.elem_.classList.contains('highlight'),
};
}
@@ -32,6 +33,10 @@ class EditorNode extends EditorEntryBase {
this.onInput();
}
setHighlight(highlight) {
this.elem_.classList.toggle('highlight', highlight);
}
wantFocus() {
return this.getLabel() == '';
}
@@ -91,6 +96,13 @@ class EditorNode extends EditorEntryBase {
e.stopPropagation();
e.preventDefault();
break;
case ' ':
this.elem_.classList.toggle('highlight');
this.onInput();
e.stopPropagation();
e.preventDefault();
break;
}
}
@@ -105,6 +117,7 @@ class EditorNode extends EditorEntryBase {
static unserialize(ser) {
let node = new EditorNode();
node.setLabel(ser.label);
node.setHighlight(ser.highlight);
return node.getElement();
}
}