microboard-temp 0.4.59 → 0.4.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +876 -874
- package/dist/cjs/index.js +876 -874
- package/dist/cjs/node.js +876 -874
- package/dist/esm/browser.js +876 -874
- package/dist/esm/index.js +876 -874
- package/dist/esm/node.js +876 -874
- package/package.json +1 -1
package/dist/esm/node.js
CHANGED
|
@@ -1271,8 +1271,8 @@ var require_tinyqueue = __commonJS((exports, module) => {
|
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
1273
|
};
|
|
1274
|
-
TinyQueue.prototype.push = function push(
|
|
1275
|
-
this.data.push(
|
|
1274
|
+
TinyQueue.prototype.push = function push(item) {
|
|
1275
|
+
this.data.push(item);
|
|
1276
1276
|
this.length++;
|
|
1277
1277
|
this._up(this.length - 1);
|
|
1278
1278
|
};
|
|
@@ -1296,24 +1296,24 @@ var require_tinyqueue = __commonJS((exports, module) => {
|
|
|
1296
1296
|
var ref = this;
|
|
1297
1297
|
var data = ref.data;
|
|
1298
1298
|
var compare = ref.compare;
|
|
1299
|
-
var
|
|
1299
|
+
var item = data[pos];
|
|
1300
1300
|
while (pos > 0) {
|
|
1301
1301
|
var parent = pos - 1 >> 1;
|
|
1302
1302
|
var current = data[parent];
|
|
1303
|
-
if (compare(
|
|
1303
|
+
if (compare(item, current) >= 0) {
|
|
1304
1304
|
break;
|
|
1305
1305
|
}
|
|
1306
1306
|
data[pos] = current;
|
|
1307
1307
|
pos = parent;
|
|
1308
1308
|
}
|
|
1309
|
-
data[pos] =
|
|
1309
|
+
data[pos] = item;
|
|
1310
1310
|
};
|
|
1311
1311
|
TinyQueue.prototype._down = function _down(pos) {
|
|
1312
1312
|
var ref = this;
|
|
1313
1313
|
var data = ref.data;
|
|
1314
1314
|
var compare = ref.compare;
|
|
1315
1315
|
var halfLength = this.length >> 1;
|
|
1316
|
-
var
|
|
1316
|
+
var item = data[pos];
|
|
1317
1317
|
while (pos < halfLength) {
|
|
1318
1318
|
var left = (pos << 1) + 1;
|
|
1319
1319
|
var best = data[left];
|
|
@@ -1322,13 +1322,13 @@ var require_tinyqueue = __commonJS((exports, module) => {
|
|
|
1322
1322
|
left = right;
|
|
1323
1323
|
best = data[right];
|
|
1324
1324
|
}
|
|
1325
|
-
if (compare(best,
|
|
1325
|
+
if (compare(best, item) >= 0) {
|
|
1326
1326
|
break;
|
|
1327
1327
|
}
|
|
1328
1328
|
data[pos] = best;
|
|
1329
1329
|
pos = left;
|
|
1330
1330
|
}
|
|
1331
|
-
data[pos] =
|
|
1331
|
+
data[pos] = item;
|
|
1332
1332
|
};
|
|
1333
1333
|
function defaultCompare2(a, b) {
|
|
1334
1334
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -1419,8 +1419,8 @@ class BoardCommand {
|
|
|
1419
1419
|
switch (operation.method) {
|
|
1420
1420
|
case "bringToFront": {
|
|
1421
1421
|
for (const id in operation.prevZIndex) {
|
|
1422
|
-
const
|
|
1423
|
-
if (!
|
|
1422
|
+
const item = this.board.items.getById(id);
|
|
1423
|
+
if (!item) {
|
|
1424
1424
|
delete operation.prevZIndex.id;
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
@@ -1432,8 +1432,8 @@ class BoardCommand {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
case "sendToBack": {
|
|
1434
1434
|
for (const id in operation.prevZIndex) {
|
|
1435
|
-
const
|
|
1436
|
-
if (!
|
|
1435
|
+
const item = this.board.items.getById(id);
|
|
1436
|
+
if (!item) {
|
|
1437
1437
|
delete operation.prevZIndex.id;
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
@@ -1447,11 +1447,11 @@ class BoardCommand {
|
|
|
1447
1447
|
case "moveSecondBeforeFirst":
|
|
1448
1448
|
case "moveToZIndex": {
|
|
1449
1449
|
const items = this.board.items;
|
|
1450
|
-
const
|
|
1451
|
-
if (!
|
|
1450
|
+
const item = items.getById(operation.item);
|
|
1451
|
+
if (!item) {
|
|
1452
1452
|
throw new Error("Get reverse board operation. Item not found");
|
|
1453
1453
|
}
|
|
1454
|
-
const zIndex = this.board.getZIndex(
|
|
1454
|
+
const zIndex = this.board.getZIndex(item);
|
|
1455
1455
|
return {
|
|
1456
1456
|
class: "Board",
|
|
1457
1457
|
method: "moveToZIndex",
|
|
@@ -1461,8 +1461,8 @@ class BoardCommand {
|
|
|
1461
1461
|
}
|
|
1462
1462
|
case "moveManyToZIndex": {
|
|
1463
1463
|
for (const id in operation.item) {
|
|
1464
|
-
const
|
|
1465
|
-
if (!
|
|
1464
|
+
const item = this.board.items.getById(id);
|
|
1465
|
+
if (!item) {
|
|
1466
1466
|
delete operation.item.id;
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
@@ -1479,15 +1479,15 @@ class BoardCommand {
|
|
|
1479
1479
|
const items = this.board.items;
|
|
1480
1480
|
const reverse = [];
|
|
1481
1481
|
for (const itemId of operation.item) {
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1482
|
+
const item = items.getById(itemId);
|
|
1483
|
+
if (!item) {
|
|
1484
1484
|
throw new Error("Get reverse board operation. Item not found");
|
|
1485
1485
|
}
|
|
1486
1486
|
reverse.push({
|
|
1487
1487
|
class: "Board",
|
|
1488
1488
|
method: "add",
|
|
1489
1489
|
item: itemId,
|
|
1490
|
-
data:
|
|
1490
|
+
data: item.serialize()
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
return reverse;
|
|
@@ -1510,32 +1510,32 @@ class BoardCommand {
|
|
|
1510
1510
|
const items = this.board.items;
|
|
1511
1511
|
const reverse = [];
|
|
1512
1512
|
for (const itemId of operation.item) {
|
|
1513
|
-
const
|
|
1514
|
-
if (!
|
|
1513
|
+
const item = items.getById(itemId);
|
|
1514
|
+
if (!item || item.itemType !== "Group") {
|
|
1515
1515
|
throw new Error("Get reverse board operation. Item not found");
|
|
1516
1516
|
}
|
|
1517
1517
|
reverse.push({
|
|
1518
1518
|
class: "Board",
|
|
1519
1519
|
method: "addLockedGroup",
|
|
1520
1520
|
item: itemId,
|
|
1521
|
-
data:
|
|
1521
|
+
data: item.serialize()
|
|
1522
1522
|
});
|
|
1523
1523
|
}
|
|
1524
1524
|
return reverse;
|
|
1525
1525
|
}
|
|
1526
1526
|
case "duplicate":
|
|
1527
1527
|
case "paste": {
|
|
1528
|
-
const
|
|
1528
|
+
const item = [];
|
|
1529
1529
|
const map = operation.itemsMap;
|
|
1530
1530
|
for (const key in map) {
|
|
1531
1531
|
if (map.hasOwnProperty(key)) {
|
|
1532
|
-
|
|
1532
|
+
item.push(key);
|
|
1533
1533
|
}
|
|
1534
1534
|
}
|
|
1535
1535
|
return {
|
|
1536
1536
|
class: "Board",
|
|
1537
1537
|
method: "remove",
|
|
1538
|
-
item
|
|
1538
|
+
item
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
1541
|
}
|
|
@@ -7853,11 +7853,11 @@ class SubjectOperation {
|
|
|
7853
7853
|
}
|
|
7854
7854
|
|
|
7855
7855
|
// src/Items/ItemsCommandUtils.ts
|
|
7856
|
-
function mapItemsByOperation(
|
|
7857
|
-
const items = Array.isArray(
|
|
7858
|
-
return items.map((
|
|
7859
|
-
const operation = getCallback(
|
|
7860
|
-
return { item:
|
|
7856
|
+
function mapItemsByOperation(item, getCallback) {
|
|
7857
|
+
const items = Array.isArray(item) ? item : [item];
|
|
7858
|
+
return items.map((item2) => {
|
|
7859
|
+
const operation = getCallback(item2);
|
|
7860
|
+
return { item: item2, operation };
|
|
7861
7861
|
});
|
|
7862
7862
|
}
|
|
7863
7863
|
|
|
@@ -7882,8 +7882,8 @@ class TransformationCommand {
|
|
|
7882
7882
|
}
|
|
7883
7883
|
}
|
|
7884
7884
|
revert() {
|
|
7885
|
-
this.reverse.forEach(({ item
|
|
7886
|
-
|
|
7885
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
7886
|
+
item.apply(operation);
|
|
7887
7887
|
});
|
|
7888
7888
|
}
|
|
7889
7889
|
getReverse() {
|
|
@@ -8625,8 +8625,8 @@ class Path {
|
|
|
8625
8625
|
}
|
|
8626
8626
|
getIntersectionPoints(segment) {
|
|
8627
8627
|
let intersections = [];
|
|
8628
|
-
for (const
|
|
8629
|
-
intersections = intersections.concat(
|
|
8628
|
+
for (const item of this.segments) {
|
|
8629
|
+
intersections = intersections.concat(item.getIntersectionPoints(segment));
|
|
8630
8630
|
}
|
|
8631
8631
|
return intersections;
|
|
8632
8632
|
}
|
|
@@ -8691,8 +8691,8 @@ class Path {
|
|
|
8691
8691
|
}
|
|
8692
8692
|
isOpenEnclosedOrCrossedBy(rectangle) {
|
|
8693
8693
|
let is = false;
|
|
8694
|
-
for (const
|
|
8695
|
-
is = is ||
|
|
8694
|
+
for (const item of this.segments) {
|
|
8695
|
+
is = is || item.isEnclosedOrCrossedBy(rectangle);
|
|
8696
8696
|
}
|
|
8697
8697
|
return is;
|
|
8698
8698
|
}
|
|
@@ -9105,8 +9105,8 @@ class ConnectorCommand {
|
|
|
9105
9105
|
}
|
|
9106
9106
|
}
|
|
9107
9107
|
revert() {
|
|
9108
|
-
for (const { item
|
|
9109
|
-
|
|
9108
|
+
for (const { item, operation } of this.reverse) {
|
|
9109
|
+
item.apply(operation);
|
|
9110
9110
|
}
|
|
9111
9111
|
}
|
|
9112
9112
|
getReverse() {
|
|
@@ -9263,11 +9263,11 @@ class SessionStorage {
|
|
|
9263
9263
|
}
|
|
9264
9264
|
get(key) {
|
|
9265
9265
|
const boardId = this.getBoardId() || "";
|
|
9266
|
-
const
|
|
9267
|
-
if (!
|
|
9266
|
+
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
9267
|
+
if (!item) {
|
|
9268
9268
|
return;
|
|
9269
9269
|
}
|
|
9270
|
-
return JSON.parse(
|
|
9270
|
+
return JSON.parse(item);
|
|
9271
9271
|
}
|
|
9272
9272
|
remove(key) {
|
|
9273
9273
|
const boardId = this.getBoardId() || "";
|
|
@@ -10052,8 +10052,8 @@ class LinkToCommand {
|
|
|
10052
10052
|
}
|
|
10053
10053
|
}
|
|
10054
10054
|
revert() {
|
|
10055
|
-
this.reverse.forEach(({ item
|
|
10056
|
-
|
|
10055
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
10056
|
+
item.apply(operation);
|
|
10057
10057
|
});
|
|
10058
10058
|
}
|
|
10059
10059
|
getReverse() {
|
|
@@ -11390,9 +11390,9 @@ function handleSplitListItem(editor) {
|
|
|
11390
11390
|
Transforms2.insertNodes(editor, {
|
|
11391
11391
|
type: listType,
|
|
11392
11392
|
listLevel: listNode.listLevel || 0,
|
|
11393
|
-
children: itemsAfter.map((
|
|
11393
|
+
children: itemsAfter.map((item) => ({
|
|
11394
11394
|
type: "list_item",
|
|
11395
|
-
children:
|
|
11395
|
+
children: item.children
|
|
11396
11396
|
}))
|
|
11397
11397
|
}, { at: newListPath });
|
|
11398
11398
|
}
|
|
@@ -15250,10 +15250,10 @@ function initializeDocument(effects) {
|
|
|
15250
15250
|
return start;
|
|
15251
15251
|
function start(code) {
|
|
15252
15252
|
if (continued < stack.length) {
|
|
15253
|
-
const
|
|
15254
|
-
self2.containerState =
|
|
15255
|
-
ok(
|
|
15256
|
-
return effects.attempt(
|
|
15253
|
+
const item = stack[continued];
|
|
15254
|
+
self2.containerState = item[1];
|
|
15255
|
+
ok(item[0].continuation, "expected `continuation` to be defined on container construct");
|
|
15256
|
+
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
|
|
15257
15257
|
}
|
|
15258
15258
|
return checkNewContainers(code);
|
|
15259
15259
|
}
|
|
@@ -16229,17 +16229,17 @@ class SpliceBuffer {
|
|
|
16229
16229
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16230
16230
|
return this.left.pop();
|
|
16231
16231
|
}
|
|
16232
|
-
push(
|
|
16232
|
+
push(item) {
|
|
16233
16233
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16234
|
-
this.left.push(
|
|
16234
|
+
this.left.push(item);
|
|
16235
16235
|
}
|
|
16236
16236
|
pushMany(items) {
|
|
16237
16237
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16238
16238
|
chunkedPush(this.left, items);
|
|
16239
16239
|
}
|
|
16240
|
-
unshift(
|
|
16240
|
+
unshift(item) {
|
|
16241
16241
|
this.setCursor(0);
|
|
16242
|
-
this.right.push(
|
|
16242
|
+
this.right.push(item);
|
|
16243
16243
|
}
|
|
16244
16244
|
unshiftMany(items) {
|
|
16245
16245
|
this.setCursor(0);
|
|
@@ -18270,8 +18270,8 @@ function initializeFactory(field) {
|
|
|
18270
18270
|
if (list2) {
|
|
18271
18271
|
ok(Array.isArray(list2), "expected `disable.null` to be populated");
|
|
18272
18272
|
while (++index2 < list2.length) {
|
|
18273
|
-
const
|
|
18274
|
-
if (!
|
|
18273
|
+
const item = list2[index2];
|
|
18274
|
+
if (!item.previous || item.previous.call(self2, self2.previous)) {
|
|
18275
18275
|
return true;
|
|
18276
18276
|
}
|
|
18277
18277
|
}
|
|
@@ -19102,14 +19102,14 @@ function compiler(options) {
|
|
|
19102
19102
|
length++;
|
|
19103
19103
|
}
|
|
19104
19104
|
if (event[1].type === types.listItemPrefix) {
|
|
19105
|
-
const
|
|
19105
|
+
const item = {
|
|
19106
19106
|
type: "listItem",
|
|
19107
19107
|
_spread: false,
|
|
19108
19108
|
start: Object.assign({}, event[1].start),
|
|
19109
19109
|
end: undefined
|
|
19110
19110
|
};
|
|
19111
|
-
listItem2 =
|
|
19112
|
-
events.splice(index2, 0, ["enter",
|
|
19111
|
+
listItem2 = item;
|
|
19112
|
+
events.splice(index2, 0, ["enter", item, event[2]]);
|
|
19113
19113
|
index2++;
|
|
19114
19114
|
length++;
|
|
19115
19115
|
firstBlankLineIndex = undefined;
|
|
@@ -19741,14 +19741,14 @@ class MarkdownProcessor {
|
|
|
19741
19741
|
if (err || !file) {
|
|
19742
19742
|
throw err;
|
|
19743
19743
|
}
|
|
19744
|
-
const nodes = file.result.map((
|
|
19744
|
+
const nodes = file.result.map((item) => {
|
|
19745
19745
|
setNodeStyles({
|
|
19746
|
-
node:
|
|
19746
|
+
node: item,
|
|
19747
19747
|
editor: this.editor,
|
|
19748
19748
|
horisontalAlignment: "left",
|
|
19749
|
-
isPaddingTopNeeded:
|
|
19749
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
19750
19750
|
});
|
|
19751
|
-
return
|
|
19751
|
+
return item;
|
|
19752
19752
|
});
|
|
19753
19753
|
if (isNewParagraphNeeded) {
|
|
19754
19754
|
nodes.push(createParagraphNode("", this.editor));
|
|
@@ -20726,8 +20726,8 @@ class ShapeCommand {
|
|
|
20726
20726
|
}
|
|
20727
20727
|
}
|
|
20728
20728
|
revert() {
|
|
20729
|
-
for (const { item
|
|
20730
|
-
|
|
20729
|
+
for (const { item, operation } of this.reverse) {
|
|
20730
|
+
item.apply(operation);
|
|
20731
20731
|
}
|
|
20732
20732
|
}
|
|
20733
20733
|
getReverse() {
|
|
@@ -20809,8 +20809,8 @@ class RichTextCommand {
|
|
|
20809
20809
|
}
|
|
20810
20810
|
}
|
|
20811
20811
|
revert() {
|
|
20812
|
-
for (const { item
|
|
20813
|
-
const richText = this.board.items.getById(
|
|
20812
|
+
for (const { item, operation } of this.reverse) {
|
|
20813
|
+
const richText = this.board.items.getById(item);
|
|
20814
20814
|
if (!richText) {
|
|
20815
20815
|
continue;
|
|
20816
20816
|
}
|
|
@@ -20829,12 +20829,12 @@ class RichTextCommand {
|
|
|
20829
20829
|
case "setSelectionFontColor":
|
|
20830
20830
|
case "setSelectionBlockType":
|
|
20831
20831
|
const inverseOps = this.operation.ops.map((op) => Operation2.inverse(op)).reverse();
|
|
20832
|
-
return items.map((
|
|
20832
|
+
return items.map((item) => {
|
|
20833
20833
|
const operation = {
|
|
20834
20834
|
...this.operation,
|
|
20835
20835
|
ops: inverseOps
|
|
20836
20836
|
};
|
|
20837
|
-
return { item
|
|
20837
|
+
return { item, operation };
|
|
20838
20838
|
});
|
|
20839
20839
|
case "setFontColor":
|
|
20840
20840
|
return items.map((id) => ({
|
|
@@ -20926,13 +20926,13 @@ class RichTextGroupCommand {
|
|
|
20926
20926
|
this.reverseOps = this.getReverse();
|
|
20927
20927
|
}
|
|
20928
20928
|
apply() {
|
|
20929
|
-
for (const { item
|
|
20930
|
-
|
|
20929
|
+
for (const { item, operation } of this.forwardOps) {
|
|
20930
|
+
item.applyCommand(operation);
|
|
20931
20931
|
}
|
|
20932
20932
|
}
|
|
20933
20933
|
revert() {
|
|
20934
|
-
for (const { item
|
|
20935
|
-
|
|
20934
|
+
for (const { item, operation } of this.reverseOps) {
|
|
20935
|
+
item.applyCommand(operation);
|
|
20936
20936
|
}
|
|
20937
20937
|
}
|
|
20938
20938
|
getForward() {
|
|
@@ -21047,8 +21047,8 @@ class DrawingCommand {
|
|
|
21047
21047
|
item;
|
|
21048
21048
|
operation;
|
|
21049
21049
|
reverse;
|
|
21050
|
-
constructor(
|
|
21051
|
-
this.item =
|
|
21050
|
+
constructor(item, operation) {
|
|
21051
|
+
this.item = item;
|
|
21052
21052
|
this.operation = operation;
|
|
21053
21053
|
this.reverse = this.getReverse();
|
|
21054
21054
|
}
|
|
@@ -21057,52 +21057,52 @@ class DrawingCommand {
|
|
|
21057
21057
|
return this;
|
|
21058
21058
|
}
|
|
21059
21059
|
apply() {
|
|
21060
|
-
for (const
|
|
21061
|
-
|
|
21060
|
+
for (const item of this.item) {
|
|
21061
|
+
item.apply(this.operation);
|
|
21062
21062
|
}
|
|
21063
21063
|
}
|
|
21064
21064
|
revert() {
|
|
21065
|
-
for (const { item
|
|
21066
|
-
|
|
21065
|
+
for (const { item, operation } of this.reverse) {
|
|
21066
|
+
item.apply(operation);
|
|
21067
21067
|
}
|
|
21068
21068
|
}
|
|
21069
21069
|
getReverse() {
|
|
21070
21070
|
const reverse = [];
|
|
21071
|
-
for (const
|
|
21072
|
-
reverse.push({ item
|
|
21071
|
+
for (const item of this.item) {
|
|
21072
|
+
reverse.push({ item, operation: this.getReverseOperation(item) });
|
|
21073
21073
|
}
|
|
21074
21074
|
return reverse;
|
|
21075
21075
|
}
|
|
21076
|
-
getReverseOperation(
|
|
21076
|
+
getReverseOperation(item) {
|
|
21077
21077
|
switch (this.operation.method) {
|
|
21078
21078
|
case "setStrokeColor":
|
|
21079
21079
|
return {
|
|
21080
21080
|
class: "Drawing",
|
|
21081
21081
|
method: "setStrokeColor",
|
|
21082
|
-
item: [
|
|
21083
|
-
color:
|
|
21082
|
+
item: [item.getId()],
|
|
21083
|
+
color: item.getStrokeColor()
|
|
21084
21084
|
};
|
|
21085
21085
|
case "setStrokeWidth":
|
|
21086
21086
|
return {
|
|
21087
21087
|
class: "Drawing",
|
|
21088
21088
|
method: "setStrokeWidth",
|
|
21089
|
-
item: [
|
|
21089
|
+
item: [item.getId()],
|
|
21090
21090
|
width: this.operation.prevWidth,
|
|
21091
|
-
prevWidth:
|
|
21091
|
+
prevWidth: item.getStrokeWidth()
|
|
21092
21092
|
};
|
|
21093
21093
|
case "setStrokeOpacity":
|
|
21094
21094
|
return {
|
|
21095
21095
|
class: "Drawing",
|
|
21096
21096
|
method: "setStrokeOpacity",
|
|
21097
|
-
item: [
|
|
21098
|
-
opacity:
|
|
21097
|
+
item: [item.getId()],
|
|
21098
|
+
opacity: item.getStrokeOpacity()
|
|
21099
21099
|
};
|
|
21100
21100
|
case "setStrokeStyle":
|
|
21101
21101
|
return {
|
|
21102
21102
|
class: "Drawing",
|
|
21103
21103
|
method: "setStrokeStyle",
|
|
21104
|
-
item: [
|
|
21105
|
-
style:
|
|
21104
|
+
item: [item.getId()],
|
|
21105
|
+
style: item.getBorderStyle()
|
|
21106
21106
|
};
|
|
21107
21107
|
}
|
|
21108
21108
|
}
|
|
@@ -21124,8 +21124,8 @@ class StickerCommand {
|
|
|
21124
21124
|
}
|
|
21125
21125
|
}
|
|
21126
21126
|
revert() {
|
|
21127
|
-
for (const { item
|
|
21128
|
-
|
|
21127
|
+
for (const { item, operation } of this.reverse) {
|
|
21128
|
+
item.apply(operation);
|
|
21129
21129
|
}
|
|
21130
21130
|
}
|
|
21131
21131
|
getReverse() {
|
|
@@ -21157,8 +21157,8 @@ class FrameCommand {
|
|
|
21157
21157
|
}
|
|
21158
21158
|
}
|
|
21159
21159
|
revert() {
|
|
21160
|
-
for (const { item
|
|
21161
|
-
|
|
21160
|
+
for (const { item, operation } of this.reverse) {
|
|
21161
|
+
item.apply(operation);
|
|
21162
21162
|
}
|
|
21163
21163
|
}
|
|
21164
21164
|
getReverse() {
|
|
@@ -21200,21 +21200,23 @@ class FrameCommand {
|
|
|
21200
21200
|
};
|
|
21201
21201
|
});
|
|
21202
21202
|
default:
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21203
|
+
return mapItemsByOperation(frame, (item) => {
|
|
21204
|
+
const op = this.operation;
|
|
21205
|
+
let newData = {};
|
|
21206
|
+
if (op.prevData) {
|
|
21207
|
+
newData = { ...op.prevData };
|
|
21208
|
+
} else {
|
|
21209
|
+
Object.keys(op.newData).forEach((key) => {
|
|
21210
|
+
if (item[key]) {
|
|
21211
|
+
newData[key] = item[key];
|
|
21212
|
+
}
|
|
21213
|
+
});
|
|
21214
|
+
}
|
|
21215
|
+
return {
|
|
21216
|
+
...op,
|
|
21217
|
+
newData
|
|
21218
|
+
};
|
|
21219
|
+
});
|
|
21218
21220
|
}
|
|
21219
21221
|
}
|
|
21220
21222
|
}
|
|
@@ -21235,8 +21237,8 @@ class CommentCommand {
|
|
|
21235
21237
|
}
|
|
21236
21238
|
}
|
|
21237
21239
|
revert() {
|
|
21238
|
-
this.reverse.forEach(({ item
|
|
21239
|
-
|
|
21240
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
21241
|
+
item.apply(operation);
|
|
21240
21242
|
});
|
|
21241
21243
|
}
|
|
21242
21244
|
getReverse() {
|
|
@@ -21697,8 +21699,8 @@ class GroupCommand {
|
|
|
21697
21699
|
}
|
|
21698
21700
|
}
|
|
21699
21701
|
revert() {
|
|
21700
|
-
for (const { item
|
|
21701
|
-
|
|
21702
|
+
for (const { item, operation } of this.reverse) {
|
|
21703
|
+
item.apply(operation);
|
|
21702
21704
|
}
|
|
21703
21705
|
}
|
|
21704
21706
|
getReverse() {
|
|
@@ -21751,8 +21753,8 @@ class PlaceholderCommand {
|
|
|
21751
21753
|
}
|
|
21752
21754
|
}
|
|
21753
21755
|
revert() {
|
|
21754
|
-
for (const { item
|
|
21755
|
-
|
|
21756
|
+
for (const { item, operation } of this.reverse) {
|
|
21757
|
+
item.apply(operation);
|
|
21756
21758
|
}
|
|
21757
21759
|
}
|
|
21758
21760
|
getReverse() {
|
|
@@ -21846,26 +21848,26 @@ class BaseCommand {
|
|
|
21846
21848
|
return this;
|
|
21847
21849
|
}
|
|
21848
21850
|
apply() {
|
|
21849
|
-
for (const
|
|
21850
|
-
|
|
21851
|
+
for (const item of this.items) {
|
|
21852
|
+
item.apply(this.operation);
|
|
21851
21853
|
}
|
|
21852
21854
|
}
|
|
21853
21855
|
revert() {
|
|
21854
|
-
for (const { item
|
|
21855
|
-
|
|
21856
|
+
for (const { item, operation } of this.reverse) {
|
|
21857
|
+
item.apply(operation);
|
|
21856
21858
|
}
|
|
21857
21859
|
}
|
|
21858
21860
|
getReverse() {
|
|
21859
21861
|
const items = this.items;
|
|
21860
|
-
return mapItemsByOperation(items, (
|
|
21862
|
+
return mapItemsByOperation(items, (item) => {
|
|
21861
21863
|
const op = this.operation;
|
|
21862
21864
|
let newData = {};
|
|
21863
21865
|
if (op.prevData) {
|
|
21864
21866
|
newData = { ...op.prevData };
|
|
21865
21867
|
} else {
|
|
21866
21868
|
Object.keys(op.newData).forEach((key) => {
|
|
21867
|
-
if (
|
|
21868
|
-
newData[key] =
|
|
21869
|
+
if (item[key]) {
|
|
21870
|
+
newData[key] = item[key];
|
|
21869
21871
|
}
|
|
21870
21872
|
});
|
|
21871
21873
|
}
|
|
@@ -21893,37 +21895,37 @@ var itemCommandFactories = {
|
|
|
21893
21895
|
LinkTo: createLinkToCommand
|
|
21894
21896
|
};
|
|
21895
21897
|
function createConnectorCommand(items, operation) {
|
|
21896
|
-
return new ConnectorCommand(items.filter((
|
|
21898
|
+
return new ConnectorCommand(items.filter((item) => item.itemType === "Connector"), operation);
|
|
21897
21899
|
}
|
|
21898
21900
|
function createShapeCommand(items, operation) {
|
|
21899
|
-
return new ShapeCommand(items.filter((
|
|
21901
|
+
return new ShapeCommand(items.filter((item) => item.itemType === "Shape"), operation);
|
|
21900
21902
|
}
|
|
21901
21903
|
function createDrawingCommand(items, operation) {
|
|
21902
|
-
return new DrawingCommand(items.filter((
|
|
21904
|
+
return new DrawingCommand(items.filter((item) => item.itemType === "Drawing"), operation);
|
|
21903
21905
|
}
|
|
21904
21906
|
function createCommentCommand(items, operation) {
|
|
21905
|
-
return new CommentCommand(items.filter((
|
|
21907
|
+
return new CommentCommand(items.filter((item) => item.itemType === "Comment"), operation);
|
|
21906
21908
|
}
|
|
21907
21909
|
function createStickerCommand(items, operation) {
|
|
21908
|
-
return new StickerCommand(items.filter((
|
|
21910
|
+
return new StickerCommand(items.filter((item) => item.itemType === "Sticker"), operation);
|
|
21909
21911
|
}
|
|
21910
21912
|
function createFrameCommand(items, operation) {
|
|
21911
|
-
return new FrameCommand(items.filter((
|
|
21913
|
+
return new FrameCommand(items.filter((item) => item.itemType === "Frame"), operation);
|
|
21912
21914
|
}
|
|
21913
21915
|
function createPlaceholderCommand(items, operation) {
|
|
21914
|
-
return new PlaceholderCommand(items.filter((
|
|
21916
|
+
return new PlaceholderCommand(items.filter((item) => item.itemType === "Placeholder"), operation);
|
|
21915
21917
|
}
|
|
21916
21918
|
function createGroupCommand(items, operation) {
|
|
21917
|
-
return new GroupCommand(items.filter((
|
|
21919
|
+
return new GroupCommand(items.filter((item) => item.itemType === "Group"), operation);
|
|
21918
21920
|
}
|
|
21919
21921
|
function createImageCommand(items, operation) {
|
|
21920
|
-
return new ImageCommand(items.filter((
|
|
21922
|
+
return new ImageCommand(items.filter((item) => item.itemType === "Image"), operation);
|
|
21921
21923
|
}
|
|
21922
21924
|
function createVideoCommand(items, operation) {
|
|
21923
|
-
return new VideoCommand(items.filter((
|
|
21925
|
+
return new VideoCommand(items.filter((item) => item.itemType === "Video"), operation);
|
|
21924
21926
|
}
|
|
21925
21927
|
function createAudioCommand(items, operation) {
|
|
21926
|
-
return new AudioCommand(items.filter((
|
|
21928
|
+
return new AudioCommand(items.filter((item) => item.itemType === "Audio"), operation);
|
|
21927
21929
|
}
|
|
21928
21930
|
function createRichTextCommand(items, operation, board) {
|
|
21929
21931
|
if (!board) {
|
|
@@ -21931,8 +21933,8 @@ function createRichTextCommand(items, operation, board) {
|
|
|
21931
21933
|
}
|
|
21932
21934
|
if (operation.method === "groupEdit") {
|
|
21933
21935
|
const texts = [];
|
|
21934
|
-
for (const { item
|
|
21935
|
-
const found = board.items.findById(
|
|
21936
|
+
for (const { item } of operation.itemsOps) {
|
|
21937
|
+
const found = board.items.findById(item);
|
|
21936
21938
|
const text3 = found?.getRichText();
|
|
21937
21939
|
if (text3) {
|
|
21938
21940
|
texts.push(text3);
|
|
@@ -21940,14 +21942,14 @@ function createRichTextCommand(items, operation, board) {
|
|
|
21940
21942
|
}
|
|
21941
21943
|
return new RichTextGroupCommand(texts, operation);
|
|
21942
21944
|
} else {
|
|
21943
|
-
return new RichTextCommand(board, items.map((
|
|
21945
|
+
return new RichTextCommand(board, items.map((item) => item.getId()), operation);
|
|
21944
21946
|
}
|
|
21945
21947
|
}
|
|
21946
21948
|
function createTransformationCommand(items, operation) {
|
|
21947
|
-
return new TransformationCommand(items.map((
|
|
21949
|
+
return new TransformationCommand(items.map((item) => item.transformation), operation);
|
|
21948
21950
|
}
|
|
21949
21951
|
function createLinkToCommand(items, operation) {
|
|
21950
|
-
return new LinkToCommand(items.map((
|
|
21952
|
+
return new LinkToCommand(items.map((item) => item.linkTo), operation);
|
|
21951
21953
|
}
|
|
21952
21954
|
function createCommand(board, operation) {
|
|
21953
21955
|
try {
|
|
@@ -21965,13 +21967,13 @@ function createCommand(board, operation) {
|
|
|
21965
21967
|
default: {
|
|
21966
21968
|
const itemType = operation.class;
|
|
21967
21969
|
const itemIdList = "item" in operation ? Array.isArray(operation.item) ? operation.item : [operation.item] : ("items" in operation) ? Object.keys(operation.items) : operation.itemsOps.map((itemOp) => itemOp.item);
|
|
21968
|
-
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((
|
|
21969
|
-
if (typeof
|
|
21970
|
-
console.warn(`Item with ID ${
|
|
21970
|
+
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
|
|
21971
|
+
if (typeof item === "string") {
|
|
21972
|
+
console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
|
|
21971
21973
|
return false;
|
|
21972
21974
|
}
|
|
21973
|
-
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" &&
|
|
21974
|
-
console.warn(`Item with ID ${
|
|
21975
|
+
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" && item.itemType !== operation.class) {
|
|
21976
|
+
console.warn(`Item with ID ${item} is not of operation type: ${itemType}.`);
|
|
21975
21977
|
return false;
|
|
21976
21978
|
}
|
|
21977
21979
|
return true;
|
|
@@ -22272,20 +22274,20 @@ class RBush {
|
|
|
22272
22274
|
}
|
|
22273
22275
|
return this;
|
|
22274
22276
|
}
|
|
22275
|
-
insert(
|
|
22276
|
-
if (
|
|
22277
|
-
this._insert(
|
|
22277
|
+
insert(item) {
|
|
22278
|
+
if (item)
|
|
22279
|
+
this._insert(item, this.data.height - 1);
|
|
22278
22280
|
return this;
|
|
22279
22281
|
}
|
|
22280
22282
|
clear() {
|
|
22281
22283
|
this.data = createNode([]);
|
|
22282
22284
|
return this;
|
|
22283
22285
|
}
|
|
22284
|
-
remove(
|
|
22285
|
-
if (!
|
|
22286
|
+
remove(item, equalsFn) {
|
|
22287
|
+
if (!item)
|
|
22286
22288
|
return this;
|
|
22287
22289
|
let node2 = this.data;
|
|
22288
|
-
const bbox = this.toBBox(
|
|
22290
|
+
const bbox = this.toBBox(item);
|
|
22289
22291
|
const path2 = [];
|
|
22290
22292
|
const indexes = [];
|
|
22291
22293
|
let i, parent, goingUp;
|
|
@@ -22297,7 +22299,7 @@ class RBush {
|
|
|
22297
22299
|
goingUp = true;
|
|
22298
22300
|
}
|
|
22299
22301
|
if (node2.leaf) {
|
|
22300
|
-
const index2 = findItem(
|
|
22302
|
+
const index2 = findItem(item, node2.children, equalsFn);
|
|
22301
22303
|
if (index2 !== -1) {
|
|
22302
22304
|
node2.children.splice(index2, 1);
|
|
22303
22305
|
path2.push(node2);
|
|
@@ -22320,8 +22322,8 @@ class RBush {
|
|
|
22320
22322
|
}
|
|
22321
22323
|
return this;
|
|
22322
22324
|
}
|
|
22323
|
-
toBBox(
|
|
22324
|
-
return
|
|
22325
|
+
toBBox(item) {
|
|
22326
|
+
return item;
|
|
22325
22327
|
}
|
|
22326
22328
|
compareMinX(a, b) {
|
|
22327
22329
|
return a.minX - b.minX;
|
|
@@ -22404,11 +22406,11 @@ class RBush {
|
|
|
22404
22406
|
}
|
|
22405
22407
|
return node2;
|
|
22406
22408
|
}
|
|
22407
|
-
_insert(
|
|
22408
|
-
const bbox = isNode ?
|
|
22409
|
+
_insert(item, level, isNode) {
|
|
22410
|
+
const bbox = isNode ? item : this.toBBox(item);
|
|
22409
22411
|
const insertPath = [];
|
|
22410
22412
|
const node2 = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
22411
|
-
node2.children.push(
|
|
22413
|
+
node2.children.push(item);
|
|
22412
22414
|
extend2(node2, bbox);
|
|
22413
22415
|
while (level >= 0) {
|
|
22414
22416
|
if (insertPath[level].children.length > this._maxEntries) {
|
|
@@ -22507,11 +22509,11 @@ class RBush {
|
|
|
22507
22509
|
}
|
|
22508
22510
|
}
|
|
22509
22511
|
}
|
|
22510
|
-
function findItem(
|
|
22512
|
+
function findItem(item, items, equalsFn) {
|
|
22511
22513
|
if (!equalsFn)
|
|
22512
|
-
return items.indexOf(
|
|
22514
|
+
return items.indexOf(item);
|
|
22513
22515
|
for (let i = 0;i < items.length; i++) {
|
|
22514
|
-
if (equalsFn(
|
|
22516
|
+
if (equalsFn(item, items[i]))
|
|
22515
22517
|
return i;
|
|
22516
22518
|
}
|
|
22517
22519
|
return -1;
|
|
@@ -22673,10 +22675,10 @@ class RTreeIndex {
|
|
|
22673
22675
|
return container ? container.item : undefined;
|
|
22674
22676
|
}
|
|
22675
22677
|
remove(id) {
|
|
22676
|
-
const
|
|
22677
|
-
if (
|
|
22678
|
+
const item = this.map.get(id);
|
|
22679
|
+
if (item) {
|
|
22678
22680
|
this.map.delete(id);
|
|
22679
|
-
this.tree.remove(
|
|
22681
|
+
this.tree.remove(item);
|
|
22680
22682
|
}
|
|
22681
22683
|
}
|
|
22682
22684
|
list() {
|
|
@@ -22748,11 +22750,11 @@ class Container extends Mbr {
|
|
|
22748
22750
|
item;
|
|
22749
22751
|
layer;
|
|
22750
22752
|
zIndex;
|
|
22751
|
-
constructor(id,
|
|
22752
|
-
const rect =
|
|
22753
|
+
constructor(id, item, layer, zIndex) {
|
|
22754
|
+
const rect = item.getMbrWithChildren();
|
|
22753
22755
|
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
22754
22756
|
this.id = id;
|
|
22755
|
-
this.item =
|
|
22757
|
+
this.item = item;
|
|
22756
22758
|
this.layer = layer;
|
|
22757
22759
|
this.zIndex = zIndex;
|
|
22758
22760
|
}
|
|
@@ -22769,7 +22771,7 @@ class LayeredIndex {
|
|
|
22769
22771
|
this.getZIndex = this.getZIndex.bind(this);
|
|
22770
22772
|
this.layers.newOnTop();
|
|
22771
22773
|
}
|
|
22772
|
-
isT(
|
|
22774
|
+
isT(item) {
|
|
22773
22775
|
return true;
|
|
22774
22776
|
}
|
|
22775
22777
|
findById(id) {
|
|
@@ -22833,8 +22835,8 @@ class LayeredIndex {
|
|
|
22833
22835
|
}
|
|
22834
22836
|
getContainersFromItems(items) {
|
|
22835
22837
|
const containers = [];
|
|
22836
|
-
for (const
|
|
22837
|
-
const container = this.map.get(
|
|
22838
|
+
for (const item of items) {
|
|
22839
|
+
const container = this.map.get(item.getId());
|
|
22838
22840
|
if (container) {
|
|
22839
22841
|
containers.push(container);
|
|
22840
22842
|
}
|
|
@@ -22911,9 +22913,9 @@ class LayeredIndex {
|
|
|
22911
22913
|
}
|
|
22912
22914
|
}
|
|
22913
22915
|
}
|
|
22914
|
-
insert(
|
|
22915
|
-
const toInsert = new Container(
|
|
22916
|
-
const bounds =
|
|
22916
|
+
insert(item) {
|
|
22917
|
+
const toInsert = new Container(item.getId(), item, 0, this.getZIndex(item));
|
|
22918
|
+
const bounds = item.getMbrWithChildren();
|
|
22917
22919
|
const inBounds = this.getRectsEnclosedOrCrossedBy(bounds);
|
|
22918
22920
|
if (inBounds.length === 0) {
|
|
22919
22921
|
return this.insertContainer(toInsert);
|
|
@@ -22980,20 +22982,20 @@ class LayeredIndex {
|
|
|
22980
22982
|
}
|
|
22981
22983
|
}
|
|
22982
22984
|
}
|
|
22983
|
-
change(
|
|
22984
|
-
const id =
|
|
22985
|
+
change(item) {
|
|
22986
|
+
const id = item.getId();
|
|
22985
22987
|
const container = this.map.get(id);
|
|
22986
22988
|
if (container) {
|
|
22987
22989
|
const layer = this.layers.get(container.layer);
|
|
22988
22990
|
if (layer) {
|
|
22989
22991
|
layer.remove(id);
|
|
22990
22992
|
this.map.delete(id);
|
|
22991
|
-
this.insert(
|
|
22993
|
+
this.insert(item);
|
|
22992
22994
|
}
|
|
22993
22995
|
}
|
|
22994
22996
|
}
|
|
22995
|
-
remove(
|
|
22996
|
-
const id =
|
|
22997
|
+
remove(item) {
|
|
22998
|
+
const id = item.getId();
|
|
22997
22999
|
const container = this.map.get(id);
|
|
22998
23000
|
if (container) {
|
|
22999
23001
|
const layer = this.layers.get(container.layer);
|
|
@@ -23019,13 +23021,13 @@ class LayeredIndex {
|
|
|
23019
23021
|
return items;
|
|
23020
23022
|
}
|
|
23021
23023
|
batchInsert(items) {
|
|
23022
|
-
for (const
|
|
23023
|
-
this.insert(
|
|
23024
|
+
for (const item of items) {
|
|
23025
|
+
this.insert(item);
|
|
23024
23026
|
}
|
|
23025
23027
|
}
|
|
23026
23028
|
batchChange(items) {
|
|
23027
|
-
for (const
|
|
23028
|
-
this.change(
|
|
23029
|
+
for (const item of items) {
|
|
23030
|
+
this.change(item);
|
|
23029
23031
|
}
|
|
23030
23032
|
}
|
|
23031
23033
|
}
|
|
@@ -23034,8 +23036,8 @@ class LayeredIndex {
|
|
|
23034
23036
|
class SpatialIndex {
|
|
23035
23037
|
subject = new Subject;
|
|
23036
23038
|
itemsArray = [];
|
|
23037
|
-
itemsIndex = new LayeredIndex((
|
|
23038
|
-
return this.itemsArray.indexOf(
|
|
23039
|
+
itemsIndex = new LayeredIndex((item) => {
|
|
23040
|
+
return this.itemsArray.indexOf(item);
|
|
23039
23041
|
});
|
|
23040
23042
|
Mbr = new Mbr;
|
|
23041
23043
|
items;
|
|
@@ -23044,79 +23046,79 @@ class SpatialIndex {
|
|
|
23044
23046
|
}
|
|
23045
23047
|
clear() {
|
|
23046
23048
|
this.itemsArray = [];
|
|
23047
|
-
this.itemsIndex = new LayeredIndex((
|
|
23048
|
-
return this.itemsArray.indexOf(
|
|
23049
|
+
this.itemsIndex = new LayeredIndex((item) => {
|
|
23050
|
+
return this.itemsArray.indexOf(item);
|
|
23049
23051
|
});
|
|
23050
23052
|
this.Mbr = new Mbr;
|
|
23051
23053
|
}
|
|
23052
|
-
insert(
|
|
23053
|
-
this.itemsArray.push(
|
|
23054
|
-
this.itemsIndex.insert(
|
|
23054
|
+
insert(item) {
|
|
23055
|
+
this.itemsArray.push(item);
|
|
23056
|
+
this.itemsIndex.insert(item);
|
|
23055
23057
|
if (conf.isNode()) {
|
|
23056
23058
|
return;
|
|
23057
23059
|
}
|
|
23058
23060
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23059
|
-
this.Mbr =
|
|
23061
|
+
this.Mbr = item.getMbr().copy();
|
|
23060
23062
|
} else {
|
|
23061
|
-
this.Mbr.combine([
|
|
23063
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23062
23064
|
}
|
|
23063
|
-
|
|
23065
|
+
item.subject.subscribe(this.change);
|
|
23064
23066
|
this.subject.publish(this.items);
|
|
23065
23067
|
}
|
|
23066
|
-
change = (
|
|
23067
|
-
this.itemsIndex.change(
|
|
23068
|
+
change = (item) => {
|
|
23069
|
+
this.itemsIndex.change(item);
|
|
23068
23070
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23069
|
-
this.Mbr =
|
|
23071
|
+
this.Mbr = item.getMbrWithChildren().copy();
|
|
23070
23072
|
} else {
|
|
23071
|
-
this.Mbr.combine([
|
|
23073
|
+
this.Mbr.combine([item.getMbrWithChildren()]);
|
|
23072
23074
|
}
|
|
23073
23075
|
this.subject.publish(this.items);
|
|
23074
23076
|
};
|
|
23075
|
-
remove(
|
|
23076
|
-
if ("index" in
|
|
23077
|
-
|
|
23077
|
+
remove(item) {
|
|
23078
|
+
if ("index" in item && item.index) {
|
|
23079
|
+
item.removeChildItems(item.index.list());
|
|
23078
23080
|
}
|
|
23079
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
23080
|
-
this.itemsIndex.remove(
|
|
23081
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23082
|
+
this.itemsIndex.remove(item);
|
|
23081
23083
|
this.Mbr = new Mbr;
|
|
23082
|
-
this.itemsArray.forEach((
|
|
23084
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
|
|
23083
23085
|
this.subject.publish(this.items);
|
|
23084
23086
|
}
|
|
23085
23087
|
copy() {
|
|
23086
|
-
return this.getItemsWithIncludedChildren(this.itemsArray).map((
|
|
23087
|
-
...
|
|
23088
|
-
id:
|
|
23088
|
+
return this.getItemsWithIncludedChildren(this.itemsArray).map((item) => ({
|
|
23089
|
+
...item.serialize(true),
|
|
23090
|
+
id: item.getId()
|
|
23089
23091
|
}));
|
|
23090
23092
|
}
|
|
23091
23093
|
getItemsWithIncludedChildren(items) {
|
|
23092
|
-
return items.flatMap((
|
|
23093
|
-
if ("index" in
|
|
23094
|
-
return [
|
|
23094
|
+
return items.flatMap((item) => {
|
|
23095
|
+
if ("index" in item && item.index) {
|
|
23096
|
+
return [item, ...item.index.list()];
|
|
23095
23097
|
}
|
|
23096
|
-
return
|
|
23098
|
+
return item;
|
|
23097
23099
|
});
|
|
23098
23100
|
}
|
|
23099
|
-
getItemChildren(
|
|
23100
|
-
if ("index" in
|
|
23101
|
-
return
|
|
23101
|
+
getItemChildren(item) {
|
|
23102
|
+
if ("index" in item && item.index) {
|
|
23103
|
+
return item.index.list();
|
|
23102
23104
|
}
|
|
23103
23105
|
return [];
|
|
23104
23106
|
}
|
|
23105
|
-
getItemParent(
|
|
23106
|
-
if (
|
|
23107
|
+
getItemParent(item) {
|
|
23108
|
+
if (item.parent === "Board") {
|
|
23107
23109
|
return;
|
|
23108
23110
|
}
|
|
23109
|
-
return this.getById(
|
|
23111
|
+
return this.getById(item.parent);
|
|
23110
23112
|
}
|
|
23111
|
-
moveToZIndex(
|
|
23112
|
-
const index2 = this.itemsArray.indexOf(
|
|
23113
|
+
moveToZIndex(item, zIndex) {
|
|
23114
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23113
23115
|
this.itemsArray.splice(index2, 1);
|
|
23114
|
-
this.itemsArray.splice(zIndex, 0,
|
|
23115
|
-
this.change(
|
|
23116
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
23117
|
+
this.change(item);
|
|
23116
23118
|
this.subject.publish(this.items);
|
|
23117
23119
|
}
|
|
23118
23120
|
moveManyToZIndex(itemsRecord) {
|
|
23119
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
23121
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
23120
23122
|
const zIndex = Object.values(itemsRecord);
|
|
23121
23123
|
for (let i = 0;i < zIndex.length; i++) {
|
|
23122
23124
|
const index2 = zIndex[i];
|
|
@@ -23124,39 +23126,39 @@ class SpatialIndex {
|
|
|
23124
23126
|
}
|
|
23125
23127
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23126
23128
|
}
|
|
23127
|
-
sendToBack(
|
|
23128
|
-
const index2 = this.itemsArray.indexOf(
|
|
23129
|
+
sendToBack(item, shouldPublish = true) {
|
|
23130
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23129
23131
|
this.itemsArray.splice(index2, 1);
|
|
23130
|
-
this.itemsArray.unshift(
|
|
23131
|
-
this.itemsIndex.change(
|
|
23132
|
+
this.itemsArray.unshift(item);
|
|
23133
|
+
this.itemsIndex.change(item);
|
|
23132
23134
|
if (shouldPublish) {
|
|
23133
23135
|
this.subject.publish(this.items);
|
|
23134
23136
|
}
|
|
23135
23137
|
}
|
|
23136
23138
|
sendManyToBack(items) {
|
|
23137
23139
|
const newItems = [...items];
|
|
23138
|
-
this.itemsArray.forEach((
|
|
23139
|
-
if (!items.includes(
|
|
23140
|
-
newItems.push(
|
|
23140
|
+
this.itemsArray.forEach((item) => {
|
|
23141
|
+
if (!items.includes(item)) {
|
|
23142
|
+
newItems.push(item);
|
|
23141
23143
|
}
|
|
23142
23144
|
});
|
|
23143
23145
|
this.itemsArray = newItems;
|
|
23144
23146
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23145
23147
|
}
|
|
23146
|
-
bringToFront(
|
|
23147
|
-
const index2 = this.itemsArray.indexOf(
|
|
23148
|
+
bringToFront(item, shouldPublish = true) {
|
|
23149
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23148
23150
|
this.itemsArray.splice(index2, 1);
|
|
23149
|
-
this.itemsArray.push(
|
|
23150
|
-
this.itemsIndex.change(
|
|
23151
|
+
this.itemsArray.push(item);
|
|
23152
|
+
this.itemsIndex.change(item);
|
|
23151
23153
|
if (shouldPublish) {
|
|
23152
23154
|
this.subject.publish(this.items);
|
|
23153
23155
|
}
|
|
23154
23156
|
}
|
|
23155
23157
|
bringManyToFront(items) {
|
|
23156
23158
|
const newItems = [];
|
|
23157
|
-
this.itemsArray.forEach((
|
|
23158
|
-
if (!items.includes(
|
|
23159
|
-
newItems.push(
|
|
23159
|
+
this.itemsArray.forEach((item) => {
|
|
23160
|
+
if (!items.includes(item)) {
|
|
23161
|
+
newItems.push(item);
|
|
23160
23162
|
}
|
|
23161
23163
|
});
|
|
23162
23164
|
newItems.push(...items);
|
|
@@ -23182,9 +23184,9 @@ class SpatialIndex {
|
|
|
23182
23184
|
this.subject.publish(this.items);
|
|
23183
23185
|
}
|
|
23184
23186
|
getById(id) {
|
|
23185
|
-
const
|
|
23186
|
-
if (
|
|
23187
|
-
return
|
|
23187
|
+
const item = this.getItemsWithIncludedChildren(this.itemsArray).find((item2) => item2.getId() === id);
|
|
23188
|
+
if (item) {
|
|
23189
|
+
return item;
|
|
23188
23190
|
}
|
|
23189
23191
|
}
|
|
23190
23192
|
findById(id) {
|
|
@@ -23194,10 +23196,10 @@ class SpatialIndex {
|
|
|
23194
23196
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23195
23197
|
const items = this.itemsIndex.getEnclosed(mbr);
|
|
23196
23198
|
const children = [];
|
|
23197
|
-
const clearItems = items.filter((
|
|
23198
|
-
if ("index" in
|
|
23199
|
-
children.push(...
|
|
23200
|
-
if (!
|
|
23199
|
+
const clearItems = items.filter((item) => {
|
|
23200
|
+
if ("index" in item && item.index) {
|
|
23201
|
+
children.push(...item.index.getEnclosed(left, top, right, bottom));
|
|
23202
|
+
if (!item.getMbr().isEnclosedBy(mbr)) {
|
|
23201
23203
|
return false;
|
|
23202
23204
|
}
|
|
23203
23205
|
}
|
|
@@ -23209,10 +23211,10 @@ class SpatialIndex {
|
|
|
23209
23211
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23210
23212
|
const items = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
23211
23213
|
const children = [];
|
|
23212
|
-
const clearItems = items.filter((
|
|
23213
|
-
if ("index" in
|
|
23214
|
-
children.push(...
|
|
23215
|
-
if (!
|
|
23214
|
+
const clearItems = items.filter((item) => {
|
|
23215
|
+
if ("index" in item && item.index) {
|
|
23216
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
23217
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
23216
23218
|
return false;
|
|
23217
23219
|
}
|
|
23218
23220
|
}
|
|
@@ -23223,10 +23225,10 @@ class SpatialIndex {
|
|
|
23223
23225
|
getUnderPoint(point3, tolerance = 5) {
|
|
23224
23226
|
const items = this.itemsIndex.getUnderPoint(point3, tolerance);
|
|
23225
23227
|
const children = [];
|
|
23226
|
-
const clearItems = items.filter((
|
|
23227
|
-
if ("index" in
|
|
23228
|
-
children.push(...
|
|
23229
|
-
if (!
|
|
23228
|
+
const clearItems = items.filter((item) => {
|
|
23229
|
+
if ("index" in item && item.index) {
|
|
23230
|
+
children.push(...item.index.getUnderPoint(point3, tolerance));
|
|
23231
|
+
if (!item.getMbr().isUnderPoint(point3)) {
|
|
23230
23232
|
return false;
|
|
23231
23233
|
}
|
|
23232
23234
|
}
|
|
@@ -23238,10 +23240,10 @@ class SpatialIndex {
|
|
|
23238
23240
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23239
23241
|
const items = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
23240
23242
|
const children = [];
|
|
23241
|
-
const clearItems = items.filter((
|
|
23242
|
-
if ("index" in
|
|
23243
|
-
children.push(...
|
|
23244
|
-
if (!
|
|
23243
|
+
const clearItems = items.filter((item) => {
|
|
23244
|
+
if ("index" in item && item.index) {
|
|
23245
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
23246
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
23245
23247
|
return false;
|
|
23246
23248
|
}
|
|
23247
23249
|
}
|
|
@@ -23253,26 +23255,26 @@ class SpatialIndex {
|
|
|
23253
23255
|
return this.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
23254
23256
|
}
|
|
23255
23257
|
getComments() {
|
|
23256
|
-
return this.itemsArray.filter((
|
|
23258
|
+
return this.itemsArray.filter((item) => item instanceof Comment);
|
|
23257
23259
|
}
|
|
23258
23260
|
getMbr() {
|
|
23259
23261
|
return this.Mbr;
|
|
23260
23262
|
}
|
|
23261
23263
|
getNearestTo(point3, maxItems, filter, maxDistance) {
|
|
23262
23264
|
const allItems = this.getItemsWithIncludedChildren(this.itemsArray);
|
|
23263
|
-
const filtered = allItems.filter((
|
|
23264
|
-
const withDistance = filtered.map((
|
|
23265
|
-
item
|
|
23266
|
-
distance: point3.getDistance(
|
|
23265
|
+
const filtered = allItems.filter((item) => filter(item));
|
|
23266
|
+
const withDistance = filtered.map((item) => ({
|
|
23267
|
+
item,
|
|
23268
|
+
distance: point3.getDistance(item.getMbr().getCenter())
|
|
23267
23269
|
})).filter(({ distance }) => distance <= maxDistance);
|
|
23268
23270
|
withDistance.sort((a, b) => a.distance - b.distance);
|
|
23269
|
-
return withDistance.slice(0, maxItems).map(({ item
|
|
23271
|
+
return withDistance.slice(0, maxItems).map(({ item }) => item);
|
|
23270
23272
|
}
|
|
23271
23273
|
list() {
|
|
23272
23274
|
return this.getItemsWithIncludedChildren(this.itemsArray).concat();
|
|
23273
23275
|
}
|
|
23274
|
-
getZIndex(
|
|
23275
|
-
const index2 = this.itemsArray.indexOf(
|
|
23276
|
+
getZIndex(item) {
|
|
23277
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23276
23278
|
if (index2 === -1) {
|
|
23277
23279
|
return this.getLastZIndex();
|
|
23278
23280
|
}
|
|
@@ -23302,14 +23304,14 @@ class Items {
|
|
|
23302
23304
|
this.pointer = pointer;
|
|
23303
23305
|
this.subject = subject;
|
|
23304
23306
|
}
|
|
23305
|
-
update(
|
|
23306
|
-
this.index.change(
|
|
23307
|
+
update(item) {
|
|
23308
|
+
this.index.change(item);
|
|
23307
23309
|
}
|
|
23308
23310
|
listAll() {
|
|
23309
23311
|
return this.index.list();
|
|
23310
23312
|
}
|
|
23311
23313
|
listGroupItems() {
|
|
23312
|
-
return this.index.list().filter((
|
|
23314
|
+
return this.index.list().filter((item) => ("index" in item) && item.index);
|
|
23313
23315
|
}
|
|
23314
23316
|
getById(id) {
|
|
23315
23317
|
return this.index.getById(id);
|
|
@@ -23324,7 +23326,7 @@ class Items {
|
|
|
23324
23326
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
23325
23327
|
}
|
|
23326
23328
|
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
23327
|
-
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
23329
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.index);
|
|
23328
23330
|
}
|
|
23329
23331
|
getUnderPoint(point3, tolerance = 5) {
|
|
23330
23332
|
return this.index.getUnderPoint(point3, tolerance);
|
|
@@ -23352,28 +23354,28 @@ class Items {
|
|
|
23352
23354
|
const unmodifiedSize = size;
|
|
23353
23355
|
size = 16;
|
|
23354
23356
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
23355
|
-
const groups = tolerated.filter((
|
|
23357
|
+
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
23356
23358
|
if (groups.length > 0) {
|
|
23357
23359
|
return groups;
|
|
23358
23360
|
}
|
|
23359
|
-
let enclosed = tolerated.some((
|
|
23361
|
+
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
23360
23362
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
23361
23363
|
if (enclosed.length === 0) {
|
|
23362
23364
|
enclosed = underPointer;
|
|
23363
23365
|
}
|
|
23364
|
-
if (underPointer.some((
|
|
23366
|
+
if (underPointer.some((item) => item.itemType === "Drawing")) {
|
|
23365
23367
|
enclosed = [...underPointer, ...enclosed];
|
|
23366
23368
|
}
|
|
23367
|
-
const { nearest } = enclosed.reduce((acc,
|
|
23368
|
-
const area =
|
|
23369
|
-
if (
|
|
23369
|
+
const { nearest } = enclosed.reduce((acc, item) => {
|
|
23370
|
+
const area = item.getMbr().getHeight() * item.getMbr().getWidth();
|
|
23371
|
+
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
23370
23372
|
return acc;
|
|
23371
23373
|
}
|
|
23372
|
-
const isItemTransparent =
|
|
23373
|
-
const itemZIndex = this.getZIndex(
|
|
23374
|
+
const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
|
|
23375
|
+
const itemZIndex = this.getZIndex(item);
|
|
23374
23376
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
23375
23377
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
23376
|
-
return { nearest:
|
|
23378
|
+
return { nearest: item, area };
|
|
23377
23379
|
}
|
|
23378
23380
|
return acc;
|
|
23379
23381
|
}, { nearest: undefined, area: Infinity });
|
|
@@ -23385,8 +23387,8 @@ class Items {
|
|
|
23385
23387
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
23386
23388
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
23387
23389
|
}
|
|
23388
|
-
getZIndex(
|
|
23389
|
-
return this.index.getZIndex(
|
|
23390
|
+
getZIndex(item) {
|
|
23391
|
+
return this.index.getZIndex(item);
|
|
23390
23392
|
}
|
|
23391
23393
|
getByZIndex(index2) {
|
|
23392
23394
|
return this.index.getByZIndex(index2);
|
|
@@ -23395,11 +23397,11 @@ class Items {
|
|
|
23395
23397
|
return this.index.getLastZIndex();
|
|
23396
23398
|
}
|
|
23397
23399
|
getLinkedConnectorsById(id) {
|
|
23398
|
-
return this.listAll().filter((
|
|
23399
|
-
if (!(
|
|
23400
|
+
return this.listAll().filter((item) => {
|
|
23401
|
+
if (!(item instanceof Connector2)) {
|
|
23400
23402
|
return false;
|
|
23401
23403
|
}
|
|
23402
|
-
const { startItem, endItem } =
|
|
23404
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
23403
23405
|
if (startItem?.getId() === id || endItem?.getId() === id) {
|
|
23404
23406
|
return true;
|
|
23405
23407
|
}
|
|
@@ -23410,11 +23412,11 @@ class Items {
|
|
|
23410
23412
|
if (!startPointerItemId && !endPointerItemId) {
|
|
23411
23413
|
return [];
|
|
23412
23414
|
}
|
|
23413
|
-
return this.listAll().filter((
|
|
23414
|
-
if (!(
|
|
23415
|
+
return this.listAll().filter((item) => {
|
|
23416
|
+
if (!(item instanceof Connector2) || !item.isConnected()) {
|
|
23415
23417
|
return false;
|
|
23416
23418
|
}
|
|
23417
|
-
const { startItem, endItem } =
|
|
23419
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
23418
23420
|
if (startPointerItemId && endPointerItemId) {
|
|
23419
23421
|
if (startPointerItemId && startItem && startItem.getId() === startPointerItemId && endPointerItemId && endItem && endItem.getId() === endPointerItemId) {
|
|
23420
23422
|
return true;
|
|
@@ -23432,9 +23434,9 @@ class Items {
|
|
|
23432
23434
|
}
|
|
23433
23435
|
render(context) {
|
|
23434
23436
|
const items = this.getItemsInView();
|
|
23435
|
-
items.forEach((
|
|
23436
|
-
if (
|
|
23437
|
-
|
|
23437
|
+
items.forEach((item) => {
|
|
23438
|
+
if (item.parent === "Board") {
|
|
23439
|
+
item.render(context);
|
|
23438
23440
|
}
|
|
23439
23441
|
});
|
|
23440
23442
|
}
|
|
@@ -23447,17 +23449,17 @@ class Items {
|
|
|
23447
23449
|
return this.getHTML(documentFactory, items);
|
|
23448
23450
|
}
|
|
23449
23451
|
getHTML(documentFactory, items) {
|
|
23450
|
-
const lowestCoordinates = items.map((
|
|
23452
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
23451
23453
|
left: Math.min(acc.left, mbr.left),
|
|
23452
23454
|
top: Math.min(acc.top, mbr.top)
|
|
23453
23455
|
}), { left: 0, top: 0 });
|
|
23454
23456
|
const groups = [];
|
|
23455
23457
|
const rest = [];
|
|
23456
|
-
items.forEach((
|
|
23457
|
-
if ("index" in
|
|
23458
|
-
groups.push(
|
|
23458
|
+
items.forEach((item) => {
|
|
23459
|
+
if ("index" in item && item.index) {
|
|
23460
|
+
groups.push(item);
|
|
23459
23461
|
} else {
|
|
23460
|
-
rest.push(
|
|
23462
|
+
rest.push(item);
|
|
23461
23463
|
}
|
|
23462
23464
|
});
|
|
23463
23465
|
const childrenMap = new Map;
|
|
@@ -23467,34 +23469,34 @@ class Items {
|
|
|
23467
23469
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
23468
23470
|
return html;
|
|
23469
23471
|
});
|
|
23470
|
-
const restHTML = rest.map((
|
|
23471
|
-
if (
|
|
23472
|
-
const startX = parseFloat(
|
|
23473
|
-
const startY = parseFloat(
|
|
23474
|
-
const endX = parseFloat(
|
|
23475
|
-
const endY = parseFloat(
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
}
|
|
23481
|
-
return translateElementBy(
|
|
23482
|
-
});
|
|
23483
|
-
for (const
|
|
23484
|
-
const parentFrameId = childrenMap.get(
|
|
23472
|
+
const restHTML = rest.map((item) => ("renderHTML" in item) && item.renderHTML(documentFactory)).filter((item) => !!item).map((item) => {
|
|
23473
|
+
if (item.tagName.toLowerCase() === "connector-item") {
|
|
23474
|
+
const startX = parseFloat(item.getAttribute("data-start-point-x") || "0");
|
|
23475
|
+
const startY = parseFloat(item.getAttribute("data-start-point-y") || "0");
|
|
23476
|
+
const endX = parseFloat(item.getAttribute("data-end-point-x") || "0");
|
|
23477
|
+
const endY = parseFloat(item.getAttribute("data-end-point-y") || "0");
|
|
23478
|
+
item.setAttribute("data-start-point-x", (startX - lowestCoordinates.left).toString());
|
|
23479
|
+
item.setAttribute("data-start-point-y", (startY - lowestCoordinates.top).toString());
|
|
23480
|
+
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
23481
|
+
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
23482
|
+
}
|
|
23483
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
23484
|
+
});
|
|
23485
|
+
for (const item of restHTML) {
|
|
23486
|
+
const parentFrameId = childrenMap.get(item.id);
|
|
23485
23487
|
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
23486
23488
|
if (group) {
|
|
23487
|
-
positionRelatively(
|
|
23488
|
-
group.appendChild(
|
|
23489
|
+
positionRelatively(item, group);
|
|
23490
|
+
group.appendChild(item);
|
|
23489
23491
|
}
|
|
23490
23492
|
}
|
|
23491
23493
|
let result = "";
|
|
23492
23494
|
for (const group of GroupsHTML) {
|
|
23493
23495
|
result += group.outerHTML;
|
|
23494
23496
|
}
|
|
23495
|
-
for (const
|
|
23496
|
-
if (!childrenMap.get(
|
|
23497
|
-
result +=
|
|
23497
|
+
for (const item of restHTML) {
|
|
23498
|
+
if (!childrenMap.get(item.id)) {
|
|
23499
|
+
result += item.outerHTML;
|
|
23498
23500
|
}
|
|
23499
23501
|
}
|
|
23500
23502
|
return result;
|
|
@@ -23514,52 +23516,52 @@ class SimpleSpatialIndex {
|
|
|
23514
23516
|
this.itemsArray = [];
|
|
23515
23517
|
this.Mbr = new Mbr;
|
|
23516
23518
|
}
|
|
23517
|
-
insert(
|
|
23518
|
-
this.itemsArray.push(
|
|
23519
|
+
insert(item) {
|
|
23520
|
+
this.itemsArray.push(item);
|
|
23519
23521
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23520
|
-
this.Mbr =
|
|
23522
|
+
this.Mbr = item.getMbr().copy();
|
|
23521
23523
|
} else {
|
|
23522
|
-
this.Mbr.combine([
|
|
23524
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23523
23525
|
}
|
|
23524
|
-
|
|
23526
|
+
item.subject.subscribe(this.change);
|
|
23525
23527
|
this.subject.publish(this.items);
|
|
23526
23528
|
}
|
|
23527
|
-
change = (
|
|
23529
|
+
change = (item) => {
|
|
23528
23530
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23529
|
-
this.Mbr =
|
|
23531
|
+
this.Mbr = item.getMbr().copy();
|
|
23530
23532
|
} else {
|
|
23531
|
-
this.Mbr.combine([
|
|
23533
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23532
23534
|
}
|
|
23533
23535
|
this.subject.publish(this.items);
|
|
23534
23536
|
};
|
|
23535
|
-
remove(
|
|
23536
|
-
if ("index" in
|
|
23537
|
-
|
|
23537
|
+
remove(item) {
|
|
23538
|
+
if ("index" in item && item.index) {
|
|
23539
|
+
item.removeChildItems(item.index.list());
|
|
23538
23540
|
}
|
|
23539
|
-
if (
|
|
23540
|
-
const parentFrame = this.items.getById(
|
|
23541
|
-
parentFrame?.removeChildItems(
|
|
23541
|
+
if (item.parent !== "Board") {
|
|
23542
|
+
const parentFrame = this.items.getById(item.parent);
|
|
23543
|
+
parentFrame?.removeChildItems(item);
|
|
23542
23544
|
}
|
|
23543
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
23545
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23544
23546
|
this.Mbr = new Mbr;
|
|
23545
|
-
this.itemsArray.forEach((
|
|
23547
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
23546
23548
|
this.subject.publish(this.items);
|
|
23547
23549
|
}
|
|
23548
23550
|
copy() {
|
|
23549
|
-
return this.itemsArray.map((
|
|
23550
|
-
...
|
|
23551
|
-
id:
|
|
23551
|
+
return this.itemsArray.map((item) => ({
|
|
23552
|
+
...item.serialize(true),
|
|
23553
|
+
id: item.getId()
|
|
23552
23554
|
}));
|
|
23553
23555
|
}
|
|
23554
|
-
moveToZIndex(
|
|
23555
|
-
const index2 = this.itemsArray.indexOf(
|
|
23556
|
+
moveToZIndex(item, zIndex) {
|
|
23557
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23556
23558
|
this.itemsArray.splice(index2, 1);
|
|
23557
|
-
this.itemsArray.splice(zIndex, 0,
|
|
23558
|
-
this.change(
|
|
23559
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
23560
|
+
this.change(item);
|
|
23559
23561
|
this.subject.publish(this.items);
|
|
23560
23562
|
}
|
|
23561
23563
|
moveManyToZIndex(itemsRecord) {
|
|
23562
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
23564
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
23563
23565
|
const zIndex = Object.values(itemsRecord);
|
|
23564
23566
|
for (let i = 0;i < zIndex.length; i++) {
|
|
23565
23567
|
const index2 = zIndex[i];
|
|
@@ -23567,37 +23569,37 @@ class SimpleSpatialIndex {
|
|
|
23567
23569
|
}
|
|
23568
23570
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23569
23571
|
}
|
|
23570
|
-
sendToBack(
|
|
23571
|
-
const index2 = this.itemsArray.indexOf(
|
|
23572
|
+
sendToBack(item, shouldPublish = true) {
|
|
23573
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23572
23574
|
this.itemsArray.splice(index2, 1);
|
|
23573
|
-
this.itemsArray.unshift(
|
|
23575
|
+
this.itemsArray.unshift(item);
|
|
23574
23576
|
if (shouldPublish) {
|
|
23575
23577
|
this.subject.publish(this.items);
|
|
23576
23578
|
}
|
|
23577
23579
|
}
|
|
23578
23580
|
sendManyToBack(items) {
|
|
23579
23581
|
const newItems = [...items];
|
|
23580
|
-
this.itemsArray.forEach((
|
|
23581
|
-
if (!items.includes(
|
|
23582
|
-
newItems.push(
|
|
23582
|
+
this.itemsArray.forEach((item) => {
|
|
23583
|
+
if (!items.includes(item)) {
|
|
23584
|
+
newItems.push(item);
|
|
23583
23585
|
}
|
|
23584
23586
|
});
|
|
23585
23587
|
this.itemsArray = newItems;
|
|
23586
23588
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23587
23589
|
}
|
|
23588
|
-
bringToFront(
|
|
23589
|
-
const index2 = this.itemsArray.indexOf(
|
|
23590
|
+
bringToFront(item, shouldPublish = true) {
|
|
23591
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23590
23592
|
this.itemsArray.splice(index2, 1);
|
|
23591
|
-
this.itemsArray.push(
|
|
23593
|
+
this.itemsArray.push(item);
|
|
23592
23594
|
if (shouldPublish) {
|
|
23593
23595
|
this.subject.publish(this.items);
|
|
23594
23596
|
}
|
|
23595
23597
|
}
|
|
23596
23598
|
bringManyToFront(items) {
|
|
23597
23599
|
const newItems = [];
|
|
23598
|
-
this.itemsArray.forEach((
|
|
23599
|
-
if (!items.includes(
|
|
23600
|
-
newItems.push(
|
|
23600
|
+
this.itemsArray.forEach((item) => {
|
|
23601
|
+
if (!items.includes(item)) {
|
|
23602
|
+
newItems.push(item);
|
|
23601
23603
|
}
|
|
23602
23604
|
});
|
|
23603
23605
|
newItems.push(...items);
|
|
@@ -23623,9 +23625,9 @@ class SimpleSpatialIndex {
|
|
|
23623
23625
|
this.subject.publish(this.items);
|
|
23624
23626
|
}
|
|
23625
23627
|
getById(id) {
|
|
23626
|
-
const
|
|
23627
|
-
if (
|
|
23628
|
-
return
|
|
23628
|
+
const item = this.itemsArray.find((item2) => item2.getId() === id);
|
|
23629
|
+
if (item) {
|
|
23630
|
+
return item;
|
|
23629
23631
|
}
|
|
23630
23632
|
}
|
|
23631
23633
|
findById(id) {
|
|
@@ -23634,9 +23636,9 @@ class SimpleSpatialIndex {
|
|
|
23634
23636
|
getEnclosed(left, top, right, bottom) {
|
|
23635
23637
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23636
23638
|
const items = [];
|
|
23637
|
-
this.itemsArray.forEach((
|
|
23638
|
-
if (
|
|
23639
|
-
items.push(
|
|
23639
|
+
this.itemsArray.forEach((item) => {
|
|
23640
|
+
if (item.isEnclosedBy(mbr)) {
|
|
23641
|
+
items.push(item);
|
|
23640
23642
|
}
|
|
23641
23643
|
});
|
|
23642
23644
|
return items;
|
|
@@ -23644,18 +23646,18 @@ class SimpleSpatialIndex {
|
|
|
23644
23646
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
23645
23647
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23646
23648
|
const items = [];
|
|
23647
|
-
this.itemsArray.forEach((
|
|
23648
|
-
if (
|
|
23649
|
-
items.push(
|
|
23649
|
+
this.itemsArray.forEach((item) => {
|
|
23650
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
23651
|
+
items.push(item);
|
|
23650
23652
|
}
|
|
23651
23653
|
});
|
|
23652
23654
|
return items;
|
|
23653
23655
|
}
|
|
23654
23656
|
getUnderPoint(point3, tolerace = 5) {
|
|
23655
23657
|
const items = [];
|
|
23656
|
-
this.itemsArray.forEach((
|
|
23657
|
-
if (
|
|
23658
|
-
items.push(
|
|
23658
|
+
this.itemsArray.forEach((item) => {
|
|
23659
|
+
if (item.isUnderPoint(point3, tolerace)) {
|
|
23660
|
+
items.push(item);
|
|
23659
23661
|
}
|
|
23660
23662
|
});
|
|
23661
23663
|
return items;
|
|
@@ -23666,8 +23668,8 @@ class SimpleSpatialIndex {
|
|
|
23666
23668
|
list() {
|
|
23667
23669
|
return this.itemsArray.concat();
|
|
23668
23670
|
}
|
|
23669
|
-
getZIndex(
|
|
23670
|
-
return this.itemsArray.indexOf(
|
|
23671
|
+
getZIndex(item) {
|
|
23672
|
+
return this.itemsArray.indexOf(item);
|
|
23671
23673
|
}
|
|
23672
23674
|
getLastZIndex() {
|
|
23673
23675
|
return this.itemsArray.length - 1;
|
|
@@ -23681,8 +23683,8 @@ class SimpleSpatialIndex {
|
|
|
23681
23683
|
}
|
|
23682
23684
|
}
|
|
23683
23685
|
render(context) {
|
|
23684
|
-
this.itemsArray.forEach((
|
|
23685
|
-
|
|
23686
|
+
this.itemsArray.forEach((item) => {
|
|
23687
|
+
item.render(context);
|
|
23686
23688
|
});
|
|
23687
23689
|
}
|
|
23688
23690
|
}
|
|
@@ -23733,7 +23735,7 @@ class BaseItem extends Mbr {
|
|
|
23733
23735
|
if (!this.index) {
|
|
23734
23736
|
return null;
|
|
23735
23737
|
}
|
|
23736
|
-
return this.index.items.listAll().map((
|
|
23738
|
+
return this.index.items.listAll().map((item) => item.getId());
|
|
23737
23739
|
}
|
|
23738
23740
|
addChildItems(children) {
|
|
23739
23741
|
if (!this.index) {
|
|
@@ -23771,17 +23773,17 @@ class BaseItem extends Mbr {
|
|
|
23771
23773
|
this.addChildItems(itemsToAdd);
|
|
23772
23774
|
this.removeChildItems(itemsToRemove);
|
|
23773
23775
|
}
|
|
23774
|
-
handleNesting(
|
|
23775
|
-
const isItem = "itemType" in
|
|
23776
|
-
const itemMbr = isItem ?
|
|
23777
|
-
if (
|
|
23776
|
+
handleNesting(item, options) {
|
|
23777
|
+
const isItem = "itemType" in item;
|
|
23778
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
23779
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
23778
23780
|
return false;
|
|
23779
23781
|
}
|
|
23780
|
-
if (options?.cancelIfChild && isItem &&
|
|
23782
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
23781
23783
|
return false;
|
|
23782
23784
|
}
|
|
23783
23785
|
const mbr = this.getMbr().copy();
|
|
23784
|
-
if (
|
|
23786
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
23785
23787
|
if (mbr.isInside(itemMbr.getCenter())) {
|
|
23786
23788
|
if (!options || !options.onlyForOut) {
|
|
23787
23789
|
return true;
|
|
@@ -26078,8 +26080,8 @@ function isChild(value) {
|
|
|
26078
26080
|
if (!Array.isArray(value2))
|
|
26079
26081
|
return true;
|
|
26080
26082
|
const list2 = value2;
|
|
26081
|
-
for (const
|
|
26082
|
-
if (typeof
|
|
26083
|
+
for (const item of list2) {
|
|
26084
|
+
if (typeof item !== "number" && typeof item !== "string") {
|
|
26083
26085
|
return true;
|
|
26084
26086
|
}
|
|
26085
26087
|
}
|
|
@@ -26118,8 +26120,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
26118
26120
|
}
|
|
26119
26121
|
if (Array.isArray(result)) {
|
|
26120
26122
|
const finalResult = [];
|
|
26121
|
-
for (const
|
|
26122
|
-
finalResult.push(parsePrimitive(info, info.property,
|
|
26123
|
+
for (const item of result) {
|
|
26124
|
+
finalResult.push(parsePrimitive(info, info.property, item));
|
|
26123
26125
|
}
|
|
26124
26126
|
result = finalResult;
|
|
26125
26127
|
}
|
|
@@ -37186,8 +37188,8 @@ function list5(node2, parent, state, info) {
|
|
|
37186
37188
|
if (checkRule(state) === bullet && firstListItem) {
|
|
37187
37189
|
let index2 = -1;
|
|
37188
37190
|
while (++index2 < node2.children.length) {
|
|
37189
|
-
const
|
|
37190
|
-
if (
|
|
37191
|
+
const item = node2.children[index2];
|
|
37192
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
37191
37193
|
useDifferentMarker = true;
|
|
37192
37194
|
break;
|
|
37193
37195
|
}
|
|
@@ -37848,12 +37850,12 @@ async function convertMarkdownToSlate(text5) {
|
|
|
37848
37850
|
...nodes.filter((node2) => node2.type !== "list_item")
|
|
37849
37851
|
];
|
|
37850
37852
|
}
|
|
37851
|
-
return nodes.map((
|
|
37853
|
+
return nodes.map((item) => {
|
|
37852
37854
|
setNodeStyles({
|
|
37853
|
-
node:
|
|
37854
|
-
isPaddingTopNeeded:
|
|
37855
|
+
node: item,
|
|
37856
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
37855
37857
|
});
|
|
37856
|
-
return
|
|
37858
|
+
return item;
|
|
37857
37859
|
});
|
|
37858
37860
|
}
|
|
37859
37861
|
function detectListType(text5) {
|
|
@@ -38266,17 +38268,17 @@ class FloatingPoint extends Point {
|
|
|
38266
38268
|
relativePoint;
|
|
38267
38269
|
pointType = "Floating";
|
|
38268
38270
|
edge;
|
|
38269
|
-
constructor(
|
|
38271
|
+
constructor(item, relativePoint) {
|
|
38270
38272
|
super();
|
|
38271
|
-
this.item =
|
|
38273
|
+
this.item = item;
|
|
38272
38274
|
this.relativePoint = relativePoint;
|
|
38273
38275
|
if (relativePoint.y <= 0) {
|
|
38274
38276
|
this.edge = "top";
|
|
38275
|
-
} else if (relativePoint.y >=
|
|
38277
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
38276
38278
|
this.edge = "bottom";
|
|
38277
38279
|
} else if (relativePoint.x <= 0) {
|
|
38278
38280
|
this.edge = "left";
|
|
38279
|
-
} else if (relativePoint.x >=
|
|
38281
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
38280
38282
|
this.edge = "right";
|
|
38281
38283
|
}
|
|
38282
38284
|
this.recalculatePoint();
|
|
@@ -38307,17 +38309,17 @@ class FixedPoint extends Point {
|
|
|
38307
38309
|
relativePoint;
|
|
38308
38310
|
pointType = "Fixed";
|
|
38309
38311
|
edge;
|
|
38310
|
-
constructor(
|
|
38312
|
+
constructor(item, relativePoint) {
|
|
38311
38313
|
super();
|
|
38312
|
-
this.item =
|
|
38314
|
+
this.item = item;
|
|
38313
38315
|
this.relativePoint = relativePoint;
|
|
38314
38316
|
if (relativePoint.y <= 0) {
|
|
38315
38317
|
this.edge = "top";
|
|
38316
|
-
} else if (relativePoint.y >=
|
|
38318
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
38317
38319
|
this.edge = "bottom";
|
|
38318
38320
|
} else if (relativePoint.x <= 0) {
|
|
38319
38321
|
this.edge = "left";
|
|
38320
|
-
} else if (relativePoint.x >=
|
|
38322
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
38321
38323
|
this.edge = "right";
|
|
38322
38324
|
}
|
|
38323
38325
|
this.recalculatePoint();
|
|
@@ -38348,16 +38350,16 @@ class FixedConnectorPoint extends Point {
|
|
|
38348
38350
|
tangent;
|
|
38349
38351
|
segmentIndex;
|
|
38350
38352
|
pointType = "FixedConnector";
|
|
38351
|
-
constructor(
|
|
38353
|
+
constructor(item, tangent, segmentIndex) {
|
|
38352
38354
|
super();
|
|
38353
|
-
this.item =
|
|
38355
|
+
this.item = item;
|
|
38354
38356
|
this.tangent = tangent;
|
|
38355
38357
|
this.segmentIndex = segmentIndex;
|
|
38356
38358
|
this.recalculatePoint();
|
|
38357
38359
|
}
|
|
38358
38360
|
recalculatePoint() {
|
|
38359
|
-
const
|
|
38360
|
-
const segments =
|
|
38361
|
+
const item = this.item;
|
|
38362
|
+
const segments = item.getPaths().getSegments();
|
|
38361
38363
|
const segment = segments.length > this.segmentIndex ? segments[this.segmentIndex] : segments[segments.length - 1];
|
|
38362
38364
|
const point5 = segment.getPoint(this.tangent);
|
|
38363
38365
|
this.x = point5.x;
|
|
@@ -38382,38 +38384,38 @@ function getControlPoint(data, findItem2) {
|
|
|
38382
38384
|
if (data.pointType === "Board") {
|
|
38383
38385
|
return new BoardPoint(Math.round(data.x), Math.round(data.y));
|
|
38384
38386
|
} else {
|
|
38385
|
-
const
|
|
38386
|
-
if (!
|
|
38387
|
+
const item = findItem2(data.itemId);
|
|
38388
|
+
if (!item) {
|
|
38387
38389
|
console.warn(`getControlPoint(): item not found for ${data.itemId}`);
|
|
38388
38390
|
return new BoardPoint(0, 0);
|
|
38389
38391
|
}
|
|
38390
38392
|
switch (data.pointType) {
|
|
38391
38393
|
case "FixedConnector":
|
|
38392
|
-
if (
|
|
38393
|
-
return new FixedConnectorPoint(
|
|
38394
|
+
if (item instanceof Connector2) {
|
|
38395
|
+
return new FixedConnectorPoint(item, data.tangent, data.segment);
|
|
38394
38396
|
} else {
|
|
38395
38397
|
throw new Error(`getControlPoint(): item must be a connector`);
|
|
38396
38398
|
}
|
|
38397
38399
|
case "Floating":
|
|
38398
|
-
return new FloatingPoint(
|
|
38400
|
+
return new FloatingPoint(item, new Point(data.relativeX, data.relativeY));
|
|
38399
38401
|
case "Fixed":
|
|
38400
|
-
return new FixedPoint(
|
|
38402
|
+
return new FixedPoint(item, new Point(data.relativeX, data.relativeY));
|
|
38401
38403
|
}
|
|
38402
38404
|
}
|
|
38403
38405
|
}
|
|
38404
|
-
function toRelativePoint(point5,
|
|
38405
|
-
const matrix =
|
|
38406
|
+
function toRelativePoint(point5, item) {
|
|
38407
|
+
const matrix = item.transformation?.matrix || new Matrix2;
|
|
38406
38408
|
const inverse = matrix.getInverse();
|
|
38407
38409
|
point5 = point5.copy();
|
|
38408
38410
|
point5.transform(inverse);
|
|
38409
38411
|
return point5;
|
|
38410
38412
|
}
|
|
38411
|
-
function fromRelativePoint(relativePoint,
|
|
38412
|
-
const matrix =
|
|
38413
|
+
function fromRelativePoint(relativePoint, item, edge) {
|
|
38414
|
+
const matrix = item.transformation?.matrix.copy() || new Matrix2;
|
|
38413
38415
|
const point5 = relativePoint.copy();
|
|
38414
38416
|
point5.transform(matrix);
|
|
38415
|
-
if (
|
|
38416
|
-
const itemMbr =
|
|
38417
|
+
if (item instanceof RichText || item instanceof AINode) {
|
|
38418
|
+
const itemMbr = item.getMbr();
|
|
38417
38419
|
const { x: centerX, y: centerY } = itemMbr.getCenter();
|
|
38418
38420
|
switch (edge) {
|
|
38419
38421
|
case "left":
|
|
@@ -38425,7 +38427,7 @@ function fromRelativePoint(relativePoint, item2, edge) {
|
|
|
38425
38427
|
case "bottom":
|
|
38426
38428
|
return new Point(centerX, itemMbr.bottom);
|
|
38427
38429
|
default:
|
|
38428
|
-
return
|
|
38430
|
+
return item.getMbr().getClosestEdgeCenterPoint(point5);
|
|
38429
38431
|
}
|
|
38430
38432
|
}
|
|
38431
38433
|
return point5;
|
|
@@ -39774,7 +39776,7 @@ class Connector2 extends BaseItem {
|
|
|
39774
39776
|
return this;
|
|
39775
39777
|
}
|
|
39776
39778
|
getConnectorById(items, connectorId) {
|
|
39777
|
-
return items.find((
|
|
39779
|
+
return items.find((item) => item instanceof Connector2 && item.getId() === connectorId);
|
|
39778
39780
|
}
|
|
39779
39781
|
updateTitle() {
|
|
39780
39782
|
const selection = this.board.selection;
|
|
@@ -42411,8 +42413,8 @@ async function exportBoardSnapshot({
|
|
|
42411
42413
|
context.matrix.applyToContext(context.ctx);
|
|
42412
42414
|
const { left, top, right, bottom } = selection;
|
|
42413
42415
|
const inView = board.items.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
42414
|
-
for (const
|
|
42415
|
-
|
|
42416
|
+
for (const item of inView) {
|
|
42417
|
+
item.render(context);
|
|
42416
42418
|
}
|
|
42417
42419
|
const blob = await offscreenCanvas.convertToBlob({ type: "image/png" });
|
|
42418
42420
|
const dataUrl = await convertBlobToDataUrl(blob);
|
|
@@ -42610,7 +42612,7 @@ class Frame2 extends BaseItem {
|
|
|
42610
42612
|
return this.id;
|
|
42611
42613
|
}
|
|
42612
42614
|
getChildrenIds() {
|
|
42613
|
-
return this.index?.list().map((
|
|
42615
|
+
return this.index?.list().map((item) => item.getId()) || [];
|
|
42614
42616
|
}
|
|
42615
42617
|
updateMbr() {
|
|
42616
42618
|
const rect = this.path.getMbr().copy();
|
|
@@ -42845,11 +42847,11 @@ class Frame2 extends BaseItem {
|
|
|
42845
42847
|
}
|
|
42846
42848
|
});
|
|
42847
42849
|
const currMbr = this.getMbr();
|
|
42848
|
-
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((
|
|
42849
|
-
if (
|
|
42850
|
-
if (this.handleNesting(
|
|
42851
|
-
this.applyAddChildren([
|
|
42852
|
-
|
|
42850
|
+
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((item) => {
|
|
42851
|
+
if (item.parent === "Board") {
|
|
42852
|
+
if (this.handleNesting(item)) {
|
|
42853
|
+
this.applyAddChildren([item.getId()]);
|
|
42854
|
+
item.parent = this.getId();
|
|
42853
42855
|
}
|
|
42854
42856
|
}
|
|
42855
42857
|
});
|
|
@@ -45047,9 +45049,9 @@ class Group extends BaseItem {
|
|
|
45047
45049
|
if (data.children) {
|
|
45048
45050
|
data.children.forEach((childId) => {
|
|
45049
45051
|
this.applyAddChild(childId);
|
|
45050
|
-
const
|
|
45051
|
-
if (
|
|
45052
|
-
|
|
45052
|
+
const item = this.board.items.getById(childId);
|
|
45053
|
+
if (item) {
|
|
45054
|
+
item.parent = this.getId();
|
|
45053
45055
|
}
|
|
45054
45056
|
});
|
|
45055
45057
|
}
|
|
@@ -45079,11 +45081,11 @@ class Group extends BaseItem {
|
|
|
45079
45081
|
let right = Number.MIN_SAFE_INTEGER;
|
|
45080
45082
|
let bottom = Number.MIN_SAFE_INTEGER;
|
|
45081
45083
|
const mbrs = this.children.flatMap((childId) => {
|
|
45082
|
-
const
|
|
45083
|
-
if (!
|
|
45084
|
+
const item = this.board.items.getById(childId);
|
|
45085
|
+
if (!item) {
|
|
45084
45086
|
return [];
|
|
45085
45087
|
}
|
|
45086
|
-
const mbr2 =
|
|
45088
|
+
const mbr2 = item.getMbr();
|
|
45087
45089
|
if (!mbr2) {
|
|
45088
45090
|
return [];
|
|
45089
45091
|
}
|
|
@@ -45118,7 +45120,7 @@ class Group extends BaseItem {
|
|
|
45118
45120
|
return this.children;
|
|
45119
45121
|
}
|
|
45120
45122
|
getChildren() {
|
|
45121
|
-
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((
|
|
45123
|
+
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((item) => item !== undefined);
|
|
45122
45124
|
}
|
|
45123
45125
|
updateMbr() {
|
|
45124
45126
|
const rect = this.getMbr();
|
|
@@ -45131,9 +45133,9 @@ class Group extends BaseItem {
|
|
|
45131
45133
|
setChildren(items) {
|
|
45132
45134
|
items.forEach((itemId) => {
|
|
45133
45135
|
this.addChild(itemId);
|
|
45134
|
-
const
|
|
45135
|
-
if (
|
|
45136
|
-
|
|
45136
|
+
const item = this.board.items.getById(itemId);
|
|
45137
|
+
if (item) {
|
|
45138
|
+
item.parent = this.getId();
|
|
45137
45139
|
}
|
|
45138
45140
|
});
|
|
45139
45141
|
this.updateMbr();
|
|
@@ -45141,9 +45143,9 @@ class Group extends BaseItem {
|
|
|
45141
45143
|
removeChildren() {
|
|
45142
45144
|
this.children.forEach((itemId) => {
|
|
45143
45145
|
this.removeChild(itemId);
|
|
45144
|
-
const
|
|
45145
|
-
if (
|
|
45146
|
-
|
|
45146
|
+
const item = this.board.items.getById(itemId);
|
|
45147
|
+
if (item) {
|
|
45148
|
+
item.parent = this.parent;
|
|
45147
45149
|
}
|
|
45148
45150
|
});
|
|
45149
45151
|
this.updateMbr();
|
|
@@ -45476,16 +45478,16 @@ class Anchor extends Mbr {
|
|
|
45476
45478
|
}
|
|
45477
45479
|
}
|
|
45478
45480
|
// src/Items/Connector/ConnectorSnap.ts
|
|
45479
|
-
function getFixedPoint(
|
|
45480
|
-
if (
|
|
45481
|
-
const nearestSegmentData =
|
|
45481
|
+
function getFixedPoint(item, point5) {
|
|
45482
|
+
if (item instanceof Connector2) {
|
|
45483
|
+
const nearestSegmentData = item.getPaths().getNearestEdgeAndPointTo(point5);
|
|
45482
45484
|
const segment = nearestSegmentData.segment;
|
|
45483
45485
|
const index2 = nearestSegmentData.index;
|
|
45484
45486
|
const tangent = segment.getParameter(point5);
|
|
45485
|
-
return new FixedConnectorPoint(
|
|
45487
|
+
return new FixedConnectorPoint(item, tangent, index2);
|
|
45486
45488
|
} else {
|
|
45487
|
-
const relativePoint = toRelativePoint(point5,
|
|
45488
|
-
return new FixedPoint(
|
|
45489
|
+
const relativePoint = toRelativePoint(point5, item);
|
|
45490
|
+
return new FixedPoint(item, relativePoint);
|
|
45489
45491
|
}
|
|
45490
45492
|
}
|
|
45491
45493
|
|
|
@@ -45538,20 +45540,20 @@ class ConnectorSnap {
|
|
|
45538
45540
|
}
|
|
45539
45541
|
this.setSnap();
|
|
45540
45542
|
const pointer = this.board.pointer.point;
|
|
45541
|
-
const { anchor, item
|
|
45542
|
-
if (!
|
|
45543
|
+
const { anchor, item, point: point5 } = this.snap;
|
|
45544
|
+
if (!item) {
|
|
45543
45545
|
const pointer2 = this.board.pointer.point;
|
|
45544
45546
|
this.controlPoint = new BoardPoint(pointer2.x, pointer2.y);
|
|
45545
45547
|
} else if (anchor) {
|
|
45546
|
-
this.controlPoint = getFixedPoint(
|
|
45548
|
+
this.controlPoint = getFixedPoint(item, anchor.getCenter());
|
|
45547
45549
|
} else if (point5) {
|
|
45548
|
-
const nearest2 =
|
|
45549
|
-
this.controlPoint = getFixedPoint(
|
|
45550
|
+
const nearest2 = item.getNearestEdgePointTo(pointer);
|
|
45551
|
+
this.controlPoint = getFixedPoint(item, nearest2);
|
|
45550
45552
|
} else {
|
|
45551
45553
|
if (this.hover.isTimeoutElapsed) {
|
|
45552
|
-
this.controlPoint = getFixedPoint(
|
|
45554
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
45553
45555
|
} else {
|
|
45554
|
-
this.controlPoint = getFixedPoint(
|
|
45556
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
45555
45557
|
}
|
|
45556
45558
|
}
|
|
45557
45559
|
}
|
|
@@ -45612,23 +45614,23 @@ class ConnectorSnap {
|
|
|
45612
45614
|
}
|
|
45613
45615
|
return nearest;
|
|
45614
45616
|
}
|
|
45615
|
-
getClosestPointOnItem(
|
|
45616
|
-
const nearestEdgePoint =
|
|
45617
|
-
return getFixedPoint(
|
|
45617
|
+
getClosestPointOnItem(item, position4) {
|
|
45618
|
+
const nearestEdgePoint = item.getNearestEdgePointTo(position4);
|
|
45619
|
+
return getFixedPoint(item, nearestEdgePoint);
|
|
45618
45620
|
}
|
|
45619
|
-
isNearBorder(
|
|
45620
|
-
if (!
|
|
45621
|
+
isNearBorder(item) {
|
|
45622
|
+
if (!item) {
|
|
45621
45623
|
return false;
|
|
45622
45624
|
}
|
|
45623
45625
|
const pointer = this.board.pointer.point;
|
|
45624
|
-
const point5 =
|
|
45626
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
45625
45627
|
const distance = pointer.getDistance(point5);
|
|
45626
45628
|
return distance < this.distance.border / this.board.camera.getScale();
|
|
45627
45629
|
}
|
|
45628
45630
|
setSnap() {
|
|
45629
|
-
const
|
|
45630
|
-
const path2 =
|
|
45631
|
-
if (!
|
|
45631
|
+
const item = this.snap.item;
|
|
45632
|
+
const path2 = item && "getPath" in item ? item?.getPath() : null;
|
|
45633
|
+
if (!item || !path2) {
|
|
45632
45634
|
this.snap.path = null;
|
|
45633
45635
|
this.snap.anchors = [];
|
|
45634
45636
|
this.snap.anchor = null;
|
|
@@ -45639,11 +45641,11 @@ class ConnectorSnap {
|
|
|
45639
45641
|
if (this.snap.item === this.hover.item && !this.hover.isTimeoutElapsed) {
|
|
45640
45642
|
path2.setBackgroundColor(this.color.snapBackgroundHighlight);
|
|
45641
45643
|
}
|
|
45642
|
-
this.setAnchors(
|
|
45644
|
+
this.setAnchors(item);
|
|
45643
45645
|
}
|
|
45644
45646
|
}
|
|
45645
|
-
setAnchors(
|
|
45646
|
-
const points =
|
|
45647
|
+
setAnchors(item) {
|
|
45648
|
+
const points = item.getSnapAnchorPoints();
|
|
45647
45649
|
if (!points) {
|
|
45648
45650
|
return;
|
|
45649
45651
|
}
|
|
@@ -45677,10 +45679,10 @@ class ConnectorSnap {
|
|
|
45677
45679
|
}
|
|
45678
45680
|
setPoint() {
|
|
45679
45681
|
const pointer = this.board.pointer.point;
|
|
45680
|
-
const { item
|
|
45681
|
-
if (
|
|
45682
|
+
const { item, anchor } = this.snap;
|
|
45683
|
+
if (item) {
|
|
45682
45684
|
if (!anchor) {
|
|
45683
|
-
const point5 =
|
|
45685
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
45684
45686
|
if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
|
|
45685
45687
|
this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
|
|
45686
45688
|
} else {
|
|
@@ -46053,12 +46055,12 @@ class NestingHighlighter extends Tool {
|
|
|
46053
46055
|
this.toHighlight.push({ groupItem, children: array });
|
|
46054
46056
|
}
|
|
46055
46057
|
}
|
|
46056
|
-
addSingleItem(
|
|
46057
|
-
this.toHighlight.push({ children: [
|
|
46058
|
+
addSingleItem(item) {
|
|
46059
|
+
this.toHighlight.push({ children: [item] });
|
|
46058
46060
|
}
|
|
46059
|
-
remove(
|
|
46061
|
+
remove(item) {
|
|
46060
46062
|
this.toHighlight.forEach((group) => {
|
|
46061
|
-
group.children = group.children.filter((child) => child !==
|
|
46063
|
+
group.children = group.children.filter((child) => child !== item);
|
|
46062
46064
|
});
|
|
46063
46065
|
this.toHighlight = this.toHighlight.filter((group) => group.children.length > 0);
|
|
46064
46066
|
}
|
|
@@ -46125,7 +46127,7 @@ class AddFrame extends BoardTool {
|
|
|
46125
46127
|
this.mbr.borderColor = "blue";
|
|
46126
46128
|
this.nestingHighlighter.clear();
|
|
46127
46129
|
const enclosedOrCrossed = this.board.items.getEnclosedOrCrossed(this.mbr.left, this.mbr.top, this.mbr.right, this.mbr.bottom);
|
|
46128
|
-
const inside = enclosedOrCrossed.filter((
|
|
46130
|
+
const inside = enclosedOrCrossed.filter((item) => !(item instanceof Frame2) && item.parent === "Board" && this.mbr.isInside(item.getMbr().getCenter()));
|
|
46129
46131
|
this.nestingHighlighter.add(this.frame, inside);
|
|
46130
46132
|
this.initTransformation();
|
|
46131
46133
|
this.board.tools.publish();
|
|
@@ -46146,7 +46148,7 @@ class AddFrame extends BoardTool {
|
|
|
46146
46148
|
localStorage.setItem("lastFrameScale", JSON.stringify(this.frame.transformation.getScale()));
|
|
46147
46149
|
}
|
|
46148
46150
|
const currMbr = this.frame.getMbr();
|
|
46149
|
-
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
46151
|
+
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board").filter((item) => this.frame.handleNesting(item));
|
|
46150
46152
|
this.applyAddChildren(frameChildren);
|
|
46151
46153
|
if (this.shape !== "Custom") {
|
|
46152
46154
|
this.applyCanChangeRatio(false);
|
|
@@ -46162,7 +46164,7 @@ class AddFrame extends BoardTool {
|
|
|
46162
46164
|
return true;
|
|
46163
46165
|
}
|
|
46164
46166
|
addNextTo() {
|
|
46165
|
-
const framesInView = this.board.items.getItemsInView().filter((
|
|
46167
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame2);
|
|
46166
46168
|
if (framesInView.length === 0) {
|
|
46167
46169
|
if (this.shape === "Custom") {
|
|
46168
46170
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -46200,7 +46202,7 @@ class AddFrame extends BoardTool {
|
|
|
46200
46202
|
this.board.camera.viewRectangle(this.frame.getMbr());
|
|
46201
46203
|
}
|
|
46202
46204
|
const frameMbr = this.frame.getMbr();
|
|
46203
|
-
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((
|
|
46205
|
+
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((item) => item.parent === "Board").filter((item) => this.frame.handleNesting(item)).forEach((item) => this.applyAddChildren([item]));
|
|
46204
46206
|
const frame = this.board.add(this.frame);
|
|
46205
46207
|
frame.text.editor.moveCursorToEndOfTheText();
|
|
46206
46208
|
this.nestingHighlighter.clear();
|
|
@@ -46705,13 +46707,13 @@ class Eraser extends BoardTool {
|
|
|
46705
46707
|
}
|
|
46706
46708
|
removeUnderPointOrLine() {
|
|
46707
46709
|
const segments = this.drawing.getLines();
|
|
46708
|
-
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((
|
|
46709
|
-
return
|
|
46710
|
-
return line.getDistance(this.board.pointer.point) <=
|
|
46710
|
+
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((item) => {
|
|
46711
|
+
return item.itemType === "Drawing" && item.getLines().find((line) => {
|
|
46712
|
+
return line.getDistance(this.board.pointer.point) <= item.strokeWidth / 2 + this.strokeWidth / 2;
|
|
46711
46713
|
});
|
|
46712
46714
|
});
|
|
46713
|
-
items.push(...this.board.items.getEnclosedOrCrossed(this.drawing.points[0].x, this.drawing.points[0].y, this.board.pointer.point.x, this.board.pointer.point.y).filter((
|
|
46714
|
-
return
|
|
46715
|
+
items.push(...this.board.items.getEnclosedOrCrossed(this.drawing.points[0].x, this.drawing.points[0].y, this.board.pointer.point.x, this.board.pointer.point.y).filter((item) => {
|
|
46716
|
+
return item.itemType === "Drawing" && item.getLines().some((line) => {
|
|
46715
46717
|
return segments.some((segment) => segment.hasIntersectionPoint(line));
|
|
46716
46718
|
});
|
|
46717
46719
|
}));
|
|
@@ -47163,20 +47165,20 @@ function createCanvasDrawer(board) {
|
|
|
47163
47165
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
47164
47166
|
context.matrix.applyToContext(context.ctx);
|
|
47165
47167
|
const items = Object.keys(translation).map((id) => {
|
|
47166
|
-
const
|
|
47167
|
-
if (
|
|
47168
|
-
if (
|
|
47169
|
-
return
|
|
47168
|
+
const item = board2.items.getById(id);
|
|
47169
|
+
if (item) {
|
|
47170
|
+
if (item.itemType !== "Frame") {
|
|
47171
|
+
return item;
|
|
47170
47172
|
}
|
|
47171
|
-
|
|
47172
|
-
return
|
|
47173
|
+
item.render(context);
|
|
47174
|
+
return item;
|
|
47173
47175
|
}
|
|
47174
47176
|
return;
|
|
47175
|
-
}).filter((
|
|
47176
|
-
items.forEach((
|
|
47177
|
-
if (
|
|
47178
|
-
|
|
47179
|
-
board2.selection.renderItemMbr(context,
|
|
47177
|
+
}).filter((item) => !!item);
|
|
47178
|
+
items.forEach((item) => {
|
|
47179
|
+
if (item.itemType !== "Frame") {
|
|
47180
|
+
item.render(context);
|
|
47181
|
+
board2.selection.renderItemMbr(context, item, board2.camera.getMatrix().scaleX);
|
|
47180
47182
|
}
|
|
47181
47183
|
});
|
|
47182
47184
|
return { canvas: container, items };
|
|
@@ -47237,10 +47239,10 @@ function createCanvasDrawer(board) {
|
|
|
47237
47239
|
if (lastTranslationKeys) {
|
|
47238
47240
|
board.selection.shouldPublish = false;
|
|
47239
47241
|
lastTranslationKeys.forEach((id) => {
|
|
47240
|
-
const
|
|
47241
|
-
if (
|
|
47242
|
-
|
|
47243
|
-
|
|
47242
|
+
const item = board.items.getById(id);
|
|
47243
|
+
if (item) {
|
|
47244
|
+
item.transformationRenderBlock = undefined;
|
|
47245
|
+
item.subject.publish(item);
|
|
47244
47246
|
}
|
|
47245
47247
|
});
|
|
47246
47248
|
lastTranslationKeys = undefined;
|
|
@@ -47272,9 +47274,9 @@ function createCanvasDrawer(board) {
|
|
|
47272
47274
|
lastCreatedCanvas = cnvs;
|
|
47273
47275
|
lastTranslationKeys = Object.keys(translation);
|
|
47274
47276
|
lastTranslationKeys.forEach((id) => {
|
|
47275
|
-
const
|
|
47276
|
-
if (
|
|
47277
|
-
|
|
47277
|
+
const item = board.items.getById(id);
|
|
47278
|
+
if (item) {
|
|
47279
|
+
item.transformationRenderBlock = true;
|
|
47278
47280
|
}
|
|
47279
47281
|
});
|
|
47280
47282
|
board.selection.transformationRenderBlock = true;
|
|
@@ -47284,14 +47286,14 @@ function createCanvasDrawer(board) {
|
|
|
47284
47286
|
}
|
|
47285
47287
|
function countSumMbr(translation) {
|
|
47286
47288
|
return Object.keys(translation).reduce((mbr, id) => {
|
|
47287
|
-
const
|
|
47288
|
-
if (
|
|
47289
|
+
const item = board.items.getById(id);
|
|
47290
|
+
if (item) {
|
|
47289
47291
|
if (!mbr) {
|
|
47290
|
-
mbr =
|
|
47292
|
+
mbr = item.getMbr();
|
|
47291
47293
|
} else {
|
|
47292
|
-
mbr.combine(
|
|
47293
|
-
if (
|
|
47294
|
-
mbr.combine(
|
|
47294
|
+
mbr.combine(item.getMbr());
|
|
47295
|
+
if (item.itemType === "Frame") {
|
|
47296
|
+
mbr.combine(item.getRichText().getMbr());
|
|
47295
47297
|
}
|
|
47296
47298
|
}
|
|
47297
47299
|
}
|
|
@@ -47322,8 +47324,8 @@ function createCanvasDrawer(board) {
|
|
|
47322
47324
|
}
|
|
47323
47325
|
function highlightNesting() {
|
|
47324
47326
|
const container = getLastCreatedCanvas();
|
|
47325
|
-
const drawnItemsMap = drawnItems?.reduce((acc,
|
|
47326
|
-
acc.set(
|
|
47327
|
+
const drawnItemsMap = drawnItems?.reduce((acc, item) => {
|
|
47328
|
+
acc.set(item.getId(), { item, mbr: item.getMbr() });
|
|
47327
47329
|
return acc;
|
|
47328
47330
|
}, new Map);
|
|
47329
47331
|
if (!container || !drawnItems) {
|
|
@@ -47358,11 +47360,11 @@ function createCanvasDrawer(board) {
|
|
|
47358
47360
|
mbr.transform(currMatrix);
|
|
47359
47361
|
});
|
|
47360
47362
|
groups.forEach((group) => {
|
|
47361
|
-
drawnItemsMap?.forEach(({ mbr, item
|
|
47362
|
-
if ("canBeNested" in
|
|
47363
|
+
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
47364
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
47363
47365
|
return;
|
|
47364
47366
|
}
|
|
47365
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) ||
|
|
47367
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
47366
47368
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
47367
47369
|
removeHighlighted(key);
|
|
47368
47370
|
highlightedDivs.set(key, div);
|
|
@@ -47423,10 +47425,10 @@ function createCanvasDrawer(board) {
|
|
|
47423
47425
|
}
|
|
47424
47426
|
|
|
47425
47427
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
47426
|
-
function getControlPointData(
|
|
47427
|
-
const itemScale = isRichText ? { x: 1, y: 1 } :
|
|
47428
|
-
const width2 =
|
|
47429
|
-
let height3 =
|
|
47428
|
+
function getControlPointData(item, index2, isRichText = false) {
|
|
47429
|
+
const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
|
|
47430
|
+
const width2 = item.getPathMbr().getWidth();
|
|
47431
|
+
let height3 = item.getPathMbr().getHeight();
|
|
47430
47432
|
const adjMapScaled = {
|
|
47431
47433
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
47432
47434
|
1: {
|
|
@@ -47441,7 +47443,7 @@ function getControlPointData(item2, index2, isRichText = false) {
|
|
|
47441
47443
|
};
|
|
47442
47444
|
return {
|
|
47443
47445
|
pointType: "Fixed",
|
|
47444
|
-
itemId:
|
|
47446
|
+
itemId: item.getId(),
|
|
47445
47447
|
relativeX: adjMapScaled[index2].x,
|
|
47446
47448
|
relativeY: adjMapScaled[index2].y
|
|
47447
47449
|
};
|
|
@@ -47576,10 +47578,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
47576
47578
|
let newHeight = height3;
|
|
47577
47579
|
let itemData;
|
|
47578
47580
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
47579
|
-
const
|
|
47580
|
-
newWidth =
|
|
47581
|
-
newHeight =
|
|
47582
|
-
itemData =
|
|
47581
|
+
const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
47582
|
+
newWidth = item.getMbr().getWidth();
|
|
47583
|
+
newHeight = item.getMbr().getHeight();
|
|
47584
|
+
itemData = item.serialize();
|
|
47583
47585
|
const { minX, minY, maxY, maxX } = offsets;
|
|
47584
47586
|
offsetX = Math.min(offsetX, maxX);
|
|
47585
47587
|
offsetX = Math.max(offsetX, minX);
|
|
@@ -47612,7 +47614,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47612
47614
|
}
|
|
47613
47615
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
47614
47616
|
let step = 1;
|
|
47615
|
-
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((
|
|
47617
|
+
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((item) => item.itemType !== "Connector").length > 0) {
|
|
47616
47618
|
const xDirection = step % 2 === 0 ? -1 : 1;
|
|
47617
47619
|
const yDirection = newItemData.itemType === "AINode" ? -1 : xDirection;
|
|
47618
47620
|
newMbr.transform(new Matrix2(iterAdjustment[index2].x * xDirection * step, iterAdjustment[index2].y * yDirection * (newItemData.itemType === "AINode" ? 1 : step)));
|
|
@@ -47745,7 +47747,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47745
47747
|
clear();
|
|
47746
47748
|
return;
|
|
47747
47749
|
}
|
|
47748
|
-
const { positions, item
|
|
47750
|
+
const { positions, item } = position4;
|
|
47749
47751
|
const cameraMatrix = board.camera.getMatrix();
|
|
47750
47752
|
const cameraMbr = board.camera.getMbr();
|
|
47751
47753
|
const positionAdjustments = {
|
|
@@ -47773,7 +47775,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47773
47775
|
};
|
|
47774
47776
|
const button = document.createElement("button");
|
|
47775
47777
|
button.classList.add("microboard-quickAddButton");
|
|
47776
|
-
if (
|
|
47778
|
+
if (item.itemType === "AINode" && index2 === 2) {
|
|
47777
47779
|
button.classList.add("microboard-invisible");
|
|
47778
47780
|
}
|
|
47779
47781
|
button.classList.add(`microboard-${adjustment.rotate}`);
|
|
@@ -47789,7 +47791,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47789
47791
|
clearTimeout(timeoutId);
|
|
47790
47792
|
}
|
|
47791
47793
|
if (button.isMouseDown) {
|
|
47792
|
-
board.tools.addConnector(true,
|
|
47794
|
+
board.tools.addConnector(true, item, pos);
|
|
47793
47795
|
} else {
|
|
47794
47796
|
quickAddItems = undefined;
|
|
47795
47797
|
selection.subject.publish(selection);
|
|
@@ -47896,11 +47898,11 @@ class AlignmentHelper {
|
|
|
47896
47898
|
return baseThickness / (zoom / 100);
|
|
47897
47899
|
}
|
|
47898
47900
|
combineMBRs(items) {
|
|
47899
|
-
return items.reduce((acc,
|
|
47901
|
+
return items.reduce((acc, item, i) => {
|
|
47900
47902
|
if (i === 0) {
|
|
47901
47903
|
return acc;
|
|
47902
47904
|
}
|
|
47903
|
-
const itemMbr =
|
|
47905
|
+
const itemMbr = item.getPathMbr();
|
|
47904
47906
|
return acc.combine(itemMbr);
|
|
47905
47907
|
}, items[0].getMbr());
|
|
47906
47908
|
}
|
|
@@ -47914,7 +47916,7 @@ class AlignmentHelper {
|
|
|
47914
47916
|
const scale = this.board.camera.getScale();
|
|
47915
47917
|
const dynamicAlignThreshold = Math.min(this.alignThreshold / scale, 8);
|
|
47916
47918
|
const childrenIds = "index" in movingItem && movingItem.index ? movingItem.getChildrenIds() : [];
|
|
47917
|
-
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (
|
|
47919
|
+
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (item) => !excludeItems.includes(item), Math.ceil(cameraWidth)) : this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (otherItem) => otherItem !== movingMBR && otherItem.itemType !== "Connector" && otherItem.itemType !== "Drawing" && otherItem.isInView(camera) && !childrenIds.includes(otherItem.getId()), Math.ceil(cameraWidth)).filter((item) => Array.isArray(movingItem) ? !movingItem.includes(item) : true);
|
|
47918
47920
|
const verticalAlignments = new Map;
|
|
47919
47921
|
const horizontalAlignments = new Map;
|
|
47920
47922
|
const addVerticalAlignment = (x, minY, maxY) => {
|
|
@@ -47935,11 +47937,11 @@ class AlignmentHelper {
|
|
|
47935
47937
|
horizontalAlignments.set(y, { minX, maxX });
|
|
47936
47938
|
}
|
|
47937
47939
|
};
|
|
47938
|
-
nearbyItems.forEach((
|
|
47939
|
-
if (
|
|
47940
|
+
nearbyItems.forEach((item) => {
|
|
47941
|
+
if (item === movingItem || item.itemType === "Comment") {
|
|
47940
47942
|
return;
|
|
47941
47943
|
}
|
|
47942
|
-
const itemMbr =
|
|
47944
|
+
const itemMbr = item.itemType === "Shape" ? item.getPath().getMbr() : item.getMbr();
|
|
47943
47945
|
const centerXMoving = (movingMBR.left + movingMBR.right) / 2;
|
|
47944
47946
|
const centerXItem = (itemMbr.left + itemMbr.right) / 2;
|
|
47945
47947
|
const centerYMoving = (movingMBR.top + movingMBR.bottom) / 2;
|
|
@@ -48206,20 +48208,20 @@ class AlignmentHelper {
|
|
|
48206
48208
|
}
|
|
48207
48209
|
return false;
|
|
48208
48210
|
}
|
|
48209
|
-
translateItems(
|
|
48211
|
+
translateItems(item, x, y, timeStamp) {
|
|
48210
48212
|
if (this.canvasDrawer.getLastCreatedCanvas()) {
|
|
48211
48213
|
return;
|
|
48212
48214
|
}
|
|
48213
|
-
if (Array.isArray(
|
|
48215
|
+
if (Array.isArray(item)) {
|
|
48214
48216
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
48215
48217
|
this.board.selection.transformMany(translation, timeStamp);
|
|
48216
48218
|
return;
|
|
48217
48219
|
}
|
|
48218
|
-
if (
|
|
48220
|
+
if (item.itemType === "Frame") {
|
|
48219
48221
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
48220
48222
|
this.board.selection.transformMany(translation, timeStamp);
|
|
48221
48223
|
} else {
|
|
48222
|
-
const id =
|
|
48224
|
+
const id = item.getId();
|
|
48223
48225
|
const transformMap = {};
|
|
48224
48226
|
transformMap[id] = {
|
|
48225
48227
|
class: "Transformation",
|
|
@@ -48347,12 +48349,12 @@ class Select extends Tool {
|
|
|
48347
48349
|
this.debounceUpd.setFalse();
|
|
48348
48350
|
this.snapLines = { verticalLines: [], horizontalLines: [] };
|
|
48349
48351
|
}
|
|
48350
|
-
handleSnapping(
|
|
48352
|
+
handleSnapping(item) {
|
|
48351
48353
|
if (this.board.keyboard.isShift) {
|
|
48352
48354
|
return false;
|
|
48353
48355
|
}
|
|
48354
|
-
const increasedSnapThreshold = Array.isArray(
|
|
48355
|
-
this.isSnapped = this.alignmentHelper.snapToClosestLine(
|
|
48356
|
+
const increasedSnapThreshold = Array.isArray(item) ? 40 : 35;
|
|
48357
|
+
this.isSnapped = this.alignmentHelper.snapToClosestLine(item, this.snapLines, this.beginTimeStamp, this.board.pointer.point);
|
|
48356
48358
|
if (this.isSnapped) {
|
|
48357
48359
|
if (!this.snapCursorPos) {
|
|
48358
48360
|
this.snapCursorPos = new Point(this.board.pointer.point.x, this.board.pointer.point.y);
|
|
@@ -48362,10 +48364,10 @@ class Select extends Tool {
|
|
|
48362
48364
|
if ((cursorDiffX > increasedSnapThreshold || cursorDiffY > increasedSnapThreshold) && this.initialCursorPos) {
|
|
48363
48365
|
this.isSnapped = false;
|
|
48364
48366
|
this.snapCursorPos = null;
|
|
48365
|
-
const itemCenter = Array.isArray(
|
|
48367
|
+
const itemCenter = Array.isArray(item) ? this.alignmentHelper.combineMBRs(item).getCenter() : item.getMbr().getCenter();
|
|
48366
48368
|
const translateX = this.board.pointer.point.x - this.initialCursorPos.x - itemCenter.x;
|
|
48367
48369
|
const translateY = this.board.pointer.point.y - this.initialCursorPos.y - itemCenter.y;
|
|
48368
|
-
this.alignmentHelper.translateItems(
|
|
48370
|
+
this.alignmentHelper.translateItems(item, translateX, translateY, this.beginTimeStamp);
|
|
48369
48371
|
}
|
|
48370
48372
|
}
|
|
48371
48373
|
return false;
|
|
@@ -48415,10 +48417,10 @@ class Select extends Tool {
|
|
|
48415
48417
|
angleDiff = angleDiff < 0 ? angleDiff + 360 : angleDiff;
|
|
48416
48418
|
return Math.min(angleDiff, 360 - angleDiff);
|
|
48417
48419
|
}
|
|
48418
|
-
handleShiftGuidelines(
|
|
48419
|
-
if (
|
|
48420
|
+
handleShiftGuidelines(item, mousePosition) {
|
|
48421
|
+
if (item) {
|
|
48420
48422
|
if (!this.originalCenter) {
|
|
48421
|
-
this.originalCenter = Array.isArray(
|
|
48423
|
+
this.originalCenter = Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().copy() : item.getMbr().getCenter().copy();
|
|
48422
48424
|
this.guidelines = this.alignmentHelper.generateGuidelines(this.originalCenter).lines;
|
|
48423
48425
|
}
|
|
48424
48426
|
this.mainLine = new Line(this.originalCenter, mousePosition);
|
|
@@ -48439,13 +48441,13 @@ class Select extends Tool {
|
|
|
48439
48441
|
const newEndX = this.originalCenter.x + snapDirectionX * mainLineLength;
|
|
48440
48442
|
const newEndY = this.originalCenter.y + snapDirectionY * mainLineLength;
|
|
48441
48443
|
const threshold = Infinity;
|
|
48442
|
-
const translateX = newEndX - (Array.isArray(
|
|
48443
|
-
const translateY = newEndY - (Array.isArray(
|
|
48444
|
-
if (Array.isArray(
|
|
48444
|
+
const translateX = newEndX - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().x : item.getMbr().getCenter().x);
|
|
48445
|
+
const translateY = newEndY - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().y : item.getMbr().getCenter().y);
|
|
48446
|
+
if (Array.isArray(item)) {
|
|
48445
48447
|
const translation = this.board.selection.getManyItemsTranslation(translateX, translateY);
|
|
48446
48448
|
this.board.selection.transformMany(translation, this.beginTimeStamp);
|
|
48447
48449
|
} else {
|
|
48448
|
-
|
|
48450
|
+
item.transformation.translateBy(translateX, translateY, this.beginTimeStamp);
|
|
48449
48451
|
}
|
|
48450
48452
|
}
|
|
48451
48453
|
}
|
|
@@ -48488,7 +48490,7 @@ class Select extends Tool {
|
|
|
48488
48490
|
return false;
|
|
48489
48491
|
}
|
|
48490
48492
|
this.isDownOnBoard = hover.length === 0;
|
|
48491
|
-
this.isDrawingRectangle = hover.filter((
|
|
48493
|
+
this.isDrawingRectangle = hover.filter((item) => !(item instanceof Frame2)).length === 0 && hover.filter((item) => item instanceof Frame2).filter((frame) => frame.isTextUnderPoint(pointer.point)).length === 0;
|
|
48492
48494
|
if (this.isDrawingRectangle) {
|
|
48493
48495
|
const { x, y } = pointer.point;
|
|
48494
48496
|
this.line = new Line(new Point(x, y), new Point(x, y));
|
|
@@ -48508,7 +48510,7 @@ class Select extends Tool {
|
|
|
48508
48510
|
});
|
|
48509
48511
|
return false;
|
|
48510
48512
|
}
|
|
48511
|
-
const isHoverLocked = hover.every((
|
|
48513
|
+
const isHoverLocked = hover.every((item) => item.transformation.isLocked);
|
|
48512
48514
|
if (isHoverLocked) {
|
|
48513
48515
|
return false;
|
|
48514
48516
|
}
|
|
@@ -48642,7 +48644,7 @@ class Select extends Tool {
|
|
|
48642
48644
|
const translation = selection.getManyItemsTranslation(x, y);
|
|
48643
48645
|
const translationKeys = Object.keys(translation);
|
|
48644
48646
|
const commentsSet = new Set(this.board.items.getComments().map((comment2) => comment2.getId()));
|
|
48645
|
-
if (translationKeys.filter((
|
|
48647
|
+
if (translationKeys.filter((item) => !commentsSet.has(item)).length > 10) {
|
|
48646
48648
|
const selectedMbr = this.board.selection.getMbr()?.copy();
|
|
48647
48649
|
const sumMbr = this.canvasDrawer.countSumMbr(translation);
|
|
48648
48650
|
if (sumMbr) {
|
|
@@ -48669,7 +48671,7 @@ class Select extends Tool {
|
|
|
48669
48671
|
return false;
|
|
48670
48672
|
}
|
|
48671
48673
|
const draggingMbr = draggingItem.getMbr();
|
|
48672
|
-
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((
|
|
48674
|
+
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((item) => item instanceof Frame2);
|
|
48673
48675
|
frames.forEach((frame) => {
|
|
48674
48676
|
if (frame.handleNesting(draggingItem)) {
|
|
48675
48677
|
this.nestingHighlighter.add(frame, draggingItem);
|
|
@@ -48679,7 +48681,7 @@ class Select extends Tool {
|
|
|
48679
48681
|
});
|
|
48680
48682
|
}
|
|
48681
48683
|
const hover = items.getUnderPointer();
|
|
48682
|
-
this.isHoverUnselectedItem = hover.filter((
|
|
48684
|
+
this.isHoverUnselectedItem = hover.filter((item) => item.itemType === "Placeholder").length === 1;
|
|
48683
48685
|
if (this.isHoverUnselectedItem && !this.isDraggingUnselectedItem && selection.getContext() === "None") {
|
|
48684
48686
|
selection.setContext("HoverUnderPointer");
|
|
48685
48687
|
return false;
|
|
@@ -48723,15 +48725,15 @@ class Select extends Tool {
|
|
|
48723
48725
|
}
|
|
48724
48726
|
}
|
|
48725
48727
|
updateFramesNesting(selectionMbr, selection) {
|
|
48726
|
-
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((
|
|
48727
|
-
const draggingFramesIds = selection.list().filter((
|
|
48728
|
-
selection.list().forEach((
|
|
48729
|
-
if (!(
|
|
48728
|
+
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((item) => item instanceof Frame2).filter((frame) => !selection.items.list().includes(frame));
|
|
48729
|
+
const draggingFramesIds = selection.list().filter((item) => item instanceof Frame2).map((frame) => frame.getId());
|
|
48730
|
+
selection.list().forEach((item) => {
|
|
48731
|
+
if (!(item instanceof Frame2) && !draggingFramesIds.includes(item.parent)) {
|
|
48730
48732
|
frames.forEach((frame) => {
|
|
48731
|
-
if (frame.handleNesting(
|
|
48732
|
-
this.nestingHighlighter.add(frame,
|
|
48733
|
+
if (frame.handleNesting(item)) {
|
|
48734
|
+
this.nestingHighlighter.add(frame, item);
|
|
48733
48735
|
} else {
|
|
48734
|
-
this.nestingHighlighter.remove(
|
|
48736
|
+
this.nestingHighlighter.remove(item);
|
|
48735
48737
|
}
|
|
48736
48738
|
});
|
|
48737
48739
|
}
|
|
@@ -48823,7 +48825,7 @@ class Select extends Tool {
|
|
|
48823
48825
|
const childrenIds = underPointer.getChildrenIds();
|
|
48824
48826
|
console.log("UNDERPOINTER", underPointer);
|
|
48825
48827
|
console.log("CHILDREN", childrenIds);
|
|
48826
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
48828
|
+
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
48827
48829
|
this.board.selection.add(itemsInFrame);
|
|
48828
48830
|
}
|
|
48829
48831
|
this.board.selection.setContext("EditUnderPointer");
|
|
@@ -49063,8 +49065,8 @@ class ShapeTool extends CustomTool {
|
|
|
49063
49065
|
resizeType = "leftBottom";
|
|
49064
49066
|
bounds = new Mbr;
|
|
49065
49067
|
isDown = false;
|
|
49066
|
-
constructor(board, name,
|
|
49067
|
-
super(board, name,
|
|
49068
|
+
constructor(board, name, item, settings) {
|
|
49069
|
+
super(board, name, item);
|
|
49068
49070
|
this.settings = settings;
|
|
49069
49071
|
this.setCursor();
|
|
49070
49072
|
}
|
|
@@ -49147,8 +49149,8 @@ class ShapeTool extends CustomTool {
|
|
|
49147
49149
|
|
|
49148
49150
|
class StickerTool extends CustomTool {
|
|
49149
49151
|
settings;
|
|
49150
|
-
constructor(board, name,
|
|
49151
|
-
super(board, name,
|
|
49152
|
+
constructor(board, name, item, settings) {
|
|
49153
|
+
super(board, name, item);
|
|
49152
49154
|
this.settings = settings;
|
|
49153
49155
|
this.setCursor();
|
|
49154
49156
|
}
|
|
@@ -49454,7 +49456,7 @@ class Tools extends ToolContext {
|
|
|
49454
49456
|
this.subject.publish(this);
|
|
49455
49457
|
}
|
|
49456
49458
|
sortFrames() {
|
|
49457
|
-
const frames = this.board.items.listAll().filter((
|
|
49459
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame2);
|
|
49458
49460
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
49459
49461
|
const mbr1 = fr1.getMbr();
|
|
49460
49462
|
const mbr2 = fr2.getMbr();
|
|
@@ -49680,24 +49682,24 @@ function validateGroupData(groupData) {
|
|
|
49680
49682
|
}
|
|
49681
49683
|
// src/Items/RegisterItem.ts
|
|
49682
49684
|
function registerItem({
|
|
49683
|
-
item
|
|
49685
|
+
item,
|
|
49684
49686
|
defaultData: defaultData2,
|
|
49685
49687
|
toolData
|
|
49686
49688
|
}) {
|
|
49687
49689
|
const { itemType } = defaultData2;
|
|
49688
|
-
itemFactories[itemType] = createItemFactory(
|
|
49690
|
+
itemFactories[itemType] = createItemFactory(item, defaultData2);
|
|
49689
49691
|
itemValidators[itemType] = createItemValidator(defaultData2);
|
|
49690
49692
|
if (toolData) {
|
|
49691
49693
|
registeredTools[toolData.name] = toolData.tool;
|
|
49692
49694
|
}
|
|
49693
49695
|
itemCommandFactories[itemType] = createItemCommandFactory(itemType);
|
|
49694
49696
|
}
|
|
49695
|
-
function createItemFactory(
|
|
49697
|
+
function createItemFactory(item, defaultData2) {
|
|
49696
49698
|
return function itemFactory(id, data, board) {
|
|
49697
49699
|
if (data.itemType !== defaultData2.itemType) {
|
|
49698
49700
|
throw new Error(`Invalid data for ${defaultData2.itemType}`);
|
|
49699
49701
|
}
|
|
49700
|
-
return new
|
|
49702
|
+
return new item(board, id, defaultData2).setId(id).deserialize(data);
|
|
49701
49703
|
};
|
|
49702
49704
|
}
|
|
49703
49705
|
function createItemValidator(defaultData2) {
|
|
@@ -49712,7 +49714,7 @@ function createItemValidator(defaultData2) {
|
|
|
49712
49714
|
}
|
|
49713
49715
|
function createItemCommandFactory(itemType) {
|
|
49714
49716
|
return function itemCommandFactory(items, operation) {
|
|
49715
|
-
return new BaseCommand(items.filter((
|
|
49717
|
+
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49716
49718
|
};
|
|
49717
49719
|
}
|
|
49718
49720
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -50737,8 +50739,8 @@ class Camera {
|
|
|
50737
50739
|
this.observableItem = null;
|
|
50738
50740
|
}
|
|
50739
50741
|
}
|
|
50740
|
-
subscribeToItem(
|
|
50741
|
-
this.observableItem =
|
|
50742
|
+
subscribeToItem(item) {
|
|
50743
|
+
this.observableItem = item;
|
|
50742
50744
|
this.observableItem.subject.subscribe(this.observeItem);
|
|
50743
50745
|
}
|
|
50744
50746
|
observeItem = () => {
|
|
@@ -50964,7 +50966,7 @@ class Camera {
|
|
|
50964
50966
|
}
|
|
50965
50967
|
addToView(mbr, inView) {
|
|
50966
50968
|
if (!mbr.isEnclosedBy(this.getMbr())) {
|
|
50967
|
-
this.viewRectangle(inView.reduce((acc,
|
|
50969
|
+
this.viewRectangle(inView.reduce((acc, item) => acc.combine(item.getMbr()), inView[0]?.getMbr() ?? new Mbr).combine(mbr));
|
|
50968
50970
|
}
|
|
50969
50971
|
}
|
|
50970
50972
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
@@ -52573,8 +52575,8 @@ class Presence {
|
|
|
52573
52575
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.28421 4.30174C3.55182 4.02741 3.95268 3.93015 4.31625 4.05135L20.3163 9.38468C20.7064 9.51472 20.9771 9.8703 20.9987 10.2809C21.0202 10.6916 20.7882 11.0736 20.4138 11.2437L20.36 11.2682L20.2042 11.3396C20.069 11.4015 19.8742 11.4912 19.636 11.6017C19.1595 11.8227 18.5109 12.1262 17.8216 12.4571C16.4106 13.1344 14.9278 13.8797 14.3325 14.2765C14.3325 14.2765 14.3258 14.2809 14.308 14.2965C14.2906 14.3118 14.2673 14.3339 14.2382 14.3646C14.1791 14.4267 14.1072 14.5123 14.0231 14.6243C13.8542 14.8496 13.6622 15.1471 13.4541 15.5039C13.0384 16.2164 12.5946 17.1024 12.1833 17.98C11.7735 18.8541 11.4038 19.7031 11.136 20.3348C11.0023 20.6502 10.8944 20.9105 10.8201 21.0915C10.783 21.182 10.7543 21.2525 10.735 21.3002L10.7132 21.3542L10.7066 21.3707C10.5524 21.7561 10.1759 22.0069 9.76082 21.9999C9.34577 21.9928 8.97824 21.7301 8.83725 21.3397L3.05947 5.33967C2.92931 4.97922 3.0166 4.57607 3.28421 4.30174Z" fill="${color2}"/>
|
|
52574
52576
|
</svg>`;
|
|
52575
52577
|
}
|
|
52576
|
-
renderItemMbr(context,
|
|
52577
|
-
const mbr =
|
|
52578
|
+
renderItemMbr(context, item, color2, customScale) {
|
|
52579
|
+
const mbr = item.getMbr();
|
|
52578
52580
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
52579
52581
|
mbr.borderColor = color2;
|
|
52580
52582
|
mbr.render(context);
|
|
@@ -52714,8 +52716,8 @@ class Presence {
|
|
|
52714
52716
|
selectionMbr.strokeWidth = 1 / context.matrix.scaleX;
|
|
52715
52717
|
selectionMbr.borderColor = selection.color;
|
|
52716
52718
|
selectionMbr.render(context);
|
|
52717
|
-
for (const
|
|
52718
|
-
this.renderItemMbr(context,
|
|
52719
|
+
for (const item of selection.selection) {
|
|
52720
|
+
this.renderItemMbr(context, item, selection.color);
|
|
52719
52721
|
}
|
|
52720
52722
|
}
|
|
52721
52723
|
}
|
|
@@ -52748,14 +52750,14 @@ class SelectionItems {
|
|
|
52748
52750
|
items = new Map;
|
|
52749
52751
|
add(value) {
|
|
52750
52752
|
if (Array.isArray(value)) {
|
|
52751
|
-
value.forEach((
|
|
52753
|
+
value.forEach((item) => this.items.set(item.getId(), item));
|
|
52752
52754
|
} else {
|
|
52753
52755
|
this.items.set(value.getId(), value);
|
|
52754
52756
|
}
|
|
52755
52757
|
}
|
|
52756
52758
|
remove(value) {
|
|
52757
52759
|
if (Array.isArray(value)) {
|
|
52758
|
-
value.forEach((
|
|
52760
|
+
value.forEach((item) => this.items.delete(item.getId()));
|
|
52759
52761
|
} else {
|
|
52760
52762
|
this.items.delete(value.getId());
|
|
52761
52763
|
}
|
|
@@ -52785,8 +52787,8 @@ class SelectionItems {
|
|
|
52785
52787
|
if (this.isEmpty()) {
|
|
52786
52788
|
return false;
|
|
52787
52789
|
}
|
|
52788
|
-
for (const
|
|
52789
|
-
if (
|
|
52790
|
+
for (const item of this.items.values()) {
|
|
52791
|
+
if (item.itemType !== "RichText") {
|
|
52790
52792
|
return false;
|
|
52791
52793
|
}
|
|
52792
52794
|
}
|
|
@@ -52796,14 +52798,14 @@ class SelectionItems {
|
|
|
52796
52798
|
if (this.isEmpty()) {
|
|
52797
52799
|
return false;
|
|
52798
52800
|
}
|
|
52799
|
-
return Array.from(this.items).every(([,
|
|
52801
|
+
return Array.from(this.items).every(([, item]) => item.itemType === itemType);
|
|
52800
52802
|
}
|
|
52801
52803
|
isItemTypes(itemTypes) {
|
|
52802
52804
|
if (this.isEmpty()) {
|
|
52803
52805
|
return false;
|
|
52804
52806
|
}
|
|
52805
|
-
for (const
|
|
52806
|
-
if (!itemTypes.includes(
|
|
52807
|
+
for (const item of this.items.values()) {
|
|
52808
|
+
if (!itemTypes.includes(item.itemType)) {
|
|
52807
52809
|
return false;
|
|
52808
52810
|
}
|
|
52809
52811
|
}
|
|
@@ -52811,16 +52813,16 @@ class SelectionItems {
|
|
|
52811
52813
|
}
|
|
52812
52814
|
getItemTypes() {
|
|
52813
52815
|
const itemTypes = new Set;
|
|
52814
|
-
this.items.forEach((
|
|
52816
|
+
this.items.forEach((item) => itemTypes.add(item.itemType));
|
|
52815
52817
|
return Array.from(itemTypes);
|
|
52816
52818
|
}
|
|
52817
52819
|
getItemsByItemTypes(itemTypes) {
|
|
52818
|
-
return Array.from(this.items.values()).filter((
|
|
52820
|
+
return Array.from(this.items.values()).filter((item) => itemTypes.includes(item.itemType));
|
|
52819
52821
|
}
|
|
52820
52822
|
getIdsByItemTypes(itemTypes) {
|
|
52821
52823
|
const ids = [];
|
|
52822
|
-
this.items.forEach((
|
|
52823
|
-
if (itemTypes.includes(
|
|
52824
|
+
this.items.forEach((item, id) => {
|
|
52825
|
+
if (itemTypes.includes(item.itemType)) {
|
|
52824
52826
|
ids.push(id);
|
|
52825
52827
|
}
|
|
52826
52828
|
});
|
|
@@ -52830,7 +52832,7 @@ class SelectionItems {
|
|
|
52830
52832
|
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
52831
52833
|
}
|
|
52832
52834
|
listByIds(itemIdList) {
|
|
52833
|
-
return itemIdList.map((id) => this.items.get(id)).filter((
|
|
52835
|
+
return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
|
|
52834
52836
|
}
|
|
52835
52837
|
ids() {
|
|
52836
52838
|
return Array.from(this.items.keys());
|
|
@@ -52841,7 +52843,7 @@ class SelectionItems {
|
|
|
52841
52843
|
return;
|
|
52842
52844
|
}
|
|
52843
52845
|
const mbr = items[0].getMbr();
|
|
52844
|
-
items.slice(1).forEach((
|
|
52846
|
+
items.slice(1).forEach((item) => mbr.combine(item.getMbr()));
|
|
52845
52847
|
return mbr;
|
|
52846
52848
|
}
|
|
52847
52849
|
}
|
|
@@ -53046,33 +53048,33 @@ function handleMultipleItemsResize({
|
|
|
53046
53048
|
const translation = {};
|
|
53047
53049
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
53048
53050
|
board.items.getComments().forEach((comment2) => {
|
|
53049
|
-
if (items.some((
|
|
53051
|
+
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
53050
53052
|
items.push(comment2);
|
|
53051
53053
|
}
|
|
53052
53054
|
});
|
|
53053
|
-
for (const
|
|
53054
|
-
let itemX =
|
|
53055
|
-
let itemY =
|
|
53056
|
-
if (
|
|
53057
|
-
itemX =
|
|
53058
|
-
itemY =
|
|
53055
|
+
for (const item of items) {
|
|
53056
|
+
let itemX = item.getMbr().left;
|
|
53057
|
+
let itemY = item.getMbr().top;
|
|
53058
|
+
if (item.itemType === "Drawing") {
|
|
53059
|
+
itemX = item.transformation.matrix.translateX;
|
|
53060
|
+
itemY = item.transformation.matrix.translateY;
|
|
53059
53061
|
}
|
|
53060
53062
|
const deltaX = itemX - initMbr.left;
|
|
53061
53063
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
53062
53064
|
const deltaY = itemY - initMbr.top;
|
|
53063
53065
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
53064
|
-
if (
|
|
53065
|
-
translation[
|
|
53066
|
-
item
|
|
53066
|
+
if (item instanceof RichText) {
|
|
53067
|
+
translation[item.getId()] = getRichTextTranslation({
|
|
53068
|
+
item,
|
|
53067
53069
|
isWidth,
|
|
53068
53070
|
isHeight,
|
|
53069
53071
|
matrix,
|
|
53070
53072
|
translateX,
|
|
53071
53073
|
translateY
|
|
53072
53074
|
});
|
|
53073
|
-
} else if (
|
|
53074
|
-
translation[
|
|
53075
|
-
item
|
|
53075
|
+
} else if (item instanceof AINode) {
|
|
53076
|
+
translation[item.getId()] = getAINodeTranslation({
|
|
53077
|
+
item,
|
|
53076
53078
|
isWidth,
|
|
53077
53079
|
isHeight,
|
|
53078
53080
|
matrix,
|
|
@@ -53080,8 +53082,8 @@ function handleMultipleItemsResize({
|
|
|
53080
53082
|
translateY
|
|
53081
53083
|
});
|
|
53082
53084
|
} else {
|
|
53083
|
-
translation[
|
|
53084
|
-
item
|
|
53085
|
+
translation[item.getId()] = getItemTranslation({
|
|
53086
|
+
item,
|
|
53085
53087
|
isWidth,
|
|
53086
53088
|
isHeight,
|
|
53087
53089
|
matrix,
|
|
@@ -53094,7 +53096,7 @@ function handleMultipleItemsResize({
|
|
|
53094
53096
|
return translation;
|
|
53095
53097
|
}
|
|
53096
53098
|
function getRichTextTranslation({
|
|
53097
|
-
item
|
|
53099
|
+
item,
|
|
53098
53100
|
isWidth,
|
|
53099
53101
|
isHeight,
|
|
53100
53102
|
matrix,
|
|
@@ -53102,11 +53104,11 @@ function getRichTextTranslation({
|
|
|
53102
53104
|
translateY
|
|
53103
53105
|
}) {
|
|
53104
53106
|
if (isWidth) {
|
|
53105
|
-
|
|
53107
|
+
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
53106
53108
|
return {
|
|
53107
53109
|
class: "Transformation",
|
|
53108
53110
|
method: "scaleByTranslateBy",
|
|
53109
|
-
item: [
|
|
53111
|
+
item: [item.getId()],
|
|
53110
53112
|
translate: { x: matrix.translateX, y: 0 },
|
|
53111
53113
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53112
53114
|
};
|
|
@@ -53114,7 +53116,7 @@ function getRichTextTranslation({
|
|
|
53114
53116
|
return {
|
|
53115
53117
|
class: "Transformation",
|
|
53116
53118
|
method: "scaleByTranslateBy",
|
|
53117
|
-
item: [
|
|
53119
|
+
item: [item.getId()],
|
|
53118
53120
|
translate: { x: translateX, y: translateY },
|
|
53119
53121
|
scale: { x: 1, y: 1 }
|
|
53120
53122
|
};
|
|
@@ -53122,14 +53124,14 @@ function getRichTextTranslation({
|
|
|
53122
53124
|
return {
|
|
53123
53125
|
class: "Transformation",
|
|
53124
53126
|
method: "scaleByTranslateBy",
|
|
53125
|
-
item: [
|
|
53127
|
+
item: [item.getId()],
|
|
53126
53128
|
translate: { x: translateX, y: translateY },
|
|
53127
53129
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53128
53130
|
};
|
|
53129
53131
|
}
|
|
53130
53132
|
}
|
|
53131
53133
|
function getAINodeTranslation({
|
|
53132
|
-
item
|
|
53134
|
+
item,
|
|
53133
53135
|
isWidth,
|
|
53134
53136
|
isHeight,
|
|
53135
53137
|
matrix,
|
|
@@ -53137,11 +53139,11 @@ function getAINodeTranslation({
|
|
|
53137
53139
|
translateY
|
|
53138
53140
|
}) {
|
|
53139
53141
|
if (isWidth) {
|
|
53140
|
-
|
|
53142
|
+
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
53141
53143
|
return {
|
|
53142
53144
|
class: "Transformation",
|
|
53143
53145
|
method: "scaleByTranslateBy",
|
|
53144
|
-
item: [
|
|
53146
|
+
item: [item.getId()],
|
|
53145
53147
|
translate: { x: matrix.translateX, y: 0 },
|
|
53146
53148
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53147
53149
|
};
|
|
@@ -53149,7 +53151,7 @@ function getAINodeTranslation({
|
|
|
53149
53151
|
return {
|
|
53150
53152
|
class: "Transformation",
|
|
53151
53153
|
method: "scaleByTranslateBy",
|
|
53152
|
-
item: [
|
|
53154
|
+
item: [item.getId()],
|
|
53153
53155
|
translate: { x: translateX, y: translateY },
|
|
53154
53156
|
scale: { x: 1, y: 1 }
|
|
53155
53157
|
};
|
|
@@ -53157,14 +53159,14 @@ function getAINodeTranslation({
|
|
|
53157
53159
|
return {
|
|
53158
53160
|
class: "Transformation",
|
|
53159
53161
|
method: "scaleByTranslateBy",
|
|
53160
|
-
item: [
|
|
53162
|
+
item: [item.getId()],
|
|
53161
53163
|
translate: { x: translateX, y: translateY },
|
|
53162
53164
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53163
53165
|
};
|
|
53164
53166
|
}
|
|
53165
53167
|
}
|
|
53166
53168
|
function getItemTranslation({
|
|
53167
|
-
item
|
|
53169
|
+
item,
|
|
53168
53170
|
isWidth,
|
|
53169
53171
|
isHeight,
|
|
53170
53172
|
matrix,
|
|
@@ -53172,22 +53174,22 @@ function getItemTranslation({
|
|
|
53172
53174
|
translateY,
|
|
53173
53175
|
isShiftPressed
|
|
53174
53176
|
}) {
|
|
53175
|
-
if (
|
|
53177
|
+
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
53176
53178
|
return {
|
|
53177
53179
|
class: "Transformation",
|
|
53178
53180
|
method: "scaleByTranslateBy",
|
|
53179
|
-
item: [
|
|
53181
|
+
item: [item.getId()],
|
|
53180
53182
|
translate: { x: translateX, y: translateY },
|
|
53181
53183
|
scale: { x: 1, y: 1 }
|
|
53182
53184
|
};
|
|
53183
53185
|
} else {
|
|
53184
|
-
if (
|
|
53185
|
-
|
|
53186
|
+
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
53187
|
+
item.setFrameType("Custom");
|
|
53186
53188
|
}
|
|
53187
53189
|
return {
|
|
53188
53190
|
class: "Transformation",
|
|
53189
53191
|
method: "scaleByTranslateBy",
|
|
53190
|
-
item: [
|
|
53192
|
+
item: [item.getId()],
|
|
53191
53193
|
translate: { x: translateX, y: translateY },
|
|
53192
53194
|
scale: { x: matrix.scaleX, y: matrix.scaleY }
|
|
53193
53195
|
};
|
|
@@ -53460,11 +53462,11 @@ function transformItems({
|
|
|
53460
53462
|
setSnapCursorPos
|
|
53461
53463
|
}) {
|
|
53462
53464
|
const items = selection.items.list();
|
|
53463
|
-
const includesProportionalItem = items.some((
|
|
53465
|
+
const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
|
|
53464
53466
|
if (includesProportionalItem && (isWidth || isHeight)) {
|
|
53465
53467
|
return null;
|
|
53466
53468
|
}
|
|
53467
|
-
const isIncludesFixedFrame = items.some((
|
|
53469
|
+
const isIncludesFixedFrame = items.some((item) => item instanceof Frame2 && !item.getCanChangeRatio());
|
|
53468
53470
|
const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
|
|
53469
53471
|
const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
|
|
53470
53472
|
if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
|
|
@@ -53542,23 +53544,23 @@ function updateFrameChildren({
|
|
|
53542
53544
|
nestingHighlighter
|
|
53543
53545
|
}) {
|
|
53544
53546
|
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
53545
|
-
board.selection.items.list().forEach((
|
|
53546
|
-
if ("getChildrenIds" in
|
|
53547
|
-
const currMbr =
|
|
53547
|
+
board.selection.items.list().forEach((item) => {
|
|
53548
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
53549
|
+
const currMbr = item.getMbr();
|
|
53548
53550
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
53549
53551
|
itemsToCheck.forEach((currItem) => {
|
|
53550
|
-
if (
|
|
53551
|
-
nestingHighlighter.add(
|
|
53552
|
+
if (item.handleNesting(currItem) && (currItem.parent === "Board" || currItem.parent === item.getId())) {
|
|
53553
|
+
nestingHighlighter.add(item, currItem);
|
|
53552
53554
|
} else {
|
|
53553
53555
|
nestingHighlighter.remove(currItem);
|
|
53554
53556
|
}
|
|
53555
53557
|
});
|
|
53556
53558
|
} else {
|
|
53557
53559
|
groups.forEach((group) => {
|
|
53558
|
-
if (group.handleNesting(
|
|
53559
|
-
nestingHighlighter.add(group,
|
|
53560
|
+
if (group.handleNesting(item)) {
|
|
53561
|
+
nestingHighlighter.add(group, item);
|
|
53560
53562
|
} else {
|
|
53561
|
-
nestingHighlighter.remove(
|
|
53563
|
+
nestingHighlighter.remove(item);
|
|
53562
53564
|
}
|
|
53563
53565
|
});
|
|
53564
53566
|
}
|
|
@@ -53626,9 +53628,9 @@ class Transformer extends Tool {
|
|
|
53626
53628
|
const pointer = this.board.pointer;
|
|
53627
53629
|
const camera = this.board.camera;
|
|
53628
53630
|
const items = this.selection.items;
|
|
53629
|
-
const
|
|
53631
|
+
const item = items.getSingle();
|
|
53630
53632
|
let resizeType;
|
|
53631
|
-
if (
|
|
53633
|
+
if (item && (item.itemType === "RichText" || item.itemType === "Sticker")) {
|
|
53632
53634
|
resizeType = getTextResizeType(pointer.point, camera.getScale(), mbr);
|
|
53633
53635
|
} else {
|
|
53634
53636
|
resizeType = getResizeType(pointer.point, camera.getScale(), mbr);
|
|
@@ -53882,8 +53884,8 @@ class SelectionTransformer extends Tool {
|
|
|
53882
53884
|
return;
|
|
53883
53885
|
}
|
|
53884
53886
|
if (this.selection.items.isSingle()) {
|
|
53885
|
-
const
|
|
53886
|
-
if (
|
|
53887
|
+
const item = this.selection.items.getSingle();
|
|
53888
|
+
if (item?.itemType === "Connector") {
|
|
53887
53889
|
this.tool = this.connectorTransformerTool;
|
|
53888
53890
|
return;
|
|
53889
53891
|
} else {
|
|
@@ -53966,16 +53968,16 @@ class BoardSelection {
|
|
|
53966
53968
|
this.quickAddButtons = getQuickAddButtons(this, board);
|
|
53967
53969
|
}
|
|
53968
53970
|
serialize() {
|
|
53969
|
-
const selectedItems = this.items.list().map((
|
|
53971
|
+
const selectedItems = this.items.list().map((item) => item.getId());
|
|
53970
53972
|
return JSON.stringify(selectedItems);
|
|
53971
53973
|
}
|
|
53972
53974
|
deserialize(serializedData) {
|
|
53973
53975
|
const selectedItems = JSON.parse(serializedData);
|
|
53974
53976
|
this.removeAll();
|
|
53975
53977
|
selectedItems.forEach((itemId) => {
|
|
53976
|
-
const
|
|
53977
|
-
if (
|
|
53978
|
-
this.items.add(
|
|
53978
|
+
const item = this.board.items.getById(itemId);
|
|
53979
|
+
if (item) {
|
|
53980
|
+
this.items.add(item);
|
|
53979
53981
|
}
|
|
53980
53982
|
});
|
|
53981
53983
|
}
|
|
@@ -54053,19 +54055,19 @@ class BoardSelection {
|
|
|
54053
54055
|
this.updateQueue.clear();
|
|
54054
54056
|
safeRequestAnimationFrame(this.updateScheduledObservers);
|
|
54055
54057
|
};
|
|
54056
|
-
itemObserver = (
|
|
54058
|
+
itemObserver = (item) => {
|
|
54057
54059
|
if (!this.shouldPublish) {
|
|
54058
54060
|
return;
|
|
54059
54061
|
}
|
|
54060
54062
|
this.subject.publish(this);
|
|
54061
|
-
this.itemSubject.publish(
|
|
54063
|
+
this.itemSubject.publish(item);
|
|
54062
54064
|
};
|
|
54063
54065
|
decoratedItemObserver = this.decorateObserverToScheduleUpdate(this.itemObserver);
|
|
54064
54066
|
add(value) {
|
|
54065
54067
|
this.items.add(value);
|
|
54066
54068
|
if (Array.isArray(value)) {
|
|
54067
|
-
for (const
|
|
54068
|
-
|
|
54069
|
+
for (const item of value) {
|
|
54070
|
+
item.subject.subscribe(this.itemObserver);
|
|
54069
54071
|
}
|
|
54070
54072
|
} else {
|
|
54071
54073
|
value.subject.subscribe(this.itemObserver);
|
|
@@ -54074,15 +54076,15 @@ class BoardSelection {
|
|
|
54074
54076
|
this.itemsSubject.publish([]);
|
|
54075
54077
|
}
|
|
54076
54078
|
addAll() {
|
|
54077
|
-
const items = this.board.items.listAll().filter((
|
|
54079
|
+
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
54078
54080
|
this.add(items);
|
|
54079
54081
|
this.setContext("SelectByRect");
|
|
54080
54082
|
}
|
|
54081
54083
|
remove(value) {
|
|
54082
54084
|
this.items.remove(value);
|
|
54083
54085
|
if (Array.isArray(value)) {
|
|
54084
|
-
for (const
|
|
54085
|
-
|
|
54086
|
+
for (const item of value) {
|
|
54087
|
+
item.subject.unsubscribe(this.itemObserver);
|
|
54086
54088
|
}
|
|
54087
54089
|
} else {
|
|
54088
54090
|
value.subject.unsubscribe(this.itemObserver);
|
|
@@ -54176,11 +54178,11 @@ class BoardSelection {
|
|
|
54176
54178
|
if (!this.items.isSingle()) {
|
|
54177
54179
|
return;
|
|
54178
54180
|
}
|
|
54179
|
-
const
|
|
54180
|
-
if (!
|
|
54181
|
+
const item = this.items.getSingle();
|
|
54182
|
+
if (!item) {
|
|
54181
54183
|
return;
|
|
54182
54184
|
}
|
|
54183
|
-
const text5 =
|
|
54185
|
+
const text5 = item.getRichText();
|
|
54184
54186
|
if (!text5) {
|
|
54185
54187
|
return;
|
|
54186
54188
|
}
|
|
@@ -54191,7 +54193,7 @@ class BoardSelection {
|
|
|
54191
54193
|
if (shouldReplace || moveCursorToEnd) {
|
|
54192
54194
|
text5.editor.moveCursorToEndOfTheText();
|
|
54193
54195
|
}
|
|
54194
|
-
this.setTextToEdit(
|
|
54196
|
+
this.setTextToEdit(item);
|
|
54195
54197
|
this.setContext("EditTextUnderPointer");
|
|
54196
54198
|
if (shouldSelect) {
|
|
54197
54199
|
text5.editor.selectWholeText();
|
|
@@ -54201,13 +54203,13 @@ class BoardSelection {
|
|
|
54201
54203
|
editUnderPointer() {
|
|
54202
54204
|
this.removeAll();
|
|
54203
54205
|
const stack = this.board.items.getUnderPointer();
|
|
54204
|
-
const
|
|
54205
|
-
if (
|
|
54206
|
-
this.add(
|
|
54206
|
+
const item = stack.pop();
|
|
54207
|
+
if (item) {
|
|
54208
|
+
this.add(item);
|
|
54207
54209
|
this.setTextToEdit(undefined);
|
|
54208
|
-
const text5 =
|
|
54210
|
+
const text5 = item.getRichText();
|
|
54209
54211
|
if (text5) {
|
|
54210
|
-
this.setTextToEdit(
|
|
54212
|
+
this.setTextToEdit(item);
|
|
54211
54213
|
text5.editor.selectWholeText();
|
|
54212
54214
|
this.board.items.subject.publish(this.board.items);
|
|
54213
54215
|
}
|
|
@@ -54216,26 +54218,26 @@ class BoardSelection {
|
|
|
54216
54218
|
this.setContext("None");
|
|
54217
54219
|
}
|
|
54218
54220
|
}
|
|
54219
|
-
setTextToEdit(
|
|
54221
|
+
setTextToEdit(item) {
|
|
54220
54222
|
if (this.textToEdit) {
|
|
54221
54223
|
this.textToEdit.updateElement();
|
|
54222
54224
|
this.textToEdit.enableRender();
|
|
54223
54225
|
}
|
|
54224
|
-
if (!(
|
|
54226
|
+
if (!(item && item.getRichText())) {
|
|
54225
54227
|
this.textToEdit = undefined;
|
|
54226
54228
|
return;
|
|
54227
54229
|
}
|
|
54228
|
-
const text5 =
|
|
54230
|
+
const text5 = item.getRichText();
|
|
54229
54231
|
if (!text5) {
|
|
54230
54232
|
return;
|
|
54231
54233
|
}
|
|
54232
54234
|
if (text5.isEmpty()) {
|
|
54233
|
-
const textColor = tempStorage.getFontColor(
|
|
54234
|
-
const textSize = tempStorage.getFontSize(
|
|
54235
|
-
const highlightColor = tempStorage.getFontHighlight(
|
|
54236
|
-
const styles = tempStorage.getFontStyles(
|
|
54237
|
-
const horizontalAlignment = tempStorage.getHorizontalAlignment(
|
|
54238
|
-
const verticalAlignment = tempStorage.getVerticalAlignment(
|
|
54235
|
+
const textColor = tempStorage.getFontColor(item.itemType);
|
|
54236
|
+
const textSize = tempStorage.getFontSize(item.itemType);
|
|
54237
|
+
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
54238
|
+
const styles = tempStorage.getFontStyles(item.itemType);
|
|
54239
|
+
const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
|
|
54240
|
+
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
54239
54241
|
if (textColor) {
|
|
54240
54242
|
text5.setSelectionFontColor(textColor, "None");
|
|
54241
54243
|
}
|
|
@@ -54243,7 +54245,7 @@ class BoardSelection {
|
|
|
54243
54245
|
this.emit({
|
|
54244
54246
|
class: "RichText",
|
|
54245
54247
|
method: "setFontSize",
|
|
54246
|
-
item: [
|
|
54248
|
+
item: [item.getId()],
|
|
54247
54249
|
fontSize: textSize,
|
|
54248
54250
|
context: this.getContext()
|
|
54249
54251
|
});
|
|
@@ -54255,10 +54257,10 @@ class BoardSelection {
|
|
|
54255
54257
|
const stylesArr = styles;
|
|
54256
54258
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
54257
54259
|
}
|
|
54258
|
-
if (horizontalAlignment && !(
|
|
54260
|
+
if (horizontalAlignment && !(item instanceof Sticker)) {
|
|
54259
54261
|
text5.setSelectionHorisontalAlignment(horizontalAlignment);
|
|
54260
54262
|
}
|
|
54261
|
-
if (verticalAlignment && !(
|
|
54263
|
+
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
54262
54264
|
this.setVerticalAlignment(verticalAlignment);
|
|
54263
54265
|
}
|
|
54264
54266
|
}
|
|
@@ -54291,8 +54293,8 @@ class BoardSelection {
|
|
|
54291
54293
|
}
|
|
54292
54294
|
selectEnclosedOrCrossedBy(rect) {
|
|
54293
54295
|
this.removeAll();
|
|
54294
|
-
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
54295
|
-
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
54296
|
+
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => !item.transformation.isLocked);
|
|
54297
|
+
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => (!(item instanceof Frame2) || enclosedFrames.includes(item)) && !item.transformation.isLocked);
|
|
54296
54298
|
if (list6.length !== 0) {
|
|
54297
54299
|
this.add(list6);
|
|
54298
54300
|
this.setContext("SelectByRect");
|
|
@@ -54306,14 +54308,14 @@ class BoardSelection {
|
|
|
54306
54308
|
canChangeText() {
|
|
54307
54309
|
return Boolean(this.items.isSingle() && this.items.getSingle()?.getRichText());
|
|
54308
54310
|
}
|
|
54309
|
-
handleItemCopy(
|
|
54310
|
-
const serializedData =
|
|
54311
|
-
const zIndex = this.board.items.index.getZIndex(
|
|
54312
|
-
if (
|
|
54311
|
+
handleItemCopy(item, copiedItemsMap) {
|
|
54312
|
+
const serializedData = item.serialize(true);
|
|
54313
|
+
const zIndex = this.board.items.index.getZIndex(item);
|
|
54314
|
+
if (item.itemType === "Comment") {
|
|
54313
54315
|
return;
|
|
54314
54316
|
}
|
|
54315
|
-
if (
|
|
54316
|
-
const connector =
|
|
54317
|
+
if (item.itemType === "Connector" && serializedData.itemType === "Connector") {
|
|
54318
|
+
const connector = item;
|
|
54317
54319
|
const startPoint = connector.getStartPoint();
|
|
54318
54320
|
const endPoint = connector.getEndPoint();
|
|
54319
54321
|
const startItemId = startPoint.pointType !== "Board" ? startPoint.item.getId() : null;
|
|
@@ -54329,19 +54331,19 @@ class BoardSelection {
|
|
|
54329
54331
|
serializedData.endPoint = new BoardPoint(endPoint.x, endPoint.y).serialize();
|
|
54330
54332
|
}
|
|
54331
54333
|
}
|
|
54332
|
-
const textItem =
|
|
54334
|
+
const textItem = item.getRichText()?.getTextString();
|
|
54333
54335
|
const copyText = conf.i18n.t("frame.copy");
|
|
54334
54336
|
const isCopyTextExist = textItem?.includes(copyText);
|
|
54335
|
-
const isChangeCopiedFrameText =
|
|
54337
|
+
const isChangeCopiedFrameText = item.itemType === "Frame" && serializedData.itemType === "Frame" && textItem !== "" && !isCopyTextExist;
|
|
54336
54338
|
if (isChangeCopiedFrameText) {
|
|
54337
54339
|
const copiedFrameText = copyText + (textItem || serializedData.text?.placeholderText);
|
|
54338
|
-
|
|
54339
|
-
|
|
54340
|
-
serializedData.text =
|
|
54341
|
-
|
|
54342
|
-
|
|
54340
|
+
item.getRichText()?.editor.clearText();
|
|
54341
|
+
item.getRichText()?.editor.addText(copiedFrameText);
|
|
54342
|
+
serializedData.text = item.getRichText()?.serialize();
|
|
54343
|
+
item.getRichText()?.editor.clearText();
|
|
54344
|
+
item.getRichText()?.editor.addText(textItem || "");
|
|
54343
54345
|
}
|
|
54344
|
-
copiedItemsMap[
|
|
54346
|
+
copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
|
|
54345
54347
|
}
|
|
54346
54348
|
copy(skipImageBlobCopy) {
|
|
54347
54349
|
const copiedItemsMap = {};
|
|
@@ -54350,12 +54352,12 @@ class BoardSelection {
|
|
|
54350
54352
|
this.handleItemCopy(single, copiedItemsMap);
|
|
54351
54353
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
54352
54354
|
}
|
|
54353
|
-
this.list().forEach((
|
|
54354
|
-
this.handleItemCopy(
|
|
54355
|
+
this.list().forEach((item) => {
|
|
54356
|
+
this.handleItemCopy(item, copiedItemsMap);
|
|
54355
54357
|
});
|
|
54356
|
-
this.list().flatMap((
|
|
54357
|
-
if (
|
|
54358
|
-
return
|
|
54358
|
+
this.list().flatMap((item) => {
|
|
54359
|
+
if (item instanceof Frame2) {
|
|
54360
|
+
return item.getChildrenIds();
|
|
54359
54361
|
}
|
|
54360
54362
|
return [];
|
|
54361
54363
|
}).forEach((id) => {
|
|
@@ -54383,11 +54385,11 @@ class BoardSelection {
|
|
|
54383
54385
|
let maxRichText = null;
|
|
54384
54386
|
let minRichText = null;
|
|
54385
54387
|
const itemType = items[0].itemType;
|
|
54386
|
-
for (const
|
|
54387
|
-
if (
|
|
54388
|
+
for (const item of items) {
|
|
54389
|
+
if (item.itemType !== itemType) {
|
|
54388
54390
|
return null;
|
|
54389
54391
|
}
|
|
54390
|
-
const richText =
|
|
54392
|
+
const richText = item.getRichText();
|
|
54391
54393
|
if (richText) {
|
|
54392
54394
|
if (!maxRichText || richText.getFontSize() > maxRichText.getFontSize()) {
|
|
54393
54395
|
maxRichText = richText;
|
|
@@ -54493,22 +54495,22 @@ class BoardSelection {
|
|
|
54493
54495
|
}
|
|
54494
54496
|
nestSelectedItems(unselectedItem, checkFrames = true) {
|
|
54495
54497
|
const selected = this.board.selection.items.list();
|
|
54496
|
-
if (unselectedItem && !selected.find((
|
|
54498
|
+
if (unselectedItem && !selected.find((item) => item.getId() === unselectedItem.getId())) {
|
|
54497
54499
|
selected.push(unselectedItem);
|
|
54498
54500
|
}
|
|
54499
|
-
const selectedMbr = selected.reduce((acc,
|
|
54501
|
+
const selectedMbr = selected.reduce((acc, item) => {
|
|
54500
54502
|
if (!acc) {
|
|
54501
|
-
return
|
|
54503
|
+
return item.getMbr();
|
|
54502
54504
|
}
|
|
54503
|
-
return acc.combine(
|
|
54505
|
+
return acc.combine(item.getMbr());
|
|
54504
54506
|
}, undefined);
|
|
54505
54507
|
if (selectedMbr) {
|
|
54506
|
-
const selectedMap = Object.fromEntries(selected.map((
|
|
54508
|
+
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
54507
54509
|
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
54508
54510
|
enclosedGroups.forEach((group) => {
|
|
54509
|
-
selected.forEach((
|
|
54510
|
-
if (group.handleNesting(
|
|
54511
|
-
selectedMap[
|
|
54511
|
+
selected.forEach((item) => {
|
|
54512
|
+
if (group.handleNesting(item)) {
|
|
54513
|
+
selectedMap[item.getId()].nested = group;
|
|
54512
54514
|
}
|
|
54513
54515
|
});
|
|
54514
54516
|
});
|
|
@@ -54532,11 +54534,11 @@ class BoardSelection {
|
|
|
54532
54534
|
if (childrenIds && checkFrames) {
|
|
54533
54535
|
const currGroup = val.item;
|
|
54534
54536
|
const currMbr = currGroup.getMbr();
|
|
54535
|
-
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((
|
|
54536
|
-
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
54537
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
54538
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
54537
54539
|
const uniqueItems = new Set;
|
|
54538
|
-
const toCheck = [...children, ...underGroup].filter((
|
|
54539
|
-
const id =
|
|
54540
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
54541
|
+
const id = item.getId();
|
|
54540
54542
|
if (uniqueItems.has(id)) {
|
|
54541
54543
|
return false;
|
|
54542
54544
|
}
|
|
@@ -54577,8 +54579,8 @@ class BoardSelection {
|
|
|
54577
54579
|
addItemToTranslation(childId);
|
|
54578
54580
|
}
|
|
54579
54581
|
}
|
|
54580
|
-
const createTranslationWithComments = (
|
|
54581
|
-
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() ===
|
|
54582
|
+
const createTranslationWithComments = (item) => {
|
|
54583
|
+
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
54582
54584
|
for (const comment2 of followedComments) {
|
|
54583
54585
|
translation[comment2.getId()] = {
|
|
54584
54586
|
class: "Transformation",
|
|
@@ -54639,21 +54641,21 @@ class BoardSelection {
|
|
|
54639
54641
|
newData: { borderColor }
|
|
54640
54642
|
};
|
|
54641
54643
|
const operations2 = {};
|
|
54642
|
-
this.items.list().forEach((
|
|
54643
|
-
if (!operations2[
|
|
54644
|
+
this.items.list().forEach((item) => {
|
|
54645
|
+
if (!operations2[item.itemType]) {
|
|
54644
54646
|
const operationCopy = { ...operation };
|
|
54645
|
-
if (
|
|
54647
|
+
if (item.itemType === "Connector") {
|
|
54646
54648
|
operationCopy.method = "setLineColor";
|
|
54647
54649
|
operationCopy.lineColor = borderColor;
|
|
54648
|
-
} else if (
|
|
54650
|
+
} else if (item.itemType === "Drawing") {
|
|
54649
54651
|
operationCopy.method = "setStrokeColor";
|
|
54650
54652
|
operationCopy.color = borderColor;
|
|
54651
54653
|
} else {
|
|
54652
54654
|
operationCopy.borderColor = borderColor;
|
|
54653
54655
|
}
|
|
54654
|
-
operations2[
|
|
54656
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
54655
54657
|
} else {
|
|
54656
|
-
operations2[
|
|
54658
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54657
54659
|
}
|
|
54658
54660
|
});
|
|
54659
54661
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54668,13 +54670,13 @@ class BoardSelection {
|
|
|
54668
54670
|
newData: { borderWidth: width2 }
|
|
54669
54671
|
};
|
|
54670
54672
|
const operations2 = {};
|
|
54671
|
-
this.items.list().forEach((
|
|
54672
|
-
if (!operations2[
|
|
54673
|
+
this.items.list().forEach((item) => {
|
|
54674
|
+
if (!operations2[item.itemType]) {
|
|
54673
54675
|
const operationCopy = { ...operation };
|
|
54674
|
-
if (
|
|
54676
|
+
if (item.itemType === "Connector") {
|
|
54675
54677
|
operationCopy.method = "setLineWidth";
|
|
54676
54678
|
operationCopy.lineWidth = width2;
|
|
54677
|
-
} else if (
|
|
54679
|
+
} else if (item.itemType === "Drawing") {
|
|
54678
54680
|
operationCopy.method = "setStrokeWidth";
|
|
54679
54681
|
operationCopy.width = width2;
|
|
54680
54682
|
operationCopy.prevWidth = this.getStrokeWidth();
|
|
@@ -54682,9 +54684,9 @@ class BoardSelection {
|
|
|
54682
54684
|
operationCopy.borderWidth = width2;
|
|
54683
54685
|
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
54684
54686
|
}
|
|
54685
|
-
operations2[
|
|
54687
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
54686
54688
|
} else {
|
|
54687
|
-
operations2[
|
|
54689
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54688
54690
|
}
|
|
54689
54691
|
});
|
|
54690
54692
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54700,11 +54702,11 @@ class BoardSelection {
|
|
|
54700
54702
|
newData: { backgroundColor }
|
|
54701
54703
|
};
|
|
54702
54704
|
const operations2 = {};
|
|
54703
|
-
this.items.list().forEach((
|
|
54704
|
-
if (!operations2[
|
|
54705
|
-
operations2[
|
|
54705
|
+
this.items.list().forEach((item) => {
|
|
54706
|
+
if (!operations2[item.itemType]) {
|
|
54707
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
54706
54708
|
} else {
|
|
54707
|
-
operations2[
|
|
54709
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54708
54710
|
}
|
|
54709
54711
|
});
|
|
54710
54712
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54728,9 +54730,9 @@ class BoardSelection {
|
|
|
54728
54730
|
}
|
|
54729
54731
|
setFrameType(frameType) {
|
|
54730
54732
|
const items = this.items.list();
|
|
54731
|
-
items.forEach((
|
|
54732
|
-
if (
|
|
54733
|
-
|
|
54733
|
+
items.forEach((item) => {
|
|
54734
|
+
if (item instanceof Frame2) {
|
|
54735
|
+
item.setFrameType(frameType);
|
|
54734
54736
|
}
|
|
54735
54737
|
});
|
|
54736
54738
|
}
|
|
@@ -54749,21 +54751,21 @@ class BoardSelection {
|
|
|
54749
54751
|
setFontSize(size) {
|
|
54750
54752
|
const fontSize = size === "auto" ? size : toFiniteNumber(size);
|
|
54751
54753
|
const itemsOps = [];
|
|
54752
|
-
for (const
|
|
54753
|
-
const text5 =
|
|
54754
|
+
for (const item of this.items.list()) {
|
|
54755
|
+
const text5 = item.getRichText();
|
|
54754
54756
|
if (!text5) {
|
|
54755
54757
|
continue;
|
|
54756
54758
|
}
|
|
54757
54759
|
const ops = text5.setSelectionFontSize(fontSize, this.context);
|
|
54758
54760
|
itemsOps.push({
|
|
54759
|
-
item:
|
|
54761
|
+
item: item.getId(),
|
|
54760
54762
|
selection: text5.editor.getSelection(),
|
|
54761
54763
|
ops
|
|
54762
54764
|
});
|
|
54763
|
-
if (
|
|
54764
|
-
tempStorage.remove(`fontSize_${
|
|
54765
|
-
} else if (
|
|
54766
|
-
tempStorage.setFontSize(
|
|
54765
|
+
if (item.itemType === "Sticker" && fontSize === "auto") {
|
|
54766
|
+
tempStorage.remove(`fontSize_${item.itemType}`);
|
|
54767
|
+
} else if (item.itemType !== "AINode") {
|
|
54768
|
+
tempStorage.setFontSize(item.itemType, fontSize);
|
|
54767
54769
|
}
|
|
54768
54770
|
}
|
|
54769
54771
|
const emptyOps = itemsOps.filter((op) => !op.ops.length);
|
|
@@ -54786,8 +54788,8 @@ class BoardSelection {
|
|
|
54786
54788
|
setFontStyle(fontStyle) {
|
|
54787
54789
|
const isMultiple = !this.items.isSingle();
|
|
54788
54790
|
const itemsOps = [];
|
|
54789
|
-
for (const
|
|
54790
|
-
const text5 =
|
|
54791
|
+
for (const item of this.items.list()) {
|
|
54792
|
+
const text5 = item.getRichText();
|
|
54791
54793
|
if (!text5) {
|
|
54792
54794
|
continue;
|
|
54793
54795
|
}
|
|
@@ -54796,12 +54798,12 @@ class BoardSelection {
|
|
|
54796
54798
|
}
|
|
54797
54799
|
const ops = text5.setSelectionFontStyle(fontStyle, this.context);
|
|
54798
54800
|
itemsOps.push({
|
|
54799
|
-
item:
|
|
54801
|
+
item: item.getId(),
|
|
54800
54802
|
selection: text5.editor.getSelection(),
|
|
54801
54803
|
ops
|
|
54802
54804
|
});
|
|
54803
|
-
if (
|
|
54804
|
-
tempStorage.setFontStyles(
|
|
54805
|
+
if (item.itemType !== "AINode") {
|
|
54806
|
+
tempStorage.setFontStyles(item.itemType, text5.getFontStyles());
|
|
54805
54807
|
}
|
|
54806
54808
|
}
|
|
54807
54809
|
this.emitApplied({
|
|
@@ -54813,8 +54815,8 @@ class BoardSelection {
|
|
|
54813
54815
|
setFontColor(fontColor) {
|
|
54814
54816
|
const isMultiple = !this.items.isSingle();
|
|
54815
54817
|
const itemsOps = [];
|
|
54816
|
-
for (const
|
|
54817
|
-
const text5 =
|
|
54818
|
+
for (const item of this.items.list()) {
|
|
54819
|
+
const text5 = item.getRichText();
|
|
54818
54820
|
if (!text5) {
|
|
54819
54821
|
continue;
|
|
54820
54822
|
}
|
|
@@ -54823,11 +54825,11 @@ class BoardSelection {
|
|
|
54823
54825
|
}
|
|
54824
54826
|
const ops = text5.setSelectionFontColor(fontColor, this.context);
|
|
54825
54827
|
itemsOps.push({
|
|
54826
|
-
item:
|
|
54828
|
+
item: item.getId(),
|
|
54827
54829
|
selection: text5.editor.getSelection(),
|
|
54828
54830
|
ops
|
|
54829
54831
|
});
|
|
54830
|
-
tempStorage.setFontColor(
|
|
54832
|
+
tempStorage.setFontColor(item.itemType, fontColor);
|
|
54831
54833
|
}
|
|
54832
54834
|
this.emitApplied({
|
|
54833
54835
|
class: "RichText",
|
|
@@ -54856,8 +54858,8 @@ class BoardSelection {
|
|
|
54856
54858
|
setFontHighlight(fontHighlight) {
|
|
54857
54859
|
const isMultiple = !this.items.isSingle();
|
|
54858
54860
|
const itemsOps = [];
|
|
54859
|
-
for (const
|
|
54860
|
-
const text5 =
|
|
54861
|
+
for (const item of this.items.list()) {
|
|
54862
|
+
const text5 = item.getRichText();
|
|
54861
54863
|
if (!text5) {
|
|
54862
54864
|
continue;
|
|
54863
54865
|
}
|
|
@@ -54866,12 +54868,12 @@ class BoardSelection {
|
|
|
54866
54868
|
}
|
|
54867
54869
|
const ops = text5.setSelectionFontHighlight(fontHighlight, this.context);
|
|
54868
54870
|
itemsOps.push({
|
|
54869
|
-
item:
|
|
54871
|
+
item: item.getId(),
|
|
54870
54872
|
selection: text5.editor.getSelection(),
|
|
54871
54873
|
ops
|
|
54872
54874
|
});
|
|
54873
|
-
if (
|
|
54874
|
-
tempStorage.setFontHighlight(
|
|
54875
|
+
if (item.itemType !== "AINode") {
|
|
54876
|
+
tempStorage.setFontHighlight(item.itemType, fontHighlight);
|
|
54875
54877
|
}
|
|
54876
54878
|
}
|
|
54877
54879
|
this.emitApplied({
|
|
@@ -54883,8 +54885,8 @@ class BoardSelection {
|
|
|
54883
54885
|
setHorisontalAlignment(horisontalAlignment) {
|
|
54884
54886
|
const isMultiple = !this.items.isSingle();
|
|
54885
54887
|
const itemsOps = [];
|
|
54886
|
-
for (const
|
|
54887
|
-
const text5 =
|
|
54888
|
+
for (const item of this.items.list()) {
|
|
54889
|
+
const text5 = item.getRichText();
|
|
54888
54890
|
if (!text5) {
|
|
54889
54891
|
continue;
|
|
54890
54892
|
}
|
|
@@ -54893,11 +54895,11 @@ class BoardSelection {
|
|
|
54893
54895
|
}
|
|
54894
54896
|
const ops = text5.setSelectionHorisontalAlignment(horisontalAlignment, this.context);
|
|
54895
54897
|
itemsOps.push({
|
|
54896
|
-
item:
|
|
54898
|
+
item: item.getId(),
|
|
54897
54899
|
selection: text5.editor.getSelection(),
|
|
54898
54900
|
ops
|
|
54899
54901
|
});
|
|
54900
|
-
tempStorage.setHorizontalAlignment(
|
|
54902
|
+
tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
|
|
54901
54903
|
}
|
|
54902
54904
|
this.emitApplied({
|
|
54903
54905
|
class: "RichText",
|
|
@@ -54913,23 +54915,23 @@ class BoardSelection {
|
|
|
54913
54915
|
verticalAlignment
|
|
54914
54916
|
});
|
|
54915
54917
|
if (this.items.isSingle()) {
|
|
54916
|
-
const
|
|
54917
|
-
if (!
|
|
54918
|
+
const item = this.items.getSingle();
|
|
54919
|
+
if (!item) {
|
|
54918
54920
|
return;
|
|
54919
54921
|
}
|
|
54920
|
-
const text5 =
|
|
54922
|
+
const text5 = item.getRichText();
|
|
54921
54923
|
if (!text5) {
|
|
54922
54924
|
return;
|
|
54923
54925
|
}
|
|
54924
|
-
tempStorage.setVerticalAlignment(
|
|
54925
|
-
if (
|
|
54926
|
-
|
|
54926
|
+
tempStorage.setVerticalAlignment(item.itemType, verticalAlignment);
|
|
54927
|
+
if (item instanceof RichText) {
|
|
54928
|
+
item.setEditorFocus(this.context);
|
|
54927
54929
|
}
|
|
54928
54930
|
text5.setEditorFocus(this.context);
|
|
54929
54931
|
}
|
|
54930
54932
|
}
|
|
54931
54933
|
removeFromBoard() {
|
|
54932
|
-
const isLocked = this.items.list().some((
|
|
54934
|
+
const isLocked = this.items.list().some((item) => item.transformation.isLocked);
|
|
54933
54935
|
if (isLocked) {
|
|
54934
54936
|
return;
|
|
54935
54937
|
}
|
|
@@ -54952,7 +54954,7 @@ class BoardSelection {
|
|
|
54952
54954
|
}
|
|
54953
54955
|
getIsLockedSelection() {
|
|
54954
54956
|
const items = this.list();
|
|
54955
|
-
return items.some((
|
|
54957
|
+
return items.some((item) => item.transformation.isLocked);
|
|
54956
54958
|
}
|
|
54957
54959
|
isLocked() {
|
|
54958
54960
|
return false;
|
|
@@ -54979,9 +54981,9 @@ class BoardSelection {
|
|
|
54979
54981
|
}
|
|
54980
54982
|
async duplicate() {
|
|
54981
54983
|
const mediaIds = [];
|
|
54982
|
-
this.items.list().forEach((
|
|
54983
|
-
if ("getStorageId" in
|
|
54984
|
-
const storageId =
|
|
54984
|
+
this.items.list().forEach((item) => {
|
|
54985
|
+
if ("getStorageId" in item) {
|
|
54986
|
+
const storageId = item.getStorageId();
|
|
54985
54987
|
if (storageId) {
|
|
54986
54988
|
mediaIds.push(storageId);
|
|
54987
54989
|
}
|
|
@@ -54991,7 +54993,7 @@ class BoardSelection {
|
|
|
54991
54993
|
if (!canDuplicate) {
|
|
54992
54994
|
return;
|
|
54993
54995
|
}
|
|
54994
|
-
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_,
|
|
54996
|
+
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_, item]) => item.itemType !== "Group"));
|
|
54995
54997
|
this.board.duplicate(filteredItemMap);
|
|
54996
54998
|
this.setContext("EditUnderPointer");
|
|
54997
54999
|
}
|
|
@@ -55025,10 +55027,10 @@ class BoardSelection {
|
|
|
55025
55027
|
lastAssistantMessageId
|
|
55026
55028
|
};
|
|
55027
55029
|
}
|
|
55028
|
-
renderItemMbr(context,
|
|
55029
|
-
const mbr =
|
|
55030
|
+
renderItemMbr(context, item, customScale) {
|
|
55031
|
+
const mbr = item.getMbr();
|
|
55030
55032
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
55031
|
-
const selectionColor =
|
|
55033
|
+
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
55032
55034
|
mbr.borderColor = selectionColor;
|
|
55033
55035
|
mbr.render(context);
|
|
55034
55036
|
}
|
|
@@ -55044,8 +55046,8 @@ class BoardSelection {
|
|
|
55044
55046
|
}
|
|
55045
55047
|
if (!this.transformationRenderBlock) {
|
|
55046
55048
|
if (this.shouldRenderItemsMbr) {
|
|
55047
|
-
for (const
|
|
55048
|
-
this.renderItemMbr(context,
|
|
55049
|
+
for (const item of this.items.list()) {
|
|
55050
|
+
this.renderItemMbr(context, item);
|
|
55049
55051
|
}
|
|
55050
55052
|
}
|
|
55051
55053
|
this.tool.render(context);
|
|
@@ -55057,7 +55059,7 @@ class BoardSelection {
|
|
|
55057
55059
|
if (single && single instanceof AINode) {
|
|
55058
55060
|
const contextItemsIds = single.getContextItems();
|
|
55059
55061
|
if (contextItemsIds.length) {
|
|
55060
|
-
const newContextItems = this.board.items.listAll().filter((
|
|
55062
|
+
const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
|
|
55061
55063
|
contextItems.push(...newContextItems);
|
|
55062
55064
|
}
|
|
55063
55065
|
}
|
|
@@ -55075,15 +55077,15 @@ class BoardSelection {
|
|
|
55075
55077
|
}
|
|
55076
55078
|
}
|
|
55077
55079
|
}
|
|
55078
|
-
contextItems.forEach((
|
|
55079
|
-
if (
|
|
55080
|
-
const path2 =
|
|
55080
|
+
contextItems.forEach((item) => {
|
|
55081
|
+
if (item instanceof AINode) {
|
|
55082
|
+
const path2 = item.getPath();
|
|
55081
55083
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
55082
55084
|
path2.setBorderWidth(2);
|
|
55083
55085
|
path2.setBackgroundColor("none");
|
|
55084
55086
|
path2.render(context);
|
|
55085
55087
|
} else {
|
|
55086
|
-
const itemRect =
|
|
55088
|
+
const itemRect = item.getMbr();
|
|
55087
55089
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
55088
55090
|
itemRect.strokeWidth = 2;
|
|
55089
55091
|
itemRect.render(context);
|
|
@@ -55584,16 +55586,16 @@ class Board {
|
|
|
55584
55586
|
applyBoardOperation(op) {
|
|
55585
55587
|
switch (op.method) {
|
|
55586
55588
|
case "moveToZIndex": {
|
|
55587
|
-
const
|
|
55588
|
-
if (!
|
|
55589
|
+
const item = this.index.getById(op.item);
|
|
55590
|
+
if (!item) {
|
|
55589
55591
|
return;
|
|
55590
55592
|
}
|
|
55591
|
-
return this.index.moveToZIndex(
|
|
55593
|
+
return this.index.moveToZIndex(item, op.zIndex);
|
|
55592
55594
|
}
|
|
55593
55595
|
case "moveManyToZIndex": {
|
|
55594
55596
|
for (const id in op.item) {
|
|
55595
|
-
const
|
|
55596
|
-
if (!
|
|
55597
|
+
const item = this.items.getById(id);
|
|
55598
|
+
if (!item) {
|
|
55597
55599
|
delete op.item.id;
|
|
55598
55600
|
}
|
|
55599
55601
|
}
|
|
@@ -55615,11 +55617,11 @@ class Board {
|
|
|
55615
55617
|
}
|
|
55616
55618
|
return this.index.moveSecondAfterFirst(first, second);
|
|
55617
55619
|
case "bringToFront": {
|
|
55618
|
-
const items = op.item.map((
|
|
55620
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
55619
55621
|
return this.index.bringManyToFront(items);
|
|
55620
55622
|
}
|
|
55621
55623
|
case "sendToBack": {
|
|
55622
|
-
const items = op.item.map((
|
|
55624
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
55623
55625
|
return this.index.sendManyToBack(items);
|
|
55624
55626
|
}
|
|
55625
55627
|
case "add":
|
|
@@ -55643,82 +55645,82 @@ class Board {
|
|
|
55643
55645
|
applyAddItems(op) {
|
|
55644
55646
|
if (Array.isArray(op.item)) {
|
|
55645
55647
|
const data = op.data;
|
|
55646
|
-
const items = op.item.map((
|
|
55647
|
-
const created = this.createItem(
|
|
55648
|
+
const items = op.item.map((item2) => {
|
|
55649
|
+
const created = this.createItem(item2, data[item2]);
|
|
55648
55650
|
this.index.insert(created);
|
|
55649
55651
|
return created;
|
|
55650
55652
|
});
|
|
55651
|
-
items.forEach((
|
|
55652
|
-
if (
|
|
55653
|
-
const connectorData = data[
|
|
55654
|
-
|
|
55655
|
-
|
|
55653
|
+
items.forEach((item2) => {
|
|
55654
|
+
if (item2 instanceof Connector2 && data[item2.getId()]) {
|
|
55655
|
+
const connectorData = data[item2.getId()];
|
|
55656
|
+
item2.applyStartPoint(connectorData.startPoint);
|
|
55657
|
+
item2.applyEndPoint(connectorData.endPoint);
|
|
55656
55658
|
}
|
|
55657
55659
|
});
|
|
55658
55660
|
return;
|
|
55659
55661
|
}
|
|
55660
|
-
const
|
|
55661
|
-
return this.index.insert(
|
|
55662
|
+
const item = this.createItem(op.item, op.data);
|
|
55663
|
+
return this.index.insert(item);
|
|
55662
55664
|
}
|
|
55663
55665
|
applyAddLockedGroupOperation(op) {
|
|
55664
|
-
const
|
|
55665
|
-
const groupChildrenIds =
|
|
55666
|
-
this.index.insert(
|
|
55666
|
+
const item = this.createItem(op.item, op.data);
|
|
55667
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
55668
|
+
this.index.insert(item);
|
|
55667
55669
|
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
55668
55670
|
if (lastChildrenId) {
|
|
55669
55671
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
55670
|
-
this.index.moveToZIndex(
|
|
55672
|
+
this.index.moveToZIndex(item, zIndex);
|
|
55671
55673
|
}
|
|
55672
|
-
|
|
55673
|
-
|
|
55674
|
+
item.getChildren().forEach((item2) => {
|
|
55675
|
+
item2.transformation.isLocked = true;
|
|
55674
55676
|
});
|
|
55675
|
-
|
|
55677
|
+
item.transformation.isLocked = true;
|
|
55676
55678
|
}
|
|
55677
55679
|
applyRemoveOperation(op) {
|
|
55678
55680
|
const removedItems = [];
|
|
55679
|
-
this.findItemAndApply(op.item, (
|
|
55680
|
-
this.index.remove(
|
|
55681
|
-
this.selection.remove(
|
|
55682
|
-
if (
|
|
55683
|
-
|
|
55681
|
+
this.findItemAndApply(op.item, (item) => {
|
|
55682
|
+
this.index.remove(item);
|
|
55683
|
+
this.selection.remove(item);
|
|
55684
|
+
if (item instanceof Connector2) {
|
|
55685
|
+
item.clearObservedItems();
|
|
55684
55686
|
}
|
|
55685
|
-
removedItems.push(
|
|
55687
|
+
removedItems.push(item);
|
|
55686
55688
|
});
|
|
55687
55689
|
}
|
|
55688
55690
|
applyRemoveLockedGroupOperation(op) {
|
|
55689
|
-
const
|
|
55690
|
-
if (!
|
|
55691
|
+
const item = this.index.getById(op.item[0]);
|
|
55692
|
+
if (!item || !(item instanceof Group)) {
|
|
55691
55693
|
return;
|
|
55692
55694
|
}
|
|
55693
|
-
|
|
55694
|
-
|
|
55695
|
-
|
|
55695
|
+
item.getChildren().forEach((item2) => {
|
|
55696
|
+
item2.transformation.isLocked = false;
|
|
55697
|
+
item2.parent = "Board";
|
|
55696
55698
|
});
|
|
55697
|
-
|
|
55699
|
+
item.transformation.isLocked = false;
|
|
55698
55700
|
const removedItems = [];
|
|
55699
|
-
this.findItemAndApply(op.item, (
|
|
55700
|
-
this.index.remove(
|
|
55701
|
-
this.selection.remove(
|
|
55702
|
-
removedItems.push(
|
|
55701
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
55702
|
+
this.index.remove(item2);
|
|
55703
|
+
this.selection.remove(item2);
|
|
55704
|
+
removedItems.push(item2);
|
|
55703
55705
|
});
|
|
55704
55706
|
}
|
|
55705
55707
|
applyItemOperation(op) {
|
|
55706
55708
|
if ("item" in op) {
|
|
55707
|
-
this.findItemAndApply(op.item, (
|
|
55708
|
-
|
|
55709
|
+
this.findItemAndApply(op.item, (item) => {
|
|
55710
|
+
item.apply(op);
|
|
55709
55711
|
});
|
|
55710
55712
|
}
|
|
55711
55713
|
}
|
|
55712
|
-
findItemAndApply(
|
|
55713
|
-
if (Array.isArray(
|
|
55714
|
-
for (const itemId of
|
|
55714
|
+
findItemAndApply(item, apply) {
|
|
55715
|
+
if (Array.isArray(item)) {
|
|
55716
|
+
for (const itemId of item) {
|
|
55715
55717
|
const found = this.items.findById(itemId);
|
|
55716
55718
|
if (found) {
|
|
55717
55719
|
apply(found);
|
|
55718
55720
|
}
|
|
55719
55721
|
}
|
|
55720
55722
|
} else {
|
|
55721
|
-
const found = this.items.findById(
|
|
55723
|
+
const found = this.items.findById(item);
|
|
55722
55724
|
if (found) {
|
|
55723
55725
|
apply(found);
|
|
55724
55726
|
}
|
|
@@ -55727,9 +55729,9 @@ class Board {
|
|
|
55727
55729
|
handleNesting(items) {
|
|
55728
55730
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
55729
55731
|
const groupsMap = new Map;
|
|
55730
|
-
arrayed.forEach((
|
|
55731
|
-
const itemCenter =
|
|
55732
|
-
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(
|
|
55732
|
+
arrayed.forEach((item) => {
|
|
55733
|
+
const itemCenter = item.getMbr().getCenter();
|
|
55734
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
55733
55735
|
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
55734
55736
|
acc = groupItem2;
|
|
55735
55737
|
}
|
|
@@ -55739,7 +55741,7 @@ class Board {
|
|
|
55739
55741
|
if (!groupsMap.has(groupItem)) {
|
|
55740
55742
|
groupsMap.set(groupItem, []);
|
|
55741
55743
|
}
|
|
55742
|
-
groupsMap.get(groupItem)?.push(
|
|
55744
|
+
groupsMap.get(groupItem)?.push(item);
|
|
55743
55745
|
}
|
|
55744
55746
|
});
|
|
55745
55747
|
groupsMap.forEach((items2, group) => {
|
|
@@ -55760,13 +55762,13 @@ class Board {
|
|
|
55760
55762
|
}
|
|
55761
55763
|
return parser(el);
|
|
55762
55764
|
}
|
|
55763
|
-
add(
|
|
55765
|
+
add(item, timeStamp) {
|
|
55764
55766
|
const id = this.getNewItemId();
|
|
55765
55767
|
this.emit({
|
|
55766
55768
|
class: "Board",
|
|
55767
55769
|
method: "add",
|
|
55768
55770
|
item: id,
|
|
55769
|
-
data:
|
|
55771
|
+
data: item.serialize(),
|
|
55770
55772
|
timeStamp
|
|
55771
55773
|
});
|
|
55772
55774
|
const newItem = this.items.getById(id);
|
|
@@ -55776,13 +55778,13 @@ class Board {
|
|
|
55776
55778
|
this.handleNesting(newItem);
|
|
55777
55779
|
return newItem;
|
|
55778
55780
|
}
|
|
55779
|
-
addLockedGroup(
|
|
55781
|
+
addLockedGroup(item) {
|
|
55780
55782
|
const id = this.getNewItemId();
|
|
55781
55783
|
this.emit({
|
|
55782
55784
|
class: "Board",
|
|
55783
55785
|
method: "addLockedGroup",
|
|
55784
55786
|
item: id,
|
|
55785
|
-
data:
|
|
55787
|
+
data: item.serialize()
|
|
55786
55788
|
});
|
|
55787
55789
|
const newItem = this.items.getById(id);
|
|
55788
55790
|
if (!newItem) {
|
|
@@ -55791,32 +55793,32 @@ class Board {
|
|
|
55791
55793
|
this.handleNesting(newItem);
|
|
55792
55794
|
return newItem;
|
|
55793
55795
|
}
|
|
55794
|
-
remove(
|
|
55796
|
+
remove(item, withConnectors = true) {
|
|
55795
55797
|
let connectors = [];
|
|
55796
55798
|
if (withConnectors) {
|
|
55797
|
-
connectors = this.items.getLinkedConnectorsById(
|
|
55799
|
+
connectors = this.items.getLinkedConnectorsById(item.getId()).map((connector) => connector.getId());
|
|
55798
55800
|
}
|
|
55799
|
-
if ("onRemove" in
|
|
55800
|
-
|
|
55801
|
+
if ("onRemove" in item) {
|
|
55802
|
+
item.onRemove();
|
|
55801
55803
|
}
|
|
55802
55804
|
this.emit({
|
|
55803
55805
|
class: "Board",
|
|
55804
55806
|
method: "remove",
|
|
55805
|
-
item: [
|
|
55807
|
+
item: [item.getId(), ...connectors]
|
|
55806
55808
|
});
|
|
55807
55809
|
}
|
|
55808
|
-
removeLockedGroup(
|
|
55810
|
+
removeLockedGroup(item) {
|
|
55809
55811
|
this.emit({
|
|
55810
55812
|
class: "Board",
|
|
55811
55813
|
method: "removeLockedGroup",
|
|
55812
|
-
item: [
|
|
55814
|
+
item: [item.getId()]
|
|
55813
55815
|
});
|
|
55814
55816
|
}
|
|
55815
55817
|
getByZIndex(index2) {
|
|
55816
55818
|
return this.index.getByZIndex(index2);
|
|
55817
55819
|
}
|
|
55818
|
-
getZIndex(
|
|
55819
|
-
return this.index.getZIndex(
|
|
55820
|
+
getZIndex(item) {
|
|
55821
|
+
return this.index.getZIndex(item);
|
|
55820
55822
|
}
|
|
55821
55823
|
getLastZIndex() {
|
|
55822
55824
|
return this.index.getLastZIndex();
|
|
@@ -55828,11 +55830,11 @@ class Board {
|
|
|
55828
55830
|
item: items
|
|
55829
55831
|
});
|
|
55830
55832
|
}
|
|
55831
|
-
moveToZIndex(
|
|
55833
|
+
moveToZIndex(item, zIndex) {
|
|
55832
55834
|
this.emit({
|
|
55833
55835
|
class: "Board",
|
|
55834
55836
|
method: "moveToZIndex",
|
|
55835
|
-
item:
|
|
55837
|
+
item: item.getId(),
|
|
55836
55838
|
zIndex
|
|
55837
55839
|
});
|
|
55838
55840
|
}
|
|
@@ -55860,8 +55862,8 @@ class Board {
|
|
|
55860
55862
|
this.emit({
|
|
55861
55863
|
class: "Board",
|
|
55862
55864
|
method: "bringToFront",
|
|
55863
|
-
item: items.map((
|
|
55864
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
55865
|
+
item: items.map((item) => item.getId()),
|
|
55866
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
55865
55867
|
});
|
|
55866
55868
|
}
|
|
55867
55869
|
sendToBack(items) {
|
|
@@ -55872,8 +55874,8 @@ class Board {
|
|
|
55872
55874
|
this.emit({
|
|
55873
55875
|
class: "Board",
|
|
55874
55876
|
method: "sendToBack",
|
|
55875
|
-
item: items.map((
|
|
55876
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
55877
|
+
item: items.map((item) => item.getId()),
|
|
55878
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
55877
55879
|
});
|
|
55878
55880
|
}
|
|
55879
55881
|
copy() {
|
|
@@ -55950,7 +55952,7 @@ class Board {
|
|
|
55950
55952
|
return added;
|
|
55951
55953
|
});
|
|
55952
55954
|
addedFrame.addChildItems(addedChildren);
|
|
55953
|
-
parsedData.data.children = addedChildren.map((
|
|
55955
|
+
parsedData.data.children = addedChildren.map((item) => item.getId());
|
|
55954
55956
|
idsMap[parsedData.data.id] = addedFrame.getId();
|
|
55955
55957
|
} else {
|
|
55956
55958
|
const added = this.add(this.createItem(this.getNewItemId(), parsedData));
|
|
@@ -55991,15 +55993,15 @@ class Board {
|
|
|
55991
55993
|
const createdConnectors = {};
|
|
55992
55994
|
const createdFrames = {};
|
|
55993
55995
|
const addItem = (itemData) => {
|
|
55994
|
-
const
|
|
55995
|
-
if (
|
|
55996
|
-
createdConnectors[itemData.id] = { item
|
|
55996
|
+
const item = this.createItem(itemData.id, itemData);
|
|
55997
|
+
if (item instanceof Connector2) {
|
|
55998
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
55997
55999
|
}
|
|
55998
|
-
if (
|
|
55999
|
-
createdFrames[
|
|
56000
|
+
if (item instanceof Frame2) {
|
|
56001
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
56000
56002
|
}
|
|
56001
|
-
this.index.insert(
|
|
56002
|
-
return
|
|
56003
|
+
this.index.insert(item);
|
|
56004
|
+
return item;
|
|
56003
56005
|
};
|
|
56004
56006
|
for (const itemData of items) {
|
|
56005
56007
|
if ("childrenMap" in itemData) {
|
|
@@ -56010,13 +56012,13 @@ class Board {
|
|
|
56010
56012
|
}
|
|
56011
56013
|
}
|
|
56012
56014
|
for (const key in createdConnectors) {
|
|
56013
|
-
const { item
|
|
56014
|
-
|
|
56015
|
-
|
|
56015
|
+
const { item, itemData } = createdConnectors[key];
|
|
56016
|
+
item.applyStartPoint(itemData.startPoint);
|
|
56017
|
+
item.applyEndPoint(itemData.endPoint);
|
|
56016
56018
|
}
|
|
56017
56019
|
for (const key in createdFrames) {
|
|
56018
|
-
const { item
|
|
56019
|
-
|
|
56020
|
+
const { item, itemData } = createdFrames[key];
|
|
56021
|
+
item.applyAddChildren(itemData.children);
|
|
56020
56022
|
}
|
|
56021
56023
|
}
|
|
56022
56024
|
deserialize(snapshot) {
|
|
@@ -56026,33 +56028,33 @@ class Board {
|
|
|
56026
56028
|
const createdFrames = {};
|
|
56027
56029
|
if (Array.isArray(items)) {
|
|
56028
56030
|
for (const itemData of items) {
|
|
56029
|
-
const
|
|
56030
|
-
if (
|
|
56031
|
-
createdConnectors[itemData.id] = { item
|
|
56031
|
+
const item = this.createItem(itemData.id, itemData);
|
|
56032
|
+
if (item instanceof Connector2) {
|
|
56033
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
56032
56034
|
}
|
|
56033
|
-
if (
|
|
56034
|
-
createdFrames[
|
|
56035
|
+
if (item instanceof Frame2) {
|
|
56036
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
56035
56037
|
}
|
|
56036
|
-
this.index.insert(
|
|
56038
|
+
this.index.insert(item);
|
|
56037
56039
|
}
|
|
56038
56040
|
} else {
|
|
56039
56041
|
for (const key in items) {
|
|
56040
56042
|
const itemData = items[key];
|
|
56041
|
-
const
|
|
56042
|
-
if (
|
|
56043
|
-
createdConnectors[key] = { item
|
|
56043
|
+
const item = this.createItem(key, itemData);
|
|
56044
|
+
if (item instanceof Connector2) {
|
|
56045
|
+
createdConnectors[key] = { item, itemData };
|
|
56044
56046
|
}
|
|
56045
|
-
this.index.insert(
|
|
56047
|
+
this.index.insert(item);
|
|
56046
56048
|
}
|
|
56047
56049
|
}
|
|
56048
56050
|
for (const key in createdConnectors) {
|
|
56049
|
-
const { item
|
|
56050
|
-
|
|
56051
|
-
|
|
56051
|
+
const { item, itemData } = createdConnectors[key];
|
|
56052
|
+
item.applyStartPoint(itemData.startPoint);
|
|
56053
|
+
item.applyEndPoint(itemData.endPoint);
|
|
56052
56054
|
}
|
|
56053
56055
|
for (const key in createdFrames) {
|
|
56054
|
-
const { item
|
|
56055
|
-
|
|
56056
|
+
const { item, itemData } = createdFrames[key];
|
|
56057
|
+
item.applyAddChildren(itemData.children);
|
|
56056
56058
|
}
|
|
56057
56059
|
this.events?.log.deserialize(events);
|
|
56058
56060
|
}
|
|
@@ -56290,7 +56292,7 @@ class Board {
|
|
|
56290
56292
|
itemsMap: newMap,
|
|
56291
56293
|
select: select2
|
|
56292
56294
|
});
|
|
56293
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
56295
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
56294
56296
|
this.handleNesting(items);
|
|
56295
56297
|
this.selection.removeAll();
|
|
56296
56298
|
this.selection.add(items);
|
|
@@ -56298,8 +56300,8 @@ class Board {
|
|
|
56298
56300
|
return;
|
|
56299
56301
|
}
|
|
56300
56302
|
removeVoidComments() {
|
|
56301
|
-
const voidComments = this.items.listAll().filter((
|
|
56302
|
-
return
|
|
56303
|
+
const voidComments = this.items.listAll().filter((item) => {
|
|
56304
|
+
return item instanceof Comment && !item.getThread().length;
|
|
56303
56305
|
});
|
|
56304
56306
|
if (voidComments) {
|
|
56305
56307
|
for (const comment2 of voidComments) {
|
|
@@ -56373,7 +56375,7 @@ class Board {
|
|
|
56373
56375
|
}
|
|
56374
56376
|
const mbr = this.selection.getMbr();
|
|
56375
56377
|
const selectedItems = this.selection.items.list();
|
|
56376
|
-
const isSelectedItemsMinWidth = selectedItems.some((
|
|
56378
|
+
const isSelectedItemsMinWidth = selectedItems.some((item) => item.getMbr().getWidth() === 0);
|
|
56377
56379
|
const right = mbr ? mbr.right : 0;
|
|
56378
56380
|
const top = mbr ? mbr.top : 0;
|
|
56379
56381
|
const width2 = mbr ? mbr.getWidth() / 10 : 10;
|
|
@@ -56415,7 +56417,7 @@ class Board {
|
|
|
56415
56417
|
method: "duplicate",
|
|
56416
56418
|
itemsMap: newMap
|
|
56417
56419
|
});
|
|
56418
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
56420
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
56419
56421
|
this.handleNesting(items);
|
|
56420
56422
|
this.selection.removeAll();
|
|
56421
56423
|
this.selection.add(items);
|
|
@@ -56436,9 +56438,9 @@ class Board {
|
|
|
56436
56438
|
if (data.itemType === "Frame") {
|
|
56437
56439
|
data.text.placeholderText = `Frame ${this.getMaxFrameSerial() + 1}`;
|
|
56438
56440
|
}
|
|
56439
|
-
const
|
|
56440
|
-
this.index.insert(
|
|
56441
|
-
items.push(
|
|
56441
|
+
const item = this.createItem(itemId, data);
|
|
56442
|
+
this.index.insert(item);
|
|
56443
|
+
items.push(item);
|
|
56442
56444
|
};
|
|
56443
56445
|
sortedItemsMap.map(([id, data]) => {
|
|
56444
56446
|
if (data.itemType === "Connector") {
|
|
@@ -56453,8 +56455,8 @@ class Board {
|
|
|
56453
56455
|
return;
|
|
56454
56456
|
});
|
|
56455
56457
|
}
|
|
56456
|
-
isOnBoard(
|
|
56457
|
-
return this.items.findById(
|
|
56458
|
+
isOnBoard(item) {
|
|
56459
|
+
return this.items.findById(item.getId()) !== undefined;
|
|
56458
56460
|
}
|
|
56459
56461
|
getMaxFrameSerial() {
|
|
56460
56462
|
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
@@ -56500,7 +56502,7 @@ function areItemsTheSame(opA, opB) {
|
|
|
56500
56502
|
const itemsB = Object.keys(opB.items);
|
|
56501
56503
|
const setA = new Set(itemsA);
|
|
56502
56504
|
const setB = new Set(itemsB);
|
|
56503
|
-
const areArraysEqual = setA.size === setB.size && [...setA].every((
|
|
56505
|
+
const areArraysEqual = setA.size === setB.size && [...setA].every((item) => setB.has(item));
|
|
56504
56506
|
return areArraysEqual;
|
|
56505
56507
|
}
|
|
56506
56508
|
if (!(Array.isArray(opA.item) && Array.isArray(opB.item))) {
|
|
@@ -58159,9 +58161,9 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
58159
58161
|
list6.applyUnconfirmed(filter);
|
|
58160
58162
|
const hasAnyOverlap = (arr1, arr2) => {
|
|
58161
58163
|
const lookup9 = new Set(arr1);
|
|
58162
|
-
return arr2.some((
|
|
58164
|
+
return arr2.some((item) => lookup9.has(item));
|
|
58163
58165
|
};
|
|
58164
|
-
const currSelection = board.selection.list().map((
|
|
58166
|
+
const currSelection = board.selection.list().map((item) => item.getId());
|
|
58165
58167
|
if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
58166
58168
|
board.selection.applyMemoizedCaretOrRange();
|
|
58167
58169
|
}
|
|
@@ -58483,27 +58485,27 @@ function handleAiChatMassage(message, board) {
|
|
|
58483
58485
|
}
|
|
58484
58486
|
}
|
|
58485
58487
|
function handleChatChunk(chunk, board) {
|
|
58486
|
-
const
|
|
58488
|
+
const item = board.items.getById(chunk.itemId);
|
|
58487
58489
|
switch (chunk.type) {
|
|
58488
58490
|
case "chunk":
|
|
58489
|
-
if (!
|
|
58491
|
+
if (!item || item.itemType !== "AINode") {
|
|
58490
58492
|
return;
|
|
58491
58493
|
}
|
|
58492
|
-
|
|
58494
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
|
|
58493
58495
|
break;
|
|
58494
58496
|
case "done":
|
|
58495
|
-
if (!
|
|
58497
|
+
if (!item || item.itemType !== "AINode") {
|
|
58496
58498
|
board.aiGeneratingOnItem = undefined;
|
|
58497
58499
|
return;
|
|
58498
58500
|
}
|
|
58499
|
-
|
|
58501
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
58500
58502
|
break;
|
|
58501
58503
|
case "end":
|
|
58502
|
-
if (!
|
|
58504
|
+
if (!item || item.itemType !== "AINode") {
|
|
58503
58505
|
board.aiGeneratingOnItem = undefined;
|
|
58504
58506
|
return;
|
|
58505
58507
|
}
|
|
58506
|
-
|
|
58508
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
58507
58509
|
break;
|
|
58508
58510
|
case "error":
|
|
58509
58511
|
default:
|
|
@@ -58520,7 +58522,7 @@ function handleChatChunk(chunk, board) {
|
|
|
58520
58522
|
if (board.aiGeneratingOnItem && generatingItem) {
|
|
58521
58523
|
board.selection.removeAll();
|
|
58522
58524
|
board.selection.add(generatingItem);
|
|
58523
|
-
const rt =
|
|
58525
|
+
const rt = item?.getRichText();
|
|
58524
58526
|
if (generatingItem.itemType === "AINode" && rt) {
|
|
58525
58527
|
const editor = rt.editor;
|
|
58526
58528
|
editor.markdownProcessor.setStopProcessingMarkDownCb(null);
|
|
@@ -58653,14 +58655,14 @@ function handleImageGenerate(response, board) {
|
|
|
58653
58655
|
console.error("Image generation error:", response.message);
|
|
58654
58656
|
if (response.isExternalApiError) {
|
|
58655
58657
|
if (board.aiGeneratingOnItem) {
|
|
58656
|
-
const
|
|
58657
|
-
if (
|
|
58658
|
+
const item = board.items.getById(board.aiGeneratingOnItem);
|
|
58659
|
+
if (item) {
|
|
58658
58660
|
board.selection.removeAll();
|
|
58659
|
-
board.selection.add(
|
|
58660
|
-
const editor =
|
|
58661
|
+
board.selection.add(item);
|
|
58662
|
+
const editor = item.getRichText()?.editor;
|
|
58661
58663
|
editor?.clearText();
|
|
58662
58664
|
editor?.insertCopiedText(conf.i18n.t("AIInput.nodeErrorText"));
|
|
58663
|
-
board.camera.zoomToFit(
|
|
58665
|
+
board.camera.zoomToFit(item.getMbr(), 20);
|
|
58664
58666
|
}
|
|
58665
58667
|
}
|
|
58666
58668
|
} else {
|