Compare commits

...

7 Commits

Author SHA1 Message Date
Elian Doran
b220bdce9c fix(note_list): affected by floating images (closes #8899) 2026-03-03 18:14:43 +02:00
Elian Doran
4d86c6c4f1 feat(import/single): trim extension for audio files + default icon 2026-03-03 16:19:44 +02:00
Elian Doran
4fd68bf12d feat(import/single): trim extension for video files 2026-03-03 14:29:18 +02:00
Elian Doran
3ffe34964f feat(notes): add default icon for videos 2026-03-03 14:26:45 +02:00
Elian Doran
faaf26c174 fix(quick_edit): save indicator not shown 2026-03-03 14:19:24 +02:00
Elian Doran
f9c7518db2 fix(spaced_update): triggering events too often while typing 2026-03-03 14:19:24 +02:00
Elian Doran
8357c2a39c chore(pdfjs): version not updated for releases 2026-03-03 14:19:24 +02:00
9 changed files with 33 additions and 15 deletions

View File

@@ -12,6 +12,7 @@ export default class SpacedUpdate {
private updateInterval: number;
private changeForbidden?: boolean;
private stateCallback?: StateCallback;
private lastState: SaveState = "saved";
constructor(updater: Callback, updateInterval = 1000, stateCallback?: StateCallback) {
this.updater = updater;
@@ -24,7 +25,7 @@ export default class SpacedUpdate {
scheduleUpdate() {
if (!this.changeForbidden) {
this.changed = true;
this.stateCallback?.("unsaved");
this.onStateChanged("unsaved");
setTimeout(() => this.triggerUpdate());
}
}
@@ -34,12 +35,12 @@ export default class SpacedUpdate {
this.changed = false; // optimistic...
try {
this.stateCallback?.("saving");
this.onStateChanged("saving");
await this.updater();
this.stateCallback?.("saved");
this.onStateChanged("saved");
} catch (e) {
this.changed = true;
this.stateCallback?.("error");
this.onStateChanged("error");
logError(getErrorMessage(e));
throw e;
}
@@ -76,13 +77,13 @@ export default class SpacedUpdate {
}
if (Date.now() - this.lastUpdated > this.updateInterval) {
this.stateCallback?.("saving");
this.onStateChanged("saving");
try {
await this.updater();
this.stateCallback?.("saved");
this.onStateChanged("saved");
this.changed = false;
} catch (e) {
this.stateCallback?.("error");
this.onStateChanged("error");
logError(getErrorMessage(e));
}
this.lastUpdated = Date.now();
@@ -92,6 +93,13 @@ export default class SpacedUpdate {
}
}
onStateChanged(state: SaveState) {
if (state === this.lastState) return;
this.stateCallback?.(state);
this.lastState = state;
}
async allowUpdateWithoutChange(callback: Callback) {
this.changeForbidden = true;

View File

@@ -4,6 +4,7 @@
overflow: visible;
contain: none !important;
clear: both;
&.full-height {
overflow: auto;

View File

@@ -54,6 +54,8 @@ export default function PopupEditor() {
}
});
// Events triggered at note context level (e.g. the save indicator) would not work since the note context has no parent component. Propagate events to parent component so that they can be handled properly.
noteContext.triggerEvent = (name, data) => parentComponent?.handleEventInChildren(name, data);
setNoteContext(noteContext);
setShown(true);
});

View File

@@ -7,7 +7,7 @@ import { t } from "../../services/i18n";
import { goToLinkExt } from "../../services/link";
import { Badge, BadgeWithDropdown } from "../react/Badge";
import { FormDropdownDivider, FormListItem } from "../react/FormList";
import { useGetContextData, useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean } from "../react/hooks";
import { useGetContextDataFrom, useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean } from "../react/hooks";
import { useShareState } from "../ribbon/BasicPropertiesTab";
import { useShareInfo } from "../shared_info";
import { ActiveContentBadges } from "./ActiveContentBadges";
@@ -112,7 +112,8 @@ function ExecuteBadge() {
}
export function SaveStatusBadge() {
const saveState = useGetContextData("saveState");
const { noteContext} = useNoteContext();
const saveState = useGetContextDataFrom(noteContext, "saveState");
if (!saveState) return;
const stateConfig = {

View File

@@ -57,7 +57,7 @@ function importFile(taskContext: TaskContext<"importNotes">, file: File, parentN
const mime = mimeService.getMime(originalName) || file.mimetype;
const { note } = noteService.createNewNote({
parentNoteId: parentNote.noteId,
title: getNoteTitle(originalName, mime === "application/pdf"),
title: getNoteTitle(originalName, mime === "application/pdf", { mime }),
content: file.buffer,
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
type: "file",

View File

@@ -204,9 +204,13 @@ export function formatDownloadTitle(fileName: string, type: string | null, mime:
return `${fileNameBase}${getExtension()}`;
}
export function removeFileExtension(filePath: string) {
export function removeFileExtension(filePath: string, mime?: string) {
const extension = path.extname(filePath).toLowerCase();
if (mime?.startsWith("video/") || mime?.startsWith("audio/")) {
return filePath.substring(0, filePath.length - extension.length);
}
switch (extension) {
case ".md":
case ".mdx":
@@ -227,7 +231,7 @@ export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boo
const trimmedNoteMeta = noteMeta?.title?.trim();
if (trimmedNoteMeta) return trimmedNoteMeta;
const basename = path.basename(removeFileExtension(filePath));
const basename = path.basename(removeFileExtension(filePath, noteMeta?.mime));
return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename;
}

View File

@@ -59,6 +59,8 @@ export function getNoteIcon({ noteId, type, mime, iconClass, workspaceIconClass,
const correspondingMimeType = MIME_TYPES_DICT.find(m => m.mime === mime);
return correspondingMimeType?.icon ?? NOTE_TYPE_ICONS.code;
} else if (type === "file") {
if (mime.startsWith("video/")) return "bx bx-video";
if (mime.startsWith("audio/")) return "bx bx-music";
return FILE_MIME_MAPPINGS[mime] ?? NOTE_TYPE_ICONS.file;
} else if (type === "image") {
return IMAGE_MIME_MAPPINGS[mime] ?? NOTE_TYPE_ICONS.image;

View File

@@ -1,6 +1,6 @@
{
"name": "@triliumnext/pdfjs-viewer",
"version": "1.0.0",
"version": "0.102.0",
"private": true,
"scripts": {
"build": "tsx scripts/build.ts",
@@ -12,4 +12,4 @@
"devDependencies": {
"pdfjs-dist": "5.4.624"
}
}
}

View File

@@ -30,7 +30,7 @@ function main() {
patchPackageJson(join(__dirname, "..", "apps", appName, "package.json"), version);
}
for (const packageName of ["commons"]) {
for (const packageName of ["commons", "pdfjs-viewer"]) {
patchPackageJson(join(__dirname, "..", "packages", packageName, "package.json"), version);
}
}