@adobe/helix-importer 2.9.7 → 2.9.8
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 +7 -0
- package/package.json +8 -8
- package/src/utils/DOMUtils.js +17 -6
- package/test/utils/DOMUtils.spec.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.9.8](https://github.com/adobe/helix-importer/compare/v2.9.7...v2.9.8) (2023-06-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-md2docx to v2.1.6 ([#169](https://github.com/adobe/helix-importer/issues/169)) ([232cb97](https://github.com/adobe/helix-importer/commit/232cb97011a4210fad6f240e9cd2e25886279b62))
|
|
7
|
+
|
|
1
8
|
## [2.9.7](https://github.com/adobe/helix-importer/compare/v2.9.6...v2.9.7) (2023-05-19)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-importer",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.8",
|
|
4
4
|
"description": "Helix Importer tool: create md / docx from html",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,34 +27,34 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@adobe/eslint-config-helix": "2.0.2",
|
|
29
29
|
"@adobe/helix-docx2md": "1.4.3",
|
|
30
|
-
"@adobe/helix-mediahandler": "2.
|
|
30
|
+
"@adobe/helix-mediahandler": "2.2.2",
|
|
31
31
|
"@semantic-release/changelog": "6.0.3",
|
|
32
32
|
"@semantic-release/exec": "6.0.3",
|
|
33
33
|
"@semantic-release/git": "10.0.1",
|
|
34
|
-
"c8": "
|
|
34
|
+
"c8": "8.0.0",
|
|
35
35
|
"dirname-filename-esm": "1.1.1",
|
|
36
|
-
"eslint": "8.
|
|
36
|
+
"eslint": "8.43.0",
|
|
37
37
|
"husky": "8.0.3",
|
|
38
38
|
"lint-staged": "13.2.2",
|
|
39
39
|
"mocha": "10.2.0",
|
|
40
40
|
"mocha-multi-reporters": "1.5.1",
|
|
41
41
|
"mock-fs": "5.2.0",
|
|
42
|
-
"semantic-release": "21.0.
|
|
42
|
+
"semantic-release": "21.0.5"
|
|
43
43
|
},
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@adobe/helix-markdown-support": "6.1.2",
|
|
47
|
-
"@adobe/helix-md2docx": "2.1.
|
|
47
|
+
"@adobe/helix-md2docx": "2.1.6",
|
|
48
48
|
"@adobe/mdast-util-gridtables": "1.0.6",
|
|
49
49
|
"@adobe/remark-gridtables": "1.0.2",
|
|
50
50
|
"form-data": "4.0.0",
|
|
51
51
|
"fs-extra": "11.1.1",
|
|
52
52
|
"hast-util-to-mdast": "9.0.0",
|
|
53
|
-
"jsdom": "22.
|
|
53
|
+
"jsdom": "22.1.0",
|
|
54
54
|
"node-fetch": "3.3.1",
|
|
55
55
|
"rehype-parse": "8.0.4",
|
|
56
56
|
"rehype-remark": "github:adobe-rnd/rehype-remark#45735e80a3d3c805d3c4211ae035f718ddd10bcb",
|
|
57
|
-
"remark-stringify": "10.0.
|
|
57
|
+
"remark-stringify": "10.0.3",
|
|
58
58
|
"unified": "10.1.2"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/utils/DOMUtils.js
CHANGED
|
@@ -256,12 +256,23 @@ export default class DOMUtils {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
static getImgFromBackground(element, document) {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
const styleAttr = element?.getAttribute('style')?.split(';');
|
|
260
|
+
if (styleAttr) {
|
|
261
|
+
styleAttr.forEach((style) => {
|
|
262
|
+
const [prop, value] = style.split(':');
|
|
263
|
+
if (prop === 'background-image') {
|
|
264
|
+
const trimmedValue = value.replace(/\s/g, '');
|
|
265
|
+
const elStyle = element.style;
|
|
266
|
+
elStyle.backgroundImage = trimmedValue;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
const url = element.style.backgroundImage;
|
|
270
|
+
if (url && url.toLowerCase() !== 'none') {
|
|
271
|
+
const src = url.replace(/url\(/gm, '').replace(/'/gm, '').replace(/\)/gm, '');
|
|
272
|
+
const img = document.createElement('img');
|
|
273
|
+
img.src = src;
|
|
274
|
+
return img;
|
|
275
|
+
}
|
|
265
276
|
}
|
|
266
277
|
return null;
|
|
267
278
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/* eslint-disable no-shadow */
|
|
14
14
|
|
|
15
15
|
import { strictEqual } from 'assert';
|
|
16
|
-
import { describe, it } from 'mocha';
|
|
16
|
+
import { describe, it, xit } from 'mocha';
|
|
17
17
|
|
|
18
18
|
import { JSDOM } from 'jsdom';
|
|
19
19
|
|
|
@@ -410,4 +410,14 @@ describe('DOMUtils#getImgFromBackground', () => {
|
|
|
410
410
|
test(createElement('p', {}, { 'background-image': 'url(https://www.server.com/image.jpg)' }, 'Some content'), '<img src="https://www.server.com/image.jpg">');
|
|
411
411
|
test(createElement('div', { class: 'someclass' }, { 'background-image': 'url("https://www.server.com/image.jpg")', background: 'rgb(0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box' }, '<div><div>Some divs</div><div>More divs</div></div>'), '<img src="https://www.server.com/image.jpg">');
|
|
412
412
|
});
|
|
413
|
+
|
|
414
|
+
// `createElement` uses JSDOM to create the test-DOM
|
|
415
|
+
// the workaround in DOMUtils#getImgFromBackground exists _precisely_
|
|
416
|
+
// because of a potential bug in JSDOM due to which it doesn't
|
|
417
|
+
// parse `url()` with whitespaces correctly
|
|
418
|
+
// disabling the test, keeping it as a reference
|
|
419
|
+
xit('with background-image style containing whitespace in url()', () => {
|
|
420
|
+
test(createElement('p', {}, { 'background-image': 'url( /image.jpg )' }, 'Some content'), '<img src="/image.jpg">');
|
|
421
|
+
test(createElement('div', { class: 'someclass' }, { 'background-image': 'url( https://www.server.com/image.jpg )', background: 'rgb(0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box' }, '<div><div>Some divs</div><div>More divs</div></div>'), '<img src="https://www.server.com/image.jpg">');
|
|
422
|
+
});
|
|
413
423
|
});
|