@cntrl-site/sdk-nextjs 0.0.11 → 0.1.1
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.
- package/lib/components/Item.js +6 -7
- package/lib/components/LayoutStyle.js +2 -2
- package/lib/components/LinkWrapper.js +3 -1
- package/lib/components/Page.js +14 -8
- package/lib/components/items/RectangleItem.js +1 -1
- package/lib/index.js +0 -1
- package/lib/utils/RichTextConverter.js +10 -9
- package/package.json +2 -3
- package/src/components/Article.tsx +1 -1
- package/src/components/Item.tsx +2 -2
- package/src/components/LayoutStyle.tsx +1 -1
- package/src/components/LinkWrapper.tsx +17 -4
- package/src/components/Page.tsx +19 -15
- package/src/components/Section.tsx +1 -2
- package/src/components/items/ImageItem.tsx +1 -2
- package/src/components/items/RectangleItem.tsx +1 -2
- package/src/components/items/RichTextItem.tsx +1 -1
- package/src/components/items/VideoItem.tsx +1 -1
- package/src/index.ts +0 -1
- package/src/utils/RichTextConverter.tsx +4 -3
package/lib/components/Item.js
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Item = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const core_1 = require("@cntrl-site/core");
|
|
6
5
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
7
6
|
const RectangleItem_1 = require("./items/RectangleItem");
|
|
8
7
|
const ImageItem_1 = require("./items/ImageItem");
|
|
9
8
|
const VideoItem_1 = require("./items/VideoItem");
|
|
10
9
|
const RichTextItem_1 = require("./items/RichTextItem");
|
|
11
10
|
const itemsMap = {
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
11
|
+
[sdk_1.ArticleItemType.Rectangle]: RectangleItem_1.RectangleItem,
|
|
12
|
+
[sdk_1.ArticleItemType.Image]: ImageItem_1.ImageItem,
|
|
13
|
+
[sdk_1.ArticleItemType.Video]: VideoItem_1.VideoItem,
|
|
14
|
+
[sdk_1.ArticleItemType.RichText]: RichTextItem_1.RichTextItem
|
|
16
15
|
};
|
|
17
16
|
const noop = () => null;
|
|
18
17
|
const Item = ({ item, layouts }) => {
|
|
@@ -28,8 +27,8 @@ const Item = ({ item, layouts }) => {
|
|
|
28
27
|
position: absolute;
|
|
29
28
|
top: ${area.top * 100}vw;
|
|
30
29
|
left: ${layoutParams?.fullwidth ? 0 : area.left * 100}vw;
|
|
31
|
-
width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x ===
|
|
32
|
-
height: ${sizingAxis.y ===
|
|
30
|
+
width: ${layoutParams?.fullwidth ? '100vw' : sizingAxis.x === sdk_1.ArticleItemSizingType.Manual ? `${area.width * 100}vw` : 'auto'};
|
|
31
|
+
height: ${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${area.height * 100}vw` : 'auto'};
|
|
33
32
|
z-index: ${area.zIndex};
|
|
34
33
|
transform: rotate(${area.angle}deg);
|
|
35
34
|
}
|
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LayoutStyle = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const
|
|
8
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
9
|
// @ts-ignore
|
|
10
10
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
11
|
const LayoutStyle = ({ id, layouts, layoutId, children }) => {
|
|
12
12
|
const layout = layouts.find(l => l.id === layoutId);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
14
|
-
${(0,
|
|
14
|
+
${(0, sdk_1.getLayoutMediaQuery)(layoutId, layouts)} {
|
|
15
15
|
${children?.(layout)}
|
|
16
16
|
}
|
|
17
17
|
` }));
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const LinkWrapper = ({ url, children }) =>
|
|
5
|
+
const LinkWrapper = ({ url, children }) => {
|
|
6
|
+
return url ? ((0, jsx_runtime_1.jsx)("a", { href: !url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('/') ? `//${url}` : url, target: url.startsWith('/') ? '_self' : '_blank', rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
7
|
+
};
|
|
6
8
|
exports.LinkWrapper = LinkWrapper;
|
package/lib/components/Page.js
CHANGED
|
@@ -6,11 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Page = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const html_react_parser_1 = __importDefault(require("html-react-parser"));
|
|
9
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
9
10
|
const head_1 = __importDefault(require("next/head"));
|
|
10
11
|
const Article_1 = require("./Article");
|
|
11
12
|
const Page = ({ article, project, meta }) => {
|
|
12
13
|
const googleFonts = (0, html_react_parser_1.default)(project.fonts.google);
|
|
13
14
|
const adobeFonts = (0, html_react_parser_1.default)(project.fonts.adobe);
|
|
15
|
+
const getPageMeta = (projectMeta, pageMeta) => {
|
|
16
|
+
return {
|
|
17
|
+
title: pageMeta.title ? pageMeta.title : projectMeta.title,
|
|
18
|
+
description: pageMeta.description ? pageMeta.description : projectMeta.description,
|
|
19
|
+
keywords: pageMeta.keywords ? pageMeta.keywords : projectMeta.keywords,
|
|
20
|
+
opengraphThumbnail: pageMeta.opengraphThumbnail ? pageMeta.opengraphThumbnail : projectMeta.opengraphThumbnail,
|
|
21
|
+
favicon: projectMeta.favicon
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const priorityMeta = getPageMeta(project.meta, meta);
|
|
14
25
|
const parsedFonts = {
|
|
15
26
|
...(typeof googleFonts === 'object' ? googleFonts : {}),
|
|
16
27
|
...(typeof adobeFonts === 'object' ? adobeFonts : {})
|
|
@@ -19,14 +30,9 @@ const Page = ({ article, project, meta }) => {
|
|
|
19
30
|
const htmlHead = (0, html_react_parser_1.default)(project.html.head);
|
|
20
31
|
const afterBodyOpen = (0, html_react_parser_1.default)(project.html.afterBodyOpen);
|
|
21
32
|
const beforeBodyClose = (0, html_react_parser_1.default)(project.html.beforeBodyClose);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
font-family: ${font.name};
|
|
26
|
-
font-weight: ${font.weight};
|
|
27
|
-
src: ${font.files.map(file => `url('${file.url}') format('${file.type}')`).join(', ')};
|
|
28
|
-
}
|
|
29
|
-
`)).join('\n')
|
|
33
|
+
const ffGenerator = new sdk_1.FontFaceGenerator(customFonts);
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(head_1.default, { children: [(0, jsx_runtime_1.jsx)("title", { children: priorityMeta.title }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: priorityMeta.description }), (0, jsx_runtime_1.jsx)("meta", { name: "keywords", content: priorityMeta.keywords }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: priorityMeta.opengraphThumbnail }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: priorityMeta.favicon }), customFonts.length > 0 && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: {
|
|
35
|
+
__html: ffGenerator.generate()
|
|
30
36
|
} })), Object.values(parsedFonts).map((value, i) => {
|
|
31
37
|
if (!value)
|
|
32
38
|
return undefined;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RectangleItem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const LinkWrapper_1 = require("../LinkWrapper");
|
|
6
5
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
|
+
const LinkWrapper_1 = require("../LinkWrapper");
|
|
7
7
|
const RectangleItem = ({ item, layouts }) => ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}` }), (0, jsx_runtime_1.jsx)("style", { jsx: true, children: `
|
|
8
8
|
${(0, sdk_1.getLayoutStyles)(layouts, [item.layoutParams], ([{ strokeColor, fillColor, radius, strokeWidth }]) => (`
|
|
9
9
|
.rectangle-${item.id} {
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.LayoutStyle = exports.VideoItem = exports.RichTextItem = exports.RectangleItem = exports.ImageItem = exports.Item = exports.Section = exports.Article = exports.Page = exports.RichTextConverter = void 0;
|
|
18
|
-
__exportStar(require("@cntrl-site/core"), exports);
|
|
19
18
|
__exportStar(require("@cntrl-site/sdk"), exports);
|
|
20
19
|
var RichTextConverter_1 = require("./utils/RichTextConverter");
|
|
21
20
|
Object.defineProperty(exports, "RichTextConverter", { enumerable: true, get: function () { return RichTextConverter_1.RichTextConverter; } });
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RichTextConverter = exports.FontStyles = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
5
|
+
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
|
+
const LinkWrapper_1 = require("../components/LinkWrapper");
|
|
6
7
|
exports.FontStyles = {
|
|
7
8
|
'normal': {},
|
|
8
9
|
'bold': { 'font-weight': 'bold' },
|
|
@@ -18,7 +19,7 @@ class RichTextConverter {
|
|
|
18
19
|
return rec;
|
|
19
20
|
}, {});
|
|
20
21
|
let currentLineHeight = layouts.reduce((rec, layout) => {
|
|
21
|
-
const styles = (0,
|
|
22
|
+
const styles = (0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, layout.id)?.styles;
|
|
22
23
|
rec[layout.id] = styles?.find(s => s.style === 'LINEHEIGHT')?.value ?? '0';
|
|
23
24
|
return rec;
|
|
24
25
|
}, {});
|
|
@@ -38,7 +39,7 @@ class RichTextConverter {
|
|
|
38
39
|
continue;
|
|
39
40
|
}
|
|
40
41
|
const newStylesGroup = layouts.map(({ id: layoutId }) => {
|
|
41
|
-
const params = (0,
|
|
42
|
+
const params = (0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, layoutId);
|
|
42
43
|
const styles = params.styles
|
|
43
44
|
.filter(s => s.start >= block.start && s.end <= block.end)
|
|
44
45
|
.map(s => ({ ...s, start: s.start - block.start, end: s.end - block.start }));
|
|
@@ -55,7 +56,7 @@ class RichTextConverter {
|
|
|
55
56
|
styleRules[l.id].push(`
|
|
56
57
|
.${blockClass} {
|
|
57
58
|
display: ${group.some(g => g.layout === l.id) ? 'block' : 'none'};
|
|
58
|
-
text-align: ${(0,
|
|
59
|
+
text-align: ${(0, sdk_1.getClosestLayoutValue)(richText.layoutParams, layouts, l.id).textAlign};
|
|
59
60
|
line-height: 0;
|
|
60
61
|
}
|
|
61
62
|
`);
|
|
@@ -81,7 +82,7 @@ class RichTextConverter {
|
|
|
81
82
|
offset = entity.end;
|
|
82
83
|
}
|
|
83
84
|
if (entity.link) {
|
|
84
|
-
kids.push((0, jsx_runtime_1.jsx)(
|
|
85
|
+
kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: entity.link, children: entityKids }, entity.start));
|
|
85
86
|
continue;
|
|
86
87
|
}
|
|
87
88
|
kids.push(...entityKids);
|
|
@@ -111,7 +112,7 @@ class RichTextConverter {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
const styles = layouts.map(l => `
|
|
114
|
-
${(0,
|
|
115
|
+
${(0, sdk_1.getLayoutMediaQuery)(l.id, layouts)} {
|
|
115
116
|
${styleRules[l.id].join('\n')}
|
|
116
117
|
}
|
|
117
118
|
`).join('\n');
|
|
@@ -184,15 +185,15 @@ class RichTextConverter {
|
|
|
184
185
|
const { value, name } = draftStyle;
|
|
185
186
|
const map = {
|
|
186
187
|
'COLOR': { 'color': value },
|
|
187
|
-
'TYPEFACE': { 'font-family':
|
|
188
|
+
'TYPEFACE': { 'font-family': `${value}` },
|
|
188
189
|
'FONTSTYLE': value ? { ...exports.FontStyles[value] } : {},
|
|
189
190
|
'FONTWEIGHT': { 'font-weight': value },
|
|
190
191
|
'FONTSIZE': { 'font-size': `${parseFloat(value) * 100}vw` },
|
|
191
192
|
'LINEHEIGHT': { 'line-height': `${parseFloat(value) * 100}vw` },
|
|
192
193
|
'LETTERSPACING': { 'letter-spacing': `${parseFloat(value) * 100}vw` },
|
|
193
194
|
'WORDSPACING': { 'word-spacing': `${parseFloat(value) * 100}vw` },
|
|
194
|
-
'TEXTTRANSFORM': value ? { 'text-transform': value } : { 'text-transform':
|
|
195
|
-
'VERTICALALIGN': value ? { 'vertical-align': value } : { 'vertical-align':
|
|
195
|
+
'TEXTTRANSFORM': value ? { 'text-transform': value } : { 'text-transform': sdk_1.TextTransform.None },
|
|
196
|
+
'VERTICALALIGN': value ? { 'vertical-align': value } : { 'vertical-align': sdk_1.VerticalAlign.Unset },
|
|
196
197
|
'TEXTDECORATION': { 'text-decoration': value }
|
|
197
198
|
};
|
|
198
199
|
const css = map[name];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.js",
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cntrl-site/
|
|
25
|
-
"@cntrl-site/sdk": "^0.0.3",
|
|
24
|
+
"@cntrl-site/sdk": "^0.2.0",
|
|
26
25
|
"html-react-parser": "^3.0.1",
|
|
27
26
|
"styled-jsx": "^5.0.2"
|
|
28
27
|
},
|
package/src/components/Item.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ComponentType, FC } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
getLayoutStyles,
|
|
3
4
|
ArticleItemType,
|
|
4
5
|
ArticleItemSizingType as SizingType,
|
|
5
6
|
TArticleItemAny,
|
|
6
7
|
TLayout
|
|
7
|
-
} from '@cntrl-site/
|
|
8
|
-
import { getLayoutStyles } from '@cntrl-site/sdk';
|
|
8
|
+
} from '@cntrl-site/sdk';
|
|
9
9
|
import { RectangleItem } from './items/RectangleItem';
|
|
10
10
|
import { ImageItem } from './items/ImageItem';
|
|
11
11
|
import { VideoItem } from './items/VideoItem';
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
1
|
+
import React, { MouseEvent, ReactElement, ReactNode, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
4
|
url?: string;
|
|
5
|
-
children: ReactElement;
|
|
5
|
+
children: ReactElement | ReactNode[];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export const LinkWrapper: React.FC<Props> = ({ url, children }) =>
|
|
9
|
-
|
|
8
|
+
export const LinkWrapper: React.FC<Props> = ({ url, children }) => {
|
|
9
|
+
return url ? (
|
|
10
|
+
<a
|
|
11
|
+
href={!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('/') ? `//${url}`: url}
|
|
12
|
+
target={url.startsWith('/') ? '_self' : '_blank'}
|
|
13
|
+
rel="noreferrer"
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</a>
|
|
17
|
+
) : (
|
|
18
|
+
<>{children}</>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
package/src/components/Page.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import HTMLReactParser, { domToReact } from 'html-react-parser';
|
|
3
|
-
import { TArticle, TProject, TMeta } from '@cntrl-site/
|
|
3
|
+
import { TArticle, TProject, TMeta, FontFaceGenerator, TPageMeta } from '@cntrl-site/sdk';
|
|
4
4
|
import Head from 'next/head';
|
|
5
5
|
import { Article } from './Article';
|
|
6
6
|
|
|
@@ -13,6 +13,17 @@ interface Props {
|
|
|
13
13
|
export const Page: FC<Props> = ({ article, project, meta }) => {
|
|
14
14
|
const googleFonts: ReturnType<typeof domToReact> = HTMLReactParser(project.fonts.google);
|
|
15
15
|
const adobeFonts: ReturnType<typeof domToReact> = HTMLReactParser(project.fonts.adobe);
|
|
16
|
+
|
|
17
|
+
const getPageMeta = (projectMeta: TMeta, pageMeta: TPageMeta): TMeta => {
|
|
18
|
+
return {
|
|
19
|
+
title: pageMeta.title ? pageMeta.title : projectMeta.title,
|
|
20
|
+
description: pageMeta.description ? pageMeta.description : projectMeta.description,
|
|
21
|
+
keywords: pageMeta.keywords ? pageMeta.keywords : projectMeta.keywords,
|
|
22
|
+
opengraphThumbnail: pageMeta.opengraphThumbnail ? pageMeta.opengraphThumbnail : projectMeta.opengraphThumbnail,
|
|
23
|
+
favicon: projectMeta.favicon
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const priorityMeta = getPageMeta(project.meta, meta);
|
|
16
27
|
const parsedFonts = {
|
|
17
28
|
...(typeof googleFonts === 'object' ? googleFonts : {}),
|
|
18
29
|
...(typeof adobeFonts === 'object' ? adobeFonts : {})
|
|
@@ -21,26 +32,19 @@ export const Page: FC<Props> = ({ article, project, meta }) => {
|
|
|
21
32
|
const htmlHead = HTMLReactParser(project.html.head);
|
|
22
33
|
const afterBodyOpen = HTMLReactParser(project.html.afterBodyOpen);
|
|
23
34
|
const beforeBodyClose = HTMLReactParser(project.html.beforeBodyClose);
|
|
35
|
+
const ffGenerator = new FontFaceGenerator(customFonts);
|
|
24
36
|
return (
|
|
25
37
|
<>
|
|
26
38
|
<Head>
|
|
27
|
-
<title>{
|
|
28
|
-
<meta name="description" content={
|
|
29
|
-
<meta name="keywords" content={
|
|
30
|
-
<meta property="og:image" content={
|
|
31
|
-
<link rel="icon" href={
|
|
39
|
+
<title>{priorityMeta.title}</title>
|
|
40
|
+
<meta name="description" content={priorityMeta.description} />
|
|
41
|
+
<meta name="keywords" content={priorityMeta.keywords} />
|
|
42
|
+
<meta property="og:image" content={priorityMeta.opengraphThumbnail} />
|
|
43
|
+
<link rel="icon" href={priorityMeta.favicon} />
|
|
32
44
|
{customFonts.length > 0 && (
|
|
33
45
|
<style
|
|
34
46
|
dangerouslySetInnerHTML={{
|
|
35
|
-
__html:
|
|
36
|
-
`
|
|
37
|
-
@font-face {
|
|
38
|
-
font-family: ${font.name};
|
|
39
|
-
font-weight: ${font.weight};
|
|
40
|
-
src: ${font.files.map(file => `url('${file.url}') format('${file.type}')`).join(', ')};
|
|
41
|
-
}
|
|
42
|
-
`
|
|
43
|
-
)).join('\n')
|
|
47
|
+
__html: ffGenerator.generate()
|
|
44
48
|
}}
|
|
45
49
|
/>
|
|
46
50
|
)}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC, ReactElement } from 'react';
|
|
2
|
-
import { TLayout, TArticleSection } from '@cntrl-site/
|
|
3
|
-
import { getLayoutStyles } from '@cntrl-site/sdk';
|
|
2
|
+
import { getLayoutStyles, TLayout, TArticleSection } from '@cntrl-site/sdk';
|
|
4
3
|
|
|
5
4
|
type SectionChild = ReactElement<any, any>;
|
|
6
5
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { TImageItem } from '@cntrl-site/
|
|
3
|
-
import { getLayoutStyles } from '@cntrl-site/sdk';
|
|
2
|
+
import { getLayoutStyles, TImageItem } from '@cntrl-site/sdk';
|
|
4
3
|
import { ItemProps } from '../Item';
|
|
5
4
|
import { LinkWrapper } from '../LinkWrapper';
|
|
6
5
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { TRectangleItem } from '@cntrl-site/
|
|
2
|
+
import { TRectangleItem, getLayoutStyles } from '@cntrl-site/sdk';
|
|
3
3
|
import { ItemProps } from '../Item';
|
|
4
4
|
import { LinkWrapper } from '../LinkWrapper';
|
|
5
|
-
import { getLayoutStyles } from '@cntrl-site/sdk';
|
|
6
5
|
|
|
7
6
|
export const RectangleItem: FC<ItemProps<TRectangleItem>> = ({ item, layouts }) => (
|
|
8
7
|
<LinkWrapper url={item.link?.url}>
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
VerticalAlign,
|
|
8
8
|
getClosestLayoutValue,
|
|
9
9
|
getLayoutMediaQuery
|
|
10
|
-
} from '@cntrl-site/
|
|
10
|
+
} from '@cntrl-site/sdk';
|
|
11
|
+
import { LinkWrapper } from '../components/LinkWrapper';
|
|
11
12
|
|
|
12
13
|
interface StyleGroup {
|
|
13
14
|
start: number;
|
|
@@ -110,7 +111,7 @@ export class RichTextConverter {
|
|
|
110
111
|
offset = entity.end;
|
|
111
112
|
}
|
|
112
113
|
if (entity.link) {
|
|
113
|
-
kids.push(<
|
|
114
|
+
kids.push(<LinkWrapper key={entity.start} url={entity.link} >{entityKids}</LinkWrapper>);
|
|
114
115
|
continue;
|
|
115
116
|
}
|
|
116
117
|
kids.push(...entityKids);
|
|
@@ -216,7 +217,7 @@ export class RichTextConverter {
|
|
|
216
217
|
const { value, name } = draftStyle;
|
|
217
218
|
const map: Record<string, Record<string, string | undefined>> = {
|
|
218
219
|
'COLOR': { 'color': value },
|
|
219
|
-
'TYPEFACE': { 'font-family':
|
|
220
|
+
'TYPEFACE': { 'font-family': `${value}` },
|
|
220
221
|
'FONTSTYLE': value ? { ...FontStyles[value] } : {},
|
|
221
222
|
'FONTWEIGHT': { 'font-weight': value },
|
|
222
223
|
'FONTSIZE': { 'font-size': `${parseFloat(value!) * 100}vw` },
|