feat(react/ribbon): port image properties

This commit is contained in:
Elian Doran
2025-08-22 21:04:04 +03:00
parent 21683db0b8
commit 8287063aab
8 changed files with 123 additions and 154 deletions

View File

@@ -10,6 +10,7 @@ import NoteContext from "../../components/note_context";
import { ReactWrappedWidget } from "../basic_widget";
import FNote from "../../entities/fnote";
import attributes from "../../services/attributes";
import FBlob from "../../entities/fblob";
type TriliumEventHandler<T extends EventNames> = (data: EventData<T>) => void;
const registeredHandlers: Map<Component, Map<EventNames, TriliumEventHandler<any>[]>> = new Map();
@@ -388,4 +389,25 @@ export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: s
}, [note]);
return [ labelValue, setter ] as const;
}
export function useNoteBlob(note: FNote | null | undefined): [ FBlob | null | undefined ] {
if (!note) {
return [ undefined ];
}
const [ blob, setBlob ] = useState<FBlob | null>();
function refresh() {
note?.getBlob().then(setBlob);
}
useEffect(refresh, [ note?.noteId ]);
useTriliumEventBeta("entitiesReloaded", ({ loadResults }) => {
if (note && loadResults.hasRevisionForNote(note.noteId)) {
refresh();
}
});
return [ blob ] as const;
}