Files
architype/EditorLabel.js

35 lines
643 B
JavaScript
Raw Normal View History

class EditorLabel extends EditorInputBase {
constructor(id, label) {
super(id, label);
2019-07-10 04:09:54 +00:00
this.elem_.classList.add('label');
this.input_.placeholder = 'label';
}
serialize() {
return super.serialize({
2019-07-10 04:09:54 +00:00
type: 'label',
2019-07-13 22:30:37 +00:00
id: this.getId(),
});
2019-07-10 04:09:54 +00:00
}
onKeyDown(e) {
super.onKeyDown(e);
switch (e.key) {
case ' ':
// We don't support highlighting, but stop propagation
e.stopPropagation();
e.preventDefault();
break;
2019-07-10 04:09:54 +00:00
}
}
static unserialize(ser) {
let label = new EditorLabel(ser.id);
2019-07-10 04:09:54 +00:00
label.setLabel(ser.label);
return label.getElement();
}
}