fix: aggregate large ink groups safely

This commit is contained in:
2026-07-22 19:54:51 +02:00
parent ebcaf436cf
commit 95341ed81f
2 changed files with 37 additions and 12 deletions

View File

@@ -15,7 +15,10 @@ import {
type OneNoteTextBlock,
} from '../src/onenote/index.js';
import type { ParserDiagnostic } from '../src/onenote/model/diagnostics.js';
import { parseContentObjects } from '../src/onenote/one/content.js';
import {
parseContentObjects,
unionInkBoundingBoxes,
} from '../src/onenote/one/content.js';
import { JCID, PROPERTY } from '../src/onenote/one/constants.js';
import type {
ExGuid,
@@ -209,6 +212,22 @@ describe('OneNote rich-content model', () => {
expect(parsedPoints).toBeLessThanOrEqual(100);
});
it('combines a large number of child ink bounds without argument spreading', () => {
const boxes = Array.from({ length: 200_000 }, (_, index) => ({
x: index,
y: -index,
width: 2,
height: 3,
}));
expect(unionInkBoundingBoxes([undefined, ...boxes])).toEqual({
x: 0,
y: -199_999,
width: 200_001,
height: 200_002,
});
});
it('bounds retained rich text across content blocks', () => {
const guid = '{33333333-3333-3333-3333-333333333333}';
const firstId = id(guid, 1);