@learnpack/learnpack 5.0.275 → 5.0.277

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.
Files changed (95) hide show
  1. package/README.md +409 -409
  2. package/lib/commands/audit.js +15 -15
  3. package/lib/commands/breakToken.js +19 -19
  4. package/lib/commands/clean.js +3 -3
  5. package/lib/commands/init.js +41 -41
  6. package/lib/commands/logout.js +3 -3
  7. package/lib/commands/publish.js +5 -10
  8. package/lib/commands/serve.js +55 -2
  9. package/lib/creatorDist/assets/index-BfLyIQVh.js +10343 -10224
  10. package/lib/managers/config/index.js +77 -77
  11. package/lib/utils/api.d.ts +1 -1
  12. package/lib/utils/api.js +12 -9
  13. package/lib/utils/creatorUtilities.js +14 -14
  14. package/lib/utils/export/epub.d.ts +2 -0
  15. package/lib/utils/export/epub.js +298 -0
  16. package/lib/utils/export/index.d.ts +3 -0
  17. package/lib/utils/export/index.js +7 -0
  18. package/lib/utils/export/scorm.d.ts +2 -0
  19. package/lib/utils/export/scorm.js +84 -0
  20. package/lib/utils/export/shared.d.ts +4 -0
  21. package/lib/utils/export/shared.js +61 -0
  22. package/lib/utils/export/types.d.ts +15 -0
  23. package/lib/utils/export/types.js +2 -0
  24. package/package.json +2 -1
  25. package/src/commands/audit.ts +487 -487
  26. package/src/commands/breakToken.ts +67 -67
  27. package/src/commands/clean.ts +30 -30
  28. package/src/commands/init.ts +650 -650
  29. package/src/commands/logout.ts +38 -38
  30. package/src/commands/publish.ts +20 -25
  31. package/src/commands/serve.ts +69 -4
  32. package/src/commands/start.ts +333 -333
  33. package/src/commands/translate.ts +123 -123
  34. package/src/creator/README.md +54 -54
  35. package/src/creator/eslint.config.js +7 -7
  36. package/src/creator/src/components/syllabus/ContentIndex.tsx +312 -312
  37. package/src/creator/src/i18n.ts +28 -28
  38. package/src/creator/src/index.css +217 -217
  39. package/src/creator/src/locales/en.json +126 -126
  40. package/src/creator/src/locales/es.json +126 -126
  41. package/src/creator/src/utils/configTypes.ts +122 -122
  42. package/src/creator/src/utils/constants.ts +13 -13
  43. package/src/creator/src/utils/creatorUtils.ts +46 -46
  44. package/src/creator/src/utils/eventBus.ts +2 -2
  45. package/src/creator/src/utils/lib.ts +468 -468
  46. package/src/creator/src/utils/socket.ts +61 -61
  47. package/src/creator/src/utils/store.ts +222 -222
  48. package/src/creator/src/vite-env.d.ts +1 -1
  49. package/src/creator/vite.config.ts +13 -13
  50. package/src/creatorDist/assets/index-BfLyIQVh.js +10343 -10224
  51. package/src/managers/config/defaults.ts +49 -49
  52. package/src/managers/config/exercise.ts +364 -364
  53. package/src/managers/config/index.ts +775 -775
  54. package/src/managers/file.ts +236 -236
  55. package/src/managers/server/routes.ts +554 -554
  56. package/src/managers/session.ts +182 -182
  57. package/src/managers/telemetry.ts +188 -188
  58. package/src/models/action.ts +13 -13
  59. package/src/models/config-manager.ts +28 -28
  60. package/src/models/config.ts +106 -106
  61. package/src/models/creator.ts +47 -47
  62. package/src/models/exercise-obj.ts +30 -30
  63. package/src/models/session.ts +39 -39
  64. package/src/models/socket.ts +61 -61
  65. package/src/models/status.ts +16 -16
  66. package/src/ui/_app/app.css +1 -1
  67. package/src/ui/_app/app.js +400 -397
  68. package/src/ui/app.tar.gz +0 -0
  69. package/src/utils/BaseCommand.ts +56 -56
  70. package/src/utils/api.ts +53 -39
  71. package/src/utils/audit.ts +392 -392
  72. package/src/utils/checkNotInstalled.ts +267 -267
  73. package/src/utils/configBuilder.ts +82 -82
  74. package/src/utils/convertCreds.js +34 -34
  75. package/src/utils/creatorUtilities.ts +504 -504
  76. package/src/utils/export/README.md +178 -0
  77. package/src/utils/export/epub.ts +400 -0
  78. package/src/utils/export/index.ts +3 -0
  79. package/src/utils/export/scorm.ts +121 -0
  80. package/src/utils/export/shared.ts +61 -0
  81. package/src/utils/export/types.ts +17 -0
  82. package/src/utils/incrementVersion.js +74 -74
  83. package/src/utils/misc.ts +58 -58
  84. package/src/utils/rigoActions.ts +500 -500
  85. package/src/utils/sidebarGenerator.ts +195 -195
  86. package/src/utils/templates/epub/epub.css +133 -0
  87. package/src/utils/templates/isolated/exercises/01-hello-world/README.es.md +26 -26
  88. package/src/utils/templates/isolated/exercises/01-hello-world/README.md +26 -26
  89. package/src/utils/templates/scorm/adlcp_rootv1p2.xsd +110 -0
  90. package/src/utils/templates/scorm/config/api.js +175 -0
  91. package/src/utils/templates/scorm/config/index.html +210 -0
  92. package/src/utils/templates/scorm/ims_xml.xsd +1 -0
  93. package/src/utils/templates/scorm/imscp_rootv1p1p2.xsd +345 -0
  94. package/src/utils/templates/scorm/imsmanifest.xml +38 -0
  95. package/src/utils/templates/scorm/imsmd_rootv1p2p1.xsd +573 -0
@@ -1,312 +1,312 @@
1
- import { useEffect, useState, useRef } from "react"
2
- import useStore, { Syllabus } from "../../utils/store"
3
- import { Lesson, LessonItem } from "../LessonItem"
4
- import { SVGS } from "../../assets/svgs"
5
- import { TMessage } from "../Message"
6
- import Loader from "../Loader"
7
- import { motion, AnimatePresence } from "framer-motion"
8
- // import { randomUUID } from "../../utils/creatorUtils"
9
- import toast from "react-hot-toast"
10
- import { randomUUID } from "../../utils/creatorUtils"
11
- import { useTranslation } from "react-i18next"
12
- import { t } from "i18next"
13
-
14
- const ContentIndexHeader = ({
15
- messages,
16
- syllabus,
17
- }: {
18
- messages: TMessage[]
19
- syllabus: Syllabus
20
- }) => {
21
- const { t } = useTranslation()
22
- const isFirst =
23
- messages.filter((m) => m.type === "assistant" && m.content.length > 0)
24
- .length === 2
25
-
26
- const headerText = isFirst
27
- ? t("contentIndexHeader.firstMessage", {
28
- title: syllabus.courseInfo.title,
29
- })
30
- : t("contentIndexHeader.secondMessage")
31
-
32
- return (
33
- <div className="mt-2 ">
34
- <AnimatePresence mode="wait">
35
- <motion.h2
36
- key={headerText}
37
- initial={{ opacity: 0, y: -10 }}
38
- animate={{ opacity: 1, y: 0 }}
39
- exit={{ opacity: 0, y: 10 }}
40
- transition={{ duration: 0.2 }}
41
- className="text-lg font-semibold sm:text-lg md:text-xl xl:text-2xl"
42
- >
43
- {headerText}
44
- </motion.h2>
45
- </AnimatePresence>
46
- </div>
47
- )
48
- }
49
- const ContentSecondaryHeader = ({
50
- messages,
51
- }: // syllabus,
52
- {
53
- messages: TMessage[]
54
- }) => {
55
- const { t } = useTranslation()
56
- const isFirst =
57
- messages.filter((m) => m.type === "assistant" && m.content.length > 0)
58
- .length === 2
59
-
60
- const subText = isFirst
61
- ? t("contentIndex.subText.first")
62
- : t("contentIndex.subText.second")
63
-
64
- return (
65
- <AnimatePresence mode="wait">
66
- <motion.p
67
- key={subText}
68
- initial={{ opacity: 0 }}
69
- animate={{ opacity: 1 }}
70
- exit={{ opacity: 0 }}
71
- transition={{ duration: 0.2, delay: 0.1 }}
72
- className="text-sm sm:text-md md:text-lg text-gray-600 mb-5"
73
- >
74
- {subText}
75
- </motion.p>
76
- </AnimatePresence>
77
- )
78
- }
79
-
80
- export const GenerateButton = ({
81
- handleSubmit,
82
- openLogin,
83
- }: {
84
- handleSubmit: () => void
85
- openLogin: () => void
86
- }) => {
87
- const { t } = useTranslation()
88
- const history = useStore((state) => state.history)
89
- const undo = useStore((state) => state.undo)
90
- const auth = useStore((state) => state.auth)
91
- const setAuth = useStore((state) => state.setAuth)
92
- const prev = history[history.length - 2]
93
- return (
94
- <div>
95
- <div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-4 justify-end mt-6">
96
- {prev && prev.lessons.length > 0 && (
97
- <button
98
- onClick={() => {
99
- undo()
100
- toast.success(t("contentIndex.changesReverted"))
101
- }}
102
- className="w-full sm:w-auto text-gray-500 bg-gray-200 rounded px-4 py-2 hover:bg-gray-300 flex items-center justify-center gap-2 cursor-pointer"
103
- >
104
- {SVGS.undo}
105
- {t("contentIndex.revertChanges")}
106
- </button>
107
- )}
108
-
109
- <button
110
- onClick={handleSubmit}
111
- className="w-full sm:w-auto bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700 flex items-center justify-center gap-2 cursor-pointer"
112
- >
113
- <span>{t("contentIndex.readyToCreate")}</span>
114
- {SVGS.rigoSoftBlue}
115
- </button>
116
- </div>
117
- <div className="mt-2 justify-end flex">
118
- {auth.user && (
119
- <div
120
- // onClick={handleSubmit}
121
- className="text-sm text-gray-500 rounded px-4 py-2 flex items-center justify-center gap-1 "
122
- >
123
- <span>
124
- {t("contentIndex.creatingCourseAs", {
125
- name: auth.user.first_name,
126
- })}
127
- </span>
128
- <button
129
- className="text-sm rounded items-center justify-center cursor-pointer text-blue-600"
130
- onClick={() => {
131
- setAuth({
132
- rigoToken: "",
133
- bcToken: "",
134
- userId: "",
135
- user: null,
136
- publicToken: "",
137
- })
138
- openLogin()
139
- }}
140
- >
141
- {t("contentIndex.loginAsSomeoneElse")}
142
- </button>
143
- </div>
144
- )}
145
- </div>
146
- </div>
147
- )
148
- }
149
-
150
- export const ContentIndex = ({
151
- handleSubmit,
152
- messages,
153
- isThinking,
154
- openLogin,
155
- }: {
156
- handleSubmit: () => void
157
- messages: TMessage[]
158
- isThinking: boolean
159
- openLogin: () => void
160
- }) => {
161
- const history = useStore((state) => state.history)
162
- const push = useStore((state) => state.push)
163
- const mode = useStore((state) => state.mode)
164
- const containerRef = useRef<HTMLDivElement>(null)
165
- const [showScrollHint, setShowScrollHint] = useState(false)
166
-
167
- const syllabus = history[history.length - 1]
168
-
169
- const previousSyllabus = history[history.length - 2] || null
170
-
171
- const handleRemove = (lesson: Lesson) => {
172
- push({
173
- ...syllabus,
174
- lessons: syllabus.lessons.filter((l) => l.uid !== lesson.uid),
175
- })
176
- }
177
-
178
- const handleChange = (uid: string, newTitle: string) => {
179
- push({
180
- ...syllabus,
181
- lessons: syllabus.lessons.map((lesson) =>
182
- lesson.uid === uid ? { ...lesson, title: newTitle } : lesson
183
- ),
184
- })
185
- }
186
-
187
- const addLessonAfter = (index: number, id: string) => {
188
- const newLesson: Lesson = {
189
- id: (parseFloat(id) + 0.1).toFixed(1),
190
- title: "Hello World",
191
- uid: randomUUID(),
192
- type: "READ",
193
- duration: 2,
194
- description: "Hello World",
195
- }
196
- const updated = [...syllabus.lessons]
197
- updated.splice(index + 1, 0, newLesson)
198
- push({
199
- ...syllabus,
200
- lessons: updated,
201
- })
202
- }
203
-
204
- useEffect(() => {
205
- const container = containerRef.current
206
-
207
- const checkScroll = () => {
208
- if (container) {
209
- const nearBottom =
210
- container.scrollHeight >
211
- container.clientHeight + container.scrollTop + 100
212
-
213
- setShowScrollHint(nearBottom)
214
- }
215
- }
216
-
217
- checkScroll()
218
- container?.addEventListener("scroll", checkScroll)
219
- return () => container?.removeEventListener("scroll", checkScroll)
220
- }, [syllabus.lessons])
221
-
222
- const scrollToBottom = (target: "bottom" | "continue") => {
223
- if (target === "continue") {
224
- const container = containerRef.current
225
- if (container) {
226
- const scrollStep = container.clientHeight * 0.8
227
- container.scrollBy({ top: scrollStep, behavior: "smooth" })
228
- }
229
- } else {
230
- const container = containerRef.current
231
- if (container) {
232
- container.scrollTo({ top: container.scrollHeight, behavior: "smooth" })
233
- }
234
- }
235
- }
236
-
237
- return (
238
- <div className="relative w-full p-2 sm:p-4 md:p-6 lg:p-8 space-y-6">
239
- <ContentIndexHeader messages={messages} syllabus={syllabus} />
240
- <div
241
- ref={containerRef}
242
- className="space-y-3 overflow-y-auto max-h-[78vh] pr-2 scrollbar-hide relative pb-20"
243
- >
244
- {isThinking ? (
245
- <Loader text="" minheight="min-h-[69vh]" />
246
- ) : (
247
- <>
248
- <ContentSecondaryHeader messages={messages} />
249
- {syllabus.lessons.length === 0 && messages.length < 3 && (
250
- <div className="text-center text-gray-500 font-bold text-lg h-[50vh] flex items-center justify-center">
251
- {t("contentIndex.noLessons")}
252
- </div>
253
- )}
254
- {syllabus.lessons.map((lesson, index) => (
255
- <div key={lesson.uid + index}>
256
- <LessonItem
257
- key={lesson.uid}
258
- lesson={lesson}
259
- onChange={handleChange}
260
- onRemove={() => handleRemove(lesson)}
261
- isNew={Boolean(
262
- previousSyllabus &&
263
- previousSyllabus &&
264
- previousSyllabus.lessons &&
265
- previousSyllabus.lessons.length > 0 &&
266
- !previousSyllabus.lessons.some(
267
- (l) => l.uid === lesson.uid
268
- )
269
- )}
270
- />
271
- {mode === "teacher" && (
272
- <div className="relative h-6">
273
- <div className="absolute left-1/2 -translate-x-1/2 -top-3">
274
- <button
275
- onClick={() => addLessonAfter(index, lesson.id)}
276
- className="w-6 h-6 flex items-center justify-center bg-blue-100 text-blue-600 rounded hover:bg-blue-200 shadow-sm text-sm font-semibold cursor-pointer"
277
- >
278
- +
279
- </button>
280
- </div>
281
- </div>
282
- )}
283
- </div>
284
- ))}
285
- {syllabus.lessons.length > 0 && (
286
- <GenerateButton
287
- handleSubmit={handleSubmit}
288
- openLogin={openLogin}
289
- />
290
- )}
291
- </>
292
- )}
293
- </div>
294
-
295
- {showScrollHint && !isThinking && (
296
- <div className="pointer-events-none relative">
297
- <div className="absolute bottom-0 left-0 w-full h-60 bg-gradient-to-t from-white to-transparent z-10" />
298
- <div className="absolute bottom-10 left-0 w-full flex justify-center z-31">
299
- <button
300
- style={{ color: "#0084FF" }}
301
- onClick={() => scrollToBottom("bottom")}
302
- className="px-4 py-1 bg-white text-sm rounded hover:bg-blue-50 cursor-pointer pointer-events-auto font-bold flex items-center gap-2 "
303
- >
304
- {t("contentIndex.continueScrolling")}
305
- {SVGS.downArrow}
306
- </button>
307
- </div>
308
- </div>
309
- )}
310
- </div>
311
- )
312
- }
1
+ import { useEffect, useState, useRef } from "react"
2
+ import useStore, { Syllabus } from "../../utils/store"
3
+ import { Lesson, LessonItem } from "../LessonItem"
4
+ import { SVGS } from "../../assets/svgs"
5
+ import { TMessage } from "../Message"
6
+ import Loader from "../Loader"
7
+ import { motion, AnimatePresence } from "framer-motion"
8
+ // import { randomUUID } from "../../utils/creatorUtils"
9
+ import toast from "react-hot-toast"
10
+ import { randomUUID } from "../../utils/creatorUtils"
11
+ import { useTranslation } from "react-i18next"
12
+ import { t } from "i18next"
13
+
14
+ const ContentIndexHeader = ({
15
+ messages,
16
+ syllabus,
17
+ }: {
18
+ messages: TMessage[]
19
+ syllabus: Syllabus
20
+ }) => {
21
+ const { t } = useTranslation()
22
+ const isFirst =
23
+ messages.filter((m) => m.type === "assistant" && m.content.length > 0)
24
+ .length === 2
25
+
26
+ const headerText = isFirst
27
+ ? t("contentIndexHeader.firstMessage", {
28
+ title: syllabus.courseInfo.title,
29
+ })
30
+ : t("contentIndexHeader.secondMessage")
31
+
32
+ return (
33
+ <div className="mt-2 ">
34
+ <AnimatePresence mode="wait">
35
+ <motion.h2
36
+ key={headerText}
37
+ initial={{ opacity: 0, y: -10 }}
38
+ animate={{ opacity: 1, y: 0 }}
39
+ exit={{ opacity: 0, y: 10 }}
40
+ transition={{ duration: 0.2 }}
41
+ className="text-lg font-semibold sm:text-lg md:text-xl xl:text-2xl"
42
+ >
43
+ {headerText}
44
+ </motion.h2>
45
+ </AnimatePresence>
46
+ </div>
47
+ )
48
+ }
49
+ const ContentSecondaryHeader = ({
50
+ messages,
51
+ }: // syllabus,
52
+ {
53
+ messages: TMessage[]
54
+ }) => {
55
+ const { t } = useTranslation()
56
+ const isFirst =
57
+ messages.filter((m) => m.type === "assistant" && m.content.length > 0)
58
+ .length === 2
59
+
60
+ const subText = isFirst
61
+ ? t("contentIndex.subText.first")
62
+ : t("contentIndex.subText.second")
63
+
64
+ return (
65
+ <AnimatePresence mode="wait">
66
+ <motion.p
67
+ key={subText}
68
+ initial={{ opacity: 0 }}
69
+ animate={{ opacity: 1 }}
70
+ exit={{ opacity: 0 }}
71
+ transition={{ duration: 0.2, delay: 0.1 }}
72
+ className="text-sm sm:text-md md:text-lg text-gray-600 mb-5"
73
+ >
74
+ {subText}
75
+ </motion.p>
76
+ </AnimatePresence>
77
+ )
78
+ }
79
+
80
+ export const GenerateButton = ({
81
+ handleSubmit,
82
+ openLogin,
83
+ }: {
84
+ handleSubmit: () => void
85
+ openLogin: () => void
86
+ }) => {
87
+ const { t } = useTranslation()
88
+ const history = useStore((state) => state.history)
89
+ const undo = useStore((state) => state.undo)
90
+ const auth = useStore((state) => state.auth)
91
+ const setAuth = useStore((state) => state.setAuth)
92
+ const prev = history[history.length - 2]
93
+ return (
94
+ <div>
95
+ <div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-4 justify-end mt-6">
96
+ {prev && prev.lessons.length > 0 && (
97
+ <button
98
+ onClick={() => {
99
+ undo()
100
+ toast.success(t("contentIndex.changesReverted"))
101
+ }}
102
+ className="w-full sm:w-auto text-gray-500 bg-gray-200 rounded px-4 py-2 hover:bg-gray-300 flex items-center justify-center gap-2 cursor-pointer"
103
+ >
104
+ {SVGS.undo}
105
+ {t("contentIndex.revertChanges")}
106
+ </button>
107
+ )}
108
+
109
+ <button
110
+ onClick={handleSubmit}
111
+ className="w-full sm:w-auto bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700 flex items-center justify-center gap-2 cursor-pointer"
112
+ >
113
+ <span>{t("contentIndex.readyToCreate")}</span>
114
+ {SVGS.rigoSoftBlue}
115
+ </button>
116
+ </div>
117
+ <div className="mt-2 justify-end flex">
118
+ {auth.user && (
119
+ <div
120
+ // onClick={handleSubmit}
121
+ className="text-sm text-gray-500 rounded px-4 py-2 flex items-center justify-center gap-1 "
122
+ >
123
+ <span>
124
+ {t("contentIndex.creatingCourseAs", {
125
+ name: auth.user.first_name,
126
+ })}
127
+ </span>
128
+ <button
129
+ className="text-sm rounded items-center justify-center cursor-pointer text-blue-600"
130
+ onClick={() => {
131
+ setAuth({
132
+ rigoToken: "",
133
+ bcToken: "",
134
+ userId: "",
135
+ user: null,
136
+ publicToken: "",
137
+ })
138
+ openLogin()
139
+ }}
140
+ >
141
+ {t("contentIndex.loginAsSomeoneElse")}
142
+ </button>
143
+ </div>
144
+ )}
145
+ </div>
146
+ </div>
147
+ )
148
+ }
149
+
150
+ export const ContentIndex = ({
151
+ handleSubmit,
152
+ messages,
153
+ isThinking,
154
+ openLogin,
155
+ }: {
156
+ handleSubmit: () => void
157
+ messages: TMessage[]
158
+ isThinking: boolean
159
+ openLogin: () => void
160
+ }) => {
161
+ const history = useStore((state) => state.history)
162
+ const push = useStore((state) => state.push)
163
+ const mode = useStore((state) => state.mode)
164
+ const containerRef = useRef<HTMLDivElement>(null)
165
+ const [showScrollHint, setShowScrollHint] = useState(false)
166
+
167
+ const syllabus = history[history.length - 1]
168
+
169
+ const previousSyllabus = history[history.length - 2] || null
170
+
171
+ const handleRemove = (lesson: Lesson) => {
172
+ push({
173
+ ...syllabus,
174
+ lessons: syllabus.lessons.filter((l) => l.uid !== lesson.uid),
175
+ })
176
+ }
177
+
178
+ const handleChange = (uid: string, newTitle: string) => {
179
+ push({
180
+ ...syllabus,
181
+ lessons: syllabus.lessons.map((lesson) =>
182
+ lesson.uid === uid ? { ...lesson, title: newTitle } : lesson
183
+ ),
184
+ })
185
+ }
186
+
187
+ const addLessonAfter = (index: number, id: string) => {
188
+ const newLesson: Lesson = {
189
+ id: (parseFloat(id) + 0.1).toFixed(1),
190
+ title: "Hello World",
191
+ uid: randomUUID(),
192
+ type: "READ",
193
+ duration: 2,
194
+ description: "Hello World",
195
+ }
196
+ const updated = [...syllabus.lessons]
197
+ updated.splice(index + 1, 0, newLesson)
198
+ push({
199
+ ...syllabus,
200
+ lessons: updated,
201
+ })
202
+ }
203
+
204
+ useEffect(() => {
205
+ const container = containerRef.current
206
+
207
+ const checkScroll = () => {
208
+ if (container) {
209
+ const nearBottom =
210
+ container.scrollHeight >
211
+ container.clientHeight + container.scrollTop + 100
212
+
213
+ setShowScrollHint(nearBottom)
214
+ }
215
+ }
216
+
217
+ checkScroll()
218
+ container?.addEventListener("scroll", checkScroll)
219
+ return () => container?.removeEventListener("scroll", checkScroll)
220
+ }, [syllabus.lessons])
221
+
222
+ const scrollToBottom = (target: "bottom" | "continue") => {
223
+ if (target === "continue") {
224
+ const container = containerRef.current
225
+ if (container) {
226
+ const scrollStep = container.clientHeight * 0.8
227
+ container.scrollBy({ top: scrollStep, behavior: "smooth" })
228
+ }
229
+ } else {
230
+ const container = containerRef.current
231
+ if (container) {
232
+ container.scrollTo({ top: container.scrollHeight, behavior: "smooth" })
233
+ }
234
+ }
235
+ }
236
+
237
+ return (
238
+ <div className="relative w-full p-2 sm:p-4 md:p-6 lg:p-8 space-y-6">
239
+ <ContentIndexHeader messages={messages} syllabus={syllabus} />
240
+ <div
241
+ ref={containerRef}
242
+ className="space-y-3 overflow-y-auto max-h-[78vh] pr-2 scrollbar-hide relative pb-20"
243
+ >
244
+ {isThinking ? (
245
+ <Loader text="" minheight="min-h-[69vh]" />
246
+ ) : (
247
+ <>
248
+ <ContentSecondaryHeader messages={messages} />
249
+ {syllabus.lessons.length === 0 && messages.length < 3 && (
250
+ <div className="text-center text-gray-500 font-bold text-lg h-[50vh] flex items-center justify-center">
251
+ {t("contentIndex.noLessons")}
252
+ </div>
253
+ )}
254
+ {syllabus.lessons.map((lesson, index) => (
255
+ <div key={lesson.uid + index}>
256
+ <LessonItem
257
+ key={lesson.uid}
258
+ lesson={lesson}
259
+ onChange={handleChange}
260
+ onRemove={() => handleRemove(lesson)}
261
+ isNew={Boolean(
262
+ previousSyllabus &&
263
+ previousSyllabus &&
264
+ previousSyllabus.lessons &&
265
+ previousSyllabus.lessons.length > 0 &&
266
+ !previousSyllabus.lessons.some(
267
+ (l) => l.uid === lesson.uid
268
+ )
269
+ )}
270
+ />
271
+ {mode === "teacher" && (
272
+ <div className="relative h-6">
273
+ <div className="absolute left-1/2 -translate-x-1/2 -top-3">
274
+ <button
275
+ onClick={() => addLessonAfter(index, lesson.id)}
276
+ className="w-6 h-6 flex items-center justify-center bg-blue-100 text-blue-600 rounded hover:bg-blue-200 shadow-sm text-sm font-semibold cursor-pointer"
277
+ >
278
+ +
279
+ </button>
280
+ </div>
281
+ </div>
282
+ )}
283
+ </div>
284
+ ))}
285
+ {syllabus.lessons.length > 0 && (
286
+ <GenerateButton
287
+ handleSubmit={handleSubmit}
288
+ openLogin={openLogin}
289
+ />
290
+ )}
291
+ </>
292
+ )}
293
+ </div>
294
+
295
+ {showScrollHint && !isThinking && (
296
+ <div className="pointer-events-none relative">
297
+ <div className="absolute bottom-0 left-0 w-full h-60 bg-gradient-to-t from-white to-transparent z-10" />
298
+ <div className="absolute bottom-10 left-0 w-full flex justify-center z-31">
299
+ <button
300
+ style={{ color: "#0084FF" }}
301
+ onClick={() => scrollToBottom("bottom")}
302
+ className="px-4 py-1 bg-white text-sm rounded hover:bg-blue-50 cursor-pointer pointer-events-auto font-bold flex items-center gap-2 "
303
+ >
304
+ {t("contentIndex.continueScrolling")}
305
+ {SVGS.downArrow}
306
+ </button>
307
+ </div>
308
+ </div>
309
+ )}
310
+ </div>
311
+ )
312
+ }