mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
Compare commits
9 Commits
v0.40.0-be
...
v0.40.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
828cce0d78 | ||
|
|
ab535bf147 | ||
|
|
1876664dfb | ||
|
|
1690248e24 | ||
|
|
cbeb8ea17e | ||
|
|
c9113ae752 | ||
|
|
0ec11d29ba | ||
|
|
a6cd25071e | ||
|
|
20fdeee048 |
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@@ -2,4 +2,5 @@
|
||||
/workspace.xml
|
||||
|
||||
# Datasource local storage ignored files
|
||||
/dataSources.local.xml
|
||||
/dataSources.local.xml
|
||||
/dataSources/
|
||||
|
||||
1
db/migrations/0157__fix_contentLength.sql
Normal file
1
db/migrations/0157__fix_contentLength.sql
Normal file
@@ -0,0 +1 @@
|
||||
UPDATE notes SET contentLength = COALESCE((SELECT COALESCE(LENGTH(content), 0) FROM note_contents WHERE note_contents.noteId = notes.noteId), -1);
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.39.5",
|
||||
"version": "0.40.0-beta",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "trilium",
|
||||
"productName": "Trilium Notes",
|
||||
"description": "Trilium Notes",
|
||||
"version": "0.40.0-beta",
|
||||
"version": "0.40.1",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"bin": {
|
||||
|
||||
@@ -110,6 +110,10 @@ class Note extends Entity {
|
||||
async getJsonContent() {
|
||||
const content = await this.getContent();
|
||||
|
||||
if (!content || !content.trim()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
@@ -119,9 +123,11 @@ class Note extends Entity {
|
||||
throw new Error(`Cannot set null content to note ${this.noteId}`);
|
||||
}
|
||||
|
||||
content = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
||||
|
||||
// force updating note itself so that dateModified is represented correctly even for the content
|
||||
this.forcedChange = true;
|
||||
this.contentLength = content.length;
|
||||
this.contentLength = content.byteLength;
|
||||
await this.save();
|
||||
|
||||
this.content = content;
|
||||
@@ -130,7 +136,7 @@ class Note extends Entity {
|
||||
noteId: this.noteId,
|
||||
content: content,
|
||||
utcDateModified: dateUtils.utcNowDateTime(),
|
||||
hash: utils.hash(this.noteId + "|" + content)
|
||||
hash: utils.hash(this.noteId + "|" + content.toString())
|
||||
};
|
||||
|
||||
if (this.isProtected) {
|
||||
|
||||
@@ -241,7 +241,7 @@ function registerEntrypoints() {
|
||||
|
||||
d.showDialog(selectedOrActiveNodes);
|
||||
}));
|
||||
|
||||
|
||||
keyboardActionService.setGlobalActionHandler("CreateNoteIntoDayNote", async () => {
|
||||
const todayNote = await dateNoteService.getTodayNote();
|
||||
|
||||
@@ -288,6 +288,8 @@ function registerEntrypoints() {
|
||||
|
||||
searchNotesService.searchInSubtree(node.data.noteId);
|
||||
});
|
||||
|
||||
keyboardActionService.setGlobalActionHandler("CopyWithoutFormatting", utils.copySelectionToClipboard);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@@ -241,6 +241,13 @@ function getUrlForDownload(url) {
|
||||
}
|
||||
}
|
||||
|
||||
function copySelectionToClipboard() {
|
||||
const text = window.getSelection().toString();
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
reloadApp,
|
||||
parseDate,
|
||||
@@ -273,5 +280,6 @@ export default {
|
||||
isHtmlEmpty,
|
||||
clearBrowserCache,
|
||||
getUrlForDownload,
|
||||
normalizeShortcut
|
||||
normalizeShortcut,
|
||||
copySelectionToClipboard
|
||||
};
|
||||
@@ -29,8 +29,12 @@ async function searchFromNote(req) {
|
||||
return [404, `Note ${req.params.noteId} has not been found.`];
|
||||
}
|
||||
|
||||
if (note.isDeleted) {
|
||||
return [400, `Note ${req.params.noteId} is deleted.`];
|
||||
}
|
||||
|
||||
if (note.type !== 'search') {
|
||||
return [400, '`Note ${req.params.noteId} is not search note.`']
|
||||
return [400, `Note ${req.params.noteId} is not search note.`]
|
||||
}
|
||||
|
||||
const json = await note.getJsonContent();
|
||||
@@ -41,18 +45,28 @@ async function searchFromNote(req) {
|
||||
|
||||
let noteIds;
|
||||
|
||||
if (json.searchString.startsWith('=')) {
|
||||
const relationName = json.searchString.substr(1).trim();
|
||||
try {
|
||||
if (json.searchString.startsWith('=')) {
|
||||
const relationName = json.searchString.substr(1).trim();
|
||||
|
||||
noteIds = await searchFromRelation(note, relationName);
|
||||
noteIds = await searchFromRelation(note, relationName);
|
||||
} else {
|
||||
noteIds = await searchService.searchForNoteIds(json.searchString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
noteIds = await searchService.searchForNoteIds(json.searchString);
|
||||
catch (e) {
|
||||
log.error(`Search failed for note ${note.noteId}: ` + e.message + ": " + e.stack);
|
||||
|
||||
throw new Error("Search failed, see logs for details.");
|
||||
}
|
||||
|
||||
// we won't return search note's own noteId
|
||||
noteIds = noteIds.filter(noteId => noteId !== note.noteId);
|
||||
|
||||
if (noteIds.length > 200) {
|
||||
noteIds = noteIds.slice(0, 200);
|
||||
}
|
||||
|
||||
return noteIds.map(noteCacheService.getNotePath).filter(res => !!res);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const build = require('./build');
|
||||
const packageJson = require('../../package');
|
||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||
|
||||
const APP_DB_VERSION = 156;
|
||||
const APP_DB_VERSION = 157;
|
||||
const SYNC_VERSION = 14;
|
||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = { buildDate:"2020-01-11T09:54:31+01:00", buildRevision: "5e91b1b5e0fa04affbc1a5a43a874cadc382fe11" };
|
||||
module.exports = { buildDate:"2020-01-19T15:45:06+01:00", buildRevision: "ab535bf147edac113299f76f410ff88b2c06735b" };
|
||||
|
||||
@@ -40,7 +40,9 @@ async function getRootCalendarNote() {
|
||||
parentNoteId: 'root',
|
||||
title: 'Calendar',
|
||||
target: 'into',
|
||||
isProtected: false
|
||||
isProtected: false,
|
||||
type: 'text',
|
||||
content: ''
|
||||
})).note;
|
||||
|
||||
await attributeService.createLabel(rootNote.noteId, CALENDAR_ROOT_LABEL);
|
||||
|
||||
@@ -306,6 +306,10 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
{
|
||||
actionName: "ZoomIn",
|
||||
defaultShortcuts: ["CommandOrControl+="]
|
||||
},
|
||||
{
|
||||
actionName: "CopyWithoutFormatting",
|
||||
defaultShortcuts: ["CommandOrControl+Alt+C"]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -71,22 +71,36 @@ function sendMessageToAllClients(message) {
|
||||
}
|
||||
}
|
||||
|
||||
async function fillInAdditionalProperties(sync) {
|
||||
// fill in some extra data needed by the frontend
|
||||
if (sync.entityName === 'attributes') {
|
||||
sync.noteId = await sql.getValue(`SELECT noteId
|
||||
FROM attributes
|
||||
WHERE attributeId = ?`, [sync.entityId]);
|
||||
} else if (sync.entityName === 'note_revisions') {
|
||||
sync.noteId = await sql.getValue(`SELECT noteId
|
||||
FROM note_revisions
|
||||
WHERE noteRevisionId = ?`, [sync.entityId]);
|
||||
} else if (sync.entityName === 'branches') {
|
||||
const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId
|
||||
FROM branches
|
||||
WHERE branchId = ?`, [sync.entityId]);
|
||||
|
||||
sync.noteId = noteId;
|
||||
sync.parentNoteId = parentNoteId;
|
||||
}
|
||||
}
|
||||
|
||||
async function sendPing(client) {
|
||||
const syncData = require('./sync_table').getEntitySyncsNewerThan(lastAcceptedSyncIds[client.id]);
|
||||
|
||||
for (const sync of syncData) {
|
||||
// fill in some extra data needed by the frontend
|
||||
if (sync.entityName === 'attributes') {
|
||||
sync.noteId = await sql.getValue(`SELECT noteId FROM attributes WHERE attributeId = ?`, [sync.entityId]);
|
||||
try {
|
||||
await fillInAdditionalProperties(sync);
|
||||
}
|
||||
else if (sync.entityName === 'note_revisions') {
|
||||
sync.noteId = await sql.getValue(`SELECT noteId FROM note_revisions WHERE noteRevisionId = ?`, [sync.entityId]);
|
||||
}
|
||||
else if (sync.entityName === 'branches') {
|
||||
const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId FROM branches WHERE branchId = ?`, [sync.entityId]);
|
||||
|
||||
sync.noteId = noteId;
|
||||
sync.parentNoteId = parentNoteId;
|
||||
catch (e) {
|
||||
log.error("Could not fill additional properties for sync " + JSON.stringify(sync)
|
||||
+ " because of error: " + e.message + ": " + e.stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user