mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	Compare commits
	
		
			17 Commits
		
	
	
		
			v0.63.0-be
			...
			v0.62.6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | e76093e75c | ||
|  | 4f8073daa7 | ||
|  | 47fb96faa8 | ||
|  | 6e33553146 | ||
|  | 807941e6a5 | ||
|  | 1e30c0702e | ||
|  | 390ad6d813 | ||
|  | 77800d073f | ||
|  | 1953c7896f | ||
|  | cd43752f61 | ||
|  | d6046efa1b | ||
|  | ee608fcf46 | ||
|  | 894b08a1b8 | ||
|  | 4e549baedc | ||
|  | 6b6e42e9ba | ||
|  | 0404b78fb8 | ||
|  | 439743d2b0 | 
| @@ -8,3 +8,6 @@ CREATE TABLE IF NOT EXISTS "blobs" ( | ||||
|  | ||||
| ALTER TABLE notes ADD blobId TEXT DEFAULT NULL; | ||||
| ALTER TABLE note_revisions ADD blobId TEXT DEFAULT NULL; | ||||
|  | ||||
| CREATE INDEX IF NOT EXISTS IDX_notes_blobId on notes (blobId); | ||||
| CREATE INDEX IF NOT EXISTS IDX_note_revisions_blobId on note_revisions (blobId); | ||||
|   | ||||
| @@ -21,5 +21,6 @@ CREATE INDEX `IDX_revisions_utcDateCreated` ON `revisions` (`utcDateCreated`); | ||||
| CREATE INDEX `IDX_revisions_utcDateLastEdited` ON `revisions` (`utcDateLastEdited`); | ||||
| CREATE INDEX `IDX_revisions_dateCreated` ON `revisions` (`dateCreated`); | ||||
| CREATE INDEX `IDX_revisions_dateLastEdited` ON `revisions` (`dateLastEdited`); | ||||
| CREATE INDEX IF NOT EXISTS IDX_revisions_blobId on revisions (blobId); | ||||
|  | ||||
| UPDATE entity_changes SET entityName = 'revisions' WHERE entityName = 'note_revisions'; | ||||
|   | ||||
| @@ -19,3 +19,5 @@ CREATE INDEX IDX_attachments_ownerId_role | ||||
|  | ||||
| CREATE INDEX IDX_attachments_utcDateScheduledForErasureSince | ||||
|     on attachments (utcDateScheduledForErasureSince); | ||||
|  | ||||
| CREATE INDEX IF NOT EXISTS IDX_attachments_blobId on attachments (blobId); | ||||
|   | ||||
							
								
								
									
										4
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,12 +1,12 @@ | ||||
| { | ||||
|   "name": "trilium", | ||||
|   "version": "0.62.3", | ||||
|   "version": "0.62.5", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "trilium", | ||||
|       "version": "0.62.3", | ||||
|       "version": "0.62.5", | ||||
|       "hasInstallScript": true, | ||||
|       "license": "AGPL-3.0-only", | ||||
|       "dependencies": { | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|   "name": "trilium", | ||||
|   "productName": "Trilium Notes", | ||||
|   "description": "Trilium Notes", | ||||
|   "version": "0.62.4", | ||||
|   "version": "0.62.6", | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "main": "electron.js", | ||||
|   "bin": { | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| module.exports = { buildDate:"2023-12-07T00:03:59+01:00", buildRevision: "2e23c521c356c2305124f5df0f474532fa5f34ce" }; | ||||
| module.exports = { buildDate:"2024-01-21T23:49:23+01:00", buildRevision: "4f8073daa7cff1b8b6737ae45792b2e87c2adf33" }; | ||||
|   | ||||
| @@ -48,6 +48,14 @@ function isEntityEventsDisabled() { | ||||
|     return !!namespace.get('disableEntityEvents'); | ||||
| } | ||||
|  | ||||
| function setMigrationRunning(running) { | ||||
|     namespace.set('migrationRunning', !!running); | ||||
| } | ||||
|  | ||||
| function isMigrationRunning() { | ||||
|     return !!namespace.get('migrationRunning'); | ||||
| } | ||||
|  | ||||
| function disableSlowQueryLogging(disable) { | ||||
|     namespace.set('disableSlowQueryLogging', disable); | ||||
| } | ||||
| @@ -102,5 +110,7 @@ module.exports = { | ||||
|     putEntityChange, | ||||
|     ignoreEntityChangeIds, | ||||
|     disableSlowQueryLogging, | ||||
|     isSlowQueryLoggingDisabled | ||||
|     isSlowQueryLoggingDisabled, | ||||
|     setMigrationRunning, | ||||
|     isMigrationRunning | ||||
| }; | ||||
|   | ||||
| @@ -302,7 +302,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [ | ||||
|     }, | ||||
|     { | ||||
|         actionName: "lastTab", | ||||
|         defaultShortcuts: ["CommandOrControl+0"], | ||||
|         defaultShortcuts: [], | ||||
|         description: "Activates the last tab in the list", | ||||
|         scope: "window" | ||||
|     }, | ||||
|   | ||||
| @@ -5,12 +5,13 @@ const log = require('./log'); | ||||
| const utils = require('./utils'); | ||||
| const resourceDir = require('./resource_dir'); | ||||
| const appInfo = require('./app_info'); | ||||
| const cls = require('./cls.js'); | ||||
|  | ||||
| async function migrate() { | ||||
|     const currentDbVersion = getDbVersion(); | ||||
|  | ||||
|     if (currentDbVersion < 214) { | ||||
|         log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.60.X first and only then to this version."); | ||||
|         log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.60.4 first and only then to this version."); | ||||
|  | ||||
|         utils.crash(); | ||||
|         return; | ||||
| @@ -18,7 +19,7 @@ async function migrate() { | ||||
|  | ||||
|     // backup before attempting migration | ||||
|     await backupService.backupNow( | ||||
|         // creating a special backup for versions 0.60.X, the changes in 0.61 are major. | ||||
|         // creating a special backup for version 0.60.4, the changes in 0.61 are major. | ||||
|         currentDbVersion === 214 | ||||
|             ? `before-migration-v060` | ||||
|             : 'before-migration' | ||||
| @@ -51,6 +52,9 @@ async function migrate() { | ||||
|     // all migrations are executed in one transaction - upgrade either succeeds, or the user can stay at the old version | ||||
|     // otherwise if half of the migrations succeed, user can't use any version - DB is too "new" for the old app, | ||||
|     // and too old for the new app version. | ||||
|  | ||||
|     cls.setMigrationRunning(true); | ||||
|  | ||||
|     sql.transactional(() => { | ||||
|         for (const mig of migrations) { | ||||
|             try { | ||||
|   | ||||
| @@ -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'); | ||||
|         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; | ||||
| } | ||||
|  | ||||
| @@ -889,6 +895,11 @@ function scanForLinks(note, content) { | ||||
|  * Things which have to be executed after updating content, but asynchronously (separate transaction) | ||||
|  */ | ||||
| async function asyncPostProcessContent(note, content) { | ||||
|     if (cls.isMigrationRunning()) { | ||||
|         // this is rarely needed for migrations, but can cause trouble by e.g. triggering downloads | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (note.hasStringContent() && !utils.isString(content)) { | ||||
|         content = content.toString(); | ||||
|     } | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -490,6 +490,10 @@ class SNote extends AbstractShacaEntity { | ||||
|         return escape(this.title); | ||||
|     } | ||||
|  | ||||
|     get encodedTitle() { | ||||
|         return encodeURIComponent(this.title); | ||||
|     } | ||||
|  | ||||
|     getPojo() { | ||||
|         return { | ||||
|             noteId: this.noteId, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user