@vonaffenfels/slate-editor 1.0.19 → 1.0.21

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.19",
3
+ "version": "1.0.21",
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": "c07e5c97a79341c38e8439ac3e160a02b802db2f",
74
+ "gitHead": "f6bc2eb71e3132eeceb3b175e37360d419979c2d",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -35,7 +35,34 @@ export const SidebarEditorField = ({
35
35
  onChange(fieldKey, swapArrayElements(value, index, newIndex));
36
36
  };
37
37
 
38
+ const renderFieldSelectOptions = field => {
39
+ if (!field?.control?.options) {
40
+ return;
41
+ }
42
+
43
+ if (Array.isArray(field.control.options)) {
44
+ return field.control.options.map(value => (
45
+ <option key={`select-option-${value}`} value={value}>{value}</option>
46
+ ));
47
+ } else {
48
+ return Object.keys(field.control.options).map(key => (
49
+ <option key={`select-option-${key}`} value={field.control.options[key]}>{key}</option>
50
+ ));
51
+ }
52
+ };
53
+
38
54
  const getInputByField = (field, fieldKey) => {
55
+ if (field?.control?.type === undefined) {
56
+ if (field?.options) {
57
+ field.control = {
58
+ type: "select",
59
+ options: field.options,
60
+ };
61
+ } else {
62
+ field.control = {type: "text"};
63
+ }
64
+ }
65
+
39
66
  switch (field?.control?.type) {
40
67
  case "text":
41
68
  return <input
@@ -57,8 +84,17 @@ export const SidebarEditorField = ({
57
84
  value={value || ""}
58
85
  onChange={e => onChange(fieldKey, e.target.value)}>
59
86
  <option value="">Auswählen</option>
60
- {Object.keys(field.control.options).map(key => (
61
- <option key={`select-option-${key}`} value={field.control.options[key]}>{key}</option>
87
+ {renderFieldSelectOptions(field)}
88
+ </select>
89
+ );
90
+ case "data-stream":
91
+ return (
92
+ <select
93
+ value={value || ""}
94
+ onChange={e => onChange(fieldKey, e.target.value)}>
95
+ <option value="">Auswählen</option>
96
+ {field.control.streams.map(stream => (
97
+ <option key={`select-option-${stream.value}`} value={stream.value}>{stream.label}</option>
62
98
  ))}
63
99
  </select>
64
100
  );
@@ -359,11 +359,11 @@ const BlockSelect = ({
359
359
  return onChange({}); // reset to empty
360
360
  }
361
361
 
362
- // reset to the first story
362
+ // reset to the first or second story
363
363
  onChange({
364
364
  ...active,
365
365
  block: story.id,
366
- attributes: {...(story?.stories?.[0]?.args || {})},
366
+ attributes: {...(story?.stories?.[0]?.args || story?.stories?.[1]?.args || {})},
367
367
  });
368
368
  };
369
369
 
@@ -371,6 +371,10 @@ const BlockSelect = ({
371
371
  const result = {};
372
372
 
373
373
  array.forEach(item => {
374
+ if (!item.id) {
375
+ return;
376
+ }
377
+
374
378
  const parts = item.title.split('/');
375
379
  let currentLevel = result;
376
380
 
@@ -14,6 +14,18 @@ export default {
14
14
  name: "Text",
15
15
  control: {type: "text"},
16
16
  },
17
+ stream: {
18
+ name: "Logik",
19
+ control: {
20
+ type: 'data-stream',
21
+ streams: [
22
+ {
23
+ value: "contentById",
24
+ label: "Ausgewählten Inhalt laden",
25
+ },
26
+ ],
27
+ },
28
+ },
17
29
  boolean: {
18
30
  name: "Boolean",
19
31
  control: {type: "boolean"},
@@ -186,6 +198,13 @@ export default {
186
198
  control: {type: "text"},
187
199
  table: {category: "Kategorie 2"},
188
200
  },
201
+ linkTarget: {
202
+ name: "Link target (Verhalten beim Klick)",
203
+ options: [
204
+ undefined,
205
+ "_blank",
206
+ ],
207
+ },
189
208
  },
190
209
  };
191
210
 
@@ -1,8 +1,8 @@
1
1
  import TestStory3 from "./TestStory3";
2
2
 
3
3
  export default {
4
- title: "Elemente/Test 2/Test Story 3",
5
- id: "TestStory3",
4
+ title: "Design-System/Atoms/Ad Tags/Test Story 3",
5
+ // id: "TestStory3",
6
6
  component: TestStory3,
7
7
  storyContext: ["layout"],
8
8
  argTypes: {