import React, { useRef, useEffect } from "react"; import { isCodeFilePath } from "@plannotator/core/code-file"; import type { Block } from "../../types"; import { sanitizeBlockHtml } from "../../utils/sanitizeHtml"; import { getImageSrc } from "../ImageThumbnail"; import { UNAVAILABLE_IMAGE_CLASS, useImageResolver, type ImageResolver } from "../ImageResolverContext"; import { isLocalLinkTarget, isNewTabClick, useLocalLinkResolver, type LocalLinkResolver } from "../LocalLinkContext"; interface HtmlBlockProps { block: Block; imageBaseDir?: string; onOpenLinkedDoc?: (path: string) => void; onOpenCodeFile?: (path: string) => void; onNavigateAnchor?: (hash: string) => void; } function unavailableMedia(doc: Document, label: string, title: string): HTMLSpanElement { const placeholder = doc.createElement('span'); placeholder.className = UNAVAILABLE_IMAGE_CLASS; placeholder.title = title; placeholder.setAttribute('data-image-unavailable', ''); placeholder.textContent = label; return placeholder; } /** * With a host image resolver (RenderedMarkdown `resolveImage`), every media * URL is the host's call, decided on an INERT copy before anything is in the * document, so nothing is fetched from the page origin first: * - `` goes through the resolver (`src`, or a placeholder); its * `srcset` / `sizes` are dropped, so the browser cannot pick a candidate * the host never saw. * - `` is dropped; the `` inside is the fallback. * - `