Highlight links

This commit is contained in:
Ian Gulliver
2019-07-10 23:41:41 +00:00
parent 0aa272c224
commit dda2102f99
7 changed files with 47 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ class EditorLink extends EditorEntryBase {
label: this.getLabel(),
from: this.getFrom().serialize(),
to: this.getTo().serialize(),
highlight: this.elem_.classList.contains('highlight'),
};
}
@@ -52,6 +53,10 @@ class EditorLink extends EditorEntryBase {
}
}
setHighlight(highlight) {
this.elem_.classList.toggle('highlight', highlight);
}
onKeyDown(e) {
super.onKeyDown(e);
@@ -63,6 +68,13 @@ class EditorLink extends EditorEntryBase {
e.stopPropagation();
e.preventDefault();
break;
case ' ':
this.elem_.classList.toggle('highlight');
this.elem_.setAttribute('data-arch-value', '');
e.stopPropagation();
e.preventDefault();
break;
}
}
@@ -72,6 +84,7 @@ class EditorLink extends EditorEntryBase {
if (ser.label != null) {
link.setLabel(ser.label);
}
link.setHighlight(ser.highlight);
link.nodes_.unserialize([ser.from, ser.to]);
return link.getElement();
}