@cntrl-site/sdk-nextjs 0.26.1 → 0.26.2
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/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +15 -0
- package/lib/utils/RichTextConverter/RichTextConverter.js +15 -11
- package/package.json +1 -1
- package/src/utils/RichTextConverter/RichTextConverter.tsx +12 -10
- package/cntrl-site-sdk-nextjs-0.25.1.tgz +0 -0
|
@@ -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>
|
|
@@ -167,17 +167,19 @@ class RichTextConverter {
|
|
|
167
167
|
}
|
|
168
168
|
return styleGroups;
|
|
169
169
|
}
|
|
170
|
-
groupEntities(
|
|
171
|
-
var _a, _b, _c, _d;
|
|
170
|
+
groupEntities(entities, styleGroups) {
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
172
172
|
const entitiesGroups = [];
|
|
173
|
-
// some entities may have no data, need to filter them out (case with deleting a section/page that was linked to)
|
|
174
|
-
const entities = entitiesList.filter(e => e.hasOwnProperty('data'));
|
|
175
173
|
if (!entities.length && !styleGroups)
|
|
176
174
|
return;
|
|
177
175
|
if (!styleGroups || styleGroups.length === 0) {
|
|
178
|
-
const dividersSet = entities.reduce((ds,
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
const dividersSet = entities.reduce((ds, e) => {
|
|
177
|
+
// some entities may have no data, need to filter them out
|
|
178
|
+
// (case with deleting a section/page that was linked to)
|
|
179
|
+
if (!e.hasOwnProperty('data'))
|
|
180
|
+
return ds;
|
|
181
|
+
ds.add(e.start);
|
|
182
|
+
ds.add(e.end);
|
|
181
183
|
return ds;
|
|
182
184
|
}, new Set([entities[0].start, entities[entities.length - 1].end]));
|
|
183
185
|
const dividers = Array.from(dividersSet).sort((a, b) => a - b);
|
|
@@ -200,9 +202,11 @@ class RichTextConverter {
|
|
|
200
202
|
}
|
|
201
203
|
const start = entities[0].start < styleGroups[0].start ? entities[0].start : styleGroups[0].start;
|
|
202
204
|
const end = entities[entities.length - 1].end > styleGroups[styleGroups.length - 1].end ? entities[entities.length - 1].end : styleGroups[styleGroups.length - 1].end;
|
|
203
|
-
const entitiesDividers = entities.reduce((ds,
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
const entitiesDividers = entities.reduce((ds, e) => {
|
|
206
|
+
if (!e.hasOwnProperty('data'))
|
|
207
|
+
return ds;
|
|
208
|
+
ds.add(e.start);
|
|
209
|
+
ds.add(e.end);
|
|
206
210
|
return ds;
|
|
207
211
|
}, new Set([start, end]));
|
|
208
212
|
const entityDividers = Array.from(entitiesDividers).sort((a, b) => a - b);
|
|
@@ -211,7 +215,7 @@ class RichTextConverter {
|
|
|
211
215
|
const end = entityDividers[i + 1];
|
|
212
216
|
const entity = entities.find(e => e.start === start);
|
|
213
217
|
entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
|
|
214
|
-
end }, (entity && { link: entity.data.url, target: entity.data.target })));
|
|
218
|
+
end }, (entity && { link: (_f = (_e = entity.data) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : '', target: (_h = (_g = entity.data) === null || _g === void 0 ? void 0 : _g.target) !== null && _h !== void 0 ? _h : '_self' })));
|
|
215
219
|
}
|
|
216
220
|
return entitiesGroups;
|
|
217
221
|
}
|
package/package.json
CHANGED
|
@@ -199,15 +199,16 @@ export class RichTextConverter {
|
|
|
199
199
|
return styleGroups;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
private groupEntities(
|
|
202
|
+
private groupEntities(entities: RichTextEntity[], styleGroups?: StyleGroup[]): EntitiesGroup[] | undefined {
|
|
203
203
|
const entitiesGroups: EntitiesGroup[] = [];
|
|
204
|
-
// some entities may have no data, need to filter them out (case with deleting a section/page that was linked to)
|
|
205
|
-
const entities = entitiesList.filter(e => e.hasOwnProperty('data'));
|
|
206
204
|
if (!entities.length && !styleGroups) return;
|
|
207
205
|
if (!styleGroups || styleGroups.length === 0) {
|
|
208
|
-
const dividersSet = entities.reduce((ds,
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
const dividersSet = entities.reduce((ds, e) => {
|
|
207
|
+
// some entities may have no data, need to filter them out
|
|
208
|
+
// (case with deleting a section/page that was linked to)
|
|
209
|
+
if (!e.hasOwnProperty('data')) return ds;
|
|
210
|
+
ds.add(e.start);
|
|
211
|
+
ds.add(e.end);
|
|
211
212
|
return ds;
|
|
212
213
|
}, new Set<number>([entities[0].start, entities[entities.length - 1].end]));
|
|
213
214
|
const dividers = Array.from(dividersSet).sort((a, b) => a - b);
|
|
@@ -234,9 +235,10 @@ export class RichTextConverter {
|
|
|
234
235
|
}
|
|
235
236
|
const start = entities[0].start < styleGroups[0].start ? entities[0].start : styleGroups[0].start;
|
|
236
237
|
const end = entities[entities.length - 1].end > styleGroups[styleGroups.length - 1].end ? entities[entities.length - 1].end : styleGroups[styleGroups.length - 1].end;
|
|
237
|
-
const entitiesDividers = entities.reduce((ds,
|
|
238
|
-
|
|
239
|
-
ds.add(
|
|
238
|
+
const entitiesDividers = entities.reduce((ds, e) => {
|
|
239
|
+
if (!e.hasOwnProperty('data')) return ds;
|
|
240
|
+
ds.add(e.start);
|
|
241
|
+
ds.add(e.end);
|
|
240
242
|
return ds;
|
|
241
243
|
}, new Set<number>([start, end]));
|
|
242
244
|
const entityDividers = Array.from(entitiesDividers).sort((a, b) => a - b);
|
|
@@ -249,7 +251,7 @@ export class RichTextConverter {
|
|
|
249
251
|
stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end),
|
|
250
252
|
start,
|
|
251
253
|
end,
|
|
252
|
-
...(entity && { link: entity.data
|
|
254
|
+
...(entity && { link: entity.data?.url ?? '', target: entity.data?.target ?? '_self' })
|
|
253
255
|
});
|
|
254
256
|
}
|
|
255
257
|
|
|
Binary file
|