mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 13:34:30 +01:00
feat(board/relation): react to column title changes
This commit is contained in:
parent
0c616fecdf
commit
f820c6f23b
@ -1,11 +1,21 @@
|
||||
import type { AttachmentRow, EtapiTokenRow, OptionNames } from "@triliumnext/commons";
|
||||
import type { AttachmentRow, EtapiTokenRow, NoteType, OptionNames } from "@triliumnext/commons";
|
||||
import type { AttributeType } from "../entities/fattribute.js";
|
||||
import type { EntityChange } from "../server_types.js";
|
||||
|
||||
// TODO: Deduplicate with server.
|
||||
|
||||
interface NoteRow {
|
||||
blobId: string;
|
||||
dateCreated: string;
|
||||
dateMOdified: string;
|
||||
isDeleted?: boolean;
|
||||
isProtected?: boolean;
|
||||
mime: string;
|
||||
noteId: string;
|
||||
title: string;
|
||||
type: NoteType;
|
||||
utcDateCreated: string;
|
||||
utcDateModified: string;
|
||||
}
|
||||
|
||||
// TODO: Deduplicate with BranchRow from `rows.ts`/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import link, { ViewScope } from "../../services/link";
|
||||
import { useImperativeSearchHighlighlighting } from "./hooks";
|
||||
import { useImperativeSearchHighlighlighting, useTriliumEvent } from "./hooks";
|
||||
|
||||
interface NoteLinkOpts {
|
||||
className?: string;
|
||||
@ -19,9 +19,11 @@ interface NoteLinkOpts {
|
||||
|
||||
export default function NoteLink({ className, notePath, showNotePath, showNoteIcon, style, noPreview, noTnLink, highlightedTokens, title, viewScope, noContextMenu }: NoteLinkOpts) {
|
||||
const stringifiedNotePath = Array.isArray(notePath) ? notePath.join("/") : notePath;
|
||||
const noteId = stringifiedNotePath.split("/").at(-1);
|
||||
const ref = useRef<HTMLSpanElement>(null);
|
||||
const [ jqueryEl, setJqueryEl ] = useState<JQuery<HTMLElement>>();
|
||||
const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
|
||||
const [ noteTitle, setNoteTitle ] = useState<string>();
|
||||
|
||||
useEffect(() => {
|
||||
link.createLink(stringifiedNotePath, {
|
||||
@ -30,7 +32,7 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIc
|
||||
showNoteIcon,
|
||||
viewScope
|
||||
}).then(setJqueryEl);
|
||||
}, [ stringifiedNotePath, showNotePath, title, viewScope ]);
|
||||
}, [ stringifiedNotePath, showNotePath, title, viewScope, noteTitle ]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current || !jqueryEl) return;
|
||||
@ -38,6 +40,16 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIc
|
||||
highlightSearch(ref.current);
|
||||
}, [ jqueryEl, highlightedTokens ]);
|
||||
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
// React to note title changes, but only if the title is not overwritten.
|
||||
if (!title && noteId) {
|
||||
const entityRow = loadResults.getEntityRow("notes", noteId);
|
||||
if (entityRow) {
|
||||
setNoteTitle(entityRow.title);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (style) {
|
||||
jqueryEl?.css(style);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user