@vonaffenfels/slate-editor 1.0.31 → 1.0.34

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.
@@ -4,6 +4,30 @@
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
6
 
7
+ /*!
8
+ Copyright (c) 2015 Jed Watson.
9
+ Based on code that is Copyright 2013-2015, Facebook, Inc.
10
+ All rights reserved.
11
+ */
12
+
13
+ /*!
14
+ Copyright (c) 2018 Jed Watson.
15
+ Licensed under the MIT License (MIT), see
16
+ http://jedwatson.github.io/classnames
17
+ */
18
+
19
+ /*!
20
+ * Adapted from jQuery UI core
21
+ *
22
+ * http://jqueryui.com
23
+ *
24
+ * Copyright 2014 jQuery Foundation and other contributors
25
+ * Released under the MIT license.
26
+ * http://jquery.org/license
27
+ *
28
+ * http://api.jqueryui.com/category/ui-core/
29
+ */
30
+
7
31
  /*!
8
32
  * Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
9
33
  * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
@@ -34,3 +58,12 @@
34
58
  /*! https://mths.be/esrever v0.2.0 by @mathias */
35
59
 
36
60
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
61
+
62
+ /** @license React v16.13.1
63
+ * react-is.production.min.js
64
+ *
65
+ * Copyright (c) Facebook, Inc. and its affiliates.
66
+ *
67
+ * This source code is licensed under the MIT license found in the
68
+ * LICENSE file in the root directory of this source tree.
69
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.0.31",
3
+ "version": "1.0.34",
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": "007715e3b949cf0368e7b4d70626d2931c7b7829",
74
+ "gitHead": "09afee2ada365a370687380dbcb426fdb6e4d51f",
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  }
@@ -12,7 +12,7 @@
12
12
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
13
13
  }
14
14
 
15
- p, label, b {
15
+ p, label, b, span {
16
16
  color: rgb(90, 101, 124);
17
17
  }
18
18
 
@@ -37,6 +37,11 @@
37
37
  width: 100% !important;
38
38
  padding: 8px 0.75rem !important;
39
39
  }
40
+
41
+ textarea {
42
+ height: 42px;
43
+ max-height: 200px;
44
+ }
40
45
 
41
46
  input[type="color"] {
42
47
  padding: 4px !important;
@@ -170,6 +170,7 @@ export default function BlockEditor({
170
170
  isEmpty: false,
171
171
  isInline: selectedStorybookElement.isInline,
172
172
  attributes: newStorybookElement.attributes,
173
+ type: "storybook",
173
174
  };
174
175
 
175
176
  Transforms.setNodes(editor, newNodeProps, {at: selectedStorybookElement.path});
@@ -68,15 +68,7 @@ const BlockComponent = ({
68
68
  attributes,
69
69
  }) => {
70
70
  const [loadedAttributes, setLoadedAttributes] = useState(attributes);
71
- let LoadedComponent = storybookComponentLoader(block);
72
-
73
- if (!LoadedComponent) {
74
- LoadedComponent = EmptyBlock;
75
- } else {
76
- if (!LoadedComponent.displayName) {
77
- LoadedComponent.displayName = block;
78
- }
79
- }
71
+ let [LoadedComponent, setLoadedComponent] = useState(storybookComponentLoader(block));
80
72
 
81
73
  useEffect(() => {
82
74
  const loadData = async () => {
@@ -97,10 +89,26 @@ const BlockComponent = ({
97
89
  }
98
90
  });
99
91
 
92
+ let loadedComponent = storybookComponentLoader(block);
93
+
94
+ setLoadedAttributes({...attributes});
95
+
96
+ setLoadedComponent(loadedComponent);
97
+
98
+ console.log({loadedAttributes});
99
+
100
100
  return () => {
101
101
  mounted = false;
102
102
  };
103
- }, [attributes, block, storybookComponentDataLoader]);
103
+ }, [attributes, block, storybookComponentDataLoader, storybookComponentLoader]);
104
+
105
+ if (!LoadedComponent) {
106
+ LoadedComponent = EmptyBlock;
107
+ } else {
108
+ if (!LoadedComponent.displayName) {
109
+ LoadedComponent.displayName = block;
110
+ }
111
+ }
104
112
 
105
113
  if (loadedAttributes.blockWidth || loadedAttributes.margin) {
106
114
  return <span className={classNames({
@@ -59,12 +59,6 @@ export const AssetList = ({
59
59
  return asset;
60
60
  });
61
61
 
62
- console.log({
63
- newAssets,
64
- newAsset,
65
- assets,
66
- });
67
-
68
62
  onChange(newAssets);
69
63
  };
70
64
 
@@ -90,12 +84,12 @@ export const Asset = ({
90
84
  let mediaAssetId = asset?.fields?.media?.["en-US"]?.sys?.id || asset?.fields?.media?.["de"]?.sys?.id || asset?.fields?.media?.sys?.id;
91
85
 
92
86
  if (cloudinary) {
93
- title = asset.public_id;
87
+ title = asset.public_id || asset.title;
94
88
  }
95
89
 
96
90
  useEffect(() => {
97
91
  if (cloudinary) {
98
- setMediaUrl(asset.url);
92
+ setMediaUrl(asset.url || asset?.media?.url);
99
93
 
100
94
  return;
101
95
  }
@@ -161,16 +155,18 @@ export const Asset = ({
161
155
  <IconButton size="small" onClick={() => onMoveClick("down")} disabled={index === assetsLength - 1}>↓</IconButton>
162
156
  </div>
163
157
  )}
164
- <IconButton
165
- size="small"
166
- className="mr-1"
167
- onClick={() => {
168
- sdk.navigator.openEntry(id, {slideIn: {waitForClose: true}}).then(({entity}) => {
169
- if (onChange) {
170
- onChange(entity);
171
- }
172
- });
173
- }}>✎</IconButton>
158
+ {!cloudinary && (
159
+ <IconButton
160
+ size="small"
161
+ className="mr-1"
162
+ onClick={() => {
163
+ sdk.navigator.openEntry(id, {slideIn: {waitForClose: true}}).then(({entity}) => {
164
+ if (onChange) {
165
+ onChange(entity);
166
+ }
167
+ });
168
+ }}>✎</IconButton>
169
+ )}
174
170
  <IconButton size="small" onClick={onDeleteClick}>⨯</IconButton>
175
171
  </div>
176
172
  </div>
@@ -69,10 +69,21 @@ export const SidebarEditorField = ({
69
69
 
70
70
  switch (field?.control?.type) {
71
71
  case "text":
72
- return <input
72
+ return <textarea
73
73
  type="text"
74
74
  value={value || ""}
75
- onChange={e => onChange(fieldKey, e.target.value)} />;
75
+ onChange={e => {
76
+ onChange(fieldKey, e.target.value);
77
+ e.target.style.height = "5px";
78
+ e.target.style.height = e.target.scrollHeight + 2 + "px";
79
+ }}
80
+ onBlur={(e) => {
81
+ e.target.style.height = "42px";
82
+ }}
83
+ onFocus={e => {
84
+ e.target.style.height = "5px";
85
+ e.target.style.height = e.target.scrollHeight + 2 + "px";
86
+ }} />;
76
87
  case "boolean":
77
88
  return (
78
89
  <div>
@@ -123,7 +134,21 @@ export const SidebarEditorField = ({
123
134
  return (
124
135
  <textarea
125
136
  value={typeof value === "object" ? JSON.stringify(value, null, 2) || "" : value}
126
- onChange={e => onChange(fieldKey, isJson(e.target.value) ? JSON.parse(e.target.value) : e.target.value)} />
137
+ onChange={e => {
138
+ if (isJson(e.target.value)) {
139
+ onChange(fieldKey, JSON.parse(e.target.value));
140
+ }
141
+
142
+ e.target.style.height = "5px";
143
+ e.target.style.height = e.target.scrollHeight + 2 + "px";
144
+ }}
145
+ onBlur={(e) => {
146
+ e.target.style.height = "42px";
147
+ }}
148
+ onFocus={e => {
149
+ e.target.style.height = "5px";
150
+ e.target.style.height = e.target.scrollHeight + 2 + "px";
151
+ }} />
127
152
  );
128
153
  case "radio":
129
154
  return (
@@ -362,7 +387,7 @@ export const SidebarEditorField = ({
362
387
  </div>
363
388
  );
364
389
  })}
365
- <button onClick={() => onChange(fieldKey, [...(storybookElement.attributes[fieldKey] || []), {}])}>Neue Zeile</button>
390
+ <button className="button--secondary" onClick={() => onChange(fieldKey, [...(storybookElement.attributes[fieldKey] || []), {}])}>Neue Zeile</button>
366
391
  </div>
367
392
  </details>
368
393
  );
@@ -7,6 +7,7 @@ import {ToolMargin} from "./Tools/Margin";
7
7
  import "../scss/sidebarEditor.scss";
8
8
  import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
9
9
  import {faSpinner} from "@fortawesome/free-solid-svg-icons";
10
+ import {Spinner} from "@contentful/forma-36-react-components";
10
11
 
11
12
  const devMode = localStorage.getItem("dev-mode") === "true";
12
13
 
@@ -171,8 +172,9 @@ const SidebarEditor = ({
171
172
  return (
172
173
  <div id="sidebar-editor">
173
174
  {isLoading ? (
174
- <div className="flex h-full items-center justify-center">
175
- <FontAwesomeIcon icon={faSpinner} pulse />
175
+ <div className="flex h-full flex-col items-center justify-center">
176
+ <Spinner />
177
+ <span className="mt-2">Elemente werden geladen</span>
176
178
  </div>
177
179
  ) : (
178
180
  <>