@eliceio/cdk-cli 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/es/commands/create/index.js +1 -0
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/commands/doctor/index.js +19 -2
- package/es/core/sandbox.d.ts +5 -0
- package/es/core/sandbox.js +19 -1
- package/es/engines/vite/plugin.js +7 -1
- package/es/rules/check.js +19 -2
- package/es/rules/grading.d.ts +25 -0
- package/es/rules/grading.js +131 -0
- package/es/rules/privacy.d.ts +2 -0
- package/es/rules/privacy.js +1 -1
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +13 -1
- package/skills/_shared/references/02-design-the-material.md +1 -0
- package/skills/_shared/references/03-create-the-project.md +9 -9
- package/skills/_shared/references/05-screen-code.md +26 -0
- package/skills/_shared/references/06-using-the-quiz-template.md +8 -5
- package/skills/_shared/references/08-fix-check-errors.md +4 -2
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +17 -1
- package/skills/_shared/references/13-edit-screen-design.md +1 -1
- package/skills/elice-content-create/SKILL.md +1 -1
- package/skills/elice-content-edit/SKILL.md +1 -1
- package/skills/elice-content-publish/SKILL.md +2 -2
- package/templates/_shared/lib/elice-content.d.ts +45 -0
- package/templates/_shared/lib/elice-content.js +133 -5
- package/templates/document/core/load.d.ts +1 -0
- package/templates/document/core/load.js +29 -2
- package/templates/document/core/pdf.d.ts +1 -0
- package/templates/document/core/pdf.js +5 -0
- package/templates/document/screens/edit.js +6 -3
- package/templates/document/screens/learn.js +3 -1
- package/templates/document/template.json +1 -1
- package/templates/video/README.md +68 -0
- package/templates/video/commentary.txt +2 -0
- package/templates/video/core/dom.d.ts +13 -0
- package/templates/video/core/dom.js +83 -0
- package/templates/video/core/settings.d.ts +19 -0
- package/templates/video/core/settings.js +52 -0
- package/templates/video/edit.html +17 -0
- package/templates/video/gitignore +4 -0
- package/templates/video/index.html +17 -0
- package/templates/video/metadata.json +9 -0
- package/templates/video/package.json +13 -0
- package/templates/video/screens/edit.js +69 -0
- package/templates/video/screens/learn.js +46 -0
- package/templates/video/styles.css +112 -0
- package/templates/video/template.json +6 -0
- package/templates/video/ui/templates/edit.js +26 -0
- package/templates/video/ui/templates/player.js +51 -0
- package/templates/video/ui/texts.d.ts +3 -0
- package/templates/video/ui/texts.js +50 -0
- package/templates/video/ui/theme.css +14 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// 문서 불러오기 (고치지 않습니다): 저장된 주소에서 파일 바이트를 받고, 종류에 맞는 그리기 모듈로 엽니다.
|
|
2
2
|
// PDF · PPTX 모듈은 필요할 때만 불러온다 (import()): 둘 다 묶여 들어가지만 쓰지 않는 쪽은 실행하지 않는다.
|
|
3
|
+
// 화면은 문서 종류를 알면 preloadViewer로 미리 부르고, openDocument는 PPTX 파일 받기와 모듈 불러오기를 같이 한다 (차례로 기다리지 않게).
|
|
3
4
|
|
|
4
5
|
/** 파일을 받지 못함 (주소 · 권한 · 콘텐츠 CSP connect-src) */
|
|
5
6
|
export class FetchError extends Error {
|
|
@@ -28,13 +29,39 @@ export async function fetchBytes(url, fetchImpl = globalThis.fetch) {
|
|
|
28
29
|
return new Uint8Array(await res.arrayBuffer());
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/** @type {Partial<Record<'pdf' | 'pptx', Promise<any>>>} 불러오는 중이거나 불러온 그리기 모듈 (실패하면 지워 다음에 다시 시도) */
|
|
33
|
+
const viewers = {};
|
|
34
|
+
|
|
35
|
+
/** @param {'pdf' | 'pptx'} kind */
|
|
36
|
+
function viewerModule(kind) {
|
|
37
|
+
viewers[kind] ??= (kind === 'pdf' ? import('./pdf.js') : import('./pptx-view.js')).catch((e) => {
|
|
38
|
+
delete viewers[kind];
|
|
39
|
+
throw e;
|
|
40
|
+
});
|
|
41
|
+
return viewers[kind];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 그리기 모듈을 미리 불러 둔다 (문서 종류를 안 순간, 주소를 받기 전에). PDF는 pdf.js 작업자도 미리 띄운다.
|
|
46
|
+
* 실패는 여기서 삼킨다: openDocument가 다시 불러 그 오류를 낸다. 문서가 없으면 부르지 않는다 (그리기 코드를 받지 않게)
|
|
47
|
+
* @param {'pdf' | 'pptx'} kind
|
|
48
|
+
*/
|
|
49
|
+
export function preloadViewer(kind) {
|
|
50
|
+
viewerModule(kind)
|
|
51
|
+
.then((m) => m.preparePdf?.())
|
|
52
|
+
.catch(() => undefined);
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
/**
|
|
32
56
|
* @param {'pdf' | 'pptx'} kind
|
|
33
57
|
* @param {Uint8Array | string} source 바이트, 또는 주소 (PDF는 pdf.js가 Range로 필요한 부분만 받음, PPTX는 전체를 받음)
|
|
34
58
|
* @param {{ prefetch?: boolean }} [opts] PDF 주소: 첫 쪽 뒤 나머지를 미리 받기 (편집 화면, core/pdf-options.js)
|
|
35
59
|
*/
|
|
36
60
|
export async function openDocument(kind, source, opts) {
|
|
37
|
-
|
|
61
|
+
const viewer = viewerModule(kind);
|
|
62
|
+
if (kind === 'pdf') return (await viewer).openPdf(source, opts);
|
|
63
|
+
// PPTX: 파일 받기와 그리기 모듈 불러오기를 같이 한다. 둘 다 실패하면 받기 오류(FetchError)를 먼저 낸다
|
|
64
|
+
viewer.catch(() => undefined);
|
|
38
65
|
const bytes = typeof source === 'string' ? await fetchBytes(source) : source;
|
|
39
|
-
return (await
|
|
66
|
+
return (await viewer).openPptx(bytes);
|
|
40
67
|
}
|
|
@@ -71,6 +71,11 @@ function ensureWorker() {
|
|
|
71
71
|
return worker;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** 작업자를 미리 띄운다 (core/load.js preloadViewer). 실패해도 openPdf가 다시 시도하고 그 오류를 낸다 */
|
|
75
|
+
export function preparePdf() {
|
|
76
|
+
return ensureWorker().catch(() => undefined);
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
/** PDF를 여는(첫 응답 · 쪽 크기) 데 이 시간보다 오래 걸리면 멈춘 것으로 보고 오류 */
|
|
75
80
|
const OPEN_TIMEOUT_MS = 30000;
|
|
76
81
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
DOCUMENT_MIME,
|
|
18
18
|
SNIFF_BYTES,
|
|
19
19
|
} from '../core/file-type.js';
|
|
20
|
-
import { fetchBytes, openDocument } from '../core/load.js';
|
|
20
|
+
import { fetchBytes, openDocument, preloadViewer } from '../core/load.js';
|
|
21
21
|
import {
|
|
22
22
|
formatBytes,
|
|
23
23
|
MAX_DOCUMENT_BYTES,
|
|
@@ -371,8 +371,9 @@ function showDocument(doc, startAt) {
|
|
|
371
371
|
state.refit = () => {
|
|
372
372
|
if (state.view === view && pageMaxHeight(view) !== fit) void state.viewer.refresh();
|
|
373
373
|
};
|
|
374
|
-
// 쪽 목록은 큰
|
|
375
|
-
|
|
374
|
+
// 쪽 목록은 큰 쪽(첫 쪽)을 다 그린 뒤 브라우저가 한가할 때 (긴 문서에서 첫 화면이 늦지 않게)
|
|
375
|
+
state.viewer.ready
|
|
376
|
+
.then(() => afterIdle(() => doc.thumbnails(120)))
|
|
376
377
|
.then(images => {
|
|
377
378
|
if (state.doc !== doc) return;
|
|
378
379
|
state.thumbs = images;
|
|
@@ -534,6 +535,8 @@ async function getContent() {
|
|
|
534
535
|
// ---------- 처음 그리기: 저장된 문서가 있으면 받아서 연다 ----------
|
|
535
536
|
// 함수 안에서 연다: 모듈 맨 위(top-level await)에서 받은 바이트 · 문서는 다른 파일로 바꾼 뒤에도 놓이지 않았다
|
|
536
537
|
async function openSaved() {
|
|
538
|
+
// 그리기 모듈은 주소 · 파일을 받는 동안 미리 불러 둔다
|
|
539
|
+
preloadViewer(draft.document.type);
|
|
537
540
|
// 문서를 받는 동안: 글 없이 16:9 미리보기 자리만 (문구는 화면 읽기 프로그램에만)
|
|
538
541
|
previewArea.replaceChildren(loading('edit', { label: tv.loading, parts: ['media'] }));
|
|
539
542
|
// 받는 동안 다른 파일을 골라 보이면 그 파일을 둔다 (늦게 끝난 이 문서는 버림). 고른 파일을 열지 못했으면 이 문서를 보인다
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 완료 정책은 LXP 설정 '열람 시 학습 완료'(on_access)라 이 화면은 제출하지 않습니다 (LXP가 열면 완료로 기록).
|
|
3
3
|
// 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
|
|
4
4
|
import { start } from '../lib/elice-content.js';
|
|
5
|
-
import { FetchError, openDocument } from '../core/load.js';
|
|
5
|
+
import { FetchError, openDocument, preloadViewer } from '../core/load.js';
|
|
6
6
|
import { isExpiredSource } from '../core/pdf-options.js';
|
|
7
7
|
import { normalizeSettings } from '../core/settings.js';
|
|
8
8
|
import { part } from '../core/dom.js';
|
|
@@ -32,6 +32,8 @@ function isLoadError(e) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async function show(file) {
|
|
35
|
+
// 그리기 모듈(PPTX 1.4MB · pdf.js)은 주소를 받는 동안 미리 불러 둔다
|
|
36
|
+
preloadViewer(file.type);
|
|
35
37
|
// 문서를 받는 동안: 글 없이 화면 가득 빛이 지나가는 자리 (문구는 화면 읽기 프로그램에만)
|
|
36
38
|
root.replaceChildren(loading('learn', { label: t.loading }));
|
|
37
39
|
// 서명된 asset 주소 = 버전의 asset_base_url + 파일 키 asset_key(assets/{자료 id}/…) (SDK assets.get이 만듦). PDF는 pdf.js가 Range로 필요한 부분만 받는다
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
Elice Custom HTML 학습자료 프로젝트입니다 (영상 템플릿). 영상 한 편을 보여 주고, 학생이 끝까지 보면 한 번 자동으로 제출합니다.
|
|
4
|
+
|
|
5
|
+
동영상 올리기 · 진행률 · 인코딩 대기 · 재생은 **Elice 비디오 플레이어**(`embed.js`의 `<elice-video-upload>` · `<elice-video>`)가 맡습니다. 이 템플릿은 태그를 놓고, 플레이어 이벤트로 저장할 영상 id와 제출만 다룹니다.
|
|
6
|
+
|
|
7
|
+
## 고치는 곳
|
|
8
|
+
|
|
9
|
+
| 파일 | 화면 |
|
|
10
|
+
| --------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
11
|
+
| `screens/learn.js` · `index.html` | 학생 화면 (`<elice-video>` 화면 가득 · 자동 제출) |
|
|
12
|
+
| `screens/edit.js` · `edit.html` | 내용 편집 화면 (`<elice-video-upload>` · ⓘ 안내 · '초안으로 저장'). 키트 편집 화면(`body.ec-edit-page`) |
|
|
13
|
+
| `ui/` | 모양: 색 · 문구 · 마크업 (`theme.css` · `texts.js` · `templates/`) |
|
|
14
|
+
| `styles.css` | 플레이어 태그의 크기 · 모서리, 플레이어를 띄울 수 없을 때 안내 |
|
|
15
|
+
| `core/settings.js` | 저장 모양과 검증 (고치지 않음) |
|
|
16
|
+
| `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
|
|
17
|
+
| `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"`. zip에 들어가지 않음 |
|
|
18
|
+
|
|
19
|
+
플레이어 안(재생 컨트롤 · 화질 · 재생 속도 · 올리기 칸과 받는 형식 · 최대 크기 안내 · 진행률 · 취소 · 인코딩 중 · '다른 파일로 변경' · 오류 문구)은 플레이어의 iframe이라 이 프로젝트에서 바꿀 수 없습니다. 바꿀 수 있는 것은 태그의 크기 · 모서리(`styles.css`)와 태그 밖 화면입니다. 올리기 태그의 높이는 플레이어가 상태(빈 칸 · 올리는 중 · 미리보기)마다 맞춥니다.
|
|
20
|
+
|
|
21
|
+
## 플레이어 쓰는 법 (키트 `app.videoPlayer`)
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
await app.videoPlayer.load(); // SDK loadScript(sdk.videoPlayerUrl, 'EliceVideoPlayer')
|
|
25
|
+
app.videoPlayer.connect(element, { resourceId }); // material-id · resource-id · token(sdk.accessToken), 토큰이 바뀌면(sdk.onAccessTokenChange) 다시 넣음
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| 태그 | 이벤트 (버블링하지 않음, 태그에 직접) | 이 템플릿이 하는 일 |
|
|
29
|
+
| ---------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
30
|
+
| `<elice-video-upload>` | `progress`(`detail.percent`) · `complete`(`detail.resourceId`) · `cancel` · `error`(`detail.code`) | 올리는 중엔 저장을 막고, `complete`면 `settings.video.resource_id`를 바꾸고 '저장하지 않은 변경' 표시 |
|
|
31
|
+
| `<elice-video>` | `ready` · `ended` · `error`(`detail.code`) | `ended`면 한 번 자동 제출 |
|
|
32
|
+
|
|
33
|
+
- `sdk.videoPlayerUrl`은 플랫폼이 화면 주소 fragment(`videoPlayerUrl`)로 넘깁니다. 넘기지 않으면(ecdk dev, 아직 반영 전 LXP) 영상 자리에 "동영상을 불러올 수 없습니다"가 보입니다.
|
|
34
|
+
- `embed.js`는 zip에 넣지 않습니다 (플랫폼 환경마다 주소가 다름).
|
|
35
|
+
|
|
36
|
+
## 학습 완료
|
|
37
|
+
|
|
38
|
+
- `settings.completion.mode`: `'ended'`(기본, 끝까지 보면 제출) · `'open'`(학생 화면을 열면 바로 제출). 편집 화면에는 고르는 곳이 없습니다 (V3 내용 편집 화면에 없음).
|
|
39
|
+
- **N% 시청은 지금 없습니다**: 플레이어가 재생 위치 · 시청 비율 이벤트를 주지 않습니다 (`ready` · `ended` · `error`뿐). 옛 영상 템플릿(1.x)의 `mode: 'watch'`는 `'ended'`로 읽습니다.
|
|
40
|
+
- 끝(`ended`)은 학생 브라우저가 알립니다. 서버는 제출만 받고 실제로 봤는지 확인하지 않으며, 재생 막대로 끝까지 건너뛰어도 `ended`가 옵니다. 출결 · 이수 증빙이 필요한 과정에는 Elice 비디오 자료를 쓰세요.
|
|
41
|
+
- 제출 답은 `{ completedBy: 'ended' | 'open' }`(기록용), 채점은 없습니다 (`settings.grading` 없음). 다시 열었을 때 이미 낸 제출이 있으면 다시 내지 않고, 튜터링(보기 전용)은 제출하지 않습니다 (키트 `app.useAutoSubmit`).
|
|
42
|
+
- 완료 정책은 LXP 페이지 설정입니다: publish 스킬이 동의를 받아 업로드 때 정하거나 교육자가 LXP 편집 페이지 위쪽 '설정' 패널에서 **제출 시 학습 완료(on_submit)**로 골라야 이 기준이 학습 완료가 됩니다.
|
|
43
|
+
|
|
44
|
+
## 저장 모양 (`settings`)
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
{
|
|
48
|
+
video: { resource_id: '…' }, // <elice-video-upload> complete의 detail.resourceId
|
|
49
|
+
completion: { mode: 'ended' }, // 'ended' · 'open'
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **인코딩 중 저장**: 올리기가 끝나면(`complete`) 인코딩 중이어도 저장할 수 있습니다. 인코딩이 끝나면 플레이어가 알아서 재생합니다.
|
|
54
|
+
- 다른 키(예: AI · MCP가 넣은 `title`)는 저장 때 그대로 둡니다. 학생에게도 내려가므로 비밀 값을 넣지 않습니다.
|
|
55
|
+
- `ecdk dev`의 내용 편집에서 저장한 것은 `.ecdk/settings.json`에 남습니다 (zip에는 들어가지 않음). 기본으로는 로컬에만 있고, publish 스킬로 올릴 때 동의하면 업로드와 함께 보냅니다.
|
|
56
|
+
- 영상이 없으면 학생 화면은 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
|
|
57
|
+
|
|
58
|
+
교육자 화면은 없습니다 (`metadata.json` `screens.instructor.enabled: false`). LXP에서 교육자가 열면 학생 화면이 열리고, 교육자의 제출은 기록되지 않습니다.
|
|
59
|
+
|
|
60
|
+
`lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK는 `package.json` 의존성(`@eliceio/cdk`)이고 키트가 import하며, `ecdk build`(Vite)가 화면 코드와 함께 번들로 묶습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`).
|
|
61
|
+
|
|
62
|
+
## 명령
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
ecdk dev # 로컬에서 보기 (플레이어 주소가 없어 영상 자리는 안내만)
|
|
66
|
+
ecdk doctor # 환경·프로젝트 점검
|
|
67
|
+
ecdk build # 검사 후 dist/content.zip (편집 화면에 올릴 파일)
|
|
68
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// core/dom.js 타입 (편집기 자동완성 · 테스트용)
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
export declare const present: (nodes: any[]) => any[];
|
|
4
|
+
export declare function el(
|
|
5
|
+
tag: string,
|
|
6
|
+
props?: Record<string, unknown>,
|
|
7
|
+
...children: any[]
|
|
8
|
+
): HTMLElement;
|
|
9
|
+
/** 최상위 요소가 하나면 그 요소(HTMLElement로 다룸), 아니면 DocumentFragment */
|
|
10
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): any;
|
|
11
|
+
export declare function part(root: Element, name: string): HTMLElement | null;
|
|
12
|
+
export declare function parts(root: Element, name: string): HTMLElement[];
|
|
13
|
+
export declare function lock<T extends Element>(root: T): T;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// 작은 DOM 도우미 (퀴즈 템플릿 core/dom.js와 같음). ui/templates/*는 html`…`로 마크업을 쓰고, 동작은 data-role로 그 안의 요소를 찾습니다.
|
|
2
|
+
|
|
3
|
+
/** 조건부로 넣은 null · undefined · false 빼기 */
|
|
4
|
+
export const present = (nodes) => nodes.filter((c) => c !== null && c !== undefined && c !== false);
|
|
5
|
+
|
|
6
|
+
export function el(tag, props = {}, ...children) {
|
|
7
|
+
const node = Object.assign(document.createElement(tag), props);
|
|
8
|
+
node.append(...present(children));
|
|
9
|
+
return node;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const escape = (s) =>
|
|
13
|
+
s
|
|
14
|
+
.replace(/&/g, '&')
|
|
15
|
+
.replace(/</g, '<')
|
|
16
|
+
.replace(/>/g, '>')
|
|
17
|
+
.replace(/"/g, '"')
|
|
18
|
+
.replace(/'/g, ''');
|
|
19
|
+
|
|
20
|
+
const MARK = 'vd-node:';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* HTML 조각 템플릿. 끼워 넣는 값은
|
|
24
|
+
* 글자 · 숫자 → 이스케이프해서 글자로 (교육자 · 학생이 쓴 내용도 안전)
|
|
25
|
+
* 요소(Node) · 배열 → 그 자리에 그대로 (태그 사이에만, 속성 값에는 글자만)
|
|
26
|
+
* null · undefined · false → 아무것도 넣지 않음 (`${cond && '…'}`)
|
|
27
|
+
* 줄바꿈이 든 앞뒤 공백은 지우므로 들여쓰기를 자유롭게 해도 됩니다 (한 줄 안의 공백은 그대로).
|
|
28
|
+
* 최상위 요소가 하나면 그 요소를, 아니면 DocumentFragment를 돌려준다.
|
|
29
|
+
*/
|
|
30
|
+
export function html(strings, ...values) {
|
|
31
|
+
const nodes = [];
|
|
32
|
+
const part = (v) => {
|
|
33
|
+
if (v === null || v === undefined || v === false) return '';
|
|
34
|
+
if (Array.isArray(v)) return v.map(part).join('');
|
|
35
|
+
if (typeof Node !== 'undefined' && v instanceof Node) {
|
|
36
|
+
nodes.push(v);
|
|
37
|
+
return `<!--${MARK}${nodes.length - 1}-->`;
|
|
38
|
+
}
|
|
39
|
+
return escape(String(v));
|
|
40
|
+
};
|
|
41
|
+
const markup = strings.reduce((out, s, i) => out + part(values[i - 1]) + s);
|
|
42
|
+
const template = document.createElement('template');
|
|
43
|
+
// 끼워 넣는 값은 모두 위에서 이스케이프하거나 주석 자리표로 바꾼다 (퀴즈 quiz.test.ts 'html 템플릿'에서 확인)
|
|
44
|
+
// ecdk-ignore-next-line sec.html-injection
|
|
45
|
+
template.innerHTML = markup.trim();
|
|
46
|
+
const walker = document.createTreeWalker(
|
|
47
|
+
template.content,
|
|
48
|
+
NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT,
|
|
49
|
+
);
|
|
50
|
+
const swap = [];
|
|
51
|
+
for (let n = walker.nextNode(); n; n = walker.nextNode()) swap.push(n);
|
|
52
|
+
for (const n of swap) {
|
|
53
|
+
if (n.nodeType === Node.COMMENT_NODE && n.data.startsWith(MARK))
|
|
54
|
+
n.replaceWith(nodes[Number(n.data.slice(MARK.length))]);
|
|
55
|
+
else if (n.nodeType === Node.TEXT_NODE) {
|
|
56
|
+
// 들여쓰기: 줄바꿈이 든 앞뒤 공백은 지우고, 그것만 있는 글자 노드는 뺀다 (JSX와 같은 규칙)
|
|
57
|
+
const data = n.data.replace(/^\s*\n\s*/, '').replace(/\s*\n\s*$/, '');
|
|
58
|
+
if (data === '') n.remove();
|
|
59
|
+
else if (data !== n.data) n.data = data;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const fragment = template.content;
|
|
63
|
+
return fragment.childNodes.length === 1 && fragment.firstChild instanceof Element
|
|
64
|
+
? fragment.firstChild
|
|
65
|
+
: fragment;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** root 자신이나 그 안에서 data-role="name"인 첫 요소 */
|
|
69
|
+
export function part(root, name) {
|
|
70
|
+
const selector = `[data-role="${name}"]`;
|
|
71
|
+
return root.matches?.(selector) ? root : root.querySelector(selector);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** root 안의 data-role="name"인 모든 요소 */
|
|
75
|
+
export const parts = (root, name) => [...root.querySelectorAll(`[data-role="${name}"]`)];
|
|
76
|
+
|
|
77
|
+
/** 읽기 전용(교육자 · 튜터링)일 때 root와 그 안의 입력 · 버튼을 모두 막는다 */
|
|
78
|
+
export function lock(root) {
|
|
79
|
+
if ('disabled' in root) root.disabled = true;
|
|
80
|
+
for (const c of root.querySelectorAll('input, textarea, select, button, fieldset'))
|
|
81
|
+
c.disabled = true;
|
|
82
|
+
return root;
|
|
83
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// core/settings.js 타입 (편집기 자동완성 · 테스트용)
|
|
2
|
+
export type CompletionMode = 'ended' | 'open';
|
|
3
|
+
|
|
4
|
+
export interface VideoDraft {
|
|
5
|
+
rest: Record<string, unknown>;
|
|
6
|
+
video: { resource_id: string } | null;
|
|
7
|
+
completion: { mode: CompletionMode };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare const COMPLETION_MODES: readonly CompletionMode[];
|
|
11
|
+
export declare function normalizeSettings(
|
|
12
|
+
raw: Record<string, unknown> | null | undefined
|
|
13
|
+
): VideoDraft;
|
|
14
|
+
export declare function toSettings(draft: VideoDraft): Record<string, unknown>;
|
|
15
|
+
export declare function validateSettings(
|
|
16
|
+
draft: Pick<VideoDraft, 'video'>,
|
|
17
|
+
messages: { videoRequired: string; uploading: string },
|
|
18
|
+
state?: { uploading?: boolean }
|
|
19
|
+
): true | string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// 저장 모양(settings)과 검증. 편집 화면이 저장하고 학생 화면이 읽습니다. 고치지 않습니다: 키 이름을 바꾸면 저장한 자료를 읽지 못합니다.
|
|
2
|
+
//
|
|
3
|
+
// {
|
|
4
|
+
// video: { resource_id: '…' }, // Elice 비디오 플레이어가 올린 영상 id (<elice-video-upload> complete의 detail.resourceId)
|
|
5
|
+
// completion: { mode: 'ended' }, // 'ended' 끝까지 보면 제출(기본) · 'open' 열면 바로 제출
|
|
6
|
+
// }
|
|
7
|
+
// 그 밖의 키(예: AI · MCP가 넣은 title)는 저장 때 그대로 둡니다. 학생에게도 내려가므로 비밀 값을 넣지 않습니다.
|
|
8
|
+
|
|
9
|
+
/** 학습 완료 기준: 플레이어가 알려 주는 것은 ready · ended · error뿐이라 'ended'(끝까지 봄)와 'open'(열람)만 */
|
|
10
|
+
export const COMPLETION_MODES = Object.freeze(['ended', 'open']);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 저장된 settings를 화면이 쓰는 모양으로. 모르는 값은 기본값.
|
|
14
|
+
* 옛 영상 템플릿(1.x)의 completion.mode 'watch'(N% 시청)는 플레이어가 시청 비율을 알려 주지 않아 'ended'로 읽는다
|
|
15
|
+
* @param {Record<string, unknown> | null | undefined} raw
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeSettings(raw) {
|
|
18
|
+
const s = raw && typeof raw === 'object' ? raw : {};
|
|
19
|
+
const v = s.video && typeof s.video === 'object' ? s.video : null;
|
|
20
|
+
const resourceId = v && typeof v.resource_id === 'string' && v.resource_id ? v.resource_id : null;
|
|
21
|
+
const mode = s.completion && typeof s.completion === 'object' ? s.completion.mode : undefined;
|
|
22
|
+
return {
|
|
23
|
+
/** 저장 때 그대로 둘 다른 키 */
|
|
24
|
+
rest: Object.fromEntries(
|
|
25
|
+
Object.entries(s).filter(([k]) => k !== 'video' && k !== 'completion')
|
|
26
|
+
),
|
|
27
|
+
video: resourceId ? { resource_id: resourceId } : null,
|
|
28
|
+
completion: { mode: COMPLETION_MODES.includes(mode) ? mode : 'ended' },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 화면 상태를 저장 모양으로 */
|
|
33
|
+
export function toSettings(draft) {
|
|
34
|
+
return {
|
|
35
|
+
...draft.rest,
|
|
36
|
+
...(draft.video ? { video: { resource_id: draft.video.resource_id } } : {}),
|
|
37
|
+
completion: { mode: draft.completion.mode },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 저장 전 검증. 통과면 true, 아니면 화면에 보일 문구.
|
|
43
|
+
* 인코딩 중에도 저장할 수 있다 (사용자 결정): 올리기가 끝나(complete) 영상 id가 있으면 된다
|
|
44
|
+
* @param {{ video: { resource_id: string } | null }} draft
|
|
45
|
+
* @param {{ videoRequired: string, uploading: string }} messages
|
|
46
|
+
* @param {{ uploading?: boolean }} [state]
|
|
47
|
+
*/
|
|
48
|
+
export function validateSettings(draft, messages, { uploading = false } = {}) {
|
|
49
|
+
if (uploading) return messages.uploading;
|
|
50
|
+
if (!draft.video) return messages.videoRequired;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="ko">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<!-- 제목 · "불러오는 중" 문구는 ui/texts.js(page)에서 고칩니다. 여기 글은 스크립트가 돌기 전에만 보입니다 -->
|
|
7
|
+
<title>내용 편집</title>
|
|
8
|
+
<link rel="stylesheet" href="lib/elice-tokens.css" />
|
|
9
|
+
<link rel="stylesheet" href="lib/elice-content.css" />
|
|
10
|
+
<link rel="stylesheet" href="ui/theme.css" />
|
|
11
|
+
<link rel="stylesheet" href="styles.css" />
|
|
12
|
+
<script type="module" src="screens/edit.js"></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body class="ec-edit-page">
|
|
15
|
+
<main id="app"><div class="ec-sk ec-sk-edit" role="status"><span class="ec-visually-hidden">불러오는 중…</span><div class="ec-sk-bar ec-sk-shimmer"></div><div class="ec-sk-media ec-sk-shimmer"></div></div></main>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="ko">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<!-- 제목 · "불러오는 중" 문구는 ui/texts.js(page)에서 고칩니다. 여기 글은 스크립트가 돌기 전에만 보입니다 -->
|
|
7
|
+
<title>학생 화면</title>
|
|
8
|
+
<link rel="stylesheet" href="lib/elice-tokens.css" />
|
|
9
|
+
<link rel="stylesheet" href="lib/elice-content.css" />
|
|
10
|
+
<link rel="stylesheet" href="ui/theme.css" />
|
|
11
|
+
<link rel="stylesheet" href="styles.css" />
|
|
12
|
+
<script type="module" src="screens/learn.js"></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<main id="app"><div class="ec-sk ec-sk-learn ec-sk-shimmer" role="status"><span class="ec-visually-hidden">불러오는 중…</span></div></main>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// 내용 편집 화면 (디자인 V3 "내용 편집"). 영상 한 편을 올립니다.
|
|
2
|
+
// 올리기 · 진행률 · 취소 · 미리보기 · 인코딩 중 · '동영상 교체'는 Elice 비디오 플레이어(<elice-video-upload>, embed.js)가 맡고,
|
|
3
|
+
// 이 화면은 태그를 놓고 이벤트로 저장할 내용만 바꿉니다:
|
|
4
|
+
// progress → 올리는 중(저장 막음) · complete(detail.resourceId) → settings.video.resource_id · cancel · error → 올리는 중 끝
|
|
5
|
+
// 인코딩 중에도 저장할 수 있습니다 (complete는 올리기가 끝나면 바로 오고, 인코딩은 그 뒤 플레이어가 기다림).
|
|
6
|
+
// 저장 버튼('초안으로 저장') · 변경 표시는 키트(useSave)가 합니다. 모양은 ui/(templates · texts · theme.css).
|
|
7
|
+
import { infoList, start } from '../lib/elice-content.js';
|
|
8
|
+
import { part } from '../core/dom.js';
|
|
9
|
+
import { normalizeSettings, toSettings, validateSettings } from '../core/settings.js';
|
|
10
|
+
import * as ui from '../ui/templates/edit.js';
|
|
11
|
+
import { loading, unavailable } from '../ui/templates/player.js';
|
|
12
|
+
import { texts } from '../ui/texts.js';
|
|
13
|
+
|
|
14
|
+
const t = texts.edit;
|
|
15
|
+
const root = document.getElementById('app');
|
|
16
|
+
document.title = texts.page.edit;
|
|
17
|
+
root.replaceChildren(loading('edit'));
|
|
18
|
+
const app = await start({ screen: 'edit' });
|
|
19
|
+
const draft = normalizeSettings(app.content);
|
|
20
|
+
/** 플레이어가 올리는 중 (progress를 받고 complete · cancel · error 전) */
|
|
21
|
+
let uploading = false;
|
|
22
|
+
|
|
23
|
+
const videoSection = ui.section({ name: 'video', title: t.video, required: true });
|
|
24
|
+
const body = part(videoSection, 'body');
|
|
25
|
+
root.replaceChildren(videoSection);
|
|
26
|
+
|
|
27
|
+
// 올리기 전 안내 줄 (ⓘ). 영상이 생기면 숨긴다 (V3: 파일을 고른 뒤에는 라벨 · 안내 없이 영상만).
|
|
28
|
+
// 받는 형식 · 최대 크기는 플레이어 올리기 칸(디자인 v2)이 보여 주므로 겹치지 않게 저장 안내만 둔다
|
|
29
|
+
const info = infoList([t.savable]);
|
|
30
|
+
info.setAttribute('data-ec-quiet', '');
|
|
31
|
+
/** 영상이 있는지에 따라 라벨 · 안내를 보이고 숨긴다 */
|
|
32
|
+
const paintEmpty = () => {
|
|
33
|
+
videoSection.dataset.empty = String(!draft.video);
|
|
34
|
+
info.hidden = Boolean(draft.video);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const save = app.useSave({
|
|
38
|
+
label: t.save,
|
|
39
|
+
getContent: () => toSettings(draft),
|
|
40
|
+
validate: () => validateSettings(draft, t.validation, { uploading }),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await app.videoPlayer.load();
|
|
45
|
+
const upload = ui.uploader();
|
|
46
|
+
upload.setAttribute('data-ec-quiet', '');
|
|
47
|
+
app.videoPlayer.connect(upload, { resourceId: draft.video?.resource_id });
|
|
48
|
+
upload.addEventListener('progress', () => (uploading = true));
|
|
49
|
+
upload.addEventListener('complete', e => {
|
|
50
|
+
uploading = false;
|
|
51
|
+
const resourceId = e.detail?.resourceId;
|
|
52
|
+
if (typeof resourceId !== 'string' || !resourceId) return;
|
|
53
|
+
draft.video = { resource_id: resourceId };
|
|
54
|
+
paintEmpty();
|
|
55
|
+
// 영상이 바뀐 것은 입력 이벤트가 없으므로 직접 '저장하지 않은 변경'으로 표시한다
|
|
56
|
+
save.markDirty();
|
|
57
|
+
});
|
|
58
|
+
upload.addEventListener('cancel', () => (uploading = false));
|
|
59
|
+
upload.addEventListener('error', () => (uploading = false));
|
|
60
|
+
body.replaceChildren(upload, info);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// 플랫폼이 플레이어 주소를 넘기지 않았거나(ecdk dev · 반영 전 LXP) embed.js를 불러오지 못함
|
|
63
|
+
const message =
|
|
64
|
+
e?.code === 'video_player_unavailable'
|
|
65
|
+
? texts.unavailable.noPlayer
|
|
66
|
+
: texts.unavailable.loadFailed;
|
|
67
|
+
body.replaceChildren(unavailable(message, 'edit'), info);
|
|
68
|
+
}
|
|
69
|
+
paintEmpty();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// 학생 화면. 영상을 화면 가득 놓고, 학습 완료 기준이 되면 키트가 한 번 제출합니다 (버튼 없음, useAutoSubmit).
|
|
2
|
+
// 재생 · 컨트롤 · 인코딩 중 · 재생 오류 화면은 Elice 비디오 플레이어(<elice-video>, embed.js)가 맡습니다.
|
|
3
|
+
// 기준 (settings.completion.mode): 'ended' 끝까지 보면(플레이어 ended) · 'open' 화면을 열면.
|
|
4
|
+
// 플레이어는 재생 위치 · 시청 비율을 알려 주지 않아(이벤트 ready · ended · error뿐) 'N% 시청'은 아직 없습니다.
|
|
5
|
+
// 튜터링(보기 전용)은 제출하지 않고, 다시 열었을 때 이미 낸 제출이 있으면 다시 내지 않습니다 (키트가 판단).
|
|
6
|
+
// 완료 정책은 LXP 자료 편집 화면의 '설정'에서 '제출 시 학습 완료'(on_submit)로 둡니다: 제출이 곧 학습 완료.
|
|
7
|
+
import { start } from '../lib/elice-content.js';
|
|
8
|
+
import { part } from '../core/dom.js';
|
|
9
|
+
import { normalizeSettings } from '../core/settings.js';
|
|
10
|
+
import { loading, player, unavailable } from '../ui/templates/player.js';
|
|
11
|
+
import { texts } from '../ui/texts.js';
|
|
12
|
+
|
|
13
|
+
const root = document.getElementById('app');
|
|
14
|
+
document.title = texts.page.learn;
|
|
15
|
+
// 플레이어를 화면 폭 가득 (V3)
|
|
16
|
+
document.body.classList.add('vd-page');
|
|
17
|
+
root.replaceChildren(loading('learn'));
|
|
18
|
+
const app = await start({ screen: 'learn' });
|
|
19
|
+
const settings = normalizeSettings(app.content);
|
|
20
|
+
|
|
21
|
+
// 편집 화면에서 아직 영상을 저장하지 않았으면 안내만 보인다
|
|
22
|
+
if (app.hasContent && settings.video) await show();
|
|
23
|
+
else root.replaceChildren(app.emptyState());
|
|
24
|
+
|
|
25
|
+
async function show() {
|
|
26
|
+
const { mode } = settings.completion;
|
|
27
|
+
// 제출하는 답: 무엇으로 완료했는지. 채점하지 않고 기록만 남는다. 화면에는 보이지 않는다 (V3)
|
|
28
|
+
const auto = app.useAutoSubmit({ getAnswer: () => ({ completedBy: mode }) });
|
|
29
|
+
if (mode === 'open') void auto.submit();
|
|
30
|
+
try {
|
|
31
|
+
await app.videoPlayer.load();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
const message =
|
|
34
|
+
e?.code === 'video_player_unavailable'
|
|
35
|
+
? texts.unavailable.noPlayer
|
|
36
|
+
: texts.unavailable.loadFailed;
|
|
37
|
+
root.replaceChildren(unavailable(message, 'learn'));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const view = player();
|
|
41
|
+
const video = part(view, 'video');
|
|
42
|
+
app.videoPlayer.connect(video, { resourceId: settings.video.resource_id });
|
|
43
|
+
// ended는 다시 볼 때마다 오지만 키트가 한 번만 낸다
|
|
44
|
+
if (mode === 'ended') video.addEventListener('ended', () => void auto.submit());
|
|
45
|
+
root.replaceChildren(view);
|
|
46
|
+
}
|