MCPcopy
hub / github.com/callumalpass/tasknotes / renderPropertyValue

Function renderPropertyValue

src/ui/taskCardProperties.ts:687–749  ·  view source on GitHub ↗
(
	container: HTMLElement,
	value: unknown,
	plugin?: TaskNotesPlugin
)

Source from the content-addressed store, hash-verified

685}
686
687function renderPropertyValue(
688 container: HTMLElement,
689 value: unknown,
690 plugin?: TaskNotesPlugin
691): void {
692 if (!hasValidValue(value)) {
693 return;
694 }
695
696 if (plugin && renderBasesValue(container, value, plugin.app.renderContext)) {
697 return;
698 }
699
700 if (typeof value === "string" && plugin) {
701 const linkServices: LinkServices = {
702 metadataCache: plugin.app.metadataCache,
703 workspace: plugin.app.workspace,
704 };
705
706 if (containsRichTextLink(value)) {
707 renderTextWithLinks(container, value, linkServices, {
708 onTagClick: async (tag) => {
709 const searchTag = tag.startsWith("#") ? tag.slice(1) : tag;
710 await plugin.openTagsPane(`#${searchTag}`);
711 },
712 });
713 return;
714 }
715
716 container.appendChild(activeDocument.createTextNode(value));
717 return;
718 }
719
720 let displayValue: string;
721
722 if (typeof value === "object" && value !== null) {
723 if (value instanceof Date) {
724 displayValue = formatDateTimeForDisplay(value.toISOString(), {
725 dateFormat: "MMM d, yyyy",
726 timeFormat: "",
727 showTime: false,
728 });
729 } else {
730 const entries = Object.entries(value as Record<string, unknown>);
731 displayValue =
732 entries.length <= 3
733 ? entries.map(([key, item]) => `${key}: ${stringifyUnknown(item)}`).join(", ")
734 : stringifyUnknown(value);
735 }
736 } else if (typeof value === "boolean") {
737 displayValue = value ? "✓" : "✗";
738 } else if (typeof value === "number") {
739 displayValue = Number.isInteger(value) ? String(value) : value.toFixed(2);
740 } else {
741 displayValue = stringifyUnknown(value);
742 }
743
744 if (displayValue.length > 100) {

Callers 1

renderGenericPropertyFunction · 0.85

Calls 7

renderBasesValueFunction · 0.90
renderTextWithLinksFunction · 0.90
formatDateTimeForDisplayFunction · 0.90
stringifyUnknownFunction · 0.90
hasValidValueFunction · 0.85
containsRichTextLinkFunction · 0.85
openTagsPaneMethod · 0.80

Tested by

no test coverage detected