@cntrl-site/sdk-nextjs 1.6.8-alpha.0 → 1.6.9
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/cntrl-site-sdk-nextjs-1.6.9-beta.5.tgz +0 -0
- package/cntrl-site-sdk-nextjs-1.6.9-beta.6.tgz +0 -0
- package/cntrl-site-sdk-nextjs-1.6.9-beta.7.tgz +0 -0
- package/cntrl-site-sdk-nextjs-1.6.9-beta.8.tgz +0 -0
- package/lib/components/items/CompoundItem/CompoundItem.js +1 -0
- package/lib/utils/RichTextConverter/RichTextConverter.js +18 -18
- package/package.json +1 -1
- package/src/components/items/CompoundItem/CompoundItem.tsx +1 -0
- package/src/components/items/RichTextItem/RichTextItem.tsx +1 -1
- package/src/utils/RichTextConverter/RichTextConverter.tsx +19 -19
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -34,6 +34,7 @@ const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
|
|
|
34
34
|
}, [isInteractive, onVisibilityChange]);
|
|
35
35
|
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_e = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
36
36
|
.compound-${item.id} {
|
|
37
|
+
overflow: ${item.commonParams.overflow};
|
|
37
38
|
position: absolute;
|
|
38
39
|
width: 100%;
|
|
39
40
|
height: 100%;
|
|
@@ -7,9 +7,9 @@ const sdk_1 = require("@cntrl-site/sdk");
|
|
|
7
7
|
const LinkWrapper_1 = require("../../components/items/LinkWrapper");
|
|
8
8
|
const getFontFamilyValue_1 = require("../getFontFamilyValue");
|
|
9
9
|
exports.FontStyles = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
normal: { 'font-style': 'normal' },
|
|
11
|
+
bold: { 'font-weight': 'bold' },
|
|
12
|
+
italic: { 'font-style': 'italic' }
|
|
13
13
|
};
|
|
14
14
|
class RichTextConverter {
|
|
15
15
|
toHtml(richText, layouts) {
|
|
@@ -20,7 +20,7 @@ class RichTextConverter {
|
|
|
20
20
|
rec[layout.id] = [];
|
|
21
21
|
return rec;
|
|
22
22
|
}, {});
|
|
23
|
-
|
|
23
|
+
const currentLineHeight = layouts.reduce((rec, layout) => {
|
|
24
24
|
var _a;
|
|
25
25
|
const styles = richText.layoutParams[layout.id].rangeStyles;
|
|
26
26
|
rec[layout.id] = (_a = styles === null || styles === void 0 ? void 0 : styles.find(s => s.style === 'LINEHEIGHT')) === null || _a === void 0 ? void 0 : _a.value;
|
|
@@ -223,18 +223,18 @@ class RichTextConverter {
|
|
|
223
223
|
static fromRangeStylesToInline(draftStyle, exemplary) {
|
|
224
224
|
const { value, name } = draftStyle;
|
|
225
225
|
const map = {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
226
|
+
COLOR: { color: getResolvedValue(value, name) },
|
|
227
|
+
TYPEFACE: { 'font-family': `${(0, getFontFamilyValue_1.getFontFamilyValue)(value)}` },
|
|
228
|
+
FONTSTYLE: value ? Object.assign({}, exports.FontStyles[value]) : {},
|
|
229
|
+
FONTWEIGHT: { 'font-weight': value },
|
|
230
|
+
FONTSIZE: { 'font-size': `${Number.parseFloat(value) * exemplary}px` },
|
|
231
|
+
LINEHEIGHT: { 'line-height': `${Number.parseFloat(value) * exemplary}px` },
|
|
232
|
+
LETTERSPACING: { 'letter-spacing': `${Number.parseFloat(value) * exemplary}px` },
|
|
233
|
+
WORDSPACING: { 'word-spacing': `${Number.parseFloat(value) * exemplary}px` },
|
|
234
|
+
TEXTTRANSFORM: value ? { 'text-transform': value } : { 'text-transform': sdk_1.TextTransform.None },
|
|
235
|
+
VERTICALALIGN: value ? { 'vertical-align': value } : { 'vertical-align': sdk_1.VerticalAlign.Unset },
|
|
236
|
+
TEXTDECORATION: { 'text-decoration': value },
|
|
237
|
+
FONTVARIANT: { 'font-variant': value }
|
|
238
238
|
};
|
|
239
239
|
const css = map[name];
|
|
240
240
|
if (!css) {
|
|
@@ -260,8 +260,8 @@ function getResolvedValue(value, name) {
|
|
|
260
260
|
return value;
|
|
261
261
|
return value ? color_1.CntrlColor.parse(value).toCss() : value;
|
|
262
262
|
}
|
|
263
|
-
function sliceSymbols(text, start, end = NaN) {
|
|
264
|
-
let startOffset = NaN;
|
|
263
|
+
function sliceSymbols(text, start, end = Number.NaN) {
|
|
264
|
+
let startOffset = Number.NaN;
|
|
265
265
|
let endOffset = 0;
|
|
266
266
|
let count = -1;
|
|
267
267
|
for (const ch of text) {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { ItemProps } from '../Item';
|
|
|
6
6
|
import { useRichTextItem } from './useRichTextItem';
|
|
7
7
|
import { useCntrlContext } from '../../../provider/useCntrlContext';
|
|
8
8
|
import { useRichTextItemValues } from '../useRichTextItemValues';
|
|
9
|
-
import { useRegisterResize } from
|
|
9
|
+
import { useRegisterResize } from '../../../common/useRegisterResize';
|
|
10
10
|
import { getFontFamilyValue } from '../../../utils/getFontFamilyValue';
|
|
11
11
|
import { useExemplary } from '../../../common/useExemplary';
|
|
12
12
|
import { useItemAngle } from '../useItemAngle';
|
|
@@ -32,9 +32,9 @@ interface Style {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const FontStyles: Record<string, Record<string, string>> = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
normal: { 'font-style': 'normal' },
|
|
36
|
+
bold: { 'font-weight': 'bold' },
|
|
37
|
+
italic: { 'font-style': 'italic' }
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export class RichTextConverter {
|
|
@@ -48,7 +48,7 @@ export class RichTextConverter {
|
|
|
48
48
|
rec[layout.id] = [];
|
|
49
49
|
return rec;
|
|
50
50
|
}, {});
|
|
51
|
-
|
|
51
|
+
const currentLineHeight = layouts.reduce<Record<string, string | undefined>>((rec, layout) => {
|
|
52
52
|
const styles = richText.layoutParams[layout.id].rangeStyles;
|
|
53
53
|
rec[layout.id] = styles?.find(s => s.style === 'LINEHEIGHT')?.value;
|
|
54
54
|
return rec;
|
|
@@ -194,7 +194,7 @@ export class RichTextConverter {
|
|
|
194
194
|
start,
|
|
195
195
|
end,
|
|
196
196
|
styles: applied.map(s => ({ name: s.style, value: s.value }))
|
|
197
|
-
})
|
|
197
|
+
});
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
return styleGroups;
|
|
@@ -262,18 +262,18 @@ export class RichTextConverter {
|
|
|
262
262
|
private static fromRangeStylesToInline(draftStyle: Style, exemplary: number): string {
|
|
263
263
|
const { value, name } = draftStyle;
|
|
264
264
|
const map: Record<string, Record<string, string | undefined>> = {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
265
|
+
COLOR: { color: getResolvedValue(value, name) },
|
|
266
|
+
TYPEFACE: { 'font-family': `${getFontFamilyValue(value!)}` },
|
|
267
|
+
FONTSTYLE: value ? { ...FontStyles[value] } : {},
|
|
268
|
+
FONTWEIGHT: { 'font-weight': value },
|
|
269
|
+
FONTSIZE: { 'font-size': `${Number.parseFloat(value!) * exemplary}px` },
|
|
270
|
+
LINEHEIGHT: { 'line-height': `${Number.parseFloat(value!) * exemplary}px` },
|
|
271
|
+
LETTERSPACING: { 'letter-spacing': `${Number.parseFloat(value!) * exemplary}px` },
|
|
272
|
+
WORDSPACING: { 'word-spacing': `${Number.parseFloat(value!) * exemplary}px` },
|
|
273
|
+
TEXTTRANSFORM: value ? { 'text-transform': value as TextTransform } : { 'text-transform': TextTransform.None },
|
|
274
|
+
VERTICALALIGN: value ? { 'vertical-align': value as VerticalAlign } : { 'vertical-align': VerticalAlign.Unset },
|
|
275
|
+
TEXTDECORATION: { 'text-decoration': value },
|
|
276
|
+
FONTVARIANT: { 'font-variant': value }
|
|
277
277
|
};
|
|
278
278
|
const css = map[name];
|
|
279
279
|
if (!css) {
|
|
@@ -300,8 +300,8 @@ function getResolvedValue(value: string | undefined, name: string) {
|
|
|
300
300
|
return value ? CntrlColor.parse(value).toCss() : value;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
function sliceSymbols(text: string, start: number, end: number = NaN): string {
|
|
304
|
-
let startOffset = NaN;
|
|
303
|
+
function sliceSymbols(text: string, start: number, end: number = Number.NaN): string {
|
|
304
|
+
let startOffset = Number.NaN;
|
|
305
305
|
let endOffset = 0;
|
|
306
306
|
let count = -1;
|
|
307
307
|
for (const ch of text) {
|