mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6046efa1b | ||
|
|
ee608fcf46 | ||
|
|
894b08a1b8 | ||
|
|
4e549baedc | ||
|
|
6b6e42e9ba | ||
|
|
0404b78fb8 | ||
|
|
439743d2b0 | ||
|
|
0ac397e7ff | ||
|
|
d243880099 | ||
|
|
2e23c521c3 | ||
|
|
eb761b286f | ||
|
|
d0f6ff5f98 |
19
package-lock.json
generated
19
package-lock.json
generated
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.62.2",
|
"version": "0.62.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.62.2",
|
"name": "trilium",
|
||||||
|
"version": "0.62.4",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -80,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.5",
|
"electron": "25.9.8",
|
||||||
"electron-builder": "24.6.4",
|
"electron-builder": "24.6.4",
|
||||||
"electron-packager": "17.1.2",
|
"electron-packager": "17.1.2",
|
||||||
"electron-rebuild": "3.2.9",
|
"electron-rebuild": "3.2.9",
|
||||||
@@ -4365,9 +4366,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron": {
|
"node_modules/electron": {
|
||||||
"version": "25.9.5",
|
"version": "25.9.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
|
||||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/get": "^2.0.0",
|
"@electron/get": "^2.0.0",
|
||||||
@@ -16963,9 +16964,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "25.9.5",
|
"version": "25.9.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
|
||||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^2.0.0",
|
"@electron/get": "^2.0.0",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"productName": "Trilium Notes",
|
"productName": "Trilium Notes",
|
||||||
"description": "Trilium Notes",
|
"description": "Trilium Notes",
|
||||||
"version": "0.62.3",
|
"version": "0.62.5",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"main": "electron.js",
|
"main": "electron.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.5",
|
"electron": "25.9.8",
|
||||||
"electron-builder": "24.6.4",
|
"electron-builder": "24.6.4",
|
||||||
"electron-packager": "17.1.2",
|
"electron-packager": "17.1.2",
|
||||||
"electron-rebuild": "3.2.9",
|
"electron-rebuild": "3.2.9",
|
||||||
|
|||||||
@@ -427,6 +427,116 @@ paths:
|
|||||||
application/json; charset=utf-8:
|
application/json; charset=utf-8:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$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:
|
/attributes:
|
||||||
post:
|
post:
|
||||||
description: create an attribute for a given note
|
description: create an attribute for a given note
|
||||||
@@ -474,7 +584,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
patch:
|
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
|
operationId: patchAttributeById
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
@@ -496,7 +606,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
delete:
|
delete:
|
||||||
description: deletes a attribute based on the attributeId supplied.
|
description: deletes an attribute based on the attributeId supplied.
|
||||||
operationId: deleteAttributeById
|
operationId: deleteAttributeById
|
||||||
responses:
|
responses:
|
||||||
'204':
|
'204':
|
||||||
@@ -884,6 +994,57 @@ components:
|
|||||||
$ref: '#/components/schemas/Note'
|
$ref: '#/components/schemas/Note'
|
||||||
branch:
|
branch:
|
||||||
$ref: '#/components/schemas/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:
|
Attribute:
|
||||||
type: object
|
type: object
|
||||||
description: Attribute (Label, Relation) is a key-value record attached to a note.
|
description: Attribute (Label, Relation) is a key-value record attached to a note.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const cls = require('../../services/cls');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const becca = require("../../becca/becca");
|
const becca = require("../../becca/becca");
|
||||||
const blobService = require("../../services/blob");
|
const blobService = require("../../services/blob");
|
||||||
|
const eraseService = require("../../services/erase.js");
|
||||||
|
|
||||||
function getRevisionBlob(req) {
|
function getRevisionBlob(req) {
|
||||||
const preview = req.query.preview === 'true';
|
const preview = req.query.preview === 'true';
|
||||||
@@ -88,11 +89,11 @@ function eraseAllRevisions(req) {
|
|||||||
const revisionIdsToErase = sql.getColumn('SELECT revisionId FROM revisions WHERE noteId = ?',
|
const revisionIdsToErase = sql.getColumn('SELECT revisionId FROM revisions WHERE noteId = ?',
|
||||||
[req.params.noteId]);
|
[req.params.noteId]);
|
||||||
|
|
||||||
revisionService.eraseRevisions(revisionIdsToErase);
|
eraseService.eraseRevisions(revisionIdsToErase);
|
||||||
}
|
}
|
||||||
|
|
||||||
function eraseRevision(req) {
|
function eraseRevision(req) {
|
||||||
revisionService.eraseRevisions([req.params.revisionId]);
|
eraseService.eraseRevisions([req.params.revisionId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreRevision(req) {
|
function restoreRevision(req) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module.exports = { buildDate:"2023-11-27T23:37:24+01:00", buildRevision: "a6036859b8bd24be31dfcf6318e57cf696fa25bc" };
|
module.exports = { buildDate:"2024-01-08T00:05:13+01:00", buildRevision: "ee608fcf46a2052f21d94a8a72fc023dcaf955f7" };
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const becca = require("../becca/becca");
|
|||||||
const cloningService = require("./cloning");
|
const cloningService = require("./cloning");
|
||||||
const branchService = require("./branches");
|
const branchService = require("./branches");
|
||||||
const utils = require("./utils");
|
const utils = require("./utils");
|
||||||
|
const eraseService = require("./erase.js");
|
||||||
|
|
||||||
const ACTION_HANDLERS = {
|
const ACTION_HANDLERS = {
|
||||||
addLabel: (action, note) => {
|
addLabel: (action, note) => {
|
||||||
@@ -18,7 +19,7 @@ const ACTION_HANDLERS = {
|
|||||||
note.deleteNote(deleteId);
|
note.deleteNote(deleteId);
|
||||||
},
|
},
|
||||||
deleteRevisions: (action, note) => {
|
deleteRevisions: (action, note) => {
|
||||||
revisionService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
|
eraseService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
|
||||||
},
|
},
|
||||||
deleteLabel: (action, note) => {
|
deleteLabel: (action, note) => {
|
||||||
for (const label of note.getOwnedLabels(action.labelName)) {
|
for (const label of note.getOwnedLabels(action.labelName)) {
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ class ConsistencyChecks {
|
|||||||
WHERE blobs.blobId IS NULL`,
|
WHERE blobs.blobId IS NULL`,
|
||||||
({revisionId, blobId}) => {
|
({revisionId, blobId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
revisionService.eraseRevisions([revisionId]);
|
eraseService.eraseRevisions([revisionId]);
|
||||||
|
|
||||||
this.reloadNeeded = true;
|
this.reloadNeeded = true;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function eraseNotes(noteIdsToErase) {
|
|||||||
const revisionIdsToErase = sql.getManyRows(`SELECT revisionId FROM revisions WHERE noteId IN (???)`, noteIdsToErase)
|
const revisionIdsToErase = sql.getManyRows(`SELECT revisionId FROM revisions WHERE noteId IN (???)`, noteIdsToErase)
|
||||||
.map(row => row.revisionId);
|
.map(row => row.revisionId);
|
||||||
|
|
||||||
revisionService.eraseRevisions(revisionIdsToErase);
|
eraseRevisions(revisionIdsToErase);
|
||||||
|
|
||||||
log.info(`Erased notes: ${JSON.stringify(noteIdsToErase)}`);
|
log.info(`Erased notes: ${JSON.stringify(noteIdsToErase)}`);
|
||||||
}
|
}
|
||||||
@@ -79,6 +79,18 @@ function eraseAttachments(attachmentIdsToErase) {
|
|||||||
log.info(`Erased attachments: ${JSON.stringify(attachmentIdsToErase)}`);
|
log.info(`Erased attachments: ${JSON.stringify(attachmentIdsToErase)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function eraseRevisions(revisionIdsToErase) {
|
||||||
|
if (revisionIdsToErase.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
|
||||||
|
|
||||||
|
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase));
|
||||||
|
|
||||||
|
log.info(`Removed revisions: ${JSON.stringify(revisionIdsToErase)}`);
|
||||||
|
}
|
||||||
|
|
||||||
function eraseUnusedBlobs() {
|
function eraseUnusedBlobs() {
|
||||||
const unusedBlobIds = sql.getColumn(`
|
const unusedBlobIds = sql.getColumn(`
|
||||||
SELECT blobs.blobId
|
SELECT blobs.blobId
|
||||||
@@ -184,5 +196,6 @@ module.exports = {
|
|||||||
eraseUnusedAttachmentsNow,
|
eraseUnusedAttachmentsNow,
|
||||||
eraseNotesWithDeleteId,
|
eraseNotesWithDeleteId,
|
||||||
eraseUnusedBlobs,
|
eraseUnusedBlobs,
|
||||||
eraseAttachments
|
eraseAttachments,
|
||||||
|
eraseRevisions
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ async function downloadImage(noteId, imageUrl) {
|
|||||||
const title = path.basename(parsedUrl.pathname);
|
const title = path.basename(parsedUrl.pathname);
|
||||||
|
|
||||||
const imageService = require('../services/image');
|
const imageService = require('../services/image');
|
||||||
const {attachment} = imageService.saveImageToAttachment(noteId, imageBuffer, title, true, true);
|
const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, title, true, true);
|
||||||
|
|
||||||
imageUrlToAttachmentIdMapping[imageUrl] = attachment.attachmentId;
|
imageUrlToAttachmentIdMapping[imageUrl] = attachment.attachmentId;
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ const downloadImagePromises = {};
|
|||||||
function replaceUrl(content, url, attachment) {
|
function replaceUrl(content, url, attachment) {
|
||||||
const quotedUrl = utils.quoteRegex(url);
|
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) {
|
function downloadImages(noteId, content) {
|
||||||
@@ -519,7 +519,7 @@ function downloadImages(noteId, content) {
|
|||||||
let imageMatch;
|
let imageMatch;
|
||||||
|
|
||||||
while (imageMatch = imageRe.exec(content)) {
|
while (imageMatch = imageRe.exec(content)) {
|
||||||
const url = imageMatch[1];
|
let url = imageMatch[1];
|
||||||
const inlineImageMatch = /^data:image\/[a-z]+;base64,/.exec(url);
|
const inlineImageMatch = /^data:image\/[a-z]+;base64,/.exec(url);
|
||||||
|
|
||||||
if (inlineImageMatch) {
|
if (inlineImageMatch) {
|
||||||
@@ -541,6 +541,8 @@ function downloadImages(noteId, content) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url = utils.unescapeHtml(url);
|
||||||
|
|
||||||
if (url in imageUrlToAttachmentIdMapping) {
|
if (url in imageUrlToAttachmentIdMapping) {
|
||||||
const attachment = becca.getAttachment(imageUrlToAttachmentIdMapping[url]);
|
const attachment = becca.getAttachment(imageUrlToAttachmentIdMapping[url]);
|
||||||
|
|
||||||
@@ -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)}`;
|
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;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,18 +46,6 @@ function protectRevisions(note) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function eraseRevisions(revisionIdsToErase) {
|
|
||||||
if (revisionIdsToErase.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info(`Removing revisions: ${JSON.stringify(revisionIdsToErase)}`);
|
|
||||||
|
|
||||||
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
|
|
||||||
sql.executeMany(`UPDATE entity_changes SET isErased = 1, utcDateChanged = '${dateUtils.utcNowDateTime()}' WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
protectRevisions,
|
protectRevisions
|
||||||
eraseRevisions
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -209,8 +209,9 @@ function sortNotesIfNeeded(parentNoteId) {
|
|||||||
function setNoteToParent(noteId, prefix, parentNoteId) {
|
function setNoteToParent(noteId, prefix, parentNoteId) {
|
||||||
const parentNote = becca.getNote(parentNoteId);
|
const parentNote = becca.getNote(parentNoteId);
|
||||||
|
|
||||||
if (!parentNote) {
|
if (parentNoteId && !parentNote) {
|
||||||
throw new Error(`Cannot move note to deleted parent note '${parentNoteId}'`);
|
// null parentNoteId is a valid value
|
||||||
|
throw new Error(`Cannot move note to deleted / missing parent note '${parentNoteId}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// case where there might be more such branches is ignored. It's expected there should be just one
|
// case where there might be more such branches is ignored. It's expected there should be just one
|
||||||
|
|||||||
@@ -105,10 +105,10 @@ function renderText(result, note) {
|
|||||||
|
|
||||||
if (result.content.includes(`<span class="math-tex">`)) {
|
if (result.content.includes(`<span class="math-tex">`)) {
|
||||||
result.header += `
|
result.header += `
|
||||||
<script src="../../${assetPath}/libraries/katex/katex.min.js"></script>
|
<script src="../../${assetPath}/node_modules/katex/dist/katex.min.js"></script>
|
||||||
<link rel="stylesheet" href="../../${assetPath}/libraries/katex/katex.min.css">
|
<link rel="stylesheet" href="../../${assetPath}/node_modules/katex/dist/katex.min.css">
|
||||||
<script src="../../${assetPath}/libraries/katex/auto-render.min.js"></script>
|
<script src="../../${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js"></script>
|
||||||
<script src="../../${assetPath}/libraries/katex/mhchem.min.js"></script>
|
<script src="../../${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
renderMathInElement(document.getElementById('content'));
|
renderMathInElement(document.getElementById('content'));
|
||||||
|
|||||||
Reference in New Issue
Block a user