@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.
- package/README.md +69 -60
- package/es/cli.js +11 -2
- package/es/commands/build/index.js +12 -0
- package/es/commands/create/index.js +2 -1
- package/es/commands/create/scaffold.d.ts +2 -2
- package/es/commands/create/scaffold.js +3 -3
- package/es/commands/dev/index.d.ts +10 -1
- package/es/commands/dev/index.js +47 -7
- package/es/core/config.d.ts +20 -9
- package/es/core/config.js +53 -12
- package/es/core/project-check.d.ts +3 -2
- package/es/core/project-check.js +14 -3
- package/es/core/regex.d.ts +11 -0
- package/es/core/regex.js +41 -0
- package/es/core/sandbox.d.ts +26 -0
- package/es/core/sandbox.js +240 -30
- package/es/dev/check.d.ts +30 -0
- package/es/dev/check.js +224 -34
- package/es/dev/grading.d.ts +20 -1
- package/es/dev/grading.js +38 -7
- package/es/dev/host-page.js +1 -1
- package/es/dev/mock-api.d.ts +3 -1
- package/es/dev/mock-api.js +20 -11
- package/es/engines/vite/index.js +1 -1
- package/es/engines/vite/plugin.d.ts +2 -0
- package/es/engines/vite/plugin.js +33 -5
- package/es/rules/answers.d.ts +13 -0
- package/es/rules/answers.js +94 -0
- package/es/rules/check.js +70 -1
- package/es/rules/index.d.ts +1 -0
- package/es/rules/index.js +1 -0
- package/es/rules/size.d.ts +31 -0
- package/es/rules/size.js +58 -0
- package/es/rules/types.d.ts +12 -0
- package/es/rules.json.js +2 -2
- package/package.json +2 -2
- package/rules.json +32 -3
- package/skills/_shared/always.md +3 -3
- package/skills/_shared/references/00-what-the-person-decides.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -7
- package/skills/_shared/references/03-create-the-project.md +2 -1
- package/skills/_shared/references/05-screen-code.md +49 -22
- package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
- package/skills/_shared/references/08-fix-check-errors.md +23 -22
- package/skills/_shared/references/09-check.md +7 -6
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
- package/skills/_shared/references/13-edit-screen-design.md +122 -0
- package/skills/_shared/references/14-layouts.md +96 -0
- package/skills/elice-content-check/SKILL.md +2 -2
- package/skills/elice-content-create/SKILL.md +1 -1
- package/skills/elice-content-migrate/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +30 -3
- package/templates/_shared/lib/cdk-mock.js +88 -15
- package/templates/_shared/lib/elice-content-editor.js +89 -58
- package/templates/_shared/lib/elice-content.css +1313 -126
- package/templates/_shared/lib/elice-content.d.ts +162 -23
- package/templates/_shared/lib/elice-content.js +865 -84
- package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
- package/templates/_shared/lib/icons/empty-content.js +11 -0
- package/templates/_shared/lib/icons/file-video.d.ts +2 -0
- package/templates/_shared/lib/icons/file-video.js +11 -0
- package/templates/_shared/lib/icons/file.d.ts +2 -0
- package/templates/_shared/lib/icons/file.js +11 -0
- package/templates/blank/README.md +5 -3
- package/templates/blank/edit.html +8 -2
- package/templates/blank/index.html +6 -1
- package/templates/blank/instructor.html +6 -1
- package/templates/blank/template.json +1 -1
- package/templates/quiz/README.md +28 -12
- package/templates/quiz/core/behaviors.d.ts +13 -7
- package/templates/quiz/core/behaviors.js +36 -51
- package/templates/quiz/core/editor.d.ts +10 -0
- package/templates/quiz/core/editor.js +471 -8
- package/templates/quiz/core/markdown.d.ts +4 -0
- package/templates/quiz/core/markdown.js +65 -11
- package/templates/quiz/core/model.d.ts +34 -1
- package/templates/quiz/core/model.js +89 -7
- package/templates/quiz/core/rich-text.d.ts +19 -0
- package/templates/quiz/core/rich-text.js +521 -0
- package/templates/quiz/edit.html +12 -3
- package/templates/quiz/index.html +12 -3
- package/templates/quiz/screens/edit.js +848 -168
- package/templates/quiz/screens/learn.js +90 -14
- package/templates/quiz/styles.css +889 -213
- package/templates/quiz/template.json +9 -2
- package/templates/quiz/ui/templates/edit.d.ts +19 -6
- package/templates/quiz/ui/templates/edit.js +666 -87
- package/templates/quiz/ui/templates/group.js +19 -8
- package/templates/quiz/ui/templates/order.js +25 -24
- package/templates/quiz/ui/templates/page.js +19 -8
- package/templates/quiz/ui/templates/question.js +2 -2
- package/templates/quiz/ui/texts.js +104 -35
- package/templates/quiz/ui/theme.css +8 -9
- package/templates/steps/README.md +77 -0
- package/templates/steps/commentary.txt +7 -0
- package/templates/steps/edit.html +21 -0
- package/templates/steps/gitignore +4 -0
- package/templates/steps/index.html +69 -0
- package/templates/steps/metadata.json +9 -0
- package/templates/steps/package.json +13 -0
- package/templates/steps/screens/edit.js +32 -0
- package/templates/steps/screens/learn.js +108 -0
- package/templates/steps/styles.css +54 -0
- package/templates/steps/template.json +6 -0
|
@@ -1,19 +1,168 @@
|
|
|
1
1
|
// 내용 편집 화면(CMS)의 HTML 조각. 값 넣기 · 입력 반영 · 끌어서 순서 바꾸기는 core/editor.js가 붙입니다.
|
|
2
2
|
// 마크업 · 클래스는 자유롭게 바꿔도 되고, 각 조각에 적힌 data-role만 남기면 동작이 그대로입니다.
|
|
3
3
|
// 입력 칸에는 값을 넣지 않습니다 (동작이 value로 넣음).
|
|
4
|
-
import { html } from
|
|
5
|
-
import { texts } from
|
|
4
|
+
import { html } from "../../core/dom.js";
|
|
5
|
+
import { texts } from "../texts.js";
|
|
6
6
|
|
|
7
7
|
const t = texts.edit;
|
|
8
|
+
// 정답 칸 문구 (texts.answers). 이름을 따로 두는 것은 doctor의 정답 파일 이름 검사(answers.*)에 걸리지 않게 하려는 것
|
|
9
|
+
const ta = texts.answers;
|
|
8
10
|
/** 삭제 아이콘 (문항은 휴지통, 보기 · 그룹은 ✕). 요소는 한 자리에만 들어가므로 쓸 때마다 새로 만든다 (색은 버튼 글자색을 따름) */
|
|
9
11
|
const icons = {
|
|
10
12
|
trash: () => html`
|
|
11
|
-
<svg
|
|
12
|
-
|
|
13
|
+
<svg
|
|
14
|
+
viewBox="0 0 24 24"
|
|
15
|
+
width="18"
|
|
16
|
+
height="18"
|
|
17
|
+
fill="none"
|
|
18
|
+
stroke="currentColor"
|
|
19
|
+
stroke-width="2"
|
|
20
|
+
stroke-linecap="round"
|
|
21
|
+
stroke-linejoin="round"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
>
|
|
24
|
+
<path
|
|
25
|
+
d="M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
`,
|
|
29
|
+
info: () => html`
|
|
30
|
+
<svg
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
width="20"
|
|
33
|
+
height="20"
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="currentColor"
|
|
36
|
+
stroke-width="2"
|
|
37
|
+
stroke-linecap="round"
|
|
38
|
+
stroke-linejoin="round"
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
>
|
|
41
|
+
<circle cx="12" cy="12" r="9" />
|
|
42
|
+
<path d="M12 11v5M12 8h.01" />
|
|
43
|
+
</svg>
|
|
44
|
+
`,
|
|
45
|
+
check: () => html`
|
|
46
|
+
<svg
|
|
47
|
+
viewBox="0 0 24 24"
|
|
48
|
+
width="20"
|
|
49
|
+
height="20"
|
|
50
|
+
fill="none"
|
|
51
|
+
stroke="currentColor"
|
|
52
|
+
stroke-width="2.5"
|
|
53
|
+
stroke-linecap="round"
|
|
54
|
+
stroke-linejoin="round"
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
>
|
|
57
|
+
<path d="M5 12.5l4.5 4.5L19 7.5" />
|
|
58
|
+
</svg>
|
|
59
|
+
`,
|
|
60
|
+
textbox: () => html`
|
|
61
|
+
<svg
|
|
62
|
+
viewBox="0 0 24 24"
|
|
63
|
+
width="18"
|
|
64
|
+
height="18"
|
|
65
|
+
fill="none"
|
|
66
|
+
stroke="currentColor"
|
|
67
|
+
stroke-width="2"
|
|
68
|
+
stroke-linecap="round"
|
|
69
|
+
stroke-linejoin="round"
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
>
|
|
72
|
+
<rect x="3" y="6" width="18" height="12" rx="2" />
|
|
73
|
+
<path d="M8 10v4" />
|
|
74
|
+
</svg>
|
|
75
|
+
`,
|
|
76
|
+
// 설명 추가 (말풍선 줄)
|
|
77
|
+
comment: () => html`
|
|
78
|
+
<svg
|
|
79
|
+
viewBox="0 0 24 24"
|
|
80
|
+
width="18"
|
|
81
|
+
height="18"
|
|
82
|
+
fill="none"
|
|
83
|
+
stroke="currentColor"
|
|
84
|
+
stroke-width="2"
|
|
85
|
+
stroke-linecap="round"
|
|
86
|
+
stroke-linejoin="round"
|
|
87
|
+
aria-hidden="true"
|
|
88
|
+
>
|
|
89
|
+
<path d="M5 3.5h14a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-8.2L6 20.5v-4H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2z" />
|
|
90
|
+
<path d="M7.5 8.5h9M7.5 12h6" />
|
|
91
|
+
</svg>
|
|
92
|
+
`,
|
|
93
|
+
chevronDown: () => html`
|
|
94
|
+
<svg
|
|
95
|
+
viewBox="0 0 24 24"
|
|
96
|
+
width="16"
|
|
97
|
+
height="16"
|
|
98
|
+
fill="none"
|
|
99
|
+
stroke="currentColor"
|
|
100
|
+
stroke-width="2.5"
|
|
101
|
+
stroke-linecap="round"
|
|
102
|
+
stroke-linejoin="round"
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
>
|
|
105
|
+
<path d="M6 9l6 6 6-6" />
|
|
106
|
+
</svg>
|
|
107
|
+
`,
|
|
108
|
+
align: () => html`
|
|
109
|
+
<svg
|
|
110
|
+
viewBox="0 0 24 24"
|
|
111
|
+
width="18"
|
|
112
|
+
height="18"
|
|
113
|
+
fill="none"
|
|
114
|
+
stroke="currentColor"
|
|
115
|
+
stroke-width="2"
|
|
116
|
+
stroke-linecap="round"
|
|
117
|
+
stroke-linejoin="round"
|
|
118
|
+
aria-hidden="true"
|
|
119
|
+
>
|
|
120
|
+
<path d="M4 6h16M4 10h10M4 14h16M4 18h10" />
|
|
121
|
+
</svg>
|
|
122
|
+
`,
|
|
123
|
+
bulb: () => html`
|
|
124
|
+
<svg
|
|
125
|
+
viewBox="0 0 24 24"
|
|
126
|
+
width="18"
|
|
127
|
+
height="18"
|
|
128
|
+
fill="none"
|
|
129
|
+
stroke="currentColor"
|
|
130
|
+
stroke-width="2"
|
|
131
|
+
stroke-linecap="round"
|
|
132
|
+
stroke-linejoin="round"
|
|
133
|
+
aria-hidden="true"
|
|
134
|
+
>
|
|
135
|
+
<path
|
|
136
|
+
d="M9 18h6M10 21h4M12 3a6 6 0 0 0-3.5 10.9c.6.5 1 1.2 1 2.1h5c0-.9.4-1.6 1-2.1A6 6 0 0 0 12 3z"
|
|
137
|
+
/>
|
|
138
|
+
</svg>
|
|
139
|
+
`,
|
|
140
|
+
shuffle: () => html`
|
|
141
|
+
<svg
|
|
142
|
+
viewBox="0 0 24 24"
|
|
143
|
+
width="16"
|
|
144
|
+
height="16"
|
|
145
|
+
fill="none"
|
|
146
|
+
stroke="currentColor"
|
|
147
|
+
stroke-width="2"
|
|
148
|
+
stroke-linecap="round"
|
|
149
|
+
stroke-linejoin="round"
|
|
150
|
+
aria-hidden="true"
|
|
151
|
+
>
|
|
152
|
+
<path d="M16 3h5v5M4 20 21 3M21 16v5h-5M15 15l6 6M4 4l5 5" />
|
|
13
153
|
</svg>
|
|
14
154
|
`,
|
|
15
155
|
xmark: () => html`
|
|
16
|
-
<svg
|
|
156
|
+
<svg
|
|
157
|
+
viewBox="0 0 24 24"
|
|
158
|
+
width="18"
|
|
159
|
+
height="18"
|
|
160
|
+
fill="none"
|
|
161
|
+
stroke="currentColor"
|
|
162
|
+
stroke-width="2"
|
|
163
|
+
stroke-linecap="round"
|
|
164
|
+
aria-hidden="true"
|
|
165
|
+
>
|
|
17
166
|
<path d="M6 6l12 12M18 6L6 18" />
|
|
18
167
|
</svg>
|
|
19
168
|
`,
|
|
@@ -21,19 +170,19 @@ const icons = {
|
|
|
21
170
|
/** 보기 · 그룹 목록에서 종류마다 다른 문구와 번호 표시 */
|
|
22
171
|
const KIND = {
|
|
23
172
|
option: {
|
|
24
|
-
marker: i => String(i + 1),
|
|
25
|
-
name: i => t.option(i + 1),
|
|
26
|
-
input: i => t.option(i + 1),
|
|
27
|
-
remove: i => t.optionDelete(i + 1),
|
|
173
|
+
marker: (i) => String(i + 1),
|
|
174
|
+
name: (i) => t.option(i + 1),
|
|
175
|
+
input: (i) => t.option(i + 1),
|
|
176
|
+
remove: (i) => t.optionDelete(i + 1),
|
|
28
177
|
min: t.optionsMin,
|
|
29
178
|
max: t.optionsMax,
|
|
30
179
|
add: t.addOption,
|
|
31
180
|
},
|
|
32
181
|
group: {
|
|
33
|
-
marker: i => String.fromCharCode(65 + i),
|
|
34
|
-
name: i => t.group(i + 1),
|
|
35
|
-
input: i => t.groupName(i + 1),
|
|
36
|
-
remove: i => t.groupDelete(i + 1),
|
|
182
|
+
marker: (i) => String.fromCharCode(65 + i),
|
|
183
|
+
name: (i) => t.group(i + 1),
|
|
184
|
+
input: (i) => t.groupName(i + 1),
|
|
185
|
+
remove: (i) => t.groupDelete(i + 1),
|
|
37
186
|
min: t.groupsMin,
|
|
38
187
|
max: t.groupsMax,
|
|
39
188
|
add: t.addGroup,
|
|
@@ -59,54 +208,244 @@ export const field = ({
|
|
|
59
208
|
<label class="qe-field">
|
|
60
209
|
<span class="qe-label">${label}${mark}</span>
|
|
61
210
|
${hint && html`<span class="qe-hint">${hint}</span>`}
|
|
62
|
-
${
|
|
63
|
-
|
|
64
|
-
|
|
211
|
+
${
|
|
212
|
+
multiline
|
|
213
|
+
? html`<textarea class="qe-input" data-role="input"></textarea>`
|
|
214
|
+
: html`<input class="qe-input" data-role="input" />`
|
|
215
|
+
}
|
|
65
216
|
${max && html`<span class="qe-count" data-role="count"></span>`}
|
|
66
217
|
</label>
|
|
67
218
|
`;
|
|
68
219
|
};
|
|
69
220
|
|
|
221
|
+
/**
|
|
222
|
+
* 라벨 없는 바로 쓰는 칸 (퀴즈 제목 · 안내, 질문 · 설명). 보이는 라벨 대신 placeholder와 글자 크기로 무슨 칸인지 알리고,
|
|
223
|
+
* 화면 낭독기에는 aria-label로 이름을 준다. size: 'title'(퀴즈 제목) · 'question'(질문) · 'body'(안내 · 설명)
|
|
224
|
+
* data-role="input" (input · textarea) · max가 있고 showCount가 false가 아니면 data-role="count" (글자 수, 칸에 초점이 있을 때만 보임)
|
|
225
|
+
* showCount: false면 max(입력 제한)는 지키되 글자 수 표시는 뺀다
|
|
226
|
+
* 필수 칸은 data-required: 비운 채 저장하면 동작이 aria-invalid를 붙인다 (빨간 밑줄)
|
|
227
|
+
*/
|
|
228
|
+
export const inlineField = ({
|
|
229
|
+
label,
|
|
230
|
+
placeholder,
|
|
231
|
+
size = "body",
|
|
232
|
+
required = false,
|
|
233
|
+
max,
|
|
234
|
+
showCount = true,
|
|
235
|
+
multiline = false,
|
|
236
|
+
}) => html`
|
|
237
|
+
<div class="qe-inline qe-inline-${size} ec-field ec-field-${size}">
|
|
238
|
+
${
|
|
239
|
+
multiline
|
|
240
|
+
? html`<textarea
|
|
241
|
+
class="qe-inline-input ec-field-input"
|
|
242
|
+
data-role="input"
|
|
243
|
+
rows="1"
|
|
244
|
+
aria-label="${label}"
|
|
245
|
+
placeholder="${placeholder}"
|
|
246
|
+
${required && "data-required aria-required=true"}
|
|
247
|
+
></textarea>`
|
|
248
|
+
: html`<input
|
|
249
|
+
class="qe-inline-input ec-field-input"
|
|
250
|
+
data-role="input"
|
|
251
|
+
aria-label="${label}"
|
|
252
|
+
placeholder="${placeholder}"
|
|
253
|
+
${required && "data-required aria-required=true"}
|
|
254
|
+
/>`
|
|
255
|
+
}
|
|
256
|
+
${max && showCount && html`<span class="qe-count ec-field-count" data-role="count"></span>`}
|
|
257
|
+
</div>
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 지문 · 해설 칸 (보이는 그대로 고치는 글 칸과 올린 그림 칸이 차례로). 동작(core/editor.js richField)이 칸을 채운다.
|
|
262
|
+
* data-role="input" (값을 든 숨은 textarea) · "blocks" (글 칸 blockText · 그림 칸 blockImage가 들어가는 자리)
|
|
263
|
+
*/
|
|
264
|
+
export const richField = ({ label }) => html`
|
|
265
|
+
<div class="qe-inline qe-inline-body qe-blocks ec-field ec-field-body" role="group" aria-label="${label}">
|
|
266
|
+
<textarea data-role="input" hidden tabindex="-1" aria-hidden="true"></textarea>
|
|
267
|
+
<div class="qe-blocks-list" data-role="blocks"></div>
|
|
268
|
+
</div>
|
|
269
|
+
`;
|
|
270
|
+
|
|
271
|
+
/** 글 칸 (contenteditable). 비어 있으면 data-empty가 붙어 placeholder 글을 보인다 */
|
|
272
|
+
export const blockText = ({ label, placeholder }) => html`
|
|
273
|
+
<div
|
|
274
|
+
class="qe-inline-input qe-wys qz-markdown"
|
|
275
|
+
data-role="block-text"
|
|
276
|
+
contenteditable="true"
|
|
277
|
+
role="textbox"
|
|
278
|
+
aria-multiline="true"
|
|
279
|
+
aria-label="${label}"
|
|
280
|
+
data-placeholder="${placeholder}"
|
|
281
|
+
></div>
|
|
282
|
+
`;
|
|
283
|
+
|
|
284
|
+
/** 올린 그림 칸. data-role="block-remove" (그림 지우기) */
|
|
285
|
+
export const blockImage = ({ alt, src, removeLabel }) => html`
|
|
286
|
+
<figure class="qe-block-image">
|
|
287
|
+
${src && html`<img src="${src}" alt="${alt}" />`}
|
|
288
|
+
<button
|
|
289
|
+
type="button"
|
|
290
|
+
class="qe-block-remove"
|
|
291
|
+
data-role="block-remove"
|
|
292
|
+
aria-label="${removeLabel}"
|
|
293
|
+
title="${removeLabel}"
|
|
294
|
+
>
|
|
295
|
+
${icons.xmark()}
|
|
296
|
+
</button>
|
|
297
|
+
</figure>
|
|
298
|
+
`;
|
|
299
|
+
|
|
300
|
+
const toolIcon = {
|
|
301
|
+
ul: () => html`
|
|
302
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
303
|
+
<line x1="8" y1="6" x2="21" y2="6" /><line x1="8" y1="12" x2="21" y2="12" /><line x1="8" y1="18" x2="21" y2="18" />
|
|
304
|
+
<line x1="3" y1="6" x2="3.01" y2="6" /><line x1="3" y1="12" x2="3.01" y2="12" /><line x1="3" y1="18" x2="3.01" y2="18" />
|
|
305
|
+
</svg>
|
|
306
|
+
`,
|
|
307
|
+
ol: () => html`
|
|
308
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
309
|
+
<line x1="10" x2="21" y1="6" y2="6" /><line x1="10" x2="21" y1="12" y2="12" /><line x1="10" x2="21" y1="18" y2="18" />
|
|
310
|
+
<path d="M4 6h1v4" /><path d="M4 10h2" /><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" />
|
|
311
|
+
</svg>
|
|
312
|
+
`,
|
|
313
|
+
code: () => html`
|
|
314
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
315
|
+
<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />
|
|
316
|
+
</svg>
|
|
317
|
+
`,
|
|
318
|
+
image: () => html`
|
|
319
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
320
|
+
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" />
|
|
321
|
+
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
|
|
322
|
+
</svg>
|
|
323
|
+
`,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 지문 · 해설 서식 도구 (칸에 초점이 있을 때 칸 아래에 뜸). 버튼마다 data-role:
|
|
328
|
+
* "md-bold" · "md-italic" · "md-strike" · "md-ul" · "md-ol" · "md-code" · "md-image" (그림 올리기, 못 쓰면 동작이 숨김)
|
|
329
|
+
*/
|
|
330
|
+
export const mdTools = () => {
|
|
331
|
+
const m = t.md;
|
|
332
|
+
const tool = (role, name, glyph) => html`
|
|
333
|
+
<button type="button" class="qe-md-btn" data-role="${role}" aria-label="${name}" title="${name}" aria-pressed="false">
|
|
334
|
+
${glyph}
|
|
335
|
+
</button>
|
|
336
|
+
`;
|
|
337
|
+
return html`
|
|
338
|
+
<div class="qe-md" role="toolbar" aria-label="${m.toolbar}">
|
|
339
|
+
${tool("md-bold", m.bold, html`<b>B</b>`)} ${tool("md-italic", m.italic, html`<i>I</i>`)}
|
|
340
|
+
${tool("md-strike", m.strike, html`<s>S</s>`)}
|
|
341
|
+
<span class="qe-md-sep" aria-hidden="true"></span>
|
|
342
|
+
${tool("md-ul", m.ul, toolIcon.ul())} ${tool("md-ol", m.ol, toolIcon.ol())}
|
|
343
|
+
<span class="qe-md-sep" aria-hidden="true"></span>
|
|
344
|
+
${tool("md-code", m.code, toolIcon.code())}
|
|
345
|
+
<button type="button" class="qe-md-btn" data-role="md-image" aria-label="${m.image}" title="${m.image}">
|
|
346
|
+
${toolIcon.image()}
|
|
347
|
+
</button>
|
|
348
|
+
</div>
|
|
349
|
+
`;
|
|
350
|
+
};
|
|
351
|
+
|
|
70
352
|
/** 숫자 칸 (순서 맞추기 답안 칸 수). data-role="input" */
|
|
71
353
|
export const numberField = ({ label, hint, max }) => html`
|
|
72
354
|
<label class="qe-field">
|
|
73
355
|
<span class="qe-label">${label}</span>
|
|
74
356
|
<span class="qe-hint">${hint}</span>
|
|
75
|
-
<input
|
|
357
|
+
<input
|
|
358
|
+
type="number"
|
|
359
|
+
min="1"
|
|
360
|
+
max="${max}"
|
|
361
|
+
class="qe-input qe-number"
|
|
362
|
+
data-role="input"
|
|
363
|
+
/>
|
|
76
364
|
</label>
|
|
77
365
|
`;
|
|
78
366
|
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
367
|
+
/**
|
|
368
|
+
* 켜고 끄기 EDS Chip (꺼짐 outlined · 켜짐 muted primary + 체크). data-role="input" (checkbox, 화면에서만 숨김). title: 마우스를 올리면 보이는 보충 설명
|
|
369
|
+
* icon: icons의 이름 (예: 'shuffle')
|
|
370
|
+
*/
|
|
371
|
+
export const toggle = ({ label, title = "", icon }) => html`
|
|
372
|
+
<label class="qe-switch ec-toggle" title="${title}">
|
|
82
373
|
<input type="checkbox" data-role="input" />
|
|
374
|
+
${icon && html`<span class="qe-chip-icon qe-chip-off ec-toggle-off">${icons[icon]?.()}</span>`}
|
|
375
|
+
${icon && html`<span class="qe-chip-icon qe-chip-on ec-toggle-on">${icons.check()}</span>`}
|
|
83
376
|
<span>${label}</span>
|
|
84
377
|
</label>
|
|
85
378
|
`;
|
|
86
379
|
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
380
|
+
/**
|
|
381
|
+
* 제목이 붙은 묶음 (보기 · 그룹 · 정답). action: 제목줄 오른쪽에 둘 요소 (예: 보기 순서 섞기 토글)
|
|
382
|
+
* hintInline: true면 안내를 제목 바로 옆(같은 줄, 길면 말줄임)에 둔다. 아니면 제목 아래 줄
|
|
383
|
+
*/
|
|
384
|
+
export const section = ({ label, hint, body, action, hintInline = false }) => html`
|
|
385
|
+
<div class="qe-section ec-section">
|
|
386
|
+
<div class="qe-section-head ec-section-head">
|
|
387
|
+
<span class="qe-label ec-label">${label}</span>
|
|
388
|
+
${hint && hintInline && html`<span class="qe-hint-inline ec-hint-inline" title="${hint}">${hint}</span>`}
|
|
389
|
+
${action}
|
|
390
|
+
</div>
|
|
391
|
+
${hint && !hintInline && html`<span class="qe-hint">${hint}</span>`} ${body}
|
|
92
392
|
</div>
|
|
93
393
|
`;
|
|
94
394
|
|
|
395
|
+
/**
|
|
396
|
+
* 필요할 때만 여는 칸 (설명 · 해설). 닫혀 있으면 윤곽선 알약 버튼만 보인다.
|
|
397
|
+
* title이 있으면(해설) 열렸을 때 머리줄(아이콘 · 제목 · 지우기)이 있는 카드 안에 칸을 둔다.
|
|
398
|
+
* data-role="reveal" (열기 버튼) · "reveal-body" (열린 칸 묶음, 닫히면 hidden) · "reveal-close" (비우고 닫기)
|
|
399
|
+
* icon: icons의 이름 (예: 'bulb') · hint: 이름 옆에 두는 보조 글자 (글을 써도 사라지지 않는 안내)
|
|
400
|
+
*/
|
|
401
|
+
const revealClose = (name, glyph) => html`
|
|
402
|
+
<button
|
|
403
|
+
type="button"
|
|
404
|
+
class="ec-icon-button ec-danger"
|
|
405
|
+
data-role="reveal-close"
|
|
406
|
+
aria-label="${t.revealClose(name)}"
|
|
407
|
+
title="${t.revealClose(name)}"
|
|
408
|
+
>
|
|
409
|
+
${glyph}
|
|
410
|
+
</button>
|
|
411
|
+
`;
|
|
412
|
+
|
|
413
|
+
export const reveal = ({ label, field, title, icon, hint }) =>
|
|
414
|
+
title
|
|
415
|
+
? html`
|
|
416
|
+
<div class="qe-reveal qe-reveal-card ec-reveal">
|
|
417
|
+
<button type="button" class="qe-reveal-button ec-reveal-button" data-role="reveal">
|
|
418
|
+
${icon && icons[icon]?.()}<span>${label}</span
|
|
419
|
+
><span aria-hidden="true">+</span>
|
|
420
|
+
</button>
|
|
421
|
+
<div class="qe-reveal-body ec-reveal-body" data-role="reveal-body">
|
|
422
|
+
<div class="qe-reveal-head ec-reveal-head">
|
|
423
|
+
${icon && icons[icon]?.()}<strong>${title}</strong>
|
|
424
|
+
${hint && html`<span class="qe-reveal-hint ec-hint-inline" title="${hint}">${hint}</span>`}
|
|
425
|
+
${revealClose(title, icons.trash())}
|
|
426
|
+
</div>
|
|
427
|
+
<div class="qe-reveal-field">${field}</div>
|
|
428
|
+
</div>
|
|
429
|
+
</div>
|
|
430
|
+
`
|
|
431
|
+
: html`
|
|
432
|
+
<div class="qe-reveal ec-reveal">
|
|
433
|
+
<button type="button" class="qe-reveal-button ec-reveal-button" data-role="reveal">
|
|
434
|
+
${label}
|
|
435
|
+
</button>
|
|
436
|
+
<div class="qe-reveal-body ec-reveal-body" data-role="reveal-body">
|
|
437
|
+
${field} ${revealClose(label, icons.xmark())}
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
`;
|
|
441
|
+
|
|
95
442
|
/**
|
|
96
443
|
* 보기 · 그룹 목록. rows: row()들 (같은 부모 아래 형제로 두어야 끌어서 순서 바꾸기가 됨)
|
|
97
|
-
* answer: 정답 칸 종류(있으면
|
|
98
|
-
* atMin: 최소 개수라 지울 수 없음 (
|
|
444
|
+
* answer: 정답 칸 종류(있으면 줄마다 정답 칸이 붙음, 열 머리는 두지 않음) ·
|
|
445
|
+
* atMin: 최소 개수라 지울 수 없음 (줄의 ✕ 버튼이 비활성이 되고 마우스를 올리면 이유가 보임)
|
|
99
446
|
*/
|
|
100
447
|
export const list = ({ kind, rows, add, answer, atMin, min }) => html`
|
|
101
|
-
<div class="qe-options">
|
|
102
|
-
${answer &&
|
|
103
|
-
html`<div class="qe-option qe-answer-head qe-answer-head-${answer}" data-role="answer-head" aria-hidden="true">
|
|
104
|
-
<span class="qe-handle-space"></span>
|
|
105
|
-
<span class="qe-answer-col">${t.answer}</span>
|
|
106
|
-
</div>`}
|
|
107
|
-
${rows}${add}
|
|
108
|
-
${atMin && html`<p class="qe-caption">${KIND[kind].min(min)}</p>`}
|
|
109
|
-
</div>
|
|
448
|
+
<div class="qe-options ec-list">${rows}${add}</div>
|
|
110
449
|
`;
|
|
111
450
|
|
|
112
451
|
/**
|
|
@@ -114,7 +453,7 @@ export const list = ({ kind, rows, add, answer, atMin, min }) => html`
|
|
|
114
453
|
* name: 문항마다 다른 이름 (같은 문항의 radio끼리 묶임). data-role="answer" (input · select, 값은 동작이 넣음)
|
|
115
454
|
*/
|
|
116
455
|
const answerControl = ({ type, name, choices = [] }, index) =>
|
|
117
|
-
type ===
|
|
456
|
+
type === "select"
|
|
118
457
|
? html`
|
|
119
458
|
<select
|
|
120
459
|
class="qe-input qe-answer-group"
|
|
@@ -127,7 +466,7 @@ const answerControl = ({ type, name, choices = [] }, index) =>
|
|
|
127
466
|
</select>
|
|
128
467
|
`
|
|
129
468
|
: html`
|
|
130
|
-
<label class="qe-answer qe-answer-col">
|
|
469
|
+
<label class="qe-answer qe-answer-col ec-answer-mark" title="${t.answerTitle}">
|
|
131
470
|
<input
|
|
132
471
|
type="${type}"
|
|
133
472
|
data-role="answer"
|
|
@@ -139,33 +478,50 @@ const answerControl = ({ type, name, choices = [] }, index) =>
|
|
|
139
478
|
|
|
140
479
|
/**
|
|
141
480
|
* 보기 · 그룹 한 줄. kind: 'option' | 'group' · index: 0부터 · canDelete: 최소 개수보다 많음
|
|
142
|
-
* answer: 있으면 정답 칸 (answerControl, 단일 · 복수 · 그룹 문항의 보기)
|
|
481
|
+
* answer: 있으면 정답 칸 (answerControl, 단일 · 복수 · 그룹 문항의 보기) · numbered: false면 번호 표시를 뺀다 (단일 · 복수 선택)
|
|
143
482
|
* data-role="handle" (끌기 손잡이) · data-role="input" · data-role="delete" · 있으면 data-role="answer"
|
|
144
483
|
*/
|
|
145
|
-
export const row = ({
|
|
484
|
+
export const row = ({
|
|
485
|
+
kind,
|
|
486
|
+
index,
|
|
487
|
+
canDelete,
|
|
488
|
+
min,
|
|
489
|
+
answer,
|
|
490
|
+
numbered = true,
|
|
491
|
+
}) => {
|
|
146
492
|
const k = KIND[kind];
|
|
147
493
|
return html`
|
|
148
|
-
<div class="qe-option">
|
|
494
|
+
<div class="qe-option ec-list-row">
|
|
149
495
|
<button
|
|
150
496
|
type="button"
|
|
151
|
-
class="qe-handle"
|
|
497
|
+
class="qe-handle ec-handle"
|
|
152
498
|
data-role="handle"
|
|
153
499
|
aria-label="${t.sortLabel(k.name(index))}"
|
|
154
500
|
title="${t.sortTitle}"
|
|
155
501
|
>
|
|
156
502
|
${t.handle}
|
|
157
503
|
</button>
|
|
158
|
-
${answer && answer.type !==
|
|
159
|
-
|
|
160
|
-
<
|
|
161
|
-
|
|
504
|
+
${answer && answer.type !== "select" && answerControl(answer, index)}
|
|
505
|
+
${numbered && html`<span class="qe-option-no ec-list-no">${k.marker(index)}</span>`}
|
|
506
|
+
<span class="qe-option-field">
|
|
507
|
+
<input
|
|
508
|
+
class="qe-inline-input qe-option-text ec-field-input"
|
|
509
|
+
data-role="input"
|
|
510
|
+
aria-label="${k.input(index)}"
|
|
511
|
+
placeholder="${k.input(index)}"
|
|
512
|
+
/>
|
|
513
|
+
${answer &&
|
|
514
|
+
answer.type !== "select" &&
|
|
515
|
+
html`<span class="qe-correct-tag" aria-hidden="true">${t.correctTag}</span>`}
|
|
516
|
+
</span>
|
|
517
|
+
${answer && answer.type === "select" && answerControl(answer, index)}
|
|
162
518
|
<button
|
|
163
519
|
type="button"
|
|
164
520
|
class="ec-icon-button ec-danger"
|
|
165
521
|
data-role="delete"
|
|
166
522
|
aria-label="${k.remove(index)}"
|
|
167
|
-
title="${canDelete ?
|
|
168
|
-
${!canDelete &&
|
|
523
|
+
title="${canDelete ? "" : k.min(min)}"
|
|
524
|
+
${!canDelete && "disabled"}
|
|
169
525
|
>
|
|
170
526
|
${icons.xmark()}
|
|
171
527
|
</button>
|
|
@@ -177,36 +533,154 @@ export const row = ({ kind, index, canDelete, min, answer }) => {
|
|
|
177
533
|
export const addButton = ({ kind, full, max }) => html`
|
|
178
534
|
<button
|
|
179
535
|
type="button"
|
|
180
|
-
class="qe-add"
|
|
181
|
-
title="${full ? KIND[kind].max(max) :
|
|
182
|
-
${full &&
|
|
536
|
+
class="qe-add ec-list-add"
|
|
537
|
+
title="${full ? KIND[kind].max(max) : ""}"
|
|
538
|
+
${full && "disabled"}
|
|
183
539
|
>
|
|
184
540
|
${KIND[kind].add}
|
|
185
541
|
</button>
|
|
186
542
|
`;
|
|
187
543
|
|
|
544
|
+
/** 문항 유형 아이콘 (유형 고르기 앞) */
|
|
545
|
+
const typeIcons = {
|
|
546
|
+
select_one: () => html`
|
|
547
|
+
<svg
|
|
548
|
+
viewBox="0 0 24 24"
|
|
549
|
+
width="16"
|
|
550
|
+
height="16"
|
|
551
|
+
fill="none"
|
|
552
|
+
stroke="currentColor"
|
|
553
|
+
stroke-width="2"
|
|
554
|
+
stroke-linecap="round"
|
|
555
|
+
stroke-linejoin="round"
|
|
556
|
+
aria-hidden="true"
|
|
557
|
+
>
|
|
558
|
+
<circle cx="12" cy="12" r="9" />
|
|
559
|
+
<circle cx="12" cy="12" r="3.5" fill="currentColor" stroke="none" />
|
|
560
|
+
</svg>
|
|
561
|
+
`,
|
|
562
|
+
select_multiple: () => html`
|
|
563
|
+
<svg
|
|
564
|
+
viewBox="0 0 24 24"
|
|
565
|
+
width="16"
|
|
566
|
+
height="16"
|
|
567
|
+
fill="none"
|
|
568
|
+
stroke="currentColor"
|
|
569
|
+
stroke-width="2"
|
|
570
|
+
stroke-linecap="round"
|
|
571
|
+
stroke-linejoin="round"
|
|
572
|
+
aria-hidden="true"
|
|
573
|
+
>
|
|
574
|
+
<rect x="4" y="4" width="16" height="16" rx="3" />
|
|
575
|
+
<path d="M8.5 12.5l2.5 2.5 4.5-5" />
|
|
576
|
+
</svg>
|
|
577
|
+
`,
|
|
578
|
+
order: () => html`
|
|
579
|
+
<svg
|
|
580
|
+
viewBox="0 0 24 24"
|
|
581
|
+
width="16"
|
|
582
|
+
height="16"
|
|
583
|
+
fill="none"
|
|
584
|
+
stroke="currentColor"
|
|
585
|
+
stroke-width="2"
|
|
586
|
+
stroke-linecap="round"
|
|
587
|
+
stroke-linejoin="round"
|
|
588
|
+
aria-hidden="true"
|
|
589
|
+
>
|
|
590
|
+
<path d="M10 6h10M10 12h10M10 18h10M4.5 6h.01M4.5 12h.01M4.5 18h.01" />
|
|
591
|
+
</svg>
|
|
592
|
+
`,
|
|
593
|
+
text: () => html`
|
|
594
|
+
<svg
|
|
595
|
+
viewBox="0 0 24 24"
|
|
596
|
+
width="16"
|
|
597
|
+
height="16"
|
|
598
|
+
fill="none"
|
|
599
|
+
stroke="currentColor"
|
|
600
|
+
stroke-width="2"
|
|
601
|
+
stroke-linecap="round"
|
|
602
|
+
stroke-linejoin="round"
|
|
603
|
+
aria-hidden="true"
|
|
604
|
+
>
|
|
605
|
+
<rect x="3" y="6" width="18" height="12" rx="2" />
|
|
606
|
+
<path d="M8 10v4" />
|
|
607
|
+
</svg>
|
|
608
|
+
`,
|
|
609
|
+
group: () => html`
|
|
610
|
+
<svg
|
|
611
|
+
viewBox="0 0 24 24"
|
|
612
|
+
width="16"
|
|
613
|
+
height="16"
|
|
614
|
+
fill="none"
|
|
615
|
+
stroke="currentColor"
|
|
616
|
+
stroke-width="2"
|
|
617
|
+
stroke-linecap="round"
|
|
618
|
+
stroke-linejoin="round"
|
|
619
|
+
aria-hidden="true"
|
|
620
|
+
>
|
|
621
|
+
<rect x="3" y="3" width="8" height="8" rx="2" />
|
|
622
|
+
<rect x="13" y="3" width="8" height="8" rx="2" />
|
|
623
|
+
<rect x="3" y="13" width="8" height="8" rx="2" />
|
|
624
|
+
<rect x="13" y="13" width="8" height="8" rx="2" />
|
|
625
|
+
</svg>
|
|
626
|
+
`,
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
const typeName = (types, value) => types.find(([v]) => v === value)?.[1] ?? "";
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* 유형 고르기 목록 (문제 카드의 유형 버튼을 누르면 버튼 아래에 뜬다). 열고 닫기 · 키보드는 core/editor.js가 붙인다.
|
|
633
|
+
* 꼭 남길 것: role="listbox", 항목마다 role="option" · data-value · aria-selected (고른 항목에는 체크)
|
|
634
|
+
*/
|
|
635
|
+
export const typeMenu = ({ label, types, value }) => html`
|
|
636
|
+
<div class="qe-menu" role="listbox" aria-label="${label}">
|
|
637
|
+
${types.map(
|
|
638
|
+
([v, name]) => html`
|
|
639
|
+
<div
|
|
640
|
+
class="qe-menu-item"
|
|
641
|
+
role="option"
|
|
642
|
+
tabindex="-1"
|
|
643
|
+
data-value="${v}"
|
|
644
|
+
aria-selected="${v === value ? "true" : "false"}"
|
|
645
|
+
>
|
|
646
|
+
${typeIcons[v]?.()}
|
|
647
|
+
<span class="qe-menu-label">${name}</span>
|
|
648
|
+
${v === value && html`<span class="qe-menu-check" aria-hidden="true">${icons.check()}</span>`}
|
|
649
|
+
</div>
|
|
650
|
+
`,
|
|
651
|
+
)}
|
|
652
|
+
</div>
|
|
653
|
+
`;
|
|
654
|
+
|
|
188
655
|
/**
|
|
189
656
|
* 문항 카드. body: 문항 칸들 · types: [[값, 이름], …]
|
|
190
|
-
* data-role="type" (유형 select) · data-role="up" · data-role="down" · data-role="delete"
|
|
657
|
+
* data-role="type" (유형 버튼: 누르면 typeMenu, 브라우저 select를 둬도 됨) · data-role="up" · data-role="down" · data-role="delete"
|
|
191
658
|
* 문항이 하나뿐이면 ↑ · ↓는 숨긴다 (옮길 곳이 없음)
|
|
192
659
|
*/
|
|
193
660
|
export const card = ({ q, index, count, types, body }) => html`
|
|
194
|
-
<section class="qe-card">
|
|
195
|
-
<header class="qe-card-head">
|
|
661
|
+
<section class="qe-card ec-edit-card">
|
|
662
|
+
<header class="qe-card-head ec-edit-card-head">
|
|
196
663
|
<strong>${t.question(index + 1)}</strong>
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
664
|
+
<button
|
|
665
|
+
type="button"
|
|
666
|
+
class="qe-type"
|
|
667
|
+
data-role="type"
|
|
668
|
+
data-value="${q.type}"
|
|
669
|
+
aria-haspopup="listbox"
|
|
670
|
+
aria-expanded="false"
|
|
671
|
+
aria-label="${t.questionTypeNow(index + 1, typeName(types, q.type))}"
|
|
672
|
+
>
|
|
673
|
+
${typeIcons[q.type]?.()}
|
|
674
|
+
<span class="qe-type-label">${typeName(types, q.type)}</span>
|
|
675
|
+
${icons.chevronDown()}
|
|
676
|
+
</button>
|
|
203
677
|
<button
|
|
204
678
|
type="button"
|
|
205
679
|
class="ec-icon-button"
|
|
206
680
|
data-role="up"
|
|
207
681
|
aria-label="${t.questionUp(index + 1)}"
|
|
208
|
-
${index === 0 &&
|
|
209
|
-
${count === 1 &&
|
|
682
|
+
${index === 0 && "disabled"}
|
|
683
|
+
${count === 1 && "hidden"}
|
|
210
684
|
>
|
|
211
685
|
${t.up}
|
|
212
686
|
</button>
|
|
@@ -215,8 +689,8 @@ export const card = ({ q, index, count, types, body }) => html`
|
|
|
215
689
|
class="ec-icon-button"
|
|
216
690
|
data-role="down"
|
|
217
691
|
aria-label="${t.questionDown(index + 1)}"
|
|
218
|
-
${index === count - 1 &&
|
|
219
|
-
${count === 1 &&
|
|
692
|
+
${index === count - 1 && "disabled"}
|
|
693
|
+
${count === 1 && "hidden"}
|
|
220
694
|
>
|
|
221
695
|
${t.down}
|
|
222
696
|
</button>
|
|
@@ -233,40 +707,145 @@ export const card = ({ q, index, count, types, body }) => html`
|
|
|
233
707
|
</section>
|
|
234
708
|
`;
|
|
235
709
|
|
|
236
|
-
/** 문항 카드 맨 위 알림 (유형을 바꿔 정답이 초기화됨). data-role="type-warning" */
|
|
237
|
-
export const typeWarning = ({ text }) =>
|
|
238
|
-
html`<p class="qe-warning" data-role="type-warning" role="status">${text}</p>`;
|
|
239
|
-
|
|
240
710
|
/** 저장하지 못한 정답 문제 (정답 자리 위). data-role="answer-error" */
|
|
241
711
|
export const answerError = ({ text }) =>
|
|
242
|
-
html`<p class="qe-answer-error" data-role="answer-error" role="alert"
|
|
712
|
+
html`<p class="qe-answer-error" data-role="answer-error" role="alert">
|
|
713
|
+
${text}
|
|
714
|
+
</p>`;
|
|
243
715
|
|
|
244
|
-
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
716
|
+
/**
|
|
717
|
+
* 스낵바 (EDS Snackbar · info): 짧은 알림 + 되돌리기(action이 없으면 알림만). 화면 아래에 떠 있다. data-role="undo" (되돌리기 버튼)
|
|
718
|
+
* 상태 알림이라 role="status" (초점을 가져가지 않고 낭독기가 읽음)
|
|
719
|
+
*/
|
|
720
|
+
export const snackbar = ({ text, action }) => html`
|
|
721
|
+
<div class="qe-snackbar ec-snackbar" role="status">
|
|
722
|
+
<span class="qe-snackbar-icon ec-snackbar-icon">${icons.info()}</span>
|
|
723
|
+
<span class="qe-snackbar-text ec-snackbar-text">${text}</span>
|
|
724
|
+
${action &&
|
|
725
|
+
html`<button type="button" class="qe-snackbar-action ec-snackbar-action" data-role="undo">
|
|
726
|
+
${action}
|
|
727
|
+
</button>`}
|
|
249
728
|
</div>
|
|
250
729
|
`;
|
|
251
730
|
|
|
252
|
-
/**
|
|
253
|
-
export const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
731
|
+
/** 편집 화면 맨 위 안내 (정답을 어디서 고르는지) */
|
|
732
|
+
export const answersIntro = ({ text }) =>
|
|
733
|
+
html`<p class="qe-hint qe-answers-intro">${text}</p>`;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* 주관식 정답 목록: 줄마다 밑줄 칸 하나 + ✕, 아래에 "+ 유사 정답 추가" (보기 목록과 같은 모양). 그중 하나만 맞아도 정답
|
|
737
|
+
* textAnswerRow: data-role="input" · "delete" / textAnswerAdd: data-role="add"
|
|
738
|
+
*/
|
|
739
|
+
export const textAnswerRow = ({ index, canDelete }) => html`
|
|
740
|
+
<div class="qe-option qe-text-answer ec-list-row">
|
|
741
|
+
<input
|
|
742
|
+
class="qe-inline-input qe-option-text ec-field-input"
|
|
743
|
+
data-role="input"
|
|
744
|
+
aria-label="${ta.textInput(index)}"
|
|
745
|
+
placeholder="${ta.textInput(index)}"
|
|
746
|
+
/>
|
|
747
|
+
<button
|
|
748
|
+
type="button"
|
|
749
|
+
class="ec-icon-button ec-danger"
|
|
750
|
+
data-role="delete"
|
|
751
|
+
aria-label="${ta.textDelete(index)}"
|
|
752
|
+
title="${canDelete ? '' : ta.textMin}"
|
|
753
|
+
${!canDelete && 'disabled'}
|
|
754
|
+
>
|
|
755
|
+
${icons.xmark()}
|
|
756
|
+
</button>
|
|
257
757
|
</div>
|
|
258
758
|
`;
|
|
259
759
|
|
|
260
|
-
|
|
261
|
-
|
|
760
|
+
export const textAnswerAdd = () =>
|
|
761
|
+
html`<button type="button" class="qe-add ec-list-add" data-role="add">${ta.addText}</button>`;
|
|
262
762
|
|
|
263
|
-
|
|
264
|
-
export const textAnswers = ({ placeholder }) =>
|
|
265
|
-
html`<textarea class="qe-input" data-role="input" placeholder="${placeholder}"></textarea>`;
|
|
763
|
+
export const textAnswers = ({ rows, add }) => html`<div class="qe-options qe-text-answers ec-list">${rows}${add}</div>`;
|
|
266
764
|
|
|
267
765
|
/** 문항 추가 버튼 */
|
|
268
766
|
export const addQuestion = () =>
|
|
269
|
-
html`<button type="button" class="qe-add qe-add-question"
|
|
767
|
+
html`<button type="button" class="qe-add qe-add-question ec-add">
|
|
768
|
+
${t.addQuestion}
|
|
769
|
+
</button>`;
|
|
770
|
+
|
|
771
|
+
/** 문항이 최대 개수(LIMITS.questionsMax)라 "문항 추가" 대신 보이는 안내 */
|
|
772
|
+
export const questionLimit = ({ text }) =>
|
|
773
|
+
html`<p class="qe-hint qe-question-limit">${text}</p>`;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* 그룹 분류 편집판 (그룹별 상자). 보기는 어느 상자에 넣느냐로 정답이 정해진다.
|
|
777
|
+
* groupBox: 그룹 하나의 상자 (번호표 · 이름 · 지우기 + 이 그룹의 보기들). data-role="group-name" · "group-delete"
|
|
778
|
+
* noneBox: 오답 보기 상자 (어느 그룹에도 속하지 않는 보기, 점선. 머리줄의 ✕(data-role="none-close")로 닫음). noneAdd: 오답 보기가 없을 때 상자 대신 보이는 버튼 (data-role="none-add")
|
|
779
|
+
* 상자는 data-group-box와 data-group(그룹 id, 오답은 빈 값)을 가진다 (끌어 놓을 곳)
|
|
780
|
+
*/
|
|
781
|
+
export const groupBox = ({ letter, canDelete, rows, add, nameLabel, namePlaceholder, deleteLabel, deleteTitle }) => html`
|
|
782
|
+
<div class="qe-group" data-group-box>
|
|
783
|
+
<div class="qe-group-head">
|
|
784
|
+
<span class="qe-group-badge">${letter}</span>
|
|
785
|
+
<input
|
|
786
|
+
class="qe-inline-input qe-group-name ec-field-input"
|
|
787
|
+
data-role="group-name"
|
|
788
|
+
aria-label="${nameLabel}"
|
|
789
|
+
placeholder="${namePlaceholder}"
|
|
790
|
+
/>
|
|
791
|
+
<button
|
|
792
|
+
type="button"
|
|
793
|
+
class="ec-icon-button ec-danger"
|
|
794
|
+
data-role="group-delete"
|
|
795
|
+
aria-label="${deleteLabel}"
|
|
796
|
+
title="${canDelete ? '' : deleteTitle}"
|
|
797
|
+
${!canDelete && 'disabled'}
|
|
798
|
+
>
|
|
799
|
+
${icons.xmark()}
|
|
800
|
+
</button>
|
|
801
|
+
</div>
|
|
802
|
+
<div class="qe-options ec-list">${rows}${add}</div>
|
|
803
|
+
</div>
|
|
804
|
+
`;
|
|
805
|
+
|
|
806
|
+
export const noneBox = ({ rows, add, canClose, closeTitle, hint = t.noneHint }) => html`
|
|
807
|
+
<div class="qe-group qe-group-none" data-group-box>
|
|
808
|
+
<div class="qe-group-head">
|
|
809
|
+
<strong>${t.noneTitle}</strong>
|
|
810
|
+
<span class="qe-hint-inline ec-hint-inline" title="${hint}">${hint}</span>
|
|
811
|
+
<button
|
|
812
|
+
type="button"
|
|
813
|
+
class="ec-icon-button ec-danger"
|
|
814
|
+
data-role="none-close"
|
|
815
|
+
aria-label="${t.noneClose}"
|
|
816
|
+
title="${canClose ? t.noneClose : closeTitle}"
|
|
817
|
+
${!canClose && 'disabled'}
|
|
818
|
+
>
|
|
819
|
+
${icons.xmark()}
|
|
820
|
+
</button>
|
|
821
|
+
</div>
|
|
822
|
+
<div class="qe-options ec-list">${rows}${add}</div>
|
|
823
|
+
</div>
|
|
824
|
+
`;
|
|
825
|
+
|
|
826
|
+
export const noneAdd = () => html`
|
|
827
|
+
<div class="qe-reveal qe-reveal-card ec-reveal">
|
|
828
|
+
<button type="button" class="qe-reveal-button ec-reveal-button" data-role="none-add">
|
|
829
|
+
<span>${t.addNone}</span><span aria-hidden="true">+</span>
|
|
830
|
+
</button>
|
|
831
|
+
</div>
|
|
832
|
+
`;
|
|
833
|
+
|
|
834
|
+
/** 그룹 상자들 + "그룹 추가" + 오답 보기 (상자 또는 추가 버튼) */
|
|
835
|
+
export const groupBoard = ({ boxes, add, none }) => html`
|
|
836
|
+
<div class="qe-groups">
|
|
837
|
+
${boxes}
|
|
838
|
+
<div class="qe-options ec-list">${add}</div>
|
|
839
|
+
${none}
|
|
840
|
+
</div>
|
|
841
|
+
`;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* 순서 맞추기 편집판: 번호 목록(번호가 곧 정답 순서) + 오답 보기(순서에 넣지 않는 보기).
|
|
845
|
+
* orderList는 끌어 놓을 곳이라 data-group-box와 data-group="order"를 가진다
|
|
846
|
+
*/
|
|
847
|
+
export const orderList = ({ rows, add }) => html`
|
|
848
|
+
<div class="qe-options ec-list" data-group-box data-group="order">${rows}${add}</div>
|
|
849
|
+
`;
|
|
270
850
|
|
|
271
|
-
|
|
272
|
-
export const singleQuestion = ({ text }) => html`<p class="qe-hint qe-single-question">${text}</p>`;
|
|
851
|
+
export const orderBoard = ({ list, none }) => html`<div class="qe-groups">${list}${none}</div>`;
|