aboard-overlay 0.0.0-stage → 0.1.1

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/src/styles.css ADDED
@@ -0,0 +1,472 @@
1
+ /*
2
+ * Aboard Overlay 样式
3
+ * 全部限定在 .aboard-root 内,避免污染宿主应用;宿主页面本身保持透明即可让下层窗口(PPT)透出来。
4
+ */
5
+
6
+ /* 透明窗口宿主页:由 transparentWindow 选项在 <html> 上加类 */
7
+ html.aboard-transparent-window,
8
+ html.aboard-transparent-window body {
9
+ margin: 0;
10
+ height: 100%;
11
+ overflow: hidden;
12
+ background: transparent;
13
+ }
14
+
15
+ .aboard-root,
16
+ .aboard-root *,
17
+ .aboard-root *::before,
18
+ .aboard-root *::after {
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ .aboard-root {
23
+ --aboard-accent: #006fe6;
24
+ --aboard-accent-soft: #e8f1ff;
25
+ --aboard-text: #1f2937;
26
+ --aboard-muted: #6b7280;
27
+ --aboard-panel-bg: rgba(255, 255, 255, 0.96);
28
+ --aboard-panel-border: rgba(15, 23, 42, 0.08);
29
+ --aboard-panel-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.06);
30
+ --aboard-board-green: #2f4f42;
31
+
32
+ position: fixed;
33
+ inset: 0;
34
+ overflow: hidden;
35
+ background: transparent;
36
+ color: var(--aboard-text);
37
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
38
+ "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
39
+ font-size: 14px;
40
+ line-height: normal;
41
+ -webkit-font-smoothing: antialiased;
42
+ -webkit-user-select: none;
43
+ user-select: none;
44
+ -webkit-tap-highlight-color: transparent;
45
+ overscroll-behavior: none;
46
+ }
47
+
48
+ .aboard-root p {
49
+ margin: 0;
50
+ }
51
+
52
+ .aboard-root button,
53
+ .aboard-root input {
54
+ font-family: inherit;
55
+ }
56
+
57
+ /* ---------- 画板层 ---------- */
58
+
59
+ .aboard {
60
+ position: absolute;
61
+ inset: 0;
62
+ }
63
+
64
+ .aboard-surface {
65
+ position: absolute;
66
+ inset: 0;
67
+ transition: background-color 0.25s ease;
68
+ }
69
+
70
+ /* 黑板绿 */
71
+ .aboard-surface.bg-blackboard {
72
+ background-color: var(--aboard-board-green);
73
+ background-image:
74
+ radial-gradient(ellipse at 18% 8%, rgba(255, 255, 255, 0.07), transparent 55%),
75
+ radial-gradient(ellipse at 82% 94%, rgba(0, 0, 0, 0.2), transparent 62%),
76
+ repeating-linear-gradient(118deg, rgba(255, 255, 255, 0.014) 0 2px, transparent 2px 7px);
77
+ }
78
+
79
+ /* 透明背景:不绘制任何底色,直接露出下层窗口(PPT 等) */
80
+ .aboard-surface.bg-transparent {
81
+ background-color: transparent;
82
+ background-image: none;
83
+ }
84
+
85
+ /* 绘制期间隐藏配置面板与背景切换器 */
86
+ .aboard-root.is-drawing .aboard-background-switcher,
87
+ .aboard-root.is-drawing .aboard-config-area {
88
+ opacity: 0;
89
+ pointer-events: none;
90
+ transition: opacity 0.15s ease;
91
+ }
92
+
93
+ .aboard-canvas {
94
+ position: absolute;
95
+ inset: 0;
96
+ display: block;
97
+ width: 100%;
98
+ height: 100%;
99
+ z-index: 1;
100
+ cursor: crosshair;
101
+ touch-action: none;
102
+ }
103
+
104
+ .aboard-canvas.is-eraser {
105
+ cursor: none;
106
+ }
107
+
108
+ /* ---------- 橡皮擦光标 ---------- */
109
+
110
+ .aboard-eraser-cursor {
111
+ position: fixed;
112
+ top: 0;
113
+ left: 0;
114
+ display: none;
115
+ border: 1.5px solid rgba(71, 85, 105, 0.9);
116
+ border-radius: 50%;
117
+ background-color: rgba(255, 255, 255, 0.28);
118
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
119
+ transform: translate(-50%, -50%);
120
+ pointer-events: none;
121
+ z-index: 60;
122
+ }
123
+
124
+ .aboard-root[data-background="blackboard"] .aboard-eraser-cursor {
125
+ border-color: rgba(255, 255, 255, 0.9);
126
+ background-color: rgba(255, 255, 255, 0.14);
127
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
128
+ }
129
+
130
+ /* ---------- 面板通用样式 ---------- */
131
+
132
+ .aboard-panel {
133
+ background: var(--aboard-panel-bg);
134
+ border: 1px solid var(--aboard-panel-border);
135
+ border-radius: 16px;
136
+ box-shadow: var(--aboard-panel-shadow);
137
+ -webkit-backdrop-filter: blur(12px);
138
+ backdrop-filter: blur(12px);
139
+ }
140
+
141
+ /* ---------- 背景切换 ---------- */
142
+
143
+ .aboard-background-switcher {
144
+ position: absolute;
145
+ top: 20px;
146
+ right: 20px;
147
+ z-index: 30;
148
+ display: flex;
149
+ flex-direction: column;
150
+ gap: 8px;
151
+ padding: 10px 12px;
152
+ }
153
+
154
+ .aboard-panel-title {
155
+ font-size: 11px;
156
+ font-weight: 600;
157
+ letter-spacing: 0.08em;
158
+ color: var(--aboard-muted);
159
+ }
160
+
161
+ .aboard-segmented {
162
+ display: flex;
163
+ gap: 6px;
164
+ }
165
+
166
+ .aboard-seg-btn {
167
+ display: flex;
168
+ align-items: center;
169
+ gap: 6px;
170
+ padding: 7px 10px;
171
+ border: 1px solid transparent;
172
+ border-radius: 10px;
173
+ background: transparent;
174
+ color: var(--aboard-text);
175
+ font-size: 13px;
176
+ cursor: pointer;
177
+ transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
178
+ }
179
+
180
+ .aboard-seg-btn:hover {
181
+ background: #f1f5f9;
182
+ }
183
+
184
+ .aboard-seg-btn.is-active {
185
+ border-color: rgba(0, 111, 230, 0.25);
186
+ background: var(--aboard-accent-soft);
187
+ color: var(--aboard-accent);
188
+ font-weight: 600;
189
+ }
190
+
191
+ .aboard-swatch {
192
+ flex: none;
193
+ width: 16px;
194
+ height: 16px;
195
+ border: 1px solid rgba(15, 23, 42, 0.16);
196
+ border-radius: 5px;
197
+ }
198
+
199
+ .aboard-swatch--blackboard {
200
+ background-color: var(--aboard-board-green);
201
+ }
202
+
203
+ .aboard-swatch--transparent {
204
+ background-color: #fbfcfd;
205
+ background-image:
206
+ linear-gradient(45deg, #d7dde4 25%, transparent 25%),
207
+ linear-gradient(-45deg, #d7dde4 25%, transparent 25%),
208
+ linear-gradient(45deg, transparent 75%, #d7dde4 75%),
209
+ linear-gradient(-45deg, transparent 75%, #d7dde4 75%);
210
+ background-size: 8px 8px;
211
+ background-position: 0 0, 0 4px, 4px -4px, -4px 0;
212
+ }
213
+
214
+ /* ---------- 配置区 ---------- */
215
+
216
+ .aboard-config-area {
217
+ position: absolute;
218
+ left: 50%;
219
+ bottom: calc(104px + env(safe-area-inset-bottom));
220
+ z-index: 35;
221
+ width: min(620px, calc(100vw - 32px));
222
+ transform: translateX(-50%);
223
+ pointer-events: none;
224
+ }
225
+
226
+ .aboard-config-panel {
227
+ display: none;
228
+ flex-direction: column;
229
+ gap: 14px;
230
+ padding: 14px 16px 16px;
231
+ pointer-events: auto;
232
+ animation: aboard-panel-in 0.18s ease;
233
+ }
234
+
235
+ .aboard-config-panel.is-active {
236
+ display: flex;
237
+ }
238
+
239
+ @keyframes aboard-panel-in {
240
+ from {
241
+ opacity: 0;
242
+ transform: translateY(6px);
243
+ }
244
+ to {
245
+ opacity: 1;
246
+ transform: none;
247
+ }
248
+ }
249
+
250
+ .aboard-config-group {
251
+ display: flex;
252
+ flex-direction: column;
253
+ gap: 8px;
254
+ }
255
+
256
+ .aboard-config-label {
257
+ display: block;
258
+ font-size: 12px;
259
+ font-weight: 600;
260
+ color: var(--aboard-muted);
261
+ }
262
+
263
+ .aboard-config-hint {
264
+ font-size: 12px;
265
+ line-height: 1.6;
266
+ color: var(--aboard-muted);
267
+ }
268
+
269
+ /* ---------- 画笔类型 ---------- */
270
+
271
+ .aboard-pen-type-grid {
272
+ display: grid;
273
+ grid-template-columns: repeat(6, minmax(0, 1fr));
274
+ gap: 6px;
275
+ }
276
+
277
+ .aboard-pen-type-btn {
278
+ display: flex;
279
+ flex-direction: column;
280
+ align-items: center;
281
+ gap: 4px;
282
+ padding: 8px 4px;
283
+ border: 1px solid #e5e9ef;
284
+ border-radius: 10px;
285
+ background: #fff;
286
+ color: #4b5563;
287
+ font-size: 11px;
288
+ cursor: pointer;
289
+ transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
290
+ }
291
+
292
+ .aboard-pen-type-btn svg {
293
+ width: 18px;
294
+ height: 18px;
295
+ }
296
+
297
+ .aboard-pen-type-btn:hover {
298
+ border-color: #cbd5e1;
299
+ background: #f8fafc;
300
+ }
301
+
302
+ .aboard-pen-type-btn.is-active {
303
+ border-color: rgba(0, 111, 230, 0.45);
304
+ background: var(--aboard-accent-soft);
305
+ color: var(--aboard-accent);
306
+ font-weight: 600;
307
+ }
308
+
309
+ /* ---------- 颜色 ---------- */
310
+
311
+ .aboard-color-row {
312
+ display: flex;
313
+ flex-wrap: wrap;
314
+ align-items: center;
315
+ gap: 8px;
316
+ }
317
+
318
+ .aboard-color-btn {
319
+ width: 28px;
320
+ height: 28px;
321
+ padding: 0;
322
+ border: 2px solid #fff;
323
+ border-radius: 50%;
324
+ background: var(--aboard-swatch);
325
+ box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16);
326
+ cursor: pointer;
327
+ transition: transform 0.12s ease, box-shadow 0.12s ease;
328
+ }
329
+
330
+ .aboard-color-btn:hover {
331
+ transform: scale(1.08);
332
+ }
333
+
334
+ .aboard-color-btn.is-active {
335
+ box-shadow: 0 0 0 2px var(--aboard-accent);
336
+ transform: scale(1.06);
337
+ }
338
+
339
+ .aboard-color-custom {
340
+ position: relative;
341
+ display: inline-flex;
342
+ align-items: center;
343
+ justify-content: center;
344
+ width: 30px;
345
+ height: 30px;
346
+ overflow: hidden;
347
+ border: 1px dashed #b6c2cf;
348
+ border-radius: 50%;
349
+ color: #64748b;
350
+ cursor: pointer;
351
+ transition: border-color 0.15s ease, color 0.15s ease;
352
+ }
353
+
354
+ .aboard-color-custom:hover {
355
+ border-color: var(--aboard-accent);
356
+ color: var(--aboard-accent);
357
+ }
358
+
359
+ .aboard-color-custom input {
360
+ position: absolute;
361
+ inset: 0;
362
+ width: 100%;
363
+ height: 100%;
364
+ padding: 0;
365
+ border: none;
366
+ opacity: 0;
367
+ cursor: pointer;
368
+ }
369
+
370
+ .aboard-color-custom svg {
371
+ width: 16px;
372
+ height: 16px;
373
+ pointer-events: none;
374
+ }
375
+
376
+ /* ---------- 滑块 ---------- */
377
+
378
+ .aboard-slider {
379
+ display: block;
380
+ width: 100%;
381
+ height: 24px;
382
+ margin-top: 8px;
383
+ accent-color: var(--aboard-accent);
384
+ cursor: pointer;
385
+ background: transparent;
386
+ }
387
+
388
+ /* ---------- 工具栏 ---------- */
389
+
390
+ .aboard-toolbar {
391
+ position: absolute;
392
+ left: 50%;
393
+ bottom: calc(24px + env(safe-area-inset-bottom));
394
+ z-index: 40;
395
+ display: flex;
396
+ align-items: center;
397
+ gap: 6px;
398
+ padding: 6px;
399
+ transform: translateX(-50%);
400
+ }
401
+
402
+ .aboard-tool-btn {
403
+ display: flex;
404
+ flex-direction: column;
405
+ align-items: center;
406
+ justify-content: center;
407
+ gap: 4px;
408
+ min-width: 76px;
409
+ height: 58px;
410
+ padding: 6px 10px;
411
+ border: none;
412
+ border-radius: 12px;
413
+ background: transparent;
414
+ color: var(--aboard-muted);
415
+ font-size: 12px;
416
+ cursor: pointer;
417
+ transition: background-color 0.15s ease, color 0.15s ease;
418
+ }
419
+
420
+ .aboard-tool-btn svg {
421
+ width: 22px;
422
+ height: 22px;
423
+ }
424
+
425
+ .aboard-tool-btn:hover {
426
+ background: #f1f5f9;
427
+ color: var(--aboard-text);
428
+ }
429
+
430
+ .aboard-tool-btn.is-active {
431
+ background: var(--aboard-accent-soft);
432
+ color: var(--aboard-accent);
433
+ }
434
+
435
+ /* ---------- 响应式 ---------- */
436
+
437
+ @media (max-width: 640px) {
438
+ .aboard-background-switcher {
439
+ top: 12px;
440
+ right: 12px;
441
+ gap: 6px;
442
+ padding: 8px 10px;
443
+ }
444
+
445
+ .aboard-seg-btn {
446
+ padding: 6px 8px;
447
+ font-size: 12px;
448
+ }
449
+
450
+ .aboard-config-area {
451
+ bottom: calc(92px + env(safe-area-inset-bottom));
452
+ width: calc(100vw - 20px);
453
+ }
454
+
455
+ .aboard-config-panel {
456
+ gap: 12px;
457
+ padding: 12px;
458
+ }
459
+
460
+ .aboard-pen-type-grid {
461
+ grid-template-columns: repeat(3, minmax(0, 1fr));
462
+ }
463
+
464
+ .aboard-toolbar {
465
+ bottom: calc(14px + env(safe-area-inset-bottom));
466
+ }
467
+
468
+ .aboard-tool-btn {
469
+ min-width: 66px;
470
+ height: 52px;
471
+ }
472
+ }
package/src/vue.js ADDED
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Aboard Overlay 的 Vue 3 组件包装
3
+ * 只做挂载与 prop 同步,绘制逻辑全部在内核里,因此也支持无框架用法。
4
+ */
5
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from 'vue';
6
+ import { Aboard } from './index.js';
7
+
8
+ export const AboardBoard = defineComponent({
9
+ name: 'AboardBoard',
10
+ props: {
11
+ background: { type: String, default: undefined },
12
+ tool: { type: String, default: undefined },
13
+ penType: { type: String, default: undefined },
14
+ color: { type: String, default: undefined },
15
+ penSize: { type: Number, default: undefined },
16
+ eraserSize: { type: Number, default: undefined },
17
+ showToolbar: { type: Boolean, default: true },
18
+ showBackgroundSwitcher: { type: Boolean, default: true },
19
+ transparentWindow: { type: Boolean, default: false },
20
+ persist: { type: Boolean, default: true },
21
+ storageKey: { type: String, default: undefined }
22
+ },
23
+ emits: ['ready', 'change'],
24
+ setup(props, { emit, expose }) {
25
+ const host = ref(null);
26
+ let board = null;
27
+
28
+ onMounted(() => {
29
+ board = new Aboard({
30
+ host: host.value,
31
+ background: props.background,
32
+ tool: props.tool,
33
+ penType: props.penType,
34
+ color: props.color,
35
+ penSize: props.penSize,
36
+ eraserSize: props.eraserSize,
37
+ showToolbar: props.showToolbar,
38
+ showBackgroundSwitcher: props.showBackgroundSwitcher,
39
+ transparentWindow: props.transparentWindow,
40
+ persist: props.persist,
41
+ storageKey: props.storageKey,
42
+ onChange: function (settings) {
43
+ emit('change', settings);
44
+ }
45
+ });
46
+ emit('ready', board);
47
+ });
48
+
49
+ onBeforeUnmount(() => {
50
+ if (board) {
51
+ board.destroy();
52
+ board = null;
53
+ }
54
+ });
55
+
56
+ watch(
57
+ () => props.background,
58
+ function (value) {
59
+ if (board && value) board.setBackground(value);
60
+ }
61
+ );
62
+
63
+ watch(
64
+ () => props.tool,
65
+ function (value) {
66
+ if (board && value) board.setTool(value);
67
+ }
68
+ );
69
+
70
+ watch(
71
+ () => props.penType,
72
+ function (value) {
73
+ if (board && value) board.setPenType(value);
74
+ }
75
+ );
76
+
77
+ watch(
78
+ () => props.color,
79
+ function (value) {
80
+ if (board && value) board.setColor(value);
81
+ }
82
+ );
83
+
84
+ watch(
85
+ () => props.penSize,
86
+ function (value) {
87
+ if (board && value !== undefined) board.setPenSize(value);
88
+ }
89
+ );
90
+
91
+ watch(
92
+ () => props.eraserSize,
93
+ function (value) {
94
+ if (board && value !== undefined) board.setEraserSize(value);
95
+ }
96
+ );
97
+
98
+ watch(
99
+ () => props.showToolbar,
100
+ function (value) {
101
+ if (board) board.setToolbarVisible(value);
102
+ }
103
+ );
104
+
105
+ watch(
106
+ () => props.showBackgroundSwitcher,
107
+ function (value) {
108
+ if (board) board.setBackgroundSwitcherVisible(value);
109
+ }
110
+ );
111
+
112
+ expose({
113
+ getBoard: function () {
114
+ return board;
115
+ }
116
+ });
117
+
118
+ return function () {
119
+ return h('div', { ref: host, class: 'aboard-host' });
120
+ };
121
+ }
122
+ });
123
+
124
+ export default AboardBoard;