@builder.io/react 1.1.47-5 → 1.1.47-9
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/builder-react-lite.cjs.js +1 -1
- package/dist/builder-react-lite.esm.js +1 -1
- package/dist/builder-react.browser.js +3 -3
- package/dist/builder-react.browser.js.map +1 -1
- package/dist/builder-react.cjs.js +2 -2
- package/dist/builder-react.cjs.js.map +1 -1
- package/dist/builder-react.es5.js +2 -2
- package/dist/builder-react.es5.js.map +1 -1
- package/dist/builder-react.unpkg.js +3 -3
- package/dist/builder-react.unpkg.js.map +1 -1
- package/dist/lib/package.json +2 -2
- package/dist/lib/src/blocks/CustomCode.js +25 -20
- package/dist/lib/src/blocks/CustomCode.js.map +1 -1
- package/package.json +2 -2
- package/src/blocks/CustomCode.tsx +32 -27
package/dist/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/react",
|
|
3
|
-
"version": "1.1.47-
|
|
3
|
+
"version": "1.1.47-8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "dist/builder-react.cjs.js",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"prop-types": "^15.7.2"
|
|
144
144
|
},
|
|
145
145
|
"dependencies": {
|
|
146
|
-
"@builder.io/sdk": "^1.1.23
|
|
146
|
+
"@builder.io/sdk": "^1.1.23",
|
|
147
147
|
"@emotion/core": "^10.0.17",
|
|
148
148
|
"hash-sum": "^2.0.0",
|
|
149
149
|
"preact": "^10.1.0",
|
|
@@ -34,9 +34,7 @@ var with_builder_1 = require("../functions/with-builder");
|
|
|
34
34
|
var globalReplaceNodes = {} || null;
|
|
35
35
|
var isShopify = sdk_1.Builder.isBrowser && 'Shopify' in window;
|
|
36
36
|
if (sdk_1.Builder.isBrowser && globalReplaceNodes) {
|
|
37
|
-
var customCodeQuerySelector_1 =
|
|
38
|
-
? '.builder-custom-code'
|
|
39
|
-
: '.builder-custom-code.replace-nodes';
|
|
37
|
+
var customCodeQuerySelector_1 = '.builder-custom-code';
|
|
40
38
|
try {
|
|
41
39
|
var allCustomCodeElements_1 = Array.from(document.querySelectorAll(customCodeQuerySelector_1));
|
|
42
40
|
// Search each template element (if present) for custom code blocks since
|
|
@@ -75,22 +73,28 @@ var CustomCodeComponent = /** @class */ (function (_super) {
|
|
|
75
73
|
_this.scriptsInserted = new Set();
|
|
76
74
|
_this.scriptsRun = new Set();
|
|
77
75
|
_this.firstLoad = true;
|
|
78
|
-
|
|
79
|
-
_this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
_this.replaceNodes = false;
|
|
77
|
+
_this.state = {
|
|
78
|
+
hydrated: false,
|
|
79
|
+
};
|
|
80
|
+
if (sdk_1.Builder.isBrowser) {
|
|
81
|
+
var id = (_a = _this.props.builderBlock) === null || _a === void 0 ? void 0 : _a.id;
|
|
82
|
+
_this.replaceNodes = Boolean(sdk_1.Builder.isBrowser && (props.replaceNodes || isShopify) && id && (globalReplaceNodes === null || globalReplaceNodes === void 0 ? void 0 : globalReplaceNodes[id]));
|
|
83
|
+
if (_this.firstLoad && _this.props.builderBlock) {
|
|
84
|
+
if (id && (globalReplaceNodes === null || globalReplaceNodes === void 0 ? void 0 : globalReplaceNodes[id])) {
|
|
85
|
+
var el = globalReplaceNodes[id].shift() || null;
|
|
86
|
+
_this.originalRef = el;
|
|
87
|
+
if (globalReplaceNodes[id].length === 0) {
|
|
88
|
+
delete globalReplaceNodes[id];
|
|
89
|
+
}
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
else if (_this.replaceNodes) {
|
|
92
|
+
var existing = document.querySelectorAll("." + _this.props.builderBlock.id + " .builder-custom-code");
|
|
93
|
+
if (existing.length === 1) {
|
|
94
|
+
var node = existing[0];
|
|
95
|
+
_this.originalRef = node;
|
|
96
|
+
_this.originalRef.remove();
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
}
|
|
@@ -122,8 +126,9 @@ var CustomCodeComponent = /** @class */ (function (_super) {
|
|
|
122
126
|
this.firstLoad = false;
|
|
123
127
|
if (!this.replaceNodes) {
|
|
124
128
|
if (this.isHydrating) {
|
|
129
|
+
// first render need to match what's on ssr (issue with next.js)
|
|
125
130
|
this.setState({
|
|
126
|
-
|
|
131
|
+
hydrated: true,
|
|
127
132
|
});
|
|
128
133
|
sdk_1.Builder.nextTick(function () { return _this.findAndRunScripts(); });
|
|
129
134
|
}
|
|
@@ -183,7 +188,7 @@ var CustomCodeComponent = /** @class */ (function (_super) {
|
|
|
183
188
|
// like embed
|
|
184
189
|
return (react_1.default.createElement("div", __assign({ ref: function (ref) { return (_this.elementRef = ref); },
|
|
185
190
|
// TODO: add a class when node replaced in (?)
|
|
186
|
-
className: 'builder-custom-code'
|
|
191
|
+
className: 'builder-custom-code' }, (!this.replaceNodes &&
|
|
187
192
|
!this.noReactRender && {
|
|
188
193
|
dangerouslySetInnerHTML: { __html: this.code },
|
|
189
194
|
}))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomCode.js","sourceRoot":"","sources":["../../../../src/blocks/CustomCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,uCAA0D;AAC1D,0DAAwD;AASxD,kFAAkF;AAClF,IAAM,kBAAkB,GAAI,EAAgC,IAAI,IAAI,CAAC;AAErE,IAAM,SAAS,GAAG,aAAO,CAAC,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;AAE3D,IAAI,aAAO,CAAC,SAAS,IAAI,kBAAkB,EAAE;IAC3C,IAAM,yBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"CustomCode.js","sourceRoot":"","sources":["../../../../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AAC,SAAS,GAwIhD;AAEY,QAAA,UAAU,GAAG,0BAAW,CAAC,mBAAmB,EAAE;IACzD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,IAAI;IACZ,mBAAmB,EAAE,CAAC,UAAU,CAAC;IACjC,MAAM,EAAE;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,4CAA4C;YAC1D,IAAI,EAAE,IAAI;SACX;mBAEC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,oCAAoC,EAChD,QAAQ,EAAE,IAAI,IACX,CAAC,SAAS,IAAI;YACf,YAAY,EAAE,IAAI;SACnB,CAAC;mBAGF,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,SAAS,EACf,UAAU,EACR,yHAAyH,EAC3H,QAAQ,EAAE,IAAI,IACX,CAAC,CAAC,SAAS,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;KAEL;CACK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/react",
|
|
3
|
-
"version": "1.1.47-
|
|
3
|
+
"version": "1.1.47-9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "dist/builder-react.cjs.js",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"prop-types": "^15.7.2"
|
|
144
144
|
},
|
|
145
145
|
"dependencies": {
|
|
146
|
-
"@builder.io/sdk": "^1.1.23
|
|
146
|
+
"@builder.io/sdk": "^1.1.23",
|
|
147
147
|
"@emotion/core": "^10.0.17",
|
|
148
148
|
"hash-sum": "^2.0.0",
|
|
149
149
|
"preact": "^10.1.0",
|
|
@@ -15,9 +15,8 @@ const globalReplaceNodes = ({} as { [key: string]: Node[] }) || null;
|
|
|
15
15
|
const isShopify = Builder.isBrowser && 'Shopify' in window;
|
|
16
16
|
|
|
17
17
|
if (Builder.isBrowser && globalReplaceNodes) {
|
|
18
|
-
const customCodeQuerySelector =
|
|
19
|
-
|
|
20
|
-
: '.builder-custom-code.replace-nodes';
|
|
18
|
+
const customCodeQuerySelector = '.builder-custom-code';
|
|
19
|
+
|
|
21
20
|
try {
|
|
22
21
|
let allCustomCodeElements = Array.from(document.querySelectorAll(customCodeQuerySelector));
|
|
23
22
|
|
|
@@ -56,34 +55,39 @@ class CustomCodeComponent extends React.Component<Props> {
|
|
|
56
55
|
scriptsRun = new Set();
|
|
57
56
|
|
|
58
57
|
firstLoad = true;
|
|
59
|
-
replaceNodes
|
|
58
|
+
replaceNodes = false;
|
|
59
|
+
state = {
|
|
60
|
+
hydrated: false,
|
|
61
|
+
}
|
|
60
62
|
|
|
61
63
|
constructor(props: Props) {
|
|
62
64
|
super(props);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
if (Builder.isBrowser){
|
|
66
|
+
const id = this.props.builderBlock?.id;
|
|
67
|
+
this.replaceNodes = Boolean(
|
|
68
|
+
Builder.isBrowser && (props.replaceNodes || isShopify) && id && globalReplaceNodes?.[id]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (this.firstLoad && this.props.builderBlock) {
|
|
72
|
+
if (id && globalReplaceNodes?.[id]) {
|
|
73
|
+
const el = globalReplaceNodes[id].shift() || null;
|
|
74
|
+
this.originalRef = el;
|
|
75
|
+
if (globalReplaceNodes[id].length === 0) {
|
|
76
|
+
delete globalReplaceNodes[id];
|
|
77
|
+
}
|
|
78
|
+
} else if (this.replaceNodes) {
|
|
79
|
+
const existing = document.querySelectorAll(
|
|
80
|
+
`.${this.props.builderBlock.id} .builder-custom-code`
|
|
81
|
+
);
|
|
82
|
+
if (existing.length === 1) {
|
|
83
|
+
const node = existing[0];
|
|
84
|
+
this.originalRef = node as HTMLElement;
|
|
85
|
+
(this.originalRef as Element).remove();
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
90
|
+
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
get noReactRender() {
|
|
@@ -105,8 +109,9 @@ class CustomCodeComponent extends React.Component<Props> {
|
|
|
105
109
|
this.firstLoad = false;
|
|
106
110
|
if (!this.replaceNodes) {
|
|
107
111
|
if (this.isHydrating) {
|
|
112
|
+
// first render need to match what's on ssr (issue with next.js)
|
|
108
113
|
this.setState({
|
|
109
|
-
|
|
114
|
+
hydrated: true,
|
|
110
115
|
})
|
|
111
116
|
Builder.nextTick(() => this.findAndRunScripts());
|
|
112
117
|
} else {
|
|
@@ -170,7 +175,7 @@ class CustomCodeComponent extends React.Component<Props> {
|
|
|
170
175
|
<div
|
|
171
176
|
ref={ref => (this.elementRef = ref)}
|
|
172
177
|
// TODO: add a class when node replaced in (?)
|
|
173
|
-
className=
|
|
178
|
+
className='builder-custom-code'
|
|
174
179
|
{...(!this.replaceNodes &&
|
|
175
180
|
!this.noReactRender && {
|
|
176
181
|
dangerouslySetInnerHTML: { __html: this.code },
|