formatferry 1.0.19 → 1.0.20

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 (2) hide show
  1. package/dist/index.js +65 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22253,14 +22253,68 @@ function widgetToPositionedItems(ann) {
22253
22253
  if (str.length === 0) return [];
22254
22254
  return [mk(str)];
22255
22255
  }
22256
- if (ann.fieldType === "Btn" && (ann.checkBox === true || ann.radioButton === true)) {
22256
+ if (ann.fieldType === "Ch") {
22257
+ const raw = ann.fieldValue;
22258
+ const value = Array.isArray(raw) ? raw.join(", ") : raw;
22259
+ const str = (value ?? "").toString().trim();
22260
+ if (str.length === 0) return [];
22261
+ return [mk(str)];
22262
+ }
22263
+ if (ann.fieldType === "Btn" && ann.checkBox === true && !ann.radioButton) {
22257
22264
  const value = ann.fieldValue;
22258
22265
  const expected = ann.exportValue ?? ann.buttonValue ?? "Yes";
22259
22266
  const checked = value != null && value !== "Off" && (Array.isArray(value) ? value.includes(expected) : String(value) === expected);
22260
22267
  return [mk(checked ? "[X]" : "[ ]")];
22261
22268
  }
22269
+ if (ann.fieldType === "Btn" && ann.radioButton === true) {
22270
+ return [];
22271
+ }
22272
+ if (ann.fieldType === "Sig") {
22273
+ const isSigned = ann.fieldValue != null && ann.fieldValue !== "";
22274
+ return [mk(isSigned ? "[Signed]" : "[Signature]")];
22275
+ }
22262
22276
  return [];
22263
22277
  }
22278
+ function groupRadioButtons(annotations) {
22279
+ const radios = annotations.filter(
22280
+ (a) => a.fieldType === "Btn" && a.radioButton === true && a.rect?.length === 4
22281
+ );
22282
+ if (radios.length === 0) return [];
22283
+ const groups = /* @__PURE__ */ new Map();
22284
+ for (const r of radios) {
22285
+ const name = r.fieldName ?? "__unnamed__";
22286
+ let arr = groups.get(name);
22287
+ if (!arr) {
22288
+ arr = [];
22289
+ groups.set(name, arr);
22290
+ }
22291
+ arr.push(r);
22292
+ }
22293
+ const items = [];
22294
+ for (const [, members] of groups) {
22295
+ const selected = members.find((m) => {
22296
+ const v = m.fieldValue;
22297
+ return v != null && v !== "Off";
22298
+ });
22299
+ for (const m of members) {
22300
+ const [llx, lly, urx, ury] = m.rect;
22301
+ const w = urx - llx;
22302
+ const h = ury - lly;
22303
+ if (w <= 0 || h <= 0) continue;
22304
+ items.push({
22305
+ str: m === selected ? "[X]" : "[ ]",
22306
+ x: llx,
22307
+ y: lly,
22308
+ width: w,
22309
+ height: h,
22310
+ right: urx,
22311
+ rotation: 0,
22312
+ source: "acroform"
22313
+ });
22314
+ }
22315
+ }
22316
+ return items;
22317
+ }
22264
22318
  function normalizeForDedup(s) {
22265
22319
  return s.normalize("NFKC").replace(/\u200B|\u200C|\u200D|\uFEFF/g, "").replace(/\s+/g, " ").trim();
22266
22320
  }
@@ -22891,7 +22945,10 @@ var PdfAdapter = class {
22891
22945
  const p = textItemToPositioned(item);
22892
22946
  if (p) hfPositioned.push(p);
22893
22947
  }
22894
- const hfWidgets = hfAnns.flatMap(widgetToPositionedItems);
22948
+ const hfWidgets = [
22949
+ ...hfAnns.flatMap(widgetToPositionedItems),
22950
+ ...groupRadioButtons(hfAnns)
22951
+ ];
22895
22952
  const hfItems = hfWidgets.length > 0 ? [...dedupAgainstWidgets(hfPositioned, hfWidgets), ...hfWidgets] : hfPositioned;
22896
22953
  hfCandidates.push({ pageNum: pn, items: hfItems, viewportHeight: hfViewport.height });
22897
22954
  } catch {
@@ -22919,7 +22976,10 @@ var PdfAdapter = class {
22919
22976
  positionedText.push(positioned);
22920
22977
  xPositions.push(positioned.x);
22921
22978
  }
22922
- const widgetItems = annotations.flatMap(widgetToPositionedItems);
22979
+ const widgetItems = [
22980
+ ...annotations.flatMap(widgetToPositionedItems),
22981
+ ...groupRadioButtons(annotations)
22982
+ ];
22923
22983
  const items = widgetItems.length > 0 ? [...dedupAgainstWidgets(positionedText, widgetItems), ...widgetItems] : positionedText;
22924
22984
  if (getFeatureFlags().enablePdfEnhanced) {
22925
22985
  applyLinkAnnotations(items, annotations);
@@ -25358,8 +25418,8 @@ import { readFileSync as readFileSync4 } from "fs";
25358
25418
  import { resolve, dirname as dirname3 } from "path";
25359
25419
  import { fileURLToPath } from "url";
25360
25420
  var getVersion = () => {
25361
- if ("1.0.19") {
25362
- return "1.0.19";
25421
+ if ("1.0.20") {
25422
+ return "1.0.20";
25363
25423
  }
25364
25424
  try {
25365
25425
  const __dirname = dirname3(fileURLToPath(import.meta.url));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formatferry",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "FormatFerry CLI — Convert HTML, DOCX, PDF, XLSX, CSV, JSON, XML, PPTX to Markdown",
5
5
  "keywords": [
6
6
  "markdown",