mirror of
https://github.com/zadam/trilium.git
synced 2026-03-03 18:50:57 +01:00
Compare commits
7 Commits
renovate/c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b220bdce9c | ||
|
|
4d86c6c4f1 | ||
|
|
4fd68bf12d | ||
|
|
3ffe34964f | ||
|
|
faaf26c174 | ||
|
|
f9c7518db2 | ||
|
|
8357c2a39c |
@@ -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;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
overflow: visible;
|
||||
contain: none !important;
|
||||
clear: both;
|
||||
|
||||
&.full-height {
|
||||
overflow: auto;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user