(list: HTMLElement | null)
| 184 | } |
| 185 | |
| 186 | function setupResourceListHandlers(list: HTMLElement | null): void { |
| 187 | if (!list || resourceListHandlersReady) return; |
| 188 | |
| 189 | list.addEventListener('click', (event) => { |
| 190 | const target = event.target as HTMLElement; |
| 191 | if (target.closest('.resource-actions')) { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | const item = target.closest('.resource-item') as HTMLElement | null; |
| 196 | const button = item?.querySelector('.resource-preview') as HTMLElement | undefined; |
| 197 | const path = item?.dataset.path; |
| 198 | if (path) { |
| 199 | openPluginDetailsModal(path, button); |
| 200 | } |
| 201 | }); |
| 202 | |
| 203 | document.addEventListener('click', async (event) => { |
| 204 | const target = event.target as HTMLElement; |
| 205 | const installButton = target.closest( |
| 206 | '#plugin-details-install' |
| 207 | ) as HTMLButtonElement | null; |
| 208 | if (!installButton) return; |
| 209 | const pluginName = installButton.dataset.pluginName || ''; |
| 210 | if (!pluginName) return; |
| 211 | const command = `copilot plugin install ${pluginName}@awesome-copilot`; |
| 212 | const success = await copyToClipboard(command); |
| 213 | showToast(success ? 'Install command copied!' : 'Failed to copy', success ? 'success' : 'error'); |
| 214 | }); |
| 215 | |
| 216 | resourceListHandlersReady = true; |
| 217 | } |
| 218 | |
| 219 | function syncUrlState(): void { |
| 220 | updateQueryParams({ |
no test coverage detected