@cntrl-site/sdk-nextjs 0.19.2 → 0.19.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/lib/components/Item.js +1 -1
- package/lib/components/LinkWrapper.js +2 -2
- package/lib/components/items/ImageItem.js +2 -2
- package/lib/components/items/RectangleItem.js +2 -2
- package/lib/components/items/VideoItem.js +2 -2
- package/lib/components/items/VimeoEmbed.js +2 -2
- package/lib/components/items/YoutubeEmbed.js +2 -2
- package/lib/utils/RichTextConverter/RichTextConverter.js +3 -3
- package/package.json +1 -1
- package/src/components/Item.tsx +1 -1
- package/src/components/LinkWrapper.tsx +3 -2
- package/src/components/items/ImageItem.tsx +1 -1
- package/src/components/items/RectangleItem.tsx +1 -1
- package/src/components/items/VideoItem.tsx +1 -1
- package/src/components/items/VimeoEmbed.tsx +1 -1
- package/src/components/items/YoutubeEmbed.tsx +1 -1
- package/src/utils/RichTextConverter/RichTextConverter.tsx +4 -3
- package/.idea/inspectionProfiles/Project_Default.xml +0 -15
package/lib/components/Item.js
CHANGED
|
@@ -94,7 +94,7 @@ const Item = ({ item, sectionId, articleHeight }) => {
|
|
|
94
94
|
if (!layout)
|
|
95
95
|
return null;
|
|
96
96
|
const styles = {
|
|
97
|
-
top: stickyTop
|
|
97
|
+
top: `${stickyTop * 100}vw`,
|
|
98
98
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset'
|
|
99
99
|
};
|
|
100
100
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `item-wrapper-${item.id}`, ref: itemWrapperRef, style: isInitialRef.current ? {} : Object.assign({ top, left }, (wrapperHeight !== undefined ? { height: `${wrapperHeight * 100}vw` } : {})) }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ suppressHydrationWarning: true, className: `item-${item.id}`, style: isInitialRef.current ? {} : styles }, { children: (0, jsx_runtime_1.jsx)(RichTextWrapper, Object.assign({ isRichText: isRichText }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `item-${item.id}-inner`, style: {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const LinkWrapper = ({ url, children }) => {
|
|
5
|
+
const LinkWrapper = ({ url, children, target }) => {
|
|
6
6
|
const validUrl = url && buildValidUrl(url);
|
|
7
|
-
return url ? ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: validUrl, target:
|
|
7
|
+
return url ? ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: validUrl, target: target, rel: "noreferrer" }, { children: children }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
8
8
|
};
|
|
9
9
|
exports.LinkWrapper = LinkWrapper;
|
|
10
10
|
function buildValidUrl(url) {
|
|
@@ -16,7 +16,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
16
16
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
18
|
const ImageItem = ({ item, sectionId, onResize }) => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
22
|
const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
@@ -24,7 +24,7 @@ const ImageItem = ({ item, sectionId, onResize }) => {
|
|
|
24
24
|
const borderColor = (0, react_1.useMemo)(() => color_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
25
25
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
26
26
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `image-wrapper-${item.id}`, ref: setRef, style: {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `image-wrapper-${item.id}`, ref: setRef, style: {
|
|
28
28
|
opacity: `${opacity}`,
|
|
29
29
|
transform: `rotate(${angle}deg)`,
|
|
30
30
|
filter: `blur(${blur * 100}vw)`
|
|
@@ -16,7 +16,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
16
16
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
18
|
const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
22
|
const { fillColor, radius, strokeWidth, strokeColor, blur, backdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
@@ -26,7 +26,7 @@ const RectangleItem = ({ item, sectionId, onResize }) => {
|
|
|
26
26
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
27
27
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
28
28
|
const backdropFilterValue = backdropBlur !== 0 ? `blur(${backdropBlur * 100}vw)` : 'unset';
|
|
29
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: {
|
|
30
30
|
backgroundColor: `${backgroundColor.toCss()}`,
|
|
31
31
|
borderRadius: `${radius * 100}vw`,
|
|
32
32
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
@@ -16,7 +16,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
16
16
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
18
|
const VideoItem = ({ item, sectionId, onResize }) => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
22
|
const { radius, strokeWidth, strokeColor, opacity, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
@@ -24,7 +24,7 @@ const VideoItem = ({ item, sectionId, onResize }) => {
|
|
|
24
24
|
const borderColor = (0, react_1.useMemo)(() => color_1.CntrlColor.parse(strokeColor), [strokeColor]);
|
|
25
25
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
26
26
|
(0, useRegisterResize_1.useRegisterResize)(ref, onResize);
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `video-wrapper-${item.id}`, ref: setRef, style: {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `video-wrapper-${item.id}`, ref: setRef, style: {
|
|
28
28
|
opacity: `${opacity}`,
|
|
29
29
|
transform: `rotate(${angle}deg)`,
|
|
30
30
|
filter: `blur(${blur * 100}vw)`
|
|
@@ -16,7 +16,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
16
16
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
17
17
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
18
18
|
const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
22
|
const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
@@ -40,7 +40,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
40
40
|
return validURL.href;
|
|
41
41
|
};
|
|
42
42
|
const validUrl = getValidVimeoUrl(url);
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `embed-video-wrapper-${item.id}`, ref: setRef, style: {
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `embed-video-wrapper-${item.id}`, ref: setRef, style: {
|
|
44
44
|
transform: `rotate(${angle}deg)`,
|
|
45
45
|
filter: `blur(${blur * 100}vw)`
|
|
46
46
|
}, onMouseEnter: () => {
|
|
@@ -17,7 +17,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
17
17
|
const useYouTubeIframeApi_1 = require("../../utils/Youtube/useYouTubeIframeApi");
|
|
18
18
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
19
19
|
const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
20
|
-
var _a;
|
|
20
|
+
var _a, _b;
|
|
21
21
|
const id = (0, react_1.useId)();
|
|
22
22
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
23
23
|
const { play, controls, url } = item.commonParams;
|
|
@@ -56,7 +56,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
56
56
|
(_a = placeholder.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(placeholder);
|
|
57
57
|
};
|
|
58
58
|
}, [YT, div]);
|
|
59
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url, target: (_b = item.link) === null || _b === void 0 ? void 0 : _b.target }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
60
60
|
if (!player || play !== 'on-hover')
|
|
61
61
|
return;
|
|
62
62
|
player.playVideo();
|
|
@@ -91,7 +91,7 @@ class RichTextConverter {
|
|
|
91
91
|
offset = entity.end;
|
|
92
92
|
}
|
|
93
93
|
if (entity.link) {
|
|
94
|
-
kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: entity.link }, { children: entityKids }), entity.start));
|
|
94
|
+
kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: entity.link, target: entity.target }, { children: entityKids }), entity.start));
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
97
|
kids.push(...entityKids);
|
|
@@ -184,7 +184,7 @@ class RichTextConverter {
|
|
|
184
184
|
const end = dividers[i + 1];
|
|
185
185
|
const entity = entities.find(e => e.start === start);
|
|
186
186
|
entitiesGroups.push(Object.assign({ stylesGroup: [], start,
|
|
187
|
-
end }, (entity && { link: entity.data.url })));
|
|
187
|
+
end }, (entity && { link: entity.data.url, target: entity.data.target })));
|
|
188
188
|
}
|
|
189
189
|
return entitiesGroups;
|
|
190
190
|
}
|
|
@@ -209,7 +209,7 @@ class RichTextConverter {
|
|
|
209
209
|
const end = entityDividers[i + 1];
|
|
210
210
|
const entity = entities.find(e => e.start === start);
|
|
211
211
|
entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
|
|
212
|
-
end }, (entity && { link: entity.data.url })));
|
|
212
|
+
end }, (entity && { link: entity.data.url, target: entity.data.target })));
|
|
213
213
|
}
|
|
214
214
|
return entitiesGroups;
|
|
215
215
|
}
|
package/package.json
CHANGED
package/src/components/Item.tsx
CHANGED
|
@@ -117,7 +117,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight }) =
|
|
|
117
117
|
|
|
118
118
|
if (!layout) return null;
|
|
119
119
|
const styles = {
|
|
120
|
-
top: stickyTop
|
|
120
|
+
top: `${stickyTop * 100}vw`,
|
|
121
121
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset'
|
|
122
122
|
};
|
|
123
123
|
|
|
@@ -3,14 +3,15 @@ import React, { ReactElement, ReactNode } from 'react';
|
|
|
3
3
|
interface Props {
|
|
4
4
|
url?: string;
|
|
5
5
|
children: ReactElement | ReactNode[];
|
|
6
|
+
target?: string;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export const LinkWrapper: React.FC<Props> = ({ url, children }) => {
|
|
9
|
+
export const LinkWrapper: React.FC<Props> = ({ url, children, target }) => {
|
|
9
10
|
const validUrl = url && buildValidUrl(url);
|
|
10
11
|
return url ? (
|
|
11
12
|
<a
|
|
12
13
|
href={validUrl}
|
|
13
|
-
target={
|
|
14
|
+
target={target}
|
|
14
15
|
rel="noreferrer"
|
|
15
16
|
>
|
|
16
17
|
{children}
|
|
@@ -19,7 +19,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, sectionId, onResize
|
|
|
19
19
|
const [ref, setRef] = useState<HTMLDivElement | null>(null);
|
|
20
20
|
useRegisterResize(ref, onResize);
|
|
21
21
|
return (
|
|
22
|
-
<LinkWrapper url={item.link?.url}>
|
|
22
|
+
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
23
23
|
<>
|
|
24
24
|
<div
|
|
25
25
|
className={`image-wrapper-${item.id}`}
|
|
@@ -22,7 +22,7 @@ export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, sectionId,
|
|
|
22
22
|
const backdropFilterValue = backdropBlur !== 0 ? `blur(${backdropBlur * 100}vw)`: 'unset';
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<LinkWrapper url={item.link?.url}>
|
|
25
|
+
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
26
26
|
<>
|
|
27
27
|
<div
|
|
28
28
|
className={`rectangle-${item.id}`}
|
|
@@ -19,7 +19,7 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, sectionId, onResize
|
|
|
19
19
|
const [ref, setRef] = useState<HTMLDivElement | null>(null);
|
|
20
20
|
useRegisterResize(ref, onResize);
|
|
21
21
|
return (
|
|
22
|
-
<LinkWrapper url={item.link?.url}>
|
|
22
|
+
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
23
23
|
<div
|
|
24
24
|
className={`video-wrapper-${item.id}`}
|
|
25
25
|
ref={setRef}
|
|
@@ -37,7 +37,7 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
37
37
|
const validUrl = getValidVimeoUrl(url);
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<LinkWrapper url={item.link?.url}>
|
|
40
|
+
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
41
41
|
<div
|
|
42
42
|
className={`embed-video-wrapper-${item.id}`}
|
|
43
43
|
ref={setRef}
|
|
@@ -52,7 +52,7 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
|
|
|
52
52
|
}, [YT, div]);
|
|
53
53
|
|
|
54
54
|
return (
|
|
55
|
-
<LinkWrapper url={item.link?.url}>
|
|
55
|
+
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
56
56
|
<div
|
|
57
57
|
className={`embed-youtube-video-wrapper-${item.id}`}
|
|
58
58
|
onMouseEnter={() => {
|
|
@@ -21,6 +21,7 @@ interface StyleGroup {
|
|
|
21
21
|
|
|
22
22
|
interface EntitiesGroup {
|
|
23
23
|
link?: string;
|
|
24
|
+
target?: string;
|
|
24
25
|
stylesGroup: StyleGroup[];
|
|
25
26
|
start: number;
|
|
26
27
|
end: number;
|
|
@@ -122,7 +123,7 @@ export class RichTextConverter {
|
|
|
122
123
|
offset = entity.end;
|
|
123
124
|
}
|
|
124
125
|
if (entity.link) {
|
|
125
|
-
kids.push(<LinkWrapper key={entity.start} url={entity.link} >{entityKids}</LinkWrapper>);
|
|
126
|
+
kids.push(<LinkWrapper key={entity.start} url={entity.link} target={entity.target}>{entityKids}</LinkWrapper>);
|
|
126
127
|
continue;
|
|
127
128
|
}
|
|
128
129
|
kids.push(...entityKids);
|
|
@@ -218,7 +219,7 @@ export class RichTextConverter {
|
|
|
218
219
|
stylesGroup: [],
|
|
219
220
|
start,
|
|
220
221
|
end,
|
|
221
|
-
...(entity && { link: entity.data.url })
|
|
222
|
+
...(entity && { link: entity.data.url, target: entity.data.target })
|
|
222
223
|
});
|
|
223
224
|
}
|
|
224
225
|
return entitiesGroups;
|
|
@@ -248,7 +249,7 @@ export class RichTextConverter {
|
|
|
248
249
|
stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end),
|
|
249
250
|
start,
|
|
250
251
|
end,
|
|
251
|
-
...(entity && { link: entity.data.url })
|
|
252
|
+
...(entity && { link: entity.data.url, target: entity.data.target })
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
255
|
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
|
2
|
-
<profile version="1.0">
|
|
3
|
-
<option name="myName" value="Project Default" />
|
|
4
|
-
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
|
|
5
|
-
<option name="myValues">
|
|
6
|
-
<value>
|
|
7
|
-
<list size="1">
|
|
8
|
-
<item index="0" class="java.lang.String" itemvalue="jsx" />
|
|
9
|
-
</list>
|
|
10
|
-
</value>
|
|
11
|
-
</option>
|
|
12
|
-
<option name="myCustomValuesEnabled" value="true" />
|
|
13
|
-
</inspection_tool>
|
|
14
|
-
</profile>
|
|
15
|
-
</component>
|