@eliceio/cdk-cli 1.2.0 → 1.3.0-contenttypes.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 (104) hide show
  1. package/README.md +69 -60
  2. package/es/cli.js +11 -2
  3. package/es/commands/build/index.js +12 -0
  4. package/es/commands/create/index.js +2 -1
  5. package/es/commands/create/scaffold.d.ts +2 -2
  6. package/es/commands/create/scaffold.js +3 -3
  7. package/es/commands/dev/index.d.ts +10 -1
  8. package/es/commands/dev/index.js +47 -7
  9. package/es/core/config.d.ts +20 -9
  10. package/es/core/config.js +53 -12
  11. package/es/core/project-check.d.ts +3 -2
  12. package/es/core/project-check.js +14 -3
  13. package/es/core/regex.d.ts +11 -0
  14. package/es/core/regex.js +41 -0
  15. package/es/core/sandbox.d.ts +26 -0
  16. package/es/core/sandbox.js +240 -30
  17. package/es/dev/check.d.ts +30 -0
  18. package/es/dev/check.js +224 -34
  19. package/es/dev/grading.d.ts +20 -1
  20. package/es/dev/grading.js +38 -7
  21. package/es/dev/host-page.js +1 -1
  22. package/es/dev/mock-api.d.ts +3 -1
  23. package/es/dev/mock-api.js +20 -11
  24. package/es/engines/vite/index.js +1 -1
  25. package/es/engines/vite/plugin.d.ts +2 -0
  26. package/es/engines/vite/plugin.js +33 -5
  27. package/es/rules/answers.d.ts +13 -0
  28. package/es/rules/answers.js +94 -0
  29. package/es/rules/check.js +70 -1
  30. package/es/rules/index.d.ts +1 -0
  31. package/es/rules/index.js +1 -0
  32. package/es/rules/size.d.ts +31 -0
  33. package/es/rules/size.js +58 -0
  34. package/es/rules/types.d.ts +12 -0
  35. package/es/rules.json.js +2 -2
  36. package/package.json +2 -2
  37. package/rules.json +32 -3
  38. package/skills/_shared/always.md +3 -3
  39. package/skills/_shared/references/00-what-the-person-decides.md +1 -1
  40. package/skills/_shared/references/02-design-the-material.md +10 -7
  41. package/skills/_shared/references/03-create-the-project.md +2 -1
  42. package/skills/_shared/references/05-screen-code.md +49 -22
  43. package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
  44. package/skills/_shared/references/08-fix-check-errors.md +23 -22
  45. package/skills/_shared/references/09-check.md +7 -6
  46. package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
  47. package/skills/_shared/references/13-edit-screen-design.md +122 -0
  48. package/skills/_shared/references/14-layouts.md +96 -0
  49. package/skills/elice-content-check/SKILL.md +2 -2
  50. package/skills/elice-content-create/SKILL.md +1 -1
  51. package/skills/elice-content-migrate/SKILL.md +1 -1
  52. package/templates/_shared/lib/cdk-mock.d.ts +30 -3
  53. package/templates/_shared/lib/cdk-mock.js +88 -15
  54. package/templates/_shared/lib/elice-content-editor.js +89 -58
  55. package/templates/_shared/lib/elice-content.css +1313 -126
  56. package/templates/_shared/lib/elice-content.d.ts +162 -23
  57. package/templates/_shared/lib/elice-content.js +865 -84
  58. package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
  59. package/templates/_shared/lib/icons/empty-content.js +11 -0
  60. package/templates/_shared/lib/icons/file-video.d.ts +2 -0
  61. package/templates/_shared/lib/icons/file-video.js +11 -0
  62. package/templates/_shared/lib/icons/file.d.ts +2 -0
  63. package/templates/_shared/lib/icons/file.js +11 -0
  64. package/templates/blank/README.md +5 -3
  65. package/templates/blank/edit.html +8 -2
  66. package/templates/blank/index.html +6 -1
  67. package/templates/blank/instructor.html +6 -1
  68. package/templates/blank/template.json +1 -1
  69. package/templates/quiz/README.md +28 -12
  70. package/templates/quiz/core/behaviors.d.ts +13 -7
  71. package/templates/quiz/core/behaviors.js +36 -51
  72. package/templates/quiz/core/editor.d.ts +10 -0
  73. package/templates/quiz/core/editor.js +471 -8
  74. package/templates/quiz/core/markdown.d.ts +4 -0
  75. package/templates/quiz/core/markdown.js +65 -11
  76. package/templates/quiz/core/model.d.ts +34 -1
  77. package/templates/quiz/core/model.js +89 -7
  78. package/templates/quiz/core/rich-text.d.ts +19 -0
  79. package/templates/quiz/core/rich-text.js +521 -0
  80. package/templates/quiz/edit.html +12 -3
  81. package/templates/quiz/index.html +12 -3
  82. package/templates/quiz/screens/edit.js +848 -168
  83. package/templates/quiz/screens/learn.js +90 -14
  84. package/templates/quiz/styles.css +889 -213
  85. package/templates/quiz/template.json +9 -2
  86. package/templates/quiz/ui/templates/edit.d.ts +19 -6
  87. package/templates/quiz/ui/templates/edit.js +666 -87
  88. package/templates/quiz/ui/templates/group.js +19 -8
  89. package/templates/quiz/ui/templates/order.js +25 -24
  90. package/templates/quiz/ui/templates/page.js +19 -8
  91. package/templates/quiz/ui/templates/question.js +2 -2
  92. package/templates/quiz/ui/texts.js +104 -35
  93. package/templates/quiz/ui/theme.css +8 -9
  94. package/templates/steps/README.md +77 -0
  95. package/templates/steps/commentary.txt +7 -0
  96. package/templates/steps/edit.html +21 -0
  97. package/templates/steps/gitignore +4 -0
  98. package/templates/steps/index.html +69 -0
  99. package/templates/steps/metadata.json +9 -0
  100. package/templates/steps/package.json +13 -0
  101. package/templates/steps/screens/edit.js +32 -0
  102. package/templates/steps/screens/learn.js +108 -0
  103. package/templates/steps/styles.css +54 -0
  104. package/templates/steps/template.json +6 -0
@@ -22,8 +22,13 @@
22
22
  *
23
23
  * 화면 코드에는 키트(elice-content.js)만 있어도 되지만, 편집 화면만 이 파일을 부른다:
24
24
  * build가 화면마다 코드를 묶으므로 학생 화면 묶음에는 이 편집기가 들어가지 않는다.
25
+ *
26
+ * 폼 보기 모양은 키트 편집 화면 디자인(elice-content.css "편집 화면": 회색 바탕 · 흰 카드 · 밑줄 칸 · 스낵바)을 따른다.
27
+ * 편집기를 만들면 <body>에 ec-edit-page를 붙인다. .ec-json-* 클래스도 그대로 둔다 (styles.css에서 고르는 이름).
25
28
  */
26
29
 
30
+ import { showSnackbar, SNACKBAR_MS } from './elice-content.js';
31
+
27
32
  const NODE_KEYS = new Set([
28
33
  'type',
29
34
  'label',
@@ -39,8 +44,8 @@ const NODE_KEYS = new Set([
39
44
  ]);
40
45
  /** 글이 이보다 길거나 줄바꿈이 있으면 여러 줄 칸 */
41
46
  const LONG_TEXT = 60;
42
- /** 삭제 되돌리기 알림이 떠 있는 시간 */
43
- export const UNDO_MS = 6000;
47
+ /** 삭제 되돌리기 알림(스낵바)이 떠 있는 시간 */
48
+ export const UNDO_MS = SNACKBAR_MS;
44
49
 
45
50
  const isObj = v => v !== null && typeof v === 'object' && !Array.isArray(v);
46
51
  const clone = v => (v === undefined ? undefined : JSON.parse(JSON.stringify(v)));
@@ -442,6 +447,8 @@ export function useContentEditor(app, opts = {}) {
442
447
  /** 코드 보기로 바꿀 때 쓴 글 (그대로면 폼을 다시 그리지 않는다) */
443
448
  let shownText = '';
444
449
 
450
+ // 키트 편집 화면 모양 (회색 바탕 · 아래 흰 저장 바)
451
+ document.body.classList.add('ec-edit-page');
445
452
  const editor = h('section', { className: 'ec-json' });
446
453
  const note = h('p', {
447
454
  className: 'ec-json-note',
@@ -637,7 +644,19 @@ export function useContentEditor(app, opts = {}) {
637
644
  : null
638
645
  : null);
639
646
  focusNext = null;
640
- formPanel.replaceChildren(...fields(schema, value, ''));
647
+ // 맨 위 칸(제목 · 안내처럼 묶음 · 목록이 아닌 칸)은 이어진 것끼리 흰 카드 하나에, 묶음 · 목록은 저마다 카드
648
+ const out = [];
649
+ let top = null;
650
+ for (const node of fields(schema, value, '')) {
651
+ if (node.matches('fieldset')) {
652
+ top = null;
653
+ out.push(node);
654
+ continue;
655
+ }
656
+ if (!top) out.push((top = h('div', { className: 'ec-edit-card ec-json-top' })));
657
+ top.append(node);
658
+ }
659
+ formPanel.replaceChildren(...out);
641
660
  if (keep) formPanel.querySelector(keep)?.focus();
642
661
  }
643
662
 
@@ -665,7 +684,7 @@ export function useContentEditor(app, opts = {}) {
665
684
  }
666
685
  if (type === 'object') {
667
686
  if (!isObj(current)) set((current = {}));
668
- const group = h('fieldset', { className: 'ec-json-group' });
687
+ const group = h('fieldset', { className: 'ec-json-group ec-edit-card' });
669
688
  group.dataset.path = path;
670
689
  group.append(h('legend', { textContent: label }));
671
690
  if (n.hint) group.append(h('p', { className: 'ec-json-hint', textContent: n.hint }));
@@ -673,7 +692,7 @@ export function useContentEditor(app, opts = {}) {
673
692
  return group;
674
693
  }
675
694
  const id = nextId();
676
- const wrap = h('div', { className: 'ec-json-field' });
695
+ const wrap = h('div', { className: 'ec-json-field ec-field' });
677
696
  let input;
678
697
  if (type === 'boolean') {
679
698
  wrap.classList.add('ec-json-switch');
@@ -687,7 +706,7 @@ export function useContentEditor(app, opts = {}) {
687
706
  return wrap;
688
707
  }
689
708
  if (Array.isArray(n.enum)) {
690
- input = h('select', { id });
709
+ input = h('select', { id, className: 'ec-field-input' });
691
710
  for (const opt of n.enum)
692
711
  input.append(h('option', { value: String(opt), textContent: String(opt) }));
693
712
  input.value = String(current ?? '');
@@ -696,7 +715,13 @@ export function useContentEditor(app, opts = {}) {
696
715
  set(picked);
697
716
  });
698
717
  } else if (type === 'number') {
699
- input = h('input', { type: 'number', id, step: 'any', inputMode: 'decimal' });
718
+ input = h('input', {
719
+ type: 'number',
720
+ id,
721
+ step: 'any',
722
+ inputMode: 'decimal',
723
+ className: 'ec-field-input',
724
+ });
700
725
  if (typeof n.min === 'number') input.min = String(n.min);
701
726
  if (typeof n.max === 'number') input.max = String(n.max);
702
727
  input.value = typeof current === 'number' ? String(current) : '';
@@ -707,19 +732,25 @@ export function useContentEditor(app, opts = {}) {
707
732
  } else {
708
733
  const text = typeof current === 'string' ? current : current == null ? '' : String(current);
709
734
  const long = n.multiline === true || text.length > LONG_TEXT || text.includes('\n');
710
- input = long ? h('textarea', { id, rows: 3 }) : h('input', { type: 'text', id });
735
+ input = long
736
+ ? h('textarea', { id, rows: 2, className: 'ec-field-input' })
737
+ : h('input', { type: 'text', id, className: 'ec-field-input' });
711
738
  input.value = text;
712
739
  if (n.placeholder) input.placeholder = n.placeholder;
713
740
  input.addEventListener('input', () => set(input.value));
714
741
  }
715
742
  input.dataset.path = path;
716
743
  if (n.required) input.setAttribute('aria-required', 'true');
717
- const l = h('label', { htmlFor: id, textContent: label });
744
+ const l = h('label', { htmlFor: id, textContent: label, className: 'ec-field-label' });
718
745
  if (n.required)
719
- l.append(hidden$(h('span', { className: 'ec-json-required', textContent: ' *' })));
746
+ l.append(hidden$(h('span', { className: 'ec-json-required ec-required', textContent: ' *' })));
720
747
  wrap.append(l);
721
748
  if (n.hint) {
722
- const hint = h('p', { className: 'ec-json-hint', textContent: n.hint, id: nextId() });
749
+ const hint = h('p', {
750
+ className: 'ec-json-hint ec-field-hint',
751
+ textContent: n.hint,
752
+ id: nextId(),
753
+ });
723
754
  input.setAttribute('aria-describedby', hint.id);
724
755
  wrap.append(hint);
725
756
  }
@@ -736,43 +767,47 @@ export function useContentEditor(app, opts = {}) {
736
767
  const asCard = itemType === 'object' || itemType === 'array';
737
768
  const min = typeof n.min === 'number' ? n.min : 0;
738
769
  const max = typeof n.max === 'number' ? n.max : Infinity;
739
- const box = h('fieldset', { className: 'ec-json-list' });
770
+ // 묶음 목록은 항목마다 카드, 글 · 숫자 목록은 목록 전체가 카드 하나
771
+ const box = h('fieldset', { className: asCard ? 'ec-json-list ec-section' : 'ec-json-list ec-edit-card' });
740
772
  box.dataset.path = path;
741
773
  const legend = h('legend', { textContent: label });
742
774
  legend.append(h('span', { className: 'ec-json-count', textContent: ` ${arr.length}개` }));
743
775
  box.append(legend);
744
776
  if (n.hint) box.append(h('p', { className: 'ec-json-hint', textContent: n.hint }));
745
- const rows = h('div', { className: asCard ? 'ec-json-cards' : 'ec-json-rows' });
777
+ const rows = h('div', { className: asCard ? 'ec-json-cards' : 'ec-json-rows ec-list' });
746
778
  const name = i => `${label} ${i + 1}`;
747
779
  arr.forEach((item, i) => {
748
- if (undo?.list === arr && undo.index === i) rows.append(undoNotice());
749
780
  const row = asCard
750
781
  ? card(itemNode, arr, i, path, name(i), arr.length > min)
751
782
  : line(itemNode, arr, i, path, name(i), arr.length > min);
752
783
  rows.append(row);
753
784
  });
754
- if (undo?.list === arr && undo.index >= arr.length) rows.append(undoNotice());
755
785
  box.append(rows);
756
786
 
757
787
  // 최소 개수: 닿으면 늘 보이는 안내 (삭제 버튼이 꺼진 까닭)
758
788
  if (min > 0 && arr.length <= min)
759
789
  box.append(
760
790
  h('p', {
761
- className: arr.length < min ? 'ec-json-hint ec-error' : 'ec-json-hint',
791
+ className:
792
+ arr.length < min ? 'ec-json-hint ec-list-caption ec-error' : 'ec-json-hint ec-list-caption',
762
793
  textContent: `${min}개 이상이어야 합니다`,
763
794
  })
764
795
  );
765
796
  const full = arr.length >= max;
766
797
  const add = h('button', {
767
798
  type: 'button',
768
- className: 'ec-json-add',
799
+ // 목록 안 줄 추가는 회색 채움, 카드를 더하는 추가는 점선
800
+ className: asCard ? 'ec-json-add ec-add' : 'ec-json-add ec-list-add',
769
801
  textContent: `+ ${label} 추가`,
770
802
  disabled: full,
771
803
  });
772
804
  add.dataset.path = `${path}+`;
773
805
  if (full)
774
806
  box.append(
775
- h('p', { className: 'ec-json-hint', textContent: `최대 ${max}개까지 넣을 수 있습니다` })
807
+ h('p', {
808
+ className: 'ec-json-hint ec-list-caption',
809
+ textContent: `최대 ${max}개까지 넣을 수 있습니다`,
810
+ })
776
811
  );
777
812
  add.addEventListener('click', () => {
778
813
  const sample = n.item ? emptyValue(itemNode) : emptyValue(inferSchema(arr[0] ?? ''));
@@ -788,10 +823,12 @@ export function useContentEditor(app, opts = {}) {
788
823
 
789
824
  /** 글 · 숫자 목록의 한 줄: 손잡이 → 번호 → 입력 → 빼기(✕) */
790
825
  function line(itemNode, arr, i, path, name, canDelete) {
791
- const row = h('div', { className: 'ec-json-row' });
826
+ const row = h('div', { className: 'ec-json-row ec-list-row' });
792
827
  row.dataset.role = 'row';
793
828
  const handle = sortHandle(arr, i, path, name);
794
- const marker = hidden$(h('span', { className: 'ec-json-no', textContent: String(i + 1) }));
829
+ const marker = hidden$(
830
+ h('span', { className: 'ec-json-no ec-list-no', textContent: String(i + 1) })
831
+ );
795
832
  const field = control(itemNode, arr[i], v => (arr[i] = v), joinPath(path, i), name);
796
833
  field.classList.add('ec-json-inline');
797
834
  // 줄 안에서는 라벨을 숨기고 aria로만
@@ -813,10 +850,10 @@ export function useContentEditor(app, opts = {}) {
813
850
  /** 묶음 목록의 카드: 머리(손잡이 · 이름 · ↑ · ↓ · 휴지통) + 칸들 */
814
851
  function card(itemNode, arr, i, path, name, canDelete) {
815
852
  const item = arr[i];
816
- const node = h('section', { className: 'ec-json-card' });
853
+ const node = h('section', { className: 'ec-json-card ec-edit-card' });
817
854
  node.dataset.role = 'row';
818
- const head = h('header', { className: 'ec-json-card-head' });
819
- const title = h('strong', { textContent: name });
855
+ const head = h('header', { className: 'ec-json-card-head ec-edit-card-head' });
856
+ const title = h('strong', { textContent: name, className: 'ec-edit-card-title' });
820
857
  // 첫 글 칸 값을 곁들여 어느 항목인지 보이게 (예: 항목 2 · 금성)
821
858
  const first = isObj(item)
822
859
  ? Object.values(item).find(v => typeof v === 'string' && v.trim())
@@ -860,48 +897,38 @@ export function useContentEditor(app, opts = {}) {
860
897
  const [item] = arr.splice(i, 1);
861
898
  dropUndo();
862
899
  undo = { list: arr, index: i, item, path };
863
- undo.timer = setTimeout(expireUndo, UNDO_MS);
864
- focusNext = '[data-role="undo"] button';
865
900
  renderForm();
901
+ // 지운 버튼이 사라지므로 초점은 스낵바의 되돌리기로 (키보드로 지웠을 때 갈 곳)
902
+ undoNotice();
866
903
  }
867
904
 
868
- /** "항목을 삭제했습니다. 되돌리기" (지운 자리에, UNDO_MS 뒤 사라짐) */
905
+ /** "항목을 삭제했습니다. 되돌리기" 스낵바 (화면 아래, UNDO_MS 뒤 사라짐) */
869
906
  function undoNotice() {
870
- // 키트 공통 알림(.ec-notice, 퀴즈 편집 화면의 문항 되돌리기와 같은 모양)
871
- const box = h('div', { className: 'ec-notice' });
872
- box.dataset.role = 'undo';
873
- box.setAttribute('role', 'status');
874
- box.dataset.ecQuiet = '';
875
- const back = h('button', {
876
- type: 'button',
877
- className: 'ec-text-button',
878
- textContent: '되돌리기',
879
- });
880
- back.addEventListener('click', () => {
881
- if (!undo) return;
882
- const { list: arr, index, item, path } = undo;
883
- arr.splice(Math.min(index, arr.length), 0, item);
884
- dropUndo();
885
- focusNext = `[data-sort="${q(path)}:${Math.min(index, arr.length - 1)}"]`;
886
- renderForm();
907
+ const current = undo;
908
+ const sel = `[data-path="${q(current.path)}+"]`;
909
+ current.bar = showSnackbar({
910
+ text: '항목을 삭제했습니다.',
911
+ ms: UNDO_MS,
912
+ focus: true,
913
+ onAction: () => {
914
+ const { list: arr, index, item, path } = current;
915
+ arr.splice(Math.min(index, arr.length), 0, item);
916
+ focusNext = `[data-sort="${q(path)}:${Math.min(index, arr.length - 1)}"]`;
917
+ renderForm();
918
+ },
919
+ onClose: () => {
920
+ if (undo === current) undo = null;
921
+ // 시간이 지나 사라질 때 초점이 스낵바에 있었으면 목록의 추가 버튼으로
922
+ if (current.bar?.element.contains(document.activeElement))
923
+ requestAnimationFrame(() => formPanel.querySelector(sel)?.focus());
924
+ },
887
925
  });
888
- box.append(h('span', { textContent: '항목을 삭제했습니다.' }), back);
889
- if (undo) undo.element = box;
890
- return box;
891
- }
892
- function expireUndo() {
893
- if (!undo) return;
894
- const box = undo.element;
895
- const hadFocus = box?.contains(document.activeElement);
896
- const sel = `[data-path="${q(undo.path)}+"]`;
897
- undo = null;
898
- // 지우지 않고 숨긴다 (저장 안 한 변경 표시가 다시 켜지지 않게)
899
- if (box) box.hidden = true;
900
- if (hadFocus) formPanel.querySelector(sel)?.focus();
926
+ current.bar.element.dataset.role = 'undo';
901
927
  }
902
928
  function dropUndo() {
903
- if (undo) clearTimeout(undo.timer);
929
+ const was = undo;
904
930
  undo = null;
931
+ was?.bar?.close();
905
932
  }
906
933
 
907
934
  /**
@@ -909,7 +936,11 @@ export function useContentEditor(app, opts = {}) {
909
936
  * 끄는 동안 다른 줄이 비켜 자리를 보여 준다 (끄는 줄에 data-dragging)
910
937
  */
911
938
  function sortHandle(arr, i, path, name) {
912
- const handle = h('button', { type: 'button', className: 'ec-json-handle', textContent: '⠿' });
939
+ const handle = h('button', {
940
+ type: 'button',
941
+ className: 'ec-json-handle ec-handle',
942
+ textContent: '⠿',
943
+ });
913
944
  handle.setAttribute('aria-label', `${name} 순서 바꾸기 (끌거나 ↑ · ↓ 키)`);
914
945
  handle.title = '끌어서 순서 바꾸기';
915
946
  handle.dataset.sort = `${path}:${i}`;