@eliceio/cdk-cli 1.7.1 → 1.8.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 +18 -15
- package/es/commands/create/index.js +6 -3
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/commands/doctor/index.js +34 -1
- package/es/core/lesson-check.d.ts +7 -0
- package/es/core/lesson-check.js +87 -0
- package/es/core/templates.d.ts +2 -0
- package/es/core/templates.js +4 -1
- package/es/dev/host-page.js +5 -2
- package/es/dev/learner-files.d.ts +1 -1
- package/es/dev/learner-files.js +7 -4
- package/es/dev/learner-shares.d.ts +90 -0
- package/es/dev/learner-shares.js +282 -0
- package/es/dev/mock-api.d.ts +28 -0
- package/es/dev/mock-api.js +32 -1
- package/es/dev/server.d.ts +3 -0
- package/es/dev/server.js +22 -1
- package/package.json +2 -2
- package/skills/_shared/always.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -9
- package/skills/_shared/references/03-create-the-project.md +12 -11
- package/skills/_shared/references/05-screen-code.md +1 -0
- package/skills/_shared/references/08-fix-check-errors.md +1 -0
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +2 -2
- package/skills/_shared/references/17-using-the-entry-template.md +44 -5
- package/skills/_shared/references/18-using-the-lesson-template.md +207 -0
- package/skills/_shared/references/19-lesson-layouts.md +2132 -0
- package/skills/elice-content-create/SKILL.md +4 -3
- package/skills/elice-content-publish/SKILL.md +3 -3
- package/templates/_shared/lib/cdk-mock.d.ts +16 -0
- package/templates/_shared/lib/cdk-mock.js +49 -0
- package/templates/blank/template.json +1 -1
- package/templates/board/README.md +15 -7
- package/templates/board/core/board.d.ts +13 -0
- package/templates/board/core/board.js +11 -1
- package/templates/board/core/files.d.ts +40 -0
- package/templates/board/core/files.js +176 -0
- package/templates/board/core/model.d.ts +5 -0
- package/templates/board/core/model.js +24 -7
- package/templates/board/core/settings.d.ts +2 -0
- package/templates/board/core/settings.js +12 -1
- package/templates/board/package.json +1 -1
- package/templates/board/screens/board.js +58 -0
- package/templates/board/screens/edit.js +36 -1
- package/templates/board/template.json +1 -1
- package/templates/board/ui/board.css +176 -0
- package/templates/board/ui/card.js +74 -1
- package/templates/board/ui/composer.js +169 -20
- package/templates/board/ui/icons.js +2 -0
- package/templates/board/ui/texts.js +30 -2
- package/templates/lesson/README.md +71 -0
- package/templates/lesson/commentary.txt +7 -0
- package/templates/lesson/core/dom.d.ts +4 -0
- package/templates/lesson/core/dom.js +22 -0
- package/templates/lesson/core/engine.d.ts +23 -0
- package/templates/lesson/core/engine.js +169 -0
- package/templates/lesson/core/interact.d.ts +2 -0
- package/templates/lesson/core/interact.js +429 -0
- package/templates/lesson/core/layout-files.d.ts +4 -0
- package/templates/lesson/core/layout-files.js +9 -0
- package/templates/lesson/core/lesson.d.ts +95 -0
- package/templates/lesson/core/lesson.js +609 -0
- package/templates/lesson/core/sample.d.ts +4 -0
- package/templates/lesson/core/sample.js +128 -0
- package/templates/lesson/edit.html +21 -0
- package/templates/lesson/gitignore +4 -0
- package/templates/lesson/index.html +22 -0
- package/templates/lesson/layouts/_actions.html +1 -0
- package/templates/lesson/layouts/_cmp.html +1 -0
- package/templates/lesson/layouts/_deco-corner.html +1 -0
- package/templates/lesson/layouts/_deco-cover.html +1 -0
- package/templates/lesson/layouts/_deco-section.html +1 -0
- package/templates/lesson/layouts/_foot.html +1 -0
- package/templates/lesson/layouts/_head.html +1 -0
- package/templates/lesson/layouts/_media.html +1 -0
- package/templates/lesson/layouts/agenda.html +13 -0
- package/templates/lesson/layouts/bar-chart.html +14 -0
- package/templates/lesson/layouts/cards.html +12 -0
- package/templates/lesson/layouts/checklist.html +12 -0
- package/templates/lesson/layouts/choice-list.html +13 -0
- package/templates/lesson/layouts/closing.html +13 -0
- package/templates/lesson/layouts/compare.html +12 -0
- package/templates/lesson/layouts/cover-dark.html +13 -0
- package/templates/lesson/layouts/cover.html +15 -0
- package/templates/lesson/layouts/figures.html +12 -0
- package/templates/lesson/layouts/flow.html +13 -0
- package/templates/lesson/layouts/how-to.html +15 -0
- package/templates/lesson/layouts/image-bg.html +12 -0
- package/templates/lesson/layouts/image-pair.html +15 -0
- package/templates/lesson/layouts/image-split.html +12 -0
- package/templates/lesson/layouts/layers.html +12 -0
- package/templates/lesson/layouts/objectives.html +12 -0
- package/templates/lesson/layouts/ox-card.html +24 -0
- package/templates/lesson/layouts/ox-list.html +21 -0
- package/templates/lesson/layouts/process.html +14 -0
- package/templates/lesson/layouts/profile.html +13 -0
- package/templates/lesson/layouts/prompt-builder.html +18 -0
- package/templates/lesson/layouts/quiz.html +14 -0
- package/templates/lesson/layouts/quote.html +12 -0
- package/templates/lesson/layouts/scenario-rows.html +12 -0
- package/templates/lesson/layouts/section.html +14 -0
- package/templates/lesson/layouts/simulation.html +18 -0
- package/templates/lesson/layouts/stat.html +14 -0
- package/templates/lesson/layouts/statement.html +13 -0
- package/templates/lesson/layouts/stats.html +12 -0
- package/templates/lesson/layouts/stepper.html +13 -0
- package/templates/lesson/layouts/table.html +12 -0
- package/templates/lesson/layouts/tabs.html +13 -0
- package/templates/lesson/layouts/text-visual.html +16 -0
- package/templates/lesson/layouts/timeline.html +12 -0
- package/templates/lesson/layouts/toggle.html +16 -0
- package/templates/lesson/layouts/variables.html +14 -0
- package/templates/lesson/layouts/venn.html +15 -0
- package/templates/lesson/layouts/versus.html +12 -0
- package/templates/lesson/metadata.json +9 -0
- package/templates/lesson/package.json +15 -0
- package/templates/lesson/public/img/sample-chat.svg +21 -0
- package/templates/lesson/screens/edit.js +79 -0
- package/templates/lesson/screens/learn.js +56 -0
- package/templates/lesson/styles.css +27 -0
- package/templates/lesson/template.json +7 -0
- package/templates/lesson/ui/design.css +1103 -0
- package/templates/lesson/ui/fonts/PretendardVariable.woff2 +0 -0
- package/templates/lesson/ui/learn.css +64 -0
- package/templates/lesson/ui/mobile.css +492 -0
- package/templates/lesson/ui/reset.css +6 -0
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
// 카드는 보드 모델(core/board.js)이 쓴 사람 자신의 kv `public` 줄에 넣는 글(post)입니다. 화면이 정하는 값은 글의 `data`에:
|
|
4
4
|
// 텍스트 카드 text = 내용(없으면 제목), data { kind: 'card', column: 섹션 id, color, title? }
|
|
5
5
|
// 링크 카드 text = 내용(없으면 주소), data { kind: 'card', column, color, url, title? }
|
|
6
|
+
// 파일 data.file { key, type, size, width?, height?, name? } (core/files.js). 파일만 있으면 text = FILE_ONLY_TEXT
|
|
6
7
|
// title: 카드 맨 위 굵은 제목 (선택, 여러 줄, 100자). 없는 옛 카드는 제목 없이 보임
|
|
7
8
|
// 보드 모델의 글은 text가 비면 안 되므로 내용이 없으면 주소 · 제목을 text에 넣고, 읽을 때 text가 그것과 같으면 내용 없음으로 봅니다.
|
|
8
9
|
// 이 키를 바꾸면 이미 쓴 카드를 읽지 못합니다. kind가 card가 아닌 글(예전 자유 캔버스 노트 등)은 보이지 않습니다.
|
|
9
10
|
// 쓴 사람 이름 · 시각은 카드 값에 넣지도, 화면에 보이지도 않습니다. 내 카드인지(post.author.isMe)는 지우기 · 메뉴에만 씁니다.
|
|
10
11
|
// 하트는 보드 좋아요(like · unlike, post.likeCount · likedByMe)입니다. 저마다 자기 카드만 지웁니다 (교육자는 남의 카드를 숨김 · 고정만).
|
|
11
12
|
|
|
13
|
+
import { FILE_ONLY_TEXT, readFile } from './files.js';
|
|
14
|
+
|
|
12
15
|
export const CARD_KIND = 'card';
|
|
13
16
|
/** 카드 색 (ui/board.css .bw-card[data-color]) */
|
|
14
17
|
export const COLORS = Object.freeze([
|
|
@@ -73,33 +76,47 @@ export function readCard(post) {
|
|
|
73
76
|
if (d.url !== undefined && !url) return null;
|
|
74
77
|
const title = [...cleanTitle(d.title)].slice(0, CARD_TITLE_MAX).join('');
|
|
75
78
|
const raw = String(post.text ?? '').slice(0, TEXT_MAX);
|
|
79
|
+
const file = readFile(d.file);
|
|
76
80
|
return {
|
|
77
81
|
column: d.column,
|
|
78
82
|
title,
|
|
79
|
-
text:
|
|
83
|
+
text:
|
|
84
|
+
(url && raw === url) || (title && raw === title) || (file && raw === FILE_ONLY_TEXT)
|
|
85
|
+
? ''
|
|
86
|
+
: raw,
|
|
80
87
|
url,
|
|
81
88
|
color: colorValue(d.color),
|
|
89
|
+
...(file ? { file } : {}),
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
/**
|
|
86
|
-
* 새 카드 { text, data }. 제목 · 내용 · 링크 중 하나는 있어야 하고, 링크는 http(s)여야 한다. 틀리면 null
|
|
94
|
+
* 새 카드 { text, data }. 제목 · 내용 · 링크 · 파일 중 하나는 있어야 하고, 링크는 http(s)여야 한다. 틀리면 null
|
|
87
95
|
* (제목은 여러 줄, CARD_TITLE_MAX자까지)
|
|
88
|
-
* @param {{ column: string, title?: string, text?: string, url?: string, color?: string }} card
|
|
96
|
+
* @param {{ column: string, title?: string, text?: string, url?: string, color?: string, file?: object | null }} card
|
|
97
|
+
* file: 올린 파일의 카드 값 (core/files.js fileValue)
|
|
89
98
|
*/
|
|
90
|
-
export function cardValue({ column, title, text, url, color }) {
|
|
99
|
+
export function cardValue({ column, title, text, url, color, file }) {
|
|
91
100
|
const t = String(text ?? '').trim();
|
|
92
101
|
const h = cleanTitle(title ?? '');
|
|
93
102
|
if (t.length > TEXT_MAX || [...h].length > CARD_TITLE_MAX) return null;
|
|
94
|
-
const
|
|
103
|
+
const f = file == null ? null : readFile(file);
|
|
104
|
+
if (file != null && !f) return null;
|
|
105
|
+
const data = {
|
|
106
|
+
kind: CARD_KIND,
|
|
107
|
+
column,
|
|
108
|
+
color: colorValue(color),
|
|
109
|
+
...(h ? { title: h } : {}),
|
|
110
|
+
...(f ? { file: f } : {}),
|
|
111
|
+
};
|
|
95
112
|
const rawUrl = String(url ?? '').trim();
|
|
96
113
|
if (rawUrl) {
|
|
97
114
|
const u = normalizeUrl(rawUrl);
|
|
98
115
|
if (!u) return null;
|
|
99
116
|
return { text: t || u, data: { ...data, url: u } };
|
|
100
117
|
}
|
|
101
|
-
if (!t && !h) return null;
|
|
102
|
-
return { text: t || h, data };
|
|
118
|
+
if (!t && !h && !f) return null;
|
|
119
|
+
return { text: t || h || FILE_ONLY_TEXT, data };
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
/**
|
|
@@ -11,6 +11,8 @@ export interface BoardDraft {
|
|
|
11
11
|
description: string;
|
|
12
12
|
columns: BoardColumn[];
|
|
13
13
|
reactions: boolean;
|
|
14
|
+
/** 카드에 파일(그림 · PDF) 올리기 (기본 켬) */
|
|
15
|
+
fileUpload: boolean;
|
|
14
16
|
bodyPlaceholder: string;
|
|
15
17
|
board: { requireApproval: boolean; postLimit: number | null };
|
|
16
18
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// description: '…', // 선택
|
|
6
6
|
// columns: [{ id: 'c1', title: '섹션 1' }, …], // 칸반 섹션 (카드가 data.column으로 가리킴)
|
|
7
7
|
// reactions: false, // 선택. 하트를 끔 (없으면 켜짐)
|
|
8
|
+
// fileUpload: false, // 선택. 카드에 파일(그림 · PDF) 올리기를 끔 (없으면 켜짐)
|
|
8
9
|
// bodyPlaceholder: '오늘 배운 것을 적어 보세요', // 선택. 카드 내용 칸에 보일 문구
|
|
9
10
|
// board: { // 보드 설정 (보드 모델 core/board.js가 require_approval을 읽음)
|
|
10
11
|
// require_approval: false, // 학생 카드는 교육자가 승인해야 다른 학생에게 보임 (화면 수준)
|
|
@@ -28,7 +29,15 @@ export const LIMIT_MIN = 1;
|
|
|
28
29
|
export const LIMIT_MAX = 200;
|
|
29
30
|
/** 섹션 id (카드 data에 그대로 들어감) */
|
|
30
31
|
const ID_PATTERN = /^[A-Za-z0-9_-]{1,32}$/;
|
|
31
|
-
const KNOWN = [
|
|
32
|
+
const KNOWN = [
|
|
33
|
+
'title',
|
|
34
|
+
'description',
|
|
35
|
+
'columns',
|
|
36
|
+
'reactions',
|
|
37
|
+
'fileUpload',
|
|
38
|
+
'bodyPlaceholder',
|
|
39
|
+
'board',
|
|
40
|
+
];
|
|
32
41
|
const BOARD_KNOWN = ['require_approval', 'post_limit'];
|
|
33
42
|
|
|
34
43
|
/** 기본 섹션 이름 (화면 문구, ui/texts.js가 넘김) */
|
|
@@ -85,6 +94,7 @@ export function normalizeSettings(raw, labels = DEFAULT_LABELS) {
|
|
|
85
94
|
description: str(s.description, DESCRIPTION_MAX),
|
|
86
95
|
columns: readColumns(s.columns, labels.columnTitle ?? DEFAULT_LABELS.columnTitle),
|
|
87
96
|
reactions: s.reactions !== false,
|
|
97
|
+
fileUpload: s.fileUpload !== false,
|
|
88
98
|
bodyPlaceholder: str(s.bodyPlaceholder, PLACEHOLDER_MAX).trim(),
|
|
89
99
|
board: {
|
|
90
100
|
requireApproval: board.require_approval === true,
|
|
@@ -102,6 +112,7 @@ export function toSettings(draft) {
|
|
|
102
112
|
...(draft.description.trim() ? { description: draft.description.trim() } : {}),
|
|
103
113
|
columns: draft.columns.map(c => ({ id: c.id, title: c.title.trim() })),
|
|
104
114
|
...(draft.reactions ? {} : { reactions: false }),
|
|
115
|
+
...(draft.fileUpload === false ? { fileUpload: false } : {}),
|
|
105
116
|
...(placeholder ? { bodyPlaceholder: placeholder } : {}),
|
|
106
117
|
board: {
|
|
107
118
|
...draft.boardRest,
|
|
@@ -6,9 +6,18 @@
|
|
|
6
6
|
// 카드는 한 보드의 글(post)이고 data에 섹션 · 색 · 링크를 넣습니다 (core/model.js). 저마다 자기 카드만 지웁니다.
|
|
7
7
|
// 카드에는 쓴 사람 이름 · 시각을 보이지 않습니다 (교육자 화면도). 맨 위 제목(선택)에 학생이 원하면 이름 · 날짜를 직접 씁니다.
|
|
8
8
|
// 승인 · 숨김 · 고정 · 닫기 · 1인당 카드 수는 화면에서만 지킵니다: 카드 내용은 모두의 브라우저에 내려갑니다.
|
|
9
|
+
// 파일(그림 · PDF)은 SDK 공유 파일(sdk.sharedFiles)로 올리고 카드에는 key만 둡니다 (core/files.js). 내 카드를 지우면 파일도
|
|
10
|
+
// 지우고(실패해도 진행), 교육자 메뉴의 '파일 삭제'는 파일을 지운 뒤 모두에게 '삭제된 파일'로 보이게 표시합니다.
|
|
11
|
+
// 편집기 미리보기 · 튜터 · 설정에서 끈 보드는 파일 올리기를 숨깁니다.
|
|
9
12
|
import { showSnackbar } from '../lib/elice-content.js';
|
|
10
13
|
import { createBoard } from '../core/board.js';
|
|
11
14
|
import { html, part } from '../core/dom.js';
|
|
15
|
+
import {
|
|
16
|
+
createFileUrls,
|
|
17
|
+
fileValue,
|
|
18
|
+
uploadErrorKind,
|
|
19
|
+
uploadsAvailable,
|
|
20
|
+
} from '../core/files.js';
|
|
12
21
|
import { canAdd, cardsByColumn, errorKind } from '../core/model.js';
|
|
13
22
|
import { DEFAULT_POST_LIMIT, normalizeSettings } from '../core/settings.js';
|
|
14
23
|
import { cardView, confirmTwice } from '../ui/card.js';
|
|
@@ -21,6 +30,8 @@ import { texts } from '../ui/texts.js';
|
|
|
21
30
|
const t = texts.board;
|
|
22
31
|
const m = texts.menu;
|
|
23
32
|
const errText = err => texts.errors[errorKind(err)] ?? texts.errors.failed;
|
|
33
|
+
const uploadErrText = err =>
|
|
34
|
+
texts.composer.fileErrors[uploadErrorKind(err)] ?? texts.composer.fileErrors.failed;
|
|
24
35
|
|
|
25
36
|
/**
|
|
26
37
|
* @param {any} app start()가 준 화면 (lib/elice-content.js)
|
|
@@ -80,10 +91,19 @@ export async function mountBoard(app, { moderate }) {
|
|
|
80
91
|
);
|
|
81
92
|
};
|
|
82
93
|
const fail = err => showSnackbar({ text: errText(err) });
|
|
94
|
+
const sdk = app.sdk;
|
|
95
|
+
const fileUrls = createFileUrls(sdk);
|
|
96
|
+
const uploadsOn = () => uploadsAvailable(sdk, settings, app.readOnly);
|
|
83
97
|
|
|
84
98
|
const composer = createComposer({
|
|
85
99
|
columns: () => columns,
|
|
86
100
|
placeholder: () => settings.bodyPlaceholder,
|
|
101
|
+
upload: {
|
|
102
|
+
enabled: uploadsOn,
|
|
103
|
+
send: async (file, onProgress) => fileValue(await sdk.sharedFiles.post(file, { onProgress }), file),
|
|
104
|
+
discard: file => void sdk.sharedFiles.delete(file.key).catch(() => undefined),
|
|
105
|
+
errorText: uploadErrText,
|
|
106
|
+
},
|
|
87
107
|
onSubmit: async value => {
|
|
88
108
|
const blocked = addBlocked();
|
|
89
109
|
if (blocked) return blocked;
|
|
@@ -171,6 +191,9 @@ export async function mountBoard(app, { moderate }) {
|
|
|
171
191
|
pending: post.status === 'pending',
|
|
172
192
|
hidden: post.status === 'hidden',
|
|
173
193
|
pinned: post.pinned,
|
|
194
|
+
file: card.file ?? null,
|
|
195
|
+
fileDeleted: post.fileDeleted === true,
|
|
196
|
+
fileUrls,
|
|
174
197
|
canDelete: mine && !app.readOnly,
|
|
175
198
|
menu: showMenu && !app.readOnly,
|
|
176
199
|
heart: settings.reactions
|
|
@@ -207,6 +230,24 @@ export async function mountBoard(app, { moderate }) {
|
|
|
207
230
|
} catch (err) {
|
|
208
231
|
fail(err);
|
|
209
232
|
if (x) x.disabled = false;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// 카드를 지웠으면 파일도 지운다 (서버는 kv를 모름). 실패해도 카드는 지워진 채로 둔다
|
|
236
|
+
const key = fileKeyOf(post);
|
|
237
|
+
if (key) await sdk.sharedFiles?.delete(key).catch(() => undefined);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** 교육자: 파일만 지우고 모두에게 '삭제된 파일'로 보이게 표시 */
|
|
241
|
+
async function removeFile(post) {
|
|
242
|
+
const key = fileKeyOf(post);
|
|
243
|
+
if (!key) return;
|
|
244
|
+
try {
|
|
245
|
+
await sdk.sharedFiles.delete(key);
|
|
246
|
+
fileUrls.forget(key);
|
|
247
|
+
await board.markFileDeleted({ id: post.id });
|
|
248
|
+
say(m.fileDeletedDone);
|
|
249
|
+
} catch (err) {
|
|
250
|
+
fail(err);
|
|
210
251
|
}
|
|
211
252
|
}
|
|
212
253
|
|
|
@@ -221,6 +262,15 @@ export async function mountBoard(app, { moderate }) {
|
|
|
221
262
|
post.pinned
|
|
222
263
|
? { act: 'unpin', icon: 'pin', label: m.unpin }
|
|
223
264
|
: { act: 'pin', icon: 'pin', label: m.pin },
|
|
265
|
+
fileKeyOf(post) &&
|
|
266
|
+
!post.fileDeleted &&
|
|
267
|
+
typeof sdk.sharedFiles?.delete === 'function' && {
|
|
268
|
+
act: 'deleteFile',
|
|
269
|
+
icon: 'file',
|
|
270
|
+
label: m.deleteFile,
|
|
271
|
+
hint: m.deleteFileHint,
|
|
272
|
+
danger: true,
|
|
273
|
+
},
|
|
224
274
|
...(mine ? ['sep', { act: 'delete', icon: 'trash', label: m.delete, danger: true }] : []),
|
|
225
275
|
].filter(Boolean);
|
|
226
276
|
openMenu(
|
|
@@ -228,6 +278,7 @@ export async function mountBoard(app, { moderate }) {
|
|
|
228
278
|
items,
|
|
229
279
|
async act => {
|
|
230
280
|
if (act === 'delete') return removeCard(post, null);
|
|
281
|
+
if (act === 'deleteFile') return removeFile(post);
|
|
231
282
|
const done = {
|
|
232
283
|
approve: m.approved,
|
|
233
284
|
hide: m.hiddenDone,
|
|
@@ -298,6 +349,7 @@ export async function mountBoard(app, { moderate }) {
|
|
|
298
349
|
open: pre => composer.open(pre),
|
|
299
350
|
columnAt: (x, y) => columnAtX(boardEl, x, y),
|
|
300
351
|
notify: text => showSnackbar({ text }),
|
|
352
|
+
files: uploadsOn,
|
|
301
353
|
});
|
|
302
354
|
|
|
303
355
|
board.subscribe(next => {
|
|
@@ -307,6 +359,12 @@ export async function mountBoard(app, { moderate }) {
|
|
|
307
359
|
render();
|
|
308
360
|
}
|
|
309
361
|
|
|
362
|
+
/** 카드에 붙인 파일의 key (없으면 null) */
|
|
363
|
+
function fileKeyOf(post) {
|
|
364
|
+
const key = post?.data?.file?.key;
|
|
365
|
+
return typeof key === 'string' ? key : null;
|
|
366
|
+
}
|
|
367
|
+
|
|
310
368
|
function unavailable(title, detail) {
|
|
311
369
|
return html`<div class="bw-unavailable" role="status">
|
|
312
370
|
<p class="bw-h1">${title}</p>
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// '초안으로 저장'과 상관없고 '저장하지 않은 변경'도 아니다. 보드가 어디인지(실제 서버 · 메모리)는 SDK kvstore가 고른다.
|
|
6
6
|
// 저장 전 섹션(한 번도 저장하지 않은 자료 포함)에 올리면 지금 편집한 내용을 먼저 초안으로 저장한 뒤 올린다
|
|
7
7
|
// (저장하지 않은 섹션에 카드만 남으면 어느 화면에도 안 보이고 지울 수도 없음). 저장이 실패하면 올리지 않음
|
|
8
|
-
// 설정 탭: 승인 후 공개 · 하트 반응 · 1인당 카드 수 · 내용 칸 문구
|
|
8
|
+
// 설정 탭: 승인 후 공개 · 하트 반응 · 파일 업로드 · 1인당 카드 수 · 내용 칸 문구
|
|
9
|
+
// 카드 파일(그림 · PDF)도 학생 화면처럼 올림 (edit 토큰도 서버가 받음, draft 미리보기에서는 숨김)
|
|
9
10
|
// 카드는 학생 화면과 같은 모양: 맨 위 제목(선택), 쓴 사람 이름 · 시각 없음
|
|
10
11
|
// settings 모양 · 검증은 core/settings.js. settings.board의 require_approval은 보드 모델(core/board.js)이 읽습니다.
|
|
11
12
|
// 섹션 id는 처음 만들 때 한 번 정하고 바꾸지 않습니다: 카드가 id로 가리키므로 이름만 바뀝니다.
|
|
@@ -13,6 +14,12 @@
|
|
|
13
14
|
import { showSnackbar, start } from '../lib/elice-content.js';
|
|
14
15
|
import { createBoard } from '../core/board.js';
|
|
15
16
|
import { html, part, parts } from '../core/dom.js';
|
|
17
|
+
import {
|
|
18
|
+
createFileUrls,
|
|
19
|
+
fileValue,
|
|
20
|
+
uploadErrorKind,
|
|
21
|
+
uploadsAvailable,
|
|
22
|
+
} from '../core/files.js';
|
|
16
23
|
import { cardsByColumn, errorKind } from '../core/model.js';
|
|
17
24
|
import {
|
|
18
25
|
LIMIT_MAX,
|
|
@@ -108,6 +115,12 @@ const shell = html`<div class="bw">
|
|
|
108
115
|
><input type="checkbox" data-role="reactions" /><span>${t.reactions}</span></label
|
|
109
116
|
>
|
|
110
117
|
</div>
|
|
118
|
+
<div class="bw-set">
|
|
119
|
+
<label class="bw-check"
|
|
120
|
+
><input type="checkbox" data-role="uploads" /><span>${t.fileUpload}</span></label
|
|
121
|
+
>
|
|
122
|
+
<p class="bw-help">${t.fileUploadHint}</p>
|
|
123
|
+
</div>
|
|
111
124
|
<div class="bw-set">
|
|
112
125
|
<label class="bw-lab" for="bw-limit">${t.limit}</label>
|
|
113
126
|
<input
|
|
@@ -165,6 +178,9 @@ const say = text => {
|
|
|
165
178
|
|
|
166
179
|
// ---------- 카드 (보드 core/board.js, '초안으로 저장'과 따로) ----------
|
|
167
180
|
const errText = err => texts.errors[errorKind(err)] ?? texts.errors.failed;
|
|
181
|
+
const uploadErrText = err =>
|
|
182
|
+
texts.composer.fileErrors[uploadErrorKind(err)] ?? texts.composer.fileErrors.failed;
|
|
183
|
+
const fileUrls = createFileUrls(app.sdk);
|
|
168
184
|
/** 보드. 열 수 없는 SDK(kvstore 없음)면 null: 카드를 올리면 안내만 */
|
|
169
185
|
let board = null;
|
|
170
186
|
let view = null;
|
|
@@ -203,6 +219,14 @@ const composer = createComposer({
|
|
|
203
219
|
columns: () => draft.columns,
|
|
204
220
|
placeholder: () => draft.bodyPlaceholder.trim(),
|
|
205
221
|
preview: column => (savedIds().has(column) ? texts.composer.preview : t.saveWithCard),
|
|
222
|
+
// 지금 편집 중인 설정(파일 업로드)을 따름
|
|
223
|
+
upload: {
|
|
224
|
+
enabled: () => Boolean(board) && uploadsAvailable(app.sdk, draft, false),
|
|
225
|
+
send: async (file, onProgress) =>
|
|
226
|
+
fileValue(await app.sdk.sharedFiles.post(file, { onProgress }), file),
|
|
227
|
+
discard: file => void app.sdk.sharedFiles.delete(file.key).catch(() => undefined),
|
|
228
|
+
errorText: uploadErrText,
|
|
229
|
+
},
|
|
206
230
|
onSubmit: async value => {
|
|
207
231
|
if (!board) return texts.board.unavailable.detail;
|
|
208
232
|
if (!savedIds().has(value.data.column)) {
|
|
@@ -237,6 +261,9 @@ function postView(post, card) {
|
|
|
237
261
|
pending: post.status === 'pending',
|
|
238
262
|
hidden: post.status === 'hidden',
|
|
239
263
|
pinned: post.pinned,
|
|
264
|
+
file: card.file ?? null,
|
|
265
|
+
fileDeleted: post.fileDeleted === true,
|
|
266
|
+
fileUrls,
|
|
240
267
|
canDelete: mine,
|
|
241
268
|
heart: draft.reactions
|
|
242
269
|
? { on: post.likedByMe, count: post.likeCount, disabled: !view.canWrite }
|
|
@@ -263,7 +290,11 @@ function postView(post, card) {
|
|
|
263
290
|
} catch (err) {
|
|
264
291
|
showSnackbar({ text: errText(err) });
|
|
265
292
|
x.disabled = false;
|
|
293
|
+
return;
|
|
266
294
|
}
|
|
295
|
+
// 카드를 지웠으면 파일도 지운다 (실패해도 카드는 지워진 채로)
|
|
296
|
+
const key = card.file?.key;
|
|
297
|
+
if (key) await app.sdk.sharedFiles?.delete(key).catch(() => undefined);
|
|
267
298
|
});
|
|
268
299
|
return el;
|
|
269
300
|
}
|
|
@@ -341,6 +372,9 @@ reactionsEl.addEventListener('change', () => {
|
|
|
341
372
|
draft.reactions = reactionsEl.checked;
|
|
342
373
|
render();
|
|
343
374
|
});
|
|
375
|
+
const uploadsEl = part(shell, 'uploads');
|
|
376
|
+
uploadsEl.checked = draft.fileUpload;
|
|
377
|
+
uploadsEl.addEventListener('change', () => (draft.fileUpload = uploadsEl.checked));
|
|
344
378
|
const limitEl = part(shell, 'limit');
|
|
345
379
|
limitEl.value = draft.board.postLimit == null ? '' : String(draft.board.postLimit);
|
|
346
380
|
limitEl.addEventListener('input', () => {
|
|
@@ -614,6 +648,7 @@ attachQuickAdd({
|
|
|
614
648
|
open: pre => openComposer(pre),
|
|
615
649
|
columnAt: (x, y) => columnAtX(boardEl, x, y),
|
|
616
650
|
notify: text => showSnackbar({ text }),
|
|
651
|
+
files: () => Boolean(board) && uploadsAvailable(app.sdk, draft, false),
|
|
617
652
|
});
|
|
618
653
|
|
|
619
654
|
render();
|
|
@@ -1122,3 +1122,179 @@ body.ec-edit-page:has(.bw) .ec-submitbar {
|
|
|
1122
1122
|
.bw-card-x.bw-card-menu {
|
|
1123
1123
|
opacity: 1;
|
|
1124
1124
|
}
|
|
1125
|
+
|
|
1126
|
+
/* 파일 첨부 (카드 추가 창 · 카드). 연주님 시안(파일 업로드)의 모양 */
|
|
1127
|
+
.bw-drop {
|
|
1128
|
+
display: flex;
|
|
1129
|
+
align-items: center;
|
|
1130
|
+
min-height: 44px;
|
|
1131
|
+
border: 1px dashed var(--bw-border-strong);
|
|
1132
|
+
border-radius: 12px;
|
|
1133
|
+
background: rgba(255, 255, 255, 0.5);
|
|
1134
|
+
}
|
|
1135
|
+
.bw-drop[hidden] {
|
|
1136
|
+
display: none;
|
|
1137
|
+
}
|
|
1138
|
+
.bw-drop:hover,
|
|
1139
|
+
.bw-drop.is-over {
|
|
1140
|
+
border-color: var(--bw-primary);
|
|
1141
|
+
}
|
|
1142
|
+
.bw-drop-btn {
|
|
1143
|
+
flex: 1;
|
|
1144
|
+
height: 44px;
|
|
1145
|
+
display: flex;
|
|
1146
|
+
align-items: center;
|
|
1147
|
+
justify-content: center;
|
|
1148
|
+
gap: 8px;
|
|
1149
|
+
border: 0;
|
|
1150
|
+
background: transparent;
|
|
1151
|
+
border-radius: 12px;
|
|
1152
|
+
font: inherit;
|
|
1153
|
+
font-size: 13px;
|
|
1154
|
+
font-weight: 600;
|
|
1155
|
+
color: var(--bw-text2);
|
|
1156
|
+
cursor: pointer;
|
|
1157
|
+
}
|
|
1158
|
+
.bw-drop-btn:hover {
|
|
1159
|
+
color: var(--bw-primary);
|
|
1160
|
+
}
|
|
1161
|
+
.bw-drop-btn:focus-visible {
|
|
1162
|
+
outline: 2px solid var(--bw-primary);
|
|
1163
|
+
outline-offset: 2px;
|
|
1164
|
+
}
|
|
1165
|
+
.bw-drop-file {
|
|
1166
|
+
display: none;
|
|
1167
|
+
align-items: center;
|
|
1168
|
+
gap: 8px;
|
|
1169
|
+
width: 100%;
|
|
1170
|
+
min-width: 0;
|
|
1171
|
+
padding: 6px 8px;
|
|
1172
|
+
}
|
|
1173
|
+
.bw-drop.has-file {
|
|
1174
|
+
border-style: solid;
|
|
1175
|
+
}
|
|
1176
|
+
.bw-drop.has-file .bw-drop-btn {
|
|
1177
|
+
display: none;
|
|
1178
|
+
}
|
|
1179
|
+
.bw-drop.has-file .bw-drop-file {
|
|
1180
|
+
display: flex;
|
|
1181
|
+
}
|
|
1182
|
+
.bw-drop-img,
|
|
1183
|
+
.bw-drop-icon {
|
|
1184
|
+
flex: none;
|
|
1185
|
+
width: 44px;
|
|
1186
|
+
height: 44px;
|
|
1187
|
+
border-radius: 8px;
|
|
1188
|
+
background: var(--bw-gray);
|
|
1189
|
+
}
|
|
1190
|
+
.bw-drop-img {
|
|
1191
|
+
object-fit: cover;
|
|
1192
|
+
}
|
|
1193
|
+
.bw-drop-icon {
|
|
1194
|
+
display: flex;
|
|
1195
|
+
align-items: center;
|
|
1196
|
+
justify-content: center;
|
|
1197
|
+
color: var(--bw-text2);
|
|
1198
|
+
}
|
|
1199
|
+
.bw-drop-img[hidden],
|
|
1200
|
+
.bw-drop-icon[hidden] {
|
|
1201
|
+
display: none;
|
|
1202
|
+
}
|
|
1203
|
+
.bw-filename {
|
|
1204
|
+
flex: 1;
|
|
1205
|
+
min-width: 0;
|
|
1206
|
+
font-size: 13px;
|
|
1207
|
+
font-weight: 600;
|
|
1208
|
+
color: var(--bw-text);
|
|
1209
|
+
overflow: hidden;
|
|
1210
|
+
text-overflow: ellipsis;
|
|
1211
|
+
white-space: nowrap;
|
|
1212
|
+
}
|
|
1213
|
+
.bw-filehint {
|
|
1214
|
+
white-space: pre-line;
|
|
1215
|
+
margin: -4px 0 0 4px;
|
|
1216
|
+
font-size: 12px;
|
|
1217
|
+
color: var(--bw-text2);
|
|
1218
|
+
}
|
|
1219
|
+
.bw-filehint[hidden] {
|
|
1220
|
+
display: none;
|
|
1221
|
+
}
|
|
1222
|
+
.bw-card-media {
|
|
1223
|
+
display: flex;
|
|
1224
|
+
flex-direction: column;
|
|
1225
|
+
min-width: 0;
|
|
1226
|
+
}
|
|
1227
|
+
.bw-card-img {
|
|
1228
|
+
display: block;
|
|
1229
|
+
width: 100%;
|
|
1230
|
+
height: auto;
|
|
1231
|
+
max-height: 320px;
|
|
1232
|
+
object-fit: cover;
|
|
1233
|
+
border-radius: 12px;
|
|
1234
|
+
background: var(--bw-gray);
|
|
1235
|
+
}
|
|
1236
|
+
.bw-card-file {
|
|
1237
|
+
display: flex;
|
|
1238
|
+
align-items: center;
|
|
1239
|
+
gap: 8px;
|
|
1240
|
+
padding: 10px 12px;
|
|
1241
|
+
border-radius: 12px;
|
|
1242
|
+
background: rgba(255, 255, 255, 0.7);
|
|
1243
|
+
color: var(--bw-primary-dark);
|
|
1244
|
+
font-size: 13px;
|
|
1245
|
+
font-weight: 600;
|
|
1246
|
+
text-decoration: none;
|
|
1247
|
+
min-width: 0;
|
|
1248
|
+
margin: 0;
|
|
1249
|
+
}
|
|
1250
|
+
.bw-card-file[aria-disabled='true'] {
|
|
1251
|
+
cursor: progress;
|
|
1252
|
+
}
|
|
1253
|
+
.bw-card-file-name {
|
|
1254
|
+
flex: 1;
|
|
1255
|
+
min-width: 0;
|
|
1256
|
+
overflow: hidden;
|
|
1257
|
+
text-overflow: ellipsis;
|
|
1258
|
+
white-space: nowrap;
|
|
1259
|
+
}
|
|
1260
|
+
.bw-card-file-size {
|
|
1261
|
+
flex: none;
|
|
1262
|
+
font-weight: 500;
|
|
1263
|
+
color: var(--bw-text3);
|
|
1264
|
+
}
|
|
1265
|
+
.bw-card-file.is-deleted {
|
|
1266
|
+
color: var(--bw-text3);
|
|
1267
|
+
font-weight: 500;
|
|
1268
|
+
}
|
|
1269
|
+
/* 지우기 · 메뉴 버튼(오른쪽 위)이 맨 위 그림에 묻히지 않게. 한 번 누른 '삭제'(빨강, .is-confirm)는 덮지 않음 */
|
|
1270
|
+
.bw-card-x:has(+ .bw-card-media) {
|
|
1271
|
+
z-index: 1;
|
|
1272
|
+
}
|
|
1273
|
+
.bw-card-x:not(.is-confirm):has(+ .bw-card-media) {
|
|
1274
|
+
background: rgba(255, 255, 255, 0.85);
|
|
1275
|
+
border-radius: 50%;
|
|
1276
|
+
}
|
|
1277
|
+
.bw-card-x + .bw-card-media .bw-card-file {
|
|
1278
|
+
margin-right: 28px;
|
|
1279
|
+
}
|
|
1280
|
+
/* 올리는 동안 버튼의 스피너 */
|
|
1281
|
+
.bw-spin {
|
|
1282
|
+
flex: none;
|
|
1283
|
+
width: 16px;
|
|
1284
|
+
height: 16px;
|
|
1285
|
+
border-radius: 50%;
|
|
1286
|
+
border: 2px solid currentColor;
|
|
1287
|
+
border-top-color: transparent;
|
|
1288
|
+
opacity: 0.9;
|
|
1289
|
+
animation: bw-spin 0.7s linear infinite;
|
|
1290
|
+
}
|
|
1291
|
+
@keyframes bw-spin {
|
|
1292
|
+
to {
|
|
1293
|
+
transform: rotate(360deg);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1297
|
+
.bw-spin {
|
|
1298
|
+
animation-duration: 2s;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// 카드 한 장 (학생 · 교육자 화면, 편집 화면 미리보기가 같이 씀). 맨 위에 굵은 제목(선택, 여러 줄), 쓴 사람 이름 · 시각은 없음.
|
|
2
|
+
// 파일: 그림은 <img loading=lazy>(저장한 크기로 자리를 잡음), PDF는 칩(누르면 새 탭). 카드 안에 PDF를 iframe으로 띄우지 않는다
|
|
3
|
+
// (LXP 샌드박스 iframe 안에서는 브라우저 PDF 보기가 막힘). 주소를 못 받거나 그림이 404 · 오류면 '삭제된 파일'.
|
|
2
4
|
// 동작은 화면이 data-role로 찾아 붙입니다:
|
|
3
5
|
// heart(하트) · card-x(내 카드 지우기) · menu-btn(교육자 ⋯ 메뉴)
|
|
4
6
|
import { html } from '../core/dom.js';
|
|
7
|
+
import { formatSize, isImageType } from '../core/files.js';
|
|
5
8
|
import { parseBody, parseInline } from '../core/model.js';
|
|
6
9
|
import { icon } from './icons.js';
|
|
7
10
|
import { texts } from './texts.js';
|
|
@@ -50,7 +53,9 @@ export function cardBody(text) {
|
|
|
50
53
|
* pending?: boolean, hidden?: boolean, pinned?: boolean,
|
|
51
54
|
* canDelete?: boolean, menu?: boolean,
|
|
52
55
|
* heart?: { on: boolean, count: number, disabled: boolean } | null,
|
|
53
|
-
*
|
|
56
|
+
* file?: import('../core/files.js').CardFile | null, fileDeleted?: boolean,
|
|
57
|
+
* fileUrls?: import('../core/files.js').FileUrls,
|
|
58
|
+
* }} c file: 붙인 파일, fileDeleted: 교육자가 지움, fileUrls: 서명 주소 받기 (core/files.js createFileUrls)
|
|
54
59
|
*/
|
|
55
60
|
export function cardView(c) {
|
|
56
61
|
const badges = [
|
|
@@ -85,6 +90,7 @@ export function cardView(c) {
|
|
|
85
90
|
${c.title ? html`<h3 class="bw-card-title">${c.title}</h3>` : null}
|
|
86
91
|
${badges.length ? html`<div class="bw-badges">${badges}</div>` : null}
|
|
87
92
|
${c.text ? cardBody(c.text) : null}
|
|
93
|
+
${c.file ? fileView(c) : null}
|
|
88
94
|
${c.url
|
|
89
95
|
? html`<a class="bw-card-link" href="${c.url}" target="_blank" rel="noopener noreferrer"
|
|
90
96
|
>${icon('link', 14)}<span>${c.url}</span></a
|
|
@@ -114,6 +120,73 @@ export function cardView(c) {
|
|
|
114
120
|
return el;
|
|
115
121
|
}
|
|
116
122
|
|
|
123
|
+
/** 지운 파일 자리 */
|
|
124
|
+
function deletedFile() {
|
|
125
|
+
return html`<p class="bw-card-file is-deleted">${icon('file', 14)}<span>${t.fileDeleted}</span></p>`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 카드의 파일: 그림 · PDF 칩. 주소는 비동기로 받아 채운다 (받아 둔 주소가 있으면 바로)
|
|
130
|
+
* @param {{ file: import('../core/files.js').CardFile, fileDeleted?: boolean,
|
|
131
|
+
* fileUrls?: import('../core/files.js').FileUrls, title?: string }} c
|
|
132
|
+
*/
|
|
133
|
+
export function fileView(c) {
|
|
134
|
+
const { file } = c;
|
|
135
|
+
const wrap = html`<div class="bw-card-media" data-role="media"></div>`;
|
|
136
|
+
if (c.fileDeleted || !c.fileUrls) {
|
|
137
|
+
wrap.append(deletedFile());
|
|
138
|
+
return wrap;
|
|
139
|
+
}
|
|
140
|
+
const urls = c.fileUrls;
|
|
141
|
+
const gone = () => {
|
|
142
|
+
urls.forget(file.key);
|
|
143
|
+
wrap.replaceChildren(deletedFile());
|
|
144
|
+
};
|
|
145
|
+
if (isImageType(file.type)) {
|
|
146
|
+
const img = document.createElement('img');
|
|
147
|
+
img.className = 'bw-card-img';
|
|
148
|
+
img.loading = 'lazy';
|
|
149
|
+
img.decoding = 'async';
|
|
150
|
+
img.alt = c.title || t.image;
|
|
151
|
+
if (file.width && file.height) {
|
|
152
|
+
img.width = file.width;
|
|
153
|
+
img.height = file.height;
|
|
154
|
+
}
|
|
155
|
+
// 404(지운 파일) · 오류: 이미지 요청은 상태를 알 수 없어(콘텐츠 CSP가 같은 출처 fetch를 막음) 모두 '삭제된 파일'
|
|
156
|
+
img.addEventListener('error', gone, { once: true });
|
|
157
|
+
wrap.append(img);
|
|
158
|
+
const known = urls.peek(file.key);
|
|
159
|
+
if (known) img.src = known;
|
|
160
|
+
else if (known === null) gone();
|
|
161
|
+
else
|
|
162
|
+
urls.get(file.key).then(
|
|
163
|
+
url => (url ? (img.src = url) : gone()),
|
|
164
|
+
() => gone()
|
|
165
|
+
);
|
|
166
|
+
return wrap;
|
|
167
|
+
}
|
|
168
|
+
// PDF: 새 탭으로 연다 (주소를 받기 전에는 누르지 않음)
|
|
169
|
+
const chip = html`<a class="bw-card-file" target="_blank" rel="noopener noreferrer"
|
|
170
|
+
>${icon('file', 14)}<span class="bw-card-file-name">${file.name ?? ''}</span
|
|
171
|
+
><span class="bw-card-file-size">${formatSize(file.size)}</span></a
|
|
172
|
+
>`;
|
|
173
|
+
chip.setAttribute('aria-label', t.openPdf(file.name ?? ''));
|
|
174
|
+
chip.setAttribute('aria-disabled', 'true');
|
|
175
|
+
chip.addEventListener('click', e => {
|
|
176
|
+
if (!chip.getAttribute('href')) e.preventDefault();
|
|
177
|
+
});
|
|
178
|
+
wrap.append(chip);
|
|
179
|
+
const ready = url => {
|
|
180
|
+
if (!url) return gone();
|
|
181
|
+
chip.href = url;
|
|
182
|
+
chip.removeAttribute('aria-disabled');
|
|
183
|
+
};
|
|
184
|
+
const known = urls.peek(file.key);
|
|
185
|
+
if (known !== undefined) ready(known);
|
|
186
|
+
else urls.get(file.key).then(ready, () => gone());
|
|
187
|
+
return wrap;
|
|
188
|
+
}
|
|
189
|
+
|
|
117
190
|
/**
|
|
118
191
|
* 지우기 버튼을 두 번 누름으로: 처음 누르면 "삭제"로 바뀌고 3초 안에 다시 누르면 onConfirm (confirm()은 샌드박스에서 막힘)
|
|
119
192
|
* @param {HTMLButtonElement} x
|