Merge branch 'zadam:master' into master

This commit is contained in:
ngala 2024-01-14 23:23:27 +05:30 committed by GitHub
commit 71c3b988fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 219 additions and 46 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "trilium",
"version": "0.62.4",
"version": "0.62.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trilium",
"version": "0.62.4",
"version": "0.62.5",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
@ -89,7 +89,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "28.1.0",
"electron": "25.9.8",
"electron-builder": "24.9.1",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",
@ -5008,9 +5008,9 @@
}
},
"node_modules/electron": {
"version": "28.1.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-28.1.0.tgz",
"integrity": "sha512-82Y7o4PSWPn1o/aVwYPsgmBw6Gyf2lVHpaBu3Ef8LrLWXxytg7ZRZr/RtDqEMOzQp3+mcuy3huH84MyjdmP50Q==",
"version": "25.9.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
"hasInstallScript": true,
"dependencies": {
"@electron/get": "^2.0.0",
@ -18916,9 +18916,9 @@
}
},
"electron": {
"version": "28.1.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-28.1.0.tgz",
"integrity": "sha512-82Y7o4PSWPn1o/aVwYPsgmBw6Gyf2lVHpaBu3Ef8LrLWXxytg7ZRZr/RtDqEMOzQp3+mcuy3huH84MyjdmP50Q==",
"version": "25.9.8",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
"requires": {
"@electron/get": "^2.0.0",
"@types/node": "^18.11.18",

View File

@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.63.0-beta",
"version": "0.63.1-beta",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {
@ -37,11 +37,11 @@
},
"dependencies": {
"@braintree/sanitize-url": "6.0.4",
"@electron/remote": "2.1.1",
"@electron/remote": "2.1.0",
"@excalidraw/excalidraw": "0.16.1",
"archiver": "6.0.1",
"async-mutex": "0.4.0",
"axios": "1.6.3",
"axios": "1.6.2",
"better-sqlite3": "8.4.0",
"boxicons": "2.1.4",
"chokidar": "3.5.3",
@ -59,10 +59,10 @@
"escape-html": "1.0.3",
"express": "4.18.2",
"express-partial-content": "1.0.2",
"express-rate-limit": "7.1.5",
"express-rate-limit": "7.1.4",
"express-session": "1.17.3",
"force-graph": "1.43.4",
"fs-extra": "11.2.0",
"fs-extra": "11.1.1",
"helmet": "7.1.0",
"html": "1.0.0",
"html2plaintext": "2.1.4",
@ -76,13 +76,13 @@
"joplin-turndown-plugin-gfm": "1.0.12",
"jquery": "3.7.1",
"jquery-hotkeys": "0.2.2",
"jsdom": "23.0.1",
"jsdom": "22.1.0",
"katex": "0.16.9",
"marked": "9.1.6",
"mermaid": "10.6.1",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.52.0",
"node-abi": "3.51.0",
"normalize-strings": "1.1.1",
"open": "8.4.1",
"panzoom": "9.4.3",
@ -106,31 +106,31 @@
"tree-kill": "1.2.2",
"turndown": "7.1.2",
"unescape": "1.0.1",
"ws": "8.16.0",
"ws": "8.14.2",
"xml2js": "0.6.2",
"yauzl": "2.10.0"
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.9.8",
"electron-builder": "24.9.1",
"electron-builder": "24.6.4",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",
"eslint": "8.56.0",
"eslint": "8.54.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsonc": "2.11.2",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsonc": "2.10.0",
"eslint-plugin-prettier": "5.0.1",
"esm": "3.2.25",
"husky": "8.0.3",
"jasmine": "5.1.0",
"jsdoc": "4.0.2",
"jsonc-eslint-parser": "2.4.0",
"lint-staged": "15.2.0",
"lint-staged": "15.1.0",
"lorem-ipsum": "2.0.8",
"nodemon": "3.0.2",
"prettier": "3.1.1",
"nodemon": "3.0.1",
"prettier": "3.1.0",
"rcedit": "4.0.1",
"webpack": "5.89.0",
"webpack-cli": "5.1.4"

View File

@ -427,6 +427,116 @@ paths:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Error'
/attachments:
post:
description: create an attachment
operationId: postAttachment
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAttachment'
responses:
'201':
description: attachment created
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Attachment'
default:
description: unexpected error
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Error'
/attachments/{attachmentId}:
parameters:
- name: attachmentId
in: path
required: true
schema:
$ref: '#/components/schemas/EntityId'
get:
description: Returns an attachment identified by its ID
operationId: getAttachmentById
responses:
'200':
description: attachment response
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Attachment'
default:
description: unexpected error
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Error'
patch:
description: patch an attachment identified by the attachmentId with changes in the body. Only role, mime, title, and position are patchable.
operationId: patchAttachmentById
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Attachment'
responses:
'200':
description: attribute updated
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Attachment'
default:
description: unexpected error
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Error'
delete:
description: deletes an attachment based on the attachmentId supplied.
operationId: deleteAttachmentById
responses:
'204':
description: attachment deleted
default:
description: unexpected error
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Error'
/attachments/{attachmentId}/content:
parameters:
- name: attachmentId
in: path
required: true
schema:
$ref: '#/components/schemas/EntityId'
get:
description: Returns attachment content identified by its ID
operationId: getAttachmentContent
responses:
'200':
description: attachment content response
content:
text/html:
schema:
type: string
put:
description: Updates attachment content identified by its ID
operationId: putAttachmentContentById
requestBody:
description: html content of attachment
required: true
content:
text/plain:
schema:
type: string
responses:
'204':
description: attachment content updated
/attributes:
post:
description: create an attribute for a given note
@ -474,7 +584,7 @@ paths:
schema:
$ref: '#/components/schemas/Error'
patch:
description: patch a attribute identified by the attributeId with changes in the body. For labels, only value and position can be updated. For relations, only position can be updated. If you want to modify other properties, you need to delete the old attribute and create a new one.
description: patch an attribute identified by the attributeId with changes in the body. For labels, only value and position can be updated. For relations, only position can be updated. If you want to modify other properties, you need to delete the old attribute and create a new one.
operationId: patchAttributeById
requestBody:
required: true
@ -496,7 +606,7 @@ paths:
schema:
$ref: '#/components/schemas/Error'
delete:
description: deletes a attribute based on the attributeId supplied.
description: deletes an attribute based on the attributeId supplied.
operationId: deleteAttributeById
responses:
'204':
@ -884,6 +994,57 @@ components:
$ref: '#/components/schemas/Note'
branch:
$ref: '#/components/schemas/Branch'
Attachment:
type: object
description: Attachment is owned by a note, has title and content
properties:
attachmentId:
$ref: '#/components/schemas/EntityId'
readOnly: true
ownerId:
$ref: '#/components/schemas/EntityId'
description: identifies the owner of the attachment, is either noteId or revisionId
role:
type: string
mime:
type: string
title:
type: string
position:
type: integer
format: int32
blobId:
type: string
description: ID of the blob object which effectively serves as a content hash
dateModified:
$ref: '#/components/schemas/LocalDateTime'
readOnly: true
utcDateModified:
$ref: '#/components/schemas/UtcDateTime'
readOnly: true
utcDateScheduledForErasureSince:
$ref: '#/components/schemas/UtcDateTime'
readOnly: true
contentLength:
type: integer
format: int32
CreateAttachment:
type: object
properties:
ownerId:
$ref: '#/components/schemas/EntityId'
description: identifies the owner of the attachment, is either noteId or revisionId
role:
type: string
mime:
type: string
title:
type: string
content:
type: string
position:
type: integer
format: int32
Attribute:
type: object
description: Attribute (Label, Relation) is a key-value record attached to a note.

View File

@ -1 +1 @@
module.exports = { buildDate:"2024-01-04T00:49:06+01:00", buildRevision: "394530921e3f7ddd852fa4ceb1ac4585447df35e" };
module.exports = { buildDate:"2024-01-12T00:02:50+01:00", buildRevision: "17e063f01d3b6c7a601630feaa96191d26095650" };

View File

@ -181,6 +181,8 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true)
noteIdToMeta[note.noteId] = meta;
// sort children for having a stable / reproducible export format
note.sortChildren();
const childBranches = note.getChildBranches()
.filter(branch => branch.noteId !== '_hidden');

View File

@ -219,7 +219,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "reopenLastTab",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [],
description: "Repoens the last closed tab",
description: "Reopens the last closed tab",
scope: "window"
},
{
@ -291,7 +291,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "eigthTab",
defaultShortcuts: ["CommandOrControl+8"],
description: "Activates the eigth tab in the list",
description: "Activates the eighth tab in the list",
scope: "window"
},
{
@ -302,7 +302,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
},
{
actionName: "lastTab",
defaultShortcuts: ["CommandOrControl+0"],
defaultShortcuts: [],
description: "Activates the last tab in the list",
scope: "window"
},

View File

@ -471,6 +471,8 @@ function findRelationMapLinks(content, foundLinks) {
const imageUrlToAttachmentIdMapping = {};
async function downloadImage(noteId, imageUrl) {
const unescapedUrl = utils.unescapeHtml(imageUrl);
try {
let imageBuffer;
@ -487,14 +489,14 @@ async function downloadImage(noteId, imageUrl) {
});
});
} else {
imageBuffer = await request.getImage(imageUrl);
imageBuffer = await request.getImage(unescapedUrl);
}
const parsedUrl = url.parse(imageUrl);
const parsedUrl = url.parse(unescapedUrl);
const title = path.basename(parsedUrl.pathname);
const imageService = require('../services/image.js');
const {attachment} = imageService.saveImageToAttachment(noteId, imageBuffer, title, true, true);
const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, title, true, true);
imageUrlToAttachmentIdMapping[imageUrl] = attachment.attachmentId;
@ -511,7 +513,7 @@ const downloadImagePromises = {};
function replaceUrl(content, url, attachment) {
const quotedUrl = utils.quoteRegex(url);
return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "ig"), ` src="api/attachments/${encodeURIComponent(attachment.title)}/image"`);
return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "ig"), ` src="api/attachments/${attachment.attachmentId}/image/${encodeURIComponent(attachment.title)}"`);
}
function downloadImages(noteId, content) {
@ -636,6 +638,10 @@ function saveAttachments(note, content) {
content = `${content.substr(0, attachmentMatch.index)}<a class="reference-link" href="#root/${note.noteId}?viewMode=attachments&attachmentId=${attachment.attachmentId}">${title}</a>${content.substr(attachmentMatch.index + attachmentMatch[0].length)}`;
}
// removing absolute references to server to keep it working between instances,
// we also omit / at the beginning to keep the paths relative
content = content.replace(/src="[^"]*\/api\/attachments\//g, 'src="api/attachments/');
return content;
}

View File

@ -73,7 +73,6 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId, updateContext
if (localEC?.isErased) {
eraseEntity(remoteEC); // make sure it's erased anyway
updateContext.alreadyErased++;
return false; // we won't save entitychange in this case
} else {
eraseEntity(remoteEC);
updateContext.erased++;
@ -91,7 +90,8 @@ function updateNormalEntity(remoteEC, remoteEntityRow, instanceId, updateContext
updateContext.updated[remoteEC.entityName].push(remoteEC.entityId);
}
if (!localEC || localEC.utcDateChanged < remoteEC.utcDateChanged
if (!localEC
|| localEC.utcDateChanged < remoteEC.utcDateChanged
|| localEC.hash !== remoteEC.hash
|| localEC.isErased !== remoteEC.isErased
) {

View File

@ -105,10 +105,10 @@ function renderText(result, note) {
if (result.content.includes(`<span class="math-tex">`)) {
result.header += `
<script src="../../${assetPath}/libraries/katex/katex.min.js"></script>
<link rel="stylesheet" href="../../${assetPath}/libraries/katex/katex.min.css">
<script src="../../${assetPath}/libraries/katex/auto-render.min.js"></script>
<script src="../../${assetPath}/libraries/katex/mhchem.min.js"></script>
<script src="../../${assetPath}/node_modules/katex/dist/katex.min.js"></script>
<link rel="stylesheet" href="../../${assetPath}/node_modules/katex/dist/katex.min.css">
<script src="../../${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js"></script>
<script src="../../${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.getElementById('content'));
@ -137,7 +137,7 @@ function renderCode(result) {
function renderMermaid(result, note) {
result.content = `
<img src="api/images/${note.noteId}/${note.escapedTitle}?${note.utcDateModified}">
<img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}">
<hr>
<details>
<summary>Chart source</summary>
@ -146,7 +146,7 @@ function renderMermaid(result, note) {
}
function renderImage(result, note) {
result.content = `<img src="api/images/${note.noteId}/${note.escapedTitle}?${note.utcDateModified}">`;
result.content = `<img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}">`;
}
function renderFile(note, result) {

View File

@ -490,6 +490,10 @@ class SNote extends AbstractShacaEntity {
return escape(this.title);
}
get encodedTitle() {
return encodeURIComponent(this.title);
}
getPojo() {
return {
noteId: this.noteId,