@cntrl-site/sdk-nextjs 0.28.1 → 0.28.3
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/.idea/inspectionProfiles/Project_Default.xml +15 -0
- package/lib/components/Item.js +6 -3
- package/lib/components/items/GroupItem.js +1 -1
- package/lib/utils/RichTextConverter/RichTextConverter.js +2 -1
- package/package.json +1 -1
- package/src/components/Item.tsx +8 -3
- package/src/components/items/GroupItem.tsx +1 -0
- package/src/utils/RichTextConverter/RichTextConverter.tsx +2 -1
|
@@ -0,0 +1,15 @@
|
|
|
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>
|
package/lib/components/Item.js
CHANGED
|
@@ -39,13 +39,17 @@ const itemsMap = {
|
|
|
39
39
|
[sdk_1.ArticleItemType.Custom]: CustomItem_1.CustomItem,
|
|
40
40
|
[sdk_1.ArticleItemType.Group]: GroupItem_1.GroupItem
|
|
41
41
|
};
|
|
42
|
+
const stickyFix = `
|
|
43
|
+
-webkit-transform: translate3d(0, 0, 0);
|
|
44
|
+
transform: translate3d(0, 0, 0);
|
|
45
|
+
`;
|
|
42
46
|
const RichTextWrapper = ({ isRichText, children }) => {
|
|
43
47
|
if (!isRichText)
|
|
44
48
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
45
49
|
return ((0, jsx_runtime_1.jsx)("div", { style: { transformOrigin: 'top left', transform: 'scale(var(--layout-deviation))' }, children: children }));
|
|
46
50
|
};
|
|
47
51
|
const noop = () => null;
|
|
48
|
-
const Item = ({ item, sectionId, articleHeight }) => {
|
|
52
|
+
const Item = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
49
53
|
const itemWrapperRef = (0, react_1.useRef)(null);
|
|
50
54
|
const rectObserver = (0, react_1.useContext)(ArticleRectContext_1.ArticleRectContext);
|
|
51
55
|
const id = (0, react_1.useId)();
|
|
@@ -131,8 +135,7 @@ const Item = ({ item, sectionId, articleHeight }) => {
|
|
|
131
135
|
.item-wrapper-${item.id} {
|
|
132
136
|
position: ${area.positionType === sdk_1.PositionType.ScreenBased ? 'fixed' : 'absolute'};
|
|
133
137
|
z-index: ${area.zIndex};
|
|
134
|
-
|
|
135
|
-
transform: translate3d(0, 0, 0);
|
|
138
|
+
${!isInGroup && stickyFix}
|
|
136
139
|
pointer-events: none;
|
|
137
140
|
bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
|
|
138
141
|
top: ${isScreenBasedBottom ? 'unset' : (0, getItemTopStyle_1.getItemTopStyle)(area.top, area.anchorSide)};
|
|
@@ -27,7 +27,7 @@ const GroupItem = ({ item, sectionId, onResize, articleHeight }) => {
|
|
|
27
27
|
return ((0, jsx_runtime_1.jsx)(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)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: {
|
|
28
28
|
opacity,
|
|
29
29
|
transform: `rotate(${angle}deg)`,
|
|
30
|
-
}, children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
30
|
+
}, children: items && items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, articleHeight: articleHeight, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
31
31
|
.group-${item.id} {
|
|
32
32
|
position: absolute;
|
|
33
33
|
width: 100%;
|
|
@@ -31,7 +31,8 @@ class RichTextConverter {
|
|
|
31
31
|
const content = text.slice(block.start, block.end);
|
|
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}`;
|
|
35
|
+
root.push((0, jsx_runtime_1.jsx)("div", { className: id, children: (0, jsx_runtime_1.jsx)("br", {}) }, id));
|
|
35
36
|
layouts.forEach(l => {
|
|
36
37
|
const lhForLayout = currentLineHeight[l.id];
|
|
37
38
|
if (lhForLayout === undefined)
|
package/package.json
CHANGED
package/src/components/Item.tsx
CHANGED
|
@@ -39,6 +39,7 @@ export interface ItemProps<I extends ItemAny> {
|
|
|
39
39
|
|
|
40
40
|
export interface ItemWrapperProps extends ItemProps<ItemAny> {
|
|
41
41
|
articleHeight: number;
|
|
42
|
+
isInGroup?: boolean;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const itemsMap: Record<ArticleItemType, ComponentType<ItemProps<any>>> = {
|
|
@@ -56,6 +57,11 @@ interface RTWrapperProps {
|
|
|
56
57
|
isRichText: boolean;
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
const stickyFix = `
|
|
61
|
+
-webkit-transform: translate3d(0, 0, 0);
|
|
62
|
+
transform: translate3d(0, 0, 0);
|
|
63
|
+
`;
|
|
64
|
+
|
|
59
65
|
const RichTextWrapper: FC<PropsWithChildren<RTWrapperProps>> = ({ isRichText, children }) => {
|
|
60
66
|
if (!isRichText) return <>{children}</>;
|
|
61
67
|
return (
|
|
@@ -67,7 +73,7 @@ const RichTextWrapper: FC<PropsWithChildren<RTWrapperProps>> = ({ isRichText, ch
|
|
|
67
73
|
|
|
68
74
|
const noop = () => null;
|
|
69
75
|
|
|
70
|
-
export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight }) => {
|
|
76
|
+
export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight, isInGroup = false }) => {
|
|
71
77
|
const itemWrapperRef = useRef<HTMLDivElement | null>(null);
|
|
72
78
|
const rectObserver = useContext(ArticleRectContext);
|
|
73
79
|
const id = useId();
|
|
@@ -177,8 +183,7 @@ export const Item: FC<ItemWrapperProps> = ({ item, sectionId, articleHeight }) =
|
|
|
177
183
|
.item-wrapper-${item.id} {
|
|
178
184
|
position: ${area.positionType === PositionType.ScreenBased ? 'fixed': 'absolute'};
|
|
179
185
|
z-index: ${area.zIndex};
|
|
180
|
-
|
|
181
|
-
transform: translate3d(0, 0, 0);
|
|
186
|
+
${!isInGroup && stickyFix}
|
|
182
187
|
pointer-events: none;
|
|
183
188
|
bottom: ${isScreenBasedBottom ? `${-area.top * 100}vw` : 'unset'};
|
|
184
189
|
top: ${isScreenBasedBottom ? 'unset' : getItemTopStyle(area.top, area.anchorSide)};
|
|
@@ -59,7 +59,8 @@ export class RichTextConverter {
|
|
|
59
59
|
const content = text.slice(block.start, block.end);
|
|
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}`;
|
|
63
|
+
root.push(<div key={id} className={id}><br /></div>);
|
|
63
64
|
layouts.forEach(l => {
|
|
64
65
|
const lhForLayout = currentLineHeight[l.id];
|
|
65
66
|
if (lhForLayout === undefined) return;
|