added: command to search and replace text
This commit is contained in:
parent
cc790f8f89
commit
bc2fd50836
30
main.js
30
main.js
|
@ -219,7 +219,6 @@ var commands = [
|
|||
action: restore
|
||||
},
|
||||
{
|
||||
shortcut: "ctrl+h",
|
||||
hint: "Insert markdown header",
|
||||
action: insertheader,
|
||||
allowunsaved: true
|
||||
|
@ -377,6 +376,11 @@ var commands = [
|
|||
{
|
||||
hint: "Notes by size",
|
||||
action: notesbysize
|
||||
},
|
||||
{
|
||||
hint: "Replace",
|
||||
shortcut: "ctrl+h",
|
||||
action: searchandreplace
|
||||
}];
|
||||
|
||||
var snippets = [
|
||||
|
@ -2321,6 +2325,30 @@ function searchandloadnote()
|
|||
selectnote().then(loadnote);
|
||||
}
|
||||
|
||||
function searchandreplace()
|
||||
{
|
||||
var oldvalue = prompt("Search:");
|
||||
if (!oldvalue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newvalue = prompt("Replace by:");
|
||||
if (!newvalue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var doit = confirm(`Replace '${oldvalue}' by '${newvalue}'?`);
|
||||
if (!doit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
seteditorcontent(md.value.replaceAll(oldvalue, newvalue));
|
||||
datachanged();
|
||||
}
|
||||
|
||||
function notesbysize()
|
||||
{
|
||||
var sortedtitles = localdata.sort( (n1,n2) => { return n2.content.length - n1.content.length})
|
||||
|
|
Loading…
Reference in New Issue