Node highlighting
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user