fix
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
@@ -154,24 +154,6 @@ std::expected<PageImage, EngineError> PdfiumPage::renderRegionRaw(int dpi, doubl
|
||||
}
|
||||
}
|
||||
|
||||
spdlog::error("[RENDER_REGION_RAW_INSTRUMENTATION] 1. Region width: {}, height: {} (dpi: {}, yTopPt: {:.2f}, heightPt: {:.2f}, pagePt: {:.2f}x{:.2f})",
|
||||
w, regionH, dpi, yTopPt, heightPt, width(), height());
|
||||
spdlog::error("[RENDER_REGION_RAW_INSTRUMENTATION] 2. Initialized with opaque white fill (0xFFFFFFFF): TRUE (via FPDFBitmap_FillRect)");
|
||||
spdlog::error("[RENDER_REGION_RAW_INSTRUMENTATION] 3. Content scope: Entire page vertical slice from yTopPx={} to yTopPx+regionH={} (renders ALL page objects in slice, not just edited paragraph)",
|
||||
yTopPx, yTopPx + regionH);
|
||||
spdlog::error("[RENDER_REGION_RAW_INSTRUMENTATION] 4. Alpha transparency check: allAlpha255={}, non255Count={}",
|
||||
allAlpha255 ? "TRUE (100% opaque, alpha=255 everywhere)" : "FALSE", non255Count);
|
||||
|
||||
std::vector<uint8_t> pngBytes = encodeBgraToPng(bgra, w, regionH, stride);
|
||||
if (!pngBytes.empty()) {
|
||||
FILE* f = fopen("debug_preview_region.png", "wb");
|
||||
if (f) {
|
||||
fwrite(pngBytes.data(), 1, pngBytes.size(), f);
|
||||
fclose(f);
|
||||
spdlog::error("[RENDER_REGION_RAW_INSTRUMENTATION] Saved preview bitmap to debug_preview_region.png (size: {} bytes)", pngBytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
FPDFBitmap_Destroy(bitmap);
|
||||
return PageImage{w, regionH, std::move(rgba)};
|
||||
#else
|
||||
|
||||
@@ -48,6 +48,7 @@ export interface RenderParams {
|
||||
pageIndex: number;
|
||||
zoom: number;
|
||||
rotation: number;
|
||||
dpi?: number;
|
||||
}
|
||||
|
||||
export interface Annotation {
|
||||
|
||||
@@ -386,10 +386,7 @@ function sanitizeEngineLayout(
|
||||
return lay;
|
||||
}
|
||||
|
||||
function globalCaretOffset(el: HTMLElement, caretRefVal?: number): number {
|
||||
if (typeof caretRefVal === 'number') return caretRefVal;
|
||||
return (el.textContent ?? '').length;
|
||||
}
|
||||
|
||||
|
||||
/** Live caret index inside a contentEditable — matches setGlobalCaretOffset / textContent indexing. */
|
||||
function getDomCaretOffset(el: HTMLElement): number | null {
|
||||
@@ -574,7 +571,6 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
||||
const [hasPreview, setHasPreview] = useState(false);
|
||||
const [caretBox, setCaretBox] = useState<{ left: number; top: number; height: number } | null>(null);
|
||||
const [edited, setEdited] = useState(false);
|
||||
const [wasmFailed, setWasmFailed] = useState(false);
|
||||
const [listKind, setListKind] = useState<ListKind | null>(null);
|
||||
const [indentLevel, setIndentLevel] = useState(0);
|
||||
const INDENT_STEP = 18; // pt per nesting level (whole-block indent; per-item nesting is a known limit)
|
||||
@@ -606,8 +602,10 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
||||
}
|
||||
const lineH = (para?.lines ?? []).reduce((m: number, ln: any) => Math.max(m, ln?.h ?? 0), 0);
|
||||
if (!isFinite(minX)) {
|
||||
return { x: layout.columnLeft, y: bl - domSize * 0.8, w: Math.max(0, columnRight - layout.columnLeft),
|
||||
h: lineH || domSize * 1.2, ascent: domSize * 0.8, descent: domSize * 0.2, lineHeight: lineH || domSize * 1.2 };
|
||||
return {
|
||||
x: layout.columnLeft, y: bl - domSize * 0.8, w: Math.max(0, columnRight - layout.columnLeft),
|
||||
h: lineH || domSize * 1.2, ascent: domSize * 0.8, descent: domSize * 0.2, lineHeight: lineH || domSize * 1.2
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: minX, y: minY, w: maxX - minX, h: maxY - minY,
|
||||
@@ -628,7 +626,6 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
||||
const bandTop = Math.max(0, Math.min(editorTop - leadingPx * 0.5, firstBaselineScreen - fontPx * 1.15));
|
||||
// Keep column metrics for reflow payload / toolbar (editing column can be wider than ink bbox).
|
||||
const colLeftPx = columnLeft * zoom;
|
||||
const colWidthPx = (columnRight - columnLeft) * zoom;
|
||||
|
||||
// Fix 1: use extracted PDF font name (loaded via @font-face), not a generic Arial/Times/Courier map.
|
||||
const extractedFamily = (domFontName || '').replace(/^[A-Z]{6}\+/, '').trim() || 'sans-serif';
|
||||
@@ -966,8 +963,8 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
||||
// Preserve PDF hard line breaks (not a single CSS-wrapped flow).
|
||||
const lineFrags = layout.origLines.length
|
||||
? layout.origLines.map((l) => l.frags.map((f) => ({
|
||||
text: f.text, fid: f.fid, size: f.size, color: f.color, fontName: domFontName, advances: f.advances,
|
||||
})))
|
||||
text: f.text, fid: f.fid, size: f.size, color: f.color, fontName: domFontName, advances: f.advances,
|
||||
})))
|
||||
: [layout.seedRuns];
|
||||
lineFrags.forEach((frags, li) => {
|
||||
if (li > 0) el.appendChild(document.createElement('br'));
|
||||
@@ -1165,12 +1162,7 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
||||
});
|
||||
}, [fallbackVisible]);
|
||||
|
||||
// Diagnostics only — does not drive a visible HTML fallback.
|
||||
useEffect(() => {
|
||||
if (hasPreview) return;
|
||||
const t = window.setTimeout(() => setWasmFailed(true), 4000);
|
||||
return () => window.clearTimeout(t);
|
||||
}, [hasPreview]);
|
||||
|
||||
|
||||
const composingRef = useRef(false);
|
||||
const ignoreInputUntilRef = useRef(Date.now() + 150);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 173 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB |
Reference in New Issue
Block a user