Wire HtmlViewerAdapter into ViewerShell for HTML/Markdown documents
UploadDropzone accepts HTML/MD files; ViewerShell routes by representationType; PendingSelection uses SelectionCapture union.
This commit is contained in:
parent
0cd2ca5d04
commit
589b8356b4
5 changed files with 208 additions and 95 deletions
47
src/work/ViewerShell.dom.test.tsx
Normal file
47
src/work/ViewerShell.dom.test.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// @vitest-environment happy-dom
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { createEngine, type Engine } from "@engine/index";
|
||||
import { ingestHtmlFromFile } from "@source/index";
|
||||
import { EngineProvider, useActiveDocumentId, usePdfByteStore } from "./EngineContext";
|
||||
import { ViewerShell } from "./ViewerShell";
|
||||
|
||||
function BootstrapHtmlDoc({
|
||||
engine,
|
||||
file,
|
||||
}: {
|
||||
readonly engine: Engine;
|
||||
readonly file: File;
|
||||
}) {
|
||||
const byteStore = usePdfByteStore();
|
||||
const { setId } = useActiveDocumentId();
|
||||
useEffect(() => {
|
||||
void ingestHtmlFromFile(file, byteStore).then(({ document, representation }) => {
|
||||
engine.documents.register({ document, representation });
|
||||
setId(document.id);
|
||||
});
|
||||
}, [byteStore, engine, file, setId]);
|
||||
return null;
|
||||
}
|
||||
|
||||
describe("ViewerShell (dom)", () => {
|
||||
it("renders HtmlViewerAdapter content for html-dom documents", async () => {
|
||||
const engine = createEngine();
|
||||
const file = new File(
|
||||
["<!DOCTYPE html><html><body><p>Dom viewer smoke test</p></body></html>"],
|
||||
"sample.html",
|
||||
{ type: "text/html" },
|
||||
);
|
||||
|
||||
render(
|
||||
<EngineProvider engine={engine}>
|
||||
<BootstrapHtmlDoc engine={engine} file={file} />
|
||||
<ViewerShell />
|
||||
</EngineProvider>,
|
||||
);
|
||||
|
||||
expect(await screen.findByText("Dom viewer smoke test")).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue