@adobe/helix-md2jcr 1.0.5 → 1.0.7

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.0.7](https://github.com/adobe/helix-md2jcr/compare/v1.0.6...v1.0.7) (2025-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#44](https://github.com/adobe/helix-md2jcr/issues/44)) ([61fe813](https://github.com/adobe/helix-md2jcr/commit/61fe8134caba1f43b85264a2692cc478e3e09866))
7
+
8
+ ## [1.0.6](https://github.com/adobe/helix-md2jcr/compare/v1.0.5...v1.0.6) (2025-02-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * unsupported elements, include all template fields ([#43](https://github.com/adobe/helix-md2jcr/issues/43)) ([4cba7ec](https://github.com/adobe/helix-md2jcr/commit/4cba7ec79aee391a908c680519cf45429cb9bdb8))
14
+
1
15
  ## [1.0.5](https://github.com/adobe/helix-md2jcr/compare/v1.0.4...v1.0.5) (2025-01-30)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2jcr",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Helix Service that converts markdown to JCR content structure",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
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
- "hast-util-to-mdast": "10.1.1",
40
+ "hast-util-to-mdast": "10.1.2",
41
41
  "image-size": "1.2.0",
42
42
  "mdast-util-to-hast": "^13.2.0",
43
43
  "mdast-util-to-string": "^4.0.0",
@@ -52,14 +52,7 @@ class Component {
52
52
 
53
53
  /* eslint-disable no-unused-vars */
54
54
  get defaultFields() {
55
- // remove the fields that are listed below, but keep the rest as default fields
56
- // to be added to the block
57
- const {
58
- 'key-value': keyValue,
59
- ...rest
60
- } = this._template;
61
-
62
- return rest;
55
+ return this._template;
63
56
  }
64
57
  }
65
58
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2024 Adobe. All rights reserved.
2
+ * Copyright 2025 Adobe. All rights reserved.
3
3
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License. You may obtain a copy
5
5
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,8 +9,9 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- function tablePartial() {
13
- return '<section></section>\n';
12
+ export class UnsupportedElementError extends Error {
13
+ constructor(type) {
14
+ super(`Element '${type}' is currently not supported. Please open an issue for us and describe your use case.`);
15
+ this.name = 'UnsupportedElementError';
16
+ }
14
17
  }
15
-
16
- export default tablePartial;
@@ -9,14 +9,17 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
+
13
+ import Handlebars from 'handlebars';
14
+
12
15
  /**
13
16
  * Partial Resolver will return the partial helper that's associated with the
14
- * type.
17
+ * type. If no partial is found, it will return the unsupported partial.
15
18
  * @param type the type of partial
16
19
  * @returns {string} the partial type
17
20
  */
18
21
  function whichPartialHelper(type) {
19
- return type;
22
+ return Handlebars.partials[type] || Handlebars.partials.unsupported;
20
23
  }
21
24
 
22
25
  export default whichPartialHelper;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2024 Adobe. All rights reserved.
2
+ * Copyright 2025 Adobe. All rights reserved.
3
3
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License. You may obtain a copy
5
5
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -9,8 +9,10 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- function blockQuotePartial() {
13
- return '<section></section>\n';
12
+ import { UnsupportedElementError } from '../../error/UnsupportedElementError.js';
13
+
14
+ function unsupportedPartial(context) {
15
+ throw new UnsupportedElementError(context.type);
14
16
  }
15
17
 
16
- export default blockQuotePartial;
18
+ export default unsupportedPartial;
@@ -26,10 +26,9 @@ import imagePartial from './hb/partials/image.js';
26
26
  import encodeHelper from './hb/helpers/encode-helper.js';
27
27
  import whichPartialHelper from './hb/helpers/which-partial-helper.js';
28
28
  import gridTablePartial from './hb/partials/grid-table.js';
29
- import blockQuotePartial from './hb/partials/blockquote.js';
30
- import tablePartial from './hb/partials/table.js';
31
29
  import pageHelper from './hb/helpers/page-helper.js';
32
30
  import pageTemplate from './templates/page-template.js';
31
+ import unsupportedPartial from './hb/partials/unsupported.js';
33
32
 
34
33
  /**
35
34
  * Converts a markdown AST to JCR XML. This function is the main entry point
@@ -53,8 +52,7 @@ export default async function mdast2jcr(mdast, options = {}) {
53
52
  Handlebars.registerPartial('emphasis', emphasisPartial);
54
53
  Handlebars.registerPartial('paragraphWrapper', paragraphWrapperPartial);
55
54
  Handlebars.registerPartial('gridTable', gridTablePartial);
56
- Handlebars.registerPartial('blockquote', blockQuotePartial); // TODO
57
- Handlebars.registerPartial('table', tablePartial); // TODO
55
+ Handlebars.registerPartial('unsupported', unsupportedPartial);
58
56
 
59
57
  Handlebars.registerHelper('whichPartial', whichPartialHelper);
60
58
  Handlebars.registerHelper('encode', encodeHelper);