@typeface-ai/typeface-embed-react
Advanced tools
Comparing version
@@ -40,3 +40,5 @@ import { CSSProperties } from "react"; | ||
ON_ERROR = "onError", | ||
ON_IFRAME_URL_UPDATE = "onIframeUrlUpdate" | ||
ON_IFRAME_URL_UPDATE = "onIframeUrlUpdate", | ||
ON_IFRAME_URL_LOAD = "onIframeUrlLoad", | ||
ON_IFRAME_URL_LOAD_FAIL = "onIframeUrlLoadFail" | ||
} | ||
@@ -43,0 +45,0 @@ export declare enum TypefaceChatSendEvent { |
@@ -28,2 +28,4 @@ export var BlockType; | ||
TypefaceChatEvent["ON_IFRAME_URL_UPDATE"] = "onIframeUrlUpdate"; | ||
TypefaceChatEvent["ON_IFRAME_URL_LOAD"] = "onIframeUrlLoad"; | ||
TypefaceChatEvent["ON_IFRAME_URL_LOAD_FAIL"] = "onIframeUrlLoadFail"; | ||
})(TypefaceChatEvent || (TypefaceChatEvent = {})); | ||
@@ -30,0 +32,0 @@ export var TypefaceChatSendEvent; |
@@ -39,2 +39,20 @@ var __assign = (this && this.__assign) || function () { | ||
]); | ||
var onLoadIframe = function () { | ||
console.log("IFrame loaded with URL:", embedUrl); | ||
if (onEvent && !!embedUrl) { | ||
onEvent({ | ||
eventType: TypefaceChatEvent.ON_IFRAME_URL_LOAD, | ||
data: { embedUrl: embedUrl, typefaceOrigin: typefaceOrigin, sourceApp: sourceApp }, | ||
}); | ||
} | ||
}; | ||
var onErrorIframe = function (e) { | ||
console.error("IFrame failed to load URL:", embedUrl); | ||
if (onEvent) { | ||
onEvent({ | ||
eventType: TypefaceChatEvent.ON_IFRAME_URL_LOAD_FAIL, | ||
data: { embedUrl: embedUrl, typefaceOrigin: typefaceOrigin, sourceApp: sourceApp, error: e }, | ||
}); | ||
} | ||
}; | ||
useEffect(function () { | ||
@@ -56,3 +74,3 @@ if (onEvent && !!embedUrl) { | ||
React.createElement("div", { className: 'typeface-iframe-container', style: __assign(__assign({}, DEFAULT_STYLES), styles) }, | ||
React.createElement("iframe", { id: 'typeface-embed-frame', title: 'Typeface', className: 'typeface-iframe', style: iframeStyles, src: embedUrl, loading: 'lazy' })))); | ||
React.createElement("iframe", { id: 'typeface-embed-frame', title: 'Typeface', className: 'typeface-iframe', style: iframeStyles, src: embedUrl, loading: 'lazy', onLoad: onLoadIframe, onError: onErrorIframe })))); | ||
}; | ||
@@ -59,0 +77,0 @@ export var TypefacePluginIFrame = function (props) { |
{ | ||
"name": "@typeface-ai/typeface-embed-react", | ||
"version": "0.9.10", | ||
"version": "0.9.11", | ||
"description": "React SDK for Typeface Embed Integration", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
73787
1.37%1014
2.22%