@cntrl-site/sdk-nextjs 1.0.10 → 1.0.12
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/cntrl-site-sdk-nextjs-1.0.12.tgz +0 -0
- package/lib/components/Item.js +8 -4
- package/lib/components/items/VimeoEmbed.js +3 -0
- package/lib/components/items/YoutubeEmbed.js +5 -0
- package/lib/utils/RichTextConverter/RichTextConverter.js +2 -1
- package/package.json +1 -1
- package/src/components/Item.tsx +4 -4
- package/src/components/items/VimeoEmbed.tsx +3 -0
- package/src/components/items/YoutubeEmbed.tsx +6 -0
- package/src/utils/RichTextConverter/RichTextConverter.tsx +2 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
|
Binary file
|
package/lib/components/Item.js
CHANGED
|
@@ -102,14 +102,18 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
102
102
|
isInitialRef.current = false;
|
|
103
103
|
}, []);
|
|
104
104
|
const isRichText = isItemType(item, sdk_1.ArticleItemType.RichText);
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (position ? { top: position.top } : {})), (position ? { left: position.left } : {})), (position ? { bottom: position.bottom } : {})), (wrapperHeight !== undefined ? { height: `${wrapperHeight * 100}vw` } : {})), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style:
|
|
105
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, ref: itemWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (position ? { top: position.top } : {})), (position ? { left: position.left } : {})), (position ? { bottom: position.bottom } : {})), (wrapperHeight !== undefined ? { height: `${wrapperHeight * 100}vw` } : {})), children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: {
|
|
106
|
+
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
107
|
+
top: `${stickyTop * 100}vw`,
|
|
108
|
+
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset',
|
|
109
|
+
}, children: (0, jsx_runtime_1.jsx)(RichTextWrapper, { isRichText: isRichText, children: (0, jsx_runtime_1.jsx)("div", { className: `item-${item.id}-inner`, style: Object.assign(Object.assign({}, (dimensions ? {
|
|
106
110
|
width: `${sizingAxis.x === 'manual'
|
|
107
111
|
? isRichText
|
|
108
112
|
? `${dimensions.width * exemplary}px`
|
|
109
113
|
: `${dimensions.width * 100}vw`
|
|
110
114
|
: 'max-content'}`,
|
|
111
115
|
height: `${sizingAxis.y === 'manual' ? `${dimensions.height * 100}vw` : 'unset'}`
|
|
112
|
-
} : {})), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
116
|
+
} : {})), (scale !== undefined ? { transform: `scale(${scale}) translateZ(0)`, 'WebkitTransform': `scale(${scale}) translateZ(0)` } : {})), children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize, articleHeight: articleHeight }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
113
117
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, hoverParams, sticky, sectionHeight, layoutParams], exemplary) => {
|
|
114
118
|
const sizingAxis = parseSizing(layoutParams.sizing);
|
|
115
119
|
const isScreenBasedBottom = area.positionType === sdk_1.PositionType.ScreenBased && area.anchorSide === sdk_1.AnchorSide.Bottom;
|
|
@@ -122,8 +126,6 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
122
126
|
transition: opacity 0.2s linear 0.1s;
|
|
123
127
|
display: ${hidden ? 'none' : 'block'};
|
|
124
128
|
height: fit-content;
|
|
125
|
-
transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
|
|
126
|
-
transform: scale(${area.scale});
|
|
127
129
|
}
|
|
128
130
|
.item-${item.id}-inner {
|
|
129
131
|
transition: ${(0, HoverStyles_1.getTransitions)(['width', 'height', 'scale'], hoverParams)};
|
|
@@ -131,6 +133,8 @@ const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
|
131
133
|
? `${area.width * 100}vw`
|
|
132
134
|
: 'max-content'};
|
|
133
135
|
height: ${sizingAxis.y === 'manual' ? `${area.height * 100}vw` : 'unset'};
|
|
136
|
+
transform-origin: ${ScaleAnchorMap_1.ScaleAnchorMap[scaleAnchor]};
|
|
137
|
+
transform: scale(${area.scale});
|
|
134
138
|
}
|
|
135
139
|
.item-wrapper-${item.id} {
|
|
136
140
|
position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
|
|
@@ -46,6 +46,9 @@ const VimeoEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
46
46
|
(0, react_1.useEffect)(() => {
|
|
47
47
|
if (!vimeoPlayer || !imgRef)
|
|
48
48
|
return;
|
|
49
|
+
if (play === 'on-click' && !controls) {
|
|
50
|
+
setIsCoverVisible(true);
|
|
51
|
+
}
|
|
49
52
|
vimeoPlayer.on('pause', (e) => {
|
|
50
53
|
if (e.seconds === 0) {
|
|
51
54
|
setIsCoverVisible(true);
|
|
@@ -75,6 +75,11 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize }) => {
|
|
|
75
75
|
player.playVideo();
|
|
76
76
|
setIsCoverVisible(false);
|
|
77
77
|
};
|
|
78
|
+
(0, react_1.useEffect)(() => {
|
|
79
|
+
if (play === 'on-click' && !controls) {
|
|
80
|
+
setIsCoverVisible(true);
|
|
81
|
+
}
|
|
82
|
+
}, []);
|
|
78
83
|
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { 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)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
79
84
|
if (!player || play !== 'on-hover')
|
|
80
85
|
return;
|
|
@@ -28,7 +28,7 @@ class RichTextConverter {
|
|
|
28
28
|
}, {});
|
|
29
29
|
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
30
30
|
const block = blocks[blockIndex];
|
|
31
|
-
const content = text.slice(block.start, block.end);
|
|
31
|
+
const content = text.slice(block.start, block.end + 1);
|
|
32
32
|
const entities = (_a = block.entities.sort((a, b) => a.start - b.start)) !== null && _a !== void 0 ? _a : [];
|
|
33
33
|
if (content.length === 0) {
|
|
34
34
|
const id = `rt_${richText.id}_br_${blockIndex}`;
|
|
@@ -96,6 +96,7 @@ class RichTextConverter {
|
|
|
96
96
|
}
|
|
97
97
|
kids.push(...entityKids);
|
|
98
98
|
}
|
|
99
|
+
// sliceSymbols(content, style.start, style.end).forEach(c => console.log(c.charCodeAt(0)))
|
|
99
100
|
if (offset < getSymbolsCount(content)) {
|
|
100
101
|
kids.push(sliceSymbols(content, offset));
|
|
101
102
|
}
|
package/package.json
CHANGED
package/src/components/Item.tsx
CHANGED
|
@@ -148,7 +148,6 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
|
|
|
148
148
|
opacity: (keyframes.length !== 0 && !layout) ? 0 : 1,
|
|
149
149
|
top: `${stickyTop * 100}vw`,
|
|
150
150
|
height: isRichText && itemHeight ? `${itemHeight * 100}vw` : 'unset',
|
|
151
|
-
...(scale !== undefined ? { transform: `scale(${scale}) translateZ(0)`, 'WebkitTransform': `scale(${scale}) translateZ(0)` } : {}),
|
|
152
151
|
}}
|
|
153
152
|
>
|
|
154
153
|
<RichTextWrapper isRichText={isRichText}>
|
|
@@ -161,7 +160,8 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
|
|
|
161
160
|
? `${dimensions.width * exemplary}px`
|
|
162
161
|
: `${dimensions.width * 100}vw`
|
|
163
162
|
: 'max-content'}`,
|
|
164
|
-
height: `${sizingAxis.y === 'manual' ? `${dimensions.height * 100}vw` : 'unset'}` } : {})
|
|
163
|
+
height: `${sizingAxis.y === 'manual' ? `${dimensions.height * 100}vw` : 'unset'}` } : {}),
|
|
164
|
+
...(scale !== undefined ? { transform: `scale(${scale}) translateZ(0)`, 'WebkitTransform': `scale(${scale}) translateZ(0)` } : {}),
|
|
165
165
|
}}
|
|
166
166
|
>
|
|
167
167
|
<ItemComponent item={item} sectionId={sectionId} onResize={handleItemResize} articleHeight={articleHeight} />
|
|
@@ -181,8 +181,6 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
|
|
|
181
181
|
transition: opacity 0.2s linear 0.1s;
|
|
182
182
|
display: ${hidden ? 'none' : 'block'};
|
|
183
183
|
height: fit-content;
|
|
184
|
-
transform-origin: ${ScaleAnchorMap[scaleAnchor]};
|
|
185
|
-
transform: scale(${area.scale});
|
|
186
184
|
}
|
|
187
185
|
.item-${item.id}-inner {
|
|
188
186
|
transition: ${getTransitions(['width', 'height', 'scale'], hoverParams)};
|
|
@@ -190,6 +188,8 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isI
|
|
|
190
188
|
? `${area.width * 100}vw`
|
|
191
189
|
: 'max-content'};
|
|
192
190
|
height: ${sizingAxis.y === 'manual' ? `${area.height * 100}vw` : 'unset'};
|
|
191
|
+
transform-origin: ${ScaleAnchorMap[scaleAnchor]};
|
|
192
|
+
transform: scale(${area.scale});
|
|
193
193
|
}
|
|
194
194
|
.item-wrapper-${item.id} {
|
|
195
195
|
position: ${area.positionType === PositionType.ScreenBased ? 'fixed': 'absolute'};
|
|
@@ -41,6 +41,9 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
|
|
|
41
41
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
if (!vimeoPlayer || !imgRef) return;
|
|
44
|
+
if (play === 'on-click' && !controls) {
|
|
45
|
+
setIsCoverVisible(true);
|
|
46
|
+
}
|
|
44
47
|
vimeoPlayer.on('pause', (e) => {
|
|
45
48
|
if (e.seconds === 0) {
|
|
46
49
|
setIsCoverVisible(true);
|
|
@@ -69,6 +69,12 @@ export const YoutubeEmbedItem: FC<ItemProps<TYoutubeEmbedItem>> = ({ item, secti
|
|
|
69
69
|
setIsCoverVisible(false);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (play === 'on-click' && !controls) {
|
|
74
|
+
setIsCoverVisible(true);
|
|
75
|
+
}
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
72
78
|
return (
|
|
73
79
|
<LinkWrapper url={item.link?.url} target={item.link?.target}>
|
|
74
80
|
<div
|
|
@@ -56,7 +56,7 @@ export class RichTextConverter {
|
|
|
56
56
|
|
|
57
57
|
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
58
58
|
const block = blocks[blockIndex];
|
|
59
|
-
const content = text.slice(block.start, block.end);
|
|
59
|
+
const content = text.slice(block.start, block.end + 1);
|
|
60
60
|
const entities = block.entities!.sort((a, b) => a.start - b.start) ?? [];
|
|
61
61
|
if (content.length === 0) {
|
|
62
62
|
const id = `rt_${richText.id}_br_${blockIndex}`;
|
|
@@ -127,6 +127,7 @@ export class RichTextConverter {
|
|
|
127
127
|
}
|
|
128
128
|
kids.push(...entityKids);
|
|
129
129
|
}
|
|
130
|
+
// sliceSymbols(content, style.start, style.end).forEach(c => console.log(c.charCodeAt(0)))
|
|
130
131
|
if (offset < getSymbolsCount(content)) {
|
|
131
132
|
kids.push(sliceSymbols(content, offset));
|
|
132
133
|
}
|