@json-to-office/core-docx 4.4.4 → 4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/blocks/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMlB,sBAAsB,EAEtB,KAAK,qBAAqB,EAG3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,YAAY,EACV,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAO7C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnC,eAAO,MAAM,iBAAiB,+BAAyB,CAAC;AAExD,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,EAAE,CA0B3E;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,GAAG,CAuCL;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,KAAK,GAAE,OAAO,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G;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,EAAE,CA0B3E;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,GAAG,CAuCL;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,WAAW,EAClB,KAAK,GAAE,OAAO,CAAC,qBAAqB,CAAM,EAC1C,OAAO,GAAE,SAAS,kBAAkB,EAAkC,GACrE,kBAAkB,CAWpB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,WAAW,GACjB,cAAc,CAAC,CAAC,CAAC,CAkBnB;AAoJD,8EAA8E;AAC9E,wBAAsB,uBAAuB,CAAC,CAAC,EAC7C,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,EAC5D,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAa,GACxC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC,CA+C/C"}
package/dist/index.js CHANGED
@@ -12322,6 +12322,7 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, sources
12322
12322
  }
12323
12323
  const props = isBlockRecord(section2.props) ? { ...section2.props } : {};
12324
12324
  if (chrome) {
12325
+ const declaring = local.includes(chrome);
12325
12326
  const environment = {
12326
12327
  ...chrome.environment,
12327
12328
  context: {
@@ -12344,7 +12345,7 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, sources
12344
12345
  );
12345
12346
  props[part] = evaluator.expand(compiled, `${path4}/props/${part}`);
12346
12347
  }
12347
- if (props.pageBreak === void 0)
12348
+ if (props.pageBreak === void 0 && declaring)
12348
12349
  props.pageBreak = chrome.settings.pageBreak ?? true;
12349
12350
  }
12350
12351
  for (const effect of local)
@@ -14631,6 +14632,39 @@ var docxRequiredChromeRule = {
14631
14632
  }));
14632
14633
  }
14633
14634
  };
14635
+ var docxExhibitRequiredRule = {
14636
+ id: "docx/exhibit-required",
14637
+ description: "Fewer data exhibits \u2014 charts, or tables of two or more columns \u2014 than a profile or policy expects. Off until one sets a minimum.",
14638
+ code: QUALITY_CODES.EXHIBIT_MISSING,
14639
+ category: "composition",
14640
+ defaultSeverity: "warning",
14641
+ defaultCertainty: "deterministic",
14642
+ formats: ["docx"],
14643
+ defaultEnabled: false,
14644
+ defaultParameters: { minimumExhibits: 1 },
14645
+ evaluate: ({ facts, configuration, profile }) => {
14646
+ const minimum = numberParameter(
14647
+ configuration.parameters,
14648
+ "minimumExhibits",
14649
+ 1
14650
+ );
14651
+ if (minimum <= 0) return [];
14652
+ const charts = facts.filter((fact) => fact.kind === "docx/chart").length;
14653
+ const tables = facts.filter(
14654
+ (fact) => fact.kind === "docx/table" && fact.columns.length >= 2
14655
+ ).length;
14656
+ const exhibits = charts + tables;
14657
+ if (exhibits >= minimum) return [];
14658
+ return [
14659
+ {
14660
+ path: themeFact(facts)?.path ?? "/props",
14661
+ message: exhibits === 0 ? `The document carries no data exhibit \u2014 no chart, no table of two or more columns; the ${profile?.id ?? "selected"} profile expects at least ${minimum}.` : `The document carries ${exhibits} data exhibit(s); the ${profile?.id ?? "selected"} profile expects at least ${minimum}.`,
14662
+ suggestion: "Put the numbers the argument leans on into a chart-figure or a data-table block, with a takeaway and a source, where the text discusses them. A kpi-row summarises; it does not count.",
14663
+ context: { charts, tables, minimum }
14664
+ }
14665
+ ];
14666
+ }
14667
+ };
14634
14668
  var SECTION_CHROME_PARTS = ["header", "footer", "pageNumber"];
14635
14669
  var docxRunningHeadRule = {
14636
14670
  id: "docx/running-head",
@@ -14660,7 +14694,7 @@ var docxRunningHeadRule = {
14660
14694
  {
14661
14695
  path: fact.path,
14662
14696
  message: `Section ${fact.index + 1} carries no ${parts}; the ${profile?.id ?? "selected"} profile expects a running head on every section after the cover.`,
14663
- suggestion: "Invoke a running-head block at the top of the first body section: its section effect fills every later section with the tracker and n / N.",
14697
+ suggestion: "Invoke a running-head block at the top of the first body section: its section effect fills every later section with the title and n / N.",
14664
14698
  context: { section: fact.index, missing }
14665
14699
  }
14666
14700
  ];
@@ -14848,6 +14882,7 @@ var DOCX_QUALITY_RULES = {
14848
14882
  docxPaletteRule,
14849
14883
  docxRequiredChromeRule,
14850
14884
  docxRunningHeadRule,
14885
+ docxExhibitRequiredRule,
14851
14886
  docxTypeScaleRule,
14852
14887
  docxSizeCountRule,
14853
14888
  docxRoleDriftRule
@@ -14857,7 +14892,7 @@ var DOCX_QUALITY_PROFILES = {
14857
14892
  "client-report": {
14858
14893
  id: "client-report",
14859
14894
  formats: ["docx"],
14860
- description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most eight in play, and no page rendered empty or left half blank under the running head.",
14895
+ description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most eight in play, no page rendered empty or left half blank under the running head, and at least one chart or table.",
14861
14896
  rules: {
14862
14897
  "docx/required-chrome": {
14863
14898
  parameters: { required: ["takeaway", "source"] }
@@ -14879,7 +14914,9 @@ var DOCX_QUALITY_PROFILES = {
14879
14914
  "rendered/empty-page": { severity: "warning" },
14880
14915
  // A section that ends early on its own page reads as unfinished; the
14881
14916
  // judge calls a page two-thirds blank a defect.
14882
- "rendered/page-underfilled": { severity: "warning" }
14917
+ "rendered/page-underfilled": { severity: "warning" },
14918
+ // A client report argues numbers: at least one chart or real table.
14919
+ "docx/exhibit-required": { enabled: true }
14883
14920
  }
14884
14921
  },
14885
14922
  "executive-report": {
@@ -15140,8 +15177,7 @@ var client_report_docx_blueprint_default = {
15140
15177
  ref: "section-opener",
15141
15178
  slots: {
15142
15179
  number: "01",
15143
- title: "{{Section title: the finding, as a statement}}",
15144
- tracker: "{{Tracker: one word}}"
15180
+ title: "{{Section title: the finding, as a statement}}"
15145
15181
  }
15146
15182
  }
15147
15183
  },
@@ -15198,8 +15234,7 @@ var client_report_docx_blueprint_default = {
15198
15234
  ref: "section-opener",
15199
15235
  slots: {
15200
15236
  number: "02",
15201
- title: "{{Section title: the finding, as a statement}}",
15202
- tracker: "{{Tracker: one word}}"
15237
+ title: "{{Section title: the finding, as a statement}}"
15203
15238
  }
15204
15239
  }
15205
15240
  },
@@ -15271,8 +15306,7 @@ var client_report_docx_blueprint_default = {
15271
15306
  ref: "section-opener",
15272
15307
  slots: {
15273
15308
  number: "03",
15274
- title: "{{Section title: the finding, as a statement}}",
15275
- tracker: "{{Tracker: one word}}"
15309
+ title: "{{Section title: the finding, as a statement}}"
15276
15310
  }
15277
15311
  }
15278
15312
  },
@@ -15325,8 +15359,7 @@ var client_report_docx_blueprint_default = {
15325
15359
  ref: "section-opener",
15326
15360
  slots: {
15327
15361
  number: "04",
15328
- title: "{{Section title: the finding, as a statement}}",
15329
- tracker: "{{Tracker: one word}}"
15362
+ title: "{{Section title: the finding, as a statement}}"
15330
15363
  }
15331
15364
  }
15332
15365
  },
@@ -15347,7 +15380,7 @@ var client_report_docx_blueprint_default = {
15347
15380
  ]
15348
15381
  },
15349
15382
  narrative: {
15350
- description: "Argument-led: takeaways, then three sections of prose with one KPI row and one note as evidence, next steps last.",
15383
+ description: "Argument-led: takeaways, then three sections of prose with one KPI row and one note as evidence, next steps last; one data table in the analysis section carries the numbers the argument leans on.",
15351
15384
  whenToUse: "The brief is a position, an assessment or a recommendation with few numbers; the reader follows an argument.",
15352
15385
  pages: {
15353
15386
  min: 3,
@@ -15397,8 +15430,7 @@ var client_report_docx_blueprint_default = {
15397
15430
  ref: "section-opener",
15398
15431
  slots: {
15399
15432
  number: "01",
15400
- title: "{{Section title: the finding, as a statement}}",
15401
- tracker: "{{Tracker: one word}}"
15433
+ title: "{{Section title: the finding, as a statement}}"
15402
15434
  }
15403
15435
  }
15404
15436
  },
@@ -15438,8 +15470,7 @@ var client_report_docx_blueprint_default = {
15438
15470
  ref: "section-opener",
15439
15471
  slots: {
15440
15472
  number: "02",
15441
- title: "{{Section title: the finding, as a statement}}",
15442
- tracker: "{{Tracker: one word}}"
15473
+ title: "{{Section title: the finding, as a statement}}"
15443
15474
  }
15444
15475
  }
15445
15476
  },
@@ -15476,8 +15507,7 @@ var client_report_docx_blueprint_default = {
15476
15507
  ref: "section-opener",
15477
15508
  slots: {
15478
15509
  number: "03",
15479
- title: "{{Section title: the finding, as a statement}}",
15480
- tracker: "{{Tracker: one word}}"
15510
+ title: "{{Section title: the finding, as a statement}}"
15481
15511
  }
15482
15512
  }
15483
15513
  },
@@ -15487,6 +15517,28 @@ var client_report_docx_blueprint_default = {
15487
15517
  text: "{{Body: two or three short paragraphs of evidence for the section title, each opening with its claim}}"
15488
15518
  }
15489
15519
  },
15520
+ {
15521
+ name: "block",
15522
+ props: {
15523
+ ref: "data-table",
15524
+ slots: {
15525
+ title: "{{Table title: what it compares, and the period}}",
15526
+ labelHeader: "{{Row label}}",
15527
+ labels: ["{{Row 1}}", "{{Row 2}}", "{{Row 3}}"],
15528
+ columns: [
15529
+ {
15530
+ header: "{{Measure (unit)}}",
15531
+ cells: ["{{0.0}}", "{{0.0}}", "{{0.0}}"]
15532
+ },
15533
+ {
15534
+ header: "{{Change}}",
15535
+ cells: ["{{0.0}}", "{{0.0}}", "{{0.0}}"]
15536
+ }
15537
+ ],
15538
+ source: "{{Source: system or document, date}}"
15539
+ }
15540
+ }
15541
+ },
15490
15542
  {
15491
15543
  name: "block",
15492
15544
  props: {
@@ -15527,8 +15579,7 @@ var client_report_docx_blueprint_default = {
15527
15579
  ref: "section-opener",
15528
15580
  slots: {
15529
15581
  number: "04",
15530
- title: "{{Section title: the finding, as a statement}}",
15531
- tracker: "{{Tracker: one word}}"
15582
+ title: "{{Section title: the finding, as a statement}}"
15532
15583
  }
15533
15584
  }
15534
15585
  },