@cntrl-site/sdk-nextjs 0.17.0 → 0.17.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.
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,15 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="myValues">
6
+ <value>
7
+ <list size="1">
8
+ <item index="0" class="java.lang.String" itemvalue="jsx" />
9
+ </list>
10
+ </value>
11
+ </option>
12
+ <option name="myCustomValuesEnabled" value="true" />
13
+ </inspection_tool>
14
+ </profile>
15
+ </component>
Binary file
@@ -169,8 +169,24 @@ class RichTextConverter {
169
169
  }
170
170
  groupEntities(entities, styleGroups) {
171
171
  const entitiesGroups = [];
172
- if (!styleGroups || styleGroups.length === 0)
172
+ if (!entities.length && !styleGroups)
173
173
  return;
174
+ if (!styleGroups || styleGroups.length === 0) {
175
+ const dividersSet = entities.reduce((ds, s) => {
176
+ ds.add(s.start);
177
+ ds.add(s.end);
178
+ return ds;
179
+ }, new Set([entities[0].start, entities[entities.length - 1].end]));
180
+ const dividers = Array.from(dividersSet).sort((a, b) => a - b);
181
+ for (let i = 0; i < dividers.length - 1; i += 1) {
182
+ const start = dividers[i];
183
+ const end = dividers[i + 1];
184
+ const entity = entities.find(e => e.start === start);
185
+ entitiesGroups.push(Object.assign({ stylesGroup: [], start,
186
+ end }, (entity && { link: entity.data.url })));
187
+ }
188
+ return entitiesGroups;
189
+ }
174
190
  if (entities.length === 0) {
175
191
  entitiesGroups.push({
176
192
  stylesGroup: styleGroups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -201,7 +201,27 @@ export class RichTextConverter {
201
201
 
202
202
  private groupEntities(entities: RichText.Entity[], styleGroups?: StyleGroup[]): EntitiesGroup[] | undefined {
203
203
  const entitiesGroups: EntitiesGroup[] = [];
204
- if (!styleGroups || styleGroups.length === 0) return;
204
+ if (!entities.length && !styleGroups) return;
205
+ if (!styleGroups || styleGroups.length === 0) {
206
+ const dividersSet = entities.reduce((ds, s) => {
207
+ ds.add(s.start);
208
+ ds.add(s.end);
209
+ return ds;
210
+ }, new Set<number>([entities[0].start, entities[entities.length - 1].end]));
211
+ const dividers = Array.from(dividersSet).sort((a, b) => a - b);
212
+ for (let i = 0; i < dividers.length - 1; i += 1) {
213
+ const start = dividers[i];
214
+ const end = dividers[i + 1];
215
+ const entity = entities.find(e => e.start === start);
216
+ entitiesGroups.push({
217
+ stylesGroup: [],
218
+ start,
219
+ end,
220
+ ...(entity && { link: entity.data.url })
221
+ });
222
+ }
223
+ return entitiesGroups;
224
+ }
205
225
  if (entities.length === 0) {
206
226
  entitiesGroups.push({
207
227
  stylesGroup: styleGroups,
Binary file