From 4d57134aa2cc8e93ac03a261f3847035b85042ec Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 9 Sep 2025 21:11:06 +0300 Subject: [PATCH] chore(react/collections/table): port note title formatter --- .../src/widgets/collections/table/columns.tsx | 13 +++++++++++- .../widgets/collections/table/formatters.ts | 20 ------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/apps/client/src/widgets/collections/table/columns.tsx b/apps/client/src/widgets/collections/table/columns.tsx index 1e04822f40..8a6e319af3 100644 --- a/apps/client/src/widgets/collections/table/columns.tsx +++ b/apps/client/src/widgets/collections/table/columns.tsx @@ -4,6 +4,8 @@ import { LabelType } from "../../../services/promoted_attribute_definition_parse import { RelationEditor } from "./relation_editor.js"; import { JSX } from "preact"; import { renderReactWidget } from "../../react/react_utils.jsx"; +import NoteTitleWidget from "../../note_title.jsx"; +import Icon from "../../react/Icon.jsx"; type ColumnType = LabelType | "relation"; @@ -90,7 +92,16 @@ export function buildColumnDefinitions({ info, movableRows, existingColumnData, field: "title", title: "Title", editor: "input", - formatter: NoteTitleFormatter, + formatter: wrapFormatter(({ cell }) => { + const { noteId, iconClass, colorClass } = cell.getRow().getData(); + if (!noteId) { + return ""; + } + + return + {" "}{cell.getValue()} + ; + }), width: 400 } ]; diff --git a/apps/client/src/widgets/collections/table/formatters.ts b/apps/client/src/widgets/collections/table/formatters.ts index 8732313813..88a7b2cb1a 100644 --- a/apps/client/src/widgets/collections/table/formatters.ts +++ b/apps/client/src/widgets/collections/table/formatters.ts @@ -47,28 +47,8 @@ export function NoteFormatter(cell: CellComponent, _formatterParams, onRendered) } } -/** - * Custom formatter for the note title that is quite similar to {@link NoteFormatter}, but where the title and icons are read from separate fields. - */ -export function NoteTitleFormatter(cell: CellComponent) { - const { noteId, iconClass, colorClass } = cell.getRow().getData(); - if (!noteId) { - return ""; - } - - const { $noteRef } = buildNoteLink(noteId, cell.getValue(), iconClass, colorClass); - return $noteRef[0].outerHTML; -} - function buildNoteLink(noteId: string, title: string, iconClass: string, colorClass?: string) { const $noteRef = $(""); const href = `#root/${noteId}`; - $noteRef.addClass("reference-link"); - $noteRef.attr("data-href", href); - $noteRef.text(title); - $noteRef.prepend($("").addClass(iconClass)); - if (colorClass) { - $noteRef.addClass(colorClass); - } return { $noteRef, href }; }