@netless/forge-whiteboard 1.2.0-alpha.1 → 1.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +13 -1
- package/dist/LiveCursor.d.ts +2 -1
- package/dist/LiveCursor.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +10 -0
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +6 -0
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/edit/Editor.d.ts.map +1 -1
- package/dist/model/RenderableModel.d.ts +15 -1
- package/dist/model/RenderableModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +6 -3
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- package/dist/model/renderable/ElementModel.d.ts +20 -1
- package/dist/model/renderable/ElementModel.d.ts.map +1 -1
- package/dist/model/renderable/EraserModel.d.ts +5 -1
- package/dist/model/renderable/EraserModel.d.ts.map +1 -1
- package/dist/model/renderable/ImageModel.d.ts +4 -1
- package/dist/model/renderable/ImageModel.d.ts.map +1 -1
- package/dist/model/renderable/LaserPointerModel.d.ts +8 -2
- package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
- package/dist/model/renderable/LineModel.d.ts +5 -1
- package/dist/model/renderable/LineModel.d.ts.map +1 -1
- package/dist/model/renderable/PointTextModel.d.ts +6 -1
- package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
- package/dist/model/renderable/RectangleModel.d.ts +5 -1
- package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
- package/dist/model/renderable/SegmentsModel.d.ts +5 -1
- package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
- package/dist/model/renderable/SelectorModel.d.ts +5 -1
- package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
- package/dist/model/renderable/StraightLineModel.d.ts +5 -1
- package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
- package/dist/model/renderable/TriangleModel.d.ts +5 -1
- package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +3 -0
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/LaserPointerTool.d.ts.map +1 -1
- package/dist/tool/WhiteboardTool.d.ts +4 -0
- package/dist/tool/WhiteboardTool.d.ts.map +1 -1
- package/dist/utils/paperjs.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +794 -278
- package/dist/whiteboard.esm.js.map +3 -3
- package/dist/whiteboard.js +830 -314
- package/dist/whiteboard.js.map +3 -3
- package/package.json +2 -2
package/dist/whiteboard.esm.js
CHANGED
|
@@ -20839,8 +20839,8 @@ var require_lodash = __commonJS({
|
|
|
20839
20839
|
}
|
|
20840
20840
|
var runInContext = function runInContext2(context) {
|
|
20841
20841
|
context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
|
|
20842
|
-
var
|
|
20843
|
-
var arrayProto =
|
|
20842
|
+
var Array14 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
|
|
20843
|
+
var arrayProto = Array14.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
|
|
20844
20844
|
var coreJsData = context["__core-js_shared__"];
|
|
20845
20845
|
var funcToString = funcProto.toString;
|
|
20846
20846
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
@@ -21263,7 +21263,7 @@ var require_lodash = __commonJS({
|
|
|
21263
21263
|
}
|
|
21264
21264
|
}
|
|
21265
21265
|
function baseAt(object, paths) {
|
|
21266
|
-
var index = -1, length = paths.length, result2 =
|
|
21266
|
+
var index = -1, length = paths.length, result2 = Array14(length), skip = object == null;
|
|
21267
21267
|
while (++index < length) {
|
|
21268
21268
|
result2[index] = skip ? undefined2 : get(object, paths[index]);
|
|
21269
21269
|
}
|
|
@@ -21509,7 +21509,7 @@ var require_lodash = __commonJS({
|
|
|
21509
21509
|
return number >= nativeMin(start, end) && number < nativeMax(start, end);
|
|
21510
21510
|
}
|
|
21511
21511
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
21512
|
-
var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches =
|
|
21512
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array14(othLength), maxLength = Infinity, result2 = [];
|
|
21513
21513
|
while (othIndex--) {
|
|
21514
21514
|
var array = arrays[othIndex];
|
|
21515
21515
|
if (othIndex && iteratee2) {
|
|
@@ -21690,7 +21690,7 @@ var require_lodash = __commonJS({
|
|
|
21690
21690
|
return value < other;
|
|
21691
21691
|
}
|
|
21692
21692
|
function baseMap(collection, iteratee2) {
|
|
21693
|
-
var index = -1, result2 = isArrayLike(collection) ?
|
|
21693
|
+
var index = -1, result2 = isArrayLike(collection) ? Array14(collection.length) : [];
|
|
21694
21694
|
baseEach(collection, function(value, key, collection2) {
|
|
21695
21695
|
result2[++index] = iteratee2(value, key, collection2);
|
|
21696
21696
|
});
|
|
@@ -21865,7 +21865,7 @@ var require_lodash = __commonJS({
|
|
|
21865
21865
|
return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
|
|
21866
21866
|
}
|
|
21867
21867
|
function baseRange(start, end, step, fromRight) {
|
|
21868
|
-
var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 =
|
|
21868
|
+
var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array14(length);
|
|
21869
21869
|
while (length--) {
|
|
21870
21870
|
result2[fromRight ? length : ++index] = start;
|
|
21871
21871
|
start += step;
|
|
@@ -21947,7 +21947,7 @@ var require_lodash = __commonJS({
|
|
|
21947
21947
|
}
|
|
21948
21948
|
length = start > end ? 0 : end - start >>> 0;
|
|
21949
21949
|
start >>>= 0;
|
|
21950
|
-
var result2 =
|
|
21950
|
+
var result2 = Array14(length);
|
|
21951
21951
|
while (++index < length) {
|
|
21952
21952
|
result2[index] = array[index + start];
|
|
21953
21953
|
}
|
|
@@ -22107,7 +22107,7 @@ var require_lodash = __commonJS({
|
|
|
22107
22107
|
if (length < 2) {
|
|
22108
22108
|
return length ? baseUniq(arrays[0]) : [];
|
|
22109
22109
|
}
|
|
22110
|
-
var index = -1, result2 =
|
|
22110
|
+
var index = -1, result2 = Array14(length);
|
|
22111
22111
|
while (++index < length) {
|
|
22112
22112
|
var array = arrays[index], othIndex = -1;
|
|
22113
22113
|
while (++othIndex < length) {
|
|
@@ -22204,7 +22204,7 @@ var require_lodash = __commonJS({
|
|
|
22204
22204
|
return object.index - other.index;
|
|
22205
22205
|
}
|
|
22206
22206
|
function composeArgs(args, partials, holders, isCurried) {
|
|
22207
|
-
var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 =
|
|
22207
|
+
var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array14(leftLength + rangeLength), isUncurried = !isCurried;
|
|
22208
22208
|
while (++leftIndex < leftLength) {
|
|
22209
22209
|
result2[leftIndex] = partials[leftIndex];
|
|
22210
22210
|
}
|
|
@@ -22219,7 +22219,7 @@ var require_lodash = __commonJS({
|
|
|
22219
22219
|
return result2;
|
|
22220
22220
|
}
|
|
22221
22221
|
function composeArgsRight(args, partials, holders, isCurried) {
|
|
22222
|
-
var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 =
|
|
22222
|
+
var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array14(rangeLength + rightLength), isUncurried = !isCurried;
|
|
22223
22223
|
while (++argsIndex < rangeLength) {
|
|
22224
22224
|
result2[argsIndex] = args[argsIndex];
|
|
22225
22225
|
}
|
|
@@ -22236,7 +22236,7 @@ var require_lodash = __commonJS({
|
|
|
22236
22236
|
}
|
|
22237
22237
|
function copyArray(source, array) {
|
|
22238
22238
|
var index = -1, length = source.length;
|
|
22239
|
-
array || (array =
|
|
22239
|
+
array || (array = Array14(length));
|
|
22240
22240
|
while (++index < length) {
|
|
22241
22241
|
array[index] = source[index];
|
|
22242
22242
|
}
|
|
@@ -22369,7 +22369,7 @@ var require_lodash = __commonJS({
|
|
|
22369
22369
|
function createCurry(func, bitmask, arity) {
|
|
22370
22370
|
var Ctor = createCtor(func);
|
|
22371
22371
|
function wrapper() {
|
|
22372
|
-
var length = arguments.length, args =
|
|
22372
|
+
var length = arguments.length, args = Array14(length), index = length, placeholder = getHolder(wrapper);
|
|
22373
22373
|
while (index--) {
|
|
22374
22374
|
args[index] = arguments[index];
|
|
22375
22375
|
}
|
|
@@ -22449,7 +22449,7 @@ var require_lodash = __commonJS({
|
|
|
22449
22449
|
function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
|
|
22450
22450
|
var isAry = bitmask & WRAP_ARY_FLAG, isBind = bitmask & WRAP_BIND_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG, isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), isFlip = bitmask & WRAP_FLIP_FLAG, Ctor = isBindKey ? undefined2 : createCtor(func);
|
|
22451
22451
|
function wrapper() {
|
|
22452
|
-
var length = arguments.length, args =
|
|
22452
|
+
var length = arguments.length, args = Array14(length), index = length;
|
|
22453
22453
|
while (index--) {
|
|
22454
22454
|
args[index] = arguments[index];
|
|
22455
22455
|
}
|
|
@@ -22548,7 +22548,7 @@ var require_lodash = __commonJS({
|
|
|
22548
22548
|
function createPartial(func, bitmask, thisArg, partials) {
|
|
22549
22549
|
var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
|
|
22550
22550
|
function wrapper() {
|
|
22551
|
-
var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args =
|
|
22551
|
+
var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array14(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
|
|
22552
22552
|
while (++leftIndex < leftLength) {
|
|
22553
22553
|
args[leftIndex] = partials[leftIndex];
|
|
22554
22554
|
}
|
|
@@ -23161,12 +23161,12 @@ var require_lodash = __commonJS({
|
|
|
23161
23161
|
function overRest(func, start, transform2) {
|
|
23162
23162
|
start = nativeMax(start === undefined2 ? func.length - 1 : start, 0);
|
|
23163
23163
|
return function() {
|
|
23164
|
-
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array =
|
|
23164
|
+
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array14(length);
|
|
23165
23165
|
while (++index < length) {
|
|
23166
23166
|
array[index] = args[start + index];
|
|
23167
23167
|
}
|
|
23168
23168
|
index = -1;
|
|
23169
|
-
var otherArgs =
|
|
23169
|
+
var otherArgs = Array14(start + 1);
|
|
23170
23170
|
while (++index < start) {
|
|
23171
23171
|
otherArgs[index] = args[index];
|
|
23172
23172
|
}
|
|
@@ -23278,7 +23278,7 @@ var require_lodash = __commonJS({
|
|
|
23278
23278
|
result2.__values__ = wrapper.__values__;
|
|
23279
23279
|
return result2;
|
|
23280
23280
|
}
|
|
23281
|
-
function
|
|
23281
|
+
function chunk7(array, size2, guard) {
|
|
23282
23282
|
if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
|
|
23283
23283
|
size2 = 1;
|
|
23284
23284
|
} else {
|
|
@@ -23288,7 +23288,7 @@ var require_lodash = __commonJS({
|
|
|
23288
23288
|
if (!length || size2 < 1) {
|
|
23289
23289
|
return [];
|
|
23290
23290
|
}
|
|
23291
|
-
var index = 0, resIndex = 0, result2 =
|
|
23291
|
+
var index = 0, resIndex = 0, result2 = Array14(nativeCeil(length / size2));
|
|
23292
23292
|
while (index < length) {
|
|
23293
23293
|
result2[resIndex++] = baseSlice(array, index, index += size2);
|
|
23294
23294
|
}
|
|
@@ -23309,7 +23309,7 @@ var require_lodash = __commonJS({
|
|
|
23309
23309
|
if (!length) {
|
|
23310
23310
|
return [];
|
|
23311
23311
|
}
|
|
23312
|
-
var args =
|
|
23312
|
+
var args = Array14(length - 1), array = arguments[0], index = length;
|
|
23313
23313
|
while (index--) {
|
|
23314
23314
|
args[index - 1] = arguments[index];
|
|
23315
23315
|
}
|
|
@@ -23811,7 +23811,7 @@ var require_lodash = __commonJS({
|
|
|
23811
23811
|
return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
|
|
23812
23812
|
}
|
|
23813
23813
|
var invokeMap = baseRest(function(collection, path, args) {
|
|
23814
|
-
var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ?
|
|
23814
|
+
var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array14(collection.length) : [];
|
|
23815
23815
|
baseEach(collection, function(value) {
|
|
23816
23816
|
result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
|
|
23817
23817
|
});
|
|
@@ -24194,7 +24194,7 @@ var require_lodash = __commonJS({
|
|
|
24194
24194
|
}()) ? baseIsArguments : function(value) {
|
|
24195
24195
|
return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
24196
24196
|
};
|
|
24197
|
-
var isArray =
|
|
24197
|
+
var isArray = Array14.isArray;
|
|
24198
24198
|
var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
|
|
24199
24199
|
function isArrayLike(value) {
|
|
24200
24200
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
@@ -25150,7 +25150,7 @@ var require_lodash = __commonJS({
|
|
|
25150
25150
|
lodash.bindKey = bindKey;
|
|
25151
25151
|
lodash.castArray = castArray;
|
|
25152
25152
|
lodash.chain = chain;
|
|
25153
|
-
lodash.chunk =
|
|
25153
|
+
lodash.chunk = chunk7;
|
|
25154
25154
|
lodash.compact = compact;
|
|
25155
25155
|
lodash.concat = concat;
|
|
25156
25156
|
lodash.cond = cond;
|
|
@@ -25637,7 +25637,7 @@ import * as Y15 from "yjs";
|
|
|
25637
25637
|
import * as Y12 from "yjs";
|
|
25638
25638
|
import EventEmitter from "eventemitter3";
|
|
25639
25639
|
import { v4 as uuidv4 } from "uuid";
|
|
25640
|
-
import { log, removeObserver as
|
|
25640
|
+
import { log, removeObserver as removeObserver3 } from "@netless/forge-room";
|
|
25641
25641
|
|
|
25642
25642
|
// src/model/renderable/CurveModel.ts
|
|
25643
25643
|
import * as Y2 from "yjs";
|
|
@@ -25790,9 +25790,6 @@ function ae(e, t = {}) {
|
|
|
25790
25790
|
return ce(me(e, t), t);
|
|
25791
25791
|
}
|
|
25792
25792
|
|
|
25793
|
-
// src/model/renderable/CurveModel.ts
|
|
25794
|
-
var import_lodash = __toESM(require_lodash(), 1);
|
|
25795
|
-
|
|
25796
25793
|
// src/model/renderable/ElementModel.ts
|
|
25797
25794
|
import * as Y from "yjs";
|
|
25798
25795
|
import { removeDeepObserver } from "@netless/forge-room";
|
|
@@ -25880,12 +25877,23 @@ var ElementModel = class _ElementModel {
|
|
|
25880
25877
|
set shadow(value) {
|
|
25881
25878
|
this.root.set(_ElementModel.KEYS.shadow, value);
|
|
25882
25879
|
}
|
|
25883
|
-
|
|
25880
|
+
get isPerformanceEnvironment() {
|
|
25881
|
+
return this.isPerformanceMode() && this.shouldUseLocalPoints;
|
|
25882
|
+
}
|
|
25883
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
25884
25884
|
_defineProperty(this, "shadowEmitter", null);
|
|
25885
25885
|
_defineProperty(this, "root", void 0);
|
|
25886
25886
|
_defineProperty(this, "scope", void 0);
|
|
25887
25887
|
_defineProperty(this, "item", void 0);
|
|
25888
|
+
_defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
|
|
25889
|
+
_defineProperty(this, "shouldUseLocalPoints", void 0);
|
|
25890
|
+
_defineProperty(this, "localPointsPick", void 0);
|
|
25888
25891
|
_defineProperty(this, "liveCursor", void 0);
|
|
25892
|
+
_defineProperty(this, "appendPointsTimer", null);
|
|
25893
|
+
_defineProperty(this, "setPointsTimer", null);
|
|
25894
|
+
_defineProperty(this, "pointsUpdateTimer", null);
|
|
25895
|
+
_defineProperty(this, "isPerformanceMode", void 0);
|
|
25896
|
+
_defineProperty(this, "localPoints", []);
|
|
25889
25897
|
_defineProperty(this, "handlePropChange", (events) => {
|
|
25890
25898
|
if (!this.item) {
|
|
25891
25899
|
return;
|
|
@@ -25924,23 +25932,80 @@ var ElementModel = class _ElementModel {
|
|
|
25924
25932
|
}
|
|
25925
25933
|
}
|
|
25926
25934
|
} else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
|
|
25927
|
-
this.
|
|
25928
|
-
|
|
25929
|
-
|
|
25930
|
-
|
|
25931
|
-
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25935
|
+
if (this.isPerformanceEnvironment) {
|
|
25936
|
+
this.handlePointsChangePerformance();
|
|
25937
|
+
} else {
|
|
25938
|
+
this.handlePointsChangeDirect();
|
|
25932
25939
|
}
|
|
25933
25940
|
} else {
|
|
25934
25941
|
}
|
|
25935
25942
|
}
|
|
25936
25943
|
});
|
|
25944
|
+
_defineProperty(this, "onPointsArrayChange", (points) => {
|
|
25945
|
+
if (this.localPoints.length >= points.length) {
|
|
25946
|
+
return;
|
|
25947
|
+
}
|
|
25948
|
+
const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
|
|
25949
|
+
this.localPoints = this.localPoints.concat(pointsChunk);
|
|
25950
|
+
this.onVectorUpdate();
|
|
25951
|
+
this.pointsUpdateTimer = window.requestAnimationFrame(() => {
|
|
25952
|
+
this.onPointsArrayChange(points);
|
|
25953
|
+
});
|
|
25954
|
+
});
|
|
25955
|
+
this.isPerformanceMode = isPerformanceMode;
|
|
25937
25956
|
this.scope = scope;
|
|
25938
25957
|
this.liveCursor = liveCursor;
|
|
25939
25958
|
this.root = root;
|
|
25940
|
-
if (
|
|
25959
|
+
if (this.root.doc) {
|
|
25960
|
+
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25961
|
+
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25962
|
+
}
|
|
25963
|
+
} else {
|
|
25941
25964
|
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25942
25965
|
}
|
|
25966
|
+
}
|
|
25967
|
+
bindObserver() {
|
|
25968
|
+
const beforeL = this.root._eH?.l?.length ?? -1;
|
|
25969
|
+
const beforeDL = this.root._dEH?.l?.length ?? -1;
|
|
25970
|
+
removeDeepObserver(this.root, this.handlePropChange);
|
|
25971
|
+
this.subBindObserver();
|
|
25972
|
+
const afterRemoveL = this.root._eH?.l?.length ?? -1;
|
|
25973
|
+
const afterRemoveDL = this.root._dEH?.l?.length ?? -1;
|
|
25943
25974
|
this.root.observeDeep(this.handlePropChange);
|
|
25975
|
+
const afterAddL = this.root._eH?.l?.length ?? -1;
|
|
25976
|
+
const afterAddDL = this.root._dEH?.l?.length ?? -1;
|
|
25977
|
+
console.log(`[][][] bindObserver uuid=${this.uuid} doc=${!!this.root.doc} _eH: ${beforeL}->${afterRemoveL}->${afterAddL} _dEH: ${beforeDL}->${afterRemoveDL}->${afterAddDL}`);
|
|
25978
|
+
}
|
|
25979
|
+
subBindObserver() {
|
|
25980
|
+
}
|
|
25981
|
+
handlePointsChangeDirect() {
|
|
25982
|
+
this.onVectorUpdate();
|
|
25983
|
+
const liveCursorPoint = this.liveCursorPoint();
|
|
25984
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25985
|
+
if (liveCursorPoint && ownerId) {
|
|
25986
|
+
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25987
|
+
}
|
|
25988
|
+
}
|
|
25989
|
+
handlePointsChangePerformance() {
|
|
25990
|
+
const liveCursorPoint = this.liveCursorPoint();
|
|
25991
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25992
|
+
if (liveCursorPoint && ownerId) {
|
|
25993
|
+
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25994
|
+
}
|
|
25995
|
+
if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
|
|
25996
|
+
if (this.pointsUpdateTimer) {
|
|
25997
|
+
window.cancelAnimationFrame(this.pointsUpdateTimer);
|
|
25998
|
+
}
|
|
25999
|
+
if (this.shadow == "") {
|
|
26000
|
+
this.localPoints = this.points;
|
|
26001
|
+
this.onVectorUpdate();
|
|
26002
|
+
} else {
|
|
26003
|
+
if (this.clearLocalPointsWhenYPointsChange) {
|
|
26004
|
+
this.localPoints = [];
|
|
26005
|
+
}
|
|
26006
|
+
this.onPointsArrayChange(this.points);
|
|
26007
|
+
}
|
|
26008
|
+
}
|
|
25944
26009
|
}
|
|
25945
26010
|
createPaperElement() {
|
|
25946
26011
|
this.createPaperItem();
|
|
@@ -25953,14 +26018,48 @@ var ElementModel = class _ElementModel {
|
|
|
25953
26018
|
}
|
|
25954
26019
|
}
|
|
25955
26020
|
appendPoints(points) {
|
|
26021
|
+
if (this.isPerformanceEnvironment) {
|
|
26022
|
+
this.appendPointsPerformance(points);
|
|
26023
|
+
} else {
|
|
26024
|
+
this.appendPointsDirect(points);
|
|
26025
|
+
}
|
|
26026
|
+
}
|
|
26027
|
+
appendPointsDirect(points) {
|
|
25956
26028
|
this.root.get(_ElementModel.KEYS.points).push(points);
|
|
25957
26029
|
}
|
|
26030
|
+
appendPointsPerformance(points) {
|
|
26031
|
+
this.localPoints = this.localPoints.concat(points);
|
|
26032
|
+
this.onVectorUpdate();
|
|
26033
|
+
if (this.appendPointsTimer) {
|
|
26034
|
+
window.clearTimeout(this.appendPointsTimer);
|
|
26035
|
+
}
|
|
26036
|
+
if (this.localPoints.length % 80 === 0) {
|
|
26037
|
+
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26038
|
+
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26039
|
+
}
|
|
26040
|
+
this.appendPointsTimer = window.setTimeout(() => {
|
|
26041
|
+
this.appendPointsTimer = null;
|
|
26042
|
+
if (this.localPoints.length > 0) {
|
|
26043
|
+
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26044
|
+
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26045
|
+
}
|
|
26046
|
+
}, 100);
|
|
26047
|
+
}
|
|
25958
26048
|
setPoints(points) {
|
|
26049
|
+
if (this.isPerformanceEnvironment) {
|
|
26050
|
+
this.setPointsPerformance(points);
|
|
26051
|
+
} else {
|
|
26052
|
+
this.setPointsDirect(points);
|
|
26053
|
+
}
|
|
26054
|
+
}
|
|
26055
|
+
setPointsDirect(points) {
|
|
25959
26056
|
if (this.root.doc) {
|
|
25960
26057
|
this.root.doc.transact(() => {
|
|
25961
26058
|
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
25962
|
-
|
|
25963
|
-
|
|
26059
|
+
if (yArray) {
|
|
26060
|
+
yArray.delete(0, yArray.length);
|
|
26061
|
+
yArray.push(points);
|
|
26062
|
+
}
|
|
25964
26063
|
});
|
|
25965
26064
|
} else {
|
|
25966
26065
|
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
@@ -25969,6 +26068,29 @@ var ElementModel = class _ElementModel {
|
|
|
25969
26068
|
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
25970
26069
|
}
|
|
25971
26070
|
}
|
|
26071
|
+
setPointsPerformance(points) {
|
|
26072
|
+
this.localPoints = points;
|
|
26073
|
+
this.onVectorUpdate();
|
|
26074
|
+
if (this.setPointsTimer) {
|
|
26075
|
+
window.clearTimeout(this.setPointsTimer);
|
|
26076
|
+
}
|
|
26077
|
+
this.setPointsTimer = window.setTimeout(() => {
|
|
26078
|
+
if (this.root.doc) {
|
|
26079
|
+
this.root.doc.transact(() => {
|
|
26080
|
+
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26081
|
+
if (yArray) {
|
|
26082
|
+
yArray.delete(0, yArray.length);
|
|
26083
|
+
yArray.push(points);
|
|
26084
|
+
}
|
|
26085
|
+
});
|
|
26086
|
+
} else {
|
|
26087
|
+
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
26088
|
+
yArray.delete(0, yArray.length);
|
|
26089
|
+
yArray.push(points);
|
|
26090
|
+
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
26091
|
+
}
|
|
26092
|
+
}, 100);
|
|
26093
|
+
}
|
|
25972
26094
|
appendPointsMatrix(matrix) {
|
|
25973
26095
|
const current = new this.scope.Matrix(this.pointsMatrix);
|
|
25974
26096
|
const next = matrix.appended(current);
|
|
@@ -25995,6 +26117,9 @@ var ElementModel = class _ElementModel {
|
|
|
25995
26117
|
}
|
|
25996
26118
|
dispose() {
|
|
25997
26119
|
this.subDispose();
|
|
26120
|
+
}
|
|
26121
|
+
disposeObserver() {
|
|
26122
|
+
console.log(`[][][] disposeObserver uuid=${this.uuid}`);
|
|
25998
26123
|
removeDeepObserver(this.root, this.handlePropChange);
|
|
25999
26124
|
}
|
|
26000
26125
|
};
|
|
@@ -26067,47 +26192,72 @@ function _toPrimitive3(t, r) {
|
|
|
26067
26192
|
return ("string" === r ? String : Number)(t);
|
|
26068
26193
|
}
|
|
26069
26194
|
var CurveModel = class extends ElementModel {
|
|
26070
|
-
constructor(root, scope, liveCursor) {
|
|
26071
|
-
super(root, scope, liveCursor);
|
|
26195
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26196
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26072
26197
|
_defineProperty3(this, "item", null);
|
|
26073
|
-
_defineProperty3(this, "debugPath", void 0);
|
|
26074
26198
|
_defineProperty3(this, "debug", false);
|
|
26075
|
-
|
|
26199
|
+
_defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
|
|
26200
|
+
_defineProperty3(this, "shouldUseLocalPoints", true);
|
|
26201
|
+
_defineProperty3(this, "localPointsPick", 6);
|
|
26202
|
+
if (!this.root.doc || !this.root.has("type")) {
|
|
26076
26203
|
this.root.set("type", "curve");
|
|
26077
26204
|
}
|
|
26078
|
-
if (!this.root.has("points")) {
|
|
26205
|
+
if (!this.root.doc || !this.root.has("points")) {
|
|
26079
26206
|
this.root.set("points", new Y2.Array());
|
|
26080
26207
|
}
|
|
26081
|
-
this.debugPath = new scope.Path();
|
|
26082
26208
|
}
|
|
26083
26209
|
average(a2, b2) {
|
|
26084
26210
|
return (a2 + b2) / 2;
|
|
26085
26211
|
}
|
|
26086
26212
|
parsePoints(points) {
|
|
26213
|
+
const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
|
|
26214
|
+
const viewScale = this.scope.project.view.matrix.scaling.x || 1;
|
|
26215
|
+
const taper = this.strokeWidth * 5 / viewScale;
|
|
26216
|
+
const streamline = Math.min(0.7, 0.7 * viewScale);
|
|
26087
26217
|
return ae(points, {
|
|
26088
26218
|
size: this.strokeWidth,
|
|
26089
|
-
smoothing: 0.
|
|
26090
|
-
thinning:
|
|
26091
|
-
streamline
|
|
26092
|
-
simulatePressure:
|
|
26219
|
+
smoothing: 0.7,
|
|
26220
|
+
thinning: 0.5,
|
|
26221
|
+
streamline,
|
|
26222
|
+
simulatePressure: !hasRealPressure,
|
|
26093
26223
|
start: {
|
|
26094
|
-
taper
|
|
26224
|
+
taper,
|
|
26095
26225
|
cap: true
|
|
26096
26226
|
},
|
|
26097
26227
|
end: {
|
|
26098
|
-
taper
|
|
26228
|
+
taper,
|
|
26099
26229
|
cap: true
|
|
26100
26230
|
}
|
|
26101
26231
|
});
|
|
26102
26232
|
}
|
|
26233
|
+
isPressureValue(value) {
|
|
26234
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
26235
|
+
}
|
|
26236
|
+
pointStride(points) {
|
|
26237
|
+
if (points.length >= 3 && points.length % 3 === 0) {
|
|
26238
|
+
let hasPressureSlot = false;
|
|
26239
|
+
for (let i = 2; i < points.length; i += 3) {
|
|
26240
|
+
if (!this.isPressureValue(points[i])) {
|
|
26241
|
+
return 2;
|
|
26242
|
+
}
|
|
26243
|
+
hasPressureSlot = true;
|
|
26244
|
+
}
|
|
26245
|
+
if (hasPressureSlot) {
|
|
26246
|
+
return 3;
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
return 2;
|
|
26250
|
+
}
|
|
26103
26251
|
matrixedPoints() {
|
|
26104
|
-
const points = this.points;
|
|
26252
|
+
const points = this.localPoints.length === 0 ? this.points : this.localPoints;
|
|
26105
26253
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26106
26254
|
const output = [];
|
|
26107
|
-
|
|
26255
|
+
const stride = this.pointStride(points);
|
|
26256
|
+
for (let i = 0, len = points.length; i + 1 < len; i += stride) {
|
|
26108
26257
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26109
26258
|
const tp = p.transform(matrix);
|
|
26110
|
-
|
|
26259
|
+
const pressure = stride === 3 ? points[i + 2] ?? 0 : 0;
|
|
26260
|
+
output.push([tp.x, tp.y, pressure]);
|
|
26111
26261
|
}
|
|
26112
26262
|
return output;
|
|
26113
26263
|
}
|
|
@@ -26136,34 +26286,30 @@ var CurveModel = class extends ElementModel {
|
|
|
26136
26286
|
}
|
|
26137
26287
|
return path;
|
|
26138
26288
|
}
|
|
26139
|
-
updateDebugPath() {
|
|
26140
|
-
this.debugPath = new this.scope.Path();
|
|
26141
|
-
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
26142
|
-
for (let i = 0, len = points.length; i < len; i++) {
|
|
26143
|
-
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
26144
|
-
if (i === 0) {
|
|
26145
|
-
this.debugPath.moveTo(point);
|
|
26146
|
-
} else {
|
|
26147
|
-
this.debugPath.lineTo(point);
|
|
26148
|
-
}
|
|
26149
|
-
this.debugPath.strokeWidth = 1;
|
|
26150
|
-
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
26151
|
-
}
|
|
26152
|
-
}
|
|
26153
26289
|
onVectorUpdate() {
|
|
26154
26290
|
if (!this.item) {
|
|
26155
26291
|
return;
|
|
26156
26292
|
}
|
|
26293
|
+
const matrixedPts = this.matrixedPoints();
|
|
26157
26294
|
if (this.debug) {
|
|
26158
|
-
this.
|
|
26159
|
-
|
|
26160
|
-
|
|
26161
|
-
|
|
26162
|
-
|
|
26163
|
-
|
|
26164
|
-
|
|
26165
|
-
|
|
26166
|
-
|
|
26295
|
+
const path = new this.scope.Path();
|
|
26296
|
+
for (let i = 0; i < matrixedPts.length; i++) {
|
|
26297
|
+
const p = new this.scope.Point(matrixedPts[i][0], matrixedPts[i][1]);
|
|
26298
|
+
if (i === 0) {
|
|
26299
|
+
path.moveTo(p);
|
|
26300
|
+
} else {
|
|
26301
|
+
path.lineTo(p);
|
|
26302
|
+
}
|
|
26303
|
+
}
|
|
26304
|
+
this.item.removeSegments();
|
|
26305
|
+
this.item.addSegments(path.segments);
|
|
26306
|
+
this.item.fillColor = null;
|
|
26307
|
+
this.item.strokeWidth = this.strokeWidth;
|
|
26308
|
+
} else {
|
|
26309
|
+
const points = this.parsePoints(matrixedPts);
|
|
26310
|
+
const path = this.createPath(points);
|
|
26311
|
+
this.item.removeSegments();
|
|
26312
|
+
this.item.addSegments(path.segments);
|
|
26167
26313
|
}
|
|
26168
26314
|
}
|
|
26169
26315
|
createPaperItem() {
|
|
@@ -26186,11 +26332,13 @@ var CurveModel = class extends ElementModel {
|
|
|
26186
26332
|
}
|
|
26187
26333
|
liveCursorPoint() {
|
|
26188
26334
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26189
|
-
|
|
26335
|
+
const points = yArray.toArray();
|
|
26336
|
+
const stride = this.pointStride(points);
|
|
26337
|
+
if (points.length < stride) {
|
|
26190
26338
|
return null;
|
|
26191
26339
|
}
|
|
26192
|
-
const len =
|
|
26193
|
-
const point = new this.scope.Point(
|
|
26340
|
+
const len = points.length;
|
|
26341
|
+
const point = new this.scope.Point(points[len - stride], points[len - stride + 1]);
|
|
26194
26342
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26195
26343
|
}
|
|
26196
26344
|
onStyleKeyUpdate(key) {
|
|
@@ -26228,15 +26376,24 @@ function _toPrimitive4(t, r) {
|
|
|
26228
26376
|
return ("string" === r ? String : Number)(t);
|
|
26229
26377
|
}
|
|
26230
26378
|
var SelectorModel = class extends ElementModel {
|
|
26231
|
-
|
|
26232
|
-
|
|
26379
|
+
get drawPoints() {
|
|
26380
|
+
if (this.localPoints.length >= 4) {
|
|
26381
|
+
return this.localPoints;
|
|
26382
|
+
}
|
|
26383
|
+
return this.points;
|
|
26384
|
+
}
|
|
26385
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26386
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26233
26387
|
_defineProperty4(this, "item", null);
|
|
26234
|
-
|
|
26388
|
+
_defineProperty4(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26389
|
+
_defineProperty4(this, "shouldUseLocalPoints", true);
|
|
26390
|
+
_defineProperty4(this, "localPointsPick", 4);
|
|
26391
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
26235
26392
|
this.root.set("type", "selector");
|
|
26236
26393
|
}
|
|
26237
|
-
if (!this.root.has("points")) {
|
|
26394
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
26238
26395
|
const initPoints = new Y3.Array();
|
|
26239
|
-
initPoints.push([0, 0, 0, 0
|
|
26396
|
+
initPoints.push([0, 0, 0, 0]);
|
|
26240
26397
|
this.root.set("points", initPoints);
|
|
26241
26398
|
}
|
|
26242
26399
|
}
|
|
@@ -26247,8 +26404,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26247
26404
|
}
|
|
26248
26405
|
createPaperRect() {
|
|
26249
26406
|
const scope = this.scope;
|
|
26250
|
-
const bounds = new scope.Rectangle(new scope.Point(this.
|
|
26251
|
-
return new scope.Path.Rectangle(bounds
|
|
26407
|
+
const bounds = new scope.Rectangle(new scope.Point(this.drawPoints[0], this.drawPoints[1]), new scope.Size(this.drawPoints[2], this.drawPoints[3]));
|
|
26408
|
+
return new scope.Path.Rectangle(bounds);
|
|
26252
26409
|
}
|
|
26253
26410
|
onVectorUpdate() {
|
|
26254
26411
|
if (!this.item) {
|
|
@@ -26282,7 +26439,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26282
26439
|
import * as Y4 from "yjs";
|
|
26283
26440
|
|
|
26284
26441
|
// src/utils/paperjs.ts
|
|
26285
|
-
var
|
|
26442
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
26443
|
+
import { metrics } from "@netless/forge-room";
|
|
26286
26444
|
function _defineProperty5(e, r, t) {
|
|
26287
26445
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26288
26446
|
}
|
|
@@ -26315,7 +26473,7 @@ function serializePath(path) {
|
|
|
26315
26473
|
}, []);
|
|
26316
26474
|
}
|
|
26317
26475
|
function deserializePath(points, scope, matrix) {
|
|
26318
|
-
const segmentGroup = (0,
|
|
26476
|
+
const segmentGroup = (0, import_lodash.chunk)(points, 6);
|
|
26319
26477
|
const path = new scope.Path();
|
|
26320
26478
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
26321
26479
|
return path;
|
|
@@ -26325,7 +26483,27 @@ var AnimationFrame = class {
|
|
|
26325
26483
|
_defineProperty5(this, "callbacks", []);
|
|
26326
26484
|
_defineProperty5(this, "lastTime", 0);
|
|
26327
26485
|
_defineProperty5(this, "fps", 45);
|
|
26486
|
+
_defineProperty5(this, "lastCallbackTime", 0);
|
|
26487
|
+
_defineProperty5(this, "fpsBuffer", []);
|
|
26488
|
+
_defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
|
|
26328
26489
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26490
|
+
const now = performance.now();
|
|
26491
|
+
if (this.lastCallbackTime > 0) {
|
|
26492
|
+
const actualFps = 1e3 / (now - this.lastCallbackTime);
|
|
26493
|
+
this.fpsBuffer.push(actualFps);
|
|
26494
|
+
if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
|
|
26495
|
+
const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
|
|
26496
|
+
const min = Math.min(...this.fpsBuffer);
|
|
26497
|
+
const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
|
|
26498
|
+
const p90 = sorted[Math.floor(sorted.length * 0.9)];
|
|
26499
|
+
metrics().gauge("fps", Math.round(avg), {
|
|
26500
|
+
min: Math.round(min),
|
|
26501
|
+
p90: Math.round(p90)
|
|
26502
|
+
});
|
|
26503
|
+
this.fpsBuffer = [];
|
|
26504
|
+
}
|
|
26505
|
+
}
|
|
26506
|
+
this.lastCallbackTime = now;
|
|
26329
26507
|
const functions = this.callbacks;
|
|
26330
26508
|
this.callbacks = [];
|
|
26331
26509
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
@@ -26369,13 +26547,22 @@ function _toPrimitive6(t, r) {
|
|
|
26369
26547
|
return ("string" === r ? String : Number)(t);
|
|
26370
26548
|
}
|
|
26371
26549
|
var SegmentsModel = class extends ElementModel {
|
|
26372
|
-
|
|
26373
|
-
|
|
26550
|
+
get drawPoints() {
|
|
26551
|
+
if (this.localPoints.length >= 4) {
|
|
26552
|
+
return this.localPoints;
|
|
26553
|
+
}
|
|
26554
|
+
return this.points;
|
|
26555
|
+
}
|
|
26556
|
+
constructor(root, scope, type, liveCursor, isPerformanceMode) {
|
|
26557
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26374
26558
|
_defineProperty6(this, "item", null);
|
|
26375
|
-
|
|
26559
|
+
_defineProperty6(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26560
|
+
_defineProperty6(this, "shouldUseLocalPoints", true);
|
|
26561
|
+
_defineProperty6(this, "localPointsPick", 24);
|
|
26562
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
26376
26563
|
this.root.set("type", type);
|
|
26377
26564
|
}
|
|
26378
|
-
if (!this.root.has("points")) {
|
|
26565
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
26379
26566
|
this.root.set("points", new Y4.Array());
|
|
26380
26567
|
}
|
|
26381
26568
|
}
|
|
@@ -26395,13 +26582,13 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26395
26582
|
}
|
|
26396
26583
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26397
26584
|
this.item.removeSegments();
|
|
26398
|
-
const next = deserializePath(this.
|
|
26585
|
+
const next = deserializePath(this.drawPoints, this.scope, matrix);
|
|
26399
26586
|
this.item.addSegments(next.segments);
|
|
26400
26587
|
this.item.closePath();
|
|
26401
26588
|
}
|
|
26402
26589
|
createPaperItem() {
|
|
26403
26590
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26404
|
-
this.item = deserializePath(this.
|
|
26591
|
+
this.item = deserializePath(this.drawPoints, this.scope, matrix);
|
|
26405
26592
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
26406
26593
|
this.item.dashArray = this.dashArray;
|
|
26407
26594
|
this.item.strokeWidth = this.strokeWidth;
|
|
@@ -26428,7 +26615,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26428
26615
|
};
|
|
26429
26616
|
|
|
26430
26617
|
// src/model/renderable/LineModel.ts
|
|
26431
|
-
var
|
|
26618
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
26432
26619
|
import * as Y5 from "yjs";
|
|
26433
26620
|
|
|
26434
26621
|
// src/tool/WhiteboardTool.ts
|
|
@@ -26449,6 +26636,8 @@ function _toPrimitive7(t, r) {
|
|
|
26449
26636
|
}
|
|
26450
26637
|
return ("string" === r ? String : Number)(t);
|
|
26451
26638
|
}
|
|
26639
|
+
var DRAG_FPS = 10;
|
|
26640
|
+
var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
|
|
26452
26641
|
var WhiteboardTool = class {
|
|
26453
26642
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
26454
26643
|
_defineProperty7(this, "modelGetter", void 0);
|
|
@@ -26457,24 +26646,60 @@ var WhiteboardTool = class {
|
|
|
26457
26646
|
_defineProperty7(this, "shadowEmitter", void 0);
|
|
26458
26647
|
_defineProperty7(this, "enableToolEvent", void 0);
|
|
26459
26648
|
_defineProperty7(this, "eventAvailable", false);
|
|
26649
|
+
_defineProperty7(this, "lastDragTime", 0);
|
|
26650
|
+
_defineProperty7(this, "dragRafId", 0);
|
|
26651
|
+
_defineProperty7(this, "pendingDragEvent", null);
|
|
26460
26652
|
_defineProperty7(this, "onMouseDownSelf", (event) => {
|
|
26461
26653
|
this.eventAvailable = this.enableToolEvent();
|
|
26462
26654
|
if (!this.eventAvailable) {
|
|
26463
26655
|
return;
|
|
26464
26656
|
}
|
|
26657
|
+
this.lastDragTime = 0;
|
|
26658
|
+
if (this.dragRafId) {
|
|
26659
|
+
cancelAnimationFrame(this.dragRafId);
|
|
26660
|
+
this.dragRafId = 0;
|
|
26661
|
+
}
|
|
26662
|
+
this.pendingDragEvent = null;
|
|
26465
26663
|
this.shadowEmitter.setActive(true);
|
|
26466
26664
|
this.onMouseDown(event);
|
|
26467
26665
|
});
|
|
26666
|
+
_defineProperty7(this, "flushPendingDrag", () => {
|
|
26667
|
+
this.dragRafId = 0;
|
|
26668
|
+
if (this.pendingDragEvent) {
|
|
26669
|
+
this.lastDragTime = performance.now();
|
|
26670
|
+
const event = this.pendingDragEvent;
|
|
26671
|
+
this.pendingDragEvent = null;
|
|
26672
|
+
this.onMouseDrag(event);
|
|
26673
|
+
}
|
|
26674
|
+
});
|
|
26468
26675
|
_defineProperty7(this, "onMouseDragSelf", (event) => {
|
|
26469
26676
|
if (!this.eventAvailable) {
|
|
26470
26677
|
return;
|
|
26471
26678
|
}
|
|
26472
|
-
|
|
26679
|
+
const now = performance.now();
|
|
26680
|
+
if (now - this.lastDragTime >= DRAG_FRAME_MS) {
|
|
26681
|
+
this.lastDragTime = now;
|
|
26682
|
+
this.pendingDragEvent = null;
|
|
26683
|
+
this.onMouseDrag(event);
|
|
26684
|
+
} else {
|
|
26685
|
+
this.pendingDragEvent = event;
|
|
26686
|
+
if (!this.dragRafId) {
|
|
26687
|
+
this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
|
|
26688
|
+
}
|
|
26689
|
+
}
|
|
26473
26690
|
});
|
|
26474
26691
|
_defineProperty7(this, "onMouseUpSelf", (event) => {
|
|
26475
26692
|
if (!this.eventAvailable) {
|
|
26476
26693
|
return;
|
|
26477
26694
|
}
|
|
26695
|
+
if (this.dragRafId) {
|
|
26696
|
+
cancelAnimationFrame(this.dragRafId);
|
|
26697
|
+
this.dragRafId = 0;
|
|
26698
|
+
}
|
|
26699
|
+
if (this.pendingDragEvent) {
|
|
26700
|
+
this.onMouseDrag(this.pendingDragEvent);
|
|
26701
|
+
this.pendingDragEvent = null;
|
|
26702
|
+
}
|
|
26478
26703
|
this.onMouseUp(event);
|
|
26479
26704
|
this.shadowEmitter.setActive(false);
|
|
26480
26705
|
});
|
|
@@ -26490,7 +26715,7 @@ var WhiteboardTool = class {
|
|
|
26490
26715
|
};
|
|
26491
26716
|
|
|
26492
26717
|
// src/tool/LineTool.ts
|
|
26493
|
-
var
|
|
26718
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
26494
26719
|
function _defineProperty8(e, r, t) {
|
|
26495
26720
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26496
26721
|
}
|
|
@@ -26539,7 +26764,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26539
26764
|
const point = path.getPointAt(distance);
|
|
26540
26765
|
return [point.x, point.y];
|
|
26541
26766
|
});
|
|
26542
|
-
this.elementModel.setPoints((0,
|
|
26767
|
+
this.elementModel.setPoints((0, import_lodash2.flattenDeep)(points));
|
|
26543
26768
|
}
|
|
26544
26769
|
}
|
|
26545
26770
|
onMouseUp(_event) {
|
|
@@ -26569,6 +26794,12 @@ function _toPrimitive9(t, r) {
|
|
|
26569
26794
|
return ("string" === r ? String : Number)(t);
|
|
26570
26795
|
}
|
|
26571
26796
|
var LineModel = class extends ElementModel {
|
|
26797
|
+
get drawPoints() {
|
|
26798
|
+
if (this.localPoints.length > 0) {
|
|
26799
|
+
return this.localPoints;
|
|
26800
|
+
}
|
|
26801
|
+
return this.points;
|
|
26802
|
+
}
|
|
26572
26803
|
get arrowSize() {
|
|
26573
26804
|
return this.strokeWidth * 5 + 15;
|
|
26574
26805
|
}
|
|
@@ -26584,20 +26815,23 @@ var LineModel = class extends ElementModel {
|
|
|
26584
26815
|
set tailArrow(value) {
|
|
26585
26816
|
this.root.set("tailArrow", value);
|
|
26586
26817
|
}
|
|
26587
|
-
constructor(root, scope, liveCursor) {
|
|
26588
|
-
super(root, scope, liveCursor);
|
|
26818
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26819
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26589
26820
|
_defineProperty9(this, "controlledPoints", []);
|
|
26821
|
+
_defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26822
|
+
_defineProperty9(this, "shouldUseLocalPoints", true);
|
|
26823
|
+
_defineProperty9(this, "localPointsPick", 99);
|
|
26590
26824
|
_defineProperty9(this, "item", null);
|
|
26591
|
-
if (!this.root.has("type")) {
|
|
26825
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
26592
26826
|
this.root.set("type", "arrow");
|
|
26593
26827
|
}
|
|
26594
|
-
if (!this.root.has("points")) {
|
|
26828
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
26595
26829
|
this.root.set("points", new Y5.Array());
|
|
26596
26830
|
}
|
|
26597
|
-
if (!this.root.has("headArrow")) {
|
|
26831
|
+
if (this.root.doc && !this.root.has("headArrow")) {
|
|
26598
26832
|
this.root.set("headArrow", "none");
|
|
26599
26833
|
}
|
|
26600
|
-
if (!this.root.has("tailArrow")) {
|
|
26834
|
+
if (this.root.doc && !this.root.has("tailArrow")) {
|
|
26601
26835
|
this.root.set("tailArrow", "normal");
|
|
26602
26836
|
}
|
|
26603
26837
|
}
|
|
@@ -26613,7 +26847,7 @@ var LineModel = class extends ElementModel {
|
|
|
26613
26847
|
}
|
|
26614
26848
|
renderLine() {
|
|
26615
26849
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26616
|
-
const papperPoints = (0,
|
|
26850
|
+
const papperPoints = (0, import_lodash3.chunk)(this.drawPoints, 2).map((item) => {
|
|
26617
26851
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
26618
26852
|
});
|
|
26619
26853
|
const path = new this.scope.Path();
|
|
@@ -26727,13 +26961,14 @@ var LineControlPoint = class {
|
|
|
26727
26961
|
if (this.position) {
|
|
26728
26962
|
return this.model.scope.project.view.projectToView(this.position.transform(matrix));
|
|
26729
26963
|
}
|
|
26964
|
+
const points = this.model["drawPoints"];
|
|
26730
26965
|
const from = {
|
|
26731
|
-
x:
|
|
26732
|
-
y:
|
|
26966
|
+
x: points[0],
|
|
26967
|
+
y: points[1]
|
|
26733
26968
|
};
|
|
26734
26969
|
const to = {
|
|
26735
|
-
x:
|
|
26736
|
-
y:
|
|
26970
|
+
x: points[points.length - 2],
|
|
26971
|
+
y: points[points.length - 1]
|
|
26737
26972
|
};
|
|
26738
26973
|
const clonedPath = new this.scope.Path.Line(from, to);
|
|
26739
26974
|
this.position = clonedPath.getPointAt(clonedPath.length * distance);
|
|
@@ -26746,9 +26981,9 @@ var LineControlPoint = class {
|
|
|
26746
26981
|
}
|
|
26747
26982
|
const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
|
|
26748
26983
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
26749
|
-
const points = this.model
|
|
26984
|
+
const points = this.model["drawPoints"];
|
|
26750
26985
|
this.position = invertedPoint;
|
|
26751
|
-
const clonedPoints = (0,
|
|
26986
|
+
const clonedPoints = (0, import_lodash3.cloneDeep)(points);
|
|
26752
26987
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
26753
26988
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
26754
26989
|
this.model.setPoints(clonedPoints);
|
|
@@ -26794,9 +27029,18 @@ var PointTextModel = class extends ElementModel {
|
|
|
26794
27029
|
set fontFamily(value) {
|
|
26795
27030
|
this.root.set("font-family", value);
|
|
26796
27031
|
}
|
|
26797
|
-
|
|
26798
|
-
|
|
27032
|
+
get drawPoints() {
|
|
27033
|
+
if (this.localPoints.length > 1) {
|
|
27034
|
+
return this.localPoints;
|
|
27035
|
+
}
|
|
27036
|
+
return this.points;
|
|
27037
|
+
}
|
|
27038
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27039
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26799
27040
|
_defineProperty10(this, "item", null);
|
|
27041
|
+
_defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27042
|
+
_defineProperty10(this, "shouldUseLocalPoints", false);
|
|
27043
|
+
_defineProperty10(this, "localPointsPick", 2);
|
|
26800
27044
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
26801
27045
|
if (!this.item) {
|
|
26802
27046
|
return;
|
|
@@ -26813,22 +27057,28 @@ var PointTextModel = class extends ElementModel {
|
|
|
26813
27057
|
}
|
|
26814
27058
|
}
|
|
26815
27059
|
});
|
|
26816
|
-
if (!this.root.has("type")) {
|
|
27060
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
26817
27061
|
this.root.set("type", "point-text");
|
|
26818
27062
|
}
|
|
26819
|
-
if (!this.root.has(ElementModel.KEYS.points)) {
|
|
27063
|
+
if (this.root.doc && !this.root.has(ElementModel.KEYS.points)) {
|
|
26820
27064
|
this.root.set(ElementModel.KEYS.points, new Y6.Array());
|
|
26821
27065
|
}
|
|
26822
27066
|
this.root.observe(this.handleTextPropChange);
|
|
26823
|
-
|
|
26824
|
-
|
|
26825
|
-
|
|
26826
|
-
|
|
26827
|
-
|
|
27067
|
+
setTimeout(() => {
|
|
27068
|
+
if (this.root && this.root.has("font-size")) {
|
|
27069
|
+
setTimeout(() => {
|
|
27070
|
+
this.updateTextPosition();
|
|
27071
|
+
}, 60);
|
|
27072
|
+
}
|
|
27073
|
+
}, 60);
|
|
26828
27074
|
}
|
|
26829
27075
|
subDispose() {
|
|
26830
27076
|
removeObserver(this.root, this.handleTextPropChange);
|
|
26831
27077
|
}
|
|
27078
|
+
subBindObserver() {
|
|
27079
|
+
removeObserver(this.root, this.handleTextPropChange);
|
|
27080
|
+
this.root.observe(this.handleTextPropChange);
|
|
27081
|
+
}
|
|
26832
27082
|
liveCursorPoint() {
|
|
26833
27083
|
const points = this.points;
|
|
26834
27084
|
if (points.length < 1) {
|
|
@@ -26842,10 +27092,11 @@ var PointTextModel = class extends ElementModel {
|
|
|
26842
27092
|
if (!this.item) {
|
|
26843
27093
|
return null;
|
|
26844
27094
|
}
|
|
27095
|
+
console.log("[][][] drawPoints", this.drawPoints);
|
|
26845
27096
|
const bounds = this.item.internalBounds;
|
|
26846
27097
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26847
|
-
const topLeft = new this.scope.Point(this.
|
|
26848
|
-
const topRight = new this.scope.Point(this.
|
|
27098
|
+
const topLeft = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
|
|
27099
|
+
const topRight = new this.scope.Point(this.drawPoints[0] + bounds.width, this.drawPoints[1]).transform(matrix);
|
|
26849
27100
|
let scaleX = topRight.getDistance(topLeft) / bounds.width;
|
|
26850
27101
|
scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
|
|
26851
27102
|
const angle = topRight.subtract(topLeft).angle;
|
|
@@ -26933,13 +27184,22 @@ function _toPrimitive11(t, r) {
|
|
|
26933
27184
|
return ("string" === r ? String : Number)(t);
|
|
26934
27185
|
}
|
|
26935
27186
|
var TriangleModel = class extends ElementModel {
|
|
26936
|
-
|
|
26937
|
-
|
|
27187
|
+
get drawPoints() {
|
|
27188
|
+
if (this.localPoints.length >= 6) {
|
|
27189
|
+
return this.localPoints;
|
|
27190
|
+
}
|
|
27191
|
+
return this.points;
|
|
27192
|
+
}
|
|
27193
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27194
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
26938
27195
|
_defineProperty11(this, "item", null);
|
|
26939
|
-
|
|
27196
|
+
_defineProperty11(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27197
|
+
_defineProperty11(this, "shouldUseLocalPoints", true);
|
|
27198
|
+
_defineProperty11(this, "localPointsPick", 6);
|
|
27199
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
26940
27200
|
this.root.set("type", "triangle");
|
|
26941
27201
|
}
|
|
26942
|
-
if (!this.root.has("points")) {
|
|
27202
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
26943
27203
|
this.root.set("points", new Y7.Array());
|
|
26944
27204
|
}
|
|
26945
27205
|
}
|
|
@@ -26971,9 +27231,9 @@ var TriangleModel = class extends ElementModel {
|
|
|
26971
27231
|
return;
|
|
26972
27232
|
}
|
|
26973
27233
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26974
|
-
const p1 = new this.scope.Point(this.
|
|
26975
|
-
const p2 = new this.scope.Point(this.
|
|
26976
|
-
const p3 = new this.scope.Point(this.
|
|
27234
|
+
const p1 = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
|
|
27235
|
+
const p2 = new this.scope.Point(this.drawPoints[2], this.drawPoints[3]).transform(matrix);
|
|
27236
|
+
const p3 = new this.scope.Point(this.drawPoints[4], this.drawPoints[5]).transform(matrix);
|
|
26977
27237
|
this.item.removeSegments();
|
|
26978
27238
|
this.item.moveTo(p1);
|
|
26979
27239
|
this.item.lineTo(p2);
|
|
@@ -26985,7 +27245,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
26985
27245
|
config.controlPoints.push({
|
|
26986
27246
|
name: "triangle",
|
|
26987
27247
|
getPosition: () => {
|
|
26988
|
-
const point = new this.scope.Point(this.
|
|
27248
|
+
const point = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]);
|
|
26989
27249
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26990
27250
|
return this.scope.project.view.projectToView(point.transform(pointsMatrix));
|
|
26991
27251
|
},
|
|
@@ -26995,7 +27255,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
26995
27255
|
}
|
|
26996
27256
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26997
27257
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
26998
|
-
const oldPoints = this.
|
|
27258
|
+
const oldPoints = this.drawPoints;
|
|
26999
27259
|
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
|
|
27000
27260
|
}
|
|
27001
27261
|
});
|
|
@@ -27034,25 +27294,34 @@ function _toPrimitive12(t, r) {
|
|
|
27034
27294
|
return ("string" === r ? String : Number)(t);
|
|
27035
27295
|
}
|
|
27036
27296
|
var RectangleModel = class extends ElementModel {
|
|
27037
|
-
|
|
27038
|
-
|
|
27297
|
+
get drawPoints() {
|
|
27298
|
+
if (this.localPoints.length >= 4) {
|
|
27299
|
+
return this.localPoints;
|
|
27300
|
+
}
|
|
27301
|
+
return this.points;
|
|
27302
|
+
}
|
|
27303
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27304
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
27039
27305
|
_defineProperty12(this, "item", null);
|
|
27040
|
-
|
|
27306
|
+
_defineProperty12(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27307
|
+
_defineProperty12(this, "shouldUseLocalPoints", true);
|
|
27308
|
+
_defineProperty12(this, "localPointsPick", 4);
|
|
27309
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
27041
27310
|
this.root.set("type", "rectangle");
|
|
27042
27311
|
}
|
|
27043
|
-
if (!this.root.has("points")) {
|
|
27312
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
27044
27313
|
const initPoints = new Y8.Array();
|
|
27045
27314
|
initPoints.push([0, 0, 0, 0]);
|
|
27046
27315
|
this.root.set("points", initPoints);
|
|
27047
27316
|
}
|
|
27048
|
-
if (!this.root.has("radius")) {
|
|
27317
|
+
if (this.root.doc && !this.root.has("radius")) {
|
|
27049
27318
|
this.root.set("radius", 0);
|
|
27050
27319
|
}
|
|
27051
27320
|
}
|
|
27052
27321
|
subDispose() {
|
|
27053
27322
|
}
|
|
27054
27323
|
liveCursorPoint() {
|
|
27055
|
-
const points = this.
|
|
27324
|
+
const points = this.drawPoints;
|
|
27056
27325
|
if (points.length < 4) {
|
|
27057
27326
|
return null;
|
|
27058
27327
|
}
|
|
@@ -27060,7 +27329,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27060
27329
|
return new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
27061
27330
|
}
|
|
27062
27331
|
createSegments() {
|
|
27063
|
-
const [a2, b2, c, d] = this.
|
|
27332
|
+
const [a2, b2, c, d] = this.drawPoints;
|
|
27064
27333
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27065
27334
|
const maxRadius = this.maxRadiusLength();
|
|
27066
27335
|
const radius = this.root.get("radius") * maxRadius;
|
|
@@ -27125,7 +27394,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27125
27394
|
}
|
|
27126
27395
|
maxRadiusLength() {
|
|
27127
27396
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27128
|
-
const points = this.
|
|
27397
|
+
const points = this.drawPoints;
|
|
27129
27398
|
const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
|
|
27130
27399
|
const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
|
|
27131
27400
|
const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
|
|
@@ -27150,7 +27419,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27150
27419
|
name: "rect-radius",
|
|
27151
27420
|
getPosition: () => {
|
|
27152
27421
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27153
|
-
const points = this.
|
|
27422
|
+
const points = this.drawPoints;
|
|
27154
27423
|
const radius = this.root.get("radius") * this.maxRadiusLength();
|
|
27155
27424
|
let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
|
|
27156
27425
|
const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
@@ -27169,7 +27438,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27169
27438
|
if (!this.item) {
|
|
27170
27439
|
return;
|
|
27171
27440
|
}
|
|
27172
|
-
const points = this.
|
|
27441
|
+
const points = this.drawPoints;
|
|
27173
27442
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27174
27443
|
const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
|
|
27175
27444
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
@@ -27198,7 +27467,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27198
27467
|
var elementsUndoOrigin = "elementsUndoOrigin";
|
|
27199
27468
|
|
|
27200
27469
|
// src/model/renderable/EraserModel.ts
|
|
27201
|
-
var
|
|
27470
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
27202
27471
|
import * as Y9 from "yjs";
|
|
27203
27472
|
function _defineProperty13(e, r, t) {
|
|
27204
27473
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27218,14 +27487,23 @@ function _toPrimitive13(t, r) {
|
|
|
27218
27487
|
return ("string" === r ? String : Number)(t);
|
|
27219
27488
|
}
|
|
27220
27489
|
var EraserModel = class extends ElementModel {
|
|
27221
|
-
|
|
27222
|
-
|
|
27490
|
+
get drawPoints() {
|
|
27491
|
+
if (this.localPoints.length > 0) {
|
|
27492
|
+
return this.localPoints;
|
|
27493
|
+
}
|
|
27494
|
+
return this.points;
|
|
27495
|
+
}
|
|
27496
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27497
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
27223
27498
|
_defineProperty13(this, "item", null);
|
|
27224
27499
|
_defineProperty13(this, "sliceBegin", 0);
|
|
27225
|
-
|
|
27500
|
+
_defineProperty13(this, "clearLocalPointsWhenYPointsChange", false);
|
|
27501
|
+
_defineProperty13(this, "shouldUseLocalPoints", true);
|
|
27502
|
+
_defineProperty13(this, "localPointsPick", 4);
|
|
27503
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
27226
27504
|
this.root.set("type", "eraser");
|
|
27227
27505
|
}
|
|
27228
|
-
if (!this.root.has("points")) {
|
|
27506
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
27229
27507
|
this.root.set("points", new Y9.Array());
|
|
27230
27508
|
}
|
|
27231
27509
|
}
|
|
@@ -27258,7 +27536,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27258
27536
|
return path;
|
|
27259
27537
|
}
|
|
27260
27538
|
parsePoints(points) {
|
|
27261
|
-
const groupPoints = (0,
|
|
27539
|
+
const groupPoints = (0, import_lodash4.chunk)(points, 2);
|
|
27262
27540
|
return ae(groupPoints, {
|
|
27263
27541
|
size: this.strokeWidth,
|
|
27264
27542
|
smoothing: 0.5,
|
|
@@ -27276,7 +27554,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27276
27554
|
});
|
|
27277
27555
|
}
|
|
27278
27556
|
matrixedPoints() {
|
|
27279
|
-
const currentPoints = (0,
|
|
27557
|
+
const currentPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
|
|
27280
27558
|
return currentPoints.map((_ref) => {
|
|
27281
27559
|
let [x, y] = _ref;
|
|
27282
27560
|
return new this.scope.Point(x, y);
|
|
@@ -27304,11 +27582,11 @@ var EraserModel = class extends ElementModel {
|
|
|
27304
27582
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
27305
27583
|
this.onVectorUpdate();
|
|
27306
27584
|
this.item.onFrame = () => {
|
|
27307
|
-
if (!this.
|
|
27585
|
+
if (!this.drawPoints) {
|
|
27308
27586
|
return;
|
|
27309
27587
|
}
|
|
27310
|
-
if (this.
|
|
27311
|
-
this.sliceBegin = this.
|
|
27588
|
+
if (this.drawPoints.length / 2 > 50) {
|
|
27589
|
+
this.sliceBegin = this.drawPoints.length / 2 - 50;
|
|
27312
27590
|
}
|
|
27313
27591
|
};
|
|
27314
27592
|
}
|
|
@@ -27341,8 +27619,9 @@ var EraserModel = class extends ElementModel {
|
|
|
27341
27619
|
};
|
|
27342
27620
|
|
|
27343
27621
|
// src/model/renderable/LaserPointerModel.ts
|
|
27344
|
-
var
|
|
27622
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
27345
27623
|
import * as Y10 from "yjs";
|
|
27624
|
+
import { removeObserver as removeObserver2 } from "@netless/forge-room";
|
|
27346
27625
|
function _defineProperty14(e, r, t) {
|
|
27347
27626
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27348
27627
|
}
|
|
@@ -27361,24 +27640,18 @@ function _toPrimitive14(t, r) {
|
|
|
27361
27640
|
return ("string" === r ? String : Number)(t);
|
|
27362
27641
|
}
|
|
27363
27642
|
var LaserPointerModel = class extends ElementModel {
|
|
27364
|
-
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
27365
|
-
super(root, scope, liveCursor);
|
|
27643
|
+
constructor(clientId, root, scope, liveCursor, removeElement, isPerformanceMode) {
|
|
27644
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
27366
27645
|
_defineProperty14(this, "item", null);
|
|
27367
27646
|
_defineProperty14(this, "clientId", void 0);
|
|
27368
27647
|
_defineProperty14(this, "sliceBegin", 0);
|
|
27369
27648
|
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
27370
27649
|
_defineProperty14(this, "cachedPoints", null);
|
|
27371
|
-
this
|
|
27372
|
-
|
|
27373
|
-
|
|
27374
|
-
|
|
27375
|
-
|
|
27376
|
-
this.root.set("points", new Y10.Array());
|
|
27377
|
-
}
|
|
27378
|
-
if (!this.root.has("removed")) {
|
|
27379
|
-
this.root.set("removed", false);
|
|
27380
|
-
}
|
|
27381
|
-
this.root.observe((event) => {
|
|
27650
|
+
_defineProperty14(this, "clearLocalPointsWhenYPointsChange", false);
|
|
27651
|
+
_defineProperty14(this, "shouldUseLocalPoints", false);
|
|
27652
|
+
_defineProperty14(this, "localPointsPick", 4);
|
|
27653
|
+
_defineProperty14(this, "removeElement", void 0);
|
|
27654
|
+
_defineProperty14(this, "handleLaserPropChange", (event) => {
|
|
27382
27655
|
if (!this.item) {
|
|
27383
27656
|
return;
|
|
27384
27657
|
}
|
|
@@ -27396,13 +27669,31 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27396
27669
|
this.onVectorUpdate();
|
|
27397
27670
|
if (evt.count >= 30) {
|
|
27398
27671
|
if (this.ownerId === this.clientId) {
|
|
27399
|
-
removeElement(this.uuid);
|
|
27672
|
+
this.removeElement(this.uuid);
|
|
27400
27673
|
}
|
|
27401
27674
|
}
|
|
27402
27675
|
};
|
|
27403
27676
|
}
|
|
27404
27677
|
}
|
|
27405
27678
|
});
|
|
27679
|
+
this.clientId = clientId;
|
|
27680
|
+
this.removeElement = removeElement;
|
|
27681
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
27682
|
+
this.root.set("type", "laser");
|
|
27683
|
+
}
|
|
27684
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
27685
|
+
this.root.set("points", new Y10.Array());
|
|
27686
|
+
}
|
|
27687
|
+
if (this.root.doc && !this.root.has("removed")) {
|
|
27688
|
+
this.root.set("removed", false);
|
|
27689
|
+
}
|
|
27690
|
+
}
|
|
27691
|
+
subBindObserver() {
|
|
27692
|
+
removeObserver2(this.root, this.handleLaserPropChange);
|
|
27693
|
+
this.root.observe(this.handleLaserPropChange);
|
|
27694
|
+
}
|
|
27695
|
+
subDispose() {
|
|
27696
|
+
removeObserver2(this.root, this.handleLaserPropChange);
|
|
27406
27697
|
}
|
|
27407
27698
|
beginRemoveAnimate() {
|
|
27408
27699
|
this.root.set("removed", true);
|
|
@@ -27455,7 +27746,8 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27455
27746
|
matrixedPoints() {
|
|
27456
27747
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27457
27748
|
const points = this.cachedPoints || this.points;
|
|
27458
|
-
|
|
27749
|
+
console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
|
|
27750
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
|
|
27459
27751
|
return groupPoints.map((_ref) => {
|
|
27460
27752
|
let [x, y] = _ref;
|
|
27461
27753
|
return matrix.transform([x, y]);
|
|
@@ -27497,8 +27789,6 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27497
27789
|
onStyleKeyUpdate(_key) {
|
|
27498
27790
|
return;
|
|
27499
27791
|
}
|
|
27500
|
-
subDispose() {
|
|
27501
|
-
}
|
|
27502
27792
|
liveCursorPoint() {
|
|
27503
27793
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
27504
27794
|
if (yArray.length < 2) {
|
|
@@ -27536,7 +27826,7 @@ var WhiteboardPermissions = class extends AbstractApplicationPermissions {
|
|
|
27536
27826
|
};
|
|
27537
27827
|
|
|
27538
27828
|
// src/model/renderable/StraightLineModel.ts
|
|
27539
|
-
var
|
|
27829
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
27540
27830
|
import * as Y11 from "yjs";
|
|
27541
27831
|
function _defineProperty15(e, r, t) {
|
|
27542
27832
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27556,13 +27846,22 @@ function _toPrimitive15(t, r) {
|
|
|
27556
27846
|
return ("string" === r ? String : Number)(t);
|
|
27557
27847
|
}
|
|
27558
27848
|
var StraightLineModel = class extends ElementModel {
|
|
27559
|
-
|
|
27560
|
-
|
|
27849
|
+
get drawPoints() {
|
|
27850
|
+
if (this.localPoints.length >= 4) {
|
|
27851
|
+
return this.localPoints;
|
|
27852
|
+
}
|
|
27853
|
+
return this.points;
|
|
27854
|
+
}
|
|
27855
|
+
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27856
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
27561
27857
|
_defineProperty15(this, "item", null);
|
|
27562
|
-
|
|
27858
|
+
_defineProperty15(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27859
|
+
_defineProperty15(this, "shouldUseLocalPoints", true);
|
|
27860
|
+
_defineProperty15(this, "localPointsPick", 4);
|
|
27861
|
+
if (this.root.doc && !this.root.has("type")) {
|
|
27563
27862
|
this.root.set("type", "line");
|
|
27564
27863
|
}
|
|
27565
|
-
if (!this.root.has("points")) {
|
|
27864
|
+
if (this.root.doc && !this.root.has("points")) {
|
|
27566
27865
|
this.root.set("points", new Y11.Array());
|
|
27567
27866
|
}
|
|
27568
27867
|
}
|
|
@@ -27587,7 +27886,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27587
27886
|
}
|
|
27588
27887
|
renderLine() {
|
|
27589
27888
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27590
|
-
const papperPoints = (0,
|
|
27889
|
+
const papperPoints = (0, import_lodash6.chunk)(this.drawPoints, 2).map((item) => {
|
|
27591
27890
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
27592
27891
|
});
|
|
27593
27892
|
const path = new this.scope.Path();
|
|
@@ -27609,7 +27908,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27609
27908
|
name: "line-start",
|
|
27610
27909
|
getPosition: () => {
|
|
27611
27910
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27612
|
-
const points = this.
|
|
27911
|
+
const points = this.drawPoints;
|
|
27613
27912
|
const start = new this.scope.Point(points[0], points[1]);
|
|
27614
27913
|
return this.scope.project.view.projectToView(start.transform(matrix));
|
|
27615
27914
|
},
|
|
@@ -27619,14 +27918,15 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27619
27918
|
}
|
|
27620
27919
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27621
27920
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27622
|
-
|
|
27921
|
+
const oldPoints = this.drawPoints;
|
|
27922
|
+
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
|
|
27623
27923
|
}
|
|
27624
27924
|
});
|
|
27625
27925
|
cfg.controlPoints.push({
|
|
27626
27926
|
name: "line-end",
|
|
27627
27927
|
getPosition: () => {
|
|
27628
27928
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27629
|
-
const points = this.
|
|
27929
|
+
const points = this.drawPoints;
|
|
27630
27930
|
const end = new this.scope.Point(points[2], points[3]);
|
|
27631
27931
|
return this.scope.project.view.projectToView(end.transform(matrix));
|
|
27632
27932
|
},
|
|
@@ -27636,7 +27936,8 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27636
27936
|
}
|
|
27637
27937
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27638
27938
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27639
|
-
|
|
27939
|
+
const oldPoints = this.drawPoints;
|
|
27940
|
+
this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
|
|
27640
27941
|
}
|
|
27641
27942
|
});
|
|
27642
27943
|
return cfg;
|
|
@@ -27682,10 +27983,13 @@ var ImageModel = class extends ElementModel {
|
|
|
27682
27983
|
get src() {
|
|
27683
27984
|
return this.root.get("src");
|
|
27684
27985
|
}
|
|
27685
|
-
constructor(root, scope, imageSets, liveCursor) {
|
|
27686
|
-
super(root, scope, liveCursor);
|
|
27986
|
+
constructor(root, scope, imageSets, liveCursor, isPerformanceMode) {
|
|
27987
|
+
super(root, scope, liveCursor, isPerformanceMode);
|
|
27687
27988
|
_defineProperty16(this, "item", null);
|
|
27688
27989
|
_defineProperty16(this, "imageSets", void 0);
|
|
27990
|
+
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27991
|
+
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
27992
|
+
_defineProperty16(this, "localPointsPick", 4);
|
|
27689
27993
|
this.imageSets = imageSets;
|
|
27690
27994
|
if (!this.root.has("type")) {
|
|
27691
27995
|
this.root.set("type", "image");
|
|
@@ -27704,6 +28008,7 @@ var ImageModel = class extends ElementModel {
|
|
|
27704
28008
|
}
|
|
27705
28009
|
if (!this.imageSets.querySelector(`[id='${this.uuid}']`)) {
|
|
27706
28010
|
const img = document.createElement("img");
|
|
28011
|
+
img.crossOrigin = "anonymous";
|
|
27707
28012
|
img.src = this.src;
|
|
27708
28013
|
img.id = this.uuid;
|
|
27709
28014
|
this.imageSets.appendChild(img);
|
|
@@ -27768,7 +28073,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27768
28073
|
get uuid() {
|
|
27769
28074
|
return uuidv4().replace(/-/g, "");
|
|
27770
28075
|
}
|
|
27771
|
-
constructor(
|
|
28076
|
+
constructor(options) {
|
|
27772
28077
|
super();
|
|
27773
28078
|
_defineProperty17(this, "scope", void 0);
|
|
27774
28079
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -27781,6 +28086,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27781
28086
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
27782
28087
|
_defineProperty17(this, "imageSets", void 0);
|
|
27783
28088
|
_defineProperty17(this, "liveCursor", void 0);
|
|
28089
|
+
_defineProperty17(this, "isPerformanceMode", void 0);
|
|
27784
28090
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
27785
28091
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
27786
28092
|
if (value.action === "add") {
|
|
@@ -27799,15 +28105,16 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27799
28105
|
}
|
|
27800
28106
|
}
|
|
27801
28107
|
});
|
|
27802
|
-
this.
|
|
27803
|
-
this.
|
|
27804
|
-
this.
|
|
27805
|
-
this.
|
|
27806
|
-
this.
|
|
27807
|
-
this.
|
|
27808
|
-
this.
|
|
27809
|
-
this.
|
|
27810
|
-
this.
|
|
28108
|
+
this.isPerformanceMode = options.isPerformanceMode;
|
|
28109
|
+
this.liveCursor = options.liveCursor;
|
|
28110
|
+
this.imageSets = options.imageSets;
|
|
28111
|
+
this.hasPermission = options.hasPermission;
|
|
28112
|
+
this.shadowEmitter = options.shadowEmitter;
|
|
28113
|
+
this.layerId = options.layerId;
|
|
28114
|
+
this.userManager = options.userManager;
|
|
28115
|
+
this.elements = options.elements;
|
|
28116
|
+
this.scope = options.scope;
|
|
28117
|
+
this.toolbarModel = options.toolbarModel;
|
|
27811
28118
|
this.elementModels = /* @__PURE__ */ new Map();
|
|
27812
28119
|
for (const key of this.elements.keys()) {
|
|
27813
28120
|
const type = this.elements.get(key)?.get("type");
|
|
@@ -27838,33 +28145,43 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27838
28145
|
convertToModel(yMap) {
|
|
27839
28146
|
const type = yMap.get("type");
|
|
27840
28147
|
let model = null;
|
|
28148
|
+
const uuid = yMap.get(ElementModel.KEYS.uuid);
|
|
28149
|
+
if (uuid) {
|
|
28150
|
+
const existingModel = this.elementModels.get(uuid);
|
|
28151
|
+
if (existingModel) {
|
|
28152
|
+
existingModel.shadowEmitter = this.shadowEmitter;
|
|
28153
|
+
existingModel.bindObserver();
|
|
28154
|
+
return existingModel;
|
|
28155
|
+
}
|
|
28156
|
+
}
|
|
27841
28157
|
if (type === "curve") {
|
|
27842
|
-
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28158
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27843
28159
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
27844
|
-
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28160
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
|
|
27845
28161
|
} else if (type === "selector") {
|
|
27846
|
-
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28162
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27847
28163
|
} else if (type === "arrow") {
|
|
27848
|
-
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28164
|
+
model = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27849
28165
|
} else if (type === "line") {
|
|
27850
|
-
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28166
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27851
28167
|
} else if (type === "point-text") {
|
|
27852
|
-
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28168
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27853
28169
|
} else if (type === "triangle") {
|
|
27854
|
-
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28170
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27855
28171
|
} else if (type === "rectangle") {
|
|
27856
|
-
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28172
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27857
28173
|
} else if (type === "eraser") {
|
|
27858
|
-
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28174
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
27859
28175
|
} else if (type === "laser") {
|
|
27860
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (
|
|
27861
|
-
this.removeElementItem(
|
|
27862
|
-
});
|
|
28176
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
|
|
28177
|
+
this.removeElementItem(uuid2);
|
|
28178
|
+
}, this.isPerformanceMode);
|
|
27863
28179
|
} else if (type === "image") {
|
|
27864
|
-
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28180
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
|
|
27865
28181
|
}
|
|
27866
28182
|
if (model) {
|
|
27867
28183
|
model.shadowEmitter = this.shadowEmitter;
|
|
28184
|
+
model.bindObserver();
|
|
27868
28185
|
this.elementModels.set(model.uuid, model);
|
|
27869
28186
|
}
|
|
27870
28187
|
return model;
|
|
@@ -27895,16 +28212,58 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27895
28212
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
27896
28213
|
this.elements.set(uuid, yMap);
|
|
27897
28214
|
}, elementsUndoOrigin);
|
|
27898
|
-
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28215
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
|
|
28216
|
+
model.bindObserver();
|
|
27899
28217
|
model.root.set("src", src);
|
|
27900
|
-
|
|
28218
|
+
model.ownerId = this.userManager.selfId;
|
|
28219
|
+
this.fitImageToViewport(src, model);
|
|
28220
|
+
}
|
|
28221
|
+
fitImageToViewport(src, model) {
|
|
27901
28222
|
const center = this.scope.project.view.center;
|
|
27902
|
-
|
|
28223
|
+
const fallbackMatrix = new this.scope.Matrix();
|
|
28224
|
+
fallbackMatrix.translate({
|
|
27903
28225
|
x: center.x,
|
|
27904
28226
|
y: center.y
|
|
27905
28227
|
});
|
|
27906
|
-
|
|
27907
|
-
|
|
28228
|
+
this.setElementPointsMatrix(model, fallbackMatrix);
|
|
28229
|
+
const img = document.createElement("img");
|
|
28230
|
+
img.crossOrigin = "anonymous";
|
|
28231
|
+
img.onload = () => {
|
|
28232
|
+
const naturalWidth = img.naturalWidth || img.width;
|
|
28233
|
+
const naturalHeight = img.naturalHeight || img.height;
|
|
28234
|
+
if (naturalWidth <= 0 || naturalHeight <= 0) {
|
|
28235
|
+
return;
|
|
28236
|
+
}
|
|
28237
|
+
const viewportBounds = this.scope.project.view.bounds;
|
|
28238
|
+
const maxWidth = viewportBounds.width * 2 / 3;
|
|
28239
|
+
const maxHeight = viewportBounds.height * 2 / 3;
|
|
28240
|
+
const fitScale = Math.min(maxWidth / naturalWidth, maxHeight / naturalHeight, 1);
|
|
28241
|
+
const nextMatrix = new this.scope.Matrix();
|
|
28242
|
+
nextMatrix.translate({
|
|
28243
|
+
x: center.x,
|
|
28244
|
+
y: center.y
|
|
28245
|
+
});
|
|
28246
|
+
if (fitScale > 0 && Number.isFinite(fitScale)) {
|
|
28247
|
+
nextMatrix.scale(fitScale);
|
|
28248
|
+
}
|
|
28249
|
+
this.setElementPointsMatrix(model, nextMatrix);
|
|
28250
|
+
};
|
|
28251
|
+
img.onerror = () => {
|
|
28252
|
+
log("[@netless/forge-whiteboard] failed to preload image for viewport fitting", {
|
|
28253
|
+
src
|
|
28254
|
+
}, "warn");
|
|
28255
|
+
};
|
|
28256
|
+
img.src = src;
|
|
28257
|
+
}
|
|
28258
|
+
setElementPointsMatrix(model, matrix) {
|
|
28259
|
+
const values = [matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty];
|
|
28260
|
+
if (model.root.doc) {
|
|
28261
|
+
model.root.doc.transact(() => {
|
|
28262
|
+
model.root.set(ElementModel.KEYS.pointsMatrix, values);
|
|
28263
|
+
}, elementsUndoOrigin);
|
|
28264
|
+
} else {
|
|
28265
|
+
model.root.set(ElementModel.KEYS.pointsMatrix, values);
|
|
28266
|
+
}
|
|
27908
28267
|
}
|
|
27909
28268
|
createCurve() {
|
|
27910
28269
|
let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
@@ -27912,8 +28271,10 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27912
28271
|
return null;
|
|
27913
28272
|
}
|
|
27914
28273
|
const yMap = new Y12.Map();
|
|
28274
|
+
const uuid = this.uuid;
|
|
28275
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28276
|
+
this.elementModels.set(uuid, curveModel);
|
|
27915
28277
|
this.elements.doc?.transact(() => {
|
|
27916
|
-
const uuid = this.uuid;
|
|
27917
28278
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
27918
28279
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
27919
28280
|
yMap.set("type", "curve");
|
|
@@ -27926,7 +28287,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27926
28287
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
27927
28288
|
this.elements.set(uuid, yMap);
|
|
27928
28289
|
}, elementsUndoOrigin);
|
|
27929
|
-
|
|
28290
|
+
curveModel.bindObserver();
|
|
27930
28291
|
this.initElement(curveModel);
|
|
27931
28292
|
return curveModel;
|
|
27932
28293
|
}
|
|
@@ -27935,11 +28296,17 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27935
28296
|
return null;
|
|
27936
28297
|
}
|
|
27937
28298
|
const yMap = new Y12.Map();
|
|
28299
|
+
const uuid = this.uuid;
|
|
28300
|
+
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
|
|
28301
|
+
this.removeElementItem(uuid2);
|
|
28302
|
+
}, this.isPerformanceMode);
|
|
28303
|
+
this.elementModels.set(uuid, model);
|
|
27938
28304
|
this.elements.doc?.transact(() => {
|
|
27939
|
-
const uuid = this.uuid;
|
|
27940
28305
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
27941
28306
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
27942
28307
|
yMap.set("type", "laser");
|
|
28308
|
+
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28309
|
+
yMap.set("removed", false);
|
|
27943
28310
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
27944
28311
|
yMap.set(ElementModel.KEYS.strokeWidth, 8);
|
|
27945
28312
|
yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
|
|
@@ -27947,9 +28314,8 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27947
28314
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
27948
28315
|
this.elements.set(uuid, yMap);
|
|
27949
28316
|
}, elementsUndoOrigin);
|
|
27950
|
-
|
|
27951
|
-
|
|
27952
|
-
});
|
|
28317
|
+
model.bindObserver();
|
|
28318
|
+
this.initElement(model);
|
|
27953
28319
|
return model;
|
|
27954
28320
|
}
|
|
27955
28321
|
createEraser() {
|
|
@@ -27957,11 +28323,14 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27957
28323
|
return null;
|
|
27958
28324
|
}
|
|
27959
28325
|
const yMap = new Y12.Map();
|
|
28326
|
+
const uuid = this.uuid;
|
|
28327
|
+
const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28328
|
+
this.elementModels.set(uuid, model);
|
|
27960
28329
|
this.elements.doc?.transact(() => {
|
|
27961
|
-
const uuid = this.uuid;
|
|
27962
28330
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
27963
28331
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
27964
28332
|
yMap.set("type", "eraser");
|
|
28333
|
+
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
27965
28334
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
27966
28335
|
yMap.set(ElementModel.KEYS.strokeWidth, 4);
|
|
27967
28336
|
yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
|
|
@@ -27969,7 +28338,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27969
28338
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
27970
28339
|
this.elements.set(uuid, yMap);
|
|
27971
28340
|
}, elementsUndoOrigin);
|
|
27972
|
-
|
|
28341
|
+
model.bindObserver();
|
|
27973
28342
|
return model;
|
|
27974
28343
|
}
|
|
27975
28344
|
createTriangle(shadow) {
|
|
@@ -27977,45 +28346,54 @@ var RenderableModel = class extends EventEmitter {
|
|
|
27977
28346
|
return null;
|
|
27978
28347
|
}
|
|
27979
28348
|
const yMap = new Y12.Map();
|
|
28349
|
+
const uuid = this.uuid;
|
|
28350
|
+
const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28351
|
+
this.elementModels.set(uuid, triangleModel);
|
|
27980
28352
|
this.elements.doc?.transact(() => {
|
|
27981
|
-
const uuid = this.uuid;
|
|
27982
28353
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
27983
28354
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
27984
28355
|
yMap.set("type", "triangle");
|
|
27985
28356
|
if (shadow) {
|
|
27986
28357
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
27987
28358
|
}
|
|
28359
|
+
yMap.set("points", new Y12.Array());
|
|
27988
28360
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
27989
28361
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
27990
28362
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
27991
28363
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
27992
28364
|
this.elements.set(uuid, yMap);
|
|
27993
28365
|
}, elementsUndoOrigin);
|
|
27994
|
-
|
|
27995
|
-
this.initElement(
|
|
27996
|
-
|
|
27997
|
-
return
|
|
28366
|
+
triangleModel.bindObserver();
|
|
28367
|
+
this.initElement(triangleModel);
|
|
28368
|
+
triangleModel.dashArray = this.toolbarModel.dashArray;
|
|
28369
|
+
return triangleModel;
|
|
27998
28370
|
}
|
|
27999
28371
|
createRectangle(shadow) {
|
|
28000
28372
|
if (!this.confirmPermission()) {
|
|
28001
28373
|
return null;
|
|
28002
28374
|
}
|
|
28003
28375
|
const yMap = new Y12.Map();
|
|
28376
|
+
const uuid = this.uuid;
|
|
28377
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28378
|
+
this.elementModels.set(uuid, rect);
|
|
28004
28379
|
this.elements.doc?.transact(() => {
|
|
28005
|
-
const uuid = this.uuid;
|
|
28006
28380
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28007
28381
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28008
28382
|
yMap.set("type", "rectangle");
|
|
28009
28383
|
if (shadow) {
|
|
28010
28384
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28011
28385
|
}
|
|
28386
|
+
const initPoints = new Y12.Array();
|
|
28387
|
+
initPoints.push([0, 0, 0, 0]);
|
|
28388
|
+
yMap.set("points", initPoints);
|
|
28389
|
+
yMap.set("radius", 0);
|
|
28012
28390
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28013
28391
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28014
28392
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28015
28393
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28016
28394
|
this.elements.set(uuid, yMap);
|
|
28017
28395
|
}, elementsUndoOrigin);
|
|
28018
|
-
|
|
28396
|
+
rect.bindObserver();
|
|
28019
28397
|
this.initElement(rect);
|
|
28020
28398
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
28021
28399
|
return rect;
|
|
@@ -28025,21 +28403,24 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28025
28403
|
return null;
|
|
28026
28404
|
}
|
|
28027
28405
|
const yMap = new Y12.Map();
|
|
28406
|
+
const uuid = this.uuid;
|
|
28407
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
|
|
28408
|
+
this.elementModels.set(uuid, segmentsModel);
|
|
28028
28409
|
this.elements.doc?.transact(() => {
|
|
28029
|
-
const uuid = this.uuid;
|
|
28030
28410
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28031
28411
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28032
28412
|
yMap.set("type", type);
|
|
28033
28413
|
if (shadow) {
|
|
28034
28414
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28035
28415
|
}
|
|
28416
|
+
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28036
28417
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28037
28418
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28038
28419
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28039
28420
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28040
28421
|
this.elements.set(uuid, yMap);
|
|
28041
28422
|
}, elementsUndoOrigin);
|
|
28042
|
-
|
|
28423
|
+
segmentsModel.bindObserver();
|
|
28043
28424
|
this.initElement(segmentsModel);
|
|
28044
28425
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
28045
28426
|
return segmentsModel;
|
|
@@ -28050,16 +28431,21 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28050
28431
|
return null;
|
|
28051
28432
|
}
|
|
28052
28433
|
const yMap = new Y12.Map();
|
|
28434
|
+
const uuid = this.uuid;
|
|
28435
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28436
|
+
this.elementModels.set(uuid, selectorModel);
|
|
28053
28437
|
this.elements.doc?.transact(() => {
|
|
28054
|
-
const uuid = this.uuid;
|
|
28055
28438
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28056
28439
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28057
28440
|
yMap.set("type", "selector");
|
|
28441
|
+
const initPoints = new Y12.Array();
|
|
28442
|
+
initPoints.push([0, 0, 0, 0]);
|
|
28443
|
+
yMap.set(ElementModel.KEYS.points, initPoints);
|
|
28058
28444
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28059
28445
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28060
28446
|
this.elements.set(uuid, yMap);
|
|
28061
28447
|
}, elementsUndoOrigin);
|
|
28062
|
-
|
|
28448
|
+
selectorModel.bindObserver();
|
|
28063
28449
|
selectorModel.shadow = "layer";
|
|
28064
28450
|
return selectorModel;
|
|
28065
28451
|
}
|
|
@@ -28068,21 +28454,24 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28068
28454
|
return null;
|
|
28069
28455
|
}
|
|
28070
28456
|
const yMap = new Y12.Map();
|
|
28457
|
+
const uuid = this.uuid;
|
|
28458
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28459
|
+
this.elementModels.set(uuid, straightLineModel);
|
|
28071
28460
|
this.elements.doc?.transact(() => {
|
|
28072
|
-
const uuid = this.uuid;
|
|
28073
28461
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28074
28462
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28075
28463
|
yMap.set("type", "line");
|
|
28076
28464
|
if (shadow) {
|
|
28077
28465
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28078
28466
|
}
|
|
28467
|
+
yMap.set("points", new Y12.Array());
|
|
28079
28468
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28080
28469
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28081
28470
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28082
28471
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28083
28472
|
this.elements.set(uuid, yMap);
|
|
28084
28473
|
}, elementsUndoOrigin);
|
|
28085
|
-
|
|
28474
|
+
straightLineModel.bindObserver();
|
|
28086
28475
|
this.initElement(straightLineModel);
|
|
28087
28476
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
28088
28477
|
return straightLineModel;
|
|
@@ -28092,21 +28481,26 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28092
28481
|
return null;
|
|
28093
28482
|
}
|
|
28094
28483
|
const yMap = new Y12.Map();
|
|
28484
|
+
const uuid = this.uuid;
|
|
28485
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28486
|
+
this.elementModels.set(uuid, lineModel);
|
|
28095
28487
|
this.elements.doc?.transact(() => {
|
|
28096
|
-
const uuid = this.uuid;
|
|
28097
28488
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28098
28489
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28099
28490
|
yMap.set("type", "arrow");
|
|
28100
28491
|
if (shadow) {
|
|
28101
28492
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28102
28493
|
}
|
|
28494
|
+
yMap.set("headArrow", "none");
|
|
28495
|
+
yMap.set("tailArrow", "normal");
|
|
28496
|
+
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28103
28497
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28104
28498
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28105
28499
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28106
28500
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28107
28501
|
this.elements.set(uuid, yMap);
|
|
28108
28502
|
}, elementsUndoOrigin);
|
|
28109
|
-
|
|
28503
|
+
lineModel.bindObserver();
|
|
28110
28504
|
this.initElement(lineModel);
|
|
28111
28505
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
28112
28506
|
return lineModel;
|
|
@@ -28116,21 +28510,24 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28116
28510
|
return null;
|
|
28117
28511
|
}
|
|
28118
28512
|
const yMap = new Y12.Map();
|
|
28513
|
+
const uuid = this.uuid;
|
|
28514
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28515
|
+
this.elementModels.set(uuid, pointTextModel);
|
|
28119
28516
|
this.elements.doc?.transact(() => {
|
|
28120
|
-
const uuid = this.uuid;
|
|
28121
28517
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28122
28518
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28123
28519
|
yMap.set("type", "point-text");
|
|
28124
28520
|
if (shadow) {
|
|
28125
28521
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28126
28522
|
}
|
|
28523
|
+
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28127
28524
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28128
28525
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28129
28526
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28130
28527
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28131
28528
|
this.elements.set(uuid, yMap);
|
|
28132
28529
|
}, elementsUndoOrigin);
|
|
28133
|
-
|
|
28530
|
+
pointTextModel.bindObserver();
|
|
28134
28531
|
pointTextModel.setPoints([x, y]);
|
|
28135
28532
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
28136
28533
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
@@ -28153,18 +28550,19 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28153
28550
|
});
|
|
28154
28551
|
}
|
|
28155
28552
|
dispose(clearElements) {
|
|
28156
|
-
|
|
28553
|
+
removeObserver3(this.elements, this.onElementsChange);
|
|
28157
28554
|
if (clearElements) {
|
|
28158
28555
|
this.elements.clear();
|
|
28159
28556
|
}
|
|
28160
28557
|
Array.from(this.elementModels.values()).forEach((model) => {
|
|
28161
28558
|
model.dispose();
|
|
28559
|
+
model.disposeObserver();
|
|
28162
28560
|
});
|
|
28163
28561
|
}
|
|
28164
28562
|
};
|
|
28165
28563
|
|
|
28166
28564
|
// src/utils/Recognizer.ts
|
|
28167
|
-
var
|
|
28565
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
28168
28566
|
|
|
28169
28567
|
// src/utils/UnistrokeRecognizer.js
|
|
28170
28568
|
function Point(x, y) {
|
|
@@ -28411,7 +28809,7 @@ var Recognizer = class {
|
|
|
28411
28809
|
let maxX = -Number.MAX_VALUE;
|
|
28412
28810
|
let minY = Number.MAX_VALUE;
|
|
28413
28811
|
let maxY = -Number.MAX_VALUE;
|
|
28414
|
-
const result = this.dollar.Recognize((0,
|
|
28812
|
+
const result = this.dollar.Recognize((0, import_lodash7.chunk)(points, 3).map((v) => {
|
|
28415
28813
|
minX = Math.min(minX, v[0]);
|
|
28416
28814
|
maxX = Math.max(maxX, v[0]);
|
|
28417
28815
|
minY = Math.min(minY, v[1]);
|
|
@@ -28455,11 +28853,24 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28455
28853
|
_defineProperty19(this, "elementModel", null);
|
|
28456
28854
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
28457
28855
|
_defineProperty19(this, "pointCount", 0);
|
|
28856
|
+
_defineProperty19(this, "pendingPoints", []);
|
|
28857
|
+
_defineProperty19(this, "flushRafId", 0);
|
|
28458
28858
|
_defineProperty19(this, "showLiveCursor", true);
|
|
28459
|
-
this
|
|
28859
|
+
_defineProperty19(this, "flushPendingPoints", () => {
|
|
28860
|
+
this.flushRafId = 0;
|
|
28861
|
+
if (this.elementModel && this.pendingPoints.length > 0) {
|
|
28862
|
+
this.elementModel.appendPoints(this.pendingPoints);
|
|
28863
|
+
this.pendingPoints = [];
|
|
28864
|
+
}
|
|
28865
|
+
});
|
|
28460
28866
|
}
|
|
28461
28867
|
onMouseDown(_event) {
|
|
28462
28868
|
this.pointCount = 0;
|
|
28869
|
+
this.pendingPoints = [];
|
|
28870
|
+
if (this.flushRafId) {
|
|
28871
|
+
cancelAnimationFrame(this.flushRafId);
|
|
28872
|
+
this.flushRafId = 0;
|
|
28873
|
+
}
|
|
28463
28874
|
if (this.elementModel) {
|
|
28464
28875
|
this.elementModel.dispose();
|
|
28465
28876
|
}
|
|
@@ -28474,27 +28885,38 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28474
28885
|
if (this.pointCount > 1024) {
|
|
28475
28886
|
return;
|
|
28476
28887
|
}
|
|
28477
|
-
const MIN_DISTANCE =
|
|
28888
|
+
const MIN_DISTANCE = 2;
|
|
28478
28889
|
if (this.elementModel) {
|
|
28479
|
-
|
|
28480
|
-
let
|
|
28481
|
-
|
|
28482
|
-
|
|
28483
|
-
|
|
28484
|
-
|
|
28485
|
-
|
|
28486
|
-
|
|
28487
|
-
|
|
28488
|
-
|
|
28890
|
+
let lastX = 0;
|
|
28891
|
+
let lastY = 0;
|
|
28892
|
+
if (this.pendingPoints.length >= 3) {
|
|
28893
|
+
lastX = this.pendingPoints[this.pendingPoints.length - 3];
|
|
28894
|
+
lastY = this.pendingPoints[this.pendingPoints.length - 2];
|
|
28895
|
+
} else {
|
|
28896
|
+
const len = this.elementModel.points.length;
|
|
28897
|
+
if (len >= 3) {
|
|
28898
|
+
lastX = this.elementModel.points[len - 3];
|
|
28899
|
+
lastY = this.elementModel.points[len - 2];
|
|
28900
|
+
}
|
|
28489
28901
|
}
|
|
28490
|
-
const dist = Math.max(Math.abs(
|
|
28902
|
+
const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
|
|
28491
28903
|
if (dist >= MIN_DISTANCE) {
|
|
28492
28904
|
this.pointCount += 1;
|
|
28493
|
-
|
|
28905
|
+
const nativeEvent = event.event;
|
|
28906
|
+
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
28907
|
+
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
28908
|
+
if (!this.flushRafId) {
|
|
28909
|
+
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
28910
|
+
}
|
|
28494
28911
|
}
|
|
28495
28912
|
}
|
|
28496
28913
|
}
|
|
28497
28914
|
onMouseUp(event) {
|
|
28915
|
+
if (this.flushRafId) {
|
|
28916
|
+
cancelAnimationFrame(this.flushRafId);
|
|
28917
|
+
this.flushRafId = 0;
|
|
28918
|
+
}
|
|
28919
|
+
this.flushPendingPoints();
|
|
28498
28920
|
this.modelGetter().then((model) => {
|
|
28499
28921
|
if (!model) {
|
|
28500
28922
|
return;
|
|
@@ -28595,7 +29017,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28595
29017
|
|
|
28596
29018
|
// src/model/ToolbarModel.ts
|
|
28597
29019
|
import EventEmitter2 from "eventemitter3";
|
|
28598
|
-
import { removeObserver as
|
|
29020
|
+
import { removeObserver as removeObserver4 } from "@netless/forge-room";
|
|
28599
29021
|
function _defineProperty21(e, r, t) {
|
|
28600
29022
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28601
29023
|
}
|
|
@@ -28692,7 +29114,7 @@ var ToolbarModel = class extends EventEmitter2 {
|
|
|
28692
29114
|
});
|
|
28693
29115
|
}
|
|
28694
29116
|
dispose() {
|
|
28695
|
-
|
|
29117
|
+
removeObserver4(this.root, this.handleRootUpdate);
|
|
28696
29118
|
this.removeAllListeners();
|
|
28697
29119
|
}
|
|
28698
29120
|
};
|
|
@@ -29626,6 +30048,7 @@ var Editor = class extends EventEmitter5 {
|
|
|
29626
30048
|
this.shadowContainer.remove();
|
|
29627
30049
|
this.shadowScope.project.activeLayer.addChild(this.shadowContainer);
|
|
29628
30050
|
this.targets.forEach((model) => {
|
|
30051
|
+
console.log("[][][] translateShadow model", model.root._dEH);
|
|
29629
30052
|
model.shadow = this.shadowContainer.data.uuid;
|
|
29630
30053
|
});
|
|
29631
30054
|
}
|
|
@@ -29852,7 +30275,7 @@ var Gesture = class extends EventEmitter6 {
|
|
|
29852
30275
|
};
|
|
29853
30276
|
|
|
29854
30277
|
// src/Camera.ts
|
|
29855
|
-
import { removeObserver as
|
|
30278
|
+
import { removeObserver as removeObserver5 } from "@netless/forge-room";
|
|
29856
30279
|
function _defineProperty28(e, r, t) {
|
|
29857
30280
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29858
30281
|
}
|
|
@@ -29929,14 +30352,14 @@ var Camera = class extends EventEmitter7 {
|
|
|
29929
30352
|
}
|
|
29930
30353
|
const cb = this.observers.get(user.id);
|
|
29931
30354
|
if (cb) {
|
|
29932
|
-
|
|
30355
|
+
removeObserver5(this.requestUserMap(user.id), cb);
|
|
29933
30356
|
}
|
|
29934
30357
|
});
|
|
29935
30358
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
29936
30359
|
if (this.observers.has(user.id)) {
|
|
29937
30360
|
const cb = this.observers.get(user.id);
|
|
29938
30361
|
if (cb) {
|
|
29939
|
-
|
|
30362
|
+
removeObserver5(this.requestUserMap(user.id), cb);
|
|
29940
30363
|
this.observers.delete(user.id);
|
|
29941
30364
|
}
|
|
29942
30365
|
}
|
|
@@ -30048,7 +30471,7 @@ var Camera = class extends EventEmitter7 {
|
|
|
30048
30471
|
this.handleViewMatrixUpdate(userId, evt);
|
|
30049
30472
|
};
|
|
30050
30473
|
if (this.observers.has(userId)) {
|
|
30051
|
-
|
|
30474
|
+
removeObserver5(this.requestUserMap(userId), observer);
|
|
30052
30475
|
}
|
|
30053
30476
|
this.requestUserMap(userId).observe(observer);
|
|
30054
30477
|
this.observers.set(userId, observer);
|
|
@@ -30245,10 +30668,10 @@ var Camera = class extends EventEmitter7 {
|
|
|
30245
30668
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
30246
30669
|
const cb = this.observers.get(userId);
|
|
30247
30670
|
if (cb) {
|
|
30248
|
-
|
|
30671
|
+
removeObserver5(this.requestUserMap(userId), cb);
|
|
30249
30672
|
}
|
|
30250
30673
|
});
|
|
30251
|
-
|
|
30674
|
+
removeObserver5(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
30252
30675
|
this.userManager.off("join", this.handleUserJoin);
|
|
30253
30676
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30254
30677
|
this.gesture.removeAllListeners();
|
|
@@ -30419,6 +30842,8 @@ var Whiteboard = class extends EventEmitter8 {
|
|
|
30419
30842
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
30420
30843
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
30421
30844
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
30845
|
+
_defineProperty31(this, "setPerformanceMode", void 0);
|
|
30846
|
+
_defineProperty31(this, "isPerformanceMode", void 0);
|
|
30422
30847
|
_defineProperty31(this, "removeElement", void 0);
|
|
30423
30848
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
30424
30849
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
@@ -30717,9 +31142,24 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30717
31142
|
if (this.pointCount > 1024) {
|
|
30718
31143
|
return;
|
|
30719
31144
|
}
|
|
31145
|
+
const MIN_DISTANCE = 4;
|
|
30720
31146
|
if (this.elementModel) {
|
|
30721
|
-
this.
|
|
30722
|
-
|
|
31147
|
+
const len = this.elementModel.points.length;
|
|
31148
|
+
let last = {
|
|
31149
|
+
x: 0,
|
|
31150
|
+
y: 0
|
|
31151
|
+
};
|
|
31152
|
+
if (len >= 2) {
|
|
31153
|
+
last = {
|
|
31154
|
+
x: this.elementModel.points[len - 2],
|
|
31155
|
+
y: this.elementModel.points[len - 1]
|
|
31156
|
+
};
|
|
31157
|
+
}
|
|
31158
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
31159
|
+
if (dist >= MIN_DISTANCE) {
|
|
31160
|
+
this.pointCount += 1;
|
|
31161
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
31162
|
+
}
|
|
30723
31163
|
}
|
|
30724
31164
|
}
|
|
30725
31165
|
onMouseUp(_event) {
|
|
@@ -30731,7 +31171,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30731
31171
|
|
|
30732
31172
|
// src/model/PageModel.ts
|
|
30733
31173
|
import EventEmitter10 from "eventemitter3";
|
|
30734
|
-
import { log as log2, removeObserver as
|
|
31174
|
+
import { log as log2, removeObserver as removeObserver6 } from "@netless/forge-room";
|
|
30735
31175
|
function _defineProperty35(e, r, t) {
|
|
30736
31176
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30737
31177
|
}
|
|
@@ -30764,7 +31204,7 @@ var PageModel = class extends EventEmitter10 {
|
|
|
30764
31204
|
}
|
|
30765
31205
|
const cb = this.observers.get(user.id);
|
|
30766
31206
|
if (cb) {
|
|
30767
|
-
|
|
31207
|
+
removeObserver6(this.requestUserMap(user.id), cb);
|
|
30768
31208
|
}
|
|
30769
31209
|
});
|
|
30770
31210
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -30825,7 +31265,7 @@ var PageModel = class extends EventEmitter10 {
|
|
|
30825
31265
|
if (this.observers.has(userId)) {
|
|
30826
31266
|
const cb = this.observers.get(userId);
|
|
30827
31267
|
if (cb) {
|
|
30828
|
-
|
|
31268
|
+
removeObserver6(this.requestUserMap(userId), cb);
|
|
30829
31269
|
this.observers.delete(userId);
|
|
30830
31270
|
}
|
|
30831
31271
|
}
|
|
@@ -30914,12 +31354,12 @@ var PageModel = class extends EventEmitter10 {
|
|
|
30914
31354
|
dispose() {
|
|
30915
31355
|
for (const entry of this.observers.entries()) {
|
|
30916
31356
|
const [userId, observer] = entry;
|
|
30917
|
-
|
|
31357
|
+
removeObserver6(this.requestUserMap(userId), observer);
|
|
30918
31358
|
}
|
|
30919
31359
|
this.userManager.off("join", this.handleUserJoin);
|
|
30920
31360
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30921
|
-
|
|
30922
|
-
|
|
31361
|
+
removeObserver6(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
31362
|
+
removeObserver6(this.pageMap, this.handlePageMapChange);
|
|
30923
31363
|
}
|
|
30924
31364
|
};
|
|
30925
31365
|
|
|
@@ -30935,7 +31375,7 @@ async function waitUntil(fn, timeout) {
|
|
|
30935
31375
|
// src/IndexedNavigation.ts
|
|
30936
31376
|
import EventEmitter11 from "eventemitter3";
|
|
30937
31377
|
import { log as log3 } from "@netless/forge-room";
|
|
30938
|
-
import { removeObserver as
|
|
31378
|
+
import { removeObserver as removeObserver7 } from "@netless/forge-room";
|
|
30939
31379
|
function _defineProperty36(e, r, t) {
|
|
30940
31380
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30941
31381
|
}
|
|
@@ -31278,7 +31718,7 @@ var IndexedNavigation = class extends EventEmitter11 {
|
|
|
31278
31718
|
}
|
|
31279
31719
|
}
|
|
31280
31720
|
dispose() {
|
|
31281
|
-
|
|
31721
|
+
removeObserver7(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
31282
31722
|
this.pageModel.off("switchPage");
|
|
31283
31723
|
this.pageModel.off("pagesChange");
|
|
31284
31724
|
}
|
|
@@ -31499,7 +31939,7 @@ var SequenceExecutor = class {
|
|
|
31499
31939
|
};
|
|
31500
31940
|
|
|
31501
31941
|
// src/WhiteboardApplication.ts
|
|
31502
|
-
import { removeObserver as
|
|
31942
|
+
import { removeObserver as removeObserver8 } from "@netless/forge-room";
|
|
31503
31943
|
|
|
31504
31944
|
// src/LiveCursor.ts
|
|
31505
31945
|
function _defineProperty42(e, r, t) {
|
|
@@ -31554,9 +31994,19 @@ var LiveCursor = class {
|
|
|
31554
31994
|
cursor.style.fontSize = "12px";
|
|
31555
31995
|
cursor.style.padding = "2px 4px";
|
|
31556
31996
|
cursor.style.borderRadius = "4px";
|
|
31557
|
-
|
|
31997
|
+
this.updateCursorLabel(userId, cursor);
|
|
31558
31998
|
return cursor;
|
|
31559
31999
|
}
|
|
32000
|
+
updateCursorLabel(userId, cursor) {
|
|
32001
|
+
const target = cursor ?? this.cursors.get(userId);
|
|
32002
|
+
if (!target) {
|
|
32003
|
+
return;
|
|
32004
|
+
}
|
|
32005
|
+
if (target.textContent && target.textContent !== userId) {
|
|
32006
|
+
return;
|
|
32007
|
+
}
|
|
32008
|
+
target.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
32009
|
+
}
|
|
31560
32010
|
isOnSamePage(userId) {
|
|
31561
32011
|
const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
|
|
31562
32012
|
const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
|
|
@@ -31592,6 +32042,7 @@ var LiveCursor = class {
|
|
|
31592
32042
|
}
|
|
31593
32043
|
const cursor = this.cursors.get(userId);
|
|
31594
32044
|
if (cursor) {
|
|
32045
|
+
this.updateCursorLabel(userId, cursor);
|
|
31595
32046
|
const viewPoint = this.paperScope.project.view.projectToView(point);
|
|
31596
32047
|
cursor.style.left = viewPoint.x + "px";
|
|
31597
32048
|
cursor.style.top = viewPoint.y + "px";
|
|
@@ -31707,6 +32158,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
31707
32158
|
_defineProperty43(this, "permissions", void 0);
|
|
31708
32159
|
_defineProperty43(this, "inputType", "any");
|
|
31709
32160
|
_defineProperty43(this, "isPenEvent", false);
|
|
32161
|
+
_defineProperty43(this, "activePenPointerId", null);
|
|
31710
32162
|
_defineProperty43(this, "hasPenInput", null);
|
|
31711
32163
|
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
31712
32164
|
_defineProperty43(this, "internalResizeObserver", true);
|
|
@@ -31823,6 +32275,9 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
31823
32275
|
_defineProperty43(this, "hasPermission", (flag) => {
|
|
31824
32276
|
return this.permissions.hasPermission(flag, this.userId);
|
|
31825
32277
|
});
|
|
32278
|
+
_defineProperty43(this, "isPerformanceMode", () => {
|
|
32279
|
+
return this.option.performance ?? false;
|
|
32280
|
+
});
|
|
31826
32281
|
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
31827
32282
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
31828
32283
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
@@ -31837,7 +32292,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
31837
32292
|
const id = ids[i];
|
|
31838
32293
|
if (!this.layers.has(id)) {
|
|
31839
32294
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
31840
|
-
const renderableModel = new RenderableModel(
|
|
32295
|
+
const renderableModel = new RenderableModel({
|
|
32296
|
+
layerId: id,
|
|
32297
|
+
shadowEmitter: this.shadowEmitter,
|
|
32298
|
+
elements: elementsMap,
|
|
32299
|
+
scope: this.paperScope,
|
|
32300
|
+
toolbarModel: this.toolbarModel,
|
|
32301
|
+
userManager: this.userManager,
|
|
32302
|
+
imageSets: this.imageSets,
|
|
32303
|
+
liveCursor: this.liveCursor,
|
|
32304
|
+
hasPermission: this.hasPermission,
|
|
32305
|
+
isPerformanceMode: this.isPerformanceMode
|
|
32306
|
+
});
|
|
31841
32307
|
this.layers.set(id, renderableModel);
|
|
31842
32308
|
}
|
|
31843
32309
|
if (!this.undoManagers.has(id)) {
|
|
@@ -32021,11 +32487,34 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32021
32487
|
this.imageSets.setAttribute("data-image-sets", "");
|
|
32022
32488
|
this.rootElement.appendChild(this.imageSets);
|
|
32023
32489
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
32024
|
-
|
|
32025
|
-
|
|
32026
|
-
this.
|
|
32027
|
-
this.
|
|
32028
|
-
|
|
32490
|
+
if (evt.pointerType === "pen") {
|
|
32491
|
+
this.isPenEvent = true;
|
|
32492
|
+
this.activePenPointerId = evt.pointerId;
|
|
32493
|
+
if (this.hasPenInput === null) {
|
|
32494
|
+
this.hasPenInput = true;
|
|
32495
|
+
this.inputType = "pen";
|
|
32496
|
+
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32497
|
+
}
|
|
32498
|
+
} else {
|
|
32499
|
+
if (this.activePenPointerId === null) {
|
|
32500
|
+
this.isPenEvent = false;
|
|
32501
|
+
}
|
|
32502
|
+
}
|
|
32503
|
+
}, {
|
|
32504
|
+
capture: true
|
|
32505
|
+
});
|
|
32506
|
+
document.body.addEventListener("pointerup", (evt) => {
|
|
32507
|
+
if (evt.pointerId === this.activePenPointerId) {
|
|
32508
|
+
this.activePenPointerId = null;
|
|
32509
|
+
this.isPenEvent = false;
|
|
32510
|
+
}
|
|
32511
|
+
}, {
|
|
32512
|
+
capture: true
|
|
32513
|
+
});
|
|
32514
|
+
document.body.addEventListener("pointercancel", (evt) => {
|
|
32515
|
+
if (evt.pointerId === this.activePenPointerId) {
|
|
32516
|
+
this.activePenPointerId = null;
|
|
32517
|
+
this.isPenEvent = false;
|
|
32029
32518
|
}
|
|
32030
32519
|
}, {
|
|
32031
32520
|
capture: true
|
|
@@ -32104,6 +32593,12 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32104
32593
|
this.camera.resetViewMatrixToFlow(flowId);
|
|
32105
32594
|
}
|
|
32106
32595
|
};
|
|
32596
|
+
this.emitter.setPerformanceMode = (enabled) => {
|
|
32597
|
+
this.option.performance = enabled;
|
|
32598
|
+
};
|
|
32599
|
+
this.emitter.isPerformanceMode = () => {
|
|
32600
|
+
return this.isPerformanceMode();
|
|
32601
|
+
};
|
|
32107
32602
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32108
32603
|
if (that.disableViewModelUpdate) {
|
|
32109
32604
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
@@ -32158,7 +32653,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32158
32653
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
32159
32654
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
32160
32655
|
if (!this.layers.has(targetId)) {
|
|
32161
|
-
this.layers.set(targetId, new RenderableModel(
|
|
32656
|
+
this.layers.set(targetId, new RenderableModel({
|
|
32657
|
+
layerId: targetId,
|
|
32658
|
+
shadowEmitter: this.shadowEmitter,
|
|
32659
|
+
elements: target,
|
|
32660
|
+
scope: this.paperScope,
|
|
32661
|
+
toolbarModel: this.toolbarModel,
|
|
32662
|
+
userManager: this.userManager,
|
|
32663
|
+
imageSets: this.imageSets,
|
|
32664
|
+
liveCursor: this.liveCursor,
|
|
32665
|
+
hasPermission: this.hasPermission,
|
|
32666
|
+
isPerformanceMode: this.isPerformanceMode
|
|
32667
|
+
}));
|
|
32162
32668
|
}
|
|
32163
32669
|
if (!this.undoManagers.has(targetId)) {
|
|
32164
32670
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -32393,6 +32899,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32393
32899
|
this.editors.forEach((editor) => {
|
|
32394
32900
|
editor.updateBounds();
|
|
32395
32901
|
});
|
|
32902
|
+
const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
|
|
32903
|
+
const minDistance = Math.ceil(area / 4e5);
|
|
32904
|
+
Object.keys(this.tools).forEach((key) => {
|
|
32905
|
+
this.tools[key].tool.minDistance = minDistance;
|
|
32906
|
+
});
|
|
32396
32907
|
});
|
|
32397
32908
|
this.camera.on("userPageChange", (userId, pageId) => {
|
|
32398
32909
|
this.emitter.emit("activePageChange", userId, pageId);
|
|
@@ -32661,9 +33172,14 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32661
33172
|
this.snapshotScope.view.matrix.scale(scale, this.paperScope.project.view.bounds.topLeft);
|
|
32662
33173
|
this.snapshotScope.view.viewSize = this.paperScope.project.view.viewSize.clone().multiply(scale);
|
|
32663
33174
|
}
|
|
32664
|
-
return new Promise((resolve) => {
|
|
33175
|
+
return new Promise((resolve, reject) => {
|
|
32665
33176
|
setTimeout(() => {
|
|
32666
|
-
|
|
33177
|
+
try {
|
|
33178
|
+
const res = this.snapshotScope.view.element.toDataURL("image/png");
|
|
33179
|
+
resolve(res);
|
|
33180
|
+
} catch (error) {
|
|
33181
|
+
reject(error);
|
|
33182
|
+
}
|
|
32667
33183
|
}, 32);
|
|
32668
33184
|
});
|
|
32669
33185
|
}
|
|
@@ -32741,7 +33257,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32741
33257
|
this.toolbarModel.dispose();
|
|
32742
33258
|
this.emitter.indexedNavigation.dispose();
|
|
32743
33259
|
this.permissions.dispose();
|
|
32744
|
-
|
|
33260
|
+
removeObserver8(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
|
|
32745
33261
|
log4(`whiteboard ${this.appId} disposed. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
32746
33262
|
}
|
|
32747
33263
|
};
|