metanote.io
metanote.io

Low Code

Help Center
📝
` + txt; htmlContent = txt; } else if (contentObj.blob) { htmlContent = atob(contentObj.blob); } if (htmlContent) { setSrcDoc(htmlContent); setIsLoading(false); } } else { types.log("Resource found, but content was empty.", "warn"); } } catch (err) { types.log(`MCP Resource Error: ${err.message}`, "error"); console.error("MCP Resource Error:", err); setIsLoading(false); } }; fetchData(); return () => { isCancelled = true; }; }, [toolInput?.serverUrl, toolInput?.outputTemplate]); // Effect 2: Synchronize data with the iframe via postMessage useEffect(() => { const iframe = iframeRef.current; if (!iframe || !srcDoc) return; const sendDataToIframe = () => { //iframe.contentWindow.openai = chatContext; }; // Safety Check: If the iframe is already loaded (common with srcDoc), // send the data immediately. if (iframe.contentDocument?.readyState === 'complete') { sendDataToIframe(); } // Standard listener for the load event iframe.addEventListener('load', sendDataToIframe); return () => iframe.removeEventListener('load', sendDataToIframe); }, [toolInput, toolOutput, srcDoc]); return (
{isLoading && (
Loading template...
)} {!isLoading && ( )}
); }`); })();