@lukeashford/aurelius 4.1.0 → 4.2.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.
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3712,12 +3712,14 @@ import { Check as Check3, ChevronLeft as ChevronLeft2, ChevronRight as ChevronRi
|
|
|
3712
3712
|
import React54, { useMemo } from "react";
|
|
3713
3713
|
import DOMPurify from "dompurify";
|
|
3714
3714
|
import { marked } from "marked";
|
|
3715
|
-
DOMPurify.addHook
|
|
3716
|
-
|
|
3717
|
-
node.
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
}
|
|
3715
|
+
if (typeof window !== "undefined" && typeof DOMPurify.addHook === "function") {
|
|
3716
|
+
DOMPurify.addHook("afterSanitizeAttributes", (node) => {
|
|
3717
|
+
if (node.tagName === "A") {
|
|
3718
|
+
node.setAttribute("target", "_blank");
|
|
3719
|
+
node.setAttribute("rel", "noopener noreferrer");
|
|
3720
|
+
}
|
|
3721
|
+
});
|
|
3722
|
+
}
|
|
3721
3723
|
var DEFAULT_SANITIZE_CONFIG = {
|
|
3722
3724
|
ALLOWED_TAGS: [
|
|
3723
3725
|
"h1",
|
|
@@ -3794,6 +3796,9 @@ function injectStreamingCursor(html, cursorClassName) {
|
|
|
3794
3796
|
CURSOR_BASE_CLASSES,
|
|
3795
3797
|
cursorClassName
|
|
3796
3798
|
)}" aria-hidden="true"></span>`;
|
|
3799
|
+
if (typeof DOMParser === "undefined") {
|
|
3800
|
+
return html + cursorHtml;
|
|
3801
|
+
}
|
|
3797
3802
|
const parser = new DOMParser();
|
|
3798
3803
|
const doc = parser.parseFromString(`<div>${html}</div>`, "text/html");
|
|
3799
3804
|
const container = doc.body.firstChild;
|
|
@@ -3830,7 +3835,7 @@ var MarkdownContent = React54.forwardRef(
|
|
|
3830
3835
|
} else {
|
|
3831
3836
|
htmlContent = content;
|
|
3832
3837
|
}
|
|
3833
|
-
const sanitized = htmlContent ? DOMPurify.sanitize(htmlContent, config) : "";
|
|
3838
|
+
const sanitized = htmlContent && typeof DOMPurify.sanitize === "function" ? DOMPurify.sanitize(htmlContent, config) : htmlContent || "";
|
|
3834
3839
|
if (isStreaming) {
|
|
3835
3840
|
return injectStreamingCursor(sanitized, cursorClassName);
|
|
3836
3841
|
}
|