mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
paragraph fixes
This commit is contained in:
parent
5d8827e4aa
commit
eef02108c9
@ -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());
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user