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 b4096a5df..5bdd4358c 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() { @@ -176,9 +177,7 @@ export default class TocWidget extends RightPanelWidget { const headingElement = $container.find(":header")[headingIndex]; if (headingElement != null) { - headingElement.scrollIntoView({ - behavior: 'smooth' - }); + headingElement.scrollIntoView({ behavior: "smooth" }); } } else { const textEditor = await this.noteContext.getTextEditor(); @@ -263,4 +262,4 @@ class CloseTocButton extends OnClickButtonWidget { }) .class("icon-action close-toc"); } -} \ No newline at end of file +} 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%; 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/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)) { 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;