js.documents 14.4.123 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +21 -3
  2. package/dist/{composition-plan-l6QPO4FX.d.ts → composition-plan-B1Nn2JCQ.d.ts} +10 -1
  3. package/dist/{composition-plan-CfvhXeOC.cjs → composition-plan-BgsXTscN.cjs} +19 -7
  4. package/dist/{composition-plan-DU9nPPN7.d.cts → composition-plan-Cofo9qPI.d.cts} +10 -1
  5. package/dist/{composition-plan-f0zaExUW.js → composition-plan-mRolIOZY.js} +19 -7
  6. package/dist/convert/composition-plan.cjs +1 -1
  7. package/dist/convert/composition-plan.d.cts +1 -1
  8. package/dist/convert/composition-plan.d.ts +1 -1
  9. package/dist/convert/composition-plan.js +1 -1
  10. package/dist/convert/composition-to-pdf.cjs +1 -1
  11. package/dist/convert/composition-to-pdf.d.cts +1 -1
  12. package/dist/convert/composition-to-pdf.d.ts +1 -1
  13. package/dist/convert/composition-to-pdf.js +1 -1
  14. package/dist/convert/composition.cjs +1 -1
  15. package/dist/convert/composition.d.cts +1 -1
  16. package/dist/convert/composition.d.ts +1 -1
  17. package/dist/convert/composition.js +1 -1
  18. package/dist/convert/from-package.cjs +1 -1
  19. package/dist/convert/from-package.js +1 -1
  20. package/dist/convert/from-pdf.cjs +10 -6
  21. package/dist/convert/from-pdf.d.cts +10 -0
  22. package/dist/convert/from-pdf.d.ts +10 -0
  23. package/dist/convert/from-pdf.js +11 -7
  24. package/dist/convert/local.cjs +1 -1
  25. package/dist/convert/local.js +1 -1
  26. package/dist/convert/pdf-package-tables.cjs +3 -1
  27. package/dist/convert/pdf-package-tables.js +3 -1
  28. package/dist/edit/ods/floating.cjs +5 -3
  29. package/dist/edit/ods/floating.js +5 -3
  30. package/dist/edit/pdf/editor.cjs +4 -1
  31. package/dist/edit/pdf/editor.d.cts +1 -1
  32. package/dist/edit/pdf/editor.d.ts +1 -1
  33. package/dist/edit/pdf/editor.js +4 -1
  34. package/dist/index.cjs +22 -2
  35. package/dist/index.d.cts +4 -4
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.js +5 -5
  38. package/dist/layout/reconstruct-presentations-prod.cjs +1 -1
  39. package/dist/layout/reconstruct-presentations-prod.js +1 -1
  40. package/dist/layout/reconstruct-tables.cjs +1 -1
  41. package/dist/layout/reconstruct-tables.js +1 -1
  42. package/dist/layout/reconstruct.cjs +1 -1
  43. package/dist/layout/reconstruct.js +1 -1
  44. package/dist/markdown/render.d.cts +2 -2
  45. package/dist/markdown/render.d.ts +2 -2
  46. package/dist/markdown/write.cjs +54 -1
  47. package/dist/markdown/write.d.cts +23 -2
  48. package/dist/markdown/write.d.ts +23 -2
  49. package/dist/markdown/write.js +53 -2
  50. package/dist/{reconstruct-presentations-prod-X315aBmI.cjs → reconstruct-presentations-prod-CA4no_aw.cjs} +13 -12
  51. package/dist/{reconstruct-presentations-prod-B5fkPiRZ.js → reconstruct-presentations-prod-CC8ct-5O.js} +13 -12
  52. package/package.json +3 -3
@@ -6,6 +6,56 @@ const MATH_BLOCK_STYLE_ID = "MathBlock";
6
6
  const MATH_INLINE_FONT_MARKER = "Cambria Math";
7
7
  const MATH_INLINE_SOURCE = "markdown:math-inline";
8
8
  const PAGE_BREAK_MARKER = "<!-- page break -->";
9
+ /**
10
+ * The marker opening a page that `BuildMarkdownTextOptions.pageNumbers` labels: an HTML comment naming the page's number, `<!-- page 7 -->` for page 7, on a line of its own. An output-only annotation for readers of the text rather than a directive: unlike {@link PAGE_BREAK_MARKER} it states which page follows, not that a page ends, and nothing reads it back as one. Reading markdown that carries it keeps it as an ordinary HTML-comment paragraph, exactly as any other comment in a markdown source is kept, so a hand-written comment of the same shape is never mistaken for a label and lost.
11
+ * @param pageNumber - the number the page is labelled with, as the caller supplied it
12
+ * @returns the marker text
13
+ */
14
+ function pageNumberMarker(pageNumber) {
15
+ return `<!-- page ${String(pageNumber)} -->`;
16
+ }
17
+ /**
18
+ * `BuildMarkdownTextOptions.pageNumbers` did not supply exactly one number per page of the document. Thrown rather than labelling a prefix or padding, since a label on the wrong page is worse than none.
19
+ */
20
+ var MarkdownPageNumberCountError = class extends Error {
21
+ pageCount;
22
+ pageNumberCount;
23
+ constructor(pageCount, pageNumberCount) {
24
+ super(`pageNumbers supplies ${String(pageNumberCount)} page numbers for a document of ${String(pageCount)} pages; it must supply exactly one per page`);
25
+ this.name = "MarkdownPageNumberCountError";
26
+ this.pageCount = pageCount;
27
+ this.pageNumberCount = pageNumberCount;
28
+ }
29
+ };
30
+ function pageNumberParagraph(pageNumber) {
31
+ return {
32
+ kind: "paragraph",
33
+ runs: [{ text: pageNumberMarker(pageNumber) }],
34
+ styleId: markdown_codec.HTML_PREFORMATTED_STYLE_ID
35
+ };
36
+ }
37
+ function labelPages(sections, pageNumbers) {
38
+ let pageCount = 0;
39
+ const label = () => {
40
+ const pageNumber = pageNumbers[pageCount];
41
+ pageCount++;
42
+ return pageNumber === void 0 ? [] : [pageNumberParagraph(pageNumber)];
43
+ };
44
+ const labelled = sections.map((section, sectionIndex) => {
45
+ const blocks = [];
46
+ if (sectionIndex === 0 || section.breakType !== "continuous") blocks.push(...label());
47
+ for (const block of section.blocks) {
48
+ blocks.push(block);
49
+ if (block.kind === "pageBreak") blocks.push(...label());
50
+ }
51
+ return {
52
+ ...section,
53
+ blocks
54
+ };
55
+ });
56
+ if (pageCount !== pageNumbers.length) throw new MarkdownPageNumberCountError(pageCount, pageNumbers.length);
57
+ return labelled;
58
+ }
9
59
  function formulaParagraph(formula) {
10
60
  const latex = formula.presentation?.latex;
11
61
  if (latex === void 0) return {
@@ -53,7 +103,8 @@ function markdownTableCell(cell) {
53
103
  }
54
104
  function buildMarkdownText(document, options) {
55
105
  if (document.kind !== "wordprocessing") throw new markdown_codec.MarkdownUnsupportedDocumentKindError(document.kind);
56
- const sections = document.sections.map((section) => ({
106
+ const pageNumbers = options?.pageNumbers;
107
+ const sections = (pageNumbers === void 0 ? document.sections : labelPages(document.sections, pageNumbers)).map((section) => ({
57
108
  ...section,
58
109
  blocks: section.blocks.map(markdownBlock)
59
110
  }));
@@ -63,5 +114,7 @@ function buildMarkdownText(document, options) {
63
114
  }, options);
64
115
  }
65
116
  //#endregion
117
+ exports.MarkdownPageNumberCountError = MarkdownPageNumberCountError;
66
118
  exports.PAGE_BREAK_MARKER = PAGE_BREAK_MARKER;
67
119
  exports.buildMarkdownText = buildMarkdownText;
120
+ exports.pageNumberMarker = pageNumberMarker;
@@ -2,6 +2,27 @@ import { ContentDocument } from "document-schema.js";
2
2
  import { WriteMarkdownOptions } from "markdown-codec";
3
3
  //#region src/markdown/write.d.ts
4
4
  declare const PAGE_BREAK_MARKER = "<!-- page break -->";
5
- declare function buildMarkdownText(document: ContentDocument, options?: WriteMarkdownOptions): string;
5
+ /**
6
+ * The marker opening a page that `BuildMarkdownTextOptions.pageNumbers` labels: an HTML comment naming the page's number, `<!-- page 7 -->` for page 7, on a line of its own. An output-only annotation for readers of the text rather than a directive: unlike {@link PAGE_BREAK_MARKER} it states which page follows, not that a page ends, and nothing reads it back as one. Reading markdown that carries it keeps it as an ordinary HTML-comment paragraph, exactly as any other comment in a markdown source is kept, so a hand-written comment of the same shape is never mistaken for a label and lost.
7
+ * @param pageNumber - the number the page is labelled with, as the caller supplied it
8
+ * @returns the marker text
9
+ */
10
+ declare function pageNumberMarker(pageNumber: number): string;
11
+ /**
12
+ * `BuildMarkdownTextOptions.pageNumbers` did not supply exactly one number per page of the document. Thrown rather than labelling a prefix or padding, since a label on the wrong page is worse than none.
13
+ */
14
+ declare class MarkdownPageNumberCountError extends Error {
15
+ readonly pageCount: number;
16
+ readonly pageNumberCount: number;
17
+ constructor(pageCount: number, pageNumberCount: number);
18
+ }
19
+ interface BuildMarkdownTextOptions extends WriteMarkdownOptions {
20
+ /**
21
+ * One number per page of the document, in page order, written as {@link pageNumberMarker} at the start of each page so a reader of the text can tell which page each part came from. A page starts at the beginning of the document, after every top-level page break, and at the start of every section after the first that does not continue its predecessor's page (`breakType` other than `continuous`). Omitted, no page is labelled. The pdf conversions supply it for a page-selected read (`pages`), with each page's original one-based page number, since there the position of a part no longer says which page it is.
22
+ * @throws MarkdownPageNumberCountError when the count differs from the document's page count
23
+ */
24
+ readonly pageNumbers?: readonly number[];
25
+ }
26
+ declare function buildMarkdownText(document: ContentDocument, options?: BuildMarkdownTextOptions): string;
6
27
  //#endregion
7
- export { PAGE_BREAK_MARKER, buildMarkdownText };
28
+ export { BuildMarkdownTextOptions, MarkdownPageNumberCountError, PAGE_BREAK_MARKER, buildMarkdownText, pageNumberMarker };
@@ -2,6 +2,27 @@ import { ContentDocument } from "document-schema.js";
2
2
  import { WriteMarkdownOptions } from "markdown-codec";
3
3
  //#region src/markdown/write.d.ts
4
4
  declare const PAGE_BREAK_MARKER = "<!-- page break -->";
5
- declare function buildMarkdownText(document: ContentDocument, options?: WriteMarkdownOptions): string;
5
+ /**
6
+ * The marker opening a page that `BuildMarkdownTextOptions.pageNumbers` labels: an HTML comment naming the page's number, `<!-- page 7 -->` for page 7, on a line of its own. An output-only annotation for readers of the text rather than a directive: unlike {@link PAGE_BREAK_MARKER} it states which page follows, not that a page ends, and nothing reads it back as one. Reading markdown that carries it keeps it as an ordinary HTML-comment paragraph, exactly as any other comment in a markdown source is kept, so a hand-written comment of the same shape is never mistaken for a label and lost.
7
+ * @param pageNumber - the number the page is labelled with, as the caller supplied it
8
+ * @returns the marker text
9
+ */
10
+ declare function pageNumberMarker(pageNumber: number): string;
11
+ /**
12
+ * `BuildMarkdownTextOptions.pageNumbers` did not supply exactly one number per page of the document. Thrown rather than labelling a prefix or padding, since a label on the wrong page is worse than none.
13
+ */
14
+ declare class MarkdownPageNumberCountError extends Error {
15
+ readonly pageCount: number;
16
+ readonly pageNumberCount: number;
17
+ constructor(pageCount: number, pageNumberCount: number);
18
+ }
19
+ interface BuildMarkdownTextOptions extends WriteMarkdownOptions {
20
+ /**
21
+ * One number per page of the document, in page order, written as {@link pageNumberMarker} at the start of each page so a reader of the text can tell which page each part came from. A page starts at the beginning of the document, after every top-level page break, and at the start of every section after the first that does not continue its predecessor's page (`breakType` other than `continuous`). Omitted, no page is labelled. The pdf conversions supply it for a page-selected read (`pages`), with each page's original one-based page number, since there the position of a part no longer says which page it is.
22
+ * @throws MarkdownPageNumberCountError when the count differs from the document's page count
23
+ */
24
+ readonly pageNumbers?: readonly number[];
25
+ }
26
+ declare function buildMarkdownText(document: ContentDocument, options?: BuildMarkdownTextOptions): string;
6
27
  //#endregion
7
- export { PAGE_BREAK_MARKER, buildMarkdownText };
28
+ export { BuildMarkdownTextOptions, MarkdownPageNumberCountError, PAGE_BREAK_MARKER, buildMarkdownText, pageNumberMarker };
@@ -5,6 +5,56 @@ const MATH_BLOCK_STYLE_ID = "MathBlock";
5
5
  const MATH_INLINE_FONT_MARKER = "Cambria Math";
6
6
  const MATH_INLINE_SOURCE = "markdown:math-inline";
7
7
  const PAGE_BREAK_MARKER = "<!-- page break -->";
8
+ /**
9
+ * The marker opening a page that `BuildMarkdownTextOptions.pageNumbers` labels: an HTML comment naming the page's number, `<!-- page 7 -->` for page 7, on a line of its own. An output-only annotation for readers of the text rather than a directive: unlike {@link PAGE_BREAK_MARKER} it states which page follows, not that a page ends, and nothing reads it back as one. Reading markdown that carries it keeps it as an ordinary HTML-comment paragraph, exactly as any other comment in a markdown source is kept, so a hand-written comment of the same shape is never mistaken for a label and lost.
10
+ * @param pageNumber - the number the page is labelled with, as the caller supplied it
11
+ * @returns the marker text
12
+ */
13
+ function pageNumberMarker(pageNumber) {
14
+ return `<!-- page ${String(pageNumber)} -->`;
15
+ }
16
+ /**
17
+ * `BuildMarkdownTextOptions.pageNumbers` did not supply exactly one number per page of the document. Thrown rather than labelling a prefix or padding, since a label on the wrong page is worse than none.
18
+ */
19
+ var MarkdownPageNumberCountError = class extends Error {
20
+ pageCount;
21
+ pageNumberCount;
22
+ constructor(pageCount, pageNumberCount) {
23
+ super(`pageNumbers supplies ${String(pageNumberCount)} page numbers for a document of ${String(pageCount)} pages; it must supply exactly one per page`);
24
+ this.name = "MarkdownPageNumberCountError";
25
+ this.pageCount = pageCount;
26
+ this.pageNumberCount = pageNumberCount;
27
+ }
28
+ };
29
+ function pageNumberParagraph(pageNumber) {
30
+ return {
31
+ kind: "paragraph",
32
+ runs: [{ text: pageNumberMarker(pageNumber) }],
33
+ styleId: HTML_PREFORMATTED_STYLE_ID
34
+ };
35
+ }
36
+ function labelPages(sections, pageNumbers) {
37
+ let pageCount = 0;
38
+ const label = () => {
39
+ const pageNumber = pageNumbers[pageCount];
40
+ pageCount++;
41
+ return pageNumber === void 0 ? [] : [pageNumberParagraph(pageNumber)];
42
+ };
43
+ const labelled = sections.map((section, sectionIndex) => {
44
+ const blocks = [];
45
+ if (sectionIndex === 0 || section.breakType !== "continuous") blocks.push(...label());
46
+ for (const block of section.blocks) {
47
+ blocks.push(block);
48
+ if (block.kind === "pageBreak") blocks.push(...label());
49
+ }
50
+ return {
51
+ ...section,
52
+ blocks
53
+ };
54
+ });
55
+ if (pageCount !== pageNumbers.length) throw new MarkdownPageNumberCountError(pageCount, pageNumbers.length);
56
+ return labelled;
57
+ }
8
58
  function formulaParagraph(formula) {
9
59
  const latex = formula.presentation?.latex;
10
60
  if (latex === void 0) return {
@@ -52,7 +102,8 @@ function markdownTableCell(cell) {
52
102
  }
53
103
  function buildMarkdownText(document, options) {
54
104
  if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
55
- const sections = document.sections.map((section) => ({
105
+ const pageNumbers = options?.pageNumbers;
106
+ const sections = (pageNumbers === void 0 ? document.sections : labelPages(document.sections, pageNumbers)).map((section) => ({
56
107
  ...section,
57
108
  blocks: section.blocks.map(markdownBlock)
58
109
  }));
@@ -62,4 +113,4 @@ function buildMarkdownText(document, options) {
62
113
  }, options);
63
114
  }
64
115
  //#endregion
65
- export { PAGE_BREAK_MARKER, buildMarkdownText };
116
+ export { MarkdownPageNumberCountError, PAGE_BREAK_MARKER, buildMarkdownText, pageNumberMarker };
@@ -6,6 +6,7 @@ const require_ports_abort = require("./ports/abort.cjs");
6
6
  const require_layout_reconstruct_lines = require("./layout/reconstruct-lines.cjs");
7
7
  const require_layout_lattice = require("./layout/lattice.cjs");
8
8
  let document_schema_js = require("document-schema.js");
9
+ let pdf_codec_layout = require("pdf-codec/layout");
9
10
  //#region src/layout/reconstruct-tables.ts
10
11
  function recoverTables(page, pageIndex, structure) {
11
12
  if (structure !== void 0) {
@@ -381,17 +382,17 @@ function reconstructWordprocessing(doc, options) {
381
382
  const structure = indexStructure(doc);
382
383
  const sections = [];
383
384
  let currentGroup = [];
384
- let groupStartPageIndex = 0;
385
+ let groupStartPosition = 0;
385
386
  for (const page of doc.pages) {
386
387
  require_ports_abort.throwIfAborted(signal);
387
388
  if (currentGroup.length > 0 && !samePageSize(currentGroup[0], page)) {
388
- sections.push(buildSection(currentGroup, groupStartPageIndex, doc.images, headingLevels, doc.form, structure));
389
- groupStartPageIndex += currentGroup.length;
389
+ sections.push(buildSection(currentGroup, groupStartPosition, doc.images, headingLevels, doc.form, structure));
390
+ groupStartPosition += currentGroup.length;
390
391
  currentGroup = [];
391
392
  }
392
393
  currentGroup.push(page);
393
394
  }
394
- if (currentGroup.length > 0) sections.push(buildSection(currentGroup, groupStartPageIndex, doc.images, headingLevels, doc.form, structure));
395
+ if (currentGroup.length > 0) sections.push(buildSection(currentGroup, groupStartPosition, doc.images, headingLevels, doc.form, structure));
395
396
  return {
396
397
  kind: "wordprocessing",
397
398
  metadata: doc.metadata,
@@ -492,12 +493,12 @@ function headingLevelOf(paragraph, levels) {
492
493
  function samePageSize(a, b) {
493
494
  return a.widthPt === b.widthPt && a.heightPt === b.heightPt;
494
495
  }
495
- function buildSection(pages, startPageIndex, images, headingLevels, form, structure) {
496
+ function buildSection(pages, startPosition, images, headingLevels, form, structure) {
496
497
  const blocks = [];
497
498
  const divisionByBlock = /* @__PURE__ */ new WeakMap();
498
499
  pages.forEach((page, i) => {
499
500
  if (i > 0) blocks.push({ kind: "pageBreak" });
500
- blocks.push(...reconstructPageBlocks(page, startPageIndex + i, images, headingLevels, form, structure, divisionByBlock));
501
+ blocks.push(...reconstructPageBlocks(page, (0, pdf_codec_layout.sourcePageIndex)(page, startPosition + i), images, headingLevels, form, structure, divisionByBlock));
501
502
  });
502
503
  return {
503
504
  pageSize: {
@@ -736,9 +737,9 @@ function appendFormFieldConstructs(blocks, form, pageIndex) {
736
737
  }
737
738
  function reconstructSpreadsheet(doc, options) {
738
739
  const signal = options?.signal;
739
- const sheets = doc.pages.map((page, index) => {
740
+ const sheets = doc.pages.map((page, position) => {
740
741
  require_ports_abort.throwIfAborted(signal);
741
- return reconstructSheet(page, index, options?.onCellTypeInference);
742
+ return reconstructSheet(page, (0, pdf_codec_layout.sourcePageIndex)(page, position), options?.onCellTypeInference);
742
743
  });
743
744
  return {
744
745
  kind: "spreadsheet",
@@ -751,9 +752,9 @@ function reconstructSpreadsheet(doc, options) {
751
752
  function reconstructPresentation(doc, options) {
752
753
  const signal = options?.signal;
753
754
  const structure = indexStructure(doc);
754
- const slides = doc.pages.map((page, pageIndex) => {
755
+ const slides = doc.pages.map((page, position) => {
755
756
  require_ports_abort.throwIfAborted(signal);
756
- return reconstructSlide(page, pageIndex, doc.images, structure);
757
+ return reconstructSlide(page, (0, pdf_codec_layout.sourcePageIndex)(page, position), doc.images, structure);
757
758
  });
758
759
  return {
759
760
  kind: "presentation",
@@ -933,9 +934,9 @@ function imageToShape(img, slideHeightPt, pageIndex, images) {
933
934
  }
934
935
  function reconstructDrawing(doc, options) {
935
936
  const signal = options?.signal;
936
- const pages = doc.pages.map((page, pageIndex) => {
937
+ const pages = doc.pages.map((page, position) => {
937
938
  require_ports_abort.throwIfAborted(signal);
938
- return reconstructDrawPage(page, pageIndex, doc.images);
939
+ return reconstructDrawPage(page, (0, pdf_codec_layout.sourcePageIndex)(page, position), doc.images);
939
940
  });
940
941
  return {
941
942
  kind: "drawing",
@@ -6,6 +6,7 @@ import { throwIfAborted } from "./ports/abort.js";
6
6
  import { HALF_POINT_BUCKET_PT, bucketCounts, clusterIntoLines, clusterIntoParagraphs, estimateModalLineSpacing, fontSizesClose, gapExceeds, lineBox, modeOf, paragraphToContentParagraph, pushRunsForLine, textBoxOfItem, textItemToContentRun, textItemVerticalExtent } from "./layout/reconstruct-lines.js";
7
7
  import { detectGridLattice, findColumnIndex, findRowIndex } from "./layout/lattice.js";
8
8
  import { denseTableRows } from "document-schema.js";
9
+ import { sourcePageIndex } from "pdf-codec/layout";
9
10
  //#region src/layout/reconstruct-tables.ts
10
11
  function recoverTables(page, pageIndex, structure) {
11
12
  if (structure !== void 0) {
@@ -381,17 +382,17 @@ function reconstructWordprocessing(doc, options) {
381
382
  const structure = indexStructure(doc);
382
383
  const sections = [];
383
384
  let currentGroup = [];
384
- let groupStartPageIndex = 0;
385
+ let groupStartPosition = 0;
385
386
  for (const page of doc.pages) {
386
387
  throwIfAborted(signal);
387
388
  if (currentGroup.length > 0 && !samePageSize(currentGroup[0], page)) {
388
- sections.push(buildSection(currentGroup, groupStartPageIndex, doc.images, headingLevels, doc.form, structure));
389
- groupStartPageIndex += currentGroup.length;
389
+ sections.push(buildSection(currentGroup, groupStartPosition, doc.images, headingLevels, doc.form, structure));
390
+ groupStartPosition += currentGroup.length;
390
391
  currentGroup = [];
391
392
  }
392
393
  currentGroup.push(page);
393
394
  }
394
- if (currentGroup.length > 0) sections.push(buildSection(currentGroup, groupStartPageIndex, doc.images, headingLevels, doc.form, structure));
395
+ if (currentGroup.length > 0) sections.push(buildSection(currentGroup, groupStartPosition, doc.images, headingLevels, doc.form, structure));
395
396
  return {
396
397
  kind: "wordprocessing",
397
398
  metadata: doc.metadata,
@@ -492,12 +493,12 @@ function headingLevelOf(paragraph, levels) {
492
493
  function samePageSize(a, b) {
493
494
  return a.widthPt === b.widthPt && a.heightPt === b.heightPt;
494
495
  }
495
- function buildSection(pages, startPageIndex, images, headingLevels, form, structure) {
496
+ function buildSection(pages, startPosition, images, headingLevels, form, structure) {
496
497
  const blocks = [];
497
498
  const divisionByBlock = /* @__PURE__ */ new WeakMap();
498
499
  pages.forEach((page, i) => {
499
500
  if (i > 0) blocks.push({ kind: "pageBreak" });
500
- blocks.push(...reconstructPageBlocks(page, startPageIndex + i, images, headingLevels, form, structure, divisionByBlock));
501
+ blocks.push(...reconstructPageBlocks(page, sourcePageIndex(page, startPosition + i), images, headingLevels, form, structure, divisionByBlock));
501
502
  });
502
503
  return {
503
504
  pageSize: {
@@ -736,9 +737,9 @@ function appendFormFieldConstructs(blocks, form, pageIndex) {
736
737
  }
737
738
  function reconstructSpreadsheet(doc, options) {
738
739
  const signal = options?.signal;
739
- const sheets = doc.pages.map((page, index) => {
740
+ const sheets = doc.pages.map((page, position) => {
740
741
  throwIfAborted(signal);
741
- return reconstructSheet(page, index, options?.onCellTypeInference);
742
+ return reconstructSheet(page, sourcePageIndex(page, position), options?.onCellTypeInference);
742
743
  });
743
744
  return {
744
745
  kind: "spreadsheet",
@@ -751,9 +752,9 @@ function reconstructSpreadsheet(doc, options) {
751
752
  function reconstructPresentation(doc, options) {
752
753
  const signal = options?.signal;
753
754
  const structure = indexStructure(doc);
754
- const slides = doc.pages.map((page, pageIndex) => {
755
+ const slides = doc.pages.map((page, position) => {
755
756
  throwIfAborted(signal);
756
- return reconstructSlide(page, pageIndex, doc.images, structure);
757
+ return reconstructSlide(page, sourcePageIndex(page, position), doc.images, structure);
757
758
  });
758
759
  return {
759
760
  kind: "presentation",
@@ -933,9 +934,9 @@ function imageToShape(img, slideHeightPt, pageIndex, images) {
933
934
  }
934
935
  function reconstructDrawing(doc, options) {
935
936
  const signal = options?.signal;
936
- const pages = doc.pages.map((page, pageIndex) => {
937
+ const pages = doc.pages.map((page, position) => {
937
938
  throwIfAborted(signal);
938
- return reconstructDrawPage(page, pageIndex, doc.images);
939
+ return reconstructDrawPage(page, sourcePageIndex(page, position), doc.images);
939
940
  });
940
941
  return {
941
942
  kind: "drawing",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "14.4.123",
3
+ "version": "14.5.0",
4
4
  "description": "Converts between docx, pptx, odt, odp, ods, odg, xlsx, csv, svg, markdown, rtf, doc, xls, ppt and PDF through one shared, Zod-typed content schema (wpd read-only), plus read+write editors for OOXML and OpenDocument. Worker-isomorphic.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -85,8 +85,8 @@
85
85
  "fflate": "0.8.3",
86
86
  "markdown-codec": "11.1.16",
87
87
  "odf.js": "11.2.2",
88
- "ooxml.js": "12.2.31",
89
- "pdf-codec": "5.3.31",
88
+ "ooxml.js": "12.2.32",
89
+ "pdf-codec": "5.4.0",
90
90
  "ppt-codec": "2.2.23",
91
91
  "rtf-codec": "8.1.24",
92
92
  "temml": "0.13.4",