@cntrl-site/sdk-nextjs 0.1.5 → 0.1.7

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.
@@ -8,6 +8,7 @@ const ImageItem = ({ item, layouts }) => ((0, jsx_runtime_1.jsx)(LinkWrapper_1.L
8
8
  ${(0, sdk_1.getLayoutStyles)(layouts, [item.layoutParams], ([{ strokeColor, radius, strokeWidth, opacity }]) => (`
9
9
  .image-wrapper-${item.id} {
10
10
  position: absolute;
11
+ overflow: hidden;
11
12
  width: 100%;
12
13
  height: 100%;
13
14
  border-style: solid;
@@ -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", style: { whiteSpace: 'pre-wrap' }, children: content }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: styles })] }));
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;
@@ -8,6 +8,7 @@ const VideoItem = ({ item, layouts }) => ((0, jsx_runtime_1.jsx)(LinkWrapper_1.L
8
8
  ${(0, sdk_1.getLayoutStyles)(layouts, [item.layoutParams], ([{ strokeColor, radius, strokeWidth, opacity }]) => (`
9
9
  .video-wrapper-${item.id} {
10
10
  position: absolute;
11
+ overflow: hidden;
11
12
  width: 100%;
12
13
  height: 100%;
13
14
  border-style: solid;
@@ -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: ${(0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, l.id).textAlign};
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.5",
3
+ "version": "0.1.7",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.js",
@@ -13,6 +13,7 @@ export const ImageItem: FC<ItemProps<TImageItem>> = ({ item, layouts }) => (
13
13
  ${getLayoutStyles(layouts, [item.layoutParams], ([{ strokeColor, radius, strokeWidth, opacity }]) => (`
14
14
  .image-wrapper-${item.id} {
15
15
  position: absolute;
16
+ overflow: hidden;
16
17
  width: 100%;
17
18
  height: 100%;
18
19
  border-style: solid;
@@ -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" style={{ whiteSpace: 'pre-wrap' }}>{content}</div>
14
+ <div className="rich-text">{content}</div>
15
15
  <JSXStyle id={item.id}>
16
16
  {styles}
17
17
  </JSXStyle>
@@ -16,6 +16,7 @@ export const VideoItem: FC<ItemProps<TVideoItem>> = ({ item, layouts }) => (
16
16
  ${getLayoutStyles(layouts, [item.layoutParams], ([{ strokeColor, radius, strokeWidth, opacity }]) => (`
17
17
  .video-wrapper-${item.id} {
18
18
  position: absolute;
19
+ overflow: hidden;
19
20
  width: 100%;
20
21
  height: 100%;
21
22
  border-style: solid;
@@ -1,12 +1,13 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import {
3
- TLayout,
3
+ getClosestLayoutValue,
4
+ getLayoutMediaQuery,
4
5
  RichText,
5
- TRichTextItem,
6
+ TextAlign,
6
7
  TextTransform,
7
- VerticalAlign,
8
- getClosestLayoutValue,
9
- getLayoutMediaQuery
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: ${getClosestLayoutValue(richText.layoutParams, layouts, l.id).textAlign};
91
+ text-align: ${ta};
89
92
  line-height: 0;
93
+ white-space: ${whiteSpace};
90
94
  }
91
95
  `);
92
96
  });