@cntrl-site/sdk-nextjs 0.8.1 → 0.8.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.
Binary file
@@ -4,7 +4,7 @@ exports.LinkWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const LinkWrapper = ({ url, children }) => {
6
6
  const validUrl = url && buildValidUrl(url);
7
- return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: url.startsWith('/') ? '_self' : '_blank', rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
7
+ return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: url.startsWith('/') || url.startsWith('#') ? '_self' : '_blank', rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
8
8
  };
9
9
  exports.LinkWrapper = LinkWrapper;
10
10
  function buildValidUrl(url) {
@@ -22,7 +22,7 @@ const Section = ({ section, children }) => {
22
22
  }`;
23
23
  }, '');
24
24
  };
25
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, style: {
25
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, id: section.name, style: {
26
26
  backgroundColor: backgroundColor
27
27
  }, children: children }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
28
28
  ${(0, sdk_1.getLayoutStyles)(layouts, [section.height], ([height]) => (`
@@ -54,13 +54,14 @@ class RichTextConverter {
54
54
  const kids = [];
55
55
  layouts.forEach(l => {
56
56
  const ta = richText.layoutParams[l.id].textAlign;
57
+ const whiteSpace = ta === sdk_1.TextAlign.Right ? 'normal' : 'pre-wrap';
57
58
  styleRules[l.id].push(`
58
59
  .${blockClass} {
59
60
  display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
60
61
  text-align: ${ta};
61
- white-space: normal;
62
+ white-space: ${whiteSpace};
62
63
  overflow-wrap: break-word;
63
- ${!hasPreset && 'line-height: 0;'}
64
+ ${!hasPreset ? 'line-height: 0;' : ''}
64
65
  }
65
66
  `);
66
67
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.js",
@@ -10,7 +10,7 @@ export const LinkWrapper: React.FC<Props> = ({ url, children }) => {
10
10
  return url ? (
11
11
  <a
12
12
  href={validUrl}
13
- target={url.startsWith('/') ? '_self' : '_blank'}
13
+ target={url.startsWith('/') || url.startsWith('#') ? '_self' : '_blank'}
14
14
  rel="noreferrer"
15
15
  >
16
16
  {children}
@@ -4,8 +4,7 @@ import {
4
4
  getLayoutStyles,
5
5
  TArticleSection,
6
6
  TSectionHeight,
7
- SectionHeightMode,
8
- CntrlColor
7
+ SectionHeightMode
9
8
  } from '@cntrl-site/sdk';
10
9
  import { useCntrlContext } from '../provider/useCntrlContext';
11
10
  import { useSectionColor } from './useSectionColor';
@@ -39,6 +38,7 @@ export const Section: FC<Props> = ({ section, children }) => {
39
38
  <>
40
39
  <div
41
40
  className={`section-${section.id}`}
41
+ id={section.name}
42
42
  style={{
43
43
  backgroundColor: backgroundColor
44
44
  }}
@@ -6,7 +6,8 @@ import {
6
6
  TextTransform,
7
7
  TLayout,
8
8
  TRichTextItem,
9
- VerticalAlign
9
+ VerticalAlign,
10
+ TextAlign
10
11
  } from '@cntrl-site/sdk';
11
12
  import { LinkWrapper } from '../../components/LinkWrapper';
12
13
 
@@ -84,13 +85,14 @@ export class RichTextConverter {
84
85
  const kids: ReactNode[] = [];
85
86
  layouts.forEach(l => {
86
87
  const ta = richText.layoutParams[l.id].textAlign;
88
+ const whiteSpace = ta === TextAlign.Right ? 'normal' : 'pre-wrap';
87
89
  styleRules[l.id].push(`
88
90
  .${blockClass} {
89
91
  display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
90
92
  text-align: ${ta};
91
- white-space: normal;
93
+ white-space: ${whiteSpace};
92
94
  overflow-wrap: break-word;
93
- ${!hasPreset && 'line-height: 0;'}
95
+ ${!hasPreset ? 'line-height: 0;' : ''}
94
96
  }
95
97
  `);
96
98
  });
Binary file
Binary file
Binary file