qureal-editor 1.0.4 → 1.0.6
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.es.js +102 -148
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +103 -147
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,160 +1,114 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React, { Fragment, useEffect } from 'react';
|
|
3
2
|
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
9
|
-
|
|
10
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
11
|
-
var style = document.createElement('style');
|
|
12
|
-
style.type = 'text/css';
|
|
13
|
-
|
|
14
|
-
if (insertAt === 'top') {
|
|
15
|
-
if (head.firstChild) {
|
|
16
|
-
head.insertBefore(style, head.firstChild);
|
|
17
|
-
} else {
|
|
18
|
-
head.appendChild(style);
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
head.appendChild(style);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (style.styleSheet) {
|
|
25
|
-
style.styleSheet.cssText = css;
|
|
26
|
-
} else {
|
|
27
|
-
style.appendChild(document.createTextNode(css));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var css = "body{\n background-color: rgb(97, 97, 97);\n}\n.styles_outerN__IxLsd{\n padding: 10px 15px;\n border: none;\n outline: none;\n background-color: black;\n margin: 20px;\n border-radius: 5px;\n transition: 0.5s;\n}\n\n.styles_innerN__2mhRO{\n font-size: 1.3rem;\n color: #e3e3e3;\n transition: 0.5s;\n}\n\n.styles_outerN__IxLsd:hover {\n box-shadow: 0px 0px 22px 10px #34ebb7;\n cursor: pointer;\n}\n\n.styles_innerN__2mhRO:hover{\n color: #34ebb7;\n text-shadow: 0 0 15px #34ebb7;\n}\n";
|
|
32
|
-
var styles = { "outerN": "styles_outerN__IxLsd", "innerN": "styles_innerN__2mhRO" };
|
|
33
|
-
styleInject(css);
|
|
34
|
-
|
|
35
|
-
var classCallCheck = function (instance, Constructor) {
|
|
36
|
-
if (!(instance instanceof Constructor)) {
|
|
37
|
-
throw new TypeError("Cannot call a class as a function");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var createClass = function () {
|
|
42
|
-
function defineProperties(target, props) {
|
|
43
|
-
for (var i = 0; i < props.length; i++) {
|
|
44
|
-
var descriptor = props[i];
|
|
45
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
46
|
-
descriptor.configurable = true;
|
|
47
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
48
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return function (Constructor, protoProps, staticProps) {
|
|
53
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
54
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
|
55
|
-
return Constructor;
|
|
56
|
-
};
|
|
57
|
-
}();
|
|
58
|
-
|
|
59
|
-
var inherits = function (subClass, superClass) {
|
|
60
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
61
|
-
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
65
|
-
constructor: {
|
|
66
|
-
value: subClass,
|
|
67
|
-
enumerable: false,
|
|
68
|
-
writable: true,
|
|
69
|
-
configurable: true
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
3
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
4
|
+
return typeof obj;
|
|
5
|
+
} : function (obj) {
|
|
6
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
73
7
|
};
|
|
74
8
|
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
var NeonButton = function (_Component) {
|
|
84
|
-
inherits(NeonButton, _Component);
|
|
85
|
-
|
|
86
|
-
function NeonButton() {
|
|
87
|
-
var _ref;
|
|
88
|
-
|
|
89
|
-
var _temp, _this, _ret;
|
|
90
|
-
|
|
91
|
-
classCallCheck(this, NeonButton);
|
|
92
|
-
|
|
93
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
94
|
-
args[_key] = arguments[_key];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = NeonButton.__proto__ || Object.getPrototypeOf(NeonButton)).call.apply(_ref, [this].concat(args))), _this), _this.state = { hover: false }, _this.getInitialState = function () {
|
|
98
|
-
return { hover: false };
|
|
99
|
-
}, _this.toggleHover = function () {
|
|
100
|
-
_this.setState({ hover: !_this.state.hover });
|
|
101
|
-
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
createClass(NeonButton, [{
|
|
105
|
-
key: 'render',
|
|
106
|
-
value: function render() {
|
|
107
|
-
var _props = this.props,
|
|
108
|
-
text = _props.text,
|
|
109
|
-
color = _props.color;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var linkStyle;
|
|
113
|
-
if (this.state.hover) {
|
|
114
|
-
linkStyle = { color: color };
|
|
115
|
-
} else {
|
|
116
|
-
linkStyle = { color: '#e3e3e3' };
|
|
117
|
-
}
|
|
9
|
+
var _extends = Object.assign || function (target) {
|
|
10
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
11
|
+
var source = arguments[i];
|
|
118
12
|
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
} else {
|
|
123
|
-
boxStyle = { color: '#e3e3e3' };
|
|
13
|
+
for (var key in source) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15
|
+
target[key] = source[key];
|
|
124
16
|
}
|
|
125
|
-
|
|
126
|
-
return React.createElement(
|
|
127
|
-
'button',
|
|
128
|
-
{
|
|
129
|
-
className: styles.outerN,
|
|
130
|
-
style: boxStyle,
|
|
131
|
-
onMouseEnter: this.toggleHover,
|
|
132
|
-
onMouseLeave: this.toggleHover
|
|
133
|
-
},
|
|
134
|
-
React.createElement(
|
|
135
|
-
'div',
|
|
136
|
-
{
|
|
137
|
-
className: styles.innerN,
|
|
138
|
-
style: linkStyle
|
|
139
|
-
},
|
|
140
|
-
text
|
|
141
|
-
)
|
|
142
|
-
);
|
|
143
17
|
}
|
|
144
|
-
}
|
|
145
|
-
return NeonButton;
|
|
146
|
-
}(Component);
|
|
18
|
+
}
|
|
147
19
|
|
|
148
|
-
|
|
149
|
-
text: PropTypes.string,
|
|
150
|
-
color: PropTypes.string
|
|
20
|
+
return target;
|
|
151
21
|
};
|
|
152
22
|
|
|
23
|
+
function QurealiFrame(_ref) {
|
|
24
|
+
var slug = _ref.slug,
|
|
25
|
+
_ref$type = _ref.type,
|
|
26
|
+
type = _ref$type === undefined ? "creation" : _ref$type,
|
|
27
|
+
_ref$style = _ref.style,
|
|
28
|
+
style = _ref$style === undefined ? {} : _ref$style;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return React.createElement(
|
|
32
|
+
Fragment,
|
|
33
|
+
null,
|
|
34
|
+
React.createElement("iframe", {
|
|
35
|
+
id: "qureal_iframe",
|
|
36
|
+
title: "Qureal"
|
|
37
|
+
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
38
|
+
, src: type === "creation" ? "https://show.qureal.com/embed/" + slug : "https://show.qureal.com/ts/" + slug
|
|
39
|
+
// src={`https://show.qureal.com/embed/${slug}`}
|
|
40
|
+
, style: _extends({
|
|
41
|
+
width: "100%",
|
|
42
|
+
height: "100%"
|
|
43
|
+
}, style)
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
}
|
|
153
47
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
48
|
+
// export default QurealiFrame;
|
|
49
|
+
var QurealiFrame$1 = React.memo(QurealiFrame, function () {
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
var ALLOWED_ORIGINS = ["https://show.qureal.com", "http://localhost:3201"];
|
|
54
|
+
|
|
55
|
+
function QurealViewer(_ref) {
|
|
56
|
+
var _ref$slug = _ref.slug,
|
|
57
|
+
slug = _ref$slug === undefined ? "qi_sample" : _ref$slug,
|
|
58
|
+
_ref$type = _ref.type,
|
|
59
|
+
type = _ref$type === undefined ? "creation" : _ref$type,
|
|
60
|
+
_ref$onFormSubmit = _ref.onFormSubmit,
|
|
61
|
+
onFormSubmit = _ref$onFormSubmit === undefined ? function () {} : _ref$onFormSubmit,
|
|
62
|
+
_ref$style = _ref.style,
|
|
63
|
+
style = _ref$style === undefined ? { width: "800px", height: "600px" } : _ref$style;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var sendToIFrame = function sendToIFrame(creation_slug) {
|
|
67
|
+
console.log("Sending data to iFrame");
|
|
68
|
+
var qureal_element = document.getElementById("qureal_iframe");
|
|
69
|
+
|
|
70
|
+
var qureal_window = qureal_element ? qureal_element.contentWindow : null;
|
|
71
|
+
if (qureal_window) {
|
|
72
|
+
qureal_window.postMessage({
|
|
73
|
+
message_type: "OPEN_CREATION",
|
|
74
|
+
data: {
|
|
75
|
+
slug: creation_slug
|
|
76
|
+
}
|
|
77
|
+
}, "*");
|
|
78
|
+
console.log("Data sent to iframe");
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
sendToIFrame(slug);
|
|
84
|
+
}, [slug]);
|
|
85
|
+
|
|
86
|
+
useEffect(function () {
|
|
87
|
+
var handler = function handler(ev) {
|
|
88
|
+
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
|
89
|
+
switch (ev.data.event_type) {
|
|
90
|
+
case "FORM_SUBMIT":
|
|
91
|
+
onFormSubmit(ev.data.data);
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
console.log("No event type found");
|
|
95
|
+
console.log(ev.data);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
window.addEventListener("message", handler);
|
|
101
|
+
return function () {
|
|
102
|
+
return window.removeEventListener("message", handler);
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
106
|
+
return React.createElement(QurealiFrame$1, {
|
|
107
|
+
slug: slug,
|
|
108
|
+
type: type,
|
|
109
|
+
style: style
|
|
110
|
+
});
|
|
111
|
+
}
|
|
158
112
|
|
|
159
|
-
export
|
|
113
|
+
export { QurealViewer };
|
|
160
114
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}` : `https://show.qureal.com/ts/${slug}`}\n // src={`https://show.qureal.com/embed/${slug}`}\n style={{\n width: \"100%\",\n height: \"100%\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = { width: \"800px\", height: \"600px\" }\n}) {\n\n const sendToIFrame = (creation_slug) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: creation_slug\n }\n }, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame(slug)\n }, [slug])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n"],"names":["QurealiFrame","slug","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","onFormSubmit","width","height","sendToIFrame","creation_slug","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelpers.typeof","data","event_type","addEventListener","window","removeEventListener"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+D;QAAvCC,IAAuC,QAAvCA,IAAuC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA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B,SAAxB,EAAmCP,OAAnC;eACO;mBAAMQ,OAAOC,mBAAP,CAA2B,SAA3B,EAAsCT,OAAtC,CAAN;SAAP;KAfJ,EAgBG,EAhBH;;WAmBI,oBAACpB,cAAD;cACUC,IADV;cAEUC,IAFV;eAGWC;MAJf;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,165 +1,121 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
6
|
|
|
5
7
|
var React = require('react');
|
|
6
8
|
var React__default = _interopDefault(React);
|
|
7
|
-
var PropTypes = _interopDefault(require('prop-types'));
|
|
8
|
-
|
|
9
|
-
function styleInject(css, ref) {
|
|
10
|
-
if ( ref === void 0 ) ref = {};
|
|
11
|
-
var insertAt = ref.insertAt;
|
|
12
|
-
|
|
13
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
14
|
-
|
|
15
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
16
|
-
var style = document.createElement('style');
|
|
17
|
-
style.type = 'text/css';
|
|
18
|
-
|
|
19
|
-
if (insertAt === 'top') {
|
|
20
|
-
if (head.firstChild) {
|
|
21
|
-
head.insertBefore(style, head.firstChild);
|
|
22
|
-
} else {
|
|
23
|
-
head.appendChild(style);
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
head.appendChild(style);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (style.styleSheet) {
|
|
30
|
-
style.styleSheet.cssText = css;
|
|
31
|
-
} else {
|
|
32
|
-
style.appendChild(document.createTextNode(css));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var css = "body{\n background-color: rgb(97, 97, 97);\n}\n.styles_outerN__IxLsd{\n padding: 10px 15px;\n border: none;\n outline: none;\n background-color: black;\n margin: 20px;\n border-radius: 5px;\n transition: 0.5s;\n}\n\n.styles_innerN__2mhRO{\n font-size: 1.3rem;\n color: #e3e3e3;\n transition: 0.5s;\n}\n\n.styles_outerN__IxLsd:hover {\n box-shadow: 0px 0px 22px 10px #34ebb7;\n cursor: pointer;\n}\n\n.styles_innerN__2mhRO:hover{\n color: #34ebb7;\n text-shadow: 0 0 15px #34ebb7;\n}\n";
|
|
37
|
-
var styles = { "outerN": "styles_outerN__IxLsd", "innerN": "styles_innerN__2mhRO" };
|
|
38
|
-
styleInject(css);
|
|
39
9
|
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
10
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
11
|
+
return typeof obj;
|
|
12
|
+
} : function (obj) {
|
|
13
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
44
14
|
};
|
|
45
15
|
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var descriptor = props[i];
|
|
50
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
-
descriptor.configurable = true;
|
|
52
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return function (Constructor, protoProps, staticProps) {
|
|
58
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
59
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
|
60
|
-
return Constructor;
|
|
61
|
-
};
|
|
62
|
-
}();
|
|
63
|
-
|
|
64
|
-
var inherits = function (subClass, superClass) {
|
|
65
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
66
|
-
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
67
|
-
}
|
|
16
|
+
var _extends = Object.assign || function (target) {
|
|
17
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
+
var source = arguments[i];
|
|
68
19
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
enumerable: false,
|
|
73
|
-
writable: true,
|
|
74
|
-
configurable: true
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
var possibleConstructorReturn = function (self, call) {
|
|
81
|
-
if (!self) {
|
|
82
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
var NeonButton = function (_Component) {
|
|
89
|
-
inherits(NeonButton, _Component);
|
|
90
|
-
|
|
91
|
-
function NeonButton() {
|
|
92
|
-
var _ref;
|
|
93
|
-
|
|
94
|
-
var _temp, _this, _ret;
|
|
95
|
-
|
|
96
|
-
classCallCheck(this, NeonButton);
|
|
97
|
-
|
|
98
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
99
|
-
args[_key] = arguments[_key];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = NeonButton.__proto__ || Object.getPrototypeOf(NeonButton)).call.apply(_ref, [this].concat(args))), _this), _this.state = { hover: false }, _this.getInitialState = function () {
|
|
103
|
-
return { hover: false };
|
|
104
|
-
}, _this.toggleHover = function () {
|
|
105
|
-
_this.setState({ hover: !_this.state.hover });
|
|
106
|
-
}, _temp), possibleConstructorReturn(_this, _ret);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
createClass(NeonButton, [{
|
|
110
|
-
key: 'render',
|
|
111
|
-
value: function render() {
|
|
112
|
-
var _props = this.props,
|
|
113
|
-
text = _props.text,
|
|
114
|
-
color = _props.color;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var linkStyle;
|
|
118
|
-
if (this.state.hover) {
|
|
119
|
-
linkStyle = { color: color };
|
|
120
|
-
} else {
|
|
121
|
-
linkStyle = { color: '#e3e3e3' };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
var boxStyle;
|
|
125
|
-
if (this.state.hover) {
|
|
126
|
-
boxStyle = { boxShadow: '0px 0px 22px 10px ' + color };
|
|
127
|
-
} else {
|
|
128
|
-
boxStyle = { color: '#e3e3e3' };
|
|
20
|
+
for (var key in source) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
+
target[key] = source[key];
|
|
129
23
|
}
|
|
130
|
-
|
|
131
|
-
return React__default.createElement(
|
|
132
|
-
'button',
|
|
133
|
-
{
|
|
134
|
-
className: styles.outerN,
|
|
135
|
-
style: boxStyle,
|
|
136
|
-
onMouseEnter: this.toggleHover,
|
|
137
|
-
onMouseLeave: this.toggleHover
|
|
138
|
-
},
|
|
139
|
-
React__default.createElement(
|
|
140
|
-
'div',
|
|
141
|
-
{
|
|
142
|
-
className: styles.innerN,
|
|
143
|
-
style: linkStyle
|
|
144
|
-
},
|
|
145
|
-
text
|
|
146
|
-
)
|
|
147
|
-
);
|
|
148
24
|
}
|
|
149
|
-
}
|
|
150
|
-
return NeonButton;
|
|
151
|
-
}(React.Component);
|
|
25
|
+
}
|
|
152
26
|
|
|
153
|
-
|
|
154
|
-
text: PropTypes.string,
|
|
155
|
-
color: PropTypes.string
|
|
27
|
+
return target;
|
|
156
28
|
};
|
|
157
29
|
|
|
30
|
+
function QurealiFrame(_ref) {
|
|
31
|
+
var slug = _ref.slug,
|
|
32
|
+
_ref$type = _ref.type,
|
|
33
|
+
type = _ref$type === undefined ? "creation" : _ref$type,
|
|
34
|
+
_ref$style = _ref.style,
|
|
35
|
+
style = _ref$style === undefined ? {} : _ref$style;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
return React__default.createElement(
|
|
39
|
+
React.Fragment,
|
|
40
|
+
null,
|
|
41
|
+
React__default.createElement("iframe", {
|
|
42
|
+
id: "qureal_iframe",
|
|
43
|
+
title: "Qureal"
|
|
44
|
+
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
45
|
+
, src: type === "creation" ? "https://show.qureal.com/embed/" + slug : "https://show.qureal.com/ts/" + slug
|
|
46
|
+
// src={`https://show.qureal.com/embed/${slug}`}
|
|
47
|
+
, style: _extends({
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100%"
|
|
50
|
+
}, style)
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
}
|
|
158
54
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
55
|
+
// export default QurealiFrame;
|
|
56
|
+
var QurealiFrame$1 = React__default.memo(QurealiFrame, function () {
|
|
57
|
+
return true;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
var ALLOWED_ORIGINS = ["https://show.qureal.com", "http://localhost:3201"];
|
|
61
|
+
|
|
62
|
+
function QurealViewer(_ref) {
|
|
63
|
+
var _ref$slug = _ref.slug,
|
|
64
|
+
slug = _ref$slug === undefined ? "qi_sample" : _ref$slug,
|
|
65
|
+
_ref$type = _ref.type,
|
|
66
|
+
type = _ref$type === undefined ? "creation" : _ref$type,
|
|
67
|
+
_ref$onFormSubmit = _ref.onFormSubmit,
|
|
68
|
+
onFormSubmit = _ref$onFormSubmit === undefined ? function () {} : _ref$onFormSubmit,
|
|
69
|
+
_ref$style = _ref.style,
|
|
70
|
+
style = _ref$style === undefined ? { width: "800px", height: "600px" } : _ref$style;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var sendToIFrame = function sendToIFrame(creation_slug) {
|
|
74
|
+
console.log("Sending data to iFrame");
|
|
75
|
+
var qureal_element = document.getElementById("qureal_iframe");
|
|
76
|
+
|
|
77
|
+
var qureal_window = qureal_element ? qureal_element.contentWindow : null;
|
|
78
|
+
if (qureal_window) {
|
|
79
|
+
qureal_window.postMessage({
|
|
80
|
+
message_type: "OPEN_CREATION",
|
|
81
|
+
data: {
|
|
82
|
+
slug: creation_slug
|
|
83
|
+
}
|
|
84
|
+
}, "*");
|
|
85
|
+
console.log("Data sent to iframe");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
React.useEffect(function () {
|
|
90
|
+
sendToIFrame(slug);
|
|
91
|
+
}, [slug]);
|
|
92
|
+
|
|
93
|
+
React.useEffect(function () {
|
|
94
|
+
var handler = function handler(ev) {
|
|
95
|
+
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
|
96
|
+
switch (ev.data.event_type) {
|
|
97
|
+
case "FORM_SUBMIT":
|
|
98
|
+
onFormSubmit(ev.data.data);
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
console.log("No event type found");
|
|
102
|
+
console.log(ev.data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
window.addEventListener("message", handler);
|
|
108
|
+
return function () {
|
|
109
|
+
return window.removeEventListener("message", handler);
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
return React__default.createElement(QurealiFrame$1, {
|
|
114
|
+
slug: slug,
|
|
115
|
+
type: type,
|
|
116
|
+
style: style
|
|
117
|
+
});
|
|
118
|
+
}
|
|
163
119
|
|
|
164
|
-
|
|
120
|
+
exports.QurealViewer = QurealViewer;
|
|
165
121
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}` : `https://show.qureal.com/ts/${slug}`}\n // src={`https://show.qureal.com/embed/${slug}`}\n style={{\n width: \"100%\",\n height: \"100%\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = { width: \"800px\", height: \"600px\" }\n}) {\n\n const sendToIFrame = (creation_slug) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: creation_slug\n }\n }, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame(slug)\n }, [slug])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n"],"names":["QurealiFrame","slug","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","onFormSubmit","width","height","sendToIFrame","creation_slug","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","handler","ev","includes","origin","babelHelp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