@livepreso/content-react 0.3.1 → 0.3.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.3.3",
6
+ "tag": "@livepreso/content-react_v0.3.3",
7
+ "date": "Thu, 21 Dec 2023 00:50:30 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Use useState over useSharedState for now"
12
+ }
13
+ ]
14
+ }
15
+ },
16
+ {
17
+ "version": "0.3.2",
18
+ "tag": "@livepreso/content-react_v0.3.2",
19
+ "date": "Sun, 17 Dec 2023 21:02:31 GMT",
20
+ "comments": {
21
+ "patch": [
22
+ {
23
+ "comment": "Add isShareOnline to useMode"
24
+ }
25
+ ]
26
+ }
27
+ },
4
28
  {
5
29
  "version": "0.3.1",
6
30
  "tag": "@livepreso/content-react_v0.3.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 Fri, 15 Dec 2023 00:19:06 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 21 Dec 2023 00:50:30 GMT and should not be manually modified.
4
+
5
+ ## 0.3.3
6
+ Thu, 21 Dec 2023 00:50:30 GMT
7
+
8
+ ### Patches
9
+
10
+ - Use useState over useSharedState for now
11
+
12
+ ## 0.3.2
13
+ Sun, 17 Dec 2023 21:02:31 GMT
14
+
15
+ ### Patches
16
+
17
+ - Add isShareOnline to useMode
4
18
 
5
19
  ## 0.3.1
6
20
  Fri, 15 Dec 2023 00:19:06 GMT
@@ -1,62 +1,61 @@
1
+ import { useEffect, useState } from "react";
2
+
1
3
  import isPlainObject from "lodash.isplainobject";
2
- import { useEffect } from "react";
3
- import { useSharedState } from "./index.js";
4
4
 
5
5
  function getValueFromContext(context, path, defaultValue) {
6
- if (path) {
7
- return Bridge.Context.get(path, defaultValue);
8
- }
6
+ if (path) {
7
+ return Bridge.Context.get(path, defaultValue);
8
+ }
9
9
 
10
- return context;
10
+ return context;
11
11
  }
12
12
 
13
13
  export function useContext(contextPath = null, defaultValue = null) {
14
- let persist = false;
15
- let path = contextPath;
16
-
17
- const value = getValueFromContext(
18
- window.Bridge.Context.getDict(),
19
- path,
20
- defaultValue
21
- );
22
- const [context, setContextState] = useSharedState(value);
23
-
24
- // You could pass in an object, so that you can set whether
25
- // the saves are persistent or not.
26
- if (isPlainObject(contextPath)) {
27
- path = contextPath.path || null;
28
- persist = contextPath.save || false;
29
- }
30
-
31
- function setContext(key, data) {
32
- let setPath = key;
33
- let setData = data;
34
-
35
- if (path) {
36
- if (data) {
37
- setPath = `${path}.${key}`;
38
- } else {
39
- setPath = path;
40
- setData = key;
41
- }
42
- }
43
-
44
- Bridge.Context.set(setPath, setData, persist);
45
-
46
- const value = getValueFromContext(
47
- Bridge.Context.getDict(),
48
- path,
49
- defaultValue
50
- );
51
- setContextState(value);
52
- }
53
-
54
- useEffect(() => {
55
- if (context !== value) {
56
- Bridge.Context.set(path, context, persist);
57
- }
58
- }, [context]);
59
-
60
- return [context, setContext];
14
+ let persist = false;
15
+ let path = contextPath;
16
+
17
+ const value = getValueFromContext(
18
+ window.Bridge.Context.getDict(),
19
+ path,
20
+ defaultValue,
21
+ );
22
+ const [context, setContextState] = useState(value);
23
+
24
+ // You could pass in an object, so that you can set whether
25
+ // the saves are persistent or not.
26
+ if (isPlainObject(contextPath)) {
27
+ path = contextPath.path || null;
28
+ persist = contextPath.save || false;
29
+ }
30
+
31
+ function setContext(key, data) {
32
+ let setPath = key;
33
+ let setData = data;
34
+
35
+ if (path) {
36
+ if (data) {
37
+ setPath = `${path}.${key}`;
38
+ } else {
39
+ setPath = path;
40
+ setData = key;
41
+ }
42
+ }
43
+
44
+ Bridge.Context.set(setPath, setData, persist);
45
+
46
+ const value = getValueFromContext(
47
+ Bridge.Context.getDict(),
48
+ path,
49
+ defaultValue,
50
+ );
51
+ setContextState(value);
52
+ }
53
+
54
+ useEffect(() => {
55
+ if (context !== value) {
56
+ Bridge.Context.set(path, context, persist);
57
+ }
58
+ }, [context]);
59
+
60
+ return [context, setContext];
61
61
  }
62
-
@@ -24,6 +24,7 @@ function getModes() {
24
24
  isRemote,
25
25
  isScreenshot,
26
26
  isReadOnly,
27
+ isShareOnline,
27
28
  isThumbnailScreenshot,
28
29
  isPdfScreenshot,
29
30
  isPreview,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livepreso/content-react",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {