mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 17:27:06 +08:00
fix: enhance lightbox (#2429)
* fix: close on click outside; smaller icon size * fix: make ALT more visible
This commit is contained in:
@@ -7,6 +7,27 @@ export function normalizeFileUrl(src: string): string {
|
||||
return src || "";
|
||||
}
|
||||
|
||||
export function syncAltBadge(wrapper: HTMLElement, alt: unknown): void {
|
||||
const existing = wrapper.querySelector<HTMLElement>(
|
||||
":scope > .media-alt-badge",
|
||||
);
|
||||
|
||||
if (typeof alt !== "string" || !alt.trim()) {
|
||||
existing?.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
const badge = existing ?? document.createElement("span");
|
||||
badge.dataset.alt = alt;
|
||||
|
||||
if (!existing) {
|
||||
badge.className = "media-alt-badge";
|
||||
badge.textContent = "ALT";
|
||||
badge.setAttribute("aria-hidden", "true");
|
||||
wrapper.appendChild(badge);
|
||||
}
|
||||
}
|
||||
|
||||
export type UploadFn = (
|
||||
file: File,
|
||||
editor: Editor,
|
||||
|
||||
Reference in New Issue
Block a user