@netless/forge-slide 0.1.1-alpha.1 → 0.1.1-alpha.11
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/build.mjs +21 -21
- package/dist/FooterView.d.ts +26 -0
- package/dist/FooterView.d.ts.map +1 -0
- package/dist/ForgeSlidePermession.d.ts +7 -46
- package/dist/ForgeSlidePermession.d.ts.map +1 -1
- package/dist/SiderBarView.d.ts +23 -6
- package/dist/SiderBarView.d.ts.map +1 -1
- package/dist/Slide.d.ts +30 -29
- package/dist/Slide.d.ts.map +1 -1
- package/dist/SlideApplication.d.ts +15 -5
- package/dist/SlideApplication.d.ts.map +1 -1
- package/dist/SlidePool.d.ts +22 -0
- package/dist/SlidePool.d.ts.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +1840 -966
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +1832 -958
- package/dist/index.js.map +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/FooterView.ts +132 -0
- package/src/ForgeSlidePermession.ts +13 -120
- package/src/SiderBarView.ts +174 -73
- package/src/Slide.ts +29 -28
- package/src/SlideApplication.ts +531 -419
- package/src/SlidePool.ts +110 -0
- package/src/icons.ts +5 -5
- package/src/index.ts +4 -4
- package/src/utils.ts +43 -43
- package/src/FoorerView.ts +0 -109
package/dist/index.js
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/.pnpm/@netless+slide@1.4.
|
|
33
|
+
// ../../node_modules/.pnpm/@netless+slide@1.4.21/node_modules/@netless/slide/lib/Slide.js
|
|
34
34
|
var require_Slide = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/@netless+slide@1.4.
|
|
35
|
+
"../../node_modules/.pnpm/@netless+slide@1.4.21/node_modules/@netless/slide/lib/Slide.js"(exports, module2) {
|
|
36
36
|
module2.exports = function(t) {
|
|
37
37
|
var e = {};
|
|
38
38
|
function i(n) {
|
|
@@ -5703,7 +5703,7 @@ var require_Slide = __commonJS({
|
|
|
5703
5703
|
}
|
|
5704
5704
|
return void 0 === d && (d = setTimeout(b2, e2)), c;
|
|
5705
5705
|
}
|
|
5706
|
-
return e2 = o(e2) || 0, n(i2) && (m = !!i2.leading, u = (g = "maxWait" in i2) ? s(o(i2.maxWait) || 0, e2) : u, v = "trailing" in i2 ? !!i2.trailing : v), E.cancel = function() {
|
|
5706
|
+
return e2 = o(e2) || 0, n(i2) && (m = !!i2.leading, u = (g = "maxWait" in i2) ? s(o(i2.maxWait) || 0, e2) : u, v = "trailing" in i2 ? !!i2.trailing : v), console.log("max wait", u), E.cancel = function() {
|
|
5707
5707
|
void 0 !== d && clearTimeout(d), f = 0, l2 = p = h = d = void 0;
|
|
5708
5708
|
}, E.flush = function() {
|
|
5709
5709
|
return void 0 === d ? c : T(r());
|
|
@@ -29372,6 +29372,7 @@ void main(void){
|
|
|
29372
29372
|
const r3 = e2[t3], o3 = e2[t3 + 1], [s3, a3] = o3.split(",").map((t4) => Number(t4) / 100);
|
|
29373
29373
|
i2.push(r3), n2.push({ x: s3, y: a3 });
|
|
29374
29374
|
}
|
|
29375
|
+
if (n2.length < 4) return false;
|
|
29375
29376
|
if (this.isSquare(i2, n2)) return true;
|
|
29376
29377
|
for (let t3 = 0; t3 < 3; t3++) {
|
|
29377
29378
|
const e3 = n2[t3], i3 = n2[t3 + 1];
|
|
@@ -29786,7 +29787,9 @@ void main(void){
|
|
|
29786
29787
|
}
|
|
29787
29788
|
this.delayHide();
|
|
29788
29789
|
}
|
|
29789
|
-
}, this.targetId = t2.targetId, this.ctx = t2.ctx, this.height = t2.height, this.width = t2.width, this.target = t2.target, this.media = t2.media, this.info = t2.info, this.shapeId = t2.shapeId, this.canvasElement = t2.canvasElement, "video" === this.media.type && (this.isVideo = true), this.getMedianContainer(), this.createMediaController(), this.info.cut && (this.start = null !== (e2 = this.info.cut.start) && void 0 !== e2 ? e2 : 0, this.end = null !== (i2 = this.info.cut.end) && void 0 !== i2 ? i2 : 0), this.info.bookmarkList && (this.bookmarkList = this.info.bookmarkList.sort((t3, e3) => t3.time - e3.time))
|
|
29790
|
+
}, this.targetId = t2.targetId, this.ctx = t2.ctx, this.height = t2.height, this.width = t2.width, this.target = t2.target, this.media = t2.media, this.info = t2.info, this.shapeId = t2.shapeId, this.canvasElement = t2.canvasElement, "video" === this.media.type && (this.isVideo = true), this.getMedianContainer(), this.createMediaController(), this.info.cut && (this.start = null !== (e2 = this.info.cut.start) && void 0 !== e2 ? e2 : 0, this.end = null !== (i2 = this.info.cut.end) && void 0 !== i2 ? i2 : 0), this.info.bookmarkList && (this.bookmarkList = this.info.bookmarkList.sort((t3, e3) => t3.time - e3.time)), this.ctx.globalEventHub.on("togglePlayStatus", (t3) => {
|
|
29791
|
+
t3 === this.targetId && (this.media.isPlaying ? this.pauseMediaFromCtrl(false) : this.playMediaFromCtrl(false));
|
|
29792
|
+
});
|
|
29790
29793
|
}
|
|
29791
29794
|
getMedianContainer() {
|
|
29792
29795
|
var t2;
|
|
@@ -30307,9 +30310,10 @@ void main(void){
|
|
|
30307
30310
|
const a3 = null === (t2 = this.backgroundGraphics) || void 0 === t2 ? void 0 : t2.getPictureMask();
|
|
30308
30311
|
if ((null === (e2 = this.backgroundGraphics) || void 0 === e2 ? void 0 : e2.isNeedMask(s2.width, s2.height)) && a3 && (s2.mask = a3, this.effectContainer.addChild(a3)), s2.width = this.designWidth, s2.height = this.designHeight, s2 instanceof im && this.ctx.slideScopeEventHub.on("slide-render", this.onSlideRenderPlayGif), this.effectContainer.addChild(s2), this.media) {
|
|
30309
30312
|
let t3 = this.media.src;
|
|
30310
|
-
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
+
const [e3, i3] = t3.split("dynamicConvert");
|
|
30314
|
+
if (i3 && (t3 = `${this.ctx.prefix}${i3}`), "audio" === this.media.type && /mp4$/.test(t3) && (t3 = t3.replace(/mp4$/, "mp3")), this.ctx.urlInterrupter) {
|
|
30315
|
+
const e4 = Date.now();
|
|
30316
|
+
t3 = yield this.ctx.urlInterrupter(t3), this.ctx.logger.info("redirect media url by interrupter. time: " + (Date.now() - e4), this.ctx.taskId);
|
|
30313
30317
|
}
|
|
30314
30318
|
this.ctx.loaderDelegate && (t3 = this.ctx.loaderDelegate.redirectMedia(t3), this.ctx.logger.info(`redirect media url to ${t3} by delegate.`, this.ctx.taskId)), this.media.src = t3;
|
|
30315
30319
|
}
|
|
@@ -30759,12 +30763,18 @@ void main(void){
|
|
|
30759
30763
|
if ("num" === e2 && this.timingTarget) {
|
|
30760
30764
|
const e3 = new I_(t4, this.timingTarget);
|
|
30761
30765
|
this.keyFrames.push([t4.time, e3]);
|
|
30766
|
+
} else if ("str" === e2 && this.timingTarget) {
|
|
30767
|
+
const e3 = new R_(t4, this.timingTarget);
|
|
30768
|
+
this.keyFrames.push([t4.time, e3]);
|
|
30762
30769
|
}
|
|
30763
30770
|
}
|
|
30764
30771
|
const t3 = { time: 1, val: { type: "string", value: this.json.to }, fmla: "" };
|
|
30765
30772
|
if ("num" === e2 && this.timingTarget) {
|
|
30766
30773
|
const e3 = new I_(t3, this.timingTarget);
|
|
30767
30774
|
this.keyFrames.push([t3.time, e3]);
|
|
30775
|
+
} else if ("str" === e2 && this.timingTarget) {
|
|
30776
|
+
const e3 = new R_(t3, this.timingTarget);
|
|
30777
|
+
this.keyFrames.push([t3.time, e3]);
|
|
30768
30778
|
}
|
|
30769
30779
|
} else if (this.json.by) {
|
|
30770
30780
|
const i2 = { time: 0, val: { type: "string", value: this.json.cBhvr.attrList[0] }, fmla: "" };
|
|
@@ -31129,7 +31139,8 @@ void main(void){
|
|
|
31129
31139
|
const { json: e2, isIterate: i2, isSub: n2, eventHub: r2, ctx: o2, parent: s2, iterateType: a3, iterateIndex: l3, iterateId: h2, isInInteractiveSeq: u2, fromSeqId: c2 } = t2;
|
|
31130
31140
|
this.json = e2, this.id = e2.cMediaNode.ctn.id, this.commonTimeNode = new Ey({ json: e2.cMediaNode.ctn, isSub: n2, eventHubs: { global: r2, runtime: this.runtimeNodeEventHub }, ctx: o2, parent: s2, isIterate: i2, iterateType: a3, iterateIndex: l3, iterateId: h2, isInInteractiveSeq: u2, fromSeqId: c2 });
|
|
31131
31141
|
let d2 = e2.cMediaNode.tgtEl;
|
|
31132
|
-
|
|
31142
|
+
const [p2, f2] = d2.split("dynamicConvert");
|
|
31143
|
+
f2 && (d2 = `${o2.prefix}${f2}`), o2.loaderDelegate && (d2 = o2.loaderDelegate.redirectMedia(d2), o2.logger.info(`redirect media url from ${e2.cMediaNode.tgtEl} to ${d2} by delegate.`, o2.taskId)), this.audio = new c_(d2, o2.runningAudio, void 0, { enableWebAudio: o2.enableWebAudio }), o2.activeMedia.add(this.audio), this.commonTimeNode.on("timelineStart", () => {
|
|
31133
31144
|
this.audio.volume(o2.volumeAdjuster.volume), this.audio.play();
|
|
31134
31145
|
}), this.commonTimeNode.on("seekToStart", this.stopAudio), this.commonTimeNode.on("seekToEnd", this.stopAudio), this.commonTimeNode.on("timeNodeDestroy", this.destroy), this.ctx = o2, this.ctx.volumeAdjuster.on("update", this.onVolumeUpdate);
|
|
31135
31146
|
}
|
|
@@ -31992,7 +32003,7 @@ void main(void){
|
|
|
31992
32003
|
createCtx(t2) {
|
|
31993
32004
|
const { task: e2 } = this.stageStates[t2];
|
|
31994
32005
|
e2.addMTask(() => Dy(this, void 0, void 0, function* () {
|
|
31995
|
-
const e3 = new Gm(this.loader), i2 = new Za.a(), n2 = { taskId: this.taskId, mode: this.mode, renderer: this.renderer, graphicsTexture: new Km(this.maxResolution), stageWidth: 0, stageHeight: 0, ticker: this.ticker, timingTargets: new $m(i2), eventHub: i2, view: this.view, medias: /* @__PURE__ */ Object.create(null), lastViewedIndex: 0, conflictTimeNodeManager: new Qm(), clock: this.clock, spriteTexture: e3, slideIndex: t2, objectPoolGroup: this.objPoolGroup, hasBackgroundFillShape: false, slideScopeEventHub: new Za.a(), logger: this.logger, sdfManager: this.sdfManager, loaderDelegate: this.loaderDelegate, runningAudio: this.runningAudio, activeMedia: this.activeMedia, isPlayerPaused: this.isPlayerPaused, timingEventHub: new Za.a(), maxResolution: this.maxResolution, animatedIds: /* @__PURE__ */ new Set(), volumeAdjuster: this.volumeAdjuster, forceCanvas: this.forceCanvas, globalEventHub: this.globalEventHub, latestChangeFullscreenTargetId: "", isRendering: false, urlInterrupter: this.urlInterrupter, enableWebAudio: this.enableWebAudio };
|
|
32006
|
+
const e3 = new Gm(this.loader), i2 = new Za.a(), n2 = { taskId: this.taskId, prefix: this.url, mode: this.mode, renderer: this.renderer, graphicsTexture: new Km(this.maxResolution), stageWidth: 0, stageHeight: 0, ticker: this.ticker, timingTargets: new $m(i2), eventHub: i2, view: this.view, medias: /* @__PURE__ */ Object.create(null), lastViewedIndex: 0, conflictTimeNodeManager: new Qm(), clock: this.clock, spriteTexture: e3, slideIndex: t2, objectPoolGroup: this.objPoolGroup, hasBackgroundFillShape: false, slideScopeEventHub: new Za.a(), logger: this.logger, sdfManager: this.sdfManager, loaderDelegate: this.loaderDelegate, runningAudio: this.runningAudio, activeMedia: this.activeMedia, isPlayerPaused: this.isPlayerPaused, timingEventHub: new Za.a(), maxResolution: this.maxResolution, animatedIds: /* @__PURE__ */ new Set(), volumeAdjuster: this.volumeAdjuster, forceCanvas: this.forceCanvas, globalEventHub: this.globalEventHub, latestChangeFullscreenTargetId: "", isRendering: false, urlInterrupter: this.urlInterrupter, enableWebAudio: this.enableWebAudio };
|
|
31996
32007
|
this.stageCtxs[t2] = n2;
|
|
31997
32008
|
}), "@StagePool[createCtx]");
|
|
31998
32009
|
}
|
|
@@ -32288,11 +32299,15 @@ void main(void){
|
|
|
32288
32299
|
this.app.view.addEventListener("mouseover", e4, false);
|
|
32289
32300
|
const r3 = { handleEvent: () => {
|
|
32290
32301
|
this.fullscreenOnMousemove({ index: i3, targetId: n3 });
|
|
32302
|
+
} }, o3 = { handleEvent: () => {
|
|
32303
|
+
var t5;
|
|
32304
|
+
null === (t5 = this.currentStage) || void 0 === t5 || t5.ctx.globalEventHub.emit("togglePlayStatus", n3);
|
|
32291
32305
|
} };
|
|
32292
|
-
this.app.view.addEventListener("mousemove", r3, false), this.cacheFunctionMap.set("mouseover", e4), this.cacheFunctionMap.set("mousemove", r3), this.cacheFunctionMap.set("mouseout", t4);
|
|
32306
|
+
this.app.view.addEventListener("mousemove", r3, false), this.app.view.addEventListener("click", o3, false), this.cacheFunctionMap.set("click", o3), this.cacheFunctionMap.set("mouseover", e4), this.cacheFunctionMap.set("mousemove", r3), this.cacheFunctionMap.set("mouseout", t4);
|
|
32293
32307
|
} else {
|
|
32294
32308
|
const t4 = { handleEvent: () => {
|
|
32295
|
-
|
|
32309
|
+
var t5;
|
|
32310
|
+
this.fullscreenOnMousemove({ index: i3, targetId: n3 }), null === (t5 = this.currentStage) || void 0 === t5 || t5.ctx.globalEventHub.emit("togglePlayStatus", n3);
|
|
32296
32311
|
} };
|
|
32297
32312
|
this.app.view.addEventListener("touchstart", t4, false), this.cacheFunctionMap.set("touchstart", t4);
|
|
32298
32313
|
}
|
|
@@ -32602,7 +32617,7 @@ void main(void){
|
|
|
32602
32617
|
});
|
|
32603
32618
|
}
|
|
32604
32619
|
clearFullscreenEventListenersWithAppView() {
|
|
32605
|
-
["mousemove", "mouseout", "mouseover", "touchstart", "pointerdown"].forEach((t2) => {
|
|
32620
|
+
["mousemove", "click", "mouseout", "mouseover", "touchstart", "pointerdown"].forEach((t2) => {
|
|
32606
32621
|
this.cacheFunctionMap.has(t2) && (this.app.view.removeEventListener(t2, this.cacheFunctionMap.get(t2), false), this.cacheFunctionMap.delete(t2));
|
|
32607
32622
|
});
|
|
32608
32623
|
}
|
|
@@ -34224,23 +34239,44 @@ void main(void){
|
|
|
34224
34239
|
};
|
|
34225
34240
|
}
|
|
34226
34241
|
};
|
|
34227
|
-
function sT(t2, e2, i2, n2) {
|
|
34242
|
+
function sT(t2, e2, i2, n2, r2) {
|
|
34228
34243
|
return rT(this, void 0, void 0, function() {
|
|
34229
|
-
var
|
|
34230
|
-
return oT(this, function(
|
|
34231
|
-
switch (
|
|
34244
|
+
var o2, s2, a3, l3, h2, u2;
|
|
34245
|
+
return oT(this, function(c2) {
|
|
34246
|
+
switch (c2.label) {
|
|
34232
34247
|
case 0:
|
|
34233
|
-
return
|
|
34248
|
+
return o2 = document.createElement("div"), (s2 = new yT({ anchor: o2, renderOptions: { minFPS: 1, maxFPS: 1, resolution: 1, maxResolutionLevel: i2, forceCanvas: true }, mode: "local", interactive: false, useLocalCache: true })).setResource(t2, e2), [4, s2.getSlideCountAsync()];
|
|
34234
34249
|
case 1:
|
|
34235
|
-
|
|
34250
|
+
a3 = c2.sent(), c2.label = 2;
|
|
34236
34251
|
case 2:
|
|
34237
|
-
|
|
34252
|
+
if (c2.trys.push([2, 12, 13, 14]), !(r2 && r2.length > 0)) return [3, 7];
|
|
34253
|
+
l3 = r2.filter(function(t3, e3) {
|
|
34254
|
+
return r2.indexOf(t3) === e3;
|
|
34255
|
+
}), u2 = 0, c2.label = 3;
|
|
34238
34256
|
case 3:
|
|
34239
|
-
l3.
|
|
34257
|
+
return u2 < l3.length ? (h2 = l3[u2]) > 0 && h2 <= a3 ? [4, s2.player.stagePool.preload(h2, true)] : [3, 5] : [3, 6];
|
|
34240
34258
|
case 4:
|
|
34241
|
-
|
|
34259
|
+
c2.sent(), n2(Math.round((u2 + 1) / l3.length * 100) / 100), c2.label = 5;
|
|
34242
34260
|
case 5:
|
|
34243
|
-
return
|
|
34261
|
+
return u2++, [3, 3];
|
|
34262
|
+
case 6:
|
|
34263
|
+
return [3, 11];
|
|
34264
|
+
case 7:
|
|
34265
|
+
u2 = 1, c2.label = 8;
|
|
34266
|
+
case 8:
|
|
34267
|
+
return u2 <= a3 ? [4, s2.player.stagePool.preload(u2, true)] : [3, 11];
|
|
34268
|
+
case 9:
|
|
34269
|
+
c2.sent(), n2(Math.round(u2 / a3 * 100) / 100), c2.label = 10;
|
|
34270
|
+
case 10:
|
|
34271
|
+
return u2++, [3, 8];
|
|
34272
|
+
case 11:
|
|
34273
|
+
return [3, 14];
|
|
34274
|
+
case 12:
|
|
34275
|
+
throw c2.sent();
|
|
34276
|
+
case 13:
|
|
34277
|
+
return s2.destroy(), [7];
|
|
34278
|
+
case 14:
|
|
34279
|
+
return [2];
|
|
34244
34280
|
}
|
|
34245
34281
|
});
|
|
34246
34282
|
});
|
|
@@ -34376,7 +34412,7 @@ void main(void){
|
|
|
34376
34412
|
}
|
|
34377
34413
|
var mT = { syncDispatch: "syncDispatch", syncReceive: "syncReceive", syncEventLag: "syncEventLag", renderStart: "renderStart", renderEnd: "renderEnd", renderError: "renderError", slideChange: "slideChange", mainSeqStepStart: "mainSeqStepStart", mainSeqStepEnd: "mainSeqStepEnd", animateStart: "animateStart", animateEnd: "animateEnd", stateChange: "stateChange", slideStepEnd: "slideEnd", slideStepStart: "slideStart" }, gT = { taskId: "", url: "", currentSlideIndex: -1, mainSeqStep: -1, mainSeqState: null, mediaState: /* @__PURE__ */ Object.create(null), interactiveSeqState: /* @__PURE__ */ Object.create(null) }, vT = "";
|
|
34378
34414
|
try {
|
|
34379
|
-
vT = "1.4.
|
|
34415
|
+
vT = "1.4.20";
|
|
34380
34416
|
} catch (t2) {
|
|
34381
34417
|
vT = "dev";
|
|
34382
34418
|
}
|
|
@@ -34395,7 +34431,7 @@ void main(void){
|
|
|
34395
34431
|
return n3.frameResizeHandler();
|
|
34396
34432
|
}), n3.timestamp = function() {
|
|
34397
34433
|
return Date.now();
|
|
34398
|
-
}, n3.mode = "local", n3.enableGlobalClick = false, n3.lastEmitedState = null, n3.playerController = null, n3.isInitResized = false, n3.cacheImage = document.createElement("img"), n3.isTouchStart = false, n3.touchStartId = void 0, n3.taskId = "", n3.volumeAdjuster = new Hy(), n3.designWidth = 0, n3.designHeight = 0, n3._slideCount = 0, n3._dispatchIncrId = 0, n3._receiveIncrId = 0, n3.resizeView = Ky()(n3._resizeView.bind(n3), 50), n3.handleViewClick = Ky()(n3._handleViewClick.bind(n3), 300), n3.resourceList = [], n3._updateVolumeByStaticAdjuster = function(t3) {
|
|
34434
|
+
}, n3.mode = "local", n3.enableGlobalClick = false, n3.lastEmitedState = null, n3.playerController = null, n3.isInitResized = false, n3.cacheImage = document.createElement("img"), n3.isTouchStart = false, n3.touchStartId = void 0, n3.taskId = "", n3.volumeAdjuster = new Hy(), n3.designWidth = 0, n3.designHeight = 0, n3._slideCount = 0, n3._dispatchIncrId = 0, n3._receiveIncrId = 0, n3.resizeView = Ky()(n3._resizeView.bind(n3), 50), n3.handleViewClick = Ky()(n3._handleViewClick.bind(n3), 300, { leading: true }), n3.resourceList = [], n3._updateVolumeByStaticAdjuster = function(t3) {
|
|
34399
34435
|
n3.volumeAdjuster.volume = t3;
|
|
34400
34436
|
}, n3.recoverHandler = function(t3) {
|
|
34401
34437
|
if ("@slide/_recover_" === t3.data.type && t3.data.slideId === n3.randomId) {
|
|
@@ -34577,7 +34613,7 @@ void main(void){
|
|
|
34577
34613
|
return o2.setInteractive(this.interactive), o2.updateConfig(t3.renderOptions || {}), o2.on(Vy.renderStart, function(t4) {
|
|
34578
34614
|
r2.isLoading = true, r2.emit(mT.renderStart, t4), window.postMessage({ type: "@slide/_render_start_", taskId: r2.taskId, index: t4 }, "*");
|
|
34579
34615
|
}), o2.on(Vy.renderEnd, function(t4) {
|
|
34580
|
-
r2.isLoading = false, r2.player && (r2.designHeight = r2.player.designHeight, r2.designWidth = r2.player.designWidth, r2.cacheImage.style.width = r2.player.designWidth + "px", r2.cacheImage.style.height = r2.player.designHeight + "px", r2._slideCount = r2.player.slideCount), r2.emit(mT.renderEnd, t4), window.postMessage({ type: "@slide/_render_end_", taskId: r2.taskId, index: t4 }, "*");
|
|
34616
|
+
r2.isLoading = false, r2.player && (r2.designHeight = r2.player.designHeight, r2.designWidth = r2.player.designWidth, r2.cacheImage.style.width = r2.player.designWidth + "px", r2.cacheImage.style.height = r2.player.designHeight + "px", r2.cacheImage.style.maxWidth = r2.player.designWidth + "px", r2.cacheImage.style.minWidth = r2.player.designHeight + "px", r2._slideCount = r2.player.slideCount), r2.emit(mT.renderEnd, t4), window.postMessage({ type: "@slide/_render_end_", taskId: r2.taskId, index: t4 }, "*");
|
|
34581
34617
|
}), o2.on(Vy.slideChange, function(t4) {
|
|
34582
34618
|
r2.__slideState.currentSlideIndex = t4, r2.emitStateChange(), r2.emit(mT.slideChange, t4);
|
|
34583
34619
|
}), o2.on(Vy.mainSeqStateChange, function(t4) {
|
|
@@ -35105,22 +35141,27 @@ void main(void){
|
|
|
35105
35141
|
}(Za.a);
|
|
35106
35142
|
null == _T || _T.clear().catch(function() {
|
|
35107
35143
|
}), window.addEventListener("__slide_log__", yT.handleLogDownload), window.addEventListener("message", function(t2) {
|
|
35144
|
+
var e2;
|
|
35108
35145
|
if ("@slide/_request_log_" === t2.data.type) yT.handleLogReport(t2.data.sessionId).catch(function() {
|
|
35109
35146
|
});
|
|
35110
35147
|
else if ("@slide/_request_frozen_" === t2.data.type) yT.handleFrozenAllSlide();
|
|
35111
35148
|
else if ("@slide/_request_release_" === t2.data.type) yT.handleReleaseAllSlide();
|
|
35112
35149
|
else if ("@slide/_update_volume_" === t2.data.type) {
|
|
35113
|
-
var
|
|
35150
|
+
var i2 = 0.5;
|
|
35114
35151
|
try {
|
|
35115
|
-
|
|
35152
|
+
i2 = parseFloat(t2.data.volume.toString());
|
|
35116
35153
|
} catch (t3) {
|
|
35117
35154
|
}
|
|
35118
|
-
yT.volumeAdjuster.volume =
|
|
35119
|
-
} else "@slide/_get_volume_" === t2.data.type
|
|
35120
|
-
|
|
35121
|
-
|
|
35122
|
-
|
|
35123
|
-
|
|
35155
|
+
yT.volumeAdjuster.volume = i2;
|
|
35156
|
+
} else if ("@slide/_get_volume_" === t2.data.type) window.postMessage({ type: "@slide/_report_volume_", volume: yT.volumeAdjuster.volume, customMessage: "@slide/_report_volume_" }, "*");
|
|
35157
|
+
else if ("@slide/_preload_slide_" === t2.data.type) {
|
|
35158
|
+
var n2 = null !== (e2 = t2.data.sessionId) && void 0 !== e2 ? e2 : Math.random().toString(32).substr(2);
|
|
35159
|
+
yT.preloadResource(t2.data.taskId, t2.data.prefix, t2.data.maxResolutionLevel, function(e3) {
|
|
35160
|
+
window.postMessage({ type: "@slide/_preload_slide_progress_", sessionId: n2, taskId: t2.data.taskId, progress: e3 }, "*");
|
|
35161
|
+
}, t2.data.pages).catch(function(e3) {
|
|
35162
|
+
window.postMessage({ type: "@slide/_preload_slide_error_", sessionId: n2, taskId: t2.data.taskId, error: e3 }, "*");
|
|
35163
|
+
});
|
|
35164
|
+
}
|
|
35124
35165
|
}), window.setInterval(function() {
|
|
35125
35166
|
yT.flushLog().catch(function() {
|
|
35126
35167
|
});
|
|
@@ -35144,33 +35185,42 @@ var Y15 = __toESM(require("yjs"), 1);
|
|
|
35144
35185
|
var Y12 = __toESM(require("yjs"), 1);
|
|
35145
35186
|
var import_eventemitter3 = __toESM(require("eventemitter3"), 1);
|
|
35146
35187
|
var import_uuid = require("uuid");
|
|
35188
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
35147
35189
|
var Y2 = __toESM(require("yjs"), 1);
|
|
35148
35190
|
var Y = __toESM(require("yjs"), 1);
|
|
35191
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
35149
35192
|
var Y3 = __toESM(require("yjs"), 1);
|
|
35150
35193
|
var Y4 = __toESM(require("yjs"), 1);
|
|
35151
35194
|
var Y5 = __toESM(require("yjs"), 1);
|
|
35152
35195
|
var Y6 = __toESM(require("yjs"), 1);
|
|
35196
|
+
var import_forge_room4 = require("@netless/forge-room");
|
|
35153
35197
|
var Y7 = __toESM(require("yjs"), 1);
|
|
35154
35198
|
var Y8 = __toESM(require("yjs"), 1);
|
|
35155
35199
|
var Y9 = __toESM(require("yjs"), 1);
|
|
35156
35200
|
var Y10 = __toESM(require("yjs"), 1);
|
|
35157
|
-
var
|
|
35201
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
35158
35202
|
var Y11 = __toESM(require("yjs"), 1);
|
|
35159
|
-
var
|
|
35203
|
+
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
35204
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
35160
35205
|
var Y13 = __toESM(require("yjs"), 1);
|
|
35206
|
+
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
35207
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
35161
35208
|
var import_eventemitter34 = __toESM(require("eventemitter3"), 1);
|
|
35162
|
-
var import_eventemitter35 =
|
|
35163
|
-
var import_eventemitter36 = require("eventemitter3");
|
|
35209
|
+
var import_eventemitter35 = require("eventemitter3");
|
|
35210
|
+
var import_eventemitter36 = __toESM(require("eventemitter3"), 1);
|
|
35164
35211
|
var import_eventemitter37 = __toESM(require("eventemitter3"), 1);
|
|
35212
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
35165
35213
|
var import_eventemitter38 = __toESM(require("eventemitter3"), 1);
|
|
35166
|
-
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
35167
35214
|
var Y14 = __toESM(require("yjs"), 1);
|
|
35215
|
+
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
35216
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
35168
35217
|
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
35218
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
35169
35219
|
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
35170
|
-
var
|
|
35220
|
+
var import_forge_room11 = require("@netless/forge-room");
|
|
35221
|
+
var import_forge_room12 = require("@netless/forge-room");
|
|
35171
35222
|
var import_eventemitter312 = __toESM(require("eventemitter3"), 1);
|
|
35172
|
-
var
|
|
35173
|
-
var import_eventemitter313 = __toESM(require("eventemitter3"), 1);
|
|
35223
|
+
var import_forge_room13 = require("@netless/forge-room");
|
|
35174
35224
|
var __create2 = Object.create;
|
|
35175
35225
|
var __defProp2 = Object.defineProperty;
|
|
35176
35226
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -58945,7 +58995,7 @@ var require_lodash = __commonJS2({
|
|
|
58945
58995
|
var defer = baseRest(function(func, args) {
|
|
58946
58996
|
return baseDelay(func, 1, args);
|
|
58947
58997
|
});
|
|
58948
|
-
var
|
|
58998
|
+
var delay2 = baseRest(function(func, wait, args) {
|
|
58949
58999
|
return baseDelay(func, toNumber(wait) || 0, args);
|
|
58950
59000
|
});
|
|
58951
59001
|
function flip(func) {
|
|
@@ -60059,7 +60109,7 @@ var require_lodash = __commonJS2({
|
|
|
60059
60109
|
lodash.defaults = defaults;
|
|
60060
60110
|
lodash.defaultsDeep = defaultsDeep;
|
|
60061
60111
|
lodash.defer = defer;
|
|
60062
|
-
lodash.delay =
|
|
60112
|
+
lodash.delay = delay2;
|
|
60063
60113
|
lodash.difference = difference;
|
|
60064
60114
|
lodash.differenceBy = differenceBy;
|
|
60065
60115
|
lodash.differenceWith = differenceWith;
|
|
@@ -60750,11 +60800,12 @@ var ElementModel = class _ElementModel {
|
|
|
60750
60800
|
set shadow(value) {
|
|
60751
60801
|
this.root.set(_ElementModel.KEYS.shadow, value);
|
|
60752
60802
|
}
|
|
60753
|
-
constructor(root, scope) {
|
|
60803
|
+
constructor(root, scope, liveCursor) {
|
|
60754
60804
|
_defineProperty(this, "shadowEmitter", null);
|
|
60755
60805
|
_defineProperty(this, "root", void 0);
|
|
60756
60806
|
_defineProperty(this, "scope", void 0);
|
|
60757
60807
|
_defineProperty(this, "item", void 0);
|
|
60808
|
+
_defineProperty(this, "liveCursor", void 0);
|
|
60758
60809
|
_defineProperty(this, "handlePropChange", (events) => {
|
|
60759
60810
|
if (!this.item) {
|
|
60760
60811
|
return;
|
|
@@ -60763,7 +60814,7 @@ var ElementModel = class _ElementModel {
|
|
|
60763
60814
|
if (event.target === this.root) {
|
|
60764
60815
|
const updatePaperItemKeys = this.vectorKeys().concat([_ElementModel.KEYS.pointsMatrix]);
|
|
60765
60816
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
60766
|
-
if (value.action === "update") {
|
|
60817
|
+
if (value.action === "update" || value.action == "add") {
|
|
60767
60818
|
const includeKeys = this.styleKeys().include;
|
|
60768
60819
|
if (includeKeys.indexOf(key) >= 0) {
|
|
60769
60820
|
this.onStyleKeyUpdate(key);
|
|
@@ -60783,6 +60834,10 @@ var ElementModel = class _ElementModel {
|
|
|
60783
60834
|
if (this.shadow !== "") {
|
|
60784
60835
|
this.shadowEmitter?.emit("translateIn", [this.uuid], this.shadow);
|
|
60785
60836
|
} else {
|
|
60837
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
60838
|
+
if (ownerId) {
|
|
60839
|
+
this.liveCursor.updateCursorVisible(false, ownerId);
|
|
60840
|
+
}
|
|
60786
60841
|
this.shadowEmitter?.emit("translateOut", [this.uuid], value.oldValue);
|
|
60787
60842
|
}
|
|
60788
60843
|
}
|
|
@@ -60790,11 +60845,17 @@ var ElementModel = class _ElementModel {
|
|
|
60790
60845
|
}
|
|
60791
60846
|
} else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
|
|
60792
60847
|
this.onVectorUpdate();
|
|
60848
|
+
const liveCursorPoint = this.liveCursorPoint();
|
|
60849
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
60850
|
+
if (liveCursorPoint && ownerId) {
|
|
60851
|
+
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
60852
|
+
}
|
|
60793
60853
|
} else {
|
|
60794
60854
|
}
|
|
60795
60855
|
}
|
|
60796
60856
|
});
|
|
60797
60857
|
this.scope = scope;
|
|
60858
|
+
this.liveCursor = liveCursor;
|
|
60798
60859
|
this.root = root;
|
|
60799
60860
|
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
60800
60861
|
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
@@ -60852,6 +60913,10 @@ var ElementModel = class _ElementModel {
|
|
|
60852
60913
|
const ext = this.styleKeys();
|
|
60853
60914
|
return Array.from(new Set(["dashArray", "strokeColor", "fillColor", "strokeWidth"].filter((v) => ext.exclude.indexOf(v) < 0).concat(ext.include)));
|
|
60854
60915
|
}
|
|
60916
|
+
dispose() {
|
|
60917
|
+
this.subDispose();
|
|
60918
|
+
(0, import_forge_room3.removeDeepObserver)(this.root, this.handlePropChange);
|
|
60919
|
+
}
|
|
60855
60920
|
};
|
|
60856
60921
|
_defineProperty(ElementModel, "KEYS", {
|
|
60857
60922
|
index: "index",
|
|
@@ -60918,47 +60983,49 @@ function _toPrimitive3(t, r) {
|
|
|
60918
60983
|
return ("string" === r ? String : Number)(t);
|
|
60919
60984
|
}
|
|
60920
60985
|
var CurveModel = class extends ElementModel {
|
|
60921
|
-
constructor(root, scope) {
|
|
60922
|
-
super(root, scope);
|
|
60986
|
+
constructor(root, scope, liveCursor) {
|
|
60987
|
+
super(root, scope, liveCursor);
|
|
60923
60988
|
_defineProperty3(this, "item", null);
|
|
60989
|
+
_defineProperty3(this, "debugPath", void 0);
|
|
60990
|
+
_defineProperty3(this, "debug", false);
|
|
60924
60991
|
if (!this.root.has("type")) {
|
|
60925
60992
|
this.root.set("type", "curve");
|
|
60926
60993
|
}
|
|
60927
60994
|
if (!this.root.has("points")) {
|
|
60928
60995
|
this.root.set("points", new Y2.Array());
|
|
60929
60996
|
}
|
|
60997
|
+
this.debugPath = new scope.Path();
|
|
60930
60998
|
}
|
|
60931
60999
|
average(a2, b2) {
|
|
60932
61000
|
return (a2 + b2) / 2;
|
|
60933
61001
|
}
|
|
60934
61002
|
parsePoints(points) {
|
|
60935
|
-
|
|
60936
|
-
return ae(groupPoints, {
|
|
61003
|
+
return ae(points, {
|
|
60937
61004
|
size: this.strokeWidth,
|
|
60938
|
-
smoothing: 0,
|
|
60939
|
-
thinning: 0.5,
|
|
61005
|
+
smoothing: 0.5,
|
|
61006
|
+
thinning: -0.5,
|
|
60940
61007
|
streamline: 0.5,
|
|
60941
61008
|
simulatePressure: true,
|
|
60942
61009
|
start: {
|
|
60943
|
-
taper: 10,
|
|
61010
|
+
taper: this.strokeWidth * 10,
|
|
60944
61011
|
cap: true
|
|
60945
61012
|
},
|
|
60946
61013
|
end: {
|
|
60947
|
-
taper:
|
|
61014
|
+
taper: this.strokeWidth * 20,
|
|
60948
61015
|
cap: true
|
|
60949
61016
|
}
|
|
60950
61017
|
});
|
|
60951
61018
|
}
|
|
60952
61019
|
matrixedPoints() {
|
|
60953
|
-
const
|
|
60954
|
-
|
|
60955
|
-
|
|
60956
|
-
|
|
60957
|
-
|
|
60958
|
-
|
|
60959
|
-
|
|
60960
|
-
|
|
60961
|
-
|
|
61020
|
+
const points = this.points;
|
|
61021
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
61022
|
+
const output = [];
|
|
61023
|
+
for (let i = 0, len = points.length; i < len; i += 2) {
|
|
61024
|
+
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
61025
|
+
const tp = p.transform(matrix);
|
|
61026
|
+
output.push([tp.x, tp.y]);
|
|
61027
|
+
}
|
|
61028
|
+
return output;
|
|
60962
61029
|
}
|
|
60963
61030
|
createPath(points) {
|
|
60964
61031
|
const path = new this.scope.Path();
|
|
@@ -60985,27 +61052,41 @@ var CurveModel = class extends ElementModel {
|
|
|
60985
61052
|
}
|
|
60986
61053
|
return path;
|
|
60987
61054
|
}
|
|
60988
|
-
|
|
60989
|
-
|
|
60990
|
-
const
|
|
60991
|
-
|
|
61055
|
+
updateDebugPath() {
|
|
61056
|
+
this.debugPath = new this.scope.Path();
|
|
61057
|
+
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
61058
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
61059
|
+
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
61060
|
+
if (i === 0) {
|
|
61061
|
+
this.debugPath.moveTo(point);
|
|
61062
|
+
} else {
|
|
61063
|
+
this.debugPath.lineTo(point);
|
|
61064
|
+
}
|
|
61065
|
+
this.debugPath.strokeWidth = 1;
|
|
61066
|
+
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
61067
|
+
}
|
|
60992
61068
|
}
|
|
60993
61069
|
onVectorUpdate() {
|
|
60994
61070
|
if (!this.item) {
|
|
60995
61071
|
return;
|
|
60996
61072
|
}
|
|
61073
|
+
if (this.debug) {
|
|
61074
|
+
this.debugPath.remove();
|
|
61075
|
+
this.updateDebugPath();
|
|
61076
|
+
}
|
|
61077
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
61078
|
+
const path = this.createPath(points);
|
|
60997
61079
|
this.item.removeSegments();
|
|
60998
|
-
this.item.addSegments(
|
|
60999
|
-
this.
|
|
61080
|
+
this.item.addSegments(path.segments);
|
|
61081
|
+
if (this.debug) {
|
|
61082
|
+
this.item.addChild(this.debugPath);
|
|
61083
|
+
}
|
|
61000
61084
|
}
|
|
61001
61085
|
createPaperItem() {
|
|
61002
61086
|
this.item = new this.scope.Path();
|
|
61003
|
-
this.item.strokeCap = "round";
|
|
61004
|
-
this.item.strokeJoin = "round";
|
|
61005
|
-
this.item.strokeScaling = false;
|
|
61006
61087
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
61007
61088
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
61008
|
-
this.
|
|
61089
|
+
this.onVectorUpdate();
|
|
61009
61090
|
}
|
|
61010
61091
|
editorConfig() {
|
|
61011
61092
|
return new EditorConfig();
|
|
@@ -61015,10 +61096,19 @@ var CurveModel = class extends ElementModel {
|
|
|
61015
61096
|
}
|
|
61016
61097
|
styleKeys() {
|
|
61017
61098
|
return {
|
|
61018
|
-
include: ["strokeColor"],
|
|
61019
|
-
exclude: ["
|
|
61099
|
+
include: ["strokeColor", "strokeWidth"],
|
|
61100
|
+
exclude: ["dashArray", "fillColor"]
|
|
61020
61101
|
};
|
|
61021
61102
|
}
|
|
61103
|
+
liveCursorPoint() {
|
|
61104
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61105
|
+
if (yArray.length < 2) {
|
|
61106
|
+
return null;
|
|
61107
|
+
}
|
|
61108
|
+
const len = yArray.length;
|
|
61109
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
61110
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61111
|
+
}
|
|
61022
61112
|
onStyleKeyUpdate(key) {
|
|
61023
61113
|
if (!this.item) {
|
|
61024
61114
|
return;
|
|
@@ -61026,8 +61116,12 @@ var CurveModel = class extends ElementModel {
|
|
|
61026
61116
|
if (key === "strokeColor") {
|
|
61027
61117
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
61028
61118
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
61119
|
+
} else if (key === "strokeWidth") {
|
|
61120
|
+
this.onVectorUpdate();
|
|
61029
61121
|
}
|
|
61030
61122
|
}
|
|
61123
|
+
subDispose() {
|
|
61124
|
+
}
|
|
61031
61125
|
};
|
|
61032
61126
|
function _defineProperty4(e, r, t) {
|
|
61033
61127
|
return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -61047,8 +61141,8 @@ function _toPrimitive4(t, r) {
|
|
|
61047
61141
|
return ("string" === r ? String : Number)(t);
|
|
61048
61142
|
}
|
|
61049
61143
|
var SelectorModel = class extends ElementModel {
|
|
61050
|
-
constructor(root, scope) {
|
|
61051
|
-
super(root, scope);
|
|
61144
|
+
constructor(root, scope, liveCursor) {
|
|
61145
|
+
super(root, scope, liveCursor);
|
|
61052
61146
|
_defineProperty4(this, "item", null);
|
|
61053
61147
|
if (!this.root.has("type")) {
|
|
61054
61148
|
this.root.set("type", "selector");
|
|
@@ -61059,14 +61153,15 @@ var SelectorModel = class extends ElementModel {
|
|
|
61059
61153
|
this.root.set("points", initPoints);
|
|
61060
61154
|
}
|
|
61061
61155
|
}
|
|
61156
|
+
liveCursorPoint() {
|
|
61157
|
+
return null;
|
|
61158
|
+
}
|
|
61159
|
+
subDispose() {
|
|
61160
|
+
}
|
|
61062
61161
|
createPaperRect() {
|
|
61063
61162
|
const scope = this.scope;
|
|
61064
61163
|
const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
|
|
61065
|
-
return new scope.Path.Rectangle(
|
|
61066
|
-
bounds,
|
|
61067
|
-
new scope.Point(this.points[4], this.points[4])
|
|
61068
|
-
// 圆角
|
|
61069
|
-
);
|
|
61164
|
+
return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
|
|
61070
61165
|
}
|
|
61071
61166
|
onVectorUpdate() {
|
|
61072
61167
|
if (!this.item) {
|
|
@@ -61092,7 +61187,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
61092
61187
|
exclude: []
|
|
61093
61188
|
};
|
|
61094
61189
|
}
|
|
61095
|
-
onStyleKeyUpdate(
|
|
61190
|
+
onStyleKeyUpdate(_key) {
|
|
61096
61191
|
}
|
|
61097
61192
|
};
|
|
61098
61193
|
var import_lodash2 = __toESM2(require_lodash(), 1);
|
|
@@ -61139,7 +61234,7 @@ var AnimationFrame = class {
|
|
|
61139
61234
|
_defineProperty5(this, "lastTime", 0);
|
|
61140
61235
|
_defineProperty5(this, "fps", 45);
|
|
61141
61236
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
61142
|
-
|
|
61237
|
+
const functions = this.callbacks;
|
|
61143
61238
|
this.callbacks = [];
|
|
61144
61239
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
61145
61240
|
functions[i]();
|
|
@@ -61180,8 +61275,8 @@ function _toPrimitive6(t, r) {
|
|
|
61180
61275
|
return ("string" === r ? String : Number)(t);
|
|
61181
61276
|
}
|
|
61182
61277
|
var SegmentsModel = class extends ElementModel {
|
|
61183
|
-
constructor(root, scope, type) {
|
|
61184
|
-
super(root, scope);
|
|
61278
|
+
constructor(root, scope, type, liveCursor) {
|
|
61279
|
+
super(root, scope, liveCursor);
|
|
61185
61280
|
_defineProperty6(this, "item", null);
|
|
61186
61281
|
if (!this.root.has("type")) {
|
|
61187
61282
|
this.root.set("type", type);
|
|
@@ -61190,6 +61285,16 @@ var SegmentsModel = class extends ElementModel {
|
|
|
61190
61285
|
this.root.set("points", new Y4.Array());
|
|
61191
61286
|
}
|
|
61192
61287
|
}
|
|
61288
|
+
subDispose() {
|
|
61289
|
+
}
|
|
61290
|
+
liveCursorPoint() {
|
|
61291
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61292
|
+
if (yArray.length < 2) {
|
|
61293
|
+
return null;
|
|
61294
|
+
}
|
|
61295
|
+
const point = new this.scope.Point(yArray.get(0), yArray.get(1));
|
|
61296
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61297
|
+
}
|
|
61193
61298
|
onVectorUpdate() {
|
|
61194
61299
|
if (!this.item) {
|
|
61195
61300
|
return;
|
|
@@ -61224,7 +61329,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
61224
61329
|
exclude: []
|
|
61225
61330
|
};
|
|
61226
61331
|
}
|
|
61227
|
-
onStyleKeyUpdate(
|
|
61332
|
+
onStyleKeyUpdate(_key) {
|
|
61228
61333
|
}
|
|
61229
61334
|
};
|
|
61230
61335
|
var import_lodash4 = __toESM2(require_lodash(), 1);
|
|
@@ -61308,9 +61413,13 @@ var LineTool = class extends WhiteboardTool {
|
|
|
61308
61413
|
_defineProperty8(this, "elementModel", null);
|
|
61309
61414
|
_defineProperty8(this, "from", null);
|
|
61310
61415
|
_defineProperty8(this, "to", null);
|
|
61416
|
+
_defineProperty8(this, "showLiveCursor", true);
|
|
61311
61417
|
this.tool.minDistance = 1;
|
|
61312
61418
|
}
|
|
61313
61419
|
onMouseDown(event) {
|
|
61420
|
+
if (this.elementModel) {
|
|
61421
|
+
this.elementModel.dispose();
|
|
61422
|
+
}
|
|
61314
61423
|
this.elementModel = this.modelGetter().createLinePath(true);
|
|
61315
61424
|
this.from = event.point.clone();
|
|
61316
61425
|
this.to = event.point.clone();
|
|
@@ -61367,8 +61476,8 @@ var LineModel = class extends ElementModel {
|
|
|
61367
61476
|
set tailArrow(value) {
|
|
61368
61477
|
this.root.set("tailArrow", value);
|
|
61369
61478
|
}
|
|
61370
|
-
constructor(root, scope) {
|
|
61371
|
-
super(root, scope);
|
|
61479
|
+
constructor(root, scope, liveCursor) {
|
|
61480
|
+
super(root, scope, liveCursor);
|
|
61372
61481
|
_defineProperty9(this, "controlledPoints", []);
|
|
61373
61482
|
_defineProperty9(this, "item", null);
|
|
61374
61483
|
if (!this.root.has("type")) {
|
|
@@ -61384,6 +61493,8 @@ var LineModel = class extends ElementModel {
|
|
|
61384
61493
|
this.root.set("tailArrow", "normal");
|
|
61385
61494
|
}
|
|
61386
61495
|
}
|
|
61496
|
+
subDispose() {
|
|
61497
|
+
}
|
|
61387
61498
|
onVectorUpdate() {
|
|
61388
61499
|
if (!this.item) {
|
|
61389
61500
|
return;
|
|
@@ -61415,12 +61526,21 @@ var LineModel = class extends ElementModel {
|
|
|
61415
61526
|
});
|
|
61416
61527
|
return [head, path, tail];
|
|
61417
61528
|
}
|
|
61529
|
+
liveCursorPoint() {
|
|
61530
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61531
|
+
if (yArray.length < 2) {
|
|
61532
|
+
return null;
|
|
61533
|
+
}
|
|
61534
|
+
const len = yArray.length;
|
|
61535
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
61536
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61537
|
+
}
|
|
61418
61538
|
createPaperItem() {
|
|
61419
61539
|
this.item = new this.scope.Group();
|
|
61420
61540
|
this.item.addChildren(this.renderLine());
|
|
61421
61541
|
}
|
|
61422
61542
|
createArrow(path) {
|
|
61423
|
-
|
|
61543
|
+
const [headPath, tailPath] = [new this.scope.Path(), new this.scope.Path()];
|
|
61424
61544
|
if (!path) {
|
|
61425
61545
|
return [headPath, tailPath];
|
|
61426
61546
|
}
|
|
@@ -61474,7 +61594,7 @@ var LineModel = class extends ElementModel {
|
|
|
61474
61594
|
exclude: ["fillColor"]
|
|
61475
61595
|
};
|
|
61476
61596
|
}
|
|
61477
|
-
onStyleKeyUpdate(
|
|
61597
|
+
onStyleKeyUpdate(_key) {
|
|
61478
61598
|
this.onVectorUpdate();
|
|
61479
61599
|
}
|
|
61480
61600
|
};
|
|
@@ -61562,8 +61682,8 @@ var PointTextModel = class extends ElementModel {
|
|
|
61562
61682
|
set fontFamily(value) {
|
|
61563
61683
|
this.root.set("font-family", value);
|
|
61564
61684
|
}
|
|
61565
|
-
constructor(root, scope) {
|
|
61566
|
-
super(root, scope);
|
|
61685
|
+
constructor(root, scope, liveCursor) {
|
|
61686
|
+
super(root, scope, liveCursor);
|
|
61567
61687
|
_defineProperty10(this, "item", null);
|
|
61568
61688
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
61569
61689
|
if (!this.item) {
|
|
@@ -61594,6 +61714,18 @@ var PointTextModel = class extends ElementModel {
|
|
|
61594
61714
|
}, 60);
|
|
61595
61715
|
}
|
|
61596
61716
|
}
|
|
61717
|
+
subDispose() {
|
|
61718
|
+
(0, import_forge_room4.removeObserver)(this.root, this.handleTextPropChange);
|
|
61719
|
+
}
|
|
61720
|
+
liveCursorPoint() {
|
|
61721
|
+
const points = this.points;
|
|
61722
|
+
if (points.length < 1) {
|
|
61723
|
+
return null;
|
|
61724
|
+
}
|
|
61725
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
61726
|
+
const topLeft = new this.scope.Point(points[0], points[1]).transform(matrix);
|
|
61727
|
+
return topLeft;
|
|
61728
|
+
}
|
|
61597
61729
|
getInternalMeasurement() {
|
|
61598
61730
|
if (!this.item) {
|
|
61599
61731
|
return null;
|
|
@@ -61686,8 +61818,8 @@ function _toPrimitive11(t, r) {
|
|
|
61686
61818
|
return ("string" === r ? String : Number)(t);
|
|
61687
61819
|
}
|
|
61688
61820
|
var TriangleModel = class extends ElementModel {
|
|
61689
|
-
constructor(root, scope) {
|
|
61690
|
-
super(root, scope);
|
|
61821
|
+
constructor(root, scope, liveCursor) {
|
|
61822
|
+
super(root, scope, liveCursor);
|
|
61691
61823
|
_defineProperty11(this, "item", null);
|
|
61692
61824
|
if (!this.root.has("type")) {
|
|
61693
61825
|
this.root.set("type", "triangle");
|
|
@@ -61696,6 +61828,17 @@ var TriangleModel = class extends ElementModel {
|
|
|
61696
61828
|
this.root.set("points", new Y7.Array());
|
|
61697
61829
|
}
|
|
61698
61830
|
}
|
|
61831
|
+
liveCursorPoint() {
|
|
61832
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61833
|
+
if (yArray.length < 6) {
|
|
61834
|
+
return null;
|
|
61835
|
+
}
|
|
61836
|
+
const len = yArray.length;
|
|
61837
|
+
const point = new this.scope.Point(yArray.get(len - 4), yArray.get(len - 3));
|
|
61838
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61839
|
+
}
|
|
61840
|
+
subDispose() {
|
|
61841
|
+
}
|
|
61699
61842
|
createPaperItem() {
|
|
61700
61843
|
this.item = new this.scope.Path();
|
|
61701
61844
|
this.item.strokeCap = "butt";
|
|
@@ -61752,7 +61895,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
61752
61895
|
exclude: []
|
|
61753
61896
|
};
|
|
61754
61897
|
}
|
|
61755
|
-
onStyleKeyUpdate(
|
|
61898
|
+
onStyleKeyUpdate(_key) {
|
|
61756
61899
|
}
|
|
61757
61900
|
};
|
|
61758
61901
|
function _defineProperty12(e, r, t) {
|
|
@@ -61773,8 +61916,8 @@ function _toPrimitive12(t, r) {
|
|
|
61773
61916
|
return ("string" === r ? String : Number)(t);
|
|
61774
61917
|
}
|
|
61775
61918
|
var RectangleModel = class extends ElementModel {
|
|
61776
|
-
constructor(root, scope) {
|
|
61777
|
-
super(root, scope);
|
|
61919
|
+
constructor(root, scope, liveCursor) {
|
|
61920
|
+
super(root, scope, liveCursor);
|
|
61778
61921
|
_defineProperty12(this, "item", null);
|
|
61779
61922
|
if (!this.root.has("type")) {
|
|
61780
61923
|
this.root.set("type", "rectangle");
|
|
@@ -61788,6 +61931,16 @@ var RectangleModel = class extends ElementModel {
|
|
|
61788
61931
|
this.root.set("radius", 0);
|
|
61789
61932
|
}
|
|
61790
61933
|
}
|
|
61934
|
+
subDispose() {
|
|
61935
|
+
}
|
|
61936
|
+
liveCursorPoint() {
|
|
61937
|
+
const points = this.points;
|
|
61938
|
+
if (points.length < 4) {
|
|
61939
|
+
return null;
|
|
61940
|
+
}
|
|
61941
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
61942
|
+
return new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
61943
|
+
}
|
|
61791
61944
|
createSegments() {
|
|
61792
61945
|
const [a2, b2, c, d] = this.points;
|
|
61793
61946
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
@@ -61919,7 +62072,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
61919
62072
|
exclude: []
|
|
61920
62073
|
};
|
|
61921
62074
|
}
|
|
61922
|
-
onStyleKeyUpdate(
|
|
62075
|
+
onStyleKeyUpdate(_key) {
|
|
61923
62076
|
}
|
|
61924
62077
|
};
|
|
61925
62078
|
var elementsUndoOrigin = "elementsUndoOrigin";
|
|
@@ -61942,8 +62095,8 @@ function _toPrimitive13(t, r) {
|
|
|
61942
62095
|
return ("string" === r ? String : Number)(t);
|
|
61943
62096
|
}
|
|
61944
62097
|
var EraserModel = class extends ElementModel {
|
|
61945
|
-
constructor(root, scope) {
|
|
61946
|
-
super(root, scope);
|
|
62098
|
+
constructor(root, scope, liveCursor) {
|
|
62099
|
+
super(root, scope, liveCursor);
|
|
61947
62100
|
_defineProperty13(this, "item", null);
|
|
61948
62101
|
_defineProperty13(this, "sliceBegin", 0);
|
|
61949
62102
|
if (!this.root.has("type")) {
|
|
@@ -61982,14 +62135,189 @@ var EraserModel = class extends ElementModel {
|
|
|
61982
62135
|
return path;
|
|
61983
62136
|
}
|
|
61984
62137
|
parsePoints(points) {
|
|
61985
|
-
|
|
62138
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
62139
|
+
return ae(groupPoints, {
|
|
61986
62140
|
size: this.strokeWidth,
|
|
62141
|
+
smoothing: 0.5,
|
|
62142
|
+
thinning: -0.5,
|
|
62143
|
+
streamline: 0.5,
|
|
62144
|
+
simulatePressure: true,
|
|
62145
|
+
start: {
|
|
62146
|
+
taper: this.strokeWidth * 10,
|
|
62147
|
+
cap: true
|
|
62148
|
+
},
|
|
62149
|
+
end: {
|
|
62150
|
+
taper: this.strokeWidth * 20,
|
|
62151
|
+
cap: true
|
|
62152
|
+
}
|
|
62153
|
+
});
|
|
62154
|
+
}
|
|
62155
|
+
matrixedPoints() {
|
|
62156
|
+
const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
|
|
62157
|
+
return currentPoints.map((_ref) => {
|
|
62158
|
+
let [x, y] = _ref;
|
|
62159
|
+
return new this.scope.Point(x, y);
|
|
62160
|
+
}).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
|
|
62161
|
+
result.push(next.x);
|
|
62162
|
+
result.push(next.y);
|
|
62163
|
+
return result;
|
|
62164
|
+
}, []);
|
|
62165
|
+
}
|
|
62166
|
+
onVectorUpdate() {
|
|
62167
|
+
if (!this.item) {
|
|
62168
|
+
return;
|
|
62169
|
+
}
|
|
62170
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
62171
|
+
const path = this.createPath(points);
|
|
62172
|
+
this.item.removeSegments();
|
|
62173
|
+
this.item.addSegments(path.segments);
|
|
62174
|
+
}
|
|
62175
|
+
createPaperItem() {
|
|
62176
|
+
this.item = new this.scope.Path();
|
|
62177
|
+
this.item.strokeCap = "round";
|
|
62178
|
+
this.item.strokeJoin = "round";
|
|
62179
|
+
this.item.strokeScaling = false;
|
|
62180
|
+
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
62181
|
+
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
62182
|
+
this.onVectorUpdate();
|
|
62183
|
+
this.item.onFrame = () => {
|
|
62184
|
+
if (!this.points) {
|
|
62185
|
+
return;
|
|
62186
|
+
}
|
|
62187
|
+
if (this.points.length / 2 > 50) {
|
|
62188
|
+
this.sliceBegin = this.points.length / 2 - 50;
|
|
62189
|
+
}
|
|
62190
|
+
};
|
|
62191
|
+
}
|
|
62192
|
+
editorConfig() {
|
|
62193
|
+
return new EditorConfig();
|
|
62194
|
+
}
|
|
62195
|
+
vectorKeys() {
|
|
62196
|
+
return [];
|
|
62197
|
+
}
|
|
62198
|
+
styleKeys() {
|
|
62199
|
+
return {
|
|
62200
|
+
include: [],
|
|
62201
|
+
exclude: []
|
|
62202
|
+
};
|
|
62203
|
+
}
|
|
62204
|
+
onStyleKeyUpdate(_key) {
|
|
62205
|
+
return;
|
|
62206
|
+
}
|
|
62207
|
+
subDispose() {
|
|
62208
|
+
}
|
|
62209
|
+
liveCursorPoint() {
|
|
62210
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
62211
|
+
if (yArray.length < 2) {
|
|
62212
|
+
return null;
|
|
62213
|
+
}
|
|
62214
|
+
const len = yArray.length;
|
|
62215
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
62216
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
62217
|
+
}
|
|
62218
|
+
};
|
|
62219
|
+
var import_lodash6 = __toESM2(require_lodash(), 1);
|
|
62220
|
+
function _defineProperty14(e, r, t) {
|
|
62221
|
+
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62222
|
+
}
|
|
62223
|
+
function _toPropertyKey14(t) {
|
|
62224
|
+
var i = _toPrimitive14(t, "string");
|
|
62225
|
+
return "symbol" == typeof i ? i : i + "";
|
|
62226
|
+
}
|
|
62227
|
+
function _toPrimitive14(t, r) {
|
|
62228
|
+
if ("object" != typeof t || !t) return t;
|
|
62229
|
+
var e = t[Symbol.toPrimitive];
|
|
62230
|
+
if (void 0 !== e) {
|
|
62231
|
+
var i = e.call(t, r || "default");
|
|
62232
|
+
if ("object" != typeof i) return i;
|
|
62233
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62234
|
+
}
|
|
62235
|
+
return ("string" === r ? String : Number)(t);
|
|
62236
|
+
}
|
|
62237
|
+
var LaserPointerModel = class extends ElementModel {
|
|
62238
|
+
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
62239
|
+
super(root, scope, liveCursor);
|
|
62240
|
+
_defineProperty14(this, "item", null);
|
|
62241
|
+
_defineProperty14(this, "clientId", void 0);
|
|
62242
|
+
_defineProperty14(this, "sliceBegin", 0);
|
|
62243
|
+
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
62244
|
+
_defineProperty14(this, "cachedPoints", null);
|
|
62245
|
+
this.clientId = clientId;
|
|
62246
|
+
if (!this.root.has("type")) {
|
|
62247
|
+
this.root.set("type", "laser");
|
|
62248
|
+
}
|
|
62249
|
+
if (!this.root.has("points")) {
|
|
62250
|
+
this.root.set("points", new Y10.Array());
|
|
62251
|
+
}
|
|
62252
|
+
if (!this.root.has("removed")) {
|
|
62253
|
+
this.root.set("removed", false);
|
|
62254
|
+
}
|
|
62255
|
+
this.root.observe((event) => {
|
|
62256
|
+
if (!this.item) {
|
|
62257
|
+
return;
|
|
62258
|
+
}
|
|
62259
|
+
for (const [key] of event.changes.keys.entries()) {
|
|
62260
|
+
if (key === "removed") {
|
|
62261
|
+
if (this.cachedPoints == null) {
|
|
62262
|
+
this.cachedPoints = this.points;
|
|
62263
|
+
}
|
|
62264
|
+
this.item.onFrame = (evt) => {
|
|
62265
|
+
this.displayStrokeWidth = Math.max(0.1, this.displayStrokeWidth -= 8 / 30);
|
|
62266
|
+
if (evt.count >= 20) {
|
|
62267
|
+
const points = this.cachedPoints || this.points;
|
|
62268
|
+
this.sliceBegin += Math.ceil(points.length / 2 / 20);
|
|
62269
|
+
}
|
|
62270
|
+
this.onVectorUpdate();
|
|
62271
|
+
if (evt.count >= 30) {
|
|
62272
|
+
if (this.ownerId === this.clientId) {
|
|
62273
|
+
removeElement(this.uuid);
|
|
62274
|
+
}
|
|
62275
|
+
}
|
|
62276
|
+
};
|
|
62277
|
+
}
|
|
62278
|
+
}
|
|
62279
|
+
});
|
|
62280
|
+
}
|
|
62281
|
+
beginRemoveAnimate() {
|
|
62282
|
+
this.root.set("removed", true);
|
|
62283
|
+
}
|
|
62284
|
+
average(a2, b2) {
|
|
62285
|
+
return (a2 + b2) / 2;
|
|
62286
|
+
}
|
|
62287
|
+
createPath(points) {
|
|
62288
|
+
const path = new this.scope.Path();
|
|
62289
|
+
const len = points.length;
|
|
62290
|
+
if (len < 4) {
|
|
62291
|
+
return path;
|
|
62292
|
+
}
|
|
62293
|
+
let control = new this.scope.Point(0, 0);
|
|
62294
|
+
let current = new this.scope.Point(0, 0);
|
|
62295
|
+
let a2 = points[0];
|
|
62296
|
+
let b2 = points[1];
|
|
62297
|
+
const c = points[2];
|
|
62298
|
+
current = new this.scope.Point(a2[0], a2[1]);
|
|
62299
|
+
path.moveTo(current);
|
|
62300
|
+
control = new this.scope.Point(b2[0], b2[1]);
|
|
62301
|
+
current = new this.scope.Point(this.average(b2[0], c[0]), this.average(b2[1], c[1]));
|
|
62302
|
+
path.quadraticCurveTo(control, current);
|
|
62303
|
+
for (let i = 2, max = len - 1; i < max; i++) {
|
|
62304
|
+
a2 = points[i];
|
|
62305
|
+
b2 = points[i + 1];
|
|
62306
|
+
control = current.multiply(2).subtract(control);
|
|
62307
|
+
current = new this.scope.Point(this.average(a2[0], b2[0]), this.average(a2[1], b2[1]));
|
|
62308
|
+
path.quadraticCurveTo(control, current);
|
|
62309
|
+
}
|
|
62310
|
+
return path;
|
|
62311
|
+
}
|
|
62312
|
+
parsePoints(points) {
|
|
62313
|
+
return ae(points, {
|
|
62314
|
+
size: this.displayStrokeWidth,
|
|
61987
62315
|
smoothing: 0,
|
|
61988
62316
|
thinning: 0.5,
|
|
61989
|
-
streamline: 0
|
|
62317
|
+
streamline: 0,
|
|
61990
62318
|
simulatePressure: true,
|
|
61991
62319
|
start: {
|
|
61992
|
-
taper:
|
|
62320
|
+
taper: 0,
|
|
61993
62321
|
cap: true
|
|
61994
62322
|
},
|
|
61995
62323
|
end: {
|
|
@@ -62000,7 +62328,8 @@ var EraserModel = class extends ElementModel {
|
|
|
62000
62328
|
}
|
|
62001
62329
|
matrixedPoints() {
|
|
62002
62330
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
62003
|
-
const
|
|
62331
|
+
const points = this.cachedPoints || this.points;
|
|
62332
|
+
const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
|
|
62004
62333
|
return groupPoints.map((_ref) => {
|
|
62005
62334
|
let [x, y] = _ref;
|
|
62006
62335
|
return matrix.transform([x, y]);
|
|
@@ -62026,22 +62355,6 @@ var EraserModel = class extends ElementModel {
|
|
|
62026
62355
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
62027
62356
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
62028
62357
|
this.item.addSegments(this.getNextSegments());
|
|
62029
|
-
let isBegin = false;
|
|
62030
|
-
this.item.onFrame = () => {
|
|
62031
|
-
if (!this.points) {
|
|
62032
|
-
return;
|
|
62033
|
-
}
|
|
62034
|
-
if (this.points.length / 2 - this.sliceBegin >= 10 && !isBegin) {
|
|
62035
|
-
isBegin = true;
|
|
62036
|
-
}
|
|
62037
|
-
if (this.points.length / 2 <= this.sliceBegin) {
|
|
62038
|
-
isBegin = false;
|
|
62039
|
-
}
|
|
62040
|
-
if (isBegin) {
|
|
62041
|
-
this.sliceBegin += 1;
|
|
62042
|
-
this.onVectorUpdate();
|
|
62043
|
-
}
|
|
62044
|
-
};
|
|
62045
62358
|
}
|
|
62046
62359
|
editorConfig() {
|
|
62047
62360
|
return new EditorConfig();
|
|
@@ -62055,183 +62368,21 @@ var EraserModel = class extends ElementModel {
|
|
|
62055
62368
|
exclude: []
|
|
62056
62369
|
};
|
|
62057
62370
|
}
|
|
62058
|
-
onStyleKeyUpdate(
|
|
62371
|
+
onStyleKeyUpdate(_key) {
|
|
62059
62372
|
return;
|
|
62060
62373
|
}
|
|
62061
|
-
|
|
62062
|
-
var import_lodash6 = __toESM2(require_lodash(), 1);
|
|
62063
|
-
function _defineProperty14(e, r, t) {
|
|
62064
|
-
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62065
|
-
}
|
|
62066
|
-
function _toPropertyKey14(t) {
|
|
62067
|
-
var i = _toPrimitive14(t, "string");
|
|
62068
|
-
return "symbol" == typeof i ? i : i + "";
|
|
62069
|
-
}
|
|
62070
|
-
function _toPrimitive14(t, r) {
|
|
62071
|
-
if ("object" != typeof t || !t) return t;
|
|
62072
|
-
var e = t[Symbol.toPrimitive];
|
|
62073
|
-
if (void 0 !== e) {
|
|
62074
|
-
var i = e.call(t, r || "default");
|
|
62075
|
-
if ("object" != typeof i) return i;
|
|
62076
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62077
|
-
}
|
|
62078
|
-
return ("string" === r ? String : Number)(t);
|
|
62079
|
-
}
|
|
62080
|
-
var LaserPointerModel = class extends ElementModel {
|
|
62081
|
-
constructor(clientId, root, scope, removeElement) {
|
|
62082
|
-
super(root, scope);
|
|
62083
|
-
_defineProperty14(this, "item", null);
|
|
62084
|
-
_defineProperty14(this, "clientId", void 0);
|
|
62085
|
-
_defineProperty14(this, "sliceBegin", 0);
|
|
62086
|
-
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
62087
|
-
_defineProperty14(this, "cachedPoints", null);
|
|
62088
|
-
this.clientId = clientId;
|
|
62089
|
-
if (!this.root.has("type")) {
|
|
62090
|
-
this.root.set("type", "laser");
|
|
62091
|
-
}
|
|
62092
|
-
if (!this.root.has("points")) {
|
|
62093
|
-
this.root.set("points", new Y10.Array());
|
|
62094
|
-
}
|
|
62095
|
-
if (!this.root.has("removed")) {
|
|
62096
|
-
this.root.set("removed", false);
|
|
62097
|
-
}
|
|
62098
|
-
this.root.observe((event) => {
|
|
62099
|
-
if (!this.item) {
|
|
62100
|
-
return;
|
|
62101
|
-
}
|
|
62102
|
-
for (const [key] of event.changes.keys.entries()) {
|
|
62103
|
-
if (key === "removed") {
|
|
62104
|
-
if (this.cachedPoints == null) {
|
|
62105
|
-
this.cachedPoints = this.points;
|
|
62106
|
-
}
|
|
62107
|
-
this.item.onFrame = (evt) => {
|
|
62108
|
-
this.displayStrokeWidth = Math.max(0.1, this.displayStrokeWidth -= 8 / 30);
|
|
62109
|
-
if (evt.count >= 20) {
|
|
62110
|
-
const points = this.cachedPoints || this.points;
|
|
62111
|
-
this.sliceBegin += Math.ceil(points.length / 2 / 20);
|
|
62112
|
-
}
|
|
62113
|
-
this.onVectorUpdate();
|
|
62114
|
-
if (evt.count >= 30) {
|
|
62115
|
-
if (this.ownerId === this.clientId) {
|
|
62116
|
-
removeElement(this.uuid);
|
|
62117
|
-
}
|
|
62118
|
-
}
|
|
62119
|
-
};
|
|
62120
|
-
}
|
|
62121
|
-
}
|
|
62122
|
-
});
|
|
62123
|
-
}
|
|
62124
|
-
beginRemoveAnimate() {
|
|
62125
|
-
this.root.set("removed", true);
|
|
62126
|
-
}
|
|
62127
|
-
average(a2, b2) {
|
|
62128
|
-
return (a2 + b2) / 2;
|
|
62129
|
-
}
|
|
62130
|
-
createPath(points) {
|
|
62131
|
-
const path = new this.scope.Path();
|
|
62132
|
-
const len = points.length;
|
|
62133
|
-
if (len < 4) {
|
|
62134
|
-
return path;
|
|
62135
|
-
}
|
|
62136
|
-
let control = new this.scope.Point(0, 0);
|
|
62137
|
-
let current = new this.scope.Point(0, 0);
|
|
62138
|
-
let a2 = points[0];
|
|
62139
|
-
let b2 = points[1];
|
|
62140
|
-
const c = points[2];
|
|
62141
|
-
current = new this.scope.Point(a2[0], a2[1]);
|
|
62142
|
-
path.moveTo(current);
|
|
62143
|
-
control = new this.scope.Point(b2[0], b2[1]);
|
|
62144
|
-
current = new this.scope.Point(this.average(b2[0], c[0]), this.average(b2[1], c[1]));
|
|
62145
|
-
path.quadraticCurveTo(control, current);
|
|
62146
|
-
for (let i = 2, max = len - 1; i < max; i++) {
|
|
62147
|
-
a2 = points[i];
|
|
62148
|
-
b2 = points[i + 1];
|
|
62149
|
-
control = current.multiply(2).subtract(control);
|
|
62150
|
-
current = new this.scope.Point(this.average(a2[0], b2[0]), this.average(a2[1], b2[1]));
|
|
62151
|
-
path.quadraticCurveTo(control, current);
|
|
62152
|
-
}
|
|
62153
|
-
return path;
|
|
62154
|
-
}
|
|
62155
|
-
parsePoints(points) {
|
|
62156
|
-
return ae(points, {
|
|
62157
|
-
size: this.displayStrokeWidth,
|
|
62158
|
-
smoothing: 0,
|
|
62159
|
-
thinning: 0.5,
|
|
62160
|
-
streamline: 0,
|
|
62161
|
-
simulatePressure: true,
|
|
62162
|
-
start: {
|
|
62163
|
-
taper: 0,
|
|
62164
|
-
cap: true
|
|
62165
|
-
},
|
|
62166
|
-
end: {
|
|
62167
|
-
taper: 0,
|
|
62168
|
-
cap: true
|
|
62169
|
-
}
|
|
62170
|
-
});
|
|
62374
|
+
subDispose() {
|
|
62171
62375
|
}
|
|
62172
|
-
|
|
62173
|
-
const
|
|
62174
|
-
|
|
62175
|
-
|
|
62176
|
-
return groupPoints.map((_ref) => {
|
|
62177
|
-
let [x, y] = _ref;
|
|
62178
|
-
return matrix.transform([x, y]);
|
|
62179
|
-
}).map((p) => [p.x, p.y]);
|
|
62180
|
-
}
|
|
62181
|
-
getNextSegments() {
|
|
62182
|
-
const points = this.parsePoints(this.matrixedPoints());
|
|
62183
|
-
const path = this.createPath(points);
|
|
62184
|
-
return path.segments;
|
|
62185
|
-
}
|
|
62186
|
-
onVectorUpdate() {
|
|
62187
|
-
if (!this.item) {
|
|
62188
|
-
return;
|
|
62376
|
+
liveCursorPoint() {
|
|
62377
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
62378
|
+
if (yArray.length < 2) {
|
|
62379
|
+
return null;
|
|
62189
62380
|
}
|
|
62190
|
-
|
|
62191
|
-
this.
|
|
62192
|
-
|
|
62193
|
-
createPaperItem() {
|
|
62194
|
-
this.item = new this.scope.Path();
|
|
62195
|
-
this.item.strokeCap = "round";
|
|
62196
|
-
this.item.strokeJoin = "round";
|
|
62197
|
-
this.item.strokeScaling = false;
|
|
62198
|
-
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
62199
|
-
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
62200
|
-
this.item.addSegments(this.getNextSegments());
|
|
62201
|
-
}
|
|
62202
|
-
editorConfig() {
|
|
62203
|
-
return new EditorConfig();
|
|
62204
|
-
}
|
|
62205
|
-
vectorKeys() {
|
|
62206
|
-
return [];
|
|
62207
|
-
}
|
|
62208
|
-
styleKeys() {
|
|
62209
|
-
return {
|
|
62210
|
-
include: [],
|
|
62211
|
-
exclude: []
|
|
62212
|
-
};
|
|
62213
|
-
}
|
|
62214
|
-
onStyleKeyUpdate(key) {
|
|
62215
|
-
return;
|
|
62381
|
+
const len = yArray.length;
|
|
62382
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
62383
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
62216
62384
|
}
|
|
62217
62385
|
};
|
|
62218
|
-
function _defineProperty15(e, r, t) {
|
|
62219
|
-
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62220
|
-
}
|
|
62221
|
-
function _toPropertyKey15(t) {
|
|
62222
|
-
var i = _toPrimitive15(t, "string");
|
|
62223
|
-
return "symbol" == typeof i ? i : i + "";
|
|
62224
|
-
}
|
|
62225
|
-
function _toPrimitive15(t, r) {
|
|
62226
|
-
if ("object" != typeof t || !t) return t;
|
|
62227
|
-
var e = t[Symbol.toPrimitive];
|
|
62228
|
-
if (void 0 !== e) {
|
|
62229
|
-
var i = e.call(t, r || "default");
|
|
62230
|
-
if ("object" != typeof i) return i;
|
|
62231
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62232
|
-
}
|
|
62233
|
-
return ("string" === r ? String : Number)(t);
|
|
62234
|
-
}
|
|
62235
62386
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
62236
62387
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
62237
62388
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -62244,117 +62395,25 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
62244
62395
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
62245
62396
|
return WhiteboardPermissionFlag2;
|
|
62246
62397
|
}({});
|
|
62247
|
-
var WhiteboardPermissions = class extends
|
|
62248
|
-
constructor(userManager, requestUserMap) {
|
|
62249
|
-
super();
|
|
62250
|
-
_defineProperty15(this, "requestUserMap", void 0);
|
|
62251
|
-
_defineProperty15(this, "userManager", void 0);
|
|
62252
|
-
_defineProperty15(this, "observers", /* @__PURE__ */ new Map());
|
|
62253
|
-
_defineProperty15(this, "handleUserLeave", (user) => {
|
|
62254
|
-
const cb = this.observers.get(user.id);
|
|
62255
|
-
if (cb) {
|
|
62256
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
62257
|
-
}
|
|
62258
|
-
});
|
|
62259
|
-
_defineProperty15(this, "handleUserJoin", (user) => {
|
|
62260
|
-
this.addObserve(user.id);
|
|
62261
|
-
});
|
|
62262
|
-
this.userManager = userManager;
|
|
62263
|
-
this.requestUserMap = requestUserMap;
|
|
62264
|
-
this.createModel(this.userManager.selfId);
|
|
62265
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
62266
|
-
this.addObserve(userId);
|
|
62267
|
-
});
|
|
62268
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
62269
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
62270
|
-
}
|
|
62271
|
-
addObserve(userId) {
|
|
62272
|
-
if (this.observers.has(userId)) {
|
|
62273
|
-
return;
|
|
62274
|
-
}
|
|
62275
|
-
const observer = (evt) => {
|
|
62276
|
-
this.handleUserPermissionChange(userId, evt);
|
|
62277
|
-
};
|
|
62278
|
-
this.observers.set(userId, observer);
|
|
62279
|
-
this.requestUserMap(userId).observe(observer);
|
|
62280
|
-
}
|
|
62281
|
-
createModel(userId) {
|
|
62282
|
-
const userMap = this.requestUserMap(userId);
|
|
62283
|
-
if (!userMap.has("permission")) {
|
|
62284
|
-
userMap.set("permission", 0);
|
|
62285
|
-
}
|
|
62286
|
-
}
|
|
62287
|
-
handleUserPermissionChange(userId, evt) {
|
|
62288
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
62289
|
-
if (key === "permission") {
|
|
62290
|
-
if (value.action === "add" || value.action === "update") {
|
|
62291
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
62292
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
62293
|
-
}
|
|
62294
|
-
}
|
|
62295
|
-
}
|
|
62296
|
-
}
|
|
62398
|
+
var WhiteboardPermissions = class extends import_forge_room5.AbstractApplicationPermissions {
|
|
62297
62399
|
/**
|
|
62298
|
-
|
|
62299
|
-
|
|
62300
|
-
|
|
62301
|
-
|
|
62400
|
+
* 解析权限列表组合
|
|
62401
|
+
* @param {number} value - 权限数字值
|
|
62402
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
62403
|
+
*/
|
|
62302
62404
|
resolveFlags(value) {
|
|
62303
62405
|
return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
|
|
62304
62406
|
}
|
|
62305
|
-
/**
|
|
62306
|
-
* 获取权限列表组合对应的数值
|
|
62307
|
-
* @param { string } userId 不传表示获取自己
|
|
62308
|
-
*/
|
|
62309
|
-
getPermissionValue(userId) {
|
|
62310
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
62311
|
-
}
|
|
62312
|
-
/**
|
|
62313
|
-
* 获取权限列表
|
|
62314
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
62315
|
-
*/
|
|
62316
|
-
getPermissionFlags(userId) {
|
|
62317
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
62318
|
-
return this.resolveFlags(value);
|
|
62319
|
-
}
|
|
62320
|
-
/**
|
|
62321
|
-
* 返回对应 userId 是否有相应权限
|
|
62322
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
62323
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
62324
|
-
*/
|
|
62325
|
-
hasPermission(flag, userId) {
|
|
62326
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
62327
|
-
}
|
|
62328
|
-
/**
|
|
62329
|
-
* 添加权限
|
|
62330
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
62331
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
62332
|
-
*/
|
|
62333
|
-
addPermission(flag, userId) {
|
|
62334
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
62335
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
62336
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
62337
|
-
}
|
|
62338
|
-
/**
|
|
62339
|
-
* 移除权限
|
|
62340
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
62341
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
62342
|
-
*/
|
|
62343
|
-
removePermission(flag, userId) {
|
|
62344
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
62345
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
62346
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
62347
|
-
}
|
|
62348
62407
|
};
|
|
62349
62408
|
var import_lodash7 = __toESM2(require_lodash(), 1);
|
|
62350
|
-
function
|
|
62351
|
-
return (r =
|
|
62409
|
+
function _defineProperty15(e, r, t) {
|
|
62410
|
+
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62352
62411
|
}
|
|
62353
|
-
function
|
|
62354
|
-
var i =
|
|
62412
|
+
function _toPropertyKey15(t) {
|
|
62413
|
+
var i = _toPrimitive15(t, "string");
|
|
62355
62414
|
return "symbol" == typeof i ? i : i + "";
|
|
62356
62415
|
}
|
|
62357
|
-
function
|
|
62416
|
+
function _toPrimitive15(t, r) {
|
|
62358
62417
|
if ("object" != typeof t || !t) return t;
|
|
62359
62418
|
var e = t[Symbol.toPrimitive];
|
|
62360
62419
|
if (void 0 !== e) {
|
|
@@ -62365,9 +62424,9 @@ function _toPrimitive16(t, r) {
|
|
|
62365
62424
|
return ("string" === r ? String : Number)(t);
|
|
62366
62425
|
}
|
|
62367
62426
|
var StraightLineModel = class extends ElementModel {
|
|
62368
|
-
constructor(root, scope) {
|
|
62369
|
-
super(root, scope);
|
|
62370
|
-
|
|
62427
|
+
constructor(root, scope, liveCursor) {
|
|
62428
|
+
super(root, scope, liveCursor);
|
|
62429
|
+
_defineProperty15(this, "item", null);
|
|
62371
62430
|
if (!this.root.has("type")) {
|
|
62372
62431
|
this.root.set("type", "line");
|
|
62373
62432
|
}
|
|
@@ -62375,6 +62434,17 @@ var StraightLineModel = class extends ElementModel {
|
|
|
62375
62434
|
this.root.set("points", new Y11.Array());
|
|
62376
62435
|
}
|
|
62377
62436
|
}
|
|
62437
|
+
liveCursorPoint() {
|
|
62438
|
+
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
62439
|
+
if (yArray.length < 2) {
|
|
62440
|
+
return null;
|
|
62441
|
+
}
|
|
62442
|
+
const len = yArray.length;
|
|
62443
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
62444
|
+
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
62445
|
+
}
|
|
62446
|
+
subDispose() {
|
|
62447
|
+
}
|
|
62378
62448
|
onVectorUpdate() {
|
|
62379
62449
|
if (!this.item) {
|
|
62380
62450
|
return;
|
|
@@ -62448,7 +62518,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
62448
62518
|
exclude: ["fillColor"]
|
|
62449
62519
|
};
|
|
62450
62520
|
}
|
|
62451
|
-
onStyleKeyUpdate(
|
|
62521
|
+
onStyleKeyUpdate(_key) {
|
|
62452
62522
|
if (!this.item) {
|
|
62453
62523
|
return;
|
|
62454
62524
|
}
|
|
@@ -62457,6 +62527,84 @@ var StraightLineModel = class extends ElementModel {
|
|
|
62457
62527
|
this.item.addSegments(path.segments);
|
|
62458
62528
|
}
|
|
62459
62529
|
};
|
|
62530
|
+
function _defineProperty16(e, r, t) {
|
|
62531
|
+
return (r = _toPropertyKey16(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62532
|
+
}
|
|
62533
|
+
function _toPropertyKey16(t) {
|
|
62534
|
+
var i = _toPrimitive16(t, "string");
|
|
62535
|
+
return "symbol" == typeof i ? i : i + "";
|
|
62536
|
+
}
|
|
62537
|
+
function _toPrimitive16(t, r) {
|
|
62538
|
+
if ("object" != typeof t || !t) return t;
|
|
62539
|
+
var e = t[Symbol.toPrimitive];
|
|
62540
|
+
if (void 0 !== e) {
|
|
62541
|
+
var i = e.call(t, r || "default");
|
|
62542
|
+
if ("object" != typeof i) return i;
|
|
62543
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62544
|
+
}
|
|
62545
|
+
return ("string" === r ? String : Number)(t);
|
|
62546
|
+
}
|
|
62547
|
+
var ImageModel = class extends ElementModel {
|
|
62548
|
+
get src() {
|
|
62549
|
+
return this.root.get("src");
|
|
62550
|
+
}
|
|
62551
|
+
constructor(root, scope, imageSets, liveCursor) {
|
|
62552
|
+
super(root, scope, liveCursor);
|
|
62553
|
+
_defineProperty16(this, "item", null);
|
|
62554
|
+
_defineProperty16(this, "imageSets", void 0);
|
|
62555
|
+
this.imageSets = imageSets;
|
|
62556
|
+
if (!this.root.has("type")) {
|
|
62557
|
+
this.root.set("type", "image");
|
|
62558
|
+
}
|
|
62559
|
+
this.root.set(ElementModel.KEYS.shadow, "");
|
|
62560
|
+
}
|
|
62561
|
+
subDispose() {
|
|
62562
|
+
const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
62563
|
+
if (img) {
|
|
62564
|
+
img.remove();
|
|
62565
|
+
}
|
|
62566
|
+
}
|
|
62567
|
+
createPaperItem() {
|
|
62568
|
+
if (this.item) {
|
|
62569
|
+
return;
|
|
62570
|
+
}
|
|
62571
|
+
if (!this.imageSets.querySelector(`[id='${this.uuid}']`)) {
|
|
62572
|
+
const img = document.createElement("img");
|
|
62573
|
+
img.src = this.src;
|
|
62574
|
+
img.id = this.uuid;
|
|
62575
|
+
this.imageSets.appendChild(img);
|
|
62576
|
+
}
|
|
62577
|
+
this.item = new this.scope.Raster(this.uuid);
|
|
62578
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
62579
|
+
this.item.matrix = matrix;
|
|
62580
|
+
}
|
|
62581
|
+
onVectorUpdate() {
|
|
62582
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
62583
|
+
if (this.item) {
|
|
62584
|
+
this.item.matrix = matrix;
|
|
62585
|
+
}
|
|
62586
|
+
}
|
|
62587
|
+
vectorKeys() {
|
|
62588
|
+
return [];
|
|
62589
|
+
}
|
|
62590
|
+
styleKeys() {
|
|
62591
|
+
return {
|
|
62592
|
+
include: [],
|
|
62593
|
+
exclude: ["dashArray", "strokeColor", "fillColor", "strokeWidth"]
|
|
62594
|
+
};
|
|
62595
|
+
}
|
|
62596
|
+
onStyleKeyUpdate(_key) {
|
|
62597
|
+
}
|
|
62598
|
+
editorConfig() {
|
|
62599
|
+
const cfg = new EditorConfig();
|
|
62600
|
+
cfg.resizeModel = () => "four-corner";
|
|
62601
|
+
cfg.uniformScale = () => true;
|
|
62602
|
+
return cfg;
|
|
62603
|
+
}
|
|
62604
|
+
liveCursorPoint() {
|
|
62605
|
+
return null;
|
|
62606
|
+
}
|
|
62607
|
+
};
|
|
62460
62608
|
function _defineProperty17(e, r, t) {
|
|
62461
62609
|
return (r = _toPropertyKey17(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62462
62610
|
}
|
|
@@ -62476,9 +62624,9 @@ function _toPrimitive17(t, r) {
|
|
|
62476
62624
|
}
|
|
62477
62625
|
var RenderableModel = class extends import_eventemitter3.default {
|
|
62478
62626
|
get uuid() {
|
|
62479
|
-
return (0, import_uuid.v4)();
|
|
62627
|
+
return (0, import_uuid.v4)().replace(/-/g, "");
|
|
62480
62628
|
}
|
|
62481
|
-
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, hasPermission) {
|
|
62629
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
|
|
62482
62630
|
super();
|
|
62483
62631
|
_defineProperty17(this, "scope", void 0);
|
|
62484
62632
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -62489,6 +62637,8 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62489
62637
|
_defineProperty17(this, "maxIndex", -1);
|
|
62490
62638
|
_defineProperty17(this, "hasPermission", void 0);
|
|
62491
62639
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
62640
|
+
_defineProperty17(this, "imageSets", void 0);
|
|
62641
|
+
_defineProperty17(this, "liveCursor", void 0);
|
|
62492
62642
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
62493
62643
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
62494
62644
|
if (value.action === "add") {
|
|
@@ -62496,7 +62646,9 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62496
62646
|
if (root) {
|
|
62497
62647
|
const model = this.convertToModel(root);
|
|
62498
62648
|
if (model) {
|
|
62499
|
-
|
|
62649
|
+
setTimeout(() => {
|
|
62650
|
+
this.emit("elementInsert", [model]);
|
|
62651
|
+
});
|
|
62500
62652
|
}
|
|
62501
62653
|
}
|
|
62502
62654
|
} else if (value.action === "delete") {
|
|
@@ -62504,6 +62656,8 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62504
62656
|
}
|
|
62505
62657
|
}
|
|
62506
62658
|
});
|
|
62659
|
+
this.liveCursor = liveCursor;
|
|
62660
|
+
this.imageSets = imageSets;
|
|
62507
62661
|
this.hasPermission = hasPermission;
|
|
62508
62662
|
this.shadowEmitter = shadowEmitter;
|
|
62509
62663
|
this.layerId = layerId;
|
|
@@ -62542,27 +62696,29 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62542
62696
|
const type = yMap.get("type");
|
|
62543
62697
|
let model = null;
|
|
62544
62698
|
if (type === "curve") {
|
|
62545
|
-
model = new CurveModel(yMap, this.scope);
|
|
62699
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
62546
62700
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
62547
|
-
model = new SegmentsModel(yMap, this.scope, type);
|
|
62701
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
62548
62702
|
} else if (type === "selector") {
|
|
62549
|
-
model = new SelectorModel(yMap, this.scope);
|
|
62703
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
62550
62704
|
} else if (type === "arrow") {
|
|
62551
|
-
model = new LineModel(yMap, this.scope);
|
|
62705
|
+
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
62552
62706
|
} else if (type === "line") {
|
|
62553
|
-
model = new StraightLineModel(yMap, this.scope);
|
|
62707
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
62554
62708
|
} else if (type === "point-text") {
|
|
62555
|
-
model = new PointTextModel(yMap, this.scope);
|
|
62709
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
62556
62710
|
} else if (type === "triangle") {
|
|
62557
|
-
model = new TriangleModel(yMap, this.scope);
|
|
62711
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
62558
62712
|
} else if (type === "rectangle") {
|
|
62559
|
-
model = new RectangleModel(yMap, this.scope);
|
|
62713
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
62560
62714
|
} else if (type === "eraser") {
|
|
62561
|
-
model = new EraserModel(yMap, this.scope);
|
|
62715
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
62562
62716
|
} else if (type === "laser") {
|
|
62563
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
|
|
62717
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
62564
62718
|
this.removeElementItem(uuid);
|
|
62565
62719
|
});
|
|
62720
|
+
} else if (type === "image") {
|
|
62721
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
62566
62722
|
}
|
|
62567
62723
|
if (model) {
|
|
62568
62724
|
model.shadowEmitter = this.shadowEmitter;
|
|
@@ -62571,142 +62727,271 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62571
62727
|
return model;
|
|
62572
62728
|
}
|
|
62573
62729
|
initElement(element) {
|
|
62574
|
-
let shadow = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
62575
|
-
if (shadow) {
|
|
62576
|
-
element.shadow = "layer";
|
|
62577
|
-
}
|
|
62578
|
-
element.strokeWidth = this.toolbarModel.strokeWidth;
|
|
62579
|
-
element.strokeColor = this.toolbarModel.strokeColor;
|
|
62580
|
-
element.fillColor = this.toolbarModel.fillColor;
|
|
62581
|
-
element.ownerId = this.userManager.selfId;
|
|
62582
62730
|
element.shadowEmitter = this.shadowEmitter;
|
|
62583
62731
|
}
|
|
62584
62732
|
removeElementItem(uuid) {
|
|
62585
62733
|
this.elements.delete(uuid);
|
|
62586
62734
|
}
|
|
62587
|
-
addElementToDoc(map) {
|
|
62588
|
-
this.elements.doc?.transact(() => {
|
|
62589
|
-
const uuid = this.uuid;
|
|
62590
|
-
map.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62591
|
-
map.set(ElementModel.KEYS.uuid, uuid);
|
|
62592
|
-
this.elements.set(uuid, map);
|
|
62593
|
-
}, elementsUndoOrigin);
|
|
62594
|
-
}
|
|
62595
62735
|
confirmPermission() {
|
|
62596
62736
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
62597
62737
|
if (!hasPermission) {
|
|
62598
|
-
|
|
62738
|
+
(0, import_forge_room2.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warning");
|
|
62599
62739
|
}
|
|
62600
62740
|
return hasPermission;
|
|
62601
62741
|
}
|
|
62742
|
+
createImage(src) {
|
|
62743
|
+
if (!this.confirmPermission()) {
|
|
62744
|
+
return;
|
|
62745
|
+
}
|
|
62746
|
+
const yMap = new Y12.Map();
|
|
62747
|
+
this.elements.doc?.transact(() => {
|
|
62748
|
+
const uuid = this.uuid;
|
|
62749
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62750
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62751
|
+
yMap.set("type", "image");
|
|
62752
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62753
|
+
this.elements.set(uuid, yMap);
|
|
62754
|
+
}, elementsUndoOrigin);
|
|
62755
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
62756
|
+
model.root.set("src", src);
|
|
62757
|
+
const initMatrix = new this.scope.Matrix();
|
|
62758
|
+
const center = this.scope.project.view.center;
|
|
62759
|
+
initMatrix.translate({
|
|
62760
|
+
x: center.x,
|
|
62761
|
+
y: center.y
|
|
62762
|
+
});
|
|
62763
|
+
model.appendPointsMatrix(initMatrix);
|
|
62764
|
+
model.ownerId = this.userManager.selfId;
|
|
62765
|
+
}
|
|
62602
62766
|
createCurve() {
|
|
62603
62767
|
let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
62604
62768
|
if (!this.confirmPermission()) {
|
|
62605
62769
|
return null;
|
|
62606
62770
|
}
|
|
62607
|
-
const
|
|
62608
|
-
this.
|
|
62609
|
-
|
|
62771
|
+
const yMap = new Y12.Map();
|
|
62772
|
+
this.elements.doc?.transact(() => {
|
|
62773
|
+
const uuid = this.uuid;
|
|
62774
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62775
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62776
|
+
yMap.set("type", "curve");
|
|
62777
|
+
if (shadow) {
|
|
62778
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62779
|
+
}
|
|
62780
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62781
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62782
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62783
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62784
|
+
this.elements.set(uuid, yMap);
|
|
62785
|
+
}, elementsUndoOrigin);
|
|
62786
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
62787
|
+
this.initElement(curveModel);
|
|
62610
62788
|
return curveModel;
|
|
62611
62789
|
}
|
|
62612
62790
|
createLaserPointer() {
|
|
62613
62791
|
if (!this.confirmPermission()) {
|
|
62614
62792
|
return null;
|
|
62615
62793
|
}
|
|
62616
|
-
const
|
|
62794
|
+
const yMap = new Y12.Map();
|
|
62795
|
+
this.elements.doc?.transact(() => {
|
|
62796
|
+
const uuid = this.uuid;
|
|
62797
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62798
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62799
|
+
yMap.set("type", "laser");
|
|
62800
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62801
|
+
yMap.set(ElementModel.KEYS.strokeWidth, 8);
|
|
62802
|
+
yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
|
|
62803
|
+
yMap.set(ElementModel.KEYS.fillColor, "#F44336");
|
|
62804
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62805
|
+
this.elements.set(uuid, yMap);
|
|
62806
|
+
}, elementsUndoOrigin);
|
|
62807
|
+
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
62617
62808
|
this.removeElementItem(uuid);
|
|
62618
62809
|
});
|
|
62619
|
-
model.strokeWidth = 8;
|
|
62620
|
-
model.strokeColor = "#F44336";
|
|
62621
|
-
model.fillColor = "#F44336";
|
|
62622
|
-
model.ownerId = this.userManager.selfId;
|
|
62623
|
-
model.shadow = "layer";
|
|
62624
|
-
this.addElementToDoc(model.root);
|
|
62625
62810
|
return model;
|
|
62626
62811
|
}
|
|
62627
62812
|
createEraser() {
|
|
62628
62813
|
if (!this.hasPermission(WhiteboardPermissionFlag.deleteSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
62629
62814
|
return null;
|
|
62630
62815
|
}
|
|
62631
|
-
const
|
|
62632
|
-
|
|
62633
|
-
|
|
62634
|
-
|
|
62635
|
-
|
|
62636
|
-
|
|
62637
|
-
|
|
62816
|
+
const yMap = new Y12.Map();
|
|
62817
|
+
this.elements.doc?.transact(() => {
|
|
62818
|
+
const uuid = this.uuid;
|
|
62819
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62820
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62821
|
+
yMap.set("type", "eraser");
|
|
62822
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62823
|
+
yMap.set(ElementModel.KEYS.strokeWidth, 4);
|
|
62824
|
+
yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
|
|
62825
|
+
yMap.set(ElementModel.KEYS.fillColor, "#9E9E9E");
|
|
62826
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62827
|
+
this.elements.set(uuid, yMap);
|
|
62828
|
+
}, elementsUndoOrigin);
|
|
62829
|
+
const model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
62638
62830
|
return model;
|
|
62639
62831
|
}
|
|
62640
62832
|
createTriangle(shadow) {
|
|
62641
62833
|
if (!this.confirmPermission()) {
|
|
62642
62834
|
return null;
|
|
62643
62835
|
}
|
|
62644
|
-
const
|
|
62645
|
-
this.
|
|
62836
|
+
const yMap = new Y12.Map();
|
|
62837
|
+
this.elements.doc?.transact(() => {
|
|
62838
|
+
const uuid = this.uuid;
|
|
62839
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62840
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62841
|
+
yMap.set("type", "triangle");
|
|
62842
|
+
if (shadow) {
|
|
62843
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62844
|
+
}
|
|
62845
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62846
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62847
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62848
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62849
|
+
this.elements.set(uuid, yMap);
|
|
62850
|
+
}, elementsUndoOrigin);
|
|
62851
|
+
const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
62852
|
+
this.initElement(triangle);
|
|
62646
62853
|
triangle.dashArray = this.toolbarModel.dashArray;
|
|
62647
|
-
this.addElementToDoc(triangle.root);
|
|
62648
62854
|
return triangle;
|
|
62649
62855
|
}
|
|
62650
62856
|
createRectangle(shadow) {
|
|
62651
62857
|
if (!this.confirmPermission()) {
|
|
62652
62858
|
return null;
|
|
62653
62859
|
}
|
|
62654
|
-
const
|
|
62655
|
-
this.
|
|
62860
|
+
const yMap = new Y12.Map();
|
|
62861
|
+
this.elements.doc?.transact(() => {
|
|
62862
|
+
const uuid = this.uuid;
|
|
62863
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62864
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62865
|
+
yMap.set("type", "rectangle");
|
|
62866
|
+
if (shadow) {
|
|
62867
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62868
|
+
}
|
|
62869
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62870
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62871
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62872
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62873
|
+
this.elements.set(uuid, yMap);
|
|
62874
|
+
}, elementsUndoOrigin);
|
|
62875
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
62876
|
+
this.initElement(rect);
|
|
62656
62877
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
62657
|
-
this.addElementToDoc(rect.root);
|
|
62658
62878
|
return rect;
|
|
62659
62879
|
}
|
|
62660
62880
|
createSegmentedPath(type, shadow) {
|
|
62661
62881
|
if (!this.confirmPermission()) {
|
|
62662
62882
|
return null;
|
|
62663
62883
|
}
|
|
62664
|
-
const
|
|
62665
|
-
this.
|
|
62884
|
+
const yMap = new Y12.Map();
|
|
62885
|
+
this.elements.doc?.transact(() => {
|
|
62886
|
+
const uuid = this.uuid;
|
|
62887
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62888
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62889
|
+
yMap.set("type", type);
|
|
62890
|
+
if (shadow) {
|
|
62891
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62892
|
+
}
|
|
62893
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62894
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62895
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62896
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62897
|
+
this.elements.set(uuid, yMap);
|
|
62898
|
+
}, elementsUndoOrigin);
|
|
62899
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
62900
|
+
this.initElement(segmentsModel);
|
|
62666
62901
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
62667
|
-
this.addElementToDoc(segmentsModel.root);
|
|
62668
62902
|
return segmentsModel;
|
|
62669
62903
|
}
|
|
62670
62904
|
createSelector() {
|
|
62671
|
-
let
|
|
62905
|
+
let _shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
62672
62906
|
if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
62673
62907
|
return null;
|
|
62674
62908
|
}
|
|
62675
|
-
const
|
|
62909
|
+
const yMap = new Y12.Map();
|
|
62910
|
+
this.elements.doc?.transact(() => {
|
|
62911
|
+
const uuid = this.uuid;
|
|
62912
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62913
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62914
|
+
yMap.set("type", "selector");
|
|
62915
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62916
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62917
|
+
this.elements.set(uuid, yMap);
|
|
62918
|
+
}, elementsUndoOrigin);
|
|
62919
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
62676
62920
|
selectorModel.shadow = "layer";
|
|
62677
|
-
this.addElementToDoc(selectorModel.root);
|
|
62678
62921
|
return selectorModel;
|
|
62679
62922
|
}
|
|
62680
62923
|
createStraightLine(shadow) {
|
|
62681
62924
|
if (!this.confirmPermission()) {
|
|
62682
62925
|
return null;
|
|
62683
62926
|
}
|
|
62684
|
-
const
|
|
62685
|
-
this.
|
|
62927
|
+
const yMap = new Y12.Map();
|
|
62928
|
+
this.elements.doc?.transact(() => {
|
|
62929
|
+
const uuid = this.uuid;
|
|
62930
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62931
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62932
|
+
yMap.set("type", "line");
|
|
62933
|
+
if (shadow) {
|
|
62934
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62935
|
+
}
|
|
62936
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62937
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62938
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62939
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62940
|
+
this.elements.set(uuid, yMap);
|
|
62941
|
+
}, elementsUndoOrigin);
|
|
62942
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
62943
|
+
this.initElement(straightLineModel);
|
|
62686
62944
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
62687
|
-
this.addElementToDoc(straightLineModel.root);
|
|
62688
62945
|
return straightLineModel;
|
|
62689
62946
|
}
|
|
62690
62947
|
createLinePath(shadow) {
|
|
62691
62948
|
if (!this.confirmPermission()) {
|
|
62692
62949
|
return null;
|
|
62693
62950
|
}
|
|
62694
|
-
const
|
|
62695
|
-
this.
|
|
62951
|
+
const yMap = new Y12.Map();
|
|
62952
|
+
this.elements.doc?.transact(() => {
|
|
62953
|
+
const uuid = this.uuid;
|
|
62954
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62955
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62956
|
+
yMap.set("type", "arrow");
|
|
62957
|
+
if (shadow) {
|
|
62958
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62959
|
+
}
|
|
62960
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62961
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62962
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62963
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62964
|
+
this.elements.set(uuid, yMap);
|
|
62965
|
+
}, elementsUndoOrigin);
|
|
62966
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
|
|
62967
|
+
this.initElement(lineModel);
|
|
62696
62968
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
62697
|
-
this.addElementToDoc(lineModel.root);
|
|
62698
62969
|
return lineModel;
|
|
62699
62970
|
}
|
|
62700
62971
|
createPointText(x, y, shadow) {
|
|
62701
62972
|
if (!this.confirmPermission()) {
|
|
62702
62973
|
return null;
|
|
62703
62974
|
}
|
|
62704
|
-
const
|
|
62975
|
+
const yMap = new Y12.Map();
|
|
62976
|
+
this.elements.doc?.transact(() => {
|
|
62977
|
+
const uuid = this.uuid;
|
|
62978
|
+
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
62979
|
+
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
62980
|
+
yMap.set("type", "point-text");
|
|
62981
|
+
if (shadow) {
|
|
62982
|
+
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
62983
|
+
}
|
|
62984
|
+
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
62985
|
+
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
62986
|
+
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
62987
|
+
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
62988
|
+
this.elements.set(uuid, yMap);
|
|
62989
|
+
}, elementsUndoOrigin);
|
|
62990
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
62705
62991
|
pointTextModel.setPoints([x, y]);
|
|
62706
62992
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
62707
62993
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
62708
|
-
this.initElement(pointTextModel
|
|
62709
|
-
this.addElementToDoc(pointTextModel.root);
|
|
62994
|
+
this.initElement(pointTextModel);
|
|
62710
62995
|
return pointTextModel;
|
|
62711
62996
|
}
|
|
62712
62997
|
clearElement() {
|
|
@@ -62724,8 +63009,14 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
62724
63009
|
removeIds.forEach((id) => this.elements.delete(id));
|
|
62725
63010
|
});
|
|
62726
63011
|
}
|
|
62727
|
-
dispose() {
|
|
62728
|
-
this.elements.
|
|
63012
|
+
dispose(clearElements) {
|
|
63013
|
+
(0, import_forge_room2.removeObserver)(this.elements, this.onElementsChange);
|
|
63014
|
+
if (clearElements) {
|
|
63015
|
+
this.elements.clear();
|
|
63016
|
+
}
|
|
63017
|
+
Array.from(this.elementModels.values()).forEach((model) => {
|
|
63018
|
+
model.dispose();
|
|
63019
|
+
});
|
|
62729
63020
|
}
|
|
62730
63021
|
};
|
|
62731
63022
|
var import_lodash8 = __toESM2(require_lodash(), 1);
|
|
@@ -62764,10 +63055,10 @@ var AnglePrecision = Deg2Rad(2);
|
|
|
62764
63055
|
var Phi = 0.5 * (-1 + Math.sqrt(5));
|
|
62765
63056
|
function DollarRecognizer() {
|
|
62766
63057
|
this.Unistrokes = new Array(3);
|
|
62767
|
-
this.Unistrokes[0] = new Unistroke("triangle", new
|
|
62768
|
-
this.Unistrokes[1] = new Unistroke("rectangle", new
|
|
62769
|
-
this.Unistrokes[2] = new Unistroke("circle", new
|
|
62770
|
-
this.Unistrokes[3] = new Unistroke("arrow", new
|
|
63058
|
+
this.Unistrokes[0] = new Unistroke("triangle", [new Point(137, 139), new Point(135, 141), new Point(133, 144), new Point(132, 146), new Point(130, 149), new Point(128, 151), new Point(126, 155), new Point(123, 160), new Point(120, 166), new Point(116, 171), new Point(112, 177), new Point(107, 183), new Point(102, 188), new Point(100, 191), new Point(95, 195), new Point(90, 199), new Point(86, 203), new Point(82, 206), new Point(80, 209), new Point(75, 213), new Point(73, 213), new Point(70, 216), new Point(67, 219), new Point(64, 221), new Point(61, 223), new Point(60, 225), new Point(62, 226), new Point(65, 225), new Point(67, 226), new Point(74, 226), new Point(77, 227), new Point(85, 229), new Point(91, 230), new Point(99, 231), new Point(108, 232), new Point(116, 233), new Point(125, 233), new Point(134, 234), new Point(145, 233), new Point(153, 232), new Point(160, 233), new Point(170, 234), new Point(177, 235), new Point(179, 236), new Point(186, 237), new Point(193, 238), new Point(198, 239), new Point(200, 237), new Point(202, 239), new Point(204, 238), new Point(206, 234), new Point(205, 230), new Point(202, 222), new Point(197, 216), new Point(192, 207), new Point(186, 198), new Point(179, 189), new Point(174, 183), new Point(170, 178), new Point(164, 171), new Point(161, 168), new Point(154, 160), new Point(148, 155), new Point(143, 150), new Point(138, 148), new Point(136, 148)]);
|
|
63059
|
+
this.Unistrokes[1] = new Unistroke("rectangle", [new Point(78, 149), new Point(78, 153), new Point(78, 157), new Point(78, 160), new Point(79, 162), new Point(79, 164), new Point(79, 167), new Point(79, 169), new Point(79, 173), new Point(79, 178), new Point(79, 183), new Point(80, 189), new Point(80, 193), new Point(80, 198), new Point(80, 202), new Point(81, 208), new Point(81, 210), new Point(81, 216), new Point(82, 222), new Point(82, 224), new Point(82, 227), new Point(83, 229), new Point(83, 231), new Point(85, 230), new Point(88, 232), new Point(90, 233), new Point(92, 232), new Point(94, 233), new Point(99, 232), new Point(102, 233), new Point(106, 233), new Point(109, 234), new Point(117, 235), new Point(123, 236), new Point(126, 236), new Point(135, 237), new Point(142, 238), new Point(145, 238), new Point(152, 238), new Point(154, 239), new Point(165, 238), new Point(174, 237), new Point(179, 236), new Point(186, 235), new Point(191, 235), new Point(195, 233), new Point(197, 233), new Point(200, 233), new Point(201, 235), new Point(201, 233), new Point(199, 231), new Point(198, 226), new Point(198, 220), new Point(196, 207), new Point(195, 195), new Point(195, 181), new Point(195, 173), new Point(195, 163), new Point(194, 155), new Point(192, 145), new Point(192, 143), new Point(192, 138), new Point(191, 135), new Point(191, 133), new Point(191, 130), new Point(190, 128), new Point(188, 129), new Point(186, 129), new Point(181, 132), new Point(173, 131), new Point(162, 131), new Point(151, 132), new Point(149, 132), new Point(138, 132), new Point(136, 132), new Point(122, 131), new Point(120, 131), new Point(109, 130), new Point(107, 130), new Point(90, 132), new Point(81, 133), new Point(76, 133)]);
|
|
63060
|
+
this.Unistrokes[2] = new Unistroke("circle", [new Point(127, 141), new Point(124, 140), new Point(120, 139), new Point(118, 139), new Point(116, 139), new Point(111, 140), new Point(109, 141), new Point(104, 144), new Point(100, 147), new Point(96, 152), new Point(93, 157), new Point(90, 163), new Point(87, 169), new Point(85, 175), new Point(83, 181), new Point(82, 190), new Point(82, 195), new Point(83, 200), new Point(84, 205), new Point(88, 213), new Point(91, 216), new Point(96, 219), new Point(103, 222), new Point(108, 224), new Point(111, 224), new Point(120, 224), new Point(133, 223), new Point(142, 222), new Point(152, 218), new Point(160, 214), new Point(167, 210), new Point(173, 204), new Point(178, 198), new Point(179, 196), new Point(182, 188), new Point(182, 177), new Point(178, 167), new Point(170, 150), new Point(163, 138), new Point(152, 130), new Point(143, 129), new Point(140, 131), new Point(129, 136), new Point(126, 139)]);
|
|
63061
|
+
this.Unistrokes[3] = new Unistroke("arrow", [new Point(68, 222), new Point(70, 220), new Point(73, 218), new Point(75, 217), new Point(77, 215), new Point(80, 213), new Point(82, 212), new Point(84, 210), new Point(87, 209), new Point(89, 208), new Point(92, 206), new Point(95, 204), new Point(101, 201), new Point(106, 198), new Point(112, 194), new Point(118, 191), new Point(124, 187), new Point(127, 186), new Point(132, 183), new Point(138, 181), new Point(141, 180), new Point(146, 178), new Point(154, 173), new Point(159, 171), new Point(161, 170), new Point(166, 167), new Point(168, 167), new Point(171, 166), new Point(174, 164), new Point(177, 162), new Point(180, 160), new Point(182, 158), new Point(183, 156), new Point(181, 154), new Point(178, 153), new Point(171, 153), new Point(164, 153), new Point(160, 153), new Point(150, 154), new Point(147, 155), new Point(141, 157), new Point(137, 158), new Point(135, 158), new Point(137, 158), new Point(140, 157), new Point(143, 156), new Point(151, 154), new Point(160, 152), new Point(170, 149), new Point(179, 147), new Point(185, 145), new Point(192, 144), new Point(196, 144), new Point(198, 144), new Point(200, 144), new Point(201, 147), new Point(199, 149), new Point(194, 157), new Point(191, 160), new Point(186, 167), new Point(180, 176), new Point(177, 179), new Point(171, 187), new Point(169, 189), new Point(165, 194), new Point(164, 196)]);
|
|
62771
63062
|
this.Recognize = function(points, useProtractor) {
|
|
62772
63063
|
var t0 = Date.now();
|
|
62773
63064
|
var candidate = new Unistroke("", points);
|
|
@@ -62828,7 +63119,7 @@ function RotateBy(points, radians) {
|
|
|
62828
63119
|
var c = Centroid(points);
|
|
62829
63120
|
var cos = Math.cos(radians);
|
|
62830
63121
|
var sin = Math.sin(radians);
|
|
62831
|
-
var newpoints =
|
|
63122
|
+
var newpoints = [];
|
|
62832
63123
|
for (var i = 0; i < points.length; i++) {
|
|
62833
63124
|
var qx = (points[i].X - c.X) * cos - (points[i].Y - c.Y) * sin + c.X;
|
|
62834
63125
|
var qy = (points[i].X - c.X) * sin + (points[i].Y - c.Y) * cos + c.Y;
|
|
@@ -62838,7 +63129,7 @@ function RotateBy(points, radians) {
|
|
|
62838
63129
|
}
|
|
62839
63130
|
function ScaleTo(points, size) {
|
|
62840
63131
|
var B2 = BoundingBox(points);
|
|
62841
|
-
var newpoints =
|
|
63132
|
+
var newpoints = [];
|
|
62842
63133
|
for (var i = 0; i < points.length; i++) {
|
|
62843
63134
|
var qx = points[i].X * (size / B2.Width);
|
|
62844
63135
|
var qy = points[i].Y * (size / B2.Height);
|
|
@@ -62848,7 +63139,7 @@ function ScaleTo(points, size) {
|
|
|
62848
63139
|
}
|
|
62849
63140
|
function TranslateTo(points, pt) {
|
|
62850
63141
|
var c = Centroid(points);
|
|
62851
|
-
var newpoints =
|
|
63142
|
+
var newpoints = [];
|
|
62852
63143
|
for (var i = 0; i < points.length; i++) {
|
|
62853
63144
|
var qx = points[i].X + pt.X - c.X;
|
|
62854
63145
|
var qy = points[i].Y + pt.Y - c.Y;
|
|
@@ -62858,14 +63149,14 @@ function TranslateTo(points, pt) {
|
|
|
62858
63149
|
}
|
|
62859
63150
|
function Vectorize(points) {
|
|
62860
63151
|
var sum = 0;
|
|
62861
|
-
var vector =
|
|
62862
|
-
for (
|
|
63152
|
+
var vector = [];
|
|
63153
|
+
for (let i = 0; i < points.length; i++) {
|
|
62863
63154
|
vector[vector.length] = points[i].X;
|
|
62864
63155
|
vector[vector.length] = points[i].Y;
|
|
62865
63156
|
sum += points[i].X * points[i].X + points[i].Y * points[i].Y;
|
|
62866
63157
|
}
|
|
62867
63158
|
var magnitude = Math.sqrt(sum);
|
|
62868
|
-
for (
|
|
63159
|
+
for (let i = 0; i < vector.length; i++)
|
|
62869
63160
|
vector[i] /= magnitude;
|
|
62870
63161
|
return vector;
|
|
62871
63162
|
}
|
|
@@ -63013,19 +63304,38 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
63013
63304
|
_defineProperty19(this, "elementModel", null);
|
|
63014
63305
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
63015
63306
|
_defineProperty19(this, "pointCount", 0);
|
|
63016
|
-
this
|
|
63307
|
+
_defineProperty19(this, "showLiveCursor", true);
|
|
63308
|
+
this.tool.minDistance = 5;
|
|
63017
63309
|
}
|
|
63018
|
-
onMouseDown(
|
|
63310
|
+
onMouseDown(_event) {
|
|
63019
63311
|
this.pointCount = 0;
|
|
63312
|
+
if (this.elementModel) {
|
|
63313
|
+
this.elementModel.dispose();
|
|
63314
|
+
}
|
|
63020
63315
|
this.elementModel = this.modelGetter().createCurve(true);
|
|
63021
63316
|
}
|
|
63022
63317
|
onMouseDrag(event) {
|
|
63023
63318
|
if (this.pointCount > 1024) {
|
|
63024
63319
|
return;
|
|
63025
63320
|
}
|
|
63321
|
+
const MIN_DISTANCE = 4;
|
|
63026
63322
|
if (this.elementModel) {
|
|
63027
|
-
this.
|
|
63028
|
-
|
|
63323
|
+
const len = this.elementModel.points.length;
|
|
63324
|
+
let last = {
|
|
63325
|
+
x: 0,
|
|
63326
|
+
y: 0
|
|
63327
|
+
};
|
|
63328
|
+
if (len >= 2) {
|
|
63329
|
+
last = {
|
|
63330
|
+
x: this.elementModel.points[len - 2],
|
|
63331
|
+
y: this.elementModel.points[len - 1]
|
|
63332
|
+
};
|
|
63333
|
+
}
|
|
63334
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
63335
|
+
if (dist >= MIN_DISTANCE) {
|
|
63336
|
+
this.pointCount += 1;
|
|
63337
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
63338
|
+
}
|
|
63029
63339
|
}
|
|
63030
63340
|
}
|
|
63031
63341
|
onMouseUp(event) {
|
|
@@ -63082,9 +63392,13 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
63082
63392
|
_defineProperty20(this, "elementModel", null);
|
|
63083
63393
|
_defineProperty20(this, "from", null);
|
|
63084
63394
|
_defineProperty20(this, "to", null);
|
|
63395
|
+
_defineProperty20(this, "showLiveCursor", true);
|
|
63085
63396
|
this.tool.minDistance = 1;
|
|
63086
63397
|
}
|
|
63087
63398
|
onMouseDown(event) {
|
|
63399
|
+
if (this.elementModel) {
|
|
63400
|
+
this.elementModel.dispose();
|
|
63401
|
+
}
|
|
63088
63402
|
this.elementModel = this.modelGetter().createRectangle(true);
|
|
63089
63403
|
this.from = event.point.clone();
|
|
63090
63404
|
this.to = event.point.clone();
|
|
@@ -63130,7 +63444,7 @@ var TOOLBAR_KEYS = {
|
|
|
63130
63444
|
strokeWidth: "strokeWidth",
|
|
63131
63445
|
dashArray: "dashArray"
|
|
63132
63446
|
};
|
|
63133
|
-
var ToolbarModel = class extends
|
|
63447
|
+
var ToolbarModel = class extends import_eventemitter32.default {
|
|
63134
63448
|
get currentTool() {
|
|
63135
63449
|
return this.root.get(TOOLBAR_KEYS.tool);
|
|
63136
63450
|
}
|
|
@@ -63199,6 +63513,10 @@ var ToolbarModel = class extends import_eventemitter33.default {
|
|
|
63199
63513
|
}
|
|
63200
63514
|
});
|
|
63201
63515
|
}
|
|
63516
|
+
dispose() {
|
|
63517
|
+
(0, import_forge_room6.removeObserver)(this.root, this.handleRootUpdate);
|
|
63518
|
+
this.removeAllListeners();
|
|
63519
|
+
}
|
|
63202
63520
|
};
|
|
63203
63521
|
function _defineProperty22(e, r, t) {
|
|
63204
63522
|
return (r = _toPropertyKey22(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -63225,11 +63543,15 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
63225
63543
|
_defineProperty22(this, "to", null);
|
|
63226
63544
|
_defineProperty22(this, "selectElementsModel", void 0);
|
|
63227
63545
|
_defineProperty22(this, "selectElements", /* @__PURE__ */ new Map());
|
|
63546
|
+
_defineProperty22(this, "showLiveCursor", false);
|
|
63228
63547
|
this.selectElementsModel = selectElementsModel;
|
|
63229
63548
|
}
|
|
63230
63549
|
onMouseDown(event) {
|
|
63231
63550
|
this.from = null;
|
|
63232
63551
|
this.to = null;
|
|
63552
|
+
if (this.elementModel) {
|
|
63553
|
+
this.elementModel.dispose();
|
|
63554
|
+
}
|
|
63233
63555
|
this.elementModel = this.modelGetter().createSelector();
|
|
63234
63556
|
this.from = event.point.clone();
|
|
63235
63557
|
this.to = event.point.clone();
|
|
@@ -63302,7 +63624,7 @@ function _toPrimitive23(t, r) {
|
|
|
63302
63624
|
}
|
|
63303
63625
|
return ("string" === r ? String : Number)(t);
|
|
63304
63626
|
}
|
|
63305
|
-
var SelectElementsModel = class extends
|
|
63627
|
+
var SelectElementsModel = class extends import_eventemitter33.default {
|
|
63306
63628
|
get hasEditSelfPermission() {
|
|
63307
63629
|
return this.hasPermission(WhiteboardPermissionFlag.editSelf);
|
|
63308
63630
|
}
|
|
@@ -63318,13 +63640,17 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
63318
63640
|
_defineProperty23(this, "handleUserLeave", (user) => {
|
|
63319
63641
|
const cb = this.observers.get(user.id);
|
|
63320
63642
|
if (cb) {
|
|
63321
|
-
this.requestUserMap(user.id)
|
|
63643
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
63644
|
+
this.observers.delete(user.id);
|
|
63322
63645
|
}
|
|
63323
63646
|
});
|
|
63324
63647
|
_defineProperty23(this, "handleUserJoin", (user) => {
|
|
63325
63648
|
const observer = (evts) => {
|
|
63326
63649
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
63327
63650
|
};
|
|
63651
|
+
if (this.observers.has(user.id)) {
|
|
63652
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
63653
|
+
}
|
|
63328
63654
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
63329
63655
|
this.observers.set(user.id, observer);
|
|
63330
63656
|
});
|
|
@@ -63344,6 +63670,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
63344
63670
|
const observer = (evts) => {
|
|
63345
63671
|
this.handleUserSelectElementsChange(userId, evts);
|
|
63346
63672
|
};
|
|
63673
|
+
if (this.observers.has(userId)) {
|
|
63674
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
63675
|
+
}
|
|
63347
63676
|
this.requestUserMap(userId).observeDeep(observer);
|
|
63348
63677
|
this.observers.set(userId, observer);
|
|
63349
63678
|
});
|
|
@@ -63398,12 +63727,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
63398
63727
|
});
|
|
63399
63728
|
}
|
|
63400
63729
|
dispose() {
|
|
63401
|
-
this.
|
|
63402
|
-
|
|
63403
|
-
|
|
63404
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
63405
|
-
}
|
|
63406
|
-
});
|
|
63730
|
+
for (const [key, value] of this.observers.entries()) {
|
|
63731
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(key), value);
|
|
63732
|
+
}
|
|
63407
63733
|
this.observers.clear();
|
|
63408
63734
|
this.userManager.off("leave", this.handleUserLeave);
|
|
63409
63735
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -63426,7 +63752,7 @@ function _toPrimitive24(t, r) {
|
|
|
63426
63752
|
}
|
|
63427
63753
|
return ("string" === r ? String : Number)(t);
|
|
63428
63754
|
}
|
|
63429
|
-
var TextEditor = class extends
|
|
63755
|
+
var TextEditor = class extends import_eventemitter35.EventEmitter {
|
|
63430
63756
|
constructor(camera) {
|
|
63431
63757
|
super();
|
|
63432
63758
|
_defineProperty24(this, "rootView", void 0);
|
|
@@ -63459,12 +63785,12 @@ var TextEditor = class extends import_eventemitter36.EventEmitter {
|
|
|
63459
63785
|
});
|
|
63460
63786
|
this.camera = camera;
|
|
63461
63787
|
this.rootView = document.createElement("div");
|
|
63462
|
-
this.rootView.style.cssText =
|
|
63788
|
+
this.rootView.style.cssText = "position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden;";
|
|
63463
63789
|
this.content = document.createElement("div");
|
|
63464
63790
|
this.content.setAttribute("spellcheck", "false");
|
|
63465
63791
|
this.content.textContent = "";
|
|
63466
63792
|
this.content.setAttribute("contenteditable", "plaintext-only");
|
|
63467
|
-
this.content.style.cssText =
|
|
63793
|
+
this.content.style.cssText = "white-space: nowrap;border:1px solid red;text-wrap:nowrap;caret-color:red;line-height:1.2em;position:absolute;z-index:2;color:transparent;outline:none;";
|
|
63468
63794
|
this.content.style.transformOrigin = "0 0";
|
|
63469
63795
|
this.rootView.appendChild(this.content);
|
|
63470
63796
|
this.content.addEventListener("input", this.handleContentInput);
|
|
@@ -63567,7 +63893,7 @@ var ANCHOR_STYLE = {
|
|
|
63567
63893
|
b: "cursor:s-resize;bottom:-3px;left:50%;translate:-50%;",
|
|
63568
63894
|
br: "cursor:se-resize;bottom:-3px;right:-3px"
|
|
63569
63895
|
};
|
|
63570
|
-
var Bounds = class extends
|
|
63896
|
+
var Bounds = class extends import_eventemitter34.default {
|
|
63571
63897
|
get width() {
|
|
63572
63898
|
return this.maxX - this.minX;
|
|
63573
63899
|
}
|
|
@@ -63706,7 +64032,7 @@ var Bounds = class extends import_eventemitter35.default {
|
|
|
63706
64032
|
this.maxY = maxY;
|
|
63707
64033
|
}
|
|
63708
64034
|
};
|
|
63709
|
-
var Editor = class extends
|
|
64035
|
+
var Editor = class extends import_eventemitter34.default {
|
|
63710
64036
|
constructor(scope, shadowScope, shadowEmitter, canvasElement, camera, initConfig) {
|
|
63711
64037
|
super();
|
|
63712
64038
|
_defineProperty25(this, "rootView", void 0);
|
|
@@ -63807,7 +64133,7 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
63807
64133
|
}
|
|
63808
64134
|
if (this.editMode === "matrix" && this.editAnchor && this.lastEditPoint) {
|
|
63809
64135
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
63810
|
-
|
|
64136
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
63811
64137
|
this.bounds.offsetBy(this.editAnchor, offsetX, offsetY, this.uniformScale ? this.aspectRatio : -1);
|
|
63812
64138
|
this.lastEditPoint = {
|
|
63813
64139
|
x: evt.pageX,
|
|
@@ -63832,7 +64158,7 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
63832
64158
|
}
|
|
63833
64159
|
if (this.editMode === "translate" && this.lastEditPoint) {
|
|
63834
64160
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
63835
|
-
|
|
64161
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
63836
64162
|
this.bounds.translate(offsetX, offsetY);
|
|
63837
64163
|
this.updateBoundsByShadow();
|
|
63838
64164
|
this.lastEditPoint = {
|
|
@@ -63909,7 +64235,7 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
63909
64235
|
this.ctrlId = initConfig.ctrlId;
|
|
63910
64236
|
this.ctrlNickName = initConfig.ctrlNickName;
|
|
63911
64237
|
this.rootView = document.createElement("div");
|
|
63912
|
-
this.rootView.style.cssText =
|
|
64238
|
+
this.rootView.style.cssText = "overflow:hidden;position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
63913
64239
|
this.frame = document.createElement("div");
|
|
63914
64240
|
this.frame.style.position = "absolute";
|
|
63915
64241
|
this.frame.style.padding = "8px";
|
|
@@ -63930,7 +64256,7 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
63930
64256
|
} else {
|
|
63931
64257
|
this.title = document.createElement("div");
|
|
63932
64258
|
this.title.textContent = `${this.ctrlNickName}`;
|
|
63933
|
-
this.title.style.cssText =
|
|
64259
|
+
this.title.style.cssText = "color:#fff;font-size:12px;padding: 0.2em 0.4em;border-radius: 0.4em;position: absolute;top: 0%;left: 0;margin: -0.4em;transform: translate(-100%, -100%);";
|
|
63934
64260
|
this.frame.appendChild(this.title);
|
|
63935
64261
|
this.rootView.style.pointerEvents = "none";
|
|
63936
64262
|
}
|
|
@@ -64153,6 +64479,7 @@ var TextTool = class extends WhiteboardTool {
|
|
|
64153
64479
|
_defineProperty26(this, "elementModel", null);
|
|
64154
64480
|
_defineProperty26(this, "toolbarModel", void 0);
|
|
64155
64481
|
_defineProperty26(this, "camera", void 0);
|
|
64482
|
+
_defineProperty26(this, "showLiveCursor", false);
|
|
64156
64483
|
this.rootView = rootView;
|
|
64157
64484
|
this.canvasElement = canvasElement;
|
|
64158
64485
|
this.toolbarModel = toolbarModel;
|
|
@@ -64161,7 +64488,7 @@ var TextTool = class extends WhiteboardTool {
|
|
|
64161
64488
|
onMouseDown(event) {
|
|
64162
64489
|
this.from = event.point.clone();
|
|
64163
64490
|
}
|
|
64164
|
-
onMouseDrag(
|
|
64491
|
+
onMouseDrag(_event) {
|
|
64165
64492
|
}
|
|
64166
64493
|
onMouseUp(event) {
|
|
64167
64494
|
this.to = event.point.clone();
|
|
@@ -64173,6 +64500,9 @@ var TextTool = class extends WhiteboardTool {
|
|
|
64173
64500
|
}
|
|
64174
64501
|
}
|
|
64175
64502
|
createPointEditor(x, y) {
|
|
64503
|
+
if (this.elementModel) {
|
|
64504
|
+
this.elementModel.dispose();
|
|
64505
|
+
}
|
|
64176
64506
|
this.elementModel = this.modelGetter().createPointText(x, y, true);
|
|
64177
64507
|
if (this.elementModel === null) {
|
|
64178
64508
|
return;
|
|
@@ -64228,7 +64558,7 @@ function _toPrimitive27(t, r) {
|
|
|
64228
64558
|
}
|
|
64229
64559
|
return ("string" === r ? String : Number)(t);
|
|
64230
64560
|
}
|
|
64231
|
-
var Gesture = class extends
|
|
64561
|
+
var Gesture = class extends import_eventemitter37.default {
|
|
64232
64562
|
constructor(element, scope) {
|
|
64233
64563
|
super();
|
|
64234
64564
|
_defineProperty27(this, "element", void 0);
|
|
@@ -64307,7 +64637,7 @@ function _toPrimitive28(t, r) {
|
|
|
64307
64637
|
}
|
|
64308
64638
|
return ("string" === r ? String : Number)(t);
|
|
64309
64639
|
}
|
|
64310
|
-
var Camera = class extends
|
|
64640
|
+
var Camera = class extends import_eventemitter36.default {
|
|
64311
64641
|
get inherentMatrix() {
|
|
64312
64642
|
const inherentMatrix = new this.scope.Matrix();
|
|
64313
64643
|
inherentMatrix.scale(this.inherentScale, [0, 0]);
|
|
@@ -64363,13 +64693,16 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64363
64693
|
_defineProperty28(this, "handleUserLeave", (user) => {
|
|
64364
64694
|
const cb = this.observers.get(user.id);
|
|
64365
64695
|
if (cb) {
|
|
64366
|
-
this.requestUserMap(user.id)
|
|
64696
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), cb);
|
|
64367
64697
|
}
|
|
64368
64698
|
});
|
|
64369
64699
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
64370
64700
|
const observer = (evt) => {
|
|
64371
64701
|
this.handleViewMatrixUpdate(user.id, evt);
|
|
64372
64702
|
};
|
|
64703
|
+
if (this.observers.has(user.id)) {
|
|
64704
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), observer);
|
|
64705
|
+
}
|
|
64373
64706
|
this.requestUserMap(user.id).observe(observer);
|
|
64374
64707
|
this.observers.set(user.id, observer);
|
|
64375
64708
|
});
|
|
@@ -64449,7 +64782,7 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64449
64782
|
});
|
|
64450
64783
|
this.maxScale = maxScale;
|
|
64451
64784
|
this.bound = window.document.createElement("div");
|
|
64452
|
-
this.bound.style.cssText =
|
|
64785
|
+
this.bound.style.cssText = "transition: box-shadow 100ms;pointer-events:none;z-index:99;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
64453
64786
|
this.initSize = initSize;
|
|
64454
64787
|
this.hasPermission = hasPermission;
|
|
64455
64788
|
this.paperSize = _paperSize;
|
|
@@ -64474,6 +64807,9 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64474
64807
|
const observer = (evt) => {
|
|
64475
64808
|
this.handleViewMatrixUpdate(userId, evt);
|
|
64476
64809
|
};
|
|
64810
|
+
if (this.observers.has(userId)) {
|
|
64811
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(userId), observer);
|
|
64812
|
+
}
|
|
64477
64813
|
this.requestUserMap(userId).observe(observer);
|
|
64478
64814
|
this.observers.set(userId, observer);
|
|
64479
64815
|
});
|
|
@@ -64510,7 +64846,7 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64510
64846
|
this.bound.style.boxShadow = `inset 0px 0px 6px 2px ${this.boundaryColor}`;
|
|
64511
64847
|
window.clearTimeout(this.boundTiemoutId);
|
|
64512
64848
|
this.boundTiemoutId = window.setTimeout(() => {
|
|
64513
|
-
this.bound.style.boxShadow =
|
|
64849
|
+
this.bound.style.boxShadow = "none";
|
|
64514
64850
|
}, 100);
|
|
64515
64851
|
}
|
|
64516
64852
|
}
|
|
@@ -64520,6 +64856,9 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64520
64856
|
updateInherentScale(scale) {
|
|
64521
64857
|
this.inherentScale = scale;
|
|
64522
64858
|
}
|
|
64859
|
+
getInherentScale() {
|
|
64860
|
+
return this.inherentScale;
|
|
64861
|
+
}
|
|
64523
64862
|
getActiveMatrix() {
|
|
64524
64863
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
64525
64864
|
let matrixValue;
|
|
@@ -64662,6 +65001,19 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
64662
65001
|
y: 0
|
|
64663
65002
|
};
|
|
64664
65003
|
}
|
|
65004
|
+
dispose() {
|
|
65005
|
+
Array.from(this.observers.keys()).forEach((userId) => {
|
|
65006
|
+
const cb = this.observers.get(userId);
|
|
65007
|
+
if (cb) {
|
|
65008
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(userId), cb);
|
|
65009
|
+
}
|
|
65010
|
+
});
|
|
65011
|
+
(0, import_forge_room8.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
65012
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
65013
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
65014
|
+
this.gesture.removeAllListeners();
|
|
65015
|
+
this.removeAllListeners();
|
|
65016
|
+
}
|
|
64665
65017
|
};
|
|
64666
65018
|
function _defineProperty29(e, r, t) {
|
|
64667
65019
|
return (r = _toPropertyKey29(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -64686,9 +65038,13 @@ var EllipseTool = class extends WhiteboardTool {
|
|
|
64686
65038
|
_defineProperty29(this, "elementModel", null);
|
|
64687
65039
|
_defineProperty29(this, "from", null);
|
|
64688
65040
|
_defineProperty29(this, "to", null);
|
|
65041
|
+
_defineProperty29(this, "showLiveCursor", true);
|
|
64689
65042
|
this.tool.minDistance = 1;
|
|
64690
65043
|
}
|
|
64691
65044
|
onMouseDown(event) {
|
|
65045
|
+
if (this.elementModel) {
|
|
65046
|
+
this.elementModel.dispose();
|
|
65047
|
+
}
|
|
64692
65048
|
this.elementModel = this.modelGetter().createSegmentedPath("ellipse", true);
|
|
64693
65049
|
this.from = event.point.clone();
|
|
64694
65050
|
this.to = event.point.clone();
|
|
@@ -64735,9 +65091,13 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
64735
65091
|
_defineProperty30(this, "elementModel", null);
|
|
64736
65092
|
_defineProperty30(this, "from", null);
|
|
64737
65093
|
_defineProperty30(this, "to", null);
|
|
65094
|
+
_defineProperty30(this, "showLiveCursor", true);
|
|
64738
65095
|
this.tool.minDistance = 1;
|
|
64739
65096
|
}
|
|
64740
65097
|
onMouseDown(event) {
|
|
65098
|
+
if (this.elementModel) {
|
|
65099
|
+
this.elementModel.dispose();
|
|
65100
|
+
}
|
|
64741
65101
|
this.elementModel = this.modelGetter().createTriangle(true);
|
|
64742
65102
|
this.from = event.point.clone();
|
|
64743
65103
|
this.to = event.point.clone();
|
|
@@ -64774,8 +65134,7 @@ function _toPrimitive31(t, r) {
|
|
|
64774
65134
|
}
|
|
64775
65135
|
return ("string" === r ? String : Number)(t);
|
|
64776
65136
|
}
|
|
64777
|
-
var Whiteboard = class extends
|
|
64778
|
-
// public insertImage!: (src: string) => void;
|
|
65137
|
+
var Whiteboard = class extends import_eventemitter38.default {
|
|
64779
65138
|
constructor(view) {
|
|
64780
65139
|
super();
|
|
64781
65140
|
_defineProperty31(this, "view", void 0);
|
|
@@ -64794,6 +65153,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
64794
65153
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
64795
65154
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
64796
65155
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
65156
|
+
_defineProperty31(this, "removeElement", void 0);
|
|
64797
65157
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
64798
65158
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
64799
65159
|
_defineProperty31(this, "setCanvasBackgroundColor", void 0);
|
|
@@ -64808,6 +65168,8 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
64808
65168
|
_defineProperty31(this, "translateCamera", void 0);
|
|
64809
65169
|
_defineProperty31(this, "scaleCamera", void 0);
|
|
64810
65170
|
_defineProperty31(this, "resetCamera", void 0);
|
|
65171
|
+
_defineProperty31(this, "showLiveCursor", void 0);
|
|
65172
|
+
_defineProperty31(this, "updateViewport", void 0);
|
|
64811
65173
|
_defineProperty31(this, "setFreeModelUserPage", void 0);
|
|
64812
65174
|
_defineProperty31(this, "indexedNavigation", void 0);
|
|
64813
65175
|
_defineProperty31(this, "setViewModeToFree", void 0);
|
|
@@ -64820,6 +65182,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
64820
65182
|
_defineProperty31(this, "rasterizeElementsBounds", void 0);
|
|
64821
65183
|
_defineProperty31(this, "rasterizeMaxBounds", void 0);
|
|
64822
65184
|
_defineProperty31(this, "setInputType", void 0);
|
|
65185
|
+
_defineProperty31(this, "insertImage", void 0);
|
|
64823
65186
|
this.view = view;
|
|
64824
65187
|
}
|
|
64825
65188
|
};
|
|
@@ -64841,16 +65204,22 @@ function _toPrimitive32(t, r) {
|
|
|
64841
65204
|
return ("string" === r ? String : Number)(t);
|
|
64842
65205
|
}
|
|
64843
65206
|
var EraserTool = class extends WhiteboardTool {
|
|
64844
|
-
constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel) {
|
|
65207
|
+
constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel, shadowScope) {
|
|
64845
65208
|
super(enableToolEvent, renderableModel, shadowEmitter, scope);
|
|
64846
65209
|
_defineProperty32(this, "elementModel", null);
|
|
64847
65210
|
_defineProperty32(this, "trashedElementsModel", void 0);
|
|
64848
65211
|
_defineProperty32(this, "pointCount", 0);
|
|
65212
|
+
_defineProperty32(this, "showLiveCursor", true);
|
|
65213
|
+
_defineProperty32(this, "shadowScope", void 0);
|
|
64849
65214
|
this.trashedElementsModel = trashedElementsModel;
|
|
64850
|
-
this.tool.minDistance =
|
|
65215
|
+
this.tool.minDistance = 2;
|
|
65216
|
+
this.shadowScope = shadowScope;
|
|
64851
65217
|
}
|
|
64852
|
-
onMouseDown(
|
|
65218
|
+
onMouseDown(_event) {
|
|
64853
65219
|
this.pointCount = 0;
|
|
65220
|
+
if (this.elementModel) {
|
|
65221
|
+
this.elementModel.dispose();
|
|
65222
|
+
}
|
|
64854
65223
|
this.elementModel = this.modelGetter().createEraser();
|
|
64855
65224
|
}
|
|
64856
65225
|
onMouseDrag(event) {
|
|
@@ -64871,8 +65240,18 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
64871
65240
|
this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
|
|
64872
65241
|
}
|
|
64873
65242
|
});
|
|
65243
|
+
this.shadowScope.project.activeLayer.children.forEach((item) => {
|
|
65244
|
+
if (item.data.type && ["selector", "eraser", "laser"].indexOf(item.data.type) < 0 && item.hitTest(event.point, {
|
|
65245
|
+
segments: true,
|
|
65246
|
+
stroke: true,
|
|
65247
|
+
fill: true,
|
|
65248
|
+
tolerance: 5
|
|
65249
|
+
})) {
|
|
65250
|
+
this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
|
|
65251
|
+
}
|
|
65252
|
+
});
|
|
64874
65253
|
}
|
|
64875
|
-
onMouseUp(
|
|
65254
|
+
onMouseUp(_event) {
|
|
64876
65255
|
if (this.elementModel) {
|
|
64877
65256
|
this.modelGetter().removeElementItem(this.elementModel.uuid);
|
|
64878
65257
|
}
|
|
@@ -64896,7 +65275,7 @@ function _toPrimitive33(t, r) {
|
|
|
64896
65275
|
}
|
|
64897
65276
|
return ("string" === r ? String : Number)(t);
|
|
64898
65277
|
}
|
|
64899
|
-
var TrashedElementsModel = class extends
|
|
65278
|
+
var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
64900
65279
|
get hasDeleteSelfPermission() {
|
|
64901
65280
|
return this.hasPermission(WhiteboardPermissionFlag.deleteSelf);
|
|
64902
65281
|
}
|
|
@@ -64912,13 +65291,16 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
64912
65291
|
_defineProperty33(this, "handleUserLeave", (user) => {
|
|
64913
65292
|
const cb = this.observers.get(user.id);
|
|
64914
65293
|
if (cb) {
|
|
64915
|
-
this.requestUserMap(user.id)
|
|
65294
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
64916
65295
|
}
|
|
64917
65296
|
});
|
|
64918
65297
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
64919
65298
|
const observer = (evts) => {
|
|
64920
65299
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
64921
65300
|
};
|
|
65301
|
+
if (this.observers.has(user.id)) {
|
|
65302
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
65303
|
+
}
|
|
64922
65304
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
64923
65305
|
this.observers.set(user.id, observer);
|
|
64924
65306
|
});
|
|
@@ -64930,6 +65312,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
64930
65312
|
const observer = (evts) => {
|
|
64931
65313
|
this.handleUserTrashElementsChange(userId, evts);
|
|
64932
65314
|
};
|
|
65315
|
+
if (this.observers.has(userId)) {
|
|
65316
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
65317
|
+
}
|
|
64933
65318
|
this.requestUserMap(userId).observeDeep(observer);
|
|
64934
65319
|
this.observers.set(userId, observer);
|
|
64935
65320
|
});
|
|
@@ -64984,12 +65369,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
64984
65369
|
});
|
|
64985
65370
|
}
|
|
64986
65371
|
dispose() {
|
|
64987
|
-
this.
|
|
64988
|
-
|
|
64989
|
-
|
|
64990
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
64991
|
-
}
|
|
64992
|
-
});
|
|
65372
|
+
for (const [key, value] of this.observers.entries()) {
|
|
65373
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(key), value);
|
|
65374
|
+
}
|
|
64993
65375
|
this.observers.clear();
|
|
64994
65376
|
this.userManager.off("leave", this.handleUserLeave);
|
|
64995
65377
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -65017,10 +65399,14 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
65017
65399
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
65018
65400
|
_defineProperty34(this, "elementModel", null);
|
|
65019
65401
|
_defineProperty34(this, "pointCount", 0);
|
|
65402
|
+
_defineProperty34(this, "showLiveCursor", true);
|
|
65020
65403
|
this.tool.minDistance = 5;
|
|
65021
65404
|
}
|
|
65022
|
-
onMouseDown(
|
|
65405
|
+
onMouseDown(_event) {
|
|
65023
65406
|
this.pointCount = 0;
|
|
65407
|
+
if (this.elementModel) {
|
|
65408
|
+
this.elementModel.dispose();
|
|
65409
|
+
}
|
|
65024
65410
|
this.elementModel = this.modelGetter().createLaserPointer();
|
|
65025
65411
|
}
|
|
65026
65412
|
onMouseDrag(event) {
|
|
@@ -65032,7 +65418,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
65032
65418
|
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
65033
65419
|
}
|
|
65034
65420
|
}
|
|
65035
|
-
onMouseUp(
|
|
65421
|
+
onMouseUp(_event) {
|
|
65036
65422
|
if (this.elementModel) {
|
|
65037
65423
|
this.elementModel.beginRemoveAnimate();
|
|
65038
65424
|
}
|
|
@@ -65055,7 +65441,7 @@ function _toPrimitive35(t, r) {
|
|
|
65055
65441
|
}
|
|
65056
65442
|
return ("string" === r ? String : Number)(t);
|
|
65057
65443
|
}
|
|
65058
|
-
var PageModel = class extends
|
|
65444
|
+
var PageModel = class extends import_eventemitter310.default {
|
|
65059
65445
|
constructor(whiteboardAttrsMap, userManager, requestUserMap, pageMap, hasPermission) {
|
|
65060
65446
|
super();
|
|
65061
65447
|
_defineProperty35(this, "whiteboardAttrsMap", void 0);
|
|
@@ -65067,7 +65453,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
65067
65453
|
_defineProperty35(this, "handleUserLeave", (user) => {
|
|
65068
65454
|
const cb = this.observers.get(user.id);
|
|
65069
65455
|
if (cb) {
|
|
65070
|
-
this.requestUserMap(user.id)
|
|
65456
|
+
(0, import_forge_room10.removeObserver)(this.requestUserMap(user.id), cb);
|
|
65071
65457
|
}
|
|
65072
65458
|
});
|
|
65073
65459
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -65081,7 +65467,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
65081
65467
|
if (cameraMode === "main") {
|
|
65082
65468
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
65083
65469
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
65084
|
-
(0,
|
|
65470
|
+
(0, import_forge_room10.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
65085
65471
|
return;
|
|
65086
65472
|
}
|
|
65087
65473
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -65150,11 +65536,11 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
65150
65536
|
}
|
|
65151
65537
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
65152
65538
|
if (cameraMode !== "main") {
|
|
65153
|
-
console.warn(
|
|
65539
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
65154
65540
|
return false;
|
|
65155
65541
|
}
|
|
65156
65542
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
65157
|
-
console.warn(
|
|
65543
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
65158
65544
|
return false;
|
|
65159
65545
|
}
|
|
65160
65546
|
return true;
|
|
@@ -65206,13 +65592,22 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
65206
65592
|
}
|
|
65207
65593
|
}
|
|
65208
65594
|
}
|
|
65595
|
+
dispose() {
|
|
65596
|
+
for (const entry of this.observers.entries()) {
|
|
65597
|
+
const [userId, observer] = entry;
|
|
65598
|
+
(0, import_forge_room10.removeObserver)(this.requestUserMap(userId), observer);
|
|
65599
|
+
}
|
|
65600
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
65601
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
65602
|
+
(0, import_forge_room10.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
65603
|
+
(0, import_forge_room10.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
65604
|
+
}
|
|
65209
65605
|
};
|
|
65210
65606
|
var delay = (value) => new Promise((resolve) => setTimeout(resolve, value));
|
|
65211
65607
|
async function waitUntil(fn, timeout) {
|
|
65212
|
-
|
|
65608
|
+
const start = Date.now();
|
|
65213
65609
|
while (!fn() && Date.now() - start < timeout) {
|
|
65214
65610
|
await delay(50);
|
|
65215
|
-
start = Date.now();
|
|
65216
65611
|
}
|
|
65217
65612
|
}
|
|
65218
65613
|
function _defineProperty36(e, r, t) {
|
|
@@ -65232,19 +65627,19 @@ function _toPrimitive36(t, r) {
|
|
|
65232
65627
|
}
|
|
65233
65628
|
return ("string" === r ? String : Number)(t);
|
|
65234
65629
|
}
|
|
65235
|
-
var IndexedNavigation = class extends
|
|
65630
|
+
var IndexedNavigation = class extends import_eventemitter311.default {
|
|
65236
65631
|
get idList() {
|
|
65237
65632
|
return this.pageModel.pageList().filter((id) => /^_i_/.test(id));
|
|
65238
65633
|
}
|
|
65239
65634
|
get head() {
|
|
65240
|
-
|
|
65635
|
+
const headId = Object.keys(this.list).find((key) => {
|
|
65241
65636
|
return this.list[key] && this.list[key].prev === "";
|
|
65242
65637
|
});
|
|
65243
65638
|
if (!headId) {
|
|
65244
|
-
(0,
|
|
65639
|
+
(0, import_forge_room11.log)("indexed navigation confusion", {
|
|
65245
65640
|
list: JSON.stringify(this.list)
|
|
65246
65641
|
}, "error");
|
|
65247
|
-
throw new Error(
|
|
65642
|
+
throw new Error("indexed navigation confusion");
|
|
65248
65643
|
}
|
|
65249
65644
|
return headId;
|
|
65250
65645
|
}
|
|
@@ -65265,7 +65660,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65265
65660
|
_defineProperty36(this, "indexedPageMap", void 0);
|
|
65266
65661
|
_defineProperty36(this, "list", {});
|
|
65267
65662
|
_defineProperty36(this, "hasPermission", void 0);
|
|
65268
|
-
_defineProperty36(this, "handleIndexedPageMapUpdate", (
|
|
65663
|
+
_defineProperty36(this, "handleIndexedPageMapUpdate", (_evt) => {
|
|
65269
65664
|
this.list = this.indexedPageMap.get("list");
|
|
65270
65665
|
const needRemoveList = this.pageModel.pageList().filter((v) => /^_i_/.test(v) && Object.keys(this.list).indexOf(v) < 0);
|
|
65271
65666
|
const needAddList = Object.keys(this.list).filter((v) => this.pageModel.pageList().indexOf(v) < 0);
|
|
@@ -65320,8 +65715,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65320
65715
|
initIndexed() {
|
|
65321
65716
|
return new Promise((resolve) => {
|
|
65322
65717
|
setTimeout(() => {
|
|
65718
|
+
this.pageModel.addPage("_i_");
|
|
65323
65719
|
if (this.pageModel.pageList().length === 0) {
|
|
65324
|
-
this.pageModel.addPage("_i_");
|
|
65325
65720
|
resolve(true);
|
|
65326
65721
|
} else {
|
|
65327
65722
|
resolve(false);
|
|
@@ -65330,19 +65725,22 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65330
65725
|
});
|
|
65331
65726
|
}
|
|
65332
65727
|
/**
|
|
65333
|
-
|
|
65334
|
-
|
|
65335
|
-
|
|
65728
|
+
* 获取总页数
|
|
65729
|
+
* @returns {number}
|
|
65730
|
+
*/
|
|
65336
65731
|
get pageCount() {
|
|
65337
65732
|
return this.idList.length;
|
|
65338
65733
|
}
|
|
65339
65734
|
/**
|
|
65340
|
-
|
|
65341
|
-
|
|
65735
|
+
* 获取当前页索引
|
|
65736
|
+
*/
|
|
65342
65737
|
get currentPageIndex() {
|
|
65343
65738
|
const userPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
65344
65739
|
return this.getPageIndex(userPageId);
|
|
65345
65740
|
}
|
|
65741
|
+
get currentPageId() {
|
|
65742
|
+
return this.userMap.get(WhiteboardKeys.currentPage);
|
|
65743
|
+
}
|
|
65346
65744
|
getPageIndex(pageId) {
|
|
65347
65745
|
let i = 0;
|
|
65348
65746
|
let currentId = this.head;
|
|
@@ -65358,9 +65756,9 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65358
65756
|
return i;
|
|
65359
65757
|
}
|
|
65360
65758
|
/**
|
|
65361
|
-
|
|
65362
|
-
|
|
65363
|
-
|
|
65759
|
+
* 获取指定索引对应的 pageId
|
|
65760
|
+
* @param {number} index
|
|
65761
|
+
*/
|
|
65364
65762
|
getPageId(index) {
|
|
65365
65763
|
const firstKey = this.head;
|
|
65366
65764
|
if (firstKey) {
|
|
@@ -65382,20 +65780,20 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65382
65780
|
modifyDetect() {
|
|
65383
65781
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
65384
65782
|
if (cameraMode !== "main") {
|
|
65385
|
-
console.warn(
|
|
65783
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
65386
65784
|
return false;
|
|
65387
65785
|
}
|
|
65388
65786
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
65389
|
-
console.warn(
|
|
65787
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
65390
65788
|
return false;
|
|
65391
65789
|
}
|
|
65392
65790
|
return true;
|
|
65393
65791
|
}
|
|
65394
65792
|
/**
|
|
65395
|
-
|
|
65396
|
-
|
|
65397
|
-
|
|
65398
|
-
|
|
65793
|
+
* 在尾部插入新页面
|
|
65794
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
65795
|
+
* @return 总页数
|
|
65796
|
+
*/
|
|
65399
65797
|
pushPage() {
|
|
65400
65798
|
let goto = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
65401
65799
|
this.indexedPageMap.doc.transact(() => {
|
|
@@ -65424,11 +65822,11 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65424
65822
|
return this.pageCount;
|
|
65425
65823
|
}
|
|
65426
65824
|
/**
|
|
65427
|
-
|
|
65428
|
-
|
|
65429
|
-
|
|
65430
|
-
|
|
65431
|
-
|
|
65825
|
+
* 在 after 之后插入新页面
|
|
65826
|
+
* @param {number} after 在此页之后插入
|
|
65827
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
65828
|
+
* @return 总页数
|
|
65829
|
+
*/
|
|
65432
65830
|
insertPage(after) {
|
|
65433
65831
|
let goto = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
65434
65832
|
const afterPageId = this.getPageId(after);
|
|
@@ -65437,7 +65835,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65437
65835
|
}
|
|
65438
65836
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
65439
65837
|
if (cameraMode !== "main") {
|
|
65440
|
-
console.warn(
|
|
65838
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
65441
65839
|
return this.pageCount;
|
|
65442
65840
|
}
|
|
65443
65841
|
const prev = this.list[afterPageId];
|
|
@@ -65480,8 +65878,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65480
65878
|
return this.pageCount;
|
|
65481
65879
|
}
|
|
65482
65880
|
/**
|
|
65483
|
-
|
|
65484
|
-
|
|
65881
|
+
* 跳转至上一页, 并返回跳转后的页面索引.
|
|
65882
|
+
*/
|
|
65485
65883
|
prevPage() {
|
|
65486
65884
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
65487
65885
|
const data = this.list[currentPageId];
|
|
@@ -65493,8 +65891,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65493
65891
|
return nextIndex;
|
|
65494
65892
|
}
|
|
65495
65893
|
/**
|
|
65496
|
-
|
|
65497
|
-
|
|
65894
|
+
* 跳转至下一页, 并返回跳转后的页面索引.
|
|
65895
|
+
*/
|
|
65498
65896
|
nextPage() {
|
|
65499
65897
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
65500
65898
|
const data = this.list[currentPageId];
|
|
@@ -65506,16 +65904,14 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65506
65904
|
return nextIndex;
|
|
65507
65905
|
}
|
|
65508
65906
|
/**
|
|
65509
|
-
|
|
65510
|
-
|
|
65511
|
-
|
|
65907
|
+
* 删除指定页面
|
|
65908
|
+
* @param {number} index
|
|
65909
|
+
*/
|
|
65512
65910
|
removePage(index) {
|
|
65513
65911
|
if (this.pageCount <= 1) {
|
|
65514
65912
|
return this.pageCount;
|
|
65515
65913
|
}
|
|
65516
|
-
|
|
65517
|
-
if (cameraMode !== "main") {
|
|
65518
|
-
console.warn(`cannot modify pages in non-main view mode.`);
|
|
65914
|
+
if (!this.modifyDetect()) {
|
|
65519
65915
|
return this.pageCount;
|
|
65520
65916
|
}
|
|
65521
65917
|
const targetId = this.getPageId(index);
|
|
@@ -65555,6 +65951,11 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
65555
65951
|
this.pageModel.gotoPage(targetId);
|
|
65556
65952
|
}
|
|
65557
65953
|
}
|
|
65954
|
+
dispose() {
|
|
65955
|
+
(0, import_forge_room12.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
65956
|
+
this.pageModel.off("switchPage");
|
|
65957
|
+
this.pageModel.off("pagesChange");
|
|
65958
|
+
}
|
|
65558
65959
|
};
|
|
65559
65960
|
function _defineProperty37(e, r, t) {
|
|
65560
65961
|
return (r = _toPropertyKey37(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -65573,7 +65974,7 @@ function _toPrimitive37(t, r) {
|
|
|
65573
65974
|
}
|
|
65574
65975
|
return ("string" === r ? String : Number)(t);
|
|
65575
65976
|
}
|
|
65576
|
-
var ShadowEmitter = class extends
|
|
65977
|
+
var ShadowEmitter = class extends import_eventemitter312.default {
|
|
65577
65978
|
constructor(userMap) {
|
|
65578
65979
|
super();
|
|
65579
65980
|
_defineProperty37(this, "userMap", void 0);
|
|
@@ -65609,9 +66010,13 @@ var StraightLineTool = class extends WhiteboardTool {
|
|
|
65609
66010
|
_defineProperty38(this, "elementModel", null);
|
|
65610
66011
|
_defineProperty38(this, "from", null);
|
|
65611
66012
|
_defineProperty38(this, "to", null);
|
|
66013
|
+
_defineProperty38(this, "showLiveCursor", true);
|
|
65612
66014
|
this.tool.minDistance = 1;
|
|
65613
66015
|
}
|
|
65614
66016
|
onMouseDown(event) {
|
|
66017
|
+
if (this.elementModel) {
|
|
66018
|
+
this.elementModel.dispose();
|
|
66019
|
+
}
|
|
65615
66020
|
this.elementModel = this.modelGetter().createStraightLine(true);
|
|
65616
66021
|
this.from = event.point.clone();
|
|
65617
66022
|
this.to = event.point.clone();
|
|
@@ -65653,6 +66058,7 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
65653
66058
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
65654
66059
|
_defineProperty39(this, "camera", void 0);
|
|
65655
66060
|
_defineProperty39(this, "downPoint", null);
|
|
66061
|
+
_defineProperty39(this, "showLiveCursor", false);
|
|
65656
66062
|
this.camera = camera;
|
|
65657
66063
|
}
|
|
65658
66064
|
onMouseDown(event) {
|
|
@@ -65671,25 +66077,207 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
65671
66077
|
this.shadowEmitter.emit("grabUp");
|
|
65672
66078
|
}
|
|
65673
66079
|
};
|
|
66080
|
+
function _defineProperty40(e, r, t) {
|
|
66081
|
+
return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
66082
|
+
}
|
|
66083
|
+
function _toPropertyKey40(t) {
|
|
66084
|
+
var i = _toPrimitive40(t, "string");
|
|
66085
|
+
return "symbol" == typeof i ? i : i + "";
|
|
66086
|
+
}
|
|
66087
|
+
function _toPrimitive40(t, r) {
|
|
66088
|
+
if ("object" != typeof t || !t) return t;
|
|
66089
|
+
var e = t[Symbol.toPrimitive];
|
|
66090
|
+
if (void 0 !== e) {
|
|
66091
|
+
var i = e.call(t, r || "default");
|
|
66092
|
+
if ("object" != typeof i) return i;
|
|
66093
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
66094
|
+
}
|
|
66095
|
+
return ("string" === r ? String : Number)(t);
|
|
66096
|
+
}
|
|
65674
66097
|
var PointerTool = class extends WhiteboardTool {
|
|
65675
66098
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
65676
66099
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
66100
|
+
_defineProperty40(this, "showLiveCursor", false);
|
|
65677
66101
|
}
|
|
65678
|
-
onMouseDown(
|
|
66102
|
+
onMouseDown(_event) {
|
|
65679
66103
|
}
|
|
65680
|
-
onMouseDrag(
|
|
66104
|
+
onMouseDrag(_event) {
|
|
65681
66105
|
}
|
|
65682
66106
|
onMouseUp() {
|
|
65683
66107
|
}
|
|
65684
66108
|
};
|
|
65685
|
-
function
|
|
65686
|
-
return (r =
|
|
66109
|
+
function _defineProperty41(e, r, t) {
|
|
66110
|
+
return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
65687
66111
|
}
|
|
65688
|
-
function
|
|
65689
|
-
var i =
|
|
66112
|
+
function _toPropertyKey41(t) {
|
|
66113
|
+
var i = _toPrimitive41(t, "string");
|
|
65690
66114
|
return "symbol" == typeof i ? i : i + "";
|
|
65691
66115
|
}
|
|
65692
|
-
function
|
|
66116
|
+
function _toPrimitive41(t, r) {
|
|
66117
|
+
if ("object" != typeof t || !t) return t;
|
|
66118
|
+
var e = t[Symbol.toPrimitive];
|
|
66119
|
+
if (void 0 !== e) {
|
|
66120
|
+
var i = e.call(t, r || "default");
|
|
66121
|
+
if ("object" != typeof i) return i;
|
|
66122
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
66123
|
+
}
|
|
66124
|
+
return ("string" === r ? String : Number)(t);
|
|
66125
|
+
}
|
|
66126
|
+
var SequenceExecutor = class {
|
|
66127
|
+
constructor() {
|
|
66128
|
+
_defineProperty41(this, "tasks", []);
|
|
66129
|
+
_defineProperty41(this, "isRunning", false);
|
|
66130
|
+
}
|
|
66131
|
+
addTask(task) {
|
|
66132
|
+
this.tasks.push(task);
|
|
66133
|
+
if (!this.isRunning) {
|
|
66134
|
+
this.execute();
|
|
66135
|
+
}
|
|
66136
|
+
}
|
|
66137
|
+
async execute() {
|
|
66138
|
+
if (this.isRunning) {
|
|
66139
|
+
return;
|
|
66140
|
+
}
|
|
66141
|
+
this.isRunning = true;
|
|
66142
|
+
while (this.tasks.length > 0) {
|
|
66143
|
+
const task = this.tasks.shift();
|
|
66144
|
+
if (task) {
|
|
66145
|
+
try {
|
|
66146
|
+
await task();
|
|
66147
|
+
} catch (e) {
|
|
66148
|
+
}
|
|
66149
|
+
}
|
|
66150
|
+
}
|
|
66151
|
+
this.isRunning = false;
|
|
66152
|
+
}
|
|
66153
|
+
};
|
|
66154
|
+
function _defineProperty42(e, r, t) {
|
|
66155
|
+
return (r = _toPropertyKey42(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
66156
|
+
}
|
|
66157
|
+
function _toPropertyKey42(t) {
|
|
66158
|
+
var i = _toPrimitive42(t, "string");
|
|
66159
|
+
return "symbol" == typeof i ? i : i + "";
|
|
66160
|
+
}
|
|
66161
|
+
function _toPrimitive42(t, r) {
|
|
66162
|
+
if ("object" != typeof t || !t) return t;
|
|
66163
|
+
var e = t[Symbol.toPrimitive];
|
|
66164
|
+
if (void 0 !== e) {
|
|
66165
|
+
var i = e.call(t, r || "default");
|
|
66166
|
+
if ("object" != typeof i) return i;
|
|
66167
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
66168
|
+
}
|
|
66169
|
+
return ("string" === r ? String : Number)(t);
|
|
66170
|
+
}
|
|
66171
|
+
var LiveCursor = class {
|
|
66172
|
+
constructor(canvasElement, paperScope, userManager, requestUserMap) {
|
|
66173
|
+
_defineProperty42(this, "container", document.createElement("div"));
|
|
66174
|
+
_defineProperty42(this, "showLiveCursor", true);
|
|
66175
|
+
_defineProperty42(this, "userManager", void 0);
|
|
66176
|
+
_defineProperty42(this, "requestUserMap", void 0);
|
|
66177
|
+
_defineProperty42(this, "cursors", /* @__PURE__ */ new Map());
|
|
66178
|
+
_defineProperty42(this, "paperScope", void 0);
|
|
66179
|
+
_defineProperty42(this, "resizeobserver", void 0);
|
|
66180
|
+
_defineProperty42(this, "timeoutIdMap", /* @__PURE__ */ new Map());
|
|
66181
|
+
_defineProperty42(this, "lastVisibleChangeTimes", /* @__PURE__ */ new Map());
|
|
66182
|
+
this.userManager = userManager;
|
|
66183
|
+
this.paperScope = paperScope;
|
|
66184
|
+
this.requestUserMap = requestUserMap;
|
|
66185
|
+
this.container.setAttribute("data-forge-cursors", "");
|
|
66186
|
+
this.container.style.cssText = "overflow:hidden;pointer-events:none;z-index:999;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
66187
|
+
this.container.style.pointerEvents = "none";
|
|
66188
|
+
this.resizeobserver = new ResizeObserver(() => {
|
|
66189
|
+
const bounds = canvasElement.getBoundingClientRect();
|
|
66190
|
+
this.container.style.width = bounds.width + "px";
|
|
66191
|
+
this.container.style.height = bounds.height + "px";
|
|
66192
|
+
});
|
|
66193
|
+
this.resizeobserver.observe(canvasElement);
|
|
66194
|
+
}
|
|
66195
|
+
createCursor(userId) {
|
|
66196
|
+
const cursor = document.createElement("fcursor");
|
|
66197
|
+
cursor.setAttribute("data-forge-cursor", userId);
|
|
66198
|
+
cursor.style.backgroundColor = this.requestUserMap(userId).get(WhiteboardKeys.themeColor);
|
|
66199
|
+
cursor.style.color = "#fff";
|
|
66200
|
+
cursor.style.position = "absolute";
|
|
66201
|
+
cursor.style.whiteSpace = "nowrap";
|
|
66202
|
+
cursor.style.display = "block";
|
|
66203
|
+
cursor.style.fontSize = "12px";
|
|
66204
|
+
cursor.style.padding = "2px 4px";
|
|
66205
|
+
cursor.style.borderRadius = "4px";
|
|
66206
|
+
cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
66207
|
+
return cursor;
|
|
66208
|
+
}
|
|
66209
|
+
isOnSamePage(userId) {
|
|
66210
|
+
const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
|
|
66211
|
+
const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
|
|
66212
|
+
if (otherPage !== selfPage) {
|
|
66213
|
+
return false;
|
|
66214
|
+
}
|
|
66215
|
+
return true;
|
|
66216
|
+
}
|
|
66217
|
+
detectEnable(userId) {
|
|
66218
|
+
if (!this.showLiveCursor) {
|
|
66219
|
+
const cursor = this.cursors.get(userId);
|
|
66220
|
+
if (cursor) {
|
|
66221
|
+
cursor.style.display = "none";
|
|
66222
|
+
}
|
|
66223
|
+
}
|
|
66224
|
+
return this.showLiveCursor;
|
|
66225
|
+
}
|
|
66226
|
+
updateCursorPosition(point, userId) {
|
|
66227
|
+
if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
|
|
66228
|
+
return;
|
|
66229
|
+
}
|
|
66230
|
+
if (!this.detectEnable(userId)) {
|
|
66231
|
+
return;
|
|
66232
|
+
}
|
|
66233
|
+
const lastVisibleChangeTime = this.lastVisibleChangeTimes.get(userId);
|
|
66234
|
+
if (lastVisibleChangeTime && Date.now() - lastVisibleChangeTime < 100) {
|
|
66235
|
+
return;
|
|
66236
|
+
}
|
|
66237
|
+
if (!this.cursors.has(userId)) {
|
|
66238
|
+
const cursor2 = this.createCursor(userId);
|
|
66239
|
+
this.cursors.set(userId, cursor2);
|
|
66240
|
+
this.container.appendChild(cursor2);
|
|
66241
|
+
}
|
|
66242
|
+
const cursor = this.cursors.get(userId);
|
|
66243
|
+
if (cursor) {
|
|
66244
|
+
const viewPoint = this.paperScope.project.view.projectToView(point);
|
|
66245
|
+
cursor.style.left = viewPoint.x + "px";
|
|
66246
|
+
cursor.style.top = viewPoint.y + "px";
|
|
66247
|
+
cursor.style.display = "block";
|
|
66248
|
+
}
|
|
66249
|
+
if (this.timeoutIdMap.has(userId)) {
|
|
66250
|
+
clearTimeout(this.timeoutIdMap.get(userId));
|
|
66251
|
+
}
|
|
66252
|
+
this.timeoutIdMap.set(userId, setTimeout(() => {
|
|
66253
|
+
const cursor2 = this.cursors.get(userId);
|
|
66254
|
+
if (cursor2) {
|
|
66255
|
+
cursor2.style.display = "none";
|
|
66256
|
+
}
|
|
66257
|
+
}, 5e3));
|
|
66258
|
+
}
|
|
66259
|
+
updateCursorVisible(visible, userId) {
|
|
66260
|
+
if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
|
|
66261
|
+
return;
|
|
66262
|
+
}
|
|
66263
|
+
if (!this.detectEnable(userId)) {
|
|
66264
|
+
return;
|
|
66265
|
+
}
|
|
66266
|
+
this.lastVisibleChangeTimes.set(userId, Date.now());
|
|
66267
|
+
const cursor = this.cursors.get(userId);
|
|
66268
|
+
if (cursor) {
|
|
66269
|
+
cursor.style.display = visible ? "block" : "none";
|
|
66270
|
+
}
|
|
66271
|
+
}
|
|
66272
|
+
};
|
|
66273
|
+
function _defineProperty43(e, r, t) {
|
|
66274
|
+
return (r = _toPropertyKey43(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
66275
|
+
}
|
|
66276
|
+
function _toPropertyKey43(t) {
|
|
66277
|
+
var i = _toPrimitive43(t, "string");
|
|
66278
|
+
return "symbol" == typeof i ? i : i + "";
|
|
66279
|
+
}
|
|
66280
|
+
function _toPrimitive43(t, r) {
|
|
65693
66281
|
if ("object" != typeof t || !t) return t;
|
|
65694
66282
|
var e = t[Symbol.toPrimitive];
|
|
65695
66283
|
if (void 0 !== e) {
|
|
@@ -65700,6 +66288,21 @@ function _toPrimitive40(t, r) {
|
|
|
65700
66288
|
return ("string" === r ? String : Number)(t);
|
|
65701
66289
|
}
|
|
65702
66290
|
var WHITEBOARD_APP_NAME = "whiteboard";
|
|
66291
|
+
var AsyncMap = class {
|
|
66292
|
+
constructor() {
|
|
66293
|
+
_defineProperty43(this, "map", void 0);
|
|
66294
|
+
this.map = /* @__PURE__ */ new Map();
|
|
66295
|
+
}
|
|
66296
|
+
get(key) {
|
|
66297
|
+
return Promise.resolve(this.map.get(key));
|
|
66298
|
+
}
|
|
66299
|
+
set(key, value) {
|
|
66300
|
+
this.map.set(key, value);
|
|
66301
|
+
}
|
|
66302
|
+
};
|
|
66303
|
+
if (!window.__forge_gl_wb_status__) {
|
|
66304
|
+
window.__forge_gl_wb_status__ = new AsyncMap();
|
|
66305
|
+
}
|
|
65703
66306
|
var WhiteboardApplication = class extends import_forge_room.AbstractApplication {
|
|
65704
66307
|
get undoManager() {
|
|
65705
66308
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
@@ -65708,47 +66311,116 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65708
66311
|
}
|
|
65709
66312
|
return null;
|
|
65710
66313
|
}
|
|
66314
|
+
get viewportWidth() {
|
|
66315
|
+
const vw = this.getMap("attrs").get("viewportWidth");
|
|
66316
|
+
if (vw) {
|
|
66317
|
+
return vw;
|
|
66318
|
+
}
|
|
66319
|
+
return this.option.width;
|
|
66320
|
+
}
|
|
66321
|
+
get viewportHeight() {
|
|
66322
|
+
const vh = this.getMap("attrs").get("viewportHeight");
|
|
66323
|
+
if (vh) {
|
|
66324
|
+
return vh;
|
|
66325
|
+
}
|
|
66326
|
+
return this.option.height;
|
|
66327
|
+
}
|
|
65711
66328
|
constructor() {
|
|
65712
66329
|
var _this;
|
|
65713
66330
|
super();
|
|
65714
66331
|
_this = this;
|
|
65715
|
-
|
|
65716
|
-
|
|
65717
|
-
|
|
65718
|
-
|
|
65719
|
-
|
|
65720
|
-
|
|
65721
|
-
|
|
65722
|
-
|
|
65723
|
-
|
|
65724
|
-
|
|
65725
|
-
|
|
65726
|
-
|
|
65727
|
-
|
|
65728
|
-
|
|
65729
|
-
|
|
65730
|
-
|
|
65731
|
-
|
|
65732
|
-
|
|
65733
|
-
|
|
65734
|
-
|
|
65735
|
-
|
|
65736
|
-
|
|
65737
|
-
|
|
65738
|
-
|
|
65739
|
-
|
|
65740
|
-
|
|
65741
|
-
|
|
65742
|
-
|
|
65743
|
-
|
|
66332
|
+
_defineProperty43(this, "name", WHITEBOARD_APP_NAME);
|
|
66333
|
+
_defineProperty43(this, "emitter", void 0);
|
|
66334
|
+
_defineProperty43(this, "toolbarModel", void 0);
|
|
66335
|
+
_defineProperty43(this, "selectElementsModel", void 0);
|
|
66336
|
+
_defineProperty43(this, "trashedElementsModel", void 0);
|
|
66337
|
+
_defineProperty43(this, "pageModel", void 0);
|
|
66338
|
+
_defineProperty43(this, "layers", /* @__PURE__ */ new Map());
|
|
66339
|
+
_defineProperty43(this, "undoManagers", /* @__PURE__ */ new Map());
|
|
66340
|
+
_defineProperty43(this, "imageSets", document.createElement("div"));
|
|
66341
|
+
_defineProperty43(this, "rootElement", document.createElement("div"));
|
|
66342
|
+
_defineProperty43(this, "paperScope", new import_paper.default.PaperScope());
|
|
66343
|
+
_defineProperty43(this, "canvasElement", document.createElement("canvas"));
|
|
66344
|
+
_defineProperty43(this, "shadowScope", new import_paper.default.PaperScope());
|
|
66345
|
+
_defineProperty43(this, "snapshotCanvasElement", document.createElement("canvas"));
|
|
66346
|
+
_defineProperty43(this, "snapshotScope", new import_paper.default.PaperScope());
|
|
66347
|
+
_defineProperty43(this, "shadowCanvasElement", document.createElement("canvas"));
|
|
66348
|
+
_defineProperty43(this, "shadowEmitter", void 0);
|
|
66349
|
+
_defineProperty43(this, "tools", void 0);
|
|
66350
|
+
_defineProperty43(this, "editors", /* @__PURE__ */ new Map());
|
|
66351
|
+
_defineProperty43(this, "camera", void 0);
|
|
66352
|
+
_defineProperty43(this, "resizeObserver", void 0);
|
|
66353
|
+
_defineProperty43(this, "option", void 0);
|
|
66354
|
+
_defineProperty43(this, "permissions", void 0);
|
|
66355
|
+
_defineProperty43(this, "inputType", "any");
|
|
66356
|
+
_defineProperty43(this, "isPenEvent", false);
|
|
66357
|
+
_defineProperty43(this, "hasPenInput", null);
|
|
66358
|
+
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
66359
|
+
_defineProperty43(this, "internalResizeObserver", true);
|
|
66360
|
+
_defineProperty43(this, "sequenceExecutor", new SequenceExecutor());
|
|
66361
|
+
_defineProperty43(this, "linkWhiteboardId", null);
|
|
66362
|
+
_defineProperty43(this, "liveCursor", void 0);
|
|
66363
|
+
_defineProperty43(this, "delayTranslateOut", -1);
|
|
66364
|
+
_defineProperty43(this, "addWhiteboardStatus", (evt) => {
|
|
66365
|
+
if (evt.detail.whiteboardAppId && evt.detail.status) {
|
|
66366
|
+
if (this.linkWhiteboardId === evt.detail.whiteboardAppId) {
|
|
66367
|
+
this.toolbarModel.currentTool = evt.detail.status.currentTool;
|
|
66368
|
+
this.toolbarModel.strokeColor = evt.detail.status.strokeColor;
|
|
66369
|
+
this.toolbarModel.fillColor = evt.detail.status.fillColor;
|
|
66370
|
+
this.toolbarModel.fontSize = evt.detail.status.fontSize;
|
|
66371
|
+
this.toolbarModel.fontFamily = evt.detail.status.fontFamily;
|
|
66372
|
+
this.toolbarModel.strokeWidth = evt.detail.status.strokeWidth;
|
|
66373
|
+
this.toolbarModel.dashArray = evt.detail.status.dashArray;
|
|
66374
|
+
this.permissions.removePermission(WhiteboardPermissionFlag.all);
|
|
66375
|
+
this.permissions.addPermission(evt.detail.status.permission);
|
|
66376
|
+
}
|
|
66377
|
+
}
|
|
66378
|
+
});
|
|
66379
|
+
_defineProperty43(this, "enableToolEvent", () => {
|
|
65744
66380
|
return !(this.inputType === "pen" && !this.isPenEvent);
|
|
65745
66381
|
});
|
|
65746
|
-
|
|
65747
|
-
|
|
65748
|
-
|
|
66382
|
+
_defineProperty43(this, "handleViewportUpdate", (evt) => {
|
|
66383
|
+
if (evt.keysChanged.has("viewportWidth") || evt.keysChanged.has("viewportHeight")) {
|
|
66384
|
+
const rect = this.rootElement.getBoundingClientRect();
|
|
66385
|
+
this.adjustByOutFrame(rect.width, rect.height);
|
|
65749
66386
|
}
|
|
65750
|
-
|
|
65751
|
-
|
|
66387
|
+
});
|
|
66388
|
+
_defineProperty43(this, "handleElementTranslateOut", (ids, container) => {
|
|
66389
|
+
const shadowLayer = this.shadowScope.project.activeLayer;
|
|
66390
|
+
let parent = null;
|
|
66391
|
+
if (container === "layer") {
|
|
66392
|
+
parent = shadowLayer;
|
|
66393
|
+
} else {
|
|
66394
|
+
parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
|
|
66395
|
+
}
|
|
66396
|
+
if (parent) {
|
|
66397
|
+
ids.forEach((id) => {
|
|
66398
|
+
const target = parent.children.find((child) => child.data.uuid === id);
|
|
66399
|
+
if (target) {
|
|
66400
|
+
target.remove();
|
|
66401
|
+
this.insertElementToParent(target, this.paperScope.project.activeLayer);
|
|
66402
|
+
} else {
|
|
66403
|
+
const pageId = this.pageModel.getCurrentPage(this.userId);
|
|
66404
|
+
if (pageId) {
|
|
66405
|
+
const page = this.layers.get(pageId);
|
|
66406
|
+
if (page) {
|
|
66407
|
+
const model = page.elementModels.get(id);
|
|
66408
|
+
if (model && model.item) {
|
|
66409
|
+
this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
|
|
66410
|
+
}
|
|
66411
|
+
}
|
|
66412
|
+
}
|
|
66413
|
+
}
|
|
66414
|
+
});
|
|
66415
|
+
}
|
|
66416
|
+
});
|
|
66417
|
+
_defineProperty43(this, "handlePageSwitch", (pageId) => {
|
|
66418
|
+
this.sequenceExecutor.addTask(async () => {
|
|
66419
|
+
for (const editor of this.editors.values()) {
|
|
66420
|
+
editor.hidden();
|
|
66421
|
+
}
|
|
66422
|
+
this.selectElementsModel.clearSelectElementForSelf();
|
|
66423
|
+
await waitUntil(() => this.layers.has(pageId), 1e3);
|
|
65752
66424
|
if (this.layers.has(pageId)) {
|
|
65753
66425
|
for (const entry of this.layers.entries()) {
|
|
65754
66426
|
entry[1].off("elementInsert", this.handleElementInsert);
|
|
@@ -65760,6 +66432,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65760
66432
|
renderableModel.on("elementRemove", this.handleElementRemove);
|
|
65761
66433
|
renderableModel.on("elementClear", this.handleElementClear);
|
|
65762
66434
|
renderableModel.flushRenderables();
|
|
66435
|
+
this.paperScope.project.activeLayer.data.pageId = pageId;
|
|
65763
66436
|
const others = this.userManager.userIdList().filter((v) => v !== this.userId);
|
|
65764
66437
|
for (const other of others) {
|
|
65765
66438
|
if (this.userMap(other).get(WhiteboardKeys.currentPage) === pageId) {
|
|
@@ -65769,9 +66442,11 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65769
66442
|
}
|
|
65770
66443
|
}
|
|
65771
66444
|
}
|
|
66445
|
+
} else {
|
|
66446
|
+
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
66447
|
+
(0, import_forge_room.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warning");
|
|
65772
66448
|
}
|
|
65773
|
-
|
|
65774
|
-
waitUntil(() => this.undoManagers.has(pageId), 3e3).then(() => {
|
|
66449
|
+
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
65775
66450
|
if (this.undoManagers.has(pageId)) {
|
|
65776
66451
|
for (const entry of this.undoManagers.entries()) {
|
|
65777
66452
|
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
@@ -65779,29 +66454,32 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65779
66454
|
}
|
|
65780
66455
|
this.undoManagers.get(pageId).on("stack-item-added", this.handleStackItemAdded);
|
|
65781
66456
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
66457
|
+
} else {
|
|
66458
|
+
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
66459
|
+
(0, import_forge_room.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warning");
|
|
65782
66460
|
}
|
|
66461
|
+
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
66462
|
+
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
65783
66463
|
});
|
|
65784
|
-
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
65785
|
-
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
65786
66464
|
});
|
|
65787
|
-
|
|
66465
|
+
_defineProperty43(this, "hasPermission", (flag) => {
|
|
65788
66466
|
return this.permissions.hasPermission(flag, this.userId);
|
|
65789
66467
|
});
|
|
65790
|
-
|
|
66468
|
+
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
65791
66469
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
65792
66470
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
65793
66471
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
65794
66472
|
});
|
|
65795
|
-
|
|
66473
|
+
_defineProperty43(this, "handleStackItemPopped", () => {
|
|
65796
66474
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
65797
66475
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
65798
66476
|
});
|
|
65799
|
-
|
|
66477
|
+
_defineProperty43(this, "handleLayersChange", (ids) => {
|
|
65800
66478
|
for (let i = 0, len = ids.length; i < len; i++) {
|
|
65801
66479
|
const id = ids[i];
|
|
65802
66480
|
if (!this.layers.has(id)) {
|
|
65803
66481
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
65804
|
-
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission);
|
|
66482
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
|
|
65805
66483
|
this.layers.set(id, renderableModel);
|
|
65806
66484
|
}
|
|
65807
66485
|
if (!this.undoManagers.has(id)) {
|
|
@@ -65812,12 +66490,12 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65812
66490
|
this.undoManagers.set(id, undoManager);
|
|
65813
66491
|
}
|
|
65814
66492
|
}
|
|
65815
|
-
for (
|
|
66493
|
+
for (const entry of this.layers.entries()) {
|
|
65816
66494
|
if (ids.indexOf(entry[0]) < 0) {
|
|
65817
66495
|
const renderableModel = this.layers.get(entry[0]);
|
|
65818
66496
|
this.layers.delete(entry[0]);
|
|
65819
66497
|
if (renderableModel) {
|
|
65820
|
-
renderableModel.dispose();
|
|
66498
|
+
renderableModel.dispose(true);
|
|
65821
66499
|
}
|
|
65822
66500
|
const cameraMode = this.userMap(this.userId).get(WhiteboardKeys.cameraMode);
|
|
65823
66501
|
const currentPage = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
@@ -65828,17 +66506,18 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65828
66506
|
}
|
|
65829
66507
|
}
|
|
65830
66508
|
});
|
|
65831
|
-
|
|
65832
|
-
|
|
66509
|
+
_defineProperty43(this, "getCurrentRenderableModel", () => {
|
|
66510
|
+
const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
65833
66511
|
if (!this.layers.has(layerId)) {
|
|
65834
66512
|
this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
|
|
65835
66513
|
}
|
|
65836
66514
|
return this.layers.get(layerId);
|
|
65837
66515
|
});
|
|
65838
|
-
|
|
66516
|
+
_defineProperty43(this, "handleElementClear", () => {
|
|
66517
|
+
this.shadowScope.project.activeLayer.removeChildren();
|
|
65839
66518
|
this.paperScope.project.activeLayer.removeChildren();
|
|
65840
66519
|
});
|
|
65841
|
-
|
|
66520
|
+
_defineProperty43(this, "handleElementInsert", (elements) => {
|
|
65842
66521
|
for (const element of elements) {
|
|
65843
66522
|
element.createPaperElement();
|
|
65844
66523
|
const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
|
|
@@ -65850,7 +66529,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65850
66529
|
this.insertElementToParent(element.item, scope.project.activeLayer);
|
|
65851
66530
|
}
|
|
65852
66531
|
});
|
|
65853
|
-
|
|
66532
|
+
_defineProperty43(this, "handleElementRemove", (elementId, layerId) => {
|
|
65854
66533
|
const layerModel = this.layers.get(layerId);
|
|
65855
66534
|
if (!layerModel) {
|
|
65856
66535
|
return;
|
|
@@ -65861,11 +66540,11 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65861
66540
|
}
|
|
65862
66541
|
layerModel.elementModels.delete(elementId);
|
|
65863
66542
|
});
|
|
65864
|
-
|
|
66543
|
+
_defineProperty43(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
|
|
65865
66544
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
65866
66545
|
this.layers.get(selfLayerId)?.removeElementItem(elementId);
|
|
65867
66546
|
});
|
|
65868
|
-
|
|
66547
|
+
_defineProperty43(this, "handleElementsTrash", (userId, elements) => {
|
|
65869
66548
|
const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
|
|
65870
66549
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
65871
66550
|
if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
|
|
@@ -65878,7 +66557,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65878
66557
|
}
|
|
65879
66558
|
});
|
|
65880
66559
|
});
|
|
65881
|
-
|
|
66560
|
+
_defineProperty43(this, "handleElementsSelect", (userId, elements) => {
|
|
65882
66561
|
if (!this.editors.has(userId)) {
|
|
65883
66562
|
const ctrl = this.userManager.getUser(userId);
|
|
65884
66563
|
const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
|
|
@@ -65910,7 +66589,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65910
66589
|
}).filter((v) => !!v);
|
|
65911
66590
|
editor.setTargets(elementModels);
|
|
65912
66591
|
if (elementModels.length === 1) {
|
|
65913
|
-
|
|
66592
|
+
const model = elementModels[0];
|
|
65914
66593
|
if (model.item) {
|
|
65915
66594
|
const topLeft = this.paperScope.project.view.projectToView(model.item.bounds.topLeft);
|
|
65916
66595
|
const bottomRight = this.paperScope.project.view.projectToView(model.item.bounds.bottomRight);
|
|
@@ -65921,34 +66600,44 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65921
66600
|
this.emitter.emit("elementDeselected", userId);
|
|
65922
66601
|
}
|
|
65923
66602
|
});
|
|
65924
|
-
|
|
65925
|
-
|
|
65926
|
-
|
|
65927
|
-
|
|
65928
|
-
|
|
65929
|
-
|
|
65930
|
-
|
|
65931
|
-
|
|
65932
|
-
|
|
65933
|
-
|
|
65934
|
-
|
|
65935
|
-
|
|
65936
|
-
|
|
65937
|
-
|
|
65938
|
-
|
|
66603
|
+
_defineProperty43(this, "handleSyncedWhiteboardStatusChange", (evt) => {
|
|
66604
|
+
if ([TOOLBAR_KEYS.tool, TOOLBAR_KEYS.strokeColor, TOOLBAR_KEYS.fillColor, TOOLBAR_KEYS.fontSize, TOOLBAR_KEYS.fontFamily, TOOLBAR_KEYS.strokeWidth, TOOLBAR_KEYS.dashArray, "permission"].some((key) => evt.keysChanged.has(key))) {
|
|
66605
|
+
const nextState = {
|
|
66606
|
+
currentTool: evt.target.get(TOOLBAR_KEYS.tool),
|
|
66607
|
+
strokeColor: evt.target.get(TOOLBAR_KEYS.strokeColor),
|
|
66608
|
+
fillColor: evt.target.get(TOOLBAR_KEYS.fillColor),
|
|
66609
|
+
fontSize: evt.target.get(TOOLBAR_KEYS.fontSize),
|
|
66610
|
+
fontFamily: evt.target.get(TOOLBAR_KEYS.fontFamily),
|
|
66611
|
+
strokeWidth: evt.target.get(TOOLBAR_KEYS.strokeWidth),
|
|
66612
|
+
dashArray: evt.target.get(TOOLBAR_KEYS.dashArray),
|
|
66613
|
+
permission: evt.target.get("permission")
|
|
66614
|
+
};
|
|
66615
|
+
window.__forge_gl_wb_status__.set(this.appId, nextState);
|
|
66616
|
+
window.dispatchEvent(new CustomEvent("forge-whiteboard-synced-status", {
|
|
66617
|
+
detail: {
|
|
66618
|
+
whiteboardAppId: this.appId,
|
|
66619
|
+
status: nextState,
|
|
66620
|
+
userId: this.userId
|
|
66621
|
+
}
|
|
66622
|
+
}));
|
|
65939
66623
|
}
|
|
65940
66624
|
});
|
|
65941
|
-
|
|
65942
|
-
if (this.
|
|
66625
|
+
_defineProperty43(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
|
|
66626
|
+
if (!this.paperScope.project.view || !this.shadowScope.project.view) {
|
|
66627
|
+
return;
|
|
66628
|
+
}
|
|
66629
|
+
const viewportWidth = this.viewportWidth;
|
|
66630
|
+
const viewportHeight = this.viewportHeight;
|
|
66631
|
+
if (viewportWidth > 0 && viewportHeight > 0) {
|
|
65943
66632
|
const minWidth = Math.max(frameWidth, 10);
|
|
65944
66633
|
const minHeight = Math.max(frameHeight, 10);
|
|
65945
66634
|
let width = minWidth;
|
|
65946
|
-
let height = width *
|
|
66635
|
+
let height = width * viewportHeight / viewportWidth;
|
|
65947
66636
|
if (height > minHeight) {
|
|
65948
66637
|
height = minHeight;
|
|
65949
|
-
width = height *
|
|
66638
|
+
width = height * viewportWidth / viewportHeight;
|
|
65950
66639
|
}
|
|
65951
|
-
this.camera.updateInherentScale(width /
|
|
66640
|
+
this.camera.updateInherentScale(width / viewportWidth);
|
|
65952
66641
|
this.paperScope.project.view.viewSize = new this.paperScope.Size(width, height);
|
|
65953
66642
|
this.shadowScope.project.view.viewSize = new this.paperScope.Size(width, height);
|
|
65954
66643
|
this.camera.triggerZoom();
|
|
@@ -65956,7 +66645,11 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
65956
66645
|
});
|
|
65957
66646
|
requestAnimationFrameHook(this.paperScope);
|
|
65958
66647
|
requestAnimationFrameHook(this.shadowScope);
|
|
66648
|
+
const that = this;
|
|
65959
66649
|
this.rootElement.setAttribute("data-forge-app", "whiteboard");
|
|
66650
|
+
this.imageSets.style.display = "none";
|
|
66651
|
+
this.imageSets.setAttribute("data-image-sets", "");
|
|
66652
|
+
this.rootElement.appendChild(this.imageSets);
|
|
65960
66653
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
65961
66654
|
this.isPenEvent = evt.pointerType === "pen";
|
|
65962
66655
|
if (evt.pointerType === "pen" && this.hasPenInput === null) {
|
|
@@ -66056,6 +66749,30 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66056
66749
|
this.camera.resetViewMatrixToMain();
|
|
66057
66750
|
}
|
|
66058
66751
|
};
|
|
66752
|
+
this.emitter.insertImage = (src, pageId) => {
|
|
66753
|
+
if (!/https/.test(src)) {
|
|
66754
|
+
(0, import_forge_room.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
66755
|
+
src
|
|
66756
|
+
}, "warning");
|
|
66757
|
+
return;
|
|
66758
|
+
}
|
|
66759
|
+
let targetPageId = pageId;
|
|
66760
|
+
if (!targetPageId) {
|
|
66761
|
+
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
66762
|
+
}
|
|
66763
|
+
if (!targetPageId) {
|
|
66764
|
+
(0, import_forge_room.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
66765
|
+
return;
|
|
66766
|
+
}
|
|
66767
|
+
this.layers.get(targetPageId)?.createImage(src);
|
|
66768
|
+
};
|
|
66769
|
+
this.emitter.removeElement = (pageId, elementId) => {
|
|
66770
|
+
if (!this.layers.has(pageId)) {
|
|
66771
|
+
(0, import_forge_room.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
66772
|
+
return;
|
|
66773
|
+
}
|
|
66774
|
+
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
66775
|
+
};
|
|
66059
66776
|
this.emitter.getViewModel = (userId) => {
|
|
66060
66777
|
const targetId = userId ? userId : this.userId;
|
|
66061
66778
|
return this.userMap(targetId).get(WhiteboardKeys.cameraMode);
|
|
@@ -66071,7 +66788,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66071
66788
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
66072
66789
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
66073
66790
|
if (!this.layers.has(targetId)) {
|
|
66074
|
-
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission));
|
|
66791
|
+
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
|
|
66075
66792
|
}
|
|
66076
66793
|
if (!this.undoManagers.has(targetId)) {
|
|
66077
66794
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -66121,13 +66838,29 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66121
66838
|
this.emitter.resetCamera = () => {
|
|
66122
66839
|
this.camera.reset();
|
|
66123
66840
|
};
|
|
66841
|
+
this.emitter.showLiveCursor = (value) => {
|
|
66842
|
+
this.liveCursor.showLiveCursor = value;
|
|
66843
|
+
};
|
|
66844
|
+
this.emitter.updateViewport = (width, height) => {
|
|
66845
|
+
this.updateOptionSize(width, height);
|
|
66846
|
+
};
|
|
66847
|
+
this.emitter.__setMainCanvasVisible = (visible) => {
|
|
66848
|
+
this.canvasElement.style.opacity = visible ? "1" : "0";
|
|
66849
|
+
};
|
|
66124
66850
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
66125
66851
|
(0, import_forge_room.log)("WhiteboardApplicationError", {
|
|
66126
66852
|
errorCode,
|
|
66127
66853
|
errorMessage
|
|
66128
66854
|
});
|
|
66129
66855
|
});
|
|
66130
|
-
|
|
66856
|
+
Object.defineProperty(this.emitter, "__delayTranslateOut", {
|
|
66857
|
+
get() {
|
|
66858
|
+
return that.delayTranslateOut;
|
|
66859
|
+
},
|
|
66860
|
+
set(value) {
|
|
66861
|
+
that.delayTranslateOut = value;
|
|
66862
|
+
}
|
|
66863
|
+
});
|
|
66131
66864
|
Object.defineProperty(this.emitter, "tool", {
|
|
66132
66865
|
get() {
|
|
66133
66866
|
return that.toolbarModel.currentTool;
|
|
@@ -66216,6 +66949,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66216
66949
|
that.camera.enableBoundaryHighlight = value;
|
|
66217
66950
|
}
|
|
66218
66951
|
});
|
|
66952
|
+
window.addEventListener("forge-whiteboard-synced-status", this.addWhiteboardStatus);
|
|
66219
66953
|
}
|
|
66220
66954
|
userMap(userId) {
|
|
66221
66955
|
return this.getMap(`user/${userId}`);
|
|
@@ -66224,10 +66958,23 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66224
66958
|
this.permissions = new WhiteboardPermissions(this.userManager, (userId) => {
|
|
66225
66959
|
return this.userMap(userId);
|
|
66226
66960
|
});
|
|
66961
|
+
this.permissions.setPermission(WhiteboardPermissionFlag.all);
|
|
66227
66962
|
this.emitter["permissions"] = this.permissions;
|
|
66228
66963
|
this.emitter["selfUserId"] = this.userId;
|
|
66229
66964
|
this.option = option;
|
|
66965
|
+
if (this.option.stretchToFill) {
|
|
66966
|
+
this.getMap("attrs").set("viewportWidth", -1);
|
|
66967
|
+
this.getMap("attrs").set("viewportHeight", -1);
|
|
66968
|
+
} else {
|
|
66969
|
+
if (!this.getMap("attrs").has("viewportWidth")) {
|
|
66970
|
+
this.getMap("attrs").set("viewportWidth", option.width);
|
|
66971
|
+
}
|
|
66972
|
+
if (!this.getMap("attrs").has("viewportHeight")) {
|
|
66973
|
+
this.getMap("attrs").set("viewportHeight", option.height);
|
|
66974
|
+
}
|
|
66975
|
+
}
|
|
66230
66976
|
this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
|
|
66977
|
+
this.userMap(this.userId).observe(this.handleSyncedWhiteboardStatusChange);
|
|
66231
66978
|
this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
|
|
66232
66979
|
this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
|
|
66233
66980
|
return this.userMap(userId);
|
|
@@ -66275,6 +67022,9 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66275
67022
|
this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
|
|
66276
67023
|
return this.userMap(userId);
|
|
66277
67024
|
}, this.hasPermission);
|
|
67025
|
+
this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
|
|
67026
|
+
return this.userMap(userId);
|
|
67027
|
+
});
|
|
66278
67028
|
this.tools = {
|
|
66279
67029
|
pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
66280
67030
|
curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
@@ -66285,7 +67035,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66285
67035
|
text: new TextTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
|
|
66286
67036
|
ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
66287
67037
|
triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
66288
|
-
eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel),
|
|
67038
|
+
eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
|
|
66289
67039
|
laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
66290
67040
|
grab: new GrabTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.camera)
|
|
66291
67041
|
};
|
|
@@ -66357,32 +67107,12 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66357
67107
|
}
|
|
66358
67108
|
});
|
|
66359
67109
|
this.shadowEmitter.on("translateOut", (ids, container) => {
|
|
66360
|
-
|
|
66361
|
-
|
|
66362
|
-
|
|
66363
|
-
|
|
67110
|
+
if (this.delayTranslateOut > 0) {
|
|
67111
|
+
setTimeout(() => {
|
|
67112
|
+
this.handleElementTranslateOut(ids, container);
|
|
67113
|
+
}, this.delayTranslateOut);
|
|
66364
67114
|
} else {
|
|
66365
|
-
|
|
66366
|
-
}
|
|
66367
|
-
if (parent) {
|
|
66368
|
-
ids.forEach((id) => {
|
|
66369
|
-
const target = parent.children.find((child) => child.data.uuid === id);
|
|
66370
|
-
if (target) {
|
|
66371
|
-
target.remove();
|
|
66372
|
-
this.insertElementToParent(target, this.paperScope.project.activeLayer);
|
|
66373
|
-
} else {
|
|
66374
|
-
const pageId = this.pageModel.getCurrentPage(this.userId);
|
|
66375
|
-
if (pageId) {
|
|
66376
|
-
const page = this.layers.get(pageId);
|
|
66377
|
-
if (page) {
|
|
66378
|
-
const model = page.elementModels.get(id);
|
|
66379
|
-
if (model && model.item) {
|
|
66380
|
-
this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
|
|
66381
|
-
}
|
|
66382
|
-
}
|
|
66383
|
-
}
|
|
66384
|
-
}
|
|
66385
|
-
});
|
|
67115
|
+
this.handleElementTranslateOut(ids, container);
|
|
66386
67116
|
}
|
|
66387
67117
|
});
|
|
66388
67118
|
this.shadowEmitter.on("translateIn", (ids, container) => {
|
|
@@ -66409,6 +67139,15 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66409
67139
|
this.emitter.emit("grabUp");
|
|
66410
67140
|
});
|
|
66411
67141
|
this.clearElements();
|
|
67142
|
+
if (this.option.stretchToFill) {
|
|
67143
|
+
window.addEventListener("resize", () => {
|
|
67144
|
+
const bounds = this.rootElement.getBoundingClientRect();
|
|
67145
|
+
this.updateOptionSize(bounds.width, bounds.height);
|
|
67146
|
+
this.adjustByOutFrame(bounds.width, bounds.height);
|
|
67147
|
+
});
|
|
67148
|
+
}
|
|
67149
|
+
this.rootElement.appendChild(this.liveCursor.container);
|
|
67150
|
+
this.getMap("attrs").observe(this.handleViewportUpdate);
|
|
66412
67151
|
}
|
|
66413
67152
|
clearElements() {
|
|
66414
67153
|
const userIds = this.userManager.userIdList();
|
|
@@ -66475,7 +67214,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66475
67214
|
if (renderableModel.elementModels.has(key)) {
|
|
66476
67215
|
elementModel = renderableModel.elementModels.get(key) ?? null;
|
|
66477
67216
|
} else {
|
|
66478
|
-
|
|
67217
|
+
const elementMap = renderableModel.elements.get(key);
|
|
66479
67218
|
if (elementMap) {
|
|
66480
67219
|
elementModel = renderableModel.convertToModel(elementMap);
|
|
66481
67220
|
}
|
|
@@ -66504,10 +67243,10 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66504
67243
|
this.snapshotScope.view.viewSize = bounds.size.multiply(scale2);
|
|
66505
67244
|
this.snapshotScope.view.matrix = matrix;
|
|
66506
67245
|
} else if (area === "maxScale" && this.option.maxScaleRatio && this.option.maxScaleRatio !== -1) {
|
|
66507
|
-
const width = this.
|
|
66508
|
-
const height = this.
|
|
66509
|
-
const offsetX = this.
|
|
66510
|
-
const offsetY = this.
|
|
67246
|
+
const width = this.viewportWidth * this.option.maxScaleRatio;
|
|
67247
|
+
const height = this.viewportHeight * this.option.maxScaleRatio;
|
|
67248
|
+
const offsetX = this.viewportWidth * (this.option.maxScaleRatio - 1) / 2;
|
|
67249
|
+
const offsetY = this.viewportHeight * (this.option.maxScaleRatio - 1) / 2;
|
|
66511
67250
|
const matrix = new this.paperScope.Matrix();
|
|
66512
67251
|
matrix.scale(scale);
|
|
66513
67252
|
matrix.translate({
|
|
@@ -66531,28 +67270,23 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66531
67270
|
this.disableViewModelUpdate = true;
|
|
66532
67271
|
}
|
|
66533
67272
|
linkToWhiteboard(targetId) {
|
|
66534
|
-
|
|
66535
|
-
|
|
66536
|
-
|
|
66537
|
-
|
|
66538
|
-
|
|
66539
|
-
|
|
66540
|
-
|
|
66541
|
-
|
|
66542
|
-
|
|
66543
|
-
|
|
66544
|
-
|
|
66545
|
-
|
|
66546
|
-
|
|
66547
|
-
|
|
66548
|
-
this.permissions.addPermission(this.linkTarget.get("permission"), this.userId);
|
|
66549
|
-
this.linkTarget.observe(this.handleLinkedMapChange);
|
|
66550
|
-
}
|
|
67273
|
+
this.linkWhiteboardId = targetId;
|
|
67274
|
+
window.__forge_gl_wb_status__.get(targetId).then((currentStatus) => {
|
|
67275
|
+
if (currentStatus) {
|
|
67276
|
+
this.toolbarModel.currentTool = currentStatus.currentTool;
|
|
67277
|
+
this.toolbarModel.strokeColor = currentStatus.strokeColor;
|
|
67278
|
+
this.toolbarModel.fillColor = currentStatus.fillColor;
|
|
67279
|
+
this.toolbarModel.fontSize = currentStatus.fontSize;
|
|
67280
|
+
this.toolbarModel.fontFamily = currentStatus.fontFamily;
|
|
67281
|
+
this.toolbarModel.strokeWidth = currentStatus.strokeWidth;
|
|
67282
|
+
this.toolbarModel.dashArray = currentStatus.dashArray;
|
|
67283
|
+
this.permissions.removePermission(WhiteboardPermissionFlag.all);
|
|
67284
|
+
this.permissions.addPermission(currentStatus.permission);
|
|
67285
|
+
}
|
|
67286
|
+
});
|
|
66551
67287
|
}
|
|
66552
67288
|
unlink() {
|
|
66553
|
-
|
|
66554
|
-
this.linkTarget.unobserve(this.handleLinkedMapChange);
|
|
66555
|
-
}
|
|
67289
|
+
this.linkWhiteboardId = null;
|
|
66556
67290
|
}
|
|
66557
67291
|
setViewSize(width, height) {
|
|
66558
67292
|
this.paperScope.project.view.viewSize = new this.paperScope.Size(width, height);
|
|
@@ -66562,15 +67296,21 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66562
67296
|
const size = this.paperScope.view.viewSize;
|
|
66563
67297
|
return [size.width, size.height];
|
|
66564
67298
|
}
|
|
67299
|
+
getInherentScale() {
|
|
67300
|
+
return this.camera.getInherentScale();
|
|
67301
|
+
}
|
|
66565
67302
|
updateInternalResizeObserverStatus(value) {
|
|
66566
67303
|
this.internalResizeObserver = value;
|
|
66567
67304
|
}
|
|
66568
67305
|
updateOptionSize(width, height) {
|
|
66569
|
-
this.
|
|
66570
|
-
this.
|
|
67306
|
+
this.getMap("attrs").set("viewportWidth", width);
|
|
67307
|
+
this.getMap("attrs").set("viewportHeight", height);
|
|
66571
67308
|
this.camera.updateInitSize(new import_paper.default.Size(width, height));
|
|
66572
67309
|
}
|
|
66573
|
-
async dispose() {
|
|
67310
|
+
async dispose(removeSubDoc) {
|
|
67311
|
+
if (removeSubDoc) {
|
|
67312
|
+
this.deleteSubDoc(this.appId);
|
|
67313
|
+
}
|
|
66574
67314
|
this.selectElementsModel.dispose();
|
|
66575
67315
|
this.trashedElementsModel.dispose();
|
|
66576
67316
|
this.paperScope.view.remove();
|
|
@@ -66581,72 +67321,92 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
|
|
|
66581
67321
|
this.shadowScope.project.clear();
|
|
66582
67322
|
this.snapshotScope.project.clear();
|
|
66583
67323
|
this.resizeObserver.disconnect();
|
|
67324
|
+
this.unlink();
|
|
67325
|
+
for (const entry of this.undoManagers.entries()) {
|
|
67326
|
+
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
67327
|
+
entry[1].off("stack-item-popped", this.handleStackItemPopped);
|
|
67328
|
+
}
|
|
67329
|
+
for (const entry of this.layers.entries()) {
|
|
67330
|
+
entry[1].dispose(removeSubDoc);
|
|
67331
|
+
entry[1].removeAllListeners();
|
|
67332
|
+
}
|
|
67333
|
+
this.camera.dispose();
|
|
67334
|
+
this.pageModel.dispose();
|
|
67335
|
+
this.pageModel.removeAllListeners();
|
|
67336
|
+
for (const entry of this.editors.entries()) {
|
|
67337
|
+
entry[1].dispose();
|
|
67338
|
+
}
|
|
67339
|
+
this.toolbarModel.dispose();
|
|
67340
|
+
this.emitter.indexedNavigation.dispose();
|
|
67341
|
+
this.permissions.dispose();
|
|
67342
|
+
(0, import_forge_room13.removeObserver)(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
|
|
66584
67343
|
}
|
|
66585
67344
|
};
|
|
66586
|
-
|
|
67345
|
+
_defineProperty43(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
|
|
66587
67346
|
|
|
66588
67347
|
// src/SlideApplication.ts
|
|
66589
67348
|
var import_slide = __toESM(require_Slide());
|
|
66590
|
-
var
|
|
67349
|
+
var import_forge_room16 = require("@netless/forge-room");
|
|
66591
67350
|
|
|
66592
67351
|
// src/Slide.ts
|
|
66593
|
-
var
|
|
66594
|
-
var SlideForge = class extends
|
|
67352
|
+
var import_eventemitter313 = __toESM(require("eventemitter3"));
|
|
67353
|
+
var SlideForge = class extends import_eventemitter313.default {
|
|
66595
67354
|
view;
|
|
66596
67355
|
permissions;
|
|
66597
67356
|
footView;
|
|
67357
|
+
sideBarView;
|
|
66598
67358
|
/**
|
|
66599
|
-
|
|
66600
|
-
|
|
67359
|
+
* 当前页面索引, 从 0 开始
|
|
67360
|
+
*/
|
|
66601
67361
|
pageIndex;
|
|
66602
67362
|
/**
|
|
66603
|
-
|
|
66604
|
-
|
|
67363
|
+
* 总页数
|
|
67364
|
+
*/
|
|
66605
67365
|
pageCount;
|
|
66606
67366
|
/**
|
|
66607
|
-
|
|
66608
|
-
|
|
66609
|
-
|
|
67367
|
+
* 切换到参数指定页面, index 从 0 开始
|
|
67368
|
+
* @param {number} index 页面索引
|
|
67369
|
+
*/
|
|
66610
67370
|
goto;
|
|
66611
67371
|
/**
|
|
66612
|
-
|
|
66613
|
-
|
|
67372
|
+
* 下一步, 如果已经是本页的最后一步, 则切换到下一页
|
|
67373
|
+
*/
|
|
66614
67374
|
nextStep;
|
|
66615
67375
|
/**
|
|
66616
|
-
|
|
66617
|
-
|
|
67376
|
+
* 上一步, 如果已经是本页的第一步, 则切换到上一页
|
|
67377
|
+
*/
|
|
66618
67378
|
prevStep;
|
|
66619
67379
|
/**
|
|
66620
|
-
|
|
66621
|
-
|
|
67380
|
+
* 下一页, 如果是最后一页, 则不执行任何操作
|
|
67381
|
+
*/
|
|
66622
67382
|
nextPage;
|
|
66623
67383
|
/**
|
|
66624
|
-
|
|
66625
|
-
|
|
67384
|
+
* 上一页, 如果是第一页, 则不执行任何操作
|
|
67385
|
+
*/
|
|
66626
67386
|
prevPage;
|
|
66627
67387
|
/**
|
|
66628
|
-
|
|
66629
|
-
|
|
67388
|
+
* 切换侧栏显示状态
|
|
67389
|
+
*/
|
|
66630
67390
|
sideBarToggle;
|
|
66631
67391
|
/**
|
|
66632
|
-
|
|
66633
|
-
|
|
66634
|
-
|
|
67392
|
+
* 获取预览图图片内容, base64 编码
|
|
67393
|
+
* @param {number} index 页面索引
|
|
67394
|
+
*/
|
|
66635
67395
|
imgContent;
|
|
66636
67396
|
/**
|
|
66637
|
-
|
|
66638
|
-
|
|
66639
|
-
|
|
67397
|
+
* 获取预览图图片链接
|
|
67398
|
+
* @param {number} index 页面索引
|
|
67399
|
+
*/
|
|
66640
67400
|
imgUrl;
|
|
66641
67401
|
/**
|
|
66642
|
-
|
|
66643
|
-
|
|
66644
|
-
|
|
67402
|
+
* 获取预览图图片尺寸
|
|
67403
|
+
* @param {number} index 页面索引
|
|
67404
|
+
*/
|
|
66645
67405
|
imgSize;
|
|
66646
67406
|
};
|
|
66647
67407
|
|
|
66648
67408
|
// src/ForgeSlidePermession.ts
|
|
66649
|
-
var
|
|
67409
|
+
var import_forge_room14 = require("@netless/forge-room");
|
|
66650
67410
|
var ForgeSlidePermissionFlag = /* @__PURE__ */ ((ForgeSlidePermissionFlag2) => {
|
|
66651
67411
|
ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["none"] = 0] = "none";
|
|
66652
67412
|
ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["changeStep"] = 1] = "changeStep";
|
|
@@ -66655,58 +67415,12 @@ var ForgeSlidePermissionFlag = /* @__PURE__ */ ((ForgeSlidePermissionFlag2) => {
|
|
|
66655
67415
|
ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["all"] = 7] = "all";
|
|
66656
67416
|
return ForgeSlidePermissionFlag2;
|
|
66657
67417
|
})(ForgeSlidePermissionFlag || {});
|
|
66658
|
-
var ForgeSlidePermissions = class extends
|
|
66659
|
-
requestUserMap;
|
|
66660
|
-
userManager;
|
|
66661
|
-
observers = /* @__PURE__ */ new Map();
|
|
66662
|
-
constructor(userManager, requestUserMap) {
|
|
66663
|
-
super();
|
|
66664
|
-
this.userManager = userManager;
|
|
66665
|
-
this.requestUserMap = requestUserMap;
|
|
66666
|
-
this.createModel(this.userManager.selfId);
|
|
66667
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
66668
|
-
this.addObserve(userId);
|
|
66669
|
-
});
|
|
66670
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
66671
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
66672
|
-
}
|
|
66673
|
-
handleUserLeave = (user) => {
|
|
66674
|
-
const cb = this.observers.get(user.id);
|
|
66675
|
-
if (cb) {
|
|
66676
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
66677
|
-
}
|
|
66678
|
-
};
|
|
66679
|
-
handleUserJoin = (user) => {
|
|
66680
|
-
this.addObserve(user.id);
|
|
66681
|
-
};
|
|
66682
|
-
addObserve(userId) {
|
|
66683
|
-
const observer = (evt) => {
|
|
66684
|
-
this.handleUserPermissionChange(userId, evt);
|
|
66685
|
-
};
|
|
66686
|
-
this.observers.set(userId, observer);
|
|
66687
|
-
this.requestUserMap(userId).observe(observer);
|
|
66688
|
-
}
|
|
66689
|
-
createModel(userId) {
|
|
66690
|
-
const userMap = this.requestUserMap(userId);
|
|
66691
|
-
if (!userMap.has("permission")) {
|
|
66692
|
-
userMap.set("permission", 0);
|
|
66693
|
-
}
|
|
66694
|
-
}
|
|
66695
|
-
handleUserPermissionChange(userId, evt) {
|
|
66696
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
66697
|
-
if (key === "permission") {
|
|
66698
|
-
if (value.action === "add" || value.action === "update") {
|
|
66699
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
66700
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
66701
|
-
}
|
|
66702
|
-
}
|
|
66703
|
-
}
|
|
66704
|
-
}
|
|
67418
|
+
var ForgeSlidePermissions = class extends import_forge_room14.AbstractApplicationPermissions {
|
|
66705
67419
|
/**
|
|
66706
|
-
|
|
66707
|
-
|
|
66708
|
-
|
|
66709
|
-
|
|
67420
|
+
* 解析权限列表组合
|
|
67421
|
+
* @param {number} value - 权限数字值
|
|
67422
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
67423
|
+
*/
|
|
66710
67424
|
resolveFlags(value) {
|
|
66711
67425
|
return [
|
|
66712
67426
|
2 /* changePage */,
|
|
@@ -66714,53 +67428,10 @@ var ForgeSlidePermissions = class extends import_eventemitter315.default {
|
|
|
66714
67428
|
4 /* clickAnim */
|
|
66715
67429
|
].filter((v) => (v & value) !== 0);
|
|
66716
67430
|
}
|
|
66717
|
-
/**
|
|
66718
|
-
* 获取权限列表组合对应的数值
|
|
66719
|
-
* @param { string } userId 不传表示获取自己
|
|
66720
|
-
*/
|
|
66721
|
-
getPermissionValue(userId) {
|
|
66722
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
66723
|
-
}
|
|
66724
|
-
/**
|
|
66725
|
-
* 获取权限列表
|
|
66726
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
66727
|
-
*/
|
|
66728
|
-
getPermissionFlags(userId) {
|
|
66729
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
66730
|
-
return this.resolveFlags(value);
|
|
66731
|
-
}
|
|
66732
|
-
/**
|
|
66733
|
-
* 返回对应 userId 是否有相应权限
|
|
66734
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
66735
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
66736
|
-
*/
|
|
66737
|
-
hasPermission(flag, userId) {
|
|
66738
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
66739
|
-
}
|
|
66740
|
-
/**
|
|
66741
|
-
* 添加权限
|
|
66742
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
66743
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
66744
|
-
*/
|
|
66745
|
-
addPermission(flag, userId) {
|
|
66746
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
66747
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
66748
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
66749
|
-
}
|
|
66750
|
-
/**
|
|
66751
|
-
* 移除权限
|
|
66752
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
66753
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
66754
|
-
*/
|
|
66755
|
-
removePermission(flag, userId) {
|
|
66756
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
66757
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
66758
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
66759
|
-
}
|
|
66760
67431
|
};
|
|
66761
67432
|
|
|
66762
|
-
// src/
|
|
66763
|
-
var
|
|
67433
|
+
// src/FooterView.ts
|
|
67434
|
+
var import_eventemitter314 = __toESM(require("eventemitter3"));
|
|
66764
67435
|
|
|
66765
67436
|
// src/icons.ts
|
|
66766
67437
|
var prevPage = (color) => `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none">
|
|
@@ -66789,18 +67460,20 @@ var Icons = {
|
|
|
66789
67460
|
sideBar
|
|
66790
67461
|
};
|
|
66791
67462
|
|
|
66792
|
-
// src/
|
|
67463
|
+
// src/FooterView.ts
|
|
66793
67464
|
var EM_COLOR = "#8C8C8C";
|
|
66794
|
-
var FooterView = class extends
|
|
67465
|
+
var FooterView = class extends import_eventemitter314.default {
|
|
66795
67466
|
root;
|
|
66796
67467
|
prevStep;
|
|
66797
67468
|
nextStep;
|
|
66798
67469
|
prevPage;
|
|
66799
67470
|
nextPage;
|
|
66800
67471
|
sideBarToggle;
|
|
67472
|
+
eventMap = /* @__PURE__ */ new Map();
|
|
66801
67473
|
constructor() {
|
|
66802
67474
|
super();
|
|
66803
67475
|
this.root = document.createElement("div");
|
|
67476
|
+
this.root.classList.add("forge-slide-footer");
|
|
66804
67477
|
this.root.style.height = "24px";
|
|
66805
67478
|
this.root.style.zIndex = "6";
|
|
66806
67479
|
this.root.style.display = "flex";
|
|
@@ -66860,28 +67533,53 @@ var FooterView = class extends import_eventemitter316.default {
|
|
|
66860
67533
|
icon.style.borderRadius = "2px";
|
|
66861
67534
|
icon.style.margin = "6px";
|
|
66862
67535
|
icon.innerHTML = svgContent;
|
|
66863
|
-
|
|
67536
|
+
const onClickHandle = () => {
|
|
66864
67537
|
action();
|
|
66865
|
-
}
|
|
66866
|
-
|
|
67538
|
+
};
|
|
67539
|
+
const onMouseOverHandle = () => {
|
|
66867
67540
|
icon.style.backgroundColor = "#f0f0f0";
|
|
66868
|
-
}
|
|
66869
|
-
|
|
67541
|
+
};
|
|
67542
|
+
const onMouseOutHandle = () => {
|
|
66870
67543
|
icon.style.backgroundColor = "transparent";
|
|
66871
|
-
}
|
|
67544
|
+
};
|
|
67545
|
+
icon.addEventListener("click", onClickHandle);
|
|
67546
|
+
icon.addEventListener("mouseover", onMouseOverHandle);
|
|
67547
|
+
icon.addEventListener("mouseout", onMouseOutHandle);
|
|
67548
|
+
this.eventMap.set(icon, [onClickHandle, onMouseOutHandle, onMouseOverHandle]);
|
|
66872
67549
|
return icon;
|
|
66873
67550
|
}
|
|
67551
|
+
clearHTMLEventListeners() {
|
|
67552
|
+
this.eventMap.forEach((value, key) => {
|
|
67553
|
+
if (key) {
|
|
67554
|
+
const [clickEvent, mouseOutEvent, mouseOverEvent] = value;
|
|
67555
|
+
key.removeEventListener("click", clickEvent);
|
|
67556
|
+
key.removeEventListener("mouseover", mouseOverEvent);
|
|
67557
|
+
key.removeEventListener("mouseout", mouseOutEvent);
|
|
67558
|
+
}
|
|
67559
|
+
});
|
|
67560
|
+
}
|
|
67561
|
+
dispose() {
|
|
67562
|
+
this.removeAllListeners();
|
|
67563
|
+
this.clearHTMLEventListeners();
|
|
67564
|
+
}
|
|
66874
67565
|
};
|
|
66875
67566
|
|
|
66876
67567
|
// src/SiderBarView.ts
|
|
66877
|
-
var
|
|
66878
|
-
var
|
|
67568
|
+
var import_eventemitter315 = __toESM(require("eventemitter3"));
|
|
67569
|
+
var import_forge_room15 = require("@netless/forge-room");
|
|
67570
|
+
var SideBarView = class extends import_eventemitter315.default {
|
|
66879
67571
|
root = document.createElement("div");
|
|
66880
|
-
|
|
67572
|
+
isShow = false;
|
|
67573
|
+
eventsMap = /* @__PURE__ */ new Map();
|
|
67574
|
+
taskId = "";
|
|
67575
|
+
prefix = "";
|
|
67576
|
+
addImagesPool = [];
|
|
67577
|
+
scheduleId = 0;
|
|
67578
|
+
isSchedule = false;
|
|
66881
67579
|
constructor() {
|
|
66882
67580
|
super();
|
|
66883
67581
|
this.root.style.backgroundColor = "#eee";
|
|
66884
|
-
this.root.className = "slide-sidebar";
|
|
67582
|
+
this.root.className = "forge-slide-sidebar";
|
|
66885
67583
|
this.root.style.width = "240px";
|
|
66886
67584
|
this.root.style.height = "100%";
|
|
66887
67585
|
this.root.style.position = "absolute";
|
|
@@ -66890,65 +67588,147 @@ var SideBarView = class extends import_eventemitter317.default {
|
|
|
66890
67588
|
this.root.style.zIndex = "5";
|
|
66891
67589
|
this.root.style.transition = "left 0.3s ease-in-out";
|
|
66892
67590
|
this.root.style.overflow = "auto";
|
|
66893
|
-
this.root.style.border = "1px solid #ccc";
|
|
66894
|
-
this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
|
|
66895
67591
|
this.root.style.display = "flex";
|
|
66896
67592
|
this.root.style.flexDirection = "column";
|
|
66897
67593
|
this.root.style.justifyContent = "flex-start";
|
|
66898
67594
|
this.root.style.alignItems = "center";
|
|
66899
67595
|
}
|
|
66900
|
-
|
|
66901
|
-
|
|
66902
|
-
}
|
|
66903
|
-
|
|
66904
|
-
|
|
66905
|
-
|
|
66906
|
-
|
|
66907
|
-
|
|
66908
|
-
|
|
67596
|
+
get isShowSideBar() {
|
|
67597
|
+
return this.isShow;
|
|
67598
|
+
}
|
|
67599
|
+
async getPreviewImage(imageUrl) {
|
|
67600
|
+
const image = await fetch(imageUrl);
|
|
67601
|
+
const blob = await image.blob();
|
|
67602
|
+
return new Promise((resolve) => {
|
|
67603
|
+
const reader = new FileReader();
|
|
67604
|
+
reader.onloadend = () => {
|
|
67605
|
+
const base64Data = reader.result;
|
|
67606
|
+
const img = document.createElement("img");
|
|
67607
|
+
img.src = base64Data;
|
|
67608
|
+
img.onload = () => {
|
|
67609
|
+
resolve({
|
|
67610
|
+
url: imageUrl,
|
|
67611
|
+
src: base64Data,
|
|
67612
|
+
width: img.width,
|
|
67613
|
+
height: img.height
|
|
67614
|
+
});
|
|
67615
|
+
};
|
|
67616
|
+
};
|
|
67617
|
+
reader.readAsDataURL(blob);
|
|
67618
|
+
});
|
|
67619
|
+
}
|
|
67620
|
+
async appendPreviewImage(pageIndex) {
|
|
67621
|
+
const itemContainer = document.createElement("div");
|
|
67622
|
+
itemContainer.style.width = "60%";
|
|
67623
|
+
itemContainer.style.display = "flex";
|
|
67624
|
+
itemContainer.style.justifyContent = "center";
|
|
67625
|
+
itemContainer.style.alignItems = "flex-start";
|
|
67626
|
+
itemContainer.style.position = "relative";
|
|
67627
|
+
itemContainer.style.borderRadius = "4px";
|
|
67628
|
+
itemContainer.style.transition = "border-color .3s";
|
|
67629
|
+
itemContainer.style.marginBottom = "10px";
|
|
67630
|
+
const onMouseOverHandle = () => {
|
|
67631
|
+
itemContainer.style.borderColor = "#ccc";
|
|
67632
|
+
};
|
|
67633
|
+
const onMouseOutHandle = () => {
|
|
67634
|
+
itemContainer.style.borderColor = "transparent";
|
|
67635
|
+
};
|
|
67636
|
+
const onClickHandle = () => {
|
|
67637
|
+
this.emit("pageChange", pageIndex);
|
|
67638
|
+
};
|
|
67639
|
+
itemContainer.addEventListener("click", onClickHandle);
|
|
67640
|
+
itemContainer.addEventListener("mouseover", onMouseOverHandle);
|
|
67641
|
+
itemContainer.addEventListener("mouseout", onMouseOutHandle);
|
|
67642
|
+
this.eventsMap.set(itemContainer, [onClickHandle, onMouseOverHandle, onMouseOutHandle]);
|
|
67643
|
+
const pageIndexContainer = document.createElement("span");
|
|
67644
|
+
pageIndexContainer.textContent = `${pageIndex}`;
|
|
67645
|
+
pageIndexContainer.style.position = "absolute";
|
|
67646
|
+
pageIndexContainer.style.top = "1px";
|
|
67647
|
+
pageIndexContainer.style.left = "-10px";
|
|
67648
|
+
pageIndexContainer.style.transform = "translate(-100%)";
|
|
67649
|
+
pageIndexContainer.style.fontSize = "12px";
|
|
67650
|
+
pageIndexContainer.style.color = "#5f5f5f";
|
|
67651
|
+
const previewUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex}.png`;
|
|
67652
|
+
const preview = document.createElement("img");
|
|
67653
|
+
const cachePreview = await import_forge_room15.kvStore.getItem(previewUrl);
|
|
67654
|
+
if (cachePreview) {
|
|
67655
|
+
const { src } = JSON.parse(cachePreview);
|
|
67656
|
+
preview.src = src;
|
|
67657
|
+
} else {
|
|
67658
|
+
const previewInfo = await this.getPreviewImage(previewUrl);
|
|
67659
|
+
await import_forge_room15.kvStore.setItem(previewUrl, JSON.stringify(previewInfo));
|
|
67660
|
+
const { src } = previewInfo;
|
|
67661
|
+
preview.src = src;
|
|
67662
|
+
}
|
|
67663
|
+
preview.style.width = "100%";
|
|
67664
|
+
preview.style.display = "inline-block";
|
|
67665
|
+
itemContainer.appendChild(preview);
|
|
67666
|
+
itemContainer.appendChild(pageIndexContainer);
|
|
67667
|
+
this.root.appendChild(itemContainer);
|
|
67668
|
+
}
|
|
67669
|
+
async scheduleGetPreviewImage() {
|
|
67670
|
+
if (!this.isSchedule) {
|
|
67671
|
+
this.scheduleId = setTimeout(async () => {
|
|
67672
|
+
await this.scheduleGetPreviewImage();
|
|
67673
|
+
}, 32);
|
|
67674
|
+
return;
|
|
67675
|
+
}
|
|
67676
|
+
const pageIndex = this.addImagesPool.shift();
|
|
67677
|
+
if (!pageIndex) {
|
|
67678
|
+
clearTimeout(this.scheduleId);
|
|
67679
|
+
this.scheduleId = 0;
|
|
67680
|
+
return;
|
|
67681
|
+
}
|
|
67682
|
+
await this.appendPreviewImage(pageIndex);
|
|
67683
|
+
this.scheduleId = setTimeout(async () => {
|
|
67684
|
+
await this.scheduleGetPreviewImage();
|
|
67685
|
+
}, 32);
|
|
67686
|
+
}
|
|
67687
|
+
async startGetPreviewImageSchedule() {
|
|
67688
|
+
this.isSchedule = true;
|
|
67689
|
+
}
|
|
67690
|
+
pauseGetPreviewImageSchedule() {
|
|
67691
|
+
this.isSchedule = false;
|
|
67692
|
+
}
|
|
66909
67693
|
initialize(slideCount, option) {
|
|
67694
|
+
this.taskId = option.taskId;
|
|
67695
|
+
this.prefix = option.prefix;
|
|
66910
67696
|
for (let i = 1; i <= slideCount; i++) {
|
|
66911
|
-
|
|
66912
|
-
|
|
66913
|
-
|
|
66914
|
-
|
|
66915
|
-
|
|
66916
|
-
|
|
66917
|
-
|
|
66918
|
-
|
|
66919
|
-
|
|
66920
|
-
|
|
66921
|
-
|
|
66922
|
-
|
|
66923
|
-
|
|
66924
|
-
|
|
66925
|
-
|
|
66926
|
-
|
|
66927
|
-
pageIndex.style.position = "absolute";
|
|
66928
|
-
pageIndex.style.top = "1px";
|
|
66929
|
-
pageIndex.style.left = "-10px";
|
|
66930
|
-
pageIndex.style.transform = "translate(-100%)";
|
|
66931
|
-
pageIndex.style.fontSize = "12px";
|
|
66932
|
-
pageIndex.style.color = "#5f5f5f";
|
|
66933
|
-
const preview = document.createElement("img");
|
|
66934
|
-
preview.style.width = "100%";
|
|
66935
|
-
preview.style.display = "inline-block";
|
|
66936
|
-
preview.src = `${option.prefix}/${option.taskId}/preview/${i}.png`;
|
|
66937
|
-
itemContainer.appendChild(preview);
|
|
66938
|
-
itemContainer.appendChild(pageIndex);
|
|
66939
|
-
this.root.appendChild(itemContainer);
|
|
67697
|
+
this.addImagesPool.push(i);
|
|
67698
|
+
}
|
|
67699
|
+
this.scheduleGetPreviewImage();
|
|
67700
|
+
}
|
|
67701
|
+
hidden() {
|
|
67702
|
+
if (!this.root || !this.isShow) {
|
|
67703
|
+
return;
|
|
67704
|
+
}
|
|
67705
|
+
this.root.style.left = "-240px";
|
|
67706
|
+
this.root.style.border = "none";
|
|
67707
|
+
this.root.style.boxShadow = "none";
|
|
67708
|
+
this.isShow = false;
|
|
67709
|
+
}
|
|
67710
|
+
show() {
|
|
67711
|
+
if (!this.root) {
|
|
67712
|
+
return;
|
|
66940
67713
|
}
|
|
67714
|
+
this.root.style.left = "0";
|
|
67715
|
+
this.root.style.border = "1px solid #ccc";
|
|
67716
|
+
this.root.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)";
|
|
67717
|
+
this.isShow = true;
|
|
66941
67718
|
}
|
|
66942
67719
|
dispose() {
|
|
66943
|
-
this.
|
|
66944
|
-
|
|
66945
|
-
|
|
67720
|
+
this.removeAllListeners();
|
|
67721
|
+
this.eventsMap.forEach((handlers, element) => {
|
|
67722
|
+
const [clickEvent, mouseOverEvent, mouseOutEvent] = handlers;
|
|
67723
|
+
element.removeEventListener("click", clickEvent);
|
|
67724
|
+
element.removeEventListener("mouseover", mouseOverEvent);
|
|
67725
|
+
element.removeEventListener("mouseout", mouseOutEvent);
|
|
66946
67726
|
});
|
|
66947
67727
|
}
|
|
66948
67728
|
};
|
|
66949
67729
|
|
|
66950
67730
|
// src/utils.ts
|
|
66951
|
-
function deepEqual(a2, b2, excludeKeys = ["
|
|
67731
|
+
function deepEqual(a2, b2, excludeKeys = ["mediaState"]) {
|
|
66952
67732
|
if (a2 === b2) return true;
|
|
66953
67733
|
if (typeof a2 !== "object" || a2 === null || typeof b2 !== "object" || b2 === null) return false;
|
|
66954
67734
|
if (a2.constructor !== b2.constructor) return false;
|
|
@@ -66981,14 +67761,10 @@ function arrayEqual(arr1, arr2) {
|
|
|
66981
67761
|
}
|
|
66982
67762
|
return true;
|
|
66983
67763
|
}
|
|
66984
|
-
async function delay2(time) {
|
|
66985
|
-
return new Promise((resolve) => setTimeout(resolve, time));
|
|
66986
|
-
}
|
|
66987
67764
|
|
|
66988
67765
|
// src/SlideApplication.ts
|
|
66989
|
-
var import_forge_room5 = require("@netless/forge-room");
|
|
66990
67766
|
var Slide_APP_NAME = "forge_slide";
|
|
66991
|
-
var SlideApplication = class extends
|
|
67767
|
+
var SlideApplication = class extends import_forge_room16.AbstractApplication {
|
|
66992
67768
|
static applicationName = Slide_APP_NAME;
|
|
66993
67769
|
name = Slide_APP_NAME;
|
|
66994
67770
|
emitter = new SlideForge();
|
|
@@ -67005,11 +67781,15 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67005
67781
|
currentSlideIndex = 0;
|
|
67006
67782
|
taskId = "";
|
|
67007
67783
|
prefix = "";
|
|
67784
|
+
slideCount = 0;
|
|
67785
|
+
lastDispatchUuid = "";
|
|
67786
|
+
syncMessageQueue = [];
|
|
67787
|
+
isSyncing = false;
|
|
67008
67788
|
constructor() {
|
|
67009
67789
|
super();
|
|
67010
67790
|
window.emitter = this.emitter;
|
|
67011
67791
|
this.rootView.setAttribute("data-forge-app", Slide_APP_NAME);
|
|
67012
|
-
this.rootView.style.background = "#
|
|
67792
|
+
this.rootView.style.background = "#f9f9fc";
|
|
67013
67793
|
this.rootView.style.overflow = "hidden";
|
|
67014
67794
|
this.contentContainer.style.width = "100%";
|
|
67015
67795
|
this.contentContainer.style.height = "100%";
|
|
@@ -67020,7 +67800,7 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67020
67800
|
this.footer = new FooterView();
|
|
67021
67801
|
this.sideBar = new SideBarView();
|
|
67022
67802
|
this.sideBar.on("pageChange", (index) => {
|
|
67023
|
-
if (index > 0 && index <= this.
|
|
67803
|
+
if (index > 0 && index <= this.slideCount) {
|
|
67024
67804
|
this.slide.renderSlide(index);
|
|
67025
67805
|
}
|
|
67026
67806
|
});
|
|
@@ -67062,7 +67842,7 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67062
67842
|
if (!this.permissions.hasPermission(2 /* changePage */)) {
|
|
67063
67843
|
return;
|
|
67064
67844
|
}
|
|
67065
|
-
if (this.currentSlideIndex < this.
|
|
67845
|
+
if (this.currentSlideIndex < this.slideCount) {
|
|
67066
67846
|
this.slide.renderSlide(this.currentSlideIndex + 1);
|
|
67067
67847
|
}
|
|
67068
67848
|
});
|
|
@@ -67070,10 +67850,10 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67070
67850
|
if (!this.permissions.hasPermission(2 /* changePage */)) {
|
|
67071
67851
|
return;
|
|
67072
67852
|
}
|
|
67073
|
-
if (this.sideBar.
|
|
67074
|
-
this.sideBar.
|
|
67853
|
+
if (this.sideBar.isShowSideBar) {
|
|
67854
|
+
this.sideBar.hidden();
|
|
67075
67855
|
} else {
|
|
67076
|
-
this.sideBar.
|
|
67856
|
+
this.sideBar.show();
|
|
67077
67857
|
}
|
|
67078
67858
|
});
|
|
67079
67859
|
this.rootView.appendChild(this.contentContainer);
|
|
@@ -67096,6 +67876,11 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67096
67876
|
return that.footer.root;
|
|
67097
67877
|
}
|
|
67098
67878
|
});
|
|
67879
|
+
Object.defineProperty(this.emitter, "sidebarView", {
|
|
67880
|
+
get() {
|
|
67881
|
+
return that.sideBar.root;
|
|
67882
|
+
}
|
|
67883
|
+
});
|
|
67099
67884
|
Object.defineProperty(this.emitter, "pageIndex", {
|
|
67100
67885
|
get() {
|
|
67101
67886
|
return that.currentSlideIndex;
|
|
@@ -67103,7 +67888,7 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67103
67888
|
});
|
|
67104
67889
|
Object.defineProperty(this.emitter, "pageCount", {
|
|
67105
67890
|
get() {
|
|
67106
|
-
return that.
|
|
67891
|
+
return that.slideCount;
|
|
67107
67892
|
}
|
|
67108
67893
|
});
|
|
67109
67894
|
Object.defineProperty(this.emitter, "goto", {
|
|
@@ -67169,37 +67954,22 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67169
67954
|
return this.getImageSize(pageIndex);
|
|
67170
67955
|
}
|
|
67171
67956
|
});
|
|
67957
|
+
this.applySlideState();
|
|
67172
67958
|
}
|
|
67173
|
-
|
|
67174
|
-
|
|
67175
|
-
|
|
67176
|
-
|
|
67177
|
-
|
|
67178
|
-
reader.onloadend = () => {
|
|
67179
|
-
const base64Data = reader.result;
|
|
67180
|
-
const img = document.createElement("img");
|
|
67181
|
-
img.src = base64Data;
|
|
67182
|
-
img.onload = () => {
|
|
67183
|
-
resolve({
|
|
67184
|
-
url: imageUrl,
|
|
67185
|
-
src: base64Data,
|
|
67186
|
-
width: img.width,
|
|
67187
|
-
height: img.height
|
|
67188
|
-
});
|
|
67189
|
-
};
|
|
67190
|
-
};
|
|
67191
|
-
reader.readAsDataURL(blob);
|
|
67192
|
-
});
|
|
67193
|
-
});
|
|
67959
|
+
getPreviewImageUrl(pageIndex) {
|
|
67960
|
+
if (pageIndex < 1 || pageIndex > this.slideCount) {
|
|
67961
|
+
throw new Error("pageIndex out of range");
|
|
67962
|
+
}
|
|
67963
|
+
return `${this.prefix}/${this.taskId}/preview/${pageIndex}.png`;
|
|
67194
67964
|
}
|
|
67195
67965
|
async getImageUrl(pageIndex) {
|
|
67196
|
-
return
|
|
67966
|
+
return this.getPreviewImageUrl(pageIndex);
|
|
67197
67967
|
}
|
|
67198
67968
|
async getImageSize(pageIndex) {
|
|
67199
|
-
const imageUrl =
|
|
67969
|
+
const imageUrl = this.getPreviewImageUrl(pageIndex);
|
|
67200
67970
|
let preview = null;
|
|
67201
67971
|
try {
|
|
67202
|
-
const result = await
|
|
67972
|
+
const result = await import_forge_room16.kvStore.getItem(imageUrl);
|
|
67203
67973
|
preview = result ? JSON.parse(result) : null;
|
|
67204
67974
|
} catch (e) {
|
|
67205
67975
|
console.warn("kvStore getItem error", e);
|
|
@@ -67207,15 +67977,15 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67207
67977
|
if (preview) {
|
|
67208
67978
|
return { width: preview.width, height: preview.height };
|
|
67209
67979
|
}
|
|
67210
|
-
preview = await this.getPreviewImage(imageUrl);
|
|
67211
|
-
await
|
|
67980
|
+
preview = await this.sideBar.getPreviewImage(imageUrl);
|
|
67981
|
+
await import_forge_room16.kvStore.setItem(imageUrl, JSON.stringify(preview));
|
|
67212
67982
|
return { width: preview.width, height: preview.height };
|
|
67213
67983
|
}
|
|
67214
67984
|
async getImageContent(pageIndex) {
|
|
67215
|
-
const imageUrl =
|
|
67985
|
+
const imageUrl = this.getPreviewImageUrl(pageIndex);
|
|
67216
67986
|
let preview = null;
|
|
67217
67987
|
try {
|
|
67218
|
-
const result = await
|
|
67988
|
+
const result = await import_forge_room16.kvStore.getItem(imageUrl);
|
|
67219
67989
|
preview = result ? JSON.parse(result) : null;
|
|
67220
67990
|
} catch (e) {
|
|
67221
67991
|
console.warn("kvStore getItem error", e);
|
|
@@ -67223,43 +67993,96 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67223
67993
|
if (preview) {
|
|
67224
67994
|
return preview.src;
|
|
67225
67995
|
}
|
|
67226
|
-
preview = await this.getPreviewImage(imageUrl);
|
|
67227
|
-
await
|
|
67996
|
+
preview = await this.sideBar.getPreviewImage(imageUrl);
|
|
67997
|
+
await import_forge_room16.kvStore.setItem(imageUrl, JSON.stringify(preview));
|
|
67228
67998
|
return preview.src;
|
|
67229
67999
|
}
|
|
67230
|
-
|
|
67231
|
-
|
|
67232
|
-
|
|
68000
|
+
nextTick = () => {
|
|
68001
|
+
this.isSyncing = false;
|
|
68002
|
+
requestAnimationFrame(() => {
|
|
68003
|
+
this.applySlideState().catch((error) => {
|
|
68004
|
+
console.error("Error in applySlideState:", error);
|
|
68005
|
+
});
|
|
68006
|
+
});
|
|
68007
|
+
};
|
|
68008
|
+
applySlideState = async () => {
|
|
68009
|
+
if (this.isSyncing) {
|
|
67233
68010
|
return;
|
|
67234
68011
|
}
|
|
67235
|
-
|
|
67236
|
-
|
|
68012
|
+
const lastSyncMessage = this.syncMessageQueue.pop();
|
|
68013
|
+
if (!lastSyncMessage) {
|
|
68014
|
+
return this.nextTick();
|
|
68015
|
+
}
|
|
68016
|
+
this.syncMessageQueue = [];
|
|
68017
|
+
this.isSyncing = true;
|
|
68018
|
+
const { state, dispatch } = lastSyncMessage;
|
|
68019
|
+
let ignoreKeys = void 0;
|
|
68020
|
+
if (dispatch.type === "mediaPlay" || dispatch.type === "mediaPause" || dispatch.type === "mediaFullscreen") {
|
|
68021
|
+
ignoreKeys = [dispatch.id];
|
|
68022
|
+
}
|
|
68023
|
+
if (this.slide.slideState.currentSlideIndex < 0 || state.currentSlideIndex < 0) {
|
|
68024
|
+
await this.slide.receiveSyncHandler(dispatch);
|
|
68025
|
+
return this.nextTick();
|
|
68026
|
+
} else if (!deepEqual(this.slide.slideState, state, ignoreKeys)) {
|
|
68027
|
+
await this.slide.setSlideState(state);
|
|
68028
|
+
await this.slide.receiveSyncHandler(dispatch);
|
|
67237
68029
|
} else {
|
|
67238
|
-
|
|
67239
|
-
await delay2(200);
|
|
67240
|
-
this.slide.emit(import_slide.SLIDE_EVENTS.syncReceive, lastDispatch);
|
|
68030
|
+
this.slide.emit(import_slide.SLIDE_EVENTS.syncReceive, dispatch);
|
|
67241
68031
|
}
|
|
68032
|
+
return this.nextTick();
|
|
67242
68033
|
};
|
|
67243
68034
|
onSlideEventHandler = async (event) => {
|
|
67244
68035
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
67245
68036
|
if (key === "syncSlide") {
|
|
67246
68037
|
if (value.action === "add" || value.action === "update") {
|
|
67247
68038
|
const { slideState: slideStateFromServer, dispatch: dispatchFromServer } = this.getMap(this.name).get("syncSlide");
|
|
67248
|
-
this.
|
|
68039
|
+
if (this.lastDispatchUuid === dispatchFromServer.uuid) {
|
|
68040
|
+
return;
|
|
68041
|
+
}
|
|
68042
|
+
this.lastDispatchUuid = dispatchFromServer.uuid;
|
|
68043
|
+
this.syncMessageQueue.push({
|
|
68044
|
+
state: slideStateFromServer,
|
|
68045
|
+
dispatch: dispatchFromServer
|
|
68046
|
+
});
|
|
68047
|
+
this.applySlideState();
|
|
67249
68048
|
}
|
|
67250
68049
|
}
|
|
67251
68050
|
}
|
|
67252
68051
|
};
|
|
68052
|
+
keyBoardEvents = (event) => {
|
|
68053
|
+
if (event.key === "ArrowLeft") {
|
|
68054
|
+
this.footer.emit("prevStep");
|
|
68055
|
+
} else if (event.key === "ArrowRight") {
|
|
68056
|
+
this.footer.emit("nextStep");
|
|
68057
|
+
} else if (event.key === "ArrowUp") {
|
|
68058
|
+
this.footer.emit("prevPage");
|
|
68059
|
+
} else if (event.key === "ArrowDown") {
|
|
68060
|
+
this.footer.emit("nextPage");
|
|
68061
|
+
}
|
|
68062
|
+
};
|
|
68063
|
+
bindKeyBoardEvent() {
|
|
68064
|
+
document.addEventListener("keydown", this.keyBoardEvents);
|
|
68065
|
+
}
|
|
68066
|
+
unbindKeyBoardEvent() {
|
|
68067
|
+
document.removeEventListener("keydown", this.keyBoardEvents);
|
|
68068
|
+
}
|
|
68069
|
+
async onFocusInstance() {
|
|
68070
|
+
this.bindKeyBoardEvent();
|
|
68071
|
+
}
|
|
68072
|
+
onRefocusInstance() {
|
|
68073
|
+
this.unbindKeyBoardEvent();
|
|
68074
|
+
}
|
|
67253
68075
|
async initialize(option) {
|
|
67254
68076
|
this.prefix = option.prefix;
|
|
67255
68077
|
this.taskId = option.taskId;
|
|
67256
68078
|
const whiteboardApp = new WhiteboardApplication();
|
|
67257
|
-
whiteboardApp.
|
|
67258
|
-
whiteboardApp.appId = `${
|
|
68079
|
+
whiteboardApp.appDoc = this.appDoc;
|
|
68080
|
+
whiteboardApp.appId = `${this.appId}_wb`;
|
|
67259
68081
|
whiteboardApp.userId = this.userId;
|
|
67260
68082
|
whiteboardApp.userManager = this.userManager;
|
|
67261
|
-
whiteboardApp.
|
|
68083
|
+
whiteboardApp.deleteSubDoc = this.deleteSubDoc;
|
|
67262
68084
|
const json = await fetch(`${option.prefix}/${option.taskId}/jsonOutput/slide-1.json`).then((res) => res.json());
|
|
68085
|
+
this.slideCount = json.slideCount;
|
|
67263
68086
|
await whiteboardApp.initialize({
|
|
67264
68087
|
width: json.width,
|
|
67265
68088
|
height: json.height
|
|
@@ -67274,11 +68097,13 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67274
68097
|
this.whiteboard.view.style.top = "0";
|
|
67275
68098
|
this.whiteboard.view.style.left = "0";
|
|
67276
68099
|
this.whiteboard.view.style.zIndex = "4";
|
|
68100
|
+
this.whiteboard.view.classList.add("slide-whiteboard");
|
|
67277
68101
|
this.whiteboard.permissions.addPermission(WhiteboardPermissionFlag.all);
|
|
67278
68102
|
this.whiteboard.setCanvasBackgroundColor("#f0f0f000");
|
|
67279
68103
|
this.whiteboardContainer.style.position = "relative";
|
|
67280
68104
|
this.whiteboardContainer.style.flex = "0 0 auto";
|
|
67281
68105
|
this.whiteboardContainer.style.height = "calc(100% - 24px)";
|
|
68106
|
+
this.whiteboardContainer.classList.add("forge-slide-whiteboard-container");
|
|
67282
68107
|
this.whiteboardContainer.appendChild(this.whiteboard.view);
|
|
67283
68108
|
this.whiteboardContainer.appendChild(this.slideContainer);
|
|
67284
68109
|
this.contentContainer.appendChild(this.whiteboardContainer);
|
|
@@ -67293,7 +68118,13 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67293
68118
|
...option.options,
|
|
67294
68119
|
interactive: true,
|
|
67295
68120
|
anchor: this.slideContainer,
|
|
67296
|
-
mode: "interactive"
|
|
68121
|
+
mode: "interactive",
|
|
68122
|
+
clientId: Math.random().toString(36).substring(2, 15),
|
|
68123
|
+
timestamp: () => {
|
|
68124
|
+
console.log("timestamp");
|
|
68125
|
+
console.log(Date.now, this.calibrationTimestamp, Date.now() - this.calibrationTimestamp);
|
|
68126
|
+
return this.calibrationTimestamp;
|
|
68127
|
+
}
|
|
67297
68128
|
// logger: {
|
|
67298
68129
|
// info: console.log,
|
|
67299
68130
|
// warn: console.warn,
|
|
@@ -67302,39 +68133,54 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67302
68133
|
});
|
|
67303
68134
|
this.slide.setResource(option.taskId, option.prefix);
|
|
67304
68135
|
this.sideBar.initialize(json.slideCount, option);
|
|
67305
|
-
this.slide.on(
|
|
68136
|
+
this.slide.on(import_slide.SLIDE_EVENTS.syncDispatch, (event) => {
|
|
67306
68137
|
this.getMap(this.name).set("syncSlide", {
|
|
67307
68138
|
slideState: this.slide.slideState,
|
|
67308
68139
|
dispatch: event
|
|
67309
68140
|
});
|
|
67310
68141
|
});
|
|
67311
|
-
this.slide.on(
|
|
68142
|
+
this.slide.on(import_slide.SLIDE_EVENTS.mainSeqStepStart, (animateIndex) => {
|
|
67312
68143
|
this.emitter.emit("mainSeqStepStart", animateIndex);
|
|
67313
68144
|
});
|
|
67314
|
-
this.slide.on(
|
|
68145
|
+
this.slide.on(import_slide.SLIDE_EVENTS.mainSeqStepEnd, (animateIndex) => {
|
|
67315
68146
|
this.emitter.emit("mainSeqStepEnd", animateIndex);
|
|
67316
68147
|
});
|
|
67317
|
-
this.slide.on(
|
|
67318
|
-
|
|
67319
|
-
|
|
67320
|
-
|
|
67321
|
-
this.emitter.emit("renderStart", slideIndex);
|
|
68148
|
+
this.slide.on(import_slide.SLIDE_EVENTS.renderError, ({ error, index }) => {
|
|
68149
|
+
if (error.errorType === "CANVAS_CRASH") {
|
|
68150
|
+
this.slide.renderSlide(index);
|
|
68151
|
+
}
|
|
67322
68152
|
});
|
|
67323
|
-
this.slide.on(
|
|
67324
|
-
|
|
67325
|
-
|
|
67326
|
-
|
|
68153
|
+
this.slide.on(import_slide.SLIDE_EVENTS.renderStart, (slideIndex) => {
|
|
68154
|
+
if (slideIndex >= 0) {
|
|
68155
|
+
this.sideBar.pauseGetPreviewImageSchedule();
|
|
68156
|
+
this.whiteboardApp.emitter.view.style.opacity = "0";
|
|
68157
|
+
this.whiteboardApp.emitter.addPage(`${slideIndex}`);
|
|
68158
|
+
this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
|
|
68159
|
+
this.sideBar.hidden();
|
|
68160
|
+
this.emitter.emit("renderStart", slideIndex);
|
|
68161
|
+
}
|
|
68162
|
+
});
|
|
68163
|
+
this.slide.on(import_slide.SLIDE_EVENTS.renderEnd, (slideIndex) => {
|
|
68164
|
+
if (slideIndex >= 0) {
|
|
68165
|
+
this.sideBar.startGetPreviewImageSchedule();
|
|
68166
|
+
this.currentSlideIndex = slideIndex;
|
|
68167
|
+
this.whiteboardApp.emitter.view.style.opacity = "1";
|
|
68168
|
+
this.emitter.emit("renderEnd", slideIndex);
|
|
68169
|
+
}
|
|
67327
68170
|
});
|
|
67328
|
-
this.slide.on(
|
|
68171
|
+
this.slide.on(import_slide.SLIDE_EVENTS.stateChange, (state) => {
|
|
67329
68172
|
this.getMap(this.name).set("slideState", state);
|
|
67330
68173
|
});
|
|
67331
68174
|
this.getMap(this.name).observe(this.onSlideEventHandler);
|
|
67332
68175
|
window.slide = this.slide;
|
|
67333
68176
|
window.slideWhiteboard = this.whiteboardApp;
|
|
67334
68177
|
window.forgeSlide = this;
|
|
68178
|
+
this.whiteboardContainer.addEventListener("click", () => {
|
|
68179
|
+
this.sideBar.hidden();
|
|
68180
|
+
}, false);
|
|
67335
68181
|
const syncSlide = this.getMap(this.name).get("slideState");
|
|
67336
68182
|
if (syncSlide && syncSlide.taskId === option.taskId) {
|
|
67337
|
-
|
|
68183
|
+
this.slide.setSlideState(syncSlide);
|
|
67338
68184
|
} else {
|
|
67339
68185
|
this.slide.renderSlide(1);
|
|
67340
68186
|
}
|
|
@@ -67351,8 +68197,32 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67351
68197
|
}
|
|
67352
68198
|
}
|
|
67353
68199
|
});
|
|
67354
|
-
this.permissions.
|
|
68200
|
+
this.permissions.setPermission(7 /* all */);
|
|
67355
68201
|
this.whiteboardApp.disableViewModel();
|
|
68202
|
+
if (this.window) {
|
|
68203
|
+
let prevStatus = "normal";
|
|
68204
|
+
this.window.on("statusChange", (status) => {
|
|
68205
|
+
if (prevStatus === "minimized") {
|
|
68206
|
+
this.onFocusInstance();
|
|
68207
|
+
prevStatus = status;
|
|
68208
|
+
return;
|
|
68209
|
+
}
|
|
68210
|
+
prevStatus = status;
|
|
68211
|
+
if (status === "normal") {
|
|
68212
|
+
this.onFocusInstance();
|
|
68213
|
+
} else if (status === "minimized") {
|
|
68214
|
+
this.onRefocusInstance();
|
|
68215
|
+
}
|
|
68216
|
+
});
|
|
68217
|
+
this.window.on("focusedChange", (status) => {
|
|
68218
|
+
if (status) {
|
|
68219
|
+
this.onFocusInstance();
|
|
68220
|
+
} else {
|
|
68221
|
+
this.onRefocusInstance();
|
|
68222
|
+
}
|
|
68223
|
+
});
|
|
68224
|
+
this.bindKeyBoardEvent();
|
|
68225
|
+
}
|
|
67356
68226
|
window.__forge_slide = this;
|
|
67357
68227
|
window.slidePermissions = this.permissions;
|
|
67358
68228
|
return Promise.resolve(void 0);
|
|
@@ -67360,13 +68230,17 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67360
68230
|
userMap(userId) {
|
|
67361
68231
|
return this.getMap(`user/${userId}`);
|
|
67362
68232
|
}
|
|
67363
|
-
async dispose() {
|
|
67364
|
-
|
|
68233
|
+
async dispose(removeSubDoc) {
|
|
68234
|
+
if (removeSubDoc) {
|
|
68235
|
+
this.deleteSubDoc(this.appId);
|
|
68236
|
+
}
|
|
68237
|
+
await this.whiteboardApp.dispose(removeSubDoc);
|
|
67365
68238
|
this.rootView.parentElement?.removeChild(this.rootView);
|
|
67366
68239
|
this.slide.destroy();
|
|
67367
68240
|
this.sideBar.dispose();
|
|
67368
68241
|
this.getMap(this.name).unobserve(this.onSlideEventHandler);
|
|
67369
|
-
|
|
68242
|
+
this.permissions.dispose();
|
|
68243
|
+
this.footer.dispose();
|
|
67370
68244
|
}
|
|
67371
68245
|
};
|
|
67372
68246
|
/*! Bundled license information:
|