From 70728c274e138906cfaf66ec25c6dfbcde9ce3b9 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 22 Aug 2025 17:41:45 +0300 Subject: [PATCH] feat(react/ribbon): port note properties --- .../src/widgets/ribbon/NotePropertiesTab.tsx | 20 +++++++ apps/client/src/widgets/ribbon/Ribbon.tsx | 7 ++- .../widgets/ribbon_widgets/note_properties.ts | 53 ------------------- 3 files changed, 25 insertions(+), 55 deletions(-) create mode 100644 apps/client/src/widgets/ribbon/NotePropertiesTab.tsx delete mode 100644 apps/client/src/widgets/ribbon_widgets/note_properties.ts diff --git a/apps/client/src/widgets/ribbon/NotePropertiesTab.tsx b/apps/client/src/widgets/ribbon/NotePropertiesTab.tsx new file mode 100644 index 000000000..8cc0c2b85 --- /dev/null +++ b/apps/client/src/widgets/ribbon/NotePropertiesTab.tsx @@ -0,0 +1,20 @@ +import { t } from "../../services/i18n"; +import { useNoteLabel } from "../react/hooks"; +import { TabContext } from "./ribbon-interface"; + +/** + * TODO: figure out better name or conceptualize better. + */ +export default function NotePropertiesTab({ note }: TabContext) { + const [ pageUrl ] = useNoteLabel(note, "pageUrl"); + + return ( +
+ { pageUrl && ( +
+ {t("note_properties.this_note_was_originally_taken_from")} {pageUrl} +
+ )} +
+ ) +} \ No newline at end of file diff --git a/apps/client/src/widgets/ribbon/Ribbon.tsx b/apps/client/src/widgets/ribbon/Ribbon.tsx index c043f84e3..5dbeb1c62 100644 --- a/apps/client/src/widgets/ribbon/Ribbon.tsx +++ b/apps/client/src/widgets/ribbon/Ribbon.tsx @@ -12,6 +12,7 @@ import { CommandNames } from "../../components/app_context"; import FNote from "../../entities/fnote"; import ScriptTab from "./ScriptTab"; import EditedNotesTab from "./EditedNotesTab"; +import NotePropertiesTab from "./NotePropertiesTab"; interface TitleContext { note: FNote | null | undefined; @@ -67,9 +68,11 @@ const TAB_CONFIGURATION = numberObjectsInPlace([ icon: "bx bx-book" }, { - // NotePropertiesWidget title: t("note_properties.info"), - icon: "bx bx-info-square" + icon: "bx bx-info-square", + content: NotePropertiesTab, + show: ({ note }) => !!note?.getLabelValue("pageUrl"), + activate: true }, { // FilePropertiesWidget diff --git a/apps/client/src/widgets/ribbon_widgets/note_properties.ts b/apps/client/src/widgets/ribbon_widgets/note_properties.ts deleted file mode 100644 index 7f875e4e4..000000000 --- a/apps/client/src/widgets/ribbon_widgets/note_properties.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type FNote from "../../entities/fnote.js"; -import { t } from "../../services/i18n.js"; -import NoteContextAwareWidget from "../note_context_aware_widget.js"; - -const TPL = /*html*/` -
- - -
- ${t("note_properties.this_note_was_originally_taken_from")} -
-
`; - -/** - * TODO: figure out better name or conceptualize better. - */ -export default class NotePropertiesWidget extends NoteContextAwareWidget { - - private $pageUrl!: JQuery; - - isEnabled() { - return this.note && !!this.note.getLabelValue("pageUrl"); - } - - getTitle() { - return { - show: this.isEnabled(), - activate: true, - - }; - } - - doRender() { - this.$widget = $(TPL); - this.contentSized(); - - this.$pageUrl = this.$widget.find(".page-url"); - } - - async refreshWithNote(note: FNote) { - const pageUrl = note.getLabelValue("pageUrl"); - - this.$pageUrl - .attr("href", pageUrl) - .attr("title", pageUrl) - .text(pageUrl ?? ""); - } -}