chore(react/type_widget): list attachments with content

This commit is contained in:
Elian Doran
2025-09-21 10:32:12 +03:00
parent 58b14ae31c
commit dc73467d34
5 changed files with 146 additions and 121 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from "preact/hooks";
import link from "../../services/link";
import link, { ViewScope } from "../../services/link";
import { useImperativeSearchHighlighlighting } from "./hooks";
interface NoteLinkOpts {
@@ -11,18 +11,25 @@ interface NoteLinkOpts {
noPreview?: boolean;
noTnLink?: boolean;
highlightedTokens?: string[] | null | undefined;
// Override the text of the link, otherwise the note title is used.
title?: string;
viewScope?: ViewScope;
}
export default function NoteLink({ className, notePath, showNotePath, showNoteIcon, style, noPreview, noTnLink, highlightedTokens }: NoteLinkOpts) {
export default function NoteLink({ className, notePath, showNotePath, showNoteIcon, style, noPreview, noTnLink, highlightedTokens, title, viewScope }: NoteLinkOpts) {
const stringifiedNotePath = Array.isArray(notePath) ? notePath.join("/") : notePath;
const ref = useRef<HTMLSpanElement>(null);
const [ jqueryEl, setJqueryEl ] = useState<JQuery<HTMLElement>>();
const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
useEffect(() => {
link.createLink(stringifiedNotePath, { showNotePath, showNoteIcon })
.then(setJqueryEl);
}, [ stringifiedNotePath, showNotePath ]);
link.createLink(stringifiedNotePath, {
title,
showNotePath,
showNoteIcon,
viewScope
}).then(setJqueryEl);
}, [ stringifiedNotePath, showNotePath, title, viewScope ]);
useEffect(() => {
if (!ref.current || !jqueryEl) return;