@adobe/helix-md2jcr 1.0.4 → 1.0.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.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/mdast2jcr/domain/Component.js +1 -8
- package/src/mdast2jcr/{hb/partials/table.js → error/UnsupportedElementError.js} +6 -5
- package/src/mdast2jcr/hb/helpers/which-partial-helper.js +5 -2
- package/src/mdast2jcr/hb/partials/grid-table.js +5 -5
- package/src/mdast2jcr/hb/partials/{blockquote.js → unsupported.js} +6 -4
- package/src/mdast2jcr/index.js +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.0.6](https://github.com/adobe/helix-md2jcr/compare/v1.0.5...v1.0.6) (2025-02-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* unsupported elements, include all template fields ([#43](https://github.com/adobe/helix-md2jcr/issues/43)) ([4cba7ec](https://github.com/adobe/helix-md2jcr/commit/4cba7ec79aee391a908c680519cf45429cb9bdb8))
|
|
7
|
+
|
|
8
|
+
## [1.0.5](https://github.com/adobe/helix-md2jcr/compare/v1.0.4...v1.0.5) (2025-01-30)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **sites-28655:** blocks that have no model are missing properties ([#42](https://github.com/adobe/helix-md2jcr/issues/42)) ([7b07416](https://github.com/adobe/helix-md2jcr/commit/7b07416bb0fb691c9cfc1213b8e87362a87980b6))
|
|
14
|
+
|
|
1
15
|
## [1.0.4](https://github.com/adobe/helix-md2jcr/compare/v1.0.3...v1.0.4) (2025-01-28)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -52,14 +52,7 @@ class Component {
|
|
|
52
52
|
|
|
53
53
|
/* eslint-disable no-unused-vars */
|
|
54
54
|
get defaultFields() {
|
|
55
|
-
|
|
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
|
|
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
|
-
|
|
13
|
-
|
|
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;
|
|
@@ -458,17 +458,17 @@ function gridTablePartial(context) {
|
|
|
458
458
|
if (model) {
|
|
459
459
|
fieldGroup = modelHelper.getModelFieldGroup(model.id);
|
|
460
460
|
extractProperties(mdast, model, mode, component, fieldGroup.fields, properties);
|
|
461
|
-
|
|
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
461
|
} else {
|
|
467
462
|
// because we have no model we expect the block to have a filter with a component that does
|
|
468
463
|
// so that means we can remove the header row from the mdast tree
|
|
469
464
|
remove(mdast, (n) => is(n, { type: 'gtHeader' }));
|
|
470
465
|
}
|
|
471
466
|
|
|
467
|
+
// sort all the properties so that they are in a consistent order
|
|
468
|
+
// helpful for debugging and xml readability
|
|
469
|
+
const sorted = Object.entries(properties).sort(sortJcrProperties);
|
|
470
|
+
blockProperties = sorted.map(([k, v]) => `${k}="${v}"`).join(' ');
|
|
471
|
+
|
|
472
472
|
// *****************************************************
|
|
473
473
|
// Component Block Processing
|
|
474
474
|
// *****************************************************
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
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
|
-
|
|
13
|
-
|
|
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
|
|
18
|
+
export default unsupportedPartial;
|
package/src/mdast2jcr/index.js
CHANGED
|
@@ -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('
|
|
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);
|