@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.
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +15 -0
- package/cntrl-site-sdk-nextjs-0.17.1.tgz +0 -0
- package/lib/utils/RichTextConverter/RichTextConverter.js +17 -1
- package/package.json +1 -1
- package/src/utils/RichTextConverter/RichTextConverter.tsx +21 -1
- package/cntrl-site-sdk-nextjs-0.16.15.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>
|
|
Binary file
|
|
@@ -169,8 +169,24 @@ class RichTextConverter {
|
|
|
169
169
|
}
|
|
170
170
|
groupEntities(entities, styleGroups) {
|
|
171
171
|
const entitiesGroups = [];
|
|
172
|
-
if (!
|
|
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
|
@@ -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 (!
|
|
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
|