@eliceio/cdk-cli 0.1.0-alpha.6 → 0.1.0-alpha.8

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 (87) hide show
  1. package/README.md +110 -104
  2. package/es/cli.js +7 -22
  3. package/es/commands/build/index.d.ts +3 -21
  4. package/es/commands/build/index.js +17 -140
  5. package/es/commands/create/scaffold.d.ts +2 -0
  6. package/es/commands/create/scaffold.js +15 -1
  7. package/es/commands/doctor/index.d.ts +4 -3
  8. package/es/commands/doctor/index.js +14 -14
  9. package/es/commands/setup/index.d.ts +4 -7
  10. package/es/commands/setup/index.js +41 -70
  11. package/es/commands/uninstall/index.d.ts +9 -8
  12. package/es/commands/uninstall/index.js +41 -47
  13. package/es/commands/update/index.d.ts +4 -2
  14. package/es/commands/update/index.js +27 -18
  15. package/es/commands/validate/index.js +3 -1
  16. package/es/core/collect.d.ts +1 -1
  17. package/es/core/collect.js +3 -1
  18. package/es/core/config.d.ts +2 -2
  19. package/es/core/config.js +3 -3
  20. package/es/core/manifest.d.ts +3 -3
  21. package/es/core/manifest.js +4 -8
  22. package/es/{commands/mcp/index.d.ts → core/mcp.d.ts} +11 -18
  23. package/es/{commands/mcp/index.js → core/mcp.js} +29 -51
  24. package/es/core/prepare.d.ts +15 -10
  25. package/es/core/prepare.js +35 -35
  26. package/es/core/project-check.d.ts +6 -5
  27. package/es/core/project-check.js +9 -9
  28. package/es/core/sandbox.d.ts +6 -5
  29. package/es/core/sandbox.js +30 -8
  30. package/es/core/sdk.d.ts +7 -18
  31. package/es/core/sdk.js +8 -38
  32. package/es/{commands/skill/index.d.ts → core/skills.d.ts} +1 -17
  33. package/es/{commands/skill/index.js → core/skills.js} +6 -22
  34. package/es/dev/grading.d.ts +1 -1
  35. package/es/dev/grading.js +1 -1
  36. package/es/dev/host-page.js +2 -2
  37. package/es/dev/server.d.ts +6 -4
  38. package/es/dev/server.js +47 -77
  39. package/es/engines/vite/index.d.ts +2 -2
  40. package/es/engines/vite/index.js +2 -4
  41. package/es/engines/vite/plugin.d.ts +58 -0
  42. package/es/engines/vite/plugin.js +286 -0
  43. package/es/engines/vite/run.d.ts +15 -0
  44. package/es/engines/vite/run.js +92 -0
  45. package/es/rules/check.js +10 -12
  46. package/es/rules/csp.d.ts +1 -1
  47. package/es/rules/csp.js +1 -1
  48. package/es/rules/types.d.ts +8 -3
  49. package/es/rules.json.js +1 -1
  50. package/es/test-packages.d.ts +3 -1
  51. package/package.json +8 -3
  52. package/rules.json +9 -3
  53. package/skills/_shared/always.md +1 -1
  54. package/skills/elice-content-create/SKILL.md +2 -1
  55. package/skills/elice-content-guide/topics/01-check-the-environment.md +2 -2
  56. package/skills/elice-content-guide/topics/02-design-the-material.md +2 -0
  57. package/skills/elice-content-guide/topics/03-create-the-project.md +3 -3
  58. package/skills/elice-content-guide/topics/04-rules.md +1 -1
  59. package/skills/elice-content-guide/topics/05-screen-code.md +44 -13
  60. package/skills/elice-content-guide/topics/07-move-existing-html.md +2 -2
  61. package/skills/elice-content-guide/topics/08-fix-check-errors.md +21 -21
  62. package/skills/elice-content-guide/topics/10-build.md +1 -1
  63. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +2 -2
  64. package/skills/elice-content-publish/SKILL.md +1 -1
  65. package/templates/_shared/lib/cdk-mock.js +2 -2
  66. package/templates/_shared/lib/elice-content-editor.d.ts +80 -0
  67. package/templates/_shared/lib/elice-content-editor.js +1062 -0
  68. package/templates/_shared/lib/elice-content.css +332 -0
  69. package/templates/_shared/lib/elice-content.js +18 -15
  70. package/templates/blank/README.md +29 -5
  71. package/templates/blank/commentary.txt +5 -0
  72. package/templates/blank/screens/edit.js +38 -17
  73. package/templates/blank/screens/instructor.js +20 -8
  74. package/templates/blank/screens/learn.js +151 -13
  75. package/templates/blank/styles.css +171 -0
  76. package/templates/blank/template.json +2 -2
  77. package/templates/quiz/README.md +2 -3
  78. package/templates/quiz/core/model.js +1 -1
  79. package/templates/quiz/screens/edit.js +14 -2
  80. package/templates/quiz/styles.css +11 -0
  81. package/templates/quiz/template.json +1 -1
  82. package/templates/quiz/ui/texts.js +1 -1
  83. package/es/core/minify.d.ts +0 -18
  84. package/es/core/minify.js +0 -93
  85. package/es/engines/static/index.d.ts +0 -3
  86. package/es/engines/static/index.js +0 -11
  87. package/es/engines/types.d.ts +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -8,6 +8,10 @@
8
8
  ".": {
9
9
  "types": "./es/index.d.ts",
10
10
  "import": "./es/index.js"
11
+ },
12
+ "./vite": {
13
+ "types": "./es/engines/vite/index.d.ts",
14
+ "import": "./es/engines/vite/index.js"
11
15
  }
12
16
  },
13
17
  "publishConfig": {
@@ -30,7 +34,8 @@
30
34
  ],
31
35
  "dependencies": {
32
36
  "esbuild": "~0.28.2",
33
- "fflate": "^0.8.3"
37
+ "fflate": "^0.8.3",
38
+ "vite": "^8.3.6"
34
39
  },
35
40
  "devDependencies": {
36
41
  "@elice/rollup-config": "^1.260406.0",
@@ -40,7 +45,7 @@
40
45
  "rollup": "^4.0.0",
41
46
  "tslib": "^2.6.1",
42
47
  "typescript": "~5.9.3",
43
- "@eliceio/cdk": "^1.0.0-alpha.6"
48
+ "@eliceio/cdk": "^1.0.0-alpha.7"
44
49
  },
45
50
  "scripts": {
46
51
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
package/rules.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.11.0",
2
+ "version": "0.12.0",
3
3
  "manifest": {
4
4
  "file": "metadata.json",
5
5
  "kinds": ["material", "description"],
@@ -557,6 +557,12 @@
557
557
  "scope": "client",
558
558
  "title": "라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"
559
559
  },
560
+ {
561
+ "id": "ref.script-not-public",
562
+ "level": "error",
563
+ "scope": "client",
564
+ "title": "type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"
565
+ },
560
566
  {
561
567
  "id": "sandbox.module-src",
562
568
  "level": "warn",
@@ -661,9 +667,9 @@
661
667
  },
662
668
  {
663
669
  "id": "sdk.lib-copy",
664
- "level": "warn",
670
+ "level": "error",
665
671
  "scope": "client",
666
- "title": "옛 lib/cdk.js 복사본 (package.json에 @eliceio/cdk가 없음, 프로젝트 검사만. SDK를 package.json 의존성으로 옮기기)"
672
+ "title": "SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"
667
673
  }
668
674
  ]
669
675
  }
@@ -4,7 +4,7 @@
4
4
  - The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
5
5
  - The content CSP blocks external images, fonts, video, CSS, `<iframe>` and external APIs: put everything in the zip (fonts as files or data URIs). If a library calls outside hosts while running, that is blocked too → check the `ecdk dev` log for "막힌 외부 요청".
6
6
  - If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Run each command through their login shell instead: `"$SHELL" -ilc 'ecdk build --json'` (use `zsh -ilc` when `$SHELL` is empty). With `--json`, read only the last JSON block of the output (a login shell may print other text first). If that also fails, ask the person how Node was installed.
7
- - Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); `ecdk build` adds it to the zip as `lib/cdk.js`.
7
+ - Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); the kit imports it and `ecdk build` (Vite) bundles it into the screens. Never copy SDK code into the project.
8
8
  - Ask the person before you settle correct answers, install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
9
9
  - LXP draws its own 이전 · 다음 bar under the material to move between lecture pages. For steps inside a material use the kit's `app.usePaging` (side chevrons, `n / N`; on the first and last step they become "이전 자료" · "다음 자료" to the previous / next lecture page, `../elice-content-guide/topics/02-design-the-material.md`), never a look-alike bottom 이전 · 다음 bar.
10
10
  - Answer the person in their language. The guide is in English.
@@ -14,7 +14,8 @@ Read guide topics with the Read tool from the sibling `elice-content-guide` skil
14
14
  1. **Design before code.** Read `../elice-content-guide/topics/00-what-the-person-decides.md` (what the person decides) and `../elice-content-guide/topics/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). Do not decide the completion policy: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고른다 (the instructor picks `on_access` · `on_submit` · `on_graded` in the LXP settings tab after the upload; do not write it in `metadata.json`). Only tell the person which policy fits, ③ the instructor 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.
15
15
  2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`../elice-content-guide/topics/01-check-the-environment.md`; when `cli.latest` warns, offer `ecdk update` and run it only after the person agrees), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`../elice-content-guide/topics/03-create-the-project.md`; it runs `npm install` for the SDK, so when that fails run `npm install` in the project).
16
16
  3. **Write the screens.** You build the template: screens and code (`../elice-content-guide/topics/05-screen-code.md`, following its UI patterns: kit icon buttons, list rows, drop zones; the quiz template: `../elice-content-guide/topics/06-using-the-quiz-template.md`), and `commentary.txt` (key concepts and intent, no answers). The real content and answers are entered in the LXP edit screen after upload; there is no default content file. In `ecdk dev`, try the edit and learn screens with a little sample input (saved only locally in `.ecdk/settings.json`, never uploaded); do not author the full question set locally.
17
- - If the person describes the content (for example "5 questions about perceptrons"), give it as draft text with the answers for the person to enter in the LXP edit screen. A quiz material holds one question, so several questions mean several quiz materials (pages).
17
+ - For a material that is not a quiz, start from the blank template and its content editor: design the content JSON shape and its schema first (`../elice-content-guide/topics/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 `이 자료에 맞게 바꿀 곳`.
18
+ - If the person describes the content (for example "5 questions about perceptrons"), give it as draft text with the answers for the person to enter in the LXP edit screen. A quiz material holds one question, so several questions mean several quiz materials (pages). For a material built on the content editor, give the content as one JSON block in the schema's shape for the person to paste into 코드 보기 of the LXP edit screen (no graded answers in it).
18
19
  4. **Check.** `ecdk validate`, fix errors (`../elice-content-guide/topics/08-fix-check-errors.md`), then `ecdk dev` and go through the screens (`../elice-content-guide/topics/09-check.md`). The person looks at the screens too.
19
20
  5. **Build and report.** `ecdk build --json` must return `ok: true`. Report as `../elice-content-guide/topics/10-build.md` says.
20
21
  6. **Upload** only after the person approves: the elice-content-publish skill (`../elice-content-guide/topics/12-upload-with-the-material-mcp.md`), or the person uploads `dist/content.zip` in LXP. Then the person enters the content and answers in the LXP edit screen and saves the page (the edit screen's button, then 저장 at the bottom of the LXP edit page; learners see it after that).
@@ -5,6 +5,6 @@ ecdk --version && ecdk doctor --json
5
5
  ```
6
6
 
7
7
  - Without `ecdk`: it needs Node.js 20.19 or later (22 LTS recommended) and `@eliceio/cdk-cli`. Tell the user how to install it, and run **a global install (`npm install -g @eliceio/cdk-cli`) only after the user agrees**. Without agreement, run `npx @eliceio/cdk-cli <command>`.
8
- - `doctor` item `mcp.material` warns when the Elice material server MCP is not registered. It is used later to upload to LXP (the elice-content-publish skill), so it is not needed to make a material. To register it, ask the user first, then run `ecdk setup` (installs the skills and registers the MCP in one go; production by default, `--env qa5` for the QA server; `ecdk setup --only mcp` registers the MCP only) and tell the user the login step it prints.
9
- - `doctor` item `cli.latest` warns when npm `latest` has a newer ecdk (`skip` when offline). Tell the user and run `ecdk update` **only after the user agrees** (it runs a global install, refreshes the skills with the new ecdk and runs `npm update @eliceio/cdk` when the current folder is a project; `ecdk update --check` only shows the plan). It never downgrades. After it, Claude Code picks up the changed skills in open sessions; only when the output (or `--json` `skillsDirCreated: true`) says the skills folder was just created, a Claude Code session that was already open needs `/reload-skills` once. Helpy Code desktop needs a restart. If it fails with `EACCES`, show the manual command it prints.
8
+ - `doctor` item `mcp.material` warns when the Elice material server MCP is not registered. It is used later to upload to LXP (the elice-content-publish skill), so it is not needed to make a material. To register it, ask the user first, then run `ecdk setup` (installs the skills and registers the MCP in one go; `ecdk setup --only mcp` registers the MCP only) and tell the user the login step it prints.
9
+ - `doctor` item `cli.latest` warns when npm `latest` has a newer ecdk (`skip` when offline). Tell the user and run `ecdk update` **only after the user agrees** (it runs a global install, refreshes the skills with the new ecdk and runs `npm update @eliceio/cdk` when the current folder is a project; `ecdk update --check` only shows the plan; `ecdk update --project` when the skills are in the project's `.claude/skills/`). It never downgrades. After it, Claude Code picks up the changed skills in open sessions; only when the output (or `--json` `skillsDirCreated: true`) says the skills folder was just created, a Claude Code session that was already open needs `/reload-skills` once. Helpy Code desktop needs a restart. If it fails with `EACCES`, show the manual command it prints.
10
10
  - Fix each `fail` item in `doctor` as its `fix.description` says. `--fix` fixes only the items that can be fixed automatically.
@@ -25,6 +25,8 @@ Read or watch / change values and observe (simulation, visualization) / follow s
25
25
 
26
26
  **④ Does it need a content edit screen?** When instructors may want to rewrite text, numbers or lists (for example a simulation's initial values, a card list, step descriptions), keep them in the content the edit screen saves (`app.content`, the material's `settings`) and let the edit screen change them. There is no default content file: until the edit screen saves, `app.content` is `{}`, `app.hasContent` is false, and the student and instructor screens show `app.emptyState()` ("아직 내용이 없습니다 …"). Turn the edit screen off only when the material needs no content at all (everything is in the code).
27
27
 
28
+ **④-1 Design the content JSON shape** before the screens: the keys the student screen reads (for example `{ "title": "…", "unit": "km", "items": [{ "name": "수성", "value": 4879 }] }`), which are required, number ranges and list sizes. That shape becomes the schema of the kit's content editor (`useContentEditor`, see 5), so the edit screen needs no hand-written fields. Keep it small and flat, and keep graded answers out of it.
29
+
28
30
  **⑤ Purpose**: the material itself (`kind: material`, the default), or the **problem description** of another material such as a practice (`kind: description`: student screen only, no grading).
29
31
 
30
32
  **Steps inside one material (paging)**: LXP already draws a bar **under every material** with `< 이전 · 3/6 · 다음 >` that moves between **lecture pages** of the course. Inside the material, never draw a bottom bar with 이전 · 다음 (or "◀ 이전 · 2 / 6 · 다음 ▶") that looks like it: the student cannot tell which one moves the step and which one leaves the material. For a material with several steps (slides, STEP 1~5), use the kit's `app.usePaging` (see 5):
@@ -1,18 +1,18 @@
1
1
  # 3. Create the project
2
2
 
3
- Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.3.0`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
3
+ Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.3.1`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
4
4
 
5
5
  | Case | Start with |
6
6
  | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
7
  | A quiz (one question per quiz material; several questions mean several quiz materials) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds one question of any of the five types with "문항 추가"; answers set on the edit screen; `pattern` grading, `on_graded` picked in LXP) |
8
- | Any other material | `ecdk create <folder> --template blank` (skeleton of the three screens) |
8
+ | Any other material | `ecdk create <folder> --template blank` (three screens with a small example to replace, "예측하고 확인하기", and the kit content editor on the edit screen: see 5) |
9
9
  | A dark screen | Add `--theme dark` to the above |
10
10
  | A problem description | Create with blank, set `metadata.json` to `{ "kind": "description", "screens": { "learn": { "enabled": true, "entry": "index.html" } }, "commentary": "commentary.txt" }`, delete the other screen files |
11
11
  | An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
12
12
 
13
13
  `create` refuses a folder that is not empty. Use a new subfolder. It then runs `npm install` in the project (the SDK `@eliceio/cdk` comes from npm through `package.json`; `--no-install` skips it). When the install fails, the project stays: run `npm install` in it (network or proxy problem; tell the user).
14
14
 
15
- The project files: screens, `lib/` (the screen kit, copied as is), `metadata.json` (screens · `commentary`; `ecdk build` copies it and fills only `build`), `package.json` (the SDK version in `dependencies`, build options `minify` · `sourcemap` · `root` · `outDir` · `exclude` · `template` under `"ecdk"`). There is no `lib/cdk.js` in the project: `ecdk build` and `ecdk dev` take it from `node_modules/@eliceio/cdk`. To update the SDK run `npm update @eliceio/cdk`.
15
+ The project files: screens, `lib/` (the screen kit, copied as is), `metadata.json` (screens · `commentary`; `ecdk build` copies it and fills only `build`), `package.json` (the SDK version in `dependencies`, build options `minify` · `sourcemap` · `root` · `outDir` · `exclude` · `template` under `"ecdk"`). `ecdk build` and `ecdk dev` run on Vite (a project `vite.config.*` is used when present). The kit imports the SDK from `node_modules/@eliceio/cdk` and `ecdk build` bundles it into the screens; there is no SDK file in the project or the zip. To update the SDK run `npm update @eliceio/cdk`.
16
16
 
17
17
  Then:
18
18
 
@@ -1,7 +1,7 @@
1
1
  # 4. Rules
2
2
 
3
3
  1. **Never put correct answers in the content**: not in a data JSON file, the screen code, or comments. They reach the student's browser. Answers go only in `settings.grading` through the edit screen (the server never sends it to students; `ecdk dev` keeps it in `.ecdk/settings.json`, left out of the zip).
4
- 2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (`lib/cdk.js`, added by `ecdk build` from `node_modules`) directly.
4
+ 2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (`@eliceio/cdk`, imported by the kit and bundled by `ecdk build`) directly.
5
5
  3. **Do not use blocked features**: `alert`/`confirm`/`prompt` · `window.open` · `<form>` submission · access to `window.parent`/`top` · `fetch`/`WebSocket` to external addresses · external `<script src>`. `localStorage` · `sessionStorage` · `indexedDB` · `document.cookie` work, but they stay only in that browser and device and are not the learner's record: to keep progress, submit it (`useSubmit`); to keep content, save it from the edit screen.
6
6
  4. **Libraries and media go inside the zip.** Download libraries for charts, visualization or physics (for example Chart.js, D3, p5.js) into `vendor/` and load them by relative path instead of a CDN. Fonts, images and sounds also go in the zip. Limits: zip 20 MB, 300 files. Upload long videos separately as Elice video materials.
7
7
  - The content CSP (same as LXP) blocks every external image, font, video, CSS file, `<iframe src>`/`<object>`/`<embed>` and `fetch` (errors `ref.external-request` · `html.iframe`; an `<iframe>` filled with `srcdoc` for a code preview is fine). Fonts go in the zip as files or data URIs: external fonts (Google Fonts too) are blocked for now; they open once the server allowlist is settled.
@@ -55,17 +55,49 @@ app.useSave({ getContent: () => app.content, getGrading: () => grading.getGradin
55
55
 
56
56
  - Run simulations and animations with `requestAnimationFrame` and stop them while the view is hidden. Split heavy computation into small pieces.
57
57
 
58
+ ### Content editor (JSON)
59
+
60
+ Design the **content JSON shape first** (for example `{ title, intro, unit, items: [{ name, value, note }] }`); the student and instructor screens only read that shape from `app.content`. Then the edit screen does not need hand-written fields: the kit's content editor draws them from the shape.
61
+
62
+ ```js
63
+ import { start } from '../lib/elice-content.js';
64
+ import { useContentEditor } from '../lib/elice-content-editor.js';
65
+
66
+ const app = await start({ screen: 'edit' });
67
+ const schema = {
68
+ title: { label: '제목', required: true },
69
+ items: {
70
+ label: '항목',
71
+ min: 2,
72
+ max: 12,
73
+ item: {
74
+ name: { label: '이름', required: true },
75
+ value: { label: '값', type: 'number', required: true },
76
+ },
77
+ },
78
+ };
79
+ // initial: the sample the editor starts from while nothing is saved (there is still no default content file)
80
+ const editor = useContentEditor(app, { initial: sample, schema });
81
+ app.useSave({ getContent: editor.getContent, validate: editor.validate });
82
+ ```
83
+
84
+ - Two tabs. **폼 보기** (default) builds fields from the value: text → input (long text or `multiline` → textarea), number → number input, boolean → switch, `enum` → select, object → a group, list of text or numbers → rows, list of objects → cards. Lists add (a new item has the item shape with empty values), remove (a red ✕ on rows, trash on cards) with an undo notice (`.ec-notice` "항목을 삭제했습니다. 되돌리기", 6 s), reorder by dragging the `⠿` handle, the handle's ↑ · ↓ keys or the card's ↑ · ↓ buttons, and show "N개 이상이어야 합니다" at the minimum. **코드 보기** is the JSON text with colors, "정렬" (pretty print) and pasting; a syntax error shows line and column (`4줄 16칸: 쉼표(,)가 겹쳤습니다`), a schema error shows the path (`items[2].value: 숫자여야 합니다`). Going back to 폼 보기 applies the JSON only when it parses and has the right shape.
85
+ - Schema (optional, a plain object, name → field): `label` · `type` (`string` · `number` · `boolean` · `object` · `array`) · `required` · `min` · `max` (number range, or item count for a list) · `multiline` · `enum` · `hint` · `placeholder` · `item` (list item: one field, or name → field for objects) · `fields` (fields of a group). Without a schema the labels are the key names and the types come from `initial`, so a number in `initial` must stay a number.
86
+ - `validate` blocks the save: in 폼 보기 it shows the message under the field and focuses it (the save bar says `항목 3 › 값: 입력해 주세요`). Pass your own check as `useContentEditor(app, { validate: c => … || '…' })`. With the grader block add `getGrading` to `useSave` as above.
87
+ - Only the edit screen imports `lib/elice-content-editor.js`; `ecdk build` bundles code per screen, so the student screen does not carry it.
88
+ - Use the editor when the content is data (lists, numbers, short texts). Write a custom edit screen when editing needs its own UI (placing points on an image, a per-question answer UI like the quiz template). The content is visible to students: values the student screen reveals (like "정답 보기" of a self-check) may be in it, answers that are graded never are (`settings.grading`).
89
+
58
90
  ### UI patterns
59
91
 
60
92
  Build screens from the kit's classes in `lib/elice-content.css` (EDS values, both themes) so every material looks and behaves the same. The quiz template follows these patterns; copy its markup from `ui/templates/`.
61
93
 
62
- | Where | Pattern |
63
- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
- | Edit screen, a card for one item (question, step) | Title on the left, then a type `<select>` in regular weight. On the right, borderless icon buttons `button.ec-icon-button`: ↑ · ↓ · delete with a **trash** icon. Hide ↑ · ↓ when there is only one card. |
65
- | Edit screen, one row in a list (choice, group) | `⠿` drag handle → the answer control (radio or checkbox) → number → text input → remove with `button.ec-icon-button.ec-danger` (a red **circle with −**, no border). A wide answer control (a `<select>`) goes after the input instead. Disable remove at the minimum count. |
66
- | Student screen, an empty drop target | `.ec-dropzone`: a dashed box with an icon, a bold line `.ec-dropzone-title` (for example "보기를 여기로 끌어 놓으세요") and a hint `<p>` ("또는 보기를 누른 뒤 이곳을 눌러 주세요."). It also takes clicks, not only drops. |
67
- | Student screen, undo actions ("답안 초기화") | Show only when there is something to undo (for example at least one item placed), hide on read-only screens, and keep the row height fixed so nothing below jumps. Keep it away from the submit button. |
68
- | Any Korean text in a narrow box | `word-break: keep-all` so lines do not break inside a word. |
94
+ | Where | Pattern |
95
+ | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96
+ | Edit screen, a card for one item (question, step) | Title on the left, then a type `<select>` in regular weight. On the right, borderless icon buttons `button.ec-icon-button`: ↑ · ↓ · delete with a **trash** icon. Hide ↑ · ↓ when there is only one card. |
97
+ | Edit screen, one row in a list (choice, group) | `⠿` drag handle → the answer control (radio or checkbox) → number → text input → remove with `button.ec-icon-button.ec-danger` (a red **✕**, no border). A wide answer control (a `<select>`) goes after the input instead. Disable remove at the minimum count. |
98
+ | Student screen, an empty drop target | `.ec-dropzone`: a dashed box with an icon, a bold line `.ec-dropzone-title` (for example "보기를 여기로 끌어 놓으세요") and a hint `<p>` ("또는 보기를 누른 뒤 이곳을 눌러 주세요."). It also takes clicks, not only drops. |
99
+ | Student screen, undo actions ("답안 초기화") | Show only when there is something to undo (for example at least one item placed), hide on read-only screens, and keep the row height fixed so nothing below jumps. Keep it away from the submit button. |
100
+ | Any Korean text in a narrow box | `word-break: keep-all` so lines do not break inside a word. |
69
101
 
70
102
  Icon buttons always need `aria-label`. Icons are inline SVG with `stroke="currentColor"`, so color follows the button:
71
103
 
@@ -84,18 +116,17 @@ Icon buttons always need `aria-label`. Icons are inline SVG with `stroke="curren
84
116
  >
85
117
  <path d="M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3" />
86
118
  </svg>
87
- <!-- circle with − (remove one row) -->
119
+ <!-- ✕ (remove one row) -->
88
120
  <svg
89
121
  viewBox="0 0 24 24"
90
- width="22"
91
- height="22"
122
+ width="18"
123
+ height="18"
92
124
  fill="none"
93
125
  stroke="currentColor"
94
- stroke-width="1.5"
126
+ stroke-width="2"
95
127
  stroke-linecap="round"
96
128
  aria-hidden="true"
97
129
  >
98
- <circle cx="12" cy="12" r="9" />
99
- <path d="M8 12h8" />
130
+ <path d="M6 6l12 12M18 6L6 18" />
100
131
  </svg>
101
132
  ```
@@ -1,10 +1,10 @@
1
1
  # 7. Move existing HTML
2
2
 
3
3
  1. Create a skeleton with `ecdk create <new folder> --template blank`.
4
- 2. Move the original body, styles and scripts to the student screen (`index.html` · `screens/learn.js` · `styles.css`). Copy image, font and library folders as they are and use relative paths.
4
+ 2. Move the original body, styles and scripts to the student screen (`index.html` · `screens/learn.js` · `styles.css`). Copy image, font and library folders as they are and use relative paths. The build only keeps what HTML, CSS and `import` reach: files the code loads by a string path at run time (`fetch('data.json')`, `new Worker('w.js')`, a `<script src>` without `type="module"`) go in `public/` (`public/data.json` becomes `data.json` in the zip). A `<script src>` without `type="module"` outside `public/` fails with `ref.script-not-public`: add `type="module"` or move the file to `public/`.
5
5
  3. Download external CDN scripts, fonts, images, CSS and videos into the zip (fonts as files or data URIs, long videos as Elice video materials, no `<iframe>`). After `ecdk dev`, check the log for "막힌 외部 요청".
6
6
  4. Replace blocked code (storage, `alert`, external sends) as in [4](04-rules.md).
7
7
  5. Merge multiple HTML pages into one HTML that switches views.
8
8
  6. Decide submission and grading as in [2 ②](02-design-the-material.md). The completion policy is not written in the project: the instructor picks it in the LXP settings tab after the upload (suggest `on_access` when there is no submission).
9
9
  7. Turn off the instructor and edit screens in `metadata.json` `screens` (`{ "enabled": false }`) and delete their files when they are not needed.
10
- 8. An old ecdk project with `elice.config.json` or `lib/cdk.js` and no `@eliceio/cdk` in `package.json`: run `ecdk doctor --fix` (moves the settings to `metadata.json` and `package.json` `"ecdk"`, adds the SDK dependency), then `npm install`.
10
+ 8. An old ecdk project with `elice.config.json` or `lib/cdk.js` and no `@eliceio/cdk` in `package.json`: run `ecdk doctor --fix` (moves the settings to `metadata.json` and `package.json` `"ecdk"`, adds the SDK dependency), then `npm install`, replace `lib/elice-content.js` with the one from a new `ecdk create` project (it imports `@eliceio/cdk`) and delete `lib/cdk.js` (the zip never takes an SDK copy: `sdk.lib-copy` error).
@@ -2,26 +2,26 @@
2
2
 
3
3
  Read `check.issues[]` (`id` · `level` · `path` · `line` · `message`) from `ecdk build --json`. With an `error` no zip is made. Each `message` says how to fix it.
4
4
 
5
- | id | Fix |
6
- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
- | `ref.missing` · `ref.case-mismatch` | Match the path and case to the real file |
8
- | `ref.root-absolute` | Change `/…` to a relative path |
9
- | `ref.external-script` · `ref.external-request` · `ref.insecure` | Put the library, image, font or video in the zip and use a relative path (fonts: files or data URIs) |
10
- | `html.iframe` | Remove the `<iframe src>`/`<object>`/`<embed>` (an `<iframe>` with `srcdoc` for a code preview passes): upload video as an Elice video material, put other content in this HTML |
11
- | `ref.external-font` (warn) | A font from a host in `rules.json` `externalAllow` (empty for now): closed-network schools cannot reach it, so put a font that matters in the zip |
12
- | `ref.vendor-external-url` (warn) | A library file holds outside addresses: run `ecdk dev`, look for "막힌 외부 요청", put what it loads in the zip and set the library to a relative path |
13
- | `api.storage` · `api.cookie` (warn) | Browser storage and cookies stay only in that browser and device and are not the learner's record. Submit results; save content from the edit screen |
14
- | `api.dialog` · `api.window-open` · `html.form` | An in-page message · the same view · a button click + `useSubmit` |
15
- | `api.external-send` | Remove the external send |
16
- | `sec.html-injection` | Use `textContent`. If justified: escape + `ecdk-ignore` + the reason |
17
- | `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**) |
18
- | `manifest.completion-policies-ignored` (warn) | Remove the old `completionPolicies` and `screens.completionPolicy` from `metadata.json` (and the completion policy screen files). The instructor picks the policy in the LXP settings tab |
19
- | `grading.no-submit` (warn) | The edit screen saves the grading but nothing submits: add `useSubmit` to the student screen, or drop the grading block when the material is not graded |
20
- | `project.legacy-file` (warn, project only) | An old `elice.config.json` · `content.json` · `grading.json` is left: `ecdk doctor --fix` moves `elice.config.json`; re-enter the content and answers in the edit screen, then delete the other files |
21
- | `sdk.outdated` (error) | The SDK in the zip is older than the minimum (1.0.0-alpha.3 or older cannot save in the LXP edit screen - draft save fails): `npm update @eliceio/cdk` (an old `lib/cdk.js` copy: `ecdk doctor --fix && npm install`), then build again |
22
- | `sdk.lib-copy` (warn, project only) | An old `lib/cdk.js` copy and no `@eliceio/cdk` in `package.json`: `ecdk doctor --fix`, then `npm install` |
23
- | `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"` |
24
- | `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json` |
25
- | `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere") |
5
+ | id | Fix |
6
+ | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | `ref.missing` · `ref.case-mismatch` | Match the path and case to the real file |
8
+ | `ref.root-absolute` | Change `/…` to a relative path |
9
+ | `ref.external-script` · `ref.external-request` · `ref.insecure` | Put the library, image, font or video in the zip and use a relative path (fonts: files or data URIs) |
10
+ | `html.iframe` | Remove the `<iframe src>`/`<object>`/`<embed>` (an `<iframe>` with `srcdoc` for a code preview passes): upload video as an Elice video material, put other content in this HTML |
11
+ | `ref.external-font` (warn) | A font from a host in `rules.json` `externalAllow` (empty for now): closed-network schools cannot reach it, so put a font that matters in the zip |
12
+ | `ref.vendor-external-url` (warn) | A library file holds outside addresses: run `ecdk dev`, look for "막힌 외부 요청", put what it loads in the zip and set the library to a relative path |
13
+ | `api.storage` · `api.cookie` (warn) | Browser storage and cookies stay only in that browser and device and are not the learner's record. Submit results; save content from the edit screen |
14
+ | `api.dialog` · `api.window-open` · `html.form` | An in-page message · the same view · a button click + `useSubmit` |
15
+ | `api.external-send` | Remove the external send |
16
+ | `sec.html-injection` | Use `textContent`. If justified: escape + `ecdk-ignore` + the reason |
17
+ | `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**) |
18
+ | `manifest.completion-policies-ignored` (warn) | Remove the old `completionPolicies` and `screens.completionPolicy` from `metadata.json` (and the completion policy screen files). The instructor picks the policy in the LXP settings tab |
19
+ | `grading.no-submit` (warn) | The edit screen saves the grading but nothing submits: add `useSubmit` to the student screen, or drop the grading block when the material is not graded |
20
+ | `project.legacy-file` (warn, project only) | An old `elice.config.json` · `content.json` · `grading.json` is left: `ecdk doctor --fix` moves `elice.config.json`; re-enter the content and answers in the edit screen, then delete the other files |
21
+ | `sdk.outdated` (error) | The installed SDK bundled into the zip is older than the minimum (1.0.0-alpha.3 or older cannot save in the LXP edit screen - draft save fails): `npm update @eliceio/cdk`, then build again |
22
+ | `sdk.lib-copy` (error, project only) | An SDK copy `lib/cdk.js` in the project (never put in the zip): `ecdk doctor --fix`, `npm install`, replace the kit `lib/elice-content.js` with a new `ecdk create` one, delete `lib/cdk.js` |
23
+ | `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"` |
24
+ | `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json` |
25
+ | `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere") |
26
26
 
27
27
  Use `ecdk-ignore`, which turns a rule off, only for legitimate code a regular expression cannot tell apart, and **always with the reason**. Do not scatter it to silence errors.
@@ -4,5 +4,5 @@
4
4
  ecdk build --json
5
5
  ```
6
6
 
7
- - With `ok: true` the zip is `dist/content.zip`. To make it smaller, set `"minify": true` in `package.json` `"ecdk"` (quiz template about 122 KB → 87 KB).
7
+ - With `ok: true` the zip is `dist/content.zip`. The build minifies by default (comments do not reach learners' browsers, quiz template about 149 KB → 107 KB). Screen code, the kit and the SDK go into the HTML as one bundle, not as separate files. Besides the bundle the zip holds only `metadata.json`, the files it names (`commentary`) and the files in `public/` (as they are, at the zip root); a source file nothing bundles is left out, so put files loaded by a string path at run time in `public/`. Turn minifying off only to debug, with `"minify": false` in `package.json` `"ecdk"`.
8
8
  - Report to the user: what the material is (what the student does, which screens are on, how it completes), the zip path and size, **what to pick in the LXP settings tab** (the completion policy that fits, which the instructor picks there, the grading type, and where the answers are set), the upload steps (Custom HTML material in LXP → upload the zip → settings tab → save → check the student and instructor screens), and anything left to check. Saving makes the new version visible to learners at once, so the person approves it first (see [0. What the person decides](00-what-the-person-decides.md)).
@@ -1,6 +1,6 @@
1
1
  # 12. Upload with the material MCP
2
2
 
3
- The `elice-material` MCP server (elice-material backend) uploads a built zip to a LXP Custom page and saves it as a new version. Register it with `ecdk setup` (QA: `ecdk setup --only mcp --env qa5`) and log in once per tool (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`). Every page tool takes `org` (the organization's `name_short`, the subdomain of `https://{org}.elice.io`) and `lecture_page_id`.
3
+ The `elice-material` MCP server (elice-material backend) uploads a built zip to a LXP Custom page and saves it as a new version. Register it with `ecdk setup` (MCP only: `ecdk setup --only mcp`) and log in once per tool (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`). Every page tool takes `org` (the organization's `name_short`, the subdomain of `https://{org}.elice.io`) and `lecture_page_id`.
4
4
 
5
5
  **Confirm the target page.** Never upload to a page the person has not explicitly confirmed. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 (names and ids), and its LXP edit URL, then wait for an explicit yes. This holds every time: also when `.ecdk/link.json` exists and when the person gave a URL (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`. 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. Creating a page (`create_custom_page`) needs its own yes that names the 수업 it goes into.
6
6
 
@@ -22,7 +22,7 @@ The `elice-material` MCP server (elice-material backend) uploads a built zip to
22
22
  After a successful save, write `.ecdk/link.json` in the project (it is not put in the zip; add `.ecdk/` to `.gitignore`):
23
23
 
24
24
  ```json
25
- { "org": "trial-cdk-qa5", "lecture_page_id": 129, "version_id": "…" }
25
+ { "org": "my-school", "lecture_page_id": 129, "version_id": "…" }
26
26
  ```
27
27
 
28
28
  Next time, read it, confirm the page with the person as above (기관 · 과목 · 수업 · 페이지 and the URL), and compare `version_id` with `get_material`'s `current_version.id`: if they differ, someone saved in LXP since — tell the person before uploading.
@@ -11,7 +11,7 @@ Read guide topics with the Read tool from the sibling `elice-content-guide` skil
11
11
 
12
12
  ## Steps
13
13
 
14
- 1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp` (QA: `ecdk setup --only mcp --env qa5`) and log in (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`), then stop.
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
16
  3. **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, and its LXP edit URL, 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.
17
17
  4. **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.
@@ -17,7 +17,7 @@
17
17
  * - 시나리오: 주소에 ?mock=session_expired | rate_limited | request_failed | external_service_error
18
18
  * | slow | content_not_ready | unauthorized | draft_not_ready
19
19
  *
20
- * 실제 SDK: @eliceio/cdk 1.x (eliceio-cdk-v2 feat/PLAT-4973-monorepo) 기준
20
+ * 실제 SDK: @eliceio/cdk 1.x 기준
21
21
  */
22
22
 
23
23
  export const ErrorCode = Object.freeze({
@@ -125,7 +125,7 @@ export function normalizeGradingSettings(grading) {
125
125
  * elice-material 채점 흉내 (채점 방식 → 점수). 실제 서버처럼 요청 안에서 바로 채점한 `{ isCorrect, score }`만
126
126
  * 돌려준다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012): 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
127
127
  * - pattern: 정답 정규식(문자열 하나)이 답 문자열 전체와 맞으면 100, 아니면 0
128
- * - rubric: 바로 80점으로 흉내, 통과로 봄 (통과 기준 pass_threshold는 정해지지 않음, G136)
128
+ * - rubric: 바로 80점으로 흉내, 통과로 봄 (통과 기준 pass_threshold는 정해지지 않음)
129
129
  * - 채점 설정 없음: 점수 없음 `{ isCorrect: null, score: null }`
130
130
  * @param {object | null} grading settings.grading
131
131
  * @param {unknown} answer
@@ -0,0 +1,80 @@
1
+ // 편집기 자동완성용 타입. lib/elice-content-editor.js와 같이 고치지 않습니다.
2
+
3
+ export type ContentFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array';
4
+
5
+ /** 스키마 칸 하나 (JSON Schema를 줄인 것) */
6
+ export interface ContentField {
7
+ /** 칸 이름 (없으면 키) */
8
+ label?: string;
9
+ /** 종류 (없으면 견본 값에서) */
10
+ type?: ContentFieldType;
11
+ /** 비우면 저장을 막음 */
12
+ required?: boolean;
13
+ /** 숫자는 범위, 목록은 개수 */
14
+ min?: number;
15
+ max?: number;
16
+ /** 여러 줄 글 칸 */
17
+ multiline?: boolean;
18
+ /** 고르기 (select) */
19
+ enum?: Array<string | number | boolean>;
20
+ /** 칸 아래 도움말 */
21
+ hint?: string;
22
+ placeholder?: string;
23
+ /** 목록 항목 모양 (칸 하나 또는 이름 → 칸 묶음) */
24
+ item?: ContentField | ContentSchema;
25
+ /** 묶음 안 칸들 (이름 → 칸) */
26
+ fields?: ContentSchema;
27
+ }
28
+
29
+ /** 이름 → 칸 */
30
+ export type ContentSchema = Record<string, ContentField>;
31
+
32
+ export interface ContentEditorOptions<C> {
33
+ /** 저장한 내용이 없을 때 시작할 견본 (정답 넣지 않음) */
34
+ initial?: C;
35
+ schema?: ContentSchema;
36
+ /** 스키마 검사 다음에 할 검사. 통과면 true, 아니면 보여 줄 문장 */
37
+ validate?: (content: C) => true | string | false;
38
+ /** 편집기를 그릴 곳 (기본 #app, 안을 비움) */
39
+ root?: Element;
40
+ }
41
+
42
+ export interface ContentEditor<C> {
43
+ element: Element;
44
+ readonly view: 'form' | 'code';
45
+ /** 보기 바꾸기. 코드 → 폼은 JSON이 올바를 때만 (아니면 false) */
46
+ showView(view: 'form' | 'code'): boolean;
47
+ /** useSave getContent에 넘김 */
48
+ getContent(): C;
49
+ setContent(content: C): void;
50
+ /** useSave validate에 넘김: 코드 JSON 오류(줄 · 칸) → 스키마(경로) → options.validate */
51
+ validate(content?: C): true | string;
52
+ }
53
+
54
+ /** 편집 화면의 JSON 내용 편집기 (폼 보기 · 코드 보기). app은 start({ screen: 'edit' })가 준 것 */
55
+ export declare function useContentEditor<C = Record<string, unknown>>(
56
+ app: { screen: string; hasContent: boolean; content: unknown },
57
+ options?: ContentEditorOptions<C>
58
+ ): ContentEditor<C>;
59
+
60
+ export declare const UNDO_MS: number;
61
+ export declare function typeOf(value: unknown): ContentFieldType | undefined;
62
+ export declare function asNode(schema: unknown): ContentField;
63
+ export declare function inferSchema(value: unknown): ContentField;
64
+ export declare function mergeSchema(user: unknown, inferred: unknown): ContentField;
65
+ export declare function emptyValue(field: unknown): unknown;
66
+ export declare function joinPath(base: string, key: string | number): string;
67
+ export declare function validateContent(
68
+ value: unknown,
69
+ schema: unknown,
70
+ path?: string
71
+ ): { path: string; message: string; kind: 'type' | 'rule' }[];
72
+ export declare function labelPath(schema: unknown, path: string): string;
73
+ export declare function parseJson(
74
+ text: string
75
+ ):
76
+ | { ok: true; value: unknown }
77
+ | { ok: false; index: number; line: number; column: number; message: string };
78
+ export declare function lineColumn(text: string, index: number): { line: number; column: number };
79
+ export declare function highlightJson(text: string, errorAt?: number): DocumentFragment;
80
+ export declare function moveItem(list: unknown[], from: number, to: number): boolean;