@cntrl-site/sdk-nextjs 1.11.0 → 1.11.2

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.
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/sdk-nextjs.iml" filepath="$PROJECT_DIR$/.idea/sdk-nextjs.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SectionImage = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const SectionImage = ({ media, sectionId }) => {
6
- const { url, size, position, offsetX, opacity, tileSize } = media;
6
+ const { url, size, position, offsetX, opacity, tileSize, scale = 1 } = media;
7
7
  const isContainHeight = size === 'contain-height';
8
8
  const isTile = size === 'tile';
9
9
  const hasOffsetX = offsetX !== null && size === 'contain';
@@ -27,7 +27,7 @@ const SectionImage = ({ media, sectionId }) => {
27
27
  } })) : ((0, jsx_runtime_1.jsx)("img", { src: url, className: `image-background-${sectionId}`, style: {
28
28
  objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
29
29
  width: isContainHeight || hasOffsetX ? 'auto' : '100%',
30
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
30
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
31
31
  position: 'relative',
32
32
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
33
33
  height: '100%',
@@ -8,7 +8,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
8
8
  const [video, setVideo] = (0, react_1.useState)(null);
9
9
  const [videoWrapper, setVideoWrapper] = (0, react_1.useState)(null);
10
10
  const [isVideoWidthOverflow, setIsVideoWidthOverflow] = (0, react_1.useState)(false);
11
- const { url, size, position, offsetX, coverUrl, play, opacity } = media;
11
+ const { url, size, position, offsetX, coverUrl, play, opacity, scale = 1 } = media;
12
12
  const [isPlaying, setIsPlaying] = (0, react_1.useState)(false);
13
13
  const [userPaused, setUserPaused] = (0, react_1.useState)(false);
14
14
  const [isClickedOnCover, setIsClickedOnCover] = (0, react_1.useState)(false);
@@ -69,7 +69,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
69
69
  opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 : opacity,
70
70
  objectFit: isContainHeight ? 'cover' : (size !== null && size !== void 0 ? size : 'cover'),
71
71
  width: isContainHeight && !isVideoWidthOverflow ? 'auto' : '100%',
72
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
72
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
73
73
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
74
74
  height: '100%',
75
75
  position: 'relative'
@@ -84,7 +84,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
84
84
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
85
85
  width: isContainHeight ? 'auto' : '100%',
86
86
  objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
87
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
87
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
88
88
  position: 'relative',
89
89
  height: '100%',
90
90
  transition: 'opacity 0.1s ease-in-out'
@@ -68,7 +68,8 @@ class RichTextConverter {
68
68
  const content = text.slice(block.start, block.end + 1);
69
69
  const entities = [...((_a = block.entities) !== null && _a !== void 0 ? _a : [])].sort((a, b) => a.start - b.start);
70
70
  const typeClass = hasLists ? ` ${(_b = LIST_ITEM_CLASSES[block.type]) !== null && _b !== void 0 ? _b : 'rt-paragraph'}` : '';
71
- if (content.length === 1) {
71
+ // an empty line keeps its height, as in the editor; a text never typed into comes without even its line break
72
+ if (content === '' || content === '\n') {
72
73
  const id = `rt_${richText.id}_br_${blockIndex}`;
73
74
  root.push((0, jsx_runtime_1.jsx)("div", { className: `${id}${typeClass}`, children: (0, jsx_runtime_1.jsx)("br", {}) }, id));
74
75
  layouts.forEach(l => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "@cntrl-site/color": "^1.0.0",
33
33
  "@cntrl-site/components": "^1.0.106",
34
34
  "@cntrl-site/effects": "^1.4.2",
35
- "@cntrl-site/sdk": "^1.29.1",
35
+ "@cntrl-site/sdk": "^1.29.2",
36
36
  "@types/vimeo__player": "^2.18.0",
37
37
  "@vimeo/player": "^2.25.0",
38
38
  "franc-min": "^5.0.0",
@@ -9,6 +9,7 @@ export type TSectionImage = {
9
9
  offsetX: number | null;
10
10
  opacity?: number;
11
11
  tileSize?: number;
12
+ scale?: number;
12
13
  };
13
14
 
14
15
  interface Props {
@@ -17,7 +18,7 @@ interface Props {
17
18
  }
18
19
 
19
20
  export const SectionImage: FC<Props> = ({ media, sectionId }) => {
20
- const { url, size, position, offsetX, opacity, tileSize } = media;
21
+ const { url, size, position, offsetX, opacity, tileSize, scale = 1 } = media;
21
22
  const isContainHeight = size === 'contain-height';
22
23
  const isTile = size === 'tile';
23
24
  const hasOffsetX = offsetX !== null && size === 'contain';
@@ -56,7 +57,7 @@ export const SectionImage: FC<Props> = ({ media, sectionId }) => {
56
57
  style={{
57
58
  objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
58
59
  width: isContainHeight || hasOffsetX ? 'auto' : '100%',
59
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
60
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
60
61
  position: 'relative',
61
62
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
62
63
  height: '100%',
@@ -11,6 +11,7 @@ export type TSectionVideo = {
11
11
  coverUrl: string | null;
12
12
  offsetX: number | null;
13
13
  opacity?: number;
14
+ scale?: number;
14
15
  };
15
16
 
16
17
  interface Props {
@@ -23,7 +24,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
23
24
  const [video, setVideo] = useState<HTMLVideoElement | null>(null);
24
25
  const [videoWrapper, setVideoWrapper] = useState<HTMLDivElement | null>(null);
25
26
  const [isVideoWidthOverflow, setIsVideoWidthOverflow] = useState(false);
26
- const { url, size, position, offsetX, coverUrl, play, opacity } = media;
27
+ const { url, size, position, offsetX, coverUrl, play, opacity, scale = 1 } = media;
27
28
  const [isPlaying, setIsPlaying] = useState(false);
28
29
  const [userPaused, setUserPaused] = useState(false);
29
30
  const [isClickedOnCover, setIsClickedOnCover] = useState(false);
@@ -94,7 +95,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
94
95
  opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 : opacity,
95
96
  objectFit: isContainHeight ? 'cover' : (size ?? 'cover') as CSSProperties['objectFit'],
96
97
  width: isContainHeight && !isVideoWidthOverflow ? 'auto' : '100%',
97
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
98
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
98
99
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
99
100
  height: '100%',
100
101
  position: 'relative'
@@ -131,7 +132,7 @@ export const SectionVideo: FC<Props> = ({ container, sectionId, media }) => {
131
132
  left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
132
133
  width: isContainHeight ? 'auto' : '100%',
133
134
  objectFit: isContainHeight ? 'unset' : (size ?? 'cover') as CSSProperties['objectFit'],
134
- transform: isContainHeight ? 'translateX(-50%)' : 'none',
135
+ transform: `${isContainHeight ? 'translateX(-50%) ' : ''}scale(${scale})`,
135
136
  position: 'relative',
136
137
  height: '100%',
137
138
  transition: 'opacity 0.1s ease-in-out'
@@ -60,6 +60,26 @@ describe('RichTextConverter', () => {
60
60
  expect(styles).toContain('background-color: rgba(255, 255, 0, 1)');
61
61
  });
62
62
 
63
+ it('keeps an empty line a line tall, in a text never typed into as well, and a one-letter last line its letter', () => {
64
+ const untyped: RichTextSource = {
65
+ id: 'text',
66
+ commonParams: { text: '', blocks: [{ start: 0, end: 0, type: 'unstyled', entities: [] }] },
67
+ layoutParams: { desktop: { rangeStyles: [], textAlign: TextAlign.Left } }
68
+ };
69
+ const emptied = text([{ text: '' }], []);
70
+ for (const source of [untyped, emptied]) {
71
+ const { container } = render(<>{converter.toHtml(source, layouts)[0]}</>);
72
+ expect(container.innerHTML).toBe('<div class="rt_text_br_0"><br></div>');
73
+ }
74
+ const unterminated: RichTextSource = {
75
+ id: 'text',
76
+ commonParams: { text: 'a', blocks: [{ start: 0, end: 1, type: 'unstyled', entities: [] }] },
77
+ layoutParams: { desktop: { rangeStyles: [], textAlign: TextAlign.Left } }
78
+ };
79
+ const { container } = render(<>{converter.toHtml(unterminated, layouts)[0]}</>);
80
+ expect(container.textContent).toBe('a');
81
+ });
82
+
63
83
  it('leaves text without lists as it was', () => {
64
84
  const [content, styles] = converter.toHtml(text([{ text: 'Plain' }]), layouts);
65
85
  const { container } = render(<>{content}</>);
@@ -125,7 +125,8 @@ export class RichTextConverter {
125
125
  const content = text.slice(block.start, block.end + 1);
126
126
  const entities = [...(block.entities ?? [])].sort((a, b) => a.start - b.start);
127
127
  const typeClass = hasLists ? ` ${LIST_ITEM_CLASSES[block.type] ?? 'rt-paragraph'}` : '';
128
- if (content.length === 1) {
128
+ // an empty line keeps its height, as in the editor; a text never typed into comes without even its line break
129
+ if (content === '' || content === '\n') {
129
130
  const id = `rt_${richText.id}_br_${blockIndex}`;
130
131
  root.push(<div key={id} className={`${id}${typeClass}`}><br /></div>);
131
132
  layouts.forEach(l => {
Binary file