@netless/app-presentation 0.1.9-beta.6 → 0.1.9-beta.7
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 +65 -3
- package/dist/index.global.js +45 -13
- package/dist/index.js +45 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app-presentation.ts +11 -9
- package/src/index.ts +1 -0
- package/src/scrollbar/index.ts +32 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { View, NetlessApp, AppContext, WindowManager } from '@netless/window-manager';
|
|
2
|
+
import * as lodash from 'lodash';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* A combination of {@link Disposer} and {@link IDisposable}.
|
|
@@ -308,6 +309,18 @@ declare class Presentation implements IDisposable<void> {
|
|
|
308
309
|
private isEditable;
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
interface ScrollbarOption {
|
|
313
|
+
appId: string;
|
|
314
|
+
readonly?: boolean;
|
|
315
|
+
getPageSize: () => {
|
|
316
|
+
width: number;
|
|
317
|
+
height: number;
|
|
318
|
+
};
|
|
319
|
+
getWritable: () => boolean;
|
|
320
|
+
getOriginScale: () => number;
|
|
321
|
+
syncView: () => void;
|
|
322
|
+
scrollbarEventCallback?: ScrollbarEventCallback;
|
|
323
|
+
}
|
|
311
324
|
interface ScrollbarEventCallback {
|
|
312
325
|
onScrollbarDragStart?: () => void;
|
|
313
326
|
onScrollbarDragEnd?: () => void;
|
|
@@ -315,6 +328,55 @@ interface ScrollbarEventCallback {
|
|
|
315
328
|
onScrollbarDragY?: (y: number) => void;
|
|
316
329
|
onScrollCameraUpdated?: (appid: string, originScale: number, scale: number) => void;
|
|
317
330
|
}
|
|
331
|
+
declare class Scrollbar {
|
|
332
|
+
readonly namespace = "netless-app-presentation";
|
|
333
|
+
readonly appId: string;
|
|
334
|
+
private container;
|
|
335
|
+
private scrollContainer;
|
|
336
|
+
private option;
|
|
337
|
+
private view;
|
|
338
|
+
private scrollbarContainerX?;
|
|
339
|
+
private scrollbarContainerY?;
|
|
340
|
+
private scrollbarX?;
|
|
341
|
+
private scrollbarY?;
|
|
342
|
+
private draggableX?;
|
|
343
|
+
private draggableY?;
|
|
344
|
+
private cameraCache?;
|
|
345
|
+
private readonly;
|
|
346
|
+
constructor(container: HTMLElement, option: ScrollbarOption, view: View);
|
|
347
|
+
private c;
|
|
348
|
+
setReadonly(bol: boolean): void;
|
|
349
|
+
onCameraUpdated: lodash.DebouncedFunc<() => void>;
|
|
350
|
+
onDragStart: () => void;
|
|
351
|
+
getScrollXRange(camera: {
|
|
352
|
+
scale: number;
|
|
353
|
+
}): {
|
|
354
|
+
minX: number;
|
|
355
|
+
maxX: number;
|
|
356
|
+
};
|
|
357
|
+
getScrollYRange(camera: {
|
|
358
|
+
scale: number;
|
|
359
|
+
}): {
|
|
360
|
+
minY: number;
|
|
361
|
+
maxY: number;
|
|
362
|
+
};
|
|
363
|
+
onDragX: (transformedDrag: {
|
|
364
|
+
x: number;
|
|
365
|
+
y: number;
|
|
366
|
+
}) => void;
|
|
367
|
+
onDragY: (transformedDrag: {
|
|
368
|
+
x: number;
|
|
369
|
+
y: number;
|
|
370
|
+
}) => void;
|
|
371
|
+
onDragEnd: () => void;
|
|
372
|
+
private init;
|
|
373
|
+
destroy(): void;
|
|
374
|
+
moveCamera: (camera: {
|
|
375
|
+
centerX: number;
|
|
376
|
+
centerY: number;
|
|
377
|
+
scale: number;
|
|
378
|
+
}) => void;
|
|
379
|
+
}
|
|
318
380
|
|
|
319
381
|
type Logger = (...data: any[]) => void;
|
|
320
382
|
interface Viewport {
|
|
@@ -421,5 +483,5 @@ declare const install: (register: RegisterFn, options?: InstallOptions) => Promi
|
|
|
421
483
|
|
|
422
484
|
declare const version: string;
|
|
423
485
|
|
|
424
|
-
export { NetlessAppPresentation, Presentation, NetlessAppPresentation as default, install, version };
|
|
425
|
-
export type { InstallOptions, Logger, PresentationAppOptions, PresentationConfig, PresentationController, PresentationPage, RegisterFn };
|
|
486
|
+
export { NetlessAppPresentation, Presentation, Scrollbar, NetlessAppPresentation as default, install, version };
|
|
487
|
+
export type { InstallOptions, Logger, PresentationAppOptions, PresentationConfig, PresentationController, PresentationPage, RegisterFn, ScrollbarEventCallback, ScrollbarOption };
|
package/dist/index.global.js
CHANGED
|
@@ -4174,7 +4174,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
4174
4174
|
return baseIsMatch(object, source, getMatchData(source), customizer);
|
|
4175
4175
|
}
|
|
4176
4176
|
function isNaN(value) {
|
|
4177
|
-
return
|
|
4177
|
+
return isNumber2(value) && value != +value;
|
|
4178
4178
|
}
|
|
4179
4179
|
function isNative(value) {
|
|
4180
4180
|
if (isMaskable(value)) {
|
|
@@ -4188,7 +4188,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
4188
4188
|
function isNil(value) {
|
|
4189
4189
|
return value == null;
|
|
4190
4190
|
}
|
|
4191
|
-
function
|
|
4191
|
+
function isNumber2(value) {
|
|
4192
4192
|
return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
|
|
4193
4193
|
}
|
|
4194
4194
|
function isPlainObject(value) {
|
|
@@ -5254,7 +5254,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
5254
5254
|
lodash.isNative = isNative;
|
|
5255
5255
|
lodash.isNil = isNil;
|
|
5256
5256
|
lodash.isNull = isNull;
|
|
5257
|
-
lodash.isNumber =
|
|
5257
|
+
lodash.isNumber = isNumber2;
|
|
5258
5258
|
lodash.isObject = isObject;
|
|
5259
5259
|
lodash.isObjectLike = isObjectLike;
|
|
5260
5260
|
lodash.isPlainObject = isPlainObject;
|
|
@@ -6922,6 +6922,35 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
6922
6922
|
this.option.syncView();
|
|
6923
6923
|
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollbarDragEnd) == null ? void 0 : _b.call(_a);
|
|
6924
6924
|
};
|
|
6925
|
+
this.moveCamera = (camera) => {
|
|
6926
|
+
const { centerX, centerY } = camera;
|
|
6927
|
+
const cacheCamera = this.view.camera;
|
|
6928
|
+
const _camera = {};
|
|
6929
|
+
if ((0, import_lodash.isNumber)(centerX)) {
|
|
6930
|
+
const { minX, maxX } = this.getScrollXRange(cacheCamera);
|
|
6931
|
+
let newCenterX = centerX;
|
|
6932
|
+
if (centerX < minX) {
|
|
6933
|
+
newCenterX = minX;
|
|
6934
|
+
} else if (centerX > maxX) {
|
|
6935
|
+
newCenterX = maxX;
|
|
6936
|
+
}
|
|
6937
|
+
_camera.centerX = newCenterX;
|
|
6938
|
+
}
|
|
6939
|
+
if ((0, import_lodash.isNumber)(centerY)) {
|
|
6940
|
+
const { minY, maxY } = this.getScrollYRange(cacheCamera);
|
|
6941
|
+
let newCenterY = centerY;
|
|
6942
|
+
if (centerY < minY) {
|
|
6943
|
+
newCenterY = minY;
|
|
6944
|
+
} else if (centerY > maxY) {
|
|
6945
|
+
newCenterY = maxY;
|
|
6946
|
+
}
|
|
6947
|
+
_camera.centerY = newCenterY;
|
|
6948
|
+
}
|
|
6949
|
+
this.view.moveCamera(__spreadProps(__spreadValues({}, _camera), {
|
|
6950
|
+
animationMode: "immediately"
|
|
6951
|
+
}));
|
|
6952
|
+
this.option.syncView();
|
|
6953
|
+
};
|
|
6925
6954
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6926
6955
|
this.container = container;
|
|
6927
6956
|
this.option = option;
|
|
@@ -7265,7 +7294,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7265
7294
|
};
|
|
7266
7295
|
const box = context.getBox();
|
|
7267
7296
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
|
|
7268
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7297
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.7";
|
|
7269
7298
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7270
7299
|
app.log = log;
|
|
7271
7300
|
if (options.justDocsViewReadonly) {
|
|
@@ -7358,14 +7387,6 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7358
7387
|
});
|
|
7359
7388
|
}
|
|
7360
7389
|
};
|
|
7361
|
-
const moveCamera = (camera) => {
|
|
7362
|
-
if (context.getIsWritable()) {
|
|
7363
|
-
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
7364
|
-
syncView();
|
|
7365
|
-
return;
|
|
7366
|
-
}
|
|
7367
|
-
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7368
|
-
};
|
|
7369
7390
|
let scrollbar;
|
|
7370
7391
|
if (options.useScrollbar) {
|
|
7371
7392
|
dispose2.make(() => {
|
|
@@ -7380,6 +7401,16 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7380
7401
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
7381
7402
|
});
|
|
7382
7403
|
}
|
|
7404
|
+
const moveCamera = (camera) => {
|
|
7405
|
+
if (context.getIsWritable() && scrollbar) {
|
|
7406
|
+
if (!scrollbar) {
|
|
7407
|
+
throw new Error("[Presentation]: moveCamera must be called when appOptions: useScrollbar is true");
|
|
7408
|
+
}
|
|
7409
|
+
scrollbar.moveCamera(camera);
|
|
7410
|
+
return;
|
|
7411
|
+
}
|
|
7412
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7413
|
+
};
|
|
7383
7414
|
context.emitter.on("destroy", () => dispose2());
|
|
7384
7415
|
const reportProgress = (progress, result) => {
|
|
7385
7416
|
window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
|
|
@@ -7582,7 +7613,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7582
7613
|
};
|
|
7583
7614
|
|
|
7584
7615
|
// src/index.ts
|
|
7585
|
-
var version = "0.1.9-beta.
|
|
7616
|
+
var version = "0.1.9-beta.7";
|
|
7586
7617
|
/*! Bundled license information:
|
|
7587
7618
|
|
|
7588
7619
|
lodash/lodash.js:
|
|
@@ -7598,6 +7629,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7598
7629
|
|
|
7599
7630
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
7600
7631
|
exports.Presentation = Presentation;
|
|
7632
|
+
exports.Scrollbar = Scrollbar;
|
|
7601
7633
|
exports.default = NetlessAppPresentation;
|
|
7602
7634
|
exports.install = install;
|
|
7603
7635
|
exports.version = version;
|
package/dist/index.js
CHANGED
|
@@ -4175,7 +4175,7 @@ var require_lodash = __commonJS({
|
|
|
4175
4175
|
return baseIsMatch(object, source, getMatchData(source), customizer);
|
|
4176
4176
|
}
|
|
4177
4177
|
function isNaN(value) {
|
|
4178
|
-
return
|
|
4178
|
+
return isNumber2(value) && value != +value;
|
|
4179
4179
|
}
|
|
4180
4180
|
function isNative(value) {
|
|
4181
4181
|
if (isMaskable(value)) {
|
|
@@ -4189,7 +4189,7 @@ var require_lodash = __commonJS({
|
|
|
4189
4189
|
function isNil(value) {
|
|
4190
4190
|
return value == null;
|
|
4191
4191
|
}
|
|
4192
|
-
function
|
|
4192
|
+
function isNumber2(value) {
|
|
4193
4193
|
return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
|
|
4194
4194
|
}
|
|
4195
4195
|
function isPlainObject(value) {
|
|
@@ -5255,7 +5255,7 @@ var require_lodash = __commonJS({
|
|
|
5255
5255
|
lodash.isNative = isNative;
|
|
5256
5256
|
lodash.isNil = isNil;
|
|
5257
5257
|
lodash.isNull = isNull;
|
|
5258
|
-
lodash.isNumber =
|
|
5258
|
+
lodash.isNumber = isNumber2;
|
|
5259
5259
|
lodash.isObject = isObject;
|
|
5260
5260
|
lodash.isObjectLike = isObjectLike;
|
|
5261
5261
|
lodash.isPlainObject = isPlainObject;
|
|
@@ -6923,6 +6923,35 @@ var Scrollbar = class {
|
|
|
6923
6923
|
this.option.syncView();
|
|
6924
6924
|
(_b = (_a = this.option.scrollbarEventCallback) == null ? void 0 : _a.onScrollbarDragEnd) == null ? void 0 : _b.call(_a);
|
|
6925
6925
|
};
|
|
6926
|
+
this.moveCamera = (camera) => {
|
|
6927
|
+
const { centerX, centerY } = camera;
|
|
6928
|
+
const cacheCamera = this.view.camera;
|
|
6929
|
+
const _camera = {};
|
|
6930
|
+
if ((0, import_lodash.isNumber)(centerX)) {
|
|
6931
|
+
const { minX, maxX } = this.getScrollXRange(cacheCamera);
|
|
6932
|
+
let newCenterX = centerX;
|
|
6933
|
+
if (centerX < minX) {
|
|
6934
|
+
newCenterX = minX;
|
|
6935
|
+
} else if (centerX > maxX) {
|
|
6936
|
+
newCenterX = maxX;
|
|
6937
|
+
}
|
|
6938
|
+
_camera.centerX = newCenterX;
|
|
6939
|
+
}
|
|
6940
|
+
if ((0, import_lodash.isNumber)(centerY)) {
|
|
6941
|
+
const { minY, maxY } = this.getScrollYRange(cacheCamera);
|
|
6942
|
+
let newCenterY = centerY;
|
|
6943
|
+
if (centerY < minY) {
|
|
6944
|
+
newCenterY = minY;
|
|
6945
|
+
} else if (centerY > maxY) {
|
|
6946
|
+
newCenterY = maxY;
|
|
6947
|
+
}
|
|
6948
|
+
_camera.centerY = newCenterY;
|
|
6949
|
+
}
|
|
6950
|
+
this.view.moveCamera(__spreadProps(__spreadValues({}, _camera), {
|
|
6951
|
+
animationMode: "immediately"
|
|
6952
|
+
}));
|
|
6953
|
+
this.option.syncView();
|
|
6954
|
+
};
|
|
6926
6955
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6927
6956
|
this.container = container;
|
|
6928
6957
|
this.option = option;
|
|
@@ -7266,7 +7295,7 @@ var NetlessAppPresentation = {
|
|
|
7266
7295
|
};
|
|
7267
7296
|
const box = context.getBox();
|
|
7268
7297
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
|
|
7269
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7298
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.7";
|
|
7270
7299
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7271
7300
|
app.log = log;
|
|
7272
7301
|
if (options.justDocsViewReadonly) {
|
|
@@ -7359,14 +7388,6 @@ var NetlessAppPresentation = {
|
|
|
7359
7388
|
});
|
|
7360
7389
|
}
|
|
7361
7390
|
};
|
|
7362
|
-
const moveCamera = (camera) => {
|
|
7363
|
-
if (context.getIsWritable()) {
|
|
7364
|
-
view.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: "immediately" }));
|
|
7365
|
-
syncView();
|
|
7366
|
-
return;
|
|
7367
|
-
}
|
|
7368
|
-
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7369
|
-
};
|
|
7370
7391
|
let scrollbar;
|
|
7371
7392
|
if (options.useScrollbar) {
|
|
7372
7393
|
dispose2.make(() => {
|
|
@@ -7381,6 +7402,16 @@ var NetlessAppPresentation = {
|
|
|
7381
7402
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
7382
7403
|
});
|
|
7383
7404
|
}
|
|
7405
|
+
const moveCamera = (camera) => {
|
|
7406
|
+
if (context.getIsWritable() && scrollbar) {
|
|
7407
|
+
if (!scrollbar) {
|
|
7408
|
+
throw new Error("[Presentation]: moveCamera must be called when appOptions: useScrollbar is true");
|
|
7409
|
+
}
|
|
7410
|
+
scrollbar.moveCamera(camera);
|
|
7411
|
+
return;
|
|
7412
|
+
}
|
|
7413
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7414
|
+
};
|
|
7384
7415
|
context.emitter.on("destroy", () => dispose2());
|
|
7385
7416
|
const reportProgress = (progress, result) => {
|
|
7386
7417
|
window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
|
|
@@ -7583,7 +7614,7 @@ var install = (register, options = {}) => {
|
|
|
7583
7614
|
};
|
|
7584
7615
|
|
|
7585
7616
|
// src/index.ts
|
|
7586
|
-
var version = "0.1.9-beta.
|
|
7617
|
+
var version = "0.1.9-beta.7";
|
|
7587
7618
|
/*! Bundled license information:
|
|
7588
7619
|
|
|
7589
7620
|
lodash/lodash.js:
|
|
@@ -7599,6 +7630,7 @@ lodash/lodash.js:
|
|
|
7599
7630
|
|
|
7600
7631
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
7601
7632
|
exports.Presentation = Presentation;
|
|
7633
|
+
exports.Scrollbar = Scrollbar;
|
|
7602
7634
|
exports.default = NetlessAppPresentation;
|
|
7603
7635
|
exports.install = install;
|
|
7604
7636
|
exports.version = version;
|