@netless/app-presentation 0.1.8 → 0.1.9-beta.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/dist/index.d.ts CHANGED
@@ -334,6 +334,10 @@ interface PresentationAppOptions {
334
334
  viewport?: Viewport | ((page: PresentationPage) => Viewport);
335
335
  /** justDocsViewReadonly is used to set the presentation readonly, it will be used in the presentation, and the presentation will be readonly when the app is initialized */
336
336
  justDocsViewReadonly?: true;
337
+ /** useScrollbar is used to set the presentation use scrollbar, it will be used in the presentation, and the presentation will be use scrollbar when the app is initialized */
338
+ useScrollbar?: boolean;
339
+ /** debounceSync is used to set the presentation debounce sync, it will be used in the presentation, and the presentation will be debounce sync when the app is initialized */
340
+ debounceSync?: boolean;
337
341
  }
338
342
  interface PresentationController {
339
343
  readonly app: Presentation;
@@ -357,6 +361,8 @@ interface PresentationController {
357
361
  log: Logger;
358
362
  /** set the docs view readonly */
359
363
  setDocsViewReadonly: (bol: boolean) => void;
364
+ /** set the presentation readonly */
365
+ setReadonly: (bol: boolean) => void;
360
366
  }
361
367
 
362
368
  declare const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions, PresentationController>;
@@ -1156,7 +1156,7 @@ var NetlessAppPresentation = (function (exports) {
1156
1156
  };
1157
1157
 
1158
1158
  // src/style.scss?inline
1159
- var style_default = ".netless-app-presentation{height:100%;display:flex;flex-flow:column nowrap}.netless-app-presentation-content{position:relative;height:100%;overflow:hidden}.netless-app-presentation-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-presentation-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:#ededf0e6;box-shadow:inset -1px 0 #0000001c;transition:transform .4s;overflow:auto;overflow-y:scroll}.netless-app-presentation-preview-active .netless-app-presentation-preview-mask{display:block}.netless-app-presentation-preview-active .netless-app-presentation-preview{transform:translate(0)}.netless-app-presentation-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:#0000;outline:none;border:7px solid rgba(0,0,0,0);border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-presentation-preview-page:hover,.netless-app-presentation-preview-page.netless-app-presentation-preview-page-active{border-color:#444e601a}.netless-app-presentation-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-presentation-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-presentation-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-presentation-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:#f9f9fce6;transition:opacity .4s}.netless-app-presentation-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:#0000;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-footer-btn:hover{background:#ededf0e6}@media (hover: none){.netless-app-presentation-footer-btn:hover{background:#0000!important}}.netless-app-presentation-footer-btn>svg{width:100%;height:100%}.netless-app-presentation-footer-btn>svg:nth-of-type(2){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-presentation-footer-btn~.netless-app-presentation-footer-btn{margin-left:15px}.netless-app-presentation-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-presentation-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-presentation-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:#0000;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-page-number-input:hover,.netless-app-presentation-page-number-input:focus,.netless-app-presentation-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-presentation-readonly.netless-app-presentation-footer{display:none}.netless-app-presentation-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden;transition:opacity .2s}.netless-app-presentation-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.netless-app-presentation-image>img{max-width:100%;max-height:100%;object-fit:contain}.telebox-color-scheme-dark .netless-app-presentation-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-presentation-page-number-input:active,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:focus,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-presentation-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-presentation-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-presentation-preview{background:#323232e6}";
1159
+ var style_default = ".netless-app-presentation{height:100%;display:flex;flex-flow:column nowrap}.netless-app-presentation-content{position:relative;height:100%;overflow:hidden}.netless-app-presentation-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-presentation-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:#ededf0e6;box-shadow:inset -1px 0 #0000001c;transition:transform .4s;overflow:auto;overflow-y:scroll}.netless-app-presentation-preview-active .netless-app-presentation-preview-mask{display:block}.netless-app-presentation-preview-active .netless-app-presentation-preview{transform:translate(0)}.netless-app-presentation-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:#0000;outline:none;border:7px solid rgba(0,0,0,0);border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-presentation-preview-page:hover,.netless-app-presentation-preview-page.netless-app-presentation-preview-page-active{border-color:#444e601a}.netless-app-presentation-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-presentation-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-presentation-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-presentation-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:#f9f9fce6;transition:opacity .4s}.netless-app-presentation-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:#0000;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-footer-btn:hover{background:#ededf0e6}@media (hover: none){.netless-app-presentation-footer-btn:hover{background:#0000!important}}.netless-app-presentation-footer-btn>svg{width:100%;height:100%}.netless-app-presentation-footer-btn>svg:nth-of-type(2){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-presentation-footer-btn.netless-app-presentation-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-presentation-footer-btn~.netless-app-presentation-footer-btn{margin-left:15px}.netless-app-presentation-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-presentation-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-presentation-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:#0000;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-presentation-page-number-input:hover,.netless-app-presentation-page-number-input:focus,.netless-app-presentation-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-presentation-readonly.netless-app-presentation-footer{display:none}.netless-app-presentation-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden;transition:opacity .2s}.netless-app-presentation-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.netless-app-presentation-image>img{max-width:100%;max-height:100%;object-fit:contain}.telebox-color-scheme-dark .netless-app-presentation-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-presentation-page-number-input:active,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:focus,.telebox-color-scheme-dark .netless-app-presentation-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-presentation-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-presentation-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-presentation-preview{background:#323232e6}.netless-app-presentation-scrollbar-container{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;z-index:101}.netless-app-presentation-scrollbar-container-x,.netless-app-presentation-scrollbar-container-y{position:absolute;pointer-events:none;display:flex;justify-content:center;box-sizing:border-box;padding:0}.netless-app-presentation-scrollbar-container-x{bottom:0;left:0;height:6px;width:100%;padding-right:6px}.netless-app-presentation-scrollbar-container-y{top:0;right:0;width:6px;height:100%;flex-direction:column;padding-bottom:6px}.netless-app-presentation-scrollbar-x,.netless-app-presentation-scrollbar-y{border-radius:2px;background-color:#1b1f4d4d;pointer-events:auto;cursor:default}.netless-app-presentation-scrollbar-x{height:6px}.netless-app-presentation-scrollbar-y{width:6px}";
1160
1160
 
1161
1161
  // src/store.ts
1162
1162
  function noop() {
@@ -1227,6 +1227,249 @@ var NetlessAppPresentation = (function (exports) {
1227
1227
  };
1228
1228
  }
1229
1229
 
1230
+ // src/scrollbar/Draggable.ts
1231
+ function makeDraggable(element, options) {
1232
+ let currentDragger = null;
1233
+ let originalMouseX = 0;
1234
+ let originalMouseY = 0;
1235
+ const { onDragEnd, onDrag, onDragStart, direction = "xy" } = options;
1236
+ const drag = (e, state) => {
1237
+ e.stopPropagation();
1238
+ if (!currentDragger)
1239
+ return;
1240
+ let transformedDragX = 0;
1241
+ let transformedDragY = 0;
1242
+ if (direction === "x") {
1243
+ transformedDragX = Math.round(e.pageX - originalMouseX);
1244
+ } else if (direction === "y") {
1245
+ transformedDragY = Math.round(e.pageY - originalMouseY);
1246
+ } else {
1247
+ transformedDragX = Math.round(e.pageX - originalMouseX);
1248
+ transformedDragY = Math.round(e.pageY - originalMouseY);
1249
+ }
1250
+ if (state === 3 /* END */) {
1251
+ onDragEnd == null ? void 0 : onDragEnd({ x: transformedDragX, y: transformedDragY });
1252
+ } else {
1253
+ onDrag == null ? void 0 : onDrag({ x: transformedDragX, y: transformedDragY });
1254
+ }
1255
+ };
1256
+ element.addEventListener("pointerdown", bindDrag);
1257
+ function bindDrag(e) {
1258
+ currentDragger = e.target;
1259
+ e.stopPropagation();
1260
+ if (currentDragger !== element) {
1261
+ return;
1262
+ }
1263
+ originalMouseX = e.pageX;
1264
+ originalMouseY = e.pageY;
1265
+ element.addEventListener("pointermove", drag);
1266
+ document.body.addEventListener("pointerup", stopDrag);
1267
+ document.body.addEventListener("pointercancel", stopDrag);
1268
+ element.setPointerCapture(e.pointerId);
1269
+ onDragStart == null ? void 0 : onDragStart();
1270
+ }
1271
+ function removeEventListener2() {
1272
+ currentDragger = null;
1273
+ element.removeEventListener("pointermove", drag);
1274
+ document.body.removeEventListener("pointerup", stopDrag);
1275
+ document.body.removeEventListener("pointercancel", stopDrag);
1276
+ }
1277
+ function stopDrag(e) {
1278
+ if (!currentDragger)
1279
+ return;
1280
+ e.stopPropagation();
1281
+ drag(e, 3 /* END */);
1282
+ removeEventListener2();
1283
+ }
1284
+ function destroy() {
1285
+ stop();
1286
+ element.removeEventListener("pointerdown", bindDrag);
1287
+ }
1288
+ function stop() {
1289
+ removeEventListener2();
1290
+ }
1291
+ return { destroy };
1292
+ }
1293
+
1294
+ // src/scrollbar/index.ts
1295
+ var Scrollbar = class {
1296
+ constructor(container, option, view) {
1297
+ this.namespace = "netless-app-presentation";
1298
+ this.scrollContainer = document.createElement("div");
1299
+ this.option = {
1300
+ getPageSize: () => {
1301
+ return {
1302
+ width: 0,
1303
+ height: 0
1304
+ };
1305
+ },
1306
+ getWritable: () => false,
1307
+ syncView: () => void 0
1308
+ };
1309
+ this.onCameraUpdated = () => {
1310
+ if (this.readonly)
1311
+ return;
1312
+ const { scale, centerX, centerY } = this.view.camera;
1313
+ const originScale = this.getOriginScale();
1314
+ const ratio = Math.round(originScale / scale * 1e3) / 1e3;
1315
+ const scrollX = Math.round(centerX * originScale);
1316
+ const scrollY = Math.round(centerY * originScale);
1317
+ if (this.scrollbarX) {
1318
+ this.scrollbarX.style.width = `${ratio * 100}%`;
1319
+ this.scrollbarX.style.display = ratio === 1 ? "none" : "block";
1320
+ this.scrollbarX.style.transform = `translateX(${scrollX}px)`;
1321
+ }
1322
+ if (this.scrollbarY) {
1323
+ this.scrollbarY.style.height = `${ratio * 100}%`;
1324
+ this.scrollbarY.style.display = ratio === 1 ? "none" : "block";
1325
+ this.scrollbarY.style.transform = `translateY(${scrollY}px)`;
1326
+ }
1327
+ };
1328
+ this.onDragStart = () => {
1329
+ const camera = this.view.camera;
1330
+ this.cameraCache = {
1331
+ centerX: camera.centerX,
1332
+ centerY: camera.centerY,
1333
+ scale: camera.scale
1334
+ };
1335
+ };
1336
+ this.onDragX = (transformedDrag) => {
1337
+ if (this.cameraCache) {
1338
+ const { x } = transformedDrag;
1339
+ const originScale = this.getOriginScale();
1340
+ const { minX, maxX } = this.getScrollXRange(this.cameraCache);
1341
+ const scrollX = Math.round(x / originScale);
1342
+ let centerX = scrollX + this.cameraCache.centerX;
1343
+ if (centerX < minX) {
1344
+ centerX = minX;
1345
+ } else if (centerX > maxX) {
1346
+ centerX = maxX;
1347
+ }
1348
+ this.view.moveCamera({
1349
+ centerX,
1350
+ animationMode: "immediately"
1351
+ });
1352
+ }
1353
+ };
1354
+ this.onDragY = (transformedDrag) => {
1355
+ if (this.cameraCache) {
1356
+ const { y } = transformedDrag;
1357
+ const originScale = this.getOriginScale();
1358
+ const { minY, maxY } = this.getScrollYRange(this.cameraCache);
1359
+ const scrollY = Math.round(y / originScale);
1360
+ let centerY = scrollY + this.cameraCache.centerY;
1361
+ if (centerY < minY) {
1362
+ centerY = minY;
1363
+ } else if (centerY > maxY) {
1364
+ centerY = maxY;
1365
+ }
1366
+ this.view.moveCamera({
1367
+ centerY,
1368
+ animationMode: "immediately"
1369
+ });
1370
+ }
1371
+ };
1372
+ this.onDragEnd = () => {
1373
+ this.cameraCache = void 0;
1374
+ this.option.syncView();
1375
+ };
1376
+ this.scrollContainer.className = this.c("scrollbar-container");
1377
+ this.container = container;
1378
+ this.option = option;
1379
+ this.readonly = option.readonly || false;
1380
+ this.view = view;
1381
+ this.init();
1382
+ }
1383
+ c(className) {
1384
+ return `${this.namespace}-${className}`;
1385
+ }
1386
+ getOriginScale() {
1387
+ const { size } = this.view;
1388
+ const { width, height } = this.option.getPageSize();
1389
+ return Math.min(size.height / height, size.width / width);
1390
+ }
1391
+ setReadonly(bol) {
1392
+ this.readonly = bol;
1393
+ if (this.readonly) {
1394
+ this.destroy();
1395
+ } else {
1396
+ this.init();
1397
+ }
1398
+ }
1399
+ getScrollXRange(camera) {
1400
+ const { width } = this.option.getPageSize();
1401
+ const originScale = this.getOriginScale();
1402
+ const scale = camera.scale;
1403
+ const ratio = Math.round(originScale / scale * 1e3) / 1e3;
1404
+ const scrollWidth = width * (1 - ratio);
1405
+ const minX = -scrollWidth / 2;
1406
+ const maxX = scrollWidth / 2;
1407
+ return { minX, maxX };
1408
+ }
1409
+ getScrollYRange(camera) {
1410
+ const { height } = this.option.getPageSize();
1411
+ const originScale = this.getOriginScale();
1412
+ const scale = camera.scale;
1413
+ const ratio = Math.round(originScale / scale * 1e3) / 1e3;
1414
+ const scrollHeight = height * (1 - ratio);
1415
+ const minY = -scrollHeight / 2;
1416
+ const maxY = scrollHeight / 2;
1417
+ return { minY, maxY };
1418
+ }
1419
+ init() {
1420
+ this.scrollbarX = document.createElement("div");
1421
+ this.scrollbarX.classList.add(this.c("scrollbar-x"));
1422
+ if (this.option.getWritable()) {
1423
+ this.draggableX = makeDraggable(this.scrollbarX, {
1424
+ direction: "x",
1425
+ onDrag: this.onDragX,
1426
+ onDragEnd: this.onDragEnd,
1427
+ onDragStart: this.onDragStart
1428
+ });
1429
+ }
1430
+ Object.assign(this.scrollbarX.style, {
1431
+ width: "100%",
1432
+ display: "none"
1433
+ });
1434
+ this.scrollbarContainerX = document.createElement("div");
1435
+ this.scrollbarContainerX.classList.add(this.c("scrollbar-container-x"));
1436
+ this.scrollbarContainerX.appendChild(this.scrollbarX);
1437
+ this.scrollbarY = document.createElement("div");
1438
+ this.scrollbarY.classList.add(this.c("scrollbar-y"));
1439
+ if (this.option.getWritable()) {
1440
+ this.draggableY = makeDraggable(this.scrollbarY, {
1441
+ direction: "y",
1442
+ onDrag: this.onDragY,
1443
+ onDragEnd: this.onDragEnd,
1444
+ onDragStart: this.onDragStart
1445
+ });
1446
+ }
1447
+ Object.assign(this.scrollbarY.style, {
1448
+ height: "100%",
1449
+ display: "none"
1450
+ });
1451
+ this.scrollbarContainerY = document.createElement("div");
1452
+ this.scrollbarContainerY.classList.add(this.c("scrollbar-container-y"));
1453
+ this.scrollbarContainerY.appendChild(this.scrollbarY);
1454
+ this.scrollContainer.append(this.scrollbarContainerX, this.scrollbarContainerY);
1455
+ this.container.appendChild(this.scrollContainer);
1456
+ this.view.callbacks.on("onCameraUpdated", this.onCameraUpdated);
1457
+ this.onCameraUpdated();
1458
+ }
1459
+ destroy() {
1460
+ var _a, _b, _c, _d;
1461
+ this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
1462
+ (_a = this.scrollbarX) == null ? void 0 : _a.remove();
1463
+ (_b = this.scrollbarY) == null ? void 0 : _b.remove();
1464
+ this.scrollbarX = void 0;
1465
+ this.scrollbarY = void 0;
1466
+ (_c = this.draggableX) == null ? void 0 : _c.destroy();
1467
+ (_d = this.draggableY) == null ? void 0 : _d.destroy();
1468
+ this.draggableX = void 0;
1469
+ this.draggableY = void 0;
1470
+ }
1471
+ };
1472
+
1230
1473
  // src/app-presentation.ts
1231
1474
  var emptySceneName = "$$empty$$";
1232
1475
  var ppt2page = (ppt, name) => ppt ? { width: ppt.width, height: ppt.height, src: ppt.src, thumbnail: ppt.previewURL, name } : null;
@@ -1418,21 +1661,27 @@ var NetlessAppPresentation = (function (exports) {
1418
1661
  }
1419
1662
  };
1420
1663
  const syncView = () => {
1421
- if (throttleSyncView > 0)
1422
- return;
1423
- const { width, height } = app.page() || {};
1424
- if (width && height && context.getIsWritable()) {
1425
- const { camera, size } = view;
1426
- const fixedW = Math.min(size.width, size.height * width / height);
1427
- const fixedH = Math.min(size.height, size.width * height / width);
1428
- const w = fixedW / camera.scale;
1429
- const h = fixedH / camera.scale;
1430
- const x = camera.centerX - w / 2;
1431
- const y = camera.centerY - h / 2;
1432
- throttleSyncView = setTimeout(() => {
1664
+ if (context.getIsWritable()) {
1665
+ if (options.debounceSync) {
1666
+ clearTimeout(throttleSyncView);
1433
1667
  throttleSyncView = 0;
1434
- view$$.setState({ uid: me, originX: x, originY: y, width: w, height: h });
1435
- }, 50);
1668
+ }
1669
+ if (throttleSyncView > 0)
1670
+ return;
1671
+ const { width, height } = app.page() || {};
1672
+ if (width && height) {
1673
+ throttleSyncView = setTimeout(() => {
1674
+ throttleSyncView = 0;
1675
+ const { camera, size } = view;
1676
+ const fixedW = Math.min(size.width, size.height * width / height);
1677
+ const fixedH = Math.min(size.height, size.width * height / width);
1678
+ const w = fixedW / camera.scale;
1679
+ const h = fixedH / camera.scale;
1680
+ const x = camera.centerX - w / 2;
1681
+ const y = camera.centerY - h / 2;
1682
+ view$$.setState({ uid: me, originX: x, originY: y, width: w, height: h });
1683
+ }, 50);
1684
+ }
1436
1685
  }
1437
1686
  };
1438
1687
  dispose2.add(() => {
@@ -1454,7 +1703,7 @@ var NetlessAppPresentation = (function (exports) {
1454
1703
  dispose2.add(view$$.addStateChangedListener(() => syncViewFromRemote(false, true)));
1455
1704
  const box = context.getBox();
1456
1705
  const app = dispose2.add(createPresentation(box, pages, jumpPage, pageIndex$, options.thumbnail));
1457
- app.contentDOM.dataset.appPresentationVersion = "0.1.8";
1706
+ app.contentDOM.dataset.appPresentationVersion = "0.1.9-beta.1";
1458
1707
  app.scaleDocsToFit = scaleDocsToFit;
1459
1708
  app.log = log;
1460
1709
  if (options.justDocsViewReadonly) {
@@ -1489,6 +1738,20 @@ var NetlessAppPresentation = (function (exports) {
1489
1738
  dispose2.add(context.emitter.on("writableChange", (isWritable) => {
1490
1739
  app.setReadonly(!isWritable);
1491
1740
  }));
1741
+ let scrollbar;
1742
+ if (options.useScrollbar) {
1743
+ dispose2.make(() => {
1744
+ scrollbar = new Scrollbar(app.contentDOM, {
1745
+ getPageSize: () => {
1746
+ const { width, height } = app.page() || {};
1747
+ return { width: width || 0, height: height || 0 };
1748
+ },
1749
+ getWritable: () => context.getIsWritable(),
1750
+ syncView: () => syncView()
1751
+ }, view);
1752
+ return () => scrollbar == null ? void 0 : scrollbar.destroy();
1753
+ });
1754
+ }
1492
1755
  context.emitter.on("destroy", () => dispose2());
1493
1756
  const reportProgress = (progress, result) => {
1494
1757
  window.postMessage({ type: "@netless/_result_save_pdf_", appId: context.appId, progress, result }, "*");
@@ -1606,7 +1869,13 @@ var NetlessAppPresentation = (function (exports) {
1606
1869
  const setDocsViewReadonly = (bol) => {
1607
1870
  app.setDocsViewReadonly(bol);
1608
1871
  };
1609
- const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly };
1872
+ const setReadonly = (bol) => {
1873
+ app.setReadonly(bol);
1874
+ if (scrollbar) {
1875
+ scrollbar.setReadonly(bol);
1876
+ }
1877
+ };
1878
+ const controller = { app, view, context, jumpPage, prevPage, nextPage, pageState, toPdf, log, setDocsViewReadonly, setReadonly };
1610
1879
  dispose2.add(listen(window, "message", (ev) => {
1611
1880
  if (ev.data === "@netless/_presentation_") {
1612
1881
  if (typeof window !== "undefined")
@@ -1662,7 +1931,7 @@ var NetlessAppPresentation = (function (exports) {
1662
1931
  };
1663
1932
 
1664
1933
  // src/index.ts
1665
- var version = "0.1.8";
1934
+ var version = "0.1.9-beta.1";
1666
1935
 
1667
1936
  exports.NetlessAppPresentation = NetlessAppPresentation;
1668
1937
  exports.Presentation = Presentation;