react-iframe-plugin 0.1.2 → 0.1.4
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.d.ts +7 -8
- package/dist/index.es.js +40 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
interface IframePluginProps {
|
|
3
3
|
src: string;
|
|
4
|
-
title
|
|
5
|
-
width
|
|
6
|
-
height
|
|
7
|
-
types
|
|
8
|
-
currentDomain: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
width?: string;
|
|
6
|
+
height?: string;
|
|
7
|
+
types?: string;
|
|
9
8
|
iframeDomain: string;
|
|
10
|
-
basicHeight
|
|
9
|
+
basicHeight?: string;
|
|
11
10
|
url: string;
|
|
12
|
-
newWindow
|
|
13
|
-
zIndex
|
|
11
|
+
newWindow?: boolean;
|
|
12
|
+
zIndex?: string;
|
|
14
13
|
}
|
|
15
14
|
declare const IframePlugin: React.FC<IframePluginProps>;
|
|
16
15
|
export default IframePlugin;
|
package/dist/index.es.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
import { jsx as l, Fragment as b, jsxs as B } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
4
|
-
const [a,
|
|
5
|
-
zIndex:
|
|
6
|
-
newWindow:
|
|
7
|
-
url:
|
|
2
|
+
import { useState as h, useRef as D, useEffect as y } from "react";
|
|
3
|
+
const L = (E) => {
|
|
4
|
+
const [a, m] = h("250px"), [f, S] = h("250px"), {
|
|
5
|
+
zIndex: u,
|
|
6
|
+
newWindow: s,
|
|
7
|
+
url: c,
|
|
8
8
|
basicHeight: o,
|
|
9
9
|
iframeDomain: n,
|
|
10
|
-
currentDomain
|
|
10
|
+
// currentDomain,
|
|
11
11
|
types: r,
|
|
12
|
-
src:
|
|
13
|
-
title:
|
|
14
|
-
width:
|
|
12
|
+
src: g,
|
|
13
|
+
title: p,
|
|
14
|
+
width: w,
|
|
15
15
|
height: d
|
|
16
|
-
} =
|
|
17
|
-
|
|
16
|
+
} = E, i = D(!1), [F, I] = h(!1);
|
|
17
|
+
y(() => {
|
|
18
18
|
const t = r == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin");
|
|
19
19
|
console.log(
|
|
20
20
|
87878787,
|
|
21
21
|
t.contentWindow,
|
|
22
|
-
|
|
22
|
+
// currentDomain,
|
|
23
23
|
n,
|
|
24
|
-
|
|
24
|
+
c,
|
|
25
25
|
d,
|
|
26
26
|
o,
|
|
27
|
-
|
|
27
|
+
s
|
|
28
28
|
), t.addEventListener("load", function() {
|
|
29
|
-
console.log("currentDomain────────────", o),
|
|
29
|
+
console.log("currentDomain────────────", o), m(o || "250px");
|
|
30
30
|
const e = window.location.origin;
|
|
31
31
|
e && t.contentWindow.postMessage(
|
|
32
32
|
{
|
|
33
|
-
currentDomain: e
|
|
33
|
+
currentDomain: e,
|
|
34
34
|
iframeDomain: n || "http://localhost:8086",
|
|
35
|
-
url:
|
|
35
|
+
url: c || "http://localhost:8081",
|
|
36
36
|
height: d || "800px",
|
|
37
37
|
basicHeight: o,
|
|
38
|
-
newWindow:
|
|
38
|
+
newWindow: s || !0
|
|
39
39
|
},
|
|
40
40
|
n || "http://localhost:8086"
|
|
41
|
-
),
|
|
42
|
-
|
|
41
|
+
), x(), window.addEventListener("scroll", (W) => {
|
|
42
|
+
x();
|
|
43
43
|
});
|
|
44
44
|
}), window.addEventListener("message", function(e) {
|
|
45
45
|
console.log("message", e), console.log(
|
|
46
46
|
"plugin Fetch iframe:",
|
|
47
47
|
e.data.height,
|
|
48
48
|
e.data.footerHeight
|
|
49
|
-
), e.data && (e.data.height &&
|
|
49
|
+
), e.data && (e.data.height && m(e.data.height || o), e.data.footerHeight && S(e.data.footerHeight));
|
|
50
50
|
});
|
|
51
51
|
}, []);
|
|
52
|
-
const H = () => (document.scrollingElement || document.documentElement).scrollTop,
|
|
52
|
+
const H = () => (document.scrollingElement || document.documentElement).scrollTop, x = () => {
|
|
53
53
|
var t = H();
|
|
54
|
-
t > Number(a.replace("px", "")) ? i.current = !0 : i.current = !1,
|
|
54
|
+
t > Number(a.replace("px", "")) ? i.current = !0 : i.current = !1, I(i.current);
|
|
55
55
|
};
|
|
56
|
-
return
|
|
56
|
+
return y(() => {
|
|
57
57
|
console.log("isScroll", i.current), (r == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin")).contentWindow.postMessage(
|
|
58
58
|
{
|
|
59
|
-
currentDomain:
|
|
59
|
+
currentDomain: window.location.origin,
|
|
60
60
|
iframeDomain: n || "http://localhost:8086",
|
|
61
|
-
url:
|
|
61
|
+
url: c || "http://localhost:8081",
|
|
62
62
|
height: d || "800px",
|
|
63
63
|
basicHeight: o,
|
|
64
|
-
newWindow:
|
|
64
|
+
newWindow: s || !0,
|
|
65
65
|
isScroll: i.current
|
|
66
66
|
},
|
|
67
67
|
n || "http://localhost:8086"
|
|
68
68
|
);
|
|
69
|
-
}, [
|
|
69
|
+
}, [F]), /* @__PURE__ */ l(b, { children: /* @__PURE__ */ B(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
72
|
style: {
|
|
73
73
|
width: "100%",
|
|
74
74
|
position: "relative",
|
|
75
|
-
zIndex:
|
|
75
|
+
zIndex: u || 999,
|
|
76
76
|
paddingBottom: r === "footer" ? "0px" : "250px"
|
|
77
77
|
},
|
|
78
78
|
children: [
|
|
@@ -84,19 +84,19 @@ const T = (S) => {
|
|
|
84
84
|
left: "30%",
|
|
85
85
|
top: 0,
|
|
86
86
|
color: "white",
|
|
87
|
-
zIndex:
|
|
87
|
+
zIndex: u || 999
|
|
88
88
|
},
|
|
89
|
-
children: r === "footer" ?
|
|
89
|
+
children: r === "footer" ? f : a
|
|
90
90
|
}
|
|
91
91
|
),
|
|
92
92
|
r === "footer" ? /* @__PURE__ */ l(
|
|
93
93
|
"iframe",
|
|
94
94
|
{
|
|
95
95
|
id: "iframeFooter",
|
|
96
|
-
src:
|
|
97
|
-
title:
|
|
98
|
-
width:
|
|
99
|
-
height:
|
|
96
|
+
src: g,
|
|
97
|
+
title: p,
|
|
98
|
+
width: w,
|
|
99
|
+
height: f,
|
|
100
100
|
style: {
|
|
101
101
|
border: "none",
|
|
102
102
|
width: "100vw",
|
|
@@ -108,9 +108,9 @@ const T = (S) => {
|
|
|
108
108
|
"iframe",
|
|
109
109
|
{
|
|
110
110
|
id: "iframePlugin",
|
|
111
|
-
src:
|
|
112
|
-
title:
|
|
113
|
-
width:
|
|
111
|
+
src: g,
|
|
112
|
+
title: p,
|
|
113
|
+
width: w,
|
|
114
114
|
height: a,
|
|
115
115
|
style: {
|
|
116
116
|
border: "none",
|
|
@@ -128,5 +128,5 @@ const T = (S) => {
|
|
|
128
128
|
) });
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
L as default
|
|
132
132
|
};
|