@cntrl-site/sdk-nextjs 0.16.12 → 0.16.14
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/items/RichTextItem.js +2 -1
- package/lib/utils/RichTextConverter/RichTextConverter.js +2 -1
- package/lib/utils/getFontFamilyValue.js +7 -0
- package/package.json +1 -1
- package/src/components/items/RichTextItem.tsx +2 -1
- package/src/utils/RichTextConverter/RichTextConverter.tsx +2 -1
- package/src/utils/getFontFamilyValue.ts +3 -0
|
@@ -13,6 +13,7 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
|
|
|
13
13
|
const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
|
|
14
14
|
const useRichTextItemValues_1 = require("./useRichTextItemValues");
|
|
15
15
|
const useRegisterResize_1 = require("../../common/useRegisterResize");
|
|
16
|
+
const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
|
|
16
17
|
const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
17
18
|
const [content, styles] = (0, useRichTextItem_1.useRichTextItem)(item);
|
|
18
19
|
const id = (0, react_1.useId)();
|
|
@@ -40,7 +41,7 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
|
|
|
40
41
|
line-height: ${layoutParams.lineHeight * exemplary}px;
|
|
41
42
|
letter-spacing: ${layoutParams.letterSpacing * exemplary}px;
|
|
42
43
|
word-spacing: ${layoutParams.wordSpacing * exemplary}px;
|
|
43
|
-
font-family:
|
|
44
|
+
font-family: ${(0, getFontFamilyValue_1.getFontFamilyValue)(layoutParams.typeFace)};
|
|
44
45
|
font-weight: ${layoutParams.fontWeight};
|
|
45
46
|
font-style: ${layoutParams.fontStyle ? layoutParams.fontStyle : 'normal'};
|
|
46
47
|
text-decoration: ${layoutParams.textDecoration};
|
|
@@ -4,6 +4,7 @@ exports.RichTextConverter = exports.FontStyles = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
6
|
const LinkWrapper_1 = require("../../components/LinkWrapper");
|
|
7
|
+
const getFontFamilyValue_1 = require("../getFontFamilyValue");
|
|
7
8
|
exports.FontStyles = {
|
|
8
9
|
'normal': {},
|
|
9
10
|
'bold': { 'font-weight': 'bold' },
|
|
@@ -199,7 +200,7 @@ class RichTextConverter {
|
|
|
199
200
|
const { value, name } = draftStyle;
|
|
200
201
|
const map = {
|
|
201
202
|
'COLOR': { 'color': getResolvedValue(value, name) },
|
|
202
|
-
'TYPEFACE': { 'font-family':
|
|
203
|
+
'TYPEFACE': { 'font-family': `${(0, getFontFamilyValue_1.getFontFamilyValue)(value)}` },
|
|
203
204
|
'FONTSTYLE': value ? Object.assign({}, exports.FontStyles[value]) : {},
|
|
204
205
|
'FONTWEIGHT': { 'font-weight': value },
|
|
205
206
|
'FONTSIZE': { 'font-size': `${parseFloat(value) * exemplary}px` },
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFontFamilyValue = void 0;
|
|
4
|
+
function getFontFamilyValue(value) {
|
|
5
|
+
return value && value.includes('"') ? value : `"${value}"`;
|
|
6
|
+
}
|
|
7
|
+
exports.getFontFamilyValue = getFontFamilyValue;
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { useCntrlContext } from '../../provider/useCntrlContext';
|
|
|
7
7
|
import { getHoverStyles, getTransitions } from '../../utils/HoverStyles/HoverStyles';
|
|
8
8
|
import { useRichTextItemValues } from './useRichTextItemValues';
|
|
9
9
|
import { useRegisterResize } from "../../common/useRegisterResize";
|
|
10
|
+
import { getFontFamilyValue } from '../../utils/getFontFamilyValue';
|
|
10
11
|
|
|
11
12
|
export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, onResize }) => {
|
|
12
13
|
const [content, styles] = useRichTextItem(item);
|
|
@@ -48,7 +49,7 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
|
|
|
48
49
|
line-height: ${layoutParams.lineHeight * exemplary}px;
|
|
49
50
|
letter-spacing: ${layoutParams.letterSpacing * exemplary}px;
|
|
50
51
|
word-spacing: ${layoutParams.wordSpacing * exemplary}px;
|
|
51
|
-
font-family:
|
|
52
|
+
font-family: ${getFontFamilyValue(layoutParams.typeFace)};
|
|
52
53
|
font-weight: ${layoutParams.fontWeight};
|
|
53
54
|
font-style: ${layoutParams.fontStyle ? layoutParams.fontStyle : 'normal'};
|
|
54
55
|
text-decoration: ${layoutParams.textDecoration};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
TextAlign
|
|
11
11
|
} from '@cntrl-site/sdk';
|
|
12
12
|
import { LinkWrapper } from '../../components/LinkWrapper';
|
|
13
|
+
import { getFontFamilyValue } from '../getFontFamilyValue';
|
|
13
14
|
|
|
14
15
|
interface StyleGroup {
|
|
15
16
|
start: number;
|
|
@@ -237,7 +238,7 @@ export class RichTextConverter {
|
|
|
237
238
|
const { value, name } = draftStyle;
|
|
238
239
|
const map: Record<string, Record<string, string | undefined>> = {
|
|
239
240
|
'COLOR': { 'color': getResolvedValue(value, name) },
|
|
240
|
-
'TYPEFACE': { 'font-family':
|
|
241
|
+
'TYPEFACE': { 'font-family': `${getFontFamilyValue(value!)}` },
|
|
241
242
|
'FONTSTYLE': value ? { ...FontStyles[value] } : {},
|
|
242
243
|
'FONTWEIGHT': { 'font-weight': value },
|
|
243
244
|
'FONTSIZE': { 'font-size': `${parseFloat(value!) * exemplary}px` },
|