@livepreso/content-react 0.5.1 → 0.5.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../content/content-react": "../../content/content-react:
|
|
2
|
+
"../../content/content-react": "../../content/content-react:2Nu2IX5k2YZ9jYAYKnRIgfmWOO8vgtcjym4HUCOFj4U=:",
|
|
3
3
|
"/@ampproject/remapping@2.3.0": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
|
|
4
4
|
"/@babel/code-frame@7.26.2": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
|
|
5
5
|
"/@babel/compat-data@7.26.2": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==",
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livepreso/content-react",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.5.2",
|
|
6
|
+
"tag": "@livepreso/content-react_v0.5.2",
|
|
7
|
+
"date": "Fri, 17 Jan 2025 04:54:14 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "resolved race condition in useCompanywide setter"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.5.1",
|
|
6
18
|
"tag": "@livepreso/content-react_v0.5.1",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @livepreso/content-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on Fri, 17 Jan 2025
|
|
3
|
+
This log was last generated on Fri, 17 Jan 2025 04:54:14 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.5.2
|
|
6
|
+
Fri, 17 Jan 2025 04:54:14 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- resolved race condition in useCompanywide setter
|
|
4
11
|
|
|
5
12
|
## 0.5.1
|
|
6
13
|
Fri, 17 Jan 2025 03:37:56 GMT
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState } from "react";
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { CWE_JSON_KEY } from "../constants.js";
|
|
4
4
|
import { CompanywideJSONContext } from "../contexts.js";
|
|
5
|
+
import set from "lodash.set";
|
|
5
6
|
import unescape from "lodash.unescape";
|
|
6
7
|
import { useEditableInitialState } from "../hooks/use-editable-initial-state.js";
|
|
7
8
|
import { useSlide } from "../hooks/use-slide.js";
|
|
@@ -11,7 +12,7 @@ export function CompanywideJSON({ children }) {
|
|
|
11
12
|
const editableRef = useRef();
|
|
12
13
|
const [editableValue, editableName] = useEditableInitialState(
|
|
13
14
|
`${slideKey}-${CWE_JSON_KEY}`,
|
|
14
|
-
"{}"
|
|
15
|
+
"{}",
|
|
15
16
|
);
|
|
16
17
|
|
|
17
18
|
let initialState = {};
|
|
@@ -26,12 +27,17 @@ export function CompanywideJSON({ children }) {
|
|
|
26
27
|
|
|
27
28
|
const [state, setState] = useState(initialState);
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
window.$(editableRef.current).text(JSON.stringify(
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
window.$(editableRef.current).text(JSON.stringify(state));
|
|
31
32
|
window.$(editableRef.current).trigger("save");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
}, [state]);
|
|
34
|
+
|
|
35
|
+
function updateField(val, path) {
|
|
36
|
+
setState((curr) => {
|
|
37
|
+
const obj = { ...(curr || {}) };
|
|
38
|
+
set(obj, path, val);
|
|
39
|
+
return obj;
|
|
40
|
+
});
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
const providerValues = useMemo(
|
|
@@ -40,7 +46,7 @@ export function CompanywideJSON({ children }) {
|
|
|
40
46
|
// If not editable, we just pass a no-op function
|
|
41
47
|
updateCompanywide: editableName ? updateField : () => {},
|
|
42
48
|
}),
|
|
43
|
-
[state]
|
|
49
|
+
[state],
|
|
44
50
|
);
|
|
45
51
|
|
|
46
52
|
return (
|
|
@@ -52,8 +58,8 @@ export function CompanywideJSON({ children }) {
|
|
|
52
58
|
tabIndex={-1}
|
|
53
59
|
style={{
|
|
54
60
|
position: "absolute",
|
|
55
|
-
top:
|
|
56
|
-
|
|
61
|
+
top: -1000,
|
|
62
|
+
left: -1000,
|
|
57
63
|
}}
|
|
58
64
|
/>
|
|
59
65
|
)}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CompanywideJSONContext } from "../contexts.js";
|
|
2
2
|
import get from "lodash.get";
|
|
3
|
-
import set from "lodash.set";
|
|
4
3
|
import { useContext } from "react";
|
|
5
4
|
|
|
6
5
|
export function useCompanywide(cwePath, defaultValue) {
|
|
@@ -13,9 +12,7 @@ export function useCompanywide(cwePath, defaultValue) {
|
|
|
13
12
|
const value = get(companyWide, cwePath, defaultValue);
|
|
14
13
|
|
|
15
14
|
function update(val) {
|
|
16
|
-
|
|
17
|
-
set(obj, cwePath, val);
|
|
18
|
-
updateCompanywide(obj);
|
|
15
|
+
updateCompanywide(val, cwePath);
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
return [value, update];
|