@livepreso/content-react 0.7.1 → 0.7.3
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/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livepreso/content-react",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.7.3",
|
|
6
|
+
"tag": "@livepreso/content-react_v0.7.3",
|
|
7
|
+
"date": "Wed, 23 Apr 2025 22:55:14 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Previous deploy failed, forcing a new one"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "0.7.2",
|
|
18
|
+
"tag": "@livepreso/content-react_v0.7.2",
|
|
19
|
+
"date": "Wed, 23 Apr 2025 06:25:28 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"patch": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "When using useEditableInitialState for user templates, only prefix returned key with slideID-- when it's going to be used to traverse userCMSVals context data. If slideID-- prefix is already included in the provided key, do not add it again."
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
"version": "0.7.1",
|
|
6
30
|
"tag": "@livepreso/content-react_v0.7.1",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @livepreso/content-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 23 Apr 2025 22:55:14 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.7.3
|
|
6
|
+
Wed, 23 Apr 2025 22:55:14 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Previous deploy failed, forcing a new one
|
|
11
|
+
|
|
12
|
+
## 0.7.2
|
|
13
|
+
Wed, 23 Apr 2025 06:25:28 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- When using useEditableInitialState for user templates, only prefix returned key with slideID-- when it's going to be used to traverse userCMSVals context data. If slideID-- prefix is already included in the provided key, do not add it again.
|
|
4
18
|
|
|
5
19
|
## 0.7.1
|
|
6
20
|
Thu, 03 Apr 2025 22:38:00 GMT
|
|
@@ -10,7 +10,7 @@ import { useSlide } from "../hooks/use-slide.js";
|
|
|
10
10
|
export function CompanywideJSON({ children }) {
|
|
11
11
|
const { slideKey } = useSlide();
|
|
12
12
|
const editableRef = useRef();
|
|
13
|
-
const [editableValue,
|
|
13
|
+
const [editableValue, editableKey] = useEditableInitialState(
|
|
14
14
|
`${slideKey}-${CWE_JSON_KEY}`,
|
|
15
15
|
"{}",
|
|
16
16
|
);
|
|
@@ -44,16 +44,16 @@ export function CompanywideJSON({ children }) {
|
|
|
44
44
|
() => ({
|
|
45
45
|
companyWide: state,
|
|
46
46
|
// If not editable, we just pass a no-op function
|
|
47
|
-
updateCompanywide:
|
|
47
|
+
updateCompanywide: editableKey ? updateField : () => {},
|
|
48
48
|
}),
|
|
49
49
|
[state],
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
<CompanywideJSONContext.Provider value={providerValues}>
|
|
54
|
-
{
|
|
54
|
+
{editableKey && (
|
|
55
55
|
<div
|
|
56
|
-
data-companywide-editable={
|
|
56
|
+
data-companywide-editable={editableKey}
|
|
57
57
|
ref={editableRef}
|
|
58
58
|
tabIndex={-1}
|
|
59
59
|
style={{
|
|
@@ -11,6 +11,9 @@ function getSlideNumericID() {
|
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a user template field key based on the provided key and slide details.
|
|
13
13
|
*
|
|
14
|
+
* Note: field keys are prefixed with the slide ID when saved to the Context (_userTemplateCMSvals)
|
|
15
|
+
* however they are not prefixed when used for the data-companywide-editable attribute.
|
|
16
|
+
*
|
|
14
17
|
* Slide ID variations:
|
|
15
18
|
* saved user template: adjunct-template-slide-415
|
|
16
19
|
* unsaved user template: adjunct-template-slide-tempkey-1168
|
|
@@ -20,20 +23,26 @@ function getSlideNumericID() {
|
|
|
20
23
|
* unsaved user template: slideID--key-adjunct-1168
|
|
21
24
|
*
|
|
22
25
|
* @param {string} key - The base key of the target field.
|
|
26
|
+
* @param {boolean} options.isUserCMSVals - If true, prefix the returned key with the slide ID.
|
|
23
27
|
* @returns {string} - The constructed field key for the user template.
|
|
24
28
|
*/
|
|
25
|
-
function getUserTemplateFieldKey(key) {
|
|
29
|
+
function getUserTemplateFieldKey(key, { isUserCMSVals = false } = {}) {
|
|
26
30
|
const { slideID } = useSlide();
|
|
27
31
|
const slideNumericID = getSlideNumericID();
|
|
28
32
|
const isUnsavedTemplate = slideID.indexOf("-tempkey") > -1;
|
|
29
|
-
|
|
33
|
+
let fieldKey = key;
|
|
34
|
+
|
|
35
|
+
// Add slideID prefix if requested and not included in key
|
|
36
|
+
if (isUserCMSVals && !key.startsWith(`${slideID}--`)) {
|
|
37
|
+
fieldKey = `${slideID}--${key}`;
|
|
38
|
+
}
|
|
30
39
|
|
|
31
40
|
// unsaved user template adds all this on the end
|
|
32
41
|
if (isUnsavedTemplate) {
|
|
33
|
-
return `${
|
|
42
|
+
return `${fieldKey}-tempkey-${slideNumericID}`;
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
return `${
|
|
45
|
+
return `${fieldKey}-adjunct-${slideNumericID}`;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
function getUserTemplateData(fieldKey) {
|
|
@@ -101,7 +110,10 @@ export function useEditableInitialState(key, defaultValue = "") {
|
|
|
101
110
|
|
|
102
111
|
if (isUserTemplate) {
|
|
103
112
|
fieldKey = getUserTemplateFieldKey(key);
|
|
104
|
-
|
|
113
|
+
const dataKey = getUserTemplateFieldKey(key, {
|
|
114
|
+
isUserCMSVals: true,
|
|
115
|
+
});
|
|
116
|
+
data = getUserTemplateData(dataKey);
|
|
105
117
|
} else if (isPMTemplate) {
|
|
106
118
|
fieldKey = getPMTemplateFieldKey(key);
|
|
107
119
|
data = getCWEData(fieldKey);
|
package/package.json
CHANGED
package/content-react.build.log
DELETED