From 20838fdb54d4c0dbf25d4e7e6414b2a58606ceb3 Mon Sep 17 00:00:00 2001 From: Quorafind Date: Wed, 29 Oct 2025 15:53:23 +0800 Subject: [PATCH] feat(rendering): use originalMarkdown for file-source tasks Updated calendar and kanban components to render the full originalMarkdown content for file-source tasks instead of just the title. This ensures file-based tasks display their complete markdown content consistently across different view types. Changes: - CalendarEventComponent: Check source type before rendering - KanbanCardComponent: Use originalMarkdown for file-source tasks --- .../calendar/rendering/event-renderer.ts | 36 ++++++++++--------- src/components/features/kanban/kanban-card.ts | 30 ++++++++-------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/components/features/calendar/rendering/event-renderer.ts b/src/components/features/calendar/rendering/event-renderer.ts index 1e3bdbb4..aa59bea3 100644 --- a/src/components/features/calendar/rendering/event-renderer.ts +++ b/src/components/features/calendar/rendering/event-renderer.ts @@ -1,5 +1,5 @@ import { App, Component, debounce, moment } from "obsidian"; -import { CalendarEvent } from '@/components/features/calendar/index'; // Adjust path as needed +import { CalendarEvent } from "@/components/features/calendar/index"; // Adjust path as needed import { EventLayout, determineEventColor } from "../algorithm"; // Adjust path as needed import { clearAllMarks, @@ -126,16 +126,16 @@ export class CalendarEventComponent extends Component { }${ this.event.metadata.dueDate ? `\nDue: ${moment(this.event.metadata.dueDate).format( - "YYYY-MM-DD" - )}` + "YYYY-MM-DD", + )}` : "" }${ this.event.metadata.startDate ? `\nStart: ${moment(this.event.metadata.startDate).format( - "YYYY-MM-DD" - )}` + "YYYY-MM-DD", + )}` : "" - }` + }`, ); } @@ -168,7 +168,7 @@ export class CalendarEventComponent extends Component { const checkbox = createTaskCheckbox( this.event.status, this.event, - this.eventEl + this.eventEl, ); this.registerDomEvent(checkbox, "click", (ev) => { @@ -191,11 +191,15 @@ export class CalendarEventComponent extends Component { this.markdownRenderer = new MarkdownRendererComponent( this.app, titleContainer, - this.event.filePath + this.event.filePath, ); this.addChild(this.markdownRenderer); - this.markdownRenderer.render(this.event.title); + this.markdownRenderer.render( + this.event.metadata.source === "file-source" + ? this.event.originalMarkdown + : this.event.title, + ); if (this.positioningHints?.isMultiDay) { this.eventEl.addClass("is-multi-day"); @@ -211,7 +215,7 @@ export class CalendarEventComponent extends Component { private renderTimedEvent(): void { this.eventEl.toggleClass( ["calendar-event-timed", "calendar-event"], - true + true, ); if (this.viewType === "week-timed") { this.eventEl.addClass("calendar-event-timed-week"); @@ -235,7 +239,7 @@ export class CalendarEventComponent extends Component { // Only warn if layout is missing for week-timed console.warn( "Timed event render called without layout info for event:", - this.event.id + this.event.id, ); // Provide some default fallback style this.eventEl.style.position = "relative"; // Avoid breaking layout completely @@ -254,7 +258,7 @@ export class CalendarEventComponent extends Component { const checkbox = createTaskCheckbox( this.event.status, this.event, - this.eventEl + this.eventEl, ); this.registerDomEvent(checkbox, "click", (ev) => { @@ -274,7 +278,7 @@ export class CalendarEventComponent extends Component { this.markdownRenderer = new MarkdownRendererComponent( this.app, titleEl, - this.event.filePath + this.event.filePath, ); this.addChild(this.markdownRenderer); @@ -297,7 +301,7 @@ export class CalendarEventComponent extends Component { const checkbox = createTaskCheckbox( this.event.status, this.event, - this.eventEl + this.eventEl, ); this.registerDomEvent(checkbox, "click", (ev) => { @@ -323,7 +327,7 @@ export class CalendarEventComponent extends Component { this.markdownRenderer = new MarkdownRendererComponent( this.app, titleEl, - this.event.filePath + this.event.filePath, ); this.addChild(this.markdownRenderer); @@ -364,7 +368,7 @@ export function renderCalendarEvent(params: RenderEventParams): { "contextmenu", (ev) => { params.onEventContextMenu?.(ev, params.event); - } + }, ); return { eventEl: eventComponent.eventEl, component: eventComponent }; } diff --git a/src/components/features/kanban/kanban-card.ts b/src/components/features/kanban/kanban-card.ts index 0594f436..746d7a2d 100644 --- a/src/components/features/kanban/kanban-card.ts +++ b/src/components/features/kanban/kanban-card.ts @@ -30,9 +30,9 @@ export class KanbanCardComponent extends Component { onTaskContextMenu?: (ev: MouseEvent, task: Task) => void; onFilterApply?: ( filterType: string, - value: string | number | string[] + value: string | number | string[], ) => void; - } = {} + } = {}, ) { super(); this.plugin = plugin; @@ -51,7 +51,7 @@ export class KanbanCardComponent extends Component { const metadata = this.task.metadata || {}; if (metadata.priority) { const sanitizedPriority = sanitizePriorityForClass( - metadata.priority + metadata.priority, ); if (sanitizedPriority) { this.element.classList.add(`priority-${sanitizedPriority}`); @@ -67,7 +67,7 @@ export class KanbanCardComponent extends Component { const checkbox = createTaskCheckbox( this.task.status, this.task, - el + el, ); this.registerDomEvent(checkbox, "click", (ev) => { @@ -86,7 +86,7 @@ export class KanbanCardComponent extends Component { if ( ( this.plugin.settings.viewConfiguration.find( - (v) => v.id === "kanban" + (v) => v.id === "kanban", )?.specificConfig as KanbanSpecificConfig )?.showCheckbox ) { @@ -96,7 +96,7 @@ export class KanbanCardComponent extends Component { } this.contentEl = el.createDiv("tg-kanban-card-content"); - } + }, ); this.renderMarkdown(); @@ -126,14 +126,16 @@ export class KanbanCardComponent extends Component { this.markdownRenderer = new MarkdownRendererComponent( this.app, this.contentEl, - this.task.filePath + this.task.filePath, ); this.addChild(this.markdownRenderer); // Render the markdown content (use originalMarkdown or just description) // Using originalMarkdown might be too much, maybe just the description part? this.markdownRenderer.render( - this.task.content || this.task.originalMarkdown + this.task.metadata.source === "file-source" + ? this.task.originalMarkdown + : this.task.content || this.task.originalMarkdown, ); } @@ -189,7 +191,7 @@ export class KanbanCardComponent extends Component { dueEl.textContent = `${dateText}`; dueEl.setAttribute( "aria-label", - `Due: ${dueDate.toLocaleDateString()}` + `Due: ${dueDate.toLocaleDateString()}`, ); } @@ -201,11 +203,11 @@ export class KanbanCardComponent extends Component { const completedDate = new Date(metadata.completedDate || ""); completedEl.textContent = `Done: ${completedDate.toLocaleDateString( undefined, - { month: "short", day: "numeric" } + { month: "short", day: "numeric" }, )}`; completedEl.setAttribute( "aria-label", - `Completed: ${completedDate.toLocaleDateString()}` + `Completed: ${completedDate.toLocaleDateString()}`, ); } @@ -321,7 +323,7 @@ export class KanbanCardComponent extends Component { // Fallback: check for CSS custom properties set by other tag color plugins const computedStyle = getComputedStyle(document.body); const tagColorVar = computedStyle.getPropertyValue( - `--tag-color-${tagName}` + `--tag-color-${tagName}`, ); if (tagColorVar) { tagEl.style.setProperty("--tag-color", tagColorVar); @@ -348,7 +350,7 @@ export class KanbanCardComponent extends Component { if (oldMetadata.priority !== newMetadata.priority) { if (oldMetadata.priority) { const oldSanitized = sanitizePriorityForClass( - oldMetadata.priority + oldMetadata.priority, ); if (oldSanitized) { this.element.classList.remove(`priority-${oldSanitized}`); @@ -356,7 +358,7 @@ export class KanbanCardComponent extends Component { } if (newMetadata.priority) { const newSanitized = sanitizePriorityForClass( - newMetadata.priority + newMetadata.priority, ); if (newSanitized) { this.element.classList.add(`priority-${newSanitized}`);