@capytale/meta-player 0.3.14 → 0.3.16
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/package.json +2 -2
- package/src/App.tsx +1 -1
- package/src/MetaPlayer.tsx +2 -0
- package/src/app.module.scss +5 -0
- package/src/features/activityData/ExitWarning.ts +26 -0
- package/src/index.css +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capytale/meta-player",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@capytale/activity.js": "^3.1.
|
|
22
|
+
"@capytale/activity.js": "^3.1.7",
|
|
23
23
|
"@capytale/capytale-anti-triche": "^0.2.1",
|
|
24
24
|
"@capytale/capytale-rich-text-editor": "^0.4.3",
|
|
25
25
|
"@reduxjs/toolkit": "^2.0.1",
|
package/src/App.tsx
CHANGED
|
@@ -101,7 +101,7 @@ const App: FC<AppProps> = (props) => {
|
|
|
101
101
|
<SplitterPanel minSize={15} size={30} className={styles.pedagoPanel}>
|
|
102
102
|
<Pedago key="pedago" />
|
|
103
103
|
</SplitterPanel>
|
|
104
|
-
<SplitterPanel minSize={40} size={70}>
|
|
104
|
+
<SplitterPanel minSize={40} size={70} className={styles.contentPanel}>
|
|
105
105
|
<div className="meta-player-content-cover"></div>
|
|
106
106
|
<div id="meta-player-content">{props.children}</div>
|
|
107
107
|
</SplitterPanel>
|
package/src/MetaPlayer.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from "./features/activityData/activityDataSlice";
|
|
33
33
|
|
|
34
34
|
import { initialState as layoutInitialState } from "./features/layout/layoutSlice";
|
|
35
|
+
import ExitWarning from "./features/activityData/ExitWarning";
|
|
35
36
|
|
|
36
37
|
type AntiCheatOptions = {
|
|
37
38
|
preserveDom: boolean;
|
|
@@ -81,6 +82,7 @@ const MetaPlayer: FC<MetaPlayerProps> = (props) => {
|
|
|
81
82
|
<PrimeReactProvider value={primeSettings}>
|
|
82
83
|
<Provider store={store}>
|
|
83
84
|
<ThemeSwitcher />
|
|
85
|
+
<ExitWarning />
|
|
84
86
|
<ErrorBoundary fallback={<div>Une erreur est survenue</div>}>
|
|
85
87
|
<ActivityJSProvider options={props.activityJSOptions}>
|
|
86
88
|
<Saver />
|
package/src/app.module.scss
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, useEffect } from "react";
|
|
2
|
+
import { useAppSelector } from "../../app/hooks";
|
|
3
|
+
import { selectIsDirty } from "./activityDataSlice";
|
|
4
|
+
|
|
5
|
+
const ExitWarning: FC = () => {
|
|
6
|
+
const isDirty = useAppSelector(selectIsDirty);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
10
|
+
if (isDirty) {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
e.returnValue = true;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
17
|
+
|
|
18
|
+
return () => {
|
|
19
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
20
|
+
};
|
|
21
|
+
}, [isDirty]);
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default ExitWarning;
|
package/src/index.css
CHANGED