Merge remote-tracking branch 'origin/stable' into redesign

# Conflicts:
#	package-lock.json
#	package.json
This commit is contained in:
zadam
2021-05-26 21:27:06 +02:00
7 changed files with 26 additions and 8 deletions

View File

@@ -7,7 +7,13 @@ const {LOG_DIR} = require('../../services/data_dir.js');
function getBackendLog() {
const file = `${LOG_DIR}/trilium-${dateUtils.localNowDate()}.log`;
return fs.readFileSync(file, 'utf8');
try {
return fs.readFileSync(file, 'utf8');
}
catch (e) {
// most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
return "";
}
}
module.exports = {

View File

@@ -11,7 +11,7 @@ function sanitize(dirtyHtml) {
'figure', 'span', 'label', 'input'
],
allowedAttributes: {
'a': [ 'href', 'class' ],
'a': [ 'href', 'class', 'data-note-path' ],
'img': [ 'src' ],
'section': [ 'class', 'data-note-id' ],
'figure': [ 'class' ],

View File

@@ -307,6 +307,14 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
return `href="#root/${targetNoteId}"`;
});
content = content.replace(/data-note-path="([^"]*)"/g, (match, notePath) => {
const noteId = notePath.split("/").pop();
const targetNoteId = noteIdMap[noteId];
return `data-note-path="root/${targetNoteId}"`;
});
if (noteMeta) {
const includeNoteLinks = (noteMeta.attributes || [])
.filter(attr => attr.type === 'relation' && attr.name === 'includeNoteLink');

View File

@@ -41,13 +41,17 @@ function initLogFile() {
function checkDate(millisSinceMidnight) {
if (millisSinceMidnight >= DAY) {
initLogFile();
millisSinceMidnight =- DAY;
}
return millisSinceMidnight;
}
function log(str) {
const millisSinceMidnight = Date.now() - todaysMidnight.getTime();
let millisSinceMidnight = Date.now() - todaysMidnight.getTime();
checkDate(millisSinceMidnight);
millisSinceMidnight = checkDate(millisSinceMidnight);
logFile.write(formatTime(millisSinceMidnight) + ' ' + str + NEW_LINE);