@netless/forge-slide 0.1.1-alpha.6 → 0.1.1-alpha.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.js CHANGED
@@ -66595,6 +66595,8 @@ var SlideForge = class extends import_eventemitter314.default {
66595
66595
  view;
66596
66596
  permissions;
66597
66597
  footView;
66598
+ sideBarView;
66599
+ whiteboardView;
66598
66600
  /**
66599
66601
  * 当前页面索引, 从 0 开始
66600
66602
  */
@@ -66878,6 +66880,7 @@ var FooterView = class extends import_eventemitter316.default {
66878
66880
  var import_eventemitter317 = __toESM(require("eventemitter3"));
66879
66881
  var SideBarView = class extends import_eventemitter317.default {
66880
66882
  root = document.createElement("div");
66883
+ isShow = false;
66881
66884
  itemList = [];
66882
66885
  constructor() {
66883
66886
  super();
@@ -66891,13 +66894,14 @@ var SideBarView = class extends import_eventemitter317.default {
66891
66894
  this.root.style.zIndex = "5";
66892
66895
  this.root.style.transition = "left 0.3s ease-in-out";
66893
66896
  this.root.style.overflow = "auto";
66894
- this.root.style.border = "1px solid #ccc";
66895
- this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
66896
66897
  this.root.style.display = "flex";
66897
66898
  this.root.style.flexDirection = "column";
66898
66899
  this.root.style.justifyContent = "flex-start";
66899
66900
  this.root.style.alignItems = "center";
66900
66901
  }
66902
+ get isShowSideBar() {
66903
+ return this.isShow;
66904
+ }
66901
66905
  onMouseOver = (itemContainer) => {
66902
66906
  itemContainer.style.borderColor = "#ccc";
66903
66907
  };
@@ -66915,7 +66919,6 @@ var SideBarView = class extends import_eventemitter317.default {
66915
66919
  itemContainer.style.display = "flex";
66916
66920
  itemContainer.style.justifyContent = "center";
66917
66921
  itemContainer.style.alignItems = "flex-start";
66918
- itemContainer.style.border = "7px solid transparent";
66919
66922
  itemContainer.style.position = "relative";
66920
66923
  itemContainer.style.borderRadius = "4px";
66921
66924
  itemContainer.style.transition = "border-color .3s";
@@ -66940,6 +66943,24 @@ var SideBarView = class extends import_eventemitter317.default {
66940
66943
  this.root.appendChild(itemContainer);
66941
66944
  }
66942
66945
  }
66946
+ hidden() {
66947
+ if (!this.root) {
66948
+ return;
66949
+ }
66950
+ this.root.style.left = "-240px";
66951
+ this.root.style.border = "none";
66952
+ this.root.style.boxShadow = "none";
66953
+ this.isShow = false;
66954
+ }
66955
+ show() {
66956
+ if (!this.root) {
66957
+ return;
66958
+ }
66959
+ this.root.style.left = "0";
66960
+ this.root.style.border = "1px solid #ccc";
66961
+ this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
66962
+ this.isShow = true;
66963
+ }
66943
66964
  dispose() {
66944
66965
  this.itemList.forEach((item) => {
66945
66966
  item.removeEventListener("mouseover", () => this.onMouseOver(item));
@@ -67072,103 +67093,116 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
67072
67093
  if (!this.permissions.hasPermission(2 /* changePage */)) {
67073
67094
  return;
67074
67095
  }
67075
- if (this.sideBar.root.style.left === "0px") {
67076
- this.sideBar.root.style.left = "-240px";
67096
+ if (this.sideBar.isShowSideBar) {
67097
+ this.sideBar.hidden();
67077
67098
  } else {
67078
- this.sideBar.root.style.left = "0px";
67099
+ this.sideBar.show();
67079
67100
  }
67080
67101
  });
67081
67102
  this.rootView.appendChild(this.contentContainer);
67082
67103
  this.emitter.on("renderStart", (pageIndex) => {
67083
67104
  this.footer.prevPageState(pageIndex !== 0);
67084
67105
  });
67085
- const that = this;
67086
- Object.defineProperty(this.emitter, "view", {
67087
- get() {
67088
- return that.rootView;
67089
- }
67090
- });
67091
- Object.defineProperty(this.emitter, "permissions", {
67092
- get() {
67093
- return that.permissions;
67094
- }
67095
- });
67096
- Object.defineProperty(this.emitter, "footView", {
67097
- get() {
67098
- return that.footer.root;
67099
- }
67100
- });
67101
- Object.defineProperty(this.emitter, "pageIndex", {
67102
- get() {
67103
- return that.currentSlideIndex;
67104
- }
67105
- });
67106
- Object.defineProperty(this.emitter, "pageCount", {
67107
- get() {
67108
- return that.slideCount;
67109
- }
67110
- });
67111
- Object.defineProperty(this.emitter, "goto", {
67112
- writable: false,
67113
- enumerable: false,
67114
- value: (pageIndex) => {
67115
- this.sideBar.emit("pageChange", pageIndex);
67116
- }
67117
- });
67118
- Object.defineProperty(this.emitter, "nextStep", {
67119
- writable: false,
67120
- enumerable: false,
67121
- value: () => {
67122
- this.footer.emit("nextStep");
67123
- }
67124
- });
67125
- Object.defineProperty(this.emitter, "prevStep", {
67126
- writable: false,
67127
- enumerable: false,
67128
- value: () => {
67129
- this.footer.emit("prevStep");
67130
- }
67131
- });
67132
- Object.defineProperty(this.emitter, "nextPage", {
67133
- writable: false,
67106
+ const propertyConfig = {
67107
+ configurable: false,
67134
67108
  enumerable: false,
67135
- value: () => {
67136
- this.footer.emit("nextPage");
67137
- }
67138
- });
67139
- Object.defineProperty(this.emitter, "prevPage", {
67140
- writable: false,
67141
- enumerable: false,
67142
- value: () => {
67143
- this.footer.emit("prevPage");
67144
- }
67145
- });
67146
- Object.defineProperty(this.emitter, "sideBarToggle", {
67147
- writable: false,
67148
- enumerable: false,
67149
- value: () => {
67150
- this.footer.emit("sideBarToggle");
67151
- }
67152
- });
67153
- Object.defineProperty(this.emitter, "imgContent", {
67154
- writable: false,
67155
- enumerable: false,
67156
- value: (pageIndex) => {
67157
- return this.getImageContent(pageIndex);
67158
- }
67159
- });
67160
- Object.defineProperty(this.emitter, "imgUrl", {
67161
- writable: false,
67162
- enumerable: false,
67163
- value: (pageIndex) => {
67164
- return this.getImageUrl(pageIndex);
67165
- }
67166
- });
67167
- Object.defineProperty(this.emitter, "imgSize", {
67168
- writable: false,
67169
- enumerable: false,
67170
- value: (pageIndex) => {
67171
- return this.getImageSize(pageIndex);
67109
+ writable: false
67110
+ };
67111
+ const that = this;
67112
+ Object.defineProperties(this.emitter, {
67113
+ view: {
67114
+ get() {
67115
+ return that.rootView;
67116
+ }
67117
+ },
67118
+ permissions: {
67119
+ get() {
67120
+ return that.permissions;
67121
+ }
67122
+ },
67123
+ footView: {
67124
+ get() {
67125
+ return that.footer.root;
67126
+ }
67127
+ },
67128
+ sidebarView: {
67129
+ get() {
67130
+ return that.sideBar.root;
67131
+ }
67132
+ },
67133
+ whiteboardView: {
67134
+ get() {
67135
+ return that.whiteboard.view;
67136
+ }
67137
+ },
67138
+ slideView: {
67139
+ get() {
67140
+ return that.slideContainer;
67141
+ }
67142
+ },
67143
+ pageIndex: {
67144
+ get() {
67145
+ return that.currentSlideIndex;
67146
+ }
67147
+ },
67148
+ pageCount: {
67149
+ get() {
67150
+ return that.slideCount;
67151
+ }
67152
+ },
67153
+ goto: {
67154
+ ...propertyConfig,
67155
+ value: (pageIndex) => {
67156
+ this.sideBar.emit("pageChange", pageIndex);
67157
+ }
67158
+ },
67159
+ nextStep: {
67160
+ ...propertyConfig,
67161
+ value: () => {
67162
+ this.footer.emit("nextStep");
67163
+ }
67164
+ },
67165
+ prevStep: {
67166
+ ...propertyConfig,
67167
+ value: () => {
67168
+ this.footer.emit("prevStep");
67169
+ }
67170
+ },
67171
+ nextPage: {
67172
+ ...propertyConfig,
67173
+ value: () => {
67174
+ this.footer.emit("nextPage");
67175
+ }
67176
+ },
67177
+ prevPage: {
67178
+ ...propertyConfig,
67179
+ value: () => {
67180
+ this.footer.emit("prevPage");
67181
+ }
67182
+ },
67183
+ sideBarToggle: {
67184
+ ...propertyConfig,
67185
+ value: () => {
67186
+ this.footer.emit("sideBarToggle");
67187
+ }
67188
+ },
67189
+ imgContent: {
67190
+ ...propertyConfig,
67191
+ value: (pageIndex) => {
67192
+ return this.getImageContent(pageIndex);
67193
+ }
67194
+ },
67195
+ imgUrl: {
67196
+ ...propertyConfig,
67197
+ value: (pageIndex) => {
67198
+ return this.getImageUrl(pageIndex);
67199
+ }
67200
+ },
67201
+ imgSize: {
67202
+ ...propertyConfig,
67203
+ value: (pageIndex) => {
67204
+ return this.getImageSize(pageIndex);
67205
+ }
67172
67206
  }
67173
67207
  });
67174
67208
  }
@@ -67258,6 +67292,23 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
67258
67292
  }
67259
67293
  }
67260
67294
  };
67295
+ keyBoardEvents = (event) => {
67296
+ if (event.key === "ArrowLeft") {
67297
+ this.footer.emit("prevStep");
67298
+ } else if (event.key === "ArrowRight") {
67299
+ this.footer.emit("nextStep");
67300
+ } else if (event.key === "ArrowUp") {
67301
+ this.footer.emit("prevPage");
67302
+ } else if (event.key === "ArrowDown") {
67303
+ this.footer.emit("nextPage");
67304
+ }
67305
+ };
67306
+ bindKeyBoardEvent() {
67307
+ document.addEventListener("keydown", this.keyBoardEvents);
67308
+ }
67309
+ unbindKeyBoarEvent() {
67310
+ document.removeEventListener("keydown", this.keyBoardEvents);
67311
+ }
67261
67312
  async initialize(option) {
67262
67313
  this.prefix = option.prefix;
67263
67314
  this.taskId = option.taskId;
@@ -67313,30 +67364,34 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
67313
67364
  });
67314
67365
  this.slide.setResource(option.taskId, option.prefix);
67315
67366
  this.sideBar.initialize(json.slideCount, option);
67316
- this.slide.on("syncDispatch", (event) => {
67367
+ this.slide.on(import_slide.SLIDE_EVENTS.syncDispatch, (event) => {
67317
67368
  this.getMap(this.name).set("syncSlide", {
67318
67369
  slideState: this.slide.slideState,
67319
67370
  dispatch: event
67320
67371
  });
67321
67372
  });
67322
- this.slide.on("mainSeqStepStart", (animateIndex) => {
67373
+ this.slide.on(import_slide.SLIDE_EVENTS.mainSeqStepStart, (animateIndex) => {
67323
67374
  this.emitter.emit("mainSeqStepStart", animateIndex);
67324
67375
  });
67325
- this.slide.on("mainSeqStepEnd", (animateIndex) => {
67376
+ this.slide.on(import_slide.SLIDE_EVENTS.mainSeqStepEnd, (animateIndex) => {
67326
67377
  this.emitter.emit("mainSeqStepEnd", animateIndex);
67327
67378
  });
67328
- this.slide.on("renderStart", (slideIndex) => {
67379
+ this.slide.on(import_slide.SLIDE_EVENTS.animateStart, () => {
67380
+ this.sideBar.hidden();
67381
+ });
67382
+ this.slide.on(import_slide.SLIDE_EVENTS.renderStart, (slideIndex) => {
67329
67383
  this.whiteboardApp.emitter.view.style.opacity = "0";
67330
67384
  this.whiteboardApp.emitter.addPage(`${slideIndex}`);
67331
67385
  this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
67332
67386
  this.emitter.emit("renderStart", slideIndex);
67387
+ this.sideBar.hidden();
67333
67388
  });
67334
- this.slide.on("renderEnd", (slideIndex) => {
67389
+ this.slide.on(import_slide.SLIDE_EVENTS.renderEnd, (slideIndex) => {
67335
67390
  this.currentSlideIndex = slideIndex;
67336
67391
  this.whiteboardApp.emitter.view.style.opacity = "1";
67337
67392
  this.emitter.emit("renderEnd", slideIndex);
67338
67393
  });
67339
- this.slide.on("stateChange", (state) => {
67394
+ this.slide.on(import_slide.SLIDE_EVENTS.stateChange, (state) => {
67340
67395
  this.getMap(this.name).set("slideState", state);
67341
67396
  });
67342
67397
  this.getMap(this.name).observe(this.onSlideEventHandler);
@@ -67362,8 +67417,30 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
67362
67417
  }
67363
67418
  }
67364
67419
  });
67365
- this.permissions.addPermission(7 /* all */);
67366
67420
  this.whiteboardApp.disableViewModel();
67421
+ if (this.window) {
67422
+ let prevStatus = "normal";
67423
+ this.window.on("statusChange", (status) => {
67424
+ if (prevStatus === "minimized") {
67425
+ this.bindKeyBoardEvent();
67426
+ prevStatus = status;
67427
+ return;
67428
+ }
67429
+ prevStatus = status;
67430
+ if (status === "normal") {
67431
+ this.bindKeyBoardEvent();
67432
+ } else if (status === "minimized") {
67433
+ this.unbindKeyBoarEvent();
67434
+ }
67435
+ });
67436
+ this.window.on("focusedChange", (status) => {
67437
+ if (status) {
67438
+ this.bindKeyBoardEvent();
67439
+ } else {
67440
+ this.unbindKeyBoarEvent();
67441
+ }
67442
+ });
67443
+ }
67367
67444
  window.__forge_slide = this;
67368
67445
  window.slidePermissions = this.permissions;
67369
67446
  return Promise.resolve(void 0);
@@ -67377,7 +67454,6 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
67377
67454
  this.slide.destroy();
67378
67455
  this.sideBar.dispose();
67379
67456
  this.getMap(this.name).unobserve(this.onSlideEventHandler);
67380
- return Promise.resolve(void 0);
67381
67457
  }
67382
67458
  };
67383
67459
  /*! Bundled license information: