Add EditorLabel

This commit is contained in:
Ian Gulliver
2019-07-10 04:09:54 +00:00
parent 9202ab2001
commit 56ff0d1201
6 changed files with 157 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ class Editor extends List {
static NODE = 1;
static GROUP = 2;
static LINK = 3;
static LABEL = 4;
constructor(container, allowedTypes) {
super(container);
@@ -54,6 +55,24 @@ class Editor extends List {
}
}
addLabelBefore() {
if (this.isAllowed(Editor.LABEL)) {
EditorLabel.addBefore(this.container_, this.getSelected());
}
}
addLabelAfter() {
if (this.isAllowed(Editor.LABEL)) {
EditorLabel.addAfter(this.container_, this.getSelected());
}
}
addLinkBefore() {
if (this.isAllowed(Editor.LINK)) {
EditorLink.addBefore(this.container_, this.getSelected());
}
}
addLinkAfter() {
if (this.isAllowed(Editor.LINK)) {
EditorLink.addAfter(this.container_, this.getSelected());
@@ -80,6 +99,18 @@ class Editor extends List {
onKeyDown(e) {
switch (e.key) {
case 'a':
this.addLabelAfter();
e.stopPropagation();
e.preventDefault();
return;
case 'A':
this.addLabelBefore();
e.stopPropagation();
e.preventDefault();
return;
case 'g':
this.addGroupAfter();
e.stopPropagation();
@@ -120,3 +151,9 @@ class Editor extends List {
super.onKeyDown(e);
}
}
<!--# include file="EditorEntryBase.js" -->
<!--# include file="EditorGroup.js" -->
<!--# include file="EditorLabel.js" -->
<!--# include file="EditorLink.js" -->
<!--# include file="EditorNode.js" -->