andy-stack_vaultkeeper-ai/Helpers/ElementHelper.ts
Andrew Beal d2e7b47c65 refactor: centralize icon handling and improve attachment UI
- Move icon name logic to Attachment and Reference classes
- Create reusable setElementIcon Svelte action in ElementHelper
- Update ChatArea and ChatAttachments to use new icon helper
- Add visual separator and background color for message attachments
- Fix duplicate URIs in drag-and-drop file handling
- Improve attachment icon centering with flexbox layout
2025-12-23 20:18:27 +00:00

20 lines
No EOL
615 B
TypeScript

import { setIcon } from "obsidian";
export function getOuterHeight(element: HTMLElement): number {
const marginTop = parseFloat(getComputedStyle(element).marginTop) || 0;
const marginBottom = parseFloat(getComputedStyle(element).marginBottom) || 0;
return element.offsetHeight + marginTop + marginBottom;
}
export function setElementIcon(element: HTMLDivElement, iconName: string) {
if (element) {
setIcon(element, iconName);
}
return {
update(newIconName: string) {
if (element) {
setIcon(element, newIconName);
}
}
};
}