@socialgouv/fiches-travail-data-types 4.439.0 → 4.440.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.
@@ -43,26 +43,35 @@ const formatPicture = (node) => {
43
43
  }
44
44
  }
45
45
  });
46
- if (!comment) {
47
- //upper sibbling node is not a comment so it's not a case we handle
48
- return;
46
+ if (comment) {
47
+ const [, src = ""] = comment.data.match(SRC_REGEX);
48
+ if (src.length) {
49
+ const srcClean = getCleanSrc(src);
50
+ node.parentNode.innerHTML = `<img src="${srcClean}" style="width:100%;height:auto;" />`;
51
+ return;
52
+ }
49
53
  }
50
- const [, src = ""] = comment.data.match(SRC_REGEX);
51
- if (src.length === 0) {
52
- return;
54
+ let image;
55
+ node
56
+ .childNodes
57
+ .forEach(function (childNode) {
58
+ if (childNode.nodeName === "IMG") {
59
+ image = childNode;
60
+ }
61
+ });
62
+ if (image) {
63
+ node.replaceWith(image);
53
64
  }
54
- const srcClean = getCleanSrc(src);
55
- node.parentNode.innerHTML = `<img src="${srcClean}" style="width:100%;height:auto;" />`;
56
65
  };
57
66
  const formatImage = (node) => {
58
67
  node.removeAttribute("onmousedown");
59
68
  if (node.getAttribute("src").indexOf("data:image") === -1) {
69
+ node.removeAttribute("srcset");
70
+ node.removeAttribute("sizes");
60
71
  let src = node.getAttribute("src");
61
72
  if (!src.match(/^https?:\/\//)) {
62
73
  const srcClean = getCleanSrc(src);
63
74
  node.setAttribute("src", srcClean);
64
- node.removeAttribute("srcset");
65
- node.removeAttribute("sizes");
66
75
  }
67
76
  }
68
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socialgouv/fiches-travail-data-types",
3
- "version": "4.439.0",
3
+ "version": "4.440.0",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.js",
6
6
  "files": [