@livepreso/content-react 0.3.0 → 0.3.1
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 +12 -0
- package/CHANGELOG.md +8 -1
- package/lib/hooks/use-modes.js +27 -1
- package/lib/hooks/use-prep-editable.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livepreso/content-react",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.3.1",
|
|
6
|
+
"tag": "@livepreso/content-react_v0.3.1",
|
|
7
|
+
"date": "Fri, 15 Dec 2023 00:19:06 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add modes and fix use-prep-editables import"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.3.0",
|
|
6
18
|
"tag": "@livepreso/content-react_v0.3.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @livepreso/content-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 15 Dec 2023 00:19:06 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.1
|
|
6
|
+
Fri, 15 Dec 2023 00:19:06 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Add modes and fix use-prep-editables import
|
|
4
11
|
|
|
5
12
|
## 0.3.0
|
|
6
13
|
Thu, 14 Dec 2023 03:11:26 GMT
|
package/lib/hooks/use-modes.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
function getModes() {
|
|
2
4
|
const bodyClasses = [...document.body.classList];
|
|
3
5
|
|
|
4
6
|
const isMaster = bodyClasses.includes("master");
|
|
5
7
|
const isClient = bodyClasses.includes("client");
|
|
6
8
|
const isOnline = bodyClasses.includes("online");
|
|
7
9
|
const isScreenshot = bodyClasses.includes("screenshot");
|
|
10
|
+
const isReadOnly = bodyClasses.includes("preso-readonly");
|
|
8
11
|
const isThumbnailScreenshot = bodyClasses.includes("screenshot-thumbnail");
|
|
9
12
|
const isPdfScreenshot = bodyClasses.includes("screenshot-full");
|
|
10
13
|
const isShareOnline = bodyClasses.includes("share_online");
|
|
11
14
|
const isPreview = bodyClasses.includes("preview");
|
|
15
|
+
const isPresent = bodyClasses.includes("present");
|
|
16
|
+
const isReview = bodyClasses.includes("review");
|
|
12
17
|
const isPresomanager = bodyClasses.includes("edit-mode");
|
|
13
18
|
const isRemote = isOnline && isClient && !isShareOnline;
|
|
14
19
|
|
|
@@ -18,9 +23,30 @@ export function useModes() {
|
|
|
18
23
|
isOnline,
|
|
19
24
|
isRemote,
|
|
20
25
|
isScreenshot,
|
|
26
|
+
isReadOnly,
|
|
21
27
|
isThumbnailScreenshot,
|
|
22
28
|
isPdfScreenshot,
|
|
23
29
|
isPreview,
|
|
30
|
+
isPresent,
|
|
31
|
+
isReview,
|
|
24
32
|
isPresomanager,
|
|
25
33
|
};
|
|
26
34
|
}
|
|
35
|
+
|
|
36
|
+
export function useModes() {
|
|
37
|
+
const [modes, setModes] = useState(getModes());
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const observer = new MutationObserver(() => {
|
|
41
|
+
setModes(getModes());
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
observer.observe(document.body, {
|
|
45
|
+
attributes: ["classList"],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => observer.disconnect();
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return modes;
|
|
52
|
+
}
|