@netless/app-slide 0.2.34 → 0.2.35
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/dist/index.d.ts +5 -2
- package/dist/main.cjs.js +145 -145
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +34 -20
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +203 -203
- package/dist/main.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/DocsViewer/index.ts +20 -5
- package/src/SlideDocsViewer/index.ts +3 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
package/src/DocsViewer/index.ts
CHANGED
|
@@ -19,13 +19,15 @@ export interface DocsViewerConfig {
|
|
|
19
19
|
readonly: boolean;
|
|
20
20
|
onNewPageIndex: (index: number) => void;
|
|
21
21
|
onPlay?: () => void;
|
|
22
|
+
urlInterrupter?: (url: string) => Promise<string>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export class DocsViewer {
|
|
25
|
-
public constructor({ readonly, onNewPageIndex, onPlay }: DocsViewerConfig) {
|
|
26
|
+
public constructor({ readonly, onNewPageIndex, onPlay, urlInterrupter }: DocsViewerConfig) {
|
|
26
27
|
this.readonly = readonly;
|
|
27
28
|
this.onNewPageIndex = onNewPageIndex;
|
|
28
29
|
this.onPlay = onPlay;
|
|
30
|
+
this.urlInterrupter = urlInterrupter || (url => url);
|
|
29
31
|
|
|
30
32
|
this.render();
|
|
31
33
|
}
|
|
@@ -33,14 +35,14 @@ export class DocsViewer {
|
|
|
33
35
|
protected readonly: boolean;
|
|
34
36
|
protected onNewPageIndex: (index: number) => void;
|
|
35
37
|
protected onPlay?: () => void;
|
|
38
|
+
protected urlInterrupter: (url: string) => Promise<string> | string;
|
|
36
39
|
|
|
37
40
|
private _pages: DocsViewerPage[] = [];
|
|
38
41
|
|
|
39
42
|
public set pages(value: DocsViewerPage[]) {
|
|
40
43
|
this._pages = value;
|
|
41
|
-
this.refreshPreview();
|
|
44
|
+
this.refreshPreview().then(this.refreshBtnSidebar.bind(this));
|
|
42
45
|
this.refreshTotalPage();
|
|
43
|
-
this.refreshBtnSidebar();
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
public get pages() {
|
|
@@ -148,7 +150,7 @@ export class DocsViewer {
|
|
|
148
150
|
return this.$preview;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
private refreshPreview() {
|
|
153
|
+
private async refreshPreview() {
|
|
152
154
|
const { $preview } = this;
|
|
153
155
|
const pageClassName = this.wrapClassName("preview-page");
|
|
154
156
|
const pageNameClassName = this.wrapClassName("preview-page-name");
|
|
@@ -156,8 +158,21 @@ export class DocsViewer {
|
|
|
156
158
|
$preview.firstChild.remove();
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
const previewSRCs: Record<number, Promise<string> | string> = [];
|
|
162
|
+
for (let i = 0, len = this.pages.length; i < len; i++) {
|
|
163
|
+
const page = this.pages[i];
|
|
164
|
+
const src = page.thumbnail ?? (page.src.startsWith("ppt") ? void 0 : page.src);
|
|
165
|
+
if (src) {
|
|
166
|
+
previewSRCs[i] = this.urlInterrupter(src);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Promise.all(), but no closure
|
|
170
|
+
for (let i = 0, len = this.pages.length; i < len; i++) {
|
|
171
|
+
previewSRCs[i] = await previewSRCs[i]
|
|
172
|
+
}
|
|
173
|
+
|
|
159
174
|
this.pages.forEach((page, i) => {
|
|
160
|
-
const previewSRC =
|
|
175
|
+
const previewSRC = previewSRCs[i] as string | undefined;
|
|
161
176
|
if (!previewSRC) {
|
|
162
177
|
return;
|
|
163
178
|
}
|
|
@@ -19,6 +19,7 @@ export interface SlideDocsViewerConfig {
|
|
|
19
19
|
mountWhiteboard: (dom: HTMLDivElement) => void;
|
|
20
20
|
baseScenePath: string;
|
|
21
21
|
appId: string;
|
|
22
|
+
urlInterrupter?: (url: string) => Promise<string>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface SavePdfConfig {
|
|
@@ -45,6 +46,7 @@ export class SlideDocsViewer {
|
|
|
45
46
|
mountWhiteboard,
|
|
46
47
|
baseScenePath,
|
|
47
48
|
appId,
|
|
49
|
+
urlInterrupter,
|
|
48
50
|
}: SlideDocsViewerConfig) {
|
|
49
51
|
this.box = box;
|
|
50
52
|
this.whiteboardView = view;
|
|
@@ -56,6 +58,7 @@ export class SlideDocsViewer {
|
|
|
56
58
|
readonly: box.readonly,
|
|
57
59
|
onNewPageIndex: this.onNewPageIndex,
|
|
58
60
|
onPlay: this.onPlay,
|
|
61
|
+
urlInterrupter,
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
this.sideEffect.add(() => {
|
package/src/index.ts
CHANGED
|
@@ -170,6 +170,7 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, AppResult> = {
|
|
|
170
170
|
mountWhiteboard: context.mountView.bind(context),
|
|
171
171
|
baseScenePath,
|
|
172
172
|
appId: context.appId,
|
|
173
|
+
urlInterrupter: context.getAppOptions()?.urlInterrupter,
|
|
173
174
|
});
|
|
174
175
|
|
|
175
176
|
if (import.meta.env.DEV) {
|