@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.esm.js
CHANGED
|
@@ -86,7 +86,7 @@ var LazyImage = class {
|
|
|
86
86
|
const blob = await response.blob();
|
|
87
87
|
return new Promise((resolve, reject) => {
|
|
88
88
|
const reader = new FileReader();
|
|
89
|
-
reader.onload = (
|
|
89
|
+
reader.onload = (_e) => {
|
|
90
90
|
kvStore.setItem(this.src, reader.result);
|
|
91
91
|
resolve(reader.result);
|
|
92
92
|
};
|
|
@@ -111,24 +111,7 @@ var LazyImage = class {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
// src/ImageryDocPermissions.ts
|
|
114
|
-
import
|
|
115
|
-
function _defineProperty3(e, r, t) {
|
|
116
|
-
return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
117
|
-
}
|
|
118
|
-
function _toPropertyKey3(t) {
|
|
119
|
-
var i = _toPrimitive3(t, "string");
|
|
120
|
-
return "symbol" == typeof i ? i : i + "";
|
|
121
|
-
}
|
|
122
|
-
function _toPrimitive3(t, r) {
|
|
123
|
-
if ("object" != typeof t || !t) return t;
|
|
124
|
-
var e = t[Symbol.toPrimitive];
|
|
125
|
-
if (void 0 !== e) {
|
|
126
|
-
var i = e.call(t, r || "default");
|
|
127
|
-
if ("object" != typeof i) return i;
|
|
128
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
129
|
-
}
|
|
130
|
-
return ("string" === r ? String : Number)(t);
|
|
131
|
-
}
|
|
114
|
+
import { AbstractApplicationPermissions } from "@netless/forge-room";
|
|
132
115
|
var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
|
|
133
116
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["none"] = 0] = "none";
|
|
134
117
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["switchPage"] = 1] = "switchPage";
|
|
@@ -137,104 +120,15 @@ var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
|
|
|
137
120
|
ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["all"] = ImageryDocPermissionFlag2.switchPage | ImageryDocPermissionFlag2.camera | ImageryDocPermissionFlag2.sideBar] = "all";
|
|
138
121
|
return ImageryDocPermissionFlag2;
|
|
139
122
|
}({});
|
|
140
|
-
var ImageryDocPermissions = class extends
|
|
141
|
-
constructor(userManager, requestUserMap) {
|
|
142
|
-
super();
|
|
143
|
-
_defineProperty3(this, "requestUserMap", void 0);
|
|
144
|
-
_defineProperty3(this, "userManager", void 0);
|
|
145
|
-
_defineProperty3(this, "observers", /* @__PURE__ */ new Map());
|
|
146
|
-
_defineProperty3(this, "handleUserLeave", (user) => {
|
|
147
|
-
const cb = this.observers.get(user.id);
|
|
148
|
-
if (cb) {
|
|
149
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
_defineProperty3(this, "handleUserJoin", (user) => {
|
|
153
|
-
this.addObserve(user.id);
|
|
154
|
-
});
|
|
155
|
-
this.userManager = userManager;
|
|
156
|
-
this.requestUserMap = requestUserMap;
|
|
157
|
-
this.createModel(this.userManager.selfId);
|
|
158
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
159
|
-
this.addObserve(userId);
|
|
160
|
-
});
|
|
161
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
162
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
163
|
-
}
|
|
164
|
-
addObserve(userId) {
|
|
165
|
-
const observer = (evt) => {
|
|
166
|
-
this.handleUserPermissionChange(userId, evt);
|
|
167
|
-
};
|
|
168
|
-
this.observers.set(userId, observer);
|
|
169
|
-
this.requestUserMap(userId).observe(observer);
|
|
170
|
-
}
|
|
171
|
-
createModel(userId) {
|
|
172
|
-
const userMap = this.requestUserMap(userId);
|
|
173
|
-
if (!userMap.has("permission")) {
|
|
174
|
-
userMap.set("permission", 0);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
handleUserPermissionChange(userId, evt) {
|
|
178
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
179
|
-
if (key === "permission") {
|
|
180
|
-
if (value.action === "add" || value.action === "update") {
|
|
181
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
182
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
123
|
+
var ImageryDocPermissions = class extends AbstractApplicationPermissions {
|
|
187
124
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
125
|
+
* 解析权限列表组合
|
|
126
|
+
* @param {number} value - 权限数字值
|
|
127
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
128
|
+
*/
|
|
192
129
|
resolveFlags(value) {
|
|
193
130
|
return [ImageryDocPermissionFlag.switchPage, ImageryDocPermissionFlag.sideBar, ImageryDocPermissionFlag.camera].filter((v) => (v & value) !== 0);
|
|
194
131
|
}
|
|
195
|
-
/**
|
|
196
|
-
* 获取权限列表组合对应的数值
|
|
197
|
-
* @param { string } userId 不传表示获取自己
|
|
198
|
-
*/
|
|
199
|
-
getPermissionValue(userId) {
|
|
200
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 获取权限列表
|
|
204
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
205
|
-
*/
|
|
206
|
-
getPermissionFlags(userId) {
|
|
207
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
208
|
-
return this.resolveFlags(value);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* 返回对应 userId 是否有相应权限
|
|
212
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
213
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
214
|
-
*/
|
|
215
|
-
hasPermission(flag, userId) {
|
|
216
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* 添加权限
|
|
220
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
221
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
222
|
-
*/
|
|
223
|
-
addPermission(flag, userId) {
|
|
224
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
225
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
226
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* 移除权限
|
|
230
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
231
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
232
|
-
*/
|
|
233
|
-
removePermission(flag, userId) {
|
|
234
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
235
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
236
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
237
|
-
}
|
|
238
132
|
};
|
|
239
133
|
|
|
240
134
|
// src/icons.ts
|
|
@@ -248,14 +142,14 @@ var Icons = {
|
|
|
248
142
|
};
|
|
249
143
|
|
|
250
144
|
// src/FooterView.ts
|
|
251
|
-
function
|
|
252
|
-
return (r =
|
|
145
|
+
function _defineProperty3(e, r, t) {
|
|
146
|
+
return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
253
147
|
}
|
|
254
|
-
function
|
|
255
|
-
var i =
|
|
148
|
+
function _toPropertyKey3(t) {
|
|
149
|
+
var i = _toPrimitive3(t, "string");
|
|
256
150
|
return "symbol" == typeof i ? i : i + "";
|
|
257
151
|
}
|
|
258
|
-
function
|
|
152
|
+
function _toPrimitive3(t, r) {
|
|
259
153
|
if ("object" != typeof t || !t) return t;
|
|
260
154
|
var e = t[Symbol.toPrimitive];
|
|
261
155
|
if (void 0 !== e) {
|
|
@@ -268,14 +162,23 @@ function _toPrimitive4(t, r) {
|
|
|
268
162
|
var EM_COLOR = "#8C8C8C";
|
|
269
163
|
var FooterView = class {
|
|
270
164
|
constructor(imageryDoc) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
165
|
+
_defineProperty3(this, "root", void 0);
|
|
166
|
+
_defineProperty3(this, "prevPage", void 0);
|
|
167
|
+
_defineProperty3(this, "nextPage", void 0);
|
|
168
|
+
_defineProperty3(this, "sideBarToggle", void 0);
|
|
169
|
+
_defineProperty3(this, "sideBarContainer", document.createElement("div"));
|
|
170
|
+
_defineProperty3(this, "navigator", document.createElement("div"));
|
|
171
|
+
_defineProperty3(this, "navigatorIndex", document.createElement("span"));
|
|
172
|
+
_defineProperty3(this, "navigatorTotal", document.createElement("span"));
|
|
173
|
+
_defineProperty3(this, "isSlideBarVisible", false);
|
|
174
|
+
_defineProperty3(this, "imageryDoc", void 0);
|
|
175
|
+
_defineProperty3(this, "updateIndex", () => {
|
|
176
|
+
this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
|
|
177
|
+
});
|
|
178
|
+
_defineProperty3(this, "updateTotal", () => {
|
|
179
|
+
this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
|
|
180
|
+
});
|
|
181
|
+
_defineProperty3(this, "handleSideBarClick", (evt) => {
|
|
279
182
|
const target = evt.target;
|
|
280
183
|
const targetIndex = target.getAttribute("data-doc-index");
|
|
281
184
|
if (targetIndex) {
|
|
@@ -310,6 +213,9 @@ var FooterView = class {
|
|
|
310
213
|
this.root.appendChild(this.prevPage);
|
|
311
214
|
this.root.appendChild(this.nextPage);
|
|
312
215
|
this.root.appendChild(this.createSpacer());
|
|
216
|
+
this.createNavigator();
|
|
217
|
+
this.imageryDoc.addListener("renderEnd", this.updateIndex);
|
|
218
|
+
this.imageryDoc.addListener("ready", this.updateTotal);
|
|
313
219
|
}
|
|
314
220
|
prevPageState(enable) {
|
|
315
221
|
if (enable) {
|
|
@@ -352,6 +258,20 @@ var FooterView = class {
|
|
|
352
258
|
});
|
|
353
259
|
return icon;
|
|
354
260
|
}
|
|
261
|
+
createNavigator() {
|
|
262
|
+
this.navigator.style.height = "24px";
|
|
263
|
+
this.navigator.style.padding = "12px";
|
|
264
|
+
this.navigator.style.display = "flex";
|
|
265
|
+
this.navigator.style.alignItems = "center";
|
|
266
|
+
this.navigator.style.justifyContent = "center";
|
|
267
|
+
this.navigator.style.fontSize = "12px";
|
|
268
|
+
this.navigator.style.color = "#585858";
|
|
269
|
+
this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
|
|
270
|
+
this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
|
|
271
|
+
this.navigator.appendChild(this.navigatorIndex);
|
|
272
|
+
this.navigator.appendChild(this.navigatorTotal);
|
|
273
|
+
this.root.appendChild(this.navigator);
|
|
274
|
+
}
|
|
355
275
|
createSideBar() {
|
|
356
276
|
if (this.imageryDoc.pageCount === 0) {
|
|
357
277
|
return;
|
|
@@ -363,7 +283,7 @@ var FooterView = class {
|
|
|
363
283
|
this.sideBarContainer.style.maxWidth = "180px";
|
|
364
284
|
this.sideBarContainer.style.height = "calc(100% - 24px)";
|
|
365
285
|
this.sideBarContainer.style.position = "absolute";
|
|
366
|
-
this.sideBarContainer.style.bottom = "
|
|
286
|
+
this.sideBarContainer.style.bottom = "25px";
|
|
367
287
|
this.sideBarContainer.style.left = "0";
|
|
368
288
|
this.sideBarContainer.style.fontSize = "0px";
|
|
369
289
|
this.sideBarContainer.style.overflow = "auto";
|
|
@@ -378,7 +298,7 @@ var FooterView = class {
|
|
|
378
298
|
reviewIndex.textContent = `${i + 1}`;
|
|
379
299
|
const reviewImg = document.createElement("img");
|
|
380
300
|
reviewImg.setAttribute("data-doc-index", `${i}`);
|
|
381
|
-
reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #
|
|
301
|
+
reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #f9f9fc";
|
|
382
302
|
this.imageryDoc.imgContent(i).then((base64Data) => {
|
|
383
303
|
reviewImg.src = base64Data;
|
|
384
304
|
});
|
|
@@ -391,15 +311,15 @@ var FooterView = class {
|
|
|
391
311
|
};
|
|
392
312
|
|
|
393
313
|
// src/InfinityScroll.ts
|
|
394
|
-
import
|
|
395
|
-
function
|
|
396
|
-
return (r =
|
|
314
|
+
import EventEmitter2 from "eventemitter3";
|
|
315
|
+
function _defineProperty4(e, r, t) {
|
|
316
|
+
return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
397
317
|
}
|
|
398
|
-
function
|
|
399
|
-
var i =
|
|
318
|
+
function _toPropertyKey4(t) {
|
|
319
|
+
var i = _toPrimitive4(t, "string");
|
|
400
320
|
return "symbol" == typeof i ? i : i + "";
|
|
401
321
|
}
|
|
402
|
-
function
|
|
322
|
+
function _toPrimitive4(t, r) {
|
|
403
323
|
if ("object" != typeof t || !t) return t;
|
|
404
324
|
var e = t[Symbol.toPrimitive];
|
|
405
325
|
if (void 0 !== e) {
|
|
@@ -409,16 +329,16 @@ function _toPrimitive5(t, r) {
|
|
|
409
329
|
}
|
|
410
330
|
return ("string" === r ? String : Number)(t);
|
|
411
331
|
}
|
|
412
|
-
var InfinityScroll = class extends
|
|
332
|
+
var InfinityScroll = class extends EventEmitter2 {
|
|
413
333
|
constructor(view) {
|
|
414
334
|
super();
|
|
415
|
-
|
|
416
|
-
|
|
335
|
+
_defineProperty4(this, "view", void 0);
|
|
336
|
+
_defineProperty4(this, "lastDelta", {
|
|
417
337
|
x: 0,
|
|
418
338
|
y: 0
|
|
419
339
|
});
|
|
420
|
-
|
|
421
|
-
|
|
340
|
+
_defineProperty4(this, "lastTriggerTime", 0);
|
|
341
|
+
_defineProperty4(this, "handleWheel", (evt) => {
|
|
422
342
|
evt.preventDefault();
|
|
423
343
|
evt.stopImmediatePropagation();
|
|
424
344
|
evt.stopPropagation();
|
|
@@ -458,6 +378,7 @@ var InfinityScroll = class extends EventEmitter3 {
|
|
|
458
378
|
}
|
|
459
379
|
dispose() {
|
|
460
380
|
this.view.removeEventListener("wheel", this.handleWheel);
|
|
381
|
+
this.removeAllListeners();
|
|
461
382
|
}
|
|
462
383
|
};
|
|
463
384
|
|
|
@@ -470,14 +391,14 @@ var ContainerKeys = {
|
|
|
470
391
|
};
|
|
471
392
|
|
|
472
393
|
// src/ContinuousContainer.ts
|
|
473
|
-
function
|
|
474
|
-
return (r =
|
|
394
|
+
function _defineProperty5(e, r, t) {
|
|
395
|
+
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
475
396
|
}
|
|
476
|
-
function
|
|
477
|
-
var i =
|
|
397
|
+
function _toPropertyKey5(t) {
|
|
398
|
+
var i = _toPrimitive5(t, "string");
|
|
478
399
|
return "symbol" == typeof i ? i : i + "";
|
|
479
400
|
}
|
|
480
|
-
function
|
|
401
|
+
function _toPrimitive5(t, r) {
|
|
481
402
|
if ("object" != typeof t || !t) return t;
|
|
482
403
|
var e = t[Symbol.toPrimitive];
|
|
483
404
|
if (void 0 !== e) {
|
|
@@ -504,26 +425,26 @@ var ContinuousContainer = class {
|
|
|
504
425
|
return this.images.length - 1;
|
|
505
426
|
}
|
|
506
427
|
constructor(map, whiteboardApp, parentView, imageDoc) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
428
|
+
_defineProperty5(this, "view", void 0);
|
|
429
|
+
_defineProperty5(this, "parentView", void 0);
|
|
430
|
+
_defineProperty5(this, "resizeObserver", void 0);
|
|
431
|
+
_defineProperty5(this, "images", []);
|
|
432
|
+
_defineProperty5(this, "scroll", void 0);
|
|
433
|
+
_defineProperty5(this, "map", void 0);
|
|
434
|
+
_defineProperty5(this, "whiteboardApp", void 0);
|
|
435
|
+
_defineProperty5(this, "imageDoc", void 0);
|
|
436
|
+
_defineProperty5(this, "totalHeight", 0);
|
|
437
|
+
_defineProperty5(this, "localScale", 1);
|
|
438
|
+
_defineProperty5(this, "handleMapChange", (event) => {
|
|
518
439
|
if (event.keysChanged.has(ContainerKeys.translateY)) {
|
|
519
440
|
this.updateSyncedTransform();
|
|
520
441
|
}
|
|
521
442
|
});
|
|
522
|
-
|
|
443
|
+
_defineProperty5(this, "handleResize", () => {
|
|
523
444
|
const bound = this.view.getBoundingClientRect();
|
|
524
445
|
let scaledHeight = 0;
|
|
525
446
|
for (const image of this.images) {
|
|
526
|
-
|
|
447
|
+
const scale = bound.width / image.width;
|
|
527
448
|
image.scale(scale);
|
|
528
449
|
scaledHeight += image.height * scale;
|
|
529
450
|
}
|
|
@@ -532,7 +453,7 @@ var ContinuousContainer = class {
|
|
|
532
453
|
this.whiteboardApp.adjustByOutFrame(bound.width, bound.height);
|
|
533
454
|
this.updateSyncedTransform();
|
|
534
455
|
});
|
|
535
|
-
|
|
456
|
+
_defineProperty5(this, "updateSyncedTransform", () => {
|
|
536
457
|
const bounds = this.view.getBoundingClientRect();
|
|
537
458
|
const maxTy = this.totalHeight * this.localScale - bounds.height;
|
|
538
459
|
let ty = this.translateY * this.totalHeight * this.localScale;
|
|
@@ -542,7 +463,6 @@ var ContinuousContainer = class {
|
|
|
542
463
|
this.whiteboardApp.emitter.resetCamera();
|
|
543
464
|
this.whiteboardApp.emitter.translateCamera(0, -ty);
|
|
544
465
|
this.whiteboardApp.emitter.scaleCamera(this.localScale, "top-left");
|
|
545
|
-
console.log("localScale: ", this.localScale, this.translateY);
|
|
546
466
|
this.handleGoto(this.pageIndex);
|
|
547
467
|
});
|
|
548
468
|
this.imageDoc = imageDoc;
|
|
@@ -619,14 +539,15 @@ var ContinuousContainer = class {
|
|
|
619
539
|
};
|
|
620
540
|
|
|
621
541
|
// src/SingleContainer.ts
|
|
622
|
-
|
|
623
|
-
|
|
542
|
+
import { removeObserver } from "@netless/forge-room";
|
|
543
|
+
function _defineProperty6(e, r, t) {
|
|
544
|
+
return (r = _toPropertyKey6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
624
545
|
}
|
|
625
|
-
function
|
|
626
|
-
var i =
|
|
546
|
+
function _toPropertyKey6(t) {
|
|
547
|
+
var i = _toPrimitive6(t, "string");
|
|
627
548
|
return "symbol" == typeof i ? i : i + "";
|
|
628
549
|
}
|
|
629
|
-
function
|
|
550
|
+
function _toPrimitive6(t, r) {
|
|
630
551
|
if ("object" != typeof t || !t) return t;
|
|
631
552
|
var e = t[Symbol.toPrimitive];
|
|
632
553
|
if (void 0 !== e) {
|
|
@@ -667,26 +588,25 @@ var SingleContainer = class {
|
|
|
667
588
|
return this.map.get(ContainerKeys.pageIndex);
|
|
668
589
|
}
|
|
669
590
|
constructor(map, whiteboardApp, parentView, imageDoc) {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
_defineProperty7(this, "handleMapChange", (event) => {
|
|
591
|
+
_defineProperty6(this, "view", void 0);
|
|
592
|
+
_defineProperty6(this, "parentView", void 0);
|
|
593
|
+
_defineProperty6(this, "resizeObserver", void 0);
|
|
594
|
+
_defineProperty6(this, "images", []);
|
|
595
|
+
_defineProperty6(this, "currentImage", null);
|
|
596
|
+
_defineProperty6(this, "scroll", void 0);
|
|
597
|
+
_defineProperty6(this, "map", void 0);
|
|
598
|
+
_defineProperty6(this, "whiteboardApp", void 0);
|
|
599
|
+
_defineProperty6(this, "imageDoc", void 0);
|
|
600
|
+
_defineProperty6(this, "handleMapChange", (event) => {
|
|
681
601
|
if (event.keysChanged.has(ContainerKeys.scale) || event.keysChanged.has(ContainerKeys.translateX) || event.keysChanged.has(ContainerKeys.translateY)) {
|
|
682
602
|
this.updateSyncedTransform();
|
|
683
603
|
}
|
|
684
604
|
if (event.keysChanged.has(ContainerKeys.pageIndex)) {
|
|
685
|
-
this.handleGoto(this.pageIndex).catch((
|
|
605
|
+
this.handleGoto(this.pageIndex).catch((_error) => {
|
|
686
606
|
});
|
|
687
607
|
}
|
|
688
608
|
});
|
|
689
|
-
|
|
609
|
+
_defineProperty6(this, "handleResize", () => {
|
|
690
610
|
const bound = this.parentView.getBoundingClientRect();
|
|
691
611
|
if (this.currentImage) {
|
|
692
612
|
let scale = bound.width / this.currentImage.width;
|
|
@@ -697,9 +617,10 @@ var SingleContainer = class {
|
|
|
697
617
|
const ty = Math.round((bound.height - this.currentImage.height * scale) / 2 / scale);
|
|
698
618
|
this.currentImage.view.style.transform = `scale(${scale}) translate(${tx}px, ${ty}px)`;
|
|
699
619
|
this.updateSyncedTransform();
|
|
620
|
+
this.resetTranslateOnResize();
|
|
700
621
|
}
|
|
701
622
|
});
|
|
702
|
-
|
|
623
|
+
_defineProperty6(this, "updateSyncedTransform", () => {
|
|
703
624
|
if (!this.currentImage) {
|
|
704
625
|
return;
|
|
705
626
|
}
|
|
@@ -707,22 +628,11 @@ var SingleContainer = class {
|
|
|
707
628
|
const tx = -this.translateX * parentBounds.width / this.scale;
|
|
708
629
|
const ty = -this.translateY * parentBounds.height / this.scale;
|
|
709
630
|
this.view.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
whiteboardView.style.transform = `scale(${this.scale}) translate(${tx}px, ${ty}px)`;
|
|
716
|
-
this.whiteboardApp.adjustByOutFrame(parentBounds.width, parentBounds.height);
|
|
717
|
-
window.clearTimeout(this.timeoutId);
|
|
718
|
-
this.timeoutId = window.setTimeout(() => {
|
|
719
|
-
whiteboardView.style.width = `${parentBounds.width * this.scale}px`;
|
|
720
|
-
whiteboardView.style.height = `${parentBounds.height * this.scale}px`;
|
|
721
|
-
whiteboardView.style.top = `${-(this.scale - 1) * parentBounds.height / 2 + ty * this.scale}px`;
|
|
722
|
-
whiteboardView.style.left = `${-(this.scale - 1) * parentBounds.width / 2 + tx * this.scale}px`;
|
|
723
|
-
whiteboardView.style.transform = `scale(1) translate(0px, 0px)`;
|
|
724
|
-
this.whiteboardApp.adjustByOutFrame(parentBounds.width * this.scale, parentBounds.height * this.scale);
|
|
725
|
-
}, 200);
|
|
631
|
+
this.whiteboardApp.adjustByOutFrame(parentBounds.width * this.scale, parentBounds.height * this.scale);
|
|
632
|
+
const whiteboardSize = this.whiteboardApp.getViewSize();
|
|
633
|
+
const whiteboardScale = this.whiteboardApp.getInherentScale();
|
|
634
|
+
this.whiteboardApp.emitter.resetCamera();
|
|
635
|
+
this.whiteboardApp.emitter.translateCamera(-this.translateX * whiteboardSize[0] / whiteboardScale / this.scale, -this.translateY * whiteboardSize[1] / whiteboardScale / this.scale);
|
|
726
636
|
});
|
|
727
637
|
this.imageDoc = imageDoc;
|
|
728
638
|
this.parentView = parentView;
|
|
@@ -739,7 +649,6 @@ var SingleContainer = class {
|
|
|
739
649
|
this.view.setAttribute("data-imagery-container", "single");
|
|
740
650
|
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
741
651
|
this.resizeObserver.observe(this.view);
|
|
742
|
-
window.imageWhiteboard = this.whiteboardApp;
|
|
743
652
|
this.whiteboardApp.updateInternalResizeObserverStatus(false);
|
|
744
653
|
this.map.observe(this.handleMapChange);
|
|
745
654
|
if (!this.map.has(ContainerKeys.scale)) {
|
|
@@ -766,10 +675,29 @@ var SingleContainer = class {
|
|
|
766
675
|
});
|
|
767
676
|
}
|
|
768
677
|
init() {
|
|
769
|
-
this.handleGoto(this.pageIndex).catch((
|
|
678
|
+
this.handleGoto(this.pageIndex).catch((_error) => {
|
|
679
|
+
console.error(_error);
|
|
680
|
+
}).finally(() => {
|
|
681
|
+
this.handleResize();
|
|
770
682
|
});
|
|
771
683
|
this.updateSyncedTransform();
|
|
772
684
|
}
|
|
685
|
+
resetTranslateOnResize() {
|
|
686
|
+
const image = this.view.children[0];
|
|
687
|
+
if (!image) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const imageBounds = image.getBoundingClientRect();
|
|
691
|
+
const parentBounds = this.parentView.getBoundingClientRect();
|
|
692
|
+
const maxDx = (imageBounds.width - parentBounds.width) / 2;
|
|
693
|
+
const maxDy = (imageBounds.height - parentBounds.height) / 2;
|
|
694
|
+
if (maxDx < 0) {
|
|
695
|
+
this.translateX = 0;
|
|
696
|
+
}
|
|
697
|
+
if (maxDy < 0) {
|
|
698
|
+
this.translateY = 0;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
773
701
|
handleTranslate(dx, dy) {
|
|
774
702
|
const image = this.view.children[0];
|
|
775
703
|
if (!image) {
|
|
@@ -839,21 +767,21 @@ var SingleContainer = class {
|
|
|
839
767
|
}
|
|
840
768
|
}
|
|
841
769
|
dispose() {
|
|
770
|
+
removeObserver(this.map, this.handleMapChange);
|
|
842
771
|
this.resizeObserver.disconnect();
|
|
843
772
|
this.scroll.dispose();
|
|
844
|
-
window.clearTimeout(this.timeoutId);
|
|
845
773
|
}
|
|
846
774
|
};
|
|
847
775
|
|
|
848
776
|
// src/ImageryDocApplication.ts
|
|
849
|
-
function
|
|
850
|
-
return (r =
|
|
777
|
+
function _defineProperty7(e, r, t) {
|
|
778
|
+
return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
851
779
|
}
|
|
852
|
-
function
|
|
853
|
-
var i =
|
|
780
|
+
function _toPropertyKey7(t) {
|
|
781
|
+
var i = _toPrimitive7(t, "string");
|
|
854
782
|
return "symbol" == typeof i ? i : i + "";
|
|
855
783
|
}
|
|
856
|
-
function
|
|
784
|
+
function _toPrimitive7(t, r) {
|
|
857
785
|
if ("object" != typeof t || !t) return t;
|
|
858
786
|
var e = t[Symbol.toPrimitive];
|
|
859
787
|
if (void 0 !== e) {
|
|
@@ -867,21 +795,22 @@ var IMAGERY_DOC_APP_NAME = "imagery_doc";
|
|
|
867
795
|
var ImageryDocApplication = class extends AbstractApplication {
|
|
868
796
|
constructor() {
|
|
869
797
|
super();
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
798
|
+
_defineProperty7(this, "name", IMAGERY_DOC_APP_NAME);
|
|
799
|
+
_defineProperty7(this, "emitter", new ImageryDoc());
|
|
800
|
+
_defineProperty7(this, "whiteboardApp", void 0);
|
|
801
|
+
_defineProperty7(this, "whiteboard", void 0);
|
|
802
|
+
_defineProperty7(this, "container", void 0);
|
|
803
|
+
_defineProperty7(this, "rootView", document.createElement("div"));
|
|
804
|
+
_defineProperty7(this, "contentContainer", document.createElement("div"));
|
|
805
|
+
_defineProperty7(this, "whiteboardContainer", document.createElement("div"));
|
|
806
|
+
_defineProperty7(this, "footerContainer", document.createElement("div"));
|
|
807
|
+
_defineProperty7(this, "permissions", void 0);
|
|
808
|
+
_defineProperty7(this, "footer", void 0);
|
|
809
|
+
_defineProperty7(this, "images", []);
|
|
882
810
|
this.rootView.setAttribute("data-forge-app", "imagery-doc");
|
|
883
|
-
this.rootView.style.background = "red";
|
|
884
811
|
this.rootView.style.overflow = "hidden";
|
|
812
|
+
this.rootView.style.userSelect = "none";
|
|
813
|
+
this.rootView.style.backgroundColor = "#f9f9fc";
|
|
885
814
|
this.contentContainer.style.width = "100%";
|
|
886
815
|
this.contentContainer.style.height = "100%";
|
|
887
816
|
this.contentContainer.style.display = "flex";
|
|
@@ -947,11 +876,11 @@ var ImageryDocApplication = class extends AbstractApplication {
|
|
|
947
876
|
}
|
|
948
877
|
async initialize(option) {
|
|
949
878
|
const whiteboardApp = new WhiteboardApplication();
|
|
950
|
-
whiteboardApp.
|
|
879
|
+
whiteboardApp.appDoc = this.appDoc;
|
|
951
880
|
whiteboardApp.appId = `${this.appId}_wb`;
|
|
952
881
|
whiteboardApp.userId = this.userId;
|
|
953
882
|
whiteboardApp.userManager = this.userManager;
|
|
954
|
-
whiteboardApp.
|
|
883
|
+
whiteboardApp.deleteSubDoc = this.deleteSubDoc;
|
|
955
884
|
await whiteboardApp.initialize({
|
|
956
885
|
width: -1,
|
|
957
886
|
height: -1
|
|
@@ -979,9 +908,9 @@ var ImageryDocApplication = class extends AbstractApplication {
|
|
|
979
908
|
this.contentContainer.appendChild(this.whiteboardContainer);
|
|
980
909
|
this.contentContainer.appendChild(this.footerContainer);
|
|
981
910
|
this.footerContainer.appendChild(this.footer.root);
|
|
982
|
-
this.whiteboard.setViewModeToMain();
|
|
983
911
|
let i = 0;
|
|
984
912
|
this.whiteboard.permissions.addPermission(WhiteboardPermissionFlag.mainView);
|
|
913
|
+
this.whiteboard.setViewModeToMain();
|
|
985
914
|
while (i < option.images.length) {
|
|
986
915
|
const image = option.images[i];
|
|
987
916
|
this.images[i] = new LazyImage(image.src, image.width, image.height);
|
|
@@ -995,34 +924,40 @@ var ImageryDocApplication = class extends AbstractApplication {
|
|
|
995
924
|
this.whiteboard.addPage("doc_continuous");
|
|
996
925
|
this.whiteboard.gotoPage("doc_continuous");
|
|
997
926
|
}
|
|
998
|
-
|
|
999
|
-
this.whiteboard.setViewModeToMain();
|
|
1000
|
-
} else {
|
|
1001
|
-
this.whiteboard.setViewModeToFree();
|
|
1002
|
-
}
|
|
927
|
+
this.whiteboard.setViewModeToFree();
|
|
1003
928
|
this.permissions = new ImageryDocPermissions(this.userManager, (userId) => {
|
|
1004
929
|
return this.userMap(userId);
|
|
1005
930
|
});
|
|
1006
|
-
this.permissions.
|
|
931
|
+
this.permissions.on("change", (userId, flags, value) => {
|
|
932
|
+
this.emitter.emit("permissionChange", userId, flags, value);
|
|
933
|
+
});
|
|
934
|
+
this.permissions.setPermission(ImageryDocPermissionFlag.all);
|
|
1007
935
|
this.whiteboardApp.disableViewModel();
|
|
1008
936
|
this.container.init();
|
|
1009
937
|
this.whiteboard.permissions.removePermission(WhiteboardPermissionFlag.mainView);
|
|
1010
938
|
if (option.inheritWhiteboardId) {
|
|
1011
939
|
whiteboardApp.linkToWhiteboard(option.inheritWhiteboardId);
|
|
1012
940
|
}
|
|
941
|
+
this.emitter.emit("ready");
|
|
1013
942
|
return Promise.resolve(void 0);
|
|
1014
943
|
}
|
|
1015
944
|
userMap(userId) {
|
|
1016
945
|
return this.getMap(`user/${userId}`);
|
|
1017
946
|
}
|
|
1018
|
-
async dispose() {
|
|
1019
|
-
|
|
1020
|
-
|
|
947
|
+
async dispose(removeSubDoc) {
|
|
948
|
+
if (removeSubDoc) {
|
|
949
|
+
this.deleteSubDoc(this.appId);
|
|
950
|
+
}
|
|
951
|
+
await this.whiteboardApp.dispose(removeSubDoc);
|
|
952
|
+
this.whiteboardApp.emitter.view.remove();
|
|
1021
953
|
this.container.dispose();
|
|
954
|
+
this.permissions.dispose();
|
|
955
|
+
this.emitter.removeAllListeners();
|
|
1022
956
|
return Promise.resolve(void 0);
|
|
1023
957
|
}
|
|
1024
958
|
};
|
|
1025
|
-
|
|
959
|
+
_defineProperty7(ImageryDocApplication, "applicationName", IMAGERY_DOC_APP_NAME);
|
|
960
|
+
window.__ImageryDocApplication = ImageryDocApplication;
|
|
1026
961
|
export {
|
|
1027
962
|
ImageryDoc,
|
|
1028
963
|
ImageryDocApplication,
|