@eliceio/cdk-cli 1.5.3 → 1.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "rollup": "^4.0.0",
47
47
  "tslib": "^2.6.1",
48
48
  "typescript": "~5.9.3",
49
- "@eliceio/cdk": "^1.5.3"
49
+ "@eliceio/cdk": "^1.5.4"
50
50
  },
51
51
  "scripts": {
52
52
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
@@ -63,8 +63,21 @@ export declare function createEditor(opts: {
63
63
  },
64
64
  ): HTMLElement;
65
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 },
66
+ props: {
67
+ q: any;
68
+ index: number;
69
+ count: number;
70
+ full: boolean;
71
+ types: [string, string][];
72
+ body: Node[];
73
+ },
74
+ on: {
75
+ type(value: string): void;
76
+ up(): void;
77
+ down(): void;
78
+ duplicate(): void;
79
+ remove(): void;
80
+ },
68
81
  ): HTMLElement;
69
82
  /** 버튼에 고르기 목록(ui.typeMenu)을 붙인다. choices: [값, 이름] */
70
83
  picker(
@@ -553,7 +553,7 @@ export function createEditor({ rerender, root, templates, labels }) {
553
553
  }
554
554
 
555
555
  /**
556
- * 문항 카드: 유형 바꾸기 · 위로 · 아래로 · 삭제를 붙인다. on: { type(값), up(), down(), remove() }
556
+ * 문항 카드: 유형 바꾸기 · 위로 · 아래로 · 복제 · 삭제를 붙인다. on: { type(값), up(), down(), duplicate(), remove() }
557
557
  */
558
558
  /** 열린 유형 목록 하나 ({ button, close }) */
559
559
  let menu = null;
@@ -584,6 +584,7 @@ export function createEditor({ rerender, root, templates, labels }) {
584
584
  }
585
585
  part(node, 'up').addEventListener('click', on.up);
586
586
  part(node, 'down').addEventListener('click', on.down);
587
+ part(node, 'duplicate').addEventListener('click', on.duplicate);
587
588
  part(node, 'delete').addEventListener('click', on.remove);
588
589
  return node;
589
590
  }
@@ -19,6 +19,7 @@ import {
19
19
  LIMITS,
20
20
  makeContent,
21
21
  newQuestion,
22
+ nextId,
22
23
  normalizeScale,
23
24
  SCALE_MAXES,
24
25
  SCALE_MINS,
@@ -246,6 +247,7 @@ function questionCard(q, i) {
246
247
  q,
247
248
  index: i,
248
249
  count,
250
+ full: !canAddQuestion(draft.questions),
249
251
  types: TYPES.map(type => [type, texts.types[type]]),
250
252
  body,
251
253
  required: requiredSwitch(q),
@@ -257,6 +259,20 @@ function questionCard(q, i) {
257
259
  },
258
260
  up: () => swap(i, i - 1),
259
261
  down: () => swap(i, i + 1),
262
+ // 바로 아래에 새 문항 id로 복사한다. 보기 id는 문항 안에서만 쓰여 그대로 둔다
263
+ duplicate: () => {
264
+ if (!canAddQuestion(draft.questions)) return;
265
+ const copy = {
266
+ ...structuredClone(q),
267
+ id: nextId(
268
+ draft.questions.map(other => other.id),
269
+ 'q'
270
+ ),
271
+ };
272
+ draft.questions.splice(i + 1, 0, copy);
273
+ focusNext = `[data-focus="q-${copy.id}"]`;
274
+ changed();
275
+ },
260
276
  remove: () => {
261
277
  if (draft.questions.length === 1) return;
262
278
  draft.questions.splice(i, 1);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "survey",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "title": "설문조사",
5
5
  "description": "학생 의견을 모읍니다",
6
6
  "catalog": {
@@ -24,6 +24,22 @@ const icons = {
24
24
  />
25
25
  </svg>
26
26
  `,
27
+ copy: () => html`
28
+ <svg
29
+ viewBox="0 0 24 24"
30
+ width="18"
31
+ height="18"
32
+ fill="none"
33
+ stroke="currentColor"
34
+ stroke-width="2"
35
+ stroke-linecap="round"
36
+ stroke-linejoin="round"
37
+ aria-hidden="true"
38
+ >
39
+ <rect x="9" y="9" width="12" height="12" rx="2" />
40
+ <path d="M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1" />
41
+ </svg>
42
+ `,
27
43
  info: () => html`
28
44
  <svg
29
45
  viewBox="0 0 24 24"
@@ -567,10 +583,10 @@ export const typeMenu = ({ label, types, value }) => html`
567
583
 
568
584
  /**
569
585
  * 문항 카드. body: 문항 칸들 · types: [[값, 이름], …] · required: 필수 응답 스위치 (requiredSwitch)
570
- * data-role="type" (유형 버튼: 누르면 typeMenu) · data-role="up" · data-role="down" · data-role="delete"
571
- * 문항이 하나뿐이면 ↑ · ↓는 숨기고 삭제는 끈다 (설문에는 문항이 하나 이상 있어야 함)
586
+ * data-role="type" (유형 버튼: 누르면 typeMenu) · data-role="up" · data-role="down" · data-role="duplicate" · data-role="delete"
587
+ * 문항이 하나뿐이면 ↑ · ↓는 숨기고 삭제는 끈다 (설문에는 문항이 하나 이상 있어야 함). full: 문항이 최대 개수라 복제를 끈다
572
588
  */
573
- export const card = ({ q, index, count, types, body, required }) => html`
589
+ export const card = ({ q, index, count, full, types, body, required }) => html`
574
590
  <section class="qe-card ec-edit-card">
575
591
  <header class="qe-card-head ec-edit-card-head">
576
592
  <strong>${t.question(index + 1)}</strong>
@@ -609,6 +625,15 @@ export const card = ({ q, index, count, types, body, required }) => html`
609
625
  >
610
626
  ${t.down}
611
627
  </button>
628
+ <button
629
+ type="button"
630
+ class="ec-icon-button"
631
+ data-role="duplicate"
632
+ aria-label="${t.questionDuplicate(index + 1)}"
633
+ ${full && 'disabled'}
634
+ >
635
+ ${icons.copy()}
636
+ </button>
612
637
  <button
613
638
  type="button"
614
639
  class="ec-icon-button"
@@ -50,6 +50,7 @@ export const texts = {
50
50
  questionTypeNow: (no, type) => `문항 ${no} 유형: ${type}`,
51
51
  questionUp: no => `문항 ${no} 위로`,
52
52
  questionDown: no => `문항 ${no} 아래로`,
53
+ questionDuplicate: no => `문항 ${no} 복제`,
53
54
  questionDelete: no => `문항 ${no} 삭제`,
54
55
  titlePlaceholder: '질문을 입력하세요',
55
56
  addDescription: '설명 추가',