Populate EditorLink based on highlighted items

This commit is contained in:
Ian Gulliver
2019-07-11 04:40:43 +00:00
parent f7822b24b5
commit 7390acb978
3 changed files with 20 additions and 13 deletions

View File

@@ -84,21 +84,17 @@ class Editor extends List {
}
}
addLinkBefore() {
if (this.mayAdd(EditorLink)) {
EditorLink.addBefore(this.container_, this.getSelected());
}
}
addLinkAfter() {
if (this.mayAdd(EditorLink)) {
EditorLink.addAfter(this.container_, this.getSelected());
EditorLink.addAfter(this.container_, this.getSelected(),
this.queryEntries('.highlight', EditorNode));
}
}
addLinkBefore() {
if (this.mayAdd(EditorLink)) {
EditorLink.addBefore(this.container_, this.getSelected());
EditorLink.addBefore(this.container_, this.getSelected(),
this.queryEntries('.highlight', EditorNode));
}
}
@@ -179,8 +175,15 @@ class Editor extends List {
return;
case 'Escape':
for (let entry of this.queryEntries('.highlight')) {
entry.getElement().classList.toggle('highlight', false);
if (!this.container_.parentElement.xArchObj) {
for (let entry of this.queryEntries('.highlight')) {
entry.getElement().classList.toggle('highlight', false);
}
// TODO: rename this to data-arch-refresh, make value noop everywhere
this.container_.setAttribute('data-arch-value', '');
e.stopPropagation();
e.preventDefault();
return;
}
}

View File

@@ -1,5 +1,5 @@
class EditorLink extends EditorEntryBase {
constructor() {
constructor(entries) {
super();
this.elem_.innerText = '↓';
@@ -10,8 +10,10 @@ class EditorLink extends EditorEntryBase {
[EditorNode, [2, 2]],
[EditorLabel, [0, 1]],
]);
this.nodes_.addNodeAfter();
this.nodes_.addNodeAfter();
this.nodes_.addNodeAfter(
entries && entries[0] ? entries[0].getLabel() : null);
this.nodes_.addNodeAfter(
entries && entries[1] ? entries[1].getLabel() : null);
this.elem_.appendChild(nodeList);
}

View File

@@ -128,6 +128,8 @@ class List {
if (this.container_.parentElement.xArchObj) {
this.container_.parentElement.focus();
}
e.stopPropagation();
e.preventDefault();
break;
case 'd':