@etsoo/materialui 1.5.24 → 1.5.25

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.
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HtmlDiv = HtmlDiv;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const shared_1 = require("@etsoo/shared");
8
9
  const dompurify_1 = __importDefault(require("dompurify"));
9
10
  class HtmlDivElement extends HTMLElement {
10
11
  constructor() {
@@ -15,10 +16,16 @@ class HtmlDivElement extends HTMLElement {
15
16
  const shadow = this.attachShadow({ mode: "open" });
16
17
  // Create a wrapper element to hold the sanitized HTML content
17
18
  const wrapper = document.createElement("div");
18
- if (this.textContent) {
19
+ const html = this.innerHTML;
20
+ if (shared_1.Utils.hasHtmlEntity(html) &&
21
+ !shared_1.Utils.hasHtmlTag(html) &&
22
+ this.textContent) {
19
23
  wrapper.innerHTML = dompurify_1.default.sanitize(this.textContent);
20
- this.textContent = null; // Clear the textContent to avoid duplication
21
24
  }
25
+ else {
26
+ wrapper.innerHTML = dompurify_1.default.sanitize(html);
27
+ }
28
+ this.textContent = null; // Clear the textContent to avoid duplication
22
29
  shadow.appendChild(wrapper);
23
30
  }
24
31
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Utils } from "@etsoo/shared";
2
3
  import DOMPurify from "dompurify";
3
4
  class HtmlDivElement extends HTMLElement {
4
5
  constructor() {
@@ -9,10 +10,16 @@ class HtmlDivElement extends HTMLElement {
9
10
  const shadow = this.attachShadow({ mode: "open" });
10
11
  // Create a wrapper element to hold the sanitized HTML content
11
12
  const wrapper = document.createElement("div");
12
- if (this.textContent) {
13
+ const html = this.innerHTML;
14
+ if (Utils.hasHtmlEntity(html) &&
15
+ !Utils.hasHtmlTag(html) &&
16
+ this.textContent) {
13
17
  wrapper.innerHTML = DOMPurify.sanitize(this.textContent);
14
- this.textContent = null; // Clear the textContent to avoid duplication
15
18
  }
19
+ else {
20
+ wrapper.innerHTML = DOMPurify.sanitize(html);
21
+ }
22
+ this.textContent = null; // Clear the textContent to avoid duplication
16
23
  shadow.appendChild(wrapper);
17
24
  }
18
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.24",
3
+ "version": "1.5.25",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -43,7 +43,7 @@
43
43
  "@etsoo/appscript": "^1.6.22",
44
44
  "@etsoo/notificationbase": "^1.1.60",
45
45
  "@etsoo/react": "^1.8.38",
46
- "@etsoo/shared": "^1.2.66",
46
+ "@etsoo/shared": "^1.2.68",
47
47
  "@mui/icons-material": "^7.0.2",
48
48
  "@mui/material": "^7.0.2",
49
49
  "@mui/x-data-grid": "^7.28.3",
@@ -1,3 +1,4 @@
1
+ import { Utils } from "@etsoo/shared";
1
2
  import DOMPurify from "dompurify";
2
3
  import { HTMLAttributes } from "react";
3
4
 
@@ -12,11 +13,19 @@ class HtmlDivElement extends HTMLElement {
12
13
 
13
14
  // Create a wrapper element to hold the sanitized HTML content
14
15
  const wrapper = document.createElement("div");
15
- if (this.textContent) {
16
+ const html = this.innerHTML;
17
+ if (
18
+ Utils.hasHtmlEntity(html) &&
19
+ !Utils.hasHtmlTag(html) &&
20
+ this.textContent
21
+ ) {
16
22
  wrapper.innerHTML = DOMPurify.sanitize(this.textContent);
17
- this.textContent = null; // Clear the textContent to avoid duplication
23
+ } else {
24
+ wrapper.innerHTML = DOMPurify.sanitize(html);
18
25
  }
19
26
 
27
+ this.textContent = null; // Clear the textContent to avoid duplication
28
+
20
29
  shadow.appendChild(wrapper);
21
30
  }
22
31
  }