@capytale/meta-player 0.9.4 → 0.9.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/package.json
CHANGED
|
@@ -40,6 +40,7 @@ export const activityDataSlice = createAppSlice({
|
|
|
40
40
|
state.accessTimerange = action.payload.accessTimerange;
|
|
41
41
|
state.studentInfo = action.payload.studentInfo;
|
|
42
42
|
state.instructions = action.payload.instructions;
|
|
43
|
+
state.loadedInstructions = action.payload.loadedInstructions;
|
|
43
44
|
state.instructionsType = action.payload.instructionsType;
|
|
44
45
|
state.sharedNotesContent = action.payload.sharedNotesContent;
|
|
45
46
|
state.sharedNotesType = action.payload.sharedNotesType;
|
|
@@ -145,6 +146,7 @@ export const activityDataSlice = createAppSlice({
|
|
|
145
146
|
codeLink: data.codeLink,
|
|
146
147
|
}),
|
|
147
148
|
selectInstructions: (data) => data.instructions,
|
|
149
|
+
selectLoadedInstructions: (data) => data.loadedInstructions,
|
|
148
150
|
selectInstructionsType: (data) => data.instructionsType,
|
|
149
151
|
selectPdfInstructions: (data) => data.pdfInstructions,
|
|
150
152
|
selectSharedNotesContent: (data) => data.sharedNotesContent,
|
|
@@ -220,6 +222,7 @@ export const {
|
|
|
220
222
|
selectActivityInfo,
|
|
221
223
|
selectSharingInfo,
|
|
222
224
|
selectInstructions,
|
|
225
|
+
selectLoadedInstructions,
|
|
223
226
|
selectInstructionsType,
|
|
224
227
|
selectPdfInstructions,
|
|
225
228
|
selectSharedNotesContent,
|
|
@@ -17,6 +17,12 @@ export type Instructions = {
|
|
|
17
17
|
format: "html" | "markdown" | "lexical";
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
export type LoadedInstructions = {
|
|
21
|
+
value: string | null;
|
|
22
|
+
htmlValue: string | null;
|
|
23
|
+
format: "html" | "markdown" | "lexical";
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
export type Icon = {
|
|
21
27
|
path: string;
|
|
22
28
|
style?: any;
|
|
@@ -36,6 +42,7 @@ export type ActivityJSData = {
|
|
|
36
42
|
accessTimerange: TimeRange | null;
|
|
37
43
|
studentInfo: StudentInfo | null;
|
|
38
44
|
instructions: Instructions | null;
|
|
45
|
+
loadedInstructions: LoadedInstructions | null;
|
|
39
46
|
instructionsType: EditorType;
|
|
40
47
|
pdfInstructions: Blob | null;
|
|
41
48
|
sharedNotesContent: InitialEditorStateType | null;
|
|
@@ -69,6 +76,7 @@ export const defaultActivityJSData: ActivityJSData = {
|
|
|
69
76
|
class: "",
|
|
70
77
|
},
|
|
71
78
|
instructions: null,
|
|
79
|
+
loadedInstructions: null,
|
|
72
80
|
instructionsType: "rich",
|
|
73
81
|
pdfInstructions: null,
|
|
74
82
|
sharedNotesContent: null,
|
|
@@ -87,6 +87,17 @@ export const ActivityJSProvider: FC<ActivityJSProviderProps> = (props) => {
|
|
|
87
87
|
htmlValue: ab.instructions.value.html || "",
|
|
88
88
|
format: "html",
|
|
89
89
|
},
|
|
90
|
+
loadedInstructions: ab.instructions.value.lexical
|
|
91
|
+
? {
|
|
92
|
+
value: ab.instructions.value.lexical,
|
|
93
|
+
htmlValue: ab.instructions.value.html,
|
|
94
|
+
format: "lexical",
|
|
95
|
+
}
|
|
96
|
+
: {
|
|
97
|
+
value: null,
|
|
98
|
+
htmlValue: ab.instructions.value.html || "",
|
|
99
|
+
format: "html",
|
|
100
|
+
},
|
|
90
101
|
instructionsType:
|
|
91
102
|
ab.instructions.value.lexical ||
|
|
92
103
|
ab.instructions.value.html ||
|
|
@@ -3,10 +3,10 @@ import { useAppSelector } from "../../app/hooks";
|
|
|
3
3
|
import {
|
|
4
4
|
selectHasGradingOrComments,
|
|
5
5
|
selectShowPedagoByDefault,
|
|
6
|
-
selectInstructions,
|
|
7
6
|
selectInstructionsType,
|
|
8
7
|
selectMode,
|
|
9
8
|
selectSharedNotesType,
|
|
9
|
+
selectLoadedInstructions,
|
|
10
10
|
} from "../activityData/activityDataSlice";
|
|
11
11
|
import {
|
|
12
12
|
selectIsGradingVisible,
|
|
@@ -22,34 +22,35 @@ export const usePedagoOptions = () => {
|
|
|
22
22
|
const showPedagoByDefault = useAppSelector(selectShowPedagoByDefault);
|
|
23
23
|
const hasGradingOrComments = useAppSelector(selectHasGradingOrComments);
|
|
24
24
|
const instructionsType = useAppSelector(selectInstructionsType);
|
|
25
|
-
const
|
|
25
|
+
const loadedInstructions = useAppSelector(selectLoadedInstructions);
|
|
26
26
|
const sharedNotesType = useAppSelector(selectSharedNotesType);
|
|
27
|
+
|
|
27
28
|
const hasNonEmptyInstructions = useMemo(() => {
|
|
28
|
-
if (instructionsType === "none" || !
|
|
29
|
+
if (instructionsType === "none" || !loadedInstructions) {
|
|
29
30
|
return false;
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
-
if (typeof
|
|
33
|
-
console.warn("HTML instructions value is not a string");
|
|
32
|
+
if (loadedInstructions.format === "html") {
|
|
33
|
+
if (typeof loadedInstructions.htmlValue !== "string") {
|
|
34
|
+
console.warn("HTML loaded instructions value is not a string");
|
|
34
35
|
return true;
|
|
35
36
|
}
|
|
36
37
|
return (
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
loadedInstructions.htmlValue.trim() !== "" &&
|
|
39
|
+
loadedInstructions.htmlValue.trim() !== "<p></p>"
|
|
39
40
|
);
|
|
40
|
-
} else if (
|
|
41
|
-
if (typeof
|
|
42
|
-
console.warn("Markdown instructions value is not a string");
|
|
41
|
+
} else if (loadedInstructions.format === "markdown") {
|
|
42
|
+
if (typeof loadedInstructions.value !== "string") {
|
|
43
|
+
console.warn("Markdown loaded instructions value is not a string");
|
|
43
44
|
return true;
|
|
44
45
|
}
|
|
45
|
-
return
|
|
46
|
-
} else if (
|
|
47
|
-
if (typeof
|
|
48
|
-
console.warn("Lexical instructions value is not a string");
|
|
46
|
+
return loadedInstructions.value.trim() !== "";
|
|
47
|
+
} else if (loadedInstructions.format === "lexical") {
|
|
48
|
+
if (typeof loadedInstructions.value !== "string") {
|
|
49
|
+
console.warn("Lexical loaded instructions value is not a string");
|
|
49
50
|
return true;
|
|
50
51
|
}
|
|
51
52
|
try {
|
|
52
|
-
const parsedInstructions = JSON.parse(
|
|
53
|
+
const parsedInstructions = JSON.parse(loadedInstructions.value);
|
|
53
54
|
if (
|
|
54
55
|
!parsedInstructions.root ||
|
|
55
56
|
!parsedInstructions.root.children ||
|
|
@@ -66,12 +67,12 @@ export const usePedagoOptions = () => {
|
|
|
66
67
|
}
|
|
67
68
|
return singleNode.children && singleNode.children.length > 0;
|
|
68
69
|
} catch (error) {
|
|
69
|
-
console.warn("Lexical instructions value is not valid JSON");
|
|
70
|
+
console.warn("Lexical loaded instructions value is not valid JSON");
|
|
70
71
|
return true;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
return false;
|
|
74
|
-
}, [instructionsType,
|
|
75
|
+
}, [instructionsType, loadedInstructions]);
|
|
75
76
|
|
|
76
77
|
const hasSharedNotes = sharedNotesType !== "none";
|
|
77
78
|
const hasPedago =
|