@netless/forge-imagery-doc 0.1.2 → 0.1.3-appha.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/changelog.md +4 -0
- package/dist/Container.d.ts +1 -1
- package/dist/Container.d.ts.map +1 -1
- package/dist/ContinuousContainer.d.ts +5 -5
- package/dist/ContinuousContainer.d.ts.map +1 -1
- package/dist/FooterView.d.ts +7 -1
- package/dist/FooterView.d.ts.map +1 -1
- package/dist/ImageryDoc.d.ts +22 -18
- package/dist/ImageryDoc.d.ts.map +1 -1
- package/dist/ImageryDocApplication.d.ts +4 -4
- package/dist/ImageryDocApplication.d.ts.map +1 -1
- package/dist/ImageryDocPermissions.d.ts +7 -46
- package/dist/ImageryDocPermissions.d.ts.map +1 -1
- package/dist/InfinityScroll.d.ts +1 -1
- package/dist/InfinityScroll.d.ts.map +1 -1
- package/dist/LazyImage.d.ts.map +1 -1
- package/dist/SingleContainer.d.ts +6 -6
- package/dist/SingleContainer.d.ts.map +1 -1
- package/dist/imagery-doc.esm.js +163 -228
- package/dist/imagery-doc.esm.js.map +3 -3
- package/dist/imagery-doc.js +165 -230
- package/dist/imagery-doc.js.map +3 -3
- package/dist/index.d.ts +4 -4
- package/package.json +5 -4
- package/src/Container.ts +6 -6
- package/src/ContinuousContainer.ts +134 -135
- package/src/FooterView.ts +157 -125
- package/src/ImageryDoc.ts +22 -17
- package/src/ImageryDocApplication.ts +208 -198
- package/src/ImageryDocPermissions.ts +12 -118
- package/src/InfinityScroll.ts +43 -42
- package/src/LazyImage.ts +55 -55
- package/src/SingleContainer.ts +237 -226
- package/src/icons.ts +3 -3
- package/src/index.ts +4 -4
package/dist/imagery-doc.js
CHANGED
|
@@ -70,7 +70,7 @@ var ImageryDoc = class extends import_eventemitter3.default {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
// src/ImageryDocApplication.ts
|
|
73
|
-
var
|
|
73
|
+
var import_forge_room4 = require("@netless/forge-room");
|
|
74
74
|
var import_forge_whiteboard = require("@netless/forge-whiteboard");
|
|
75
75
|
|
|
76
76
|
// src/LazyImage.ts
|
|
@@ -124,7 +124,7 @@ var LazyImage = class {
|
|
|
124
124
|
const blob = await response.blob();
|
|
125
125
|
return new Promise((resolve, reject) => {
|
|
126
126
|
const reader = new FileReader();
|
|
127
|
-
reader.onload = (
|
|
127
|
+
reader.onload = (_e) => {
|
|
128
128
|
import_forge_room.kvStore.setItem(this.src, reader.result);
|
|
129
129
|
resolve(reader.result);
|
|
130
130
|
};
|
|
@@ -149,24 +149,7 @@ var LazyImage = class {
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
// src/ImageryDocPermissions.ts
|
|
152
|
-
var
|
|
153
|
-
function _defineProperty3(e, r, t) {
|
|
154
|
-
return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
155
|
-
}
|
|
156
|
-
function _toPropertyKey3(t) {
|
|
157
|
-
var i = _toPrimitive3(t, "string");
|
|
158
|
-
return "symbol" == typeof i ? i : i + "";
|
|
159
|
-
}
|
|
160
|
-
function _toPrimitive3(t, r) {
|
|
161
|
-
if ("object" != typeof t || !t) return t;
|
|
162
|
-
var e = t[Symbol.toPrimitive];
|
|
163
|
-
if (void 0 !== e) {
|
|
164
|
-
var i = e.call(t, r || "default");
|
|
165
|
-
if ("object" != typeof i) return i;
|
|
166
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
167
|
-
}
|
|
168
|
-
return ("string" === r ? String : Number)(t);
|
|
169
|
-
}
|
|
152
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
170
153
|
var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
|
|
171
154
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["none"] = 0] = "none";
|
|
172
155
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["switchPage"] = 1] = "switchPage";
|
|
@@ -175,104 +158,15 @@ var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
|
|
|
175
158
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["all"] = ImageryDocPermissionFlag2.switchPage | ImageryDocPermissionFlag2.camera | ImageryDocPermissionFlag2.sideBar] = "all";
|
|
176
159
|
return ImageryDocPermissionFlag2;
|
|
177
160
|
}({});
|
|
178
|
-
var ImageryDocPermissions = class extends
|
|
179
|
-
constructor(userManager, requestUserMap) {
|
|
180
|
-
super();
|
|
181
|
-
_defineProperty3(this, "requestUserMap", void 0);
|
|
182
|
-
_defineProperty3(this, "userManager", void 0);
|
|
183
|
-
_defineProperty3(this, "observers", /* @__PURE__ */ new Map());
|
|
184
|
-
_defineProperty3(this, "handleUserLeave", (user) => {
|
|
185
|
-
const cb = this.observers.get(user.id);
|
|
186
|
-
if (cb) {
|
|
187
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
_defineProperty3(this, "handleUserJoin", (user) => {
|
|
191
|
-
this.addObserve(user.id);
|
|
192
|
-
});
|
|
193
|
-
this.userManager = userManager;
|
|
194
|
-
this.requestUserMap = requestUserMap;
|
|
195
|
-
this.createModel(this.userManager.selfId);
|
|
196
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
197
|
-
this.addObserve(userId);
|
|
198
|
-
});
|
|
199
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
200
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
201
|
-
}
|
|
202
|
-
addObserve(userId) {
|
|
203
|
-
const observer = (evt) => {
|
|
204
|
-
this.handleUserPermissionChange(userId, evt);
|
|
205
|
-
};
|
|
206
|
-
this.observers.set(userId, observer);
|
|
207
|
-
this.requestUserMap(userId).observe(observer);
|
|
208
|
-
}
|
|
209
|
-
createModel(userId) {
|
|
210
|
-
const userMap = this.requestUserMap(userId);
|
|
211
|
-
if (!userMap.has("permission")) {
|
|
212
|
-
userMap.set("permission", 0);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
handleUserPermissionChange(userId, evt) {
|
|
216
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
217
|
-
if (key === "permission") {
|
|
218
|
-
if (value.action === "add" || value.action === "update") {
|
|
219
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
220
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
161
|
+
var ImageryDocPermissions = class extends import_forge_room2.AbstractApplicationPermissions {
|
|
225
162
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
163
|
+
* 解析权限列表组合
|
|
164
|
+
* @param {number} value - 权限数字值
|
|
165
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
166
|
+
*/
|
|
230
167
|
resolveFlags(value) {
|
|
231
168
|
return [ImageryDocPermissionFlag.switchPage, ImageryDocPermissionFlag.sideBar, ImageryDocPermissionFlag.camera].filter((v) => (v & value) !== 0);
|
|
232
169
|
}
|
|
233
|
-
/**
|
|
234
|
-
* 获取权限列表组合对应的数值
|
|
235
|
-
* @param { string } userId 不传表示获取自己
|
|
236
|
-
*/
|
|
237
|
-
getPermissionValue(userId) {
|
|
238
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* 获取权限列表
|
|
242
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
243
|
-
*/
|
|
244
|
-
getPermissionFlags(userId) {
|
|
245
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
246
|
-
return this.resolveFlags(value);
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* 返回对应 userId 是否有相应权限
|
|
250
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
251
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
252
|
-
*/
|
|
253
|
-
hasPermission(flag, userId) {
|
|
254
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* 添加权限
|
|
258
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
259
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
260
|
-
*/
|
|
261
|
-
addPermission(flag, userId) {
|
|
262
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
263
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
264
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* 移除权限
|
|
268
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
269
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
270
|
-
*/
|
|
271
|
-
removePermission(flag, userId) {
|
|
272
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
273
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
274
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
275
|
-
}
|
|
276
170
|
};
|
|
277
171
|
|
|
278
172
|
// src/icons.ts
|
|
@@ -286,14 +180,14 @@ var Icons = {
|
|
|
286
180
|
};
|
|
287
181
|
|
|
288
182
|
// src/FooterView.ts
|
|
289
|
-
function
|
|
290
|
-
return (r =
|
|
183
|
+
function _defineProperty3(e, r, t) {
|
|
184
|
+
return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
291
185
|
}
|
|
292
|
-
function
|
|
293
|
-
var i =
|
|
186
|
+
function _toPropertyKey3(t) {
|
|
187
|
+
var i = _toPrimitive3(t, "string");
|
|
294
188
|
return "symbol" == typeof i ? i : i + "";
|
|
295
189
|
}
|
|
296
|
-
function
|
|
190
|
+
function _toPrimitive3(t, r) {
|
|
297
191
|
if ("object" != typeof t || !t) return t;
|
|
298
192
|
var e = t[Symbol.toPrimitive];
|
|
299
193
|
if (void 0 !== e) {
|
|
@@ -306,14 +200,23 @@ function _toPrimitive4(t, r) {
|
|
|
306
200
|
var EM_COLOR = "#8C8C8C";
|
|
307
201
|
var FooterView = class {
|
|
308
202
|
constructor(imageryDoc) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
203
|
+
_defineProperty3(this, "root", void 0);
|
|
204
|
+
_defineProperty3(this, "prevPage", void 0);
|
|
205
|
+
_defineProperty3(this, "nextPage", void 0);
|
|
206
|
+
_defineProperty3(this, "sideBarToggle", void 0);
|
|
207
|
+
_defineProperty3(this, "sideBarContainer", document.createElement("div"));
|
|
208
|
+
_defineProperty3(this, "navigator", document.createElement("div"));
|
|
209
|
+
_defineProperty3(this, "navigatorIndex", document.createElement("span"));
|
|
210
|
+
_defineProperty3(this, "navigatorTotal", document.createElement("span"));
|
|
211
|
+
_defineProperty3(this, "isSlideBarVisible", false);
|
|
212
|
+
_defineProperty3(this, "imageryDoc", void 0);
|
|
213
|
+
_defineProperty3(this, "updateIndex", () => {
|
|
214
|
+
this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
|
|
215
|
+
});
|
|
216
|
+
_defineProperty3(this, "updateTotal", () => {
|
|
217
|
+
this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
|
|
218
|
+
});
|
|
219
|
+
_defineProperty3(this, "handleSideBarClick", (evt) => {
|
|
317
220
|
const target = evt.target;
|
|
318
221
|
const targetIndex = target.getAttribute("data-doc-index");
|
|
319
222
|
if (targetIndex) {
|
|
@@ -348,6 +251,9 @@ var FooterView = class {
|
|
|
348
251
|
this.root.appendChild(this.prevPage);
|
|
349
252
|
this.root.appendChild(this.nextPage);
|
|
350
253
|
this.root.appendChild(this.createSpacer());
|
|
254
|
+
this.createNavigator();
|
|
255
|
+
this.imageryDoc.addListener("renderEnd", this.updateIndex);
|
|
256
|
+
this.imageryDoc.addListener("ready", this.updateTotal);
|
|
351
257
|
}
|
|
352
258
|
prevPageState(enable) {
|
|
353
259
|
if (enable) {
|
|
@@ -390,6 +296,20 @@ var FooterView = class {
|
|
|
390
296
|
});
|
|
391
297
|
return icon;
|
|
392
298
|
}
|
|
299
|
+
createNavigator() {
|
|
300
|
+
this.navigator.style.height = "24px";
|
|
301
|
+
this.navigator.style.padding = "12px";
|
|
302
|
+
this.navigator.style.display = "flex";
|
|
303
|
+
this.navigator.style.alignItems = "center";
|
|
304
|
+
this.navigator.style.justifyContent = "center";
|
|
305
|
+
this.navigator.style.fontSize = "12px";
|
|
306
|
+
this.navigator.style.color = "#585858";
|
|
307
|
+
this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
|
|
308
|
+
this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
|
|
309
|
+
this.navigator.appendChild(this.navigatorIndex);
|
|
310
|
+
this.navigator.appendChild(this.navigatorTotal);
|
|
311
|
+
this.root.appendChild(this.navigator);
|
|
312
|
+
}
|
|
393
313
|
createSideBar() {
|
|
394
314
|
if (this.imageryDoc.pageCount === 0) {
|
|
395
315
|
return;
|
|
@@ -401,7 +321,7 @@ var FooterView = class {
|
|
|
401
321
|
this.sideBarContainer.style.maxWidth = "180px";
|
|
402
322
|
this.sideBarContainer.style.height = "calc(100% - 24px)";
|
|
403
323
|
this.sideBarContainer.style.position = "absolute";
|
|
404
|
-
this.sideBarContainer.style.bottom = "
|
|
324
|
+
this.sideBarContainer.style.bottom = "25px";
|
|
405
325
|
this.sideBarContainer.style.left = "0";
|
|
406
326
|
this.sideBarContainer.style.fontSize = "0px";
|
|
407
327
|
this.sideBarContainer.style.overflow = "auto";
|
|
@@ -416,7 +336,7 @@ var FooterView = class {
|
|
|
416
336
|
reviewIndex.textContent = `${i + 1}`;
|
|
417
337
|
const reviewImg = document.createElement("img");
|
|
418
338
|
reviewImg.setAttribute("data-doc-index", `${i}`);
|
|
419
|
-
reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #
|
|
339
|
+
reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #f9f9fc";
|
|
420
340
|
this.imageryDoc.imgContent(i).then((base64Data) => {
|
|
421
341
|
reviewImg.src = base64Data;
|
|
422
342
|
});
|
|
@@ -429,15 +349,15 @@ var FooterView = class {
|
|
|
429
349
|
};
|
|
430
350
|
|
|
431
351
|
// src/InfinityScroll.ts
|
|
432
|
-
var
|
|
433
|
-
function
|
|
434
|
-
return (r =
|
|
352
|
+
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
353
|
+
function _defineProperty4(e, r, t) {
|
|
354
|
+
return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
435
355
|
}
|
|
436
|
-
function
|
|
437
|
-
var i =
|
|
356
|
+
function _toPropertyKey4(t) {
|
|
357
|
+
var i = _toPrimitive4(t, "string");
|
|
438
358
|
return "symbol" == typeof i ? i : i + "";
|
|
439
359
|
}
|
|
440
|
-
function
|
|
360
|
+
function _toPrimitive4(t, r) {
|
|
441
361
|
if ("object" != typeof t || !t) return t;
|
|
442
362
|
var e = t[Symbol.toPrimitive];
|
|
443
363
|
if (void 0 !== e) {
|
|
@@ -447,16 +367,16 @@ function _toPrimitive5(t, r) {
|
|
|
447
367
|
}
|
|
448
368
|
return ("string" === r ? String : Number)(t);
|
|
449
369
|
}
|
|
450
|
-
var InfinityScroll = class extends
|
|
370
|
+
var InfinityScroll = class extends import_eventemitter32.default {
|
|
451
371
|
constructor(view) {
|
|
452
372
|
super();
|
|
453
|
-
|
|
454
|
-
|
|
373
|
+
_defineProperty4(this, "view", void 0);
|
|
374
|
+
_defineProperty4(this, "lastDelta", {
|
|
455
375
|
x: 0,
|
|
456
376
|
y: 0
|
|
457
377
|
});
|
|
458
|
-
|
|
459
|
-
|
|
378
|
+
_defineProperty4(this, "lastTriggerTime", 0);
|
|
379
|
+
_defineProperty4(this, "handleWheel", (evt) => {
|
|
460
380
|
evt.preventDefault();
|
|
461
381
|
evt.stopImmediatePropagation();
|
|
462
382
|
evt.stopPropagation();
|
|
@@ -496,6 +416,7 @@ var InfinityScroll = class extends import_eventemitter33.default {
|
|
|
496
416
|
}
|
|
497
417
|
dispose() {
|
|
498
418
|
this.view.removeEventListener("wheel", this.handleWheel);
|
|
419
|
+
this.removeAllListeners();
|
|
499
420
|
}
|
|
500
421
|
};
|
|
501
422
|
|
|
@@ -508,14 +429,14 @@ var ContainerKeys = {
|
|
|
508
429
|
};
|
|
509
430
|
|
|
510
431
|
// src/ContinuousContainer.ts
|
|
511
|
-
function
|
|
512
|
-
return (r =
|
|
432
|
+
function _defineProperty5(e, r, t) {
|
|
433
|
+
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
513
434
|
}
|
|
514
|
-
function
|
|
515
|
-
var i =
|
|
435
|
+
function _toPropertyKey5(t) {
|
|
436
|
+
var i = _toPrimitive5(t, "string");
|
|
516
437
|
return "symbol" == typeof i ? i : i + "";
|
|
517
438
|
}
|
|
518
|
-
function
|
|
439
|
+
function _toPrimitive5(t, r) {
|
|
519
440
|
if ("object" != typeof t || !t) return t;
|
|
520
441
|
var e = t[Symbol.toPrimitive];
|
|
521
442
|
if (void 0 !== e) {
|
|
@@ -542,26 +463,26 @@ var ContinuousContainer = class {
|
|
|
542
463
|
return this.images.length - 1;
|
|
543
464
|
}
|
|
544
465
|
constructor(map, whiteboardApp, parentView, imageDoc) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
466
|
+
_defineProperty5(this, "view", void 0);
|
|
467
|
+
_defineProperty5(this, "parentView", void 0);
|
|
468
|
+
_defineProperty5(this, "resizeObserver", void 0);
|
|
469
|
+
_defineProperty5(this, "images", []);
|
|
470
|
+
_defineProperty5(this, "scroll", void 0);
|
|
471
|
+
_defineProperty5(this, "map", void 0);
|
|
472
|
+
_defineProperty5(this, "whiteboardApp", void 0);
|
|
473
|
+
_defineProperty5(this, "imageDoc", void 0);
|
|
474
|
+
_defineProperty5(this, "totalHeight", 0);
|
|
475
|
+
_defineProperty5(this, "localScale", 1);
|
|
476
|
+
_defineProperty5(this, "handleMapChange", (event) => {
|
|
556
477
|
if (event.keysChanged.has(ContainerKeys.translateY)) {
|
|
557
478
|
this.updateSyncedTransform();
|
|
558
479
|
}
|
|
559
480
|
});
|
|
560
|
-
|
|
481
|
+
_defineProperty5(this, "handleResize", () => {
|
|
561
482
|
const bound = this.view.getBoundingClientRect();
|
|
562
483
|
let scaledHeight = 0;
|
|
563
484
|
for (const image of this.images) {
|
|
564
|
-
|
|
485
|
+
const scale = bound.width / image.width;
|
|
565
486
|
image.scale(scale);
|
|
566
487
|
scaledHeight += image.height * scale;
|
|
567
488
|
}
|
|
@@ -570,7 +491,7 @@ var ContinuousContainer = class {
|
|
|
570
491
|
this.whiteboardApp.adjustByOutFrame(bound.width, bound.height);
|
|
571
492
|
this.updateSyncedTransform();
|
|
572
493
|
});
|
|
573
|
-
|
|
494
|
+
_defineProperty5(this, "updateSyncedTransform", () => {
|
|
574
495
|
const bounds = this.view.getBoundingClientRect();
|
|
575
496
|
const maxTy = this.totalHeight * this.localScale - bounds.height;
|
|
576
497
|
let ty = this.translateY * this.totalHeight * this.localScale;
|
|
@@ -580,7 +501,6 @@ var ContinuousContainer = class {
|
|
|
580
501
|
this.whiteboardApp.emitter.resetCamera();
|
|
581
502
|
this.whiteboardApp.emitter.translateCamera(0, -ty);
|
|
582
503
|
this.whiteboardApp.emitter.scaleCamera(this.localScale, "top-left");
|
|
583
|
-
console.log("localScale: ", this.localScale, this.translateY);
|
|
584
504
|
this.handleGoto(this.pageIndex);
|
|
585
505
|
});
|
|
586
506
|
this.imageDoc = imageDoc;
|
|
@@ -657,14 +577,15 @@ var ContinuousContainer = class {
|
|
|
657
577
|
};
|
|
658
578
|
|
|
659
579
|
// src/SingleContainer.ts
|
|
660
|
-
|
|
661
|
-
|
|
580
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
581
|
+
function _defineProperty6(e, r, t) {
|
|
582
|
+
return (r = _toPropertyKey6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
662
583
|
}
|
|
663
|
-
function
|
|
664
|
-
var i =
|
|
584
|
+
function _toPropertyKey6(t) {
|
|
585
|
+
var i = _toPrimitive6(t, "string");
|
|
665
586
|
return "symbol" == typeof i ? i : i + "";
|
|
666
587
|
}
|
|
667
|
-
function
|
|
588
|
+
function _toPrimitive6(t, r) {
|
|
668
589
|
if ("object" != typeof t || !t) return t;
|
|
669
590
|
var e = t[Symbol.toPrimitive];
|
|
670
591
|
if (void 0 !== e) {
|
|
@@ -705,26 +626,25 @@ var SingleContainer = class {
|
|
|
705
626
|
return this.map.get(ContainerKeys.pageIndex);
|
|
706
627
|
}
|
|
707
628
|
constructor(map, whiteboardApp, parentView, imageDoc) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
_defineProperty7(this, "handleMapChange", (event) => {
|
|
629
|
+
_defineProperty6(this, "view", void 0);
|
|
630
|
+
_defineProperty6(this, "parentView", void 0);
|
|
631
|
+
_defineProperty6(this, "resizeObserver", void 0);
|
|
632
|
+
_defineProperty6(this, "images", []);
|
|
633
|
+
_defineProperty6(this, "currentImage", null);
|
|
634
|
+
_defineProperty6(this, "scroll", void 0);
|
|
635
|
+
_defineProperty6(this, "map", void 0);
|
|
636
|
+
_defineProperty6(this, "whiteboardApp", void 0);
|
|
637
|
+
_defineProperty6(this, "imageDoc", void 0);
|
|
638
|
+
_defineProperty6(this, "handleMapChange", (event) => {
|
|
719
639
|
if (event.keysChanged.has(ContainerKeys.scale) || event.keysChanged.has(ContainerKeys.translateX) || event.keysChanged.has(ContainerKeys.translateY)) {
|
|
720
640
|
this.updateSyncedTransform();
|
|
721
641
|
}
|
|
722
642
|
if (event.keysChanged.has(ContainerKeys.pageIndex)) {
|
|
723
|
-
this.handleGoto(this.pageIndex).catch((
|
|
643
|
+
this.handleGoto(this.pageIndex).catch((_error) => {
|
|
724
644
|
});
|
|
725
645
|
}
|
|
726
646
|
});
|
|
727
|
-
|
|
647
|
+
_defineProperty6(this, "handleResize", () => {
|
|
728
648
|
const bound = this.parentView.getBoundingClientRect();
|
|
729
649
|
if (this.currentImage) {
|
|
730
650
|
let scale = bound.width / this.currentImage.width;
|
|
@@ -735,9 +655,10 @@ var SingleContainer = class {
|
|
|
735
655
|
const ty = Math.round((bound.height - this.currentImage.height * scale) / 2 / scale);
|
|
736
656
|
this.currentImage.view.style.transform = `scale(${scale}) translate(${tx}px, ${ty}px)`;
|
|
737
657
|
this.updateSyncedTransform();
|
|
658
|
+
this.resetTranslateOnResize();
|
|
738
659
|
}
|
|
739
660
|
});
|
|
740
|
-
|
|
661
|
+
_defineProperty6(this, "updateSyncedTransform", () => {
|
|
741
662
|
if (!this.currentImage) {
|
|
742
663
|
return;
|
|
743
664
|
}
|
|
@@ -745,22 +666,11 @@ var SingleContainer = class {
|
|
|
745
666
|
const tx = -this.translateX * parentBounds.width / this.scale;
|
|
746
667
|
const ty = -this.translateY * parentBounds.height / this.scale;
|
|
747
668
|
this.view.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
whiteboardView.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
|
|
754
|
-
this.whiteboardApp.adjustByOutFrame(parentBounds.width, parentBounds.height);
|
|
755
|
-
window.clearTimeout(this.timeoutId);
|
|
756
|
-
this.timeoutId = window.setTimeout(() => {
|
|
757
|
-
whiteboardView.style.width = `${parentBounds.width * this.scale}px`;
|
|
758
|
-
whiteboardView.style.height = `${parentBounds.height * this.scale}px`;
|
|
759
|
-
whiteboardView.style.top = `${-(this.scale - 1) * parentBounds.height / 2 + ty * this.scale}px`;
|
|
760
|
-
whiteboardView.style.left = `${-(this.scale - 1) * parentBounds.width / 2 + tx * this.scale}px`;
|
|
761
|
-
whiteboardView.style.transform = `scale(1) translate(0px, 0px)`;
|
|
762
|
-
this.whiteboardApp.adjustByOutFrame(parentBounds.width * this.scale, parentBounds.height * this.scale);
|
|
763
|
-
}, 200);
|
|
669
|
+
this.whiteboardApp.adjustByOutFrame(parentBounds.width * this.scale, parentBounds.height * this.scale);
|
|
670
|
+
const whiteboardSize = this.whiteboardApp.getViewSize();
|
|
671
|
+
const whiteboardScale = this.whiteboardApp.getInherentScale();
|
|
672
|
+
this.whiteboardApp.emitter.resetCamera();
|
|
673
|
+
this.whiteboardApp.emitter.translateCamera(-this.translateX * whiteboardSize[0] / whiteboardScale / this.scale, -this.translateY * whiteboardSize[1] / whiteboardScale / this.scale);
|
|
764
674
|
});
|
|
765
675
|
this.imageDoc = imageDoc;
|
|
766
676
|
this.parentView = parentView;
|
|
@@ -777,7 +687,6 @@ var SingleContainer = class {
|
|
|
777
687
|
this.view.setAttribute("data-imagery-container", "single");
|
|
778
688
|
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
779
689
|
this.resizeObserver.observe(this.view);
|
|
780
|
-
window.imageWhiteboard = this.whiteboardApp;
|
|
781
690
|
this.whiteboardApp.updateInternalResizeObserverStatus(false);
|
|
782
691
|
this.map.observe(this.handleMapChange);
|
|
783
692
|
if (!this.map.has(ContainerKeys.scale)) {
|
|
@@ -804,10 +713,29 @@ var SingleContainer = class {
|
|
|
804
713
|
});
|
|
805
714
|
}
|
|
806
715
|
init() {
|
|
807
|
-
this.handleGoto(this.pageIndex).catch((
|
|
716
|
+
this.handleGoto(this.pageIndex).catch((_error) => {
|
|
717
|
+
console.error(_error);
|
|
718
|
+
}).finally(() => {
|
|
719
|
+
this.handleResize();
|
|
808
720
|
});
|
|
809
721
|
this.updateSyncedTransform();
|
|
810
722
|
}
|
|
723
|
+
resetTranslateOnResize() {
|
|
724
|
+
const image = this.view.children[0];
|
|
725
|
+
if (!image) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const imageBounds = image.getBoundingClientRect();
|
|
729
|
+
const parentBounds = this.parentView.getBoundingClientRect();
|
|
730
|
+
const maxDx = (imageBounds.width - parentBounds.width) / 2;
|
|
731
|
+
const maxDy = (imageBounds.height - parentBounds.height) / 2;
|
|
732
|
+
if (maxDx < 0) {
|
|
733
|
+
this.translateX = 0;
|
|
734
|
+
}
|
|
735
|
+
if (maxDy < 0) {
|
|
736
|
+
this.translateY = 0;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
811
739
|
handleTranslate(dx, dy) {
|
|
812
740
|
const image = this.view.children[0];
|
|
813
741
|
if (!image) {
|
|
@@ -877,21 +805,21 @@ var SingleContainer = class {
|
|
|
877
805
|
}
|
|
878
806
|
}
|
|
879
807
|
dispose() {
|
|
808
|
+
(0, import_forge_room3.removeObserver)(this.map, this.handleMapChange);
|
|
880
809
|
this.resizeObserver.disconnect();
|
|
881
810
|
this.scroll.dispose();
|
|
882
|
-
window.clearTimeout(this.timeoutId);
|
|
883
811
|
}
|
|
884
812
|
};
|
|
885
813
|
|
|
886
814
|
// src/ImageryDocApplication.ts
|
|
887
|
-
function
|
|
888
|
-
return (r =
|
|
815
|
+
function _defineProperty7(e, r, t) {
|
|
816
|
+
return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
889
817
|
}
|
|
890
|
-
function
|
|
891
|
-
var i =
|
|
818
|
+
function _toPropertyKey7(t) {
|
|
819
|
+
var i = _toPrimitive7(t, "string");
|
|
892
820
|
return "symbol" == typeof i ? i : i + "";
|
|
893
821
|
}
|
|
894
|
-
function
|
|
822
|
+
function _toPrimitive7(t, r) {
|
|
895
823
|
if ("object" != typeof t || !t) return t;
|
|
896
824
|
var e = t[Symbol.toPrimitive];
|
|
897
825
|
if (void 0 !== e) {
|
|
@@ -902,24 +830,25 @@ function _toPrimitive8(t, r) {
|
|
|
902
830
|
return ("string" === r ? String : Number)(t);
|
|
903
831
|
}
|
|
904
832
|
var IMAGERY_DOC_APP_NAME = "imagery_doc";
|
|
905
|
-
var ImageryDocApplication = class extends
|
|
833
|
+
var ImageryDocApplication = class extends import_forge_room4.AbstractApplication {
|
|
906
834
|
constructor() {
|
|
907
835
|
super();
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
836
|
+
_defineProperty7(this, "name", IMAGERY_DOC_APP_NAME);
|
|
837
|
+
_defineProperty7(this, "emitter", new ImageryDoc());
|
|
838
|
+
_defineProperty7(this, "whiteboardApp", void 0);
|
|
839
|
+
_defineProperty7(this, "whiteboard", void 0);
|
|
840
|
+
_defineProperty7(this, "container", void 0);
|
|
841
|
+
_defineProperty7(this, "rootView", document.createElement("div"));
|
|
842
|
+
_defineProperty7(this, "contentContainer", document.createElement("div"));
|
|
843
|
+
_defineProperty7(this, "whiteboardContainer", document.createElement("div"));
|
|
844
|
+
_defineProperty7(this, "footerContainer", document.createElement("div"));
|
|
845
|
+
_defineProperty7(this, "permissions", void 0);
|
|
846
|
+
_defineProperty7(this, "footer", void 0);
|
|
847
|
+
_defineProperty7(this, "images", []);
|
|
920
848
|
this.rootView.setAttribute("data-forge-app", "imagery-doc");
|
|
921
|
-
this.rootView.style.background = "red";
|
|
922
849
|
this.rootView.style.overflow = "hidden";
|
|
850
|
+
this.rootView.style.userSelect = "none";
|
|
851
|
+
this.rootView.style.backgroundColor = "#f9f9fc";
|
|
923
852
|
this.contentContainer.style.width = "100%";
|
|
924
853
|
this.contentContainer.style.height = "100%";
|
|
925
854
|
this.contentContainer.style.display = "flex";
|
|
@@ -985,11 +914,11 @@ var ImageryDocApplication = class extends import_forge_room2.AbstractApplication
|
|
|
985
914
|
}
|
|
986
915
|
async initialize(option) {
|
|
987
916
|
const whiteboardApp = new import_forge_whiteboard.WhiteboardApplication();
|
|
988
|
-
whiteboardApp.
|
|
917
|
+
whiteboardApp.appDoc = this.appDoc;
|
|
989
918
|
whiteboardApp.appId = `${this.appId}_wb`;
|
|
990
919
|
whiteboardApp.userId = this.userId;
|
|
991
920
|
whiteboardApp.userManager = this.userManager;
|
|
992
|
-
whiteboardApp.
|
|
921
|
+
whiteboardApp.deleteSubDoc = this.deleteSubDoc;
|
|
993
922
|
await whiteboardApp.initialize({
|
|
994
923
|
width: -1,
|
|
995
924
|
height: -1
|
|
@@ -1017,9 +946,9 @@ var ImageryDocApplication = class extends import_forge_room2.AbstractApplication
|
|
|
1017
946
|
this.contentContainer.appendChild(this.whiteboardContainer);
|
|
1018
947
|
this.contentContainer.appendChild(this.footerContainer);
|
|
1019
948
|
this.footerContainer.appendChild(this.footer.root);
|
|
1020
|
-
this.whiteboard.setViewModeToMain();
|
|
1021
949
|
let i = 0;
|
|
1022
950
|
this.whiteboard.permissions.addPermission(import_forge_whiteboard.WhiteboardPermissionFlag.mainView);
|
|
951
|
+
this.whiteboard.setViewModeToMain();
|
|
1023
952
|
while (i < option.images.length) {
|
|
1024
953
|
const image = option.images[i];
|
|
1025
954
|
this.images[i] = new LazyImage(image.src, image.width, image.height);
|
|
@@ -1033,32 +962,38 @@ var ImageryDocApplication = class extends import_forge_room2.AbstractApplication
|
|
|
1033
962
|
this.whiteboard.addPage("doc_continuous");
|
|
1034
963
|
this.whiteboard.gotoPage("doc_continuous");
|
|
1035
964
|
}
|
|
1036
|
-
|
|
1037
|
-
this.whiteboard.setViewModeToMain();
|
|
1038
|
-
} else {
|
|
1039
|
-
this.whiteboard.setViewModeToFree();
|
|
1040
|
-
}
|
|
965
|
+
this.whiteboard.setViewModeToFree();
|
|
1041
966
|
this.permissions = new ImageryDocPermissions(this.userManager, (userId) => {
|
|
1042
967
|
return this.userMap(userId);
|
|
1043
968
|
});
|
|
1044
|
-
this.permissions.
|
|
969
|
+
this.permissions.on("change", (userId, flags, value) => {
|
|
970
|
+
this.emitter.emit("permissionChange", userId, flags, value);
|
|
971
|
+
});
|
|
972
|
+
this.permissions.setPermission(ImageryDocPermissionFlag.all);
|
|
1045
973
|
this.whiteboardApp.disableViewModel();
|
|
1046
974
|
this.container.init();
|
|
1047
975
|
this.whiteboard.permissions.removePermission(import_forge_whiteboard.WhiteboardPermissionFlag.mainView);
|
|
1048
976
|
if (option.inheritWhiteboardId) {
|
|
1049
977
|
whiteboardApp.linkToWhiteboard(option.inheritWhiteboardId);
|
|
1050
978
|
}
|
|
979
|
+
this.emitter.emit("ready");
|
|
1051
980
|
return Promise.resolve(void 0);
|
|
1052
981
|
}
|
|
1053
982
|
userMap(userId) {
|
|
1054
983
|
return this.getMap(`user/${userId}`);
|
|
1055
984
|
}
|
|
1056
|
-
async dispose() {
|
|
1057
|
-
|
|
1058
|
-
|
|
985
|
+
async dispose(removeSubDoc) {
|
|
986
|
+
if (removeSubDoc) {
|
|
987
|
+
this.deleteSubDoc(this.appId);
|
|
988
|
+
}
|
|
989
|
+
await this.whiteboardApp.dispose(removeSubDoc);
|
|
990
|
+
this.whiteboardApp.emitter.view.remove();
|
|
1059
991
|
this.container.dispose();
|
|
992
|
+
this.permissions.dispose();
|
|
993
|
+
this.emitter.removeAllListeners();
|
|
1060
994
|
return Promise.resolve(void 0);
|
|
1061
995
|
}
|
|
1062
996
|
};
|
|
1063
|
-
|
|
997
|
+
_defineProperty7(ImageryDocApplication, "applicationName", IMAGERY_DOC_APP_NAME);
|
|
998
|
+
window.__ImageryDocApplication = ImageryDocApplication;
|
|
1064
999
|
//# sourceMappingURL=imagery-doc.js.map
|