@vonaffenfels/slate-editor 1.0.78 → 1.0.80

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.0.78",
3
+ "version": "1.0.80",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -71,7 +71,7 @@
71
71
  "cssnano": "^5.0.1",
72
72
  "escape-html": "^1.0.3"
73
73
  },
74
- "gitHead": "d9a15e949b3c97d57e927366ab4063e3f83618ef",
74
+ "gitHead": "4fb98b27f14958fc2d5c99f8d95c5010da0c266e",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -161,7 +161,8 @@ export function Serializer({
161
161
  [typeProps.classNameArticle + " article-width"]: !isInSlot && (props.attributes?.width === "article" || !props.attributes?.width),
162
162
  })}
163
163
  >
164
- {props.children.map((v, i) => <Fragment key={"layout-pos-" + i}>{serializeNode(v, i, isInSlot)}</Fragment>)}
164
+ {props.children.map((v, i) => <Fragment
165
+ key={"layout-pos-" + i}>{serializeNode(v, i, isInSlot)}</Fragment>)}
165
166
  </div>
166
167
  </Wrapper>;
167
168
  }
@@ -176,7 +177,8 @@ export function Serializer({
176
177
  "md:ml-4": props.attributes?.margin?.left,
177
178
  })}
178
179
  >
179
- {props.children.map((v, i) => <Fragment key={"layout-slot-" + i}>{serializeNode(v, i, props.attributes.name)}</Fragment>)}
180
+ {props.children.map((v, i) => <Fragment
181
+ key={"layout-slot-" + i}>{serializeNode(v, i, props.attributes.name)}</Fragment>)}
180
182
  </div>
181
183
  </Wrapper>;
182
184
  default: {
@@ -189,7 +191,8 @@ export function Serializer({
189
191
  type: props.type,
190
192
  },
191
193
  attributes: props.htmlAttributes || {},
192
- children: props.children.map((v, i) => <Fragment key={props.type + "-pos-item-" + i}>{serializeNode(v, i, isInSlot)}</Fragment>),
194
+ children: props.children.map((v, i) => <Fragment
195
+ key={props.type + "-pos-item-" + i}>{serializeNode(v, i, isInSlot)}</Fragment>),
193
196
  };
194
197
 
195
198
  return <Default
@@ -217,6 +220,19 @@ export function Serializer({
217
220
  return serializeLeaf(node);
218
221
  }
219
222
 
223
+ // unwrap elements that are inside of a paragraph (that has no text content) so they have been inserted "inline" by mistake
224
+ // this helps preventing a lot of hydration errors!
225
+ if (node?.type === "paragraph") {
226
+ const textContent = node.children.find(v => !v?.type && v?.text);
227
+ if (!textContent) {
228
+ const storybookNodes = node.children.filter(v => v?.type === "storybook");
229
+ if (storybookNodes.length === 1) {
230
+ // only unwrap if we only have exactly 1 node
231
+ return renderElement(storybookNodes.at(0), isInSlot);
232
+ }
233
+ }
234
+ }
235
+
220
236
  return renderElement(node, isInSlot);
221
237
  }
222
238