Populate EditorLink based on highlighted items
This commit is contained in:
23
Editor.js
23
Editor.js
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user