@eliceio/cdk-cli 1.7.1 → 1.8.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.
Files changed (127) hide show
  1. package/README.md +18 -15
  2. package/es/commands/create/index.js +6 -3
  3. package/es/commands/create/scaffold.d.ts +1 -1
  4. package/es/commands/create/scaffold.js +1 -1
  5. package/es/commands/doctor/index.js +34 -1
  6. package/es/core/lesson-check.d.ts +7 -0
  7. package/es/core/lesson-check.js +87 -0
  8. package/es/core/templates.d.ts +2 -0
  9. package/es/core/templates.js +4 -1
  10. package/es/dev/host-page.js +5 -2
  11. package/es/dev/learner-files.d.ts +1 -1
  12. package/es/dev/learner-files.js +7 -4
  13. package/es/dev/learner-shares.d.ts +90 -0
  14. package/es/dev/learner-shares.js +282 -0
  15. package/es/dev/mock-api.d.ts +28 -0
  16. package/es/dev/mock-api.js +32 -1
  17. package/es/dev/server.d.ts +3 -0
  18. package/es/dev/server.js +22 -1
  19. package/package.json +2 -2
  20. package/skills/_shared/always.md +1 -1
  21. package/skills/_shared/references/02-design-the-material.md +10 -9
  22. package/skills/_shared/references/03-create-the-project.md +12 -11
  23. package/skills/_shared/references/05-screen-code.md +1 -0
  24. package/skills/_shared/references/08-fix-check-errors.md +1 -0
  25. package/skills/_shared/references/12-upload-with-the-material-mcp.md +2 -2
  26. package/skills/_shared/references/17-using-the-entry-template.md +44 -5
  27. package/skills/_shared/references/18-using-the-lesson-template.md +207 -0
  28. package/skills/_shared/references/19-lesson-layouts.md +2132 -0
  29. package/skills/elice-content-create/SKILL.md +4 -3
  30. package/skills/elice-content-publish/SKILL.md +3 -3
  31. package/templates/_shared/lib/cdk-mock.d.ts +16 -0
  32. package/templates/_shared/lib/cdk-mock.js +49 -0
  33. package/templates/blank/template.json +1 -1
  34. package/templates/board/README.md +15 -7
  35. package/templates/board/core/board.d.ts +13 -0
  36. package/templates/board/core/board.js +11 -1
  37. package/templates/board/core/files.d.ts +40 -0
  38. package/templates/board/core/files.js +176 -0
  39. package/templates/board/core/model.d.ts +5 -0
  40. package/templates/board/core/model.js +24 -7
  41. package/templates/board/core/settings.d.ts +2 -0
  42. package/templates/board/core/settings.js +12 -1
  43. package/templates/board/package.json +1 -1
  44. package/templates/board/screens/board.js +58 -0
  45. package/templates/board/screens/edit.js +36 -1
  46. package/templates/board/template.json +1 -1
  47. package/templates/board/ui/board.css +176 -0
  48. package/templates/board/ui/card.js +74 -1
  49. package/templates/board/ui/composer.js +169 -20
  50. package/templates/board/ui/icons.js +2 -0
  51. package/templates/board/ui/texts.js +30 -2
  52. package/templates/lesson/README.md +71 -0
  53. package/templates/lesson/commentary.txt +7 -0
  54. package/templates/lesson/core/dom.d.ts +4 -0
  55. package/templates/lesson/core/dom.js +22 -0
  56. package/templates/lesson/core/engine.d.ts +23 -0
  57. package/templates/lesson/core/engine.js +169 -0
  58. package/templates/lesson/core/interact.d.ts +2 -0
  59. package/templates/lesson/core/interact.js +429 -0
  60. package/templates/lesson/core/layout-files.d.ts +4 -0
  61. package/templates/lesson/core/layout-files.js +9 -0
  62. package/templates/lesson/core/lesson.d.ts +95 -0
  63. package/templates/lesson/core/lesson.js +609 -0
  64. package/templates/lesson/core/sample.d.ts +4 -0
  65. package/templates/lesson/core/sample.js +128 -0
  66. package/templates/lesson/edit.html +21 -0
  67. package/templates/lesson/gitignore +4 -0
  68. package/templates/lesson/index.html +22 -0
  69. package/templates/lesson/layouts/_actions.html +1 -0
  70. package/templates/lesson/layouts/_cmp.html +1 -0
  71. package/templates/lesson/layouts/_deco-corner.html +1 -0
  72. package/templates/lesson/layouts/_deco-cover.html +1 -0
  73. package/templates/lesson/layouts/_deco-section.html +1 -0
  74. package/templates/lesson/layouts/_foot.html +1 -0
  75. package/templates/lesson/layouts/_head.html +1 -0
  76. package/templates/lesson/layouts/_media.html +1 -0
  77. package/templates/lesson/layouts/agenda.html +13 -0
  78. package/templates/lesson/layouts/bar-chart.html +14 -0
  79. package/templates/lesson/layouts/cards.html +12 -0
  80. package/templates/lesson/layouts/checklist.html +12 -0
  81. package/templates/lesson/layouts/choice-list.html +13 -0
  82. package/templates/lesson/layouts/closing.html +13 -0
  83. package/templates/lesson/layouts/compare.html +12 -0
  84. package/templates/lesson/layouts/cover-dark.html +13 -0
  85. package/templates/lesson/layouts/cover.html +15 -0
  86. package/templates/lesson/layouts/figures.html +12 -0
  87. package/templates/lesson/layouts/flow.html +13 -0
  88. package/templates/lesson/layouts/how-to.html +15 -0
  89. package/templates/lesson/layouts/image-bg.html +12 -0
  90. package/templates/lesson/layouts/image-pair.html +15 -0
  91. package/templates/lesson/layouts/image-split.html +12 -0
  92. package/templates/lesson/layouts/layers.html +12 -0
  93. package/templates/lesson/layouts/objectives.html +12 -0
  94. package/templates/lesson/layouts/ox-card.html +24 -0
  95. package/templates/lesson/layouts/ox-list.html +21 -0
  96. package/templates/lesson/layouts/process.html +14 -0
  97. package/templates/lesson/layouts/profile.html +13 -0
  98. package/templates/lesson/layouts/prompt-builder.html +18 -0
  99. package/templates/lesson/layouts/quiz.html +14 -0
  100. package/templates/lesson/layouts/quote.html +12 -0
  101. package/templates/lesson/layouts/scenario-rows.html +12 -0
  102. package/templates/lesson/layouts/section.html +14 -0
  103. package/templates/lesson/layouts/simulation.html +18 -0
  104. package/templates/lesson/layouts/stat.html +14 -0
  105. package/templates/lesson/layouts/statement.html +13 -0
  106. package/templates/lesson/layouts/stats.html +12 -0
  107. package/templates/lesson/layouts/stepper.html +13 -0
  108. package/templates/lesson/layouts/table.html +12 -0
  109. package/templates/lesson/layouts/tabs.html +13 -0
  110. package/templates/lesson/layouts/text-visual.html +16 -0
  111. package/templates/lesson/layouts/timeline.html +12 -0
  112. package/templates/lesson/layouts/toggle.html +16 -0
  113. package/templates/lesson/layouts/variables.html +14 -0
  114. package/templates/lesson/layouts/venn.html +15 -0
  115. package/templates/lesson/layouts/versus.html +12 -0
  116. package/templates/lesson/metadata.json +9 -0
  117. package/templates/lesson/package.json +15 -0
  118. package/templates/lesson/public/img/sample-chat.svg +21 -0
  119. package/templates/lesson/screens/edit.js +79 -0
  120. package/templates/lesson/screens/learn.js +56 -0
  121. package/templates/lesson/styles.css +27 -0
  122. package/templates/lesson/template.json +7 -0
  123. package/templates/lesson/ui/design.css +1103 -0
  124. package/templates/lesson/ui/fonts/PretendardVariable.woff2 +0 -0
  125. package/templates/lesson/ui/learn.css +64 -0
  126. package/templates/lesson/ui/mobile.css +492 -0
  127. package/templates/lesson/ui/reset.css +6 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: elice-content-create
3
- description: Create a new Elice Custom HTML learning material (LXP material type 17) with the ecdk CLI - a quiz, simulation, interactive explanation, guided exercise, flashcards or survey - and answer how-to questions about making one (design, screens, the screen kit and SDK, templates, the content editor, checking in ecdk dev, building the zip). Use when the person asks to make Elice or LXP learning content, a Custom HTML material or an ecdk project, or asks how to build something in one. To change a material that already exists (its questions, answers or points), use elice-content-edit.
3
+ description: Create a new Elice Custom HTML learning material (LXP material type 17) with the ecdk CLI - a page-by-page learning material (the default lesson template), a quiz, simulation, interactive explanation, guided exercise, flashcards or survey - and answer how-to questions about making one (design, screens, the screen kit and SDK, templates, the content editor, checking in ecdk dev, building the zip). Use when the person asks to make Elice or LXP learning content, a Custom HTML material or an ecdk project, or asks how to build something in one. To change a material that already exists (its questions, answers or points), use elice-content-edit.
4
4
  ---
5
5
 
6
6
  # Create an Elice learning material
@@ -16,8 +16,9 @@ Write the progress line `[n/N] …` before and after every step below (Always
16
16
  1. **Design before code.** Read `references/00-what-the-person-decides.md` and `references/02-design-the-material.md`. Decide ① what the student does, ② whether the student submits and the grading (`type` `pattern` or `rubric`, set on the edit screen; the quiz template uses `pattern`, so do not ask for a quiz; AI grading is `rubric` saved by the edit screen's `getGrading` and the student submits only the answer, never a score computed with `mlapi`, `references/05-screen-code.md` "AI grading") and which completion policy fits (the publish skill sets it after the person agrees; only `on_graded` grades, `on_submit` completes on any submission without grading), ③ the instructor screen (seen only in the LXP editor preview; instructors on the learning page see the student screen), ④ the content edit screen, ⑤ the purpose. Decide what the request leaves out and tell the person briefly; ask only when the learning goal is unclear. Then show the numbered plan.
17
17
  2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`references/01-check-the-environment.md`, also for `cli.latest`), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`references/03-create-the-project.md`; it runs `npm install` for the SDK, so when that fails run `npm install` in the project). Start `ecdk dev <folder>` in the background now and give the person the URL.
18
18
  3. **Write the screens.** Start from the template's example code and the kit API table at the top of `references/05-screen-code.md`; do not open `lib/` to learn the API (the table is the API). Follow its UI patterns (kit icon buttons, list rows, drop zones; the quiz template: `references/06-using-the-quiz-template.md`; a survey (opinions, feedback, self-assessment, no right answers): the survey template and `references/16-using-the-survey-template.md` for the settings shape, question-writing rules, personal data and where the answers are; block coding in Entry: the Entry template and `references/17-using-the-entry-template.md`, where the person builds the start and answer projects on the edit screen and you never write project JSON); an edit screen you write by hand follows `references/13-edit-screen-design.md` (kit classes, layout, microcopy); when a student or instructor screen has nothing to show, always use `app.emptyState()`, never your own empty-state markup, illustration or text (`references/05-screen-code.md`, "Nothing to show"), and write `commentary.txt` (key concepts and intent, no answers). There is no default content file: the content and answers are what the edit screen saves (`ecdk dev` writes `.ecdk/settings.json`, local by default; the elice-content-publish skill can send it with the upload after the person agrees, otherwise the person enters it in the LXP edit screen).
19
- - For a material that is not a quiz or a survey, start from the blank template and its content editor: design the content JSON shape and its schema first (`references/02-design-the-material.md` ④-1), put them in `screens/edit.js` (`useContentEditor(app, { initial, schema })`), then write the student screen against that shape. Replace the template's example everywhere it says `이 자료에 맞게 바꿀 곳`.
20
- - If the person describes the content (for example "5 questions about perceptrons"), fill it in so the upload can carry it: write `.ecdk/settings.json` in the shape `references/09-check.md` describes (the edit screen's content object at the top level, `grading` when graded), then have the person open the edit view in `ecdk dev`, check it and save with the edit screen's button, so the edit screen's own validation runs. Draft the answers, but the person confirms them before any upload (Always). One quiz material holds up to 20 questions (`references/06-using-the-quiz-template.md`): put them all in one material; only more than 20 means several quiz materials (pages). If the person prefers, give the content as draft text (the content editor: one JSON block for 코드 보기) to enter in the LXP edit screen instead.
19
+ - **A learning material the person did not give a screen layout for** (explanations, guided practice, self-check, "학습 자료 만들어줘") and that is not a quiz, survey, PDF/PPT document, video, Entry or board request: use the lesson template and `references/18-using-the-lesson-template.md`. You write only the content (`.ecdk/settings.json`, the lesson content object with layouts from `references/19-lesson-layouts.md`), never screen code; `ecdk doctor` (`project.lesson`) checks it. Lesson quizzes are self-check only. In a run without a person, skip the edit-view save and report how the content reaches LXP (`references/18-using-the-lesson-template.md` step 8).
20
+ - When the person wants to design the screens themselves, or the activity needs an interaction the lesson layouts cannot do (a live simulation, a game, a custom visualization), start from the blank template and its content editor: design the content JSON shape and its schema first (`references/02-design-the-material.md` ④-1), put them in `screens/edit.js` (`useContentEditor(app, { initial, schema })`), then write the student screen against that shape. Replace the template's example everywhere it says `이 자료에 맞게 바꿀 곳`.
21
+ - If the person describes the content (for example "5 questions about perceptrons"), fill it in so the upload can carry it: write `.ecdk/settings.json` in the shape `references/09-check.md` describes (the edit screen's content object at the top level, `grading` when graded), then have the person open the edit view in `ecdk dev`, check it and save with the edit screen's button, so the edit screen's own validation runs. Draft the answers, but the person confirms them before any upload (Always). One quiz material holds up to 20 questions (`references/06-using-the-quiz-template.md`): put them all in one material; only more than 20 means several quiz materials (pages). If the person prefers, give the content as draft text (the content editor: one JSON block for 코드 보기) to enter in the LXP edit screen instead. Not for the Entry template: its settings are Entry projects the person builds on the edit screen, never written by you, also in a run without a person (`references/17-using-the-entry-template.md` "Who makes what").
21
22
  4. **Check each screen** with `ecdk dev <folder> --check --screens <screen>` after you write it (`references/09-check.md`), fix what it reports (error ids: `references/08-fix-check-errors.md`). The person looks at the screens too.
22
23
  5. **Build and report.** `ecdk validate` once, then `ecdk build --json` must return `ok: true`. Report as `references/10-build.md` says.
23
24
  6. **Upload** only after the person approves: the elice-content-publish skill (it can send `.ecdk/settings.json` with the upload after the person agrees to the summary), or the person uploads `dist/content.zip` in LXP. Content not sent with the upload is entered in the LXP edit screen, then '수업 자료에 반영' at the top of the LXP edit page (`references/12-upload-with-the-material-mcp.md`, "Content and answers (settings)" and "Fallback").
@@ -13,13 +13,13 @@ Reference files are in `references/` in this skill's folder (see Always). Read `
13
13
 
14
14
  1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp` and log in (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`), then stop.
15
15
  2. **Build.** `ecdk build --json` must return `ok: true`. Keep `zip` and `zipBytes`.
16
- 3. **Content and answers.** Check whether the input schema of `save_draft` (or `update_material`) lists `settings` as a key of `payload` (on an older server, a top-level parameter). If it does and this project has `.ecdk/settings.json`: make sure the edit screen saved it (the person saves the edit view in `ecdk dev`; a file you wrote by hand must go through that save), run `ecdk doctor` and send no `settings` while its `project.grading` or `project.quiz` check fails (tell the person why, never the answer values; they fix it in the edit view), show a short summary (title, number of questions or items, answers included or not and `grading.type`, never the answer values) and ask for an explicit yes to send it with the upload. `settings` replaces the page's settings as a whole: on a page that already has a version, compare `get_material`'s settings with the file first, and if keys would disappear or the LXP content differs (an instructor edited it in LXP), show the difference briefly and ask before overwriting (a new page needs no comparison). Adding images to a page that already has a version: merge its current settings (`get_material` or `get_draft`) into `.ecdk/settings.json` first, keeping `asset:` images as they are (`references/12-upload-with-the-material-mcp.md` item 8). No file: suggest filling the edit view in `ecdk dev` first, or skip it. No `settings` key, or the person says no: zip only (the fallback). Details: `references/12-upload-with-the-material-mcp.md` "Content and answers (settings)".
17
- 4. **Completion policy.** If `save_draft` (or `update_material`) lists `completion_policy` in its input schema (in `payload`), propose one (`references/12-upload-with-the-material-mcp.md` "Completion policy"): graded (the quiz template, or settings with `grading`) → `on_graded`, the survey template → `on_access` (decided 2026-11-25; may change; its submissions are still recorded), other submits without grading → `on_submit`, no submission → `on_access`. `on_graded` only when the same save carries `settings` with `grading` (or the page already has grading); a material that grades with AI (`mlapi.fetch`, evaluation criteria) and has no `grading`: stop and fix it first (rubric from the criteria, `references/12-upload-with-the-material-mcp.md` "AI grading"), never `on_graded` without grading, and `on_submit` only on purpose for display-only AI feedback (tell the person scores won't reflect the AI); otherwise no policy at the first save, or `on_submit` if the person wants it (ask). Tell the person that only `on_graded` grades: `on_submit` completes on any submission without grading ("제출했어요."), `on_access` completes on open. The policy is a page setting and applies at once.
16
+ 3. **Content and answers.** Check whether the input schema of `save_draft` (or `update_material`) lists `settings` as a key of `payload` (on an older server, a top-level parameter). If it does and this project has `.ecdk/settings.json`: make sure the edit screen saved it (the person saves the edit view in `ecdk dev`; a file you wrote by hand must go through that save, except for **the lesson template**, whose hand-written content counts as checked when `ecdk doctor` `project.lesson` does not fail, so a run without a person skips the save: `references/18-using-the-lesson-template.md` step 8), run `ecdk doctor` and send no `settings` while its `project.grading` or `project.quiz` check fails (tell the person why, never the answer values; they fix it in the edit view), show a short summary (title, number of questions or items, answers included or not and `grading.type`, never the answer values) and ask for an explicit yes to send it with the upload. `settings` replaces the page's settings as a whole: on a page that already has a version, compare `get_material`'s settings with the file first, and if keys would disappear or the LXP content differs (an instructor edited it in LXP), show the difference briefly and ask before overwriting (a new page needs no comparison). Adding images to a page that already has a version: merge its current settings (`get_material` or `get_draft`) into `.ecdk/settings.json` first, keeping `asset:` images as they are (`references/12-upload-with-the-material-mcp.md` item 8). No file: suggest filling the edit view in `ecdk dev` first, or skip it. **The Entry template** (`references/17-using-the-entry-template.md`): never write or complete `.ecdk/settings.json` yourself (the start and answer projects are Entry project JSON the person builds), even when no one can open the edit screen in this run (Helpy and other unattended runs); send only a file the edit view saved, otherwise zip only. No `settings` key, or the person says no: zip only (the fallback). Details: `references/12-upload-with-the-material-mcp.md` "Content and answers (settings)".
17
+ 4. **Completion policy.** If `save_draft` (or `update_material`) lists `completion_policy` in its input schema (in `payload`), propose one (`references/12-upload-with-the-material-mcp.md` "Completion policy"): graded (the quiz template, or settings with `grading`) → `on_graded`, the survey template → `on_access` (decided 2026-11-25; may change; its submissions are still recorded), other submits without grading → `on_submit`, no submission → `on_access`. `on_graded` only when the same save carries `settings` with `grading` (or the page already has grading; the Entry template without them: no policy now, and the to-do in step 10); a material that grades with AI (`mlapi.fetch`, evaluation criteria) and has no `grading`: stop and fix it first (rubric from the criteria, `references/12-upload-with-the-material-mcp.md` "AI grading"), never `on_graded` without grading, and `on_submit` only on purpose for display-only AI feedback (tell the person scores won't reflect the AI); otherwise no policy at the first save, or `on_submit` if the person wants it (ask). Tell the person that only `on_graded` grades: `on_submit` completes on any submission without grading ("제출했어요."), `on_access` completes on open. The policy is a page setting and applies at once.
18
18
  5. **Pick the page and confirm it.** Candidates: `.ecdk/link.json`, the LXP edit URL the person gives (`https://{org}.…/lecturepages/{id}/edit`), or the person's choice from `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages`. Never pick a page yourself (not the first in a list, not a guess by title, not a page from another project); if the answer is ambiguous, ask again. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 with names and ids, its LXP edit URL, whether content and answers go with it and the completion policy to set (the page's current one too), then wait for an explicit yes. Do this every time: also for `.ecdk/link.json` (and compare its `version_id` with `get_material`) and for a URL the person gave (confirm the names it resolves to). `.ecdk/link.json` and an edit URL give only the org's `name_short`: get the 기관 name from `list_my_organizations` and the 과목 · 수업 · 페이지 names from `get_material`. A new page (`create_custom_page`) needs its own yes that names the 수업 it goes into. If the page already has content or answers saved in LXP, say that sending settings replaces them and ask again.
19
19
  6. **Upload.** `get_material` (keep `current_version.id`) → `create_package_upload` with `size_bytes = zipBytes` → run its `curl_command` with `package.zip` replaced by the zip path → `submit_package` → poll `get_draft` until ready or failed. On failure, report the server's reason with `ecdk validate dist/content.zip` and stop. Images or a PDF/PPTX for the settings: only now (draft ready), `create_asset_upload` per file → its `curl_command`, and put the returned `key`, never the URL, into the merged settings (`references/12-upload-with-the-material-mcp.md` "Images and documents"); no such tool: zip images, and tell the person.
20
20
  7. **Approve.** Show what changes (page, title, whether the content and answers go with it or are entered on the LXP edit screen after saving, the completion policy) and the draft `preview_urls`. Saving is visible to learners at once if the page is open. Wait for an explicit yes.
21
21
  8. **Save.** One `save_draft` with `material_draft_id`, `expected_current_version_id` and `payload` holding only keys its schema lists: `settings` (the content of `.ecdk/settings.json`) only when step 3 got a yes, `completion_policy` only when step 4 got a yes, and `title` · `icon` when the page has none (a new page; icon: `references/12-upload-with-the-material-mcp.md` "Icon"), all in this one save so no extra version is made. On `MATERIAL_CHANGED` or `MATERIAL_GRADING_REQUIRED`, stop and tell the person (`references/12-upload-with-the-material-mcp.md` "Errors and warnings").
22
22
  9. **Check.** Show any `warnings` in the result to the person close to word for word. `get_material` must show what was sent: the settings (same keys, item count and `grading.type` as the summary), the completion policy, the title. If not, tell the person and use the fallback. Without settings: tell the person to enter the content and answers in the LXP edit screen, save with its own button, then press '수업 자료에 반영' at the top of the LXP edit page (`references/12-upload-with-the-material-mcp.md` "Fallback"); for a graded material, then pick 답안 확인 후 완료 in the '설정' panel at the top of the LXP edit page, or offer to set `on_graded` with `update_material` (when it takes `completion_policy`) once `get_material` shows the grading. No `completion_policy` key: tell the person which policy to pick in that '설정' panel. `update_material` stopping with `MATERIAL_DRAFT_PENDING`: someone's upload is not saved; explain and ask whether to save it (`save_draft`) or discard it (`discard_draft`), never pick for them.
23
- 10. **Finish.** Write `.ecdk/link.json` as `{ "org": …, "lecture_page_id": …, "version_id": … }` so the next upload goes to the same page. Report 기관 · 과목 · 수업 · 페이지 (names and ids), the LXP URL, the saved version, whether content and answers were sent, the completion policy (only `on_graded` grades: a quiz with `on_submit` completes on any submission and shows "제출했어요.", not a score), any `warnings`, and whether the page is closed to learners (a new page stays closed until the person opens it in LXP). Later changes to the title, icon, settings or policy of this page without a new zip go through `update_material`.
23
+ 10. **Finish.** Write `.ecdk/link.json` as `{ "org": …, "lecture_page_id": …, "version_id": … }` so the next upload goes to the same page. Report 기관 · 과목 · 수업 · 페이지 (names and ids), the LXP URL, the saved version, whether content and answers were sent, the completion policy (only `on_graded` grades: a quiz with `on_submit` completes on any submission and shows "제출했어요.", not a score), any `warnings`, and whether the page is closed to learners (a new page stays closed until the person opens it in LXP). **The Entry template uploaded without settings** (always the case in a run without a person): the report is not "done"; end it with a remaining to-do, in the person's language, to open the LXP edit screen, build the start project ('시작 화면' tab) and the answer project ('채점 화면' tab), pick the grading (일반 채점 · AI 채점, with the AI criteria you drafted as text to type in) in the '설정' tab, press '초안으로 저장' and then '수업 자료에 반영', and for grading pick '답안 확인 후 완료' (`on_graded`) in the '설정' panel at the top of the LXP edit page (`references/17-using-the-entry-template.md` "Runs without a person"). Later changes to the title, icon, settings or policy of this page without a new zip go through `update_material`.
24
24
 
25
25
  {{version}}
@@ -181,6 +181,21 @@ interface LearnerFiles {
181
181
  url(path: string): Promise<string | null>;
182
182
  }
183
183
 
184
+ interface SharedFiles {
185
+ /** The mock keeps the file in memory as it is (no canvas re-encoding) */
186
+ post(
187
+ file: Blob,
188
+ options?: {
189
+ reencode?: boolean;
190
+ onProgress?: (progress: { loaded: number; total: number }) => void;
191
+ signal?: AbortSignal;
192
+ }
193
+ ): Promise<{ key: string; size: number; contentType: string; width?: number; height?: number }>;
194
+ /** Object URL of a file posted in this page, else null */
195
+ url(key: string): Promise<string | null>;
196
+ delete(key: string): Promise<void>;
197
+ }
198
+
184
199
  interface Mlapi {
185
200
  /** Same as `fetch`. The mock answers 503 SERVICE_UNAVAILABLE (reason ai_not_configured) */
186
201
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
@@ -214,6 +229,7 @@ export declare class MockEliceCDK {
214
229
  readonly assets: Assets;
215
230
  readonly kvstore: Kvstore;
216
231
  readonly learnerFiles: LearnerFiles;
232
+ readonly sharedFiles: SharedFiles;
217
233
  readonly mlapi: Mlapi;
218
234
  readonly accessToken: string | null;
219
235
  readonly videoPlayerUrl: string | null;
@@ -551,6 +551,7 @@ export class MockEliceCDK {
551
551
  #assets;
552
552
  #kvstore;
553
553
  #learnerFiles;
554
+ #sharedFiles;
554
555
  #mlapi;
555
556
 
556
557
  /** @param {MockOptions} [options] */
@@ -777,6 +778,50 @@ export class MockEliceCDK {
777
778
  },
778
779
  });
779
780
 
781
+ // Shared files (provisional SDK API): kept in memory with object URLs, like the SDK's editor preview.
782
+ // No canvas re-encoding here: the file is kept as it is (the real SDK draws pictures again)
783
+ const sharedFiles = new Map();
784
+ const SHARED_KINDS = { 'image/png': ['png', 10], 'image/jpeg': ['jpg', 10], 'image/webp': ['webp', 10], 'application/pdf': ['pdf', 20] };
785
+ const sharedType = (file) => {
786
+ const own = String(file?.type ?? '').toLowerCase();
787
+ if (own) return own === 'image/jpg' ? 'image/jpeg' : own;
788
+ const ext = String(file?.name ?? '').split('.').pop().toLowerCase();
789
+ return Object.keys(SHARED_KINDS).find((type) => SHARED_KINDS[type][0] === ext || (ext === 'jpeg' && type === 'image/jpeg')) ?? '';
790
+ };
791
+ const SHARED_KEY = /^learner-shares\/[^/]+\/[^/]+\/[0-9a-f-]{36}\.(png|jpg|jpeg|webp|pdf)$/;
792
+ this.#sharedFiles = Object.freeze({
793
+ post: async (file, { onProgress, signal } = {}) => {
794
+ this.#assertReady();
795
+ if (this.#viewer === 'tutor' && this.#scope !== 'edit')
796
+ throw new EliceCDKError(ErrorCode.ReadOnlyMode, 'A tutor cannot share files (mock).');
797
+ const contentType = sharedType(file);
798
+ const kind = SHARED_KINDS[contentType];
799
+ if (kind == null)
800
+ throw new EliceCDKError(ErrorCode.FileInvalidType, 'Only PNG, JPEG, WebP and PDF files can be shared (mock).');
801
+ if (!(file.size >= 1) || file.size > kind[1] * MB)
802
+ throw new EliceCDKError(ErrorCode.FileInvalidSize, `The file must be between 1 byte and ${kind[1]}MB (mock).`);
803
+ if (signal?.aborted) throw signal.reason;
804
+ await this.#delay();
805
+ const key = `learner-shares/mock/mock/${crypto.randomUUID()}.${kind[0]}`;
806
+ sharedFiles.set(key, URL.createObjectURL(file));
807
+ onProgress?.({ loaded: file.size, total: file.size });
808
+ return { key, size: file.size, contentType };
809
+ },
810
+ url: async (key) => {
811
+ this.#assertReady();
812
+ return SHARED_KEY.test(String(key)) ? (sharedFiles.get(key) ?? null) : null;
813
+ },
814
+ delete: async (key) => {
815
+ this.#assertReady();
816
+ if (!SHARED_KEY.test(String(key))) throw new EliceCDKError(ErrorCode.InvalidParam, '`key` must be a shared file key (mock).');
817
+ if (this.#viewer === 'tutor' && this.#scope !== 'edit')
818
+ throw new EliceCDKError(ErrorCode.ReadOnlyMode, 'A tutor cannot delete files (mock).');
819
+ const url = sharedFiles.get(key);
820
+ if (url) URL.revokeObjectURL(url);
821
+ sharedFiles.delete(key);
822
+ },
823
+ });
824
+
780
825
  this.#mlapi = Object.freeze({
781
826
  // There is no mlapi locally: answer like a server without AI (503 ai_not_configured).
782
827
  fetch: async (_input, _init) => {
@@ -839,6 +884,10 @@ export class MockEliceCDK {
839
884
  get learnerFiles() {
840
885
  return this.#learnerFiles;
841
886
  }
887
+
888
+ get sharedFiles() {
889
+ return this.#sharedFiles;
890
+ }
842
891
  /** Calls mlapi. The mock calls nothing and answers 503 ai_not_configured. */
843
892
  get mlapi() {
844
893
  return this.#mlapi;
@@ -2,5 +2,5 @@
2
2
  "name": "blank",
3
3
  "version": "1.2.6",
4
4
  "title": "빈 자료",
5
- "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 자료 편집 화면의 '설정'에서 교육자가 고름)"
5
+ "description": "화면을 직접 짜야 하는 자료(시뮬레이션 · 게임 · 시각화 등, 레이아웃에 내용만 채우는 학습 자료는 lesson). 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 자료 편집 화면의 '설정'에서 교육자가 고름)"
6
6
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Elice Custom HTML 학습자료 프로젝트입니다 (참여형 보드: 학생과 교육자가 섹션마다 카드를 올리고 하트를 남기며 실시간으로 봅니다. 패들릿의 칸반 모양).
4
4
 
5
- 보드 모델은 이 템플릿의 `core/board.js`(`createBoard`)입니다. SDK의 공용 kvstore(`sdk.kvstore`의 `get` · `post` · `delete` · `readPublic` · `subscribe`) 위에서 돕니다. 서버에 보드 표는 없고, 저마다 자기 kv `public` 줄(16 KB)에 쓴 것을 모아 보드로 보여 줍니다. **공개 kv · 실시간 알림 API는 아직 임시입니다**: 바뀌면 SDK kvstore 안만 바뀌도록 했습니다. SDK 1.7.0 이상(`readPublic` · `subscribe`가 든 버전)이 필요합니다.
5
+ 보드 모델은 이 템플릿의 `core/board.js`(`createBoard`)입니다. SDK의 공용 kvstore(`sdk.kvstore`의 `get` · `post` · `delete` · `readPublic` · `subscribe`) 위에서 돕니다. 서버에 보드 표는 없고, 저마다 자기 kv `public` 줄(16 KB)에 쓴 것을 모아 보드로 보여 줍니다. **공개 kv · 실시간 알림 API는 아직 임시입니다**: 바뀌면 SDK kvstore 안만 바뀌도록 했습니다. SDK 1.7.0 이상(`readPublic` · `subscribe`가 든 버전)이 필요합니다. 카드 파일 첨부는 SDK `sharedFiles`(임시 API)가 든 버전에서만 보이고, 없는 SDK에서는 파일 올리기를 숨깁니다.
6
6
 
7
7
  ## 고치는 곳
8
8
 
@@ -23,7 +23,7 @@ ui/ 모양 — 마음대로 고칩니다
23
23
  ├─ background.css 세 화면 공통 배경 (board-bg.webp, 흰 막 농도로 옅기 조절)
24
24
  ├─ texts.js 화면에 보이는 문구 전부 (탭 제목 · 버튼 · 안내 · 오류 · 편집 화면)
25
25
  ├─ card.js 카드 한 장 (맨 위 제목, 내용 목록 · **굵게**, 링크, 하트, 고정 · 승인 대기 · 숨김 표시)
26
- ├─ composer.js 카드 추가 창 (섹션 · 제목 · 내용 · 색 · 링크), 빈 곳 두 번 클릭 · 붙여넣기
26
+ ├─ composer.js 카드 추가 창 (섹션 · 제목 · 내용 · 색 · 링크 · 파일), 빈 곳 두 번 클릭 · 붙여넣기 · 끌어다 놓기
27
27
  ├─ dropdown.js EDS Menu 모양 드롭다운
28
28
  ├─ menu.js ⋯ 메뉴 (카드 · 섹션)
29
29
  └─ icons.js 선 아이콘
@@ -32,6 +32,7 @@ core/ 동작 — 고치지 않습니다
32
32
  ├─ board.js 보드 모델: 모두의 kv public 줄 읽기 · 합치기 · 실시간 · 쓰기(카드 · 하트 · 교육자 표시), createBoard(app.sdk)
33
33
  ├─ settings.js 저장 내용 모양 · 기본값 · 검증
34
34
  ├─ model.js 카드 읽기 · 만들기(data), 섹션마다 나누기, 1인당 카드 수, 내용 목록 · 굵게 읽기, 오류 종류
35
+ ├─ files.js 카드 파일(그림 · PDF): 종류 · 크기 검사, 카드 값(data.file), 올릴 수 있는지, 서명 주소 잠깐 들고 있기
35
36
  └─ dom.js html`…` 템플릿 · data-role 찾기
36
37
  ```
37
38
 
@@ -43,11 +44,13 @@ core/ 동작 — 고치지 않습니다
43
44
 
44
45
  | 화면 | 하는 일 |
45
46
  | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46
- | 편집 | 머리에서 제목 · 설명을 바로 고침. "보드" 탭: 섹션 이름을 바로 고치고 ⋯ 메뉴(이름 바꾸기 · 앞 · 뒤로 이동 · 뒤에 섹션 추가 · 삭제), 손잡이를 끌거나 ← →로 순서 바꾸기, 섹션 추가(최대 8). 카드 추가는 학생 화면과 같은 보드에 바로 올라감('초안으로 저장'과 무관, 저장한 섹션에만). "설정" 탭: 승인 후 공개 · 하트 반응 · 1인당 카드 수 · 내용 칸 문구 |
47
- | 학생 | 섹션마다 카드(고정 먼저, 그다음 오래된 것부터) · 카드 수. 카드 추가: 섹션의 "카드 추가" · 오른쪽 아래 버튼 · 빈 곳 두 번 클릭(그 섹션) · 붙여넣기(글이나 링크, 파일은 안내만). 창: 섹션 · 제목 · 내용(목록 이어쓰기, Ctrl · ⌘ + Enter로 올리기) · 색 · 링크. 하트, 내 카드 지우기(두 번 누름) |
48
- | 교육자 | 학생 화면 + 카드 ⋯ 메뉴: 승인(승인 대기 카드) · 숨기기 · 보이기 · 맨 위에 고정 · 고정 풀기, 내 카드 삭제. 머리: 승인 대기 수 · 보드 닫기 · 열기. **남의 카드는 지울 수 없어(쓰기는 자기 줄만) 숨기기로 가립니다** |
47
+ | 편집 | 머리에서 제목 · 설명을 바로 고침. "보드" 탭: 섹션 이름을 바로 고치고 ⋯ 메뉴(이름 바꾸기 · 앞 · 뒤로 이동 · 뒤에 섹션 추가 · 삭제), 손잡이를 끌거나 ← →로 순서 바꾸기, 섹션 추가(최대 8). 카드 추가는 학생 화면과 같은 보드에 바로 올라감('초안으로 저장'과 무관, 저장한 섹션에만). "설정" 탭: 승인 후 공개 · 하트 반응 · 파일 업로드 · 1인당 카드 수 · 내용 칸 문구 |
48
+ | 학생 | 섹션마다 카드(고정 먼저, 그다음 오래된 것부터) · 카드 수. 카드 추가: 섹션의 "카드 추가" · 오른쪽 아래 버튼 · 빈 곳 두 번 클릭(그 섹션) · 붙여넣기(글 · 링크 · 파일) · 파일 끌어다 놓기. 창: 섹션 · 제목 · 내용(목록 이어쓰기, Ctrl · ⌘ + Enter로 올리기) · 색 · 링크 · 파일 올리기(미리보기, 올리는 동안 진행 %). 하트, 내 카드 지우기(두 번 누름, 파일도 지움) |
49
+ | 교육자 | 학생 화면 + 카드 ⋯ 메뉴: 승인(승인 대기 카드) · 숨기기 · 보이기 · 맨 위에 고정 · 고정 풀기 · 파일 삭제(파일이 있는 카드), 내 카드 삭제. 머리: 승인 대기 수 · 보드 닫기 · 열기. **남의 카드는 지울 수 없어(쓰기는 자기 줄만) 숨기기로 가립니다** |
49
50
 
50
- - 튜터링(보기 전용): 카드 추가 · 하트 · 지우기 없음, 안내 줄
51
+ - 튜터링(보기 전용): 카드 추가 · 하트 · 지우기 · 파일 올리기 없음, 안내 줄 (파일은 봄)
52
+ - 카드 파일: 그림(PNG · JPG · WebP 10MB)과 PDF(20MB). GIF · SVG는 받지 않습니다. 그림은 SDK가 긴 변 2048px로 줄이고 EXIF(위치 등)를 지워 보냅니다. 카드에는 그림이 바로 보이고(`loading=lazy`), PDF는 이름 칩을 누르면 새 탭에서 열립니다(카드 안에 PDF를 띄우지 않음: LXP 샌드박스 iframe 안에서는 브라우저 PDF 보기가 막힘). 지운 파일은 '삭제된 파일'. 한 사람이 자료마다 50개까지(서버), 1분에 10번까지 올립니다
53
+ - 파일 업로드 설정(편집 화면 설정 탭, 기본 켬): 끄면 파일 올리기가 사라집니다(이미 올린 파일은 그대로 보임). 편집기 미리보기에서는 파일 올리기가 보이지 않습니다(메모리 보드라 서버에 올리지 않음)
51
54
  - 닫힌 보드: 학생의 카드 추가가 꺼지고 안내 줄 (교육자는 그대로 쓸 수 있음)
52
55
  - 1인당 카드 수(비우면 50): 내 카드가 한도에 닿으면 카드 추가가 꺼짐 (교육자는 한도 없음)
53
56
  - 승인 후 공개: 학생 카드는 쓴 사람 · 교육자에게만 보이고 "승인 대기" 표시, 교육자 화면에서 승인하면 모두에게
@@ -76,6 +79,7 @@ core/ 동작 — 고치지 않습니다
76
79
  description: '…', // 선택
77
80
  columns: [{ id: 'c1', title: '섹션 1' }, …], // 섹션. 기본 "섹션 1" 하나, 최대 8
78
81
  reactions: false, // 선택: 하트 끔 (없으면 켜짐)
82
+ fileUpload: false, // 선택: 카드 파일(그림 · PDF) 올리기 끔 (없으면 켜짐)
79
83
  bodyPlaceholder: '오늘 배운 것을 적어 보세요', // 선택: 카드 내용 칸 문구 (60자)
80
84
  board: {
81
85
  require_approval: false, // core/board.js가 읽음: 학생 카드는 교육자 승인 뒤 다른 학생에게 (화면 수준)
@@ -95,12 +99,16 @@ core/ 동작 — 고치지 않습니다
95
99
  | ------ | ------------------ | ------------------------------------------ |
96
100
  | 텍스트 | 내용 (없으면 제목) | `{ kind: 'card', column: 섹션 id, color, title? }` |
97
101
  | 링크 | 내용 (없으면 주소) | `{ kind: 'card', column, color, url, title? }` |
102
+ | 파일 | 내용 (없으면 제목 · 주소, 다 없으면 `📎`) | `{ kind: 'card', column, color, file, title?, url? }` |
103
+
104
+ `file`은 서버가 정한 key와 표시에 필요한 것만: 그림 `{ key, type, size, width, height }`, PDF `{ key, type, size, name }`(이름은 PDF 칩에만). 서명 주소는 저장하지 않고 열 때마다 `sdk.sharedFiles.url(key)`로 받습니다. 교육자가 파일만 지우면 교육자 줄에 `file_deleted.{글 id}`를 남겨 모두 '삭제된 파일'로 봅니다.
98
105
 
99
106
  색은 `white`(기본) · `yellow` · `pink` · `green` · `blue` · `purple` · `peach`. 내용은 500자까지, 링크는 http · https만 (앞에 없으면 https://를 붙임). `kind`가 `card`가 아닌 글(예전 자유 캔버스 노트 등)은 보이지 않습니다. 하트는 보드 좋아요(`like` · `unlike`)입니다. 한 사람의 카드 · 좋아요는 합쳐 16 KB까지라, 넘으면 "몇 개를 지운 뒤 다시" 안내가 뜹니다.
100
107
 
101
108
  ## 한계
102
109
 
103
- - 그림 · 파일 올리기는 아직 없습니다. 붙여넣거나 끌어 놓은 파일은 안내만 합니다.
110
+ - 파일 수 · 속도 한도는 서버가 지킵니다(한 사람 50개, 1분 10번). 숨김 · 승인 전 카드의 파일도 서버가 거르지 않습니다(주소를 아는 사람은 봄).
111
+ - 카드를 지우지 않고 파일만 바꾸기 · 지우기는 학생 화면에 없습니다(교육자 '파일 삭제'만).
104
112
  - 화면에는 `<form>` 제출을 쓰지 않습니다 (샌드박스에 `allow-forms`가 없어 submit 이벤트가 오지 않음). 창은 버튼과 키로 보냅니다.
105
113
  - 지우기 확인은 버튼을 두 번 누르는 것으로 합니다 (`confirm`은 샌드박스에서 막힘). 편집 화면의 섹션 지우기는 스낵바로 되돌립니다.
106
114
  - `ecdk dev` 연결 수: Chrome은 한 호스트에 HTTP/1.1 연결을 6개까지 엽니다. dev 탭 하나가 긴 연결 2개(dev 호스트 이벤트 · 보드 SSE)를 쓰므로 여러 학생을 볼 때 탭은 3개까지 엽니다.
@@ -12,6 +12,15 @@ export interface BoardSdk {
12
12
  readonly scope: 'learn' | 'edit' | null;
13
13
  readonly isDraft: boolean;
14
14
  readonly material: { settings?: Record<string, any> | null } | null;
15
+ /** 카드 파일 (임시 API, 없는 SDK면 파일 올리기를 숨김). 보드 모델은 쓰지 않고 화면이 씀 */
16
+ readonly sharedFiles?: {
17
+ post(
18
+ file: Blob,
19
+ options?: { onProgress?: (p: { loaded: number; total: number }) => void; signal?: AbortSignal }
20
+ ): Promise<{ key: string; size: number; contentType: string; width?: number; height?: number }>;
21
+ url(key: string): Promise<string | null>;
22
+ delete(key: string): Promise<void>;
23
+ };
15
24
  readonly kvstore: {
16
25
  get(params: { key: string }): Promise<any>;
17
26
  post(params: { key: string; value: any }): Promise<void>;
@@ -83,6 +92,8 @@ export interface BoardPost {
83
92
  status: BoardStatus;
84
93
  /** 교육자가 고정. 순서는 시간순 그대로, 정렬하는 화면이 앞에 둠 */
85
94
  pinned: boolean;
95
+ /** 교육자가 이 글의 파일을 지움 (교육자 줄의 file_deleted). 화면은 '삭제된 파일'로 보임 */
96
+ fileDeleted: boolean;
86
97
  likeCount: number;
87
98
  likedByMe: boolean;
88
99
  comments: BoardComment[];
@@ -149,6 +160,8 @@ export interface Board {
149
160
  approve(params: { id: string }): Promise<void>;
150
161
  pin(params: { id: string }): Promise<void>;
151
162
  unpin(params: { id: string }): Promise<void>;
163
+ /** 교육자만: 글의 파일을 지웠다고 표시 (파일은 화면이 sdk.sharedFiles.delete로 지움, 서버는 kv를 고치지 않음) */
164
+ markFileDeleted(params: { id: string }): Promise<void>;
152
165
  setClosed(params: { closed: boolean }): Promise<void>;
153
166
  }
154
167
 
@@ -9,6 +9,7 @@
9
9
  // likes.{postId} { created_at } 누른 사람 자기 줄에
10
10
  // comments.{id} { post, text, created_at }
11
11
  // hidden.{id} · approved.{id} · pinned.{id} (참) · closed (true) 교육자 줄에 있을 때만 뜻이 있음
12
+ // file_deleted.{id} (참) 교육자가 글의 파일을 지움 (교육자 줄에서만, 화면이 '삭제된 파일')
12
13
  // role 쓴 사람 역할 (서버가 알려 주지 않아 첫 쓰기 전에 씀). 교육자 표시를 믿을지 정할 때만 쓰고 화면에 보이지 않음
13
14
  // 그 밖의 key(옛 코드가 쓴 이름 등)는 읽지도 새로 쓰지도 않습니다 (보드는 쓴 사람 이름 · 시각을 보이지 않음)
14
15
  //
@@ -127,7 +128,7 @@ function compare(a, b) {
127
128
 
128
129
  /**
129
130
  * 모든 줄을 이 사람이 보는 보드로 합칩니다 (connection 빼고).
130
- * - 교육자 줄의 hidden · approved · pinned · closed만 셈 (학생 줄의 같은 key는 무시)
131
+ * - 교육자 줄의 hidden · approved · pinned · file_deleted · closed만 셈 (학생 줄의 같은 key는 무시)
131
132
  * - requireApproval이면 승인 안 된 학생 글은 pending: 쓴 사람 · 교육자만 봄. 교육자 글은 기다리지 않음
132
133
  * - 숨긴 글 · 댓글은 교육자만 봄. 보이지 않는 글의 하트 · 댓글은 같이 빠짐
133
134
  * - 모양이 틀린 항목(객체 아님, text · created_at 없음)은 건너뜀
@@ -140,12 +141,14 @@ export function buildBoardView(rows, context) {
140
141
  const hidden = new Set();
141
142
  const approved = new Set();
142
143
  const pinned = new Set();
144
+ const fileDeleted = new Set();
143
145
  let closed = false;
144
146
  for (const row of all) {
145
147
  if (row.role !== 'instructor') continue;
146
148
  for (const [id, flag] of entriesOf(row.value.hidden)) if (flag) hidden.add(id);
147
149
  for (const [id, flag] of entriesOf(row.value.approved)) if (flag) approved.add(id);
148
150
  for (const [id, flag] of entriesOf(row.value.pinned)) if (flag) pinned.add(id);
151
+ for (const [id, flag] of entriesOf(row.value.file_deleted)) if (flag) fileDeleted.add(id);
149
152
  if (row.value.closed === true) closed = true;
150
153
  }
151
154
 
@@ -180,6 +183,7 @@ export function buildBoardView(rows, context) {
180
183
  author,
181
184
  status,
182
185
  pinned: pinned.has(id),
186
+ fileDeleted: fileDeleted.has(id),
183
187
  likeCount: 0,
184
188
  likedByMe: false,
185
189
  comments: [],
@@ -720,6 +724,12 @@ export function createBoard(sdk) {
720
724
  await target.write(['pinned', params.id], undefined);
721
725
  },
722
726
 
727
+ markFileDeleted: async params => {
728
+ const target = moderator();
729
+ assertId(params?.id);
730
+ await target.write(['file_deleted', params.id], true);
731
+ },
732
+
723
733
  setClosed: async params => {
724
734
  const target = moderator();
725
735
  if (typeof params?.closed !== 'boolean') throw invalid('`closed` must be a boolean.');
@@ -0,0 +1,40 @@
1
+ // core/files.js 타입 (편집기 자동완성 · 테스트용)
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+
4
+ export type CardFileType = 'image/png' | 'image/jpeg' | 'image/webp' | 'application/pdf';
5
+
6
+ /** 카드 값 data.file: 그림은 이름 없이 크기(픽셀)만, PDF는 칩에 보일 이름 */
7
+ export interface CardFile {
8
+ key: string;
9
+ type: CardFileType;
10
+ size: number;
11
+ width?: number;
12
+ height?: number;
13
+ name?: string;
14
+ }
15
+
16
+ export type UploadErrorKind = 'type' | 'size' | 'count' | 'rate' | 'readOnly' | 'session' | 'failed';
17
+
18
+ export interface FileUrls {
19
+ peek(key: string): string | null | undefined;
20
+ get(key: string): Promise<string | null>;
21
+ forget(key: string): void;
22
+ }
23
+
24
+ export const FILE_KINDS: Readonly<Record<CardFileType, number>>;
25
+ export const FILE_ACCEPT: string;
26
+ export const IMAGE_INPUT_MAX: number;
27
+ export const FILE_NAME_MAX: number;
28
+ export const FILE_ONLY_TEXT: string;
29
+ export function isImageType(type: unknown): boolean;
30
+ export function fileType(file: { type?: string; name?: string } | null | undefined): CardFileType | '';
31
+ export function checkFile(file: Blob & { name?: string }): 'type' | 'size' | null;
32
+ export function fileValue(
33
+ shared: { key: string; size: number; contentType: string; width?: number; height?: number },
34
+ file: { name?: string } | null | undefined
35
+ ): CardFile;
36
+ export function readFile(raw: unknown): CardFile | null;
37
+ export function formatSize(bytes: number): string;
38
+ export function uploadsAvailable(sdk: any, settings: { fileUpload: boolean }, readOnly: boolean): boolean;
39
+ export function uploadErrorKind(err: any): UploadErrorKind;
40
+ export function createFileUrls(sdk: any): FileUrls;
@@ -0,0 +1,176 @@
1
+ // 카드에 붙이는 파일 (그림 · PDF). SDK 공유 파일(sdk.sharedFiles: post · url · delete, 임시 API · 3인 합의 전)로 올리고,
2
+ // 카드 값(data.file)에는 서버가 정한 key와 표시에 필요한 것만 둡니다 (한 사람의 보드 줄은 16 KB):
3
+ // 그림 { key, type: 'image/png' | 'image/jpeg' | 'image/webp', size, width?, height? } 파일 이름은 두지 않음
4
+ // PDF { key, type: 'application/pdf', size, name } name은 칩에 보일 이름(80자)
5
+ // 서명 주소는 저장하지 않고 열 때마다 sdk.sharedFiles.url(key)로 받습니다. 서버는 kv를 고치지 않으므로, 카드를 지울 때 파일도
6
+ // 지우고(실패해도 진행), 교육자가 파일만 지우면 교육자 줄에 표시(file_deleted)를 남겨 모두가 '삭제된 파일'로 봅니다.
7
+ // 종류 · 크기는 서버 기준: PNG · JPEG · WebP 10MB, PDF 20MB. GIF · SVG · HTML은 받지 않습니다.
8
+ // SDK가 그림을 다시 그려(긴 변 2048px, EXIF 제거) 보내므로, 그림은 원본이 10MB를 넘어도 줄어들면 올라갑니다.
9
+
10
+ const MB = 1024 * 1024;
11
+
12
+ /** 받는 종류 → 최대 크기 (서버 기준) */
13
+ export const FILE_KINDS = Object.freeze({
14
+ 'image/png': 10 * MB,
15
+ 'image/jpeg': 10 * MB,
16
+ 'image/webp': 10 * MB,
17
+ 'application/pdf': 20 * MB,
18
+ });
19
+ /** 파일 고르기 창이 보일 종류 (input accept) */
20
+ export const FILE_ACCEPT = Object.keys(FILE_KINDS).join(',');
21
+ /** 그림은 SDK가 줄이므로 원본은 이만큼까지 받는다 (그 뒤 SDK가 10MB를 다시 봄) */
22
+ export const IMAGE_INPUT_MAX = 50 * MB;
23
+ /** PDF 칩에 보일 이름 글자 수 */
24
+ export const FILE_NAME_MAX = 80;
25
+ /** 파일만 있는 카드의 text (보드 글은 text가 비면 안 됨). 읽을 때 파일이 있고 이 값이면 내용 없음 */
26
+ export const FILE_ONLY_TEXT = '📎';
27
+
28
+ const EXT_TYPES = {
29
+ png: 'image/png',
30
+ jpg: 'image/jpeg',
31
+ jpeg: 'image/jpeg',
32
+ webp: 'image/webp',
33
+ pdf: 'application/pdf',
34
+ };
35
+ const KEY_PATTERN = /^learner-shares\/[^/]+\/[^/]+\/[0-9a-f-]{36}\.(png|jpg|jpeg|webp|pdf)$/;
36
+
37
+ const isRecord = v => !!v && typeof v === 'object' && !Array.isArray(v);
38
+ export const isImageType = type => typeof type === 'string' && type.startsWith('image/');
39
+
40
+ /** 파일의 종류: 브라우저가 준 type, 없으면 이름의 확장자. 받지 않는 종류면 '' */
41
+ export function fileType(file) {
42
+ let type = String(file?.type ?? '').toLowerCase();
43
+ if (type === 'image/jpg') type = 'image/jpeg';
44
+ if (!type)
45
+ type =
46
+ EXT_TYPES[
47
+ String(file?.name ?? '')
48
+ .split('.')
49
+ .pop()
50
+ ?.toLowerCase() ?? ''
51
+ ] ?? '';
52
+ return type in FILE_KINDS ? type : '';
53
+ }
54
+
55
+ /**
56
+ * 고른 파일 검사: 받으면 null, 아니면 이유 'type' | 'size'
57
+ * @param {Blob & { name?: string }} file
58
+ */
59
+ export function checkFile(file) {
60
+ const type = fileType(file);
61
+ if (!type) return 'type';
62
+ const max = isImageType(type) ? IMAGE_INPUT_MAX : FILE_KINDS[type];
63
+ return file.size >= 1 && file.size <= max ? null : 'size';
64
+ }
65
+
66
+ /**
67
+ * 올린 결과(sdk.sharedFiles.post)를 카드 값 data.file로
68
+ * @param {{ key: string, size: number, contentType: string, width?: number, height?: number }} shared
69
+ * @param {{ name?: string }} file 고른 파일 (PDF 이름만 씀)
70
+ */
71
+ export function fileValue(shared, file) {
72
+ const value = { key: shared.key, type: shared.contentType, size: shared.size };
73
+ if (isImageType(shared.contentType)) {
74
+ if (Number.isInteger(shared.width) && Number.isInteger(shared.height)) {
75
+ value.width = shared.width;
76
+ value.height = shared.height;
77
+ }
78
+ return value;
79
+ }
80
+ value.name = [...String(file?.name || 'file.pdf')].slice(0, FILE_NAME_MAX).join('');
81
+ return value;
82
+ }
83
+
84
+ /** 카드 값의 data.file 읽기: 틀리면 null */
85
+ export function readFile(raw) {
86
+ if (!isRecord(raw) || typeof raw.key !== 'string' || !KEY_PATTERN.test(raw.key)) return null;
87
+ if (typeof raw.type !== 'string' || !(raw.type in FILE_KINDS)) return null;
88
+ const size = Number.isFinite(raw.size) && raw.size > 0 ? raw.size : 0;
89
+ if (isImageType(raw.type)) {
90
+ const dims =
91
+ Number.isInteger(raw.width) && Number.isInteger(raw.height) && raw.width > 0 && raw.height > 0
92
+ ? { width: raw.width, height: raw.height }
93
+ : {};
94
+ return { key: raw.key, type: raw.type, size, ...dims };
95
+ }
96
+ const name = typeof raw.name === 'string' && raw.name.trim() ? raw.name : 'file.pdf';
97
+ return { key: raw.key, type: raw.type, size, name: [...name].slice(0, FILE_NAME_MAX).join('') };
98
+ }
99
+
100
+ /** 크기 글: 1.2 MB · 340 KB */
101
+ export function formatSize(bytes) {
102
+ if (!(bytes > 0)) return '';
103
+ if (bytes >= MB) return `${(bytes / MB).toFixed(1)} MB`;
104
+ return `${Math.max(1, Math.round(bytes / 1024))} KB`;
105
+ }
106
+
107
+ /**
108
+ * 이 화면에서 파일을 올릴 수 있는지: 설정(파일 업로드)이 켜졌고, SDK에 sharedFiles가 있고, 편집기 미리보기(draft) · 튜터 ·
109
+ * 보기 전용이 아님. 미리보기에서는 카드가 메모리 보드에 남고 파일도 서버에 가지 않아 올리기를 숨긴다
110
+ * @param {any} sdk
111
+ * @param {{ fileUpload: boolean }} settings
112
+ * @param {boolean} readOnly
113
+ */
114
+ export function uploadsAvailable(sdk, settings, readOnly) {
115
+ return (
116
+ settings.fileUpload &&
117
+ !readOnly &&
118
+ !sdk?.isDraft &&
119
+ !(sdk?.viewer === 'tutor' && sdk?.scope !== 'edit') &&
120
+ typeof sdk?.sharedFiles?.post === 'function'
121
+ );
122
+ }
123
+
124
+ /**
125
+ * 파일 올리기 실패를 화면 문구 키로: type · size · count · rate · readOnly · session · failed
126
+ * @param {any} err EliceCDKError
127
+ */
128
+ export function uploadErrorKind(err) {
129
+ switch (err?.code) {
130
+ case 'file_invalid_type':
131
+ return 'type';
132
+ case 'file_invalid_size':
133
+ return 'size';
134
+ case 'storage_limit_exceeded':
135
+ return 'count';
136
+ case 'rate_limited':
137
+ return 'rate';
138
+ case 'read_only_mode':
139
+ return 'readOnly';
140
+ case 'session_expired':
141
+ case 'unauthorized':
142
+ return 'session';
143
+ default:
144
+ return 'failed';
145
+ }
146
+ }
147
+
148
+ /** 서명 주소를 이만큼 다시 쓴다 (SDK도 자료 주소를 만료 1분 전까지 들고 있음) */
149
+ const URL_REUSE_MS = 5 * 60 * 1000;
150
+
151
+ /**
152
+ * 카드 파일 주소: key마다 받은 주소를 잠깐 들고 있어, 실시간으로 다시 그릴 때 그림이 깜빡이지 않게 한다
153
+ * @param {any} sdk
154
+ */
155
+ export function createFileUrls(sdk) {
156
+ /** @type {Map<string, { url: string | null, at: number }>} */
157
+ const known = new Map();
158
+ return {
159
+ /** 들고 있는 주소 (없거나 오래되면 undefined) */
160
+ peek(key) {
161
+ const hit = known.get(key);
162
+ return hit && Date.now() - hit.at < URL_REUSE_MS ? hit.url : undefined;
163
+ },
164
+ /** 주소 받기: 못 받으면(미리보기의 남의 파일 등) null, 요청이 실패하면 던짐 */
165
+ async get(key) {
166
+ const hit = this.peek(key);
167
+ if (hit !== undefined) return hit;
168
+ const url = (await sdk?.sharedFiles?.url?.(key)) ?? null;
169
+ known.set(key, { url, at: Date.now() });
170
+ return url;
171
+ },
172
+ forget(key) {
173
+ known.delete(key);
174
+ },
175
+ };
176
+ }
@@ -1,5 +1,7 @@
1
1
  // core/model.js 타입 (편집기 자동완성 · 테스트용)
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import type { CardFile } from './files.js';
4
+
3
5
  export type CardColor = 'white' | 'yellow' | 'pink' | 'green' | 'blue' | 'purple' | 'peach';
4
6
 
5
7
  interface PostLike {
@@ -17,6 +19,8 @@ export interface Card {
17
19
  text: string;
18
20
  url: string | null;
19
21
  color: CardColor;
22
+ /** 붙인 파일 (core/files.js), 없으면 키가 없음 */
23
+ file?: CardFile;
20
24
  }
21
25
 
22
26
  export type BodyBlock =
@@ -42,6 +46,7 @@ export function cardValue(card: {
42
46
  text?: string;
43
47
  url?: string;
44
48
  color?: string;
49
+ file?: CardFile | null;
45
50
  }): { text: string; data: Record<string, unknown> } | null;
46
51
  export function cardsByColumn<P extends PostLike>(
47
52
  posts: P[],