@cntrl-site/sdk-nextjs 1.8.30 → 1.8.31
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.
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CodeEmbedItem = void 0;
|
|
6
|
+
exports.decodeBase64 = exports.CodeEmbedItem = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
9
|
const react_1 = require("react");
|
|
@@ -33,7 +33,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
33
33
|
const fontCustomTags = new sdk_1.FontFaceGenerator((_a = fonts === null || fonts === void 0 ? void 0 : fonts.custom) !== null && _a !== void 0 ? _a : []).generate();
|
|
34
34
|
const { anchor, blur: itemBlur, opacity: itemOpacity } = (0, useCodeEmbedItem_1.useCodeEmbedItem)(item, sectionId);
|
|
35
35
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
36
|
-
const
|
|
36
|
+
const html = decodeBase64(item.commonParams.html);
|
|
37
37
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
38
38
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
39
39
|
const pos = stylesMap[anchor];
|
|
@@ -55,7 +55,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
55
55
|
script.parentNode.removeChild(script);
|
|
56
56
|
ref.appendChild(newScript);
|
|
57
57
|
}
|
|
58
|
-
}, [
|
|
58
|
+
}, [html]);
|
|
59
59
|
(0, react_1.useEffect)(() => {
|
|
60
60
|
if (!ref)
|
|
61
61
|
return;
|
|
@@ -73,10 +73,10 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
73
73
|
padding: 0 !important;
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
|
-
${
|
|
76
|
+
${html}
|
|
77
77
|
`;
|
|
78
78
|
iframe.srcdoc = htmlWithStyles;
|
|
79
|
-
}, [
|
|
79
|
+
}, [html, item.commonParams.iframe, ref]);
|
|
80
80
|
const isInteractive = opacity !== 0;
|
|
81
81
|
(0, react_1.useEffect)(() => {
|
|
82
82
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
@@ -109,3 +109,9 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
109
109
|
` })] }));
|
|
110
110
|
};
|
|
111
111
|
exports.CodeEmbedItem = CodeEmbedItem;
|
|
112
|
+
function decodeBase64(str) {
|
|
113
|
+
const binary = atob(str);
|
|
114
|
+
const bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
|
|
115
|
+
return new TextDecoder().decode(bytes);
|
|
116
|
+
}
|
|
117
|
+
exports.decodeBase64 = decodeBase64;
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
|
|
|
28
28
|
const fontCustomTags = new FontFaceGenerator(fonts?.custom ?? []).generate();
|
|
29
29
|
const { anchor, blur: itemBlur, opacity: itemOpacity } = useCodeEmbedItem(item, sectionId);
|
|
30
30
|
const itemAngle = useItemAngle(item, sectionId);
|
|
31
|
-
const
|
|
31
|
+
const html = decodeBase64(item.commonParams.html);
|
|
32
32
|
const [ref, setRef] = useState<HTMLDivElement | null>(null);
|
|
33
33
|
useRegisterResize(ref, onResize);
|
|
34
34
|
const pos = stylesMap[anchor];
|
|
@@ -50,7 +50,7 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
|
|
|
50
50
|
script.parentNode!.removeChild(script);
|
|
51
51
|
ref.appendChild(newScript);
|
|
52
52
|
}
|
|
53
|
-
}, [
|
|
53
|
+
}, [html]);
|
|
54
54
|
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
if (!ref) return;
|
|
@@ -67,10 +67,10 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
|
|
|
67
67
|
padding: 0 !important;
|
|
68
68
|
}
|
|
69
69
|
</style>
|
|
70
|
-
${
|
|
70
|
+
${html}
|
|
71
71
|
`;
|
|
72
72
|
iframe.srcdoc = htmlWithStyles;
|
|
73
|
-
}, [
|
|
73
|
+
}, [html, item.commonParams.iframe, ref]);
|
|
74
74
|
|
|
75
75
|
const isInteractive = opacity !== 0;
|
|
76
76
|
useEffect(() => {
|
|
@@ -135,3 +135,9 @@ export const CodeEmbedItem: FC<ItemProps<TCodeEmbedItem>> = ({ item, sectionId,
|
|
|
135
135
|
</LinkWrapper>
|
|
136
136
|
);
|
|
137
137
|
};
|
|
138
|
+
|
|
139
|
+
export function decodeBase64(str: string): string {
|
|
140
|
+
const binary = atob(str);
|
|
141
|
+
const bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
|
|
142
|
+
return new TextDecoder().decode(bytes);
|
|
143
|
+
}
|