diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsx index 17c77f8d8..16167a471 100644 --- a/apps/client/src/layouts/desktop_layout.tsx +++ b/apps/client/src/layouts/desktop_layout.tsx @@ -31,6 +31,7 @@ import ScrollingContainer from "../widgets/containers/scrolling_container.js"; import ScrollPadding from "../widgets/scroll_padding.js"; import SearchResult from "../widgets/search_result.jsx"; import SharedInfo from "../widgets/shared_info.jsx"; +import OriginInfo from "../widgets/note_origin.jsx"; import SpacerWidget from "../widgets/spacer.js"; import SplitNoteContainer from "../widgets/containers/split_note_container.js"; import SqlResults from "../widgets/sql_result.js"; @@ -137,6 +138,7 @@ export default class DesktopLayout { new ScrollingContainer() .filling() .child(new ContentHeader() + .child() .child() .child() ) diff --git a/apps/client/src/widgets/note_origin.tsx b/apps/client/src/widgets/note_origin.tsx new file mode 100644 index 000000000..bf6f0ccfc --- /dev/null +++ b/apps/client/src/widgets/note_origin.tsx @@ -0,0 +1,43 @@ +import { t } from "../services/i18n"; +import { useNoteContext, useTriliumEvent, useTriliumOption } from "./react/hooks"; +import { useEffect, useState } from "preact/hooks"; +import attributes from "../services/attributes"; +import InfoBar from "./react/InfoBar"; +import RawHtml from "./react/RawHtml"; +import FNote from "../entities/fnote"; + +export default function OriginInfo() { + const { note } = useNoteContext(); + const [link, setLink] = useState(); + + function refresh() { + if (!note) return; + const pageUrl = getPageUrl(note); + if (!pageUrl) { + setLink(undefined); + return; + } + setLink(`${pageUrl}`); + } + + useEffect(refresh, [note]); + useTriliumEvent("entitiesReloaded", ({ loadResults }) => { + if (loadResults.getAttributeRows().find((attr) => attr.type === "label" && attr.name?.toString() === "pageUrl" && attributes.isAffecting(attr, note))) { + refresh(); + } + }); + + return ( + + {link && ( + + )} + + ) +} + +function getPageUrl(note: FNote) { + return note.getOwnedLabelValue("pageUrl"); +} \ No newline at end of file diff --git a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx index e961ae1f0..fb68b7950 100644 --- a/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/CollectionPropertiesTab.tsx @@ -28,7 +28,7 @@ export default function CollectionPropertiesTab({ note }: TabContext) { const defaultViewType = (note?.type === "search" ? "list" : "grid"); const viewTypeWithDefault = (viewType ?? defaultViewType) as ViewTypeOptions; const properties = bookPropertiesConfig[viewTypeWithDefault].properties; - + console.warn('CollectionPropertiesTab:', properties) return (
{note && ( @@ -137,7 +137,7 @@ function NumberPropertyView({ note, property }: { note: FNote, property: NumberP function ComboBoxPropertyView({ note, property }: { note: FNote, property: ComboBoxProperty }) { const [ value, setValue ] = useNoteLabel(note, property.bindToLabel); - + console.warn('ComboBoxPropertyView:', value) return (