@cntrl-site/sdk-nextjs 0.0.4 → 0.0.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,7 +8,7 @@ const Article = ({ article, layouts }) => {
8
8
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "article", children: article.sections.map((section, i) => ((0, jsx_runtime_1.jsx)(Section_1.Section, { section: section, layouts: layouts, children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { layouts: layouts, item: item }, item.id))) }, section.id))) }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
9
9
  .article {
10
10
  position: relative;
11
- overflow-x: hidden;
11
+ overflow: hidden;
12
12
  }
13
13
  ` })] }));
14
14
  };
@@ -27,11 +27,11 @@ const Page = ({ article, project, meta }) => {
27
27
  src: ${font.files.map(file => `url('${file.url}') format('${file.type}')`).join(', ')};
28
28
  }
29
29
  `)).join('\n')
30
- } })), project.fonts.adobe, Object.values(parsedFonts).map((value, i) => {
30
+ } })), Object.values(parsedFonts).map((value, i) => {
31
31
  if (!value)
32
32
  return undefined;
33
- const rel = value.props?.rel;
34
- const href = value.props?.href;
33
+ const rel = value?.rel || value.props?.rel;
34
+ const href = value?.href || value.props?.href;
35
35
  if (!rel || !href)
36
36
  return undefined;
37
37
  return ((0, jsx_runtime_1.jsx)("link", { rel: rel, href: href }, i));
@@ -10,7 +10,8 @@ exports.FontStyles = {
10
10
  };
11
11
  class RichTextConverter {
12
12
  toHtml(richText, layouts) {
13
- const { text, blocks = [] } = richText.commonParams;
13
+ const { text: rawText, blocks = [] } = richText.commonParams;
14
+ const text = Array.from(rawText); // because of emoji
14
15
  const root = [];
15
16
  const styleRules = layouts.reduce((rec, layout) => {
16
17
  rec[layout.id] = [];
@@ -65,18 +66,18 @@ class RichTextConverter {
65
66
  for (const entity of entitiesGroups) {
66
67
  const entityKids = [];
67
68
  if (offset < entity.start) {
68
- kids.push(content.slice(offset, entity.start));
69
+ kids.push(content.slice(offset, entity.start).join(''));
69
70
  offset = entity.start;
70
71
  }
71
72
  for (const style of entity.stylesGroup) {
72
73
  if (offset < style.start) {
73
- entityKids.push(content.slice(offset, style.start));
74
+ entityKids.push(content.slice(offset, style.start).join(''));
74
75
  }
75
- entityKids.push((0, jsx_runtime_1.jsx)("span", { className: `s-${style.start}-${style.end}`, children: content.slice(style.start, style.end) }, style.start));
76
+ entityKids.push((0, jsx_runtime_1.jsx)("span", { className: `s-${style.start}-${style.end}`, children: content.slice(style.start, style.end).join('') }, style.start));
76
77
  offset = style.end;
77
78
  }
78
79
  if (offset < entity.end) {
79
- entityKids.push(content.slice(offset, entity.end));
80
+ entityKids.push(content.slice(offset, entity.end).join(''));
80
81
  offset = entity.end;
81
82
  }
82
83
  if (entity.link) {
@@ -86,7 +87,7 @@ class RichTextConverter {
86
87
  kids.push(...entityKids);
87
88
  }
88
89
  if (offset < content.length) {
89
- kids.push(content.slice(offset));
90
+ kids.push(content.slice(offset).join(''));
90
91
  }
91
92
  for (const item of group) {
92
93
  const entitiesGroups = this.groupEntities(entities, item.styles) ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.js",
@@ -23,7 +23,7 @@ export const Article: FC<Props> = ({ article, layouts }) => {
23
23
  <style jsx>{`
24
24
  .article {
25
25
  position: relative;
26
- overflow-x: hidden;
26
+ overflow: hidden;
27
27
  }
28
28
  `}</style>
29
29
  </>
@@ -44,11 +44,10 @@ export const Page: FC<Props> = ({ article, project, meta }) => {
44
44
  }}
45
45
  />
46
46
  )}
47
- {project.fonts.adobe}
48
47
  {Object.values(parsedFonts as ReturnType<typeof domToReact>).map((value, i) => {
49
48
  if (!value) return undefined;
50
- const rel = value.props?.rel;
51
- const href = value.props?.href;
49
+ const rel = value?.rel || value.props?.rel;
50
+ const href = value?.href || value.props?.href;
52
51
  if (!rel || !href) return undefined;
53
52
  return (
54
53
  <link key={i} rel={rel} href={href} />
@@ -38,7 +38,8 @@ export class RichTextConverter {
38
38
  richText: TRichTextItem,
39
39
  layouts: TLayout[]
40
40
  ): [ReactNode[], string] {
41
- const { text, blocks = [] } = richText.commonParams;
41
+ const { text: rawText, blocks = [] } = richText.commonParams;
42
+ const text = Array.from(rawText); // because of emoji
42
43
  const root: ReactElement[] = [];
43
44
  const styleRules = layouts.reduce<Record<string, string[]>>((rec, layout) => {
44
45
  rec[layout.id] = [];
@@ -94,18 +95,18 @@ export class RichTextConverter {
94
95
  for (const entity of entitiesGroups) {
95
96
  const entityKids: ReactNode[] = [];
96
97
  if (offset < entity.start) {
97
- kids.push(content.slice(offset, entity.start));
98
+ kids.push(content.slice(offset, entity.start).join(''));
98
99
  offset = entity.start;
99
100
  }
100
101
  for (const style of entity.stylesGroup) {
101
102
  if (offset < style.start) {
102
- entityKids.push(content.slice(offset, style.start));
103
+ entityKids.push(content.slice(offset, style.start).join(''));
103
104
  }
104
- entityKids.push(<span key={style.start} className={`s-${style.start}-${style.end}`}>{content.slice(style.start, style.end)}</span>);
105
+ entityKids.push(<span key={style.start} className={`s-${style.start}-${style.end}`}>{content.slice(style.start, style.end).join('')}</span>);
105
106
  offset = style.end;
106
107
  }
107
108
  if (offset < entity.end) {
108
- entityKids.push(content.slice(offset, entity.end));
109
+ entityKids.push(content.slice(offset, entity.end).join(''));
109
110
  offset = entity.end;
110
111
  }
111
112
  if (entity.link) {
@@ -115,7 +116,7 @@ export class RichTextConverter {
115
116
  kids.push(...entityKids);
116
117
  }
117
118
  if (offset < content.length) {
118
- kids.push(content.slice(offset));
119
+ kids.push(content.slice(offset).join(''));
119
120
  }
120
121
  for (const item of group) {
121
122
  const entitiesGroups = this.groupEntities(entities, item.styles) ?? [];