@vonaffenfels/slate-editor 1.2.23 → 1.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.2.23",
3
+ "version": "1.2.29",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -72,7 +72,7 @@
72
72
  "cssnano": "^5.0.1",
73
73
  "escape-html": "^1.0.3"
74
74
  },
75
- "gitHead": "f655174e66d666f29f698c19fa9f32984c1408c3",
75
+ "gitHead": "564cc567d33fd5e681c7503a86a41f54a9d5c502",
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  }
@@ -1,6 +1,6 @@
1
1
  import React, {
2
2
  isValidElement,
3
- Fragment, useMemo, useEffect,
3
+ Fragment, useMemo,
4
4
  } from "react";
5
5
  import {Default} from "../Nodes/Default";
6
6
  import {Leaf} from "../Nodes/Leaf";
@@ -75,6 +75,18 @@ export function Serializer({
75
75
  return val;
76
76
  }, [value, adDefinitionDesktop, adDefinitionMobile, fixedPositions, fixedPositionTypes]);
77
77
 
78
+ const filteredValue = useMemo(() => {
79
+ const context = {content: processedValue};
80
+ return processedValue.filter(v => {
81
+ try {
82
+ return filterContent ? filterContent(v, context) : true;
83
+ } catch (e) {
84
+ console.error("[Serializer] Error in filterContent prop function: ", e);
85
+ return true;
86
+ }
87
+ });
88
+ }, [processedValue, filterContent]);
89
+
78
90
  const getPropsForType = (type, isInSlot = false) => {
79
91
  if (!elementPropsMap) {
80
92
  return {};
@@ -227,15 +239,6 @@ export function Serializer({
227
239
  }
228
240
  }
229
241
 
230
- try {
231
- let filterCtx = {content: value};
232
- if (filterContent && !filterContent(node, filterCtx)) {
233
- return null;
234
- }
235
- } catch (e) {
236
- console.error(e);
237
- }
238
-
239
242
  if (!node.children || !node.children.length) {
240
243
  return serializeLeaf(node);
241
244
  }
@@ -265,7 +268,7 @@ export function Serializer({
265
268
  }
266
269
 
267
270
  return <>
268
- {!!processedValue && processedValue.map((v, i) => {
271
+ {!!filteredValue && filteredValue.map((v, i) => {
269
272
  return <Fragment key={v.block + "-pos-" + i}>{serializeNode(v, i)}</Fragment>;
270
273
  })}
271
274
  </>;