@contenify/chatbot 4.0.0 → 4.0.2

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.mjs CHANGED
@@ -2874,10 +2874,25 @@ ${optionsList}` }) : m
2874
2874
 
2875
2875
  // src/index.tsx
2876
2876
  import { jsx as jsx9 } from "react/jsx-runtime";
2877
- function ContenifyChatBot({ apiUrl, apiKey, domain, onPost }) {
2877
+ function ContenifyChatBot({
2878
+ apiUrl = process.env.NEXT_PUBLIC_CONTENIFY_API_URL,
2879
+ apiKey = process.env.NEXT_PUBLIC_API_KEY,
2880
+ domain = process.env.NEXT_PUBLIC_CONTENIFY_DOMAIN,
2881
+ onPost
2882
+ }) {
2878
2883
  useEffect7(() => {
2879
2884
  setConfig({ apiUrl, apiKey, domain });
2880
2885
  }, [apiUrl, apiKey, domain]);
2886
+ useEffect7(() => {
2887
+ if (!onPost) return;
2888
+ const handler = (e) => {
2889
+ var _a, _b;
2890
+ const detail = e.detail;
2891
+ onPost((_a = detail.article) != null ? _a : "", (_b = detail.keywords) != null ? _b : []);
2892
+ };
2893
+ window.addEventListener("contenify-post-article", handler);
2894
+ return () => window.removeEventListener("contenify-post-article", handler);
2895
+ }, [onPost]);
2881
2896
  return /* @__PURE__ */ jsx9(ChatBot, {});
2882
2897
  }
2883
2898
  var index_default = ContenifyChatBot;