@adobe/helix-md2jcr 1.1.27 → 1.1.29

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.1.29](https://github.com/adobe/helix-md2jcr/compare/v1.1.28...v1.1.29) (2025-07-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * report content failing to map to the model ([#128](https://github.com/adobe/helix-md2jcr/issues/128)) ([52f9989](https://github.com/adobe/helix-md2jcr/commit/52f99890b6c7145afae65d784af62c09b25c9495)), closes [#127](https://github.com/adobe/helix-md2jcr/issues/127)
7
+
8
+ ## [1.1.28](https://github.com/adobe/helix-md2jcr/compare/v1.1.27...v1.1.28) (2025-07-16)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external major ([#16](https://github.com/adobe/helix-md2jcr/issues/16)) ([20a1999](https://github.com/adobe/helix-md2jcr/commit/20a1999bc2ae2f5fb3755a3da029b38f5b5e9f58))
14
+
1
15
  ## [1.1.27](https://github.com/adobe/helix-md2jcr/compare/v1.1.26...v1.1.27) (2025-07-16)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2jcr",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "description": "Helix Service that converts markdown to JCR content structure",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -32,13 +32,13 @@
32
32
  "@adobe/helix-markdown-support": "7.1.12",
33
33
  "@adobe/helix-shared-process-queue": "3.1.3",
34
34
  "@adobe/remark-gridtables": "3.0.14",
35
- "entities": "^5.0.0",
35
+ "entities": "^6.0.0",
36
36
  "github-slugger": "2.0.0",
37
37
  "handlebars": "^4.7.8",
38
38
  "hast-util-is-element": "3.0.0",
39
39
  "hast-util-to-html": "^9.0.3",
40
40
  "hast-util-to-mdast": "10.1.2",
41
- "image-size": "1.2.1",
41
+ "image-size": "2.0.2",
42
42
  "mdast-util-to-hast": "^13.2.0",
43
43
  "mdast-util-to-string": "^4.0.0",
44
44
  "mime": "4.0.7",
@@ -55,23 +55,23 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@adobe/eslint-config-helix": "3.0.8",
58
- "@adobe/helix-mediahandler": "2.7.17",
58
+ "@adobe/helix-mediahandler": "2.7.21",
59
59
  "@commitlint/cli": "^19.6.1",
60
60
  "@commitlint/config-conventional": "^19.6.0",
61
61
  "@semantic-release/changelog": "6.0.3",
62
- "@semantic-release/exec": "6.0.3",
62
+ "@semantic-release/exec": "7.1.0",
63
63
  "@semantic-release/git": "10.0.1",
64
64
  "c8": "10.1.3",
65
65
  "chai": "^5.2.0",
66
- "dotenv": "16.6.1",
66
+ "dotenv": "17.2.1",
67
67
  "eslint": "^9.0.0",
68
68
  "eslint-import-resolver-exports": "1.0.0-beta.5",
69
69
  "eslint-plugin-header": "3.1.1",
70
70
  "eslint-plugin-import": "2.32.0",
71
71
  "husky": "^9.1.7",
72
72
  "junit-report-builder": "5.1.1",
73
- "lint-staged": "15.5.2",
74
- "mocha": "10.8.2",
73
+ "lint-staged": "16.1.2",
74
+ "mocha": "11.7.1",
75
75
  "mocha-multi-reporters": "1.5.1",
76
76
  "nock": "13.5.6",
77
77
  "semantic-release": "24.2.7",
@@ -199,10 +199,25 @@ function extractKeyValueProperties(row, model, fieldResolver, fieldGroup, proper
199
199
 
200
200
  function processCell(cell, fieldGroup, fieldResolver, properties) {
201
201
  const cellChildren = cell.children;
202
+
202
203
  if (cellChildren.length !== 0) {
204
+ // while the cell has children we need to process the fields in the fieldGroup
205
+ // if we run out of fields but there are still more nodes, then we need to throw an error
206
+ // because the model does not map correctly to the content
203
207
  while (cellChildren.length > 0) {
204
208
  const node = cellChildren.shift();
209
+
210
+ // have we run out of fields?
211
+ if (fieldGroup.fields.length === 0) {
212
+ let errorMsg = 'The content isn’t mapping to the model correctly, likely due to the import ';
213
+ errorMsg += 'script generating incompatible markdown. Review the model file and ensure the ';
214
+ errorMsg += 'import script meets all column and row requirements, every field must align ';
215
+ errorMsg += 'with a column, even if empty.';
216
+ throw new Error(errorMsg);
217
+ }
218
+
205
219
  const field = fieldResolver.resolve(node, fieldGroup);
220
+
206
221
  let pWrapper;
207
222
  if (field.component === 'richtext') {
208
223
  pWrapper = {
@@ -294,7 +309,7 @@ function extractProperties(mdast, model, mode, component, fields, properties) {
294
309
  if (mode === 'blockItem') {
295
310
  fieldGroup = fieldsCloned.shift();
296
311
  }
297
- processCell(cell, fieldGroup, fieldResolver, properties, mode);
312
+ processCell(cell, fieldGroup, fieldResolver, properties);
298
313
  }
299
314
  }
300
315
  }
@@ -447,45 +462,53 @@ function gridTablePartial(context) {
447
462
  filters,
448
463
  );
449
464
 
465
+ // children of the parent block
466
+ let blockItems;
467
+
450
468
  // it is possible that a block (Accordion) does not have a model, but the
451
469
  // child component will, which will be handled in the Component Block Processing
452
470
  // section
453
- if (model) {
454
- fieldGroup = modelHelper.getModelFieldGroup(model.id);
455
- extractProperties(mdast, model, mode, component, fieldGroup.fields, properties);
456
- } else {
457
- // because we have no model we expect the block to have a filter with a component that does
458
- // so that means we can remove the header row from the mdast tree
459
- remove(mdast, (n) => is(n, { type: 'gtHeader' }));
460
- }
471
+ try {
472
+ if (model) {
473
+ fieldGroup = modelHelper.getModelFieldGroup(model.id);
474
+ extractProperties(mdast, model, mode, component, fieldGroup.fields, properties);
475
+ } else {
476
+ // because we have no model we expect the block to have a filter with a component that does
477
+ // so that means we can remove the header row from the mdast tree
478
+ remove(mdast, (n) => is(n, { type: 'gtHeader' }));
479
+ }
461
480
 
462
- // sort all the properties so that they are in a consistent order
463
- // helpful for debugging and xml readability
464
- const sorted = Object.entries(properties).sort(sortJcrProperties);
465
- blockProperties = sorted.map(([k, v]) => `${k}="${v}"`).join(' ');
466
-
467
- // *****************************************************
468
- // Component Block Processing
469
- // *****************************************************
470
- // 1. In this section attempt to locate the associated model for the block.
471
- // 2. Trim the mdast nodes to only be relevant for the child block.
472
- // 3. Then getBlockitems will process the mdast nodes and return the block items.
473
- const allowedComponents = filters.find((f) => f.id === component.filterId)?.components || [];
474
- // collect all rows
475
- const blockRows = findAll(mdast, (node) => node.type === 'gtRow', true);
476
- // the fieldGroup (parent model) determines the expected number of rows in the table
477
- // so we can remove the rows that belong to the parent and leave only the
478
- // relevant rows for the child
479
- if (model) {
480
- const removed = blockRows.splice(0, fieldGroup.fields.length + 1);
481
- // remove the elements from the mdast tree that match the items in the removed array
482
- removed.forEach((r) => {
483
- remove(mdast, (n) => is(n, r));
484
- });
481
+ // sort all the properties so that they are in a consistent order
482
+ // helpful for debugging and xml readability
483
+ const sorted = Object.entries(properties).sort(sortJcrProperties);
484
+ blockProperties = sorted.map(([k, v]) => `${k}="${v}"`).join(' ');
485
+
486
+ // *****************************************************
487
+ // Component Block Processing
488
+ // *****************************************************
489
+ // 1. In this section attempt to locate the associated model for the block.
490
+ // 2. Trim the mdast nodes to only be relevant for the child block.
491
+ // 3. Then getBlockitems will process the mdast nodes and return the block items.
492
+ const allowedComponents = filters.find((f) => f.id === component.filterId)?.components || [];
493
+ // collect all rows
494
+ const blockRows = findAll(mdast, (node) => node.type === 'gtRow', true);
495
+ // the fieldGroup (parent model) determines the expected number of rows in the table
496
+ // so we can remove the rows that belong to the parent and leave only the
497
+ // relevant rows for the child
498
+ if (model) {
499
+ const removed = blockRows.splice(0, fieldGroup.fields.length + 1);
500
+ // remove the elements from the mdast tree that match the items in the removed array
501
+ removed.forEach((r) => {
502
+ remove(mdast, (n) => is(n, r));
503
+ });
504
+ }
505
+ blockItems = getBlockItems(mdast, modelHelper, definition, allowedComponents) || [];
506
+ } catch (e) {
507
+ const blockname = `${blockHeaderProperties.name} ${blockHeaderProperties.classes ? `(${blockHeaderProperties.classes})` : ''}`;
508
+ const msg = `${blockname} has errors!`;
509
+ throw new Error(`${msg}\n${e?.message || e}`);
485
510
  }
486
511
 
487
- const blockItems = getBlockItems(mdast, modelHelper, definition, allowedComponents) || [];
488
-
489
512
  return `<block${uniqueName} ${blockProperties}>${blockItems.length > 0 ? blockItems.join('\n') : ''}</block${uniqueName}>`;
490
513
  }
491
514