@netless/app-presentation 0.1.9-beta.6 → 0.1.9-beta.8
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 +53 -13
- package/dist/index.js +53 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -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 +40 -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,43 @@ 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, scale } = 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
|
+
if ((0, import_lodash.isNumber)(scale)) {
|
|
6950
|
+
let newScale = scale;
|
|
6951
|
+
const originScale = this.option.getOriginScale();
|
|
6952
|
+
if (scale < originScale) {
|
|
6953
|
+
newScale = originScale;
|
|
6954
|
+
}
|
|
6955
|
+
_camera.scale = newScale;
|
|
6956
|
+
}
|
|
6957
|
+
this.view.moveCamera(__spreadProps(__spreadValues({}, _camera), {
|
|
6958
|
+
animationMode: "immediately"
|
|
6959
|
+
}));
|
|
6960
|
+
this.option.syncView();
|
|
6961
|
+
};
|
|
6925
6962
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6926
6963
|
this.container = container;
|
|
6927
6964
|
this.option = option;
|
|
@@ -7265,7 +7302,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7265
7302
|
};
|
|
7266
7303
|
const box = context.getBox();
|
|
7267
7304
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
|
|
7268
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7305
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.8";
|
|
7269
7306
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7270
7307
|
app.log = log;
|
|
7271
7308
|
if (options.justDocsViewReadonly) {
|
|
@@ -7358,14 +7395,6 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7358
7395
|
});
|
|
7359
7396
|
}
|
|
7360
7397
|
};
|
|
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
7398
|
let scrollbar;
|
|
7370
7399
|
if (options.useScrollbar) {
|
|
7371
7400
|
dispose2.make(() => {
|
|
@@ -7380,6 +7409,16 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7380
7409
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
7381
7410
|
});
|
|
7382
7411
|
}
|
|
7412
|
+
const moveCamera = (camera) => {
|
|
7413
|
+
if (context.getIsWritable() && scrollbar) {
|
|
7414
|
+
if (!scrollbar) {
|
|
7415
|
+
throw new Error("[Presentation]: moveCamera must be called when appOptions: useScrollbar is true");
|
|
7416
|
+
}
|
|
7417
|
+
scrollbar.moveCamera(camera);
|
|
7418
|
+
return;
|
|
7419
|
+
}
|
|
7420
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7421
|
+
};
|
|
7383
7422
|
context.emitter.on("destroy", () => dispose2());
|
|
7384
7423
|
const reportProgress = (progress, result) => {
|
|
7385
7424
|
window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
|
|
@@ -7582,7 +7621,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7582
7621
|
};
|
|
7583
7622
|
|
|
7584
7623
|
// src/index.ts
|
|
7585
|
-
var version = "0.1.9-beta.
|
|
7624
|
+
var version = "0.1.9-beta.8";
|
|
7586
7625
|
/*! Bundled license information:
|
|
7587
7626
|
|
|
7588
7627
|
lodash/lodash.js:
|
|
@@ -7598,6 +7637,7 @@ var NetlessAppPresentation = (function (exports) {
|
|
|
7598
7637
|
|
|
7599
7638
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
7600
7639
|
exports.Presentation = Presentation;
|
|
7640
|
+
exports.Scrollbar = Scrollbar;
|
|
7601
7641
|
exports.default = NetlessAppPresentation;
|
|
7602
7642
|
exports.install = install;
|
|
7603
7643
|
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,43 @@ 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, scale } = 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
|
+
if ((0, import_lodash.isNumber)(scale)) {
|
|
6951
|
+
let newScale = scale;
|
|
6952
|
+
const originScale = this.option.getOriginScale();
|
|
6953
|
+
if (scale < originScale) {
|
|
6954
|
+
newScale = originScale;
|
|
6955
|
+
}
|
|
6956
|
+
_camera.scale = newScale;
|
|
6957
|
+
}
|
|
6958
|
+
this.view.moveCamera(__spreadProps(__spreadValues({}, _camera), {
|
|
6959
|
+
animationMode: "immediately"
|
|
6960
|
+
}));
|
|
6961
|
+
this.option.syncView();
|
|
6962
|
+
};
|
|
6926
6963
|
this.scrollContainer.className = this.c("scrollbar-container");
|
|
6927
6964
|
this.container = container;
|
|
6928
6965
|
this.option = option;
|
|
@@ -7266,7 +7303,7 @@ var NetlessAppPresentation = {
|
|
|
7266
7303
|
};
|
|
7267
7304
|
const box = context.getBox();
|
|
7268
7305
|
const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, view, options.thumbnail, options.useClipView));
|
|
7269
|
-
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.
|
|
7306
|
+
app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.8";
|
|
7270
7307
|
app.scaleDocsToFit = scaleDocsToFit;
|
|
7271
7308
|
app.log = log;
|
|
7272
7309
|
if (options.justDocsViewReadonly) {
|
|
@@ -7359,14 +7396,6 @@ var NetlessAppPresentation = {
|
|
|
7359
7396
|
});
|
|
7360
7397
|
}
|
|
7361
7398
|
};
|
|
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
7399
|
let scrollbar;
|
|
7371
7400
|
if (options.useScrollbar) {
|
|
7372
7401
|
dispose2.make(() => {
|
|
@@ -7381,6 +7410,16 @@ var NetlessAppPresentation = {
|
|
|
7381
7410
|
return () => scrollbar == null ? void 0 : scrollbar.destroy();
|
|
7382
7411
|
});
|
|
7383
7412
|
}
|
|
7413
|
+
const moveCamera = (camera) => {
|
|
7414
|
+
if (context.getIsWritable() && scrollbar) {
|
|
7415
|
+
if (!scrollbar) {
|
|
7416
|
+
throw new Error("[Presentation]: moveCamera must be called when appOptions: useScrollbar is true");
|
|
7417
|
+
}
|
|
7418
|
+
scrollbar.moveCamera(camera);
|
|
7419
|
+
return;
|
|
7420
|
+
}
|
|
7421
|
+
throw new Error("[Presentation]: moveCamera must be called in writable room");
|
|
7422
|
+
};
|
|
7384
7423
|
context.emitter.on("destroy", () => dispose2());
|
|
7385
7424
|
const reportProgress = (progress, result) => {
|
|
7386
7425
|
window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
|
|
@@ -7583,7 +7622,7 @@ var install = (register, options = {}) => {
|
|
|
7583
7622
|
};
|
|
7584
7623
|
|
|
7585
7624
|
// src/index.ts
|
|
7586
|
-
var version = "0.1.9-beta.
|
|
7625
|
+
var version = "0.1.9-beta.8";
|
|
7587
7626
|
/*! Bundled license information:
|
|
7588
7627
|
|
|
7589
7628
|
lodash/lodash.js:
|
|
@@ -7599,6 +7638,7 @@ lodash/lodash.js:
|
|
|
7599
7638
|
|
|
7600
7639
|
exports.NetlessAppPresentation = NetlessAppPresentation;
|
|
7601
7640
|
exports.Presentation = Presentation;
|
|
7641
|
+
exports.Scrollbar = Scrollbar;
|
|
7602
7642
|
exports.default = NetlessAppPresentation;
|
|
7603
7643
|
exports.install = install;
|
|
7604
7644
|
exports.version = version;
|