mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-30 00:55:30 +02:00
allow tab input in editor plus dont delete empty
This commit is contained in:
parent
239fafba92
commit
cf9f7f012a
@ -548,7 +548,10 @@ class NavFile extends NavEntry {
|
|||||||
async write_to_file() {
|
async write_to_file() {
|
||||||
var new_contents = document.getElementById("nav-edit-contents-textarea").value;
|
var new_contents = document.getElementById("nav-edit-contents-textarea").value;
|
||||||
try {
|
try {
|
||||||
await cockpit.file(this.path_str(), {superuser: "try"}).replace(new_contents); // cockpit.script("echo -n \"$1\" > $2", [new_contents, this.path_str()], {superuser: "try"});
|
if (new_contents.length)
|
||||||
|
await cockpit.file(this.path_str(), {superuser: "try"}).replace(new_contents);
|
||||||
|
else
|
||||||
|
await cockpit.script("echo -n > $1", [this.path_str()], {superuser: "try"});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.alert(e.message);
|
window.alert(e.message);
|
||||||
}
|
}
|
||||||
@ -2130,6 +2133,16 @@ function set_up_buttons() {
|
|||||||
if (e.keyCode === 13)
|
if (e.keyCode === 13)
|
||||||
nav_window.search_filter(e);
|
nav_window.search_filter(e);
|
||||||
});
|
});
|
||||||
|
// fix tab in editor input
|
||||||
|
document.getElementById('nav-edit-contents-textarea').addEventListener('keydown', (e) => {
|
||||||
|
if (e.key == 'Tab') {
|
||||||
|
e.preventDefault();
|
||||||
|
var start = e.target.selectionStart;
|
||||||
|
var end = e.target.selectionEnd;
|
||||||
|
e.target.value = `${e.target.value.substring(0, start)}\t${e.target.value.substring(end)}`;
|
||||||
|
e.target.selectionStart = e.target.selectionEnd = start + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user