@eliceio/cdk-cli 1.4.0 → 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 +10 -3
@@ -0,0 +1,469 @@
1
+ // 지문 · 해설 편집 칸: 보이는 그대로 고치는 글 칸(contenteditable)과 마크다운 사이를 오간다 (연주님 최종 수정본).
2
+ // 저장하는 값은 늘 마크다운이라 학생 화면(core/markdown.js)이 그대로 읽는다. 붙여 넣기는 글자만 받는다.
3
+ // 서식: 굵게 · 기울임 · 취소선 · 글머리 · 번호 목록 · 코드(한 문단 안은 `코드`, 여러 문단을 고르면 코드 블록)
4
+ import { lineNumbers, markdown } from './markdown.js';
5
+
6
+ // 서식은 브라우저 편집 명령으로 (없는 환경에서는 아무 일도 하지 않음)
7
+ const command = (...args) => document.execCommand?.(...args);
8
+ const commandState = (name) => Boolean(document.queryCommandState?.(name));
9
+
10
+ const BLOCK_TAGS = new Set([
11
+ 'P',
12
+ 'DIV',
13
+ 'UL',
14
+ 'OL',
15
+ 'LI',
16
+ 'PRE',
17
+ 'BLOCKQUOTE',
18
+ 'H1',
19
+ 'H2',
20
+ 'H3',
21
+ 'H4',
22
+ 'H5',
23
+ 'H6',
24
+ ]);
25
+ const isBlock = (node) => node.nodeType === 1 && BLOCK_TAGS.has(node.tagName);
26
+ // 글 속 서식 기호는 \로 막아 마크다운으로 읽히지 않게 (코드 안은 \ · `만)
27
+ const escapeText = (s) => s.replace(/ /g, ' ').replace(/[\\*`[\]~]/g, '\\$&');
28
+ const escapeCode = (s) => s.replace(/ /g, ' ').replace(/[\\`]/g, '\\$&');
29
+ const wrap = (s, mark) => (s.trim() === '' ? s : `${mark}${s}${mark}`);
30
+
31
+ /** 한 문단 안의 글과 서식을 마크다운으로 */
32
+ function inlineMarkdown(node, inCode = false) {
33
+ let out = '';
34
+ for (const child of node.childNodes) {
35
+ if (child.nodeType === 3) {
36
+ out += inCode ? escapeCode(child.data) : escapeText(child.data);
37
+ continue;
38
+ }
39
+ if (child.nodeType !== 1) continue;
40
+ const tag = child.tagName;
41
+ if (tag === 'BR') {
42
+ out += '\n';
43
+ continue;
44
+ }
45
+ if (tag === 'IMG') {
46
+ // zip 안 그림(img/…)만 글 속에 남는다. 올린 그림은 칸 사이 그림 칸(블록)으로 따로 둔다
47
+ const src = child.getAttribute('src') ?? '';
48
+ if (/^img\//.test(src))
49
+ out += `![${(child.getAttribute('alt') ?? '').replace(/[[\]]/g, '')}](${src})`;
50
+ continue;
51
+ }
52
+ const inner = inlineMarkdown(child, inCode || tag === 'CODE');
53
+ if (!inner) continue;
54
+ if (inCode) out += inner;
55
+ else if (tag === 'STRONG' || tag === 'B') out += wrap(inner, '**');
56
+ else if (tag === 'EM' || tag === 'I') out += wrap(inner, '*');
57
+ else if (tag === 'DEL' || tag === 'S' || tag === 'STRIKE') out += wrap(inner, '~~');
58
+ else if (tag === 'CODE') out += inner.trim() === '' ? inner : `\`${inner}\``;
59
+ else if (tag === 'A') {
60
+ const href = child.getAttribute('href') ?? '';
61
+ out += /^https?:\/\//.test(href) ? `[${inner}](${href})` : inner;
62
+ } else out += inner;
63
+ }
64
+ return out;
65
+ }
66
+
67
+ /** 문단 첫머리의 # · - · 1. 은 제목 · 목록으로 읽히지 않게 막는다 */
68
+ const paragraph = (s) =>
69
+ s
70
+ .split('\n')
71
+ .map((line) =>
72
+ line
73
+ .replace(/^(\s*)(#{1,3})(\s)/, '$1\\$2$3')
74
+ .replace(/^(\s*)-(\s)/, '$1\\-$2')
75
+ .replace(/^(\s*)(\d+)\.(\s)/, '$1$2\\.$3'),
76
+ )
77
+ .join('\n')
78
+ .replace(/^\n+|\n+$/g, '')
79
+ .trim();
80
+
81
+ /** 서식 없이 글만 (코드 블록) */
82
+ function plainText(node) {
83
+ let out = '';
84
+ const walk = (n) => {
85
+ for (const child of n.childNodes) {
86
+ if (child.nodeType === 3) out += child.data.replace(/ /g, ' ');
87
+ else if (child.tagName === 'BR') out += '\n';
88
+ else walk(child);
89
+ }
90
+ };
91
+ walk(node);
92
+ return out.replace(/\n+$/, '');
93
+ }
94
+
95
+ /** 칸 안의 문단들을 마크다운 덩어리로 */
96
+ function blocks(root) {
97
+ const out = [];
98
+ let loose = [];
99
+ const flush = () => {
100
+ if (!loose.length) return;
101
+ const box = document.createElement('div');
102
+ for (const n of loose) box.append(n.cloneNode(true));
103
+ const text = paragraph(inlineMarkdown(box));
104
+ if (text) out.push(text);
105
+ loose = [];
106
+ };
107
+ for (const node of root.childNodes) {
108
+ if (node.nodeType === 3 || (node.nodeType === 1 && !isBlock(node))) {
109
+ loose.push(node);
110
+ continue;
111
+ }
112
+ flush();
113
+ if (node.nodeType !== 1) continue;
114
+ const tag = node.tagName;
115
+ if (tag === 'UL' || tag === 'OL') {
116
+ const items = [...node.children]
117
+ .filter((li) => li.tagName === 'LI')
118
+ .map((li, i) => [
119
+ tag === 'UL' ? '- ' : `${i + 1}. `,
120
+ inlineMarkdown(li).replace(/\n+/g, ' ').trim(),
121
+ ])
122
+ .filter(([, text]) => text)
123
+ .map(([mark, text]) => mark + text);
124
+ if (items.length) out.push(items.join('\n'));
125
+ } else if (tag === 'PRE') {
126
+ const code = plainText(node);
127
+ if (code.trim()) out.push(`\`\`\`\n${code}\n\`\`\``);
128
+ } else if (/^H[1-6]$/.test(tag)) {
129
+ const text = inlineMarkdown(node).replace(/\n+/g, ' ').trim();
130
+ if (text) out.push(`${'#'.repeat(Math.min(3, Math.max(1, Number(tag[1]) - 2)))} ${text}`);
131
+ } else if (node.querySelector('p, div, ul, ol, pre, h1, h2, h3, h4, h5, h6')) {
132
+ out.push(...blocks(node));
133
+ } else {
134
+ const text = paragraph(inlineMarkdown(node));
135
+ if (text) out.push(text);
136
+ }
137
+ }
138
+ flush();
139
+ return out;
140
+ }
141
+
142
+ /** 글 칸(또는 그 일부)을 마크다운으로 */
143
+ export const toMarkdown = (root) => blocks(root).join('\n\n');
144
+
145
+ const LAST_BLOCK = /^(PRE|UL|OL|H[1-6])$/;
146
+ const emptyParagraph = () => {
147
+ const p = document.createElement('p');
148
+ p.append(document.createElement('br'));
149
+ return p;
150
+ };
151
+ /** 마지막이 목록 · 코드 블록이면 뒤에 빈 문단을 두어 그 밖으로 이어 쓸 수 있게 */
152
+ function keepTrailingParagraph(root) {
153
+ const last = root.lastElementChild;
154
+ if (!last || LAST_BLOCK.test(last.tagName)) root.append(emptyParagraph());
155
+ }
156
+ /** 커서를 요소 처음(false) · 끝(true)으로 */
157
+ function caretAt(node, atEnd) {
158
+ const range = document.createRange();
159
+ range.selectNodeContents(node);
160
+ range.collapse(!atEnd);
161
+ const selection = getSelection();
162
+ selection.removeAllRanges();
163
+ selection.addRange(range);
164
+ }
165
+
166
+ /**
167
+ * 글 칸 하나를 보이는 그대로 고치는 칸으로. 고칠 때마다 onChange(마크다운)
168
+ * @param {HTMLElement} el contenteditable 요소
169
+ * @param {{ onChange: (markdown: string) => void }} opts
170
+ */
171
+ export function richText(el, { onChange }) {
172
+ let saved = null;
173
+ const remember = () => {
174
+ const selection = getSelection();
175
+ if (selection.rangeCount && el.contains(selection.anchorNode))
176
+ saved = selection.getRangeAt(0).cloneRange();
177
+ };
178
+ /** 서식 버튼을 누를 때 칸의 선택 범위 (초점이 버튼에 가 있었으면 마지막 선택을 되살림) */
179
+ const range = () => {
180
+ el.focus();
181
+ const selection = getSelection();
182
+ if (selection.rangeCount && el.contains(selection.anchorNode)) return selection.getRangeAt(0);
183
+ if (saved && el.contains(saved.startContainer)) {
184
+ selection.removeAllRanges();
185
+ selection.addRange(saved);
186
+ return saved;
187
+ }
188
+ caretAt(el, true);
189
+ return selection.getRangeAt(0);
190
+ };
191
+ /** 칸 바로 아래 문단 */
192
+ const topBlock = (node) => {
193
+ let n = node;
194
+ while (n && n.parentNode !== el) n = n.parentNode;
195
+ return n && n !== el ? n : null;
196
+ };
197
+ const closest = (node, tag) => {
198
+ for (let n = node; n && n !== el; n = n.parentNode) if (n.tagName === tag) return n;
199
+ return null;
200
+ };
201
+ const markLines = () => {
202
+ for (const pre of el.querySelectorAll('pre')) {
203
+ const count = plainText(pre).split('\n').length;
204
+ if (count >= 3) {
205
+ pre.classList.add('qz-lines');
206
+ pre.dataset.lines = lineNumbers(count);
207
+ } else {
208
+ pre.classList.remove('qz-lines');
209
+ delete pre.dataset.lines;
210
+ }
211
+ }
212
+ };
213
+ const markEmpty = () => el.toggleAttribute('data-empty', toMarkdown(el) === '');
214
+ const changed = () => {
215
+ markLines();
216
+ markEmpty();
217
+ onChange(toMarkdown(el));
218
+ };
219
+ const tidy = () => {
220
+ if (!el.childNodes.length || (el.childNodes.length === 1 && el.firstChild.nodeName === 'BR')) {
221
+ el.replaceChildren(emptyParagraph());
222
+ caretAt(el, false);
223
+ }
224
+ keepTrailingParagraph(el);
225
+ };
226
+
227
+ el.addEventListener('input', () => {
228
+ tidy();
229
+ changed();
230
+ remember();
231
+ });
232
+ for (const type of ['keyup', 'mouseup', 'touchend', 'focusout'])
233
+ el.addEventListener(type, remember);
234
+ el.addEventListener('paste', (e) => {
235
+ e.preventDefault();
236
+ command('insertText', false, e.clipboardData?.getData('text/plain') ?? '');
237
+ });
238
+ // 코드 블록 안에서 Enter는 블록을 끝내지 않고 줄만 바꾼다
239
+ el.addEventListener('keydown', (e) => {
240
+ if (e.key !== 'Enter' || e.shiftKey || e.isComposing) return;
241
+ const selection = getSelection();
242
+ if (selection.rangeCount && closest(selection.anchorNode, 'PRE')) {
243
+ e.preventDefault();
244
+ command('insertLineBreak');
245
+ }
246
+ });
247
+
248
+ const textOf = (node) => {
249
+ let out = '';
250
+ for (const child of node.childNodes)
251
+ out += child.nodeType === 3 ? child.data : child.tagName === 'BR' ? '\n' : textOf(child);
252
+ return out.replace(/ /g, ' ');
253
+ };
254
+ /** 코드 블록을 줄마다 문단으로 */
255
+ const unwrapPre = (pre) => {
256
+ const fragment = document.createDocumentFragment();
257
+ for (const line of plainText(pre).split('\n')) {
258
+ const p = document.createElement('p');
259
+ if (line) p.textContent = line;
260
+ else p.append(document.createElement('br'));
261
+ fragment.append(p);
262
+ }
263
+ pre.replaceWith(fragment);
264
+ };
265
+ /** first부터 last까지 문단을 코드 블록 하나로 */
266
+ const wrapPre = (first, last) => {
267
+ const nodes = [];
268
+ for (let n = first; n; n = n.nextSibling) {
269
+ nodes.push(n);
270
+ if (n === last) break;
271
+ }
272
+ const lines = nodes.flatMap((n) =>
273
+ n.tagName === 'UL' || n.tagName === 'OL'
274
+ ? [...n.children].map((li) => li.textContent)
275
+ : n.tagName === 'PRE'
276
+ ? plainText(n).split('\n')
277
+ : textOf(n).split('\n'),
278
+ );
279
+ const pre = document.createElement('pre');
280
+ const code = document.createElement('code');
281
+ code.textContent = lines.join('\n');
282
+ pre.append(code);
283
+ first.before(pre);
284
+ for (const n of nodes) n.remove();
285
+ caretAt(code, true);
286
+ };
287
+
288
+ const editor = {
289
+ el,
290
+ set(value) {
291
+ el.replaceChildren(...markdown(value ?? '').childNodes);
292
+ keepTrailingParagraph(el);
293
+ markLines();
294
+ markEmpty();
295
+ },
296
+ get: () => toMarkdown(el),
297
+ focus(atEnd = false) {
298
+ el.focus();
299
+ caretAt(el, atEnd);
300
+ },
301
+ /** 커서 앞 · 뒤 글 (그 자리에 그림을 넣을 때) */
302
+ split() {
303
+ const at = range();
304
+ const before = document.createRange();
305
+ before.selectNodeContents(el);
306
+ before.setEnd(at.startContainer, at.startOffset);
307
+ const after = document.createRange();
308
+ after.selectNodeContents(el);
309
+ after.setStart(at.endContainer, at.endOffset);
310
+ return {
311
+ before: toMarkdown(before.cloneContents()),
312
+ after: toMarkdown(after.cloneContents()),
313
+ };
314
+ },
315
+ /** 서식 버튼 눌림 표시 */
316
+ state() {
317
+ const selection = getSelection();
318
+ const inside = selection.rangeCount && el.contains(selection.anchorNode);
319
+ return {
320
+ bold: inside && commandState('bold'),
321
+ italic: inside && commandState('italic'),
322
+ strike: inside && commandState('strikeThrough'),
323
+ ul: inside && Boolean(closest(selection.anchorNode, 'UL')),
324
+ ol: inside && Boolean(closest(selection.anchorNode, 'OL')),
325
+ code:
326
+ inside &&
327
+ Boolean(closest(selection.anchorNode, 'CODE') || closest(selection.anchorNode, 'PRE')),
328
+ };
329
+ },
330
+ bold() {
331
+ range();
332
+ if (!editor.state().code) command('bold');
333
+ },
334
+ italic() {
335
+ range();
336
+ if (!editor.state().code) command('italic');
337
+ },
338
+ strike() {
339
+ range();
340
+ if (!editor.state().code) command('strikeThrough');
341
+ },
342
+ /** 고른 문단을 목록으로 · 같은 목록이면 문단으로 · 다른 목록이면 종류만 바꿈 */
343
+ list(tag = 'ul') {
344
+ const at = range();
345
+ if (editor.state().code) return;
346
+ const first = topBlock(at.startContainer);
347
+ const last = topBlock(at.endContainer);
348
+ if (!first || !last) return;
349
+ const selection = getSelection();
350
+ const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;
351
+ const isList = (n) => n.tagName === 'UL' || n.tagName === 'OL';
352
+ let caret;
353
+ if (isList(first) && first === last && first.tagName !== tag.toUpperCase()) {
354
+ const next = document.createElement(tag);
355
+ next.append(...first.childNodes);
356
+ first.replaceWith(next);
357
+ caret = next.lastElementChild;
358
+ } else if (isList(first) && first === last) {
359
+ const fragment = document.createDocumentFragment();
360
+ for (const li of first.children) {
361
+ const p = document.createElement('p');
362
+ p.append(...li.childNodes);
363
+ if (!p.childNodes.length) p.append(document.createElement('br'));
364
+ fragment.append(p);
365
+ caret = p;
366
+ }
367
+ first.replaceWith(fragment);
368
+ } else {
369
+ const nodes = [];
370
+ for (let n = first; n; n = n.nextSibling) {
371
+ nodes.push(n);
372
+ if (n === last) break;
373
+ }
374
+ const list = document.createElement(tag);
375
+ for (const n of nodes) {
376
+ if (isList(n)) list.append(...n.children);
377
+ else if (n.tagName === 'PRE') {
378
+ const li = document.createElement('li');
379
+ li.textContent = plainText(n);
380
+ list.append(li);
381
+ } else {
382
+ const li = document.createElement('li');
383
+ li.append(...n.childNodes);
384
+ if (!li.childNodes.length) li.append(document.createElement('br'));
385
+ list.append(li);
386
+ }
387
+ }
388
+ first.before(list);
389
+ for (const n of nodes) n.remove();
390
+ caret = list.lastElementChild;
391
+ }
392
+ if (anchorNode && focusNode && el.contains(anchorNode) && el.contains(focusNode))
393
+ selection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
394
+ else if (caret) caretAt(caret, true);
395
+ tidy();
396
+ changed();
397
+ remember();
398
+ },
399
+ /** 코드: 코드 블록 안이면 풀고, 여러 문단을 골랐으면 코드 블록, 아니면 `코드` 켜고 끄기 (빈 커서면 sample을 넣음) */
400
+ code(sample) {
401
+ const at = range();
402
+ const pre = closest(at.startContainer, 'PRE');
403
+ if (pre) unwrapPre(pre);
404
+ else {
405
+ const first = topBlock(at.startContainer);
406
+ const last = topBlock(at.endContainer);
407
+ if (first && last && first !== last) wrapPre(first, last);
408
+ else {
409
+ const start = closest(at.startContainer, 'CODE');
410
+ const end = closest(at.endContainer, 'CODE');
411
+ if (start && (at.collapsed || start === end)) start.replaceWith(...start.childNodes);
412
+ else {
413
+ if (start) at.setStartBefore(start);
414
+ if (end) at.setEndAfter(end);
415
+ const code = document.createElement('code');
416
+ if (at.collapsed) code.textContent = sample;
417
+ else code.append(at.extractContents());
418
+ for (const inner of code.querySelectorAll('code, b, strong, i, em, s, del, strike'))
419
+ inner.replaceWith(...inner.childNodes);
420
+ at.insertNode(code);
421
+ const selection = getSelection();
422
+ selection.removeAllRanges();
423
+ const picked = document.createRange();
424
+ picked.selectNodeContents(code);
425
+ selection.addRange(picked);
426
+ }
427
+ }
428
+ }
429
+ tidy();
430
+ changed();
431
+ remember();
432
+ },
433
+ };
434
+ // Enter로 새 문단을 <p>로 (브라우저 기본 <div> 대신)
435
+ command('defaultParagraphSeparator', false, 'p');
436
+ return editor;
437
+ }
438
+
439
+ /** 한 줄을 차지하는 그림: 올린 그림 asset:파일키 · 옛 그림 image:아이디 */
440
+ const IMAGE_LINE =
441
+ /^!\[([^\]]*)\]\((image:[\w-]+|asset:assets\/[\w-]+\/[\w-]+\.(?:png|jpe?g|webp|gif))\)$/i;
442
+ /**
443
+ * 마크다운을 글 칸 · 그림 칸 차례로 나눈다 (한 줄을 차지하는 올린 그림 ![설명](asset:파일키) · 옛 ![설명](image:아이디)만 그림 칸)
444
+ * @returns {({ type: 'text', text: string } | { type: 'image', alt: string, ref: string })[]}
445
+ */
446
+ export function splitBlocks(source) {
447
+ const out = [];
448
+ let lines = [];
449
+ const flush = () => {
450
+ out.push({ type: 'text', text: lines.join('\n').replace(/^\n+|\n+$/g, '') });
451
+ lines = [];
452
+ };
453
+ for (const line of String(source ?? '').split('\n')) {
454
+ const image = IMAGE_LINE.exec(line.trim());
455
+ if (image) {
456
+ flush();
457
+ out.push({ type: 'image', alt: image[1], ref: image[2] });
458
+ } else lines.push(line);
459
+ }
460
+ flush();
461
+ return out;
462
+ }
463
+
464
+ /** splitBlocks의 반대 (빈 글 칸은 뺀다) */
465
+ export const joinBlocks = (items) =>
466
+ items
467
+ .map((b) => (b.type === 'image' ? `![${b.alt}](${b.ref})` : b.text.replace(/^\n+|\n+$/g, '')))
468
+ .filter((s) => s !== '')
469
+ .join('\n\n');
@@ -0,0 +1,26 @@
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)에서 고칩니다. #app 안은 스크립트가 돌기 전 자리로, ui/templates/page.js loading()과 같은 모양 (질문 막대 + 보기 막대 넷) -->
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">
16
+ <div class="qz-skeleton" role="status">
17
+ <span class="ec-visually-hidden">불러오는 중…</span>
18
+ <span class="qz-sk qz-sk-title"></span>
19
+ <span class="qz-sk qz-sk-option"></span>
20
+ <span class="qz-sk qz-sk-option"></span>
21
+ <span class="qz-sk qz-sk-option"></span>
22
+ <span class="qz-sk qz-sk-option"></span>
23
+ </div>
24
+ </main>
25
+ </body>
26
+ </html>
@@ -0,0 +1,4 @@
1
+ dist/
2
+ node_modules/
3
+ .env
4
+ .ecdk/
@@ -0,0 +1,26 @@
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)에서 고칩니다. #app 안은 스크립트가 돌기 전 자리로, ui/templates/page.js loading()과 같은 모양 (질문 막대 + 보기 막대 넷) -->
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">
16
+ <div class="qz-skeleton" role="status">
17
+ <span class="ec-visually-hidden">불러오는 중…</span>
18
+ <span class="qz-sk qz-sk-title"></span>
19
+ <span class="qz-sk qz-sk-option"></span>
20
+ <span class="qz-sk qz-sk-option"></span>
21
+ <span class="qz-sk qz-sk-option"></span>
22
+ <span class="qz-sk qz-sk-option"></span>
23
+ </div>
24
+ </main>
25
+ </body>
26
+ </html>
@@ -0,0 +1,9 @@
1
+ {
2
+ "kind": "material",
3
+ "screens": {
4
+ "learn": { "enabled": true, "entry": "index.html" },
5
+ "instructor": { "enabled": false },
6
+ "edit": { "enabled": true, "entry": "edit.html" }
7
+ },
8
+ "commentary": "commentary.txt"
9
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "private": true,
3
+ "type": "module",
4
+ "scripts": {
5
+ "dev": "ecdk dev",
6
+ "build": "ecdk build",
7
+ "validate": "ecdk validate"
8
+ },
9
+ "dependencies": {
10
+ "@eliceio/cdk": "workspace:^1.0.0-alpha.4"
11
+ },
12
+ "ecdk": {}
13
+ }