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;
|
stage: string;
|
||||||
message: string;
|
message: string;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [forceSingleTextElement, setForceSingleTextElement] = useState(false);
|
const [forceSingleTextElement, setForceSingleTextElement] = useState(true);
|
||||||
const [groupingMode, setGroupingMode] = useState<'auto' | 'paragraph' | 'singleLine'>('auto');
|
const [groupingMode, setGroupingMode] = useState<'auto' | 'paragraph' | 'singleLine'>('auto');
|
||||||
const [hasVectorPreview, setHasVectorPreview] = useState(false);
|
const [hasVectorPreview, setHasVectorPreview] = useState(false);
|
||||||
const [pagePreviews, setPagePreviews] = useState<Map<number, string>>(new Map());
|
const [pagePreviews, setPagePreviews] = useState<Map<number, string>>(new Map());
|
||||||
|
|||||||
@ -1069,15 +1069,17 @@ export const restoreGlyphElements = (
|
|||||||
|
|
||||||
groups.forEach((group) => {
|
groups.forEach((group) => {
|
||||||
if (group.text !== group.originalText) {
|
if (group.text !== group.originalText) {
|
||||||
if (forceMergedGroups) {
|
// Always try to rebuild paragraph lines if text has newlines
|
||||||
rebuiltElements.push(createMergedElement(group));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const paragraphElements = rebuildParagraphLineElements(group);
|
const paragraphElements = rebuildParagraphLineElements(group);
|
||||||
if (paragraphElements && paragraphElements.length > 0) {
|
if (paragraphElements && paragraphElements.length > 0) {
|
||||||
rebuiltElements.push(...paragraphElements);
|
rebuiltElements.push(...paragraphElements);
|
||||||
return;
|
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(
|
const originalGlyphCount = group.originalElements.reduce(
|
||||||
(sum, element) => sum + countGraphemes(element.text ?? ''),
|
(sum, element) => sum + countGraphemes(element.text ?? ''),
|
||||||
0,
|
0,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user