@netless/app-slide 0.2.2 → 0.3.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-zh.md +1 -4
- package/README.md +1 -4
- package/dist/Refrigerator.d.ts +13 -0
- package/dist/SlideViewer.d.ts +66 -0
- package/dist/constants.d.ts +2 -0
- package/dist/{DocsViewer/icons → icons}/arrow-left.d.ts +0 -0
- package/dist/{DocsViewer/icons → icons}/arrow-right.d.ts +0 -0
- package/dist/{DocsViewer/icons → icons}/pause.d.ts +0 -0
- package/dist/{DocsViewer/icons → icons}/play.d.ts +0 -0
- package/dist/{DocsViewer/icons → icons}/sidebar.d.ts +0 -0
- package/dist/index.d.ts +10 -35
- package/dist/main.cjs.js +177 -177
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1918 -2478
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +254 -254
- package/dist/main.iife.js.map +1 -1
- package/dist/typings.d.ts +21 -9
- package/dist/utils.d.ts +1 -0
- package/package.json +2 -2
- package/src/Refrigerator.ts +66 -0
- package/src/SlideViewer.ts +557 -0
- package/src/constants.ts +3 -0
- package/src/fancy-scrollbar.scss +57 -0
- package/src/{DocsViewer/icons → icons}/arrow-left.ts +0 -0
- package/src/{DocsViewer/icons → icons}/arrow-right.ts +0 -0
- package/src/{DocsViewer/icons → icons}/pause.ts +0 -0
- package/src/{DocsViewer/icons → icons}/play.ts +0 -0
- package/src/{DocsViewer/icons → icons}/sidebar.ts +0 -0
- package/src/index.ts +216 -205
- package/src/style.scss +247 -5
- package/src/typings.ts +23 -10
- package/src/utils.ts +3 -0
- package/dist/DocsViewer/index.d.ts +0 -53
- package/dist/SlideController/helpers.d.ts +0 -6
- package/dist/SlideController/index.d.ts +0 -60
- package/dist/SlideDocsViewer/index.d.ts +0 -45
- package/dist/SlidePreviewer/index.d.ts +0 -52
- package/dist/utils/bgcolor.d.ts +0 -3
- package/dist/utils/freezer.d.ts +0 -22
- package/dist/utils/helpers.d.ts +0 -6
- package/dist/utils/logger.d.ts +0 -39
- package/src/DocsViewer/icons/arrow-left.svg +0 -4
- package/src/DocsViewer/icons/arrow-right.svg +0 -4
- package/src/DocsViewer/icons/pause.svg +0 -4
- package/src/DocsViewer/icons/play.svg +0 -4
- package/src/DocsViewer/icons/sidebar.svg +0 -4
- package/src/DocsViewer/index.ts +0 -368
- package/src/DocsViewer/style.scss +0 -228
- package/src/DocsViewer/variables.scss +0 -1
- package/src/SlideController/helpers.ts +0 -48
- package/src/SlideController/index.ts +0 -356
- package/src/SlideDocsViewer/index.ts +0 -210
- package/src/SlideDocsViewer/style.scss +0 -11
- package/src/SlidePreviewer/index.ts +0 -226
- package/src/utils/bgcolor.ts +0 -45
- package/src/utils/freezer.ts +0 -75
- package/src/utils/helpers.ts +0 -26
- package/src/utils/logger.ts +0 -106
package/src/DocsViewer/index.ts
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { sidebarSVG } from "./icons/sidebar";
|
|
2
|
-
import { arrowLeftSVG } from "./icons/arrow-left";
|
|
3
|
-
import { arrowRightSVG } from "./icons/arrow-right";
|
|
4
|
-
import { playSVG } from "./icons/play";
|
|
5
|
-
import { pauseSVG } from "./icons/pause";
|
|
6
|
-
|
|
7
|
-
import type { ILazyLoadInstance } from "vanilla-lazyload";
|
|
8
|
-
import LazyLoad from "vanilla-lazyload";
|
|
9
|
-
import { SideEffectManager } from "side-effect-manager";
|
|
10
|
-
|
|
11
|
-
export interface DocsViewerPage {
|
|
12
|
-
src: string;
|
|
13
|
-
height: number;
|
|
14
|
-
width: number;
|
|
15
|
-
thumbnail?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface DocsViewerConfig {
|
|
19
|
-
readonly: boolean;
|
|
20
|
-
onNewPageIndex: (index: number) => void;
|
|
21
|
-
onPlay?: () => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class DocsViewer {
|
|
25
|
-
public constructor({ readonly, onNewPageIndex, onPlay }: DocsViewerConfig) {
|
|
26
|
-
this.readonly = readonly;
|
|
27
|
-
this.onNewPageIndex = onNewPageIndex;
|
|
28
|
-
this.onPlay = onPlay;
|
|
29
|
-
|
|
30
|
-
this.render();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected readonly: boolean;
|
|
34
|
-
protected onNewPageIndex: (index: number) => void;
|
|
35
|
-
protected onPlay?: () => void;
|
|
36
|
-
|
|
37
|
-
private _pages: DocsViewerPage[] = [];
|
|
38
|
-
|
|
39
|
-
public set pages(value: DocsViewerPage[]) {
|
|
40
|
-
this._pages = value;
|
|
41
|
-
this.refreshPreview();
|
|
42
|
-
this.refreshTotalPage();
|
|
43
|
-
this.refreshBtnSidebar();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public get pages() {
|
|
47
|
-
return this._pages;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public $content!: HTMLElement;
|
|
51
|
-
public $preview!: HTMLElement;
|
|
52
|
-
public $previewMask!: HTMLElement;
|
|
53
|
-
public $footer!: HTMLElement;
|
|
54
|
-
public $pageNumberInput!: HTMLInputElement;
|
|
55
|
-
public $totalPage!: HTMLSpanElement;
|
|
56
|
-
public $btnPlay!: HTMLButtonElement;
|
|
57
|
-
public $btnSidebar!: HTMLButtonElement;
|
|
58
|
-
|
|
59
|
-
public pageIndex = 0;
|
|
60
|
-
|
|
61
|
-
public unmount(): void {
|
|
62
|
-
this.$content.remove();
|
|
63
|
-
this.$footer.remove();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public setReadonly(readonly: boolean): void {
|
|
67
|
-
this.readonly = readonly;
|
|
68
|
-
this.$content.classList.toggle(this.wrapClassName("readonly"), readonly);
|
|
69
|
-
this.$footer.classList.toggle(this.wrapClassName("readonly"), readonly);
|
|
70
|
-
this.$pageNumberInput.disabled = readonly;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public destroy(): void {
|
|
74
|
-
this.sideEffect.flushAll();
|
|
75
|
-
this.unmount();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public setPageIndex(pageIndex: number): void {
|
|
79
|
-
if (!Number.isNaN(pageIndex)) {
|
|
80
|
-
this.pageIndex = pageIndex;
|
|
81
|
-
this.$pageNumberInput.value = String(pageIndex + 1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public refreshTotalPage(): void {
|
|
86
|
-
if (this.pages.length) {
|
|
87
|
-
this.$totalPage.textContent = " / " + this.pages.length;
|
|
88
|
-
} else {
|
|
89
|
-
this.$totalPage.textContent = "";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public setSmallBox(isSmallBox: boolean): void {
|
|
94
|
-
if (this.isSmallBox !== isSmallBox) {
|
|
95
|
-
this.isSmallBox = isSmallBox;
|
|
96
|
-
this.$footer.classList.toggle(this.wrapClassName("float-footer"), isSmallBox);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public render(): HTMLElement {
|
|
101
|
-
this.renderContent();
|
|
102
|
-
this.renderFooter();
|
|
103
|
-
return this.$content;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected renderContent(): HTMLElement {
|
|
107
|
-
if (!this.$content) {
|
|
108
|
-
const $content = document.createElement("div");
|
|
109
|
-
$content.className = this.wrapClassName("content");
|
|
110
|
-
this.$content = $content;
|
|
111
|
-
|
|
112
|
-
if (this.readonly) {
|
|
113
|
-
$content.classList.add(this.wrapClassName("readonly"));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
$content.appendChild(this.renderPreviewMask());
|
|
117
|
-
$content.appendChild(this.renderPreview());
|
|
118
|
-
}
|
|
119
|
-
return this.$content;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private previewLazyLoad?: ILazyLoadInstance;
|
|
123
|
-
|
|
124
|
-
protected renderPreview(): HTMLElement {
|
|
125
|
-
if (!this.$preview) {
|
|
126
|
-
const $preview = document.createElement("div");
|
|
127
|
-
$preview.className = this.wrapClassName("preview") + " tele-fancy-scrollbar";
|
|
128
|
-
this.$preview = $preview;
|
|
129
|
-
this.sideEffect.add(() => {
|
|
130
|
-
this.previewLazyLoad = new LazyLoad({
|
|
131
|
-
container: this.$preview,
|
|
132
|
-
elements_selector: `.${this.wrapClassName("preview-page>img")}`,
|
|
133
|
-
});
|
|
134
|
-
return () => this.previewLazyLoad?.destroy();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
this.refreshPreview();
|
|
138
|
-
|
|
139
|
-
this.sideEffect.addEventListener($preview, "click", ev => {
|
|
140
|
-
if (this.readonly) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const pageIndex = (ev.target as HTMLElement).dataset?.pageIndex;
|
|
144
|
-
if (pageIndex) {
|
|
145
|
-
ev.preventDefault();
|
|
146
|
-
ev.stopPropagation();
|
|
147
|
-
ev.stopImmediatePropagation();
|
|
148
|
-
this.onNewPageIndex(Number(pageIndex));
|
|
149
|
-
this.togglePreview(false);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return this.$preview;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private refreshPreview() {
|
|
158
|
-
const { $preview } = this;
|
|
159
|
-
const pageClassName = this.wrapClassName("preview-page");
|
|
160
|
-
const pageNameClassName = this.wrapClassName("preview-page-name");
|
|
161
|
-
while ($preview.firstChild) {
|
|
162
|
-
$preview.firstChild.remove();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
this.pages.forEach((page, i) => {
|
|
166
|
-
const previewSRC = page.thumbnail ?? (page.src.startsWith("ppt") ? void 0 : page.src);
|
|
167
|
-
if (!previewSRC) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const pageIndex = String(i);
|
|
172
|
-
|
|
173
|
-
const $page = document.createElement("a");
|
|
174
|
-
$page.className = pageClassName + " " + this.wrapClassName(`preview-page-${i}`);
|
|
175
|
-
$page.setAttribute("href", "#");
|
|
176
|
-
$page.dataset.pageIndex = pageIndex;
|
|
177
|
-
|
|
178
|
-
const $name = document.createElement("span");
|
|
179
|
-
$name.className = pageNameClassName;
|
|
180
|
-
$name.textContent = String(i + 1);
|
|
181
|
-
$name.dataset.pageIndex = pageIndex;
|
|
182
|
-
|
|
183
|
-
const $img = document.createElement("img");
|
|
184
|
-
$img.width = page.width;
|
|
185
|
-
$img.height = page.height;
|
|
186
|
-
$img.dataset.src = previewSRC;
|
|
187
|
-
$img.dataset.pageIndex = pageIndex;
|
|
188
|
-
|
|
189
|
-
$page.appendChild($img);
|
|
190
|
-
$page.appendChild($name);
|
|
191
|
-
$preview.appendChild($page);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
this.previewLazyLoad?.update();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
protected renderPreviewMask(): HTMLElement {
|
|
198
|
-
if (!this.$previewMask) {
|
|
199
|
-
this.$previewMask = document.createElement("div");
|
|
200
|
-
this.$previewMask.className = this.wrapClassName("preview-mask");
|
|
201
|
-
this.sideEffect.addEventListener(this.$previewMask, "click", ev => {
|
|
202
|
-
if (this.readonly) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (ev.target === this.$previewMask) {
|
|
206
|
-
this.togglePreview(false);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return this.$previewMask;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
public setPaused = () => {
|
|
214
|
-
this.$btnPlay.classList.toggle(this.wrapClassName("footer-btn-playing"), false);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
public setPlaying = () => {
|
|
218
|
-
this.$btnPlay.classList.toggle(this.wrapClassName("footer-btn-playing"), true);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
public refreshBtnSidebar() {
|
|
222
|
-
this.$btnSidebar.style.display = this.pages.length > 0 ? "" : "none";
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
protected renderFooter(): HTMLElement {
|
|
226
|
-
if (!this.$footer) {
|
|
227
|
-
const $footer = document.createElement("div");
|
|
228
|
-
$footer.className = this.wrapClassName("footer");
|
|
229
|
-
this.$footer = $footer;
|
|
230
|
-
|
|
231
|
-
if (this.readonly) {
|
|
232
|
-
$footer.classList.add(this.wrapClassName("readonly"));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (this.isSmallBox) {
|
|
236
|
-
$footer.classList.add(this.wrapClassName("float-footer"));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const $btnSidebar = this.renderFooterBtn("btn-sidebar", sidebarSVG(this.namespace));
|
|
240
|
-
this.sideEffect.addEventListener($btnSidebar, "click", () => {
|
|
241
|
-
if (this.readonly) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
this.togglePreview();
|
|
245
|
-
});
|
|
246
|
-
this.$btnSidebar = $btnSidebar;
|
|
247
|
-
this.$btnSidebar.style.display = "none";
|
|
248
|
-
this.$footer.appendChild($btnSidebar);
|
|
249
|
-
|
|
250
|
-
const $pageJumps = document.createElement("div");
|
|
251
|
-
$pageJumps.className = this.wrapClassName("page-jumps");
|
|
252
|
-
|
|
253
|
-
const $btnPageBack = this.renderFooterBtn("btn-page-back", arrowLeftSVG(this.namespace));
|
|
254
|
-
this.sideEffect.addEventListener($btnPageBack, "click", () => {
|
|
255
|
-
if (this.readonly) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
this.onNewPageIndex(this.pageIndex - 1);
|
|
259
|
-
});
|
|
260
|
-
$pageJumps.appendChild($btnPageBack);
|
|
261
|
-
|
|
262
|
-
if (this.onPlay) {
|
|
263
|
-
const $btnPlay = this.renderFooterBtn(
|
|
264
|
-
"btn-page-play",
|
|
265
|
-
playSVG(this.namespace),
|
|
266
|
-
pauseSVG(this.namespace)
|
|
267
|
-
);
|
|
268
|
-
this.$btnPlay = $btnPlay;
|
|
269
|
-
this.sideEffect.addEventListener($btnPlay, "click", () => {
|
|
270
|
-
if (this.readonly) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
this.setPlaying();
|
|
274
|
-
if (this.onPlay) {
|
|
275
|
-
this.onPlay();
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
$pageJumps.appendChild($btnPlay);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const $btnPageNext = this.renderFooterBtn("btn-page-next", arrowRightSVG(this.namespace));
|
|
283
|
-
this.sideEffect.addEventListener($btnPageNext, "click", () => {
|
|
284
|
-
if (this.readonly) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
this.onNewPageIndex(this.pageIndex + 1);
|
|
288
|
-
});
|
|
289
|
-
$pageJumps.appendChild($btnPageNext);
|
|
290
|
-
|
|
291
|
-
const $pageNumber = document.createElement("div");
|
|
292
|
-
$pageNumber.className = this.wrapClassName("page-number");
|
|
293
|
-
|
|
294
|
-
const $pageNumberInput = document.createElement("input");
|
|
295
|
-
$pageNumberInput.className = this.wrapClassName("page-number-input");
|
|
296
|
-
$pageNumberInput.value = String(this.pageIndex + 1);
|
|
297
|
-
if (this.readonly) {
|
|
298
|
-
$pageNumberInput.disabled = true;
|
|
299
|
-
}
|
|
300
|
-
this.$pageNumberInput = $pageNumberInput;
|
|
301
|
-
this.sideEffect.addEventListener($pageNumberInput, "focus", () => {
|
|
302
|
-
$pageNumberInput.select();
|
|
303
|
-
});
|
|
304
|
-
this.sideEffect.addEventListener($pageNumberInput, "change", () => {
|
|
305
|
-
if (this.readonly) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
if ($pageNumberInput.value) {
|
|
309
|
-
this.onNewPageIndex(Number($pageNumberInput.value) - 1);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
const $totalPage = document.createElement("span");
|
|
314
|
-
this.$totalPage = $totalPage;
|
|
315
|
-
|
|
316
|
-
$pageNumber.appendChild($pageNumberInput);
|
|
317
|
-
$pageNumber.appendChild($totalPage);
|
|
318
|
-
|
|
319
|
-
this.$footer.appendChild($pageJumps);
|
|
320
|
-
this.$footer.appendChild($pageNumber);
|
|
321
|
-
}
|
|
322
|
-
return this.$footer;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
protected renderFooterBtn(
|
|
326
|
-
className: string,
|
|
327
|
-
$icon: SVGElement,
|
|
328
|
-
$iconActive?: SVGElement
|
|
329
|
-
): HTMLButtonElement {
|
|
330
|
-
const $btn = document.createElement("button");
|
|
331
|
-
$btn.className = this.wrapClassName("footer-btn") + " " + this.wrapClassName(className);
|
|
332
|
-
|
|
333
|
-
$btn.appendChild($icon);
|
|
334
|
-
|
|
335
|
-
if ($iconActive) {
|
|
336
|
-
$btn.appendChild($iconActive);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return $btn;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
protected togglePreview(isShowPreview?: boolean): void {
|
|
343
|
-
this.isShowPreview = isShowPreview ?? !this.isShowPreview;
|
|
344
|
-
this.$content.classList.toggle(this.wrapClassName("preview-active"), this.isShowPreview);
|
|
345
|
-
if (this.isShowPreview) {
|
|
346
|
-
const $previewPage = this.$preview.querySelector<HTMLElement>(
|
|
347
|
-
"." + this.wrapClassName(`preview-page-${this.pageIndex}`)
|
|
348
|
-
);
|
|
349
|
-
if ($previewPage) {
|
|
350
|
-
this.$preview.scrollTo({
|
|
351
|
-
top: $previewPage.offsetTop - 16,
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
protected wrapClassName(className: string): string {
|
|
358
|
-
return `${this.namespace}-${className}`;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
protected namespace = "netless-app-slide";
|
|
362
|
-
|
|
363
|
-
protected isShowPreview = false;
|
|
364
|
-
|
|
365
|
-
protected isSmallBox = false;
|
|
366
|
-
|
|
367
|
-
protected sideEffect = new SideEffectManager();
|
|
368
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
@import "./variables.scss";
|
|
2
|
-
|
|
3
|
-
$namespace: $slide-namespace;
|
|
4
|
-
|
|
5
|
-
.#{$namespace}-content {
|
|
6
|
-
position: relative;
|
|
7
|
-
height: 100%;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.#{$namespace}-preview-mask {
|
|
12
|
-
display: none;
|
|
13
|
-
position: absolute;
|
|
14
|
-
z-index: 200;
|
|
15
|
-
top: 0;
|
|
16
|
-
left: 0;
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.#{$namespace}-preview {
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
align-items: center;
|
|
25
|
-
position: absolute;
|
|
26
|
-
z-index: 300;
|
|
27
|
-
top: 0;
|
|
28
|
-
left: 0;
|
|
29
|
-
width: 33%;
|
|
30
|
-
max-width: 200px;
|
|
31
|
-
height: 100%;
|
|
32
|
-
padding-top: 10px;
|
|
33
|
-
transform: translateX(-100%);
|
|
34
|
-
background: rgba(237, 237, 240, 0.9);
|
|
35
|
-
box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.11);
|
|
36
|
-
transition: transform 0.4s;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.#{$namespace}-preview-active {
|
|
40
|
-
.#{$namespace}-preview-mask {
|
|
41
|
-
display: block;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.#{$namespace}-preview {
|
|
45
|
-
transform: translateX(0);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.#{$namespace}-preview-page {
|
|
50
|
-
position: relative;
|
|
51
|
-
display: block;
|
|
52
|
-
width: 55%;
|
|
53
|
-
margin-bottom: 10px;
|
|
54
|
-
font-size: 0;
|
|
55
|
-
color: transparent;
|
|
56
|
-
outline: none;
|
|
57
|
-
border: 7px solid transparent;
|
|
58
|
-
border-radius: 4px;
|
|
59
|
-
transition: border-color 0.3s;
|
|
60
|
-
user-select: none;
|
|
61
|
-
|
|
62
|
-
&:hover,
|
|
63
|
-
&.#{$namespace}-preview-page-active {
|
|
64
|
-
border-color: rgba(68, 78, 96, 0.1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
& > img {
|
|
68
|
-
width: 100%;
|
|
69
|
-
height: auto;
|
|
70
|
-
box-sizing: border-box;
|
|
71
|
-
border: 1px solid rgba(0, 0, 0, 0.5);
|
|
72
|
-
border-radius: 1px;
|
|
73
|
-
background-color: rgba(255, 255, 255, 1);
|
|
74
|
-
box-shadow: 0 2px 8px rgb(0 0 0 / 30%);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.#{$namespace}-preview-page-name {
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: 1px;
|
|
81
|
-
left: -10px;
|
|
82
|
-
transform: translate(-100%);
|
|
83
|
-
text-align: right;
|
|
84
|
-
font-size: 12px;
|
|
85
|
-
color: #5f5f5f;
|
|
86
|
-
user-select: none;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.#{$namespace}-footer {
|
|
90
|
-
box-sizing: border-box;
|
|
91
|
-
height: 26px;
|
|
92
|
-
display: flex;
|
|
93
|
-
align-items: center;
|
|
94
|
-
padding: 0 16px;
|
|
95
|
-
border-top: 1px solid #eeeef7;
|
|
96
|
-
color: #191919;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.#{$namespace}-float-footer {
|
|
100
|
-
width: 100%;
|
|
101
|
-
min-height: 26px;
|
|
102
|
-
position: absolute;
|
|
103
|
-
left: 0;
|
|
104
|
-
bottom: 0;
|
|
105
|
-
z-index: 2000;
|
|
106
|
-
background: rgba(249, 249, 252, 0.9);
|
|
107
|
-
transition: opacity 0.4s;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.#{$namespace}-footer-btn {
|
|
111
|
-
box-sizing: border-box;
|
|
112
|
-
width: 26px;
|
|
113
|
-
height: 26px;
|
|
114
|
-
font-size: 0;
|
|
115
|
-
margin: 0;
|
|
116
|
-
padding: 3px;
|
|
117
|
-
border: none;
|
|
118
|
-
border-radius: 1px;
|
|
119
|
-
outline: none;
|
|
120
|
-
color: currentColor;
|
|
121
|
-
background: transparent;
|
|
122
|
-
transition: background 0.4s;
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
user-select: none;
|
|
125
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
126
|
-
|
|
127
|
-
&:hover {
|
|
128
|
-
background: rgba(237, 237, 240, 0.9);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@media (hover: none) {
|
|
132
|
-
&:hover {
|
|
133
|
-
background: transparent !important;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
& > svg {
|
|
138
|
-
width: 100%;
|
|
139
|
-
height: 100%;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
& > svg:nth-of-type(2) {
|
|
143
|
-
display: none;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
&.#{$namespace}-footer-btn-playing {
|
|
147
|
-
& > svg:nth-of-type(1) {
|
|
148
|
-
display: none;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
& > svg:nth-of-type(2) {
|
|
152
|
-
display: initial;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
& ~ & {
|
|
157
|
-
margin-left: 15px;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.#{$namespace}-page-jumps {
|
|
162
|
-
flex: 1;
|
|
163
|
-
display: flex;
|
|
164
|
-
justify-content: center;
|
|
165
|
-
align-items: center;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.#{$namespace}-page-number {
|
|
169
|
-
margin-left: auto;
|
|
170
|
-
font-size: 13px;
|
|
171
|
-
user-select: none;
|
|
172
|
-
white-space: nowrap;
|
|
173
|
-
word-break: keep-all;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.#{$namespace}-page-number-input {
|
|
177
|
-
border: none;
|
|
178
|
-
outline: none;
|
|
179
|
-
width: 3em;
|
|
180
|
-
margin: 0;
|
|
181
|
-
padding: 0 2px;
|
|
182
|
-
text-align: right;
|
|
183
|
-
font-size: 13px;
|
|
184
|
-
line-height: 1;
|
|
185
|
-
font-weight: normal;
|
|
186
|
-
font-family: inherit;
|
|
187
|
-
border-radius: 2px;
|
|
188
|
-
color: currentColor;
|
|
189
|
-
background: transparent;
|
|
190
|
-
transition: background 0.4s;
|
|
191
|
-
user-select: text;
|
|
192
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
193
|
-
|
|
194
|
-
&:hover,
|
|
195
|
-
&:focus,
|
|
196
|
-
&:active {
|
|
197
|
-
background: #fff;
|
|
198
|
-
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.#{$namespace}-readonly {
|
|
203
|
-
&.#{$namespace}-footer {
|
|
204
|
-
display: none;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.telebox-color-scheme-dark {
|
|
209
|
-
.#{$namespace}-page-number-input {
|
|
210
|
-
color: #a6a6a8;
|
|
211
|
-
}
|
|
212
|
-
.#{$namespace}-page-number-input:active,
|
|
213
|
-
.#{$namespace}-page-number-input:focus,
|
|
214
|
-
.#{$namespace}-page-number-input:hover {
|
|
215
|
-
color: #222;
|
|
216
|
-
}
|
|
217
|
-
.#{$namespace}-footer {
|
|
218
|
-
color: #a6a6a8;
|
|
219
|
-
background: #2d2d33;
|
|
220
|
-
border-top: none;
|
|
221
|
-
}
|
|
222
|
-
.#{$namespace}-footer-btn:hover {
|
|
223
|
-
background: #212126;
|
|
224
|
-
}
|
|
225
|
-
.#{$namespace}-preview {
|
|
226
|
-
background: rgba(50, 50, 50, 0.9);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$slide-namespace: "netless-app-slide";
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { AppContext, Room } from "@netless/window-manager";
|
|
2
|
-
import type { ScenePathType } from "white-web-sdk";
|
|
3
|
-
import type { Slide } from "@netless/slide";
|
|
4
|
-
import type { DocsViewerPage } from "../DocsViewer";
|
|
5
|
-
import type { Attributes } from "../typings";
|
|
6
|
-
|
|
7
|
-
export function createDocsViewerPages(slide: Slide): DocsViewerPage[] {
|
|
8
|
-
const { width, height, slideCount, slideState } = slide;
|
|
9
|
-
const { taskId, url } = slideState;
|
|
10
|
-
const pages: DocsViewerPage[] = [];
|
|
11
|
-
for (let i = 1; i <= slideCount; ++i) {
|
|
12
|
-
pages.push({ width, height, thumbnail: `${url}/${taskId}/preview/${i}.png`, src: "ppt" });
|
|
13
|
-
}
|
|
14
|
-
return pages;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// because `renderSlide()` is slow, but switching between scenes in whiteboard is fast
|
|
18
|
-
// so here we make scenes sync with slide page
|
|
19
|
-
export function syncSceneWithSlide(
|
|
20
|
-
room: Room,
|
|
21
|
-
context: AppContext<Attributes>,
|
|
22
|
-
slide: Slide,
|
|
23
|
-
baseScenePath: string
|
|
24
|
-
) {
|
|
25
|
-
const page = slide.slideState.currentSlideIndex;
|
|
26
|
-
if (!(page > 0) || !context.getIsWritable()) return;
|
|
27
|
-
|
|
28
|
-
const scenePath = [baseScenePath, page].join("/");
|
|
29
|
-
|
|
30
|
-
if (room.scenePathType(scenePath) !== ("page" as ScenePathType.Page)) {
|
|
31
|
-
room.removeScenes(baseScenePath);
|
|
32
|
-
const count = slide.slideCount;
|
|
33
|
-
const scenes: { name: string }[] = [];
|
|
34
|
-
for (let i = 1; i <= count; ++i) scenes.push({ name: `${i}` });
|
|
35
|
-
room.putScenes(baseScenePath, scenes);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let currentScenePath: string;
|
|
39
|
-
if (context.getBox().focus) {
|
|
40
|
-
currentScenePath = room.state.sceneState.scenePath;
|
|
41
|
-
} else {
|
|
42
|
-
currentScenePath = context.getView()?.focusScenePath || "";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (currentScenePath !== scenePath) {
|
|
46
|
-
context.setScenePath(scenePath);
|
|
47
|
-
}
|
|
48
|
-
}
|