@cntrl-site/sdk-nextjs 0.1.6 → 0.1.8
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.
|
@@ -11,6 +11,6 @@ const RichTextConverter_1 = require("../../utils/RichTextConverter");
|
|
|
11
11
|
const richTextConv = new RichTextConverter_1.RichTextConverter();
|
|
12
12
|
const RichTextItem = ({ item, layouts }) => {
|
|
13
13
|
const [content, styles] = richTextConv.toHtml(item, layouts);
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "rich-text",
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "rich-text", children: content }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: styles })] }));
|
|
15
15
|
};
|
|
16
16
|
exports.RichTextItem = RichTextItem;
|
|
@@ -53,11 +53,14 @@ class RichTextConverter {
|
|
|
53
53
|
const blockClass = `rt_${richText.id}-b${blockIndex}_${layouts.map(l => group.some(g => g.layout === l.id) ? '1' : '0').join('')}`;
|
|
54
54
|
const kids = [];
|
|
55
55
|
layouts.forEach(l => {
|
|
56
|
+
const ta = (0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, l.id).textAlign;
|
|
57
|
+
const whiteSpace = ta === sdk_1.TextAlign.Justify || ta === sdk_1.TextAlign.Right ? 'normal' : 'pre-wrap';
|
|
56
58
|
styleRules[l.id].push(`
|
|
57
59
|
.${blockClass} {
|
|
58
60
|
display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
|
|
59
|
-
text-align: ${
|
|
61
|
+
text-align: ${ta};
|
|
60
62
|
line-height: 0;
|
|
63
|
+
white-space: ${whiteSpace};
|
|
61
64
|
}
|
|
62
65
|
`);
|
|
63
66
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cntrl-site/sdk": "^0.2.
|
|
24
|
+
"@cntrl-site/sdk": "^0.2.6",
|
|
25
25
|
"html-react-parser": "^3.0.1",
|
|
26
26
|
"styled-jsx": "^5.0.2"
|
|
27
27
|
},
|
|
@@ -11,7 +11,7 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, layouts }) =>
|
|
|
11
11
|
const [content, styles] = richTextConv.toHtml(item, layouts);
|
|
12
12
|
return (
|
|
13
13
|
<>
|
|
14
|
-
<div className="rich-text"
|
|
14
|
+
<div className="rich-text">{content}</div>
|
|
15
15
|
<JSXStyle id={item.id}>
|
|
16
16
|
{styles}
|
|
17
17
|
</JSXStyle>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
getClosestLayoutValue,
|
|
4
|
+
getLayoutMediaQuery,
|
|
4
5
|
RichText,
|
|
5
|
-
|
|
6
|
+
TextAlign,
|
|
6
7
|
TextTransform,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
TLayout,
|
|
9
|
+
TRichTextItem,
|
|
10
|
+
VerticalAlign
|
|
10
11
|
} from '@cntrl-site/sdk';
|
|
11
12
|
import { LinkWrapper } from '../components/LinkWrapper';
|
|
12
13
|
|
|
@@ -82,11 +83,14 @@ export class RichTextConverter {
|
|
|
82
83
|
const blockClass = `rt_${richText.id}-b${blockIndex}_${layouts.map(l => group.some(g => g.layout === l.id) ? '1' : '0').join('')}`;
|
|
83
84
|
const kids: ReactNode[] = [];
|
|
84
85
|
layouts.forEach(l => {
|
|
86
|
+
const ta = getClosestLayoutValue(richText.layoutParams, layouts, l.id).textAlign;
|
|
87
|
+
const whiteSpace = ta === TextAlign.Justify || ta === TextAlign.Right ? 'normal' : 'pre-wrap';
|
|
85
88
|
styleRules[l.id].push(`
|
|
86
89
|
.${blockClass} {
|
|
87
90
|
display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
|
|
88
|
-
text-align: ${
|
|
91
|
+
text-align: ${ta};
|
|
89
92
|
line-height: 0;
|
|
93
|
+
white-space: ${whiteSpace};
|
|
90
94
|
}
|
|
91
95
|
`);
|
|
92
96
|
});
|