paragraph fixes

This commit is contained in:
Anthony Stirling 2025-11-12 00:33:28 +00:00
parent 5d8827e4aa
commit eef02108c9
2 changed files with 7 additions and 5 deletions

View File

@ -77,7 +77,7 @@ const PdfJsonEditor = ({ onComplete, onError }: BaseToolProps) => {
stage: string;
message: string;
} | null>(null);
const [forceSingleTextElement, setForceSingleTextElement] = useState(false);
const [forceSingleTextElement, setForceSingleTextElement] = useState(true);
const [groupingMode, setGroupingMode] = useState<'auto' | 'paragraph' | 'singleLine'>('auto');
const [hasVectorPreview, setHasVectorPreview] = useState(false);
const [pagePreviews, setPagePreviews] = useState<Map<number, string>>(new Map());

View File

@ -1069,15 +1069,17 @@ export const restoreGlyphElements = (
groups.forEach((group) => {
if (group.text !== group.originalText) {
if (forceMergedGroups) {
rebuiltElements.push(createMergedElement(group));
return;
}
// Always try to rebuild paragraph lines if text has newlines
const paragraphElements = rebuildParagraphLineElements(group);
if (paragraphElements && paragraphElements.length > 0) {
rebuiltElements.push(...paragraphElements);
return;
}
// If no newlines or rebuilding failed, check if we should force merge
if (forceMergedGroups) {
rebuiltElements.push(createMergedElement(group));
return;
}
const originalGlyphCount = group.originalElements.reduce(
(sum, element) => sum + countGraphemes(element.text ?? ''),
0,