@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.
Files changed (2) hide show
  1. package/dist/index.js +13 -11
  2. 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
- DOMPurify.addHook("uponSanitizeAttribute", (_node, data) => {
1059
- if (data.attrName === "style") {
1060
- const allowedStyles = ["font-size", "font-weight"];
1061
- const styleValue = data.attrValue;
1062
- const filteredStyles = styleValue.split(";").map((s) => s.trim()).filter((s) => {
1063
- const [prop] = s.split(":").map((p) => p.trim());
1064
- return allowedStyles.includes(prop);
1065
- }).join("; ");
1066
- data.attrValue = filteredStyles;
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("#")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/core",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Core components, router, and utilities for YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",