Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix(webui): keep long source page controls scrollable

myhloli939918f2f019
diff --git a/mineru/kit/gradio/artifacts.py b/mineru/kit/gradio/artifacts.py
index 865557c6..6adfb82c 100644
--- a/mineru/kit/gradio/artifacts.py
+++ b/mineru/kit/gradio/artifacts.py
@@ -319,6 +319,8 @@ def _add_trace_preview(document: str, artifacts: RunArtifacts, *, middle_json: M
.mineru-trace-pages { position: fixed; right: 8px; z-index: 100;
display: flex; flex-wrap: wrap; gap: 4px;
max-width: 75%; padding: 5px; background: Canvas;
+ box-sizing: border-box; max-height: calc(100vh - var(--mineru-preview-offset, 8px) - 8px);
+ overflow-y: auto; overscroll-behavior: contain;
border: 1px solid var(--trace-strong); border-radius: 6px; }
.mineru-trace-pages[hidden] { display: none; }
.mineru-trace-pages button { cursor: pointer; color: CanvasText; background: Canvas;
diff --git a/mineru/resources/gradio_trace_html.js b/mineru/resources/gradio_trace_html.js
index 5c510af8..f45b5e42 100644
--- a/mineru/resources/gradio_trace_html.js
+++ b/mineru/resources/gradio_trace_html.js
@@ -130,6 +130,8 @@
);
}
window.addEventListener("scroll", positionNavigation, { passive: true });
+ // 预览区缩小时重新约束控件位置,即使用户操作已停用正文自动对齐。
+ window.addEventListener("resize", positionNavigation);
// 目录接管正文导航时,结束旧来源块的自动对齐。
window.addEventListener("mineru-preview-navigate", () => { alignOnResize = false; });
const observer = new ResizeObserver(() => {
diff --git a/tests/unittest/test_kit_gradio_trace.cjs b/tests/unittest/test_kit_gradio_trace.cjs
index 007a647f..100c173f 100644
--- a/tests/unittest/test_kit_gradio_trace.cjs
+++ b/tests/unittest/test_kit_gradio_trace.cjs
@@ -137,6 +137,10 @@ const checkHtmlNavigation = (
} });
assert.equal(selected.style["--trace-color"], "rgb(0 153 26)");
assert.equal(navigation.style["--trace-color"], selected.style["--trace-color"]);
+ // 用户选择后已停用正文自动对齐,缩小视口仍须把来源控件移回可见范围。
+ context.innerHeight = 200;
+ htmlHandlers.resize();
+ assert.equal(navigation.style.top, `${Math.min(expectedTop, 162)}px`);
};
checkHtmlNavigation("52px", -100, 52);
checkHtmlNavigation("", -100, 8);
diff --git a/tests/unittest/test_kit_gradio_trace.py b/tests/unittest/test_kit_gradio_trace.py
index 64137030..3b6d13bf 100644
--- a/tests/unittest/test_kit_gradio_trace.py
+++ b/tests/unittest/test_kit_gradio_trace.py
@@ -28,6 +28,10 @@ def test_pdf_trace_preview_and_public_render(tmp_path: Path) -> None:
assert document.select_one("[data-docvortex-trace-id]")
assert artifacts.root.name in document.get_text() or artifacts.root.name in str(document)
assert "pageIndices" in str(document)
+ trace_style = next(style.string for style in document.select("style") if ".mineru-trace-pages {" in (style.string or ""))
+ assert "max-height: calc(100vh - var(--mineru-preview-offset, 8px) - 8px)" in trace_style
+ assert "overflow-y: auto" in trace_style
+ assert "box-sizing: border-box" in trace_style
script = next(script.string for script in document.select("script") if script.string and '"layoutRegions"' in script.string)
config = json.loads(script.rsplit(")(", 1)[1].removesuffix(");"))
assert config["layoutRegions"]