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

Function createTaskCardWidget

src/editor/TaskCardNoteDecorations.ts:101–129  ·  view source on GitHub ↗

* Helper function to create the task card widget * Now includes Component lifecycle management for proper cleanup

(plugin: TaskNotesPlugin, task: TaskInfo)

Source from the content-addressed store, hash-verified

99 * Now includes Component lifecycle management for proper cleanup
100 */
101function 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
131function removeTaskCardWidgets(container: ParentNode): void {
132 container.querySelectorAll(`.${CSS_TASK_CARD_WIDGET}`).forEach((el) => {

Callers 3

injectWidgetMethod · 0.85
injectReadingModeWidgetFunction · 0.85

Calls 2

createTaskCardFunction · 0.90

Tested by

no test coverage detected