mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
if parent note is encrypted, then child note will be created as encrypted as well
This commit is contained in:
parent
9ba958205d
commit
adf18132fb
@ -125,7 +125,8 @@ def createChild(parent_note_id):
|
|||||||
'date_created': now,
|
'date_created': now,
|
||||||
'date_modified': now,
|
'date_modified': now,
|
||||||
'icon_info': 'pencil',
|
'icon_info': 'pencil',
|
||||||
'is_finished': 0
|
'is_finished': 0,
|
||||||
|
'encryption': note['encryption']
|
||||||
})
|
})
|
||||||
|
|
||||||
insert("notes_tree", {
|
insert("notes_tree", {
|
||||||
|
@ -141,6 +141,10 @@ setInterval(function() {
|
|||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
function isEncryptionAvailable() {
|
||||||
|
return globalEncryptionKey !== null;
|
||||||
|
}
|
||||||
|
|
||||||
function getAes() {
|
function getAes() {
|
||||||
globalLastEncryptionOperationDate = new Date();
|
globalLastEncryptionOperationDate = new Date();
|
||||||
|
|
||||||
|
@ -101,23 +101,32 @@ function createNewTopLevelNote() {
|
|||||||
|
|
||||||
let newNoteCreated = false;
|
let newNoteCreated = false;
|
||||||
|
|
||||||
function createNote(node, parentKey, target) {
|
function createNote(node, parentKey, target, encryption) {
|
||||||
let newNoteName = "new note";
|
// if encryption isn't available (user didn't enter password yet), then note is created as unencrypted
|
||||||
|
// but this is quite weird since user doesn't see where the note is being created so it shouldn't occur often
|
||||||
|
if (!encryption || !isEncryptionAvailable()) {
|
||||||
|
encryption = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newNoteName = "new note";
|
||||||
|
const newNoteNameEncryptedIfNecessary = encryption > 0 ? encryptString(newNoteName) : newNoteName;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + 'notes/' + parentKey + '/children' ,
|
url: baseUrl + 'notes/' + parentKey + '/children' ,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
note_title: newNoteName,
|
note_title: newNoteNameEncryptedIfNecessary,
|
||||||
target: target,
|
target: target,
|
||||||
target_note_id: node.key
|
target_note_id: node.key,
|
||||||
|
encryption: encryption
|
||||||
}),
|
}),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
let newNode = {
|
let newNode = {
|
||||||
"title": newNoteName,
|
title: newNoteName,
|
||||||
"key": result.note_id,
|
key: result.note_id,
|
||||||
"note_id": result.note_id
|
note_id: result.note_id,
|
||||||
|
encryption: encryption
|
||||||
};
|
};
|
||||||
|
|
||||||
globalAllNoteIds.push(result.note_id);
|
globalAllNoteIds.push(result.note_id);
|
||||||
|
@ -70,14 +70,19 @@ function getParentKey(node) {
|
|||||||
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key;
|
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParentEncryption(node) {
|
||||||
|
return node.getParent() === null ? 0 : node.getParent().data.encryption;
|
||||||
|
}
|
||||||
|
|
||||||
const keybindings = {
|
const keybindings = {
|
||||||
"insert": function(node) {
|
"insert": function(node) {
|
||||||
const parentKey = getParentKey(node);
|
const parentKey = getParentKey(node);
|
||||||
|
const encryption = getParentEncryption(node);
|
||||||
|
|
||||||
createNote(node, parentKey, 'after');
|
createNote(node, parentKey, 'after', encryption);
|
||||||
},
|
},
|
||||||
"ctrl+insert": function(node) {
|
"ctrl+insert": function(node) {
|
||||||
createNote(node, node.key, 'into');
|
createNote(node, node.key, 'into', node.data.encryption);
|
||||||
},
|
},
|
||||||
"del": function(node) {
|
"del": function(node) {
|
||||||
deleteNode(node);
|
deleteNode(node);
|
||||||
@ -329,9 +334,10 @@ $(function(){
|
|||||||
const node = $.ui.fancytree.getNode(ui.target);
|
const node = $.ui.fancytree.getNode(ui.target);
|
||||||
|
|
||||||
if (ui.cmd === "insertNoteHere") {
|
if (ui.cmd === "insertNoteHere") {
|
||||||
const parentKey = getParentKey(node);
|
const parentKey = getParentKey(node);
|
||||||
|
const encryption = getParentEncryption(node);
|
||||||
|
|
||||||
createNote(node, parentKey, 'after');
|
createNote(node, parentKey, 'after', encryption);
|
||||||
}
|
}
|
||||||
else if (ui.cmd === "insertChildNote") {
|
else if (ui.cmd === "insertChildNote") {
|
||||||
createNote(node, node.key, 'into');
|
createNote(node, node.key, 'into');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user