* Helper function to create the task card widget * Now includes Component lifecycle management for proper cleanup
(plugin: TaskNotesPlugin, task: TaskInfo)
| 99 | * Now includes Component lifecycle management for proper cleanup |
| 100 | */ |
| 101 | function createTaskCardWidget(plugin: TaskNotesPlugin, task: TaskInfo): HTMLElementWithComponent { |
| 102 | const container = activeDocument.createElement("div") as HTMLElementWithComponent; |
| 103 | container.className = `tasknotes-plugin task-card-note-widget ${CSS_TASK_CARD_WIDGET}`; |
| 104 | |
| 105 | container.setAttribute("contenteditable", "false"); |
| 106 | container.setAttribute("spellcheck", "false"); |
| 107 | container.setAttribute("data-widget-type", "task-card"); |
| 108 | container.setAttribute("data-task-path", task.path); |
| 109 | |
| 110 | // Create component for lifecycle management |
| 111 | const component = new Component(); |
| 112 | component.load(); |
| 113 | container.component = component; |
| 114 | |
| 115 | // Get the visible properties from settings and convert internal names to user-configured names |
| 116 | const visibleProperties = plugin.settings.defaultVisibleProperties |
| 117 | ? convertInternalToUserProperties(plugin.settings.defaultVisibleProperties, plugin) |
| 118 | : undefined; |
| 119 | |
| 120 | // Create the task card |
| 121 | const taskCard = createTaskCard(task, plugin, visibleProperties); |
| 122 | |
| 123 | // Add specific styling for the note widget |
| 124 | taskCard.classList.add("task-card-note-widget__card"); |
| 125 | |
| 126 | container.appendChild(taskCard); |
| 127 | |
| 128 | return container; |
| 129 | } |
| 130 | |
| 131 | function removeTaskCardWidgets(container: ParentNode): void { |
| 132 | container.querySelectorAll(`.${CSS_TASK_CARD_WIDGET}`).forEach((el) => { |
no test coverage detected