@vonaffenfels/slate-editor 1.0.77 → 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.77",
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": "99fb79dcd4b84bae8274c511f27e685e42f0fea2",
74
+ "gitHead": "4fb98b27f14958fc2d5c99f8d95c5010da0c266e",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -30,6 +30,7 @@
30
30
  input[type="number"],
31
31
  input[type="color"],
32
32
  input[type="datetime-local"],
33
+ input[type="search"],
33
34
  select,
34
35
  textarea {
35
36
  display: block;
package/scss/toolbar.scss CHANGED
@@ -9,6 +9,25 @@
9
9
  position: absolute;
10
10
  z-index: 500;
11
11
 
12
+ input[type="text"],
13
+ input[type="number"],
14
+ input[type="color"],
15
+ input[type="datetime-local"],
16
+ input[type="search"],
17
+ select,
18
+ textarea {
19
+ display: block;
20
+ font-size: 0.875rem !important;
21
+ color: rgb(90, 101, 124) !important;
22
+ background-color: white !important;
23
+ border: 1px solid #cfd9e0 !important;
24
+ border-radius: 6px !important;
25
+ box-shadow: none !important;
26
+ filter: none !important;
27
+ width: 100% !important;
28
+ padding: 8px 0.75rem !important;
29
+ }
30
+
12
31
  &.toolbar-static {
13
32
  display: block;
14
33
  position: fixed;
@@ -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
 
@@ -157,14 +157,6 @@ const SidebarEditor = ({
157
157
  setVersions([]);
158
158
  };
159
159
 
160
- const handleBlockSelectChange = (block) => {
161
- if (onChange) {
162
- setLastChangedProperty(null);
163
- addVersion(storybookElement);
164
- onChange(block);
165
- }
166
- };
167
-
168
160
  const handleVariantSelectChange = (variant) => {
169
161
  if (onChange) {
170
162
  setLastChangedProperty(null);
@@ -228,6 +220,13 @@ const SidebarEditor = ({
228
220
 
229
221
  return (
230
222
  <>
223
+ <input
224
+ type="text"
225
+ placeholder="🔍 Feld suchen..."
226
+ onChange={e => setPropertySearch(e.target.value)}
227
+ value={propertySearch}
228
+ className="mb-2"
229
+ />
231
230
  {Object.keys(fields.fields).map(key => {
232
231
  const field = fields.fields[key];
233
232
 
@@ -356,13 +355,6 @@ const SidebarEditor = ({
356
355
  <hr className="my-4" style={{borderColor: "#cfd9e0"}}/>
357
356
  </div>
358
357
  )}
359
- <input
360
- type="text"
361
- placeholder="🔍 Eigenschaft suchen..."
362
- onChange={e => setPropertySearch(e.target.value)}
363
- value={propertySearch}
364
- className="mb-2"
365
- />
366
358
  {renderFields()}
367
359
  </div>
368
360
  </>
@@ -450,6 +442,7 @@ const VariantSelect = ({
450
442
  onChange={e => onChange && onChange({
451
443
  block: story.id,
452
444
  attributes: {...stories.find(s => s.title === e.target.value)?.args || {}},
445
+ type: "storybook",
453
446
  })}>
454
447
  <option>Preset wählen</option>
455
448
  {stories.map(s => (