@capytale/meta-player 0.1.4 → 0.1.6

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/.eslintrc.json CHANGED
@@ -3,7 +3,8 @@
3
3
  "eslint:recommended",
4
4
  "react-app",
5
5
  "plugin:react/jsx-runtime",
6
- "prettier"
6
+ "prettier",
7
+ "plugin:react-hooks/recommended"
7
8
  ],
8
9
  "parser": "@typescript-eslint/parser",
9
10
  "parserOptions": { "project": true, "tsconfigRootDir": "./" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capytale/meta-player",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -20,8 +20,6 @@
20
20
  "@uidotdev/usehooks": "^2.4.1",
21
21
  "primeicons": "^7.0.0",
22
22
  "primereact": "^10.8.3",
23
- "react": "^18.2.0",
24
- "react-dom": "^18.2.0",
25
23
  "react-html-props": "^2.0.9",
26
24
  "react-redux": "^9.1.0",
27
25
  "screenfull": "^6.0.2"
@@ -31,18 +29,25 @@
31
29
  "@testing-library/jest-dom": "^6.2.0",
32
30
  "@testing-library/react": "^14.1.2",
33
31
  "@testing-library/user-event": "^14.5.2",
34
- "@types/react": "^18.2.47",
35
- "@types/react-dom": "^18.2.18",
36
- "@vitejs/plugin-react": "^4.2.1",
32
+ "@types/react": "^18.3.8",
33
+ "@types/react-dom": "^18.3.0",
34
+ "@vitejs/plugin-react": "^4.3.1",
37
35
  "eslint": "^8.56.0",
38
36
  "eslint-config-prettier": "^9.1.0",
39
37
  "eslint-config-react-app": "^7.0.1",
40
38
  "eslint-plugin-prettier": "^5.1.3",
39
+ "eslint-plugin-react-hooks": "^4.6.2",
41
40
  "jsdom": "^23.2.0",
42
41
  "prettier": "^3.2.1",
42
+ "react": "^18.3.1",
43
+ "react-dom": "^18.3.1",
43
44
  "sass": "^1.75.0",
44
45
  "typescript": "^5.3.3",
45
46
  "vite": "^5.4.6",
46
47
  "vitest": "^1.2.0"
48
+ },
49
+ "peerDependencies": {
50
+ "react": "^18.3.1",
51
+ "react-dom": "^18.3.1"
47
52
  }
48
53
  }
@@ -6,10 +6,10 @@ import {
6
6
  selectGrading,
7
7
  selectInstructions,
8
8
  selectSaveState,
9
- selectWorkflow,
10
9
  setIsMPDirty,
11
10
  setIsPlayerDirty,
12
11
  setSaveState,
12
+ setWorkflow,
13
13
  } from "../activityData/activityDataSlice";
14
14
  import { useActivityJS } from "./ActivityJSProvider";
15
15
  import { Toast } from "primereact/toast";
@@ -24,7 +24,6 @@ const Saver: FC<{}> = () => {
24
24
  const grading = useAppSelector(selectGrading);
25
25
  const beforeSave = useAppSelector(selectBeforeSave);
26
26
  const afterSave = useAppSelector(selectAfterSave);
27
- const workflow = useAppSelector(selectWorkflow);
28
27
 
29
28
  const toast = useRef<Toast>(null);
30
29
 
@@ -85,16 +84,16 @@ const Saver: FC<{}> = () => {
85
84
  ? answerSheetContent
86
85
  : JSON.stringify(answerSheetContent);
87
86
  }
88
- if (
89
- activityJs.activitySession.mode === "assignment" ||
90
- activityJs.activitySession.mode === "review"
91
- ) {
92
- ab.assignmentNode!.workflow = workflow!;
93
- }
94
87
  try {
95
88
  const saveData = await ab.save();
96
89
  console.log("Save return data", saveData);
97
90
  dispatch(setSaveState("idle"));
91
+ if (
92
+ activityJs.activitySession.mode === "assignment" ||
93
+ activityJs.activitySession.mode === "review"
94
+ ) {
95
+ dispatch(setWorkflow(ab.assignmentNode!.workflow));
96
+ }
98
97
  dispatch(setIsPlayerDirty(false));
99
98
  dispatch(setIsMPDirty(false));
100
99
  toast.current!.show({
@@ -1,4 +1,4 @@
1
- import { memo, useState } from "react";
1
+ import { memo, useMemo, useState } from "react";
2
2
  import styles from "./style.module.scss";
3
3
 
4
4
  import { Button } from "primereact/button";
@@ -17,6 +17,7 @@ const ActivityMenu: React.FC = memo(() => {
17
17
  const isFullscreen = useFullscreen(wantFullscreen, () =>
18
18
  setWantFullscreen(false),
19
19
  );
20
+ const isInIframe = useMemo(() => capytaleUI.isInCapytaletIframe(), []);
20
21
  const [helpDialogVisible, setHelpDialogVisible] = useState(false);
21
22
  const activityJS = useActivityJS();
22
23
  return (
@@ -46,18 +47,20 @@ const ActivityMenu: React.FC = memo(() => {
46
47
  }}
47
48
  onClick={() => setWantFullscreen((prev) => !prev)}
48
49
  />
49
- <Button
50
- severity="secondary"
51
- size="small"
52
- icon={"pi pi-times"}
53
- text
54
- tooltip="Retour à la liste des activités"
55
- tooltipOptions={{
56
- position: "left",
57
- showDelay: settings.TOOLTIP_SHOW_DELAY,
58
- }}
59
- onClick={() => capytaleUI.closeCapytaleIframe()}
60
- />
50
+ {isInIframe && (
51
+ <Button
52
+ severity="secondary"
53
+ size="small"
54
+ icon={"pi pi-times"}
55
+ text
56
+ tooltip="Retour à la liste des activités"
57
+ tooltipOptions={{
58
+ position: "left",
59
+ showDelay: settings.TOOLTIP_SHOW_DELAY,
60
+ }}
61
+ onClick={() => capytaleUI.closeCapytaleIframe()}
62
+ />
63
+ )}
61
64
  <Sidebar
62
65
  header="Paramètres"
63
66
  visible={settingsSidebarVisible}
@@ -17,7 +17,6 @@ import {
17
17
  selectShowSaveButton,
18
18
  selectWorkflow,
19
19
  setSaveState,
20
- setWorkflow,
21
20
  } from "../activityData/activityDataSlice";
22
21
  import { copyToClipboard } from "../../utils/clipboard";
23
22
  import settings from "../../settings";
@@ -25,9 +24,11 @@ import { wf } from "@capytale/activity.js/activity/field/workflow";
25
24
  import capytaleUI from "@capytale/activity.js/backend/capytale/ui";
26
25
  import ButtonDoubleIcon from "../../utils/ButtonDoubleIcon";
27
26
  import CardSelector from "../../utils/CardSelector";
27
+ import { useActivityJS } from "../activityJS/ActivityJSProvider";
28
28
 
29
29
  const CapytaleMenu: React.FC = () => {
30
30
  const dispatch = useAppDispatch();
31
+ const activityJS = useActivityJS();
31
32
  const sharingInfo = useAppSelector(selectSharingInfo);
32
33
  const saveState = useAppSelector(selectSaveState);
33
34
  const windowsSize = useWindowSize();
@@ -46,7 +47,7 @@ const CapytaleMenu: React.FC = () => {
46
47
  const isInIframe = useMemo(() => capytaleUI.isInCapytaletIframe(), []);
47
48
  const toast = useRef<Toast>(null);
48
49
  const changeWorkflow = (value: wf) => {
49
- dispatch(setWorkflow(value));
50
+ activityJS.activitySession!.activityBunch.assignmentNode!.workflow = value;
50
51
  dispatch(setSaveState("should-save"));
51
52
  };
52
53
  const confirmFinishAssignment = () => {
@@ -80,25 +81,27 @@ const CapytaleMenu: React.FC = () => {
80
81
  }}
81
82
  />
82
83
  )}
83
- {showSaveButton && (
84
- <Button
85
- label={isQuiteSmall ? undefined : "Enregistrer"}
86
- disabled={!isDirty}
87
- severity={"warning"}
88
- size="small"
89
- icon="pi pi-save"
90
- loading={saveState !== "idle"}
84
+ {
85
+ showSaveButton && (
86
+ <Button
87
+ label={isQuiteSmall ? undefined : "Enregistrer"}
88
+ disabled={!isDirty}
89
+ severity={"warning"}
90
+ size="small"
91
+ icon="pi pi-save"
92
+ loading={saveState !== "idle"}
93
+ onClick={() => {
94
+ dispatch(setSaveState("should-save"));
95
+ }}
96
+ />
97
+ ) /**
91
98
  tooltip={isDirty ? "Enregistrer l'activité" : "Rien à enregistrer"}
92
99
  tooltipOptions={{
93
100
  position: "bottom",
94
101
  showDelay: settings.TOOLTIP_SHOW_DELAY,
95
102
  showOnDisabled: true,
96
- }}
97
- onClick={() => {
98
- dispatch(setSaveState("should-save"));
99
- }}
100
- />
101
- )}
103
+ }} */
104
+ }
102
105
 
103
106
  {mode === "create" && (
104
107
  <SplitButton