Merge remote-tracking branch 'origin/stable'

This commit is contained in:
zadam 2020-10-06 21:03:28 +02:00
commit 99f35b2588
18 changed files with 69 additions and 32 deletions

Binary file not shown.

View File

@ -3,13 +3,15 @@ const repository = require('../../src/services/repository');
module.exports = () => { module.exports = () => {
for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) { for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {
try { try {
let content = note.getContent(); let origContent = note.getContent();
content = content const newContent = origContent
.replace(/<h1/ig, "<h2") .replace(/<h1/ig, "<h2")
.replace(/<\/h1/ig, "</h2"); .replace(/<\/h1/ig, "</h2");
note.setContent(content); if (newContent !== origContent) {
note.setContent(newContent);
}
} }
catch (e) { catch (e) {
console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`); console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.44.4", "version": "0.44.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -3165,9 +3165,9 @@
} }
}, },
"electron": { "electron": {
"version": "9.3.1", "version": "9.3.2",
"resolved": "https://registry.npmjs.org/electron/-/electron-9.3.1.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-9.3.2.tgz",
"integrity": "sha512-DScrhqBT4a54KfdF0EoipALpHmdQTn3m7SSCtbpTcEcG+UDUiXad2cOfW6DHeVH7N+CVDKDG12q2PhVJjXkFAA==", "integrity": "sha512-0lleEf9msAXGDi2GukAuiGdw3VDgSTlONOnJgqDEz1fuSEVsXz5RX+hNPKDsVDerLTFg/C34RuJf4LwHvkKcBA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",

View File

@ -2,7 +2,7 @@
"name": "trilium", "name": "trilium",
"productName": "Trilium Notes", "productName": "Trilium Notes",
"description": "Trilium Notes", "description": "Trilium Notes",
"version": "0.44.4", "version": "0.44.5",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"main": "electron.js", "main": "electron.js",
"bin": { "bin": {
@ -76,7 +76,7 @@
}, },
"devDependencies": { "devDependencies": {
"cross-env": "7.0.2", "cross-env": "7.0.2",
"electron": "9.3.1", "electron": "9.3.2",
"electron-builder": "22.8.1", "electron-builder": "22.8.1",
"electron-packager": "15.1.0", "electron-packager": "15.1.0",
"electron-rebuild": "2.0.3", "electron-rebuild": "2.0.3",

View File

@ -21,12 +21,7 @@ app.set('view engine', 'ejs');
app.use(helmet({ app.use(helmet({
hidePoweredBy: false, // deactivated because electron 4.0 crashes on this right after startup hidePoweredBy: false, // deactivated because electron 4.0 crashes on this right after startup
contentSecurityPolicy: { contentSecurityPolicy: false
directives: {
defaultSrc: ["*", "'unsafe-inline'", "'unsafe-eval'"],
imgSrc: ["'self' data:"]
}
}
})); }));
app.use(bodyParser.json({limit: '500mb'})); app.use(bodyParser.json({limit: '500mb'}));

View File

@ -67,6 +67,9 @@ function showRecentNotes($el) {
function initNoteAutocomplete($el, options) { function initNoteAutocomplete($el, options) {
if ($el.hasClass("note-autocomplete-input") || utils.isMobile()) { if ($el.hasClass("note-autocomplete-input") || utils.isMobile()) {
// clear any event listener added in previous invocation of this function
$el.off('autocomplete:noteselected');
return $el; return $el;
} }
@ -157,6 +160,9 @@ function initNoteAutocomplete($el, options) {
} }
}); });
// clear any event listener added in previous invocation of this function
$el.off('autocomplete:noteselected');
return $el; return $el;
} }

View File

@ -38,6 +38,10 @@ const TPL = `
cursor: text !important; cursor: text !important;
} }
.note-detail-editable-text *:first-child {
margin-top: 0 !important;
}
.note-detail-editable-text h1 { font-size: 2.0em; } .note-detail-editable-text h1 { font-size: 2.0em; }
.note-detail-editable-text h2 { font-size: 1.8em; } .note-detail-editable-text h2 { font-size: 1.8em; }
.note-detail-editable-text h3 { font-size: 1.6em; } .note-detail-editable-text h3 { font-size: 1.6em; }
@ -59,10 +63,6 @@ const TPL = `
/* This is because with empty content height of editor is 0 and it's impossible to click into it */ /* This is because with empty content height of editor is 0 and it's impossible to click into it */
min-height: 500px; min-height: 500px;
} }
.note-detail-editable-text p:first-child, .note-detail-editable-text::before {
margin-top: 0;
}
</style> </style>
<div class="note-detail-editable-text-editor" tabindex="300"></div> <div class="note-detail-editable-text-editor" tabindex="300"></div>

View File

@ -768,7 +768,7 @@ body {
#context-menu-container, #context-menu-container .dropdown-menu { #context-menu-container, #context-menu-container .dropdown-menu {
padding: 3px 0 0; padding: 3px 0 0;
z-index: 1000; z-index: 2000;
} }
#context-menu-container .dropdown-item { #context-menu-container .dropdown-item {

View File

@ -71,8 +71,17 @@ function getTree(req) {
JOIN treeWithDescendantsAndAscendants ON branches.noteId = treeWithDescendantsAndAscendants.noteId JOIN treeWithDescendantsAndAscendants ON branches.noteId = treeWithDescendantsAndAscendants.noteId
WHERE branches.isDeleted = 0 WHERE branches.isDeleted = 0
AND branches.parentNoteId != ? AND branches.parentNoteId != ?
),
treeWithDescendantsAscendantsAndTemplates AS (
SELECT noteId FROM treeWithDescendantsAndAscendants
UNION
SELECT attributes.value FROM attributes
JOIN treeWithDescendantsAscendantsAndTemplates ON attributes.noteId = treeWithDescendantsAscendantsAndTemplates.noteId
WHERE attributes.isDeleted = 0
AND attributes.type = 'relation'
AND attributes.name = 'template'
) )
SELECT noteId FROM treeWithDescendantsAndAscendants`, [subTreeNoteId, subTreeNoteId]); SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);
noteIds.push(subTreeNoteId); noteIds.push(subTreeNoteId);

View File

@ -109,7 +109,16 @@ function getAttributeNames(type, nameLike) {
} }
} }
names.sort(); names.sort((a, b) => {
const aPrefix = a.toLowerCase().startsWith(nameLike);
const bPrefix = b.toLowerCase().startsWith(nameLike);
if (aPrefix !== bPrefix) {
return aPrefix ? -1 : 1;
}
return a < b ? -1 : 1;
});
return names; return names;
} }

View File

@ -1 +1 @@
module.exports = { buildDate:"2020-09-24T23:33:36+02:00", buildRevision: "748979eafd44704af42df54f4195d118dec891ae" }; module.exports = { buildDate:"2020-10-01T23:45:09+02:00", buildRevision: "8f018cc7c69257bbd11590e41e267872e19d7bb6" };

View File

@ -12,9 +12,11 @@ const RecentNote = require('../entities/recent_note');
const Option = require('../entities/option'); const Option = require('../entities/option');
function getSectorHashes(tableName, primaryKeyName, whereBranch) { function getSectorHashes(tableName, primaryKeyName, whereBranch) {
const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName} ` const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName}`
+ (whereBranch ? `WHERE ${whereBranch} ` : '') + (whereBranch ? ` WHERE ${whereBranch} ` : ''));
+ ` ORDER BY ${primaryKeyName}`);
// sorting is faster in memory
hashes.sort((a, b) => a.id < b.id ? -1 : 1);
const map = {}; const map = {};

View File

@ -229,6 +229,7 @@ function exportToZip(taskContext, branch, format, res) {
content = `<html> content = `<html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="${cssUrl}"> <link rel="stylesheet" href="${cssUrl}">
</head> </head>
<body> <body>
@ -356,6 +357,7 @@ ${content}
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
<frameset cols="25%,75%"> <frameset cols="25%,75%">
<frame name="navigation" src="navigation.html"> <frame name="navigation" src="navigation.html">

View File

@ -402,7 +402,13 @@ for (const action of DEFAULT_KEYBOARD_ACTIONS) {
} }
} }
let cachedActions = null;
function getKeyboardActions() { function getKeyboardActions() {
if (cachedActions) {
return cachedActions;
}
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
for (const action of actions) { for (const action of actions) {
@ -430,6 +436,8 @@ function getKeyboardActions() {
} }
} }
cachedActions = actions;
return actions; return actions;
} }

View File

@ -49,6 +49,10 @@ function isInAncestor(noteId, ancestorNoteId) {
const note = noteCache.notes[noteId]; const note = noteCache.notes[noteId];
if (!note) {
return false;
}
for (const parentNote of note.parents) { for (const parentNote of note.parents) {
if (isInAncestor(parentNote.noteId, ancestorNoteId)) { if (isInAncestor(parentNote.noteId, ancestorNoteId)) {
return true; return true;

View File

@ -23,17 +23,17 @@ function protectNoteRevisions(note) {
/** /**
* @param {Note} note * @param {Note} note
* @return {NoteRevision} * @return {NoteRevision|null}
*/ */
function createNoteRevision(note) { function createNoteRevision(note) {
if (note.hasLabel("disableVersioning")) { if (note.hasLabel("disableVersioning")) {
return; return null;
} }
const content = note.getContent(); const content = note.getContent();
if (!content) { if (!content || (Buffer.isBuffer(content) && content.byteLength === 0)) {
return; return null;
} }
const contentMetadata = note.getContentMetadata(); const contentMetadata = note.getContentMetadata();