(
task: TaskInfo,
plugin: TaskNotesPlugin,
visibleProperties?: string[],
options: Partial<TaskCardOptions> = {}
)
| 120 | * createTaskCard(task, plugin, ["completeInstances", "status"]); // ❌ |
| 121 | */ |
| 122 | export function createTaskCard( |
| 123 | task: TaskInfo, |
| 124 | plugin: TaskNotesPlugin, |
| 125 | visibleProperties?: string[], |
| 126 | options: Partial<TaskCardOptions> = {} |
| 127 | ): HTMLElement { |
| 128 | const opts = { ...DEFAULT_TASK_CARD_OPTIONS, ...options }; |
| 129 | const renderState = buildTaskCardRenderState(task, plugin, opts); |
| 130 | const { targetDate, effectiveStatus, layout, isCompleted, hasDetails } = renderState; |
| 131 | |
| 132 | // Main container with BEM class structure |
| 133 | // Use span for inline layout to ensure proper inline flow in CodeMirror |
| 134 | const card = activeDocument.createElement(layout === "inline" ? "span" : "div"); |
| 135 | |
| 136 | // Store task path for circular reference detection |
| 137 | const taskCardElement = card as TaskCardElement; |
| 138 | taskCardElement._taskPath = task.path; |
| 139 | taskCardElement._taskCardOptions = opts; |
| 140 | |
| 141 | card.className = renderState.cardClasses.join(" "); |
| 142 | card.dataset.taskPath = task.path; |
| 143 | card.dataset.key = task.path; // For DOMReconciler compatibility |
| 144 | card.dataset.status = effectiveStatus; |
| 145 | if (task.priority) { |
| 146 | card.dataset.priority = task.priority; |
| 147 | } else { |
| 148 | delete card.dataset.priority; |
| 149 | } |
| 150 | card.dataset.hasDetails = hasDetails ? "true" : "false"; |
| 151 | |
| 152 | // Create main row container for horizontal layout |
| 153 | // Use span for inline layout to maintain inline flow |
| 154 | const mainRow = card.createEl(layout === "inline" ? "span" : "div", { |
| 155 | cls: "task-card__main-row", |
| 156 | }); |
| 157 | |
| 158 | applyTaskCardPriorityColor(card, task, plugin); |
| 159 | |
| 160 | createStatusIndicator({ |
| 161 | mainRow, |
| 162 | card, |
| 163 | task, |
| 164 | plugin, |
| 165 | effectiveStatus, |
| 166 | visibleProperties, |
| 167 | hideStatusIndicator: opts.hideStatusIndicator, |
| 168 | onClick: createStatusCycleHandler({ |
| 169 | task, |
| 170 | plugin, |
| 171 | targetDate, |
| 172 | updateStatusVisuals: (updatedTask, effectiveStatus, isCompleted) => { |
| 173 | const currentStatusDot = card.querySelector<HTMLElement>(".task-card__status-dot"); |
| 174 | if (currentStatusDot) { |
| 175 | updateTaskCardStatusIndicatorVisuals({ |
| 176 | card, |
| 177 | statusDot: currentStatusDot, |
| 178 | plugin, |
| 179 | updatedTask, |
no test coverage detected