@eliceio/cdk-cli 1.4.1 → 1.5.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 (79) hide show
  1. package/README.md +17 -16
  2. package/es/cli.js +1 -1
  3. package/es/commands/create/index.js +1 -0
  4. package/es/commands/create/scaffold.d.ts +1 -1
  5. package/es/commands/create/scaffold.js +1 -1
  6. package/es/core/config.d.ts +36 -0
  7. package/es/core/config.js +234 -6
  8. package/es/core/quiz-check.js +123 -4
  9. package/es/dev/grading.d.ts +26 -4
  10. package/es/dev/grading.js +66 -11
  11. package/es/dev/mock-api.d.ts +6 -1
  12. package/es/dev/mock-api.js +45 -6
  13. package/es/rules/answers.d.ts +1 -0
  14. package/es/rules/answers.js +8 -0
  15. package/es/rules.json.js +1 -1
  16. package/package.json +2 -2
  17. package/rules.json +1 -1
  18. package/skills/_shared/always.md +1 -1
  19. package/skills/_shared/references/02-design-the-material.md +8 -7
  20. package/skills/_shared/references/03-create-the-project.md +10 -9
  21. package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
  22. package/skills/_shared/references/16-using-the-survey-template.md +158 -0
  23. package/skills/elice-content-create/SKILL.md +2 -2
  24. package/skills/elice-content-edit/SKILL.md +2 -2
  25. package/skills/elice-content-publish/SKILL.md +1 -1
  26. package/templates/_shared/lib/cdk-mock.d.ts +22 -3
  27. package/templates/_shared/lib/cdk-mock.js +78 -11
  28. package/templates/_shared/lib/elice-content.d.ts +17 -1
  29. package/templates/_shared/lib/elice-content.js +47 -5
  30. package/templates/blank/template.json +1 -1
  31. package/templates/document/template.json +1 -1
  32. package/templates/quiz/README.md +26 -1
  33. package/templates/quiz/core/behaviors.d.ts +5 -0
  34. package/templates/quiz/core/behaviors.js +16 -1
  35. package/templates/quiz/core/model.d.ts +78 -1
  36. package/templates/quiz/core/model.js +219 -4
  37. package/templates/quiz/screens/edit.js +244 -55
  38. package/templates/quiz/screens/learn.js +137 -27
  39. package/templates/quiz/styles.css +258 -5
  40. package/templates/quiz/template.json +1 -1
  41. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  42. package/templates/quiz/ui/templates/edit.js +67 -8
  43. package/templates/quiz/ui/templates/page.js +34 -0
  44. package/templates/quiz/ui/templates/text.js +15 -2
  45. package/templates/quiz/ui/texts.js +61 -0
  46. package/templates/steps/template.json +1 -1
  47. package/templates/survey/README.md +112 -0
  48. package/templates/survey/commentary.txt +2 -0
  49. package/templates/survey/core/behaviors.d.ts +14 -0
  50. package/templates/survey/core/behaviors.js +115 -0
  51. package/templates/survey/core/dom.d.ts +13 -0
  52. package/templates/survey/core/dom.js +83 -0
  53. package/templates/survey/core/editor.d.ts +80 -0
  54. package/templates/survey/core/editor.js +720 -0
  55. package/templates/survey/core/markdown.d.ts +21 -0
  56. package/templates/survey/core/markdown.js +298 -0
  57. package/templates/survey/core/model.d.ts +83 -0
  58. package/templates/survey/core/model.js +209 -0
  59. package/templates/survey/core/rich-text.d.ts +18 -0
  60. package/templates/survey/core/rich-text.js +469 -0
  61. package/templates/survey/edit.html +26 -0
  62. package/templates/survey/gitignore +4 -0
  63. package/templates/survey/index.html +26 -0
  64. package/templates/survey/metadata.json +9 -0
  65. package/templates/survey/package.json +13 -0
  66. package/templates/survey/screens/edit.js +345 -0
  67. package/templates/survey/screens/learn.js +100 -0
  68. package/templates/survey/styles.css +1264 -0
  69. package/templates/survey/template.json +6 -0
  70. package/templates/survey/ui/templates/edit.d.ts +27 -0
  71. package/templates/survey/ui/templates/edit.js +656 -0
  72. package/templates/survey/ui/templates/index.d.ts +3 -0
  73. package/templates/survey/ui/templates/index.js +3 -0
  74. package/templates/survey/ui/templates/learn.js +147 -0
  75. package/templates/survey/ui/templates/page.js +19 -0
  76. package/templates/survey/ui/texts.d.ts +3 -0
  77. package/templates/survey/ui/texts.js +116 -0
  78. package/templates/survey/ui/theme.css +42 -0
  79. package/templates/video/template.json +1 -1
@@ -0,0 +1,83 @@
1
+ // 작은 DOM 도우미. ui/templates/*는 html`…`로 마크업을 쓰고, core/behaviors.js는 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, '&lt;')
16
+ .replace(/>/g, '&gt;')
17
+ .replace(/"/g, '&quot;')
18
+ .replace(/'/g, '&#39;');
19
+
20
+ const MARK = 'qz-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,80 @@
1
+ // core/editor.js 타입 (퀴즈 템플릿과 같음 + picker · formatTools) (편집기 자동완성 · 테스트용). templates는 ui/templates/edit.js와 같은 모양
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /** 동작이 바꾸는 문구 (글자 수 · 새 그룹 이름) */
4
+ export interface EditorLabels {
5
+ count(length: number, max: number): string;
6
+ group(letter: string): string;
7
+ }
8
+ export declare function createEditor(opts: {
9
+ rerender: () => void;
10
+ root: Element;
11
+ templates: Record<string, (props?: any) => any>;
12
+ labels: EditorLabels;
13
+ }): {
14
+ ui: Record<string, (props?: any) => any>;
15
+ field(
16
+ label: string,
17
+ value: string | undefined,
18
+ onInput: (v: string) => void,
19
+ opts?: {
20
+ multiline?: boolean;
21
+ required?: boolean;
22
+ /** false면 "선택" 표시 없음 (기본 true) */
23
+ showOptional?: boolean;
24
+ max?: number;
25
+ hint?: string;
26
+ },
27
+ ): HTMLElement;
28
+ /** 지문 · 해설 칸 (보이는 그대로 고치는 글 칸 + 올린 그림 칸, 값은 마크다운) */
29
+ richField(
30
+ label: string,
31
+ value: string | undefined,
32
+ onInput: (v: string) => void,
33
+ opts?: {
34
+ placeholder?: string;
35
+ images?: { removeLabel: string; onRemoved?: (undo: () => void) => void };
36
+ },
37
+ ): HTMLElement;
38
+ numberField(
39
+ label: string,
40
+ hint: string,
41
+ value: number,
42
+ max: number,
43
+ onInput: (v: number) => void,
44
+ ): HTMLElement;
45
+ toggle(label: string, checked: boolean | undefined, onChange: (v: boolean) => void): HTMLElement;
46
+ itemList(
47
+ kind: 'option' | 'group',
48
+ items: any[],
49
+ key: string,
50
+ opts?: {
51
+ /** 추가한 뒤 (예: 순서 맞추기 칸 수 늘리기) */
52
+ onAdd?: () => void;
53
+ onDelete?: () => void;
54
+ onInput?: (item: any) => void;
55
+ /** 줄마다 정답 칸 (data-role="answer"): radio · checkbox · select(choices: [값, 이름]) */
56
+ answer?: {
57
+ type: 'radio' | 'checkbox' | 'select';
58
+ name: string;
59
+ choices?: [string, string][] | undefined;
60
+ get(item: any): boolean | string;
61
+ set(item: any, value: boolean | string): void;
62
+ };
63
+ },
64
+ ): HTMLElement;
65
+ card(
66
+ props: { q: any; index: number; count: number; types: [string, string][]; body: Node[] },
67
+ on: { type(value: string): void; up(): void; down(): void; remove(): void },
68
+ ): HTMLElement;
69
+ /** 버튼에 고르기 목록(ui.typeMenu)을 붙인다. choices: [값, 이름] */
70
+ picker(
71
+ button: HTMLElement,
72
+ choices: [string, string][],
73
+ value: () => string,
74
+ choose: (value: string) => void,
75
+ ): HTMLElement;
76
+ /** richField 아래 서식 도구 */
77
+ formatTools(field: HTMLElement, texts: Record<string, string>, images?: unknown): void;
78
+ addQuestion(onClick: () => void): HTMLElement;
79
+ cardAt(index: number): HTMLElement | undefined;
80
+ };