@yoamigo.com/core 0.3.5 → 0.3.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/dist/index.js +13 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1055,17 +1055,19 @@ import DOMPurify from "dompurify";
|
|
|
1055
1055
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1056
1056
|
var ALLOWED_TAGS = ["strong", "em", "a", "span", "br", "b", "i", "u"];
|
|
1057
1057
|
var ALLOWED_ATTR = ["href", "style", "class", "target", "rel"];
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1058
|
+
if (typeof window !== "undefined") {
|
|
1059
|
+
DOMPurify.addHook("uponSanitizeAttribute", (_node, data) => {
|
|
1060
|
+
if (data.attrName === "style") {
|
|
1061
|
+
const allowedStyles = ["font-size", "font-weight"];
|
|
1062
|
+
const styleValue = data.attrValue;
|
|
1063
|
+
const filteredStyles = styleValue.split(";").map((s) => s.trim()).filter((s) => {
|
|
1064
|
+
const [prop] = s.split(":").map((p) => p.trim());
|
|
1065
|
+
return allowedStyles.includes(prop);
|
|
1066
|
+
}).join("; ");
|
|
1067
|
+
data.attrValue = filteredStyles;
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1069
1071
|
function extractLinkDisplayText(href) {
|
|
1070
1072
|
if (!href) return { text: "link", isExternal: false };
|
|
1071
1073
|
if (href.startsWith("#")) {
|