microboard-temp 0.4.57 → 0.4.59
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 +875 -859
- package/dist/cjs/index.js +875 -859
- package/dist/cjs/node.js +875 -859
- package/dist/esm/browser.js +875 -859
- package/dist/esm/index.js +875 -859
- package/dist/esm/node.js +875 -859
- package/package.json +1 -1
package/dist/esm/browser.js
CHANGED
|
@@ -642,8 +642,8 @@ class BoardCommand {
|
|
|
642
642
|
switch (operation.method) {
|
|
643
643
|
case "bringToFront": {
|
|
644
644
|
for (const id in operation.prevZIndex) {
|
|
645
|
-
const
|
|
646
|
-
if (!
|
|
645
|
+
const item2 = this.board.items.getById(id);
|
|
646
|
+
if (!item2) {
|
|
647
647
|
delete operation.prevZIndex.id;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
@@ -655,8 +655,8 @@ class BoardCommand {
|
|
|
655
655
|
}
|
|
656
656
|
case "sendToBack": {
|
|
657
657
|
for (const id in operation.prevZIndex) {
|
|
658
|
-
const
|
|
659
|
-
if (!
|
|
658
|
+
const item2 = this.board.items.getById(id);
|
|
659
|
+
if (!item2) {
|
|
660
660
|
delete operation.prevZIndex.id;
|
|
661
661
|
}
|
|
662
662
|
}
|
|
@@ -670,11 +670,11 @@ class BoardCommand {
|
|
|
670
670
|
case "moveSecondBeforeFirst":
|
|
671
671
|
case "moveToZIndex": {
|
|
672
672
|
const items = this.board.items;
|
|
673
|
-
const
|
|
674
|
-
if (!
|
|
673
|
+
const item2 = items.getById(operation.item);
|
|
674
|
+
if (!item2) {
|
|
675
675
|
throw new Error("Get reverse board operation. Item not found");
|
|
676
676
|
}
|
|
677
|
-
const zIndex = this.board.getZIndex(
|
|
677
|
+
const zIndex = this.board.getZIndex(item2);
|
|
678
678
|
return {
|
|
679
679
|
class: "Board",
|
|
680
680
|
method: "moveToZIndex",
|
|
@@ -684,8 +684,8 @@ class BoardCommand {
|
|
|
684
684
|
}
|
|
685
685
|
case "moveManyToZIndex": {
|
|
686
686
|
for (const id in operation.item) {
|
|
687
|
-
const
|
|
688
|
-
if (!
|
|
687
|
+
const item2 = this.board.items.getById(id);
|
|
688
|
+
if (!item2) {
|
|
689
689
|
delete operation.item.id;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
@@ -702,15 +702,15 @@ class BoardCommand {
|
|
|
702
702
|
const items = this.board.items;
|
|
703
703
|
const reverse = [];
|
|
704
704
|
for (const itemId of operation.item) {
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
705
|
+
const item2 = items.getById(itemId);
|
|
706
|
+
if (!item2) {
|
|
707
707
|
throw new Error("Get reverse board operation. Item not found");
|
|
708
708
|
}
|
|
709
709
|
reverse.push({
|
|
710
710
|
class: "Board",
|
|
711
711
|
method: "add",
|
|
712
712
|
item: itemId,
|
|
713
|
-
data:
|
|
713
|
+
data: item2.serialize()
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
716
|
return reverse;
|
|
@@ -733,32 +733,32 @@ class BoardCommand {
|
|
|
733
733
|
const items = this.board.items;
|
|
734
734
|
const reverse = [];
|
|
735
735
|
for (const itemId of operation.item) {
|
|
736
|
-
const
|
|
737
|
-
if (!
|
|
736
|
+
const item2 = items.getById(itemId);
|
|
737
|
+
if (!item2 || item2.itemType !== "Group") {
|
|
738
738
|
throw new Error("Get reverse board operation. Item not found");
|
|
739
739
|
}
|
|
740
740
|
reverse.push({
|
|
741
741
|
class: "Board",
|
|
742
742
|
method: "addLockedGroup",
|
|
743
743
|
item: itemId,
|
|
744
|
-
data:
|
|
744
|
+
data: item2.serialize()
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
return reverse;
|
|
748
748
|
}
|
|
749
749
|
case "duplicate":
|
|
750
750
|
case "paste": {
|
|
751
|
-
const
|
|
751
|
+
const item2 = [];
|
|
752
752
|
const map = operation.itemsMap;
|
|
753
753
|
for (const key in map) {
|
|
754
754
|
if (map.hasOwnProperty(key)) {
|
|
755
|
-
|
|
755
|
+
item2.push(key);
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
return {
|
|
759
759
|
class: "Board",
|
|
760
760
|
method: "remove",
|
|
761
|
-
item
|
|
761
|
+
item: item2
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
764
|
}
|
|
@@ -7076,11 +7076,11 @@ class SubjectOperation {
|
|
|
7076
7076
|
}
|
|
7077
7077
|
|
|
7078
7078
|
// src/Items/ItemsCommandUtils.ts
|
|
7079
|
-
function mapItemsByOperation(
|
|
7080
|
-
const items = Array.isArray(
|
|
7081
|
-
return items.map((
|
|
7082
|
-
const operation = getCallback(
|
|
7083
|
-
return { item:
|
|
7079
|
+
function mapItemsByOperation(item2, getCallback) {
|
|
7080
|
+
const items = Array.isArray(item2) ? item2 : [item2];
|
|
7081
|
+
return items.map((item3) => {
|
|
7082
|
+
const operation = getCallback(item3);
|
|
7083
|
+
return { item: item3, operation };
|
|
7084
7084
|
});
|
|
7085
7085
|
}
|
|
7086
7086
|
|
|
@@ -7105,8 +7105,8 @@ class TransformationCommand {
|
|
|
7105
7105
|
}
|
|
7106
7106
|
}
|
|
7107
7107
|
revert() {
|
|
7108
|
-
this.reverse.forEach(({ item, operation }) => {
|
|
7109
|
-
|
|
7108
|
+
this.reverse.forEach(({ item: item2, operation }) => {
|
|
7109
|
+
item2.apply(operation);
|
|
7110
7110
|
});
|
|
7111
7111
|
}
|
|
7112
7112
|
getReverse() {
|
|
@@ -7848,8 +7848,8 @@ class Path {
|
|
|
7848
7848
|
}
|
|
7849
7849
|
getIntersectionPoints(segment) {
|
|
7850
7850
|
let intersections = [];
|
|
7851
|
-
for (const
|
|
7852
|
-
intersections = intersections.concat(
|
|
7851
|
+
for (const item2 of this.segments) {
|
|
7852
|
+
intersections = intersections.concat(item2.getIntersectionPoints(segment));
|
|
7853
7853
|
}
|
|
7854
7854
|
return intersections;
|
|
7855
7855
|
}
|
|
@@ -7914,8 +7914,8 @@ class Path {
|
|
|
7914
7914
|
}
|
|
7915
7915
|
isOpenEnclosedOrCrossedBy(rectangle) {
|
|
7916
7916
|
let is = false;
|
|
7917
|
-
for (const
|
|
7918
|
-
is = is ||
|
|
7917
|
+
for (const item2 of this.segments) {
|
|
7918
|
+
is = is || item2.isEnclosedOrCrossedBy(rectangle);
|
|
7919
7919
|
}
|
|
7920
7920
|
return is;
|
|
7921
7921
|
}
|
|
@@ -8328,8 +8328,8 @@ class ConnectorCommand {
|
|
|
8328
8328
|
}
|
|
8329
8329
|
}
|
|
8330
8330
|
revert() {
|
|
8331
|
-
for (const { item, operation } of this.reverse) {
|
|
8332
|
-
|
|
8331
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
8332
|
+
item2.apply(operation);
|
|
8333
8333
|
}
|
|
8334
8334
|
}
|
|
8335
8335
|
getReverse() {
|
|
@@ -8486,11 +8486,11 @@ class SessionStorage {
|
|
|
8486
8486
|
}
|
|
8487
8487
|
get(key) {
|
|
8488
8488
|
const boardId = this.getBoardId() || "";
|
|
8489
|
-
const
|
|
8490
|
-
if (!
|
|
8489
|
+
const item2 = _sessionStorage.getItem(boardId + "_" + key);
|
|
8490
|
+
if (!item2) {
|
|
8491
8491
|
return;
|
|
8492
8492
|
}
|
|
8493
|
-
return JSON.parse(
|
|
8493
|
+
return JSON.parse(item2);
|
|
8494
8494
|
}
|
|
8495
8495
|
remove(key) {
|
|
8496
8496
|
const boardId = this.getBoardId() || "";
|
|
@@ -9275,8 +9275,8 @@ class LinkToCommand {
|
|
|
9275
9275
|
}
|
|
9276
9276
|
}
|
|
9277
9277
|
revert() {
|
|
9278
|
-
this.reverse.forEach(({ item, operation }) => {
|
|
9279
|
-
|
|
9278
|
+
this.reverse.forEach(({ item: item2, operation }) => {
|
|
9279
|
+
item2.apply(operation);
|
|
9280
9280
|
});
|
|
9281
9281
|
}
|
|
9282
9282
|
getReverse() {
|
|
@@ -10577,9 +10577,9 @@ function handleSplitListItem(editor) {
|
|
|
10577
10577
|
Transforms3.insertNodes(editor, {
|
|
10578
10578
|
type: listType,
|
|
10579
10579
|
listLevel: listNode.listLevel || 0,
|
|
10580
|
-
children: itemsAfter.map((
|
|
10580
|
+
children: itemsAfter.map((item2) => ({
|
|
10581
10581
|
type: "list_item",
|
|
10582
|
-
children:
|
|
10582
|
+
children: item2.children
|
|
10583
10583
|
}))
|
|
10584
10584
|
}, { at: newListPath });
|
|
10585
10585
|
}
|
|
@@ -12556,10 +12556,10 @@ function initializeDocument(effects) {
|
|
|
12556
12556
|
return start;
|
|
12557
12557
|
function start(code) {
|
|
12558
12558
|
if (continued < stack.length) {
|
|
12559
|
-
const
|
|
12560
|
-
self2.containerState =
|
|
12561
|
-
ok(
|
|
12562
|
-
return effects.attempt(
|
|
12559
|
+
const item2 = stack[continued];
|
|
12560
|
+
self2.containerState = item2[1];
|
|
12561
|
+
ok(item2[0].continuation, "expected `continuation` to be defined on container construct");
|
|
12562
|
+
return effects.attempt(item2[0].continuation, documentContinue, checkNewContainers)(code);
|
|
12563
12563
|
}
|
|
12564
12564
|
return checkNewContainers(code);
|
|
12565
12565
|
}
|
|
@@ -13535,17 +13535,17 @@ class SpliceBuffer {
|
|
|
13535
13535
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13536
13536
|
return this.left.pop();
|
|
13537
13537
|
}
|
|
13538
|
-
push(
|
|
13538
|
+
push(item2) {
|
|
13539
13539
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13540
|
-
this.left.push(
|
|
13540
|
+
this.left.push(item2);
|
|
13541
13541
|
}
|
|
13542
13542
|
pushMany(items) {
|
|
13543
13543
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13544
13544
|
chunkedPush(this.left, items);
|
|
13545
13545
|
}
|
|
13546
|
-
unshift(
|
|
13546
|
+
unshift(item2) {
|
|
13547
13547
|
this.setCursor(0);
|
|
13548
|
-
this.right.push(
|
|
13548
|
+
this.right.push(item2);
|
|
13549
13549
|
}
|
|
13550
13550
|
unshiftMany(items) {
|
|
13551
13551
|
this.setCursor(0);
|
|
@@ -15576,8 +15576,8 @@ function initializeFactory(field) {
|
|
|
15576
15576
|
if (list2) {
|
|
15577
15577
|
ok(Array.isArray(list2), "expected `disable.null` to be populated");
|
|
15578
15578
|
while (++index2 < list2.length) {
|
|
15579
|
-
const
|
|
15580
|
-
if (!
|
|
15579
|
+
const item2 = list2[index2];
|
|
15580
|
+
if (!item2.previous || item2.previous.call(self2, self2.previous)) {
|
|
15581
15581
|
return true;
|
|
15582
15582
|
}
|
|
15583
15583
|
}
|
|
@@ -16408,14 +16408,14 @@ function compiler(options) {
|
|
|
16408
16408
|
length++;
|
|
16409
16409
|
}
|
|
16410
16410
|
if (event[1].type === types.listItemPrefix) {
|
|
16411
|
-
const
|
|
16411
|
+
const item2 = {
|
|
16412
16412
|
type: "listItem",
|
|
16413
16413
|
_spread: false,
|
|
16414
16414
|
start: Object.assign({}, event[1].start),
|
|
16415
16415
|
end: undefined
|
|
16416
16416
|
};
|
|
16417
|
-
listItem2 =
|
|
16418
|
-
events.splice(index2, 0, ["enter",
|
|
16417
|
+
listItem2 = item2;
|
|
16418
|
+
events.splice(index2, 0, ["enter", item2, event[2]]);
|
|
16419
16419
|
index2++;
|
|
16420
16420
|
length++;
|
|
16421
16421
|
firstBlankLineIndex = undefined;
|
|
@@ -17213,14 +17213,14 @@ class MarkdownProcessor {
|
|
|
17213
17213
|
if (err || !file) {
|
|
17214
17214
|
throw err;
|
|
17215
17215
|
}
|
|
17216
|
-
const nodes = file.result.map((
|
|
17216
|
+
const nodes = file.result.map((item2) => {
|
|
17217
17217
|
setNodeStyles({
|
|
17218
|
-
node:
|
|
17218
|
+
node: item2,
|
|
17219
17219
|
editor: this.editor,
|
|
17220
17220
|
horisontalAlignment: "left",
|
|
17221
|
-
isPaddingTopNeeded:
|
|
17221
|
+
isPaddingTopNeeded: item2.type !== "code_block"
|
|
17222
17222
|
});
|
|
17223
|
-
return
|
|
17223
|
+
return item2;
|
|
17224
17224
|
});
|
|
17225
17225
|
if (isNewParagraphNeeded) {
|
|
17226
17226
|
nodes.push(createParagraphNode("", this.editor));
|
|
@@ -18198,8 +18198,8 @@ class ShapeCommand {
|
|
|
18198
18198
|
}
|
|
18199
18199
|
}
|
|
18200
18200
|
revert() {
|
|
18201
|
-
for (const { item, operation } of this.reverse) {
|
|
18202
|
-
|
|
18201
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
18202
|
+
item2.apply(operation);
|
|
18203
18203
|
}
|
|
18204
18204
|
}
|
|
18205
18205
|
getReverse() {
|
|
@@ -18281,8 +18281,8 @@ class RichTextCommand {
|
|
|
18281
18281
|
}
|
|
18282
18282
|
}
|
|
18283
18283
|
revert() {
|
|
18284
|
-
for (const { item, operation } of this.reverse) {
|
|
18285
|
-
const richText = this.board.items.getById(
|
|
18284
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
18285
|
+
const richText = this.board.items.getById(item2);
|
|
18286
18286
|
if (!richText) {
|
|
18287
18287
|
continue;
|
|
18288
18288
|
}
|
|
@@ -18301,12 +18301,12 @@ class RichTextCommand {
|
|
|
18301
18301
|
case "setSelectionFontColor":
|
|
18302
18302
|
case "setSelectionBlockType":
|
|
18303
18303
|
const inverseOps = this.operation.ops.map((op) => Operation3.inverse(op)).reverse();
|
|
18304
|
-
return items.map((
|
|
18304
|
+
return items.map((item2) => {
|
|
18305
18305
|
const operation = {
|
|
18306
18306
|
...this.operation,
|
|
18307
18307
|
ops: inverseOps
|
|
18308
18308
|
};
|
|
18309
|
-
return { item, operation };
|
|
18309
|
+
return { item: item2, operation };
|
|
18310
18310
|
});
|
|
18311
18311
|
case "setFontColor":
|
|
18312
18312
|
return items.map((id) => ({
|
|
@@ -18398,13 +18398,13 @@ class RichTextGroupCommand {
|
|
|
18398
18398
|
this.reverseOps = this.getReverse();
|
|
18399
18399
|
}
|
|
18400
18400
|
apply() {
|
|
18401
|
-
for (const { item, operation } of this.forwardOps) {
|
|
18402
|
-
|
|
18401
|
+
for (const { item: item2, operation } of this.forwardOps) {
|
|
18402
|
+
item2.applyCommand(operation);
|
|
18403
18403
|
}
|
|
18404
18404
|
}
|
|
18405
18405
|
revert() {
|
|
18406
|
-
for (const { item, operation } of this.reverseOps) {
|
|
18407
|
-
|
|
18406
|
+
for (const { item: item2, operation } of this.reverseOps) {
|
|
18407
|
+
item2.applyCommand(operation);
|
|
18408
18408
|
}
|
|
18409
18409
|
}
|
|
18410
18410
|
getForward() {
|
|
@@ -18519,8 +18519,8 @@ class DrawingCommand {
|
|
|
18519
18519
|
item;
|
|
18520
18520
|
operation;
|
|
18521
18521
|
reverse;
|
|
18522
|
-
constructor(
|
|
18523
|
-
this.item =
|
|
18522
|
+
constructor(item2, operation) {
|
|
18523
|
+
this.item = item2;
|
|
18524
18524
|
this.operation = operation;
|
|
18525
18525
|
this.reverse = this.getReverse();
|
|
18526
18526
|
}
|
|
@@ -18529,52 +18529,52 @@ class DrawingCommand {
|
|
|
18529
18529
|
return this;
|
|
18530
18530
|
}
|
|
18531
18531
|
apply() {
|
|
18532
|
-
for (const
|
|
18533
|
-
|
|
18532
|
+
for (const item2 of this.item) {
|
|
18533
|
+
item2.apply(this.operation);
|
|
18534
18534
|
}
|
|
18535
18535
|
}
|
|
18536
18536
|
revert() {
|
|
18537
|
-
for (const { item, operation } of this.reverse) {
|
|
18538
|
-
|
|
18537
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
18538
|
+
item2.apply(operation);
|
|
18539
18539
|
}
|
|
18540
18540
|
}
|
|
18541
18541
|
getReverse() {
|
|
18542
18542
|
const reverse = [];
|
|
18543
|
-
for (const
|
|
18544
|
-
reverse.push({ item, operation: this.getReverseOperation(
|
|
18543
|
+
for (const item2 of this.item) {
|
|
18544
|
+
reverse.push({ item: item2, operation: this.getReverseOperation(item2) });
|
|
18545
18545
|
}
|
|
18546
18546
|
return reverse;
|
|
18547
18547
|
}
|
|
18548
|
-
getReverseOperation(
|
|
18548
|
+
getReverseOperation(item2) {
|
|
18549
18549
|
switch (this.operation.method) {
|
|
18550
18550
|
case "setStrokeColor":
|
|
18551
18551
|
return {
|
|
18552
18552
|
class: "Drawing",
|
|
18553
18553
|
method: "setStrokeColor",
|
|
18554
|
-
item: [
|
|
18555
|
-
color:
|
|
18554
|
+
item: [item2.getId()],
|
|
18555
|
+
color: item2.getStrokeColor()
|
|
18556
18556
|
};
|
|
18557
18557
|
case "setStrokeWidth":
|
|
18558
18558
|
return {
|
|
18559
18559
|
class: "Drawing",
|
|
18560
18560
|
method: "setStrokeWidth",
|
|
18561
|
-
item: [
|
|
18561
|
+
item: [item2.getId()],
|
|
18562
18562
|
width: this.operation.prevWidth,
|
|
18563
|
-
prevWidth:
|
|
18563
|
+
prevWidth: item2.getStrokeWidth()
|
|
18564
18564
|
};
|
|
18565
18565
|
case "setStrokeOpacity":
|
|
18566
18566
|
return {
|
|
18567
18567
|
class: "Drawing",
|
|
18568
18568
|
method: "setStrokeOpacity",
|
|
18569
|
-
item: [
|
|
18570
|
-
opacity:
|
|
18569
|
+
item: [item2.getId()],
|
|
18570
|
+
opacity: item2.getStrokeOpacity()
|
|
18571
18571
|
};
|
|
18572
18572
|
case "setStrokeStyle":
|
|
18573
18573
|
return {
|
|
18574
18574
|
class: "Drawing",
|
|
18575
18575
|
method: "setStrokeStyle",
|
|
18576
|
-
item: [
|
|
18577
|
-
style:
|
|
18576
|
+
item: [item2.getId()],
|
|
18577
|
+
style: item2.getBorderStyle()
|
|
18578
18578
|
};
|
|
18579
18579
|
}
|
|
18580
18580
|
}
|
|
@@ -18596,8 +18596,8 @@ class StickerCommand {
|
|
|
18596
18596
|
}
|
|
18597
18597
|
}
|
|
18598
18598
|
revert() {
|
|
18599
|
-
for (const { item, operation } of this.reverse) {
|
|
18600
|
-
|
|
18599
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
18600
|
+
item2.apply(operation);
|
|
18601
18601
|
}
|
|
18602
18602
|
}
|
|
18603
18603
|
getReverse() {
|
|
@@ -18629,8 +18629,8 @@ class FrameCommand {
|
|
|
18629
18629
|
}
|
|
18630
18630
|
}
|
|
18631
18631
|
revert() {
|
|
18632
|
-
for (const { item, operation } of this.reverse) {
|
|
18633
|
-
|
|
18632
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
18633
|
+
item2.apply(operation);
|
|
18634
18634
|
}
|
|
18635
18635
|
}
|
|
18636
18636
|
getReverse() {
|
|
@@ -18671,6 +18671,22 @@ class FrameCommand {
|
|
|
18671
18671
|
children: frame2.getChildrenIds()
|
|
18672
18672
|
};
|
|
18673
18673
|
});
|
|
18674
|
+
default:
|
|
18675
|
+
const op = this.operation;
|
|
18676
|
+
let newData = {};
|
|
18677
|
+
if (op.prevData) {
|
|
18678
|
+
newData = { ...op.prevData };
|
|
18679
|
+
} else {
|
|
18680
|
+
Object.keys(op.newData).forEach((key) => {
|
|
18681
|
+
if (item[key]) {
|
|
18682
|
+
newData[key] = item[key];
|
|
18683
|
+
}
|
|
18684
|
+
});
|
|
18685
|
+
}
|
|
18686
|
+
return {
|
|
18687
|
+
...op,
|
|
18688
|
+
newData
|
|
18689
|
+
};
|
|
18674
18690
|
}
|
|
18675
18691
|
}
|
|
18676
18692
|
}
|
|
@@ -18691,8 +18707,8 @@ class CommentCommand {
|
|
|
18691
18707
|
}
|
|
18692
18708
|
}
|
|
18693
18709
|
revert() {
|
|
18694
|
-
this.reverse.forEach(({ item, operation }) => {
|
|
18695
|
-
|
|
18710
|
+
this.reverse.forEach(({ item: item2, operation }) => {
|
|
18711
|
+
item2.apply(operation);
|
|
18696
18712
|
});
|
|
18697
18713
|
}
|
|
18698
18714
|
getReverse() {
|
|
@@ -19154,8 +19170,8 @@ class GroupCommand {
|
|
|
19154
19170
|
}
|
|
19155
19171
|
}
|
|
19156
19172
|
revert() {
|
|
19157
|
-
for (const { item, operation } of this.reverse) {
|
|
19158
|
-
|
|
19173
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
19174
|
+
item2.apply(operation);
|
|
19159
19175
|
}
|
|
19160
19176
|
}
|
|
19161
19177
|
getReverse() {
|
|
@@ -19208,8 +19224,8 @@ class PlaceholderCommand {
|
|
|
19208
19224
|
}
|
|
19209
19225
|
}
|
|
19210
19226
|
revert() {
|
|
19211
|
-
for (const { item, operation } of this.reverse) {
|
|
19212
|
-
|
|
19227
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
19228
|
+
item2.apply(operation);
|
|
19213
19229
|
}
|
|
19214
19230
|
}
|
|
19215
19231
|
getReverse() {
|
|
@@ -19303,26 +19319,26 @@ class BaseCommand {
|
|
|
19303
19319
|
return this;
|
|
19304
19320
|
}
|
|
19305
19321
|
apply() {
|
|
19306
|
-
for (const
|
|
19307
|
-
|
|
19322
|
+
for (const item2 of this.items) {
|
|
19323
|
+
item2.apply(this.operation);
|
|
19308
19324
|
}
|
|
19309
19325
|
}
|
|
19310
19326
|
revert() {
|
|
19311
|
-
for (const { item, operation } of this.reverse) {
|
|
19312
|
-
|
|
19327
|
+
for (const { item: item2, operation } of this.reverse) {
|
|
19328
|
+
item2.apply(operation);
|
|
19313
19329
|
}
|
|
19314
19330
|
}
|
|
19315
19331
|
getReverse() {
|
|
19316
19332
|
const items = this.items;
|
|
19317
|
-
return mapItemsByOperation(items, (
|
|
19333
|
+
return mapItemsByOperation(items, (item2) => {
|
|
19318
19334
|
const op = this.operation;
|
|
19319
19335
|
let newData = {};
|
|
19320
19336
|
if (op.prevData) {
|
|
19321
19337
|
newData = { ...op.prevData };
|
|
19322
19338
|
} else {
|
|
19323
19339
|
Object.keys(op.newData).forEach((key) => {
|
|
19324
|
-
if (
|
|
19325
|
-
newData[key] =
|
|
19340
|
+
if (item2[key]) {
|
|
19341
|
+
newData[key] = item2[key];
|
|
19326
19342
|
}
|
|
19327
19343
|
});
|
|
19328
19344
|
}
|
|
@@ -19350,37 +19366,37 @@ var itemCommandFactories = {
|
|
|
19350
19366
|
LinkTo: createLinkToCommand
|
|
19351
19367
|
};
|
|
19352
19368
|
function createConnectorCommand(items, operation) {
|
|
19353
|
-
return new ConnectorCommand(items.filter((
|
|
19369
|
+
return new ConnectorCommand(items.filter((item2) => item2.itemType === "Connector"), operation);
|
|
19354
19370
|
}
|
|
19355
19371
|
function createShapeCommand(items, operation) {
|
|
19356
|
-
return new ShapeCommand(items.filter((
|
|
19372
|
+
return new ShapeCommand(items.filter((item2) => item2.itemType === "Shape"), operation);
|
|
19357
19373
|
}
|
|
19358
19374
|
function createDrawingCommand(items, operation) {
|
|
19359
|
-
return new DrawingCommand(items.filter((
|
|
19375
|
+
return new DrawingCommand(items.filter((item2) => item2.itemType === "Drawing"), operation);
|
|
19360
19376
|
}
|
|
19361
19377
|
function createCommentCommand(items, operation) {
|
|
19362
|
-
return new CommentCommand(items.filter((
|
|
19378
|
+
return new CommentCommand(items.filter((item2) => item2.itemType === "Comment"), operation);
|
|
19363
19379
|
}
|
|
19364
19380
|
function createStickerCommand(items, operation) {
|
|
19365
|
-
return new StickerCommand(items.filter((
|
|
19381
|
+
return new StickerCommand(items.filter((item2) => item2.itemType === "Sticker"), operation);
|
|
19366
19382
|
}
|
|
19367
19383
|
function createFrameCommand(items, operation) {
|
|
19368
|
-
return new FrameCommand(items.filter((
|
|
19384
|
+
return new FrameCommand(items.filter((item2) => item2.itemType === "Frame"), operation);
|
|
19369
19385
|
}
|
|
19370
19386
|
function createPlaceholderCommand(items, operation) {
|
|
19371
|
-
return new PlaceholderCommand(items.filter((
|
|
19387
|
+
return new PlaceholderCommand(items.filter((item2) => item2.itemType === "Placeholder"), operation);
|
|
19372
19388
|
}
|
|
19373
19389
|
function createGroupCommand(items, operation) {
|
|
19374
|
-
return new GroupCommand(items.filter((
|
|
19390
|
+
return new GroupCommand(items.filter((item2) => item2.itemType === "Group"), operation);
|
|
19375
19391
|
}
|
|
19376
19392
|
function createImageCommand(items, operation) {
|
|
19377
|
-
return new ImageCommand(items.filter((
|
|
19393
|
+
return new ImageCommand(items.filter((item2) => item2.itemType === "Image"), operation);
|
|
19378
19394
|
}
|
|
19379
19395
|
function createVideoCommand(items, operation) {
|
|
19380
|
-
return new VideoCommand(items.filter((
|
|
19396
|
+
return new VideoCommand(items.filter((item2) => item2.itemType === "Video"), operation);
|
|
19381
19397
|
}
|
|
19382
19398
|
function createAudioCommand(items, operation) {
|
|
19383
|
-
return new AudioCommand(items.filter((
|
|
19399
|
+
return new AudioCommand(items.filter((item2) => item2.itemType === "Audio"), operation);
|
|
19384
19400
|
}
|
|
19385
19401
|
function createRichTextCommand(items, operation, board) {
|
|
19386
19402
|
if (!board) {
|
|
@@ -19388,8 +19404,8 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19388
19404
|
}
|
|
19389
19405
|
if (operation.method === "groupEdit") {
|
|
19390
19406
|
const texts = [];
|
|
19391
|
-
for (const { item } of operation.itemsOps) {
|
|
19392
|
-
const found = board.items.findById(
|
|
19407
|
+
for (const { item: item2 } of operation.itemsOps) {
|
|
19408
|
+
const found = board.items.findById(item2);
|
|
19393
19409
|
const text3 = found?.getRichText();
|
|
19394
19410
|
if (text3) {
|
|
19395
19411
|
texts.push(text3);
|
|
@@ -19397,14 +19413,14 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19397
19413
|
}
|
|
19398
19414
|
return new RichTextGroupCommand(texts, operation);
|
|
19399
19415
|
} else {
|
|
19400
|
-
return new RichTextCommand(board, items.map((
|
|
19416
|
+
return new RichTextCommand(board, items.map((item2) => item2.getId()), operation);
|
|
19401
19417
|
}
|
|
19402
19418
|
}
|
|
19403
19419
|
function createTransformationCommand(items, operation) {
|
|
19404
|
-
return new TransformationCommand(items.map((
|
|
19420
|
+
return new TransformationCommand(items.map((item2) => item2.transformation), operation);
|
|
19405
19421
|
}
|
|
19406
19422
|
function createLinkToCommand(items, operation) {
|
|
19407
|
-
return new LinkToCommand(items.map((
|
|
19423
|
+
return new LinkToCommand(items.map((item2) => item2.linkTo), operation);
|
|
19408
19424
|
}
|
|
19409
19425
|
function createCommand(board, operation) {
|
|
19410
19426
|
try {
|
|
@@ -19422,13 +19438,13 @@ function createCommand(board, operation) {
|
|
|
19422
19438
|
default: {
|
|
19423
19439
|
const itemType = operation.class;
|
|
19424
19440
|
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);
|
|
19425
|
-
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((
|
|
19426
|
-
if (typeof
|
|
19427
|
-
console.warn(`Item with ID ${
|
|
19441
|
+
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item2) => {
|
|
19442
|
+
if (typeof item2 === "string") {
|
|
19443
|
+
console.warn(`Item with ID ${item2} not found for operation ${operation.class}.${operation.method}`);
|
|
19428
19444
|
return false;
|
|
19429
19445
|
}
|
|
19430
|
-
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" &&
|
|
19431
|
-
console.warn(`Item with ID ${
|
|
19446
|
+
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" && item2.itemType !== operation.class) {
|
|
19447
|
+
console.warn(`Item with ID ${item2} is not of operation type: ${itemType}.`);
|
|
19432
19448
|
return false;
|
|
19433
19449
|
}
|
|
19434
19450
|
return true;
|
|
@@ -19729,20 +19745,20 @@ class RBush {
|
|
|
19729
19745
|
}
|
|
19730
19746
|
return this;
|
|
19731
19747
|
}
|
|
19732
|
-
insert(
|
|
19733
|
-
if (
|
|
19734
|
-
this._insert(
|
|
19748
|
+
insert(item2) {
|
|
19749
|
+
if (item2)
|
|
19750
|
+
this._insert(item2, this.data.height - 1);
|
|
19735
19751
|
return this;
|
|
19736
19752
|
}
|
|
19737
19753
|
clear() {
|
|
19738
19754
|
this.data = createNode([]);
|
|
19739
19755
|
return this;
|
|
19740
19756
|
}
|
|
19741
|
-
remove(
|
|
19742
|
-
if (!
|
|
19757
|
+
remove(item2, equalsFn) {
|
|
19758
|
+
if (!item2)
|
|
19743
19759
|
return this;
|
|
19744
19760
|
let node2 = this.data;
|
|
19745
|
-
const bbox = this.toBBox(
|
|
19761
|
+
const bbox = this.toBBox(item2);
|
|
19746
19762
|
const path2 = [];
|
|
19747
19763
|
const indexes = [];
|
|
19748
19764
|
let i, parent, goingUp;
|
|
@@ -19754,7 +19770,7 @@ class RBush {
|
|
|
19754
19770
|
goingUp = true;
|
|
19755
19771
|
}
|
|
19756
19772
|
if (node2.leaf) {
|
|
19757
|
-
const index2 = findItem(
|
|
19773
|
+
const index2 = findItem(item2, node2.children, equalsFn);
|
|
19758
19774
|
if (index2 !== -1) {
|
|
19759
19775
|
node2.children.splice(index2, 1);
|
|
19760
19776
|
path2.push(node2);
|
|
@@ -19777,8 +19793,8 @@ class RBush {
|
|
|
19777
19793
|
}
|
|
19778
19794
|
return this;
|
|
19779
19795
|
}
|
|
19780
|
-
toBBox(
|
|
19781
|
-
return
|
|
19796
|
+
toBBox(item2) {
|
|
19797
|
+
return item2;
|
|
19782
19798
|
}
|
|
19783
19799
|
compareMinX(a, b) {
|
|
19784
19800
|
return a.minX - b.minX;
|
|
@@ -19861,11 +19877,11 @@ class RBush {
|
|
|
19861
19877
|
}
|
|
19862
19878
|
return node2;
|
|
19863
19879
|
}
|
|
19864
|
-
_insert(
|
|
19865
|
-
const bbox = isNode ?
|
|
19880
|
+
_insert(item2, level, isNode) {
|
|
19881
|
+
const bbox = isNode ? item2 : this.toBBox(item2);
|
|
19866
19882
|
const insertPath = [];
|
|
19867
19883
|
const node2 = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
19868
|
-
node2.children.push(
|
|
19884
|
+
node2.children.push(item2);
|
|
19869
19885
|
extend2(node2, bbox);
|
|
19870
19886
|
while (level >= 0) {
|
|
19871
19887
|
if (insertPath[level].children.length > this._maxEntries) {
|
|
@@ -19964,11 +19980,11 @@ class RBush {
|
|
|
19964
19980
|
}
|
|
19965
19981
|
}
|
|
19966
19982
|
}
|
|
19967
|
-
function findItem(
|
|
19983
|
+
function findItem(item2, items, equalsFn) {
|
|
19968
19984
|
if (!equalsFn)
|
|
19969
|
-
return items.indexOf(
|
|
19985
|
+
return items.indexOf(item2);
|
|
19970
19986
|
for (let i = 0;i < items.length; i++) {
|
|
19971
|
-
if (equalsFn(
|
|
19987
|
+
if (equalsFn(item2, items[i]))
|
|
19972
19988
|
return i;
|
|
19973
19989
|
}
|
|
19974
19990
|
return -1;
|
|
@@ -20059,8 +20075,8 @@ class TinyQueue {
|
|
|
20059
20075
|
this._down(i);
|
|
20060
20076
|
}
|
|
20061
20077
|
}
|
|
20062
|
-
push(
|
|
20063
|
-
this.data.push(
|
|
20078
|
+
push(item2) {
|
|
20079
|
+
this.data.push(item2);
|
|
20064
20080
|
this.length++;
|
|
20065
20081
|
this._up(this.length - 1);
|
|
20066
20082
|
}
|
|
@@ -20081,21 +20097,21 @@ class TinyQueue {
|
|
|
20081
20097
|
}
|
|
20082
20098
|
_up(pos) {
|
|
20083
20099
|
const { data, compare } = this;
|
|
20084
|
-
const
|
|
20100
|
+
const item2 = data[pos];
|
|
20085
20101
|
while (pos > 0) {
|
|
20086
20102
|
const parent = pos - 1 >> 1;
|
|
20087
20103
|
const current = data[parent];
|
|
20088
|
-
if (compare(
|
|
20104
|
+
if (compare(item2, current) >= 0)
|
|
20089
20105
|
break;
|
|
20090
20106
|
data[pos] = current;
|
|
20091
20107
|
pos = parent;
|
|
20092
20108
|
}
|
|
20093
|
-
data[pos] =
|
|
20109
|
+
data[pos] = item2;
|
|
20094
20110
|
}
|
|
20095
20111
|
_down(pos) {
|
|
20096
20112
|
const { data, compare } = this;
|
|
20097
20113
|
const halfLength = this.length >> 1;
|
|
20098
|
-
const
|
|
20114
|
+
const item2 = data[pos];
|
|
20099
20115
|
while (pos < halfLength) {
|
|
20100
20116
|
let left = (pos << 1) + 1;
|
|
20101
20117
|
let best = data[left];
|
|
@@ -20104,12 +20120,12 @@ class TinyQueue {
|
|
|
20104
20120
|
left = right;
|
|
20105
20121
|
best = data[right];
|
|
20106
20122
|
}
|
|
20107
|
-
if (compare(best,
|
|
20123
|
+
if (compare(best, item2) >= 0)
|
|
20108
20124
|
break;
|
|
20109
20125
|
data[pos] = best;
|
|
20110
20126
|
pos = left;
|
|
20111
20127
|
}
|
|
20112
|
-
data[pos] =
|
|
20128
|
+
data[pos] = item2;
|
|
20113
20129
|
}
|
|
20114
20130
|
}
|
|
20115
20131
|
function defaultCompare2(a, b) {
|
|
@@ -20197,10 +20213,10 @@ class RTreeIndex {
|
|
|
20197
20213
|
return container ? container.item : undefined;
|
|
20198
20214
|
}
|
|
20199
20215
|
remove(id) {
|
|
20200
|
-
const
|
|
20201
|
-
if (
|
|
20216
|
+
const item2 = this.map.get(id);
|
|
20217
|
+
if (item2) {
|
|
20202
20218
|
this.map.delete(id);
|
|
20203
|
-
this.tree.remove(
|
|
20219
|
+
this.tree.remove(item2);
|
|
20204
20220
|
}
|
|
20205
20221
|
}
|
|
20206
20222
|
list() {
|
|
@@ -20272,11 +20288,11 @@ class Container extends Mbr {
|
|
|
20272
20288
|
item;
|
|
20273
20289
|
layer;
|
|
20274
20290
|
zIndex;
|
|
20275
|
-
constructor(id,
|
|
20276
|
-
const rect =
|
|
20291
|
+
constructor(id, item2, layer, zIndex) {
|
|
20292
|
+
const rect = item2.getMbrWithChildren();
|
|
20277
20293
|
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
20278
20294
|
this.id = id;
|
|
20279
|
-
this.item =
|
|
20295
|
+
this.item = item2;
|
|
20280
20296
|
this.layer = layer;
|
|
20281
20297
|
this.zIndex = zIndex;
|
|
20282
20298
|
}
|
|
@@ -20293,7 +20309,7 @@ class LayeredIndex {
|
|
|
20293
20309
|
this.getZIndex = this.getZIndex.bind(this);
|
|
20294
20310
|
this.layers.newOnTop();
|
|
20295
20311
|
}
|
|
20296
|
-
isT(
|
|
20312
|
+
isT(item2) {
|
|
20297
20313
|
return true;
|
|
20298
20314
|
}
|
|
20299
20315
|
findById(id) {
|
|
@@ -20357,8 +20373,8 @@ class LayeredIndex {
|
|
|
20357
20373
|
}
|
|
20358
20374
|
getContainersFromItems(items) {
|
|
20359
20375
|
const containers = [];
|
|
20360
|
-
for (const
|
|
20361
|
-
const container = this.map.get(
|
|
20376
|
+
for (const item2 of items) {
|
|
20377
|
+
const container = this.map.get(item2.getId());
|
|
20362
20378
|
if (container) {
|
|
20363
20379
|
containers.push(container);
|
|
20364
20380
|
}
|
|
@@ -20435,9 +20451,9 @@ class LayeredIndex {
|
|
|
20435
20451
|
}
|
|
20436
20452
|
}
|
|
20437
20453
|
}
|
|
20438
|
-
insert(
|
|
20439
|
-
const toInsert = new Container(
|
|
20440
|
-
const bounds =
|
|
20454
|
+
insert(item2) {
|
|
20455
|
+
const toInsert = new Container(item2.getId(), item2, 0, this.getZIndex(item2));
|
|
20456
|
+
const bounds = item2.getMbrWithChildren();
|
|
20441
20457
|
const inBounds = this.getRectsEnclosedOrCrossedBy(bounds);
|
|
20442
20458
|
if (inBounds.length === 0) {
|
|
20443
20459
|
return this.insertContainer(toInsert);
|
|
@@ -20504,20 +20520,20 @@ class LayeredIndex {
|
|
|
20504
20520
|
}
|
|
20505
20521
|
}
|
|
20506
20522
|
}
|
|
20507
|
-
change(
|
|
20508
|
-
const id =
|
|
20523
|
+
change(item2) {
|
|
20524
|
+
const id = item2.getId();
|
|
20509
20525
|
const container = this.map.get(id);
|
|
20510
20526
|
if (container) {
|
|
20511
20527
|
const layer = this.layers.get(container.layer);
|
|
20512
20528
|
if (layer) {
|
|
20513
20529
|
layer.remove(id);
|
|
20514
20530
|
this.map.delete(id);
|
|
20515
|
-
this.insert(
|
|
20531
|
+
this.insert(item2);
|
|
20516
20532
|
}
|
|
20517
20533
|
}
|
|
20518
20534
|
}
|
|
20519
|
-
remove(
|
|
20520
|
-
const id =
|
|
20535
|
+
remove(item2) {
|
|
20536
|
+
const id = item2.getId();
|
|
20521
20537
|
const container = this.map.get(id);
|
|
20522
20538
|
if (container) {
|
|
20523
20539
|
const layer = this.layers.get(container.layer);
|
|
@@ -20543,13 +20559,13 @@ class LayeredIndex {
|
|
|
20543
20559
|
return items;
|
|
20544
20560
|
}
|
|
20545
20561
|
batchInsert(items) {
|
|
20546
|
-
for (const
|
|
20547
|
-
this.insert(
|
|
20562
|
+
for (const item2 of items) {
|
|
20563
|
+
this.insert(item2);
|
|
20548
20564
|
}
|
|
20549
20565
|
}
|
|
20550
20566
|
batchChange(items) {
|
|
20551
|
-
for (const
|
|
20552
|
-
this.change(
|
|
20567
|
+
for (const item2 of items) {
|
|
20568
|
+
this.change(item2);
|
|
20553
20569
|
}
|
|
20554
20570
|
}
|
|
20555
20571
|
}
|
|
@@ -20558,8 +20574,8 @@ class LayeredIndex {
|
|
|
20558
20574
|
class SpatialIndex {
|
|
20559
20575
|
subject = new Subject;
|
|
20560
20576
|
itemsArray = [];
|
|
20561
|
-
itemsIndex = new LayeredIndex((
|
|
20562
|
-
return this.itemsArray.indexOf(
|
|
20577
|
+
itemsIndex = new LayeredIndex((item2) => {
|
|
20578
|
+
return this.itemsArray.indexOf(item2);
|
|
20563
20579
|
});
|
|
20564
20580
|
Mbr = new Mbr;
|
|
20565
20581
|
items;
|
|
@@ -20568,79 +20584,79 @@ class SpatialIndex {
|
|
|
20568
20584
|
}
|
|
20569
20585
|
clear() {
|
|
20570
20586
|
this.itemsArray = [];
|
|
20571
|
-
this.itemsIndex = new LayeredIndex((
|
|
20572
|
-
return this.itemsArray.indexOf(
|
|
20587
|
+
this.itemsIndex = new LayeredIndex((item2) => {
|
|
20588
|
+
return this.itemsArray.indexOf(item2);
|
|
20573
20589
|
});
|
|
20574
20590
|
this.Mbr = new Mbr;
|
|
20575
20591
|
}
|
|
20576
|
-
insert(
|
|
20577
|
-
this.itemsArray.push(
|
|
20578
|
-
this.itemsIndex.insert(
|
|
20592
|
+
insert(item2) {
|
|
20593
|
+
this.itemsArray.push(item2);
|
|
20594
|
+
this.itemsIndex.insert(item2);
|
|
20579
20595
|
if (conf.isNode()) {
|
|
20580
20596
|
return;
|
|
20581
20597
|
}
|
|
20582
20598
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20583
|
-
this.Mbr =
|
|
20599
|
+
this.Mbr = item2.getMbr().copy();
|
|
20584
20600
|
} else {
|
|
20585
|
-
this.Mbr.combine([
|
|
20601
|
+
this.Mbr.combine([item2.getMbr()]);
|
|
20586
20602
|
}
|
|
20587
|
-
|
|
20603
|
+
item2.subject.subscribe(this.change);
|
|
20588
20604
|
this.subject.publish(this.items);
|
|
20589
20605
|
}
|
|
20590
|
-
change = (
|
|
20591
|
-
this.itemsIndex.change(
|
|
20606
|
+
change = (item2) => {
|
|
20607
|
+
this.itemsIndex.change(item2);
|
|
20592
20608
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20593
|
-
this.Mbr =
|
|
20609
|
+
this.Mbr = item2.getMbrWithChildren().copy();
|
|
20594
20610
|
} else {
|
|
20595
|
-
this.Mbr.combine([
|
|
20611
|
+
this.Mbr.combine([item2.getMbrWithChildren()]);
|
|
20596
20612
|
}
|
|
20597
20613
|
this.subject.publish(this.items);
|
|
20598
20614
|
};
|
|
20599
|
-
remove(
|
|
20600
|
-
if ("index" in
|
|
20601
|
-
|
|
20615
|
+
remove(item2) {
|
|
20616
|
+
if ("index" in item2 && item2.index) {
|
|
20617
|
+
item2.removeChildItems(item2.index.list());
|
|
20602
20618
|
}
|
|
20603
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
20604
|
-
this.itemsIndex.remove(
|
|
20619
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item2), 1);
|
|
20620
|
+
this.itemsIndex.remove(item2);
|
|
20605
20621
|
this.Mbr = new Mbr;
|
|
20606
|
-
this.itemsArray.forEach((
|
|
20622
|
+
this.itemsArray.forEach((item3) => this.Mbr.combine([item3.getMbrWithChildren()]));
|
|
20607
20623
|
this.subject.publish(this.items);
|
|
20608
20624
|
}
|
|
20609
20625
|
copy() {
|
|
20610
|
-
return this.getItemsWithIncludedChildren(this.itemsArray).map((
|
|
20611
|
-
...
|
|
20612
|
-
id:
|
|
20626
|
+
return this.getItemsWithIncludedChildren(this.itemsArray).map((item2) => ({
|
|
20627
|
+
...item2.serialize(true),
|
|
20628
|
+
id: item2.getId()
|
|
20613
20629
|
}));
|
|
20614
20630
|
}
|
|
20615
20631
|
getItemsWithIncludedChildren(items) {
|
|
20616
|
-
return items.flatMap((
|
|
20617
|
-
if ("index" in
|
|
20618
|
-
return [
|
|
20632
|
+
return items.flatMap((item2) => {
|
|
20633
|
+
if ("index" in item2 && item2.index) {
|
|
20634
|
+
return [item2, ...item2.index.list()];
|
|
20619
20635
|
}
|
|
20620
|
-
return
|
|
20636
|
+
return item2;
|
|
20621
20637
|
});
|
|
20622
20638
|
}
|
|
20623
|
-
getItemChildren(
|
|
20624
|
-
if ("index" in
|
|
20625
|
-
return
|
|
20639
|
+
getItemChildren(item2) {
|
|
20640
|
+
if ("index" in item2 && item2.index) {
|
|
20641
|
+
return item2.index.list();
|
|
20626
20642
|
}
|
|
20627
20643
|
return [];
|
|
20628
20644
|
}
|
|
20629
|
-
getItemParent(
|
|
20630
|
-
if (
|
|
20645
|
+
getItemParent(item2) {
|
|
20646
|
+
if (item2.parent === "Board") {
|
|
20631
20647
|
return;
|
|
20632
20648
|
}
|
|
20633
|
-
return this.getById(
|
|
20649
|
+
return this.getById(item2.parent);
|
|
20634
20650
|
}
|
|
20635
|
-
moveToZIndex(
|
|
20636
|
-
const index2 = this.itemsArray.indexOf(
|
|
20651
|
+
moveToZIndex(item2, zIndex) {
|
|
20652
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
20637
20653
|
this.itemsArray.splice(index2, 1);
|
|
20638
|
-
this.itemsArray.splice(zIndex, 0,
|
|
20639
|
-
this.change(
|
|
20654
|
+
this.itemsArray.splice(zIndex, 0, item2);
|
|
20655
|
+
this.change(item2);
|
|
20640
20656
|
this.subject.publish(this.items);
|
|
20641
20657
|
}
|
|
20642
20658
|
moveManyToZIndex(itemsRecord) {
|
|
20643
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
20659
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item2) => item2 !== undefined);
|
|
20644
20660
|
const zIndex = Object.values(itemsRecord);
|
|
20645
20661
|
for (let i = 0;i < zIndex.length; i++) {
|
|
20646
20662
|
const index2 = zIndex[i];
|
|
@@ -20648,39 +20664,39 @@ class SpatialIndex {
|
|
|
20648
20664
|
}
|
|
20649
20665
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20650
20666
|
}
|
|
20651
|
-
sendToBack(
|
|
20652
|
-
const index2 = this.itemsArray.indexOf(
|
|
20667
|
+
sendToBack(item2, shouldPublish = true) {
|
|
20668
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
20653
20669
|
this.itemsArray.splice(index2, 1);
|
|
20654
|
-
this.itemsArray.unshift(
|
|
20655
|
-
this.itemsIndex.change(
|
|
20670
|
+
this.itemsArray.unshift(item2);
|
|
20671
|
+
this.itemsIndex.change(item2);
|
|
20656
20672
|
if (shouldPublish) {
|
|
20657
20673
|
this.subject.publish(this.items);
|
|
20658
20674
|
}
|
|
20659
20675
|
}
|
|
20660
20676
|
sendManyToBack(items) {
|
|
20661
20677
|
const newItems = [...items];
|
|
20662
|
-
this.itemsArray.forEach((
|
|
20663
|
-
if (!items.includes(
|
|
20664
|
-
newItems.push(
|
|
20678
|
+
this.itemsArray.forEach((item2) => {
|
|
20679
|
+
if (!items.includes(item2)) {
|
|
20680
|
+
newItems.push(item2);
|
|
20665
20681
|
}
|
|
20666
20682
|
});
|
|
20667
20683
|
this.itemsArray = newItems;
|
|
20668
20684
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20669
20685
|
}
|
|
20670
|
-
bringToFront(
|
|
20671
|
-
const index2 = this.itemsArray.indexOf(
|
|
20686
|
+
bringToFront(item2, shouldPublish = true) {
|
|
20687
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
20672
20688
|
this.itemsArray.splice(index2, 1);
|
|
20673
|
-
this.itemsArray.push(
|
|
20674
|
-
this.itemsIndex.change(
|
|
20689
|
+
this.itemsArray.push(item2);
|
|
20690
|
+
this.itemsIndex.change(item2);
|
|
20675
20691
|
if (shouldPublish) {
|
|
20676
20692
|
this.subject.publish(this.items);
|
|
20677
20693
|
}
|
|
20678
20694
|
}
|
|
20679
20695
|
bringManyToFront(items) {
|
|
20680
20696
|
const newItems = [];
|
|
20681
|
-
this.itemsArray.forEach((
|
|
20682
|
-
if (!items.includes(
|
|
20683
|
-
newItems.push(
|
|
20697
|
+
this.itemsArray.forEach((item2) => {
|
|
20698
|
+
if (!items.includes(item2)) {
|
|
20699
|
+
newItems.push(item2);
|
|
20684
20700
|
}
|
|
20685
20701
|
});
|
|
20686
20702
|
newItems.push(...items);
|
|
@@ -20706,9 +20722,9 @@ class SpatialIndex {
|
|
|
20706
20722
|
this.subject.publish(this.items);
|
|
20707
20723
|
}
|
|
20708
20724
|
getById(id) {
|
|
20709
|
-
const
|
|
20710
|
-
if (
|
|
20711
|
-
return
|
|
20725
|
+
const item2 = this.getItemsWithIncludedChildren(this.itemsArray).find((item3) => item3.getId() === id);
|
|
20726
|
+
if (item2) {
|
|
20727
|
+
return item2;
|
|
20712
20728
|
}
|
|
20713
20729
|
}
|
|
20714
20730
|
findById(id) {
|
|
@@ -20718,10 +20734,10 @@ class SpatialIndex {
|
|
|
20718
20734
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20719
20735
|
const items = this.itemsIndex.getEnclosed(mbr);
|
|
20720
20736
|
const children = [];
|
|
20721
|
-
const clearItems = items.filter((
|
|
20722
|
-
if ("index" in
|
|
20723
|
-
children.push(...
|
|
20724
|
-
if (!
|
|
20737
|
+
const clearItems = items.filter((item2) => {
|
|
20738
|
+
if ("index" in item2 && item2.index) {
|
|
20739
|
+
children.push(...item2.index.getEnclosed(left, top, right, bottom));
|
|
20740
|
+
if (!item2.getMbr().isEnclosedBy(mbr)) {
|
|
20725
20741
|
return false;
|
|
20726
20742
|
}
|
|
20727
20743
|
}
|
|
@@ -20733,10 +20749,10 @@ class SpatialIndex {
|
|
|
20733
20749
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20734
20750
|
const items = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
20735
20751
|
const children = [];
|
|
20736
|
-
const clearItems = items.filter((
|
|
20737
|
-
if ("index" in
|
|
20738
|
-
children.push(...
|
|
20739
|
-
if (!
|
|
20752
|
+
const clearItems = items.filter((item2) => {
|
|
20753
|
+
if ("index" in item2 && item2.index) {
|
|
20754
|
+
children.push(...item2.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20755
|
+
if (!item2.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20740
20756
|
return false;
|
|
20741
20757
|
}
|
|
20742
20758
|
}
|
|
@@ -20747,10 +20763,10 @@ class SpatialIndex {
|
|
|
20747
20763
|
getUnderPoint(point3, tolerance = 5) {
|
|
20748
20764
|
const items = this.itemsIndex.getUnderPoint(point3, tolerance);
|
|
20749
20765
|
const children = [];
|
|
20750
|
-
const clearItems = items.filter((
|
|
20751
|
-
if ("index" in
|
|
20752
|
-
children.push(...
|
|
20753
|
-
if (!
|
|
20766
|
+
const clearItems = items.filter((item2) => {
|
|
20767
|
+
if ("index" in item2 && item2.index) {
|
|
20768
|
+
children.push(...item2.index.getUnderPoint(point3, tolerance));
|
|
20769
|
+
if (!item2.getMbr().isUnderPoint(point3)) {
|
|
20754
20770
|
return false;
|
|
20755
20771
|
}
|
|
20756
20772
|
}
|
|
@@ -20762,10 +20778,10 @@ class SpatialIndex {
|
|
|
20762
20778
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20763
20779
|
const items = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
20764
20780
|
const children = [];
|
|
20765
|
-
const clearItems = items.filter((
|
|
20766
|
-
if ("index" in
|
|
20767
|
-
children.push(...
|
|
20768
|
-
if (!
|
|
20781
|
+
const clearItems = items.filter((item2) => {
|
|
20782
|
+
if ("index" in item2 && item2.index) {
|
|
20783
|
+
children.push(...item2.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20784
|
+
if (!item2.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20769
20785
|
return false;
|
|
20770
20786
|
}
|
|
20771
20787
|
}
|
|
@@ -20777,26 +20793,26 @@ class SpatialIndex {
|
|
|
20777
20793
|
return this.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
20778
20794
|
}
|
|
20779
20795
|
getComments() {
|
|
20780
|
-
return this.itemsArray.filter((
|
|
20796
|
+
return this.itemsArray.filter((item2) => item2 instanceof Comment);
|
|
20781
20797
|
}
|
|
20782
20798
|
getMbr() {
|
|
20783
20799
|
return this.Mbr;
|
|
20784
20800
|
}
|
|
20785
20801
|
getNearestTo(point3, maxItems, filter, maxDistance) {
|
|
20786
20802
|
const allItems = this.getItemsWithIncludedChildren(this.itemsArray);
|
|
20787
|
-
const filtered = allItems.filter((
|
|
20788
|
-
const withDistance = filtered.map((
|
|
20789
|
-
item,
|
|
20790
|
-
distance: point3.getDistance(
|
|
20803
|
+
const filtered = allItems.filter((item2) => filter(item2));
|
|
20804
|
+
const withDistance = filtered.map((item2) => ({
|
|
20805
|
+
item: item2,
|
|
20806
|
+
distance: point3.getDistance(item2.getMbr().getCenter())
|
|
20791
20807
|
})).filter(({ distance }) => distance <= maxDistance);
|
|
20792
20808
|
withDistance.sort((a, b) => a.distance - b.distance);
|
|
20793
|
-
return withDistance.slice(0, maxItems).map(({ item }) =>
|
|
20809
|
+
return withDistance.slice(0, maxItems).map(({ item: item2 }) => item2);
|
|
20794
20810
|
}
|
|
20795
20811
|
list() {
|
|
20796
20812
|
return this.getItemsWithIncludedChildren(this.itemsArray).concat();
|
|
20797
20813
|
}
|
|
20798
|
-
getZIndex(
|
|
20799
|
-
const index2 = this.itemsArray.indexOf(
|
|
20814
|
+
getZIndex(item2) {
|
|
20815
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
20800
20816
|
if (index2 === -1) {
|
|
20801
20817
|
return this.getLastZIndex();
|
|
20802
20818
|
}
|
|
@@ -20826,14 +20842,14 @@ class Items {
|
|
|
20826
20842
|
this.pointer = pointer;
|
|
20827
20843
|
this.subject = subject;
|
|
20828
20844
|
}
|
|
20829
|
-
update(
|
|
20830
|
-
this.index.change(
|
|
20845
|
+
update(item2) {
|
|
20846
|
+
this.index.change(item2);
|
|
20831
20847
|
}
|
|
20832
20848
|
listAll() {
|
|
20833
20849
|
return this.index.list();
|
|
20834
20850
|
}
|
|
20835
20851
|
listGroupItems() {
|
|
20836
|
-
return this.index.list().filter((
|
|
20852
|
+
return this.index.list().filter((item2) => ("index" in item2) && item2.index);
|
|
20837
20853
|
}
|
|
20838
20854
|
getById(id) {
|
|
20839
20855
|
return this.index.getById(id);
|
|
@@ -20848,7 +20864,7 @@ class Items {
|
|
|
20848
20864
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
20849
20865
|
}
|
|
20850
20866
|
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
20851
|
-
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
20867
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item2) => item2 instanceof BaseItem && item2.index);
|
|
20852
20868
|
}
|
|
20853
20869
|
getUnderPoint(point3, tolerance = 5) {
|
|
20854
20870
|
return this.index.getUnderPoint(point3, tolerance);
|
|
@@ -20876,28 +20892,28 @@ class Items {
|
|
|
20876
20892
|
const unmodifiedSize = size;
|
|
20877
20893
|
size = 16;
|
|
20878
20894
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
20879
|
-
const groups = tolerated.filter((
|
|
20895
|
+
const groups = tolerated.filter((item2) => item2.itemType === "Group");
|
|
20880
20896
|
if (groups.length > 0) {
|
|
20881
20897
|
return groups;
|
|
20882
20898
|
}
|
|
20883
|
-
let enclosed = tolerated.some((
|
|
20899
|
+
let enclosed = tolerated.some((item2) => item2 instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
20884
20900
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
20885
20901
|
if (enclosed.length === 0) {
|
|
20886
20902
|
enclosed = underPointer;
|
|
20887
20903
|
}
|
|
20888
|
-
if (underPointer.some((
|
|
20904
|
+
if (underPointer.some((item2) => item2.itemType === "Drawing")) {
|
|
20889
20905
|
enclosed = [...underPointer, ...enclosed];
|
|
20890
20906
|
}
|
|
20891
|
-
const { nearest } = enclosed.reduce((acc,
|
|
20892
|
-
const area =
|
|
20893
|
-
if (
|
|
20907
|
+
const { nearest } = enclosed.reduce((acc, item2) => {
|
|
20908
|
+
const area = item2.getMbr().getHeight() * item2.getMbr().getWidth();
|
|
20909
|
+
if (item2.itemType === "Drawing" && !item2.isPointNearLine(this.pointer.point)) {
|
|
20894
20910
|
return acc;
|
|
20895
20911
|
}
|
|
20896
|
-
const isItemTransparent =
|
|
20897
|
-
const itemZIndex = this.getZIndex(
|
|
20912
|
+
const isItemTransparent = item2 instanceof Shape && item2?.getBackgroundColor() === "none";
|
|
20913
|
+
const itemZIndex = this.getZIndex(item2);
|
|
20898
20914
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
20899
20915
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
20900
|
-
return { nearest:
|
|
20916
|
+
return { nearest: item2, area };
|
|
20901
20917
|
}
|
|
20902
20918
|
return acc;
|
|
20903
20919
|
}, { nearest: undefined, area: Infinity });
|
|
@@ -20909,8 +20925,8 @@ class Items {
|
|
|
20909
20925
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
20910
20926
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
20911
20927
|
}
|
|
20912
|
-
getZIndex(
|
|
20913
|
-
return this.index.getZIndex(
|
|
20928
|
+
getZIndex(item2) {
|
|
20929
|
+
return this.index.getZIndex(item2);
|
|
20914
20930
|
}
|
|
20915
20931
|
getByZIndex(index2) {
|
|
20916
20932
|
return this.index.getByZIndex(index2);
|
|
@@ -20919,11 +20935,11 @@ class Items {
|
|
|
20919
20935
|
return this.index.getLastZIndex();
|
|
20920
20936
|
}
|
|
20921
20937
|
getLinkedConnectorsById(id) {
|
|
20922
|
-
return this.listAll().filter((
|
|
20923
|
-
if (!(
|
|
20938
|
+
return this.listAll().filter((item2) => {
|
|
20939
|
+
if (!(item2 instanceof Connector2)) {
|
|
20924
20940
|
return false;
|
|
20925
20941
|
}
|
|
20926
|
-
const { startItem, endItem } =
|
|
20942
|
+
const { startItem, endItem } = item2.getConnectedItems();
|
|
20927
20943
|
if (startItem?.getId() === id || endItem?.getId() === id) {
|
|
20928
20944
|
return true;
|
|
20929
20945
|
}
|
|
@@ -20934,11 +20950,11 @@ class Items {
|
|
|
20934
20950
|
if (!startPointerItemId && !endPointerItemId) {
|
|
20935
20951
|
return [];
|
|
20936
20952
|
}
|
|
20937
|
-
return this.listAll().filter((
|
|
20938
|
-
if (!(
|
|
20953
|
+
return this.listAll().filter((item2) => {
|
|
20954
|
+
if (!(item2 instanceof Connector2) || !item2.isConnected()) {
|
|
20939
20955
|
return false;
|
|
20940
20956
|
}
|
|
20941
|
-
const { startItem, endItem } =
|
|
20957
|
+
const { startItem, endItem } = item2.getConnectedItems();
|
|
20942
20958
|
if (startPointerItemId && endPointerItemId) {
|
|
20943
20959
|
if (startPointerItemId && startItem && startItem.getId() === startPointerItemId && endPointerItemId && endItem && endItem.getId() === endPointerItemId) {
|
|
20944
20960
|
return true;
|
|
@@ -20956,9 +20972,9 @@ class Items {
|
|
|
20956
20972
|
}
|
|
20957
20973
|
render(context) {
|
|
20958
20974
|
const items = this.getItemsInView();
|
|
20959
|
-
items.forEach((
|
|
20960
|
-
if (
|
|
20961
|
-
|
|
20975
|
+
items.forEach((item2) => {
|
|
20976
|
+
if (item2.parent === "Board") {
|
|
20977
|
+
item2.render(context);
|
|
20962
20978
|
}
|
|
20963
20979
|
});
|
|
20964
20980
|
}
|
|
@@ -20971,17 +20987,17 @@ class Items {
|
|
|
20971
20987
|
return this.getHTML(documentFactory, items);
|
|
20972
20988
|
}
|
|
20973
20989
|
getHTML(documentFactory, items) {
|
|
20974
|
-
const lowestCoordinates = items.map((
|
|
20990
|
+
const lowestCoordinates = items.map((item2) => item2.getMbr()).reduce((acc, mbr) => ({
|
|
20975
20991
|
left: Math.min(acc.left, mbr.left),
|
|
20976
20992
|
top: Math.min(acc.top, mbr.top)
|
|
20977
20993
|
}), { left: 0, top: 0 });
|
|
20978
20994
|
const groups = [];
|
|
20979
20995
|
const rest = [];
|
|
20980
|
-
items.forEach((
|
|
20981
|
-
if ("index" in
|
|
20982
|
-
groups.push(
|
|
20996
|
+
items.forEach((item2) => {
|
|
20997
|
+
if ("index" in item2 && item2.index) {
|
|
20998
|
+
groups.push(item2);
|
|
20983
20999
|
} else {
|
|
20984
|
-
rest.push(
|
|
21000
|
+
rest.push(item2);
|
|
20985
21001
|
}
|
|
20986
21002
|
});
|
|
20987
21003
|
const childrenMap = new Map;
|
|
@@ -20991,34 +21007,34 @@ class Items {
|
|
|
20991
21007
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
20992
21008
|
return html;
|
|
20993
21009
|
});
|
|
20994
|
-
const restHTML = rest.map((
|
|
20995
|
-
if (
|
|
20996
|
-
const startX = parseFloat(
|
|
20997
|
-
const startY = parseFloat(
|
|
20998
|
-
const endX = parseFloat(
|
|
20999
|
-
const endY = parseFloat(
|
|
21000
|
-
|
|
21001
|
-
|
|
21002
|
-
|
|
21003
|
-
|
|
21004
|
-
}
|
|
21005
|
-
return translateElementBy(
|
|
21006
|
-
});
|
|
21007
|
-
for (const
|
|
21008
|
-
const parentFrameId = childrenMap.get(
|
|
21010
|
+
const restHTML = rest.map((item2) => ("renderHTML" in item2) && item2.renderHTML(documentFactory)).filter((item2) => !!item2).map((item2) => {
|
|
21011
|
+
if (item2.tagName.toLowerCase() === "connector-item") {
|
|
21012
|
+
const startX = parseFloat(item2.getAttribute("data-start-point-x") || "0");
|
|
21013
|
+
const startY = parseFloat(item2.getAttribute("data-start-point-y") || "0");
|
|
21014
|
+
const endX = parseFloat(item2.getAttribute("data-end-point-x") || "0");
|
|
21015
|
+
const endY = parseFloat(item2.getAttribute("data-end-point-y") || "0");
|
|
21016
|
+
item2.setAttribute("data-start-point-x", (startX - lowestCoordinates.left).toString());
|
|
21017
|
+
item2.setAttribute("data-start-point-y", (startY - lowestCoordinates.top).toString());
|
|
21018
|
+
item2.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21019
|
+
item2.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21020
|
+
}
|
|
21021
|
+
return translateElementBy(item2, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21022
|
+
});
|
|
21023
|
+
for (const item2 of restHTML) {
|
|
21024
|
+
const parentFrameId = childrenMap.get(item2.id);
|
|
21009
21025
|
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
21010
21026
|
if (group) {
|
|
21011
|
-
positionRelatively(
|
|
21012
|
-
group.appendChild(
|
|
21027
|
+
positionRelatively(item2, group);
|
|
21028
|
+
group.appendChild(item2);
|
|
21013
21029
|
}
|
|
21014
21030
|
}
|
|
21015
21031
|
let result = "";
|
|
21016
21032
|
for (const group of GroupsHTML) {
|
|
21017
21033
|
result += group.outerHTML;
|
|
21018
21034
|
}
|
|
21019
|
-
for (const
|
|
21020
|
-
if (!childrenMap.get(
|
|
21021
|
-
result +=
|
|
21035
|
+
for (const item2 of restHTML) {
|
|
21036
|
+
if (!childrenMap.get(item2.id)) {
|
|
21037
|
+
result += item2.outerHTML;
|
|
21022
21038
|
}
|
|
21023
21039
|
}
|
|
21024
21040
|
return result;
|
|
@@ -21038,52 +21054,52 @@ class SimpleSpatialIndex {
|
|
|
21038
21054
|
this.itemsArray = [];
|
|
21039
21055
|
this.Mbr = new Mbr;
|
|
21040
21056
|
}
|
|
21041
|
-
insert(
|
|
21042
|
-
this.itemsArray.push(
|
|
21057
|
+
insert(item2) {
|
|
21058
|
+
this.itemsArray.push(item2);
|
|
21043
21059
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21044
|
-
this.Mbr =
|
|
21060
|
+
this.Mbr = item2.getMbr().copy();
|
|
21045
21061
|
} else {
|
|
21046
|
-
this.Mbr.combine([
|
|
21062
|
+
this.Mbr.combine([item2.getMbr()]);
|
|
21047
21063
|
}
|
|
21048
|
-
|
|
21064
|
+
item2.subject.subscribe(this.change);
|
|
21049
21065
|
this.subject.publish(this.items);
|
|
21050
21066
|
}
|
|
21051
|
-
change = (
|
|
21067
|
+
change = (item2) => {
|
|
21052
21068
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21053
|
-
this.Mbr =
|
|
21069
|
+
this.Mbr = item2.getMbr().copy();
|
|
21054
21070
|
} else {
|
|
21055
|
-
this.Mbr.combine([
|
|
21071
|
+
this.Mbr.combine([item2.getMbr()]);
|
|
21056
21072
|
}
|
|
21057
21073
|
this.subject.publish(this.items);
|
|
21058
21074
|
};
|
|
21059
|
-
remove(
|
|
21060
|
-
if ("index" in
|
|
21061
|
-
|
|
21075
|
+
remove(item2) {
|
|
21076
|
+
if ("index" in item2 && item2.index) {
|
|
21077
|
+
item2.removeChildItems(item2.index.list());
|
|
21062
21078
|
}
|
|
21063
|
-
if (
|
|
21064
|
-
const parentFrame = this.items.getById(
|
|
21065
|
-
parentFrame?.removeChildItems(
|
|
21079
|
+
if (item2.parent !== "Board") {
|
|
21080
|
+
const parentFrame = this.items.getById(item2.parent);
|
|
21081
|
+
parentFrame?.removeChildItems(item2);
|
|
21066
21082
|
}
|
|
21067
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
21083
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item2), 1);
|
|
21068
21084
|
this.Mbr = new Mbr;
|
|
21069
|
-
this.itemsArray.forEach((
|
|
21085
|
+
this.itemsArray.forEach((item3) => this.Mbr.combine([item3.getMbr()]));
|
|
21070
21086
|
this.subject.publish(this.items);
|
|
21071
21087
|
}
|
|
21072
21088
|
copy() {
|
|
21073
|
-
return this.itemsArray.map((
|
|
21074
|
-
...
|
|
21075
|
-
id:
|
|
21089
|
+
return this.itemsArray.map((item2) => ({
|
|
21090
|
+
...item2.serialize(true),
|
|
21091
|
+
id: item2.getId()
|
|
21076
21092
|
}));
|
|
21077
21093
|
}
|
|
21078
|
-
moveToZIndex(
|
|
21079
|
-
const index2 = this.itemsArray.indexOf(
|
|
21094
|
+
moveToZIndex(item2, zIndex) {
|
|
21095
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
21080
21096
|
this.itemsArray.splice(index2, 1);
|
|
21081
|
-
this.itemsArray.splice(zIndex, 0,
|
|
21082
|
-
this.change(
|
|
21097
|
+
this.itemsArray.splice(zIndex, 0, item2);
|
|
21098
|
+
this.change(item2);
|
|
21083
21099
|
this.subject.publish(this.items);
|
|
21084
21100
|
}
|
|
21085
21101
|
moveManyToZIndex(itemsRecord) {
|
|
21086
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
21102
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item2) => item2 !== undefined);
|
|
21087
21103
|
const zIndex = Object.values(itemsRecord);
|
|
21088
21104
|
for (let i = 0;i < zIndex.length; i++) {
|
|
21089
21105
|
const index2 = zIndex[i];
|
|
@@ -21091,37 +21107,37 @@ class SimpleSpatialIndex {
|
|
|
21091
21107
|
}
|
|
21092
21108
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21093
21109
|
}
|
|
21094
|
-
sendToBack(
|
|
21095
|
-
const index2 = this.itemsArray.indexOf(
|
|
21110
|
+
sendToBack(item2, shouldPublish = true) {
|
|
21111
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
21096
21112
|
this.itemsArray.splice(index2, 1);
|
|
21097
|
-
this.itemsArray.unshift(
|
|
21113
|
+
this.itemsArray.unshift(item2);
|
|
21098
21114
|
if (shouldPublish) {
|
|
21099
21115
|
this.subject.publish(this.items);
|
|
21100
21116
|
}
|
|
21101
21117
|
}
|
|
21102
21118
|
sendManyToBack(items) {
|
|
21103
21119
|
const newItems = [...items];
|
|
21104
|
-
this.itemsArray.forEach((
|
|
21105
|
-
if (!items.includes(
|
|
21106
|
-
newItems.push(
|
|
21120
|
+
this.itemsArray.forEach((item2) => {
|
|
21121
|
+
if (!items.includes(item2)) {
|
|
21122
|
+
newItems.push(item2);
|
|
21107
21123
|
}
|
|
21108
21124
|
});
|
|
21109
21125
|
this.itemsArray = newItems;
|
|
21110
21126
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21111
21127
|
}
|
|
21112
|
-
bringToFront(
|
|
21113
|
-
const index2 = this.itemsArray.indexOf(
|
|
21128
|
+
bringToFront(item2, shouldPublish = true) {
|
|
21129
|
+
const index2 = this.itemsArray.indexOf(item2);
|
|
21114
21130
|
this.itemsArray.splice(index2, 1);
|
|
21115
|
-
this.itemsArray.push(
|
|
21131
|
+
this.itemsArray.push(item2);
|
|
21116
21132
|
if (shouldPublish) {
|
|
21117
21133
|
this.subject.publish(this.items);
|
|
21118
21134
|
}
|
|
21119
21135
|
}
|
|
21120
21136
|
bringManyToFront(items) {
|
|
21121
21137
|
const newItems = [];
|
|
21122
|
-
this.itemsArray.forEach((
|
|
21123
|
-
if (!items.includes(
|
|
21124
|
-
newItems.push(
|
|
21138
|
+
this.itemsArray.forEach((item2) => {
|
|
21139
|
+
if (!items.includes(item2)) {
|
|
21140
|
+
newItems.push(item2);
|
|
21125
21141
|
}
|
|
21126
21142
|
});
|
|
21127
21143
|
newItems.push(...items);
|
|
@@ -21147,9 +21163,9 @@ class SimpleSpatialIndex {
|
|
|
21147
21163
|
this.subject.publish(this.items);
|
|
21148
21164
|
}
|
|
21149
21165
|
getById(id) {
|
|
21150
|
-
const
|
|
21151
|
-
if (
|
|
21152
|
-
return
|
|
21166
|
+
const item2 = this.itemsArray.find((item3) => item3.getId() === id);
|
|
21167
|
+
if (item2) {
|
|
21168
|
+
return item2;
|
|
21153
21169
|
}
|
|
21154
21170
|
}
|
|
21155
21171
|
findById(id) {
|
|
@@ -21158,9 +21174,9 @@ class SimpleSpatialIndex {
|
|
|
21158
21174
|
getEnclosed(left, top, right, bottom) {
|
|
21159
21175
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21160
21176
|
const items = [];
|
|
21161
|
-
this.itemsArray.forEach((
|
|
21162
|
-
if (
|
|
21163
|
-
items.push(
|
|
21177
|
+
this.itemsArray.forEach((item2) => {
|
|
21178
|
+
if (item2.isEnclosedBy(mbr)) {
|
|
21179
|
+
items.push(item2);
|
|
21164
21180
|
}
|
|
21165
21181
|
});
|
|
21166
21182
|
return items;
|
|
@@ -21168,18 +21184,18 @@ class SimpleSpatialIndex {
|
|
|
21168
21184
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
21169
21185
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21170
21186
|
const items = [];
|
|
21171
|
-
this.itemsArray.forEach((
|
|
21172
|
-
if (
|
|
21173
|
-
items.push(
|
|
21187
|
+
this.itemsArray.forEach((item2) => {
|
|
21188
|
+
if (item2.isEnclosedOrCrossedBy(mbr)) {
|
|
21189
|
+
items.push(item2);
|
|
21174
21190
|
}
|
|
21175
21191
|
});
|
|
21176
21192
|
return items;
|
|
21177
21193
|
}
|
|
21178
21194
|
getUnderPoint(point3, tolerace = 5) {
|
|
21179
21195
|
const items = [];
|
|
21180
|
-
this.itemsArray.forEach((
|
|
21181
|
-
if (
|
|
21182
|
-
items.push(
|
|
21196
|
+
this.itemsArray.forEach((item2) => {
|
|
21197
|
+
if (item2.isUnderPoint(point3, tolerace)) {
|
|
21198
|
+
items.push(item2);
|
|
21183
21199
|
}
|
|
21184
21200
|
});
|
|
21185
21201
|
return items;
|
|
@@ -21190,8 +21206,8 @@ class SimpleSpatialIndex {
|
|
|
21190
21206
|
list() {
|
|
21191
21207
|
return this.itemsArray.concat();
|
|
21192
21208
|
}
|
|
21193
|
-
getZIndex(
|
|
21194
|
-
return this.itemsArray.indexOf(
|
|
21209
|
+
getZIndex(item2) {
|
|
21210
|
+
return this.itemsArray.indexOf(item2);
|
|
21195
21211
|
}
|
|
21196
21212
|
getLastZIndex() {
|
|
21197
21213
|
return this.itemsArray.length - 1;
|
|
@@ -21205,8 +21221,8 @@ class SimpleSpatialIndex {
|
|
|
21205
21221
|
}
|
|
21206
21222
|
}
|
|
21207
21223
|
render(context) {
|
|
21208
|
-
this.itemsArray.forEach((
|
|
21209
|
-
|
|
21224
|
+
this.itemsArray.forEach((item2) => {
|
|
21225
|
+
item2.render(context);
|
|
21210
21226
|
});
|
|
21211
21227
|
}
|
|
21212
21228
|
}
|
|
@@ -21257,7 +21273,7 @@ class BaseItem extends Mbr {
|
|
|
21257
21273
|
if (!this.index) {
|
|
21258
21274
|
return null;
|
|
21259
21275
|
}
|
|
21260
|
-
return this.index.items.listAll().map((
|
|
21276
|
+
return this.index.items.listAll().map((item2) => item2.getId());
|
|
21261
21277
|
}
|
|
21262
21278
|
addChildItems(children) {
|
|
21263
21279
|
if (!this.index) {
|
|
@@ -21295,17 +21311,17 @@ class BaseItem extends Mbr {
|
|
|
21295
21311
|
this.addChildItems(itemsToAdd);
|
|
21296
21312
|
this.removeChildItems(itemsToRemove);
|
|
21297
21313
|
}
|
|
21298
|
-
handleNesting(
|
|
21299
|
-
const isItem = "itemType" in
|
|
21300
|
-
const itemMbr = isItem ?
|
|
21301
|
-
if (
|
|
21314
|
+
handleNesting(item2, options) {
|
|
21315
|
+
const isItem = "itemType" in item2;
|
|
21316
|
+
const itemMbr = isItem ? item2.getMbr() : item2;
|
|
21317
|
+
if (item2 instanceof BaseItem && !item2.canBeNested) {
|
|
21302
21318
|
return false;
|
|
21303
21319
|
}
|
|
21304
|
-
if (options?.cancelIfChild && isItem &&
|
|
21320
|
+
if (options?.cancelIfChild && isItem && item2.parent !== "Board") {
|
|
21305
21321
|
return false;
|
|
21306
21322
|
}
|
|
21307
21323
|
const mbr = this.getMbr().copy();
|
|
21308
|
-
if (
|
|
21324
|
+
if (item2.isEnclosedOrCrossedBy(mbr)) {
|
|
21309
21325
|
if (mbr.isInside(itemMbr.getCenter())) {
|
|
21310
21326
|
if (!options || !options.onlyForOut) {
|
|
21311
21327
|
return true;
|
|
@@ -23602,8 +23618,8 @@ function isChild(value) {
|
|
|
23602
23618
|
if (!Array.isArray(value2))
|
|
23603
23619
|
return true;
|
|
23604
23620
|
const list2 = value2;
|
|
23605
|
-
for (const
|
|
23606
|
-
if (typeof
|
|
23621
|
+
for (const item2 of list2) {
|
|
23622
|
+
if (typeof item2 !== "number" && typeof item2 !== "string") {
|
|
23607
23623
|
return true;
|
|
23608
23624
|
}
|
|
23609
23625
|
}
|
|
@@ -23642,8 +23658,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
23642
23658
|
}
|
|
23643
23659
|
if (Array.isArray(result)) {
|
|
23644
23660
|
const finalResult = [];
|
|
23645
|
-
for (const
|
|
23646
|
-
finalResult.push(parsePrimitive(info, info.property,
|
|
23661
|
+
for (const item2 of result) {
|
|
23662
|
+
finalResult.push(parsePrimitive(info, info.property, item2));
|
|
23647
23663
|
}
|
|
23648
23664
|
result = finalResult;
|
|
23649
23665
|
}
|
|
@@ -34710,8 +34726,8 @@ function list5(node2, parent, state, info) {
|
|
|
34710
34726
|
if (checkRule(state) === bullet && firstListItem) {
|
|
34711
34727
|
let index2 = -1;
|
|
34712
34728
|
while (++index2 < node2.children.length) {
|
|
34713
|
-
const
|
|
34714
|
-
if (
|
|
34729
|
+
const item2 = node2.children[index2];
|
|
34730
|
+
if (item2 && item2.type === "listItem" && item2.children && item2.children[0] && item2.children[0].type === "thematicBreak") {
|
|
34715
34731
|
useDifferentMarker = true;
|
|
34716
34732
|
break;
|
|
34717
34733
|
}
|
|
@@ -35371,12 +35387,12 @@ async function convertMarkdownToSlate(text5) {
|
|
|
35371
35387
|
...nodes.filter((node2) => node2.type !== "list_item")
|
|
35372
35388
|
];
|
|
35373
35389
|
}
|
|
35374
|
-
return nodes.map((
|
|
35390
|
+
return nodes.map((item2) => {
|
|
35375
35391
|
setNodeStyles({
|
|
35376
|
-
node:
|
|
35377
|
-
isPaddingTopNeeded:
|
|
35392
|
+
node: item2,
|
|
35393
|
+
isPaddingTopNeeded: item2.type !== "code_block"
|
|
35378
35394
|
});
|
|
35379
|
-
return
|
|
35395
|
+
return item2;
|
|
35380
35396
|
});
|
|
35381
35397
|
}
|
|
35382
35398
|
function detectListType(text5) {
|
|
@@ -35789,17 +35805,17 @@ class FloatingPoint extends Point {
|
|
|
35789
35805
|
relativePoint;
|
|
35790
35806
|
pointType = "Floating";
|
|
35791
35807
|
edge;
|
|
35792
|
-
constructor(
|
|
35808
|
+
constructor(item2, relativePoint) {
|
|
35793
35809
|
super();
|
|
35794
|
-
this.item =
|
|
35810
|
+
this.item = item2;
|
|
35795
35811
|
this.relativePoint = relativePoint;
|
|
35796
35812
|
if (relativePoint.y <= 0) {
|
|
35797
35813
|
this.edge = "top";
|
|
35798
|
-
} else if (relativePoint.y >=
|
|
35814
|
+
} else if (relativePoint.y >= item2.getMbr().getHeight()) {
|
|
35799
35815
|
this.edge = "bottom";
|
|
35800
35816
|
} else if (relativePoint.x <= 0) {
|
|
35801
35817
|
this.edge = "left";
|
|
35802
|
-
} else if (relativePoint.x >=
|
|
35818
|
+
} else if (relativePoint.x >= item2.getMbr().getWidth()) {
|
|
35803
35819
|
this.edge = "right";
|
|
35804
35820
|
}
|
|
35805
35821
|
this.recalculatePoint();
|
|
@@ -35830,17 +35846,17 @@ class FixedPoint extends Point {
|
|
|
35830
35846
|
relativePoint;
|
|
35831
35847
|
pointType = "Fixed";
|
|
35832
35848
|
edge;
|
|
35833
|
-
constructor(
|
|
35849
|
+
constructor(item2, relativePoint) {
|
|
35834
35850
|
super();
|
|
35835
|
-
this.item =
|
|
35851
|
+
this.item = item2;
|
|
35836
35852
|
this.relativePoint = relativePoint;
|
|
35837
35853
|
if (relativePoint.y <= 0) {
|
|
35838
35854
|
this.edge = "top";
|
|
35839
|
-
} else if (relativePoint.y >=
|
|
35855
|
+
} else if (relativePoint.y >= item2.getMbr().getHeight()) {
|
|
35840
35856
|
this.edge = "bottom";
|
|
35841
35857
|
} else if (relativePoint.x <= 0) {
|
|
35842
35858
|
this.edge = "left";
|
|
35843
|
-
} else if (relativePoint.x >=
|
|
35859
|
+
} else if (relativePoint.x >= item2.getMbr().getWidth()) {
|
|
35844
35860
|
this.edge = "right";
|
|
35845
35861
|
}
|
|
35846
35862
|
this.recalculatePoint();
|
|
@@ -35871,16 +35887,16 @@ class FixedConnectorPoint extends Point {
|
|
|
35871
35887
|
tangent;
|
|
35872
35888
|
segmentIndex;
|
|
35873
35889
|
pointType = "FixedConnector";
|
|
35874
|
-
constructor(
|
|
35890
|
+
constructor(item2, tangent, segmentIndex) {
|
|
35875
35891
|
super();
|
|
35876
|
-
this.item =
|
|
35892
|
+
this.item = item2;
|
|
35877
35893
|
this.tangent = tangent;
|
|
35878
35894
|
this.segmentIndex = segmentIndex;
|
|
35879
35895
|
this.recalculatePoint();
|
|
35880
35896
|
}
|
|
35881
35897
|
recalculatePoint() {
|
|
35882
|
-
const
|
|
35883
|
-
const segments =
|
|
35898
|
+
const item2 = this.item;
|
|
35899
|
+
const segments = item2.getPaths().getSegments();
|
|
35884
35900
|
const segment = segments.length > this.segmentIndex ? segments[this.segmentIndex] : segments[segments.length - 1];
|
|
35885
35901
|
const point5 = segment.getPoint(this.tangent);
|
|
35886
35902
|
this.x = point5.x;
|
|
@@ -35905,38 +35921,38 @@ function getControlPoint(data, findItem2) {
|
|
|
35905
35921
|
if (data.pointType === "Board") {
|
|
35906
35922
|
return new BoardPoint(Math.round(data.x), Math.round(data.y));
|
|
35907
35923
|
} else {
|
|
35908
|
-
const
|
|
35909
|
-
if (!
|
|
35924
|
+
const item2 = findItem2(data.itemId);
|
|
35925
|
+
if (!item2) {
|
|
35910
35926
|
console.warn(`getControlPoint(): item not found for ${data.itemId}`);
|
|
35911
35927
|
return new BoardPoint(0, 0);
|
|
35912
35928
|
}
|
|
35913
35929
|
switch (data.pointType) {
|
|
35914
35930
|
case "FixedConnector":
|
|
35915
|
-
if (
|
|
35916
|
-
return new FixedConnectorPoint(
|
|
35931
|
+
if (item2 instanceof Connector2) {
|
|
35932
|
+
return new FixedConnectorPoint(item2, data.tangent, data.segment);
|
|
35917
35933
|
} else {
|
|
35918
35934
|
throw new Error(`getControlPoint(): item must be a connector`);
|
|
35919
35935
|
}
|
|
35920
35936
|
case "Floating":
|
|
35921
|
-
return new FloatingPoint(
|
|
35937
|
+
return new FloatingPoint(item2, new Point(data.relativeX, data.relativeY));
|
|
35922
35938
|
case "Fixed":
|
|
35923
|
-
return new FixedPoint(
|
|
35939
|
+
return new FixedPoint(item2, new Point(data.relativeX, data.relativeY));
|
|
35924
35940
|
}
|
|
35925
35941
|
}
|
|
35926
35942
|
}
|
|
35927
|
-
function toRelativePoint(point5,
|
|
35928
|
-
const matrix =
|
|
35943
|
+
function toRelativePoint(point5, item2) {
|
|
35944
|
+
const matrix = item2.transformation?.matrix || new Matrix2;
|
|
35929
35945
|
const inverse = matrix.getInverse();
|
|
35930
35946
|
point5 = point5.copy();
|
|
35931
35947
|
point5.transform(inverse);
|
|
35932
35948
|
return point5;
|
|
35933
35949
|
}
|
|
35934
|
-
function fromRelativePoint(relativePoint,
|
|
35935
|
-
const matrix =
|
|
35950
|
+
function fromRelativePoint(relativePoint, item2, edge) {
|
|
35951
|
+
const matrix = item2.transformation?.matrix.copy() || new Matrix2;
|
|
35936
35952
|
const point5 = relativePoint.copy();
|
|
35937
35953
|
point5.transform(matrix);
|
|
35938
|
-
if (
|
|
35939
|
-
const itemMbr =
|
|
35954
|
+
if (item2 instanceof RichText || item2 instanceof AINode) {
|
|
35955
|
+
const itemMbr = item2.getMbr();
|
|
35940
35956
|
const { x: centerX, y: centerY } = itemMbr.getCenter();
|
|
35941
35957
|
switch (edge) {
|
|
35942
35958
|
case "left":
|
|
@@ -35948,7 +35964,7 @@ function fromRelativePoint(relativePoint, item, edge) {
|
|
|
35948
35964
|
case "bottom":
|
|
35949
35965
|
return new Point(centerX, itemMbr.bottom);
|
|
35950
35966
|
default:
|
|
35951
|
-
return
|
|
35967
|
+
return item2.getMbr().getClosestEdgeCenterPoint(point5);
|
|
35952
35968
|
}
|
|
35953
35969
|
}
|
|
35954
35970
|
return point5;
|
|
@@ -37297,7 +37313,7 @@ class Connector2 extends BaseItem {
|
|
|
37297
37313
|
return this;
|
|
37298
37314
|
}
|
|
37299
37315
|
getConnectorById(items, connectorId) {
|
|
37300
|
-
return items.find((
|
|
37316
|
+
return items.find((item2) => item2 instanceof Connector2 && item2.getId() === connectorId);
|
|
37301
37317
|
}
|
|
37302
37318
|
updateTitle() {
|
|
37303
37319
|
const selection = this.board.selection;
|
|
@@ -39934,8 +39950,8 @@ async function exportBoardSnapshot({
|
|
|
39934
39950
|
context.matrix.applyToContext(context.ctx);
|
|
39935
39951
|
const { left, top, right, bottom } = selection;
|
|
39936
39952
|
const inView = board.items.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
39937
|
-
for (const
|
|
39938
|
-
|
|
39953
|
+
for (const item2 of inView) {
|
|
39954
|
+
item2.render(context);
|
|
39939
39955
|
}
|
|
39940
39956
|
const blob = await offscreenCanvas.convertToBlob({ type: "image/png" });
|
|
39941
39957
|
const dataUrl = await convertBlobToDataUrl(blob);
|
|
@@ -40133,7 +40149,7 @@ class Frame2 extends BaseItem {
|
|
|
40133
40149
|
return this.id;
|
|
40134
40150
|
}
|
|
40135
40151
|
getChildrenIds() {
|
|
40136
|
-
return this.index?.list().map((
|
|
40152
|
+
return this.index?.list().map((item2) => item2.getId()) || [];
|
|
40137
40153
|
}
|
|
40138
40154
|
updateMbr() {
|
|
40139
40155
|
const rect = this.path.getMbr().copy();
|
|
@@ -40368,11 +40384,11 @@ class Frame2 extends BaseItem {
|
|
|
40368
40384
|
}
|
|
40369
40385
|
});
|
|
40370
40386
|
const currMbr = this.getMbr();
|
|
40371
|
-
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((
|
|
40372
|
-
if (
|
|
40373
|
-
if (this.handleNesting(
|
|
40374
|
-
this.applyAddChildren([
|
|
40375
|
-
|
|
40387
|
+
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((item2) => {
|
|
40388
|
+
if (item2.parent === "Board") {
|
|
40389
|
+
if (this.handleNesting(item2)) {
|
|
40390
|
+
this.applyAddChildren([item2.getId()]);
|
|
40391
|
+
item2.parent = this.getId();
|
|
40376
40392
|
}
|
|
40377
40393
|
}
|
|
40378
40394
|
});
|
|
@@ -42570,9 +42586,9 @@ class Group extends BaseItem {
|
|
|
42570
42586
|
if (data.children) {
|
|
42571
42587
|
data.children.forEach((childId) => {
|
|
42572
42588
|
this.applyAddChild(childId);
|
|
42573
|
-
const
|
|
42574
|
-
if (
|
|
42575
|
-
|
|
42589
|
+
const item2 = this.board.items.getById(childId);
|
|
42590
|
+
if (item2) {
|
|
42591
|
+
item2.parent = this.getId();
|
|
42576
42592
|
}
|
|
42577
42593
|
});
|
|
42578
42594
|
}
|
|
@@ -42602,11 +42618,11 @@ class Group extends BaseItem {
|
|
|
42602
42618
|
let right = Number.MIN_SAFE_INTEGER;
|
|
42603
42619
|
let bottom = Number.MIN_SAFE_INTEGER;
|
|
42604
42620
|
const mbrs = this.children.flatMap((childId) => {
|
|
42605
|
-
const
|
|
42606
|
-
if (!
|
|
42621
|
+
const item2 = this.board.items.getById(childId);
|
|
42622
|
+
if (!item2) {
|
|
42607
42623
|
return [];
|
|
42608
42624
|
}
|
|
42609
|
-
const mbr2 =
|
|
42625
|
+
const mbr2 = item2.getMbr();
|
|
42610
42626
|
if (!mbr2) {
|
|
42611
42627
|
return [];
|
|
42612
42628
|
}
|
|
@@ -42641,7 +42657,7 @@ class Group extends BaseItem {
|
|
|
42641
42657
|
return this.children;
|
|
42642
42658
|
}
|
|
42643
42659
|
getChildren() {
|
|
42644
|
-
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((
|
|
42660
|
+
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((item2) => item2 !== undefined);
|
|
42645
42661
|
}
|
|
42646
42662
|
updateMbr() {
|
|
42647
42663
|
const rect = this.getMbr();
|
|
@@ -42654,9 +42670,9 @@ class Group extends BaseItem {
|
|
|
42654
42670
|
setChildren(items) {
|
|
42655
42671
|
items.forEach((itemId) => {
|
|
42656
42672
|
this.addChild(itemId);
|
|
42657
|
-
const
|
|
42658
|
-
if (
|
|
42659
|
-
|
|
42673
|
+
const item2 = this.board.items.getById(itemId);
|
|
42674
|
+
if (item2) {
|
|
42675
|
+
item2.parent = this.getId();
|
|
42660
42676
|
}
|
|
42661
42677
|
});
|
|
42662
42678
|
this.updateMbr();
|
|
@@ -42664,9 +42680,9 @@ class Group extends BaseItem {
|
|
|
42664
42680
|
removeChildren() {
|
|
42665
42681
|
this.children.forEach((itemId) => {
|
|
42666
42682
|
this.removeChild(itemId);
|
|
42667
|
-
const
|
|
42668
|
-
if (
|
|
42669
|
-
|
|
42683
|
+
const item2 = this.board.items.getById(itemId);
|
|
42684
|
+
if (item2) {
|
|
42685
|
+
item2.parent = this.parent;
|
|
42670
42686
|
}
|
|
42671
42687
|
});
|
|
42672
42688
|
this.updateMbr();
|
|
@@ -42999,16 +43015,16 @@ class Anchor extends Mbr {
|
|
|
42999
43015
|
}
|
|
43000
43016
|
}
|
|
43001
43017
|
// src/Items/Connector/ConnectorSnap.ts
|
|
43002
|
-
function getFixedPoint(
|
|
43003
|
-
if (
|
|
43004
|
-
const nearestSegmentData =
|
|
43018
|
+
function getFixedPoint(item2, point5) {
|
|
43019
|
+
if (item2 instanceof Connector2) {
|
|
43020
|
+
const nearestSegmentData = item2.getPaths().getNearestEdgeAndPointTo(point5);
|
|
43005
43021
|
const segment = nearestSegmentData.segment;
|
|
43006
43022
|
const index2 = nearestSegmentData.index;
|
|
43007
43023
|
const tangent = segment.getParameter(point5);
|
|
43008
|
-
return new FixedConnectorPoint(
|
|
43024
|
+
return new FixedConnectorPoint(item2, tangent, index2);
|
|
43009
43025
|
} else {
|
|
43010
|
-
const relativePoint = toRelativePoint(point5,
|
|
43011
|
-
return new FixedPoint(
|
|
43026
|
+
const relativePoint = toRelativePoint(point5, item2);
|
|
43027
|
+
return new FixedPoint(item2, relativePoint);
|
|
43012
43028
|
}
|
|
43013
43029
|
}
|
|
43014
43030
|
|
|
@@ -43061,20 +43077,20 @@ class ConnectorSnap {
|
|
|
43061
43077
|
}
|
|
43062
43078
|
this.setSnap();
|
|
43063
43079
|
const pointer = this.board.pointer.point;
|
|
43064
|
-
const { anchor, item, point: point5 } = this.snap;
|
|
43065
|
-
if (!
|
|
43080
|
+
const { anchor, item: item2, point: point5 } = this.snap;
|
|
43081
|
+
if (!item2) {
|
|
43066
43082
|
const pointer2 = this.board.pointer.point;
|
|
43067
43083
|
this.controlPoint = new BoardPoint(pointer2.x, pointer2.y);
|
|
43068
43084
|
} else if (anchor) {
|
|
43069
|
-
this.controlPoint = getFixedPoint(
|
|
43085
|
+
this.controlPoint = getFixedPoint(item2, anchor.getCenter());
|
|
43070
43086
|
} else if (point5) {
|
|
43071
|
-
const nearest2 =
|
|
43072
|
-
this.controlPoint = getFixedPoint(
|
|
43087
|
+
const nearest2 = item2.getNearestEdgePointTo(pointer);
|
|
43088
|
+
this.controlPoint = getFixedPoint(item2, nearest2);
|
|
43073
43089
|
} else {
|
|
43074
43090
|
if (this.hover.isTimeoutElapsed) {
|
|
43075
|
-
this.controlPoint = getFixedPoint(
|
|
43091
|
+
this.controlPoint = getFixedPoint(item2, pointer);
|
|
43076
43092
|
} else {
|
|
43077
|
-
this.controlPoint = getFixedPoint(
|
|
43093
|
+
this.controlPoint = getFixedPoint(item2, pointer);
|
|
43078
43094
|
}
|
|
43079
43095
|
}
|
|
43080
43096
|
}
|
|
@@ -43135,23 +43151,23 @@ class ConnectorSnap {
|
|
|
43135
43151
|
}
|
|
43136
43152
|
return nearest;
|
|
43137
43153
|
}
|
|
43138
|
-
getClosestPointOnItem(
|
|
43139
|
-
const nearestEdgePoint =
|
|
43140
|
-
return getFixedPoint(
|
|
43154
|
+
getClosestPointOnItem(item2, position4) {
|
|
43155
|
+
const nearestEdgePoint = item2.getNearestEdgePointTo(position4);
|
|
43156
|
+
return getFixedPoint(item2, nearestEdgePoint);
|
|
43141
43157
|
}
|
|
43142
|
-
isNearBorder(
|
|
43143
|
-
if (!
|
|
43158
|
+
isNearBorder(item2) {
|
|
43159
|
+
if (!item2) {
|
|
43144
43160
|
return false;
|
|
43145
43161
|
}
|
|
43146
43162
|
const pointer = this.board.pointer.point;
|
|
43147
|
-
const point5 =
|
|
43163
|
+
const point5 = item2.getNearestEdgePointTo(pointer);
|
|
43148
43164
|
const distance = pointer.getDistance(point5);
|
|
43149
43165
|
return distance < this.distance.border / this.board.camera.getScale();
|
|
43150
43166
|
}
|
|
43151
43167
|
setSnap() {
|
|
43152
|
-
const
|
|
43153
|
-
const path2 =
|
|
43154
|
-
if (!
|
|
43168
|
+
const item2 = this.snap.item;
|
|
43169
|
+
const path2 = item2 && "getPath" in item2 ? item2?.getPath() : null;
|
|
43170
|
+
if (!item2 || !path2) {
|
|
43155
43171
|
this.snap.path = null;
|
|
43156
43172
|
this.snap.anchors = [];
|
|
43157
43173
|
this.snap.anchor = null;
|
|
@@ -43162,11 +43178,11 @@ class ConnectorSnap {
|
|
|
43162
43178
|
if (this.snap.item === this.hover.item && !this.hover.isTimeoutElapsed) {
|
|
43163
43179
|
path2.setBackgroundColor(this.color.snapBackgroundHighlight);
|
|
43164
43180
|
}
|
|
43165
|
-
this.setAnchors(
|
|
43181
|
+
this.setAnchors(item2);
|
|
43166
43182
|
}
|
|
43167
43183
|
}
|
|
43168
|
-
setAnchors(
|
|
43169
|
-
const points =
|
|
43184
|
+
setAnchors(item2) {
|
|
43185
|
+
const points = item2.getSnapAnchorPoints();
|
|
43170
43186
|
if (!points) {
|
|
43171
43187
|
return;
|
|
43172
43188
|
}
|
|
@@ -43200,10 +43216,10 @@ class ConnectorSnap {
|
|
|
43200
43216
|
}
|
|
43201
43217
|
setPoint() {
|
|
43202
43218
|
const pointer = this.board.pointer.point;
|
|
43203
|
-
const { item, anchor } = this.snap;
|
|
43204
|
-
if (
|
|
43219
|
+
const { item: item2, anchor } = this.snap;
|
|
43220
|
+
if (item2) {
|
|
43205
43221
|
if (!anchor) {
|
|
43206
|
-
const point5 =
|
|
43222
|
+
const point5 = item2.getNearestEdgePointTo(pointer);
|
|
43207
43223
|
if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
|
|
43208
43224
|
this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
|
|
43209
43225
|
} else {
|
|
@@ -43576,12 +43592,12 @@ class NestingHighlighter extends Tool {
|
|
|
43576
43592
|
this.toHighlight.push({ groupItem, children: array });
|
|
43577
43593
|
}
|
|
43578
43594
|
}
|
|
43579
|
-
addSingleItem(
|
|
43580
|
-
this.toHighlight.push({ children: [
|
|
43595
|
+
addSingleItem(item2) {
|
|
43596
|
+
this.toHighlight.push({ children: [item2] });
|
|
43581
43597
|
}
|
|
43582
|
-
remove(
|
|
43598
|
+
remove(item2) {
|
|
43583
43599
|
this.toHighlight.forEach((group) => {
|
|
43584
|
-
group.children = group.children.filter((child) => child !==
|
|
43600
|
+
group.children = group.children.filter((child) => child !== item2);
|
|
43585
43601
|
});
|
|
43586
43602
|
this.toHighlight = this.toHighlight.filter((group) => group.children.length > 0);
|
|
43587
43603
|
}
|
|
@@ -43648,7 +43664,7 @@ class AddFrame extends BoardTool {
|
|
|
43648
43664
|
this.mbr.borderColor = "blue";
|
|
43649
43665
|
this.nestingHighlighter.clear();
|
|
43650
43666
|
const enclosedOrCrossed = this.board.items.getEnclosedOrCrossed(this.mbr.left, this.mbr.top, this.mbr.right, this.mbr.bottom);
|
|
43651
|
-
const inside = enclosedOrCrossed.filter((
|
|
43667
|
+
const inside = enclosedOrCrossed.filter((item2) => !(item2 instanceof Frame2) && item2.parent === "Board" && this.mbr.isInside(item2.getMbr().getCenter()));
|
|
43652
43668
|
this.nestingHighlighter.add(this.frame, inside);
|
|
43653
43669
|
this.initTransformation();
|
|
43654
43670
|
this.board.tools.publish();
|
|
@@ -43669,7 +43685,7 @@ class AddFrame extends BoardTool {
|
|
|
43669
43685
|
localStorage.setItem("lastFrameScale", JSON.stringify(this.frame.transformation.getScale()));
|
|
43670
43686
|
}
|
|
43671
43687
|
const currMbr = this.frame.getMbr();
|
|
43672
|
-
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
43688
|
+
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item2) => item2.parent === "Board").filter((item2) => this.frame.handleNesting(item2));
|
|
43673
43689
|
this.applyAddChildren(frameChildren);
|
|
43674
43690
|
if (this.shape !== "Custom") {
|
|
43675
43691
|
this.applyCanChangeRatio(false);
|
|
@@ -43685,7 +43701,7 @@ class AddFrame extends BoardTool {
|
|
|
43685
43701
|
return true;
|
|
43686
43702
|
}
|
|
43687
43703
|
addNextTo() {
|
|
43688
|
-
const framesInView = this.board.items.getItemsInView().filter((
|
|
43704
|
+
const framesInView = this.board.items.getItemsInView().filter((item2) => item2 instanceof Frame2);
|
|
43689
43705
|
if (framesInView.length === 0) {
|
|
43690
43706
|
if (this.shape === "Custom") {
|
|
43691
43707
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -43723,7 +43739,7 @@ class AddFrame extends BoardTool {
|
|
|
43723
43739
|
this.board.camera.viewRectangle(this.frame.getMbr());
|
|
43724
43740
|
}
|
|
43725
43741
|
const frameMbr = this.frame.getMbr();
|
|
43726
|
-
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((
|
|
43742
|
+
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((item2) => item2.parent === "Board").filter((item2) => this.frame.handleNesting(item2)).forEach((item2) => this.applyAddChildren([item2]));
|
|
43727
43743
|
const frame = this.board.add(this.frame);
|
|
43728
43744
|
frame.text.editor.moveCursorToEndOfTheText();
|
|
43729
43745
|
this.nestingHighlighter.clear();
|
|
@@ -44228,13 +44244,13 @@ class Eraser extends BoardTool {
|
|
|
44228
44244
|
}
|
|
44229
44245
|
removeUnderPointOrLine() {
|
|
44230
44246
|
const segments = this.drawing.getLines();
|
|
44231
|
-
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((
|
|
44232
|
-
return
|
|
44233
|
-
return line.getDistance(this.board.pointer.point) <=
|
|
44247
|
+
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((item2) => {
|
|
44248
|
+
return item2.itemType === "Drawing" && item2.getLines().find((line) => {
|
|
44249
|
+
return line.getDistance(this.board.pointer.point) <= item2.strokeWidth / 2 + this.strokeWidth / 2;
|
|
44234
44250
|
});
|
|
44235
44251
|
});
|
|
44236
|
-
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((
|
|
44237
|
-
return
|
|
44252
|
+
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((item2) => {
|
|
44253
|
+
return item2.itemType === "Drawing" && item2.getLines().some((line) => {
|
|
44238
44254
|
return segments.some((segment) => segment.hasIntersectionPoint(line));
|
|
44239
44255
|
});
|
|
44240
44256
|
}));
|
|
@@ -44686,20 +44702,20 @@ function createCanvasDrawer(board) {
|
|
|
44686
44702
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
44687
44703
|
context.matrix.applyToContext(context.ctx);
|
|
44688
44704
|
const items = Object.keys(translation).map((id) => {
|
|
44689
|
-
const
|
|
44690
|
-
if (
|
|
44691
|
-
if (
|
|
44692
|
-
return
|
|
44705
|
+
const item2 = board2.items.getById(id);
|
|
44706
|
+
if (item2) {
|
|
44707
|
+
if (item2.itemType !== "Frame") {
|
|
44708
|
+
return item2;
|
|
44693
44709
|
}
|
|
44694
|
-
|
|
44695
|
-
return
|
|
44710
|
+
item2.render(context);
|
|
44711
|
+
return item2;
|
|
44696
44712
|
}
|
|
44697
44713
|
return;
|
|
44698
|
-
}).filter((
|
|
44699
|
-
items.forEach((
|
|
44700
|
-
if (
|
|
44701
|
-
|
|
44702
|
-
board2.selection.renderItemMbr(context,
|
|
44714
|
+
}).filter((item2) => !!item2);
|
|
44715
|
+
items.forEach((item2) => {
|
|
44716
|
+
if (item2.itemType !== "Frame") {
|
|
44717
|
+
item2.render(context);
|
|
44718
|
+
board2.selection.renderItemMbr(context, item2, board2.camera.getMatrix().scaleX);
|
|
44703
44719
|
}
|
|
44704
44720
|
});
|
|
44705
44721
|
return { canvas: container, items };
|
|
@@ -44760,10 +44776,10 @@ function createCanvasDrawer(board) {
|
|
|
44760
44776
|
if (lastTranslationKeys) {
|
|
44761
44777
|
board.selection.shouldPublish = false;
|
|
44762
44778
|
lastTranslationKeys.forEach((id) => {
|
|
44763
|
-
const
|
|
44764
|
-
if (
|
|
44765
|
-
|
|
44766
|
-
|
|
44779
|
+
const item2 = board.items.getById(id);
|
|
44780
|
+
if (item2) {
|
|
44781
|
+
item2.transformationRenderBlock = undefined;
|
|
44782
|
+
item2.subject.publish(item2);
|
|
44767
44783
|
}
|
|
44768
44784
|
});
|
|
44769
44785
|
lastTranslationKeys = undefined;
|
|
@@ -44795,9 +44811,9 @@ function createCanvasDrawer(board) {
|
|
|
44795
44811
|
lastCreatedCanvas = cnvs;
|
|
44796
44812
|
lastTranslationKeys = Object.keys(translation);
|
|
44797
44813
|
lastTranslationKeys.forEach((id) => {
|
|
44798
|
-
const
|
|
44799
|
-
if (
|
|
44800
|
-
|
|
44814
|
+
const item2 = board.items.getById(id);
|
|
44815
|
+
if (item2) {
|
|
44816
|
+
item2.transformationRenderBlock = true;
|
|
44801
44817
|
}
|
|
44802
44818
|
});
|
|
44803
44819
|
board.selection.transformationRenderBlock = true;
|
|
@@ -44807,14 +44823,14 @@ function createCanvasDrawer(board) {
|
|
|
44807
44823
|
}
|
|
44808
44824
|
function countSumMbr(translation) {
|
|
44809
44825
|
return Object.keys(translation).reduce((mbr, id) => {
|
|
44810
|
-
const
|
|
44811
|
-
if (
|
|
44826
|
+
const item2 = board.items.getById(id);
|
|
44827
|
+
if (item2) {
|
|
44812
44828
|
if (!mbr) {
|
|
44813
|
-
mbr =
|
|
44829
|
+
mbr = item2.getMbr();
|
|
44814
44830
|
} else {
|
|
44815
|
-
mbr.combine(
|
|
44816
|
-
if (
|
|
44817
|
-
mbr.combine(
|
|
44831
|
+
mbr.combine(item2.getMbr());
|
|
44832
|
+
if (item2.itemType === "Frame") {
|
|
44833
|
+
mbr.combine(item2.getRichText().getMbr());
|
|
44818
44834
|
}
|
|
44819
44835
|
}
|
|
44820
44836
|
}
|
|
@@ -44845,8 +44861,8 @@ function createCanvasDrawer(board) {
|
|
|
44845
44861
|
}
|
|
44846
44862
|
function highlightNesting() {
|
|
44847
44863
|
const container = getLastCreatedCanvas();
|
|
44848
|
-
const drawnItemsMap = drawnItems?.reduce((acc,
|
|
44849
|
-
acc.set(
|
|
44864
|
+
const drawnItemsMap = drawnItems?.reduce((acc, item2) => {
|
|
44865
|
+
acc.set(item2.getId(), { item: item2, mbr: item2.getMbr() });
|
|
44850
44866
|
return acc;
|
|
44851
44867
|
}, new Map);
|
|
44852
44868
|
if (!container || !drawnItems) {
|
|
@@ -44881,11 +44897,11 @@ function createCanvasDrawer(board) {
|
|
|
44881
44897
|
mbr.transform(currMatrix);
|
|
44882
44898
|
});
|
|
44883
44899
|
groups.forEach((group) => {
|
|
44884
|
-
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
44885
|
-
if ("canBeNested" in
|
|
44900
|
+
drawnItemsMap?.forEach(({ mbr, item: item2 }, key) => {
|
|
44901
|
+
if ("canBeNested" in item2 && !item2.canBeNested) {
|
|
44886
44902
|
return;
|
|
44887
44903
|
}
|
|
44888
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) ||
|
|
44904
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item2.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
44889
44905
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
44890
44906
|
removeHighlighted(key);
|
|
44891
44907
|
highlightedDivs.set(key, div);
|
|
@@ -44946,10 +44962,10 @@ function createCanvasDrawer(board) {
|
|
|
44946
44962
|
}
|
|
44947
44963
|
|
|
44948
44964
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
44949
|
-
function getControlPointData(
|
|
44950
|
-
const itemScale = isRichText ? { x: 1, y: 1 } :
|
|
44951
|
-
const width2 =
|
|
44952
|
-
let height3 =
|
|
44965
|
+
function getControlPointData(item2, index2, isRichText = false) {
|
|
44966
|
+
const itemScale = isRichText ? { x: 1, y: 1 } : item2.transformation.getScale();
|
|
44967
|
+
const width2 = item2.getPathMbr().getWidth();
|
|
44968
|
+
let height3 = item2.getPathMbr().getHeight();
|
|
44953
44969
|
const adjMapScaled = {
|
|
44954
44970
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
44955
44971
|
1: {
|
|
@@ -44964,7 +44980,7 @@ function getControlPointData(item, index2, isRichText = false) {
|
|
|
44964
44980
|
};
|
|
44965
44981
|
return {
|
|
44966
44982
|
pointType: "Fixed",
|
|
44967
|
-
itemId:
|
|
44983
|
+
itemId: item2.getId(),
|
|
44968
44984
|
relativeX: adjMapScaled[index2].x,
|
|
44969
44985
|
relativeY: adjMapScaled[index2].y
|
|
44970
44986
|
};
|
|
@@ -45099,10 +45115,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
45099
45115
|
let newHeight = height3;
|
|
45100
45116
|
let itemData;
|
|
45101
45117
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
45102
|
-
const
|
|
45103
|
-
newWidth =
|
|
45104
|
-
newHeight =
|
|
45105
|
-
itemData =
|
|
45118
|
+
const item2 = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
45119
|
+
newWidth = item2.getMbr().getWidth();
|
|
45120
|
+
newHeight = item2.getMbr().getHeight();
|
|
45121
|
+
itemData = item2.serialize();
|
|
45106
45122
|
const { minX, minY, maxY, maxX } = offsets;
|
|
45107
45123
|
offsetX = Math.min(offsetX, maxX);
|
|
45108
45124
|
offsetX = Math.max(offsetX, minX);
|
|
@@ -45135,7 +45151,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45135
45151
|
}
|
|
45136
45152
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
45137
45153
|
let step = 1;
|
|
45138
|
-
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((
|
|
45154
|
+
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((item2) => item2.itemType !== "Connector").length > 0) {
|
|
45139
45155
|
const xDirection = step % 2 === 0 ? -1 : 1;
|
|
45140
45156
|
const yDirection = newItemData.itemType === "AINode" ? -1 : xDirection;
|
|
45141
45157
|
newMbr.transform(new Matrix2(iterAdjustment[index2].x * xDirection * step, iterAdjustment[index2].y * yDirection * (newItemData.itemType === "AINode" ? 1 : step)));
|
|
@@ -45268,7 +45284,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45268
45284
|
clear();
|
|
45269
45285
|
return;
|
|
45270
45286
|
}
|
|
45271
|
-
const { positions, item } = position4;
|
|
45287
|
+
const { positions, item: item2 } = position4;
|
|
45272
45288
|
const cameraMatrix = board.camera.getMatrix();
|
|
45273
45289
|
const cameraMbr = board.camera.getMbr();
|
|
45274
45290
|
const positionAdjustments = {
|
|
@@ -45296,7 +45312,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45296
45312
|
};
|
|
45297
45313
|
const button = document.createElement("button");
|
|
45298
45314
|
button.classList.add("microboard-quickAddButton");
|
|
45299
|
-
if (
|
|
45315
|
+
if (item2.itemType === "AINode" && index2 === 2) {
|
|
45300
45316
|
button.classList.add("microboard-invisible");
|
|
45301
45317
|
}
|
|
45302
45318
|
button.classList.add(`microboard-${adjustment.rotate}`);
|
|
@@ -45312,7 +45328,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45312
45328
|
clearTimeout(timeoutId);
|
|
45313
45329
|
}
|
|
45314
45330
|
if (button.isMouseDown) {
|
|
45315
|
-
board.tools.addConnector(true,
|
|
45331
|
+
board.tools.addConnector(true, item2, pos);
|
|
45316
45332
|
} else {
|
|
45317
45333
|
quickAddItems = undefined;
|
|
45318
45334
|
selection.subject.publish(selection);
|
|
@@ -45419,11 +45435,11 @@ class AlignmentHelper {
|
|
|
45419
45435
|
return baseThickness / (zoom / 100);
|
|
45420
45436
|
}
|
|
45421
45437
|
combineMBRs(items) {
|
|
45422
|
-
return items.reduce((acc,
|
|
45438
|
+
return items.reduce((acc, item2, i) => {
|
|
45423
45439
|
if (i === 0) {
|
|
45424
45440
|
return acc;
|
|
45425
45441
|
}
|
|
45426
|
-
const itemMbr =
|
|
45442
|
+
const itemMbr = item2.getPathMbr();
|
|
45427
45443
|
return acc.combine(itemMbr);
|
|
45428
45444
|
}, items[0].getMbr());
|
|
45429
45445
|
}
|
|
@@ -45437,7 +45453,7 @@ class AlignmentHelper {
|
|
|
45437
45453
|
const scale = this.board.camera.getScale();
|
|
45438
45454
|
const dynamicAlignThreshold = Math.min(this.alignThreshold / scale, 8);
|
|
45439
45455
|
const childrenIds = "index" in movingItem && movingItem.index ? movingItem.getChildrenIds() : [];
|
|
45440
|
-
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (
|
|
45456
|
+
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (item2) => !excludeItems.includes(item2), 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((item2) => Array.isArray(movingItem) ? !movingItem.includes(item2) : true);
|
|
45441
45457
|
const verticalAlignments = new Map;
|
|
45442
45458
|
const horizontalAlignments = new Map;
|
|
45443
45459
|
const addVerticalAlignment = (x, minY, maxY) => {
|
|
@@ -45458,11 +45474,11 @@ class AlignmentHelper {
|
|
|
45458
45474
|
horizontalAlignments.set(y, { minX, maxX });
|
|
45459
45475
|
}
|
|
45460
45476
|
};
|
|
45461
|
-
nearbyItems.forEach((
|
|
45462
|
-
if (
|
|
45477
|
+
nearbyItems.forEach((item2) => {
|
|
45478
|
+
if (item2 === movingItem || item2.itemType === "Comment") {
|
|
45463
45479
|
return;
|
|
45464
45480
|
}
|
|
45465
|
-
const itemMbr =
|
|
45481
|
+
const itemMbr = item2.itemType === "Shape" ? item2.getPath().getMbr() : item2.getMbr();
|
|
45466
45482
|
const centerXMoving = (movingMBR.left + movingMBR.right) / 2;
|
|
45467
45483
|
const centerXItem = (itemMbr.left + itemMbr.right) / 2;
|
|
45468
45484
|
const centerYMoving = (movingMBR.top + movingMBR.bottom) / 2;
|
|
@@ -45729,20 +45745,20 @@ class AlignmentHelper {
|
|
|
45729
45745
|
}
|
|
45730
45746
|
return false;
|
|
45731
45747
|
}
|
|
45732
|
-
translateItems(
|
|
45748
|
+
translateItems(item2, x, y, timeStamp) {
|
|
45733
45749
|
if (this.canvasDrawer.getLastCreatedCanvas()) {
|
|
45734
45750
|
return;
|
|
45735
45751
|
}
|
|
45736
|
-
if (Array.isArray(
|
|
45752
|
+
if (Array.isArray(item2)) {
|
|
45737
45753
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45738
45754
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45739
45755
|
return;
|
|
45740
45756
|
}
|
|
45741
|
-
if (
|
|
45757
|
+
if (item2.itemType === "Frame") {
|
|
45742
45758
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45743
45759
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45744
45760
|
} else {
|
|
45745
|
-
const id =
|
|
45761
|
+
const id = item2.getId();
|
|
45746
45762
|
const transformMap = {};
|
|
45747
45763
|
transformMap[id] = {
|
|
45748
45764
|
class: "Transformation",
|
|
@@ -45870,12 +45886,12 @@ class Select extends Tool {
|
|
|
45870
45886
|
this.debounceUpd.setFalse();
|
|
45871
45887
|
this.snapLines = { verticalLines: [], horizontalLines: [] };
|
|
45872
45888
|
}
|
|
45873
|
-
handleSnapping(
|
|
45889
|
+
handleSnapping(item2) {
|
|
45874
45890
|
if (this.board.keyboard.isShift) {
|
|
45875
45891
|
return false;
|
|
45876
45892
|
}
|
|
45877
|
-
const increasedSnapThreshold = Array.isArray(
|
|
45878
|
-
this.isSnapped = this.alignmentHelper.snapToClosestLine(
|
|
45893
|
+
const increasedSnapThreshold = Array.isArray(item2) ? 40 : 35;
|
|
45894
|
+
this.isSnapped = this.alignmentHelper.snapToClosestLine(item2, this.snapLines, this.beginTimeStamp, this.board.pointer.point);
|
|
45879
45895
|
if (this.isSnapped) {
|
|
45880
45896
|
if (!this.snapCursorPos) {
|
|
45881
45897
|
this.snapCursorPos = new Point(this.board.pointer.point.x, this.board.pointer.point.y);
|
|
@@ -45885,10 +45901,10 @@ class Select extends Tool {
|
|
|
45885
45901
|
if ((cursorDiffX > increasedSnapThreshold || cursorDiffY > increasedSnapThreshold) && this.initialCursorPos) {
|
|
45886
45902
|
this.isSnapped = false;
|
|
45887
45903
|
this.snapCursorPos = null;
|
|
45888
|
-
const itemCenter = Array.isArray(
|
|
45904
|
+
const itemCenter = Array.isArray(item2) ? this.alignmentHelper.combineMBRs(item2).getCenter() : item2.getMbr().getCenter();
|
|
45889
45905
|
const translateX = this.board.pointer.point.x - this.initialCursorPos.x - itemCenter.x;
|
|
45890
45906
|
const translateY = this.board.pointer.point.y - this.initialCursorPos.y - itemCenter.y;
|
|
45891
|
-
this.alignmentHelper.translateItems(
|
|
45907
|
+
this.alignmentHelper.translateItems(item2, translateX, translateY, this.beginTimeStamp);
|
|
45892
45908
|
}
|
|
45893
45909
|
}
|
|
45894
45910
|
return false;
|
|
@@ -45938,10 +45954,10 @@ class Select extends Tool {
|
|
|
45938
45954
|
angleDiff = angleDiff < 0 ? angleDiff + 360 : angleDiff;
|
|
45939
45955
|
return Math.min(angleDiff, 360 - angleDiff);
|
|
45940
45956
|
}
|
|
45941
|
-
handleShiftGuidelines(
|
|
45942
|
-
if (
|
|
45957
|
+
handleShiftGuidelines(item2, mousePosition) {
|
|
45958
|
+
if (item2) {
|
|
45943
45959
|
if (!this.originalCenter) {
|
|
45944
|
-
this.originalCenter = Array.isArray(
|
|
45960
|
+
this.originalCenter = Array.isArray(item2) ? this.board.selection.getMbr()?.getCenter().copy() : item2.getMbr().getCenter().copy();
|
|
45945
45961
|
this.guidelines = this.alignmentHelper.generateGuidelines(this.originalCenter).lines;
|
|
45946
45962
|
}
|
|
45947
45963
|
this.mainLine = new Line(this.originalCenter, mousePosition);
|
|
@@ -45962,13 +45978,13 @@ class Select extends Tool {
|
|
|
45962
45978
|
const newEndX = this.originalCenter.x + snapDirectionX * mainLineLength;
|
|
45963
45979
|
const newEndY = this.originalCenter.y + snapDirectionY * mainLineLength;
|
|
45964
45980
|
const threshold = Infinity;
|
|
45965
|
-
const translateX = newEndX - (Array.isArray(
|
|
45966
|
-
const translateY = newEndY - (Array.isArray(
|
|
45967
|
-
if (Array.isArray(
|
|
45981
|
+
const translateX = newEndX - (Array.isArray(item2) ? this.board.selection.getMbr()?.getCenter().x : item2.getMbr().getCenter().x);
|
|
45982
|
+
const translateY = newEndY - (Array.isArray(item2) ? this.board.selection.getMbr()?.getCenter().y : item2.getMbr().getCenter().y);
|
|
45983
|
+
if (Array.isArray(item2)) {
|
|
45968
45984
|
const translation = this.board.selection.getManyItemsTranslation(translateX, translateY);
|
|
45969
45985
|
this.board.selection.transformMany(translation, this.beginTimeStamp);
|
|
45970
45986
|
} else {
|
|
45971
|
-
|
|
45987
|
+
item2.transformation.translateBy(translateX, translateY, this.beginTimeStamp);
|
|
45972
45988
|
}
|
|
45973
45989
|
}
|
|
45974
45990
|
}
|
|
@@ -46011,7 +46027,7 @@ class Select extends Tool {
|
|
|
46011
46027
|
return false;
|
|
46012
46028
|
}
|
|
46013
46029
|
this.isDownOnBoard = hover.length === 0;
|
|
46014
|
-
this.isDrawingRectangle = hover.filter((
|
|
46030
|
+
this.isDrawingRectangle = hover.filter((item2) => !(item2 instanceof Frame2)).length === 0 && hover.filter((item2) => item2 instanceof Frame2).filter((frame) => frame.isTextUnderPoint(pointer.point)).length === 0;
|
|
46015
46031
|
if (this.isDrawingRectangle) {
|
|
46016
46032
|
const { x, y } = pointer.point;
|
|
46017
46033
|
this.line = new Line(new Point(x, y), new Point(x, y));
|
|
@@ -46031,7 +46047,7 @@ class Select extends Tool {
|
|
|
46031
46047
|
});
|
|
46032
46048
|
return false;
|
|
46033
46049
|
}
|
|
46034
|
-
const isHoverLocked = hover.every((
|
|
46050
|
+
const isHoverLocked = hover.every((item2) => item2.transformation.isLocked);
|
|
46035
46051
|
if (isHoverLocked) {
|
|
46036
46052
|
return false;
|
|
46037
46053
|
}
|
|
@@ -46165,7 +46181,7 @@ class Select extends Tool {
|
|
|
46165
46181
|
const translation = selection.getManyItemsTranslation(x, y);
|
|
46166
46182
|
const translationKeys = Object.keys(translation);
|
|
46167
46183
|
const commentsSet = new Set(this.board.items.getComments().map((comment2) => comment2.getId()));
|
|
46168
|
-
if (translationKeys.filter((
|
|
46184
|
+
if (translationKeys.filter((item2) => !commentsSet.has(item2)).length > 10) {
|
|
46169
46185
|
const selectedMbr = this.board.selection.getMbr()?.copy();
|
|
46170
46186
|
const sumMbr = this.canvasDrawer.countSumMbr(translation);
|
|
46171
46187
|
if (sumMbr) {
|
|
@@ -46192,7 +46208,7 @@ class Select extends Tool {
|
|
|
46192
46208
|
return false;
|
|
46193
46209
|
}
|
|
46194
46210
|
const draggingMbr = draggingItem.getMbr();
|
|
46195
|
-
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((
|
|
46211
|
+
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((item2) => item2 instanceof Frame2);
|
|
46196
46212
|
frames.forEach((frame) => {
|
|
46197
46213
|
if (frame.handleNesting(draggingItem)) {
|
|
46198
46214
|
this.nestingHighlighter.add(frame, draggingItem);
|
|
@@ -46202,7 +46218,7 @@ class Select extends Tool {
|
|
|
46202
46218
|
});
|
|
46203
46219
|
}
|
|
46204
46220
|
const hover = items.getUnderPointer();
|
|
46205
|
-
this.isHoverUnselectedItem = hover.filter((
|
|
46221
|
+
this.isHoverUnselectedItem = hover.filter((item2) => item2.itemType === "Placeholder").length === 1;
|
|
46206
46222
|
if (this.isHoverUnselectedItem && !this.isDraggingUnselectedItem && selection.getContext() === "None") {
|
|
46207
46223
|
selection.setContext("HoverUnderPointer");
|
|
46208
46224
|
return false;
|
|
@@ -46246,15 +46262,15 @@ class Select extends Tool {
|
|
|
46246
46262
|
}
|
|
46247
46263
|
}
|
|
46248
46264
|
updateFramesNesting(selectionMbr, selection) {
|
|
46249
|
-
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((
|
|
46250
|
-
const draggingFramesIds = selection.list().filter((
|
|
46251
|
-
selection.list().forEach((
|
|
46252
|
-
if (!(
|
|
46265
|
+
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((item2) => item2 instanceof Frame2).filter((frame) => !selection.items.list().includes(frame));
|
|
46266
|
+
const draggingFramesIds = selection.list().filter((item2) => item2 instanceof Frame2).map((frame) => frame.getId());
|
|
46267
|
+
selection.list().forEach((item2) => {
|
|
46268
|
+
if (!(item2 instanceof Frame2) && !draggingFramesIds.includes(item2.parent)) {
|
|
46253
46269
|
frames.forEach((frame) => {
|
|
46254
|
-
if (frame.handleNesting(
|
|
46255
|
-
this.nestingHighlighter.add(frame,
|
|
46270
|
+
if (frame.handleNesting(item2)) {
|
|
46271
|
+
this.nestingHighlighter.add(frame, item2);
|
|
46256
46272
|
} else {
|
|
46257
|
-
this.nestingHighlighter.remove(
|
|
46273
|
+
this.nestingHighlighter.remove(item2);
|
|
46258
46274
|
}
|
|
46259
46275
|
});
|
|
46260
46276
|
}
|
|
@@ -46346,7 +46362,7 @@ class Select extends Tool {
|
|
|
46346
46362
|
const childrenIds = underPointer.getChildrenIds();
|
|
46347
46363
|
console.log("UNDERPOINTER", underPointer);
|
|
46348
46364
|
console.log("CHILDREN", childrenIds);
|
|
46349
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
46365
|
+
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item2) => childrenIds && childrenIds.includes(item2.getId()));
|
|
46350
46366
|
this.board.selection.add(itemsInFrame);
|
|
46351
46367
|
}
|
|
46352
46368
|
this.board.selection.setContext("EditUnderPointer");
|
|
@@ -46586,8 +46602,8 @@ class ShapeTool extends CustomTool {
|
|
|
46586
46602
|
resizeType = "leftBottom";
|
|
46587
46603
|
bounds = new Mbr;
|
|
46588
46604
|
isDown = false;
|
|
46589
|
-
constructor(board, name,
|
|
46590
|
-
super(board, name,
|
|
46605
|
+
constructor(board, name, item2, settings) {
|
|
46606
|
+
super(board, name, item2);
|
|
46591
46607
|
this.settings = settings;
|
|
46592
46608
|
this.setCursor();
|
|
46593
46609
|
}
|
|
@@ -46670,8 +46686,8 @@ class ShapeTool extends CustomTool {
|
|
|
46670
46686
|
|
|
46671
46687
|
class StickerTool extends CustomTool {
|
|
46672
46688
|
settings;
|
|
46673
|
-
constructor(board, name,
|
|
46674
|
-
super(board, name,
|
|
46689
|
+
constructor(board, name, item2, settings) {
|
|
46690
|
+
super(board, name, item2);
|
|
46675
46691
|
this.settings = settings;
|
|
46676
46692
|
this.setCursor();
|
|
46677
46693
|
}
|
|
@@ -46977,7 +46993,7 @@ class Tools extends ToolContext {
|
|
|
46977
46993
|
this.subject.publish(this);
|
|
46978
46994
|
}
|
|
46979
46995
|
sortFrames() {
|
|
46980
|
-
const frames = this.board.items.listAll().filter((
|
|
46996
|
+
const frames = this.board.items.listAll().filter((item2) => item2 instanceof Frame2);
|
|
46981
46997
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
46982
46998
|
const mbr1 = fr1.getMbr();
|
|
46983
46999
|
const mbr2 = fr2.getMbr();
|
|
@@ -47203,24 +47219,24 @@ function validateGroupData(groupData) {
|
|
|
47203
47219
|
}
|
|
47204
47220
|
// src/Items/RegisterItem.ts
|
|
47205
47221
|
function registerItem({
|
|
47206
|
-
item,
|
|
47222
|
+
item: item2,
|
|
47207
47223
|
defaultData: defaultData2,
|
|
47208
47224
|
toolData
|
|
47209
47225
|
}) {
|
|
47210
47226
|
const { itemType } = defaultData2;
|
|
47211
|
-
itemFactories[itemType] = createItemFactory(
|
|
47227
|
+
itemFactories[itemType] = createItemFactory(item2, defaultData2);
|
|
47212
47228
|
itemValidators[itemType] = createItemValidator(defaultData2);
|
|
47213
47229
|
if (toolData) {
|
|
47214
47230
|
registeredTools[toolData.name] = toolData.tool;
|
|
47215
47231
|
}
|
|
47216
47232
|
itemCommandFactories[itemType] = createItemCommandFactory(itemType);
|
|
47217
47233
|
}
|
|
47218
|
-
function createItemFactory(
|
|
47234
|
+
function createItemFactory(item2, defaultData2) {
|
|
47219
47235
|
return function itemFactory(id, data, board) {
|
|
47220
47236
|
if (data.itemType !== defaultData2.itemType) {
|
|
47221
47237
|
throw new Error(`Invalid data for ${defaultData2.itemType}`);
|
|
47222
47238
|
}
|
|
47223
|
-
return new
|
|
47239
|
+
return new item2(board, id, defaultData2).setId(id).deserialize(data);
|
|
47224
47240
|
};
|
|
47225
47241
|
}
|
|
47226
47242
|
function createItemValidator(defaultData2) {
|
|
@@ -47235,7 +47251,7 @@ function createItemValidator(defaultData2) {
|
|
|
47235
47251
|
}
|
|
47236
47252
|
function createItemCommandFactory(itemType) {
|
|
47237
47253
|
return function itemCommandFactory(items, operation) {
|
|
47238
|
-
return new BaseCommand(items.filter((
|
|
47254
|
+
return new BaseCommand(items.filter((item2) => item2.itemType === itemType), operation);
|
|
47239
47255
|
};
|
|
47240
47256
|
}
|
|
47241
47257
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -48260,8 +48276,8 @@ class Camera {
|
|
|
48260
48276
|
this.observableItem = null;
|
|
48261
48277
|
}
|
|
48262
48278
|
}
|
|
48263
|
-
subscribeToItem(
|
|
48264
|
-
this.observableItem =
|
|
48279
|
+
subscribeToItem(item2) {
|
|
48280
|
+
this.observableItem = item2;
|
|
48265
48281
|
this.observableItem.subject.subscribe(this.observeItem);
|
|
48266
48282
|
}
|
|
48267
48283
|
observeItem = () => {
|
|
@@ -48487,7 +48503,7 @@ class Camera {
|
|
|
48487
48503
|
}
|
|
48488
48504
|
addToView(mbr, inView) {
|
|
48489
48505
|
if (!mbr.isEnclosedBy(this.getMbr())) {
|
|
48490
|
-
this.viewRectangle(inView.reduce((acc,
|
|
48506
|
+
this.viewRectangle(inView.reduce((acc, item2) => acc.combine(item2.getMbr()), inView[0]?.getMbr() ?? new Mbr).combine(mbr));
|
|
48491
48507
|
}
|
|
48492
48508
|
}
|
|
48493
48509
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
@@ -50096,8 +50112,8 @@ class Presence {
|
|
|
50096
50112
|
<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}"/>
|
|
50097
50113
|
</svg>`;
|
|
50098
50114
|
}
|
|
50099
|
-
renderItemMbr(context,
|
|
50100
|
-
const mbr =
|
|
50115
|
+
renderItemMbr(context, item2, color2, customScale) {
|
|
50116
|
+
const mbr = item2.getMbr();
|
|
50101
50117
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
50102
50118
|
mbr.borderColor = color2;
|
|
50103
50119
|
mbr.render(context);
|
|
@@ -50237,8 +50253,8 @@ class Presence {
|
|
|
50237
50253
|
selectionMbr.strokeWidth = 1 / context.matrix.scaleX;
|
|
50238
50254
|
selectionMbr.borderColor = selection.color;
|
|
50239
50255
|
selectionMbr.render(context);
|
|
50240
|
-
for (const
|
|
50241
|
-
this.renderItemMbr(context,
|
|
50256
|
+
for (const item2 of selection.selection) {
|
|
50257
|
+
this.renderItemMbr(context, item2, selection.color);
|
|
50242
50258
|
}
|
|
50243
50259
|
}
|
|
50244
50260
|
}
|
|
@@ -50271,14 +50287,14 @@ class SelectionItems {
|
|
|
50271
50287
|
items = new Map;
|
|
50272
50288
|
add(value) {
|
|
50273
50289
|
if (Array.isArray(value)) {
|
|
50274
|
-
value.forEach((
|
|
50290
|
+
value.forEach((item2) => this.items.set(item2.getId(), item2));
|
|
50275
50291
|
} else {
|
|
50276
50292
|
this.items.set(value.getId(), value);
|
|
50277
50293
|
}
|
|
50278
50294
|
}
|
|
50279
50295
|
remove(value) {
|
|
50280
50296
|
if (Array.isArray(value)) {
|
|
50281
|
-
value.forEach((
|
|
50297
|
+
value.forEach((item2) => this.items.delete(item2.getId()));
|
|
50282
50298
|
} else {
|
|
50283
50299
|
this.items.delete(value.getId());
|
|
50284
50300
|
}
|
|
@@ -50308,8 +50324,8 @@ class SelectionItems {
|
|
|
50308
50324
|
if (this.isEmpty()) {
|
|
50309
50325
|
return false;
|
|
50310
50326
|
}
|
|
50311
|
-
for (const
|
|
50312
|
-
if (
|
|
50327
|
+
for (const item2 of this.items.values()) {
|
|
50328
|
+
if (item2.itemType !== "RichText") {
|
|
50313
50329
|
return false;
|
|
50314
50330
|
}
|
|
50315
50331
|
}
|
|
@@ -50319,14 +50335,14 @@ class SelectionItems {
|
|
|
50319
50335
|
if (this.isEmpty()) {
|
|
50320
50336
|
return false;
|
|
50321
50337
|
}
|
|
50322
|
-
return Array.from(this.items).every(([,
|
|
50338
|
+
return Array.from(this.items).every(([, item2]) => item2.itemType === itemType);
|
|
50323
50339
|
}
|
|
50324
50340
|
isItemTypes(itemTypes) {
|
|
50325
50341
|
if (this.isEmpty()) {
|
|
50326
50342
|
return false;
|
|
50327
50343
|
}
|
|
50328
|
-
for (const
|
|
50329
|
-
if (!itemTypes.includes(
|
|
50344
|
+
for (const item2 of this.items.values()) {
|
|
50345
|
+
if (!itemTypes.includes(item2.itemType)) {
|
|
50330
50346
|
return false;
|
|
50331
50347
|
}
|
|
50332
50348
|
}
|
|
@@ -50334,16 +50350,16 @@ class SelectionItems {
|
|
|
50334
50350
|
}
|
|
50335
50351
|
getItemTypes() {
|
|
50336
50352
|
const itemTypes = new Set;
|
|
50337
|
-
this.items.forEach((
|
|
50353
|
+
this.items.forEach((item2) => itemTypes.add(item2.itemType));
|
|
50338
50354
|
return Array.from(itemTypes);
|
|
50339
50355
|
}
|
|
50340
50356
|
getItemsByItemTypes(itemTypes) {
|
|
50341
|
-
return Array.from(this.items.values()).filter((
|
|
50357
|
+
return Array.from(this.items.values()).filter((item2) => itemTypes.includes(item2.itemType));
|
|
50342
50358
|
}
|
|
50343
50359
|
getIdsByItemTypes(itemTypes) {
|
|
50344
50360
|
const ids = [];
|
|
50345
|
-
this.items.forEach((
|
|
50346
|
-
if (itemTypes.includes(
|
|
50361
|
+
this.items.forEach((item2, id) => {
|
|
50362
|
+
if (itemTypes.includes(item2.itemType)) {
|
|
50347
50363
|
ids.push(id);
|
|
50348
50364
|
}
|
|
50349
50365
|
});
|
|
@@ -50353,7 +50369,7 @@ class SelectionItems {
|
|
|
50353
50369
|
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
50354
50370
|
}
|
|
50355
50371
|
listByIds(itemIdList) {
|
|
50356
|
-
return itemIdList.map((id) => this.items.get(id)).filter((
|
|
50372
|
+
return itemIdList.map((id) => this.items.get(id)).filter((item2) => item2 !== undefined);
|
|
50357
50373
|
}
|
|
50358
50374
|
ids() {
|
|
50359
50375
|
return Array.from(this.items.keys());
|
|
@@ -50364,7 +50380,7 @@ class SelectionItems {
|
|
|
50364
50380
|
return;
|
|
50365
50381
|
}
|
|
50366
50382
|
const mbr = items[0].getMbr();
|
|
50367
|
-
items.slice(1).forEach((
|
|
50383
|
+
items.slice(1).forEach((item2) => mbr.combine(item2.getMbr()));
|
|
50368
50384
|
return mbr;
|
|
50369
50385
|
}
|
|
50370
50386
|
}
|
|
@@ -50569,33 +50585,33 @@ function handleMultipleItemsResize({
|
|
|
50569
50585
|
const translation = {};
|
|
50570
50586
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
50571
50587
|
board.items.getComments().forEach((comment2) => {
|
|
50572
|
-
if (items.some((
|
|
50588
|
+
if (items.some((item2) => item2.getId() === comment2.getItemToFollow())) {
|
|
50573
50589
|
items.push(comment2);
|
|
50574
50590
|
}
|
|
50575
50591
|
});
|
|
50576
|
-
for (const
|
|
50577
|
-
let itemX =
|
|
50578
|
-
let itemY =
|
|
50579
|
-
if (
|
|
50580
|
-
itemX =
|
|
50581
|
-
itemY =
|
|
50592
|
+
for (const item2 of items) {
|
|
50593
|
+
let itemX = item2.getMbr().left;
|
|
50594
|
+
let itemY = item2.getMbr().top;
|
|
50595
|
+
if (item2.itemType === "Drawing") {
|
|
50596
|
+
itemX = item2.transformation.matrix.translateX;
|
|
50597
|
+
itemY = item2.transformation.matrix.translateY;
|
|
50582
50598
|
}
|
|
50583
50599
|
const deltaX = itemX - initMbr.left;
|
|
50584
50600
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
50585
50601
|
const deltaY = itemY - initMbr.top;
|
|
50586
50602
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
50587
|
-
if (
|
|
50588
|
-
translation[
|
|
50589
|
-
item,
|
|
50603
|
+
if (item2 instanceof RichText) {
|
|
50604
|
+
translation[item2.getId()] = getRichTextTranslation({
|
|
50605
|
+
item: item2,
|
|
50590
50606
|
isWidth,
|
|
50591
50607
|
isHeight,
|
|
50592
50608
|
matrix,
|
|
50593
50609
|
translateX,
|
|
50594
50610
|
translateY
|
|
50595
50611
|
});
|
|
50596
|
-
} else if (
|
|
50597
|
-
translation[
|
|
50598
|
-
item,
|
|
50612
|
+
} else if (item2 instanceof AINode) {
|
|
50613
|
+
translation[item2.getId()] = getAINodeTranslation({
|
|
50614
|
+
item: item2,
|
|
50599
50615
|
isWidth,
|
|
50600
50616
|
isHeight,
|
|
50601
50617
|
matrix,
|
|
@@ -50603,8 +50619,8 @@ function handleMultipleItemsResize({
|
|
|
50603
50619
|
translateY
|
|
50604
50620
|
});
|
|
50605
50621
|
} else {
|
|
50606
|
-
translation[
|
|
50607
|
-
item,
|
|
50622
|
+
translation[item2.getId()] = getItemTranslation({
|
|
50623
|
+
item: item2,
|
|
50608
50624
|
isWidth,
|
|
50609
50625
|
isHeight,
|
|
50610
50626
|
matrix,
|
|
@@ -50617,7 +50633,7 @@ function handleMultipleItemsResize({
|
|
|
50617
50633
|
return translation;
|
|
50618
50634
|
}
|
|
50619
50635
|
function getRichTextTranslation({
|
|
50620
|
-
item,
|
|
50636
|
+
item: item2,
|
|
50621
50637
|
isWidth,
|
|
50622
50638
|
isHeight,
|
|
50623
50639
|
matrix,
|
|
@@ -50625,11 +50641,11 @@ function getRichTextTranslation({
|
|
|
50625
50641
|
translateY
|
|
50626
50642
|
}) {
|
|
50627
50643
|
if (isWidth) {
|
|
50628
|
-
|
|
50644
|
+
item2.editor.setMaxWidth(item2.getWidth() / item2.transformation.getScale().x * matrix.scaleX);
|
|
50629
50645
|
return {
|
|
50630
50646
|
class: "Transformation",
|
|
50631
50647
|
method: "scaleByTranslateBy",
|
|
50632
|
-
item: [
|
|
50648
|
+
item: [item2.getId()],
|
|
50633
50649
|
translate: { x: matrix.translateX, y: 0 },
|
|
50634
50650
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50635
50651
|
};
|
|
@@ -50637,7 +50653,7 @@ function getRichTextTranslation({
|
|
|
50637
50653
|
return {
|
|
50638
50654
|
class: "Transformation",
|
|
50639
50655
|
method: "scaleByTranslateBy",
|
|
50640
|
-
item: [
|
|
50656
|
+
item: [item2.getId()],
|
|
50641
50657
|
translate: { x: translateX, y: translateY },
|
|
50642
50658
|
scale: { x: 1, y: 1 }
|
|
50643
50659
|
};
|
|
@@ -50645,14 +50661,14 @@ function getRichTextTranslation({
|
|
|
50645
50661
|
return {
|
|
50646
50662
|
class: "Transformation",
|
|
50647
50663
|
method: "scaleByTranslateBy",
|
|
50648
|
-
item: [
|
|
50664
|
+
item: [item2.getId()],
|
|
50649
50665
|
translate: { x: translateX, y: translateY },
|
|
50650
50666
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50651
50667
|
};
|
|
50652
50668
|
}
|
|
50653
50669
|
}
|
|
50654
50670
|
function getAINodeTranslation({
|
|
50655
|
-
item,
|
|
50671
|
+
item: item2,
|
|
50656
50672
|
isWidth,
|
|
50657
50673
|
isHeight,
|
|
50658
50674
|
matrix,
|
|
@@ -50660,11 +50676,11 @@ function getAINodeTranslation({
|
|
|
50660
50676
|
translateY
|
|
50661
50677
|
}) {
|
|
50662
50678
|
if (isWidth) {
|
|
50663
|
-
|
|
50679
|
+
item2.text.editor.setMaxWidth(item2.text.getWidth() / item2.transformation.getScale().x * matrix.scaleX);
|
|
50664
50680
|
return {
|
|
50665
50681
|
class: "Transformation",
|
|
50666
50682
|
method: "scaleByTranslateBy",
|
|
50667
|
-
item: [
|
|
50683
|
+
item: [item2.getId()],
|
|
50668
50684
|
translate: { x: matrix.translateX, y: 0 },
|
|
50669
50685
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50670
50686
|
};
|
|
@@ -50672,7 +50688,7 @@ function getAINodeTranslation({
|
|
|
50672
50688
|
return {
|
|
50673
50689
|
class: "Transformation",
|
|
50674
50690
|
method: "scaleByTranslateBy",
|
|
50675
|
-
item: [
|
|
50691
|
+
item: [item2.getId()],
|
|
50676
50692
|
translate: { x: translateX, y: translateY },
|
|
50677
50693
|
scale: { x: 1, y: 1 }
|
|
50678
50694
|
};
|
|
@@ -50680,14 +50696,14 @@ function getAINodeTranslation({
|
|
|
50680
50696
|
return {
|
|
50681
50697
|
class: "Transformation",
|
|
50682
50698
|
method: "scaleByTranslateBy",
|
|
50683
|
-
item: [
|
|
50699
|
+
item: [item2.getId()],
|
|
50684
50700
|
translate: { x: translateX, y: translateY },
|
|
50685
50701
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50686
50702
|
};
|
|
50687
50703
|
}
|
|
50688
50704
|
}
|
|
50689
50705
|
function getItemTranslation({
|
|
50690
|
-
item,
|
|
50706
|
+
item: item2,
|
|
50691
50707
|
isWidth,
|
|
50692
50708
|
isHeight,
|
|
50693
50709
|
matrix,
|
|
@@ -50695,22 +50711,22 @@ function getItemTranslation({
|
|
|
50695
50711
|
translateY,
|
|
50696
50712
|
isShiftPressed
|
|
50697
50713
|
}) {
|
|
50698
|
-
if (
|
|
50714
|
+
if (item2 instanceof Sticker && (isWidth || isHeight)) {
|
|
50699
50715
|
return {
|
|
50700
50716
|
class: "Transformation",
|
|
50701
50717
|
method: "scaleByTranslateBy",
|
|
50702
|
-
item: [
|
|
50718
|
+
item: [item2.getId()],
|
|
50703
50719
|
translate: { x: translateX, y: translateY },
|
|
50704
50720
|
scale: { x: 1, y: 1 }
|
|
50705
50721
|
};
|
|
50706
50722
|
} else {
|
|
50707
|
-
if (
|
|
50708
|
-
|
|
50723
|
+
if (item2 instanceof Frame2 && item2.getCanChangeRatio() && isShiftPressed && item2.getFrameType() !== "Custom") {
|
|
50724
|
+
item2.setFrameType("Custom");
|
|
50709
50725
|
}
|
|
50710
50726
|
return {
|
|
50711
50727
|
class: "Transformation",
|
|
50712
50728
|
method: "scaleByTranslateBy",
|
|
50713
|
-
item: [
|
|
50729
|
+
item: [item2.getId()],
|
|
50714
50730
|
translate: { x: translateX, y: translateY },
|
|
50715
50731
|
scale: { x: matrix.scaleX, y: matrix.scaleY }
|
|
50716
50732
|
};
|
|
@@ -50983,11 +50999,11 @@ function transformItems({
|
|
|
50983
50999
|
setSnapCursorPos
|
|
50984
51000
|
}) {
|
|
50985
51001
|
const items = selection.items.list();
|
|
50986
|
-
const includesProportionalItem = items.some((
|
|
51002
|
+
const includesProportionalItem = items.some((item2) => item2.itemType === "Sticker" || item2.itemType === "RichText" || item2.itemType === "AINode" || item2.itemType === "Video" || item2.itemType === "Audio");
|
|
50987
51003
|
if (includesProportionalItem && (isWidth || isHeight)) {
|
|
50988
51004
|
return null;
|
|
50989
51005
|
}
|
|
50990
|
-
const isIncludesFixedFrame = items.some((
|
|
51006
|
+
const isIncludesFixedFrame = items.some((item2) => item2 instanceof Frame2 && !item2.getCanChangeRatio());
|
|
50991
51007
|
const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
|
|
50992
51008
|
const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
|
|
50993
51009
|
if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
|
|
@@ -51065,23 +51081,23 @@ function updateFrameChildren({
|
|
|
51065
51081
|
nestingHighlighter
|
|
51066
51082
|
}) {
|
|
51067
51083
|
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
51068
|
-
board.selection.items.list().forEach((
|
|
51069
|
-
if ("getChildrenIds" in
|
|
51070
|
-
const currMbr =
|
|
51084
|
+
board.selection.items.list().forEach((item2) => {
|
|
51085
|
+
if ("getChildrenIds" in item2 && item2.getChildrenIds()) {
|
|
51086
|
+
const currMbr = item2.getMbr();
|
|
51071
51087
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
51072
51088
|
itemsToCheck.forEach((currItem) => {
|
|
51073
|
-
if (
|
|
51074
|
-
nestingHighlighter.add(
|
|
51089
|
+
if (item2.handleNesting(currItem) && (currItem.parent === "Board" || currItem.parent === item2.getId())) {
|
|
51090
|
+
nestingHighlighter.add(item2, currItem);
|
|
51075
51091
|
} else {
|
|
51076
51092
|
nestingHighlighter.remove(currItem);
|
|
51077
51093
|
}
|
|
51078
51094
|
});
|
|
51079
51095
|
} else {
|
|
51080
51096
|
groups.forEach((group) => {
|
|
51081
|
-
if (group.handleNesting(
|
|
51082
|
-
nestingHighlighter.add(group,
|
|
51097
|
+
if (group.handleNesting(item2)) {
|
|
51098
|
+
nestingHighlighter.add(group, item2);
|
|
51083
51099
|
} else {
|
|
51084
|
-
nestingHighlighter.remove(
|
|
51100
|
+
nestingHighlighter.remove(item2);
|
|
51085
51101
|
}
|
|
51086
51102
|
});
|
|
51087
51103
|
}
|
|
@@ -51149,9 +51165,9 @@ class Transformer extends Tool {
|
|
|
51149
51165
|
const pointer = this.board.pointer;
|
|
51150
51166
|
const camera = this.board.camera;
|
|
51151
51167
|
const items = this.selection.items;
|
|
51152
|
-
const
|
|
51168
|
+
const item2 = items.getSingle();
|
|
51153
51169
|
let resizeType;
|
|
51154
|
-
if (
|
|
51170
|
+
if (item2 && (item2.itemType === "RichText" || item2.itemType === "Sticker")) {
|
|
51155
51171
|
resizeType = getTextResizeType(pointer.point, camera.getScale(), mbr);
|
|
51156
51172
|
} else {
|
|
51157
51173
|
resizeType = getResizeType(pointer.point, camera.getScale(), mbr);
|
|
@@ -51405,8 +51421,8 @@ class SelectionTransformer extends Tool {
|
|
|
51405
51421
|
return;
|
|
51406
51422
|
}
|
|
51407
51423
|
if (this.selection.items.isSingle()) {
|
|
51408
|
-
const
|
|
51409
|
-
if (
|
|
51424
|
+
const item2 = this.selection.items.getSingle();
|
|
51425
|
+
if (item2?.itemType === "Connector") {
|
|
51410
51426
|
this.tool = this.connectorTransformerTool;
|
|
51411
51427
|
return;
|
|
51412
51428
|
} else {
|
|
@@ -51489,16 +51505,16 @@ class BoardSelection {
|
|
|
51489
51505
|
this.quickAddButtons = getQuickAddButtons(this, board);
|
|
51490
51506
|
}
|
|
51491
51507
|
serialize() {
|
|
51492
|
-
const selectedItems = this.items.list().map((
|
|
51508
|
+
const selectedItems = this.items.list().map((item2) => item2.getId());
|
|
51493
51509
|
return JSON.stringify(selectedItems);
|
|
51494
51510
|
}
|
|
51495
51511
|
deserialize(serializedData) {
|
|
51496
51512
|
const selectedItems = JSON.parse(serializedData);
|
|
51497
51513
|
this.removeAll();
|
|
51498
51514
|
selectedItems.forEach((itemId) => {
|
|
51499
|
-
const
|
|
51500
|
-
if (
|
|
51501
|
-
this.items.add(
|
|
51515
|
+
const item2 = this.board.items.getById(itemId);
|
|
51516
|
+
if (item2) {
|
|
51517
|
+
this.items.add(item2);
|
|
51502
51518
|
}
|
|
51503
51519
|
});
|
|
51504
51520
|
}
|
|
@@ -51576,19 +51592,19 @@ class BoardSelection {
|
|
|
51576
51592
|
this.updateQueue.clear();
|
|
51577
51593
|
safeRequestAnimationFrame(this.updateScheduledObservers);
|
|
51578
51594
|
};
|
|
51579
|
-
itemObserver = (
|
|
51595
|
+
itemObserver = (item2) => {
|
|
51580
51596
|
if (!this.shouldPublish) {
|
|
51581
51597
|
return;
|
|
51582
51598
|
}
|
|
51583
51599
|
this.subject.publish(this);
|
|
51584
|
-
this.itemSubject.publish(
|
|
51600
|
+
this.itemSubject.publish(item2);
|
|
51585
51601
|
};
|
|
51586
51602
|
decoratedItemObserver = this.decorateObserverToScheduleUpdate(this.itemObserver);
|
|
51587
51603
|
add(value) {
|
|
51588
51604
|
this.items.add(value);
|
|
51589
51605
|
if (Array.isArray(value)) {
|
|
51590
|
-
for (const
|
|
51591
|
-
|
|
51606
|
+
for (const item2 of value) {
|
|
51607
|
+
item2.subject.subscribe(this.itemObserver);
|
|
51592
51608
|
}
|
|
51593
51609
|
} else {
|
|
51594
51610
|
value.subject.subscribe(this.itemObserver);
|
|
@@ -51597,15 +51613,15 @@ class BoardSelection {
|
|
|
51597
51613
|
this.itemsSubject.publish([]);
|
|
51598
51614
|
}
|
|
51599
51615
|
addAll() {
|
|
51600
|
-
const items = this.board.items.listAll().filter((
|
|
51616
|
+
const items = this.board.items.listAll().filter((item2) => !item2.transformation.isLocked);
|
|
51601
51617
|
this.add(items);
|
|
51602
51618
|
this.setContext("SelectByRect");
|
|
51603
51619
|
}
|
|
51604
51620
|
remove(value) {
|
|
51605
51621
|
this.items.remove(value);
|
|
51606
51622
|
if (Array.isArray(value)) {
|
|
51607
|
-
for (const
|
|
51608
|
-
|
|
51623
|
+
for (const item2 of value) {
|
|
51624
|
+
item2.subject.unsubscribe(this.itemObserver);
|
|
51609
51625
|
}
|
|
51610
51626
|
} else {
|
|
51611
51627
|
value.subject.unsubscribe(this.itemObserver);
|
|
@@ -51699,11 +51715,11 @@ class BoardSelection {
|
|
|
51699
51715
|
if (!this.items.isSingle()) {
|
|
51700
51716
|
return;
|
|
51701
51717
|
}
|
|
51702
|
-
const
|
|
51703
|
-
if (!
|
|
51718
|
+
const item2 = this.items.getSingle();
|
|
51719
|
+
if (!item2) {
|
|
51704
51720
|
return;
|
|
51705
51721
|
}
|
|
51706
|
-
const text5 =
|
|
51722
|
+
const text5 = item2.getRichText();
|
|
51707
51723
|
if (!text5) {
|
|
51708
51724
|
return;
|
|
51709
51725
|
}
|
|
@@ -51714,7 +51730,7 @@ class BoardSelection {
|
|
|
51714
51730
|
if (shouldReplace || moveCursorToEnd) {
|
|
51715
51731
|
text5.editor.moveCursorToEndOfTheText();
|
|
51716
51732
|
}
|
|
51717
|
-
this.setTextToEdit(
|
|
51733
|
+
this.setTextToEdit(item2);
|
|
51718
51734
|
this.setContext("EditTextUnderPointer");
|
|
51719
51735
|
if (shouldSelect) {
|
|
51720
51736
|
text5.editor.selectWholeText();
|
|
@@ -51724,13 +51740,13 @@ class BoardSelection {
|
|
|
51724
51740
|
editUnderPointer() {
|
|
51725
51741
|
this.removeAll();
|
|
51726
51742
|
const stack = this.board.items.getUnderPointer();
|
|
51727
|
-
const
|
|
51728
|
-
if (
|
|
51729
|
-
this.add(
|
|
51743
|
+
const item2 = stack.pop();
|
|
51744
|
+
if (item2) {
|
|
51745
|
+
this.add(item2);
|
|
51730
51746
|
this.setTextToEdit(undefined);
|
|
51731
|
-
const text5 =
|
|
51747
|
+
const text5 = item2.getRichText();
|
|
51732
51748
|
if (text5) {
|
|
51733
|
-
this.setTextToEdit(
|
|
51749
|
+
this.setTextToEdit(item2);
|
|
51734
51750
|
text5.editor.selectWholeText();
|
|
51735
51751
|
this.board.items.subject.publish(this.board.items);
|
|
51736
51752
|
}
|
|
@@ -51739,26 +51755,26 @@ class BoardSelection {
|
|
|
51739
51755
|
this.setContext("None");
|
|
51740
51756
|
}
|
|
51741
51757
|
}
|
|
51742
|
-
setTextToEdit(
|
|
51758
|
+
setTextToEdit(item2) {
|
|
51743
51759
|
if (this.textToEdit) {
|
|
51744
51760
|
this.textToEdit.updateElement();
|
|
51745
51761
|
this.textToEdit.enableRender();
|
|
51746
51762
|
}
|
|
51747
|
-
if (!(
|
|
51763
|
+
if (!(item2 && item2.getRichText())) {
|
|
51748
51764
|
this.textToEdit = undefined;
|
|
51749
51765
|
return;
|
|
51750
51766
|
}
|
|
51751
|
-
const text5 =
|
|
51767
|
+
const text5 = item2.getRichText();
|
|
51752
51768
|
if (!text5) {
|
|
51753
51769
|
return;
|
|
51754
51770
|
}
|
|
51755
51771
|
if (text5.isEmpty()) {
|
|
51756
|
-
const textColor = tempStorage.getFontColor(
|
|
51757
|
-
const textSize = tempStorage.getFontSize(
|
|
51758
|
-
const highlightColor = tempStorage.getFontHighlight(
|
|
51759
|
-
const styles = tempStorage.getFontStyles(
|
|
51760
|
-
const horizontalAlignment = tempStorage.getHorizontalAlignment(
|
|
51761
|
-
const verticalAlignment = tempStorage.getVerticalAlignment(
|
|
51772
|
+
const textColor = tempStorage.getFontColor(item2.itemType);
|
|
51773
|
+
const textSize = tempStorage.getFontSize(item2.itemType);
|
|
51774
|
+
const highlightColor = tempStorage.getFontHighlight(item2.itemType);
|
|
51775
|
+
const styles = tempStorage.getFontStyles(item2.itemType);
|
|
51776
|
+
const horizontalAlignment = tempStorage.getHorizontalAlignment(item2.itemType);
|
|
51777
|
+
const verticalAlignment = tempStorage.getVerticalAlignment(item2.itemType);
|
|
51762
51778
|
if (textColor) {
|
|
51763
51779
|
text5.setSelectionFontColor(textColor, "None");
|
|
51764
51780
|
}
|
|
@@ -51766,7 +51782,7 @@ class BoardSelection {
|
|
|
51766
51782
|
this.emit({
|
|
51767
51783
|
class: "RichText",
|
|
51768
51784
|
method: "setFontSize",
|
|
51769
|
-
item: [
|
|
51785
|
+
item: [item2.getId()],
|
|
51770
51786
|
fontSize: textSize,
|
|
51771
51787
|
context: this.getContext()
|
|
51772
51788
|
});
|
|
@@ -51778,10 +51794,10 @@ class BoardSelection {
|
|
|
51778
51794
|
const stylesArr = styles;
|
|
51779
51795
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
51780
51796
|
}
|
|
51781
|
-
if (horizontalAlignment && !(
|
|
51797
|
+
if (horizontalAlignment && !(item2 instanceof Sticker)) {
|
|
51782
51798
|
text5.setSelectionHorisontalAlignment(horizontalAlignment);
|
|
51783
51799
|
}
|
|
51784
|
-
if (verticalAlignment && !(
|
|
51800
|
+
if (verticalAlignment && !(item2 instanceof Sticker)) {
|
|
51785
51801
|
this.setVerticalAlignment(verticalAlignment);
|
|
51786
51802
|
}
|
|
51787
51803
|
}
|
|
@@ -51814,8 +51830,8 @@ class BoardSelection {
|
|
|
51814
51830
|
}
|
|
51815
51831
|
selectEnclosedOrCrossedBy(rect) {
|
|
51816
51832
|
this.removeAll();
|
|
51817
|
-
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51818
|
-
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51833
|
+
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((item2) => !item2.transformation.isLocked);
|
|
51834
|
+
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((item2) => (!(item2 instanceof Frame2) || enclosedFrames.includes(item2)) && !item2.transformation.isLocked);
|
|
51819
51835
|
if (list6.length !== 0) {
|
|
51820
51836
|
this.add(list6);
|
|
51821
51837
|
this.setContext("SelectByRect");
|
|
@@ -51829,14 +51845,14 @@ class BoardSelection {
|
|
|
51829
51845
|
canChangeText() {
|
|
51830
51846
|
return Boolean(this.items.isSingle() && this.items.getSingle()?.getRichText());
|
|
51831
51847
|
}
|
|
51832
|
-
handleItemCopy(
|
|
51833
|
-
const serializedData =
|
|
51834
|
-
const zIndex = this.board.items.index.getZIndex(
|
|
51835
|
-
if (
|
|
51848
|
+
handleItemCopy(item2, copiedItemsMap) {
|
|
51849
|
+
const serializedData = item2.serialize(true);
|
|
51850
|
+
const zIndex = this.board.items.index.getZIndex(item2);
|
|
51851
|
+
if (item2.itemType === "Comment") {
|
|
51836
51852
|
return;
|
|
51837
51853
|
}
|
|
51838
|
-
if (
|
|
51839
|
-
const connector =
|
|
51854
|
+
if (item2.itemType === "Connector" && serializedData.itemType === "Connector") {
|
|
51855
|
+
const connector = item2;
|
|
51840
51856
|
const startPoint = connector.getStartPoint();
|
|
51841
51857
|
const endPoint = connector.getEndPoint();
|
|
51842
51858
|
const startItemId = startPoint.pointType !== "Board" ? startPoint.item.getId() : null;
|
|
@@ -51852,19 +51868,19 @@ class BoardSelection {
|
|
|
51852
51868
|
serializedData.endPoint = new BoardPoint(endPoint.x, endPoint.y).serialize();
|
|
51853
51869
|
}
|
|
51854
51870
|
}
|
|
51855
|
-
const textItem =
|
|
51871
|
+
const textItem = item2.getRichText()?.getTextString();
|
|
51856
51872
|
const copyText = conf.i18n.t("frame.copy");
|
|
51857
51873
|
const isCopyTextExist = textItem?.includes(copyText);
|
|
51858
|
-
const isChangeCopiedFrameText =
|
|
51874
|
+
const isChangeCopiedFrameText = item2.itemType === "Frame" && serializedData.itemType === "Frame" && textItem !== "" && !isCopyTextExist;
|
|
51859
51875
|
if (isChangeCopiedFrameText) {
|
|
51860
51876
|
const copiedFrameText = copyText + (textItem || serializedData.text?.placeholderText);
|
|
51861
|
-
|
|
51862
|
-
|
|
51863
|
-
serializedData.text =
|
|
51864
|
-
|
|
51865
|
-
|
|
51877
|
+
item2.getRichText()?.editor.clearText();
|
|
51878
|
+
item2.getRichText()?.editor.addText(copiedFrameText);
|
|
51879
|
+
serializedData.text = item2.getRichText()?.serialize();
|
|
51880
|
+
item2.getRichText()?.editor.clearText();
|
|
51881
|
+
item2.getRichText()?.editor.addText(textItem || "");
|
|
51866
51882
|
}
|
|
51867
|
-
copiedItemsMap[
|
|
51883
|
+
copiedItemsMap[item2.getId()] = { ...serializedData, zIndex };
|
|
51868
51884
|
}
|
|
51869
51885
|
copy(skipImageBlobCopy) {
|
|
51870
51886
|
const copiedItemsMap = {};
|
|
@@ -51873,12 +51889,12 @@ class BoardSelection {
|
|
|
51873
51889
|
this.handleItemCopy(single, copiedItemsMap);
|
|
51874
51890
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
51875
51891
|
}
|
|
51876
|
-
this.list().forEach((
|
|
51877
|
-
this.handleItemCopy(
|
|
51892
|
+
this.list().forEach((item2) => {
|
|
51893
|
+
this.handleItemCopy(item2, copiedItemsMap);
|
|
51878
51894
|
});
|
|
51879
|
-
this.list().flatMap((
|
|
51880
|
-
if (
|
|
51881
|
-
return
|
|
51895
|
+
this.list().flatMap((item2) => {
|
|
51896
|
+
if (item2 instanceof Frame2) {
|
|
51897
|
+
return item2.getChildrenIds();
|
|
51882
51898
|
}
|
|
51883
51899
|
return [];
|
|
51884
51900
|
}).forEach((id) => {
|
|
@@ -51906,11 +51922,11 @@ class BoardSelection {
|
|
|
51906
51922
|
let maxRichText = null;
|
|
51907
51923
|
let minRichText = null;
|
|
51908
51924
|
const itemType = items[0].itemType;
|
|
51909
|
-
for (const
|
|
51910
|
-
if (
|
|
51925
|
+
for (const item2 of items) {
|
|
51926
|
+
if (item2.itemType !== itemType) {
|
|
51911
51927
|
return null;
|
|
51912
51928
|
}
|
|
51913
|
-
const richText =
|
|
51929
|
+
const richText = item2.getRichText();
|
|
51914
51930
|
if (richText) {
|
|
51915
51931
|
if (!maxRichText || richText.getFontSize() > maxRichText.getFontSize()) {
|
|
51916
51932
|
maxRichText = richText;
|
|
@@ -52016,22 +52032,22 @@ class BoardSelection {
|
|
|
52016
52032
|
}
|
|
52017
52033
|
nestSelectedItems(unselectedItem, checkFrames = true) {
|
|
52018
52034
|
const selected = this.board.selection.items.list();
|
|
52019
|
-
if (unselectedItem && !selected.find((
|
|
52035
|
+
if (unselectedItem && !selected.find((item2) => item2.getId() === unselectedItem.getId())) {
|
|
52020
52036
|
selected.push(unselectedItem);
|
|
52021
52037
|
}
|
|
52022
|
-
const selectedMbr = selected.reduce((acc,
|
|
52038
|
+
const selectedMbr = selected.reduce((acc, item2) => {
|
|
52023
52039
|
if (!acc) {
|
|
52024
|
-
return
|
|
52040
|
+
return item2.getMbr();
|
|
52025
52041
|
}
|
|
52026
|
-
return acc.combine(
|
|
52042
|
+
return acc.combine(item2.getMbr());
|
|
52027
52043
|
}, undefined);
|
|
52028
52044
|
if (selectedMbr) {
|
|
52029
|
-
const selectedMap = Object.fromEntries(selected.map((
|
|
52045
|
+
const selectedMap = Object.fromEntries(selected.map((item2) => [item2.getId(), { item: item2, nested: false }]));
|
|
52030
52046
|
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
52031
52047
|
enclosedGroups.forEach((group) => {
|
|
52032
|
-
selected.forEach((
|
|
52033
|
-
if (group.handleNesting(
|
|
52034
|
-
selectedMap[
|
|
52048
|
+
selected.forEach((item2) => {
|
|
52049
|
+
if (group.handleNesting(item2)) {
|
|
52050
|
+
selectedMap[item2.getId()].nested = group;
|
|
52035
52051
|
}
|
|
52036
52052
|
});
|
|
52037
52053
|
});
|
|
@@ -52055,11 +52071,11 @@ class BoardSelection {
|
|
|
52055
52071
|
if (childrenIds && checkFrames) {
|
|
52056
52072
|
const currGroup = val.item;
|
|
52057
52073
|
const currMbr = currGroup.getMbr();
|
|
52058
|
-
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((
|
|
52059
|
-
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
52074
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item2) => !!item2);
|
|
52075
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item2) => item2.parent === "Board" || item2.parent === currGroup.getId());
|
|
52060
52076
|
const uniqueItems = new Set;
|
|
52061
|
-
const toCheck = [...children, ...underGroup].filter((
|
|
52062
|
-
const id =
|
|
52077
|
+
const toCheck = [...children, ...underGroup].filter((item2) => {
|
|
52078
|
+
const id = item2.getId();
|
|
52063
52079
|
if (uniqueItems.has(id)) {
|
|
52064
52080
|
return false;
|
|
52065
52081
|
}
|
|
@@ -52100,8 +52116,8 @@ class BoardSelection {
|
|
|
52100
52116
|
addItemToTranslation(childId);
|
|
52101
52117
|
}
|
|
52102
52118
|
}
|
|
52103
|
-
const createTranslationWithComments = (
|
|
52104
|
-
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() ===
|
|
52119
|
+
const createTranslationWithComments = (item2) => {
|
|
52120
|
+
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item2.getId());
|
|
52105
52121
|
for (const comment2 of followedComments) {
|
|
52106
52122
|
translation[comment2.getId()] = {
|
|
52107
52123
|
class: "Transformation",
|
|
@@ -52162,21 +52178,21 @@ class BoardSelection {
|
|
|
52162
52178
|
newData: { borderColor }
|
|
52163
52179
|
};
|
|
52164
52180
|
const operations2 = {};
|
|
52165
|
-
this.items.list().forEach((
|
|
52166
|
-
if (!operations2[
|
|
52181
|
+
this.items.list().forEach((item2) => {
|
|
52182
|
+
if (!operations2[item2.itemType]) {
|
|
52167
52183
|
const operationCopy = { ...operation };
|
|
52168
|
-
if (
|
|
52184
|
+
if (item2.itemType === "Connector") {
|
|
52169
52185
|
operationCopy.method = "setLineColor";
|
|
52170
52186
|
operationCopy.lineColor = borderColor;
|
|
52171
|
-
} else if (
|
|
52187
|
+
} else if (item2.itemType === "Drawing") {
|
|
52172
52188
|
operationCopy.method = "setStrokeColor";
|
|
52173
52189
|
operationCopy.color = borderColor;
|
|
52174
52190
|
} else {
|
|
52175
52191
|
operationCopy.borderColor = borderColor;
|
|
52176
52192
|
}
|
|
52177
|
-
operations2[
|
|
52193
|
+
operations2[item2.itemType] = { ...operationCopy, class: item2.itemType, item: [item2.getId()] };
|
|
52178
52194
|
} else {
|
|
52179
|
-
operations2[
|
|
52195
|
+
operations2[item2.itemType].item.push(item2.getId());
|
|
52180
52196
|
}
|
|
52181
52197
|
});
|
|
52182
52198
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52191,13 +52207,13 @@ class BoardSelection {
|
|
|
52191
52207
|
newData: { borderWidth: width2 }
|
|
52192
52208
|
};
|
|
52193
52209
|
const operations2 = {};
|
|
52194
|
-
this.items.list().forEach((
|
|
52195
|
-
if (!operations2[
|
|
52210
|
+
this.items.list().forEach((item2) => {
|
|
52211
|
+
if (!operations2[item2.itemType]) {
|
|
52196
52212
|
const operationCopy = { ...operation };
|
|
52197
|
-
if (
|
|
52213
|
+
if (item2.itemType === "Connector") {
|
|
52198
52214
|
operationCopy.method = "setLineWidth";
|
|
52199
52215
|
operationCopy.lineWidth = width2;
|
|
52200
|
-
} else if (
|
|
52216
|
+
} else if (item2.itemType === "Drawing") {
|
|
52201
52217
|
operationCopy.method = "setStrokeWidth";
|
|
52202
52218
|
operationCopy.width = width2;
|
|
52203
52219
|
operationCopy.prevWidth = this.getStrokeWidth();
|
|
@@ -52205,9 +52221,9 @@ class BoardSelection {
|
|
|
52205
52221
|
operationCopy.borderWidth = width2;
|
|
52206
52222
|
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
52207
52223
|
}
|
|
52208
|
-
operations2[
|
|
52224
|
+
operations2[item2.itemType] = { ...operationCopy, class: item2.itemType, item: [item2.getId()] };
|
|
52209
52225
|
} else {
|
|
52210
|
-
operations2[
|
|
52226
|
+
operations2[item2.itemType].item.push(item2.getId());
|
|
52211
52227
|
}
|
|
52212
52228
|
});
|
|
52213
52229
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52223,11 +52239,11 @@ class BoardSelection {
|
|
|
52223
52239
|
newData: { backgroundColor }
|
|
52224
52240
|
};
|
|
52225
52241
|
const operations2 = {};
|
|
52226
|
-
this.items.list().forEach((
|
|
52227
|
-
if (!operations2[
|
|
52228
|
-
operations2[
|
|
52242
|
+
this.items.list().forEach((item2) => {
|
|
52243
|
+
if (!operations2[item2.itemType]) {
|
|
52244
|
+
operations2[item2.itemType] = { ...operation, class: item2.itemType, item: [item2.getId()] };
|
|
52229
52245
|
} else {
|
|
52230
|
-
operations2[
|
|
52246
|
+
operations2[item2.itemType].item.push(item2.getId());
|
|
52231
52247
|
}
|
|
52232
52248
|
});
|
|
52233
52249
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52251,9 +52267,9 @@ class BoardSelection {
|
|
|
52251
52267
|
}
|
|
52252
52268
|
setFrameType(frameType) {
|
|
52253
52269
|
const items = this.items.list();
|
|
52254
|
-
items.forEach((
|
|
52255
|
-
if (
|
|
52256
|
-
|
|
52270
|
+
items.forEach((item2) => {
|
|
52271
|
+
if (item2 instanceof Frame2) {
|
|
52272
|
+
item2.setFrameType(frameType);
|
|
52257
52273
|
}
|
|
52258
52274
|
});
|
|
52259
52275
|
}
|
|
@@ -52272,21 +52288,21 @@ class BoardSelection {
|
|
|
52272
52288
|
setFontSize(size) {
|
|
52273
52289
|
const fontSize = size === "auto" ? size : toFiniteNumber(size);
|
|
52274
52290
|
const itemsOps = [];
|
|
52275
|
-
for (const
|
|
52276
|
-
const text5 =
|
|
52291
|
+
for (const item2 of this.items.list()) {
|
|
52292
|
+
const text5 = item2.getRichText();
|
|
52277
52293
|
if (!text5) {
|
|
52278
52294
|
continue;
|
|
52279
52295
|
}
|
|
52280
52296
|
const ops = text5.setSelectionFontSize(fontSize, this.context);
|
|
52281
52297
|
itemsOps.push({
|
|
52282
|
-
item:
|
|
52298
|
+
item: item2.getId(),
|
|
52283
52299
|
selection: text5.editor.getSelection(),
|
|
52284
52300
|
ops
|
|
52285
52301
|
});
|
|
52286
|
-
if (
|
|
52287
|
-
tempStorage.remove(`fontSize_${
|
|
52288
|
-
} else if (
|
|
52289
|
-
tempStorage.setFontSize(
|
|
52302
|
+
if (item2.itemType === "Sticker" && fontSize === "auto") {
|
|
52303
|
+
tempStorage.remove(`fontSize_${item2.itemType}`);
|
|
52304
|
+
} else if (item2.itemType !== "AINode") {
|
|
52305
|
+
tempStorage.setFontSize(item2.itemType, fontSize);
|
|
52290
52306
|
}
|
|
52291
52307
|
}
|
|
52292
52308
|
const emptyOps = itemsOps.filter((op) => !op.ops.length);
|
|
@@ -52309,8 +52325,8 @@ class BoardSelection {
|
|
|
52309
52325
|
setFontStyle(fontStyle) {
|
|
52310
52326
|
const isMultiple = !this.items.isSingle();
|
|
52311
52327
|
const itemsOps = [];
|
|
52312
|
-
for (const
|
|
52313
|
-
const text5 =
|
|
52328
|
+
for (const item2 of this.items.list()) {
|
|
52329
|
+
const text5 = item2.getRichText();
|
|
52314
52330
|
if (!text5) {
|
|
52315
52331
|
continue;
|
|
52316
52332
|
}
|
|
@@ -52319,12 +52335,12 @@ class BoardSelection {
|
|
|
52319
52335
|
}
|
|
52320
52336
|
const ops = text5.setSelectionFontStyle(fontStyle, this.context);
|
|
52321
52337
|
itemsOps.push({
|
|
52322
|
-
item:
|
|
52338
|
+
item: item2.getId(),
|
|
52323
52339
|
selection: text5.editor.getSelection(),
|
|
52324
52340
|
ops
|
|
52325
52341
|
});
|
|
52326
|
-
if (
|
|
52327
|
-
tempStorage.setFontStyles(
|
|
52342
|
+
if (item2.itemType !== "AINode") {
|
|
52343
|
+
tempStorage.setFontStyles(item2.itemType, text5.getFontStyles());
|
|
52328
52344
|
}
|
|
52329
52345
|
}
|
|
52330
52346
|
this.emitApplied({
|
|
@@ -52336,8 +52352,8 @@ class BoardSelection {
|
|
|
52336
52352
|
setFontColor(fontColor) {
|
|
52337
52353
|
const isMultiple = !this.items.isSingle();
|
|
52338
52354
|
const itemsOps = [];
|
|
52339
|
-
for (const
|
|
52340
|
-
const text5 =
|
|
52355
|
+
for (const item2 of this.items.list()) {
|
|
52356
|
+
const text5 = item2.getRichText();
|
|
52341
52357
|
if (!text5) {
|
|
52342
52358
|
continue;
|
|
52343
52359
|
}
|
|
@@ -52346,11 +52362,11 @@ class BoardSelection {
|
|
|
52346
52362
|
}
|
|
52347
52363
|
const ops = text5.setSelectionFontColor(fontColor, this.context);
|
|
52348
52364
|
itemsOps.push({
|
|
52349
|
-
item:
|
|
52365
|
+
item: item2.getId(),
|
|
52350
52366
|
selection: text5.editor.getSelection(),
|
|
52351
52367
|
ops
|
|
52352
52368
|
});
|
|
52353
|
-
tempStorage.setFontColor(
|
|
52369
|
+
tempStorage.setFontColor(item2.itemType, fontColor);
|
|
52354
52370
|
}
|
|
52355
52371
|
this.emitApplied({
|
|
52356
52372
|
class: "RichText",
|
|
@@ -52379,8 +52395,8 @@ class BoardSelection {
|
|
|
52379
52395
|
setFontHighlight(fontHighlight) {
|
|
52380
52396
|
const isMultiple = !this.items.isSingle();
|
|
52381
52397
|
const itemsOps = [];
|
|
52382
|
-
for (const
|
|
52383
|
-
const text5 =
|
|
52398
|
+
for (const item2 of this.items.list()) {
|
|
52399
|
+
const text5 = item2.getRichText();
|
|
52384
52400
|
if (!text5) {
|
|
52385
52401
|
continue;
|
|
52386
52402
|
}
|
|
@@ -52389,12 +52405,12 @@ class BoardSelection {
|
|
|
52389
52405
|
}
|
|
52390
52406
|
const ops = text5.setSelectionFontHighlight(fontHighlight, this.context);
|
|
52391
52407
|
itemsOps.push({
|
|
52392
|
-
item:
|
|
52408
|
+
item: item2.getId(),
|
|
52393
52409
|
selection: text5.editor.getSelection(),
|
|
52394
52410
|
ops
|
|
52395
52411
|
});
|
|
52396
|
-
if (
|
|
52397
|
-
tempStorage.setFontHighlight(
|
|
52412
|
+
if (item2.itemType !== "AINode") {
|
|
52413
|
+
tempStorage.setFontHighlight(item2.itemType, fontHighlight);
|
|
52398
52414
|
}
|
|
52399
52415
|
}
|
|
52400
52416
|
this.emitApplied({
|
|
@@ -52406,8 +52422,8 @@ class BoardSelection {
|
|
|
52406
52422
|
setHorisontalAlignment(horisontalAlignment) {
|
|
52407
52423
|
const isMultiple = !this.items.isSingle();
|
|
52408
52424
|
const itemsOps = [];
|
|
52409
|
-
for (const
|
|
52410
|
-
const text5 =
|
|
52425
|
+
for (const item2 of this.items.list()) {
|
|
52426
|
+
const text5 = item2.getRichText();
|
|
52411
52427
|
if (!text5) {
|
|
52412
52428
|
continue;
|
|
52413
52429
|
}
|
|
@@ -52416,11 +52432,11 @@ class BoardSelection {
|
|
|
52416
52432
|
}
|
|
52417
52433
|
const ops = text5.setSelectionHorisontalAlignment(horisontalAlignment, this.context);
|
|
52418
52434
|
itemsOps.push({
|
|
52419
|
-
item:
|
|
52435
|
+
item: item2.getId(),
|
|
52420
52436
|
selection: text5.editor.getSelection(),
|
|
52421
52437
|
ops
|
|
52422
52438
|
});
|
|
52423
|
-
tempStorage.setHorizontalAlignment(
|
|
52439
|
+
tempStorage.setHorizontalAlignment(item2.itemType, horisontalAlignment);
|
|
52424
52440
|
}
|
|
52425
52441
|
this.emitApplied({
|
|
52426
52442
|
class: "RichText",
|
|
@@ -52436,23 +52452,23 @@ class BoardSelection {
|
|
|
52436
52452
|
verticalAlignment
|
|
52437
52453
|
});
|
|
52438
52454
|
if (this.items.isSingle()) {
|
|
52439
|
-
const
|
|
52440
|
-
if (!
|
|
52455
|
+
const item2 = this.items.getSingle();
|
|
52456
|
+
if (!item2) {
|
|
52441
52457
|
return;
|
|
52442
52458
|
}
|
|
52443
|
-
const text5 =
|
|
52459
|
+
const text5 = item2.getRichText();
|
|
52444
52460
|
if (!text5) {
|
|
52445
52461
|
return;
|
|
52446
52462
|
}
|
|
52447
|
-
tempStorage.setVerticalAlignment(
|
|
52448
|
-
if (
|
|
52449
|
-
|
|
52463
|
+
tempStorage.setVerticalAlignment(item2.itemType, verticalAlignment);
|
|
52464
|
+
if (item2 instanceof RichText) {
|
|
52465
|
+
item2.setEditorFocus(this.context);
|
|
52450
52466
|
}
|
|
52451
52467
|
text5.setEditorFocus(this.context);
|
|
52452
52468
|
}
|
|
52453
52469
|
}
|
|
52454
52470
|
removeFromBoard() {
|
|
52455
|
-
const isLocked = this.items.list().some((
|
|
52471
|
+
const isLocked = this.items.list().some((item2) => item2.transformation.isLocked);
|
|
52456
52472
|
if (isLocked) {
|
|
52457
52473
|
return;
|
|
52458
52474
|
}
|
|
@@ -52475,7 +52491,7 @@ class BoardSelection {
|
|
|
52475
52491
|
}
|
|
52476
52492
|
getIsLockedSelection() {
|
|
52477
52493
|
const items = this.list();
|
|
52478
|
-
return items.some((
|
|
52494
|
+
return items.some((item2) => item2.transformation.isLocked);
|
|
52479
52495
|
}
|
|
52480
52496
|
isLocked() {
|
|
52481
52497
|
return false;
|
|
@@ -52502,9 +52518,9 @@ class BoardSelection {
|
|
|
52502
52518
|
}
|
|
52503
52519
|
async duplicate() {
|
|
52504
52520
|
const mediaIds = [];
|
|
52505
|
-
this.items.list().forEach((
|
|
52506
|
-
if ("getStorageId" in
|
|
52507
|
-
const storageId =
|
|
52521
|
+
this.items.list().forEach((item2) => {
|
|
52522
|
+
if ("getStorageId" in item2) {
|
|
52523
|
+
const storageId = item2.getStorageId();
|
|
52508
52524
|
if (storageId) {
|
|
52509
52525
|
mediaIds.push(storageId);
|
|
52510
52526
|
}
|
|
@@ -52514,7 +52530,7 @@ class BoardSelection {
|
|
|
52514
52530
|
if (!canDuplicate) {
|
|
52515
52531
|
return;
|
|
52516
52532
|
}
|
|
52517
|
-
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_,
|
|
52533
|
+
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_, item2]) => item2.itemType !== "Group"));
|
|
52518
52534
|
this.board.duplicate(filteredItemMap);
|
|
52519
52535
|
this.setContext("EditUnderPointer");
|
|
52520
52536
|
}
|
|
@@ -52548,10 +52564,10 @@ class BoardSelection {
|
|
|
52548
52564
|
lastAssistantMessageId
|
|
52549
52565
|
};
|
|
52550
52566
|
}
|
|
52551
|
-
renderItemMbr(context,
|
|
52552
|
-
const mbr =
|
|
52567
|
+
renderItemMbr(context, item2, customScale) {
|
|
52568
|
+
const mbr = item2.getMbr();
|
|
52553
52569
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
52554
|
-
const selectionColor =
|
|
52570
|
+
const selectionColor = item2.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
52555
52571
|
mbr.borderColor = selectionColor;
|
|
52556
52572
|
mbr.render(context);
|
|
52557
52573
|
}
|
|
@@ -52567,8 +52583,8 @@ class BoardSelection {
|
|
|
52567
52583
|
}
|
|
52568
52584
|
if (!this.transformationRenderBlock) {
|
|
52569
52585
|
if (this.shouldRenderItemsMbr) {
|
|
52570
|
-
for (const
|
|
52571
|
-
this.renderItemMbr(context,
|
|
52586
|
+
for (const item2 of this.items.list()) {
|
|
52587
|
+
this.renderItemMbr(context, item2);
|
|
52572
52588
|
}
|
|
52573
52589
|
}
|
|
52574
52590
|
this.tool.render(context);
|
|
@@ -52580,7 +52596,7 @@ class BoardSelection {
|
|
|
52580
52596
|
if (single && single instanceof AINode) {
|
|
52581
52597
|
const contextItemsIds = single.getContextItems();
|
|
52582
52598
|
if (contextItemsIds.length) {
|
|
52583
|
-
const newContextItems = this.board.items.listAll().filter((
|
|
52599
|
+
const newContextItems = this.board.items.listAll().filter((item2) => contextItemsIds.includes(item2.getId()));
|
|
52584
52600
|
contextItems.push(...newContextItems);
|
|
52585
52601
|
}
|
|
52586
52602
|
}
|
|
@@ -52598,15 +52614,15 @@ class BoardSelection {
|
|
|
52598
52614
|
}
|
|
52599
52615
|
}
|
|
52600
52616
|
}
|
|
52601
|
-
contextItems.forEach((
|
|
52602
|
-
if (
|
|
52603
|
-
const path2 =
|
|
52617
|
+
contextItems.forEach((item2) => {
|
|
52618
|
+
if (item2 instanceof AINode) {
|
|
52619
|
+
const path2 = item2.getPath();
|
|
52604
52620
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
52605
52621
|
path2.setBorderWidth(2);
|
|
52606
52622
|
path2.setBackgroundColor("none");
|
|
52607
52623
|
path2.render(context);
|
|
52608
52624
|
} else {
|
|
52609
|
-
const itemRect =
|
|
52625
|
+
const itemRect = item2.getMbr();
|
|
52610
52626
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
52611
52627
|
itemRect.strokeWidth = 2;
|
|
52612
52628
|
itemRect.render(context);
|
|
@@ -53107,16 +53123,16 @@ class Board {
|
|
|
53107
53123
|
applyBoardOperation(op) {
|
|
53108
53124
|
switch (op.method) {
|
|
53109
53125
|
case "moveToZIndex": {
|
|
53110
|
-
const
|
|
53111
|
-
if (!
|
|
53126
|
+
const item2 = this.index.getById(op.item);
|
|
53127
|
+
if (!item2) {
|
|
53112
53128
|
return;
|
|
53113
53129
|
}
|
|
53114
|
-
return this.index.moveToZIndex(
|
|
53130
|
+
return this.index.moveToZIndex(item2, op.zIndex);
|
|
53115
53131
|
}
|
|
53116
53132
|
case "moveManyToZIndex": {
|
|
53117
53133
|
for (const id in op.item) {
|
|
53118
|
-
const
|
|
53119
|
-
if (!
|
|
53134
|
+
const item2 = this.items.getById(id);
|
|
53135
|
+
if (!item2) {
|
|
53120
53136
|
delete op.item.id;
|
|
53121
53137
|
}
|
|
53122
53138
|
}
|
|
@@ -53138,11 +53154,11 @@ class Board {
|
|
|
53138
53154
|
}
|
|
53139
53155
|
return this.index.moveSecondAfterFirst(first, second);
|
|
53140
53156
|
case "bringToFront": {
|
|
53141
|
-
const items = op.item.map((
|
|
53157
|
+
const items = op.item.map((item2) => this.items.getById(item2)).filter((item2) => item2 !== undefined);
|
|
53142
53158
|
return this.index.bringManyToFront(items);
|
|
53143
53159
|
}
|
|
53144
53160
|
case "sendToBack": {
|
|
53145
|
-
const items = op.item.map((
|
|
53161
|
+
const items = op.item.map((item2) => this.items.getById(item2)).filter((item2) => item2 !== undefined);
|
|
53146
53162
|
return this.index.sendManyToBack(items);
|
|
53147
53163
|
}
|
|
53148
53164
|
case "add":
|
|
@@ -53166,82 +53182,82 @@ class Board {
|
|
|
53166
53182
|
applyAddItems(op) {
|
|
53167
53183
|
if (Array.isArray(op.item)) {
|
|
53168
53184
|
const data = op.data;
|
|
53169
|
-
const items = op.item.map((
|
|
53170
|
-
const created = this.createItem(
|
|
53185
|
+
const items = op.item.map((item3) => {
|
|
53186
|
+
const created = this.createItem(item3, data[item3]);
|
|
53171
53187
|
this.index.insert(created);
|
|
53172
53188
|
return created;
|
|
53173
53189
|
});
|
|
53174
|
-
items.forEach((
|
|
53175
|
-
if (
|
|
53176
|
-
const connectorData = data[
|
|
53177
|
-
|
|
53178
|
-
|
|
53190
|
+
items.forEach((item3) => {
|
|
53191
|
+
if (item3 instanceof Connector2 && data[item3.getId()]) {
|
|
53192
|
+
const connectorData = data[item3.getId()];
|
|
53193
|
+
item3.applyStartPoint(connectorData.startPoint);
|
|
53194
|
+
item3.applyEndPoint(connectorData.endPoint);
|
|
53179
53195
|
}
|
|
53180
53196
|
});
|
|
53181
53197
|
return;
|
|
53182
53198
|
}
|
|
53183
|
-
const
|
|
53184
|
-
return this.index.insert(
|
|
53199
|
+
const item2 = this.createItem(op.item, op.data);
|
|
53200
|
+
return this.index.insert(item2);
|
|
53185
53201
|
}
|
|
53186
53202
|
applyAddLockedGroupOperation(op) {
|
|
53187
|
-
const
|
|
53188
|
-
const groupChildrenIds =
|
|
53189
|
-
this.index.insert(
|
|
53203
|
+
const item2 = this.createItem(op.item, op.data);
|
|
53204
|
+
const groupChildrenIds = item2.getChildrenIds();
|
|
53205
|
+
this.index.insert(item2);
|
|
53190
53206
|
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
53191
53207
|
if (lastChildrenId) {
|
|
53192
53208
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
53193
|
-
this.index.moveToZIndex(
|
|
53209
|
+
this.index.moveToZIndex(item2, zIndex);
|
|
53194
53210
|
}
|
|
53195
|
-
|
|
53196
|
-
|
|
53211
|
+
item2.getChildren().forEach((item3) => {
|
|
53212
|
+
item3.transformation.isLocked = true;
|
|
53197
53213
|
});
|
|
53198
|
-
|
|
53214
|
+
item2.transformation.isLocked = true;
|
|
53199
53215
|
}
|
|
53200
53216
|
applyRemoveOperation(op) {
|
|
53201
53217
|
const removedItems = [];
|
|
53202
|
-
this.findItemAndApply(op.item, (
|
|
53203
|
-
this.index.remove(
|
|
53204
|
-
this.selection.remove(
|
|
53205
|
-
if (
|
|
53206
|
-
|
|
53218
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
53219
|
+
this.index.remove(item2);
|
|
53220
|
+
this.selection.remove(item2);
|
|
53221
|
+
if (item2 instanceof Connector2) {
|
|
53222
|
+
item2.clearObservedItems();
|
|
53207
53223
|
}
|
|
53208
|
-
removedItems.push(
|
|
53224
|
+
removedItems.push(item2);
|
|
53209
53225
|
});
|
|
53210
53226
|
}
|
|
53211
53227
|
applyRemoveLockedGroupOperation(op) {
|
|
53212
|
-
const
|
|
53213
|
-
if (!
|
|
53228
|
+
const item2 = this.index.getById(op.item[0]);
|
|
53229
|
+
if (!item2 || !(item2 instanceof Group)) {
|
|
53214
53230
|
return;
|
|
53215
53231
|
}
|
|
53216
|
-
|
|
53217
|
-
|
|
53218
|
-
|
|
53232
|
+
item2.getChildren().forEach((item3) => {
|
|
53233
|
+
item3.transformation.isLocked = false;
|
|
53234
|
+
item3.parent = "Board";
|
|
53219
53235
|
});
|
|
53220
|
-
|
|
53236
|
+
item2.transformation.isLocked = false;
|
|
53221
53237
|
const removedItems = [];
|
|
53222
|
-
this.findItemAndApply(op.item, (
|
|
53223
|
-
this.index.remove(
|
|
53224
|
-
this.selection.remove(
|
|
53225
|
-
removedItems.push(
|
|
53238
|
+
this.findItemAndApply(op.item, (item3) => {
|
|
53239
|
+
this.index.remove(item3);
|
|
53240
|
+
this.selection.remove(item3);
|
|
53241
|
+
removedItems.push(item3);
|
|
53226
53242
|
});
|
|
53227
53243
|
}
|
|
53228
53244
|
applyItemOperation(op) {
|
|
53229
53245
|
if ("item" in op) {
|
|
53230
|
-
this.findItemAndApply(op.item, (
|
|
53231
|
-
|
|
53246
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
53247
|
+
item2.apply(op);
|
|
53232
53248
|
});
|
|
53233
53249
|
}
|
|
53234
53250
|
}
|
|
53235
|
-
findItemAndApply(
|
|
53236
|
-
if (Array.isArray(
|
|
53237
|
-
for (const itemId of
|
|
53251
|
+
findItemAndApply(item2, apply) {
|
|
53252
|
+
if (Array.isArray(item2)) {
|
|
53253
|
+
for (const itemId of item2) {
|
|
53238
53254
|
const found = this.items.findById(itemId);
|
|
53239
53255
|
if (found) {
|
|
53240
53256
|
apply(found);
|
|
53241
53257
|
}
|
|
53242
53258
|
}
|
|
53243
53259
|
} else {
|
|
53244
|
-
const found = this.items.findById(
|
|
53260
|
+
const found = this.items.findById(item2);
|
|
53245
53261
|
if (found) {
|
|
53246
53262
|
apply(found);
|
|
53247
53263
|
}
|
|
@@ -53250,9 +53266,9 @@ class Board {
|
|
|
53250
53266
|
handleNesting(items) {
|
|
53251
53267
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
53252
53268
|
const groupsMap = new Map;
|
|
53253
|
-
arrayed.forEach((
|
|
53254
|
-
const itemCenter =
|
|
53255
|
-
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(
|
|
53269
|
+
arrayed.forEach((item2) => {
|
|
53270
|
+
const itemCenter = item2.getMbr().getCenter();
|
|
53271
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item2)).reduce((acc, groupItem2) => {
|
|
53256
53272
|
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
53257
53273
|
acc = groupItem2;
|
|
53258
53274
|
}
|
|
@@ -53262,7 +53278,7 @@ class Board {
|
|
|
53262
53278
|
if (!groupsMap.has(groupItem)) {
|
|
53263
53279
|
groupsMap.set(groupItem, []);
|
|
53264
53280
|
}
|
|
53265
|
-
groupsMap.get(groupItem)?.push(
|
|
53281
|
+
groupsMap.get(groupItem)?.push(item2);
|
|
53266
53282
|
}
|
|
53267
53283
|
});
|
|
53268
53284
|
groupsMap.forEach((items2, group) => {
|
|
@@ -53283,13 +53299,13 @@ class Board {
|
|
|
53283
53299
|
}
|
|
53284
53300
|
return parser(el);
|
|
53285
53301
|
}
|
|
53286
|
-
add(
|
|
53302
|
+
add(item2, timeStamp) {
|
|
53287
53303
|
const id = this.getNewItemId();
|
|
53288
53304
|
this.emit({
|
|
53289
53305
|
class: "Board",
|
|
53290
53306
|
method: "add",
|
|
53291
53307
|
item: id,
|
|
53292
|
-
data:
|
|
53308
|
+
data: item2.serialize(),
|
|
53293
53309
|
timeStamp
|
|
53294
53310
|
});
|
|
53295
53311
|
const newItem = this.items.getById(id);
|
|
@@ -53299,13 +53315,13 @@ class Board {
|
|
|
53299
53315
|
this.handleNesting(newItem);
|
|
53300
53316
|
return newItem;
|
|
53301
53317
|
}
|
|
53302
|
-
addLockedGroup(
|
|
53318
|
+
addLockedGroup(item2) {
|
|
53303
53319
|
const id = this.getNewItemId();
|
|
53304
53320
|
this.emit({
|
|
53305
53321
|
class: "Board",
|
|
53306
53322
|
method: "addLockedGroup",
|
|
53307
53323
|
item: id,
|
|
53308
|
-
data:
|
|
53324
|
+
data: item2.serialize()
|
|
53309
53325
|
});
|
|
53310
53326
|
const newItem = this.items.getById(id);
|
|
53311
53327
|
if (!newItem) {
|
|
@@ -53314,32 +53330,32 @@ class Board {
|
|
|
53314
53330
|
this.handleNesting(newItem);
|
|
53315
53331
|
return newItem;
|
|
53316
53332
|
}
|
|
53317
|
-
remove(
|
|
53333
|
+
remove(item2, withConnectors = true) {
|
|
53318
53334
|
let connectors = [];
|
|
53319
53335
|
if (withConnectors) {
|
|
53320
|
-
connectors = this.items.getLinkedConnectorsById(
|
|
53336
|
+
connectors = this.items.getLinkedConnectorsById(item2.getId()).map((connector) => connector.getId());
|
|
53321
53337
|
}
|
|
53322
|
-
if ("onRemove" in
|
|
53323
|
-
|
|
53338
|
+
if ("onRemove" in item2) {
|
|
53339
|
+
item2.onRemove();
|
|
53324
53340
|
}
|
|
53325
53341
|
this.emit({
|
|
53326
53342
|
class: "Board",
|
|
53327
53343
|
method: "remove",
|
|
53328
|
-
item: [
|
|
53344
|
+
item: [item2.getId(), ...connectors]
|
|
53329
53345
|
});
|
|
53330
53346
|
}
|
|
53331
|
-
removeLockedGroup(
|
|
53347
|
+
removeLockedGroup(item2) {
|
|
53332
53348
|
this.emit({
|
|
53333
53349
|
class: "Board",
|
|
53334
53350
|
method: "removeLockedGroup",
|
|
53335
|
-
item: [
|
|
53351
|
+
item: [item2.getId()]
|
|
53336
53352
|
});
|
|
53337
53353
|
}
|
|
53338
53354
|
getByZIndex(index2) {
|
|
53339
53355
|
return this.index.getByZIndex(index2);
|
|
53340
53356
|
}
|
|
53341
|
-
getZIndex(
|
|
53342
|
-
return this.index.getZIndex(
|
|
53357
|
+
getZIndex(item2) {
|
|
53358
|
+
return this.index.getZIndex(item2);
|
|
53343
53359
|
}
|
|
53344
53360
|
getLastZIndex() {
|
|
53345
53361
|
return this.index.getLastZIndex();
|
|
@@ -53351,11 +53367,11 @@ class Board {
|
|
|
53351
53367
|
item: items
|
|
53352
53368
|
});
|
|
53353
53369
|
}
|
|
53354
|
-
moveToZIndex(
|
|
53370
|
+
moveToZIndex(item2, zIndex) {
|
|
53355
53371
|
this.emit({
|
|
53356
53372
|
class: "Board",
|
|
53357
53373
|
method: "moveToZIndex",
|
|
53358
|
-
item:
|
|
53374
|
+
item: item2.getId(),
|
|
53359
53375
|
zIndex
|
|
53360
53376
|
});
|
|
53361
53377
|
}
|
|
@@ -53383,8 +53399,8 @@ class Board {
|
|
|
53383
53399
|
this.emit({
|
|
53384
53400
|
class: "Board",
|
|
53385
53401
|
method: "bringToFront",
|
|
53386
|
-
item: items.map((
|
|
53387
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53402
|
+
item: items.map((item2) => item2.getId()),
|
|
53403
|
+
prevZIndex: Object.fromEntries(boardItems.map((item2) => [item2.getId(), boardItems.indexOf(item2)]))
|
|
53388
53404
|
});
|
|
53389
53405
|
}
|
|
53390
53406
|
sendToBack(items) {
|
|
@@ -53395,8 +53411,8 @@ class Board {
|
|
|
53395
53411
|
this.emit({
|
|
53396
53412
|
class: "Board",
|
|
53397
53413
|
method: "sendToBack",
|
|
53398
|
-
item: items.map((
|
|
53399
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53414
|
+
item: items.map((item2) => item2.getId()),
|
|
53415
|
+
prevZIndex: Object.fromEntries(boardItems.map((item2) => [item2.getId(), boardItems.indexOf(item2)]))
|
|
53400
53416
|
});
|
|
53401
53417
|
}
|
|
53402
53418
|
copy() {
|
|
@@ -53473,7 +53489,7 @@ class Board {
|
|
|
53473
53489
|
return added;
|
|
53474
53490
|
});
|
|
53475
53491
|
addedFrame.addChildItems(addedChildren);
|
|
53476
|
-
parsedData.data.children = addedChildren.map((
|
|
53492
|
+
parsedData.data.children = addedChildren.map((item2) => item2.getId());
|
|
53477
53493
|
idsMap[parsedData.data.id] = addedFrame.getId();
|
|
53478
53494
|
} else {
|
|
53479
53495
|
const added = this.add(this.createItem(this.getNewItemId(), parsedData));
|
|
@@ -53514,15 +53530,15 @@ class Board {
|
|
|
53514
53530
|
const createdConnectors = {};
|
|
53515
53531
|
const createdFrames = {};
|
|
53516
53532
|
const addItem = (itemData) => {
|
|
53517
|
-
const
|
|
53518
|
-
if (
|
|
53519
|
-
createdConnectors[itemData.id] = { item, itemData };
|
|
53533
|
+
const item2 = this.createItem(itemData.id, itemData);
|
|
53534
|
+
if (item2 instanceof Connector2) {
|
|
53535
|
+
createdConnectors[itemData.id] = { item: item2, itemData };
|
|
53520
53536
|
}
|
|
53521
|
-
if (
|
|
53522
|
-
createdFrames[
|
|
53537
|
+
if (item2 instanceof Frame2) {
|
|
53538
|
+
createdFrames[item2.getId()] = { item: item2, itemData };
|
|
53523
53539
|
}
|
|
53524
|
-
this.index.insert(
|
|
53525
|
-
return
|
|
53540
|
+
this.index.insert(item2);
|
|
53541
|
+
return item2;
|
|
53526
53542
|
};
|
|
53527
53543
|
for (const itemData of items) {
|
|
53528
53544
|
if ("childrenMap" in itemData) {
|
|
@@ -53533,13 +53549,13 @@ class Board {
|
|
|
53533
53549
|
}
|
|
53534
53550
|
}
|
|
53535
53551
|
for (const key in createdConnectors) {
|
|
53536
|
-
const { item, itemData } = createdConnectors[key];
|
|
53537
|
-
|
|
53538
|
-
|
|
53552
|
+
const { item: item2, itemData } = createdConnectors[key];
|
|
53553
|
+
item2.applyStartPoint(itemData.startPoint);
|
|
53554
|
+
item2.applyEndPoint(itemData.endPoint);
|
|
53539
53555
|
}
|
|
53540
53556
|
for (const key in createdFrames) {
|
|
53541
|
-
const { item, itemData } = createdFrames[key];
|
|
53542
|
-
|
|
53557
|
+
const { item: item2, itemData } = createdFrames[key];
|
|
53558
|
+
item2.applyAddChildren(itemData.children);
|
|
53543
53559
|
}
|
|
53544
53560
|
}
|
|
53545
53561
|
deserialize(snapshot) {
|
|
@@ -53549,33 +53565,33 @@ class Board {
|
|
|
53549
53565
|
const createdFrames = {};
|
|
53550
53566
|
if (Array.isArray(items)) {
|
|
53551
53567
|
for (const itemData of items) {
|
|
53552
|
-
const
|
|
53553
|
-
if (
|
|
53554
|
-
createdConnectors[itemData.id] = { item, itemData };
|
|
53568
|
+
const item2 = this.createItem(itemData.id, itemData);
|
|
53569
|
+
if (item2 instanceof Connector2) {
|
|
53570
|
+
createdConnectors[itemData.id] = { item: item2, itemData };
|
|
53555
53571
|
}
|
|
53556
|
-
if (
|
|
53557
|
-
createdFrames[
|
|
53572
|
+
if (item2 instanceof Frame2) {
|
|
53573
|
+
createdFrames[item2.getId()] = { item: item2, itemData };
|
|
53558
53574
|
}
|
|
53559
|
-
this.index.insert(
|
|
53575
|
+
this.index.insert(item2);
|
|
53560
53576
|
}
|
|
53561
53577
|
} else {
|
|
53562
53578
|
for (const key in items) {
|
|
53563
53579
|
const itemData = items[key];
|
|
53564
|
-
const
|
|
53565
|
-
if (
|
|
53566
|
-
createdConnectors[key] = { item, itemData };
|
|
53580
|
+
const item2 = this.createItem(key, itemData);
|
|
53581
|
+
if (item2 instanceof Connector2) {
|
|
53582
|
+
createdConnectors[key] = { item: item2, itemData };
|
|
53567
53583
|
}
|
|
53568
|
-
this.index.insert(
|
|
53584
|
+
this.index.insert(item2);
|
|
53569
53585
|
}
|
|
53570
53586
|
}
|
|
53571
53587
|
for (const key in createdConnectors) {
|
|
53572
|
-
const { item, itemData } = createdConnectors[key];
|
|
53573
|
-
|
|
53574
|
-
|
|
53588
|
+
const { item: item2, itemData } = createdConnectors[key];
|
|
53589
|
+
item2.applyStartPoint(itemData.startPoint);
|
|
53590
|
+
item2.applyEndPoint(itemData.endPoint);
|
|
53575
53591
|
}
|
|
53576
53592
|
for (const key in createdFrames) {
|
|
53577
|
-
const { item, itemData } = createdFrames[key];
|
|
53578
|
-
|
|
53593
|
+
const { item: item2, itemData } = createdFrames[key];
|
|
53594
|
+
item2.applyAddChildren(itemData.children);
|
|
53579
53595
|
}
|
|
53580
53596
|
this.events?.log.deserialize(events);
|
|
53581
53597
|
}
|
|
@@ -53813,7 +53829,7 @@ class Board {
|
|
|
53813
53829
|
itemsMap: newMap,
|
|
53814
53830
|
select: select2
|
|
53815
53831
|
});
|
|
53816
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
53832
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item2) => typeof item2 !== "undefined");
|
|
53817
53833
|
this.handleNesting(items);
|
|
53818
53834
|
this.selection.removeAll();
|
|
53819
53835
|
this.selection.add(items);
|
|
@@ -53821,8 +53837,8 @@ class Board {
|
|
|
53821
53837
|
return;
|
|
53822
53838
|
}
|
|
53823
53839
|
removeVoidComments() {
|
|
53824
|
-
const voidComments = this.items.listAll().filter((
|
|
53825
|
-
return
|
|
53840
|
+
const voidComments = this.items.listAll().filter((item2) => {
|
|
53841
|
+
return item2 instanceof Comment && !item2.getThread().length;
|
|
53826
53842
|
});
|
|
53827
53843
|
if (voidComments) {
|
|
53828
53844
|
for (const comment2 of voidComments) {
|
|
@@ -53896,7 +53912,7 @@ class Board {
|
|
|
53896
53912
|
}
|
|
53897
53913
|
const mbr = this.selection.getMbr();
|
|
53898
53914
|
const selectedItems = this.selection.items.list();
|
|
53899
|
-
const isSelectedItemsMinWidth = selectedItems.some((
|
|
53915
|
+
const isSelectedItemsMinWidth = selectedItems.some((item2) => item2.getMbr().getWidth() === 0);
|
|
53900
53916
|
const right = mbr ? mbr.right : 0;
|
|
53901
53917
|
const top = mbr ? mbr.top : 0;
|
|
53902
53918
|
const width2 = mbr ? mbr.getWidth() / 10 : 10;
|
|
@@ -53938,7 +53954,7 @@ class Board {
|
|
|
53938
53954
|
method: "duplicate",
|
|
53939
53955
|
itemsMap: newMap
|
|
53940
53956
|
});
|
|
53941
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
53957
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item2) => typeof item2 !== "undefined");
|
|
53942
53958
|
this.handleNesting(items);
|
|
53943
53959
|
this.selection.removeAll();
|
|
53944
53960
|
this.selection.add(items);
|
|
@@ -53959,9 +53975,9 @@ class Board {
|
|
|
53959
53975
|
if (data.itemType === "Frame") {
|
|
53960
53976
|
data.text.placeholderText = `Frame ${this.getMaxFrameSerial() + 1}`;
|
|
53961
53977
|
}
|
|
53962
|
-
const
|
|
53963
|
-
this.index.insert(
|
|
53964
|
-
items.push(
|
|
53978
|
+
const item2 = this.createItem(itemId, data);
|
|
53979
|
+
this.index.insert(item2);
|
|
53980
|
+
items.push(item2);
|
|
53965
53981
|
};
|
|
53966
53982
|
sortedItemsMap.map(([id, data]) => {
|
|
53967
53983
|
if (data.itemType === "Connector") {
|
|
@@ -53976,8 +53992,8 @@ class Board {
|
|
|
53976
53992
|
return;
|
|
53977
53993
|
});
|
|
53978
53994
|
}
|
|
53979
|
-
isOnBoard(
|
|
53980
|
-
return this.items.findById(
|
|
53995
|
+
isOnBoard(item2) {
|
|
53996
|
+
return this.items.findById(item2.getId()) !== undefined;
|
|
53981
53997
|
}
|
|
53982
53998
|
getMaxFrameSerial() {
|
|
53983
53999
|
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
@@ -54023,7 +54039,7 @@ function areItemsTheSame(opA, opB) {
|
|
|
54023
54039
|
const itemsB = Object.keys(opB.items);
|
|
54024
54040
|
const setA = new Set(itemsA);
|
|
54025
54041
|
const setB = new Set(itemsB);
|
|
54026
|
-
const areArraysEqual = setA.size === setB.size && [...setA].every((
|
|
54042
|
+
const areArraysEqual = setA.size === setB.size && [...setA].every((item2) => setB.has(item2));
|
|
54027
54043
|
return areArraysEqual;
|
|
54028
54044
|
}
|
|
54029
54045
|
if (!(Array.isArray(opA.item) && Array.isArray(opB.item))) {
|
|
@@ -55682,9 +55698,9 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
55682
55698
|
list6.applyUnconfirmed(filter);
|
|
55683
55699
|
const hasAnyOverlap = (arr1, arr2) => {
|
|
55684
55700
|
const lookup9 = new Set(arr1);
|
|
55685
|
-
return arr2.some((
|
|
55701
|
+
return arr2.some((item2) => lookup9.has(item2));
|
|
55686
55702
|
};
|
|
55687
|
-
const currSelection = board.selection.list().map((
|
|
55703
|
+
const currSelection = board.selection.list().map((item2) => item2.getId());
|
|
55688
55704
|
if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
55689
55705
|
board.selection.applyMemoizedCaretOrRange();
|
|
55690
55706
|
}
|
|
@@ -56006,27 +56022,27 @@ function handleAiChatMassage(message, board) {
|
|
|
56006
56022
|
}
|
|
56007
56023
|
}
|
|
56008
56024
|
function handleChatChunk(chunk, board) {
|
|
56009
|
-
const
|
|
56025
|
+
const item2 = board.items.getById(chunk.itemId);
|
|
56010
56026
|
switch (chunk.type) {
|
|
56011
56027
|
case "chunk":
|
|
56012
|
-
if (!
|
|
56028
|
+
if (!item2 || item2.itemType !== "AINode") {
|
|
56013
56029
|
return;
|
|
56014
56030
|
}
|
|
56015
|
-
|
|
56031
|
+
item2.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
|
|
56016
56032
|
break;
|
|
56017
56033
|
case "done":
|
|
56018
|
-
if (!
|
|
56034
|
+
if (!item2 || item2.itemType !== "AINode") {
|
|
56019
56035
|
board.aiGeneratingOnItem = undefined;
|
|
56020
56036
|
return;
|
|
56021
56037
|
}
|
|
56022
|
-
|
|
56038
|
+
item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56023
56039
|
break;
|
|
56024
56040
|
case "end":
|
|
56025
|
-
if (!
|
|
56041
|
+
if (!item2 || item2.itemType !== "AINode") {
|
|
56026
56042
|
board.aiGeneratingOnItem = undefined;
|
|
56027
56043
|
return;
|
|
56028
56044
|
}
|
|
56029
|
-
|
|
56045
|
+
item2.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56030
56046
|
break;
|
|
56031
56047
|
case "error":
|
|
56032
56048
|
default:
|
|
@@ -56043,7 +56059,7 @@ function handleChatChunk(chunk, board) {
|
|
|
56043
56059
|
if (board.aiGeneratingOnItem && generatingItem) {
|
|
56044
56060
|
board.selection.removeAll();
|
|
56045
56061
|
board.selection.add(generatingItem);
|
|
56046
|
-
const rt =
|
|
56062
|
+
const rt = item2?.getRichText();
|
|
56047
56063
|
if (generatingItem.itemType === "AINode" && rt) {
|
|
56048
56064
|
const editor = rt.editor;
|
|
56049
56065
|
editor.markdownProcessor.setStopProcessingMarkDownCb(null);
|
|
@@ -56176,14 +56192,14 @@ function handleImageGenerate(response, board) {
|
|
|
56176
56192
|
console.error("Image generation error:", response.message);
|
|
56177
56193
|
if (response.isExternalApiError) {
|
|
56178
56194
|
if (board.aiGeneratingOnItem) {
|
|
56179
|
-
const
|
|
56180
|
-
if (
|
|
56195
|
+
const item2 = board.items.getById(board.aiGeneratingOnItem);
|
|
56196
|
+
if (item2) {
|
|
56181
56197
|
board.selection.removeAll();
|
|
56182
|
-
board.selection.add(
|
|
56183
|
-
const editor =
|
|
56198
|
+
board.selection.add(item2);
|
|
56199
|
+
const editor = item2.getRichText()?.editor;
|
|
56184
56200
|
editor?.clearText();
|
|
56185
56201
|
editor?.insertCopiedText(conf.i18n.t("AIInput.nodeErrorText"));
|
|
56186
|
-
board.camera.zoomToFit(
|
|
56202
|
+
board.camera.zoomToFit(item2.getMbr(), 20);
|
|
56187
56203
|
}
|
|
56188
56204
|
}
|
|
56189
56205
|
} else {
|