From c4a2ff5fa1b8cc53870caacc37978954b24ea81c Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 7 May 2023 12:09:38 +0200 Subject: [PATCH 1/6] fix hamburger icon in canvas, #3780 --- src/public/app/widgets/type_widgets/canvas.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/public/app/widgets/type_widgets/canvas.js b/src/public/app/widgets/type_widgets/canvas.js index dbe1eba2e..b4c92c4f0 100644 --- a/src/public/app/widgets/type_widgets/canvas.js +++ b/src/public/app/widgets/type_widgets/canvas.js @@ -12,6 +12,14 @@ const TPL = ` .excalidraw .App-menu_top .buttonList { display: flex; } + + /* Conflict between excalidraw and bootstrap classes keeps the menu hidden */ + /* https://github.com/zadam/trilium/issues/3780 */ + /* https://github.com/excalidraw/excalidraw/issues/6567 */ + .excalidraw .dropdown-menu { + display: block; + } + .excalidraw-wrapper { height: 100%; From 331d2800755483641f5e1f480229cc12fcf500d2 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 9 May 2023 23:14:56 +0200 Subject: [PATCH 2/6] TOC scrolls smoothly (on readonly), #3911 --- src/public/app/widgets/toc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js index 5e826cf1f..3fbc29ee6 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.js @@ -176,7 +176,7 @@ export default class TocWidget extends RightPanelWidget { const headingElement = $container.find(":header")[headingIndex]; if (headingElement != null) { - headingElement.scrollIntoView(); + headingElement.scrollIntoView({ behavior: "smooth" }); } } else { const textEditor = await this.noteContext.getTextEditor(); @@ -302,4 +302,4 @@ class CloseTocButton extends OnClickButtonWidget { }) .class("icon-action close-toc"); } -} \ No newline at end of file +} From cc1f831a6a6481b457b081769f26da246bec6862 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 9 May 2023 23:32:06 +0200 Subject: [PATCH 3/6] don't allow setting image quality to empty value, #3894 --- .../app/widgets/type_widgets/options/images/images.js | 2 +- src/services/image.js | 2 +- src/services/options.js | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/images/images.js b/src/public/app/widgets/type_widgets/options/images/images.js index 38eae0db8..c6ceb6e04 100644 --- a/src/public/app/widgets/type_widgets/options/images/images.js +++ b/src/public/app/widgets/type_widgets/options/images/images.js @@ -48,7 +48,7 @@ export default class ImageOptions extends OptionsWidget { this.updateOption('imageMaxWidthHeight', this.$imageMaxWidthHeight.val())); this.$imageJpegQuality.on('change', () => - this.updateOption('imageJpegQuality', this.$imageJpegQuality.val())); + this.updateOption('imageJpegQuality', this.$imageJpegQuality.val().trim() || "75")); this.$downloadImagesAutomatically = this.$widget.find(".download-images-automatically"); diff --git a/src/services/image.js b/src/services/image.js index ac9d9cfd1..1dc624e95 100644 --- a/src/services/image.js +++ b/src/services/image.js @@ -134,7 +134,7 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch, } async function shrinkImage(buffer, originalName) { - let jpegQuality = optionService.getOptionInt('imageJpegQuality'); + let jpegQuality = optionService.getOptionInt('imageJpegQuality', 0); if (jpegQuality < 10 || jpegQuality > 100) { jpegQuality = 75; diff --git a/src/services/options.js b/src/services/options.js index 9d227ec4c..d2b1404fd 100644 --- a/src/services/options.js +++ b/src/services/options.js @@ -10,7 +10,7 @@ function getOptionOrNull(name) { // e.g. in initial sync becca is not loaded because DB is not initialized option = sql.getRow("SELECT * FROM options WHERE name = ?", name); } - + return option ? option.value : null; } @@ -27,13 +27,17 @@ function getOption(name) { /** * @returns {number} */ -function getOptionInt(name) { +function getOptionInt(name, defaultValue = undefined) { const val = getOption(name); const intVal = parseInt(val); if (isNaN(intVal)) { - throw new Error(`Could not parse "${val}" into integer for option "${name}"`); + if (defaultValue === undefined) { + throw new Error(`Could not parse "${val}" into integer for option "${name}"`); + } else { + return defaultValue; + } } return intVal; From 04caba9f5b05121109ad848be283177e34d22da1 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 9 May 2023 23:44:43 +0200 Subject: [PATCH 4/6] fix parsing the authentication header with password containing a colon, closes #3916 --- src/services/auth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/auth.js b/src/services/auth.js index 331f1d252..8081cd34c 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -110,8 +110,8 @@ function checkCredentials(req, res, next) { const header = req.headers['trilium-cred'] || ''; const auth = new Buffer.from(header, 'base64').toString(); - const [username, password] = auth.split(/:/); - + const colonIndex = auth.indexOf(':'); + const password = colonIndex === -1 ? "" : auth.substr(colonIndex + 1); // username is ignored if (!passwordEncryptionService.verifyPassword(password)) { From 8eb0a4e1cbcebd8103f53084b999fe3b11e1b7ff Mon Sep 17 00:00:00 2001 From: baiyongjie <407221377@qq.com> Date: Wed, 10 May 2023 18:08:25 +0800 Subject: [PATCH 5/6] fix cursor position when Jumping from note to included note (cherry picked from commit 6a9aa5eedaf27d8b077d200cca659eef541b2143) --- src/public/app/widgets/type_widgets/editable_text.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js index aa1015242..1bae06696 100644 --- a/src/public/app/widgets/type_widgets/editable_text.js +++ b/src/public/app/widgets/type_widgets/editable_text.js @@ -187,6 +187,11 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { const noteComplement = await froca.getNoteComplement(note.noteId); await this.spacedUpdate.allowUpdateWithoutChange(() => { + // https://github.com/zadam/trilium/issues/3914 + // todo: quite hacky, but it works. remove it if ckeditor has fixed it. + this.$editor.trigger('focus'); + this.$editor.trigger('blur') + this.watchdog.editor.setData(noteComplement.content || ""); }); } From 239c14a5df027cbcbd0bb8256a72c6c1bad94134 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 13 May 2023 15:58:32 +0200 Subject: [PATCH 6/6] fix search in "view source", closes #3929 --- src/public/app/components/note_context.js | 4 ++++ src/public/app/widgets/buttons/edit_button.js | 4 +++- src/public/app/widgets/toc.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/public/app/components/note_context.js b/src/public/app/components/note_context.js index 5bed983c7..3df6b206e 100644 --- a/src/public/app/components/note_context.js +++ b/src/public/app/components/note_context.js @@ -226,6 +226,10 @@ class NoteContext extends Component { return true; } + if (this.viewScope.viewMode === 'source') { + return true; + } + const noteComplement = await this.getNoteComplement(); const sizeLimit = this.note.type === 'text' diff --git a/src/public/app/widgets/buttons/edit_button.js b/src/public/app/widgets/buttons/edit_button.js index 112b3264c..a161f7540 100644 --- a/src/public/app/widgets/buttons/edit_button.js +++ b/src/public/app/widgets/buttons/edit_button.js @@ -5,7 +5,9 @@ import protectedSessionHolder from "../../services/protected_session_holder.js"; export default class EditButton extends OnClickButtonWidget { isEnabled() { - return super.isEnabled() && this.note; + return super.isEnabled() + && this.note + && this.noteContext.viewScope.viewMode === 'default'; } constructor() { diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js index 3fbc29ee6..b35218b1b 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.js @@ -69,7 +69,8 @@ export default class TocWidget extends RightPanelWidget { isEnabled() { return super.isEnabled() && this.note.type === 'text' - && !this.noteContext.viewScope.tocTemporarilyHidden; + && !this.noteContext.viewScope.tocTemporarilyHidden + && this.noteContext.viewScope.viewMode === 'default'; } async doRenderBody() {