microboard-temp 0.4.59 → 0.4.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +876 -874
- package/dist/cjs/index.js +876 -874
- package/dist/cjs/node.js +876 -874
- package/dist/esm/browser.js +876 -874
- package/dist/esm/index.js +876 -874
- package/dist/esm/node.js +876 -874
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -801,8 +801,8 @@ class BoardCommand {
|
|
|
801
801
|
switch (operation.method) {
|
|
802
802
|
case "bringToFront": {
|
|
803
803
|
for (const id in operation.prevZIndex) {
|
|
804
|
-
const
|
|
805
|
-
if (!
|
|
804
|
+
const item = this.board.items.getById(id);
|
|
805
|
+
if (!item) {
|
|
806
806
|
delete operation.prevZIndex.id;
|
|
807
807
|
}
|
|
808
808
|
}
|
|
@@ -814,8 +814,8 @@ class BoardCommand {
|
|
|
814
814
|
}
|
|
815
815
|
case "sendToBack": {
|
|
816
816
|
for (const id in operation.prevZIndex) {
|
|
817
|
-
const
|
|
818
|
-
if (!
|
|
817
|
+
const item = this.board.items.getById(id);
|
|
818
|
+
if (!item) {
|
|
819
819
|
delete operation.prevZIndex.id;
|
|
820
820
|
}
|
|
821
821
|
}
|
|
@@ -829,11 +829,11 @@ class BoardCommand {
|
|
|
829
829
|
case "moveSecondBeforeFirst":
|
|
830
830
|
case "moveToZIndex": {
|
|
831
831
|
const items = this.board.items;
|
|
832
|
-
const
|
|
833
|
-
if (!
|
|
832
|
+
const item = items.getById(operation.item);
|
|
833
|
+
if (!item) {
|
|
834
834
|
throw new Error("Get reverse board operation. Item not found");
|
|
835
835
|
}
|
|
836
|
-
const zIndex = this.board.getZIndex(
|
|
836
|
+
const zIndex = this.board.getZIndex(item);
|
|
837
837
|
return {
|
|
838
838
|
class: "Board",
|
|
839
839
|
method: "moveToZIndex",
|
|
@@ -843,8 +843,8 @@ class BoardCommand {
|
|
|
843
843
|
}
|
|
844
844
|
case "moveManyToZIndex": {
|
|
845
845
|
for (const id in operation.item) {
|
|
846
|
-
const
|
|
847
|
-
if (!
|
|
846
|
+
const item = this.board.items.getById(id);
|
|
847
|
+
if (!item) {
|
|
848
848
|
delete operation.item.id;
|
|
849
849
|
}
|
|
850
850
|
}
|
|
@@ -861,15 +861,15 @@ class BoardCommand {
|
|
|
861
861
|
const items = this.board.items;
|
|
862
862
|
const reverse = [];
|
|
863
863
|
for (const itemId of operation.item) {
|
|
864
|
-
const
|
|
865
|
-
if (!
|
|
864
|
+
const item = items.getById(itemId);
|
|
865
|
+
if (!item) {
|
|
866
866
|
throw new Error("Get reverse board operation. Item not found");
|
|
867
867
|
}
|
|
868
868
|
reverse.push({
|
|
869
869
|
class: "Board",
|
|
870
870
|
method: "add",
|
|
871
871
|
item: itemId,
|
|
872
|
-
data:
|
|
872
|
+
data: item.serialize()
|
|
873
873
|
});
|
|
874
874
|
}
|
|
875
875
|
return reverse;
|
|
@@ -892,32 +892,32 @@ class BoardCommand {
|
|
|
892
892
|
const items = this.board.items;
|
|
893
893
|
const reverse = [];
|
|
894
894
|
for (const itemId of operation.item) {
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
895
|
+
const item = items.getById(itemId);
|
|
896
|
+
if (!item || item.itemType !== "Group") {
|
|
897
897
|
throw new Error("Get reverse board operation. Item not found");
|
|
898
898
|
}
|
|
899
899
|
reverse.push({
|
|
900
900
|
class: "Board",
|
|
901
901
|
method: "addLockedGroup",
|
|
902
902
|
item: itemId,
|
|
903
|
-
data:
|
|
903
|
+
data: item.serialize()
|
|
904
904
|
});
|
|
905
905
|
}
|
|
906
906
|
return reverse;
|
|
907
907
|
}
|
|
908
908
|
case "duplicate":
|
|
909
909
|
case "paste": {
|
|
910
|
-
const
|
|
910
|
+
const item = [];
|
|
911
911
|
const map = operation.itemsMap;
|
|
912
912
|
for (const key in map) {
|
|
913
913
|
if (map.hasOwnProperty(key)) {
|
|
914
|
-
|
|
914
|
+
item.push(key);
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
917
|
return {
|
|
918
918
|
class: "Board",
|
|
919
919
|
method: "remove",
|
|
920
|
-
item
|
|
920
|
+
item
|
|
921
921
|
};
|
|
922
922
|
}
|
|
923
923
|
}
|
|
@@ -7235,11 +7235,11 @@ class SubjectOperation {
|
|
|
7235
7235
|
}
|
|
7236
7236
|
|
|
7237
7237
|
// src/Items/ItemsCommandUtils.ts
|
|
7238
|
-
function mapItemsByOperation(
|
|
7239
|
-
const items = Array.isArray(
|
|
7240
|
-
return items.map((
|
|
7241
|
-
const operation = getCallback(
|
|
7242
|
-
return { item:
|
|
7238
|
+
function mapItemsByOperation(item, getCallback) {
|
|
7239
|
+
const items = Array.isArray(item) ? item : [item];
|
|
7240
|
+
return items.map((item2) => {
|
|
7241
|
+
const operation = getCallback(item2);
|
|
7242
|
+
return { item: item2, operation };
|
|
7243
7243
|
});
|
|
7244
7244
|
}
|
|
7245
7245
|
|
|
@@ -7264,8 +7264,8 @@ class TransformationCommand {
|
|
|
7264
7264
|
}
|
|
7265
7265
|
}
|
|
7266
7266
|
revert() {
|
|
7267
|
-
this.reverse.forEach(({ item
|
|
7268
|
-
|
|
7267
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
7268
|
+
item.apply(operation);
|
|
7269
7269
|
});
|
|
7270
7270
|
}
|
|
7271
7271
|
getReverse() {
|
|
@@ -8007,8 +8007,8 @@ class Path {
|
|
|
8007
8007
|
}
|
|
8008
8008
|
getIntersectionPoints(segment) {
|
|
8009
8009
|
let intersections = [];
|
|
8010
|
-
for (const
|
|
8011
|
-
intersections = intersections.concat(
|
|
8010
|
+
for (const item of this.segments) {
|
|
8011
|
+
intersections = intersections.concat(item.getIntersectionPoints(segment));
|
|
8012
8012
|
}
|
|
8013
8013
|
return intersections;
|
|
8014
8014
|
}
|
|
@@ -8073,8 +8073,8 @@ class Path {
|
|
|
8073
8073
|
}
|
|
8074
8074
|
isOpenEnclosedOrCrossedBy(rectangle) {
|
|
8075
8075
|
let is = false;
|
|
8076
|
-
for (const
|
|
8077
|
-
is = is ||
|
|
8076
|
+
for (const item of this.segments) {
|
|
8077
|
+
is = is || item.isEnclosedOrCrossedBy(rectangle);
|
|
8078
8078
|
}
|
|
8079
8079
|
return is;
|
|
8080
8080
|
}
|
|
@@ -8487,8 +8487,8 @@ class ConnectorCommand {
|
|
|
8487
8487
|
}
|
|
8488
8488
|
}
|
|
8489
8489
|
revert() {
|
|
8490
|
-
for (const { item
|
|
8491
|
-
|
|
8490
|
+
for (const { item, operation } of this.reverse) {
|
|
8491
|
+
item.apply(operation);
|
|
8492
8492
|
}
|
|
8493
8493
|
}
|
|
8494
8494
|
getReverse() {
|
|
@@ -8645,11 +8645,11 @@ class SessionStorage {
|
|
|
8645
8645
|
}
|
|
8646
8646
|
get(key) {
|
|
8647
8647
|
const boardId = this.getBoardId() || "";
|
|
8648
|
-
const
|
|
8649
|
-
if (!
|
|
8648
|
+
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
8649
|
+
if (!item) {
|
|
8650
8650
|
return;
|
|
8651
8651
|
}
|
|
8652
|
-
return JSON.parse(
|
|
8652
|
+
return JSON.parse(item);
|
|
8653
8653
|
}
|
|
8654
8654
|
remove(key) {
|
|
8655
8655
|
const boardId = this.getBoardId() || "";
|
|
@@ -9429,8 +9429,8 @@ class LinkToCommand {
|
|
|
9429
9429
|
}
|
|
9430
9430
|
}
|
|
9431
9431
|
revert() {
|
|
9432
|
-
this.reverse.forEach(({ item
|
|
9433
|
-
|
|
9432
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
9433
|
+
item.apply(operation);
|
|
9434
9434
|
});
|
|
9435
9435
|
}
|
|
9436
9436
|
getReverse() {
|
|
@@ -10727,9 +10727,9 @@ function handleSplitListItem(editor) {
|
|
|
10727
10727
|
import_slate5.Transforms.insertNodes(editor, {
|
|
10728
10728
|
type: listType,
|
|
10729
10729
|
listLevel: listNode.listLevel || 0,
|
|
10730
|
-
children: itemsAfter.map((
|
|
10730
|
+
children: itemsAfter.map((item) => ({
|
|
10731
10731
|
type: "list_item",
|
|
10732
|
-
children:
|
|
10732
|
+
children: item.children
|
|
10733
10733
|
}))
|
|
10734
10734
|
}, { at: newListPath });
|
|
10735
10735
|
}
|
|
@@ -12706,10 +12706,10 @@ function initializeDocument(effects) {
|
|
|
12706
12706
|
return start;
|
|
12707
12707
|
function start(code) {
|
|
12708
12708
|
if (continued < stack.length) {
|
|
12709
|
-
const
|
|
12710
|
-
self2.containerState =
|
|
12711
|
-
ok(
|
|
12712
|
-
return effects.attempt(
|
|
12709
|
+
const item = stack[continued];
|
|
12710
|
+
self2.containerState = item[1];
|
|
12711
|
+
ok(item[0].continuation, "expected `continuation` to be defined on container construct");
|
|
12712
|
+
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
|
|
12713
12713
|
}
|
|
12714
12714
|
return checkNewContainers(code);
|
|
12715
12715
|
}
|
|
@@ -13685,17 +13685,17 @@ class SpliceBuffer {
|
|
|
13685
13685
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13686
13686
|
return this.left.pop();
|
|
13687
13687
|
}
|
|
13688
|
-
push(
|
|
13688
|
+
push(item) {
|
|
13689
13689
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13690
|
-
this.left.push(
|
|
13690
|
+
this.left.push(item);
|
|
13691
13691
|
}
|
|
13692
13692
|
pushMany(items) {
|
|
13693
13693
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13694
13694
|
chunkedPush(this.left, items);
|
|
13695
13695
|
}
|
|
13696
|
-
unshift(
|
|
13696
|
+
unshift(item) {
|
|
13697
13697
|
this.setCursor(0);
|
|
13698
|
-
this.right.push(
|
|
13698
|
+
this.right.push(item);
|
|
13699
13699
|
}
|
|
13700
13700
|
unshiftMany(items) {
|
|
13701
13701
|
this.setCursor(0);
|
|
@@ -15726,8 +15726,8 @@ function initializeFactory(field) {
|
|
|
15726
15726
|
if (list2) {
|
|
15727
15727
|
ok(Array.isArray(list2), "expected `disable.null` to be populated");
|
|
15728
15728
|
while (++index2 < list2.length) {
|
|
15729
|
-
const
|
|
15730
|
-
if (!
|
|
15729
|
+
const item = list2[index2];
|
|
15730
|
+
if (!item.previous || item.previous.call(self2, self2.previous)) {
|
|
15731
15731
|
return true;
|
|
15732
15732
|
}
|
|
15733
15733
|
}
|
|
@@ -16558,14 +16558,14 @@ function compiler(options) {
|
|
|
16558
16558
|
length++;
|
|
16559
16559
|
}
|
|
16560
16560
|
if (event[1].type === types.listItemPrefix) {
|
|
16561
|
-
const
|
|
16561
|
+
const item = {
|
|
16562
16562
|
type: "listItem",
|
|
16563
16563
|
_spread: false,
|
|
16564
16564
|
start: Object.assign({}, event[1].start),
|
|
16565
16565
|
end: undefined
|
|
16566
16566
|
};
|
|
16567
|
-
listItem2 =
|
|
16568
|
-
events.splice(index2, 0, ["enter",
|
|
16567
|
+
listItem2 = item;
|
|
16568
|
+
events.splice(index2, 0, ["enter", item, event[2]]);
|
|
16569
16569
|
index2++;
|
|
16570
16570
|
length++;
|
|
16571
16571
|
firstBlankLineIndex = undefined;
|
|
@@ -17363,14 +17363,14 @@ class MarkdownProcessor {
|
|
|
17363
17363
|
if (err || !file) {
|
|
17364
17364
|
throw err;
|
|
17365
17365
|
}
|
|
17366
|
-
const nodes = file.result.map((
|
|
17366
|
+
const nodes = file.result.map((item) => {
|
|
17367
17367
|
setNodeStyles({
|
|
17368
|
-
node:
|
|
17368
|
+
node: item,
|
|
17369
17369
|
editor: this.editor,
|
|
17370
17370
|
horisontalAlignment: "left",
|
|
17371
|
-
isPaddingTopNeeded:
|
|
17371
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
17372
17372
|
});
|
|
17373
|
-
return
|
|
17373
|
+
return item;
|
|
17374
17374
|
});
|
|
17375
17375
|
if (isNewParagraphNeeded) {
|
|
17376
17376
|
nodes.push(createParagraphNode("", this.editor));
|
|
@@ -18348,8 +18348,8 @@ class ShapeCommand {
|
|
|
18348
18348
|
}
|
|
18349
18349
|
}
|
|
18350
18350
|
revert() {
|
|
18351
|
-
for (const { item
|
|
18352
|
-
|
|
18351
|
+
for (const { item, operation } of this.reverse) {
|
|
18352
|
+
item.apply(operation);
|
|
18353
18353
|
}
|
|
18354
18354
|
}
|
|
18355
18355
|
getReverse() {
|
|
@@ -18431,8 +18431,8 @@ class RichTextCommand {
|
|
|
18431
18431
|
}
|
|
18432
18432
|
}
|
|
18433
18433
|
revert() {
|
|
18434
|
-
for (const { item
|
|
18435
|
-
const richText = this.board.items.getById(
|
|
18434
|
+
for (const { item, operation } of this.reverse) {
|
|
18435
|
+
const richText = this.board.items.getById(item);
|
|
18436
18436
|
if (!richText) {
|
|
18437
18437
|
continue;
|
|
18438
18438
|
}
|
|
@@ -18451,12 +18451,12 @@ class RichTextCommand {
|
|
|
18451
18451
|
case "setSelectionFontColor":
|
|
18452
18452
|
case "setSelectionBlockType":
|
|
18453
18453
|
const inverseOps = this.operation.ops.map((op) => import_slate34.Operation.inverse(op)).reverse();
|
|
18454
|
-
return items.map((
|
|
18454
|
+
return items.map((item) => {
|
|
18455
18455
|
const operation = {
|
|
18456
18456
|
...this.operation,
|
|
18457
18457
|
ops: inverseOps
|
|
18458
18458
|
};
|
|
18459
|
-
return { item
|
|
18459
|
+
return { item, operation };
|
|
18460
18460
|
});
|
|
18461
18461
|
case "setFontColor":
|
|
18462
18462
|
return items.map((id) => ({
|
|
@@ -18548,13 +18548,13 @@ class RichTextGroupCommand {
|
|
|
18548
18548
|
this.reverseOps = this.getReverse();
|
|
18549
18549
|
}
|
|
18550
18550
|
apply() {
|
|
18551
|
-
for (const { item
|
|
18552
|
-
|
|
18551
|
+
for (const { item, operation } of this.forwardOps) {
|
|
18552
|
+
item.applyCommand(operation);
|
|
18553
18553
|
}
|
|
18554
18554
|
}
|
|
18555
18555
|
revert() {
|
|
18556
|
-
for (const { item
|
|
18557
|
-
|
|
18556
|
+
for (const { item, operation } of this.reverseOps) {
|
|
18557
|
+
item.applyCommand(operation);
|
|
18558
18558
|
}
|
|
18559
18559
|
}
|
|
18560
18560
|
getForward() {
|
|
@@ -18669,8 +18669,8 @@ class DrawingCommand {
|
|
|
18669
18669
|
item;
|
|
18670
18670
|
operation;
|
|
18671
18671
|
reverse;
|
|
18672
|
-
constructor(
|
|
18673
|
-
this.item =
|
|
18672
|
+
constructor(item, operation) {
|
|
18673
|
+
this.item = item;
|
|
18674
18674
|
this.operation = operation;
|
|
18675
18675
|
this.reverse = this.getReverse();
|
|
18676
18676
|
}
|
|
@@ -18679,52 +18679,52 @@ class DrawingCommand {
|
|
|
18679
18679
|
return this;
|
|
18680
18680
|
}
|
|
18681
18681
|
apply() {
|
|
18682
|
-
for (const
|
|
18683
|
-
|
|
18682
|
+
for (const item of this.item) {
|
|
18683
|
+
item.apply(this.operation);
|
|
18684
18684
|
}
|
|
18685
18685
|
}
|
|
18686
18686
|
revert() {
|
|
18687
|
-
for (const { item
|
|
18688
|
-
|
|
18687
|
+
for (const { item, operation } of this.reverse) {
|
|
18688
|
+
item.apply(operation);
|
|
18689
18689
|
}
|
|
18690
18690
|
}
|
|
18691
18691
|
getReverse() {
|
|
18692
18692
|
const reverse = [];
|
|
18693
|
-
for (const
|
|
18694
|
-
reverse.push({ item
|
|
18693
|
+
for (const item of this.item) {
|
|
18694
|
+
reverse.push({ item, operation: this.getReverseOperation(item) });
|
|
18695
18695
|
}
|
|
18696
18696
|
return reverse;
|
|
18697
18697
|
}
|
|
18698
|
-
getReverseOperation(
|
|
18698
|
+
getReverseOperation(item) {
|
|
18699
18699
|
switch (this.operation.method) {
|
|
18700
18700
|
case "setStrokeColor":
|
|
18701
18701
|
return {
|
|
18702
18702
|
class: "Drawing",
|
|
18703
18703
|
method: "setStrokeColor",
|
|
18704
|
-
item: [
|
|
18705
|
-
color:
|
|
18704
|
+
item: [item.getId()],
|
|
18705
|
+
color: item.getStrokeColor()
|
|
18706
18706
|
};
|
|
18707
18707
|
case "setStrokeWidth":
|
|
18708
18708
|
return {
|
|
18709
18709
|
class: "Drawing",
|
|
18710
18710
|
method: "setStrokeWidth",
|
|
18711
|
-
item: [
|
|
18711
|
+
item: [item.getId()],
|
|
18712
18712
|
width: this.operation.prevWidth,
|
|
18713
|
-
prevWidth:
|
|
18713
|
+
prevWidth: item.getStrokeWidth()
|
|
18714
18714
|
};
|
|
18715
18715
|
case "setStrokeOpacity":
|
|
18716
18716
|
return {
|
|
18717
18717
|
class: "Drawing",
|
|
18718
18718
|
method: "setStrokeOpacity",
|
|
18719
|
-
item: [
|
|
18720
|
-
opacity:
|
|
18719
|
+
item: [item.getId()],
|
|
18720
|
+
opacity: item.getStrokeOpacity()
|
|
18721
18721
|
};
|
|
18722
18722
|
case "setStrokeStyle":
|
|
18723
18723
|
return {
|
|
18724
18724
|
class: "Drawing",
|
|
18725
18725
|
method: "setStrokeStyle",
|
|
18726
|
-
item: [
|
|
18727
|
-
style:
|
|
18726
|
+
item: [item.getId()],
|
|
18727
|
+
style: item.getBorderStyle()
|
|
18728
18728
|
};
|
|
18729
18729
|
}
|
|
18730
18730
|
}
|
|
@@ -18746,8 +18746,8 @@ class StickerCommand {
|
|
|
18746
18746
|
}
|
|
18747
18747
|
}
|
|
18748
18748
|
revert() {
|
|
18749
|
-
for (const { item
|
|
18750
|
-
|
|
18749
|
+
for (const { item, operation } of this.reverse) {
|
|
18750
|
+
item.apply(operation);
|
|
18751
18751
|
}
|
|
18752
18752
|
}
|
|
18753
18753
|
getReverse() {
|
|
@@ -18779,8 +18779,8 @@ class FrameCommand {
|
|
|
18779
18779
|
}
|
|
18780
18780
|
}
|
|
18781
18781
|
revert() {
|
|
18782
|
-
for (const { item
|
|
18783
|
-
|
|
18782
|
+
for (const { item, operation } of this.reverse) {
|
|
18783
|
+
item.apply(operation);
|
|
18784
18784
|
}
|
|
18785
18785
|
}
|
|
18786
18786
|
getReverse() {
|
|
@@ -18822,21 +18822,23 @@ class FrameCommand {
|
|
|
18822
18822
|
};
|
|
18823
18823
|
});
|
|
18824
18824
|
default:
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18825
|
+
return mapItemsByOperation(frame, (item) => {
|
|
18826
|
+
const op = this.operation;
|
|
18827
|
+
let newData = {};
|
|
18828
|
+
if (op.prevData) {
|
|
18829
|
+
newData = { ...op.prevData };
|
|
18830
|
+
} else {
|
|
18831
|
+
Object.keys(op.newData).forEach((key) => {
|
|
18832
|
+
if (item[key]) {
|
|
18833
|
+
newData[key] = item[key];
|
|
18834
|
+
}
|
|
18835
|
+
});
|
|
18836
|
+
}
|
|
18837
|
+
return {
|
|
18838
|
+
...op,
|
|
18839
|
+
newData
|
|
18840
|
+
};
|
|
18841
|
+
});
|
|
18840
18842
|
}
|
|
18841
18843
|
}
|
|
18842
18844
|
}
|
|
@@ -18857,8 +18859,8 @@ class CommentCommand {
|
|
|
18857
18859
|
}
|
|
18858
18860
|
}
|
|
18859
18861
|
revert() {
|
|
18860
|
-
this.reverse.forEach(({ item
|
|
18861
|
-
|
|
18862
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
18863
|
+
item.apply(operation);
|
|
18862
18864
|
});
|
|
18863
18865
|
}
|
|
18864
18866
|
getReverse() {
|
|
@@ -19320,8 +19322,8 @@ class GroupCommand {
|
|
|
19320
19322
|
}
|
|
19321
19323
|
}
|
|
19322
19324
|
revert() {
|
|
19323
|
-
for (const { item
|
|
19324
|
-
|
|
19325
|
+
for (const { item, operation } of this.reverse) {
|
|
19326
|
+
item.apply(operation);
|
|
19325
19327
|
}
|
|
19326
19328
|
}
|
|
19327
19329
|
getReverse() {
|
|
@@ -19374,8 +19376,8 @@ class PlaceholderCommand {
|
|
|
19374
19376
|
}
|
|
19375
19377
|
}
|
|
19376
19378
|
revert() {
|
|
19377
|
-
for (const { item
|
|
19378
|
-
|
|
19379
|
+
for (const { item, operation } of this.reverse) {
|
|
19380
|
+
item.apply(operation);
|
|
19379
19381
|
}
|
|
19380
19382
|
}
|
|
19381
19383
|
getReverse() {
|
|
@@ -19469,26 +19471,26 @@ class BaseCommand {
|
|
|
19469
19471
|
return this;
|
|
19470
19472
|
}
|
|
19471
19473
|
apply() {
|
|
19472
|
-
for (const
|
|
19473
|
-
|
|
19474
|
+
for (const item of this.items) {
|
|
19475
|
+
item.apply(this.operation);
|
|
19474
19476
|
}
|
|
19475
19477
|
}
|
|
19476
19478
|
revert() {
|
|
19477
|
-
for (const { item
|
|
19478
|
-
|
|
19479
|
+
for (const { item, operation } of this.reverse) {
|
|
19480
|
+
item.apply(operation);
|
|
19479
19481
|
}
|
|
19480
19482
|
}
|
|
19481
19483
|
getReverse() {
|
|
19482
19484
|
const items = this.items;
|
|
19483
|
-
return mapItemsByOperation(items, (
|
|
19485
|
+
return mapItemsByOperation(items, (item) => {
|
|
19484
19486
|
const op = this.operation;
|
|
19485
19487
|
let newData = {};
|
|
19486
19488
|
if (op.prevData) {
|
|
19487
19489
|
newData = { ...op.prevData };
|
|
19488
19490
|
} else {
|
|
19489
19491
|
Object.keys(op.newData).forEach((key) => {
|
|
19490
|
-
if (
|
|
19491
|
-
newData[key] =
|
|
19492
|
+
if (item[key]) {
|
|
19493
|
+
newData[key] = item[key];
|
|
19492
19494
|
}
|
|
19493
19495
|
});
|
|
19494
19496
|
}
|
|
@@ -19516,37 +19518,37 @@ var itemCommandFactories = {
|
|
|
19516
19518
|
LinkTo: createLinkToCommand
|
|
19517
19519
|
};
|
|
19518
19520
|
function createConnectorCommand(items, operation) {
|
|
19519
|
-
return new ConnectorCommand(items.filter((
|
|
19521
|
+
return new ConnectorCommand(items.filter((item) => item.itemType === "Connector"), operation);
|
|
19520
19522
|
}
|
|
19521
19523
|
function createShapeCommand(items, operation) {
|
|
19522
|
-
return new ShapeCommand(items.filter((
|
|
19524
|
+
return new ShapeCommand(items.filter((item) => item.itemType === "Shape"), operation);
|
|
19523
19525
|
}
|
|
19524
19526
|
function createDrawingCommand(items, operation) {
|
|
19525
|
-
return new DrawingCommand(items.filter((
|
|
19527
|
+
return new DrawingCommand(items.filter((item) => item.itemType === "Drawing"), operation);
|
|
19526
19528
|
}
|
|
19527
19529
|
function createCommentCommand(items, operation) {
|
|
19528
|
-
return new CommentCommand(items.filter((
|
|
19530
|
+
return new CommentCommand(items.filter((item) => item.itemType === "Comment"), operation);
|
|
19529
19531
|
}
|
|
19530
19532
|
function createStickerCommand(items, operation) {
|
|
19531
|
-
return new StickerCommand(items.filter((
|
|
19533
|
+
return new StickerCommand(items.filter((item) => item.itemType === "Sticker"), operation);
|
|
19532
19534
|
}
|
|
19533
19535
|
function createFrameCommand(items, operation) {
|
|
19534
|
-
return new FrameCommand(items.filter((
|
|
19536
|
+
return new FrameCommand(items.filter((item) => item.itemType === "Frame"), operation);
|
|
19535
19537
|
}
|
|
19536
19538
|
function createPlaceholderCommand(items, operation) {
|
|
19537
|
-
return new PlaceholderCommand(items.filter((
|
|
19539
|
+
return new PlaceholderCommand(items.filter((item) => item.itemType === "Placeholder"), operation);
|
|
19538
19540
|
}
|
|
19539
19541
|
function createGroupCommand(items, operation) {
|
|
19540
|
-
return new GroupCommand(items.filter((
|
|
19542
|
+
return new GroupCommand(items.filter((item) => item.itemType === "Group"), operation);
|
|
19541
19543
|
}
|
|
19542
19544
|
function createImageCommand(items, operation) {
|
|
19543
|
-
return new ImageCommand(items.filter((
|
|
19545
|
+
return new ImageCommand(items.filter((item) => item.itemType === "Image"), operation);
|
|
19544
19546
|
}
|
|
19545
19547
|
function createVideoCommand(items, operation) {
|
|
19546
|
-
return new VideoCommand(items.filter((
|
|
19548
|
+
return new VideoCommand(items.filter((item) => item.itemType === "Video"), operation);
|
|
19547
19549
|
}
|
|
19548
19550
|
function createAudioCommand(items, operation) {
|
|
19549
|
-
return new AudioCommand(items.filter((
|
|
19551
|
+
return new AudioCommand(items.filter((item) => item.itemType === "Audio"), operation);
|
|
19550
19552
|
}
|
|
19551
19553
|
function createRichTextCommand(items, operation, board) {
|
|
19552
19554
|
if (!board) {
|
|
@@ -19554,8 +19556,8 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19554
19556
|
}
|
|
19555
19557
|
if (operation.method === "groupEdit") {
|
|
19556
19558
|
const texts = [];
|
|
19557
|
-
for (const { item
|
|
19558
|
-
const found = board.items.findById(
|
|
19559
|
+
for (const { item } of operation.itemsOps) {
|
|
19560
|
+
const found = board.items.findById(item);
|
|
19559
19561
|
const text3 = found?.getRichText();
|
|
19560
19562
|
if (text3) {
|
|
19561
19563
|
texts.push(text3);
|
|
@@ -19563,14 +19565,14 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19563
19565
|
}
|
|
19564
19566
|
return new RichTextGroupCommand(texts, operation);
|
|
19565
19567
|
} else {
|
|
19566
|
-
return new RichTextCommand(board, items.map((
|
|
19568
|
+
return new RichTextCommand(board, items.map((item) => item.getId()), operation);
|
|
19567
19569
|
}
|
|
19568
19570
|
}
|
|
19569
19571
|
function createTransformationCommand(items, operation) {
|
|
19570
|
-
return new TransformationCommand(items.map((
|
|
19572
|
+
return new TransformationCommand(items.map((item) => item.transformation), operation);
|
|
19571
19573
|
}
|
|
19572
19574
|
function createLinkToCommand(items, operation) {
|
|
19573
|
-
return new LinkToCommand(items.map((
|
|
19575
|
+
return new LinkToCommand(items.map((item) => item.linkTo), operation);
|
|
19574
19576
|
}
|
|
19575
19577
|
function createCommand(board, operation) {
|
|
19576
19578
|
try {
|
|
@@ -19588,13 +19590,13 @@ function createCommand(board, operation) {
|
|
|
19588
19590
|
default: {
|
|
19589
19591
|
const itemType = operation.class;
|
|
19590
19592
|
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);
|
|
19591
|
-
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((
|
|
19592
|
-
if (typeof
|
|
19593
|
-
console.warn(`Item with ID ${
|
|
19593
|
+
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
|
|
19594
|
+
if (typeof item === "string") {
|
|
19595
|
+
console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
|
|
19594
19596
|
return false;
|
|
19595
19597
|
}
|
|
19596
|
-
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" &&
|
|
19597
|
-
console.warn(`Item with ID ${
|
|
19598
|
+
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" && item.itemType !== operation.class) {
|
|
19599
|
+
console.warn(`Item with ID ${item} is not of operation type: ${itemType}.`);
|
|
19598
19600
|
return false;
|
|
19599
19601
|
}
|
|
19600
19602
|
return true;
|
|
@@ -19895,20 +19897,20 @@ class RBush {
|
|
|
19895
19897
|
}
|
|
19896
19898
|
return this;
|
|
19897
19899
|
}
|
|
19898
|
-
insert(
|
|
19899
|
-
if (
|
|
19900
|
-
this._insert(
|
|
19900
|
+
insert(item) {
|
|
19901
|
+
if (item)
|
|
19902
|
+
this._insert(item, this.data.height - 1);
|
|
19901
19903
|
return this;
|
|
19902
19904
|
}
|
|
19903
19905
|
clear() {
|
|
19904
19906
|
this.data = createNode([]);
|
|
19905
19907
|
return this;
|
|
19906
19908
|
}
|
|
19907
|
-
remove(
|
|
19908
|
-
if (!
|
|
19909
|
+
remove(item, equalsFn) {
|
|
19910
|
+
if (!item)
|
|
19909
19911
|
return this;
|
|
19910
19912
|
let node2 = this.data;
|
|
19911
|
-
const bbox = this.toBBox(
|
|
19913
|
+
const bbox = this.toBBox(item);
|
|
19912
19914
|
const path2 = [];
|
|
19913
19915
|
const indexes = [];
|
|
19914
19916
|
let i, parent, goingUp;
|
|
@@ -19920,7 +19922,7 @@ class RBush {
|
|
|
19920
19922
|
goingUp = true;
|
|
19921
19923
|
}
|
|
19922
19924
|
if (node2.leaf) {
|
|
19923
|
-
const index2 = findItem(
|
|
19925
|
+
const index2 = findItem(item, node2.children, equalsFn);
|
|
19924
19926
|
if (index2 !== -1) {
|
|
19925
19927
|
node2.children.splice(index2, 1);
|
|
19926
19928
|
path2.push(node2);
|
|
@@ -19943,8 +19945,8 @@ class RBush {
|
|
|
19943
19945
|
}
|
|
19944
19946
|
return this;
|
|
19945
19947
|
}
|
|
19946
|
-
toBBox(
|
|
19947
|
-
return
|
|
19948
|
+
toBBox(item) {
|
|
19949
|
+
return item;
|
|
19948
19950
|
}
|
|
19949
19951
|
compareMinX(a, b) {
|
|
19950
19952
|
return a.minX - b.minX;
|
|
@@ -20027,11 +20029,11 @@ class RBush {
|
|
|
20027
20029
|
}
|
|
20028
20030
|
return node2;
|
|
20029
20031
|
}
|
|
20030
|
-
_insert(
|
|
20031
|
-
const bbox = isNode ?
|
|
20032
|
+
_insert(item, level, isNode) {
|
|
20033
|
+
const bbox = isNode ? item : this.toBBox(item);
|
|
20032
20034
|
const insertPath = [];
|
|
20033
20035
|
const node2 = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
20034
|
-
node2.children.push(
|
|
20036
|
+
node2.children.push(item);
|
|
20035
20037
|
extend2(node2, bbox);
|
|
20036
20038
|
while (level >= 0) {
|
|
20037
20039
|
if (insertPath[level].children.length > this._maxEntries) {
|
|
@@ -20130,11 +20132,11 @@ class RBush {
|
|
|
20130
20132
|
}
|
|
20131
20133
|
}
|
|
20132
20134
|
}
|
|
20133
|
-
function findItem(
|
|
20135
|
+
function findItem(item, items, equalsFn) {
|
|
20134
20136
|
if (!equalsFn)
|
|
20135
|
-
return items.indexOf(
|
|
20137
|
+
return items.indexOf(item);
|
|
20136
20138
|
for (let i = 0;i < items.length; i++) {
|
|
20137
|
-
if (equalsFn(
|
|
20139
|
+
if (equalsFn(item, items[i]))
|
|
20138
20140
|
return i;
|
|
20139
20141
|
}
|
|
20140
20142
|
return -1;
|
|
@@ -20225,8 +20227,8 @@ class TinyQueue {
|
|
|
20225
20227
|
this._down(i);
|
|
20226
20228
|
}
|
|
20227
20229
|
}
|
|
20228
|
-
push(
|
|
20229
|
-
this.data.push(
|
|
20230
|
+
push(item) {
|
|
20231
|
+
this.data.push(item);
|
|
20230
20232
|
this.length++;
|
|
20231
20233
|
this._up(this.length - 1);
|
|
20232
20234
|
}
|
|
@@ -20247,21 +20249,21 @@ class TinyQueue {
|
|
|
20247
20249
|
}
|
|
20248
20250
|
_up(pos) {
|
|
20249
20251
|
const { data, compare } = this;
|
|
20250
|
-
const
|
|
20252
|
+
const item = data[pos];
|
|
20251
20253
|
while (pos > 0) {
|
|
20252
20254
|
const parent = pos - 1 >> 1;
|
|
20253
20255
|
const current = data[parent];
|
|
20254
|
-
if (compare(
|
|
20256
|
+
if (compare(item, current) >= 0)
|
|
20255
20257
|
break;
|
|
20256
20258
|
data[pos] = current;
|
|
20257
20259
|
pos = parent;
|
|
20258
20260
|
}
|
|
20259
|
-
data[pos] =
|
|
20261
|
+
data[pos] = item;
|
|
20260
20262
|
}
|
|
20261
20263
|
_down(pos) {
|
|
20262
20264
|
const { data, compare } = this;
|
|
20263
20265
|
const halfLength = this.length >> 1;
|
|
20264
|
-
const
|
|
20266
|
+
const item = data[pos];
|
|
20265
20267
|
while (pos < halfLength) {
|
|
20266
20268
|
let left = (pos << 1) + 1;
|
|
20267
20269
|
let best = data[left];
|
|
@@ -20270,12 +20272,12 @@ class TinyQueue {
|
|
|
20270
20272
|
left = right;
|
|
20271
20273
|
best = data[right];
|
|
20272
20274
|
}
|
|
20273
|
-
if (compare(best,
|
|
20275
|
+
if (compare(best, item) >= 0)
|
|
20274
20276
|
break;
|
|
20275
20277
|
data[pos] = best;
|
|
20276
20278
|
pos = left;
|
|
20277
20279
|
}
|
|
20278
|
-
data[pos] =
|
|
20280
|
+
data[pos] = item;
|
|
20279
20281
|
}
|
|
20280
20282
|
}
|
|
20281
20283
|
function defaultCompare2(a, b) {
|
|
@@ -20363,10 +20365,10 @@ class RTreeIndex {
|
|
|
20363
20365
|
return container ? container.item : undefined;
|
|
20364
20366
|
}
|
|
20365
20367
|
remove(id) {
|
|
20366
|
-
const
|
|
20367
|
-
if (
|
|
20368
|
+
const item = this.map.get(id);
|
|
20369
|
+
if (item) {
|
|
20368
20370
|
this.map.delete(id);
|
|
20369
|
-
this.tree.remove(
|
|
20371
|
+
this.tree.remove(item);
|
|
20370
20372
|
}
|
|
20371
20373
|
}
|
|
20372
20374
|
list() {
|
|
@@ -20438,11 +20440,11 @@ class Container extends Mbr {
|
|
|
20438
20440
|
item;
|
|
20439
20441
|
layer;
|
|
20440
20442
|
zIndex;
|
|
20441
|
-
constructor(id,
|
|
20442
|
-
const rect =
|
|
20443
|
+
constructor(id, item, layer, zIndex) {
|
|
20444
|
+
const rect = item.getMbrWithChildren();
|
|
20443
20445
|
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
20444
20446
|
this.id = id;
|
|
20445
|
-
this.item =
|
|
20447
|
+
this.item = item;
|
|
20446
20448
|
this.layer = layer;
|
|
20447
20449
|
this.zIndex = zIndex;
|
|
20448
20450
|
}
|
|
@@ -20459,7 +20461,7 @@ class LayeredIndex {
|
|
|
20459
20461
|
this.getZIndex = this.getZIndex.bind(this);
|
|
20460
20462
|
this.layers.newOnTop();
|
|
20461
20463
|
}
|
|
20462
|
-
isT(
|
|
20464
|
+
isT(item) {
|
|
20463
20465
|
return true;
|
|
20464
20466
|
}
|
|
20465
20467
|
findById(id) {
|
|
@@ -20523,8 +20525,8 @@ class LayeredIndex {
|
|
|
20523
20525
|
}
|
|
20524
20526
|
getContainersFromItems(items) {
|
|
20525
20527
|
const containers = [];
|
|
20526
|
-
for (const
|
|
20527
|
-
const container = this.map.get(
|
|
20528
|
+
for (const item of items) {
|
|
20529
|
+
const container = this.map.get(item.getId());
|
|
20528
20530
|
if (container) {
|
|
20529
20531
|
containers.push(container);
|
|
20530
20532
|
}
|
|
@@ -20601,9 +20603,9 @@ class LayeredIndex {
|
|
|
20601
20603
|
}
|
|
20602
20604
|
}
|
|
20603
20605
|
}
|
|
20604
|
-
insert(
|
|
20605
|
-
const toInsert = new Container(
|
|
20606
|
-
const bounds =
|
|
20606
|
+
insert(item) {
|
|
20607
|
+
const toInsert = new Container(item.getId(), item, 0, this.getZIndex(item));
|
|
20608
|
+
const bounds = item.getMbrWithChildren();
|
|
20607
20609
|
const inBounds = this.getRectsEnclosedOrCrossedBy(bounds);
|
|
20608
20610
|
if (inBounds.length === 0) {
|
|
20609
20611
|
return this.insertContainer(toInsert);
|
|
@@ -20670,20 +20672,20 @@ class LayeredIndex {
|
|
|
20670
20672
|
}
|
|
20671
20673
|
}
|
|
20672
20674
|
}
|
|
20673
|
-
change(
|
|
20674
|
-
const id =
|
|
20675
|
+
change(item) {
|
|
20676
|
+
const id = item.getId();
|
|
20675
20677
|
const container = this.map.get(id);
|
|
20676
20678
|
if (container) {
|
|
20677
20679
|
const layer = this.layers.get(container.layer);
|
|
20678
20680
|
if (layer) {
|
|
20679
20681
|
layer.remove(id);
|
|
20680
20682
|
this.map.delete(id);
|
|
20681
|
-
this.insert(
|
|
20683
|
+
this.insert(item);
|
|
20682
20684
|
}
|
|
20683
20685
|
}
|
|
20684
20686
|
}
|
|
20685
|
-
remove(
|
|
20686
|
-
const id =
|
|
20687
|
+
remove(item) {
|
|
20688
|
+
const id = item.getId();
|
|
20687
20689
|
const container = this.map.get(id);
|
|
20688
20690
|
if (container) {
|
|
20689
20691
|
const layer = this.layers.get(container.layer);
|
|
@@ -20709,13 +20711,13 @@ class LayeredIndex {
|
|
|
20709
20711
|
return items;
|
|
20710
20712
|
}
|
|
20711
20713
|
batchInsert(items) {
|
|
20712
|
-
for (const
|
|
20713
|
-
this.insert(
|
|
20714
|
+
for (const item of items) {
|
|
20715
|
+
this.insert(item);
|
|
20714
20716
|
}
|
|
20715
20717
|
}
|
|
20716
20718
|
batchChange(items) {
|
|
20717
|
-
for (const
|
|
20718
|
-
this.change(
|
|
20719
|
+
for (const item of items) {
|
|
20720
|
+
this.change(item);
|
|
20719
20721
|
}
|
|
20720
20722
|
}
|
|
20721
20723
|
}
|
|
@@ -20724,8 +20726,8 @@ class LayeredIndex {
|
|
|
20724
20726
|
class SpatialIndex {
|
|
20725
20727
|
subject = new Subject;
|
|
20726
20728
|
itemsArray = [];
|
|
20727
|
-
itemsIndex = new LayeredIndex((
|
|
20728
|
-
return this.itemsArray.indexOf(
|
|
20729
|
+
itemsIndex = new LayeredIndex((item) => {
|
|
20730
|
+
return this.itemsArray.indexOf(item);
|
|
20729
20731
|
});
|
|
20730
20732
|
Mbr = new Mbr;
|
|
20731
20733
|
items;
|
|
@@ -20734,79 +20736,79 @@ class SpatialIndex {
|
|
|
20734
20736
|
}
|
|
20735
20737
|
clear() {
|
|
20736
20738
|
this.itemsArray = [];
|
|
20737
|
-
this.itemsIndex = new LayeredIndex((
|
|
20738
|
-
return this.itemsArray.indexOf(
|
|
20739
|
+
this.itemsIndex = new LayeredIndex((item) => {
|
|
20740
|
+
return this.itemsArray.indexOf(item);
|
|
20739
20741
|
});
|
|
20740
20742
|
this.Mbr = new Mbr;
|
|
20741
20743
|
}
|
|
20742
|
-
insert(
|
|
20743
|
-
this.itemsArray.push(
|
|
20744
|
-
this.itemsIndex.insert(
|
|
20744
|
+
insert(item) {
|
|
20745
|
+
this.itemsArray.push(item);
|
|
20746
|
+
this.itemsIndex.insert(item);
|
|
20745
20747
|
if (conf.isNode()) {
|
|
20746
20748
|
return;
|
|
20747
20749
|
}
|
|
20748
20750
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20749
|
-
this.Mbr =
|
|
20751
|
+
this.Mbr = item.getMbr().copy();
|
|
20750
20752
|
} else {
|
|
20751
|
-
this.Mbr.combine([
|
|
20753
|
+
this.Mbr.combine([item.getMbr()]);
|
|
20752
20754
|
}
|
|
20753
|
-
|
|
20755
|
+
item.subject.subscribe(this.change);
|
|
20754
20756
|
this.subject.publish(this.items);
|
|
20755
20757
|
}
|
|
20756
|
-
change = (
|
|
20757
|
-
this.itemsIndex.change(
|
|
20758
|
+
change = (item) => {
|
|
20759
|
+
this.itemsIndex.change(item);
|
|
20758
20760
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20759
|
-
this.Mbr =
|
|
20761
|
+
this.Mbr = item.getMbrWithChildren().copy();
|
|
20760
20762
|
} else {
|
|
20761
|
-
this.Mbr.combine([
|
|
20763
|
+
this.Mbr.combine([item.getMbrWithChildren()]);
|
|
20762
20764
|
}
|
|
20763
20765
|
this.subject.publish(this.items);
|
|
20764
20766
|
};
|
|
20765
|
-
remove(
|
|
20766
|
-
if ("index" in
|
|
20767
|
-
|
|
20767
|
+
remove(item) {
|
|
20768
|
+
if ("index" in item && item.index) {
|
|
20769
|
+
item.removeChildItems(item.index.list());
|
|
20768
20770
|
}
|
|
20769
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
20770
|
-
this.itemsIndex.remove(
|
|
20771
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
20772
|
+
this.itemsIndex.remove(item);
|
|
20771
20773
|
this.Mbr = new Mbr;
|
|
20772
|
-
this.itemsArray.forEach((
|
|
20774
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
|
|
20773
20775
|
this.subject.publish(this.items);
|
|
20774
20776
|
}
|
|
20775
20777
|
copy() {
|
|
20776
|
-
return this.getItemsWithIncludedChildren(this.itemsArray).map((
|
|
20777
|
-
...
|
|
20778
|
-
id:
|
|
20778
|
+
return this.getItemsWithIncludedChildren(this.itemsArray).map((item) => ({
|
|
20779
|
+
...item.serialize(true),
|
|
20780
|
+
id: item.getId()
|
|
20779
20781
|
}));
|
|
20780
20782
|
}
|
|
20781
20783
|
getItemsWithIncludedChildren(items) {
|
|
20782
|
-
return items.flatMap((
|
|
20783
|
-
if ("index" in
|
|
20784
|
-
return [
|
|
20784
|
+
return items.flatMap((item) => {
|
|
20785
|
+
if ("index" in item && item.index) {
|
|
20786
|
+
return [item, ...item.index.list()];
|
|
20785
20787
|
}
|
|
20786
|
-
return
|
|
20788
|
+
return item;
|
|
20787
20789
|
});
|
|
20788
20790
|
}
|
|
20789
|
-
getItemChildren(
|
|
20790
|
-
if ("index" in
|
|
20791
|
-
return
|
|
20791
|
+
getItemChildren(item) {
|
|
20792
|
+
if ("index" in item && item.index) {
|
|
20793
|
+
return item.index.list();
|
|
20792
20794
|
}
|
|
20793
20795
|
return [];
|
|
20794
20796
|
}
|
|
20795
|
-
getItemParent(
|
|
20796
|
-
if (
|
|
20797
|
+
getItemParent(item) {
|
|
20798
|
+
if (item.parent === "Board") {
|
|
20797
20799
|
return;
|
|
20798
20800
|
}
|
|
20799
|
-
return this.getById(
|
|
20801
|
+
return this.getById(item.parent);
|
|
20800
20802
|
}
|
|
20801
|
-
moveToZIndex(
|
|
20802
|
-
const index2 = this.itemsArray.indexOf(
|
|
20803
|
+
moveToZIndex(item, zIndex) {
|
|
20804
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20803
20805
|
this.itemsArray.splice(index2, 1);
|
|
20804
|
-
this.itemsArray.splice(zIndex, 0,
|
|
20805
|
-
this.change(
|
|
20806
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
20807
|
+
this.change(item);
|
|
20806
20808
|
this.subject.publish(this.items);
|
|
20807
20809
|
}
|
|
20808
20810
|
moveManyToZIndex(itemsRecord) {
|
|
20809
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
20811
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
20810
20812
|
const zIndex = Object.values(itemsRecord);
|
|
20811
20813
|
for (let i = 0;i < zIndex.length; i++) {
|
|
20812
20814
|
const index2 = zIndex[i];
|
|
@@ -20814,39 +20816,39 @@ class SpatialIndex {
|
|
|
20814
20816
|
}
|
|
20815
20817
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20816
20818
|
}
|
|
20817
|
-
sendToBack(
|
|
20818
|
-
const index2 = this.itemsArray.indexOf(
|
|
20819
|
+
sendToBack(item, shouldPublish = true) {
|
|
20820
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20819
20821
|
this.itemsArray.splice(index2, 1);
|
|
20820
|
-
this.itemsArray.unshift(
|
|
20821
|
-
this.itemsIndex.change(
|
|
20822
|
+
this.itemsArray.unshift(item);
|
|
20823
|
+
this.itemsIndex.change(item);
|
|
20822
20824
|
if (shouldPublish) {
|
|
20823
20825
|
this.subject.publish(this.items);
|
|
20824
20826
|
}
|
|
20825
20827
|
}
|
|
20826
20828
|
sendManyToBack(items) {
|
|
20827
20829
|
const newItems = [...items];
|
|
20828
|
-
this.itemsArray.forEach((
|
|
20829
|
-
if (!items.includes(
|
|
20830
|
-
newItems.push(
|
|
20830
|
+
this.itemsArray.forEach((item) => {
|
|
20831
|
+
if (!items.includes(item)) {
|
|
20832
|
+
newItems.push(item);
|
|
20831
20833
|
}
|
|
20832
20834
|
});
|
|
20833
20835
|
this.itemsArray = newItems;
|
|
20834
20836
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20835
20837
|
}
|
|
20836
|
-
bringToFront(
|
|
20837
|
-
const index2 = this.itemsArray.indexOf(
|
|
20838
|
+
bringToFront(item, shouldPublish = true) {
|
|
20839
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20838
20840
|
this.itemsArray.splice(index2, 1);
|
|
20839
|
-
this.itemsArray.push(
|
|
20840
|
-
this.itemsIndex.change(
|
|
20841
|
+
this.itemsArray.push(item);
|
|
20842
|
+
this.itemsIndex.change(item);
|
|
20841
20843
|
if (shouldPublish) {
|
|
20842
20844
|
this.subject.publish(this.items);
|
|
20843
20845
|
}
|
|
20844
20846
|
}
|
|
20845
20847
|
bringManyToFront(items) {
|
|
20846
20848
|
const newItems = [];
|
|
20847
|
-
this.itemsArray.forEach((
|
|
20848
|
-
if (!items.includes(
|
|
20849
|
-
newItems.push(
|
|
20849
|
+
this.itemsArray.forEach((item) => {
|
|
20850
|
+
if (!items.includes(item)) {
|
|
20851
|
+
newItems.push(item);
|
|
20850
20852
|
}
|
|
20851
20853
|
});
|
|
20852
20854
|
newItems.push(...items);
|
|
@@ -20872,9 +20874,9 @@ class SpatialIndex {
|
|
|
20872
20874
|
this.subject.publish(this.items);
|
|
20873
20875
|
}
|
|
20874
20876
|
getById(id) {
|
|
20875
|
-
const
|
|
20876
|
-
if (
|
|
20877
|
-
return
|
|
20877
|
+
const item = this.getItemsWithIncludedChildren(this.itemsArray).find((item2) => item2.getId() === id);
|
|
20878
|
+
if (item) {
|
|
20879
|
+
return item;
|
|
20878
20880
|
}
|
|
20879
20881
|
}
|
|
20880
20882
|
findById(id) {
|
|
@@ -20884,10 +20886,10 @@ class SpatialIndex {
|
|
|
20884
20886
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20885
20887
|
const items = this.itemsIndex.getEnclosed(mbr);
|
|
20886
20888
|
const children = [];
|
|
20887
|
-
const clearItems = items.filter((
|
|
20888
|
-
if ("index" in
|
|
20889
|
-
children.push(...
|
|
20890
|
-
if (!
|
|
20889
|
+
const clearItems = items.filter((item) => {
|
|
20890
|
+
if ("index" in item && item.index) {
|
|
20891
|
+
children.push(...item.index.getEnclosed(left, top, right, bottom));
|
|
20892
|
+
if (!item.getMbr().isEnclosedBy(mbr)) {
|
|
20891
20893
|
return false;
|
|
20892
20894
|
}
|
|
20893
20895
|
}
|
|
@@ -20899,10 +20901,10 @@ class SpatialIndex {
|
|
|
20899
20901
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20900
20902
|
const items = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
20901
20903
|
const children = [];
|
|
20902
|
-
const clearItems = items.filter((
|
|
20903
|
-
if ("index" in
|
|
20904
|
-
children.push(...
|
|
20905
|
-
if (!
|
|
20904
|
+
const clearItems = items.filter((item) => {
|
|
20905
|
+
if ("index" in item && item.index) {
|
|
20906
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20907
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20906
20908
|
return false;
|
|
20907
20909
|
}
|
|
20908
20910
|
}
|
|
@@ -20913,10 +20915,10 @@ class SpatialIndex {
|
|
|
20913
20915
|
getUnderPoint(point3, tolerance = 5) {
|
|
20914
20916
|
const items = this.itemsIndex.getUnderPoint(point3, tolerance);
|
|
20915
20917
|
const children = [];
|
|
20916
|
-
const clearItems = items.filter((
|
|
20917
|
-
if ("index" in
|
|
20918
|
-
children.push(...
|
|
20919
|
-
if (!
|
|
20918
|
+
const clearItems = items.filter((item) => {
|
|
20919
|
+
if ("index" in item && item.index) {
|
|
20920
|
+
children.push(...item.index.getUnderPoint(point3, tolerance));
|
|
20921
|
+
if (!item.getMbr().isUnderPoint(point3)) {
|
|
20920
20922
|
return false;
|
|
20921
20923
|
}
|
|
20922
20924
|
}
|
|
@@ -20928,10 +20930,10 @@ class SpatialIndex {
|
|
|
20928
20930
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20929
20931
|
const items = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
20930
20932
|
const children = [];
|
|
20931
|
-
const clearItems = items.filter((
|
|
20932
|
-
if ("index" in
|
|
20933
|
-
children.push(...
|
|
20934
|
-
if (!
|
|
20933
|
+
const clearItems = items.filter((item) => {
|
|
20934
|
+
if ("index" in item && item.index) {
|
|
20935
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20936
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20935
20937
|
return false;
|
|
20936
20938
|
}
|
|
20937
20939
|
}
|
|
@@ -20943,26 +20945,26 @@ class SpatialIndex {
|
|
|
20943
20945
|
return this.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
20944
20946
|
}
|
|
20945
20947
|
getComments() {
|
|
20946
|
-
return this.itemsArray.filter((
|
|
20948
|
+
return this.itemsArray.filter((item) => item instanceof Comment);
|
|
20947
20949
|
}
|
|
20948
20950
|
getMbr() {
|
|
20949
20951
|
return this.Mbr;
|
|
20950
20952
|
}
|
|
20951
20953
|
getNearestTo(point3, maxItems, filter, maxDistance) {
|
|
20952
20954
|
const allItems = this.getItemsWithIncludedChildren(this.itemsArray);
|
|
20953
|
-
const filtered = allItems.filter((
|
|
20954
|
-
const withDistance = filtered.map((
|
|
20955
|
-
item
|
|
20956
|
-
distance: point3.getDistance(
|
|
20955
|
+
const filtered = allItems.filter((item) => filter(item));
|
|
20956
|
+
const withDistance = filtered.map((item) => ({
|
|
20957
|
+
item,
|
|
20958
|
+
distance: point3.getDistance(item.getMbr().getCenter())
|
|
20957
20959
|
})).filter(({ distance }) => distance <= maxDistance);
|
|
20958
20960
|
withDistance.sort((a, b) => a.distance - b.distance);
|
|
20959
|
-
return withDistance.slice(0, maxItems).map(({ item
|
|
20961
|
+
return withDistance.slice(0, maxItems).map(({ item }) => item);
|
|
20960
20962
|
}
|
|
20961
20963
|
list() {
|
|
20962
20964
|
return this.getItemsWithIncludedChildren(this.itemsArray).concat();
|
|
20963
20965
|
}
|
|
20964
|
-
getZIndex(
|
|
20965
|
-
const index2 = this.itemsArray.indexOf(
|
|
20966
|
+
getZIndex(item) {
|
|
20967
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20966
20968
|
if (index2 === -1) {
|
|
20967
20969
|
return this.getLastZIndex();
|
|
20968
20970
|
}
|
|
@@ -20992,14 +20994,14 @@ class Items {
|
|
|
20992
20994
|
this.pointer = pointer;
|
|
20993
20995
|
this.subject = subject;
|
|
20994
20996
|
}
|
|
20995
|
-
update(
|
|
20996
|
-
this.index.change(
|
|
20997
|
+
update(item) {
|
|
20998
|
+
this.index.change(item);
|
|
20997
20999
|
}
|
|
20998
21000
|
listAll() {
|
|
20999
21001
|
return this.index.list();
|
|
21000
21002
|
}
|
|
21001
21003
|
listGroupItems() {
|
|
21002
|
-
return this.index.list().filter((
|
|
21004
|
+
return this.index.list().filter((item) => ("index" in item) && item.index);
|
|
21003
21005
|
}
|
|
21004
21006
|
getById(id) {
|
|
21005
21007
|
return this.index.getById(id);
|
|
@@ -21014,7 +21016,7 @@ class Items {
|
|
|
21014
21016
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
21015
21017
|
}
|
|
21016
21018
|
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
21017
|
-
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
21019
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.index);
|
|
21018
21020
|
}
|
|
21019
21021
|
getUnderPoint(point3, tolerance = 5) {
|
|
21020
21022
|
return this.index.getUnderPoint(point3, tolerance);
|
|
@@ -21042,28 +21044,28 @@ class Items {
|
|
|
21042
21044
|
const unmodifiedSize = size;
|
|
21043
21045
|
size = 16;
|
|
21044
21046
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
21045
|
-
const groups = tolerated.filter((
|
|
21047
|
+
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
21046
21048
|
if (groups.length > 0) {
|
|
21047
21049
|
return groups;
|
|
21048
21050
|
}
|
|
21049
|
-
let enclosed = tolerated.some((
|
|
21051
|
+
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
21050
21052
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
21051
21053
|
if (enclosed.length === 0) {
|
|
21052
21054
|
enclosed = underPointer;
|
|
21053
21055
|
}
|
|
21054
|
-
if (underPointer.some((
|
|
21056
|
+
if (underPointer.some((item) => item.itemType === "Drawing")) {
|
|
21055
21057
|
enclosed = [...underPointer, ...enclosed];
|
|
21056
21058
|
}
|
|
21057
|
-
const { nearest } = enclosed.reduce((acc,
|
|
21058
|
-
const area =
|
|
21059
|
-
if (
|
|
21059
|
+
const { nearest } = enclosed.reduce((acc, item) => {
|
|
21060
|
+
const area = item.getMbr().getHeight() * item.getMbr().getWidth();
|
|
21061
|
+
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
21060
21062
|
return acc;
|
|
21061
21063
|
}
|
|
21062
|
-
const isItemTransparent =
|
|
21063
|
-
const itemZIndex = this.getZIndex(
|
|
21064
|
+
const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
|
|
21065
|
+
const itemZIndex = this.getZIndex(item);
|
|
21064
21066
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
21065
21067
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
21066
|
-
return { nearest:
|
|
21068
|
+
return { nearest: item, area };
|
|
21067
21069
|
}
|
|
21068
21070
|
return acc;
|
|
21069
21071
|
}, { nearest: undefined, area: Infinity });
|
|
@@ -21075,8 +21077,8 @@ class Items {
|
|
|
21075
21077
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
21076
21078
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
21077
21079
|
}
|
|
21078
|
-
getZIndex(
|
|
21079
|
-
return this.index.getZIndex(
|
|
21080
|
+
getZIndex(item) {
|
|
21081
|
+
return this.index.getZIndex(item);
|
|
21080
21082
|
}
|
|
21081
21083
|
getByZIndex(index2) {
|
|
21082
21084
|
return this.index.getByZIndex(index2);
|
|
@@ -21085,11 +21087,11 @@ class Items {
|
|
|
21085
21087
|
return this.index.getLastZIndex();
|
|
21086
21088
|
}
|
|
21087
21089
|
getLinkedConnectorsById(id) {
|
|
21088
|
-
return this.listAll().filter((
|
|
21089
|
-
if (!(
|
|
21090
|
+
return this.listAll().filter((item) => {
|
|
21091
|
+
if (!(item instanceof Connector2)) {
|
|
21090
21092
|
return false;
|
|
21091
21093
|
}
|
|
21092
|
-
const { startItem, endItem } =
|
|
21094
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
21093
21095
|
if (startItem?.getId() === id || endItem?.getId() === id) {
|
|
21094
21096
|
return true;
|
|
21095
21097
|
}
|
|
@@ -21100,11 +21102,11 @@ class Items {
|
|
|
21100
21102
|
if (!startPointerItemId && !endPointerItemId) {
|
|
21101
21103
|
return [];
|
|
21102
21104
|
}
|
|
21103
|
-
return this.listAll().filter((
|
|
21104
|
-
if (!(
|
|
21105
|
+
return this.listAll().filter((item) => {
|
|
21106
|
+
if (!(item instanceof Connector2) || !item.isConnected()) {
|
|
21105
21107
|
return false;
|
|
21106
21108
|
}
|
|
21107
|
-
const { startItem, endItem } =
|
|
21109
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
21108
21110
|
if (startPointerItemId && endPointerItemId) {
|
|
21109
21111
|
if (startPointerItemId && startItem && startItem.getId() === startPointerItemId && endPointerItemId && endItem && endItem.getId() === endPointerItemId) {
|
|
21110
21112
|
return true;
|
|
@@ -21122,9 +21124,9 @@ class Items {
|
|
|
21122
21124
|
}
|
|
21123
21125
|
render(context) {
|
|
21124
21126
|
const items = this.getItemsInView();
|
|
21125
|
-
items.forEach((
|
|
21126
|
-
if (
|
|
21127
|
-
|
|
21127
|
+
items.forEach((item) => {
|
|
21128
|
+
if (item.parent === "Board") {
|
|
21129
|
+
item.render(context);
|
|
21128
21130
|
}
|
|
21129
21131
|
});
|
|
21130
21132
|
}
|
|
@@ -21137,17 +21139,17 @@ class Items {
|
|
|
21137
21139
|
return this.getHTML(documentFactory, items);
|
|
21138
21140
|
}
|
|
21139
21141
|
getHTML(documentFactory, items) {
|
|
21140
|
-
const lowestCoordinates = items.map((
|
|
21142
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
21141
21143
|
left: Math.min(acc.left, mbr.left),
|
|
21142
21144
|
top: Math.min(acc.top, mbr.top)
|
|
21143
21145
|
}), { left: 0, top: 0 });
|
|
21144
21146
|
const groups = [];
|
|
21145
21147
|
const rest = [];
|
|
21146
|
-
items.forEach((
|
|
21147
|
-
if ("index" in
|
|
21148
|
-
groups.push(
|
|
21148
|
+
items.forEach((item) => {
|
|
21149
|
+
if ("index" in item && item.index) {
|
|
21150
|
+
groups.push(item);
|
|
21149
21151
|
} else {
|
|
21150
|
-
rest.push(
|
|
21152
|
+
rest.push(item);
|
|
21151
21153
|
}
|
|
21152
21154
|
});
|
|
21153
21155
|
const childrenMap = new Map;
|
|
@@ -21157,34 +21159,34 @@ class Items {
|
|
|
21157
21159
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21158
21160
|
return html;
|
|
21159
21161
|
});
|
|
21160
|
-
const restHTML = rest.map((
|
|
21161
|
-
if (
|
|
21162
|
-
const startX = parseFloat(
|
|
21163
|
-
const startY = parseFloat(
|
|
21164
|
-
const endX = parseFloat(
|
|
21165
|
-
const endY = parseFloat(
|
|
21166
|
-
|
|
21167
|
-
|
|
21168
|
-
|
|
21169
|
-
|
|
21170
|
-
}
|
|
21171
|
-
return translateElementBy(
|
|
21172
|
-
});
|
|
21173
|
-
for (const
|
|
21174
|
-
const parentFrameId = childrenMap.get(
|
|
21162
|
+
const restHTML = rest.map((item) => ("renderHTML" in item) && item.renderHTML(documentFactory)).filter((item) => !!item).map((item) => {
|
|
21163
|
+
if (item.tagName.toLowerCase() === "connector-item") {
|
|
21164
|
+
const startX = parseFloat(item.getAttribute("data-start-point-x") || "0");
|
|
21165
|
+
const startY = parseFloat(item.getAttribute("data-start-point-y") || "0");
|
|
21166
|
+
const endX = parseFloat(item.getAttribute("data-end-point-x") || "0");
|
|
21167
|
+
const endY = parseFloat(item.getAttribute("data-end-point-y") || "0");
|
|
21168
|
+
item.setAttribute("data-start-point-x", (startX - lowestCoordinates.left).toString());
|
|
21169
|
+
item.setAttribute("data-start-point-y", (startY - lowestCoordinates.top).toString());
|
|
21170
|
+
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21171
|
+
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21172
|
+
}
|
|
21173
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21174
|
+
});
|
|
21175
|
+
for (const item of restHTML) {
|
|
21176
|
+
const parentFrameId = childrenMap.get(item.id);
|
|
21175
21177
|
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
21176
21178
|
if (group) {
|
|
21177
|
-
positionRelatively(
|
|
21178
|
-
group.appendChild(
|
|
21179
|
+
positionRelatively(item, group);
|
|
21180
|
+
group.appendChild(item);
|
|
21179
21181
|
}
|
|
21180
21182
|
}
|
|
21181
21183
|
let result = "";
|
|
21182
21184
|
for (const group of GroupsHTML) {
|
|
21183
21185
|
result += group.outerHTML;
|
|
21184
21186
|
}
|
|
21185
|
-
for (const
|
|
21186
|
-
if (!childrenMap.get(
|
|
21187
|
-
result +=
|
|
21187
|
+
for (const item of restHTML) {
|
|
21188
|
+
if (!childrenMap.get(item.id)) {
|
|
21189
|
+
result += item.outerHTML;
|
|
21188
21190
|
}
|
|
21189
21191
|
}
|
|
21190
21192
|
return result;
|
|
@@ -21204,52 +21206,52 @@ class SimpleSpatialIndex {
|
|
|
21204
21206
|
this.itemsArray = [];
|
|
21205
21207
|
this.Mbr = new Mbr;
|
|
21206
21208
|
}
|
|
21207
|
-
insert(
|
|
21208
|
-
this.itemsArray.push(
|
|
21209
|
+
insert(item) {
|
|
21210
|
+
this.itemsArray.push(item);
|
|
21209
21211
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21210
|
-
this.Mbr =
|
|
21212
|
+
this.Mbr = item.getMbr().copy();
|
|
21211
21213
|
} else {
|
|
21212
|
-
this.Mbr.combine([
|
|
21214
|
+
this.Mbr.combine([item.getMbr()]);
|
|
21213
21215
|
}
|
|
21214
|
-
|
|
21216
|
+
item.subject.subscribe(this.change);
|
|
21215
21217
|
this.subject.publish(this.items);
|
|
21216
21218
|
}
|
|
21217
|
-
change = (
|
|
21219
|
+
change = (item) => {
|
|
21218
21220
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21219
|
-
this.Mbr =
|
|
21221
|
+
this.Mbr = item.getMbr().copy();
|
|
21220
21222
|
} else {
|
|
21221
|
-
this.Mbr.combine([
|
|
21223
|
+
this.Mbr.combine([item.getMbr()]);
|
|
21222
21224
|
}
|
|
21223
21225
|
this.subject.publish(this.items);
|
|
21224
21226
|
};
|
|
21225
|
-
remove(
|
|
21226
|
-
if ("index" in
|
|
21227
|
-
|
|
21227
|
+
remove(item) {
|
|
21228
|
+
if ("index" in item && item.index) {
|
|
21229
|
+
item.removeChildItems(item.index.list());
|
|
21228
21230
|
}
|
|
21229
|
-
if (
|
|
21230
|
-
const parentFrame = this.items.getById(
|
|
21231
|
-
parentFrame?.removeChildItems(
|
|
21231
|
+
if (item.parent !== "Board") {
|
|
21232
|
+
const parentFrame = this.items.getById(item.parent);
|
|
21233
|
+
parentFrame?.removeChildItems(item);
|
|
21232
21234
|
}
|
|
21233
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
21235
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
21234
21236
|
this.Mbr = new Mbr;
|
|
21235
|
-
this.itemsArray.forEach((
|
|
21237
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
21236
21238
|
this.subject.publish(this.items);
|
|
21237
21239
|
}
|
|
21238
21240
|
copy() {
|
|
21239
|
-
return this.itemsArray.map((
|
|
21240
|
-
...
|
|
21241
|
-
id:
|
|
21241
|
+
return this.itemsArray.map((item) => ({
|
|
21242
|
+
...item.serialize(true),
|
|
21243
|
+
id: item.getId()
|
|
21242
21244
|
}));
|
|
21243
21245
|
}
|
|
21244
|
-
moveToZIndex(
|
|
21245
|
-
const index2 = this.itemsArray.indexOf(
|
|
21246
|
+
moveToZIndex(item, zIndex) {
|
|
21247
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21246
21248
|
this.itemsArray.splice(index2, 1);
|
|
21247
|
-
this.itemsArray.splice(zIndex, 0,
|
|
21248
|
-
this.change(
|
|
21249
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
21250
|
+
this.change(item);
|
|
21249
21251
|
this.subject.publish(this.items);
|
|
21250
21252
|
}
|
|
21251
21253
|
moveManyToZIndex(itemsRecord) {
|
|
21252
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
21254
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
21253
21255
|
const zIndex = Object.values(itemsRecord);
|
|
21254
21256
|
for (let i = 0;i < zIndex.length; i++) {
|
|
21255
21257
|
const index2 = zIndex[i];
|
|
@@ -21257,37 +21259,37 @@ class SimpleSpatialIndex {
|
|
|
21257
21259
|
}
|
|
21258
21260
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21259
21261
|
}
|
|
21260
|
-
sendToBack(
|
|
21261
|
-
const index2 = this.itemsArray.indexOf(
|
|
21262
|
+
sendToBack(item, shouldPublish = true) {
|
|
21263
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21262
21264
|
this.itemsArray.splice(index2, 1);
|
|
21263
|
-
this.itemsArray.unshift(
|
|
21265
|
+
this.itemsArray.unshift(item);
|
|
21264
21266
|
if (shouldPublish) {
|
|
21265
21267
|
this.subject.publish(this.items);
|
|
21266
21268
|
}
|
|
21267
21269
|
}
|
|
21268
21270
|
sendManyToBack(items) {
|
|
21269
21271
|
const newItems = [...items];
|
|
21270
|
-
this.itemsArray.forEach((
|
|
21271
|
-
if (!items.includes(
|
|
21272
|
-
newItems.push(
|
|
21272
|
+
this.itemsArray.forEach((item) => {
|
|
21273
|
+
if (!items.includes(item)) {
|
|
21274
|
+
newItems.push(item);
|
|
21273
21275
|
}
|
|
21274
21276
|
});
|
|
21275
21277
|
this.itemsArray = newItems;
|
|
21276
21278
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21277
21279
|
}
|
|
21278
|
-
bringToFront(
|
|
21279
|
-
const index2 = this.itemsArray.indexOf(
|
|
21280
|
+
bringToFront(item, shouldPublish = true) {
|
|
21281
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21280
21282
|
this.itemsArray.splice(index2, 1);
|
|
21281
|
-
this.itemsArray.push(
|
|
21283
|
+
this.itemsArray.push(item);
|
|
21282
21284
|
if (shouldPublish) {
|
|
21283
21285
|
this.subject.publish(this.items);
|
|
21284
21286
|
}
|
|
21285
21287
|
}
|
|
21286
21288
|
bringManyToFront(items) {
|
|
21287
21289
|
const newItems = [];
|
|
21288
|
-
this.itemsArray.forEach((
|
|
21289
|
-
if (!items.includes(
|
|
21290
|
-
newItems.push(
|
|
21290
|
+
this.itemsArray.forEach((item) => {
|
|
21291
|
+
if (!items.includes(item)) {
|
|
21292
|
+
newItems.push(item);
|
|
21291
21293
|
}
|
|
21292
21294
|
});
|
|
21293
21295
|
newItems.push(...items);
|
|
@@ -21313,9 +21315,9 @@ class SimpleSpatialIndex {
|
|
|
21313
21315
|
this.subject.publish(this.items);
|
|
21314
21316
|
}
|
|
21315
21317
|
getById(id) {
|
|
21316
|
-
const
|
|
21317
|
-
if (
|
|
21318
|
-
return
|
|
21318
|
+
const item = this.itemsArray.find((item2) => item2.getId() === id);
|
|
21319
|
+
if (item) {
|
|
21320
|
+
return item;
|
|
21319
21321
|
}
|
|
21320
21322
|
}
|
|
21321
21323
|
findById(id) {
|
|
@@ -21324,9 +21326,9 @@ class SimpleSpatialIndex {
|
|
|
21324
21326
|
getEnclosed(left, top, right, bottom) {
|
|
21325
21327
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21326
21328
|
const items = [];
|
|
21327
|
-
this.itemsArray.forEach((
|
|
21328
|
-
if (
|
|
21329
|
-
items.push(
|
|
21329
|
+
this.itemsArray.forEach((item) => {
|
|
21330
|
+
if (item.isEnclosedBy(mbr)) {
|
|
21331
|
+
items.push(item);
|
|
21330
21332
|
}
|
|
21331
21333
|
});
|
|
21332
21334
|
return items;
|
|
@@ -21334,18 +21336,18 @@ class SimpleSpatialIndex {
|
|
|
21334
21336
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
21335
21337
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21336
21338
|
const items = [];
|
|
21337
|
-
this.itemsArray.forEach((
|
|
21338
|
-
if (
|
|
21339
|
-
items.push(
|
|
21339
|
+
this.itemsArray.forEach((item) => {
|
|
21340
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
21341
|
+
items.push(item);
|
|
21340
21342
|
}
|
|
21341
21343
|
});
|
|
21342
21344
|
return items;
|
|
21343
21345
|
}
|
|
21344
21346
|
getUnderPoint(point3, tolerace = 5) {
|
|
21345
21347
|
const items = [];
|
|
21346
|
-
this.itemsArray.forEach((
|
|
21347
|
-
if (
|
|
21348
|
-
items.push(
|
|
21348
|
+
this.itemsArray.forEach((item) => {
|
|
21349
|
+
if (item.isUnderPoint(point3, tolerace)) {
|
|
21350
|
+
items.push(item);
|
|
21349
21351
|
}
|
|
21350
21352
|
});
|
|
21351
21353
|
return items;
|
|
@@ -21356,8 +21358,8 @@ class SimpleSpatialIndex {
|
|
|
21356
21358
|
list() {
|
|
21357
21359
|
return this.itemsArray.concat();
|
|
21358
21360
|
}
|
|
21359
|
-
getZIndex(
|
|
21360
|
-
return this.itemsArray.indexOf(
|
|
21361
|
+
getZIndex(item) {
|
|
21362
|
+
return this.itemsArray.indexOf(item);
|
|
21361
21363
|
}
|
|
21362
21364
|
getLastZIndex() {
|
|
21363
21365
|
return this.itemsArray.length - 1;
|
|
@@ -21371,8 +21373,8 @@ class SimpleSpatialIndex {
|
|
|
21371
21373
|
}
|
|
21372
21374
|
}
|
|
21373
21375
|
render(context) {
|
|
21374
|
-
this.itemsArray.forEach((
|
|
21375
|
-
|
|
21376
|
+
this.itemsArray.forEach((item) => {
|
|
21377
|
+
item.render(context);
|
|
21376
21378
|
});
|
|
21377
21379
|
}
|
|
21378
21380
|
}
|
|
@@ -21423,7 +21425,7 @@ class BaseItem extends Mbr {
|
|
|
21423
21425
|
if (!this.index) {
|
|
21424
21426
|
return null;
|
|
21425
21427
|
}
|
|
21426
|
-
return this.index.items.listAll().map((
|
|
21428
|
+
return this.index.items.listAll().map((item) => item.getId());
|
|
21427
21429
|
}
|
|
21428
21430
|
addChildItems(children) {
|
|
21429
21431
|
if (!this.index) {
|
|
@@ -21461,17 +21463,17 @@ class BaseItem extends Mbr {
|
|
|
21461
21463
|
this.addChildItems(itemsToAdd);
|
|
21462
21464
|
this.removeChildItems(itemsToRemove);
|
|
21463
21465
|
}
|
|
21464
|
-
handleNesting(
|
|
21465
|
-
const isItem = "itemType" in
|
|
21466
|
-
const itemMbr = isItem ?
|
|
21467
|
-
if (
|
|
21466
|
+
handleNesting(item, options) {
|
|
21467
|
+
const isItem = "itemType" in item;
|
|
21468
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
21469
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
21468
21470
|
return false;
|
|
21469
21471
|
}
|
|
21470
|
-
if (options?.cancelIfChild && isItem &&
|
|
21472
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
21471
21473
|
return false;
|
|
21472
21474
|
}
|
|
21473
21475
|
const mbr = this.getMbr().copy();
|
|
21474
|
-
if (
|
|
21476
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
21475
21477
|
if (mbr.isInside(itemMbr.getCenter())) {
|
|
21476
21478
|
if (!options || !options.onlyForOut) {
|
|
21477
21479
|
return true;
|
|
@@ -23768,8 +23770,8 @@ function isChild(value) {
|
|
|
23768
23770
|
if (!Array.isArray(value2))
|
|
23769
23771
|
return true;
|
|
23770
23772
|
const list2 = value2;
|
|
23771
|
-
for (const
|
|
23772
|
-
if (typeof
|
|
23773
|
+
for (const item of list2) {
|
|
23774
|
+
if (typeof item !== "number" && typeof item !== "string") {
|
|
23773
23775
|
return true;
|
|
23774
23776
|
}
|
|
23775
23777
|
}
|
|
@@ -23808,8 +23810,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
23808
23810
|
}
|
|
23809
23811
|
if (Array.isArray(result)) {
|
|
23810
23812
|
const finalResult = [];
|
|
23811
|
-
for (const
|
|
23812
|
-
finalResult.push(parsePrimitive(info, info.property,
|
|
23813
|
+
for (const item of result) {
|
|
23814
|
+
finalResult.push(parsePrimitive(info, info.property, item));
|
|
23813
23815
|
}
|
|
23814
23816
|
result = finalResult;
|
|
23815
23817
|
}
|
|
@@ -34876,8 +34878,8 @@ function list5(node2, parent, state, info) {
|
|
|
34876
34878
|
if (checkRule(state) === bullet && firstListItem) {
|
|
34877
34879
|
let index2 = -1;
|
|
34878
34880
|
while (++index2 < node2.children.length) {
|
|
34879
|
-
const
|
|
34880
|
-
if (
|
|
34881
|
+
const item = node2.children[index2];
|
|
34882
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
34881
34883
|
useDifferentMarker = true;
|
|
34882
34884
|
break;
|
|
34883
34885
|
}
|
|
@@ -35537,12 +35539,12 @@ async function convertMarkdownToSlate(text5) {
|
|
|
35537
35539
|
...nodes.filter((node2) => node2.type !== "list_item")
|
|
35538
35540
|
];
|
|
35539
35541
|
}
|
|
35540
|
-
return nodes.map((
|
|
35542
|
+
return nodes.map((item) => {
|
|
35541
35543
|
setNodeStyles({
|
|
35542
|
-
node:
|
|
35543
|
-
isPaddingTopNeeded:
|
|
35544
|
+
node: item,
|
|
35545
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
35544
35546
|
});
|
|
35545
|
-
return
|
|
35547
|
+
return item;
|
|
35546
35548
|
});
|
|
35547
35549
|
}
|
|
35548
35550
|
function detectListType(text5) {
|
|
@@ -35955,17 +35957,17 @@ class FloatingPoint extends Point {
|
|
|
35955
35957
|
relativePoint;
|
|
35956
35958
|
pointType = "Floating";
|
|
35957
35959
|
edge;
|
|
35958
|
-
constructor(
|
|
35960
|
+
constructor(item, relativePoint) {
|
|
35959
35961
|
super();
|
|
35960
|
-
this.item =
|
|
35962
|
+
this.item = item;
|
|
35961
35963
|
this.relativePoint = relativePoint;
|
|
35962
35964
|
if (relativePoint.y <= 0) {
|
|
35963
35965
|
this.edge = "top";
|
|
35964
|
-
} else if (relativePoint.y >=
|
|
35966
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
35965
35967
|
this.edge = "bottom";
|
|
35966
35968
|
} else if (relativePoint.x <= 0) {
|
|
35967
35969
|
this.edge = "left";
|
|
35968
|
-
} else if (relativePoint.x >=
|
|
35970
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
35969
35971
|
this.edge = "right";
|
|
35970
35972
|
}
|
|
35971
35973
|
this.recalculatePoint();
|
|
@@ -35996,17 +35998,17 @@ class FixedPoint extends Point {
|
|
|
35996
35998
|
relativePoint;
|
|
35997
35999
|
pointType = "Fixed";
|
|
35998
36000
|
edge;
|
|
35999
|
-
constructor(
|
|
36001
|
+
constructor(item, relativePoint) {
|
|
36000
36002
|
super();
|
|
36001
|
-
this.item =
|
|
36003
|
+
this.item = item;
|
|
36002
36004
|
this.relativePoint = relativePoint;
|
|
36003
36005
|
if (relativePoint.y <= 0) {
|
|
36004
36006
|
this.edge = "top";
|
|
36005
|
-
} else if (relativePoint.y >=
|
|
36007
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
36006
36008
|
this.edge = "bottom";
|
|
36007
36009
|
} else if (relativePoint.x <= 0) {
|
|
36008
36010
|
this.edge = "left";
|
|
36009
|
-
} else if (relativePoint.x >=
|
|
36011
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
36010
36012
|
this.edge = "right";
|
|
36011
36013
|
}
|
|
36012
36014
|
this.recalculatePoint();
|
|
@@ -36037,16 +36039,16 @@ class FixedConnectorPoint extends Point {
|
|
|
36037
36039
|
tangent;
|
|
36038
36040
|
segmentIndex;
|
|
36039
36041
|
pointType = "FixedConnector";
|
|
36040
|
-
constructor(
|
|
36042
|
+
constructor(item, tangent, segmentIndex) {
|
|
36041
36043
|
super();
|
|
36042
|
-
this.item =
|
|
36044
|
+
this.item = item;
|
|
36043
36045
|
this.tangent = tangent;
|
|
36044
36046
|
this.segmentIndex = segmentIndex;
|
|
36045
36047
|
this.recalculatePoint();
|
|
36046
36048
|
}
|
|
36047
36049
|
recalculatePoint() {
|
|
36048
|
-
const
|
|
36049
|
-
const segments =
|
|
36050
|
+
const item = this.item;
|
|
36051
|
+
const segments = item.getPaths().getSegments();
|
|
36050
36052
|
const segment = segments.length > this.segmentIndex ? segments[this.segmentIndex] : segments[segments.length - 1];
|
|
36051
36053
|
const point5 = segment.getPoint(this.tangent);
|
|
36052
36054
|
this.x = point5.x;
|
|
@@ -36071,38 +36073,38 @@ function getControlPoint(data, findItem2) {
|
|
|
36071
36073
|
if (data.pointType === "Board") {
|
|
36072
36074
|
return new BoardPoint(Math.round(data.x), Math.round(data.y));
|
|
36073
36075
|
} else {
|
|
36074
|
-
const
|
|
36075
|
-
if (!
|
|
36076
|
+
const item = findItem2(data.itemId);
|
|
36077
|
+
if (!item) {
|
|
36076
36078
|
console.warn(`getControlPoint(): item not found for ${data.itemId}`);
|
|
36077
36079
|
return new BoardPoint(0, 0);
|
|
36078
36080
|
}
|
|
36079
36081
|
switch (data.pointType) {
|
|
36080
36082
|
case "FixedConnector":
|
|
36081
|
-
if (
|
|
36082
|
-
return new FixedConnectorPoint(
|
|
36083
|
+
if (item instanceof Connector2) {
|
|
36084
|
+
return new FixedConnectorPoint(item, data.tangent, data.segment);
|
|
36083
36085
|
} else {
|
|
36084
36086
|
throw new Error(`getControlPoint(): item must be a connector`);
|
|
36085
36087
|
}
|
|
36086
36088
|
case "Floating":
|
|
36087
|
-
return new FloatingPoint(
|
|
36089
|
+
return new FloatingPoint(item, new Point(data.relativeX, data.relativeY));
|
|
36088
36090
|
case "Fixed":
|
|
36089
|
-
return new FixedPoint(
|
|
36091
|
+
return new FixedPoint(item, new Point(data.relativeX, data.relativeY));
|
|
36090
36092
|
}
|
|
36091
36093
|
}
|
|
36092
36094
|
}
|
|
36093
|
-
function toRelativePoint(point5,
|
|
36094
|
-
const matrix =
|
|
36095
|
+
function toRelativePoint(point5, item) {
|
|
36096
|
+
const matrix = item.transformation?.matrix || new Matrix2;
|
|
36095
36097
|
const inverse = matrix.getInverse();
|
|
36096
36098
|
point5 = point5.copy();
|
|
36097
36099
|
point5.transform(inverse);
|
|
36098
36100
|
return point5;
|
|
36099
36101
|
}
|
|
36100
|
-
function fromRelativePoint(relativePoint,
|
|
36101
|
-
const matrix =
|
|
36102
|
+
function fromRelativePoint(relativePoint, item, edge) {
|
|
36103
|
+
const matrix = item.transformation?.matrix.copy() || new Matrix2;
|
|
36102
36104
|
const point5 = relativePoint.copy();
|
|
36103
36105
|
point5.transform(matrix);
|
|
36104
|
-
if (
|
|
36105
|
-
const itemMbr =
|
|
36106
|
+
if (item instanceof RichText || item instanceof AINode) {
|
|
36107
|
+
const itemMbr = item.getMbr();
|
|
36106
36108
|
const { x: centerX, y: centerY } = itemMbr.getCenter();
|
|
36107
36109
|
switch (edge) {
|
|
36108
36110
|
case "left":
|
|
@@ -36114,7 +36116,7 @@ function fromRelativePoint(relativePoint, item2, edge) {
|
|
|
36114
36116
|
case "bottom":
|
|
36115
36117
|
return new Point(centerX, itemMbr.bottom);
|
|
36116
36118
|
default:
|
|
36117
|
-
return
|
|
36119
|
+
return item.getMbr().getClosestEdgeCenterPoint(point5);
|
|
36118
36120
|
}
|
|
36119
36121
|
}
|
|
36120
36122
|
return point5;
|
|
@@ -37463,7 +37465,7 @@ class Connector2 extends BaseItem {
|
|
|
37463
37465
|
return this;
|
|
37464
37466
|
}
|
|
37465
37467
|
getConnectorById(items, connectorId) {
|
|
37466
|
-
return items.find((
|
|
37468
|
+
return items.find((item) => item instanceof Connector2 && item.getId() === connectorId);
|
|
37467
37469
|
}
|
|
37468
37470
|
updateTitle() {
|
|
37469
37471
|
const selection = this.board.selection;
|
|
@@ -40100,8 +40102,8 @@ async function exportBoardSnapshot({
|
|
|
40100
40102
|
context.matrix.applyToContext(context.ctx);
|
|
40101
40103
|
const { left, top, right, bottom } = selection;
|
|
40102
40104
|
const inView = board.items.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
40103
|
-
for (const
|
|
40104
|
-
|
|
40105
|
+
for (const item of inView) {
|
|
40106
|
+
item.render(context);
|
|
40105
40107
|
}
|
|
40106
40108
|
const blob = await offscreenCanvas.convertToBlob({ type: "image/png" });
|
|
40107
40109
|
const dataUrl = await convertBlobToDataUrl(blob);
|
|
@@ -40299,7 +40301,7 @@ class Frame2 extends BaseItem {
|
|
|
40299
40301
|
return this.id;
|
|
40300
40302
|
}
|
|
40301
40303
|
getChildrenIds() {
|
|
40302
|
-
return this.index?.list().map((
|
|
40304
|
+
return this.index?.list().map((item) => item.getId()) || [];
|
|
40303
40305
|
}
|
|
40304
40306
|
updateMbr() {
|
|
40305
40307
|
const rect = this.path.getMbr().copy();
|
|
@@ -40534,11 +40536,11 @@ class Frame2 extends BaseItem {
|
|
|
40534
40536
|
}
|
|
40535
40537
|
});
|
|
40536
40538
|
const currMbr = this.getMbr();
|
|
40537
|
-
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((
|
|
40538
|
-
if (
|
|
40539
|
-
if (this.handleNesting(
|
|
40540
|
-
this.applyAddChildren([
|
|
40541
|
-
|
|
40539
|
+
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((item) => {
|
|
40540
|
+
if (item.parent === "Board") {
|
|
40541
|
+
if (this.handleNesting(item)) {
|
|
40542
|
+
this.applyAddChildren([item.getId()]);
|
|
40543
|
+
item.parent = this.getId();
|
|
40542
40544
|
}
|
|
40543
40545
|
}
|
|
40544
40546
|
});
|
|
@@ -42736,9 +42738,9 @@ class Group extends BaseItem {
|
|
|
42736
42738
|
if (data.children) {
|
|
42737
42739
|
data.children.forEach((childId) => {
|
|
42738
42740
|
this.applyAddChild(childId);
|
|
42739
|
-
const
|
|
42740
|
-
if (
|
|
42741
|
-
|
|
42741
|
+
const item = this.board.items.getById(childId);
|
|
42742
|
+
if (item) {
|
|
42743
|
+
item.parent = this.getId();
|
|
42742
42744
|
}
|
|
42743
42745
|
});
|
|
42744
42746
|
}
|
|
@@ -42768,11 +42770,11 @@ class Group extends BaseItem {
|
|
|
42768
42770
|
let right = Number.MIN_SAFE_INTEGER;
|
|
42769
42771
|
let bottom = Number.MIN_SAFE_INTEGER;
|
|
42770
42772
|
const mbrs = this.children.flatMap((childId) => {
|
|
42771
|
-
const
|
|
42772
|
-
if (!
|
|
42773
|
+
const item = this.board.items.getById(childId);
|
|
42774
|
+
if (!item) {
|
|
42773
42775
|
return [];
|
|
42774
42776
|
}
|
|
42775
|
-
const mbr2 =
|
|
42777
|
+
const mbr2 = item.getMbr();
|
|
42776
42778
|
if (!mbr2) {
|
|
42777
42779
|
return [];
|
|
42778
42780
|
}
|
|
@@ -42807,7 +42809,7 @@ class Group extends BaseItem {
|
|
|
42807
42809
|
return this.children;
|
|
42808
42810
|
}
|
|
42809
42811
|
getChildren() {
|
|
42810
|
-
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((
|
|
42812
|
+
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((item) => item !== undefined);
|
|
42811
42813
|
}
|
|
42812
42814
|
updateMbr() {
|
|
42813
42815
|
const rect = this.getMbr();
|
|
@@ -42820,9 +42822,9 @@ class Group extends BaseItem {
|
|
|
42820
42822
|
setChildren(items) {
|
|
42821
42823
|
items.forEach((itemId) => {
|
|
42822
42824
|
this.addChild(itemId);
|
|
42823
|
-
const
|
|
42824
|
-
if (
|
|
42825
|
-
|
|
42825
|
+
const item = this.board.items.getById(itemId);
|
|
42826
|
+
if (item) {
|
|
42827
|
+
item.parent = this.getId();
|
|
42826
42828
|
}
|
|
42827
42829
|
});
|
|
42828
42830
|
this.updateMbr();
|
|
@@ -42830,9 +42832,9 @@ class Group extends BaseItem {
|
|
|
42830
42832
|
removeChildren() {
|
|
42831
42833
|
this.children.forEach((itemId) => {
|
|
42832
42834
|
this.removeChild(itemId);
|
|
42833
|
-
const
|
|
42834
|
-
if (
|
|
42835
|
-
|
|
42835
|
+
const item = this.board.items.getById(itemId);
|
|
42836
|
+
if (item) {
|
|
42837
|
+
item.parent = this.parent;
|
|
42836
42838
|
}
|
|
42837
42839
|
});
|
|
42838
42840
|
this.updateMbr();
|
|
@@ -43165,16 +43167,16 @@ class Anchor extends Mbr {
|
|
|
43165
43167
|
}
|
|
43166
43168
|
}
|
|
43167
43169
|
// src/Items/Connector/ConnectorSnap.ts
|
|
43168
|
-
function getFixedPoint(
|
|
43169
|
-
if (
|
|
43170
|
-
const nearestSegmentData =
|
|
43170
|
+
function getFixedPoint(item, point5) {
|
|
43171
|
+
if (item instanceof Connector2) {
|
|
43172
|
+
const nearestSegmentData = item.getPaths().getNearestEdgeAndPointTo(point5);
|
|
43171
43173
|
const segment = nearestSegmentData.segment;
|
|
43172
43174
|
const index2 = nearestSegmentData.index;
|
|
43173
43175
|
const tangent = segment.getParameter(point5);
|
|
43174
|
-
return new FixedConnectorPoint(
|
|
43176
|
+
return new FixedConnectorPoint(item, tangent, index2);
|
|
43175
43177
|
} else {
|
|
43176
|
-
const relativePoint = toRelativePoint(point5,
|
|
43177
|
-
return new FixedPoint(
|
|
43178
|
+
const relativePoint = toRelativePoint(point5, item);
|
|
43179
|
+
return new FixedPoint(item, relativePoint);
|
|
43178
43180
|
}
|
|
43179
43181
|
}
|
|
43180
43182
|
|
|
@@ -43227,20 +43229,20 @@ class ConnectorSnap {
|
|
|
43227
43229
|
}
|
|
43228
43230
|
this.setSnap();
|
|
43229
43231
|
const pointer = this.board.pointer.point;
|
|
43230
|
-
const { anchor, item
|
|
43231
|
-
if (!
|
|
43232
|
+
const { anchor, item, point: point5 } = this.snap;
|
|
43233
|
+
if (!item) {
|
|
43232
43234
|
const pointer2 = this.board.pointer.point;
|
|
43233
43235
|
this.controlPoint = new BoardPoint(pointer2.x, pointer2.y);
|
|
43234
43236
|
} else if (anchor) {
|
|
43235
|
-
this.controlPoint = getFixedPoint(
|
|
43237
|
+
this.controlPoint = getFixedPoint(item, anchor.getCenter());
|
|
43236
43238
|
} else if (point5) {
|
|
43237
|
-
const nearest2 =
|
|
43238
|
-
this.controlPoint = getFixedPoint(
|
|
43239
|
+
const nearest2 = item.getNearestEdgePointTo(pointer);
|
|
43240
|
+
this.controlPoint = getFixedPoint(item, nearest2);
|
|
43239
43241
|
} else {
|
|
43240
43242
|
if (this.hover.isTimeoutElapsed) {
|
|
43241
|
-
this.controlPoint = getFixedPoint(
|
|
43243
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
43242
43244
|
} else {
|
|
43243
|
-
this.controlPoint = getFixedPoint(
|
|
43245
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
43244
43246
|
}
|
|
43245
43247
|
}
|
|
43246
43248
|
}
|
|
@@ -43301,23 +43303,23 @@ class ConnectorSnap {
|
|
|
43301
43303
|
}
|
|
43302
43304
|
return nearest;
|
|
43303
43305
|
}
|
|
43304
|
-
getClosestPointOnItem(
|
|
43305
|
-
const nearestEdgePoint =
|
|
43306
|
-
return getFixedPoint(
|
|
43306
|
+
getClosestPointOnItem(item, position4) {
|
|
43307
|
+
const nearestEdgePoint = item.getNearestEdgePointTo(position4);
|
|
43308
|
+
return getFixedPoint(item, nearestEdgePoint);
|
|
43307
43309
|
}
|
|
43308
|
-
isNearBorder(
|
|
43309
|
-
if (!
|
|
43310
|
+
isNearBorder(item) {
|
|
43311
|
+
if (!item) {
|
|
43310
43312
|
return false;
|
|
43311
43313
|
}
|
|
43312
43314
|
const pointer = this.board.pointer.point;
|
|
43313
|
-
const point5 =
|
|
43315
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
43314
43316
|
const distance = pointer.getDistance(point5);
|
|
43315
43317
|
return distance < this.distance.border / this.board.camera.getScale();
|
|
43316
43318
|
}
|
|
43317
43319
|
setSnap() {
|
|
43318
|
-
const
|
|
43319
|
-
const path2 =
|
|
43320
|
-
if (!
|
|
43320
|
+
const item = this.snap.item;
|
|
43321
|
+
const path2 = item && "getPath" in item ? item?.getPath() : null;
|
|
43322
|
+
if (!item || !path2) {
|
|
43321
43323
|
this.snap.path = null;
|
|
43322
43324
|
this.snap.anchors = [];
|
|
43323
43325
|
this.snap.anchor = null;
|
|
@@ -43328,11 +43330,11 @@ class ConnectorSnap {
|
|
|
43328
43330
|
if (this.snap.item === this.hover.item && !this.hover.isTimeoutElapsed) {
|
|
43329
43331
|
path2.setBackgroundColor(this.color.snapBackgroundHighlight);
|
|
43330
43332
|
}
|
|
43331
|
-
this.setAnchors(
|
|
43333
|
+
this.setAnchors(item);
|
|
43332
43334
|
}
|
|
43333
43335
|
}
|
|
43334
|
-
setAnchors(
|
|
43335
|
-
const points =
|
|
43336
|
+
setAnchors(item) {
|
|
43337
|
+
const points = item.getSnapAnchorPoints();
|
|
43336
43338
|
if (!points) {
|
|
43337
43339
|
return;
|
|
43338
43340
|
}
|
|
@@ -43366,10 +43368,10 @@ class ConnectorSnap {
|
|
|
43366
43368
|
}
|
|
43367
43369
|
setPoint() {
|
|
43368
43370
|
const pointer = this.board.pointer.point;
|
|
43369
|
-
const { item
|
|
43370
|
-
if (
|
|
43371
|
+
const { item, anchor } = this.snap;
|
|
43372
|
+
if (item) {
|
|
43371
43373
|
if (!anchor) {
|
|
43372
|
-
const point5 =
|
|
43374
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
43373
43375
|
if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
|
|
43374
43376
|
this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
|
|
43375
43377
|
} else {
|
|
@@ -43742,12 +43744,12 @@ class NestingHighlighter extends Tool {
|
|
|
43742
43744
|
this.toHighlight.push({ groupItem, children: array });
|
|
43743
43745
|
}
|
|
43744
43746
|
}
|
|
43745
|
-
addSingleItem(
|
|
43746
|
-
this.toHighlight.push({ children: [
|
|
43747
|
+
addSingleItem(item) {
|
|
43748
|
+
this.toHighlight.push({ children: [item] });
|
|
43747
43749
|
}
|
|
43748
|
-
remove(
|
|
43750
|
+
remove(item) {
|
|
43749
43751
|
this.toHighlight.forEach((group) => {
|
|
43750
|
-
group.children = group.children.filter((child) => child !==
|
|
43752
|
+
group.children = group.children.filter((child) => child !== item);
|
|
43751
43753
|
});
|
|
43752
43754
|
this.toHighlight = this.toHighlight.filter((group) => group.children.length > 0);
|
|
43753
43755
|
}
|
|
@@ -43814,7 +43816,7 @@ class AddFrame extends BoardTool {
|
|
|
43814
43816
|
this.mbr.borderColor = "blue";
|
|
43815
43817
|
this.nestingHighlighter.clear();
|
|
43816
43818
|
const enclosedOrCrossed = this.board.items.getEnclosedOrCrossed(this.mbr.left, this.mbr.top, this.mbr.right, this.mbr.bottom);
|
|
43817
|
-
const inside = enclosedOrCrossed.filter((
|
|
43819
|
+
const inside = enclosedOrCrossed.filter((item) => !(item instanceof Frame2) && item.parent === "Board" && this.mbr.isInside(item.getMbr().getCenter()));
|
|
43818
43820
|
this.nestingHighlighter.add(this.frame, inside);
|
|
43819
43821
|
this.initTransformation();
|
|
43820
43822
|
this.board.tools.publish();
|
|
@@ -43835,7 +43837,7 @@ class AddFrame extends BoardTool {
|
|
|
43835
43837
|
localStorage.setItem("lastFrameScale", JSON.stringify(this.frame.transformation.getScale()));
|
|
43836
43838
|
}
|
|
43837
43839
|
const currMbr = this.frame.getMbr();
|
|
43838
|
-
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
43840
|
+
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board").filter((item) => this.frame.handleNesting(item));
|
|
43839
43841
|
this.applyAddChildren(frameChildren);
|
|
43840
43842
|
if (this.shape !== "Custom") {
|
|
43841
43843
|
this.applyCanChangeRatio(false);
|
|
@@ -43851,7 +43853,7 @@ class AddFrame extends BoardTool {
|
|
|
43851
43853
|
return true;
|
|
43852
43854
|
}
|
|
43853
43855
|
addNextTo() {
|
|
43854
|
-
const framesInView = this.board.items.getItemsInView().filter((
|
|
43856
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame2);
|
|
43855
43857
|
if (framesInView.length === 0) {
|
|
43856
43858
|
if (this.shape === "Custom") {
|
|
43857
43859
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -43889,7 +43891,7 @@ class AddFrame extends BoardTool {
|
|
|
43889
43891
|
this.board.camera.viewRectangle(this.frame.getMbr());
|
|
43890
43892
|
}
|
|
43891
43893
|
const frameMbr = this.frame.getMbr();
|
|
43892
|
-
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((
|
|
43894
|
+
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((item) => item.parent === "Board").filter((item) => this.frame.handleNesting(item)).forEach((item) => this.applyAddChildren([item]));
|
|
43893
43895
|
const frame = this.board.add(this.frame);
|
|
43894
43896
|
frame.text.editor.moveCursorToEndOfTheText();
|
|
43895
43897
|
this.nestingHighlighter.clear();
|
|
@@ -44394,13 +44396,13 @@ class Eraser extends BoardTool {
|
|
|
44394
44396
|
}
|
|
44395
44397
|
removeUnderPointOrLine() {
|
|
44396
44398
|
const segments = this.drawing.getLines();
|
|
44397
|
-
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((
|
|
44398
|
-
return
|
|
44399
|
-
return line.getDistance(this.board.pointer.point) <=
|
|
44399
|
+
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((item) => {
|
|
44400
|
+
return item.itemType === "Drawing" && item.getLines().find((line) => {
|
|
44401
|
+
return line.getDistance(this.board.pointer.point) <= item.strokeWidth / 2 + this.strokeWidth / 2;
|
|
44400
44402
|
});
|
|
44401
44403
|
});
|
|
44402
|
-
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((
|
|
44403
|
-
return
|
|
44404
|
+
items.push(...this.board.items.getEnclosedOrCrossed(this.drawing.points[0].x, this.drawing.points[0].y, this.board.pointer.point.x, this.board.pointer.point.y).filter((item) => {
|
|
44405
|
+
return item.itemType === "Drawing" && item.getLines().some((line) => {
|
|
44404
44406
|
return segments.some((segment) => segment.hasIntersectionPoint(line));
|
|
44405
44407
|
});
|
|
44406
44408
|
}));
|
|
@@ -44852,20 +44854,20 @@ function createCanvasDrawer(board) {
|
|
|
44852
44854
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
44853
44855
|
context.matrix.applyToContext(context.ctx);
|
|
44854
44856
|
const items = Object.keys(translation).map((id) => {
|
|
44855
|
-
const
|
|
44856
|
-
if (
|
|
44857
|
-
if (
|
|
44858
|
-
return
|
|
44857
|
+
const item = board2.items.getById(id);
|
|
44858
|
+
if (item) {
|
|
44859
|
+
if (item.itemType !== "Frame") {
|
|
44860
|
+
return item;
|
|
44859
44861
|
}
|
|
44860
|
-
|
|
44861
|
-
return
|
|
44862
|
+
item.render(context);
|
|
44863
|
+
return item;
|
|
44862
44864
|
}
|
|
44863
44865
|
return;
|
|
44864
|
-
}).filter((
|
|
44865
|
-
items.forEach((
|
|
44866
|
-
if (
|
|
44867
|
-
|
|
44868
|
-
board2.selection.renderItemMbr(context,
|
|
44866
|
+
}).filter((item) => !!item);
|
|
44867
|
+
items.forEach((item) => {
|
|
44868
|
+
if (item.itemType !== "Frame") {
|
|
44869
|
+
item.render(context);
|
|
44870
|
+
board2.selection.renderItemMbr(context, item, board2.camera.getMatrix().scaleX);
|
|
44869
44871
|
}
|
|
44870
44872
|
});
|
|
44871
44873
|
return { canvas: container, items };
|
|
@@ -44926,10 +44928,10 @@ function createCanvasDrawer(board) {
|
|
|
44926
44928
|
if (lastTranslationKeys) {
|
|
44927
44929
|
board.selection.shouldPublish = false;
|
|
44928
44930
|
lastTranslationKeys.forEach((id) => {
|
|
44929
|
-
const
|
|
44930
|
-
if (
|
|
44931
|
-
|
|
44932
|
-
|
|
44931
|
+
const item = board.items.getById(id);
|
|
44932
|
+
if (item) {
|
|
44933
|
+
item.transformationRenderBlock = undefined;
|
|
44934
|
+
item.subject.publish(item);
|
|
44933
44935
|
}
|
|
44934
44936
|
});
|
|
44935
44937
|
lastTranslationKeys = undefined;
|
|
@@ -44961,9 +44963,9 @@ function createCanvasDrawer(board) {
|
|
|
44961
44963
|
lastCreatedCanvas = cnvs;
|
|
44962
44964
|
lastTranslationKeys = Object.keys(translation);
|
|
44963
44965
|
lastTranslationKeys.forEach((id) => {
|
|
44964
|
-
const
|
|
44965
|
-
if (
|
|
44966
|
-
|
|
44966
|
+
const item = board.items.getById(id);
|
|
44967
|
+
if (item) {
|
|
44968
|
+
item.transformationRenderBlock = true;
|
|
44967
44969
|
}
|
|
44968
44970
|
});
|
|
44969
44971
|
board.selection.transformationRenderBlock = true;
|
|
@@ -44973,14 +44975,14 @@ function createCanvasDrawer(board) {
|
|
|
44973
44975
|
}
|
|
44974
44976
|
function countSumMbr(translation) {
|
|
44975
44977
|
return Object.keys(translation).reduce((mbr, id) => {
|
|
44976
|
-
const
|
|
44977
|
-
if (
|
|
44978
|
+
const item = board.items.getById(id);
|
|
44979
|
+
if (item) {
|
|
44978
44980
|
if (!mbr) {
|
|
44979
|
-
mbr =
|
|
44981
|
+
mbr = item.getMbr();
|
|
44980
44982
|
} else {
|
|
44981
|
-
mbr.combine(
|
|
44982
|
-
if (
|
|
44983
|
-
mbr.combine(
|
|
44983
|
+
mbr.combine(item.getMbr());
|
|
44984
|
+
if (item.itemType === "Frame") {
|
|
44985
|
+
mbr.combine(item.getRichText().getMbr());
|
|
44984
44986
|
}
|
|
44985
44987
|
}
|
|
44986
44988
|
}
|
|
@@ -45011,8 +45013,8 @@ function createCanvasDrawer(board) {
|
|
|
45011
45013
|
}
|
|
45012
45014
|
function highlightNesting() {
|
|
45013
45015
|
const container = getLastCreatedCanvas();
|
|
45014
|
-
const drawnItemsMap = drawnItems?.reduce((acc,
|
|
45015
|
-
acc.set(
|
|
45016
|
+
const drawnItemsMap = drawnItems?.reduce((acc, item) => {
|
|
45017
|
+
acc.set(item.getId(), { item, mbr: item.getMbr() });
|
|
45016
45018
|
return acc;
|
|
45017
45019
|
}, new Map);
|
|
45018
45020
|
if (!container || !drawnItems) {
|
|
@@ -45047,11 +45049,11 @@ function createCanvasDrawer(board) {
|
|
|
45047
45049
|
mbr.transform(currMatrix);
|
|
45048
45050
|
});
|
|
45049
45051
|
groups.forEach((group) => {
|
|
45050
|
-
drawnItemsMap?.forEach(({ mbr, item
|
|
45051
|
-
if ("canBeNested" in
|
|
45052
|
+
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
45053
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
45052
45054
|
return;
|
|
45053
45055
|
}
|
|
45054
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) ||
|
|
45056
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
45055
45057
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
45056
45058
|
removeHighlighted(key);
|
|
45057
45059
|
highlightedDivs.set(key, div);
|
|
@@ -45112,10 +45114,10 @@ function createCanvasDrawer(board) {
|
|
|
45112
45114
|
}
|
|
45113
45115
|
|
|
45114
45116
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
45115
|
-
function getControlPointData(
|
|
45116
|
-
const itemScale = isRichText ? { x: 1, y: 1 } :
|
|
45117
|
-
const width2 =
|
|
45118
|
-
let height3 =
|
|
45117
|
+
function getControlPointData(item, index2, isRichText = false) {
|
|
45118
|
+
const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
|
|
45119
|
+
const width2 = item.getPathMbr().getWidth();
|
|
45120
|
+
let height3 = item.getPathMbr().getHeight();
|
|
45119
45121
|
const adjMapScaled = {
|
|
45120
45122
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
45121
45123
|
1: {
|
|
@@ -45130,7 +45132,7 @@ function getControlPointData(item2, index2, isRichText = false) {
|
|
|
45130
45132
|
};
|
|
45131
45133
|
return {
|
|
45132
45134
|
pointType: "Fixed",
|
|
45133
|
-
itemId:
|
|
45135
|
+
itemId: item.getId(),
|
|
45134
45136
|
relativeX: adjMapScaled[index2].x,
|
|
45135
45137
|
relativeY: adjMapScaled[index2].y
|
|
45136
45138
|
};
|
|
@@ -45265,10 +45267,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
45265
45267
|
let newHeight = height3;
|
|
45266
45268
|
let itemData;
|
|
45267
45269
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
45268
|
-
const
|
|
45269
|
-
newWidth =
|
|
45270
|
-
newHeight =
|
|
45271
|
-
itemData =
|
|
45270
|
+
const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
45271
|
+
newWidth = item.getMbr().getWidth();
|
|
45272
|
+
newHeight = item.getMbr().getHeight();
|
|
45273
|
+
itemData = item.serialize();
|
|
45272
45274
|
const { minX, minY, maxY, maxX } = offsets;
|
|
45273
45275
|
offsetX = Math.min(offsetX, maxX);
|
|
45274
45276
|
offsetX = Math.max(offsetX, minX);
|
|
@@ -45301,7 +45303,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45301
45303
|
}
|
|
45302
45304
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
45303
45305
|
let step = 1;
|
|
45304
|
-
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((
|
|
45306
|
+
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((item) => item.itemType !== "Connector").length > 0) {
|
|
45305
45307
|
const xDirection = step % 2 === 0 ? -1 : 1;
|
|
45306
45308
|
const yDirection = newItemData.itemType === "AINode" ? -1 : xDirection;
|
|
45307
45309
|
newMbr.transform(new Matrix2(iterAdjustment[index2].x * xDirection * step, iterAdjustment[index2].y * yDirection * (newItemData.itemType === "AINode" ? 1 : step)));
|
|
@@ -45434,7 +45436,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45434
45436
|
clear();
|
|
45435
45437
|
return;
|
|
45436
45438
|
}
|
|
45437
|
-
const { positions, item
|
|
45439
|
+
const { positions, item } = position4;
|
|
45438
45440
|
const cameraMatrix = board.camera.getMatrix();
|
|
45439
45441
|
const cameraMbr = board.camera.getMbr();
|
|
45440
45442
|
const positionAdjustments = {
|
|
@@ -45462,7 +45464,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45462
45464
|
};
|
|
45463
45465
|
const button = document.createElement("button");
|
|
45464
45466
|
button.classList.add("microboard-quickAddButton");
|
|
45465
|
-
if (
|
|
45467
|
+
if (item.itemType === "AINode" && index2 === 2) {
|
|
45466
45468
|
button.classList.add("microboard-invisible");
|
|
45467
45469
|
}
|
|
45468
45470
|
button.classList.add(`microboard-${adjustment.rotate}`);
|
|
@@ -45478,7 +45480,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45478
45480
|
clearTimeout(timeoutId);
|
|
45479
45481
|
}
|
|
45480
45482
|
if (button.isMouseDown) {
|
|
45481
|
-
board.tools.addConnector(true,
|
|
45483
|
+
board.tools.addConnector(true, item, pos);
|
|
45482
45484
|
} else {
|
|
45483
45485
|
quickAddItems = undefined;
|
|
45484
45486
|
selection.subject.publish(selection);
|
|
@@ -45585,11 +45587,11 @@ class AlignmentHelper {
|
|
|
45585
45587
|
return baseThickness / (zoom / 100);
|
|
45586
45588
|
}
|
|
45587
45589
|
combineMBRs(items) {
|
|
45588
|
-
return items.reduce((acc,
|
|
45590
|
+
return items.reduce((acc, item, i) => {
|
|
45589
45591
|
if (i === 0) {
|
|
45590
45592
|
return acc;
|
|
45591
45593
|
}
|
|
45592
|
-
const itemMbr =
|
|
45594
|
+
const itemMbr = item.getPathMbr();
|
|
45593
45595
|
return acc.combine(itemMbr);
|
|
45594
45596
|
}, items[0].getMbr());
|
|
45595
45597
|
}
|
|
@@ -45603,7 +45605,7 @@ class AlignmentHelper {
|
|
|
45603
45605
|
const scale = this.board.camera.getScale();
|
|
45604
45606
|
const dynamicAlignThreshold = Math.min(this.alignThreshold / scale, 8);
|
|
45605
45607
|
const childrenIds = "index" in movingItem && movingItem.index ? movingItem.getChildrenIds() : [];
|
|
45606
|
-
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (
|
|
45608
|
+
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (item) => !excludeItems.includes(item), Math.ceil(cameraWidth)) : this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (otherItem) => otherItem !== movingMBR && otherItem.itemType !== "Connector" && otherItem.itemType !== "Drawing" && otherItem.isInView(camera) && !childrenIds.includes(otherItem.getId()), Math.ceil(cameraWidth)).filter((item) => Array.isArray(movingItem) ? !movingItem.includes(item) : true);
|
|
45607
45609
|
const verticalAlignments = new Map;
|
|
45608
45610
|
const horizontalAlignments = new Map;
|
|
45609
45611
|
const addVerticalAlignment = (x, minY, maxY) => {
|
|
@@ -45624,11 +45626,11 @@ class AlignmentHelper {
|
|
|
45624
45626
|
horizontalAlignments.set(y, { minX, maxX });
|
|
45625
45627
|
}
|
|
45626
45628
|
};
|
|
45627
|
-
nearbyItems.forEach((
|
|
45628
|
-
if (
|
|
45629
|
+
nearbyItems.forEach((item) => {
|
|
45630
|
+
if (item === movingItem || item.itemType === "Comment") {
|
|
45629
45631
|
return;
|
|
45630
45632
|
}
|
|
45631
|
-
const itemMbr =
|
|
45633
|
+
const itemMbr = item.itemType === "Shape" ? item.getPath().getMbr() : item.getMbr();
|
|
45632
45634
|
const centerXMoving = (movingMBR.left + movingMBR.right) / 2;
|
|
45633
45635
|
const centerXItem = (itemMbr.left + itemMbr.right) / 2;
|
|
45634
45636
|
const centerYMoving = (movingMBR.top + movingMBR.bottom) / 2;
|
|
@@ -45895,20 +45897,20 @@ class AlignmentHelper {
|
|
|
45895
45897
|
}
|
|
45896
45898
|
return false;
|
|
45897
45899
|
}
|
|
45898
|
-
translateItems(
|
|
45900
|
+
translateItems(item, x, y, timeStamp) {
|
|
45899
45901
|
if (this.canvasDrawer.getLastCreatedCanvas()) {
|
|
45900
45902
|
return;
|
|
45901
45903
|
}
|
|
45902
|
-
if (Array.isArray(
|
|
45904
|
+
if (Array.isArray(item)) {
|
|
45903
45905
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45904
45906
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45905
45907
|
return;
|
|
45906
45908
|
}
|
|
45907
|
-
if (
|
|
45909
|
+
if (item.itemType === "Frame") {
|
|
45908
45910
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45909
45911
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45910
45912
|
} else {
|
|
45911
|
-
const id =
|
|
45913
|
+
const id = item.getId();
|
|
45912
45914
|
const transformMap = {};
|
|
45913
45915
|
transformMap[id] = {
|
|
45914
45916
|
class: "Transformation",
|
|
@@ -46036,12 +46038,12 @@ class Select extends Tool {
|
|
|
46036
46038
|
this.debounceUpd.setFalse();
|
|
46037
46039
|
this.snapLines = { verticalLines: [], horizontalLines: [] };
|
|
46038
46040
|
}
|
|
46039
|
-
handleSnapping(
|
|
46041
|
+
handleSnapping(item) {
|
|
46040
46042
|
if (this.board.keyboard.isShift) {
|
|
46041
46043
|
return false;
|
|
46042
46044
|
}
|
|
46043
|
-
const increasedSnapThreshold = Array.isArray(
|
|
46044
|
-
this.isSnapped = this.alignmentHelper.snapToClosestLine(
|
|
46045
|
+
const increasedSnapThreshold = Array.isArray(item) ? 40 : 35;
|
|
46046
|
+
this.isSnapped = this.alignmentHelper.snapToClosestLine(item, this.snapLines, this.beginTimeStamp, this.board.pointer.point);
|
|
46045
46047
|
if (this.isSnapped) {
|
|
46046
46048
|
if (!this.snapCursorPos) {
|
|
46047
46049
|
this.snapCursorPos = new Point(this.board.pointer.point.x, this.board.pointer.point.y);
|
|
@@ -46051,10 +46053,10 @@ class Select extends Tool {
|
|
|
46051
46053
|
if ((cursorDiffX > increasedSnapThreshold || cursorDiffY > increasedSnapThreshold) && this.initialCursorPos) {
|
|
46052
46054
|
this.isSnapped = false;
|
|
46053
46055
|
this.snapCursorPos = null;
|
|
46054
|
-
const itemCenter = Array.isArray(
|
|
46056
|
+
const itemCenter = Array.isArray(item) ? this.alignmentHelper.combineMBRs(item).getCenter() : item.getMbr().getCenter();
|
|
46055
46057
|
const translateX = this.board.pointer.point.x - this.initialCursorPos.x - itemCenter.x;
|
|
46056
46058
|
const translateY = this.board.pointer.point.y - this.initialCursorPos.y - itemCenter.y;
|
|
46057
|
-
this.alignmentHelper.translateItems(
|
|
46059
|
+
this.alignmentHelper.translateItems(item, translateX, translateY, this.beginTimeStamp);
|
|
46058
46060
|
}
|
|
46059
46061
|
}
|
|
46060
46062
|
return false;
|
|
@@ -46104,10 +46106,10 @@ class Select extends Tool {
|
|
|
46104
46106
|
angleDiff = angleDiff < 0 ? angleDiff + 360 : angleDiff;
|
|
46105
46107
|
return Math.min(angleDiff, 360 - angleDiff);
|
|
46106
46108
|
}
|
|
46107
|
-
handleShiftGuidelines(
|
|
46108
|
-
if (
|
|
46109
|
+
handleShiftGuidelines(item, mousePosition) {
|
|
46110
|
+
if (item) {
|
|
46109
46111
|
if (!this.originalCenter) {
|
|
46110
|
-
this.originalCenter = Array.isArray(
|
|
46112
|
+
this.originalCenter = Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().copy() : item.getMbr().getCenter().copy();
|
|
46111
46113
|
this.guidelines = this.alignmentHelper.generateGuidelines(this.originalCenter).lines;
|
|
46112
46114
|
}
|
|
46113
46115
|
this.mainLine = new Line(this.originalCenter, mousePosition);
|
|
@@ -46128,13 +46130,13 @@ class Select extends Tool {
|
|
|
46128
46130
|
const newEndX = this.originalCenter.x + snapDirectionX * mainLineLength;
|
|
46129
46131
|
const newEndY = this.originalCenter.y + snapDirectionY * mainLineLength;
|
|
46130
46132
|
const threshold = Infinity;
|
|
46131
|
-
const translateX = newEndX - (Array.isArray(
|
|
46132
|
-
const translateY = newEndY - (Array.isArray(
|
|
46133
|
-
if (Array.isArray(
|
|
46133
|
+
const translateX = newEndX - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().x : item.getMbr().getCenter().x);
|
|
46134
|
+
const translateY = newEndY - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().y : item.getMbr().getCenter().y);
|
|
46135
|
+
if (Array.isArray(item)) {
|
|
46134
46136
|
const translation = this.board.selection.getManyItemsTranslation(translateX, translateY);
|
|
46135
46137
|
this.board.selection.transformMany(translation, this.beginTimeStamp);
|
|
46136
46138
|
} else {
|
|
46137
|
-
|
|
46139
|
+
item.transformation.translateBy(translateX, translateY, this.beginTimeStamp);
|
|
46138
46140
|
}
|
|
46139
46141
|
}
|
|
46140
46142
|
}
|
|
@@ -46177,7 +46179,7 @@ class Select extends Tool {
|
|
|
46177
46179
|
return false;
|
|
46178
46180
|
}
|
|
46179
46181
|
this.isDownOnBoard = hover.length === 0;
|
|
46180
|
-
this.isDrawingRectangle = hover.filter((
|
|
46182
|
+
this.isDrawingRectangle = hover.filter((item) => !(item instanceof Frame2)).length === 0 && hover.filter((item) => item instanceof Frame2).filter((frame) => frame.isTextUnderPoint(pointer.point)).length === 0;
|
|
46181
46183
|
if (this.isDrawingRectangle) {
|
|
46182
46184
|
const { x, y } = pointer.point;
|
|
46183
46185
|
this.line = new Line(new Point(x, y), new Point(x, y));
|
|
@@ -46197,7 +46199,7 @@ class Select extends Tool {
|
|
|
46197
46199
|
});
|
|
46198
46200
|
return false;
|
|
46199
46201
|
}
|
|
46200
|
-
const isHoverLocked = hover.every((
|
|
46202
|
+
const isHoverLocked = hover.every((item) => item.transformation.isLocked);
|
|
46201
46203
|
if (isHoverLocked) {
|
|
46202
46204
|
return false;
|
|
46203
46205
|
}
|
|
@@ -46331,7 +46333,7 @@ class Select extends Tool {
|
|
|
46331
46333
|
const translation = selection.getManyItemsTranslation(x, y);
|
|
46332
46334
|
const translationKeys = Object.keys(translation);
|
|
46333
46335
|
const commentsSet = new Set(this.board.items.getComments().map((comment2) => comment2.getId()));
|
|
46334
|
-
if (translationKeys.filter((
|
|
46336
|
+
if (translationKeys.filter((item) => !commentsSet.has(item)).length > 10) {
|
|
46335
46337
|
const selectedMbr = this.board.selection.getMbr()?.copy();
|
|
46336
46338
|
const sumMbr = this.canvasDrawer.countSumMbr(translation);
|
|
46337
46339
|
if (sumMbr) {
|
|
@@ -46358,7 +46360,7 @@ class Select extends Tool {
|
|
|
46358
46360
|
return false;
|
|
46359
46361
|
}
|
|
46360
46362
|
const draggingMbr = draggingItem.getMbr();
|
|
46361
|
-
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((
|
|
46363
|
+
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((item) => item instanceof Frame2);
|
|
46362
46364
|
frames.forEach((frame) => {
|
|
46363
46365
|
if (frame.handleNesting(draggingItem)) {
|
|
46364
46366
|
this.nestingHighlighter.add(frame, draggingItem);
|
|
@@ -46368,7 +46370,7 @@ class Select extends Tool {
|
|
|
46368
46370
|
});
|
|
46369
46371
|
}
|
|
46370
46372
|
const hover = items.getUnderPointer();
|
|
46371
|
-
this.isHoverUnselectedItem = hover.filter((
|
|
46373
|
+
this.isHoverUnselectedItem = hover.filter((item) => item.itemType === "Placeholder").length === 1;
|
|
46372
46374
|
if (this.isHoverUnselectedItem && !this.isDraggingUnselectedItem && selection.getContext() === "None") {
|
|
46373
46375
|
selection.setContext("HoverUnderPointer");
|
|
46374
46376
|
return false;
|
|
@@ -46412,15 +46414,15 @@ class Select extends Tool {
|
|
|
46412
46414
|
}
|
|
46413
46415
|
}
|
|
46414
46416
|
updateFramesNesting(selectionMbr, selection) {
|
|
46415
|
-
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((
|
|
46416
|
-
const draggingFramesIds = selection.list().filter((
|
|
46417
|
-
selection.list().forEach((
|
|
46418
|
-
if (!(
|
|
46417
|
+
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((item) => item instanceof Frame2).filter((frame) => !selection.items.list().includes(frame));
|
|
46418
|
+
const draggingFramesIds = selection.list().filter((item) => item instanceof Frame2).map((frame) => frame.getId());
|
|
46419
|
+
selection.list().forEach((item) => {
|
|
46420
|
+
if (!(item instanceof Frame2) && !draggingFramesIds.includes(item.parent)) {
|
|
46419
46421
|
frames.forEach((frame) => {
|
|
46420
|
-
if (frame.handleNesting(
|
|
46421
|
-
this.nestingHighlighter.add(frame,
|
|
46422
|
+
if (frame.handleNesting(item)) {
|
|
46423
|
+
this.nestingHighlighter.add(frame, item);
|
|
46422
46424
|
} else {
|
|
46423
|
-
this.nestingHighlighter.remove(
|
|
46425
|
+
this.nestingHighlighter.remove(item);
|
|
46424
46426
|
}
|
|
46425
46427
|
});
|
|
46426
46428
|
}
|
|
@@ -46512,7 +46514,7 @@ class Select extends Tool {
|
|
|
46512
46514
|
const childrenIds = underPointer.getChildrenIds();
|
|
46513
46515
|
console.log("UNDERPOINTER", underPointer);
|
|
46514
46516
|
console.log("CHILDREN", childrenIds);
|
|
46515
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
46517
|
+
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
46516
46518
|
this.board.selection.add(itemsInFrame);
|
|
46517
46519
|
}
|
|
46518
46520
|
this.board.selection.setContext("EditUnderPointer");
|
|
@@ -46752,8 +46754,8 @@ class ShapeTool extends CustomTool {
|
|
|
46752
46754
|
resizeType = "leftBottom";
|
|
46753
46755
|
bounds = new Mbr;
|
|
46754
46756
|
isDown = false;
|
|
46755
|
-
constructor(board, name,
|
|
46756
|
-
super(board, name,
|
|
46757
|
+
constructor(board, name, item, settings) {
|
|
46758
|
+
super(board, name, item);
|
|
46757
46759
|
this.settings = settings;
|
|
46758
46760
|
this.setCursor();
|
|
46759
46761
|
}
|
|
@@ -46836,8 +46838,8 @@ class ShapeTool extends CustomTool {
|
|
|
46836
46838
|
|
|
46837
46839
|
class StickerTool extends CustomTool {
|
|
46838
46840
|
settings;
|
|
46839
|
-
constructor(board, name,
|
|
46840
|
-
super(board, name,
|
|
46841
|
+
constructor(board, name, item, settings) {
|
|
46842
|
+
super(board, name, item);
|
|
46841
46843
|
this.settings = settings;
|
|
46842
46844
|
this.setCursor();
|
|
46843
46845
|
}
|
|
@@ -47143,7 +47145,7 @@ class Tools extends ToolContext {
|
|
|
47143
47145
|
this.subject.publish(this);
|
|
47144
47146
|
}
|
|
47145
47147
|
sortFrames() {
|
|
47146
|
-
const frames = this.board.items.listAll().filter((
|
|
47148
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame2);
|
|
47147
47149
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
47148
47150
|
const mbr1 = fr1.getMbr();
|
|
47149
47151
|
const mbr2 = fr2.getMbr();
|
|
@@ -47369,24 +47371,24 @@ function validateGroupData(groupData) {
|
|
|
47369
47371
|
}
|
|
47370
47372
|
// src/Items/RegisterItem.ts
|
|
47371
47373
|
function registerItem({
|
|
47372
|
-
item
|
|
47374
|
+
item,
|
|
47373
47375
|
defaultData: defaultData2,
|
|
47374
47376
|
toolData
|
|
47375
47377
|
}) {
|
|
47376
47378
|
const { itemType } = defaultData2;
|
|
47377
|
-
itemFactories[itemType] = createItemFactory(
|
|
47379
|
+
itemFactories[itemType] = createItemFactory(item, defaultData2);
|
|
47378
47380
|
itemValidators[itemType] = createItemValidator(defaultData2);
|
|
47379
47381
|
if (toolData) {
|
|
47380
47382
|
registeredTools[toolData.name] = toolData.tool;
|
|
47381
47383
|
}
|
|
47382
47384
|
itemCommandFactories[itemType] = createItemCommandFactory(itemType);
|
|
47383
47385
|
}
|
|
47384
|
-
function createItemFactory(
|
|
47386
|
+
function createItemFactory(item, defaultData2) {
|
|
47385
47387
|
return function itemFactory(id, data, board) {
|
|
47386
47388
|
if (data.itemType !== defaultData2.itemType) {
|
|
47387
47389
|
throw new Error(`Invalid data for ${defaultData2.itemType}`);
|
|
47388
47390
|
}
|
|
47389
|
-
return new
|
|
47391
|
+
return new item(board, id, defaultData2).setId(id).deserialize(data);
|
|
47390
47392
|
};
|
|
47391
47393
|
}
|
|
47392
47394
|
function createItemValidator(defaultData2) {
|
|
@@ -47401,7 +47403,7 @@ function createItemValidator(defaultData2) {
|
|
|
47401
47403
|
}
|
|
47402
47404
|
function createItemCommandFactory(itemType) {
|
|
47403
47405
|
return function itemCommandFactory(items, operation) {
|
|
47404
|
-
return new BaseCommand(items.filter((
|
|
47406
|
+
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47405
47407
|
};
|
|
47406
47408
|
}
|
|
47407
47409
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -48426,8 +48428,8 @@ class Camera {
|
|
|
48426
48428
|
this.observableItem = null;
|
|
48427
48429
|
}
|
|
48428
48430
|
}
|
|
48429
|
-
subscribeToItem(
|
|
48430
|
-
this.observableItem =
|
|
48431
|
+
subscribeToItem(item) {
|
|
48432
|
+
this.observableItem = item;
|
|
48431
48433
|
this.observableItem.subject.subscribe(this.observeItem);
|
|
48432
48434
|
}
|
|
48433
48435
|
observeItem = () => {
|
|
@@ -48653,7 +48655,7 @@ class Camera {
|
|
|
48653
48655
|
}
|
|
48654
48656
|
addToView(mbr, inView) {
|
|
48655
48657
|
if (!mbr.isEnclosedBy(this.getMbr())) {
|
|
48656
|
-
this.viewRectangle(inView.reduce((acc,
|
|
48658
|
+
this.viewRectangle(inView.reduce((acc, item) => acc.combine(item.getMbr()), inView[0]?.getMbr() ?? new Mbr).combine(mbr));
|
|
48657
48659
|
}
|
|
48658
48660
|
}
|
|
48659
48661
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
@@ -50262,8 +50264,8 @@ class Presence {
|
|
|
50262
50264
|
<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}"/>
|
|
50263
50265
|
</svg>`;
|
|
50264
50266
|
}
|
|
50265
|
-
renderItemMbr(context,
|
|
50266
|
-
const mbr =
|
|
50267
|
+
renderItemMbr(context, item, color2, customScale) {
|
|
50268
|
+
const mbr = item.getMbr();
|
|
50267
50269
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
50268
50270
|
mbr.borderColor = color2;
|
|
50269
50271
|
mbr.render(context);
|
|
@@ -50403,8 +50405,8 @@ class Presence {
|
|
|
50403
50405
|
selectionMbr.strokeWidth = 1 / context.matrix.scaleX;
|
|
50404
50406
|
selectionMbr.borderColor = selection.color;
|
|
50405
50407
|
selectionMbr.render(context);
|
|
50406
|
-
for (const
|
|
50407
|
-
this.renderItemMbr(context,
|
|
50408
|
+
for (const item of selection.selection) {
|
|
50409
|
+
this.renderItemMbr(context, item, selection.color);
|
|
50408
50410
|
}
|
|
50409
50411
|
}
|
|
50410
50412
|
}
|
|
@@ -50437,14 +50439,14 @@ class SelectionItems {
|
|
|
50437
50439
|
items = new Map;
|
|
50438
50440
|
add(value) {
|
|
50439
50441
|
if (Array.isArray(value)) {
|
|
50440
|
-
value.forEach((
|
|
50442
|
+
value.forEach((item) => this.items.set(item.getId(), item));
|
|
50441
50443
|
} else {
|
|
50442
50444
|
this.items.set(value.getId(), value);
|
|
50443
50445
|
}
|
|
50444
50446
|
}
|
|
50445
50447
|
remove(value) {
|
|
50446
50448
|
if (Array.isArray(value)) {
|
|
50447
|
-
value.forEach((
|
|
50449
|
+
value.forEach((item) => this.items.delete(item.getId()));
|
|
50448
50450
|
} else {
|
|
50449
50451
|
this.items.delete(value.getId());
|
|
50450
50452
|
}
|
|
@@ -50474,8 +50476,8 @@ class SelectionItems {
|
|
|
50474
50476
|
if (this.isEmpty()) {
|
|
50475
50477
|
return false;
|
|
50476
50478
|
}
|
|
50477
|
-
for (const
|
|
50478
|
-
if (
|
|
50479
|
+
for (const item of this.items.values()) {
|
|
50480
|
+
if (item.itemType !== "RichText") {
|
|
50479
50481
|
return false;
|
|
50480
50482
|
}
|
|
50481
50483
|
}
|
|
@@ -50485,14 +50487,14 @@ class SelectionItems {
|
|
|
50485
50487
|
if (this.isEmpty()) {
|
|
50486
50488
|
return false;
|
|
50487
50489
|
}
|
|
50488
|
-
return Array.from(this.items).every(([,
|
|
50490
|
+
return Array.from(this.items).every(([, item]) => item.itemType === itemType);
|
|
50489
50491
|
}
|
|
50490
50492
|
isItemTypes(itemTypes) {
|
|
50491
50493
|
if (this.isEmpty()) {
|
|
50492
50494
|
return false;
|
|
50493
50495
|
}
|
|
50494
|
-
for (const
|
|
50495
|
-
if (!itemTypes.includes(
|
|
50496
|
+
for (const item of this.items.values()) {
|
|
50497
|
+
if (!itemTypes.includes(item.itemType)) {
|
|
50496
50498
|
return false;
|
|
50497
50499
|
}
|
|
50498
50500
|
}
|
|
@@ -50500,16 +50502,16 @@ class SelectionItems {
|
|
|
50500
50502
|
}
|
|
50501
50503
|
getItemTypes() {
|
|
50502
50504
|
const itemTypes = new Set;
|
|
50503
|
-
this.items.forEach((
|
|
50505
|
+
this.items.forEach((item) => itemTypes.add(item.itemType));
|
|
50504
50506
|
return Array.from(itemTypes);
|
|
50505
50507
|
}
|
|
50506
50508
|
getItemsByItemTypes(itemTypes) {
|
|
50507
|
-
return Array.from(this.items.values()).filter((
|
|
50509
|
+
return Array.from(this.items.values()).filter((item) => itemTypes.includes(item.itemType));
|
|
50508
50510
|
}
|
|
50509
50511
|
getIdsByItemTypes(itemTypes) {
|
|
50510
50512
|
const ids = [];
|
|
50511
|
-
this.items.forEach((
|
|
50512
|
-
if (itemTypes.includes(
|
|
50513
|
+
this.items.forEach((item, id) => {
|
|
50514
|
+
if (itemTypes.includes(item.itemType)) {
|
|
50513
50515
|
ids.push(id);
|
|
50514
50516
|
}
|
|
50515
50517
|
});
|
|
@@ -50519,7 +50521,7 @@ class SelectionItems {
|
|
|
50519
50521
|
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
50520
50522
|
}
|
|
50521
50523
|
listByIds(itemIdList) {
|
|
50522
|
-
return itemIdList.map((id) => this.items.get(id)).filter((
|
|
50524
|
+
return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
|
|
50523
50525
|
}
|
|
50524
50526
|
ids() {
|
|
50525
50527
|
return Array.from(this.items.keys());
|
|
@@ -50530,7 +50532,7 @@ class SelectionItems {
|
|
|
50530
50532
|
return;
|
|
50531
50533
|
}
|
|
50532
50534
|
const mbr = items[0].getMbr();
|
|
50533
|
-
items.slice(1).forEach((
|
|
50535
|
+
items.slice(1).forEach((item) => mbr.combine(item.getMbr()));
|
|
50534
50536
|
return mbr;
|
|
50535
50537
|
}
|
|
50536
50538
|
}
|
|
@@ -50735,33 +50737,33 @@ function handleMultipleItemsResize({
|
|
|
50735
50737
|
const translation = {};
|
|
50736
50738
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
50737
50739
|
board.items.getComments().forEach((comment2) => {
|
|
50738
|
-
if (items.some((
|
|
50740
|
+
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
50739
50741
|
items.push(comment2);
|
|
50740
50742
|
}
|
|
50741
50743
|
});
|
|
50742
|
-
for (const
|
|
50743
|
-
let itemX =
|
|
50744
|
-
let itemY =
|
|
50745
|
-
if (
|
|
50746
|
-
itemX =
|
|
50747
|
-
itemY =
|
|
50744
|
+
for (const item of items) {
|
|
50745
|
+
let itemX = item.getMbr().left;
|
|
50746
|
+
let itemY = item.getMbr().top;
|
|
50747
|
+
if (item.itemType === "Drawing") {
|
|
50748
|
+
itemX = item.transformation.matrix.translateX;
|
|
50749
|
+
itemY = item.transformation.matrix.translateY;
|
|
50748
50750
|
}
|
|
50749
50751
|
const deltaX = itemX - initMbr.left;
|
|
50750
50752
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
50751
50753
|
const deltaY = itemY - initMbr.top;
|
|
50752
50754
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
50753
|
-
if (
|
|
50754
|
-
translation[
|
|
50755
|
-
item
|
|
50755
|
+
if (item instanceof RichText) {
|
|
50756
|
+
translation[item.getId()] = getRichTextTranslation({
|
|
50757
|
+
item,
|
|
50756
50758
|
isWidth,
|
|
50757
50759
|
isHeight,
|
|
50758
50760
|
matrix,
|
|
50759
50761
|
translateX,
|
|
50760
50762
|
translateY
|
|
50761
50763
|
});
|
|
50762
|
-
} else if (
|
|
50763
|
-
translation[
|
|
50764
|
-
item
|
|
50764
|
+
} else if (item instanceof AINode) {
|
|
50765
|
+
translation[item.getId()] = getAINodeTranslation({
|
|
50766
|
+
item,
|
|
50765
50767
|
isWidth,
|
|
50766
50768
|
isHeight,
|
|
50767
50769
|
matrix,
|
|
@@ -50769,8 +50771,8 @@ function handleMultipleItemsResize({
|
|
|
50769
50771
|
translateY
|
|
50770
50772
|
});
|
|
50771
50773
|
} else {
|
|
50772
|
-
translation[
|
|
50773
|
-
item
|
|
50774
|
+
translation[item.getId()] = getItemTranslation({
|
|
50775
|
+
item,
|
|
50774
50776
|
isWidth,
|
|
50775
50777
|
isHeight,
|
|
50776
50778
|
matrix,
|
|
@@ -50783,7 +50785,7 @@ function handleMultipleItemsResize({
|
|
|
50783
50785
|
return translation;
|
|
50784
50786
|
}
|
|
50785
50787
|
function getRichTextTranslation({
|
|
50786
|
-
item
|
|
50788
|
+
item,
|
|
50787
50789
|
isWidth,
|
|
50788
50790
|
isHeight,
|
|
50789
50791
|
matrix,
|
|
@@ -50791,11 +50793,11 @@ function getRichTextTranslation({
|
|
|
50791
50793
|
translateY
|
|
50792
50794
|
}) {
|
|
50793
50795
|
if (isWidth) {
|
|
50794
|
-
|
|
50796
|
+
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
50795
50797
|
return {
|
|
50796
50798
|
class: "Transformation",
|
|
50797
50799
|
method: "scaleByTranslateBy",
|
|
50798
|
-
item: [
|
|
50800
|
+
item: [item.getId()],
|
|
50799
50801
|
translate: { x: matrix.translateX, y: 0 },
|
|
50800
50802
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50801
50803
|
};
|
|
@@ -50803,7 +50805,7 @@ function getRichTextTranslation({
|
|
|
50803
50805
|
return {
|
|
50804
50806
|
class: "Transformation",
|
|
50805
50807
|
method: "scaleByTranslateBy",
|
|
50806
|
-
item: [
|
|
50808
|
+
item: [item.getId()],
|
|
50807
50809
|
translate: { x: translateX, y: translateY },
|
|
50808
50810
|
scale: { x: 1, y: 1 }
|
|
50809
50811
|
};
|
|
@@ -50811,14 +50813,14 @@ function getRichTextTranslation({
|
|
|
50811
50813
|
return {
|
|
50812
50814
|
class: "Transformation",
|
|
50813
50815
|
method: "scaleByTranslateBy",
|
|
50814
|
-
item: [
|
|
50816
|
+
item: [item.getId()],
|
|
50815
50817
|
translate: { x: translateX, y: translateY },
|
|
50816
50818
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50817
50819
|
};
|
|
50818
50820
|
}
|
|
50819
50821
|
}
|
|
50820
50822
|
function getAINodeTranslation({
|
|
50821
|
-
item
|
|
50823
|
+
item,
|
|
50822
50824
|
isWidth,
|
|
50823
50825
|
isHeight,
|
|
50824
50826
|
matrix,
|
|
@@ -50826,11 +50828,11 @@ function getAINodeTranslation({
|
|
|
50826
50828
|
translateY
|
|
50827
50829
|
}) {
|
|
50828
50830
|
if (isWidth) {
|
|
50829
|
-
|
|
50831
|
+
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
50830
50832
|
return {
|
|
50831
50833
|
class: "Transformation",
|
|
50832
50834
|
method: "scaleByTranslateBy",
|
|
50833
|
-
item: [
|
|
50835
|
+
item: [item.getId()],
|
|
50834
50836
|
translate: { x: matrix.translateX, y: 0 },
|
|
50835
50837
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50836
50838
|
};
|
|
@@ -50838,7 +50840,7 @@ function getAINodeTranslation({
|
|
|
50838
50840
|
return {
|
|
50839
50841
|
class: "Transformation",
|
|
50840
50842
|
method: "scaleByTranslateBy",
|
|
50841
|
-
item: [
|
|
50843
|
+
item: [item.getId()],
|
|
50842
50844
|
translate: { x: translateX, y: translateY },
|
|
50843
50845
|
scale: { x: 1, y: 1 }
|
|
50844
50846
|
};
|
|
@@ -50846,14 +50848,14 @@ function getAINodeTranslation({
|
|
|
50846
50848
|
return {
|
|
50847
50849
|
class: "Transformation",
|
|
50848
50850
|
method: "scaleByTranslateBy",
|
|
50849
|
-
item: [
|
|
50851
|
+
item: [item.getId()],
|
|
50850
50852
|
translate: { x: translateX, y: translateY },
|
|
50851
50853
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50852
50854
|
};
|
|
50853
50855
|
}
|
|
50854
50856
|
}
|
|
50855
50857
|
function getItemTranslation({
|
|
50856
|
-
item
|
|
50858
|
+
item,
|
|
50857
50859
|
isWidth,
|
|
50858
50860
|
isHeight,
|
|
50859
50861
|
matrix,
|
|
@@ -50861,22 +50863,22 @@ function getItemTranslation({
|
|
|
50861
50863
|
translateY,
|
|
50862
50864
|
isShiftPressed
|
|
50863
50865
|
}) {
|
|
50864
|
-
if (
|
|
50866
|
+
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
50865
50867
|
return {
|
|
50866
50868
|
class: "Transformation",
|
|
50867
50869
|
method: "scaleByTranslateBy",
|
|
50868
|
-
item: [
|
|
50870
|
+
item: [item.getId()],
|
|
50869
50871
|
translate: { x: translateX, y: translateY },
|
|
50870
50872
|
scale: { x: 1, y: 1 }
|
|
50871
50873
|
};
|
|
50872
50874
|
} else {
|
|
50873
|
-
if (
|
|
50874
|
-
|
|
50875
|
+
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
50876
|
+
item.setFrameType("Custom");
|
|
50875
50877
|
}
|
|
50876
50878
|
return {
|
|
50877
50879
|
class: "Transformation",
|
|
50878
50880
|
method: "scaleByTranslateBy",
|
|
50879
|
-
item: [
|
|
50881
|
+
item: [item.getId()],
|
|
50880
50882
|
translate: { x: translateX, y: translateY },
|
|
50881
50883
|
scale: { x: matrix.scaleX, y: matrix.scaleY }
|
|
50882
50884
|
};
|
|
@@ -51149,11 +51151,11 @@ function transformItems({
|
|
|
51149
51151
|
setSnapCursorPos
|
|
51150
51152
|
}) {
|
|
51151
51153
|
const items = selection.items.list();
|
|
51152
|
-
const includesProportionalItem = items.some((
|
|
51154
|
+
const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
|
|
51153
51155
|
if (includesProportionalItem && (isWidth || isHeight)) {
|
|
51154
51156
|
return null;
|
|
51155
51157
|
}
|
|
51156
|
-
const isIncludesFixedFrame = items.some((
|
|
51158
|
+
const isIncludesFixedFrame = items.some((item) => item instanceof Frame2 && !item.getCanChangeRatio());
|
|
51157
51159
|
const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
|
|
51158
51160
|
const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
|
|
51159
51161
|
if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
|
|
@@ -51231,23 +51233,23 @@ function updateFrameChildren({
|
|
|
51231
51233
|
nestingHighlighter
|
|
51232
51234
|
}) {
|
|
51233
51235
|
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
51234
|
-
board.selection.items.list().forEach((
|
|
51235
|
-
if ("getChildrenIds" in
|
|
51236
|
-
const currMbr =
|
|
51236
|
+
board.selection.items.list().forEach((item) => {
|
|
51237
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
51238
|
+
const currMbr = item.getMbr();
|
|
51237
51239
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
51238
51240
|
itemsToCheck.forEach((currItem) => {
|
|
51239
|
-
if (
|
|
51240
|
-
nestingHighlighter.add(
|
|
51241
|
+
if (item.handleNesting(currItem) && (currItem.parent === "Board" || currItem.parent === item.getId())) {
|
|
51242
|
+
nestingHighlighter.add(item, currItem);
|
|
51241
51243
|
} else {
|
|
51242
51244
|
nestingHighlighter.remove(currItem);
|
|
51243
51245
|
}
|
|
51244
51246
|
});
|
|
51245
51247
|
} else {
|
|
51246
51248
|
groups.forEach((group) => {
|
|
51247
|
-
if (group.handleNesting(
|
|
51248
|
-
nestingHighlighter.add(group,
|
|
51249
|
+
if (group.handleNesting(item)) {
|
|
51250
|
+
nestingHighlighter.add(group, item);
|
|
51249
51251
|
} else {
|
|
51250
|
-
nestingHighlighter.remove(
|
|
51252
|
+
nestingHighlighter.remove(item);
|
|
51251
51253
|
}
|
|
51252
51254
|
});
|
|
51253
51255
|
}
|
|
@@ -51315,9 +51317,9 @@ class Transformer extends Tool {
|
|
|
51315
51317
|
const pointer = this.board.pointer;
|
|
51316
51318
|
const camera = this.board.camera;
|
|
51317
51319
|
const items = this.selection.items;
|
|
51318
|
-
const
|
|
51320
|
+
const item = items.getSingle();
|
|
51319
51321
|
let resizeType;
|
|
51320
|
-
if (
|
|
51322
|
+
if (item && (item.itemType === "RichText" || item.itemType === "Sticker")) {
|
|
51321
51323
|
resizeType = getTextResizeType(pointer.point, camera.getScale(), mbr);
|
|
51322
51324
|
} else {
|
|
51323
51325
|
resizeType = getResizeType(pointer.point, camera.getScale(), mbr);
|
|
@@ -51571,8 +51573,8 @@ class SelectionTransformer extends Tool {
|
|
|
51571
51573
|
return;
|
|
51572
51574
|
}
|
|
51573
51575
|
if (this.selection.items.isSingle()) {
|
|
51574
|
-
const
|
|
51575
|
-
if (
|
|
51576
|
+
const item = this.selection.items.getSingle();
|
|
51577
|
+
if (item?.itemType === "Connector") {
|
|
51576
51578
|
this.tool = this.connectorTransformerTool;
|
|
51577
51579
|
return;
|
|
51578
51580
|
} else {
|
|
@@ -51655,16 +51657,16 @@ class BoardSelection {
|
|
|
51655
51657
|
this.quickAddButtons = getQuickAddButtons(this, board);
|
|
51656
51658
|
}
|
|
51657
51659
|
serialize() {
|
|
51658
|
-
const selectedItems = this.items.list().map((
|
|
51660
|
+
const selectedItems = this.items.list().map((item) => item.getId());
|
|
51659
51661
|
return JSON.stringify(selectedItems);
|
|
51660
51662
|
}
|
|
51661
51663
|
deserialize(serializedData) {
|
|
51662
51664
|
const selectedItems = JSON.parse(serializedData);
|
|
51663
51665
|
this.removeAll();
|
|
51664
51666
|
selectedItems.forEach((itemId) => {
|
|
51665
|
-
const
|
|
51666
|
-
if (
|
|
51667
|
-
this.items.add(
|
|
51667
|
+
const item = this.board.items.getById(itemId);
|
|
51668
|
+
if (item) {
|
|
51669
|
+
this.items.add(item);
|
|
51668
51670
|
}
|
|
51669
51671
|
});
|
|
51670
51672
|
}
|
|
@@ -51742,19 +51744,19 @@ class BoardSelection {
|
|
|
51742
51744
|
this.updateQueue.clear();
|
|
51743
51745
|
safeRequestAnimationFrame(this.updateScheduledObservers);
|
|
51744
51746
|
};
|
|
51745
|
-
itemObserver = (
|
|
51747
|
+
itemObserver = (item) => {
|
|
51746
51748
|
if (!this.shouldPublish) {
|
|
51747
51749
|
return;
|
|
51748
51750
|
}
|
|
51749
51751
|
this.subject.publish(this);
|
|
51750
|
-
this.itemSubject.publish(
|
|
51752
|
+
this.itemSubject.publish(item);
|
|
51751
51753
|
};
|
|
51752
51754
|
decoratedItemObserver = this.decorateObserverToScheduleUpdate(this.itemObserver);
|
|
51753
51755
|
add(value) {
|
|
51754
51756
|
this.items.add(value);
|
|
51755
51757
|
if (Array.isArray(value)) {
|
|
51756
|
-
for (const
|
|
51757
|
-
|
|
51758
|
+
for (const item of value) {
|
|
51759
|
+
item.subject.subscribe(this.itemObserver);
|
|
51758
51760
|
}
|
|
51759
51761
|
} else {
|
|
51760
51762
|
value.subject.subscribe(this.itemObserver);
|
|
@@ -51763,15 +51765,15 @@ class BoardSelection {
|
|
|
51763
51765
|
this.itemsSubject.publish([]);
|
|
51764
51766
|
}
|
|
51765
51767
|
addAll() {
|
|
51766
|
-
const items = this.board.items.listAll().filter((
|
|
51768
|
+
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
51767
51769
|
this.add(items);
|
|
51768
51770
|
this.setContext("SelectByRect");
|
|
51769
51771
|
}
|
|
51770
51772
|
remove(value) {
|
|
51771
51773
|
this.items.remove(value);
|
|
51772
51774
|
if (Array.isArray(value)) {
|
|
51773
|
-
for (const
|
|
51774
|
-
|
|
51775
|
+
for (const item of value) {
|
|
51776
|
+
item.subject.unsubscribe(this.itemObserver);
|
|
51775
51777
|
}
|
|
51776
51778
|
} else {
|
|
51777
51779
|
value.subject.unsubscribe(this.itemObserver);
|
|
@@ -51865,11 +51867,11 @@ class BoardSelection {
|
|
|
51865
51867
|
if (!this.items.isSingle()) {
|
|
51866
51868
|
return;
|
|
51867
51869
|
}
|
|
51868
|
-
const
|
|
51869
|
-
if (!
|
|
51870
|
+
const item = this.items.getSingle();
|
|
51871
|
+
if (!item) {
|
|
51870
51872
|
return;
|
|
51871
51873
|
}
|
|
51872
|
-
const text5 =
|
|
51874
|
+
const text5 = item.getRichText();
|
|
51873
51875
|
if (!text5) {
|
|
51874
51876
|
return;
|
|
51875
51877
|
}
|
|
@@ -51880,7 +51882,7 @@ class BoardSelection {
|
|
|
51880
51882
|
if (shouldReplace || moveCursorToEnd) {
|
|
51881
51883
|
text5.editor.moveCursorToEndOfTheText();
|
|
51882
51884
|
}
|
|
51883
|
-
this.setTextToEdit(
|
|
51885
|
+
this.setTextToEdit(item);
|
|
51884
51886
|
this.setContext("EditTextUnderPointer");
|
|
51885
51887
|
if (shouldSelect) {
|
|
51886
51888
|
text5.editor.selectWholeText();
|
|
@@ -51890,13 +51892,13 @@ class BoardSelection {
|
|
|
51890
51892
|
editUnderPointer() {
|
|
51891
51893
|
this.removeAll();
|
|
51892
51894
|
const stack = this.board.items.getUnderPointer();
|
|
51893
|
-
const
|
|
51894
|
-
if (
|
|
51895
|
-
this.add(
|
|
51895
|
+
const item = stack.pop();
|
|
51896
|
+
if (item) {
|
|
51897
|
+
this.add(item);
|
|
51896
51898
|
this.setTextToEdit(undefined);
|
|
51897
|
-
const text5 =
|
|
51899
|
+
const text5 = item.getRichText();
|
|
51898
51900
|
if (text5) {
|
|
51899
|
-
this.setTextToEdit(
|
|
51901
|
+
this.setTextToEdit(item);
|
|
51900
51902
|
text5.editor.selectWholeText();
|
|
51901
51903
|
this.board.items.subject.publish(this.board.items);
|
|
51902
51904
|
}
|
|
@@ -51905,26 +51907,26 @@ class BoardSelection {
|
|
|
51905
51907
|
this.setContext("None");
|
|
51906
51908
|
}
|
|
51907
51909
|
}
|
|
51908
|
-
setTextToEdit(
|
|
51910
|
+
setTextToEdit(item) {
|
|
51909
51911
|
if (this.textToEdit) {
|
|
51910
51912
|
this.textToEdit.updateElement();
|
|
51911
51913
|
this.textToEdit.enableRender();
|
|
51912
51914
|
}
|
|
51913
|
-
if (!(
|
|
51915
|
+
if (!(item && item.getRichText())) {
|
|
51914
51916
|
this.textToEdit = undefined;
|
|
51915
51917
|
return;
|
|
51916
51918
|
}
|
|
51917
|
-
const text5 =
|
|
51919
|
+
const text5 = item.getRichText();
|
|
51918
51920
|
if (!text5) {
|
|
51919
51921
|
return;
|
|
51920
51922
|
}
|
|
51921
51923
|
if (text5.isEmpty()) {
|
|
51922
|
-
const textColor = tempStorage.getFontColor(
|
|
51923
|
-
const textSize = tempStorage.getFontSize(
|
|
51924
|
-
const highlightColor = tempStorage.getFontHighlight(
|
|
51925
|
-
const styles = tempStorage.getFontStyles(
|
|
51926
|
-
const horizontalAlignment = tempStorage.getHorizontalAlignment(
|
|
51927
|
-
const verticalAlignment = tempStorage.getVerticalAlignment(
|
|
51924
|
+
const textColor = tempStorage.getFontColor(item.itemType);
|
|
51925
|
+
const textSize = tempStorage.getFontSize(item.itemType);
|
|
51926
|
+
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
51927
|
+
const styles = tempStorage.getFontStyles(item.itemType);
|
|
51928
|
+
const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
|
|
51929
|
+
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
51928
51930
|
if (textColor) {
|
|
51929
51931
|
text5.setSelectionFontColor(textColor, "None");
|
|
51930
51932
|
}
|
|
@@ -51932,7 +51934,7 @@ class BoardSelection {
|
|
|
51932
51934
|
this.emit({
|
|
51933
51935
|
class: "RichText",
|
|
51934
51936
|
method: "setFontSize",
|
|
51935
|
-
item: [
|
|
51937
|
+
item: [item.getId()],
|
|
51936
51938
|
fontSize: textSize,
|
|
51937
51939
|
context: this.getContext()
|
|
51938
51940
|
});
|
|
@@ -51944,10 +51946,10 @@ class BoardSelection {
|
|
|
51944
51946
|
const stylesArr = styles;
|
|
51945
51947
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
51946
51948
|
}
|
|
51947
|
-
if (horizontalAlignment && !(
|
|
51949
|
+
if (horizontalAlignment && !(item instanceof Sticker)) {
|
|
51948
51950
|
text5.setSelectionHorisontalAlignment(horizontalAlignment);
|
|
51949
51951
|
}
|
|
51950
|
-
if (verticalAlignment && !(
|
|
51952
|
+
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
51951
51953
|
this.setVerticalAlignment(verticalAlignment);
|
|
51952
51954
|
}
|
|
51953
51955
|
}
|
|
@@ -51980,8 +51982,8 @@ class BoardSelection {
|
|
|
51980
51982
|
}
|
|
51981
51983
|
selectEnclosedOrCrossedBy(rect) {
|
|
51982
51984
|
this.removeAll();
|
|
51983
|
-
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51984
|
-
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51985
|
+
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => !item.transformation.isLocked);
|
|
51986
|
+
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => (!(item instanceof Frame2) || enclosedFrames.includes(item)) && !item.transformation.isLocked);
|
|
51985
51987
|
if (list6.length !== 0) {
|
|
51986
51988
|
this.add(list6);
|
|
51987
51989
|
this.setContext("SelectByRect");
|
|
@@ -51995,14 +51997,14 @@ class BoardSelection {
|
|
|
51995
51997
|
canChangeText() {
|
|
51996
51998
|
return Boolean(this.items.isSingle() && this.items.getSingle()?.getRichText());
|
|
51997
51999
|
}
|
|
51998
|
-
handleItemCopy(
|
|
51999
|
-
const serializedData =
|
|
52000
|
-
const zIndex = this.board.items.index.getZIndex(
|
|
52001
|
-
if (
|
|
52000
|
+
handleItemCopy(item, copiedItemsMap) {
|
|
52001
|
+
const serializedData = item.serialize(true);
|
|
52002
|
+
const zIndex = this.board.items.index.getZIndex(item);
|
|
52003
|
+
if (item.itemType === "Comment") {
|
|
52002
52004
|
return;
|
|
52003
52005
|
}
|
|
52004
|
-
if (
|
|
52005
|
-
const connector =
|
|
52006
|
+
if (item.itemType === "Connector" && serializedData.itemType === "Connector") {
|
|
52007
|
+
const connector = item;
|
|
52006
52008
|
const startPoint = connector.getStartPoint();
|
|
52007
52009
|
const endPoint = connector.getEndPoint();
|
|
52008
52010
|
const startItemId = startPoint.pointType !== "Board" ? startPoint.item.getId() : null;
|
|
@@ -52018,19 +52020,19 @@ class BoardSelection {
|
|
|
52018
52020
|
serializedData.endPoint = new BoardPoint(endPoint.x, endPoint.y).serialize();
|
|
52019
52021
|
}
|
|
52020
52022
|
}
|
|
52021
|
-
const textItem =
|
|
52023
|
+
const textItem = item.getRichText()?.getTextString();
|
|
52022
52024
|
const copyText = conf.i18n.t("frame.copy");
|
|
52023
52025
|
const isCopyTextExist = textItem?.includes(copyText);
|
|
52024
|
-
const isChangeCopiedFrameText =
|
|
52026
|
+
const isChangeCopiedFrameText = item.itemType === "Frame" && serializedData.itemType === "Frame" && textItem !== "" && !isCopyTextExist;
|
|
52025
52027
|
if (isChangeCopiedFrameText) {
|
|
52026
52028
|
const copiedFrameText = copyText + (textItem || serializedData.text?.placeholderText);
|
|
52027
|
-
|
|
52028
|
-
|
|
52029
|
-
serializedData.text =
|
|
52030
|
-
|
|
52031
|
-
|
|
52029
|
+
item.getRichText()?.editor.clearText();
|
|
52030
|
+
item.getRichText()?.editor.addText(copiedFrameText);
|
|
52031
|
+
serializedData.text = item.getRichText()?.serialize();
|
|
52032
|
+
item.getRichText()?.editor.clearText();
|
|
52033
|
+
item.getRichText()?.editor.addText(textItem || "");
|
|
52032
52034
|
}
|
|
52033
|
-
copiedItemsMap[
|
|
52035
|
+
copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
|
|
52034
52036
|
}
|
|
52035
52037
|
copy(skipImageBlobCopy) {
|
|
52036
52038
|
const copiedItemsMap = {};
|
|
@@ -52039,12 +52041,12 @@ class BoardSelection {
|
|
|
52039
52041
|
this.handleItemCopy(single, copiedItemsMap);
|
|
52040
52042
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
52041
52043
|
}
|
|
52042
|
-
this.list().forEach((
|
|
52043
|
-
this.handleItemCopy(
|
|
52044
|
+
this.list().forEach((item) => {
|
|
52045
|
+
this.handleItemCopy(item, copiedItemsMap);
|
|
52044
52046
|
});
|
|
52045
|
-
this.list().flatMap((
|
|
52046
|
-
if (
|
|
52047
|
-
return
|
|
52047
|
+
this.list().flatMap((item) => {
|
|
52048
|
+
if (item instanceof Frame2) {
|
|
52049
|
+
return item.getChildrenIds();
|
|
52048
52050
|
}
|
|
52049
52051
|
return [];
|
|
52050
52052
|
}).forEach((id) => {
|
|
@@ -52072,11 +52074,11 @@ class BoardSelection {
|
|
|
52072
52074
|
let maxRichText = null;
|
|
52073
52075
|
let minRichText = null;
|
|
52074
52076
|
const itemType = items[0].itemType;
|
|
52075
|
-
for (const
|
|
52076
|
-
if (
|
|
52077
|
+
for (const item of items) {
|
|
52078
|
+
if (item.itemType !== itemType) {
|
|
52077
52079
|
return null;
|
|
52078
52080
|
}
|
|
52079
|
-
const richText =
|
|
52081
|
+
const richText = item.getRichText();
|
|
52080
52082
|
if (richText) {
|
|
52081
52083
|
if (!maxRichText || richText.getFontSize() > maxRichText.getFontSize()) {
|
|
52082
52084
|
maxRichText = richText;
|
|
@@ -52182,22 +52184,22 @@ class BoardSelection {
|
|
|
52182
52184
|
}
|
|
52183
52185
|
nestSelectedItems(unselectedItem, checkFrames = true) {
|
|
52184
52186
|
const selected = this.board.selection.items.list();
|
|
52185
|
-
if (unselectedItem && !selected.find((
|
|
52187
|
+
if (unselectedItem && !selected.find((item) => item.getId() === unselectedItem.getId())) {
|
|
52186
52188
|
selected.push(unselectedItem);
|
|
52187
52189
|
}
|
|
52188
|
-
const selectedMbr = selected.reduce((acc,
|
|
52190
|
+
const selectedMbr = selected.reduce((acc, item) => {
|
|
52189
52191
|
if (!acc) {
|
|
52190
|
-
return
|
|
52192
|
+
return item.getMbr();
|
|
52191
52193
|
}
|
|
52192
|
-
return acc.combine(
|
|
52194
|
+
return acc.combine(item.getMbr());
|
|
52193
52195
|
}, undefined);
|
|
52194
52196
|
if (selectedMbr) {
|
|
52195
|
-
const selectedMap = Object.fromEntries(selected.map((
|
|
52197
|
+
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
52196
52198
|
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
52197
52199
|
enclosedGroups.forEach((group) => {
|
|
52198
|
-
selected.forEach((
|
|
52199
|
-
if (group.handleNesting(
|
|
52200
|
-
selectedMap[
|
|
52200
|
+
selected.forEach((item) => {
|
|
52201
|
+
if (group.handleNesting(item)) {
|
|
52202
|
+
selectedMap[item.getId()].nested = group;
|
|
52201
52203
|
}
|
|
52202
52204
|
});
|
|
52203
52205
|
});
|
|
@@ -52221,11 +52223,11 @@ class BoardSelection {
|
|
|
52221
52223
|
if (childrenIds && checkFrames) {
|
|
52222
52224
|
const currGroup = val.item;
|
|
52223
52225
|
const currMbr = currGroup.getMbr();
|
|
52224
|
-
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((
|
|
52225
|
-
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
52226
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
52227
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
52226
52228
|
const uniqueItems = new Set;
|
|
52227
|
-
const toCheck = [...children, ...underGroup].filter((
|
|
52228
|
-
const id =
|
|
52229
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
52230
|
+
const id = item.getId();
|
|
52229
52231
|
if (uniqueItems.has(id)) {
|
|
52230
52232
|
return false;
|
|
52231
52233
|
}
|
|
@@ -52266,8 +52268,8 @@ class BoardSelection {
|
|
|
52266
52268
|
addItemToTranslation(childId);
|
|
52267
52269
|
}
|
|
52268
52270
|
}
|
|
52269
|
-
const createTranslationWithComments = (
|
|
52270
|
-
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() ===
|
|
52271
|
+
const createTranslationWithComments = (item) => {
|
|
52272
|
+
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
52271
52273
|
for (const comment2 of followedComments) {
|
|
52272
52274
|
translation[comment2.getId()] = {
|
|
52273
52275
|
class: "Transformation",
|
|
@@ -52328,21 +52330,21 @@ class BoardSelection {
|
|
|
52328
52330
|
newData: { borderColor }
|
|
52329
52331
|
};
|
|
52330
52332
|
const operations2 = {};
|
|
52331
|
-
this.items.list().forEach((
|
|
52332
|
-
if (!operations2[
|
|
52333
|
+
this.items.list().forEach((item) => {
|
|
52334
|
+
if (!operations2[item.itemType]) {
|
|
52333
52335
|
const operationCopy = { ...operation };
|
|
52334
|
-
if (
|
|
52336
|
+
if (item.itemType === "Connector") {
|
|
52335
52337
|
operationCopy.method = "setLineColor";
|
|
52336
52338
|
operationCopy.lineColor = borderColor;
|
|
52337
|
-
} else if (
|
|
52339
|
+
} else if (item.itemType === "Drawing") {
|
|
52338
52340
|
operationCopy.method = "setStrokeColor";
|
|
52339
52341
|
operationCopy.color = borderColor;
|
|
52340
52342
|
} else {
|
|
52341
52343
|
operationCopy.borderColor = borderColor;
|
|
52342
52344
|
}
|
|
52343
|
-
operations2[
|
|
52345
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52344
52346
|
} else {
|
|
52345
|
-
operations2[
|
|
52347
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52346
52348
|
}
|
|
52347
52349
|
});
|
|
52348
52350
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52357,13 +52359,13 @@ class BoardSelection {
|
|
|
52357
52359
|
newData: { borderWidth: width2 }
|
|
52358
52360
|
};
|
|
52359
52361
|
const operations2 = {};
|
|
52360
|
-
this.items.list().forEach((
|
|
52361
|
-
if (!operations2[
|
|
52362
|
+
this.items.list().forEach((item) => {
|
|
52363
|
+
if (!operations2[item.itemType]) {
|
|
52362
52364
|
const operationCopy = { ...operation };
|
|
52363
|
-
if (
|
|
52365
|
+
if (item.itemType === "Connector") {
|
|
52364
52366
|
operationCopy.method = "setLineWidth";
|
|
52365
52367
|
operationCopy.lineWidth = width2;
|
|
52366
|
-
} else if (
|
|
52368
|
+
} else if (item.itemType === "Drawing") {
|
|
52367
52369
|
operationCopy.method = "setStrokeWidth";
|
|
52368
52370
|
operationCopy.width = width2;
|
|
52369
52371
|
operationCopy.prevWidth = this.getStrokeWidth();
|
|
@@ -52371,9 +52373,9 @@ class BoardSelection {
|
|
|
52371
52373
|
operationCopy.borderWidth = width2;
|
|
52372
52374
|
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
52373
52375
|
}
|
|
52374
|
-
operations2[
|
|
52376
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52375
52377
|
} else {
|
|
52376
|
-
operations2[
|
|
52378
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52377
52379
|
}
|
|
52378
52380
|
});
|
|
52379
52381
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52389,11 +52391,11 @@ class BoardSelection {
|
|
|
52389
52391
|
newData: { backgroundColor }
|
|
52390
52392
|
};
|
|
52391
52393
|
const operations2 = {};
|
|
52392
|
-
this.items.list().forEach((
|
|
52393
|
-
if (!operations2[
|
|
52394
|
-
operations2[
|
|
52394
|
+
this.items.list().forEach((item) => {
|
|
52395
|
+
if (!operations2[item.itemType]) {
|
|
52396
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
52395
52397
|
} else {
|
|
52396
|
-
operations2[
|
|
52398
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52397
52399
|
}
|
|
52398
52400
|
});
|
|
52399
52401
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52417,9 +52419,9 @@ class BoardSelection {
|
|
|
52417
52419
|
}
|
|
52418
52420
|
setFrameType(frameType) {
|
|
52419
52421
|
const items = this.items.list();
|
|
52420
|
-
items.forEach((
|
|
52421
|
-
if (
|
|
52422
|
-
|
|
52422
|
+
items.forEach((item) => {
|
|
52423
|
+
if (item instanceof Frame2) {
|
|
52424
|
+
item.setFrameType(frameType);
|
|
52423
52425
|
}
|
|
52424
52426
|
});
|
|
52425
52427
|
}
|
|
@@ -52438,21 +52440,21 @@ class BoardSelection {
|
|
|
52438
52440
|
setFontSize(size) {
|
|
52439
52441
|
const fontSize = size === "auto" ? size : toFiniteNumber(size);
|
|
52440
52442
|
const itemsOps = [];
|
|
52441
|
-
for (const
|
|
52442
|
-
const text5 =
|
|
52443
|
+
for (const item of this.items.list()) {
|
|
52444
|
+
const text5 = item.getRichText();
|
|
52443
52445
|
if (!text5) {
|
|
52444
52446
|
continue;
|
|
52445
52447
|
}
|
|
52446
52448
|
const ops = text5.setSelectionFontSize(fontSize, this.context);
|
|
52447
52449
|
itemsOps.push({
|
|
52448
|
-
item:
|
|
52450
|
+
item: item.getId(),
|
|
52449
52451
|
selection: text5.editor.getSelection(),
|
|
52450
52452
|
ops
|
|
52451
52453
|
});
|
|
52452
|
-
if (
|
|
52453
|
-
tempStorage.remove(`fontSize_${
|
|
52454
|
-
} else if (
|
|
52455
|
-
tempStorage.setFontSize(
|
|
52454
|
+
if (item.itemType === "Sticker" && fontSize === "auto") {
|
|
52455
|
+
tempStorage.remove(`fontSize_${item.itemType}`);
|
|
52456
|
+
} else if (item.itemType !== "AINode") {
|
|
52457
|
+
tempStorage.setFontSize(item.itemType, fontSize);
|
|
52456
52458
|
}
|
|
52457
52459
|
}
|
|
52458
52460
|
const emptyOps = itemsOps.filter((op) => !op.ops.length);
|
|
@@ -52475,8 +52477,8 @@ class BoardSelection {
|
|
|
52475
52477
|
setFontStyle(fontStyle) {
|
|
52476
52478
|
const isMultiple = !this.items.isSingle();
|
|
52477
52479
|
const itemsOps = [];
|
|
52478
|
-
for (const
|
|
52479
|
-
const text5 =
|
|
52480
|
+
for (const item of this.items.list()) {
|
|
52481
|
+
const text5 = item.getRichText();
|
|
52480
52482
|
if (!text5) {
|
|
52481
52483
|
continue;
|
|
52482
52484
|
}
|
|
@@ -52485,12 +52487,12 @@ class BoardSelection {
|
|
|
52485
52487
|
}
|
|
52486
52488
|
const ops = text5.setSelectionFontStyle(fontStyle, this.context);
|
|
52487
52489
|
itemsOps.push({
|
|
52488
|
-
item:
|
|
52490
|
+
item: item.getId(),
|
|
52489
52491
|
selection: text5.editor.getSelection(),
|
|
52490
52492
|
ops
|
|
52491
52493
|
});
|
|
52492
|
-
if (
|
|
52493
|
-
tempStorage.setFontStyles(
|
|
52494
|
+
if (item.itemType !== "AINode") {
|
|
52495
|
+
tempStorage.setFontStyles(item.itemType, text5.getFontStyles());
|
|
52494
52496
|
}
|
|
52495
52497
|
}
|
|
52496
52498
|
this.emitApplied({
|
|
@@ -52502,8 +52504,8 @@ class BoardSelection {
|
|
|
52502
52504
|
setFontColor(fontColor) {
|
|
52503
52505
|
const isMultiple = !this.items.isSingle();
|
|
52504
52506
|
const itemsOps = [];
|
|
52505
|
-
for (const
|
|
52506
|
-
const text5 =
|
|
52507
|
+
for (const item of this.items.list()) {
|
|
52508
|
+
const text5 = item.getRichText();
|
|
52507
52509
|
if (!text5) {
|
|
52508
52510
|
continue;
|
|
52509
52511
|
}
|
|
@@ -52512,11 +52514,11 @@ class BoardSelection {
|
|
|
52512
52514
|
}
|
|
52513
52515
|
const ops = text5.setSelectionFontColor(fontColor, this.context);
|
|
52514
52516
|
itemsOps.push({
|
|
52515
|
-
item:
|
|
52517
|
+
item: item.getId(),
|
|
52516
52518
|
selection: text5.editor.getSelection(),
|
|
52517
52519
|
ops
|
|
52518
52520
|
});
|
|
52519
|
-
tempStorage.setFontColor(
|
|
52521
|
+
tempStorage.setFontColor(item.itemType, fontColor);
|
|
52520
52522
|
}
|
|
52521
52523
|
this.emitApplied({
|
|
52522
52524
|
class: "RichText",
|
|
@@ -52545,8 +52547,8 @@ class BoardSelection {
|
|
|
52545
52547
|
setFontHighlight(fontHighlight) {
|
|
52546
52548
|
const isMultiple = !this.items.isSingle();
|
|
52547
52549
|
const itemsOps = [];
|
|
52548
|
-
for (const
|
|
52549
|
-
const text5 =
|
|
52550
|
+
for (const item of this.items.list()) {
|
|
52551
|
+
const text5 = item.getRichText();
|
|
52550
52552
|
if (!text5) {
|
|
52551
52553
|
continue;
|
|
52552
52554
|
}
|
|
@@ -52555,12 +52557,12 @@ class BoardSelection {
|
|
|
52555
52557
|
}
|
|
52556
52558
|
const ops = text5.setSelectionFontHighlight(fontHighlight, this.context);
|
|
52557
52559
|
itemsOps.push({
|
|
52558
|
-
item:
|
|
52560
|
+
item: item.getId(),
|
|
52559
52561
|
selection: text5.editor.getSelection(),
|
|
52560
52562
|
ops
|
|
52561
52563
|
});
|
|
52562
|
-
if (
|
|
52563
|
-
tempStorage.setFontHighlight(
|
|
52564
|
+
if (item.itemType !== "AINode") {
|
|
52565
|
+
tempStorage.setFontHighlight(item.itemType, fontHighlight);
|
|
52564
52566
|
}
|
|
52565
52567
|
}
|
|
52566
52568
|
this.emitApplied({
|
|
@@ -52572,8 +52574,8 @@ class BoardSelection {
|
|
|
52572
52574
|
setHorisontalAlignment(horisontalAlignment) {
|
|
52573
52575
|
const isMultiple = !this.items.isSingle();
|
|
52574
52576
|
const itemsOps = [];
|
|
52575
|
-
for (const
|
|
52576
|
-
const text5 =
|
|
52577
|
+
for (const item of this.items.list()) {
|
|
52578
|
+
const text5 = item.getRichText();
|
|
52577
52579
|
if (!text5) {
|
|
52578
52580
|
continue;
|
|
52579
52581
|
}
|
|
@@ -52582,11 +52584,11 @@ class BoardSelection {
|
|
|
52582
52584
|
}
|
|
52583
52585
|
const ops = text5.setSelectionHorisontalAlignment(horisontalAlignment, this.context);
|
|
52584
52586
|
itemsOps.push({
|
|
52585
|
-
item:
|
|
52587
|
+
item: item.getId(),
|
|
52586
52588
|
selection: text5.editor.getSelection(),
|
|
52587
52589
|
ops
|
|
52588
52590
|
});
|
|
52589
|
-
tempStorage.setHorizontalAlignment(
|
|
52591
|
+
tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
|
|
52590
52592
|
}
|
|
52591
52593
|
this.emitApplied({
|
|
52592
52594
|
class: "RichText",
|
|
@@ -52602,23 +52604,23 @@ class BoardSelection {
|
|
|
52602
52604
|
verticalAlignment
|
|
52603
52605
|
});
|
|
52604
52606
|
if (this.items.isSingle()) {
|
|
52605
|
-
const
|
|
52606
|
-
if (!
|
|
52607
|
+
const item = this.items.getSingle();
|
|
52608
|
+
if (!item) {
|
|
52607
52609
|
return;
|
|
52608
52610
|
}
|
|
52609
|
-
const text5 =
|
|
52611
|
+
const text5 = item.getRichText();
|
|
52610
52612
|
if (!text5) {
|
|
52611
52613
|
return;
|
|
52612
52614
|
}
|
|
52613
|
-
tempStorage.setVerticalAlignment(
|
|
52614
|
-
if (
|
|
52615
|
-
|
|
52615
|
+
tempStorage.setVerticalAlignment(item.itemType, verticalAlignment);
|
|
52616
|
+
if (item instanceof RichText) {
|
|
52617
|
+
item.setEditorFocus(this.context);
|
|
52616
52618
|
}
|
|
52617
52619
|
text5.setEditorFocus(this.context);
|
|
52618
52620
|
}
|
|
52619
52621
|
}
|
|
52620
52622
|
removeFromBoard() {
|
|
52621
|
-
const isLocked = this.items.list().some((
|
|
52623
|
+
const isLocked = this.items.list().some((item) => item.transformation.isLocked);
|
|
52622
52624
|
if (isLocked) {
|
|
52623
52625
|
return;
|
|
52624
52626
|
}
|
|
@@ -52641,7 +52643,7 @@ class BoardSelection {
|
|
|
52641
52643
|
}
|
|
52642
52644
|
getIsLockedSelection() {
|
|
52643
52645
|
const items = this.list();
|
|
52644
|
-
return items.some((
|
|
52646
|
+
return items.some((item) => item.transformation.isLocked);
|
|
52645
52647
|
}
|
|
52646
52648
|
isLocked() {
|
|
52647
52649
|
return false;
|
|
@@ -52668,9 +52670,9 @@ class BoardSelection {
|
|
|
52668
52670
|
}
|
|
52669
52671
|
async duplicate() {
|
|
52670
52672
|
const mediaIds = [];
|
|
52671
|
-
this.items.list().forEach((
|
|
52672
|
-
if ("getStorageId" in
|
|
52673
|
-
const storageId =
|
|
52673
|
+
this.items.list().forEach((item) => {
|
|
52674
|
+
if ("getStorageId" in item) {
|
|
52675
|
+
const storageId = item.getStorageId();
|
|
52674
52676
|
if (storageId) {
|
|
52675
52677
|
mediaIds.push(storageId);
|
|
52676
52678
|
}
|
|
@@ -52680,7 +52682,7 @@ class BoardSelection {
|
|
|
52680
52682
|
if (!canDuplicate) {
|
|
52681
52683
|
return;
|
|
52682
52684
|
}
|
|
52683
|
-
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_,
|
|
52685
|
+
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_, item]) => item.itemType !== "Group"));
|
|
52684
52686
|
this.board.duplicate(filteredItemMap);
|
|
52685
52687
|
this.setContext("EditUnderPointer");
|
|
52686
52688
|
}
|
|
@@ -52714,10 +52716,10 @@ class BoardSelection {
|
|
|
52714
52716
|
lastAssistantMessageId
|
|
52715
52717
|
};
|
|
52716
52718
|
}
|
|
52717
|
-
renderItemMbr(context,
|
|
52718
|
-
const mbr =
|
|
52719
|
+
renderItemMbr(context, item, customScale) {
|
|
52720
|
+
const mbr = item.getMbr();
|
|
52719
52721
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
52720
|
-
const selectionColor =
|
|
52722
|
+
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
52721
52723
|
mbr.borderColor = selectionColor;
|
|
52722
52724
|
mbr.render(context);
|
|
52723
52725
|
}
|
|
@@ -52733,8 +52735,8 @@ class BoardSelection {
|
|
|
52733
52735
|
}
|
|
52734
52736
|
if (!this.transformationRenderBlock) {
|
|
52735
52737
|
if (this.shouldRenderItemsMbr) {
|
|
52736
|
-
for (const
|
|
52737
|
-
this.renderItemMbr(context,
|
|
52738
|
+
for (const item of this.items.list()) {
|
|
52739
|
+
this.renderItemMbr(context, item);
|
|
52738
52740
|
}
|
|
52739
52741
|
}
|
|
52740
52742
|
this.tool.render(context);
|
|
@@ -52746,7 +52748,7 @@ class BoardSelection {
|
|
|
52746
52748
|
if (single && single instanceof AINode) {
|
|
52747
52749
|
const contextItemsIds = single.getContextItems();
|
|
52748
52750
|
if (contextItemsIds.length) {
|
|
52749
|
-
const newContextItems = this.board.items.listAll().filter((
|
|
52751
|
+
const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
|
|
52750
52752
|
contextItems.push(...newContextItems);
|
|
52751
52753
|
}
|
|
52752
52754
|
}
|
|
@@ -52764,15 +52766,15 @@ class BoardSelection {
|
|
|
52764
52766
|
}
|
|
52765
52767
|
}
|
|
52766
52768
|
}
|
|
52767
|
-
contextItems.forEach((
|
|
52768
|
-
if (
|
|
52769
|
-
const path2 =
|
|
52769
|
+
contextItems.forEach((item) => {
|
|
52770
|
+
if (item instanceof AINode) {
|
|
52771
|
+
const path2 = item.getPath();
|
|
52770
52772
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
52771
52773
|
path2.setBorderWidth(2);
|
|
52772
52774
|
path2.setBackgroundColor("none");
|
|
52773
52775
|
path2.render(context);
|
|
52774
52776
|
} else {
|
|
52775
|
-
const itemRect =
|
|
52777
|
+
const itemRect = item.getMbr();
|
|
52776
52778
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
52777
52779
|
itemRect.strokeWidth = 2;
|
|
52778
52780
|
itemRect.render(context);
|
|
@@ -53273,16 +53275,16 @@ class Board {
|
|
|
53273
53275
|
applyBoardOperation(op) {
|
|
53274
53276
|
switch (op.method) {
|
|
53275
53277
|
case "moveToZIndex": {
|
|
53276
|
-
const
|
|
53277
|
-
if (!
|
|
53278
|
+
const item = this.index.getById(op.item);
|
|
53279
|
+
if (!item) {
|
|
53278
53280
|
return;
|
|
53279
53281
|
}
|
|
53280
|
-
return this.index.moveToZIndex(
|
|
53282
|
+
return this.index.moveToZIndex(item, op.zIndex);
|
|
53281
53283
|
}
|
|
53282
53284
|
case "moveManyToZIndex": {
|
|
53283
53285
|
for (const id in op.item) {
|
|
53284
|
-
const
|
|
53285
|
-
if (!
|
|
53286
|
+
const item = this.items.getById(id);
|
|
53287
|
+
if (!item) {
|
|
53286
53288
|
delete op.item.id;
|
|
53287
53289
|
}
|
|
53288
53290
|
}
|
|
@@ -53304,11 +53306,11 @@ class Board {
|
|
|
53304
53306
|
}
|
|
53305
53307
|
return this.index.moveSecondAfterFirst(first, second);
|
|
53306
53308
|
case "bringToFront": {
|
|
53307
|
-
const items = op.item.map((
|
|
53309
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
53308
53310
|
return this.index.bringManyToFront(items);
|
|
53309
53311
|
}
|
|
53310
53312
|
case "sendToBack": {
|
|
53311
|
-
const items = op.item.map((
|
|
53313
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
53312
53314
|
return this.index.sendManyToBack(items);
|
|
53313
53315
|
}
|
|
53314
53316
|
case "add":
|
|
@@ -53332,82 +53334,82 @@ class Board {
|
|
|
53332
53334
|
applyAddItems(op) {
|
|
53333
53335
|
if (Array.isArray(op.item)) {
|
|
53334
53336
|
const data = op.data;
|
|
53335
|
-
const items = op.item.map((
|
|
53336
|
-
const created = this.createItem(
|
|
53337
|
+
const items = op.item.map((item2) => {
|
|
53338
|
+
const created = this.createItem(item2, data[item2]);
|
|
53337
53339
|
this.index.insert(created);
|
|
53338
53340
|
return created;
|
|
53339
53341
|
});
|
|
53340
|
-
items.forEach((
|
|
53341
|
-
if (
|
|
53342
|
-
const connectorData = data[
|
|
53343
|
-
|
|
53344
|
-
|
|
53342
|
+
items.forEach((item2) => {
|
|
53343
|
+
if (item2 instanceof Connector2 && data[item2.getId()]) {
|
|
53344
|
+
const connectorData = data[item2.getId()];
|
|
53345
|
+
item2.applyStartPoint(connectorData.startPoint);
|
|
53346
|
+
item2.applyEndPoint(connectorData.endPoint);
|
|
53345
53347
|
}
|
|
53346
53348
|
});
|
|
53347
53349
|
return;
|
|
53348
53350
|
}
|
|
53349
|
-
const
|
|
53350
|
-
return this.index.insert(
|
|
53351
|
+
const item = this.createItem(op.item, op.data);
|
|
53352
|
+
return this.index.insert(item);
|
|
53351
53353
|
}
|
|
53352
53354
|
applyAddLockedGroupOperation(op) {
|
|
53353
|
-
const
|
|
53354
|
-
const groupChildrenIds =
|
|
53355
|
-
this.index.insert(
|
|
53355
|
+
const item = this.createItem(op.item, op.data);
|
|
53356
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
53357
|
+
this.index.insert(item);
|
|
53356
53358
|
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
53357
53359
|
if (lastChildrenId) {
|
|
53358
53360
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
53359
|
-
this.index.moveToZIndex(
|
|
53361
|
+
this.index.moveToZIndex(item, zIndex);
|
|
53360
53362
|
}
|
|
53361
|
-
|
|
53362
|
-
|
|
53363
|
+
item.getChildren().forEach((item2) => {
|
|
53364
|
+
item2.transformation.isLocked = true;
|
|
53363
53365
|
});
|
|
53364
|
-
|
|
53366
|
+
item.transformation.isLocked = true;
|
|
53365
53367
|
}
|
|
53366
53368
|
applyRemoveOperation(op) {
|
|
53367
53369
|
const removedItems = [];
|
|
53368
|
-
this.findItemAndApply(op.item, (
|
|
53369
|
-
this.index.remove(
|
|
53370
|
-
this.selection.remove(
|
|
53371
|
-
if (
|
|
53372
|
-
|
|
53370
|
+
this.findItemAndApply(op.item, (item) => {
|
|
53371
|
+
this.index.remove(item);
|
|
53372
|
+
this.selection.remove(item);
|
|
53373
|
+
if (item instanceof Connector2) {
|
|
53374
|
+
item.clearObservedItems();
|
|
53373
53375
|
}
|
|
53374
|
-
removedItems.push(
|
|
53376
|
+
removedItems.push(item);
|
|
53375
53377
|
});
|
|
53376
53378
|
}
|
|
53377
53379
|
applyRemoveLockedGroupOperation(op) {
|
|
53378
|
-
const
|
|
53379
|
-
if (!
|
|
53380
|
+
const item = this.index.getById(op.item[0]);
|
|
53381
|
+
if (!item || !(item instanceof Group)) {
|
|
53380
53382
|
return;
|
|
53381
53383
|
}
|
|
53382
|
-
|
|
53383
|
-
|
|
53384
|
-
|
|
53384
|
+
item.getChildren().forEach((item2) => {
|
|
53385
|
+
item2.transformation.isLocked = false;
|
|
53386
|
+
item2.parent = "Board";
|
|
53385
53387
|
});
|
|
53386
|
-
|
|
53388
|
+
item.transformation.isLocked = false;
|
|
53387
53389
|
const removedItems = [];
|
|
53388
|
-
this.findItemAndApply(op.item, (
|
|
53389
|
-
this.index.remove(
|
|
53390
|
-
this.selection.remove(
|
|
53391
|
-
removedItems.push(
|
|
53390
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
53391
|
+
this.index.remove(item2);
|
|
53392
|
+
this.selection.remove(item2);
|
|
53393
|
+
removedItems.push(item2);
|
|
53392
53394
|
});
|
|
53393
53395
|
}
|
|
53394
53396
|
applyItemOperation(op) {
|
|
53395
53397
|
if ("item" in op) {
|
|
53396
|
-
this.findItemAndApply(op.item, (
|
|
53397
|
-
|
|
53398
|
+
this.findItemAndApply(op.item, (item) => {
|
|
53399
|
+
item.apply(op);
|
|
53398
53400
|
});
|
|
53399
53401
|
}
|
|
53400
53402
|
}
|
|
53401
|
-
findItemAndApply(
|
|
53402
|
-
if (Array.isArray(
|
|
53403
|
-
for (const itemId of
|
|
53403
|
+
findItemAndApply(item, apply) {
|
|
53404
|
+
if (Array.isArray(item)) {
|
|
53405
|
+
for (const itemId of item) {
|
|
53404
53406
|
const found = this.items.findById(itemId);
|
|
53405
53407
|
if (found) {
|
|
53406
53408
|
apply(found);
|
|
53407
53409
|
}
|
|
53408
53410
|
}
|
|
53409
53411
|
} else {
|
|
53410
|
-
const found = this.items.findById(
|
|
53412
|
+
const found = this.items.findById(item);
|
|
53411
53413
|
if (found) {
|
|
53412
53414
|
apply(found);
|
|
53413
53415
|
}
|
|
@@ -53416,9 +53418,9 @@ class Board {
|
|
|
53416
53418
|
handleNesting(items) {
|
|
53417
53419
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
53418
53420
|
const groupsMap = new Map;
|
|
53419
|
-
arrayed.forEach((
|
|
53420
|
-
const itemCenter =
|
|
53421
|
-
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(
|
|
53421
|
+
arrayed.forEach((item) => {
|
|
53422
|
+
const itemCenter = item.getMbr().getCenter();
|
|
53423
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
53422
53424
|
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
53423
53425
|
acc = groupItem2;
|
|
53424
53426
|
}
|
|
@@ -53428,7 +53430,7 @@ class Board {
|
|
|
53428
53430
|
if (!groupsMap.has(groupItem)) {
|
|
53429
53431
|
groupsMap.set(groupItem, []);
|
|
53430
53432
|
}
|
|
53431
|
-
groupsMap.get(groupItem)?.push(
|
|
53433
|
+
groupsMap.get(groupItem)?.push(item);
|
|
53432
53434
|
}
|
|
53433
53435
|
});
|
|
53434
53436
|
groupsMap.forEach((items2, group) => {
|
|
@@ -53449,13 +53451,13 @@ class Board {
|
|
|
53449
53451
|
}
|
|
53450
53452
|
return parser(el);
|
|
53451
53453
|
}
|
|
53452
|
-
add(
|
|
53454
|
+
add(item, timeStamp) {
|
|
53453
53455
|
const id = this.getNewItemId();
|
|
53454
53456
|
this.emit({
|
|
53455
53457
|
class: "Board",
|
|
53456
53458
|
method: "add",
|
|
53457
53459
|
item: id,
|
|
53458
|
-
data:
|
|
53460
|
+
data: item.serialize(),
|
|
53459
53461
|
timeStamp
|
|
53460
53462
|
});
|
|
53461
53463
|
const newItem = this.items.getById(id);
|
|
@@ -53465,13 +53467,13 @@ class Board {
|
|
|
53465
53467
|
this.handleNesting(newItem);
|
|
53466
53468
|
return newItem;
|
|
53467
53469
|
}
|
|
53468
|
-
addLockedGroup(
|
|
53470
|
+
addLockedGroup(item) {
|
|
53469
53471
|
const id = this.getNewItemId();
|
|
53470
53472
|
this.emit({
|
|
53471
53473
|
class: "Board",
|
|
53472
53474
|
method: "addLockedGroup",
|
|
53473
53475
|
item: id,
|
|
53474
|
-
data:
|
|
53476
|
+
data: item.serialize()
|
|
53475
53477
|
});
|
|
53476
53478
|
const newItem = this.items.getById(id);
|
|
53477
53479
|
if (!newItem) {
|
|
@@ -53480,32 +53482,32 @@ class Board {
|
|
|
53480
53482
|
this.handleNesting(newItem);
|
|
53481
53483
|
return newItem;
|
|
53482
53484
|
}
|
|
53483
|
-
remove(
|
|
53485
|
+
remove(item, withConnectors = true) {
|
|
53484
53486
|
let connectors = [];
|
|
53485
53487
|
if (withConnectors) {
|
|
53486
|
-
connectors = this.items.getLinkedConnectorsById(
|
|
53488
|
+
connectors = this.items.getLinkedConnectorsById(item.getId()).map((connector) => connector.getId());
|
|
53487
53489
|
}
|
|
53488
|
-
if ("onRemove" in
|
|
53489
|
-
|
|
53490
|
+
if ("onRemove" in item) {
|
|
53491
|
+
item.onRemove();
|
|
53490
53492
|
}
|
|
53491
53493
|
this.emit({
|
|
53492
53494
|
class: "Board",
|
|
53493
53495
|
method: "remove",
|
|
53494
|
-
item: [
|
|
53496
|
+
item: [item.getId(), ...connectors]
|
|
53495
53497
|
});
|
|
53496
53498
|
}
|
|
53497
|
-
removeLockedGroup(
|
|
53499
|
+
removeLockedGroup(item) {
|
|
53498
53500
|
this.emit({
|
|
53499
53501
|
class: "Board",
|
|
53500
53502
|
method: "removeLockedGroup",
|
|
53501
|
-
item: [
|
|
53503
|
+
item: [item.getId()]
|
|
53502
53504
|
});
|
|
53503
53505
|
}
|
|
53504
53506
|
getByZIndex(index2) {
|
|
53505
53507
|
return this.index.getByZIndex(index2);
|
|
53506
53508
|
}
|
|
53507
|
-
getZIndex(
|
|
53508
|
-
return this.index.getZIndex(
|
|
53509
|
+
getZIndex(item) {
|
|
53510
|
+
return this.index.getZIndex(item);
|
|
53509
53511
|
}
|
|
53510
53512
|
getLastZIndex() {
|
|
53511
53513
|
return this.index.getLastZIndex();
|
|
@@ -53517,11 +53519,11 @@ class Board {
|
|
|
53517
53519
|
item: items
|
|
53518
53520
|
});
|
|
53519
53521
|
}
|
|
53520
|
-
moveToZIndex(
|
|
53522
|
+
moveToZIndex(item, zIndex) {
|
|
53521
53523
|
this.emit({
|
|
53522
53524
|
class: "Board",
|
|
53523
53525
|
method: "moveToZIndex",
|
|
53524
|
-
item:
|
|
53526
|
+
item: item.getId(),
|
|
53525
53527
|
zIndex
|
|
53526
53528
|
});
|
|
53527
53529
|
}
|
|
@@ -53549,8 +53551,8 @@ class Board {
|
|
|
53549
53551
|
this.emit({
|
|
53550
53552
|
class: "Board",
|
|
53551
53553
|
method: "bringToFront",
|
|
53552
|
-
item: items.map((
|
|
53553
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53554
|
+
item: items.map((item) => item.getId()),
|
|
53555
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
53554
53556
|
});
|
|
53555
53557
|
}
|
|
53556
53558
|
sendToBack(items) {
|
|
@@ -53561,8 +53563,8 @@ class Board {
|
|
|
53561
53563
|
this.emit({
|
|
53562
53564
|
class: "Board",
|
|
53563
53565
|
method: "sendToBack",
|
|
53564
|
-
item: items.map((
|
|
53565
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53566
|
+
item: items.map((item) => item.getId()),
|
|
53567
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
53566
53568
|
});
|
|
53567
53569
|
}
|
|
53568
53570
|
copy() {
|
|
@@ -53639,7 +53641,7 @@ class Board {
|
|
|
53639
53641
|
return added;
|
|
53640
53642
|
});
|
|
53641
53643
|
addedFrame.addChildItems(addedChildren);
|
|
53642
|
-
parsedData.data.children = addedChildren.map((
|
|
53644
|
+
parsedData.data.children = addedChildren.map((item) => item.getId());
|
|
53643
53645
|
idsMap[parsedData.data.id] = addedFrame.getId();
|
|
53644
53646
|
} else {
|
|
53645
53647
|
const added = this.add(this.createItem(this.getNewItemId(), parsedData));
|
|
@@ -53680,15 +53682,15 @@ class Board {
|
|
|
53680
53682
|
const createdConnectors = {};
|
|
53681
53683
|
const createdFrames = {};
|
|
53682
53684
|
const addItem = (itemData) => {
|
|
53683
|
-
const
|
|
53684
|
-
if (
|
|
53685
|
-
createdConnectors[itemData.id] = { item
|
|
53685
|
+
const item = this.createItem(itemData.id, itemData);
|
|
53686
|
+
if (item instanceof Connector2) {
|
|
53687
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
53686
53688
|
}
|
|
53687
|
-
if (
|
|
53688
|
-
createdFrames[
|
|
53689
|
+
if (item instanceof Frame2) {
|
|
53690
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
53689
53691
|
}
|
|
53690
|
-
this.index.insert(
|
|
53691
|
-
return
|
|
53692
|
+
this.index.insert(item);
|
|
53693
|
+
return item;
|
|
53692
53694
|
};
|
|
53693
53695
|
for (const itemData of items) {
|
|
53694
53696
|
if ("childrenMap" in itemData) {
|
|
@@ -53699,13 +53701,13 @@ class Board {
|
|
|
53699
53701
|
}
|
|
53700
53702
|
}
|
|
53701
53703
|
for (const key in createdConnectors) {
|
|
53702
|
-
const { item
|
|
53703
|
-
|
|
53704
|
-
|
|
53704
|
+
const { item, itemData } = createdConnectors[key];
|
|
53705
|
+
item.applyStartPoint(itemData.startPoint);
|
|
53706
|
+
item.applyEndPoint(itemData.endPoint);
|
|
53705
53707
|
}
|
|
53706
53708
|
for (const key in createdFrames) {
|
|
53707
|
-
const { item
|
|
53708
|
-
|
|
53709
|
+
const { item, itemData } = createdFrames[key];
|
|
53710
|
+
item.applyAddChildren(itemData.children);
|
|
53709
53711
|
}
|
|
53710
53712
|
}
|
|
53711
53713
|
deserialize(snapshot) {
|
|
@@ -53715,33 +53717,33 @@ class Board {
|
|
|
53715
53717
|
const createdFrames = {};
|
|
53716
53718
|
if (Array.isArray(items)) {
|
|
53717
53719
|
for (const itemData of items) {
|
|
53718
|
-
const
|
|
53719
|
-
if (
|
|
53720
|
-
createdConnectors[itemData.id] = { item
|
|
53720
|
+
const item = this.createItem(itemData.id, itemData);
|
|
53721
|
+
if (item instanceof Connector2) {
|
|
53722
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
53721
53723
|
}
|
|
53722
|
-
if (
|
|
53723
|
-
createdFrames[
|
|
53724
|
+
if (item instanceof Frame2) {
|
|
53725
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
53724
53726
|
}
|
|
53725
|
-
this.index.insert(
|
|
53727
|
+
this.index.insert(item);
|
|
53726
53728
|
}
|
|
53727
53729
|
} else {
|
|
53728
53730
|
for (const key in items) {
|
|
53729
53731
|
const itemData = items[key];
|
|
53730
|
-
const
|
|
53731
|
-
if (
|
|
53732
|
-
createdConnectors[key] = { item
|
|
53732
|
+
const item = this.createItem(key, itemData);
|
|
53733
|
+
if (item instanceof Connector2) {
|
|
53734
|
+
createdConnectors[key] = { item, itemData };
|
|
53733
53735
|
}
|
|
53734
|
-
this.index.insert(
|
|
53736
|
+
this.index.insert(item);
|
|
53735
53737
|
}
|
|
53736
53738
|
}
|
|
53737
53739
|
for (const key in createdConnectors) {
|
|
53738
|
-
const { item
|
|
53739
|
-
|
|
53740
|
-
|
|
53740
|
+
const { item, itemData } = createdConnectors[key];
|
|
53741
|
+
item.applyStartPoint(itemData.startPoint);
|
|
53742
|
+
item.applyEndPoint(itemData.endPoint);
|
|
53741
53743
|
}
|
|
53742
53744
|
for (const key in createdFrames) {
|
|
53743
|
-
const { item
|
|
53744
|
-
|
|
53745
|
+
const { item, itemData } = createdFrames[key];
|
|
53746
|
+
item.applyAddChildren(itemData.children);
|
|
53745
53747
|
}
|
|
53746
53748
|
this.events?.log.deserialize(events);
|
|
53747
53749
|
}
|
|
@@ -53979,7 +53981,7 @@ class Board {
|
|
|
53979
53981
|
itemsMap: newMap,
|
|
53980
53982
|
select: select2
|
|
53981
53983
|
});
|
|
53982
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
53984
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
53983
53985
|
this.handleNesting(items);
|
|
53984
53986
|
this.selection.removeAll();
|
|
53985
53987
|
this.selection.add(items);
|
|
@@ -53987,8 +53989,8 @@ class Board {
|
|
|
53987
53989
|
return;
|
|
53988
53990
|
}
|
|
53989
53991
|
removeVoidComments() {
|
|
53990
|
-
const voidComments = this.items.listAll().filter((
|
|
53991
|
-
return
|
|
53992
|
+
const voidComments = this.items.listAll().filter((item) => {
|
|
53993
|
+
return item instanceof Comment && !item.getThread().length;
|
|
53992
53994
|
});
|
|
53993
53995
|
if (voidComments) {
|
|
53994
53996
|
for (const comment2 of voidComments) {
|
|
@@ -54062,7 +54064,7 @@ class Board {
|
|
|
54062
54064
|
}
|
|
54063
54065
|
const mbr = this.selection.getMbr();
|
|
54064
54066
|
const selectedItems = this.selection.items.list();
|
|
54065
|
-
const isSelectedItemsMinWidth = selectedItems.some((
|
|
54067
|
+
const isSelectedItemsMinWidth = selectedItems.some((item) => item.getMbr().getWidth() === 0);
|
|
54066
54068
|
const right = mbr ? mbr.right : 0;
|
|
54067
54069
|
const top = mbr ? mbr.top : 0;
|
|
54068
54070
|
const width2 = mbr ? mbr.getWidth() / 10 : 10;
|
|
@@ -54104,7 +54106,7 @@ class Board {
|
|
|
54104
54106
|
method: "duplicate",
|
|
54105
54107
|
itemsMap: newMap
|
|
54106
54108
|
});
|
|
54107
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
54109
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
54108
54110
|
this.handleNesting(items);
|
|
54109
54111
|
this.selection.removeAll();
|
|
54110
54112
|
this.selection.add(items);
|
|
@@ -54125,9 +54127,9 @@ class Board {
|
|
|
54125
54127
|
if (data.itemType === "Frame") {
|
|
54126
54128
|
data.text.placeholderText = `Frame ${this.getMaxFrameSerial() + 1}`;
|
|
54127
54129
|
}
|
|
54128
|
-
const
|
|
54129
|
-
this.index.insert(
|
|
54130
|
-
items.push(
|
|
54130
|
+
const item = this.createItem(itemId, data);
|
|
54131
|
+
this.index.insert(item);
|
|
54132
|
+
items.push(item);
|
|
54131
54133
|
};
|
|
54132
54134
|
sortedItemsMap.map(([id, data]) => {
|
|
54133
54135
|
if (data.itemType === "Connector") {
|
|
@@ -54142,8 +54144,8 @@ class Board {
|
|
|
54142
54144
|
return;
|
|
54143
54145
|
});
|
|
54144
54146
|
}
|
|
54145
|
-
isOnBoard(
|
|
54146
|
-
return this.items.findById(
|
|
54147
|
+
isOnBoard(item) {
|
|
54148
|
+
return this.items.findById(item.getId()) !== undefined;
|
|
54147
54149
|
}
|
|
54148
54150
|
getMaxFrameSerial() {
|
|
54149
54151
|
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
@@ -54189,7 +54191,7 @@ function areItemsTheSame(opA, opB) {
|
|
|
54189
54191
|
const itemsB = Object.keys(opB.items);
|
|
54190
54192
|
const setA = new Set(itemsA);
|
|
54191
54193
|
const setB = new Set(itemsB);
|
|
54192
|
-
const areArraysEqual = setA.size === setB.size && [...setA].every((
|
|
54194
|
+
const areArraysEqual = setA.size === setB.size && [...setA].every((item) => setB.has(item));
|
|
54193
54195
|
return areArraysEqual;
|
|
54194
54196
|
}
|
|
54195
54197
|
if (!(Array.isArray(opA.item) && Array.isArray(opB.item))) {
|
|
@@ -55848,9 +55850,9 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
55848
55850
|
list6.applyUnconfirmed(filter);
|
|
55849
55851
|
const hasAnyOverlap = (arr1, arr2) => {
|
|
55850
55852
|
const lookup9 = new Set(arr1);
|
|
55851
|
-
return arr2.some((
|
|
55853
|
+
return arr2.some((item) => lookup9.has(item));
|
|
55852
55854
|
};
|
|
55853
|
-
const currSelection = board.selection.list().map((
|
|
55855
|
+
const currSelection = board.selection.list().map((item) => item.getId());
|
|
55854
55856
|
if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
55855
55857
|
board.selection.applyMemoizedCaretOrRange();
|
|
55856
55858
|
}
|
|
@@ -56172,27 +56174,27 @@ function handleAiChatMassage(message, board) {
|
|
|
56172
56174
|
}
|
|
56173
56175
|
}
|
|
56174
56176
|
function handleChatChunk(chunk, board) {
|
|
56175
|
-
const
|
|
56177
|
+
const item = board.items.getById(chunk.itemId);
|
|
56176
56178
|
switch (chunk.type) {
|
|
56177
56179
|
case "chunk":
|
|
56178
|
-
if (!
|
|
56180
|
+
if (!item || item.itemType !== "AINode") {
|
|
56179
56181
|
return;
|
|
56180
56182
|
}
|
|
56181
|
-
|
|
56183
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
|
|
56182
56184
|
break;
|
|
56183
56185
|
case "done":
|
|
56184
|
-
if (!
|
|
56186
|
+
if (!item || item.itemType !== "AINode") {
|
|
56185
56187
|
board.aiGeneratingOnItem = undefined;
|
|
56186
56188
|
return;
|
|
56187
56189
|
}
|
|
56188
|
-
|
|
56190
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56189
56191
|
break;
|
|
56190
56192
|
case "end":
|
|
56191
|
-
if (!
|
|
56193
|
+
if (!item || item.itemType !== "AINode") {
|
|
56192
56194
|
board.aiGeneratingOnItem = undefined;
|
|
56193
56195
|
return;
|
|
56194
56196
|
}
|
|
56195
|
-
|
|
56197
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56196
56198
|
break;
|
|
56197
56199
|
case "error":
|
|
56198
56200
|
default:
|
|
@@ -56209,7 +56211,7 @@ function handleChatChunk(chunk, board) {
|
|
|
56209
56211
|
if (board.aiGeneratingOnItem && generatingItem) {
|
|
56210
56212
|
board.selection.removeAll();
|
|
56211
56213
|
board.selection.add(generatingItem);
|
|
56212
|
-
const rt =
|
|
56214
|
+
const rt = item?.getRichText();
|
|
56213
56215
|
if (generatingItem.itemType === "AINode" && rt) {
|
|
56214
56216
|
const editor = rt.editor;
|
|
56215
56217
|
editor.markdownProcessor.setStopProcessingMarkDownCb(null);
|
|
@@ -56342,14 +56344,14 @@ function handleImageGenerate(response, board) {
|
|
|
56342
56344
|
console.error("Image generation error:", response.message);
|
|
56343
56345
|
if (response.isExternalApiError) {
|
|
56344
56346
|
if (board.aiGeneratingOnItem) {
|
|
56345
|
-
const
|
|
56346
|
-
if (
|
|
56347
|
+
const item = board.items.getById(board.aiGeneratingOnItem);
|
|
56348
|
+
if (item) {
|
|
56347
56349
|
board.selection.removeAll();
|
|
56348
|
-
board.selection.add(
|
|
56349
|
-
const editor =
|
|
56350
|
+
board.selection.add(item);
|
|
56351
|
+
const editor = item.getRichText()?.editor;
|
|
56350
56352
|
editor?.clearText();
|
|
56351
56353
|
editor?.insertCopiedText(conf.i18n.t("AIInput.nodeErrorText"));
|
|
56352
|
-
board.camera.zoomToFit(
|
|
56354
|
+
board.camera.zoomToFit(item.getMbr(), 20);
|
|
56353
56355
|
}
|
|
56354
56356
|
}
|
|
56355
56357
|
} else {
|