-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshortcuts.js
More file actions
41 lines (41 loc) · 1.75 KB
/
shortcuts.js
File metadata and controls
41 lines (41 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const electronLocalshortcut = require('electron-localshortcut');
var undoqueue = [];
var undoparent = [];
/* */
electronLocalshortcut.register(require('electron').remote.getCurrentWindow(), 'Ctrl+D', () =>
{
if (currentelement.getAttribute("contenteditable") == "false" || currentelement.getAttribute("contenteditable") == null)
{
currentelement.parentElement.insertAdjacentHTML('beforeend', currentelement.outerHTML);
}
});
/* DELETE CONTROL */
electronLocalshortcut.register(require('electron').remote.getCurrentWindow(), 'Delete', () =>
{
if (currentelement.getAttribute("contenteditable") == "false" || currentelement.getAttribute("contenteditable") == null)
{
undoparent.push(currentelement.parentElement);
currentelement.style.borderStyle = previousstyleborder;
currentelement.style.borderColor = previousstylebordercolor;
currentelement.contentEditable=false;
undoqueue.push(currentelement.outerHTML);
var tempcurrent = currentelement.parentElement;
currentelement.remove();
currentelement = tempcurrent;
previousid = 0;
}
});
/* UNDO */
electronLocalshortcut.register(require('electron').remote.getCurrentWindow(), 'Ctrl+Z', () =>
{
if (currentelement.getAttribute("contenteditable") == "false" || currentelement.getAttribute("contenteditable") == null)
{
undoparent[undoparent.length - 1].insertAdjacentHTML('beforeend', undoqueue[undoqueue.length - 1]);
var xmlString = undoqueue[undoqueue.length - 1];
parser = new DOMParser();
doc = parser.parseFromString(xmlString, "text/xml");
innerDoc.getElementById(doc.id).style.borderStyle = previousstyleborder;
undoparent.length -= 1;
undoqueue.length -= 1;
}
});