npm package diff

Package: @forge/react

Versions: 10.8.0 - 10.9.0-next.0

File: package/out/components/utils/replaceUnsupportedDocumentNodes.js

Index: package/out/components/utils/replaceUnsupportedDocumentNodes.js
===================================================================
--- package/out/components/utils/replaceUnsupportedDocumentNodes.js
+++ package/out/components/utils/replaceUnsupportedDocumentNodes.js
@@ -0,0 +1,45 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.replaceUnsupportedDocumentNodes = void 0;
+const uuid_1 = require("uuid");
+const traverse_1 = require("@atlaskit/adf-utils/traverse");
+const replaceUnsupportedDocumentNodes = (document, replaceUnsupportedNode) => {
+    if (!replaceUnsupportedNode) {
+        return document;
+    }
+    const visitors = {
+        // Partially supported nodes
+        media: (node, parent, index, depth) => {
+            if (!node?.attrs?.url) {
+                return replaceUnsupportedNode(node, parent, index, depth);
+            }
+        },
+        emoji: (node, parent, index, depth) => {
+            if (node?.attrs?.id) {
+                // Custom Atlassian generated emoji
+                if (node.attrs.id.includes('atlassian')) {
+                    return replaceUnsupportedNode(node, parent, index, depth);
+                }
+                // Custom user generated emoji
+                const isIdGuid = (0, uuid_1.validate)(node.attrs.id);
+                if (isIdGuid) {
+                    return replaceUnsupportedNode(node, parent, index, depth);
+                }
+            }
+        },
+        // Fully unsupported nodes
+        extension: replaceUnsupportedNode,
+        bodiedExtension: replaceUnsupportedNode,
+        inlineExtension: replaceUnsupportedNode,
+        // Nodes shown when a bad node is passed
+        confluenceUnsupportedBlock: replaceUnsupportedNode,
+        confluenceUnsupportedInline: replaceUnsupportedNode,
+        confluenceJiraIssue: replaceUnsupportedNode,
+        unsupportedBlock: replaceUnsupportedNode,
+        unsupportedInline: replaceUnsupportedNode,
+        unknownBlock: replaceUnsupportedNode
+    };
+    const updatedDoc = (0, traverse_1.traverse)(document, visitors);
+    return updatedDoc ? { ...updatedDoc, version: document.version } : document;
+};
+exports.replaceUnsupportedDocumentNodes = replaceUnsupportedDocumentNodes;