catchup-library-web 1.20.35 → 1.21.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/dist/index.js +1056 -823
- package/dist/index.mjs +971 -738
- package/package.json +2 -6
- package/src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent.tsx +62 -2
- package/src/components/activities/material-contents/GroupingActivityMaterialContent.tsx +363 -203
- package/src/components/activities/material-contents/MatchingActivityMaterialContent.tsx +318 -172
- package/src/components/activities/material-contents/OrderingActivityMaterialContent.tsx +76 -2
- package/src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent2.tsx +0 -306
- package/src/components/activities/material-contents/OrderingActivityMaterialContent2.tsx +0 -231
- package/src/components/dnds/DraggableDroppableItem.tsx +0 -60
- package/src/components/dnds/DraggableItem.tsx +0 -39
- package/src/components/dnds/DroppableItem.tsx +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catchup-library-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.00",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,14 +13,11 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@types/lodash": "^4.17.20",
|
|
15
15
|
"lodash": "^4.17.21",
|
|
16
|
-
"mathlive": "^0.105.3"
|
|
17
|
-
"react-dnd-html5-backend": "^16.0.1",
|
|
18
|
-
"react-dnd-touch-backend": "^16.0.1"
|
|
16
|
+
"mathlive": "^0.105.3"
|
|
19
17
|
},
|
|
20
18
|
"peerDependencies": {
|
|
21
19
|
"i18next": ">=22.0.0",
|
|
22
20
|
"react": "^18.0.0",
|
|
23
|
-
"react-dnd": "^16.0.0",
|
|
24
21
|
"react-dom": "^18.0.0",
|
|
25
22
|
"react-i18next": ">=12.0.0",
|
|
26
23
|
"react-katex": "^3.0.0",
|
|
@@ -36,7 +33,6 @@
|
|
|
36
33
|
"@types/react-modal": "^3.16.3",
|
|
37
34
|
"i18next": "^24.2.2",
|
|
38
35
|
"react": "^18.3.0",
|
|
39
|
-
"react-dnd": "^16.0.1",
|
|
40
36
|
"react-dom": "^18.3.0",
|
|
41
37
|
"react-i18next": "^15.4.0",
|
|
42
38
|
"react-katex": "^3.0.1",
|
package/src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent.tsx
CHANGED
|
@@ -28,6 +28,10 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
28
28
|
null
|
|
29
29
|
);
|
|
30
30
|
const dragElementRef = useRef<HTMLDivElement>(null);
|
|
31
|
+
const [mousePosition, setMousePosition] = useState<{ x: number; y: number }>({
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
});
|
|
31
35
|
const [touchPosition, setTouchPosition] = useState<{ x: number; y: number }>({
|
|
32
36
|
x: 0,
|
|
33
37
|
y: 0,
|
|
@@ -87,6 +91,24 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
87
91
|
e.preventDefault();
|
|
88
92
|
setDraggedOption(option);
|
|
89
93
|
setSelectedOption(null);
|
|
94
|
+
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const handleMouseMove = (e: React.MouseEvent): void => {
|
|
98
|
+
if (!draggedOption) return;
|
|
99
|
+
|
|
100
|
+
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
101
|
+
|
|
102
|
+
// Find the element under the mouse point
|
|
103
|
+
const elementUnder = document.elementFromPoint(e.clientX, e.clientY);
|
|
104
|
+
const dropZone = elementUnder?.closest("[data-drop-zone]");
|
|
105
|
+
|
|
106
|
+
if (dropZone) {
|
|
107
|
+
const dropIndex = dropZone.getAttribute("data-drop-zone");
|
|
108
|
+
setDropTargetIndex(dropIndex);
|
|
109
|
+
} else {
|
|
110
|
+
setDropTargetIndex(null);
|
|
111
|
+
}
|
|
90
112
|
};
|
|
91
113
|
|
|
92
114
|
const handleMouseUp = (): void => {
|
|
@@ -95,6 +117,7 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
95
117
|
}
|
|
96
118
|
setDraggedOption(null);
|
|
97
119
|
setDropTargetIndex(null);
|
|
120
|
+
setMousePosition({ x: 0, y: 0 });
|
|
98
121
|
};
|
|
99
122
|
|
|
100
123
|
// Touch drag handlers
|
|
@@ -138,6 +161,7 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
138
161
|
setDraggedOption(null);
|
|
139
162
|
setDropTargetIndex(null);
|
|
140
163
|
setDraggedElement(null);
|
|
164
|
+
setTouchPosition({ x: 0, y: 0 });
|
|
141
165
|
};
|
|
142
166
|
|
|
143
167
|
// Click/tap to select (for easier mobile interaction)
|
|
@@ -156,7 +180,11 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
156
180
|
const answerMap = retrieveAnswerMap();
|
|
157
181
|
|
|
158
182
|
return (
|
|
159
|
-
<div
|
|
183
|
+
<div
|
|
184
|
+
className="flex flex-row flex-wrap items-center"
|
|
185
|
+
onMouseMove={handleMouseMove}
|
|
186
|
+
onMouseUp={handleMouseUp}
|
|
187
|
+
>
|
|
160
188
|
<div className="hidden md:block">
|
|
161
189
|
<span className="font-semibold text-xl opacity-60">
|
|
162
190
|
{i18n.t("please_select_fill_in_the_blanks_text")}
|
|
@@ -166,6 +194,38 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
166
194
|
<DividerLine />
|
|
167
195
|
</div>
|
|
168
196
|
|
|
197
|
+
{/* Floating drag preview for mouse */}
|
|
198
|
+
{draggedOption && mousePosition.x > 0 && (
|
|
199
|
+
<div
|
|
200
|
+
className="fixed pointer-events-none z-50 opacity-80"
|
|
201
|
+
style={{
|
|
202
|
+
left: `${mousePosition.x}px`,
|
|
203
|
+
top: `${mousePosition.y}px`,
|
|
204
|
+
transform: "translate(-50%, -50%)",
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
{contentMap.type === "TEXT" ? (
|
|
208
|
+
<div className="border-catchup-blue border-2 px-2 rounded-catchup-xlarge bg-white shadow-lg">
|
|
209
|
+
<p className="italic whitespace-pre-wrap">
|
|
210
|
+
<InputWithSpecialExpression
|
|
211
|
+
value={draggedOption}
|
|
212
|
+
showSpecialOnly={false}
|
|
213
|
+
/>
|
|
214
|
+
</p>
|
|
215
|
+
</div>
|
|
216
|
+
) : (
|
|
217
|
+
<div className="border-catchup-blue border-2 px-2 py-1 rounded-catchup-xlarge bg-white shadow-lg">
|
|
218
|
+
<ShowMaterialMediaByContentType
|
|
219
|
+
key={uniqueValue}
|
|
220
|
+
contentType={contentMap.type}
|
|
221
|
+
src={draggedOption}
|
|
222
|
+
canFullScreen={false}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
|
|
169
229
|
{/* Floating drag preview for touch */}
|
|
170
230
|
{draggedOption && touchPosition.x > 0 && (
|
|
171
231
|
<div
|
|
@@ -254,7 +314,7 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
254
314
|
)
|
|
255
315
|
)}
|
|
256
316
|
</div>
|
|
257
|
-
<div className="w-full flex flex-row flex-wrap"
|
|
317
|
+
<div className="w-full flex flex-row flex-wrap">
|
|
258
318
|
{Object.keys(answerMap).map((materialKey, index) => {
|
|
259
319
|
const learnerAnswerState = checkAnswerState(
|
|
260
320
|
JSON.parse(materialMap[materialKey]),
|