@cntrl-site/sdk-nextjs 0.21.0 → 0.21.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.
@@ -168,8 +168,10 @@ class RichTextConverter {
168
168
  }
169
169
  return styleGroups;
170
170
  }
171
- groupEntities(entities, styleGroups) {
171
+ groupEntities(entitiesList, styleGroups) {
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'));
173
175
  if (!entities.length && !styleGroups)
174
176
  return;
175
177
  if (!styleGroups || styleGroups.length === 0) {
@@ -22,8 +22,8 @@ function useImageFx(canvas, enabled, { imageUrl, fragmentShader, cursor }) {
22
22
  return;
23
23
  const handleMouseMove = (evt) => {
24
24
  const rect = canvas.getBoundingClientRect();
25
- const x = (0, rangeMap_1.rangeMap)(evt.clientX, rect.left, rect.left + rect.width, 0, 1);
26
- const y = (0, rangeMap_1.rangeMap)(evt.clientY, rect.top, rect.top + rect.height, 0, 1);
25
+ const x = (0, rangeMap_1.rangeMap)(evt.clientX, rect.left, rect.left + rect.width, 0, 1, true);
26
+ const y = (0, rangeMap_1.rangeMap)(evt.clientY, rect.top, rect.top + rect.height, 0, 1, true);
27
27
  imageFx.setParam('cursor', [x, y]);
28
28
  };
29
29
  window.addEventListener('mousemove', handleMouseMove, { capture: true, passive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -201,8 +201,10 @@ export class RichTextConverter {
201
201
  return styleGroups;
202
202
  }
203
203
 
204
- private groupEntities(entities: RichTextEntity[], styleGroups?: StyleGroup[]): EntitiesGroup[] | undefined {
204
+ private groupEntities(entitiesList: RichTextEntity[], styleGroups?: StyleGroup[]): EntitiesGroup[] | undefined {
205
205
  const entitiesGroups: EntitiesGroup[] = [];
206
+ // some entities may have no data, need to filter them out (case with deleting a section/page that was linked to)
207
+ const entities = entitiesList.filter(e => e.hasOwnProperty('data'));
206
208
  if (!entities.length && !styleGroups) return;
207
209
  if (!styleGroups || styleGroups.length === 0) {
208
210
  const dividersSet = entities.reduce((ds, s) => {
@@ -45,8 +45,8 @@ export function useImageFx(
45
45
  if (!cursor || cursor.type !== 'mouse' || !canvas || !imageFx) return;
46
46
  const handleMouseMove = (evt: MouseEvent) => {
47
47
  const rect = canvas.getBoundingClientRect();
48
- const x = rangeMap(evt.clientX, rect.left, rect.left + rect.width, 0, 1);
49
- const y = rangeMap(evt.clientY, rect.top, rect.top + rect.height, 0, 1);
48
+ const x = rangeMap(evt.clientX, rect.left, rect.left + rect.width, 0, 1, true);
49
+ const y = rangeMap(evt.clientY, rect.top, rect.top + rect.height, 0, 1, true);
50
50
  imageFx.setParam('cursor', [x, y]);
51
51
  };
52
52
  window.addEventListener('mousemove', handleMouseMove, { capture: true, passive: true });