Merge branch 'stable'

# Conflicts:
#	src/public/app/widgets/toc.js
This commit is contained in:
zadam 2023-05-18 13:46:41 +02:00
commit f3bc604516
8 changed files with 30 additions and 13 deletions

View File

@ -226,6 +226,10 @@ class NoteContext extends Component {
return true; return true;
} }
if (this.viewScope.viewMode === 'source') {
return true;
}
const noteComplement = await this.getNoteComplement(); const noteComplement = await this.getNoteComplement();
const sizeLimit = this.note.type === 'text' const sizeLimit = this.note.type === 'text'

View File

@ -5,7 +5,9 @@ import protectedSessionHolder from "../../services/protected_session_holder.js";
export default class EditButton extends OnClickButtonWidget { export default class EditButton extends OnClickButtonWidget {
isEnabled() { isEnabled() {
return super.isEnabled() && this.note; return super.isEnabled()
&& this.note
&& this.noteContext.viewScope.viewMode === 'default';
} }
constructor() { constructor() {

View File

@ -69,7 +69,8 @@ export default class TocWidget extends RightPanelWidget {
isEnabled() { isEnabled() {
return super.isEnabled() return super.isEnabled()
&& this.note.type === 'text' && this.note.type === 'text'
&& !this.noteContext.viewScope.tocTemporarilyHidden; && !this.noteContext.viewScope.tocTemporarilyHidden
&& this.noteContext.viewScope.viewMode === 'default';
} }
async doRenderBody() { async doRenderBody() {
@ -176,9 +177,7 @@ export default class TocWidget extends RightPanelWidget {
const headingElement = $container.find(":header")[headingIndex]; const headingElement = $container.find(":header")[headingIndex];
if (headingElement != null) { if (headingElement != null) {
headingElement.scrollIntoView({ headingElement.scrollIntoView({ behavior: "smooth" });
behavior: 'smooth'
});
} }
} else { } else {
const textEditor = await this.noteContext.getTextEditor(); const textEditor = await this.noteContext.getTextEditor();

View File

@ -13,6 +13,14 @@ const TPL = `
display: flex; 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 { .excalidraw-wrapper {
height: 100%; height: 100%;
} }

View File

@ -48,7 +48,7 @@ export default class ImageOptions extends OptionsWidget {
this.updateOption('imageMaxWidthHeight', this.$imageMaxWidthHeight.val())); this.updateOption('imageMaxWidthHeight', this.$imageMaxWidthHeight.val()));
this.$imageJpegQuality.on('change', () => 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"); this.$downloadImagesAutomatically = this.$widget.find(".download-images-automatically");

View File

@ -110,8 +110,8 @@ function checkCredentials(req, res, next) {
const header = req.headers['trilium-cred'] || ''; const header = req.headers['trilium-cred'] || '';
const auth = new Buffer.from(header, 'base64').toString(); 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 // username is ignored
if (!passwordEncryptionService.verifyPassword(password)) { if (!passwordEncryptionService.verifyPassword(password)) {

View File

@ -134,7 +134,7 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch,
} }
async function shrinkImage(buffer, originalName) { async function shrinkImage(buffer, originalName) {
let jpegQuality = optionService.getOptionInt('imageJpegQuality'); let jpegQuality = optionService.getOptionInt('imageJpegQuality', 0);
if (jpegQuality < 10 || jpegQuality > 100) { if (jpegQuality < 10 || jpegQuality > 100) {
jpegQuality = 75; jpegQuality = 75;

View File

@ -27,13 +27,17 @@ function getOption(name) {
/** /**
* @returns {number} * @returns {number}
*/ */
function getOptionInt(name) { function getOptionInt(name, defaultValue = undefined) {
const val = getOption(name); const val = getOption(name);
const intVal = parseInt(val); const intVal = parseInt(val);
if (isNaN(intVal)) { 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; return intVal;