@vonaffenfels/slate-editor 1.0.20 → 1.0.23

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.20",
3
+ "version": "1.0.23",
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": "a846930c8b8e27a6ecf7bab999e1b6a77b22c6a2",
74
+ "gitHead": "3e1bd9a8bec354c2f96703797b9985250c3d37e0",
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,9 +84,7 @@ 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>
62
- ))}
87
+ {renderFieldSelectOptions(field)}
63
88
  </select>
64
89
  );
65
90
  case "data-stream":
@@ -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
 
@@ -428,6 +428,7 @@ const BlockSelect = ({
428
428
  <label className="block">Element</label>
429
429
  <select
430
430
  onChange={e => onSelectChange(stories.find(s => s.id === e.target.value))}
431
+ value={active?.block}
431
432
  className="font-bold"
432
433
  >
433
434
  <option>Element wählen</option>
@@ -198,6 +198,13 @@ export default {
198
198
  control: {type: "text"},
199
199
  table: {category: "Kategorie 2"},
200
200
  },
201
+ linkTarget: {
202
+ name: "Link target (Verhalten beim Klick)",
203
+ options: [
204
+ undefined,
205
+ "_blank",
206
+ ],
207
+ },
201
208
  },
202
209
  };
203
210