js.documents 6.3.5 → 6.3.6

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.
@@ -225,9 +225,12 @@ function structureHeadingLevel(items, structure) {
225
225
  }
226
226
  const HEADING_MIN_SIZE_DELTA_PT = 2;
227
227
  const MAX_HEADING_LEVEL = 6;
228
+ function hasVisibleText(text) {
229
+ return text.trim().length > 0;
230
+ }
228
231
  function headingSizeLevels(doc) {
229
232
  const sizes = [];
230
- for (const page of doc.pages) for (const item of page.items) if (item.kind === "text") sizes.push(item.sizePt);
233
+ for (const page of doc.pages) for (const item of page.items) if (item.kind === "text" && hasVisibleText(item.text)) sizes.push(item.sizePt);
231
234
  if (sizes.length === 0) return /* @__PURE__ */ new Map();
232
235
  const bodySizePt = modeOf(sizes, .5);
233
236
  const headingBuckets = /* @__PURE__ */ new Set();
@@ -242,7 +245,7 @@ function headingSizeLevels(doc) {
242
245
  return levels;
243
246
  }
244
247
  function headingLevelOf(paragraph, levels) {
245
- return levels.get(modeOf(paragraph.lines.flatMap((line) => line.items.map((item) => item.sizePt)), .5));
248
+ return levels.get(modeOf(paragraph.lines.flatMap((line) => line.items).filter((item) => hasVisibleText(item.text)).map((item) => item.sizePt), .5));
246
249
  }
247
250
  function samePageSize(a, b) {
248
251
  return a.widthPt === b.widthPt && a.heightPt === b.heightPt;
@@ -224,9 +224,12 @@ function structureHeadingLevel(items, structure) {
224
224
  }
225
225
  const HEADING_MIN_SIZE_DELTA_PT = 2;
226
226
  const MAX_HEADING_LEVEL = 6;
227
+ function hasVisibleText(text) {
228
+ return text.trim().length > 0;
229
+ }
227
230
  function headingSizeLevels(doc) {
228
231
  const sizes = [];
229
- for (const page of doc.pages) for (const item of page.items) if (item.kind === "text") sizes.push(item.sizePt);
232
+ for (const page of doc.pages) for (const item of page.items) if (item.kind === "text" && hasVisibleText(item.text)) sizes.push(item.sizePt);
230
233
  if (sizes.length === 0) return /* @__PURE__ */ new Map();
231
234
  const bodySizePt = modeOf(sizes, .5);
232
235
  const headingBuckets = /* @__PURE__ */ new Set();
@@ -241,7 +244,7 @@ function headingSizeLevels(doc) {
241
244
  return levels;
242
245
  }
243
246
  function headingLevelOf(paragraph, levels) {
244
- return levels.get(modeOf(paragraph.lines.flatMap((line) => line.items.map((item) => item.sizePt)), .5));
247
+ return levels.get(modeOf(paragraph.lines.flatMap((line) => line.items).filter((item) => hasVisibleText(item.text)).map((item) => item.sizePt), .5));
245
248
  }
246
249
  function samePageSize(a, b) {
247
250
  return a.widthPt === b.widthPt && a.heightPt === b.heightPt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "6.3.5",
3
+ "version": "6.3.6",
4
4
  "description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {