@capytale/meta-player 0.9.11 → 0.10.0
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/.prettierrc.json +4 -4
- package/LICENSE +674 -674
- package/README.md +12 -12
- package/eslint.config.js +28 -28
- package/index.html +15 -15
- package/package.json +60 -60
- package/public/themes/lara-dark-blue/theme.css +7015 -7015
- package/public/themes/lara-light-blue/theme.css +7005 -7005
- package/src/App.tsx +145 -140
- package/src/AppRedux.css +39 -39
- package/src/MetaPlayer.tsx +168 -168
- package/src/activityJs.ts +7 -7
- package/src/app/createAppSlice.ts +6 -6
- package/src/app/hooks.ts +12 -12
- package/src/app/store.ts +52 -52
- package/src/app.module.scss +80 -80
- package/src/demo.tsx +87 -87
- package/src/external/prime.ts +5 -5
- package/src/features/activityData/ExitWarning.ts +28 -28
- package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
- package/src/features/activityData/IsDirtySetter.tsx +17 -17
- package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
- package/src/features/activityData/activityDataSlice.ts +255 -255
- package/src/features/activityData/activityJsData.ts +90 -90
- package/src/features/activityData/hooks.ts +39 -39
- package/src/features/activityData/metaPlayerOptions.ts +23 -23
- package/src/features/activityData/uiState.ts +20 -20
- package/src/features/activityJS/ActivityJSProvider.tsx +362 -350
- package/src/features/activityJS/AfterResetAction.tsx +23 -23
- package/src/features/activityJS/AfterSaveAction.tsx +23 -23
- package/src/features/activityJS/BeforeResetAction.tsx +23 -23
- package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
- package/src/features/activityJS/Saver.tsx +167 -167
- package/src/features/activityJS/hooks.ts +85 -85
- package/src/features/activityJS/internal-hooks.ts +96 -96
- package/src/features/activityJS/saverSlice.ts +96 -96
- package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
- package/src/features/activitySettings/hooks.ts +12 -12
- package/src/features/activitySettings/index.tsx +43 -43
- package/src/features/activitySettings/store.ts +108 -108
- package/src/features/activitySettings/style.module.scss +8 -8
- package/src/features/activitySettings/types.ts +140 -140
- package/src/features/activitySettings/ui.tsx +299 -299
- package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
- package/src/features/functionalities/PreviewDialog.tsx +83 -83
- package/src/features/functionalities/functionalitiesSlice.ts +98 -98
- package/src/features/functionalities/hooks.ts +70 -70
- package/src/features/layout/hooks.ts +7 -7
- package/src/features/layout/layoutSlice.ts +93 -93
- package/src/features/navbar/activity-info/index.tsx +54 -54
- package/src/features/navbar/activity-info/style.module.scss +38 -38
- package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +89 -57
- package/src/features/navbar/activity-menu/index.tsx +154 -154
- package/src/features/navbar/activity-menu/style.module.scss +7 -7
- package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
- package/src/features/navbar/capytale-menu/Countdown.tsx +313 -313
- package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +129 -125
- package/src/features/navbar/capytale-menu/index.tsx +260 -260
- package/src/features/navbar/capytale-menu/style.module.scss +8 -8
- package/src/features/navbar/capytale-menu/useRemainingTimeMs.tsx +32 -32
- package/src/features/navbar/index.tsx +39 -39
- package/src/features/navbar/navbarSlice.ts +79 -79
- package/src/features/navbar/preview-navbar/index.tsx +18 -0
- package/src/features/navbar/preview-navbar/style.module.scss +17 -0
- package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
- package/src/features/navbar/review-navbar/index.tsx +18 -18
- package/src/features/navbar/review-navbar/style.module.scss +22 -22
- package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
- package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
- package/src/features/navbar/sidebars/style.module.scss +15 -15
- package/src/features/navbar/student-utils.ts +11 -11
- package/src/features/navbar/style.module.scss +65 -65
- package/src/features/pedago/InstructionsEditor.tsx +104 -102
- package/src/features/pedago/PdfEditor.tsx +91 -91
- package/src/features/pedago/PedagoCommands.tsx +378 -378
- package/src/features/pedago/SharedNotesEditor.tsx +144 -144
- package/src/features/pedago/hooks.ts +108 -108
- package/src/features/pedago/index.tsx +205 -205
- package/src/features/pedago/style.module.scss +233 -233
- package/src/features/theming/ThemeSwitcher.tsx +51 -51
- package/src/features/theming/hooks.ts +6 -6
- package/src/features/theming/themingSlice.ts +93 -93
- package/src/features/toast.tsx +38 -38
- package/src/hooks/index.ts +55 -16
- package/src/index.css +132 -132
- package/src/index.ts +93 -92
- package/src/logo.svg +1 -1
- package/src/my_json_data.js +4146 -4146
- package/src/settings.ts +6 -6
- package/src/types.ts +8 -8
- package/src/utils/ButtonDoubleIcon.tsx +35 -35
- package/src/utils/CardSelector.tsx +41 -41
- package/src/utils/ErrorBoundary.tsx +41 -41
- package/src/utils/PopupButton.tsx +134 -134
- package/src/utils/activity.ts +8 -8
- package/src/utils/breakpoints.ts +4 -4
- package/src/utils/capytale.ts +10 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/download.ts +7 -7
- package/src/utils/equality.ts +32 -32
- package/src/utils/server-clock.ts +42 -42
- package/src/utils/style.module.scss +45 -45
- package/src/utils/useFullscreen.ts +65 -65
- package/src/vite-env.d.ts +1 -1
- package/src/zustandStore.ts +66 -0
- package/tsconfig.json +28 -28
- package/tsconfig.node.json +9 -9
- package/vite.config.ts +11 -11
|
@@ -1,102 +1,104 @@
|
|
|
1
|
-
import { useCapytaleRichTextEditor } from "@capytale/capytale-rich-text-editor";
|
|
2
|
-
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
3
|
-
import {
|
|
4
|
-
selectInstructions,
|
|
5
|
-
selectInstructionsType,
|
|
6
|
-
selectMode,
|
|
7
|
-
setCanSaveInstructions,
|
|
8
|
-
setInstructionsType,
|
|
9
|
-
setIsMPDirty,
|
|
10
|
-
setLexicalInstructionsState,
|
|
11
|
-
} from "../activityData/activityDataSlice";
|
|
12
|
-
import { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
|
|
13
|
-
import settings from "../../settings";
|
|
14
|
-
import { Button } from "primereact/button";
|
|
15
|
-
import { useToast } from "../toast";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
import { useCapytaleRichTextEditor } from "@capytale/capytale-rich-text-editor";
|
|
2
|
+
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
3
|
+
import {
|
|
4
|
+
selectInstructions,
|
|
5
|
+
selectInstructionsType,
|
|
6
|
+
selectMode,
|
|
7
|
+
setCanSaveInstructions,
|
|
8
|
+
setInstructionsType,
|
|
9
|
+
setIsMPDirty,
|
|
10
|
+
setLexicalInstructionsState,
|
|
11
|
+
} from "../activityData/activityDataSlice";
|
|
12
|
+
import { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
|
|
13
|
+
import settings from "../../settings";
|
|
14
|
+
import { Button } from "primereact/button";
|
|
15
|
+
import { useToast } from "../toast";
|
|
16
|
+
import { useZustandStore } from "../../zustandStore";
|
|
17
|
+
|
|
18
|
+
const InstructionsEditor: React.FC = forwardRef((_props, ref) => {
|
|
19
|
+
const [Editor, getState, _canSave] = useCapytaleRichTextEditor();
|
|
20
|
+
const dispatch = useAppDispatch();
|
|
21
|
+
const toast = useToast();
|
|
22
|
+
const mode = useAppSelector(selectMode);
|
|
23
|
+
const isPreviewing = useZustandStore((state) => state.isPreviewing);
|
|
24
|
+
const isEditable = mode === "create" && !isPreviewing;
|
|
25
|
+
const initialInstructions = useAppSelector(selectInstructions);
|
|
26
|
+
const htmlInitialContent = useMemo(() => {
|
|
27
|
+
return initialInstructions?.format === "lexical"
|
|
28
|
+
? undefined
|
|
29
|
+
: initialInstructions?.htmlValue === null
|
|
30
|
+
? undefined
|
|
31
|
+
: (initialInstructions?.htmlValue as string) || ""; // HTML content in value
|
|
32
|
+
}, [initialInstructions]);
|
|
33
|
+
const initialEditorState = useMemo(() => {
|
|
34
|
+
return initialInstructions?.format === "lexical"
|
|
35
|
+
? initialInstructions?.value
|
|
36
|
+
: undefined;
|
|
37
|
+
}, [initialInstructions]);
|
|
38
|
+
const initialStateOnChangeDone = useRef<boolean>(false);
|
|
39
|
+
const instructionsType = useAppSelector(selectInstructionsType);
|
|
40
|
+
|
|
41
|
+
useImperativeHandle(ref, () => {
|
|
42
|
+
return {
|
|
43
|
+
save: async () => {
|
|
44
|
+
const state = await getState();
|
|
45
|
+
dispatch(setLexicalInstructionsState(state.json));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<>
|
|
53
|
+
{instructionsType === "none" && (
|
|
54
|
+
<>
|
|
55
|
+
<p>Pas de consigne.</p>
|
|
56
|
+
{isEditable && (
|
|
57
|
+
<Button
|
|
58
|
+
label="Créer une consigne"
|
|
59
|
+
onClick={() => dispatch(setInstructionsType("rich"))}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
</>
|
|
63
|
+
)}
|
|
64
|
+
{instructionsType === "rich" && (
|
|
65
|
+
<Editor
|
|
66
|
+
placeholderText="Écrivez la consigne ici..."
|
|
67
|
+
htmlInitialContent={htmlInitialContent}
|
|
68
|
+
initialEditorState={initialEditorState}
|
|
69
|
+
jsonSizeLimit={settings.STATEMENT_MAX_SIZE}
|
|
70
|
+
onChange={(editorState) => {
|
|
71
|
+
dispatch(setLexicalInstructionsState(editorState));
|
|
72
|
+
if (initialStateOnChangeDone.current) {
|
|
73
|
+
dispatch(setIsMPDirty(true));
|
|
74
|
+
} else {
|
|
75
|
+
initialStateOnChangeDone.current = true;
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
onJsonSizeLimitExceeded={() => {
|
|
79
|
+
dispatch(setCanSaveInstructions(false));
|
|
80
|
+
toast.show({
|
|
81
|
+
summary: "Erreur",
|
|
82
|
+
detail: `Le contenu de la consigne est trop volumineux. Veuillez le réduire avant de l'enregistrer.\nPeut-être avez-vous inséré une image trop volumineuse ?`,
|
|
83
|
+
severity: "error",
|
|
84
|
+
life: 10000,
|
|
85
|
+
});
|
|
86
|
+
}}
|
|
87
|
+
onJsonSizeLimitMet={() => {
|
|
88
|
+
dispatch(setCanSaveInstructions(true));
|
|
89
|
+
toast.show({
|
|
90
|
+
summary: "Succès",
|
|
91
|
+
detail: `Le contenu de la consigne ne dépasse plus la taille limite.`,
|
|
92
|
+
severity: "success",
|
|
93
|
+
life: 4000,
|
|
94
|
+
});
|
|
95
|
+
}}
|
|
96
|
+
isEditable={isEditable}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export default InstructionsEditor;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { FC, useEffect, useMemo } from "react";
|
|
2
|
-
import { useDropzone } from "react-dropzone";
|
|
3
|
-
import styles from "./style.module.scss";
|
|
4
|
-
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
5
|
-
import {
|
|
6
|
-
selectMode,
|
|
7
|
-
selectPdfInstructions,
|
|
8
|
-
setPdfInstructions,
|
|
9
|
-
} from "../activityData/activityDataSlice";
|
|
10
|
-
import { Button } from "primereact/button";
|
|
11
|
-
|
|
12
|
-
export const PdfEditor: FC = () => {
|
|
13
|
-
const dispatch = useAppDispatch();
|
|
14
|
-
const {
|
|
15
|
-
getRootProps,
|
|
16
|
-
getInputProps,
|
|
17
|
-
isFocused,
|
|
18
|
-
isDragAccept,
|
|
19
|
-
isDragReject,
|
|
20
|
-
acceptedFiles,
|
|
21
|
-
} = useDropzone({
|
|
22
|
-
accept: {
|
|
23
|
-
"application/pdf": [".pdf"],
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (acceptedFiles.length) {
|
|
28
|
-
dispatch(setPdfInstructions(acceptedFiles[0]));
|
|
29
|
-
}
|
|
30
|
-
}, [acceptedFiles]);
|
|
31
|
-
const mode = useAppSelector(selectMode);
|
|
32
|
-
const pdfInstructions = useAppSelector(selectPdfInstructions);
|
|
33
|
-
const pdfData = useMemo(
|
|
34
|
-
() => (pdfInstructions ? URL.createObjectURL(pdfInstructions) : null),
|
|
35
|
-
[pdfInstructions],
|
|
36
|
-
);
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
{pdfData && (
|
|
40
|
-
<div
|
|
41
|
-
style={{
|
|
42
|
-
width: "100%",
|
|
43
|
-
height: "100%",
|
|
44
|
-
position: "relative",
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<object
|
|
49
|
-
data={pdfData + "#?navpanes=0"}
|
|
50
|
-
type="application/pdf"
|
|
51
|
-
width="100%"
|
|
52
|
-
height="100%"
|
|
53
|
-
>
|
|
54
|
-
<p>
|
|
55
|
-
Votre navigateur ne supporte pas les PDFs, vous pouvez{" "}
|
|
56
|
-
<a href={pdfData}>télécharger le fichier</a> à la place.
|
|
57
|
-
</p>
|
|
58
|
-
</object>
|
|
59
|
-
<div className="meta-player-content-cover"></div>
|
|
60
|
-
{mode === "create" && (
|
|
61
|
-
<Button
|
|
62
|
-
label="Supprimer le PDF"
|
|
63
|
-
severity="danger"
|
|
64
|
-
icon="pi pi-trash"
|
|
65
|
-
className={styles.deleteButton}
|
|
66
|
-
onClick={() => dispatch(setPdfInstructions(null))}
|
|
67
|
-
style={{ position: "absolute", bottom: "20px", right: "20px" }}
|
|
68
|
-
/>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
)}
|
|
72
|
-
{!pdfData && (
|
|
73
|
-
<div className={styles.dropzone} {...getRootProps()}>
|
|
74
|
-
<div
|
|
75
|
-
className={styles.dropzoneRectangle}
|
|
76
|
-
data-is-focused={isFocused}
|
|
77
|
-
data-is-drag-accept={isDragAccept}
|
|
78
|
-
data-is-drag-reject={isDragReject}
|
|
79
|
-
>
|
|
80
|
-
<input {...getInputProps()} />
|
|
81
|
-
<p>Déposez un PDF ici ou cliquez pour sélectionner un fichier...</p>
|
|
82
|
-
<i
|
|
83
|
-
className="pi pi-file-arrow-up"
|
|
84
|
-
style={{ fontSize: "2.5rem" }}
|
|
85
|
-
></i>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
)}
|
|
89
|
-
</>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
1
|
+
import { FC, useEffect, useMemo } from "react";
|
|
2
|
+
import { useDropzone } from "react-dropzone";
|
|
3
|
+
import styles from "./style.module.scss";
|
|
4
|
+
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
|
5
|
+
import {
|
|
6
|
+
selectMode,
|
|
7
|
+
selectPdfInstructions,
|
|
8
|
+
setPdfInstructions,
|
|
9
|
+
} from "../activityData/activityDataSlice";
|
|
10
|
+
import { Button } from "primereact/button";
|
|
11
|
+
|
|
12
|
+
export const PdfEditor: FC = () => {
|
|
13
|
+
const dispatch = useAppDispatch();
|
|
14
|
+
const {
|
|
15
|
+
getRootProps,
|
|
16
|
+
getInputProps,
|
|
17
|
+
isFocused,
|
|
18
|
+
isDragAccept,
|
|
19
|
+
isDragReject,
|
|
20
|
+
acceptedFiles,
|
|
21
|
+
} = useDropzone({
|
|
22
|
+
accept: {
|
|
23
|
+
"application/pdf": [".pdf"],
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (acceptedFiles.length) {
|
|
28
|
+
dispatch(setPdfInstructions(acceptedFiles[0]));
|
|
29
|
+
}
|
|
30
|
+
}, [acceptedFiles]);
|
|
31
|
+
const mode = useAppSelector(selectMode);
|
|
32
|
+
const pdfInstructions = useAppSelector(selectPdfInstructions);
|
|
33
|
+
const pdfData = useMemo(
|
|
34
|
+
() => (pdfInstructions ? URL.createObjectURL(pdfInstructions) : null),
|
|
35
|
+
[pdfInstructions],
|
|
36
|
+
);
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{pdfData && (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
width: "100%",
|
|
43
|
+
height: "100%",
|
|
44
|
+
position: "relative",
|
|
45
|
+
overflow: "hidden",
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<object
|
|
49
|
+
data={pdfData + "#?navpanes=0"}
|
|
50
|
+
type="application/pdf"
|
|
51
|
+
width="100%"
|
|
52
|
+
height="100%"
|
|
53
|
+
>
|
|
54
|
+
<p>
|
|
55
|
+
Votre navigateur ne supporte pas les PDFs, vous pouvez{" "}
|
|
56
|
+
<a href={pdfData}>télécharger le fichier</a> à la place.
|
|
57
|
+
</p>
|
|
58
|
+
</object>
|
|
59
|
+
<div className="meta-player-content-cover"></div>
|
|
60
|
+
{mode === "create" && (
|
|
61
|
+
<Button
|
|
62
|
+
label="Supprimer le PDF"
|
|
63
|
+
severity="danger"
|
|
64
|
+
icon="pi pi-trash"
|
|
65
|
+
className={styles.deleteButton}
|
|
66
|
+
onClick={() => dispatch(setPdfInstructions(null))}
|
|
67
|
+
style={{ position: "absolute", bottom: "20px", right: "20px" }}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
{!pdfData && (
|
|
73
|
+
<div className={styles.dropzone} {...getRootProps()}>
|
|
74
|
+
<div
|
|
75
|
+
className={styles.dropzoneRectangle}
|
|
76
|
+
data-is-focused={isFocused}
|
|
77
|
+
data-is-drag-accept={isDragAccept}
|
|
78
|
+
data-is-drag-reject={isDragReject}
|
|
79
|
+
>
|
|
80
|
+
<input {...getInputProps()} />
|
|
81
|
+
<p>Déposez un PDF ici ou cliquez pour sélectionner un fichier...</p>
|
|
82
|
+
<i
|
|
83
|
+
className="pi pi-file-arrow-up"
|
|
84
|
+
style={{ fontSize: "2.5rem" }}
|
|
85
|
+
></i>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
};
|