aicommunicator 0.0.0-stage → 0.2.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/LICENSE +55 -0
- package/README.md +93 -2
- package/bin/aic.js +20427 -0
- package/host-ui/host.js +5151 -0
- package/host-ui/index.html +483 -0
- package/host-ui/lang-en.js +631 -0
- package/package.json +30 -4
- package/plugin-guide.md +997 -0
- package/plugins/plugin-animation/LICENSE +55 -0
- package/plugins/plugin-animation/dist/logic.js +2225 -0
- package/plugins/plugin-animation/docs/manual.md +217 -0
- package/plugins/plugin-animation/manifest.json +31 -0
- package/plugins/plugin-animation/ui/icon.svg +6 -0
- package/plugins/plugin-animation/ui/index.html +2266 -0
- package/plugins/plugin-html-design/LICENSE +55 -0
- package/plugins/plugin-html-design/dist/logic.js +972 -0
- package/plugins/plugin-html-design/docs/manual.md +100 -0
- package/plugins/plugin-html-design/manifest.json +39 -0
- package/plugins/plugin-html-design/samples/exhibition-page.json +570 -0
- package/plugins/plugin-html-design/ui/icon.svg +5 -0
- package/plugins/plugin-html-design/ui/index.html +1241 -0
- package/plugins/plugin-html-slides/LICENSE +55 -0
- package/plugins/plugin-html-slides/dist/logic.js +1323 -0
- package/plugins/plugin-html-slides/docs/manual.md +121 -0
- package/plugins/plugin-html-slides/manifest.json +39 -0
- package/plugins/plugin-html-slides/samples/first-week-lecture.json +1129 -0
- package/plugins/plugin-html-slides/ui/icon.svg +5 -0
- package/plugins/plugin-html-slides/ui/index.html +1349 -0
- package/plugins/plugin-mindmap/LICENSE +55 -0
- package/plugins/plugin-mindmap/dist/logic.js +966 -0
- package/plugins/plugin-mindmap/docs/manual.md +145 -0
- package/plugins/plugin-mindmap/manifest.json +39 -0
- package/plugins/plugin-mindmap/samples/book-club.json +480 -0
- package/plugins/plugin-mindmap/ui/icon.svg +5 -0
- package/plugins/plugin-mindmap/ui/index.html +1774 -0
- package/plugins/plugin-plan/LICENSE +55 -0
- package/plugins/plugin-plan/dist/logic.js +1029 -0
- package/plugins/plugin-plan/docs/manual.md +261 -0
- package/plugins/plugin-plan/manifest.json +51 -0
- package/plugins/plugin-plan/samples/kimchi-day.json +1514 -0
- package/plugins/plugin-plan/samples/meeting-outline.json +653 -0
- package/plugins/plugin-plan/samples/reading-class.json +1577 -0
- package/plugins/plugin-plan/ui/icon.svg +7 -0
- package/plugins/plugin-plan/ui/index.html +1523 -0
- package/plugins/plugin-png/LICENSE +55 -0
- package/plugins/plugin-png/dist/logic.js +1758 -0
- package/plugins/plugin-png/docs/manual.md +344 -0
- package/plugins/plugin-png/manifest.json +35 -0
- package/plugins/plugin-png/ui/icon.svg +5 -0
- package/plugins/plugin-png/ui/index.html +2885 -0
- package/plugins/plugin-process-log/LICENSE +55 -0
- package/plugins/plugin-process-log/dist/logic.js +406 -0
- package/plugins/plugin-process-log/docs/manual.md +131 -0
- package/plugins/plugin-process-log/manifest.json +43 -0
- package/plugins/plugin-process-log/samples/design-decisions.json +241 -0
- package/plugins/plugin-process-log/ui/icon.svg +7 -0
- package/plugins/plugin-process-log/ui/index.html +721 -0
- package/plugins/plugin-story/LICENSE +55 -0
- package/plugins/plugin-story/dist/logic.js +2201 -0
- package/plugins/plugin-story/docs/manual.md +428 -0
- package/plugins/plugin-story/manifest.json +49 -0
- package/plugins/plugin-story/samples/scene-body.json +758 -0
- package/plugins/plugin-story/samples/time-and-groups.json +989 -0
- package/plugins/plugin-story/ui/icon.svg +4 -0
- package/plugins/plugin-story/ui/index.html +2783 -0
- package/plugins/plugin-svg/LICENSE +55 -0
- package/plugins/plugin-svg/dist/logic.js +2150 -0
- package/plugins/plugin-svg/docs/manual.md +314 -0
- package/plugins/plugin-svg/manifest.json +45 -0
- package/plugins/plugin-svg/samples/rocket-icon.json +1305 -0
- package/plugins/plugin-svg/samples/yard-cat.json +7796 -0
- package/plugins/plugin-svg/ui/icon.svg +4 -0
- package/plugins/plugin-svg/ui/index.html +2017 -0
- package/plugins/plugin-tree/LICENSE +55 -0
- package/plugins/plugin-tree/dist/logic.js +505 -0
- package/plugins/plugin-tree/docs/manual.md +140 -0
- package/plugins/plugin-tree/manifest.json +45 -0
- package/plugins/plugin-tree/samples/book-club.json +473 -0
- package/plugins/plugin-tree/samples/sort-memos.json +604 -0
- package/plugins/plugin-tree/ui/icon.svg +7 -0
- package/plugins/plugin-tree/ui/index.html +1305 -0
- package/schema/aic_describe.input.json +11 -0
- package/schema/aic_describe.output.json +67 -0
- package/schema/aic_observe.input.json +14 -0
- package/schema/aic_observe.output.json +47 -0
- package/schema/aic_send.input.json +15 -0
- package/schema/aic_send.output.json +38 -0
- package/schema/aic_update.input.json +19 -0
- package/schema/aic_update.output.json +39 -0
- package/schema/common.json +127 -0
- package/template/plugin/LICENSE +55 -0
- package/template/plugin/README.md +27 -0
- package/template/plugin/docs/manual.md +31 -0
- package/template/plugin/logic.js +337 -0
- package/template/plugin/manifest.json +27 -0
- package/template/plugin/ui/icon.svg +4 -0
- package/template/plugin/ui/index.html +269 -0
|
@@ -0,0 +1,1349 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>HTML Slides</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
--bg: #f5f5f2; --panel: #ffffff; --text: #1f2328; --muted: #5f6771; --line: #dcdfe3; --soft: #f0f1f3;
|
|
11
|
+
--accent: #1f6a8c; --accent-text: #ffffff; --del: #a8321f; --add: #1d7a46;
|
|
12
|
+
}
|
|
13
|
+
@media (prefers-color-scheme: dark) {
|
|
14
|
+
:root {
|
|
15
|
+
--bg: #191b1e; --panel: #22252a; --text: #e6e8eb; --muted: #a0a8b2; --line: #383d44; --soft: #2b2f35;
|
|
16
|
+
--accent: #7cc0dd; --accent-text: #10222b; --del: #f1a597; --add: #7bd6a0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
* { box-sizing: border-box; }
|
|
20
|
+
html, body { height: 100%; }
|
|
21
|
+
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 system-ui, "Malgun Gothic", sans-serif; }
|
|
22
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
23
|
+
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
24
|
+
.btn { white-space: nowrap; background: transparent; border: 1px solid var(--line); border-radius: 5px; padding: 2px 9px; font-size: 13px; }
|
|
25
|
+
.btn:hover { background: var(--soft); }
|
|
26
|
+
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
|
|
27
|
+
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
|
|
28
|
+
.btn[disabled] { opacity: .5; cursor: default; }
|
|
29
|
+
|
|
30
|
+
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: 13px; }
|
|
31
|
+
#bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
|
|
32
|
+
.group { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
|
|
33
|
+
.spacer { flex: 1; }
|
|
34
|
+
.meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
|
|
35
|
+
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--muted); }
|
|
36
|
+
.icon-btn:hover { background: var(--soft); color: var(--text); }
|
|
37
|
+
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { background: var(--soft); border-color: var(--line); color: var(--accent); }
|
|
38
|
+
.icon-btn[disabled] { opacity: .4; cursor: default; }
|
|
39
|
+
.ic, .ic svg { display: block; width: 16px; height: 16px; }
|
|
40
|
+
.ic svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
41
|
+
.icon-btn .dot { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
|
|
42
|
+
details > summary { cursor: pointer; }
|
|
43
|
+
details.menu { position: relative; }
|
|
44
|
+
details.menu > summary { list-style: none; border: 1px solid var(--line); border-radius: 5px; padding: 2px 9px; font-size: 13px; white-space: nowrap; }
|
|
45
|
+
details.menu > summary::-webkit-details-marker { display: none; }
|
|
46
|
+
details.menu > summary::after { content: " ▾"; color: var(--muted); }
|
|
47
|
+
details.menu > .pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 10; display: grid; gap: 2px; min-width: 200px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
|
|
48
|
+
details.menu > .pop .btn { text-align: left; border-color: transparent; }
|
|
49
|
+
#stage { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; padding: 12px; align-items: start; }
|
|
50
|
+
#stage.closed { grid-template-columns: minmax(0, 1fr); }
|
|
51
|
+
#canvas { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 200px; }
|
|
52
|
+
#frameBox { background: #000; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
|
|
53
|
+
#frame { display: block; border: 0; width: 100%; height: 100%; background: #000; }
|
|
54
|
+
.note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
|
|
55
|
+
aside section, aside details.fold { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
|
|
56
|
+
aside h2, aside details.fold > summary { font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
|
|
57
|
+
aside details.fold:not([open]) > summary { margin: 0; }
|
|
58
|
+
details.sub > summary { color: var(--muted); font-size: 12px; margin-top: 6px; }
|
|
59
|
+
aside p { margin: 4px 0; }
|
|
60
|
+
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-size: 13px; }
|
|
61
|
+
.kv dt { color: var(--muted); }
|
|
62
|
+
.kv dd { margin: 0; overflow-wrap: anywhere; }
|
|
63
|
+
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; margin: 4px 0; }
|
|
64
|
+
.chip { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 0 8px; font-size: 12px; }
|
|
65
|
+
.chip[aria-current="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
|
|
66
|
+
.compare { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
|
|
67
|
+
.compare th, .compare td { border-top: 1px solid var(--line); padding: 2px 4px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
|
|
68
|
+
.compare th { color: var(--muted); font-weight: 600; }
|
|
69
|
+
.form { display: grid; gap: 6px; margin-top: 6px; }
|
|
70
|
+
.form label > span { display: block; color: var(--muted); font-size: 12px; }
|
|
71
|
+
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
72
|
+
.row3 { display: flex; gap: 4px; flex-wrap: wrap; }
|
|
73
|
+
textarea, input[type=text], select { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; width: 100%; }
|
|
74
|
+
textarea { resize: vertical; min-height: 3.2em; }
|
|
75
|
+
.outline, .pages { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
|
|
76
|
+
.outline button, .pages button.pick { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 4px; padding: 1px 4px; font-size: 13px; }
|
|
77
|
+
.outline button:hover, .pages button.pick:hover { background: var(--soft); }
|
|
78
|
+
.outline button[aria-current="true"], .pages button.pick[aria-current="true"] { background: var(--accent); color: var(--accent-text); }
|
|
79
|
+
.outline .id, .pages .id { color: var(--muted); font-size: 11px; margin-left: 4px; }
|
|
80
|
+
.outline button[aria-current="true"] .id, .pages button.pick[aria-current="true"] .id { color: inherit; }
|
|
81
|
+
.pages .len { display: block; font-size: 11px; color: var(--muted); }
|
|
82
|
+
.pages button.pick[aria-current="true"] .len { color: inherit; }
|
|
83
|
+
.pages .over { color: var(--del); }
|
|
84
|
+
.changed { color: var(--add); font-size: 11px; margin-left: 4px; }
|
|
85
|
+
.warn { color: var(--del); font-size: 12px; }
|
|
86
|
+
#toast { position: fixed; z-index: 50; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 5px 12px; border-radius: 6px; font-size: 14px; max-width: min(90vw, 640px); }
|
|
87
|
+
#toast.bad { background: var(--del); color: #fff; }
|
|
88
|
+
#error { color: var(--del); padding: 16px; }
|
|
89
|
+
#endShow { position: fixed; z-index: 30; right: 10px; top: 10px; opacity: .35; background: #222; color: #fff; border: 1px solid #555; }
|
|
90
|
+
#endShow:hover, #endShow:focus-visible { opacity: 1; }
|
|
91
|
+
html { scroll-padding-top: calc(var(--bar-h, 41px) + var(--talk-h, 0px) + 8px); }
|
|
92
|
+
#talkBar { position: sticky; top: var(--bar-h, 41px); z-index: 4; margin: 8px 12px 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
|
|
93
|
+
#talkBar.unsent { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
|
|
94
|
+
#talkBar .state { margin: 0 0 6px; font-size: 13px; overflow-wrap: anywhere; }
|
|
95
|
+
#talkBar .state b { font-weight: 600; }
|
|
96
|
+
#talkBar .steps { margin: 0 0 6px; padding-left: 20px; font-size: 13px; }
|
|
97
|
+
#talkBar .steps li { margin: 1px 0; }
|
|
98
|
+
#talkBar .hint { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
|
|
99
|
+
#talkBar .state .wait { color: var(--del); font-weight: 600; }
|
|
100
|
+
#talkBar .state .done { color: var(--add); font-weight: 600; }
|
|
101
|
+
#talkBar .line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
|
|
102
|
+
#talkBar .line select { width: auto; flex: none; }
|
|
103
|
+
#talkBar .line input[type=text] { flex: 1; min-width: 160px; padding: 5px 8px; }
|
|
104
|
+
#talkBar .line .btn { flex: none; padding: 5px 14px; font-size: 14px; }
|
|
105
|
+
#talkBar .state .link { margin-left: 6px; }
|
|
106
|
+
#talkBar .help { position: relative; flex: none; }
|
|
107
|
+
#talkBar .help > summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 13px; }
|
|
108
|
+
#talkBar .help > summary::-webkit-details-marker { display: none; }
|
|
109
|
+
#talkBar .help > .pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: min(380px, 80vw); padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
|
|
110
|
+
#talkBar .help .hint { margin: 0; }
|
|
111
|
+
body.present { overflow: hidden; background: #000; }
|
|
112
|
+
body.present #bar, body.present #side, body.present #talkBar { display: none; }
|
|
113
|
+
body.present #stage { display: block; padding: 0; }
|
|
114
|
+
body.present #canvas { border: 0; padding: 0; border-radius: 0; background: #000; }
|
|
115
|
+
body.present #frameBox { position: fixed; inset: 0; width: 100vw !important; height: 100vh !important; z-index: 20; box-shadow: none; }
|
|
116
|
+
[hidden] { display: none !important; }
|
|
117
|
+
@media (max-width: 900px) { #stage { grid-template-columns: minmax(0, 1fr); } }
|
|
118
|
+
</style>
|
|
119
|
+
</head>
|
|
120
|
+
<body>
|
|
121
|
+
<div id="error" role="alert" hidden></div>
|
|
122
|
+
<header id="bar"><span class="meta" id="frameNote"></span></header>
|
|
123
|
+
<div id="talkBar" role="group" aria-label="Send what you picked to the AI" hidden></div>
|
|
124
|
+
<main id="stage">
|
|
125
|
+
<div id="canvas">
|
|
126
|
+
<div id="frameBox"></div>
|
|
127
|
+
</div>
|
|
128
|
+
<aside id="side"></aside>
|
|
129
|
+
</main>
|
|
130
|
+
<button type="button" id="endShow" class="btn" data-t hidden>End presentation (Esc)</button>
|
|
131
|
+
<div id="toast" role="status" hidden></div>
|
|
132
|
+
<script>
|
|
133
|
+
// HTML 발표의 화면(plugin-design/html-slides.md). 호스트 연결로만 코어와 이야기한다. 글은 모두 textContent 로 넣는다.
|
|
134
|
+
// HTML 디자인의 화면을 바탕으로 했다(html-slides.md 3절). 발표 문서는 안쪽 srcdoc iframe 에 그리고, 같이 넣은 스크립트(agentMain)가
|
|
135
|
+
// 안쪽에서 클릭, 드래그, 측정을 하고 postMessage 로 알린다. 문서에는 논리가 준 이동 스크립트(runtime)도 들어가며 이것은
|
|
136
|
+
// 저장하는 파일의 스크립트와 같은 글자다. 측정 좌표는 보이는 페이지 기준 1920×1080 CSS px 로 바꿔 보낸다.
|
|
137
|
+
'use strict';
|
|
138
|
+
const PLUGIN_VERSION = '0.1.5';
|
|
139
|
+
const SELECTION_FORMAT = 'aic.html-slides/selection-1';
|
|
140
|
+
const RENDERER = 'aic.html-slides 0.1.5, srcdoc iframe';
|
|
141
|
+
const PROPERTIES = ['font-size', 'font-weight', 'line-height', 'letter-spacing', 'color', 'background-color', 'margin-top', 'margin-bottom', 'padding-top', 'padding-bottom', 'gap', 'border-radius', 'text-align', 'width', 'max-width', 'height', 'opacity'];
|
|
142
|
+
|
|
143
|
+
// ---- 화면의 언어 ----
|
|
144
|
+
// 화면의 언어(rawdev 2026-11-25, plugin-guide.md 4.4절). 영어가 원문이고 기본이다. capabilities 의 language 가 'ko' 일 때만 아래 사전(KO,
|
|
145
|
+
// 영어 원문 -> 한국어)에서 찾고, 없으면 영어를 보인다. 사람이 언어를 바꾸면 호스트가 화면을 다시 열므로 처음 한 번만 정한다(setLanguage).
|
|
146
|
+
// t() 에는 글자 그대로의 원문만 준다. 시험(src/lang.test.ts)이 소스에서 원문을 찾아 사전과 맞춰 보기 때문이다. 논리가 낸 문장(요약, 거절)과
|
|
147
|
+
// 작업 내용(샘플 이름, 안쪽 문서, 저장 파일의 이동 줄)은 바꾸지 않는다.
|
|
148
|
+
let lang = 'en';
|
|
149
|
+
const KO = {
|
|
150
|
+
// index.html 의 고정 글(data-t 와 속성)
|
|
151
|
+
'Send what you picked to the AI': '고른 것을 AI 에게 보내기',
|
|
152
|
+
'End presentation (Esc)': '발표 끝내기 (Esc)',
|
|
153
|
+
// 상태와 링크 대상의 이름
|
|
154
|
+
'Normal': '보통',
|
|
155
|
+
'Hover': '가리킬 때',
|
|
156
|
+
'Keyboard focus': '키보드 초점',
|
|
157
|
+
'While pressed': '누르는 중',
|
|
158
|
+
'Next page': '다음 페이지',
|
|
159
|
+
'Previous page': '이전 페이지',
|
|
160
|
+
'First page': '첫 페이지',
|
|
161
|
+
'Last page': '마지막 페이지',
|
|
162
|
+
// 슬라이드
|
|
163
|
+
'Presentation screen': '발표 화면',
|
|
164
|
+
'Shows the {width}×{height} page at {percent}%. You can also turn pages with the arrow keys': '{width}×{height} 페이지를 {percent}% 크기로 보여 줍니다. 화살표 키로도 페이지를 넘깁니다',
|
|
165
|
+
'{element} in {layout}': '{layout}의 {element}',
|
|
166
|
+
'Reference: {name}': '참고: {name}',
|
|
167
|
+
'Sample: {name}': '샘플: {name}',
|
|
168
|
+
'Could not send the new measurements: {error}': '다시 잰 값을 보내지 못했습니다: {error}',
|
|
169
|
+
// 위쪽 줄
|
|
170
|
+
'Deck': '발표 자료',
|
|
171
|
+
'View': '보는 화면',
|
|
172
|
+
'Choose what to view': '보는 화면 고르기',
|
|
173
|
+
'Pages': '페이지',
|
|
174
|
+
'Page {number}: {title}': '{number}쪽: {title}',
|
|
175
|
+
'The source of this page is over {max} characters, so it cannot be saved to AiAkiv. You can still edit and save it': '이 페이지의 소스가 {max}자를 넘어 AiAkiv 에 저장할 수 없습니다. 편집과 파일 저장은 됩니다',
|
|
176
|
+
'Over AiAkiv limit': 'AiAkiv 한도 넘음',
|
|
177
|
+
'Mode': '모드',
|
|
178
|
+
'Pick': '고르기',
|
|
179
|
+
'Click the slide to pick an element, or drag to pick an area. Write a message in the send bar at the top and send it to the AI': '슬라이드를 누르면 요소를, 끌면 영역을 고릅니다. 위쪽 보내는 칸에 말을 적어 AI 에게 보냅니다',
|
|
180
|
+
'Presentation preview': '발표 미리보기',
|
|
181
|
+
'Presents inside the plugin area. Real full screen works in the saved file': '플러그인 영역 안에서 발표합니다. 실제 전체화면은 저장한 파일에서 됩니다',
|
|
182
|
+
'Save as HTML file': 'HTML 파일로 저장',
|
|
183
|
+
'Save as HTML file: saves this deck as a single HTML file. Open it in a browser to present in full screen': 'HTML 파일로 저장: 지금 발표 자료를 HTML 파일 하나로 저장합니다. 브라우저로 열면 전체화면으로 발표합니다',
|
|
184
|
+
'Save as HTML file: start a deck first, then save': 'HTML 파일로 저장: 발표 자료를 시작한 뒤 저장합니다',
|
|
185
|
+
'Save as HTML file: this host cannot save HTML yet': 'HTML 파일로 저장: 이 호스트는 아직 HTML 저장을 지원하지 않습니다',
|
|
186
|
+
'Edit panel': '편집 칸',
|
|
187
|
+
'Open the edit panel: page list and page tools, measurements of what you picked, text and style editing, element list': '편집 칸 열기: 페이지 목록과 페이지 도구, 고른 것의 잰 값, 문구와 스타일 고치기, 요소 목록',
|
|
188
|
+
'Close the edit panel: page list and page tools, measurements of what you picked, text and style editing, element list': '편집 칸 닫기: 페이지 목록과 페이지 도구, 고른 것의 잰 값, 문구와 스타일 고치기, 요소 목록',
|
|
189
|
+
'New measurements are in': '다시 잰 값이 있습니다',
|
|
190
|
+
'Saved: {file}. Open it in a browser and press [전체화면] (Full screen) or F to present': '저장했습니다: {file}. 브라우저로 열고 [전체화면] 버튼이나 F 키로 발표합니다',
|
|
191
|
+
'Could not save': '저장하지 못했습니다',
|
|
192
|
+
// 고른 것과 잰 값
|
|
193
|
+
'none': '없음',
|
|
194
|
+
'gone': '없음',
|
|
195
|
+
'{count} lines': '{count}줄',
|
|
196
|
+
'At selection {rev}': '선택 당시 {rev}',
|
|
197
|
+
'Redrawn {rev}': '다시 그린 값 {rev}',
|
|
198
|
+
'Redrawn': '다시 그린 값',
|
|
199
|
+
'Gap': '간격',
|
|
200
|
+
'Nothing has changed yet, so the values are the same as at selection. Values are on the 1920×1080 page.': '아직 바꾼 것이 없어 선택 당시 값과 같습니다. 값은 1920×1080 페이지 기준입니다.',
|
|
201
|
+
'Waiting for measurement: go back to the page of this selection to measure again.': '측정 대기: 이 선택의 페이지로 돌아가면 다시 잽니다.',
|
|
202
|
+
'Waiting for measurement: it measures again when the new revision is drawn.': '측정 대기: 새 revision 을 그리면 다시 잽니다.',
|
|
203
|
+
'Measurements: at selection and redrawn {rev}': '잰 값: 선택 당시와 다시 그린 {rev}',
|
|
204
|
+
'Measurements': '잰 값',
|
|
205
|
+
'Picked': '고른 것',
|
|
206
|
+
'You have not picked anything yet. Click or drag on the slide to pick. With the keyboard, pick from the element list below.': '아직 고른 것이 없습니다. 슬라이드에서 누르거나 끌어 고르고, 키보드로는 아래 요소 목록에서 고릅니다.',
|
|
207
|
+
'Picked element ({page})': '고른 요소 ({page})',
|
|
208
|
+
'Picked area ({page})': '고른 영역 ({page})',
|
|
209
|
+
'page {number}': '{number}쪽',
|
|
210
|
+
'removed page': '지운 페이지',
|
|
211
|
+
'Element': '요소',
|
|
212
|
+
'Text': '문구',
|
|
213
|
+
'Pick an enclosing part': '감싼 구역 고르기',
|
|
214
|
+
'Area': '영역',
|
|
215
|
+
'Elements in it': '걸친 요소',
|
|
216
|
+
'Between': '사이',
|
|
217
|
+
'vertical {px}px between {a} and {b}': '{a}, {b} 사이 세로 {px}px',
|
|
218
|
+
'horizontal {px}px between {a} and {b}': '{a}, {b} 사이 가로 {px}px',
|
|
219
|
+
'Several elements are in it. Click one to point at that element only.': '걸친 요소가 여럿입니다. 하나를 누르면 그 요소만 가리킵니다.',
|
|
220
|
+
// 보내는 칸
|
|
221
|
+
'a removed page': '지운 페이지',
|
|
222
|
+
'{label} on {page}': '{page}의 {label}',
|
|
223
|
+
'the area between {a} and {b} on {page}': '{page}의 {a}, {b} 사이 영역',
|
|
224
|
+
'an empty area on {page}': '{page}의 빈 영역',
|
|
225
|
+
'an area on {page} ({names})': '{page}의 영역({names})',
|
|
226
|
+
'an area on {page} ({names} and {more} more)': '{page}의 영역({names} 외 {more}개)',
|
|
227
|
+
'The gap was {before}px and is now {after}px.': '간격은 {before}px 에서 지금 {after}px 입니다.',
|
|
228
|
+
'What to tell the AI about the picked place': '고른 곳에 대해 AI 에게 할 말',
|
|
229
|
+
'For example: make this title shorter. You can also send it empty': '예: 이 제목을 더 짧게. 비워 두고 보내도 됩니다',
|
|
230
|
+
'First click or drag on the slide to pick what to change, then write your message here and send it': '먼저 슬라이드에서 고칠 곳을 누르거나 끌어 고른 뒤, 여기에 할 말을 적어 보냅니다',
|
|
231
|
+
'Role of the picked place': '고른 곳의 역할',
|
|
232
|
+
'Change this': '바꿀 곳',
|
|
233
|
+
'Use as reference': '참고할 곳',
|
|
234
|
+
'Edit directly': '직접 고치기',
|
|
235
|
+
'Opens the edit panel so you can edit text, links and styles yourself': '편집 칸을 열어 문구, 링크, 스타일을 직접 고칩니다',
|
|
236
|
+
'A view-only screen does not send to the AI.': '보기만 하는 화면에서는 AI 에게 보내지 않습니다.',
|
|
237
|
+
'This host cannot send what you picked to the AI yet.': '이 호스트는 아직 고른 것을 AI 에게 보내지 못합니다.',
|
|
238
|
+
'Sent to the AI (selection {id}).': 'AI 에게 보냈습니다(선택 {id}).',
|
|
239
|
+
'message "{said}"': '말 "{said}"',
|
|
240
|
+
'no message': '말 없음',
|
|
241
|
+
'Picked: {what}.': '고른 것: {what}.',
|
|
242
|
+
'Not sent to the AI yet.': '아직 AI 에게 보내지 않았습니다.',
|
|
243
|
+
'Click what to change on the slide above. Drag across several elements to pick an area.': '슬라이드에서 고칠 곳을 누릅니다. 여러 요소에 걸쳐 끌면 영역을 고릅니다.',
|
|
244
|
+
'Write your message in this bar and press [Send to AI] or Enter. The message can be empty.': '이 칸에 할 말을 적고 [AI 에게 보내기] 를 누르거나 Enter 를 누릅니다. 말은 비워도 됩니다.',
|
|
245
|
+
'The AI can read what you picked, but picking does not wake the AI. To have it work, write a message and press [Send to AI].': '고른 것은 AI 가 읽을 수 있지만 AI 를 깨우지는 않습니다. 일을 시키려면 말을 적고 [AI 에게 보내기] 를 누릅니다.',
|
|
246
|
+
'Picking alone does not tell the AI. When you send, the AI reads the place and your message together.': '고르기만 해서는 AI 가 알지 못합니다. 보내야 AI 가 그곳과 말을 함께 읽습니다.',
|
|
247
|
+
'Help for the send bar': '보내는 칸 도움말',
|
|
248
|
+
'Send to AI': 'AI 에게 보내기',
|
|
249
|
+
'This screen does not send': '이 화면에서는 보내지 않습니다',
|
|
250
|
+
'Sends what you picked and your message to the AI. The message can be empty': '고른 것과 적은 말을 AI 에게 보냅니다. 말은 비워도 됩니다',
|
|
251
|
+
'First pick what to change on the slide': '먼저 슬라이드에서 고칠 곳을 고릅니다',
|
|
252
|
+
'Could not send the selection': '선택을 보내지 못했습니다',
|
|
253
|
+
'Sent the earlier selection as {id}. What you picked now is not sent yet': '앞의 선택을 보냈습니다({id}). 지금 고른 것은 아직 보내지 않았습니다',
|
|
254
|
+
'Sent selection {id}': '선택을 보냈습니다({id})',
|
|
255
|
+
// 편집 칸
|
|
256
|
+
'Edit: {label} ({id})': '고치기: {label} ({id})',
|
|
257
|
+
'New text': '새 문구',
|
|
258
|
+
'Text (original: {original})': '문구 (원래: {original})',
|
|
259
|
+
'Change text': '문구 바꾸기',
|
|
260
|
+
'The text did not change': '바뀐 문구가 없습니다',
|
|
261
|
+
'Page the link goes to': '링크가 갈 페이지',
|
|
262
|
+
'Page the link goes to (now {page})': '링크가 갈 페이지 (지금 {page})',
|
|
263
|
+
'Change link target': '링크 대상 바꾸기',
|
|
264
|
+
'The target did not change': '바뀐 대상이 없습니다',
|
|
265
|
+
'Property': '속성',
|
|
266
|
+
'Value': '값',
|
|
267
|
+
'For example: 96px. Leave it empty to remove this change': '예: 96px. 비우면 이 변경을 지웁니다',
|
|
268
|
+
'State': '상태',
|
|
269
|
+
'Change style': '스타일 바꾸기',
|
|
270
|
+
'Styles changed on this element': '이 요소에 바꾼 스타일',
|
|
271
|
+
'Source {length} characters, can be saved to AiAkiv': '소스 {length}자, AiAkiv 저장 가능',
|
|
272
|
+
'Source {length} characters, cannot use AiAkiv (over {max} characters)': '소스 {length}자, AiAkiv 를 쓸 수 없음({max}자 넘음)',
|
|
273
|
+
'Layout of the page to add': '더할 페이지 구성',
|
|
274
|
+
'Move earlier': '앞으로',
|
|
275
|
+
'Move later': '뒤로',
|
|
276
|
+
'Remove this page': '이 페이지 지우기',
|
|
277
|
+
'Add after this page': '이 페이지 뒤에 더하기',
|
|
278
|
+
'Pages ({count})': '페이지 ({count})',
|
|
279
|
+
'Over AiAkiv limit {count}': 'AiAkiv 한도 넘음 {count}',
|
|
280
|
+
'A page whose source is {max} characters or fewer can be saved to AiAkiv. Longer pages can still be edited and saved.': '한 페이지의 소스가 {max}자 이하이면 AiAkiv 에 저장할 수 있습니다. 넘어도 편집과 파일 저장은 됩니다.',
|
|
281
|
+
'Elements (page {number}, {count})': '요소 목록 ({number}쪽, {count}개)',
|
|
282
|
+
'Elements (page {number}, {count}, {changed} changed)': '요소 목록 ({number}쪽, {count}개, 바뀜 {changed})',
|
|
283
|
+
'changed': '바뀜',
|
|
284
|
+
// 샘플 고르기와 참고 샘플
|
|
285
|
+
'Reason for picking': '고른 이유',
|
|
286
|
+
'For example: the lecture has a lot of explanation, so the light one is easier to read': '예: 설명이 많은 강의라 밝은 쪽이 읽기 쉬워서',
|
|
287
|
+
'Version {version}. Open another sample from the menu at the far left of the top bar.': '버전 {version}. 위쪽 줄 맨 왼쪽 메뉴에서 다른 샘플을 열어 봅니다.',
|
|
288
|
+
'Start from this sample': '이 샘플로 시작',
|
|
289
|
+
'Start a deck from this sample': '이 샘플로 발표 자료 시작',
|
|
290
|
+
'Write the reason you picked it': '고른 이유를 적어 주세요',
|
|
291
|
+
'Click an element here to attach it as a reference example to the next style change.': '여기서 요소를 누르면 다음 스타일 수정에 참고한 예시로 붙습니다.',
|
|
292
|
+
'Picked example: {label}': '고른 예시: {label}',
|
|
293
|
+
'Back to the deck': '발표 자료로 돌아가기',
|
|
294
|
+
'Deck: {title}': '발표 자료: {title}',
|
|
295
|
+
'Sample': '샘플',
|
|
296
|
+
'{title} ({id}) version {version}': '{title} ({id}) 버전 {version}',
|
|
297
|
+
'Reason': '고른 이유',
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/** 사람이 읽는 화면 글. text 는 영어 원문이고 vars 의 값이 {이름} 자리에 들어간다. 한국어 화면은 사전의 글을 쓰되 없으면 영어를 쓴다. */
|
|
301
|
+
function t(text, vars) {
|
|
302
|
+
const out = lang === 'ko' && Object.prototype.hasOwnProperty.call(KO, text) ? KO[text] : text;
|
|
303
|
+
if (!vars) return out;
|
|
304
|
+
return out.replace(/\{(\w+)\}/g, (whole, name) => (Object.prototype.hasOwnProperty.call(vars, name) ? String(vars[name]) : whole));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// index.html 의 고정 글. 글을 바꿀 요소에는 data-t 를 두고, 속성은 아래 셋을 본다. 스크립트가 만든 요소가 섞이지 않게 처음에 모아 둔다
|
|
308
|
+
const STATIC_ATTRS = ['title', 'aria-label', 'placeholder'];
|
|
309
|
+
const staticEls = Array.from(document.body.querySelectorAll('[data-t], [title], [aria-label], [placeholder]'));
|
|
310
|
+
|
|
311
|
+
/** capabilities 의 language 로 화면의 언어를 한 번 정한다. 'ko' 일 때만 한국어이고, 고정 글을 바꾸고 lang 을 맞춘다. */
|
|
312
|
+
function setLanguage(code) {
|
|
313
|
+
if (code !== 'ko' || lang === 'ko') return;
|
|
314
|
+
lang = 'ko';
|
|
315
|
+
document.documentElement.lang = 'ko';
|
|
316
|
+
for (const n of staticEls) {
|
|
317
|
+
if (n.hasAttribute('data-t')) n.textContent = t(n.textContent.trim());
|
|
318
|
+
for (const a of STATIC_ATTRS) { const v = n.getAttribute(a); if (v) n.setAttribute(a, t(v)); }
|
|
319
|
+
}
|
|
320
|
+
if (frame) frame.setAttribute('title', t('Presentation screen'));
|
|
321
|
+
}
|
|
322
|
+
// ---- 화면의 언어 끝 ----
|
|
323
|
+
|
|
324
|
+
const stateLabels = () => ({ none: t('Normal'), hover: t('Hover'), focus: t('Keyboard focus'), active: t('While pressed') });
|
|
325
|
+
const linkLabels = () => ({ next: t('Next page'), prev: t('Previous page'), first: t('First page'), last: t('Last page') });
|
|
326
|
+
|
|
327
|
+
const errorEl = document.getElementById('error');
|
|
328
|
+
const toastEl = document.getElementById('toast');
|
|
329
|
+
const barEl = document.getElementById('bar');
|
|
330
|
+
const sideEl = document.getElementById('side');
|
|
331
|
+
const frameBox = document.getElementById('frameBox');
|
|
332
|
+
const frameNote = document.getElementById('frameNote');
|
|
333
|
+
const talkEl = document.getElementById('talkBar');
|
|
334
|
+
// 보내는 칸은 위쪽 아이콘 줄 바로 아래에 붙어 있다(rawdev 2026-11-25 "ai에게 보내기 창이 화면 하단에 있어서 잘 안보여. 가능하면 상단에 둬").
|
|
335
|
+
// 아이콘 줄은 폭에 따라 두 줄이 되기도 하므로 그 높이를 따라 붙는 위치를 맞춘다. 스크롤해 무엇을 보이게 할 때(scrollIntoView)는
|
|
336
|
+
// 두 줄의 높이만큼 비워 두어, 작업 내용의 윗부분이 붙어 있는 두 줄 아래에 가려지지 않게 한다
|
|
337
|
+
if (typeof ResizeObserver === 'function') {
|
|
338
|
+
const fit = () => { const st = document.documentElement.style; st.setProperty('--bar-h', `${barEl.offsetHeight}px`); st.setProperty('--talk-h', `${talkEl.offsetHeight}px`); };
|
|
339
|
+
const ro = new ResizeObserver(fit); ro.observe(barEl); ro.observe(talkEl);
|
|
340
|
+
}
|
|
341
|
+
const endShow = document.getElementById('endShow');
|
|
342
|
+
const stageEl = document.getElementById('stage');
|
|
343
|
+
// 아이콘은 이 파일에 적은 고정 svg 글자만 innerHTML 로 넣는다. 사람이나 AI 가 쓴 글은 넣지 않는다(코어 화면의 아이콘과 같은 모양)
|
|
344
|
+
const ICONS = {
|
|
345
|
+
prev: '<path d="M10 3.5 5.5 8l4.5 4.5"/>',
|
|
346
|
+
next: '<path d="M6 3.5 10.5 8 6 12.5"/>',
|
|
347
|
+
save: '<path d="M8 2v8M4.5 6.5 8 10l3.5-3.5"/><path d="M2.5 11v2.5h11V11"/>',
|
|
348
|
+
side: '<rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M10 2.5v11"/>',
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
let nextId = 1;
|
|
352
|
+
const waiting = new Map();
|
|
353
|
+
let concept = null; // 호스트의 읽기 응답. body 가 플러그인 project 의 json 이다
|
|
354
|
+
let caps = { edit: true }; // capabilities(). conceptSelection, conceptPick, output 이 있으면 선택 보내기, 고른 것 알리기, 저장을 쓴다
|
|
355
|
+
let view = null; // 'work' 이거나 샘플 id. 한 번에 하나만 펼친다
|
|
356
|
+
let mode = 'select'; // select: 고르기(누르거나 끌어 고르고 위쪽 보내는 칸에서 AI 에게 보낸다), present: 발표 미리보기(옆 칸을 숨기고 이동 스크립트가 클릭과 키를 받는다)
|
|
357
|
+
let slideId = null; // 지금 보는 페이지 id. 작업본과 샘플 모두 안쪽 문서의 section id 다
|
|
358
|
+
// 지금 고른 것. { gen, payload, shared, redrawn, shareSeq, measureSeq }. HTML 디자인과 같은 이유로 보낸 선택과 다시 잰 값을
|
|
359
|
+
// 선택 객체 안에 둔다(html-design.md 9절의 sol 리뷰 F1).
|
|
360
|
+
let selection = null;
|
|
361
|
+
let selectionGen = 0;
|
|
362
|
+
let reference = null; // 참고 샘플에서 고른 요소. { sample, version, layout, key, label }
|
|
363
|
+
let drawn = { key: null, nonce: null, ready: false, base: null };
|
|
364
|
+
let measureSeq = 0;
|
|
365
|
+
const measureWaits = new Map();
|
|
366
|
+
let committing = false;
|
|
367
|
+
|
|
368
|
+
function call(method, params) {
|
|
369
|
+
return new Promise((resolve, reject) => {
|
|
370
|
+
const id = nextId++;
|
|
371
|
+
waiting.set(id, { resolve, reject });
|
|
372
|
+
parent.postMessage({ aic: 1, id, method, params }, '*');
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// ---- 안쪽 문서에서 도는 스크립트 ----
|
|
377
|
+
// 이 두 함수는 문자열로 srcdoc 에 들어간다. 바깥 변수를 쓰지 않는다.
|
|
378
|
+
|
|
379
|
+
/** 끈 영역에서 걸친 요소와 인접한 두 요소의 간격을 낸다. HTML 디자인과 같은 함수다. */
|
|
380
|
+
function computeGap(rect, items) {
|
|
381
|
+
const right = (b) => b.x + b.width;
|
|
382
|
+
const bottom = (b) => b.y + b.height;
|
|
383
|
+
const contains = (b) => b.x <= rect.x && b.y <= rect.y && right(b) >= rect.x + rect.width && bottom(b) >= rect.y + rect.height;
|
|
384
|
+
const overlaps = (b) => b.width > 0 && b.height > 0 && b.x < rect.x + rect.width && right(b) > rect.x && b.y < rect.y + rect.height && bottom(b) > rect.y;
|
|
385
|
+
const free = items.filter((b) => b.width > 0 && b.height > 0 && !contains(b));
|
|
386
|
+
const candidates = free.filter(overlaps).map((b) => b.key);
|
|
387
|
+
const area = (b) => b.width * b.height;
|
|
388
|
+
const pick = (list, score) => list.sort((p, q) => score(p) - score(q) || area(p) - area(q))[0];
|
|
389
|
+
const vertical = () => {
|
|
390
|
+
const cy = rect.y + rect.height / 2;
|
|
391
|
+
const xs = free.filter((b) => b.x < rect.x + rect.width && right(b) > rect.x);
|
|
392
|
+
const a = pick(xs.filter((b) => bottom(b) <= cy + 0.5), (b) => -bottom(b));
|
|
393
|
+
const b = pick(xs.filter((b) => b.y >= cy - 0.5), (b) => b.y);
|
|
394
|
+
return a && b && b.y >= bottom(a) ? { a: a.key, b: b.key, direction: 'vertical', px: Math.round((b.y - bottom(a)) * 10) / 10 } : null;
|
|
395
|
+
};
|
|
396
|
+
const horizontal = () => {
|
|
397
|
+
const cx = rect.x + rect.width / 2;
|
|
398
|
+
const ys = free.filter((b) => b.y < rect.y + rect.height && bottom(b) > rect.y);
|
|
399
|
+
const a = pick(ys.filter((b) => right(b) <= cx + 0.5), (b) => -right(b));
|
|
400
|
+
const b = pick(ys.filter((b) => b.x >= cx - 0.5), (b) => b.x);
|
|
401
|
+
return a && b && b.x >= right(a) ? { a: a.key, b: b.key, direction: 'horizontal', px: Math.round((b.x - right(a)) * 10) / 10 } : null;
|
|
402
|
+
};
|
|
403
|
+
const gap = rect.width >= rect.height ? vertical() || horizontal() : horizontal() || vertical();
|
|
404
|
+
return { candidates, gap };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function agentMain(cfg, computeGap) {
|
|
408
|
+
let mode = cfg.mode;
|
|
409
|
+
const W = cfg.width, H = cfg.height;
|
|
410
|
+
const post = (m) => parent.postMessage(Object.assign({ aicAgent: 1, nonce: cfg.nonce }, m), '*');
|
|
411
|
+
// 선택 표시는 shadow root 에 그려 테마 CSS 와 섞이지 않게 한다. 저장하는 파일에는 이 스크립트가 들어가지 않는다
|
|
412
|
+
const host = document.createElement('div');
|
|
413
|
+
host.setAttribute('data-aic-overlay', '');
|
|
414
|
+
host.style.cssText = 'position:fixed;left:0;top:0;width:0;height:0;pointer-events:none;z-index:2147483647';
|
|
415
|
+
const shadow = host.attachShadow({ mode: 'closed' });
|
|
416
|
+
shadow.innerHTML = '<style>.b{position:fixed;border:2px solid #1f9bd1;background:rgba(31,155,209,.10);pointer-events:none;box-sizing:border-box}.d{border-style:dashed}.g{position:fixed;background:rgba(224,122,139,.5);pointer-events:none}.t{position:fixed;font:12px/1.4 system-ui,sans-serif;background:#1f6a8c;color:#fff;padding:0 4px;border-radius:3px;white-space:nowrap}</style><div id="l"></div>';
|
|
417
|
+
const layer = shadow.getElementById('l');
|
|
418
|
+
document.documentElement.appendChild(host);
|
|
419
|
+
let marks = null;
|
|
420
|
+
const current = () => document.querySelector('.aic-slide:not([hidden])');
|
|
421
|
+
// 페이지 기준 좌표. 무대는 transform 으로 줄이므로 보이는 크기를 배율로 나눈다
|
|
422
|
+
const frameOf = () => { const s = current(); const r = s ? s.getBoundingClientRect() : { left: 0, top: 0, width: W }; return { left: r.left, top: r.top, scale: r.width / W || 1 }; };
|
|
423
|
+
const round = (n) => Math.round(n * 10) / 10;
|
|
424
|
+
const toSlide = (b, f) => ({ x: round((b.left - f.left) / f.scale), y: round((b.top - f.top) / f.scale), width: round(b.width / f.scale), height: round(b.height / f.scale) });
|
|
425
|
+
const toClient = (b, f) => ({ x: b.x * f.scale + f.left, y: b.y * f.scale + f.top, width: b.width * f.scale, height: b.height * f.scale });
|
|
426
|
+
const visible = (e) => { const s = current(); return Boolean(s && s.contains(e)); };
|
|
427
|
+
const byKey = (k) => { const e = document.querySelector('[data-aic-key="' + CSS.escape(k) + '"]'); return e && visible(e) ? e : null; };
|
|
428
|
+
const keyed = (n) => {
|
|
429
|
+
const e = n && (n.nodeType === 1 ? n : n.parentElement);
|
|
430
|
+
return e ? e.closest('[data-aic-key]') : null;
|
|
431
|
+
};
|
|
432
|
+
const pathOf = (n) => { const out = []; for (let x = keyed(n); x; x = x.parentElement ? x.parentElement.closest('[data-aic-key]') : null) out.push(x.getAttribute('data-aic-key')); return out; };
|
|
433
|
+
const textOf = (e) => (e.children.length === 0 ? e.textContent.replace(/\s+/g, ' ').trim() : null);
|
|
434
|
+
function linesOf(e) {
|
|
435
|
+
const r = document.createRange();
|
|
436
|
+
r.selectNodeContents(e);
|
|
437
|
+
const tops = new Set();
|
|
438
|
+
for (const b of r.getClientRects()) if (b.width > 0 && b.height > 0) tops.add(Math.round(b.top));
|
|
439
|
+
return tops.size;
|
|
440
|
+
}
|
|
441
|
+
function boxOf(e, f) {
|
|
442
|
+
const out = toSlide(e.getBoundingClientRect(), f);
|
|
443
|
+
if (textOf(e)) { out.lines = linesOf(e); out.fontSize = getComputedStyle(e).fontSize; }
|
|
444
|
+
return out;
|
|
445
|
+
}
|
|
446
|
+
const slideNow = () => { const s = current(); return s ? s.id : null; };
|
|
447
|
+
const viewport = (f) => ({ width: W, height: H, scale: Math.round(f.scale * 10000) / 10000 });
|
|
448
|
+
const allBoxes = (f) => { const s = current(); return s ? Array.from(s.querySelectorAll('[data-aic-key]')).map((e) => Object.assign({ key: e.getAttribute('data-aic-key') }, boxOf(e, f))) : []; };
|
|
449
|
+
function measure(keys) {
|
|
450
|
+
const f = frameOf();
|
|
451
|
+
const measured = {}, missing = [], texts = {};
|
|
452
|
+
for (const k of keys) {
|
|
453
|
+
const e = byKey(k);
|
|
454
|
+
if (!e) { missing.push(k); continue; }
|
|
455
|
+
measured[k] = boxOf(e, f);
|
|
456
|
+
const t = textOf(e);
|
|
457
|
+
if (t !== null) texts[k] = t;
|
|
458
|
+
}
|
|
459
|
+
return { measured, missing, texts, viewport: viewport(f), slide: slideNow() };
|
|
460
|
+
}
|
|
461
|
+
function draw() {
|
|
462
|
+
layer.textContent = '';
|
|
463
|
+
if (!marks || (marks.slide && marks.slide !== slideNow())) return;
|
|
464
|
+
const f = frameOf();
|
|
465
|
+
const add = (cls, b, text) => {
|
|
466
|
+
const d = document.createElement('div');
|
|
467
|
+
d.className = cls;
|
|
468
|
+
d.style.cssText = 'left:' + b.x + 'px;top:' + b.y + 'px;width:' + b.width + 'px;height:' + b.height + 'px';
|
|
469
|
+
if (text) { d.className = 't'; d.textContent = text; d.style.cssText = 'left:' + b.x + 'px;top:' + Math.max(0, b.y - 18) + 'px'; }
|
|
470
|
+
layer.appendChild(d);
|
|
471
|
+
};
|
|
472
|
+
const client = (e) => { const r = e.getBoundingClientRect(); return { x: r.left, y: r.top, width: r.width, height: r.height }; };
|
|
473
|
+
for (const k of marks.keys || []) { const e = byKey(k); if (e) { const b = client(e); add('b', b); add('t', b, marks.labels && marks.labels[k] || k); } }
|
|
474
|
+
if (marks.rect) add('b d', marks.slideRect ? toClient(marks.rect, f) : marks.rect);
|
|
475
|
+
if (marks.gap) {
|
|
476
|
+
const a = byKey(marks.gap.a), b = byKey(marks.gap.b);
|
|
477
|
+
if (a && b) {
|
|
478
|
+
const p = a.getBoundingClientRect(), q = b.getBoundingClientRect();
|
|
479
|
+
const g = marks.gap.direction === 'vertical'
|
|
480
|
+
? { x: Math.max(p.left, q.left), y: p.bottom, width: Math.max(8, Math.min(p.right, q.right) - Math.max(p.left, q.left)), height: Math.max(0, q.top - p.bottom) }
|
|
481
|
+
: { x: p.right, y: Math.max(p.top, q.top), width: Math.max(0, q.left - p.right), height: Math.max(8, Math.min(p.bottom, q.bottom) - Math.max(p.top, q.top)) };
|
|
482
|
+
add('g', g);
|
|
483
|
+
add('t', g, round((marks.gap.direction === 'vertical' ? q.top - p.bottom : q.left - p.right) / f.scale) + 'px');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
addEventListener('resize', draw);
|
|
488
|
+
document.addEventListener('aic-deck-show', (e) => { post({ type: 'slide', id: e.detail && e.detail.id }); draw(); });
|
|
489
|
+
// 고르기 모드에서는 링크 이동과 클릭으로 넘기기를 막고 고른 것만 알린다. 발표 미리보기에서는 이동 스크립트에 맡긴다
|
|
490
|
+
let start = null, dragging = false;
|
|
491
|
+
addEventListener('pointerdown', (e) => {
|
|
492
|
+
if (mode !== 'select' || e.button !== 0) return;
|
|
493
|
+
start = { x: e.clientX, y: e.clientY };
|
|
494
|
+
dragging = false;
|
|
495
|
+
e.preventDefault();
|
|
496
|
+
}, true);
|
|
497
|
+
addEventListener('pointermove', (e) => {
|
|
498
|
+
if (!start) return;
|
|
499
|
+
const w = e.clientX - start.x, h = e.clientY - start.y;
|
|
500
|
+
if (!dragging && Math.abs(w) + Math.abs(h) < 6) return;
|
|
501
|
+
dragging = true;
|
|
502
|
+
marks = { rect: { x: Math.min(start.x, e.clientX), y: Math.min(start.y, e.clientY), width: Math.abs(w), height: Math.abs(h) } };
|
|
503
|
+
draw();
|
|
504
|
+
}, true);
|
|
505
|
+
addEventListener('pointerup', (e) => {
|
|
506
|
+
if (!start) return;
|
|
507
|
+
const s = start;
|
|
508
|
+
start = null;
|
|
509
|
+
const f = frameOf();
|
|
510
|
+
if (dragging) {
|
|
511
|
+
const rect = toSlide({ left: Math.min(s.x, e.clientX), top: Math.min(s.y, e.clientY), width: Math.abs(e.clientX - s.x), height: Math.abs(e.clientY - s.y) }, f);
|
|
512
|
+
const found = computeGap(rect, allBoxes(f));
|
|
513
|
+
const keys = found.candidates.concat(found.gap ? [found.gap.a, found.gap.b] : []);
|
|
514
|
+
post({ type: 'area', rect: rect, candidates: found.candidates, gap: found.gap, m: measure(Array.from(new Set(keys))) });
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
const target = document.elementFromPoint(e.clientX, e.clientY);
|
|
518
|
+
const path = pathOf(target);
|
|
519
|
+
post({ type: 'pick', path: path, m: measure(path) });
|
|
520
|
+
}, true);
|
|
521
|
+
addEventListener('click', (e) => {
|
|
522
|
+
if (mode === 'select') { e.preventDefault(); e.stopPropagation(); }
|
|
523
|
+
}, true);
|
|
524
|
+
addEventListener('keydown', (e) => { if (e.key === 'Escape') post({ type: 'escape' }); });
|
|
525
|
+
addEventListener('message', (e) => {
|
|
526
|
+
if (e.source !== parent || !e.data || e.data.aicHost !== 1 || e.data.nonce !== cfg.nonce) return;
|
|
527
|
+
const d = e.data;
|
|
528
|
+
if (d.type === 'mode') { mode = d.mode; if (mode !== 'select') { start = null; } draw(); }
|
|
529
|
+
else if (d.type === 'marks') { marks = d.marks; draw(); }
|
|
530
|
+
else if (d.type === 'measure') post({ type: 'measured', req: d.req, m: measure(d.keys || []) });
|
|
531
|
+
else if (d.type === 'go') { if (window.aicDeck) window.aicDeck.go(d.id); draw(); }
|
|
532
|
+
else if (d.type === 'focus') { try { window.focus(); } catch (err) { /* 무시 */ } }
|
|
533
|
+
});
|
|
534
|
+
const ready = () => {
|
|
535
|
+
if (cfg.slide && window.aicDeck) window.aicDeck.go(cfg.slide);
|
|
536
|
+
post({ type: 'ready', slide: slideNow(), m: measure([]) });
|
|
537
|
+
};
|
|
538
|
+
if (document.readyState === 'complete') ready(); else addEventListener('load', ready);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// ---- 그리기 ----
|
|
542
|
+
|
|
543
|
+
/** 원본 HTML 을 그리기 전에 한 번 더 거른다. 원본은 논리가 이미 검사했고, 이것은 겹쳐 두는 검사다(HTML 디자인과 같다). */
|
|
544
|
+
function sanitizeHtml(html) {
|
|
545
|
+
if (typeof DOMParser === 'undefined') return html.replace(/<\s*script[\s\S]*?<\s*\/\s*script\s*>/gi, '').replace(/\son[a-z]+\s*=\s*"[^"]*"/gi, '');
|
|
546
|
+
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');
|
|
547
|
+
for (const n of doc.body.querySelectorAll('script,iframe,object,embed,link,meta,base,form,frame,frameset,template,style')) n.remove();
|
|
548
|
+
for (const n of doc.body.querySelectorAll('*')) {
|
|
549
|
+
for (const a of Array.from(n.attributes)) {
|
|
550
|
+
const name = a.name.toLowerCase();
|
|
551
|
+
if (name.startsWith('on') || name === 'style' || name === 'srcset' || name === 'formaction' || name === 'action') n.removeAttribute(a.name);
|
|
552
|
+
else if (name === 'href' && !/^#[\w-]*$/.test(a.value)) n.setAttribute('href', '#');
|
|
553
|
+
else if ((name === 'src' || name === 'poster') && !/^data:image\//.test(a.value)) n.removeAttribute(a.name);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return doc.body.innerHTML;
|
|
557
|
+
}
|
|
558
|
+
const sanitizeCss = (css) => css.replace(/<\/style/gi, '').replace(/@import[^;]*;?/gi, '').replace(/url\(\s*(["']?)(?!data:)[^)]*\)/gi, 'none');
|
|
559
|
+
const scriptText = (s) => s.replace(/<\//g, '<\\/');
|
|
560
|
+
|
|
561
|
+
function srcdocFor(doc, nonce) {
|
|
562
|
+
const size = concept.body.size;
|
|
563
|
+
const cfg = { nonce, mode, width: size.width, height: size.height, slide: slideId };
|
|
564
|
+
const agent = scriptText(`(${agentMain.toString()})(${JSON.stringify(cfg)}, ${computeGap.toString()});`);
|
|
565
|
+
// 이동 스크립트는 논리가 준 글자 그대로다. 저장하는 파일에 같은 글자가 들어간다
|
|
566
|
+
return `<!doctype html><html lang="ko"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>${sanitizeCss(doc.css)}</style></head><body>${sanitizeHtml(doc.html)}<script>${scriptText(concept.body.runtime)}<\/script><script>${agent}<\/script></body></html>`;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function currentDoc() {
|
|
570
|
+
const b = concept?.body;
|
|
571
|
+
if (!b) return null;
|
|
572
|
+
if (view === 'work') return b.current;
|
|
573
|
+
return b.catalog.find((c) => c.id === view)?.doc ?? null;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** 지금 보는 문서의 페이지 목록. [{ id, number, title }] */
|
|
577
|
+
function pagesOfView() {
|
|
578
|
+
const b = concept?.body;
|
|
579
|
+
if (!b) return [];
|
|
580
|
+
if (view === 'work') return b.slides.map((s) => ({ id: s.id, number: s.number, title: s.layout.title }));
|
|
581
|
+
const c = b.catalog.find((x) => x.id === view);
|
|
582
|
+
return c ? c.start.map((k, i) => ({ id: `${c.id}-${k}`, number: i + 1, title: c.layouts.find((l) => l.key === k)?.title ?? k })) : [];
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
let frame = null;
|
|
586
|
+
function ensureFrame() {
|
|
587
|
+
if (frame) return frame;
|
|
588
|
+
frame = document.createElement('iframe');
|
|
589
|
+
frame.setAttribute('id', 'frame');
|
|
590
|
+
frame.setAttribute('title', t('Presentation screen'));
|
|
591
|
+
// sandbox 를 따로 달지 않는다. 플러그인 iframe 의 sandbox(allow-scripts)와 화면 정책을 그대로 물려받는다(html-design.md 6절)
|
|
592
|
+
frameBox.append(frame);
|
|
593
|
+
return frame;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function sizeFrame() {
|
|
597
|
+
ensureFrame();
|
|
598
|
+
if (mode === 'present') { frameBox.style.width = ''; frameBox.style.height = ''; return; }
|
|
599
|
+
const avail = Math.max(240, (document.getElementById('canvas')?.clientWidth ?? 960) - 26);
|
|
600
|
+
const width = Math.floor(avail);
|
|
601
|
+
const height = Math.round((width * 9) / 16);
|
|
602
|
+
frameBox.style.width = `${width}px`;
|
|
603
|
+
frameBox.style.height = `${height}px`;
|
|
604
|
+
const size = concept?.body?.size ?? { width: 1920, height: 1080 };
|
|
605
|
+
// 위쪽 줄에 비율만 짧게 적고, 설명은 title 에 둔다
|
|
606
|
+
const percent = Math.round((width / size.width) * 100);
|
|
607
|
+
frameNote.textContent = `${percent}%`;
|
|
608
|
+
frameNote.setAttribute('title', t('Shows the {width}×{height} page at {percent}%. You can also turn pages with the arrow keys', { width: size.width, height: size.height, percent }));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** 지금 보는 문서를 그린다. 같은 문서면 다시 그리지 않는다. */
|
|
612
|
+
function drawFrame() {
|
|
613
|
+
const doc = currentDoc();
|
|
614
|
+
sizeFrame();
|
|
615
|
+
if (!doc) return false;
|
|
616
|
+
const pages = pagesOfView();
|
|
617
|
+
if (!pages.some((p) => p.id === slideId)) slideId = pages[0]?.id ?? null;
|
|
618
|
+
const key = `${view}|${doc.css}|${doc.html}`;
|
|
619
|
+
if (drawn.key === key) return true;
|
|
620
|
+
const nonce = `n${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
621
|
+
drawn = { key, nonce, ready: false, base: drawn.base };
|
|
622
|
+
ensureFrame().srcdoc = srcdocFor(doc, nonce);
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function toAgent(msg) {
|
|
627
|
+
if (!frame?.contentWindow || !drawn.nonce) return;
|
|
628
|
+
frame.contentWindow.postMessage({ aicHost: 1, nonce: drawn.nonce, ...msg }, '*');
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function measureKeys(keys) {
|
|
632
|
+
return new Promise((resolve) => {
|
|
633
|
+
if (!drawn.ready) { resolve(null); return; }
|
|
634
|
+
const req = (measureSeq += 1);
|
|
635
|
+
measureWaits.set(req, resolve);
|
|
636
|
+
toAgent({ type: 'measure', req, keys });
|
|
637
|
+
setTimeout(() => { if (measureWaits.delete(req)) resolve(null); }, 3000);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function goSlide(id) {
|
|
642
|
+
slideId = id;
|
|
643
|
+
toAgent({ type: 'go', id });
|
|
644
|
+
render();
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// ---- 호스트 ----
|
|
648
|
+
|
|
649
|
+
window.addEventListener('message', (e) => {
|
|
650
|
+
const d = e.data;
|
|
651
|
+
if (frame && e.source === frame.contentWindow) {
|
|
652
|
+
if (typeof d === 'object' && d !== null && d.aicAgent === 1 && d.nonce === drawn.nonce) onAgent(d);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (e.source !== parent) return;
|
|
656
|
+
if (typeof d !== 'object' || d === null || d.aic !== 1) return;
|
|
657
|
+
if (d.event === 'change') { refresh(); return; }
|
|
658
|
+
const w = waiting.get(d.id);
|
|
659
|
+
if (!w) return;
|
|
660
|
+
waiting.delete(d.id);
|
|
661
|
+
if (d.error) w.reject(new Error(d.error));
|
|
662
|
+
else w.resolve(d.result);
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
function onAgent(d) {
|
|
666
|
+
if (d.type === 'ready') {
|
|
667
|
+
drawn.ready = true;
|
|
668
|
+
// 새 문서는 그릴 때의 페이지에서 시작한다. 그리는 사이 다른 페이지로 옮겼으면(페이지를 더한 뒤 등) 그쪽으로 보낸다
|
|
669
|
+
if (!slideId) slideId = d.slide;
|
|
670
|
+
else if (d.slide !== slideId) toAgent({ type: 'go', id: slideId });
|
|
671
|
+
toAgent({ type: 'mode', mode });
|
|
672
|
+
if (mode === 'present') toAgent({ type: 'focus' });
|
|
673
|
+
pushMarks();
|
|
674
|
+
render();
|
|
675
|
+
afterDraw();
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (d.type === 'measured') {
|
|
679
|
+
const w = measureWaits.get(d.req);
|
|
680
|
+
if (w) { measureWaits.delete(d.req); w(d.m); }
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (d.type === 'slide') {
|
|
684
|
+
if (d.id && d.id !== slideId) { slideId = d.id; pushMarks(); render(); remeasure(); }
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (d.type === 'escape') { if (mode === 'present') setMode('select'); return; }
|
|
688
|
+
if (d.type === 'pick') { if (Array.isArray(d.path) && d.path.length) onPick(d.path, d.m); return; }
|
|
689
|
+
if (d.type === 'area' && d.rect) onArea(d);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
const slides = () => concept?.body?.slides ?? [];
|
|
693
|
+
const slideById = (id) => slides().find((s) => s.id === id) ?? null;
|
|
694
|
+
const allEls = () => slides().flatMap((s) => s.elements.map((e) => ({ ...e, slide: s.id })));
|
|
695
|
+
const elById = (id) => allEls().find((e) => e.id === id) ?? null;
|
|
696
|
+
const catalogOf = (id) => concept?.body?.catalog?.find((c) => c.id === id) ?? null;
|
|
697
|
+
/** 안쪽 문서의 키는 작업본에서는 element id 그대로다. 없는 키는 버린다. */
|
|
698
|
+
const known = (list) => (list ?? []).filter((k) => elById(k));
|
|
699
|
+
const onlyKnown = (map) => Object.fromEntries(Object.entries(map ?? {}).filter(([k]) => elById(k)));
|
|
700
|
+
|
|
701
|
+
function basePayload(m) {
|
|
702
|
+
const deck = concept.body.deck;
|
|
703
|
+
const s = slideById(m.slide);
|
|
704
|
+
return {
|
|
705
|
+
format: SELECTION_FORMAT,
|
|
706
|
+
deck: deck.id,
|
|
707
|
+
slide: m.slide,
|
|
708
|
+
number: s ? s.number : 0,
|
|
709
|
+
sample: { id: deck.sample.id, version: deck.sample.version },
|
|
710
|
+
plugin: PLUGIN_VERSION,
|
|
711
|
+
renderer: RENDERER,
|
|
712
|
+
rev: drawn.base ?? concept.base,
|
|
713
|
+
viewport: m.viewport,
|
|
714
|
+
labels: {},
|
|
715
|
+
texts: onlyKnown(m.texts),
|
|
716
|
+
measured: onlyKnown(m.measured),
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function withLabels(p, ids) {
|
|
721
|
+
for (const id of ids) { const e = elById(id); if (e) p.labels[id] = e.label; }
|
|
722
|
+
return p;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function onPick(pathKeys, m) {
|
|
726
|
+
if (view !== 'work') {
|
|
727
|
+
// 참고 샘플에서 고른 것은 다음 스타일 수정의 출처로 붙인다. 샘플 문서의 키는 '구성.요소키' 꼴이다
|
|
728
|
+
const c = catalogOf(view);
|
|
729
|
+
const [layout, key] = String(pathKeys[0]).split('.');
|
|
730
|
+
const l = c?.layouts.find((x) => x.key === layout);
|
|
731
|
+
const e = l?.elements.find((x) => x.key === key);
|
|
732
|
+
reference = c && e ? { sample: c.id, version: c.version, layout, key, label: t('{element} in {layout}', { element: e.label, layout: l.title }) } : null;
|
|
733
|
+
pushMarks();
|
|
734
|
+
render();
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const path = known(pathKeys);
|
|
738
|
+
if (!path.length || !m.slide) return;
|
|
739
|
+
setSelection(withLabels({ ...basePayload(m), kind: 'element', element: path[0], path }, path), true);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function onArea(d) {
|
|
743
|
+
if (view !== 'work' || !d.m.slide) return;
|
|
744
|
+
const candidates = known(d.candidates);
|
|
745
|
+
const gap = d.gap && elById(d.gap.a) && elById(d.gap.b) ? d.gap : null;
|
|
746
|
+
setSelection(withLabels({ ...basePayload(d.m), kind: 'area', area: d.rect, candidates, gap }, [...candidates, ...(gap ? [gap.a, gap.b] : [])]), true);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/** 슬라이드에서 누르거나 끌어 고르면(toTalk) 바로 말을 적도록 보내는 칸에 초점을 옮긴다. 목록에서 고를 때는 옮기지 않는다. */
|
|
750
|
+
function setSelection(payload, toTalk = false) {
|
|
751
|
+
selection = { gen: (selectionGen += 1), payload, shared: null, redrawn: null, shareSeq: 0, measureSeq: 0 };
|
|
752
|
+
pushMarks();
|
|
753
|
+
render();
|
|
754
|
+
notifyPick();
|
|
755
|
+
if (toTalk) focusTalk();
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** 선택이 가리키는 record. 보낼 때와 고른 것을 알릴 때 같다. */
|
|
759
|
+
function selectionRecords(p) {
|
|
760
|
+
return [...new Set([p.slide, ...(p.kind === 'element' ? [p.element] : p.candidates), ...(p.gap ? [p.gap.a, p.gap.b] : [])])];
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/** 고른 것을 호스트에 알린다(032 30절 11번, rawdev 2026-11-18). 코어는 기록하지 않고 선택 id 를 만들지 않으며 AI 를 깨우지 않는다.
|
|
764
|
+
* AI 는 read_selection 에서 "화면에서 지금 고른 것(보내지 않음)" 으로 읽는다. 모양은 shareSelection 에서 role 과 said 를 뺀 것이고
|
|
765
|
+
* 답은 기다리지 않는다. 보낸 뒤에는 코어가 지우므로 null 을 보내지 않고, 화면이 바뀌거나 닫히면 호스트가 지운다. */
|
|
766
|
+
function notifyPick() {
|
|
767
|
+
if (!caps.conceptPick || caps.edit === false) return;
|
|
768
|
+
const p = selection?.payload ?? null;
|
|
769
|
+
call('setPick', p ? { base: p.rev, payload: p, records: selectionRecords(p) } : null).catch(() => {});
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** 고른 뒤 말 칸으로 초점을 옮긴다. 초점을 줄 때의 스크롤은 막고, 보내는 칸이 화면 밖에 있을 때만 보일 만큼 움직인다(위에 붙어 있어 보통은 움직이지 않는다).
|
|
773
|
+
* 그래야 방금 고른 곳이 화면에서 크게 밀려나지 않는다. */
|
|
774
|
+
function focusTalk() {
|
|
775
|
+
if (typeof talkInput?.focus !== 'function') return;
|
|
776
|
+
try { talkInput.focus({ preventScroll: true }); } catch { talkInput.focus(); }
|
|
777
|
+
if (typeof talkEl.getBoundingClientRect !== 'function') return;
|
|
778
|
+
const r = talkEl.getBoundingClientRect();
|
|
779
|
+
if (r.bottom > window.innerHeight || r.top < 0) talkEl.scrollIntoView({ block: 'nearest' });
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** 요소 목록이나 감싼 구역에서 고른다. 그 페이지로 가서 다시 잰다. */
|
|
783
|
+
async function selectElement(id) {
|
|
784
|
+
const e = elById(id);
|
|
785
|
+
if (!e) return;
|
|
786
|
+
if (e.slide !== slideId) goSlide(e.slide);
|
|
787
|
+
const keys = [];
|
|
788
|
+
for (let x = e; x; x = x.parent ? elById(x.parent) : null) keys.push(x.id);
|
|
789
|
+
const gen = selectionGen;
|
|
790
|
+
const m = (await measureKeys(keys)) ?? { measured: {}, texts: {}, viewport: { width: 1920, height: 1080 }, slide: e.slide };
|
|
791
|
+
if (gen !== selectionGen) return;
|
|
792
|
+
if (m.slide !== e.slide) m.slide = e.slide;
|
|
793
|
+
setSelection(withLabels({ ...basePayload(m), kind: 'element', element: id, path: keys }, keys));
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function selectionKeys(p) {
|
|
797
|
+
const ids = p.kind === 'element' ? [p.element] : [...(p.candidates ?? []), ...(p.gap ? [p.gap.a, p.gap.b] : [])];
|
|
798
|
+
return [...new Set(ids)];
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function pushMarks() {
|
|
802
|
+
if (!drawn.ready) return;
|
|
803
|
+
if (mode === 'present') { toAgent({ type: 'marks', marks: null }); return; }
|
|
804
|
+
if (view !== 'work') {
|
|
805
|
+
const k = reference && reference.sample === view ? `${reference.layout}.${reference.key}` : null;
|
|
806
|
+
toAgent({ type: 'marks', marks: k ? { keys: [k], labels: { [k]: t('Reference: {name}', { name: reference.label }) } } : null });
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
const p = selection?.payload;
|
|
810
|
+
if (!p) { toAgent({ type: 'marks', marks: null }); return; }
|
|
811
|
+
const labels = {};
|
|
812
|
+
for (const id of Object.keys(p.labels)) { const e = elById(id); if (e) labels[id] = `${e.label} ${id}`; }
|
|
813
|
+
// 끈 사각형은 그때 그린 화면의 좌표다. 다시 그린 뒤에는 숨기고 같은 두 요소 사이의 간격만 표시한다
|
|
814
|
+
const rect = p.rev === (drawn.base ?? concept.base) ? p.area : null;
|
|
815
|
+
toAgent({ type: 'marks', marks: p.kind === 'element'
|
|
816
|
+
? { slide: p.slide, keys: [p.element].filter((x) => elById(x)), labels }
|
|
817
|
+
: { slide: p.slide, rect, slideRect: true, gap: p.gap && elById(p.gap.a) && elById(p.gap.b) ? p.gap : null, keys: [], labels } });
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/** 그린 뒤에 할 일: 그린 기준을 호스트에 알리고, 선택이 있으면 같은 대상을 다시 잰다. */
|
|
821
|
+
async function afterDraw() {
|
|
822
|
+
if (drawPending && concept && typeof concept.renderToken === 'string') {
|
|
823
|
+
drawPending = false;
|
|
824
|
+
drawn.base = concept.base;
|
|
825
|
+
parent.postMessage({ aic: 1, event: 'rendered', token: concept.renderToken }, '*');
|
|
826
|
+
}
|
|
827
|
+
await remeasure();
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
async function remeasure() {
|
|
831
|
+
const sel = selection;
|
|
832
|
+
const p = sel?.payload;
|
|
833
|
+
if (!p || view !== 'work' || !concept || !drawn.ready) return;
|
|
834
|
+
if (p.rev === concept.base && !sel.redrawn) return; // 선택한 revision 그대로면 당시 값과 같다
|
|
835
|
+
if (sel.redrawn && sel.redrawn.rev === concept.base) return;
|
|
836
|
+
// 다른 페이지를 보고 있으면 그 페이지로 돌아올 때까지 측정 대기다(html-slides.md 9절)
|
|
837
|
+
if (slideId !== p.slide) return;
|
|
838
|
+
const seq = (sel.measureSeq += 1);
|
|
839
|
+
const base = concept.base;
|
|
840
|
+
const nonce = drawn.nonce;
|
|
841
|
+
const m = await measureKeys(selectionKeys(p));
|
|
842
|
+
if (!m || m.slide !== p.slide || selection !== sel || sel.measureSeq !== seq || drawn.nonce !== nonce || concept.base !== base || view !== 'work') return;
|
|
843
|
+
const measured = onlyKnown(m.measured);
|
|
844
|
+
let gap = null;
|
|
845
|
+
if (p.gap) {
|
|
846
|
+
const a = measured[p.gap.a], b = measured[p.gap.b];
|
|
847
|
+
if (a && b) gap = { ...p.gap, px: Math.round((p.gap.direction === 'vertical' ? b.y - (a.y + a.height) : b.x - (a.x + a.width)) * 10) / 10 };
|
|
848
|
+
}
|
|
849
|
+
const redrawn = { rev: base, slide: p.slide, viewport: m.viewport, renderer: RENDERER, measured, gap, missing: m.missing ?? [] };
|
|
850
|
+
sel.redrawn = redrawn;
|
|
851
|
+
if (sel.shared && caps.conceptSelection) {
|
|
852
|
+
try {
|
|
853
|
+
await call('reportMeasurement', { selection: sel.shared.id, payload: redrawn });
|
|
854
|
+
} catch (err) {
|
|
855
|
+
toast(t('Could not send the new measurements: {error}', { error: err.message }), true);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
pushMarks();
|
|
859
|
+
render();
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
let drawPending = false;
|
|
863
|
+
let inflight = null;
|
|
864
|
+
let again = false;
|
|
865
|
+
function refresh() {
|
|
866
|
+
if (inflight) { again = true; return inflight; }
|
|
867
|
+
inflight = (async () => {
|
|
868
|
+
try {
|
|
869
|
+
const c = await call('readConcept');
|
|
870
|
+
errorEl.hidden = true;
|
|
871
|
+
// 다른 참여자(AI)의 아직 합쳐지지 않은 변경까지 얹은 상태를 그린다(HTML 디자인과 같다)
|
|
872
|
+
concept = { ...c, body: c.withOthers ?? c.body };
|
|
873
|
+
const b = concept.body ?? {};
|
|
874
|
+
if (view === null || (view === 'work' && !b.deck)) view = b.deck ? 'work' : b.catalog?.[0]?.id ?? null;
|
|
875
|
+
if (selection && b.deck && selection.payload.deck !== b.deck.id) { selection = null; selectionGen += 1; notifyPick(); }
|
|
876
|
+
drawPending = typeof c.renderToken === 'string';
|
|
877
|
+
render();
|
|
878
|
+
if (drawFrame() && drawn.ready) await afterDraw();
|
|
879
|
+
} catch (err) {
|
|
880
|
+
errorEl.textContent = err.message;
|
|
881
|
+
errorEl.hidden = false;
|
|
882
|
+
}
|
|
883
|
+
})().finally(() => {
|
|
884
|
+
inflight = null;
|
|
885
|
+
if (again) { again = false; refresh(); }
|
|
886
|
+
});
|
|
887
|
+
return inflight;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
let toastTimer = null;
|
|
891
|
+
function toast(text, bad = false) {
|
|
892
|
+
toastEl.textContent = text;
|
|
893
|
+
toastEl.classList.toggle('bad', bad);
|
|
894
|
+
toastEl.hidden = false;
|
|
895
|
+
clearTimeout(toastTimer);
|
|
896
|
+
toastTimer = setTimeout(() => { toastEl.hidden = true; }, bad ? 7000 : 3500);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async function send(steps) {
|
|
900
|
+
if (committing) return null;
|
|
901
|
+
committing = true;
|
|
902
|
+
try {
|
|
903
|
+
const res = await call('applyOperation', { base: concept.base, steps });
|
|
904
|
+
if (!res.ok) { toast(res.summary ?? res.error, true); await refresh(); return null; }
|
|
905
|
+
toast(res.summary);
|
|
906
|
+
await refresh();
|
|
907
|
+
return res;
|
|
908
|
+
} catch (err) {
|
|
909
|
+
toast(err.message, true);
|
|
910
|
+
return null;
|
|
911
|
+
} finally {
|
|
912
|
+
committing = false;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// ---- 화면 ----
|
|
917
|
+
|
|
918
|
+
function el(tag, props, ...children) {
|
|
919
|
+
const n = document.createElement(tag);
|
|
920
|
+
for (const [k, v] of Object.entries(props ?? {})) {
|
|
921
|
+
if (k === 'class') n.className = v;
|
|
922
|
+
else if (k === 'on') for (const [ev, fn] of Object.entries(v)) n.addEventListener(ev, fn);
|
|
923
|
+
else if (k === 'value') n.value = v;
|
|
924
|
+
else if (v !== false && v !== null && v !== undefined) n.setAttribute(k, v === true ? '' : v);
|
|
925
|
+
}
|
|
926
|
+
for (const c of children.flat(Infinity)) {
|
|
927
|
+
if (c === null || c === undefined || c === false) continue;
|
|
928
|
+
n.append(c instanceof Node ? c : String(c));
|
|
929
|
+
}
|
|
930
|
+
return n;
|
|
931
|
+
}
|
|
932
|
+
const btn = (label, onClick, extra = {}) => el('button', { type: 'button', class: 'btn', on: { click: onClick }, ...extra }, label);
|
|
933
|
+
const pressed = (on) => (on ? 'true' : 'false');
|
|
934
|
+
const number = (n) => n.toLocaleString('ko-KR');
|
|
935
|
+
function icon(name) {
|
|
936
|
+
const s = el('span', { class: 'ic', 'aria-hidden': 'true' });
|
|
937
|
+
s.innerHTML = `<svg viewBox="0 0 16 16">${ICONS[name]}</svg>`;
|
|
938
|
+
return s;
|
|
939
|
+
}
|
|
940
|
+
/** 아이콘 버튼. 이름은 aria-label 과 title 에 둔다. title 을 따로 주면 그것을 보인다. */
|
|
941
|
+
const iconBtn = (name, label, onClick, extra = {}, ...more) => el('button', { type: 'button', class: 'icon-btn', 'aria-label': label, title: label, on: { click: onClick }, ...extra }, icon(name), ...more);
|
|
942
|
+
|
|
943
|
+
// 접는 칸의 열림은 다시 그려도 지킨다. 화면을 다시 그릴 때마다 닫히지 않게 사람이 연 것을 기억한다
|
|
944
|
+
const folds = {};
|
|
945
|
+
function fold(key, open, summary, children, extra = {}, summaryProps = {}) {
|
|
946
|
+
return el('details', { ...extra, open: folds[key] ?? open, on: { toggle: (e) => { folds[key] = e.target.open; } } }, el('summary', summaryProps, summary), children);
|
|
947
|
+
}
|
|
948
|
+
// 펼친 메뉴는 바깥을 누르면 닫는다
|
|
949
|
+
document.addEventListener?.('click', (e) => {
|
|
950
|
+
for (const d of document.querySelectorAll('details.menu[open]')) if (!d.contains(e.target)) { d.open = false; folds[d.dataset.fold] = false; }
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
// 오른쪽 편집 칸(발표 자료 정보, 페이지 목록과 페이지 도구, 고른 것의 잰 값, 문구와 스타일 고치기, 요소 목록). 발표 자료 화면에서는
|
|
954
|
+
// 닫힌 채 시작하고 위쪽 줄 오른쪽 버튼으로 연다. 샘플 고르기와 참고 샘플 화면에서는 그 칸이 그 화면의 할 일(시작하기, 돌아가기)이라
|
|
955
|
+
// 늘 보인다(rawdev 2026-11-24, 코어 화면 032 34절과 같은 방향)
|
|
956
|
+
let sideOpen = false;
|
|
957
|
+
const sideShown = () => !concept?.body?.deck || view !== 'work' || sideOpen;
|
|
958
|
+
function toggleSide() { sideOpen = !sideOpen; render(); }
|
|
959
|
+
|
|
960
|
+
function renderBar() {
|
|
961
|
+
const b = concept.body;
|
|
962
|
+
// 보는 화면은 메뉴 하나로 고른다. 메뉴 이름이 지금 보는 화면이라 펼치지 않아도 안다
|
|
963
|
+
const name = (id) => (b.deck ? (id === 'work' ? t('Deck') : t('Reference: {name}', { name: catalogOf(id)?.title ?? id })) : t('Sample: {name}', { name: catalogOf(id)?.title ?? id }));
|
|
964
|
+
const choose = (id) => { folds.view = false; switchView(id); };
|
|
965
|
+
const items = [...(b.deck ? [btn(t('Deck'), () => choose('work'), { 'aria-pressed': pressed(view === 'work') })] : []),
|
|
966
|
+
...b.catalog.map((c) => btn(b.deck ? t('Reference: {name}', { name: c.title }) : c.title, () => choose(c.id), { 'aria-pressed': pressed(view === c.id) }))];
|
|
967
|
+
const views = fold('view', false, name(view), el('div', { class: 'pop', role: 'group', 'aria-label': t('View') }, items),
|
|
968
|
+
{ class: 'menu', 'data-fold': 'view' }, { title: t('Choose what to view') });
|
|
969
|
+
// 지금 몇 쪽인지는 한눈에 보여야 하므로 위쪽 줄에 둔다. 이 페이지가 AiAkiv 저장 한도를 넘으면 그것도 적는다
|
|
970
|
+
const pages = pagesOfView();
|
|
971
|
+
const at = pages.findIndex((p) => p.id === slideId);
|
|
972
|
+
const cur = view === 'work' ? slideById(slideId) : null;
|
|
973
|
+
const nav = pages.length ? el('div', { class: 'group', role: 'group', 'aria-label': t('Pages') },
|
|
974
|
+
iconBtn('prev', t('Previous page'), () => goSlide(pages[at - 1].id), { disabled: at <= 0 }),
|
|
975
|
+
el('span', { class: 'meta', title: at >= 0 ? t('Page {number}: {title}', { number: pages[at].number, title: pages[at].title }) : '' }, `${at + 1} / ${pages.length}`),
|
|
976
|
+
iconBtn('next', t('Next page'), () => goSlide(pages[at + 1].id), { disabled: at < 0 || at >= pages.length - 1 }),
|
|
977
|
+
cur && !cur.aiakiv ? el('span', { class: 'warn', title: t('The source of this page is over {max} characters, so it cannot be saved to AiAkiv. You can still edit and save it', { max: number(b.aiakivMax) }) }, t('Over AiAkiv limit')) : null) : null;
|
|
978
|
+
const modes = el('div', { class: 'group', role: 'group', 'aria-label': t('Mode') },
|
|
979
|
+
btn(t('Pick'), () => setMode('select'), { 'aria-pressed': pressed(mode === 'select'), title: t('Click the slide to pick an element, or drag to pick an area. Write a message in the send bar at the top and send it to the AI') }),
|
|
980
|
+
btn(t('Presentation preview'), () => setMode('present'), { 'aria-pressed': pressed(mode === 'present'), title: t('Presents inside the plugin area. Real full screen works in the saved file') }), frameNote);
|
|
981
|
+
const canSave = Boolean(b.deck) && Array.isArray(caps.output) && caps.output.includes('html');
|
|
982
|
+
const save = iconBtn('save', t('Save as HTML file'), saveHtml, { disabled: !canSave, title: canSave ? t('Save as HTML file: saves this deck as a single HTML file. Open it in a browser to present in full screen') : !b.deck ? t('Save as HTML file: start a deck first, then save') : t('Save as HTML file: this host cannot save HTML yet') });
|
|
983
|
+
// 닫힌 편집 칸에 새로 다시 잰 값이 오면 버튼에 점을 찍는다. 열면 지운다
|
|
984
|
+
const fresh = !sideOpen && Boolean(selection?.redrawn) && selection.seen !== selection.redrawn;
|
|
985
|
+
const side = b.deck && view === 'work'
|
|
986
|
+
? iconBtn('side', t('Edit panel'), toggleSide, { 'aria-pressed': pressed(sideOpen), 'aria-controls': 'side',
|
|
987
|
+
title: `${sideOpen ? t('Close the edit panel: page list and page tools, measurements of what you picked, text and style editing, element list') : t('Open the edit panel: page list and page tools, measurements of what you picked, text and style editing, element list')}${fresh ? `. ${t('New measurements are in')}` : ''}` }, fresh ? el('span', { class: 'dot' }) : null)
|
|
988
|
+
: null;
|
|
989
|
+
barEl.replaceChildren(...[views, nav, modes, el('span', { class: 'spacer' }), save, side].filter(Boolean));
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function switchView(v) {
|
|
993
|
+
view = v;
|
|
994
|
+
slideId = null;
|
|
995
|
+
drawFrame();
|
|
996
|
+
render();
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function setMode(m) {
|
|
1000
|
+
mode = m;
|
|
1001
|
+
document.body.classList.toggle('present', m === 'present');
|
|
1002
|
+
endShow.hidden = m !== 'present';
|
|
1003
|
+
toAgent({ type: 'mode', mode });
|
|
1004
|
+
pushMarks();
|
|
1005
|
+
sizeFrame();
|
|
1006
|
+
render();
|
|
1007
|
+
if (m === 'present') { frame?.focus(); toAgent({ type: 'focus' }); }
|
|
1008
|
+
}
|
|
1009
|
+
endShow.addEventListener('click', () => setMode('select'));
|
|
1010
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && mode === 'present') setMode('select'); });
|
|
1011
|
+
|
|
1012
|
+
async function saveHtml() {
|
|
1013
|
+
try {
|
|
1014
|
+
const res = await call('saveOutput', { base: concept.base, format: 'html' });
|
|
1015
|
+
if (res?.ok) toast(t('Saved: {file}. Open it in a browser and press [전체화면] (Full screen) or F to present', { file: res.fileName ?? res.artifact }));
|
|
1016
|
+
else toast(res?.summary ?? res?.error ?? t('Could not save'), true);
|
|
1017
|
+
} catch (err) {
|
|
1018
|
+
toast(err.message, true);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function boxText(b) {
|
|
1023
|
+
if (!b) return t('none');
|
|
1024
|
+
return `${b.x}, ${b.y} / ${b.width}×${b.height}${b.lines ? `, ${t('{count} lines', { count: b.lines })}` : ''}`;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function compareTable(p) {
|
|
1028
|
+
const redrawn = selection?.redrawn ?? null;
|
|
1029
|
+
const rows = [];
|
|
1030
|
+
const head = el('tr', {}, el('th', {}, ''), el('th', {}, t('At selection {rev}', { rev: p.rev })), el('th', {}, redrawn ? t('Redrawn {rev}', { rev: redrawn.rev }) : t('Redrawn')));
|
|
1031
|
+
if (p.gap) rows.push(el('tr', {}, el('th', {}, t('Gap')), el('td', {}, `${p.gap.px}px`), el('td', {}, redrawn?.gap ? `${redrawn.gap.px}px` : '-')));
|
|
1032
|
+
for (const id of Object.keys(p.measured)) {
|
|
1033
|
+
rows.push(el('tr', {}, el('th', {}, `${p.labels[id] ?? id}`), el('td', {}, boxText(p.measured[id])), el('td', {}, redrawn ? (redrawn.missing?.includes(id) ? t('gone') : boxText(redrawn.measured[id])) : '-')));
|
|
1034
|
+
}
|
|
1035
|
+
const note = !redrawn
|
|
1036
|
+
? el('p', { class: 'note' }, p.rev === concept.base ? t('Nothing has changed yet, so the values are the same as at selection. Values are on the 1920×1080 page.') : slideId !== p.slide ? t('Waiting for measurement: go back to the page of this selection to measure again.') : t('Waiting for measurement: it measures again when the new revision is drawn.'))
|
|
1037
|
+
: null;
|
|
1038
|
+
return [fold('measure', false, redrawn ? t('Measurements: at selection and redrawn {rev}', { rev: redrawn.rev }) : t('Measurements'), [el('table', { class: 'compare' }, el('thead', {}, head), el('tbody', {}, rows)), note], { class: 'sub' })];
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function selectionSection() {
|
|
1042
|
+
const p = selection?.payload;
|
|
1043
|
+
if (!p) {
|
|
1044
|
+
return el('section', {}, el('h2', {}, t('Picked')),
|
|
1045
|
+
el('p', { class: 'note' }, t('You have not picked anything yet. Click or drag on the slide to pick. With the keyboard, pick from the element list below.')));
|
|
1046
|
+
}
|
|
1047
|
+
const s = slideById(p.slide);
|
|
1048
|
+
const page = s ? t('page {number}', { number: s.number }) : t('removed page');
|
|
1049
|
+
const parts = [el('h2', {}, p.kind === 'element' ? t('Picked element ({page})', { page }) : t('Picked area ({page})', { page }))];
|
|
1050
|
+
if (p.kind === 'element') {
|
|
1051
|
+
const e = elById(p.element);
|
|
1052
|
+
parts.push(el('dl', { class: 'kv' },
|
|
1053
|
+
el('dt', {}, t('Element')), el('dd', {}, `${e?.label ?? p.labels[p.element]} (${p.element})`),
|
|
1054
|
+
p.texts[p.element] !== undefined ? [el('dt', {}, t('Text')), el('dd', {}, p.texts[p.element])] : null));
|
|
1055
|
+
if (p.path && p.path.length > 1) {
|
|
1056
|
+
parts.push(el('div', { class: 'crumbs' }, el('span', { class: 'note' }, t('Pick an enclosing part')),
|
|
1057
|
+
p.path.map((id) => el('button', { type: 'button', class: 'chip', 'aria-current': id === p.element ? 'true' : 'false', on: { click: () => selectElement(id) } }, elById(id)?.label ?? id))));
|
|
1058
|
+
}
|
|
1059
|
+
} else {
|
|
1060
|
+
parts.push(el('dl', { class: 'kv' },
|
|
1061
|
+
el('dt', {}, t('Area')), el('dd', {}, `${p.area.x}, ${p.area.y} / ${p.area.width}×${p.area.height}`),
|
|
1062
|
+
el('dt', {}, t('Elements in it')), el('dd', {}, p.candidates.length ? '' : t('none')),
|
|
1063
|
+
p.gap ? [el('dt', {}, t('Between')), el('dd', {}, p.gap.direction === 'vertical'
|
|
1064
|
+
? t('vertical {px}px between {a} and {b}', { px: p.gap.px, a: p.labels[p.gap.a], b: p.labels[p.gap.b] })
|
|
1065
|
+
: t('horizontal {px}px between {a} and {b}', { px: p.gap.px, a: p.labels[p.gap.a], b: p.labels[p.gap.b] }))] : null));
|
|
1066
|
+
if (p.candidates.length) {
|
|
1067
|
+
parts.push(el('div', { class: 'crumbs' }, p.candidates.map((id) => el('button', { type: 'button', class: 'chip', on: { click: () => selectElement(id) } }, elById(id)?.label ?? id))));
|
|
1068
|
+
if (p.candidates.length > 1) parts.push(el('p', { class: 'note' }, t('Several elements are in it. Click one to point at that element only.')));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
parts.push(...compareTable(p));
|
|
1072
|
+
return el('section', {}, parts);
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
let talk = { role: 'change', said: '' };
|
|
1076
|
+
let talkInput = null;
|
|
1077
|
+
const MAX_TALK_NAMES = 3;
|
|
1078
|
+
|
|
1079
|
+
/** 보내는 칸에 적는 고른 것의 한 줄. 몇 쪽의 무엇인지 사람이 바로 알아보게 쓴다. */
|
|
1080
|
+
function selText(p) {
|
|
1081
|
+
const s = slideById(p.slide);
|
|
1082
|
+
const page = s ? t('page {number}', { number: s.number }) : t('a removed page');
|
|
1083
|
+
const label = (id) => elById(id)?.label ?? p.labels[id] ?? id;
|
|
1084
|
+
if (p.kind === 'element') {
|
|
1085
|
+
const text = p.texts[p.element];
|
|
1086
|
+
return `${t('{label} on {page}', { label: label(p.element), page })}${text ? ` "${text.length > 30 ? `${text.slice(0, 30)}…` : text}"` : ''}`;
|
|
1087
|
+
}
|
|
1088
|
+
if (p.gap) return t('the area between {a} and {b} on {page}', { a: label(p.gap.a), b: label(p.gap.b), page });
|
|
1089
|
+
if (!p.candidates.length) return t('an empty area on {page}', { page });
|
|
1090
|
+
const names = p.candidates.slice(0, MAX_TALK_NAMES).map(label).join(', ');
|
|
1091
|
+
return p.candidates.length > MAX_TALK_NAMES
|
|
1092
|
+
? t('an area on {page} ({names} and {more} more)', { page, names, more: p.candidates.length - MAX_TALK_NAMES })
|
|
1093
|
+
: t('an area on {page} ({names})', { page, names });
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/** 고른 뒤 다시 그린 값이 오면 한눈에 보이게 보내는 칸의 줄에 간격의 변화를 적는다. */
|
|
1097
|
+
function gapChange(p) {
|
|
1098
|
+
const r = selection?.redrawn;
|
|
1099
|
+
return p.gap && r?.gap ? ` ${t('The gap was {before}px and is now {after}px.', { before: p.gap.px, after: r.gap.px })}` : '';
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// 고른 것을 AI 에게 보내는 칸(svg 플러그인의 보내는 칸과 같은 이유, rawdev 2026-11-18). 위쪽 아이콘 줄 바로 아래에 붙여 늘 보이게 둔다(처음에는 슬라이드 아래였다, rawdev 2026-11-25 위로 옮김).
|
|
1103
|
+
// 한 줄로 줄였다(rawdev 2026-11-24): 고르기 전에는 말 칸의 안내 글이 할 일을 말하고, 차례와 AI 가 읽는 방식은 [?] 를 눌러 본다.
|
|
1104
|
+
// 고른 뒤에는 고른 것, 보냈는지, 다시 잰 간격처럼 한눈에 보여야 하는 것만 한 줄로 적는다.
|
|
1105
|
+
// 말은 비워도 보내고(코어는 말 없는 선택을 받는다) Enter 로도 보낸다. Esc 는 초점을 슬라이드로 돌려 화살표로 넘기게 한다
|
|
1106
|
+
function renderTalk() {
|
|
1107
|
+
const show = Boolean(concept?.body?.deck) && view === 'work';
|
|
1108
|
+
talkEl.hidden = !show;
|
|
1109
|
+
if (!show) { talkInput = null; talkEl.replaceChildren(); return; }
|
|
1110
|
+
const p = selection?.payload ?? null;
|
|
1111
|
+
const can = Boolean(caps.conceptSelection) && caps.edit !== false;
|
|
1112
|
+
const said = el('input', { type: 'text', 'data-keep': 'said', 'aria-label': t('What to tell the AI about the picked place'), value: talk.said, disabled: !can,
|
|
1113
|
+
placeholder: p ? t('For example: make this title shorter. You can also send it empty') : t('First click or drag on the slide to pick what to change, then write your message here and send it'),
|
|
1114
|
+
on: {
|
|
1115
|
+
input: (e) => { talk.said = e.target.value; },
|
|
1116
|
+
keydown: (e) => {
|
|
1117
|
+
if (e.key === 'Enter' && !e.isComposing && selection && can) { e.preventDefault(); shareSelection(); }
|
|
1118
|
+
if (e.key === 'Escape') { e.target.blur(); frame?.focus(); toAgent({ type: 'focus' }); }
|
|
1119
|
+
},
|
|
1120
|
+
} });
|
|
1121
|
+
talkInput = said;
|
|
1122
|
+
const role = el('select', { 'aria-label': t('Role of the picked place'), disabled: !can, on: { change: (e) => { talk.role = e.target.value; } } },
|
|
1123
|
+
el('option', { value: 'change', ...(talk.role === 'change' ? { selected: true } : {}) }, t('Change this')),
|
|
1124
|
+
el('option', { value: 'reference', ...(talk.role === 'reference' ? { selected: true } : {}) }, t('Use as reference')));
|
|
1125
|
+
// 편집 칸이 닫혀 있으면 고른 요소를 직접 고칠 수 있다는 것을 줄 끝에 알린다
|
|
1126
|
+
const direct = p && p.kind === 'element' && caps.edit !== false && !sideOpen ? btn(t('Edit directly'), toggleSide, { class: 'link', title: t('Opens the edit panel so you can edit text, links and styles yourself') }) : null;
|
|
1127
|
+
let head = null;
|
|
1128
|
+
if (!can) {
|
|
1129
|
+
head = el('p', { class: 'state' }, caps.edit === false ? t('A view-only screen does not send to the AI.') : t('This host cannot send what you picked to the AI yet.'));
|
|
1130
|
+
} else if (p && selection.shared) {
|
|
1131
|
+
head = el('p', { class: 'state' }, el('span', { class: 'done' }, t('Sent to the AI (selection {id}).', { id: selection.shared.id })),
|
|
1132
|
+
` ${selText(p)}, ${selection.shared.said ? t('message "{said}"', { said: selection.shared.said }) : t('no message')}.${gapChange(p)}`, direct);
|
|
1133
|
+
} else if (p) {
|
|
1134
|
+
head = el('p', { class: 'state' }, el('b', {}, t('Picked: {what}.', { what: selText(p) })), ' ', el('span', { class: 'wait' }, t('Not sent to the AI yet.')), gapChange(p), direct);
|
|
1135
|
+
}
|
|
1136
|
+
const help = fold('help', false, '?', el('div', { class: 'pop' },
|
|
1137
|
+
el('ol', { class: 'steps' },
|
|
1138
|
+
el('li', {}, t('Click what to change on the slide above. Drag across several elements to pick an area.')),
|
|
1139
|
+
el('li', {}, t('Write your message in this bar and press [Send to AI] or Enter. The message can be empty.'))),
|
|
1140
|
+
el('p', { class: 'hint' }, caps.conceptPick
|
|
1141
|
+
? t('The AI can read what you picked, but picking does not wake the AI. To have it work, write a message and press [Send to AI].')
|
|
1142
|
+
: t('Picking alone does not tell the AI. When you send, the AI reads the place and your message together.'))), { class: 'help' }, { 'aria-label': t('Help for the send bar'), title: t('Help for the send bar') });
|
|
1143
|
+
talkEl.classList.toggle('unsent', Boolean(p) && can && !selection.shared);
|
|
1144
|
+
talkEl.replaceChildren(...[head, el('div', { class: 'line' }, role, said,
|
|
1145
|
+
btn(t('Send to AI'), shareSelection, { class: 'btn primary', disabled: !can || !p, title: !can ? t('This screen does not send') : p ? t('Sends what you picked and your message to the AI. The message can be empty') : t('First pick what to change on the slide') }), help)].filter(Boolean));
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/** 다시 그릴 때 쓰던 칸(data-keep)의 초점과 커서를 지킨다(svg 플러그인의 keepFocus 와 같다). */
|
|
1149
|
+
function keepFocus(fn) {
|
|
1150
|
+
const a = document.activeElement;
|
|
1151
|
+
const key = a && typeof a.getAttribute === 'function' ? a.getAttribute('data-keep') : null;
|
|
1152
|
+
const range = key && typeof a.selectionStart === 'number' ? [a.selectionStart, a.selectionEnd] : null;
|
|
1153
|
+
fn();
|
|
1154
|
+
if (!key) return;
|
|
1155
|
+
const b = document.querySelector(`[data-keep="${key}"]`);
|
|
1156
|
+
if (!b || b === a) return;
|
|
1157
|
+
b.focus();
|
|
1158
|
+
if (range && b.setSelectionRange) try { b.setSelectionRange(range[0], range[1]); } catch {}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
async function shareSelection() {
|
|
1162
|
+
const sel = selection;
|
|
1163
|
+
const p = sel?.payload;
|
|
1164
|
+
if (!p) return;
|
|
1165
|
+
const records = selectionRecords(p);
|
|
1166
|
+
const role = talk.role;
|
|
1167
|
+
const said = talk.said;
|
|
1168
|
+
const seq = (sel.shareSeq += 1);
|
|
1169
|
+
try {
|
|
1170
|
+
const res = await call('shareSelection', { base: p.rev, role, said: said.trim(), payload: p, records });
|
|
1171
|
+
if (!res?.ok) { toast(res?.summary ?? res?.error ?? t('Could not send the selection'), true); return; }
|
|
1172
|
+
if (sel.shareSeq === seq) sel.shared = { id: res.selection, role, said: said.trim() };
|
|
1173
|
+
if (selection !== sel) { toast(t('Sent the earlier selection as {id}. What you picked now is not sent yet', { id: res.selection })); return; }
|
|
1174
|
+
if (talk.said === said) talk = { role: talk.role, said: '' };
|
|
1175
|
+
toast(t('Sent selection {id}', { id: res.selection }));
|
|
1176
|
+
render();
|
|
1177
|
+
if (sel.shared?.id === res.selection && sel.redrawn && caps.conceptSelection) await call('reportMeasurement', { selection: res.selection, payload: sel.redrawn });
|
|
1178
|
+
} catch (err) {
|
|
1179
|
+
toast(err.message, true);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
let form = { text: null, property: 'font-size', value: '', state: 'none', useRef: true, link: null, for: null };
|
|
1184
|
+
function editSection() {
|
|
1185
|
+
const p = selection?.payload;
|
|
1186
|
+
if (!p || p.kind !== 'element' || caps.edit === false) return null;
|
|
1187
|
+
const e = elById(p.element);
|
|
1188
|
+
if (!e) return null;
|
|
1189
|
+
if (form.for !== e.id) form = { ...form, text: e.text ?? e.original, value: '', link: e.link ? e.link.target ?? e.link.original : null, for: e.id };
|
|
1190
|
+
const parts = [el('h2', {}, t('Edit: {label} ({id})', { label: e.label, id: e.id }))];
|
|
1191
|
+
if (e.original !== null) {
|
|
1192
|
+
const input = el('input', { type: 'text', 'aria-label': t('New text'), value: form.text ?? '', on: { input: (ev) => { form.text = ev.target.value; } } });
|
|
1193
|
+
parts.push(el('div', { class: 'form' }, el('label', {}, el('span', {}, e.text !== null ? t('Text (original: {original})', { original: e.original }) : t('Text')), input),
|
|
1194
|
+
btn(t('Change text'), () => {
|
|
1195
|
+
const text = (form.text ?? '').trim();
|
|
1196
|
+
if (text === '' || text === (e.text ?? e.original)) { toast(t('The text did not change'), true); return; }
|
|
1197
|
+
send([{ op: 'text.set', input: { element: e.id, text } }]);
|
|
1198
|
+
})));
|
|
1199
|
+
}
|
|
1200
|
+
if (e.link) {
|
|
1201
|
+
const options = [...Object.entries(linkLabels()), ...slides().map((s) => [s.id, t('Page {number}: {title}', { number: s.number, title: `${s.title || s.layout.title} (${s.id})` })])];
|
|
1202
|
+
const target = el('select', { 'aria-label': t('Page the link goes to'), on: { change: (ev) => { form.link = ev.target.value; } } },
|
|
1203
|
+
options.map(([k, v]) => el('option', { value: k, ...(k === form.link ? { selected: true } : {}) }, v)));
|
|
1204
|
+
const goes = slideById(e.link.resolved);
|
|
1205
|
+
parts.push(el('div', { class: 'form' }, el('label', {}, el('span', {}, t('Page the link goes to (now {page})', { page: goes ? t('page {number}', { number: goes.number }) : e.link.resolved })), target),
|
|
1206
|
+
btn(t('Change link target'), () => {
|
|
1207
|
+
if (!form.link || form.link === (e.link.target ?? e.link.original)) { toast(t('The target did not change'), true); return; }
|
|
1208
|
+
send([{ op: 'link.set', input: { element: e.id, target: form.link } }]);
|
|
1209
|
+
})));
|
|
1210
|
+
}
|
|
1211
|
+
const prop = el('select', { 'aria-label': t('Property'), on: { change: (ev) => { form.property = ev.target.value; } } },
|
|
1212
|
+
PROPERTIES.map((x) => el('option', { value: x, ...(x === form.property ? { selected: true } : {}) }, x)));
|
|
1213
|
+
const value = el('input', { type: 'text', 'aria-label': t('Value'), placeholder: t('For example: 96px. Leave it empty to remove this change'), value: form.value, on: { input: (ev) => { form.value = ev.target.value; } } });
|
|
1214
|
+
const stateLabel = stateLabels();
|
|
1215
|
+
const state = el('select', { 'aria-label': t('State'), on: { change: (ev) => { form.state = ev.target.value; } } },
|
|
1216
|
+
Object.entries(stateLabel).map(([k, v]) => el('option', { value: k, ...(k === form.state ? { selected: true } : {}) }, v)));
|
|
1217
|
+
const ref = reference ? el('label', {}, el('input', { type: 'checkbox', ...(form.useRef ? { checked: true } : {}), on: { change: (ev) => { form.useRef = ev.target.checked; } } }), ` ${t('Reference: {name}', { name: `${reference.label} (${reference.sample}@${reference.version})` })}`) : null;
|
|
1218
|
+
const styles = [];
|
|
1219
|
+
for (const [s, decl] of Object.entries(e.styles ?? {})) for (const [k, v] of Object.entries(decl)) styles.push(el('li', {}, `${stateLabel[s] ?? s}: ${k} ${v}`));
|
|
1220
|
+
parts.push(el('div', { class: 'form' }, el('div', { class: 'row2' }, prop, value), state, ref,
|
|
1221
|
+
btn(t('Change style'), () => {
|
|
1222
|
+
const input = { element: e.id, property: form.property, value: form.value.trim(), state: form.state };
|
|
1223
|
+
if (reference && form.useRef && input.value !== '') input.source = { sample: reference.sample, layout: reference.layout, key: reference.key };
|
|
1224
|
+
send([{ op: 'style.set', input }]);
|
|
1225
|
+
})));
|
|
1226
|
+
if (styles.length) parts.push(el('p', { class: 'note' }, t('Styles changed on this element')), el('ul', {}, styles));
|
|
1227
|
+
return el('section', {}, parts);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
let addLayout = 'list';
|
|
1231
|
+
function pagesSection() {
|
|
1232
|
+
const b = concept.body;
|
|
1233
|
+
const max = b.aiakivMax;
|
|
1234
|
+
const can = caps.edit !== false;
|
|
1235
|
+
const list = el('ul', { class: 'pages' }, b.slides.map((s) => el('li', {},
|
|
1236
|
+
el('button', { type: 'button', class: 'pick', 'aria-current': s.id === slideId ? 'true' : 'false', on: { click: () => goSlide(s.id) } },
|
|
1237
|
+
`${s.number}. ${s.layout.title}: ${s.title}`, el('span', { class: 'id' }, s.id),
|
|
1238
|
+
el('span', { class: `len${s.aiakiv ? '' : ' over'}` }, s.aiakiv
|
|
1239
|
+
? t('Source {length} characters, can be saved to AiAkiv', { length: number(s.length) })
|
|
1240
|
+
: t('Source {length} characters, cannot use AiAkiv (over {max} characters)', { length: number(s.length), max: number(max) }))))));
|
|
1241
|
+
const cur = slideById(slideId);
|
|
1242
|
+
const sample = catalogOf(b.deck.sample.id);
|
|
1243
|
+
const layouts = sample?.layouts ?? [];
|
|
1244
|
+
const pickLayout = el('select', { 'aria-label': t('Layout of the page to add'), on: { change: (ev) => { addLayout = ev.target.value; } } },
|
|
1245
|
+
layouts.map((l) => el('option', { value: l.key, ...(l.key === addLayout ? { selected: true } : {}) }, l.title)));
|
|
1246
|
+
const tools = can && cur ? el('div', { class: 'form' },
|
|
1247
|
+
el('div', { class: 'row3' },
|
|
1248
|
+
btn(t('Move earlier'),() => { const at = b.deck.order.indexOf(cur.id); if (at > 0) send([{ op: 'slide.move', input: { slide: cur.id, after: at > 1 ? b.deck.order[at - 2] : null } }]); }, { disabled: cur.number === 1 }),
|
|
1249
|
+
btn(t('Move later'), () =>{ const at = b.deck.order.indexOf(cur.id); if (at < b.deck.order.length - 1) send([{ op: 'slide.move', input: { slide: cur.id, after: b.deck.order[at + 1] } }]); }, { disabled: cur.number === b.slides.length }),
|
|
1250
|
+
btn(t('Remove this page'), () => send([{ op: 'slide.remove', input: { slide: cur.id } }]), { disabled: b.slides.length <= 1 })),
|
|
1251
|
+
el('div', { class: 'row2' }, pickLayout,
|
|
1252
|
+
btn(t('Add after this page'), async () => {
|
|
1253
|
+
const res = await send([{ op: 'slide.add', as: '$new', input: { layout: addLayout, after: cur.id } }]);
|
|
1254
|
+
if (res?.ids?.$new) goSlide(res.ids.$new);
|
|
1255
|
+
}))) : null;
|
|
1256
|
+
// 페이지 목록과 도구는 발표 자료를 고치는 주된 도구라 칸을 열면 펼쳐져 있다. 한도를 넘은 페이지의 수는 접은 이름에도 적는다
|
|
1257
|
+
const over = b.slides.filter((s) => !s.aiakiv).length;
|
|
1258
|
+
return fold('pages', true, `${t('Pages ({count})', { count: b.slides.length })}${over ? `, ${t('Over AiAkiv limit {count}', { count: over })}` : ''}`, [list, tools,
|
|
1259
|
+
el('p', { class: 'note' }, t('A page whose source is {max} characters or fewer can be saved to AiAkiv. Longer pages can still be edited and saved.', { max: number(max) }))], { class: 'fold' });
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
function outlineSection() {
|
|
1263
|
+
const s = slideById(slideId);
|
|
1264
|
+
if (!s) return null;
|
|
1265
|
+
const byId = (id) => s.elements.find((x) => x.id === id);
|
|
1266
|
+
const depth = (e) => { let d = 0; for (let x = e.parent; x && d < 20; x = byId(x)?.parent) d += 1; return d; };
|
|
1267
|
+
const current = selection?.payload?.kind === 'element' ? selection.payload.element : null;
|
|
1268
|
+
const isChanged = (e) => e.text !== null || Object.keys(e.styles ?? {}).length > 0 || Boolean(e.link && e.link.target !== null);
|
|
1269
|
+
const changed = s.elements.filter(isChanged).length;
|
|
1270
|
+
// 접어 두되, 몇 개가 바뀌었는지는 접은 이름에 적는다
|
|
1271
|
+
return fold('outline', false, changed
|
|
1272
|
+
? t('Elements (page {number}, {count}, {changed} changed)', { number: s.number, count: s.elements.length, changed })
|
|
1273
|
+
: t('Elements (page {number}, {count})', { number: s.number, count: s.elements.length }),
|
|
1274
|
+
el('ul', { class: 'outline' }, s.elements.map((e) => el('li', {},
|
|
1275
|
+
el('button', { type: 'button', style: `padding-left:${4 + depth(e) * 12}px`, 'aria-current': e.id === current ? 'true' : 'false', on: { click: () => selectElement(e.id) } },
|
|
1276
|
+
e.label, el('span', { class: 'id' }, e.id), isChanged(e) ? el('span', { class: 'changed' }, t('changed')) : null)))), { class: 'fold' });
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
let startReason = '';
|
|
1280
|
+
function catalogPages() {
|
|
1281
|
+
const pages = pagesOfView();
|
|
1282
|
+
return el('ul', { class: 'pages' }, pages.map((p) => el('li', {},
|
|
1283
|
+
el('button', { type: 'button', class: 'pick', 'aria-current': p.id === slideId ? 'true' : 'false', on: { click: () => goSlide(p.id) } }, `${p.number}. ${p.title}`))));
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function pickerSide() {
|
|
1287
|
+
const c = catalogOf(view);
|
|
1288
|
+
if (!c) return [];
|
|
1289
|
+
const can = caps.edit !== false;
|
|
1290
|
+
const reason = el('textarea', { 'aria-label': t('Reason for picking'), placeholder: t('For example: the lecture has a lot of explanation, so the light one is easier to read'), value: startReason, on: { input: (e) => { startReason = e.target.value; } } });
|
|
1291
|
+
return [
|
|
1292
|
+
el('section', {}, el('h2', {}, t('Sample: {name}', { name: c.title })), el('p', {}, c.about), el('p', { class: 'note' }, t('Version {version}. Open another sample from the menu at the far left of the top bar.', { version: c.version })), catalogPages()),
|
|
1293
|
+
can ? el('section', {}, el('h2', {}, t('Start from this sample')), el('div', { class: 'form' }, reason,
|
|
1294
|
+
btn(t('Start a deck from this sample'), () => {
|
|
1295
|
+
const r = startReason.trim();
|
|
1296
|
+
if (!r) { toast(t('Write the reason you picked it'), true); return; }
|
|
1297
|
+
send([{ op: 'deck.start', input: { sample: c.id, reason: r } }]).then((res) => { if (res) { startReason = ''; view = 'work'; slideId = null; drawFrame(); render(); } });
|
|
1298
|
+
}, { class: 'btn primary' }))) : null,
|
|
1299
|
+
];
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
function referenceSide() {
|
|
1303
|
+
const c = catalogOf(view);
|
|
1304
|
+
return [el('section', {}, el('h2', {}, t('Reference: {name}', { name: c.title })), el('p', {}, c.about), catalogPages(),
|
|
1305
|
+
el('p', { class: 'note' }, t('Click an element here to attach it as a reference example to the next style change.')),
|
|
1306
|
+
reference && reference.sample === c.id ? el('p', {}, t('Picked example: {label}', { label: reference.label })) : null,
|
|
1307
|
+
btn(t('Back to the deck'), () => switchView('work')))];
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
let sideWas = null;
|
|
1311
|
+
function render() {
|
|
1312
|
+
if (!concept) return;
|
|
1313
|
+
// 편집 칸이 열려 있으면 다시 잰 값을 본 것으로 친다(위쪽 줄 버튼의 점을 지운다)
|
|
1314
|
+
const shown = sideShown();
|
|
1315
|
+
if (shown && view === 'work' && selection?.redrawn) selection.seen = selection.redrawn;
|
|
1316
|
+
renderBar();
|
|
1317
|
+
keepFocus(() => {
|
|
1318
|
+
renderTalk();
|
|
1319
|
+
const b = concept.body;
|
|
1320
|
+
if (!b.deck) { sideEl.replaceChildren(...pickerSide()); return; }
|
|
1321
|
+
if (view !== 'work') { sideEl.replaceChildren(...referenceSide()); return; }
|
|
1322
|
+
const info = fold('info', false, t('Deck: {title}', { title: b.deck.sample.title }),
|
|
1323
|
+
el('dl', { class: 'kv' }, el('dt', {}, t('Sample')), el('dd', {}, t('{title} ({id}) version {version}', { title: b.deck.sample.title, id: b.deck.sample.id, version: b.deck.sample.version })),
|
|
1324
|
+
el('dt', {}, t('Reason')), el('dd', {}, b.deck.reason)), { class: 'fold' });
|
|
1325
|
+
sideEl.replaceChildren(...[info, pagesSection(), selectionSection(), editSection(), outlineSection()].filter(Boolean));
|
|
1326
|
+
});
|
|
1327
|
+
sideEl.hidden = !shown;
|
|
1328
|
+
stageEl.classList.toggle('closed', !shown);
|
|
1329
|
+
// 칸을 열거나 닫으면 슬라이드가 쓸 수 있는 폭이 바뀌므로 크기를 다시 맞춘다
|
|
1330
|
+
if (sideWas !== null && sideWas !== shown) sizeFrame();
|
|
1331
|
+
sideWas = shown;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
window.addEventListener('resize', () => { if (concept) sizeFrame(); });
|
|
1335
|
+
|
|
1336
|
+
parent.postMessage({ aic: 1, event: 'ready', rendered: true }, '*');
|
|
1337
|
+
// 언어를 먼저 정한 뒤 처음 그린다. 호스트가 늦게 답하거나 답하지 않으면 기다리지 않고 영어로 그리고, 답이 오면 그때 언어를 맞춰 다시 그린다
|
|
1338
|
+
let started = false;
|
|
1339
|
+
const start = () => { if (!started) { started = true; refresh(); } };
|
|
1340
|
+
call('capabilities', {}).then((cap) => {
|
|
1341
|
+
caps = { ...caps, ...(cap ?? {}) };
|
|
1342
|
+
setLanguage(cap?.language);
|
|
1343
|
+
if (concept) render();
|
|
1344
|
+
start();
|
|
1345
|
+
}, start);
|
|
1346
|
+
setTimeout(start, 1500);
|
|
1347
|
+
</script>
|
|
1348
|
+
</body>
|
|
1349
|
+
</html>
|