microboard-temp 0.4.59 → 0.4.61
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 +905 -886
- package/dist/cjs/index.js +905 -886
- package/dist/cjs/node.js +905 -886
- package/dist/esm/browser.js +905 -886
- package/dist/esm/index.js +905 -886
- package/dist/esm/node.js +905 -886
- package/package.json +1 -1
package/dist/esm/browser.js
CHANGED
|
@@ -642,8 +642,8 @@ class BoardCommand {
|
|
|
642
642
|
switch (operation.method) {
|
|
643
643
|
case "bringToFront": {
|
|
644
644
|
for (const id in operation.prevZIndex) {
|
|
645
|
-
const
|
|
646
|
-
if (!
|
|
645
|
+
const item = this.board.items.getById(id);
|
|
646
|
+
if (!item) {
|
|
647
647
|
delete operation.prevZIndex.id;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
@@ -655,8 +655,8 @@ class BoardCommand {
|
|
|
655
655
|
}
|
|
656
656
|
case "sendToBack": {
|
|
657
657
|
for (const id in operation.prevZIndex) {
|
|
658
|
-
const
|
|
659
|
-
if (!
|
|
658
|
+
const item = this.board.items.getById(id);
|
|
659
|
+
if (!item) {
|
|
660
660
|
delete operation.prevZIndex.id;
|
|
661
661
|
}
|
|
662
662
|
}
|
|
@@ -670,11 +670,11 @@ class BoardCommand {
|
|
|
670
670
|
case "moveSecondBeforeFirst":
|
|
671
671
|
case "moveToZIndex": {
|
|
672
672
|
const items = this.board.items;
|
|
673
|
-
const
|
|
674
|
-
if (!
|
|
673
|
+
const item = items.getById(operation.item);
|
|
674
|
+
if (!item) {
|
|
675
675
|
throw new Error("Get reverse board operation. Item not found");
|
|
676
676
|
}
|
|
677
|
-
const zIndex = this.board.getZIndex(
|
|
677
|
+
const zIndex = this.board.getZIndex(item);
|
|
678
678
|
return {
|
|
679
679
|
class: "Board",
|
|
680
680
|
method: "moveToZIndex",
|
|
@@ -684,8 +684,8 @@ class BoardCommand {
|
|
|
684
684
|
}
|
|
685
685
|
case "moveManyToZIndex": {
|
|
686
686
|
for (const id in operation.item) {
|
|
687
|
-
const
|
|
688
|
-
if (!
|
|
687
|
+
const item = this.board.items.getById(id);
|
|
688
|
+
if (!item) {
|
|
689
689
|
delete operation.item.id;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
@@ -702,15 +702,15 @@ class BoardCommand {
|
|
|
702
702
|
const items = this.board.items;
|
|
703
703
|
const reverse = [];
|
|
704
704
|
for (const itemId of operation.item) {
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
705
|
+
const item = items.getById(itemId);
|
|
706
|
+
if (!item) {
|
|
707
707
|
throw new Error("Get reverse board operation. Item not found");
|
|
708
708
|
}
|
|
709
709
|
reverse.push({
|
|
710
710
|
class: "Board",
|
|
711
711
|
method: "add",
|
|
712
712
|
item: itemId,
|
|
713
|
-
data:
|
|
713
|
+
data: item.serialize()
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
716
|
return reverse;
|
|
@@ -733,32 +733,32 @@ class BoardCommand {
|
|
|
733
733
|
const items = this.board.items;
|
|
734
734
|
const reverse = [];
|
|
735
735
|
for (const itemId of operation.item) {
|
|
736
|
-
const
|
|
737
|
-
if (!
|
|
736
|
+
const item = items.getById(itemId);
|
|
737
|
+
if (!item || item.itemType !== "Group") {
|
|
738
738
|
throw new Error("Get reverse board operation. Item not found");
|
|
739
739
|
}
|
|
740
740
|
reverse.push({
|
|
741
741
|
class: "Board",
|
|
742
742
|
method: "addLockedGroup",
|
|
743
743
|
item: itemId,
|
|
744
|
-
data:
|
|
744
|
+
data: item.serialize()
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
return reverse;
|
|
748
748
|
}
|
|
749
749
|
case "duplicate":
|
|
750
750
|
case "paste": {
|
|
751
|
-
const
|
|
751
|
+
const item = [];
|
|
752
752
|
const map = operation.itemsMap;
|
|
753
753
|
for (const key in map) {
|
|
754
754
|
if (map.hasOwnProperty(key)) {
|
|
755
|
-
|
|
755
|
+
item.push(key);
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
return {
|
|
759
759
|
class: "Board",
|
|
760
760
|
method: "remove",
|
|
761
|
-
item
|
|
761
|
+
item
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
764
|
}
|
|
@@ -7076,11 +7076,11 @@ class SubjectOperation {
|
|
|
7076
7076
|
}
|
|
7077
7077
|
|
|
7078
7078
|
// src/Items/ItemsCommandUtils.ts
|
|
7079
|
-
function mapItemsByOperation(
|
|
7080
|
-
const items = Array.isArray(
|
|
7081
|
-
return items.map((
|
|
7082
|
-
const operation = getCallback(
|
|
7083
|
-
return { item:
|
|
7079
|
+
function mapItemsByOperation(item, getCallback) {
|
|
7080
|
+
const items = Array.isArray(item) ? item : [item];
|
|
7081
|
+
return items.map((item2) => {
|
|
7082
|
+
const operation = getCallback(item2);
|
|
7083
|
+
return { item: item2, operation };
|
|
7084
7084
|
});
|
|
7085
7085
|
}
|
|
7086
7086
|
|
|
@@ -7105,8 +7105,8 @@ class TransformationCommand {
|
|
|
7105
7105
|
}
|
|
7106
7106
|
}
|
|
7107
7107
|
revert() {
|
|
7108
|
-
this.reverse.forEach(({ item
|
|
7109
|
-
|
|
7108
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
7109
|
+
item.apply(operation);
|
|
7110
7110
|
});
|
|
7111
7111
|
}
|
|
7112
7112
|
getReverse() {
|
|
@@ -7848,8 +7848,8 @@ class Path {
|
|
|
7848
7848
|
}
|
|
7849
7849
|
getIntersectionPoints(segment) {
|
|
7850
7850
|
let intersections = [];
|
|
7851
|
-
for (const
|
|
7852
|
-
intersections = intersections.concat(
|
|
7851
|
+
for (const item of this.segments) {
|
|
7852
|
+
intersections = intersections.concat(item.getIntersectionPoints(segment));
|
|
7853
7853
|
}
|
|
7854
7854
|
return intersections;
|
|
7855
7855
|
}
|
|
@@ -7914,8 +7914,8 @@ class Path {
|
|
|
7914
7914
|
}
|
|
7915
7915
|
isOpenEnclosedOrCrossedBy(rectangle) {
|
|
7916
7916
|
let is = false;
|
|
7917
|
-
for (const
|
|
7918
|
-
is = is ||
|
|
7917
|
+
for (const item of this.segments) {
|
|
7918
|
+
is = is || item.isEnclosedOrCrossedBy(rectangle);
|
|
7919
7919
|
}
|
|
7920
7920
|
return is;
|
|
7921
7921
|
}
|
|
@@ -8328,8 +8328,8 @@ class ConnectorCommand {
|
|
|
8328
8328
|
}
|
|
8329
8329
|
}
|
|
8330
8330
|
revert() {
|
|
8331
|
-
for (const { item
|
|
8332
|
-
|
|
8331
|
+
for (const { item, operation } of this.reverse) {
|
|
8332
|
+
item.apply(operation);
|
|
8333
8333
|
}
|
|
8334
8334
|
}
|
|
8335
8335
|
getReverse() {
|
|
@@ -8486,11 +8486,11 @@ class SessionStorage {
|
|
|
8486
8486
|
}
|
|
8487
8487
|
get(key) {
|
|
8488
8488
|
const boardId = this.getBoardId() || "";
|
|
8489
|
-
const
|
|
8490
|
-
if (!
|
|
8489
|
+
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
8490
|
+
if (!item) {
|
|
8491
8491
|
return;
|
|
8492
8492
|
}
|
|
8493
|
-
return JSON.parse(
|
|
8493
|
+
return JSON.parse(item);
|
|
8494
8494
|
}
|
|
8495
8495
|
remove(key) {
|
|
8496
8496
|
const boardId = this.getBoardId() || "";
|
|
@@ -9275,8 +9275,8 @@ class LinkToCommand {
|
|
|
9275
9275
|
}
|
|
9276
9276
|
}
|
|
9277
9277
|
revert() {
|
|
9278
|
-
this.reverse.forEach(({ item
|
|
9279
|
-
|
|
9278
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
9279
|
+
item.apply(operation);
|
|
9280
9280
|
});
|
|
9281
9281
|
}
|
|
9282
9282
|
getReverse() {
|
|
@@ -10577,9 +10577,9 @@ function handleSplitListItem(editor) {
|
|
|
10577
10577
|
Transforms3.insertNodes(editor, {
|
|
10578
10578
|
type: listType,
|
|
10579
10579
|
listLevel: listNode.listLevel || 0,
|
|
10580
|
-
children: itemsAfter.map((
|
|
10580
|
+
children: itemsAfter.map((item) => ({
|
|
10581
10581
|
type: "list_item",
|
|
10582
|
-
children:
|
|
10582
|
+
children: item.children
|
|
10583
10583
|
}))
|
|
10584
10584
|
}, { at: newListPath });
|
|
10585
10585
|
}
|
|
@@ -12556,10 +12556,10 @@ function initializeDocument(effects) {
|
|
|
12556
12556
|
return start;
|
|
12557
12557
|
function start(code) {
|
|
12558
12558
|
if (continued < stack.length) {
|
|
12559
|
-
const
|
|
12560
|
-
self2.containerState =
|
|
12561
|
-
ok(
|
|
12562
|
-
return effects.attempt(
|
|
12559
|
+
const item = stack[continued];
|
|
12560
|
+
self2.containerState = item[1];
|
|
12561
|
+
ok(item[0].continuation, "expected `continuation` to be defined on container construct");
|
|
12562
|
+
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
|
|
12563
12563
|
}
|
|
12564
12564
|
return checkNewContainers(code);
|
|
12565
12565
|
}
|
|
@@ -13535,17 +13535,17 @@ class SpliceBuffer {
|
|
|
13535
13535
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13536
13536
|
return this.left.pop();
|
|
13537
13537
|
}
|
|
13538
|
-
push(
|
|
13538
|
+
push(item) {
|
|
13539
13539
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13540
|
-
this.left.push(
|
|
13540
|
+
this.left.push(item);
|
|
13541
13541
|
}
|
|
13542
13542
|
pushMany(items) {
|
|
13543
13543
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
13544
13544
|
chunkedPush(this.left, items);
|
|
13545
13545
|
}
|
|
13546
|
-
unshift(
|
|
13546
|
+
unshift(item) {
|
|
13547
13547
|
this.setCursor(0);
|
|
13548
|
-
this.right.push(
|
|
13548
|
+
this.right.push(item);
|
|
13549
13549
|
}
|
|
13550
13550
|
unshiftMany(items) {
|
|
13551
13551
|
this.setCursor(0);
|
|
@@ -15576,8 +15576,8 @@ function initializeFactory(field) {
|
|
|
15576
15576
|
if (list2) {
|
|
15577
15577
|
ok(Array.isArray(list2), "expected `disable.null` to be populated");
|
|
15578
15578
|
while (++index2 < list2.length) {
|
|
15579
|
-
const
|
|
15580
|
-
if (!
|
|
15579
|
+
const item = list2[index2];
|
|
15580
|
+
if (!item.previous || item.previous.call(self2, self2.previous)) {
|
|
15581
15581
|
return true;
|
|
15582
15582
|
}
|
|
15583
15583
|
}
|
|
@@ -16408,14 +16408,14 @@ function compiler(options) {
|
|
|
16408
16408
|
length++;
|
|
16409
16409
|
}
|
|
16410
16410
|
if (event[1].type === types.listItemPrefix) {
|
|
16411
|
-
const
|
|
16411
|
+
const item = {
|
|
16412
16412
|
type: "listItem",
|
|
16413
16413
|
_spread: false,
|
|
16414
16414
|
start: Object.assign({}, event[1].start),
|
|
16415
16415
|
end: undefined
|
|
16416
16416
|
};
|
|
16417
|
-
listItem2 =
|
|
16418
|
-
events.splice(index2, 0, ["enter",
|
|
16417
|
+
listItem2 = item;
|
|
16418
|
+
events.splice(index2, 0, ["enter", item, event[2]]);
|
|
16419
16419
|
index2++;
|
|
16420
16420
|
length++;
|
|
16421
16421
|
firstBlankLineIndex = undefined;
|
|
@@ -17213,14 +17213,14 @@ class MarkdownProcessor {
|
|
|
17213
17213
|
if (err || !file) {
|
|
17214
17214
|
throw err;
|
|
17215
17215
|
}
|
|
17216
|
-
const nodes = file.result.map((
|
|
17216
|
+
const nodes = file.result.map((item) => {
|
|
17217
17217
|
setNodeStyles({
|
|
17218
|
-
node:
|
|
17218
|
+
node: item,
|
|
17219
17219
|
editor: this.editor,
|
|
17220
17220
|
horisontalAlignment: "left",
|
|
17221
|
-
isPaddingTopNeeded:
|
|
17221
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
17222
17222
|
});
|
|
17223
|
-
return
|
|
17223
|
+
return item;
|
|
17224
17224
|
});
|
|
17225
17225
|
if (isNewParagraphNeeded) {
|
|
17226
17226
|
nodes.push(createParagraphNode("", this.editor));
|
|
@@ -18198,8 +18198,8 @@ class ShapeCommand {
|
|
|
18198
18198
|
}
|
|
18199
18199
|
}
|
|
18200
18200
|
revert() {
|
|
18201
|
-
for (const { item
|
|
18202
|
-
|
|
18201
|
+
for (const { item, operation } of this.reverse) {
|
|
18202
|
+
item.apply(operation);
|
|
18203
18203
|
}
|
|
18204
18204
|
}
|
|
18205
18205
|
getReverse() {
|
|
@@ -18281,8 +18281,8 @@ class RichTextCommand {
|
|
|
18281
18281
|
}
|
|
18282
18282
|
}
|
|
18283
18283
|
revert() {
|
|
18284
|
-
for (const { item
|
|
18285
|
-
const richText = this.board.items.getById(
|
|
18284
|
+
for (const { item, operation } of this.reverse) {
|
|
18285
|
+
const richText = this.board.items.getById(item);
|
|
18286
18286
|
if (!richText) {
|
|
18287
18287
|
continue;
|
|
18288
18288
|
}
|
|
@@ -18301,12 +18301,12 @@ class RichTextCommand {
|
|
|
18301
18301
|
case "setSelectionFontColor":
|
|
18302
18302
|
case "setSelectionBlockType":
|
|
18303
18303
|
const inverseOps = this.operation.ops.map((op) => Operation3.inverse(op)).reverse();
|
|
18304
|
-
return items.map((
|
|
18304
|
+
return items.map((item) => {
|
|
18305
18305
|
const operation = {
|
|
18306
18306
|
...this.operation,
|
|
18307
18307
|
ops: inverseOps
|
|
18308
18308
|
};
|
|
18309
|
-
return { item
|
|
18309
|
+
return { item, operation };
|
|
18310
18310
|
});
|
|
18311
18311
|
case "setFontColor":
|
|
18312
18312
|
return items.map((id) => ({
|
|
@@ -18398,13 +18398,13 @@ class RichTextGroupCommand {
|
|
|
18398
18398
|
this.reverseOps = this.getReverse();
|
|
18399
18399
|
}
|
|
18400
18400
|
apply() {
|
|
18401
|
-
for (const { item
|
|
18402
|
-
|
|
18401
|
+
for (const { item, operation } of this.forwardOps) {
|
|
18402
|
+
item.applyCommand(operation);
|
|
18403
18403
|
}
|
|
18404
18404
|
}
|
|
18405
18405
|
revert() {
|
|
18406
|
-
for (const { item
|
|
18407
|
-
|
|
18406
|
+
for (const { item, operation } of this.reverseOps) {
|
|
18407
|
+
item.applyCommand(operation);
|
|
18408
18408
|
}
|
|
18409
18409
|
}
|
|
18410
18410
|
getForward() {
|
|
@@ -18519,8 +18519,8 @@ class DrawingCommand {
|
|
|
18519
18519
|
item;
|
|
18520
18520
|
operation;
|
|
18521
18521
|
reverse;
|
|
18522
|
-
constructor(
|
|
18523
|
-
this.item =
|
|
18522
|
+
constructor(item, operation) {
|
|
18523
|
+
this.item = item;
|
|
18524
18524
|
this.operation = operation;
|
|
18525
18525
|
this.reverse = this.getReverse();
|
|
18526
18526
|
}
|
|
@@ -18529,52 +18529,52 @@ class DrawingCommand {
|
|
|
18529
18529
|
return this;
|
|
18530
18530
|
}
|
|
18531
18531
|
apply() {
|
|
18532
|
-
for (const
|
|
18533
|
-
|
|
18532
|
+
for (const item of this.item) {
|
|
18533
|
+
item.apply(this.operation);
|
|
18534
18534
|
}
|
|
18535
18535
|
}
|
|
18536
18536
|
revert() {
|
|
18537
|
-
for (const { item
|
|
18538
|
-
|
|
18537
|
+
for (const { item, operation } of this.reverse) {
|
|
18538
|
+
item.apply(operation);
|
|
18539
18539
|
}
|
|
18540
18540
|
}
|
|
18541
18541
|
getReverse() {
|
|
18542
18542
|
const reverse = [];
|
|
18543
|
-
for (const
|
|
18544
|
-
reverse.push({ item
|
|
18543
|
+
for (const item of this.item) {
|
|
18544
|
+
reverse.push({ item, operation: this.getReverseOperation(item) });
|
|
18545
18545
|
}
|
|
18546
18546
|
return reverse;
|
|
18547
18547
|
}
|
|
18548
|
-
getReverseOperation(
|
|
18548
|
+
getReverseOperation(item) {
|
|
18549
18549
|
switch (this.operation.method) {
|
|
18550
18550
|
case "setStrokeColor":
|
|
18551
18551
|
return {
|
|
18552
18552
|
class: "Drawing",
|
|
18553
18553
|
method: "setStrokeColor",
|
|
18554
|
-
item: [
|
|
18555
|
-
color:
|
|
18554
|
+
item: [item.getId()],
|
|
18555
|
+
color: item.getStrokeColor()
|
|
18556
18556
|
};
|
|
18557
18557
|
case "setStrokeWidth":
|
|
18558
18558
|
return {
|
|
18559
18559
|
class: "Drawing",
|
|
18560
18560
|
method: "setStrokeWidth",
|
|
18561
|
-
item: [
|
|
18561
|
+
item: [item.getId()],
|
|
18562
18562
|
width: this.operation.prevWidth,
|
|
18563
|
-
prevWidth:
|
|
18563
|
+
prevWidth: item.getStrokeWidth()
|
|
18564
18564
|
};
|
|
18565
18565
|
case "setStrokeOpacity":
|
|
18566
18566
|
return {
|
|
18567
18567
|
class: "Drawing",
|
|
18568
18568
|
method: "setStrokeOpacity",
|
|
18569
|
-
item: [
|
|
18570
|
-
opacity:
|
|
18569
|
+
item: [item.getId()],
|
|
18570
|
+
opacity: item.getStrokeOpacity()
|
|
18571
18571
|
};
|
|
18572
18572
|
case "setStrokeStyle":
|
|
18573
18573
|
return {
|
|
18574
18574
|
class: "Drawing",
|
|
18575
18575
|
method: "setStrokeStyle",
|
|
18576
|
-
item: [
|
|
18577
|
-
style:
|
|
18576
|
+
item: [item.getId()],
|
|
18577
|
+
style: item.getBorderStyle()
|
|
18578
18578
|
};
|
|
18579
18579
|
}
|
|
18580
18580
|
}
|
|
@@ -18596,8 +18596,8 @@ class StickerCommand {
|
|
|
18596
18596
|
}
|
|
18597
18597
|
}
|
|
18598
18598
|
revert() {
|
|
18599
|
-
for (const { item
|
|
18600
|
-
|
|
18599
|
+
for (const { item, operation } of this.reverse) {
|
|
18600
|
+
item.apply(operation);
|
|
18601
18601
|
}
|
|
18602
18602
|
}
|
|
18603
18603
|
getReverse() {
|
|
@@ -18629,8 +18629,8 @@ class FrameCommand {
|
|
|
18629
18629
|
}
|
|
18630
18630
|
}
|
|
18631
18631
|
revert() {
|
|
18632
|
-
for (const { item
|
|
18633
|
-
|
|
18632
|
+
for (const { item, operation } of this.reverse) {
|
|
18633
|
+
item.apply(operation);
|
|
18634
18634
|
}
|
|
18635
18635
|
}
|
|
18636
18636
|
getReverse() {
|
|
@@ -18672,21 +18672,23 @@ class FrameCommand {
|
|
|
18672
18672
|
};
|
|
18673
18673
|
});
|
|
18674
18674
|
default:
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18675
|
+
return mapItemsByOperation(frame, (item) => {
|
|
18676
|
+
const op = this.operation;
|
|
18677
|
+
let newData = {};
|
|
18678
|
+
if (op.prevData) {
|
|
18679
|
+
newData = { ...op.prevData };
|
|
18680
|
+
} else {
|
|
18681
|
+
Object.keys(op.newData).forEach((key) => {
|
|
18682
|
+
if (item[key]) {
|
|
18683
|
+
newData[key] = item[key];
|
|
18684
|
+
}
|
|
18685
|
+
});
|
|
18686
|
+
}
|
|
18687
|
+
return {
|
|
18688
|
+
...op,
|
|
18689
|
+
newData
|
|
18690
|
+
};
|
|
18691
|
+
});
|
|
18690
18692
|
}
|
|
18691
18693
|
}
|
|
18692
18694
|
}
|
|
@@ -18707,8 +18709,8 @@ class CommentCommand {
|
|
|
18707
18709
|
}
|
|
18708
18710
|
}
|
|
18709
18711
|
revert() {
|
|
18710
|
-
this.reverse.forEach(({ item
|
|
18711
|
-
|
|
18712
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
18713
|
+
item.apply(operation);
|
|
18712
18714
|
});
|
|
18713
18715
|
}
|
|
18714
18716
|
getReverse() {
|
|
@@ -19170,8 +19172,8 @@ class GroupCommand {
|
|
|
19170
19172
|
}
|
|
19171
19173
|
}
|
|
19172
19174
|
revert() {
|
|
19173
|
-
for (const { item
|
|
19174
|
-
|
|
19175
|
+
for (const { item, operation } of this.reverse) {
|
|
19176
|
+
item.apply(operation);
|
|
19175
19177
|
}
|
|
19176
19178
|
}
|
|
19177
19179
|
getReverse() {
|
|
@@ -19224,8 +19226,8 @@ class PlaceholderCommand {
|
|
|
19224
19226
|
}
|
|
19225
19227
|
}
|
|
19226
19228
|
revert() {
|
|
19227
|
-
for (const { item
|
|
19228
|
-
|
|
19229
|
+
for (const { item, operation } of this.reverse) {
|
|
19230
|
+
item.apply(operation);
|
|
19229
19231
|
}
|
|
19230
19232
|
}
|
|
19231
19233
|
getReverse() {
|
|
@@ -19319,34 +19321,51 @@ class BaseCommand {
|
|
|
19319
19321
|
return this;
|
|
19320
19322
|
}
|
|
19321
19323
|
apply() {
|
|
19322
|
-
for (const
|
|
19323
|
-
|
|
19324
|
+
for (const item of this.items) {
|
|
19325
|
+
item.apply(this.operation);
|
|
19324
19326
|
}
|
|
19325
19327
|
}
|
|
19326
19328
|
revert() {
|
|
19327
|
-
for (const { item
|
|
19328
|
-
|
|
19329
|
+
for (const { item, operation } of this.reverse) {
|
|
19330
|
+
item.apply(operation);
|
|
19329
19331
|
}
|
|
19330
19332
|
}
|
|
19331
19333
|
getReverse() {
|
|
19332
19334
|
const items = this.items;
|
|
19333
|
-
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
|
|
19338
|
-
|
|
19339
|
-
|
|
19340
|
-
|
|
19341
|
-
|
|
19335
|
+
switch (this.operation.method) {
|
|
19336
|
+
case "addChildren":
|
|
19337
|
+
return mapItemsByOperation(items, (item) => {
|
|
19338
|
+
return {
|
|
19339
|
+
...this.operation,
|
|
19340
|
+
newData: { childIds: item.getChildrenIds() }
|
|
19341
|
+
};
|
|
19342
|
+
});
|
|
19343
|
+
case "removeChildren":
|
|
19344
|
+
return mapItemsByOperation(items, (item) => {
|
|
19345
|
+
return {
|
|
19346
|
+
...this.operation,
|
|
19347
|
+
newData: { childIds: item.getChildrenIds() }
|
|
19348
|
+
};
|
|
19349
|
+
});
|
|
19350
|
+
default:
|
|
19351
|
+
return mapItemsByOperation(items, (item) => {
|
|
19352
|
+
const op = this.operation;
|
|
19353
|
+
let newData = {};
|
|
19354
|
+
if (op.prevData) {
|
|
19355
|
+
newData = { ...op.prevData };
|
|
19356
|
+
} else {
|
|
19357
|
+
Object.keys(op.newData).forEach((key) => {
|
|
19358
|
+
if (item[key]) {
|
|
19359
|
+
newData[key] = item[key];
|
|
19360
|
+
}
|
|
19361
|
+
});
|
|
19342
19362
|
}
|
|
19363
|
+
return {
|
|
19364
|
+
...op,
|
|
19365
|
+
newData
|
|
19366
|
+
};
|
|
19343
19367
|
});
|
|
19344
|
-
|
|
19345
|
-
return {
|
|
19346
|
-
...op,
|
|
19347
|
-
newData
|
|
19348
|
-
};
|
|
19349
|
-
});
|
|
19368
|
+
}
|
|
19350
19369
|
}
|
|
19351
19370
|
}
|
|
19352
19371
|
var itemCommandFactories = {
|
|
@@ -19366,37 +19385,37 @@ var itemCommandFactories = {
|
|
|
19366
19385
|
LinkTo: createLinkToCommand
|
|
19367
19386
|
};
|
|
19368
19387
|
function createConnectorCommand(items, operation) {
|
|
19369
|
-
return new ConnectorCommand(items.filter((
|
|
19388
|
+
return new ConnectorCommand(items.filter((item) => item.itemType === "Connector"), operation);
|
|
19370
19389
|
}
|
|
19371
19390
|
function createShapeCommand(items, operation) {
|
|
19372
|
-
return new ShapeCommand(items.filter((
|
|
19391
|
+
return new ShapeCommand(items.filter((item) => item.itemType === "Shape"), operation);
|
|
19373
19392
|
}
|
|
19374
19393
|
function createDrawingCommand(items, operation) {
|
|
19375
|
-
return new DrawingCommand(items.filter((
|
|
19394
|
+
return new DrawingCommand(items.filter((item) => item.itemType === "Drawing"), operation);
|
|
19376
19395
|
}
|
|
19377
19396
|
function createCommentCommand(items, operation) {
|
|
19378
|
-
return new CommentCommand(items.filter((
|
|
19397
|
+
return new CommentCommand(items.filter((item) => item.itemType === "Comment"), operation);
|
|
19379
19398
|
}
|
|
19380
19399
|
function createStickerCommand(items, operation) {
|
|
19381
|
-
return new StickerCommand(items.filter((
|
|
19400
|
+
return new StickerCommand(items.filter((item) => item.itemType === "Sticker"), operation);
|
|
19382
19401
|
}
|
|
19383
19402
|
function createFrameCommand(items, operation) {
|
|
19384
|
-
return new FrameCommand(items.filter((
|
|
19403
|
+
return new FrameCommand(items.filter((item) => item.itemType === "Frame"), operation);
|
|
19385
19404
|
}
|
|
19386
19405
|
function createPlaceholderCommand(items, operation) {
|
|
19387
|
-
return new PlaceholderCommand(items.filter((
|
|
19406
|
+
return new PlaceholderCommand(items.filter((item) => item.itemType === "Placeholder"), operation);
|
|
19388
19407
|
}
|
|
19389
19408
|
function createGroupCommand(items, operation) {
|
|
19390
|
-
return new GroupCommand(items.filter((
|
|
19409
|
+
return new GroupCommand(items.filter((item) => item.itemType === "Group"), operation);
|
|
19391
19410
|
}
|
|
19392
19411
|
function createImageCommand(items, operation) {
|
|
19393
|
-
return new ImageCommand(items.filter((
|
|
19412
|
+
return new ImageCommand(items.filter((item) => item.itemType === "Image"), operation);
|
|
19394
19413
|
}
|
|
19395
19414
|
function createVideoCommand(items, operation) {
|
|
19396
|
-
return new VideoCommand(items.filter((
|
|
19415
|
+
return new VideoCommand(items.filter((item) => item.itemType === "Video"), operation);
|
|
19397
19416
|
}
|
|
19398
19417
|
function createAudioCommand(items, operation) {
|
|
19399
|
-
return new AudioCommand(items.filter((
|
|
19418
|
+
return new AudioCommand(items.filter((item) => item.itemType === "Audio"), operation);
|
|
19400
19419
|
}
|
|
19401
19420
|
function createRichTextCommand(items, operation, board) {
|
|
19402
19421
|
if (!board) {
|
|
@@ -19404,8 +19423,8 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19404
19423
|
}
|
|
19405
19424
|
if (operation.method === "groupEdit") {
|
|
19406
19425
|
const texts = [];
|
|
19407
|
-
for (const { item
|
|
19408
|
-
const found = board.items.findById(
|
|
19426
|
+
for (const { item } of operation.itemsOps) {
|
|
19427
|
+
const found = board.items.findById(item);
|
|
19409
19428
|
const text3 = found?.getRichText();
|
|
19410
19429
|
if (text3) {
|
|
19411
19430
|
texts.push(text3);
|
|
@@ -19413,14 +19432,14 @@ function createRichTextCommand(items, operation, board) {
|
|
|
19413
19432
|
}
|
|
19414
19433
|
return new RichTextGroupCommand(texts, operation);
|
|
19415
19434
|
} else {
|
|
19416
|
-
return new RichTextCommand(board, items.map((
|
|
19435
|
+
return new RichTextCommand(board, items.map((item) => item.getId()), operation);
|
|
19417
19436
|
}
|
|
19418
19437
|
}
|
|
19419
19438
|
function createTransformationCommand(items, operation) {
|
|
19420
|
-
return new TransformationCommand(items.map((
|
|
19439
|
+
return new TransformationCommand(items.map((item) => item.transformation), operation);
|
|
19421
19440
|
}
|
|
19422
19441
|
function createLinkToCommand(items, operation) {
|
|
19423
|
-
return new LinkToCommand(items.map((
|
|
19442
|
+
return new LinkToCommand(items.map((item) => item.linkTo), operation);
|
|
19424
19443
|
}
|
|
19425
19444
|
function createCommand(board, operation) {
|
|
19426
19445
|
try {
|
|
@@ -19438,13 +19457,13 @@ function createCommand(board, operation) {
|
|
|
19438
19457
|
default: {
|
|
19439
19458
|
const itemType = operation.class;
|
|
19440
19459
|
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);
|
|
19441
|
-
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((
|
|
19442
|
-
if (typeof
|
|
19443
|
-
console.warn(`Item with ID ${
|
|
19460
|
+
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
|
|
19461
|
+
if (typeof item === "string") {
|
|
19462
|
+
console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
|
|
19444
19463
|
return false;
|
|
19445
19464
|
}
|
|
19446
|
-
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" &&
|
|
19447
|
-
console.warn(`Item with ID ${
|
|
19465
|
+
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" && item.itemType !== operation.class) {
|
|
19466
|
+
console.warn(`Item with ID ${item} is not of operation type: ${itemType}.`);
|
|
19448
19467
|
return false;
|
|
19449
19468
|
}
|
|
19450
19469
|
return true;
|
|
@@ -19745,20 +19764,20 @@ class RBush {
|
|
|
19745
19764
|
}
|
|
19746
19765
|
return this;
|
|
19747
19766
|
}
|
|
19748
|
-
insert(
|
|
19749
|
-
if (
|
|
19750
|
-
this._insert(
|
|
19767
|
+
insert(item) {
|
|
19768
|
+
if (item)
|
|
19769
|
+
this._insert(item, this.data.height - 1);
|
|
19751
19770
|
return this;
|
|
19752
19771
|
}
|
|
19753
19772
|
clear() {
|
|
19754
19773
|
this.data = createNode([]);
|
|
19755
19774
|
return this;
|
|
19756
19775
|
}
|
|
19757
|
-
remove(
|
|
19758
|
-
if (!
|
|
19776
|
+
remove(item, equalsFn) {
|
|
19777
|
+
if (!item)
|
|
19759
19778
|
return this;
|
|
19760
19779
|
let node2 = this.data;
|
|
19761
|
-
const bbox = this.toBBox(
|
|
19780
|
+
const bbox = this.toBBox(item);
|
|
19762
19781
|
const path2 = [];
|
|
19763
19782
|
const indexes = [];
|
|
19764
19783
|
let i, parent, goingUp;
|
|
@@ -19770,7 +19789,7 @@ class RBush {
|
|
|
19770
19789
|
goingUp = true;
|
|
19771
19790
|
}
|
|
19772
19791
|
if (node2.leaf) {
|
|
19773
|
-
const index2 = findItem(
|
|
19792
|
+
const index2 = findItem(item, node2.children, equalsFn);
|
|
19774
19793
|
if (index2 !== -1) {
|
|
19775
19794
|
node2.children.splice(index2, 1);
|
|
19776
19795
|
path2.push(node2);
|
|
@@ -19793,8 +19812,8 @@ class RBush {
|
|
|
19793
19812
|
}
|
|
19794
19813
|
return this;
|
|
19795
19814
|
}
|
|
19796
|
-
toBBox(
|
|
19797
|
-
return
|
|
19815
|
+
toBBox(item) {
|
|
19816
|
+
return item;
|
|
19798
19817
|
}
|
|
19799
19818
|
compareMinX(a, b) {
|
|
19800
19819
|
return a.minX - b.minX;
|
|
@@ -19877,11 +19896,11 @@ class RBush {
|
|
|
19877
19896
|
}
|
|
19878
19897
|
return node2;
|
|
19879
19898
|
}
|
|
19880
|
-
_insert(
|
|
19881
|
-
const bbox = isNode ?
|
|
19899
|
+
_insert(item, level, isNode) {
|
|
19900
|
+
const bbox = isNode ? item : this.toBBox(item);
|
|
19882
19901
|
const insertPath = [];
|
|
19883
19902
|
const node2 = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
19884
|
-
node2.children.push(
|
|
19903
|
+
node2.children.push(item);
|
|
19885
19904
|
extend2(node2, bbox);
|
|
19886
19905
|
while (level >= 0) {
|
|
19887
19906
|
if (insertPath[level].children.length > this._maxEntries) {
|
|
@@ -19980,11 +19999,11 @@ class RBush {
|
|
|
19980
19999
|
}
|
|
19981
20000
|
}
|
|
19982
20001
|
}
|
|
19983
|
-
function findItem(
|
|
20002
|
+
function findItem(item, items, equalsFn) {
|
|
19984
20003
|
if (!equalsFn)
|
|
19985
|
-
return items.indexOf(
|
|
20004
|
+
return items.indexOf(item);
|
|
19986
20005
|
for (let i = 0;i < items.length; i++) {
|
|
19987
|
-
if (equalsFn(
|
|
20006
|
+
if (equalsFn(item, items[i]))
|
|
19988
20007
|
return i;
|
|
19989
20008
|
}
|
|
19990
20009
|
return -1;
|
|
@@ -20075,8 +20094,8 @@ class TinyQueue {
|
|
|
20075
20094
|
this._down(i);
|
|
20076
20095
|
}
|
|
20077
20096
|
}
|
|
20078
|
-
push(
|
|
20079
|
-
this.data.push(
|
|
20097
|
+
push(item) {
|
|
20098
|
+
this.data.push(item);
|
|
20080
20099
|
this.length++;
|
|
20081
20100
|
this._up(this.length - 1);
|
|
20082
20101
|
}
|
|
@@ -20097,21 +20116,21 @@ class TinyQueue {
|
|
|
20097
20116
|
}
|
|
20098
20117
|
_up(pos) {
|
|
20099
20118
|
const { data, compare } = this;
|
|
20100
|
-
const
|
|
20119
|
+
const item = data[pos];
|
|
20101
20120
|
while (pos > 0) {
|
|
20102
20121
|
const parent = pos - 1 >> 1;
|
|
20103
20122
|
const current = data[parent];
|
|
20104
|
-
if (compare(
|
|
20123
|
+
if (compare(item, current) >= 0)
|
|
20105
20124
|
break;
|
|
20106
20125
|
data[pos] = current;
|
|
20107
20126
|
pos = parent;
|
|
20108
20127
|
}
|
|
20109
|
-
data[pos] =
|
|
20128
|
+
data[pos] = item;
|
|
20110
20129
|
}
|
|
20111
20130
|
_down(pos) {
|
|
20112
20131
|
const { data, compare } = this;
|
|
20113
20132
|
const halfLength = this.length >> 1;
|
|
20114
|
-
const
|
|
20133
|
+
const item = data[pos];
|
|
20115
20134
|
while (pos < halfLength) {
|
|
20116
20135
|
let left = (pos << 1) + 1;
|
|
20117
20136
|
let best = data[left];
|
|
@@ -20120,12 +20139,12 @@ class TinyQueue {
|
|
|
20120
20139
|
left = right;
|
|
20121
20140
|
best = data[right];
|
|
20122
20141
|
}
|
|
20123
|
-
if (compare(best,
|
|
20142
|
+
if (compare(best, item) >= 0)
|
|
20124
20143
|
break;
|
|
20125
20144
|
data[pos] = best;
|
|
20126
20145
|
pos = left;
|
|
20127
20146
|
}
|
|
20128
|
-
data[pos] =
|
|
20147
|
+
data[pos] = item;
|
|
20129
20148
|
}
|
|
20130
20149
|
}
|
|
20131
20150
|
function defaultCompare2(a, b) {
|
|
@@ -20213,10 +20232,10 @@ class RTreeIndex {
|
|
|
20213
20232
|
return container ? container.item : undefined;
|
|
20214
20233
|
}
|
|
20215
20234
|
remove(id) {
|
|
20216
|
-
const
|
|
20217
|
-
if (
|
|
20235
|
+
const item = this.map.get(id);
|
|
20236
|
+
if (item) {
|
|
20218
20237
|
this.map.delete(id);
|
|
20219
|
-
this.tree.remove(
|
|
20238
|
+
this.tree.remove(item);
|
|
20220
20239
|
}
|
|
20221
20240
|
}
|
|
20222
20241
|
list() {
|
|
@@ -20288,11 +20307,11 @@ class Container extends Mbr {
|
|
|
20288
20307
|
item;
|
|
20289
20308
|
layer;
|
|
20290
20309
|
zIndex;
|
|
20291
|
-
constructor(id,
|
|
20292
|
-
const rect =
|
|
20310
|
+
constructor(id, item, layer, zIndex) {
|
|
20311
|
+
const rect = item.getMbrWithChildren();
|
|
20293
20312
|
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
20294
20313
|
this.id = id;
|
|
20295
|
-
this.item =
|
|
20314
|
+
this.item = item;
|
|
20296
20315
|
this.layer = layer;
|
|
20297
20316
|
this.zIndex = zIndex;
|
|
20298
20317
|
}
|
|
@@ -20309,7 +20328,7 @@ class LayeredIndex {
|
|
|
20309
20328
|
this.getZIndex = this.getZIndex.bind(this);
|
|
20310
20329
|
this.layers.newOnTop();
|
|
20311
20330
|
}
|
|
20312
|
-
isT(
|
|
20331
|
+
isT(item) {
|
|
20313
20332
|
return true;
|
|
20314
20333
|
}
|
|
20315
20334
|
findById(id) {
|
|
@@ -20373,8 +20392,8 @@ class LayeredIndex {
|
|
|
20373
20392
|
}
|
|
20374
20393
|
getContainersFromItems(items) {
|
|
20375
20394
|
const containers = [];
|
|
20376
|
-
for (const
|
|
20377
|
-
const container = this.map.get(
|
|
20395
|
+
for (const item of items) {
|
|
20396
|
+
const container = this.map.get(item.getId());
|
|
20378
20397
|
if (container) {
|
|
20379
20398
|
containers.push(container);
|
|
20380
20399
|
}
|
|
@@ -20451,9 +20470,9 @@ class LayeredIndex {
|
|
|
20451
20470
|
}
|
|
20452
20471
|
}
|
|
20453
20472
|
}
|
|
20454
|
-
insert(
|
|
20455
|
-
const toInsert = new Container(
|
|
20456
|
-
const bounds =
|
|
20473
|
+
insert(item) {
|
|
20474
|
+
const toInsert = new Container(item.getId(), item, 0, this.getZIndex(item));
|
|
20475
|
+
const bounds = item.getMbrWithChildren();
|
|
20457
20476
|
const inBounds = this.getRectsEnclosedOrCrossedBy(bounds);
|
|
20458
20477
|
if (inBounds.length === 0) {
|
|
20459
20478
|
return this.insertContainer(toInsert);
|
|
@@ -20520,20 +20539,20 @@ class LayeredIndex {
|
|
|
20520
20539
|
}
|
|
20521
20540
|
}
|
|
20522
20541
|
}
|
|
20523
|
-
change(
|
|
20524
|
-
const id =
|
|
20542
|
+
change(item) {
|
|
20543
|
+
const id = item.getId();
|
|
20525
20544
|
const container = this.map.get(id);
|
|
20526
20545
|
if (container) {
|
|
20527
20546
|
const layer = this.layers.get(container.layer);
|
|
20528
20547
|
if (layer) {
|
|
20529
20548
|
layer.remove(id);
|
|
20530
20549
|
this.map.delete(id);
|
|
20531
|
-
this.insert(
|
|
20550
|
+
this.insert(item);
|
|
20532
20551
|
}
|
|
20533
20552
|
}
|
|
20534
20553
|
}
|
|
20535
|
-
remove(
|
|
20536
|
-
const id =
|
|
20554
|
+
remove(item) {
|
|
20555
|
+
const id = item.getId();
|
|
20537
20556
|
const container = this.map.get(id);
|
|
20538
20557
|
if (container) {
|
|
20539
20558
|
const layer = this.layers.get(container.layer);
|
|
@@ -20559,13 +20578,13 @@ class LayeredIndex {
|
|
|
20559
20578
|
return items;
|
|
20560
20579
|
}
|
|
20561
20580
|
batchInsert(items) {
|
|
20562
|
-
for (const
|
|
20563
|
-
this.insert(
|
|
20581
|
+
for (const item of items) {
|
|
20582
|
+
this.insert(item);
|
|
20564
20583
|
}
|
|
20565
20584
|
}
|
|
20566
20585
|
batchChange(items) {
|
|
20567
|
-
for (const
|
|
20568
|
-
this.change(
|
|
20586
|
+
for (const item of items) {
|
|
20587
|
+
this.change(item);
|
|
20569
20588
|
}
|
|
20570
20589
|
}
|
|
20571
20590
|
}
|
|
@@ -20574,8 +20593,8 @@ class LayeredIndex {
|
|
|
20574
20593
|
class SpatialIndex {
|
|
20575
20594
|
subject = new Subject;
|
|
20576
20595
|
itemsArray = [];
|
|
20577
|
-
itemsIndex = new LayeredIndex((
|
|
20578
|
-
return this.itemsArray.indexOf(
|
|
20596
|
+
itemsIndex = new LayeredIndex((item) => {
|
|
20597
|
+
return this.itemsArray.indexOf(item);
|
|
20579
20598
|
});
|
|
20580
20599
|
Mbr = new Mbr;
|
|
20581
20600
|
items;
|
|
@@ -20584,79 +20603,79 @@ class SpatialIndex {
|
|
|
20584
20603
|
}
|
|
20585
20604
|
clear() {
|
|
20586
20605
|
this.itemsArray = [];
|
|
20587
|
-
this.itemsIndex = new LayeredIndex((
|
|
20588
|
-
return this.itemsArray.indexOf(
|
|
20606
|
+
this.itemsIndex = new LayeredIndex((item) => {
|
|
20607
|
+
return this.itemsArray.indexOf(item);
|
|
20589
20608
|
});
|
|
20590
20609
|
this.Mbr = new Mbr;
|
|
20591
20610
|
}
|
|
20592
|
-
insert(
|
|
20593
|
-
this.itemsArray.push(
|
|
20594
|
-
this.itemsIndex.insert(
|
|
20611
|
+
insert(item) {
|
|
20612
|
+
this.itemsArray.push(item);
|
|
20613
|
+
this.itemsIndex.insert(item);
|
|
20595
20614
|
if (conf.isNode()) {
|
|
20596
20615
|
return;
|
|
20597
20616
|
}
|
|
20598
20617
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20599
|
-
this.Mbr =
|
|
20618
|
+
this.Mbr = item.getMbr().copy();
|
|
20600
20619
|
} else {
|
|
20601
|
-
this.Mbr.combine([
|
|
20620
|
+
this.Mbr.combine([item.getMbr()]);
|
|
20602
20621
|
}
|
|
20603
|
-
|
|
20622
|
+
item.subject.subscribe(this.change);
|
|
20604
20623
|
this.subject.publish(this.items);
|
|
20605
20624
|
}
|
|
20606
|
-
change = (
|
|
20607
|
-
this.itemsIndex.change(
|
|
20625
|
+
change = (item) => {
|
|
20626
|
+
this.itemsIndex.change(item);
|
|
20608
20627
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
20609
|
-
this.Mbr =
|
|
20628
|
+
this.Mbr = item.getMbrWithChildren().copy();
|
|
20610
20629
|
} else {
|
|
20611
|
-
this.Mbr.combine([
|
|
20630
|
+
this.Mbr.combine([item.getMbrWithChildren()]);
|
|
20612
20631
|
}
|
|
20613
20632
|
this.subject.publish(this.items);
|
|
20614
20633
|
};
|
|
20615
|
-
remove(
|
|
20616
|
-
if ("index" in
|
|
20617
|
-
|
|
20634
|
+
remove(item) {
|
|
20635
|
+
if ("index" in item && item.index) {
|
|
20636
|
+
item.removeChildItems(item.index.list());
|
|
20618
20637
|
}
|
|
20619
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
20620
|
-
this.itemsIndex.remove(
|
|
20638
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
20639
|
+
this.itemsIndex.remove(item);
|
|
20621
20640
|
this.Mbr = new Mbr;
|
|
20622
|
-
this.itemsArray.forEach((
|
|
20641
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
|
|
20623
20642
|
this.subject.publish(this.items);
|
|
20624
20643
|
}
|
|
20625
20644
|
copy() {
|
|
20626
|
-
return this.getItemsWithIncludedChildren(this.itemsArray).map((
|
|
20627
|
-
...
|
|
20628
|
-
id:
|
|
20645
|
+
return this.getItemsWithIncludedChildren(this.itemsArray).map((item) => ({
|
|
20646
|
+
...item.serialize(true),
|
|
20647
|
+
id: item.getId()
|
|
20629
20648
|
}));
|
|
20630
20649
|
}
|
|
20631
20650
|
getItemsWithIncludedChildren(items) {
|
|
20632
|
-
return items.flatMap((
|
|
20633
|
-
if ("index" in
|
|
20634
|
-
return [
|
|
20651
|
+
return items.flatMap((item) => {
|
|
20652
|
+
if ("index" in item && item.index) {
|
|
20653
|
+
return [item, ...item.index.list()];
|
|
20635
20654
|
}
|
|
20636
|
-
return
|
|
20655
|
+
return item;
|
|
20637
20656
|
});
|
|
20638
20657
|
}
|
|
20639
|
-
getItemChildren(
|
|
20640
|
-
if ("index" in
|
|
20641
|
-
return
|
|
20658
|
+
getItemChildren(item) {
|
|
20659
|
+
if ("index" in item && item.index) {
|
|
20660
|
+
return item.index.list();
|
|
20642
20661
|
}
|
|
20643
20662
|
return [];
|
|
20644
20663
|
}
|
|
20645
|
-
getItemParent(
|
|
20646
|
-
if (
|
|
20664
|
+
getItemParent(item) {
|
|
20665
|
+
if (item.parent === "Board") {
|
|
20647
20666
|
return;
|
|
20648
20667
|
}
|
|
20649
|
-
return this.getById(
|
|
20668
|
+
return this.getById(item.parent);
|
|
20650
20669
|
}
|
|
20651
|
-
moveToZIndex(
|
|
20652
|
-
const index2 = this.itemsArray.indexOf(
|
|
20670
|
+
moveToZIndex(item, zIndex) {
|
|
20671
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20653
20672
|
this.itemsArray.splice(index2, 1);
|
|
20654
|
-
this.itemsArray.splice(zIndex, 0,
|
|
20655
|
-
this.change(
|
|
20673
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
20674
|
+
this.change(item);
|
|
20656
20675
|
this.subject.publish(this.items);
|
|
20657
20676
|
}
|
|
20658
20677
|
moveManyToZIndex(itemsRecord) {
|
|
20659
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
20678
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
20660
20679
|
const zIndex = Object.values(itemsRecord);
|
|
20661
20680
|
for (let i = 0;i < zIndex.length; i++) {
|
|
20662
20681
|
const index2 = zIndex[i];
|
|
@@ -20664,39 +20683,39 @@ class SpatialIndex {
|
|
|
20664
20683
|
}
|
|
20665
20684
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20666
20685
|
}
|
|
20667
|
-
sendToBack(
|
|
20668
|
-
const index2 = this.itemsArray.indexOf(
|
|
20686
|
+
sendToBack(item, shouldPublish = true) {
|
|
20687
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20669
20688
|
this.itemsArray.splice(index2, 1);
|
|
20670
|
-
this.itemsArray.unshift(
|
|
20671
|
-
this.itemsIndex.change(
|
|
20689
|
+
this.itemsArray.unshift(item);
|
|
20690
|
+
this.itemsIndex.change(item);
|
|
20672
20691
|
if (shouldPublish) {
|
|
20673
20692
|
this.subject.publish(this.items);
|
|
20674
20693
|
}
|
|
20675
20694
|
}
|
|
20676
20695
|
sendManyToBack(items) {
|
|
20677
20696
|
const newItems = [...items];
|
|
20678
|
-
this.itemsArray.forEach((
|
|
20679
|
-
if (!items.includes(
|
|
20680
|
-
newItems.push(
|
|
20697
|
+
this.itemsArray.forEach((item) => {
|
|
20698
|
+
if (!items.includes(item)) {
|
|
20699
|
+
newItems.push(item);
|
|
20681
20700
|
}
|
|
20682
20701
|
});
|
|
20683
20702
|
this.itemsArray = newItems;
|
|
20684
20703
|
this.itemsArray.forEach(this.change.bind(this));
|
|
20685
20704
|
}
|
|
20686
|
-
bringToFront(
|
|
20687
|
-
const index2 = this.itemsArray.indexOf(
|
|
20705
|
+
bringToFront(item, shouldPublish = true) {
|
|
20706
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20688
20707
|
this.itemsArray.splice(index2, 1);
|
|
20689
|
-
this.itemsArray.push(
|
|
20690
|
-
this.itemsIndex.change(
|
|
20708
|
+
this.itemsArray.push(item);
|
|
20709
|
+
this.itemsIndex.change(item);
|
|
20691
20710
|
if (shouldPublish) {
|
|
20692
20711
|
this.subject.publish(this.items);
|
|
20693
20712
|
}
|
|
20694
20713
|
}
|
|
20695
20714
|
bringManyToFront(items) {
|
|
20696
20715
|
const newItems = [];
|
|
20697
|
-
this.itemsArray.forEach((
|
|
20698
|
-
if (!items.includes(
|
|
20699
|
-
newItems.push(
|
|
20716
|
+
this.itemsArray.forEach((item) => {
|
|
20717
|
+
if (!items.includes(item)) {
|
|
20718
|
+
newItems.push(item);
|
|
20700
20719
|
}
|
|
20701
20720
|
});
|
|
20702
20721
|
newItems.push(...items);
|
|
@@ -20722,9 +20741,9 @@ class SpatialIndex {
|
|
|
20722
20741
|
this.subject.publish(this.items);
|
|
20723
20742
|
}
|
|
20724
20743
|
getById(id) {
|
|
20725
|
-
const
|
|
20726
|
-
if (
|
|
20727
|
-
return
|
|
20744
|
+
const item = this.getItemsWithIncludedChildren(this.itemsArray).find((item2) => item2.getId() === id);
|
|
20745
|
+
if (item) {
|
|
20746
|
+
return item;
|
|
20728
20747
|
}
|
|
20729
20748
|
}
|
|
20730
20749
|
findById(id) {
|
|
@@ -20734,10 +20753,10 @@ class SpatialIndex {
|
|
|
20734
20753
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20735
20754
|
const items = this.itemsIndex.getEnclosed(mbr);
|
|
20736
20755
|
const children = [];
|
|
20737
|
-
const clearItems = items.filter((
|
|
20738
|
-
if ("index" in
|
|
20739
|
-
children.push(...
|
|
20740
|
-
if (!
|
|
20756
|
+
const clearItems = items.filter((item) => {
|
|
20757
|
+
if ("index" in item && item.index) {
|
|
20758
|
+
children.push(...item.index.getEnclosed(left, top, right, bottom));
|
|
20759
|
+
if (!item.getMbr().isEnclosedBy(mbr)) {
|
|
20741
20760
|
return false;
|
|
20742
20761
|
}
|
|
20743
20762
|
}
|
|
@@ -20749,10 +20768,10 @@ class SpatialIndex {
|
|
|
20749
20768
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20750
20769
|
const items = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
20751
20770
|
const children = [];
|
|
20752
|
-
const clearItems = items.filter((
|
|
20753
|
-
if ("index" in
|
|
20754
|
-
children.push(...
|
|
20755
|
-
if (!
|
|
20771
|
+
const clearItems = items.filter((item) => {
|
|
20772
|
+
if ("index" in item && item.index) {
|
|
20773
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20774
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20756
20775
|
return false;
|
|
20757
20776
|
}
|
|
20758
20777
|
}
|
|
@@ -20763,10 +20782,10 @@ class SpatialIndex {
|
|
|
20763
20782
|
getUnderPoint(point3, tolerance = 5) {
|
|
20764
20783
|
const items = this.itemsIndex.getUnderPoint(point3, tolerance);
|
|
20765
20784
|
const children = [];
|
|
20766
|
-
const clearItems = items.filter((
|
|
20767
|
-
if ("index" in
|
|
20768
|
-
children.push(...
|
|
20769
|
-
if (!
|
|
20785
|
+
const clearItems = items.filter((item) => {
|
|
20786
|
+
if ("index" in item && item.index) {
|
|
20787
|
+
children.push(...item.index.getUnderPoint(point3, tolerance));
|
|
20788
|
+
if (!item.getMbr().isUnderPoint(point3)) {
|
|
20770
20789
|
return false;
|
|
20771
20790
|
}
|
|
20772
20791
|
}
|
|
@@ -20778,10 +20797,10 @@ class SpatialIndex {
|
|
|
20778
20797
|
const mbr = new Mbr(left, top, right, bottom);
|
|
20779
20798
|
const items = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
20780
20799
|
const children = [];
|
|
20781
|
-
const clearItems = items.filter((
|
|
20782
|
-
if ("index" in
|
|
20783
|
-
children.push(...
|
|
20784
|
-
if (!
|
|
20800
|
+
const clearItems = items.filter((item) => {
|
|
20801
|
+
if ("index" in item && item.index) {
|
|
20802
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
20803
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
20785
20804
|
return false;
|
|
20786
20805
|
}
|
|
20787
20806
|
}
|
|
@@ -20793,26 +20812,26 @@ class SpatialIndex {
|
|
|
20793
20812
|
return this.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
20794
20813
|
}
|
|
20795
20814
|
getComments() {
|
|
20796
|
-
return this.itemsArray.filter((
|
|
20815
|
+
return this.itemsArray.filter((item) => item instanceof Comment);
|
|
20797
20816
|
}
|
|
20798
20817
|
getMbr() {
|
|
20799
20818
|
return this.Mbr;
|
|
20800
20819
|
}
|
|
20801
20820
|
getNearestTo(point3, maxItems, filter, maxDistance) {
|
|
20802
20821
|
const allItems = this.getItemsWithIncludedChildren(this.itemsArray);
|
|
20803
|
-
const filtered = allItems.filter((
|
|
20804
|
-
const withDistance = filtered.map((
|
|
20805
|
-
item
|
|
20806
|
-
distance: point3.getDistance(
|
|
20822
|
+
const filtered = allItems.filter((item) => filter(item));
|
|
20823
|
+
const withDistance = filtered.map((item) => ({
|
|
20824
|
+
item,
|
|
20825
|
+
distance: point3.getDistance(item.getMbr().getCenter())
|
|
20807
20826
|
})).filter(({ distance }) => distance <= maxDistance);
|
|
20808
20827
|
withDistance.sort((a, b) => a.distance - b.distance);
|
|
20809
|
-
return withDistance.slice(0, maxItems).map(({ item
|
|
20828
|
+
return withDistance.slice(0, maxItems).map(({ item }) => item);
|
|
20810
20829
|
}
|
|
20811
20830
|
list() {
|
|
20812
20831
|
return this.getItemsWithIncludedChildren(this.itemsArray).concat();
|
|
20813
20832
|
}
|
|
20814
|
-
getZIndex(
|
|
20815
|
-
const index2 = this.itemsArray.indexOf(
|
|
20833
|
+
getZIndex(item) {
|
|
20834
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
20816
20835
|
if (index2 === -1) {
|
|
20817
20836
|
return this.getLastZIndex();
|
|
20818
20837
|
}
|
|
@@ -20842,14 +20861,14 @@ class Items {
|
|
|
20842
20861
|
this.pointer = pointer;
|
|
20843
20862
|
this.subject = subject;
|
|
20844
20863
|
}
|
|
20845
|
-
update(
|
|
20846
|
-
this.index.change(
|
|
20864
|
+
update(item) {
|
|
20865
|
+
this.index.change(item);
|
|
20847
20866
|
}
|
|
20848
20867
|
listAll() {
|
|
20849
20868
|
return this.index.list();
|
|
20850
20869
|
}
|
|
20851
20870
|
listGroupItems() {
|
|
20852
|
-
return this.index.list().filter((
|
|
20871
|
+
return this.index.list().filter((item) => ("index" in item) && item.index);
|
|
20853
20872
|
}
|
|
20854
20873
|
getById(id) {
|
|
20855
20874
|
return this.index.getById(id);
|
|
@@ -20864,7 +20883,7 @@ class Items {
|
|
|
20864
20883
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
20865
20884
|
}
|
|
20866
20885
|
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
20867
|
-
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
20886
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.index);
|
|
20868
20887
|
}
|
|
20869
20888
|
getUnderPoint(point3, tolerance = 5) {
|
|
20870
20889
|
return this.index.getUnderPoint(point3, tolerance);
|
|
@@ -20892,28 +20911,28 @@ class Items {
|
|
|
20892
20911
|
const unmodifiedSize = size;
|
|
20893
20912
|
size = 16;
|
|
20894
20913
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
20895
|
-
const groups = tolerated.filter((
|
|
20914
|
+
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
20896
20915
|
if (groups.length > 0) {
|
|
20897
20916
|
return groups;
|
|
20898
20917
|
}
|
|
20899
|
-
let enclosed = tolerated.some((
|
|
20918
|
+
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
20900
20919
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
20901
20920
|
if (enclosed.length === 0) {
|
|
20902
20921
|
enclosed = underPointer;
|
|
20903
20922
|
}
|
|
20904
|
-
if (underPointer.some((
|
|
20923
|
+
if (underPointer.some((item) => item.itemType === "Drawing")) {
|
|
20905
20924
|
enclosed = [...underPointer, ...enclosed];
|
|
20906
20925
|
}
|
|
20907
|
-
const { nearest } = enclosed.reduce((acc,
|
|
20908
|
-
const area =
|
|
20909
|
-
if (
|
|
20926
|
+
const { nearest } = enclosed.reduce((acc, item) => {
|
|
20927
|
+
const area = item.getMbr().getHeight() * item.getMbr().getWidth();
|
|
20928
|
+
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
20910
20929
|
return acc;
|
|
20911
20930
|
}
|
|
20912
|
-
const isItemTransparent =
|
|
20913
|
-
const itemZIndex = this.getZIndex(
|
|
20931
|
+
const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
|
|
20932
|
+
const itemZIndex = this.getZIndex(item);
|
|
20914
20933
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
20915
20934
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
20916
|
-
return { nearest:
|
|
20935
|
+
return { nearest: item, area };
|
|
20917
20936
|
}
|
|
20918
20937
|
return acc;
|
|
20919
20938
|
}, { nearest: undefined, area: Infinity });
|
|
@@ -20925,8 +20944,8 @@ class Items {
|
|
|
20925
20944
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
20926
20945
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
20927
20946
|
}
|
|
20928
|
-
getZIndex(
|
|
20929
|
-
return this.index.getZIndex(
|
|
20947
|
+
getZIndex(item) {
|
|
20948
|
+
return this.index.getZIndex(item);
|
|
20930
20949
|
}
|
|
20931
20950
|
getByZIndex(index2) {
|
|
20932
20951
|
return this.index.getByZIndex(index2);
|
|
@@ -20935,11 +20954,11 @@ class Items {
|
|
|
20935
20954
|
return this.index.getLastZIndex();
|
|
20936
20955
|
}
|
|
20937
20956
|
getLinkedConnectorsById(id) {
|
|
20938
|
-
return this.listAll().filter((
|
|
20939
|
-
if (!(
|
|
20957
|
+
return this.listAll().filter((item) => {
|
|
20958
|
+
if (!(item instanceof Connector2)) {
|
|
20940
20959
|
return false;
|
|
20941
20960
|
}
|
|
20942
|
-
const { startItem, endItem } =
|
|
20961
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
20943
20962
|
if (startItem?.getId() === id || endItem?.getId() === id) {
|
|
20944
20963
|
return true;
|
|
20945
20964
|
}
|
|
@@ -20950,11 +20969,11 @@ class Items {
|
|
|
20950
20969
|
if (!startPointerItemId && !endPointerItemId) {
|
|
20951
20970
|
return [];
|
|
20952
20971
|
}
|
|
20953
|
-
return this.listAll().filter((
|
|
20954
|
-
if (!(
|
|
20972
|
+
return this.listAll().filter((item) => {
|
|
20973
|
+
if (!(item instanceof Connector2) || !item.isConnected()) {
|
|
20955
20974
|
return false;
|
|
20956
20975
|
}
|
|
20957
|
-
const { startItem, endItem } =
|
|
20976
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
20958
20977
|
if (startPointerItemId && endPointerItemId) {
|
|
20959
20978
|
if (startPointerItemId && startItem && startItem.getId() === startPointerItemId && endPointerItemId && endItem && endItem.getId() === endPointerItemId) {
|
|
20960
20979
|
return true;
|
|
@@ -20972,9 +20991,9 @@ class Items {
|
|
|
20972
20991
|
}
|
|
20973
20992
|
render(context) {
|
|
20974
20993
|
const items = this.getItemsInView();
|
|
20975
|
-
items.forEach((
|
|
20976
|
-
if (
|
|
20977
|
-
|
|
20994
|
+
items.forEach((item) => {
|
|
20995
|
+
if (item.parent === "Board") {
|
|
20996
|
+
item.render(context);
|
|
20978
20997
|
}
|
|
20979
20998
|
});
|
|
20980
20999
|
}
|
|
@@ -20987,17 +21006,17 @@ class Items {
|
|
|
20987
21006
|
return this.getHTML(documentFactory, items);
|
|
20988
21007
|
}
|
|
20989
21008
|
getHTML(documentFactory, items) {
|
|
20990
|
-
const lowestCoordinates = items.map((
|
|
21009
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
20991
21010
|
left: Math.min(acc.left, mbr.left),
|
|
20992
21011
|
top: Math.min(acc.top, mbr.top)
|
|
20993
21012
|
}), { left: 0, top: 0 });
|
|
20994
21013
|
const groups = [];
|
|
20995
21014
|
const rest = [];
|
|
20996
|
-
items.forEach((
|
|
20997
|
-
if ("index" in
|
|
20998
|
-
groups.push(
|
|
21015
|
+
items.forEach((item) => {
|
|
21016
|
+
if ("index" in item && item.index) {
|
|
21017
|
+
groups.push(item);
|
|
20999
21018
|
} else {
|
|
21000
|
-
rest.push(
|
|
21019
|
+
rest.push(item);
|
|
21001
21020
|
}
|
|
21002
21021
|
});
|
|
21003
21022
|
const childrenMap = new Map;
|
|
@@ -21007,34 +21026,34 @@ class Items {
|
|
|
21007
21026
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21008
21027
|
return html;
|
|
21009
21028
|
});
|
|
21010
|
-
const restHTML = rest.map((
|
|
21011
|
-
if (
|
|
21012
|
-
const startX = parseFloat(
|
|
21013
|
-
const startY = parseFloat(
|
|
21014
|
-
const endX = parseFloat(
|
|
21015
|
-
const endY = parseFloat(
|
|
21016
|
-
|
|
21017
|
-
|
|
21018
|
-
|
|
21019
|
-
|
|
21020
|
-
}
|
|
21021
|
-
return translateElementBy(
|
|
21022
|
-
});
|
|
21023
|
-
for (const
|
|
21024
|
-
const parentFrameId = childrenMap.get(
|
|
21029
|
+
const restHTML = rest.map((item) => ("renderHTML" in item) && item.renderHTML(documentFactory)).filter((item) => !!item).map((item) => {
|
|
21030
|
+
if (item.tagName.toLowerCase() === "connector-item") {
|
|
21031
|
+
const startX = parseFloat(item.getAttribute("data-start-point-x") || "0");
|
|
21032
|
+
const startY = parseFloat(item.getAttribute("data-start-point-y") || "0");
|
|
21033
|
+
const endX = parseFloat(item.getAttribute("data-end-point-x") || "0");
|
|
21034
|
+
const endY = parseFloat(item.getAttribute("data-end-point-y") || "0");
|
|
21035
|
+
item.setAttribute("data-start-point-x", (startX - lowestCoordinates.left).toString());
|
|
21036
|
+
item.setAttribute("data-start-point-y", (startY - lowestCoordinates.top).toString());
|
|
21037
|
+
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
21038
|
+
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
21039
|
+
}
|
|
21040
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
21041
|
+
});
|
|
21042
|
+
for (const item of restHTML) {
|
|
21043
|
+
const parentFrameId = childrenMap.get(item.id);
|
|
21025
21044
|
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
21026
21045
|
if (group) {
|
|
21027
|
-
positionRelatively(
|
|
21028
|
-
group.appendChild(
|
|
21046
|
+
positionRelatively(item, group);
|
|
21047
|
+
group.appendChild(item);
|
|
21029
21048
|
}
|
|
21030
21049
|
}
|
|
21031
21050
|
let result = "";
|
|
21032
21051
|
for (const group of GroupsHTML) {
|
|
21033
21052
|
result += group.outerHTML;
|
|
21034
21053
|
}
|
|
21035
|
-
for (const
|
|
21036
|
-
if (!childrenMap.get(
|
|
21037
|
-
result +=
|
|
21054
|
+
for (const item of restHTML) {
|
|
21055
|
+
if (!childrenMap.get(item.id)) {
|
|
21056
|
+
result += item.outerHTML;
|
|
21038
21057
|
}
|
|
21039
21058
|
}
|
|
21040
21059
|
return result;
|
|
@@ -21054,52 +21073,52 @@ class SimpleSpatialIndex {
|
|
|
21054
21073
|
this.itemsArray = [];
|
|
21055
21074
|
this.Mbr = new Mbr;
|
|
21056
21075
|
}
|
|
21057
|
-
insert(
|
|
21058
|
-
this.itemsArray.push(
|
|
21076
|
+
insert(item) {
|
|
21077
|
+
this.itemsArray.push(item);
|
|
21059
21078
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21060
|
-
this.Mbr =
|
|
21079
|
+
this.Mbr = item.getMbr().copy();
|
|
21061
21080
|
} else {
|
|
21062
|
-
this.Mbr.combine([
|
|
21081
|
+
this.Mbr.combine([item.getMbr()]);
|
|
21063
21082
|
}
|
|
21064
|
-
|
|
21083
|
+
item.subject.subscribe(this.change);
|
|
21065
21084
|
this.subject.publish(this.items);
|
|
21066
21085
|
}
|
|
21067
|
-
change = (
|
|
21086
|
+
change = (item) => {
|
|
21068
21087
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
21069
|
-
this.Mbr =
|
|
21088
|
+
this.Mbr = item.getMbr().copy();
|
|
21070
21089
|
} else {
|
|
21071
|
-
this.Mbr.combine([
|
|
21090
|
+
this.Mbr.combine([item.getMbr()]);
|
|
21072
21091
|
}
|
|
21073
21092
|
this.subject.publish(this.items);
|
|
21074
21093
|
};
|
|
21075
|
-
remove(
|
|
21076
|
-
if ("index" in
|
|
21077
|
-
|
|
21094
|
+
remove(item) {
|
|
21095
|
+
if ("index" in item && item.index) {
|
|
21096
|
+
item.removeChildItems(item.index.list());
|
|
21078
21097
|
}
|
|
21079
|
-
if (
|
|
21080
|
-
const parentFrame = this.items.getById(
|
|
21081
|
-
parentFrame?.removeChildItems(
|
|
21098
|
+
if (item.parent !== "Board") {
|
|
21099
|
+
const parentFrame = this.items.getById(item.parent);
|
|
21100
|
+
parentFrame?.removeChildItems(item);
|
|
21082
21101
|
}
|
|
21083
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
21102
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
21084
21103
|
this.Mbr = new Mbr;
|
|
21085
|
-
this.itemsArray.forEach((
|
|
21104
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
21086
21105
|
this.subject.publish(this.items);
|
|
21087
21106
|
}
|
|
21088
21107
|
copy() {
|
|
21089
|
-
return this.itemsArray.map((
|
|
21090
|
-
...
|
|
21091
|
-
id:
|
|
21108
|
+
return this.itemsArray.map((item) => ({
|
|
21109
|
+
...item.serialize(true),
|
|
21110
|
+
id: item.getId()
|
|
21092
21111
|
}));
|
|
21093
21112
|
}
|
|
21094
|
-
moveToZIndex(
|
|
21095
|
-
const index2 = this.itemsArray.indexOf(
|
|
21113
|
+
moveToZIndex(item, zIndex) {
|
|
21114
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21096
21115
|
this.itemsArray.splice(index2, 1);
|
|
21097
|
-
this.itemsArray.splice(zIndex, 0,
|
|
21098
|
-
this.change(
|
|
21116
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
21117
|
+
this.change(item);
|
|
21099
21118
|
this.subject.publish(this.items);
|
|
21100
21119
|
}
|
|
21101
21120
|
moveManyToZIndex(itemsRecord) {
|
|
21102
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
21121
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
21103
21122
|
const zIndex = Object.values(itemsRecord);
|
|
21104
21123
|
for (let i = 0;i < zIndex.length; i++) {
|
|
21105
21124
|
const index2 = zIndex[i];
|
|
@@ -21107,37 +21126,37 @@ class SimpleSpatialIndex {
|
|
|
21107
21126
|
}
|
|
21108
21127
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21109
21128
|
}
|
|
21110
|
-
sendToBack(
|
|
21111
|
-
const index2 = this.itemsArray.indexOf(
|
|
21129
|
+
sendToBack(item, shouldPublish = true) {
|
|
21130
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21112
21131
|
this.itemsArray.splice(index2, 1);
|
|
21113
|
-
this.itemsArray.unshift(
|
|
21132
|
+
this.itemsArray.unshift(item);
|
|
21114
21133
|
if (shouldPublish) {
|
|
21115
21134
|
this.subject.publish(this.items);
|
|
21116
21135
|
}
|
|
21117
21136
|
}
|
|
21118
21137
|
sendManyToBack(items) {
|
|
21119
21138
|
const newItems = [...items];
|
|
21120
|
-
this.itemsArray.forEach((
|
|
21121
|
-
if (!items.includes(
|
|
21122
|
-
newItems.push(
|
|
21139
|
+
this.itemsArray.forEach((item) => {
|
|
21140
|
+
if (!items.includes(item)) {
|
|
21141
|
+
newItems.push(item);
|
|
21123
21142
|
}
|
|
21124
21143
|
});
|
|
21125
21144
|
this.itemsArray = newItems;
|
|
21126
21145
|
this.itemsArray.forEach(this.change.bind(this));
|
|
21127
21146
|
}
|
|
21128
|
-
bringToFront(
|
|
21129
|
-
const index2 = this.itemsArray.indexOf(
|
|
21147
|
+
bringToFront(item, shouldPublish = true) {
|
|
21148
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
21130
21149
|
this.itemsArray.splice(index2, 1);
|
|
21131
|
-
this.itemsArray.push(
|
|
21150
|
+
this.itemsArray.push(item);
|
|
21132
21151
|
if (shouldPublish) {
|
|
21133
21152
|
this.subject.publish(this.items);
|
|
21134
21153
|
}
|
|
21135
21154
|
}
|
|
21136
21155
|
bringManyToFront(items) {
|
|
21137
21156
|
const newItems = [];
|
|
21138
|
-
this.itemsArray.forEach((
|
|
21139
|
-
if (!items.includes(
|
|
21140
|
-
newItems.push(
|
|
21157
|
+
this.itemsArray.forEach((item) => {
|
|
21158
|
+
if (!items.includes(item)) {
|
|
21159
|
+
newItems.push(item);
|
|
21141
21160
|
}
|
|
21142
21161
|
});
|
|
21143
21162
|
newItems.push(...items);
|
|
@@ -21163,9 +21182,9 @@ class SimpleSpatialIndex {
|
|
|
21163
21182
|
this.subject.publish(this.items);
|
|
21164
21183
|
}
|
|
21165
21184
|
getById(id) {
|
|
21166
|
-
const
|
|
21167
|
-
if (
|
|
21168
|
-
return
|
|
21185
|
+
const item = this.itemsArray.find((item2) => item2.getId() === id);
|
|
21186
|
+
if (item) {
|
|
21187
|
+
return item;
|
|
21169
21188
|
}
|
|
21170
21189
|
}
|
|
21171
21190
|
findById(id) {
|
|
@@ -21174,9 +21193,9 @@ class SimpleSpatialIndex {
|
|
|
21174
21193
|
getEnclosed(left, top, right, bottom) {
|
|
21175
21194
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21176
21195
|
const items = [];
|
|
21177
|
-
this.itemsArray.forEach((
|
|
21178
|
-
if (
|
|
21179
|
-
items.push(
|
|
21196
|
+
this.itemsArray.forEach((item) => {
|
|
21197
|
+
if (item.isEnclosedBy(mbr)) {
|
|
21198
|
+
items.push(item);
|
|
21180
21199
|
}
|
|
21181
21200
|
});
|
|
21182
21201
|
return items;
|
|
@@ -21184,18 +21203,18 @@ class SimpleSpatialIndex {
|
|
|
21184
21203
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
21185
21204
|
const mbr = new Mbr(left, top, right, bottom);
|
|
21186
21205
|
const items = [];
|
|
21187
|
-
this.itemsArray.forEach((
|
|
21188
|
-
if (
|
|
21189
|
-
items.push(
|
|
21206
|
+
this.itemsArray.forEach((item) => {
|
|
21207
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
21208
|
+
items.push(item);
|
|
21190
21209
|
}
|
|
21191
21210
|
});
|
|
21192
21211
|
return items;
|
|
21193
21212
|
}
|
|
21194
21213
|
getUnderPoint(point3, tolerace = 5) {
|
|
21195
21214
|
const items = [];
|
|
21196
|
-
this.itemsArray.forEach((
|
|
21197
|
-
if (
|
|
21198
|
-
items.push(
|
|
21215
|
+
this.itemsArray.forEach((item) => {
|
|
21216
|
+
if (item.isUnderPoint(point3, tolerace)) {
|
|
21217
|
+
items.push(item);
|
|
21199
21218
|
}
|
|
21200
21219
|
});
|
|
21201
21220
|
return items;
|
|
@@ -21206,8 +21225,8 @@ class SimpleSpatialIndex {
|
|
|
21206
21225
|
list() {
|
|
21207
21226
|
return this.itemsArray.concat();
|
|
21208
21227
|
}
|
|
21209
|
-
getZIndex(
|
|
21210
|
-
return this.itemsArray.indexOf(
|
|
21228
|
+
getZIndex(item) {
|
|
21229
|
+
return this.itemsArray.indexOf(item);
|
|
21211
21230
|
}
|
|
21212
21231
|
getLastZIndex() {
|
|
21213
21232
|
return this.itemsArray.length - 1;
|
|
@@ -21221,8 +21240,8 @@ class SimpleSpatialIndex {
|
|
|
21221
21240
|
}
|
|
21222
21241
|
}
|
|
21223
21242
|
render(context) {
|
|
21224
|
-
this.itemsArray.forEach((
|
|
21225
|
-
|
|
21243
|
+
this.itemsArray.forEach((item) => {
|
|
21244
|
+
item.render(context);
|
|
21226
21245
|
});
|
|
21227
21246
|
}
|
|
21228
21247
|
}
|
|
@@ -21273,7 +21292,7 @@ class BaseItem extends Mbr {
|
|
|
21273
21292
|
if (!this.index) {
|
|
21274
21293
|
return null;
|
|
21275
21294
|
}
|
|
21276
|
-
return this.index.items.listAll().map((
|
|
21295
|
+
return this.index.items.listAll().map((item) => item.getId());
|
|
21277
21296
|
}
|
|
21278
21297
|
addChildItems(children) {
|
|
21279
21298
|
if (!this.index) {
|
|
@@ -21311,17 +21330,17 @@ class BaseItem extends Mbr {
|
|
|
21311
21330
|
this.addChildItems(itemsToAdd);
|
|
21312
21331
|
this.removeChildItems(itemsToRemove);
|
|
21313
21332
|
}
|
|
21314
|
-
handleNesting(
|
|
21315
|
-
const isItem = "itemType" in
|
|
21316
|
-
const itemMbr = isItem ?
|
|
21317
|
-
if (
|
|
21333
|
+
handleNesting(item, options) {
|
|
21334
|
+
const isItem = "itemType" in item;
|
|
21335
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
21336
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
21318
21337
|
return false;
|
|
21319
21338
|
}
|
|
21320
|
-
if (options?.cancelIfChild && isItem &&
|
|
21339
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
21321
21340
|
return false;
|
|
21322
21341
|
}
|
|
21323
21342
|
const mbr = this.getMbr().copy();
|
|
21324
|
-
if (
|
|
21343
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
21325
21344
|
if (mbr.isInside(itemMbr.getCenter())) {
|
|
21326
21345
|
if (!options || !options.onlyForOut) {
|
|
21327
21346
|
return true;
|
|
@@ -23618,8 +23637,8 @@ function isChild(value) {
|
|
|
23618
23637
|
if (!Array.isArray(value2))
|
|
23619
23638
|
return true;
|
|
23620
23639
|
const list2 = value2;
|
|
23621
|
-
for (const
|
|
23622
|
-
if (typeof
|
|
23640
|
+
for (const item of list2) {
|
|
23641
|
+
if (typeof item !== "number" && typeof item !== "string") {
|
|
23623
23642
|
return true;
|
|
23624
23643
|
}
|
|
23625
23644
|
}
|
|
@@ -23658,8 +23677,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
23658
23677
|
}
|
|
23659
23678
|
if (Array.isArray(result)) {
|
|
23660
23679
|
const finalResult = [];
|
|
23661
|
-
for (const
|
|
23662
|
-
finalResult.push(parsePrimitive(info, info.property,
|
|
23680
|
+
for (const item of result) {
|
|
23681
|
+
finalResult.push(parsePrimitive(info, info.property, item));
|
|
23663
23682
|
}
|
|
23664
23683
|
result = finalResult;
|
|
23665
23684
|
}
|
|
@@ -34726,8 +34745,8 @@ function list5(node2, parent, state, info) {
|
|
|
34726
34745
|
if (checkRule(state) === bullet && firstListItem) {
|
|
34727
34746
|
let index2 = -1;
|
|
34728
34747
|
while (++index2 < node2.children.length) {
|
|
34729
|
-
const
|
|
34730
|
-
if (
|
|
34748
|
+
const item = node2.children[index2];
|
|
34749
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
34731
34750
|
useDifferentMarker = true;
|
|
34732
34751
|
break;
|
|
34733
34752
|
}
|
|
@@ -35387,12 +35406,12 @@ async function convertMarkdownToSlate(text5) {
|
|
|
35387
35406
|
...nodes.filter((node2) => node2.type !== "list_item")
|
|
35388
35407
|
];
|
|
35389
35408
|
}
|
|
35390
|
-
return nodes.map((
|
|
35409
|
+
return nodes.map((item) => {
|
|
35391
35410
|
setNodeStyles({
|
|
35392
|
-
node:
|
|
35393
|
-
isPaddingTopNeeded:
|
|
35411
|
+
node: item,
|
|
35412
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
35394
35413
|
});
|
|
35395
|
-
return
|
|
35414
|
+
return item;
|
|
35396
35415
|
});
|
|
35397
35416
|
}
|
|
35398
35417
|
function detectListType(text5) {
|
|
@@ -35805,17 +35824,17 @@ class FloatingPoint extends Point {
|
|
|
35805
35824
|
relativePoint;
|
|
35806
35825
|
pointType = "Floating";
|
|
35807
35826
|
edge;
|
|
35808
|
-
constructor(
|
|
35827
|
+
constructor(item, relativePoint) {
|
|
35809
35828
|
super();
|
|
35810
|
-
this.item =
|
|
35829
|
+
this.item = item;
|
|
35811
35830
|
this.relativePoint = relativePoint;
|
|
35812
35831
|
if (relativePoint.y <= 0) {
|
|
35813
35832
|
this.edge = "top";
|
|
35814
|
-
} else if (relativePoint.y >=
|
|
35833
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
35815
35834
|
this.edge = "bottom";
|
|
35816
35835
|
} else if (relativePoint.x <= 0) {
|
|
35817
35836
|
this.edge = "left";
|
|
35818
|
-
} else if (relativePoint.x >=
|
|
35837
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
35819
35838
|
this.edge = "right";
|
|
35820
35839
|
}
|
|
35821
35840
|
this.recalculatePoint();
|
|
@@ -35846,17 +35865,17 @@ class FixedPoint extends Point {
|
|
|
35846
35865
|
relativePoint;
|
|
35847
35866
|
pointType = "Fixed";
|
|
35848
35867
|
edge;
|
|
35849
|
-
constructor(
|
|
35868
|
+
constructor(item, relativePoint) {
|
|
35850
35869
|
super();
|
|
35851
|
-
this.item =
|
|
35870
|
+
this.item = item;
|
|
35852
35871
|
this.relativePoint = relativePoint;
|
|
35853
35872
|
if (relativePoint.y <= 0) {
|
|
35854
35873
|
this.edge = "top";
|
|
35855
|
-
} else if (relativePoint.y >=
|
|
35874
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
35856
35875
|
this.edge = "bottom";
|
|
35857
35876
|
} else if (relativePoint.x <= 0) {
|
|
35858
35877
|
this.edge = "left";
|
|
35859
|
-
} else if (relativePoint.x >=
|
|
35878
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
35860
35879
|
this.edge = "right";
|
|
35861
35880
|
}
|
|
35862
35881
|
this.recalculatePoint();
|
|
@@ -35887,16 +35906,16 @@ class FixedConnectorPoint extends Point {
|
|
|
35887
35906
|
tangent;
|
|
35888
35907
|
segmentIndex;
|
|
35889
35908
|
pointType = "FixedConnector";
|
|
35890
|
-
constructor(
|
|
35909
|
+
constructor(item, tangent, segmentIndex) {
|
|
35891
35910
|
super();
|
|
35892
|
-
this.item =
|
|
35911
|
+
this.item = item;
|
|
35893
35912
|
this.tangent = tangent;
|
|
35894
35913
|
this.segmentIndex = segmentIndex;
|
|
35895
35914
|
this.recalculatePoint();
|
|
35896
35915
|
}
|
|
35897
35916
|
recalculatePoint() {
|
|
35898
|
-
const
|
|
35899
|
-
const segments =
|
|
35917
|
+
const item = this.item;
|
|
35918
|
+
const segments = item.getPaths().getSegments();
|
|
35900
35919
|
const segment = segments.length > this.segmentIndex ? segments[this.segmentIndex] : segments[segments.length - 1];
|
|
35901
35920
|
const point5 = segment.getPoint(this.tangent);
|
|
35902
35921
|
this.x = point5.x;
|
|
@@ -35921,38 +35940,38 @@ function getControlPoint(data, findItem2) {
|
|
|
35921
35940
|
if (data.pointType === "Board") {
|
|
35922
35941
|
return new BoardPoint(Math.round(data.x), Math.round(data.y));
|
|
35923
35942
|
} else {
|
|
35924
|
-
const
|
|
35925
|
-
if (!
|
|
35943
|
+
const item = findItem2(data.itemId);
|
|
35944
|
+
if (!item) {
|
|
35926
35945
|
console.warn(`getControlPoint(): item not found for ${data.itemId}`);
|
|
35927
35946
|
return new BoardPoint(0, 0);
|
|
35928
35947
|
}
|
|
35929
35948
|
switch (data.pointType) {
|
|
35930
35949
|
case "FixedConnector":
|
|
35931
|
-
if (
|
|
35932
|
-
return new FixedConnectorPoint(
|
|
35950
|
+
if (item instanceof Connector2) {
|
|
35951
|
+
return new FixedConnectorPoint(item, data.tangent, data.segment);
|
|
35933
35952
|
} else {
|
|
35934
35953
|
throw new Error(`getControlPoint(): item must be a connector`);
|
|
35935
35954
|
}
|
|
35936
35955
|
case "Floating":
|
|
35937
|
-
return new FloatingPoint(
|
|
35956
|
+
return new FloatingPoint(item, new Point(data.relativeX, data.relativeY));
|
|
35938
35957
|
case "Fixed":
|
|
35939
|
-
return new FixedPoint(
|
|
35958
|
+
return new FixedPoint(item, new Point(data.relativeX, data.relativeY));
|
|
35940
35959
|
}
|
|
35941
35960
|
}
|
|
35942
35961
|
}
|
|
35943
|
-
function toRelativePoint(point5,
|
|
35944
|
-
const matrix =
|
|
35962
|
+
function toRelativePoint(point5, item) {
|
|
35963
|
+
const matrix = item.transformation?.matrix || new Matrix2;
|
|
35945
35964
|
const inverse = matrix.getInverse();
|
|
35946
35965
|
point5 = point5.copy();
|
|
35947
35966
|
point5.transform(inverse);
|
|
35948
35967
|
return point5;
|
|
35949
35968
|
}
|
|
35950
|
-
function fromRelativePoint(relativePoint,
|
|
35951
|
-
const matrix =
|
|
35969
|
+
function fromRelativePoint(relativePoint, item, edge) {
|
|
35970
|
+
const matrix = item.transformation?.matrix.copy() || new Matrix2;
|
|
35952
35971
|
const point5 = relativePoint.copy();
|
|
35953
35972
|
point5.transform(matrix);
|
|
35954
|
-
if (
|
|
35955
|
-
const itemMbr =
|
|
35973
|
+
if (item instanceof RichText || item instanceof AINode) {
|
|
35974
|
+
const itemMbr = item.getMbr();
|
|
35956
35975
|
const { x: centerX, y: centerY } = itemMbr.getCenter();
|
|
35957
35976
|
switch (edge) {
|
|
35958
35977
|
case "left":
|
|
@@ -35964,7 +35983,7 @@ function fromRelativePoint(relativePoint, item2, edge) {
|
|
|
35964
35983
|
case "bottom":
|
|
35965
35984
|
return new Point(centerX, itemMbr.bottom);
|
|
35966
35985
|
default:
|
|
35967
|
-
return
|
|
35986
|
+
return item.getMbr().getClosestEdgeCenterPoint(point5);
|
|
35968
35987
|
}
|
|
35969
35988
|
}
|
|
35970
35989
|
return point5;
|
|
@@ -37313,7 +37332,7 @@ class Connector2 extends BaseItem {
|
|
|
37313
37332
|
return this;
|
|
37314
37333
|
}
|
|
37315
37334
|
getConnectorById(items, connectorId) {
|
|
37316
|
-
return items.find((
|
|
37335
|
+
return items.find((item) => item instanceof Connector2 && item.getId() === connectorId);
|
|
37317
37336
|
}
|
|
37318
37337
|
updateTitle() {
|
|
37319
37338
|
const selection = this.board.selection;
|
|
@@ -39950,8 +39969,8 @@ async function exportBoardSnapshot({
|
|
|
39950
39969
|
context.matrix.applyToContext(context.ctx);
|
|
39951
39970
|
const { left, top, right, bottom } = selection;
|
|
39952
39971
|
const inView = board.items.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
39953
|
-
for (const
|
|
39954
|
-
|
|
39972
|
+
for (const item of inView) {
|
|
39973
|
+
item.render(context);
|
|
39955
39974
|
}
|
|
39956
39975
|
const blob = await offscreenCanvas.convertToBlob({ type: "image/png" });
|
|
39957
39976
|
const dataUrl = await convertBlobToDataUrl(blob);
|
|
@@ -40149,7 +40168,7 @@ class Frame2 extends BaseItem {
|
|
|
40149
40168
|
return this.id;
|
|
40150
40169
|
}
|
|
40151
40170
|
getChildrenIds() {
|
|
40152
|
-
return this.index?.list().map((
|
|
40171
|
+
return this.index?.list().map((item) => item.getId()) || [];
|
|
40153
40172
|
}
|
|
40154
40173
|
updateMbr() {
|
|
40155
40174
|
const rect = this.path.getMbr().copy();
|
|
@@ -40384,11 +40403,11 @@ class Frame2 extends BaseItem {
|
|
|
40384
40403
|
}
|
|
40385
40404
|
});
|
|
40386
40405
|
const currMbr = this.getMbr();
|
|
40387
|
-
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((
|
|
40388
|
-
if (
|
|
40389
|
-
if (this.handleNesting(
|
|
40390
|
-
this.applyAddChildren([
|
|
40391
|
-
|
|
40406
|
+
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((item) => {
|
|
40407
|
+
if (item.parent === "Board") {
|
|
40408
|
+
if (this.handleNesting(item)) {
|
|
40409
|
+
this.applyAddChildren([item.getId()]);
|
|
40410
|
+
item.parent = this.getId();
|
|
40392
40411
|
}
|
|
40393
40412
|
}
|
|
40394
40413
|
});
|
|
@@ -42586,9 +42605,9 @@ class Group extends BaseItem {
|
|
|
42586
42605
|
if (data.children) {
|
|
42587
42606
|
data.children.forEach((childId) => {
|
|
42588
42607
|
this.applyAddChild(childId);
|
|
42589
|
-
const
|
|
42590
|
-
if (
|
|
42591
|
-
|
|
42608
|
+
const item = this.board.items.getById(childId);
|
|
42609
|
+
if (item) {
|
|
42610
|
+
item.parent = this.getId();
|
|
42592
42611
|
}
|
|
42593
42612
|
});
|
|
42594
42613
|
}
|
|
@@ -42618,11 +42637,11 @@ class Group extends BaseItem {
|
|
|
42618
42637
|
let right = Number.MIN_SAFE_INTEGER;
|
|
42619
42638
|
let bottom = Number.MIN_SAFE_INTEGER;
|
|
42620
42639
|
const mbrs = this.children.flatMap((childId) => {
|
|
42621
|
-
const
|
|
42622
|
-
if (!
|
|
42640
|
+
const item = this.board.items.getById(childId);
|
|
42641
|
+
if (!item) {
|
|
42623
42642
|
return [];
|
|
42624
42643
|
}
|
|
42625
|
-
const mbr2 =
|
|
42644
|
+
const mbr2 = item.getMbr();
|
|
42626
42645
|
if (!mbr2) {
|
|
42627
42646
|
return [];
|
|
42628
42647
|
}
|
|
@@ -42657,7 +42676,7 @@ class Group extends BaseItem {
|
|
|
42657
42676
|
return this.children;
|
|
42658
42677
|
}
|
|
42659
42678
|
getChildren() {
|
|
42660
|
-
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((
|
|
42679
|
+
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((item) => item !== undefined);
|
|
42661
42680
|
}
|
|
42662
42681
|
updateMbr() {
|
|
42663
42682
|
const rect = this.getMbr();
|
|
@@ -42670,9 +42689,9 @@ class Group extends BaseItem {
|
|
|
42670
42689
|
setChildren(items) {
|
|
42671
42690
|
items.forEach((itemId) => {
|
|
42672
42691
|
this.addChild(itemId);
|
|
42673
|
-
const
|
|
42674
|
-
if (
|
|
42675
|
-
|
|
42692
|
+
const item = this.board.items.getById(itemId);
|
|
42693
|
+
if (item) {
|
|
42694
|
+
item.parent = this.getId();
|
|
42676
42695
|
}
|
|
42677
42696
|
});
|
|
42678
42697
|
this.updateMbr();
|
|
@@ -42680,9 +42699,9 @@ class Group extends BaseItem {
|
|
|
42680
42699
|
removeChildren() {
|
|
42681
42700
|
this.children.forEach((itemId) => {
|
|
42682
42701
|
this.removeChild(itemId);
|
|
42683
|
-
const
|
|
42684
|
-
if (
|
|
42685
|
-
|
|
42702
|
+
const item = this.board.items.getById(itemId);
|
|
42703
|
+
if (item) {
|
|
42704
|
+
item.parent = this.parent;
|
|
42686
42705
|
}
|
|
42687
42706
|
});
|
|
42688
42707
|
this.updateMbr();
|
|
@@ -43015,16 +43034,16 @@ class Anchor extends Mbr {
|
|
|
43015
43034
|
}
|
|
43016
43035
|
}
|
|
43017
43036
|
// src/Items/Connector/ConnectorSnap.ts
|
|
43018
|
-
function getFixedPoint(
|
|
43019
|
-
if (
|
|
43020
|
-
const nearestSegmentData =
|
|
43037
|
+
function getFixedPoint(item, point5) {
|
|
43038
|
+
if (item instanceof Connector2) {
|
|
43039
|
+
const nearestSegmentData = item.getPaths().getNearestEdgeAndPointTo(point5);
|
|
43021
43040
|
const segment = nearestSegmentData.segment;
|
|
43022
43041
|
const index2 = nearestSegmentData.index;
|
|
43023
43042
|
const tangent = segment.getParameter(point5);
|
|
43024
|
-
return new FixedConnectorPoint(
|
|
43043
|
+
return new FixedConnectorPoint(item, tangent, index2);
|
|
43025
43044
|
} else {
|
|
43026
|
-
const relativePoint = toRelativePoint(point5,
|
|
43027
|
-
return new FixedPoint(
|
|
43045
|
+
const relativePoint = toRelativePoint(point5, item);
|
|
43046
|
+
return new FixedPoint(item, relativePoint);
|
|
43028
43047
|
}
|
|
43029
43048
|
}
|
|
43030
43049
|
|
|
@@ -43077,20 +43096,20 @@ class ConnectorSnap {
|
|
|
43077
43096
|
}
|
|
43078
43097
|
this.setSnap();
|
|
43079
43098
|
const pointer = this.board.pointer.point;
|
|
43080
|
-
const { anchor, item
|
|
43081
|
-
if (!
|
|
43099
|
+
const { anchor, item, point: point5 } = this.snap;
|
|
43100
|
+
if (!item) {
|
|
43082
43101
|
const pointer2 = this.board.pointer.point;
|
|
43083
43102
|
this.controlPoint = new BoardPoint(pointer2.x, pointer2.y);
|
|
43084
43103
|
} else if (anchor) {
|
|
43085
|
-
this.controlPoint = getFixedPoint(
|
|
43104
|
+
this.controlPoint = getFixedPoint(item, anchor.getCenter());
|
|
43086
43105
|
} else if (point5) {
|
|
43087
|
-
const nearest2 =
|
|
43088
|
-
this.controlPoint = getFixedPoint(
|
|
43106
|
+
const nearest2 = item.getNearestEdgePointTo(pointer);
|
|
43107
|
+
this.controlPoint = getFixedPoint(item, nearest2);
|
|
43089
43108
|
} else {
|
|
43090
43109
|
if (this.hover.isTimeoutElapsed) {
|
|
43091
|
-
this.controlPoint = getFixedPoint(
|
|
43110
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
43092
43111
|
} else {
|
|
43093
|
-
this.controlPoint = getFixedPoint(
|
|
43112
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
43094
43113
|
}
|
|
43095
43114
|
}
|
|
43096
43115
|
}
|
|
@@ -43151,23 +43170,23 @@ class ConnectorSnap {
|
|
|
43151
43170
|
}
|
|
43152
43171
|
return nearest;
|
|
43153
43172
|
}
|
|
43154
|
-
getClosestPointOnItem(
|
|
43155
|
-
const nearestEdgePoint =
|
|
43156
|
-
return getFixedPoint(
|
|
43173
|
+
getClosestPointOnItem(item, position4) {
|
|
43174
|
+
const nearestEdgePoint = item.getNearestEdgePointTo(position4);
|
|
43175
|
+
return getFixedPoint(item, nearestEdgePoint);
|
|
43157
43176
|
}
|
|
43158
|
-
isNearBorder(
|
|
43159
|
-
if (!
|
|
43177
|
+
isNearBorder(item) {
|
|
43178
|
+
if (!item) {
|
|
43160
43179
|
return false;
|
|
43161
43180
|
}
|
|
43162
43181
|
const pointer = this.board.pointer.point;
|
|
43163
|
-
const point5 =
|
|
43182
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
43164
43183
|
const distance = pointer.getDistance(point5);
|
|
43165
43184
|
return distance < this.distance.border / this.board.camera.getScale();
|
|
43166
43185
|
}
|
|
43167
43186
|
setSnap() {
|
|
43168
|
-
const
|
|
43169
|
-
const path2 =
|
|
43170
|
-
if (!
|
|
43187
|
+
const item = this.snap.item;
|
|
43188
|
+
const path2 = item && "getPath" in item ? item?.getPath() : null;
|
|
43189
|
+
if (!item || !path2) {
|
|
43171
43190
|
this.snap.path = null;
|
|
43172
43191
|
this.snap.anchors = [];
|
|
43173
43192
|
this.snap.anchor = null;
|
|
@@ -43178,11 +43197,11 @@ class ConnectorSnap {
|
|
|
43178
43197
|
if (this.snap.item === this.hover.item && !this.hover.isTimeoutElapsed) {
|
|
43179
43198
|
path2.setBackgroundColor(this.color.snapBackgroundHighlight);
|
|
43180
43199
|
}
|
|
43181
|
-
this.setAnchors(
|
|
43200
|
+
this.setAnchors(item);
|
|
43182
43201
|
}
|
|
43183
43202
|
}
|
|
43184
|
-
setAnchors(
|
|
43185
|
-
const points =
|
|
43203
|
+
setAnchors(item) {
|
|
43204
|
+
const points = item.getSnapAnchorPoints();
|
|
43186
43205
|
if (!points) {
|
|
43187
43206
|
return;
|
|
43188
43207
|
}
|
|
@@ -43216,10 +43235,10 @@ class ConnectorSnap {
|
|
|
43216
43235
|
}
|
|
43217
43236
|
setPoint() {
|
|
43218
43237
|
const pointer = this.board.pointer.point;
|
|
43219
|
-
const { item
|
|
43220
|
-
if (
|
|
43238
|
+
const { item, anchor } = this.snap;
|
|
43239
|
+
if (item) {
|
|
43221
43240
|
if (!anchor) {
|
|
43222
|
-
const point5 =
|
|
43241
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
43223
43242
|
if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
|
|
43224
43243
|
this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
|
|
43225
43244
|
} else {
|
|
@@ -43592,12 +43611,12 @@ class NestingHighlighter extends Tool {
|
|
|
43592
43611
|
this.toHighlight.push({ groupItem, children: array });
|
|
43593
43612
|
}
|
|
43594
43613
|
}
|
|
43595
|
-
addSingleItem(
|
|
43596
|
-
this.toHighlight.push({ children: [
|
|
43614
|
+
addSingleItem(item) {
|
|
43615
|
+
this.toHighlight.push({ children: [item] });
|
|
43597
43616
|
}
|
|
43598
|
-
remove(
|
|
43617
|
+
remove(item) {
|
|
43599
43618
|
this.toHighlight.forEach((group) => {
|
|
43600
|
-
group.children = group.children.filter((child) => child !==
|
|
43619
|
+
group.children = group.children.filter((child) => child !== item);
|
|
43601
43620
|
});
|
|
43602
43621
|
this.toHighlight = this.toHighlight.filter((group) => group.children.length > 0);
|
|
43603
43622
|
}
|
|
@@ -43664,7 +43683,7 @@ class AddFrame extends BoardTool {
|
|
|
43664
43683
|
this.mbr.borderColor = "blue";
|
|
43665
43684
|
this.nestingHighlighter.clear();
|
|
43666
43685
|
const enclosedOrCrossed = this.board.items.getEnclosedOrCrossed(this.mbr.left, this.mbr.top, this.mbr.right, this.mbr.bottom);
|
|
43667
|
-
const inside = enclosedOrCrossed.filter((
|
|
43686
|
+
const inside = enclosedOrCrossed.filter((item) => !(item instanceof Frame2) && item.parent === "Board" && this.mbr.isInside(item.getMbr().getCenter()));
|
|
43668
43687
|
this.nestingHighlighter.add(this.frame, inside);
|
|
43669
43688
|
this.initTransformation();
|
|
43670
43689
|
this.board.tools.publish();
|
|
@@ -43685,7 +43704,7 @@ class AddFrame extends BoardTool {
|
|
|
43685
43704
|
localStorage.setItem("lastFrameScale", JSON.stringify(this.frame.transformation.getScale()));
|
|
43686
43705
|
}
|
|
43687
43706
|
const currMbr = this.frame.getMbr();
|
|
43688
|
-
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
43707
|
+
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));
|
|
43689
43708
|
this.applyAddChildren(frameChildren);
|
|
43690
43709
|
if (this.shape !== "Custom") {
|
|
43691
43710
|
this.applyCanChangeRatio(false);
|
|
@@ -43701,7 +43720,7 @@ class AddFrame extends BoardTool {
|
|
|
43701
43720
|
return true;
|
|
43702
43721
|
}
|
|
43703
43722
|
addNextTo() {
|
|
43704
|
-
const framesInView = this.board.items.getItemsInView().filter((
|
|
43723
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame2);
|
|
43705
43724
|
if (framesInView.length === 0) {
|
|
43706
43725
|
if (this.shape === "Custom") {
|
|
43707
43726
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -43739,7 +43758,7 @@ class AddFrame extends BoardTool {
|
|
|
43739
43758
|
this.board.camera.viewRectangle(this.frame.getMbr());
|
|
43740
43759
|
}
|
|
43741
43760
|
const frameMbr = this.frame.getMbr();
|
|
43742
|
-
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((
|
|
43761
|
+
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]));
|
|
43743
43762
|
const frame = this.board.add(this.frame);
|
|
43744
43763
|
frame.text.editor.moveCursorToEndOfTheText();
|
|
43745
43764
|
this.nestingHighlighter.clear();
|
|
@@ -44244,13 +44263,13 @@ class Eraser extends BoardTool {
|
|
|
44244
44263
|
}
|
|
44245
44264
|
removeUnderPointOrLine() {
|
|
44246
44265
|
const segments = this.drawing.getLines();
|
|
44247
|
-
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((
|
|
44248
|
-
return
|
|
44249
|
-
return line.getDistance(this.board.pointer.point) <=
|
|
44266
|
+
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((item) => {
|
|
44267
|
+
return item.itemType === "Drawing" && item.getLines().find((line) => {
|
|
44268
|
+
return line.getDistance(this.board.pointer.point) <= item.strokeWidth / 2 + this.strokeWidth / 2;
|
|
44250
44269
|
});
|
|
44251
44270
|
});
|
|
44252
|
-
items.push(...this.board.items.getEnclosedOrCrossed(this.drawing.points[0].x, this.drawing.points[0].y, this.board.pointer.point.x, this.board.pointer.point.y).filter((
|
|
44253
|
-
return
|
|
44271
|
+
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) => {
|
|
44272
|
+
return item.itemType === "Drawing" && item.getLines().some((line) => {
|
|
44254
44273
|
return segments.some((segment) => segment.hasIntersectionPoint(line));
|
|
44255
44274
|
});
|
|
44256
44275
|
}));
|
|
@@ -44702,20 +44721,20 @@ function createCanvasDrawer(board) {
|
|
|
44702
44721
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
44703
44722
|
context.matrix.applyToContext(context.ctx);
|
|
44704
44723
|
const items = Object.keys(translation).map((id) => {
|
|
44705
|
-
const
|
|
44706
|
-
if (
|
|
44707
|
-
if (
|
|
44708
|
-
return
|
|
44724
|
+
const item = board2.items.getById(id);
|
|
44725
|
+
if (item) {
|
|
44726
|
+
if (item.itemType !== "Frame") {
|
|
44727
|
+
return item;
|
|
44709
44728
|
}
|
|
44710
|
-
|
|
44711
|
-
return
|
|
44729
|
+
item.render(context);
|
|
44730
|
+
return item;
|
|
44712
44731
|
}
|
|
44713
44732
|
return;
|
|
44714
|
-
}).filter((
|
|
44715
|
-
items.forEach((
|
|
44716
|
-
if (
|
|
44717
|
-
|
|
44718
|
-
board2.selection.renderItemMbr(context,
|
|
44733
|
+
}).filter((item) => !!item);
|
|
44734
|
+
items.forEach((item) => {
|
|
44735
|
+
if (item.itemType !== "Frame") {
|
|
44736
|
+
item.render(context);
|
|
44737
|
+
board2.selection.renderItemMbr(context, item, board2.camera.getMatrix().scaleX);
|
|
44719
44738
|
}
|
|
44720
44739
|
});
|
|
44721
44740
|
return { canvas: container, items };
|
|
@@ -44776,10 +44795,10 @@ function createCanvasDrawer(board) {
|
|
|
44776
44795
|
if (lastTranslationKeys) {
|
|
44777
44796
|
board.selection.shouldPublish = false;
|
|
44778
44797
|
lastTranslationKeys.forEach((id) => {
|
|
44779
|
-
const
|
|
44780
|
-
if (
|
|
44781
|
-
|
|
44782
|
-
|
|
44798
|
+
const item = board.items.getById(id);
|
|
44799
|
+
if (item) {
|
|
44800
|
+
item.transformationRenderBlock = undefined;
|
|
44801
|
+
item.subject.publish(item);
|
|
44783
44802
|
}
|
|
44784
44803
|
});
|
|
44785
44804
|
lastTranslationKeys = undefined;
|
|
@@ -44811,9 +44830,9 @@ function createCanvasDrawer(board) {
|
|
|
44811
44830
|
lastCreatedCanvas = cnvs;
|
|
44812
44831
|
lastTranslationKeys = Object.keys(translation);
|
|
44813
44832
|
lastTranslationKeys.forEach((id) => {
|
|
44814
|
-
const
|
|
44815
|
-
if (
|
|
44816
|
-
|
|
44833
|
+
const item = board.items.getById(id);
|
|
44834
|
+
if (item) {
|
|
44835
|
+
item.transformationRenderBlock = true;
|
|
44817
44836
|
}
|
|
44818
44837
|
});
|
|
44819
44838
|
board.selection.transformationRenderBlock = true;
|
|
@@ -44823,14 +44842,14 @@ function createCanvasDrawer(board) {
|
|
|
44823
44842
|
}
|
|
44824
44843
|
function countSumMbr(translation) {
|
|
44825
44844
|
return Object.keys(translation).reduce((mbr, id) => {
|
|
44826
|
-
const
|
|
44827
|
-
if (
|
|
44845
|
+
const item = board.items.getById(id);
|
|
44846
|
+
if (item) {
|
|
44828
44847
|
if (!mbr) {
|
|
44829
|
-
mbr =
|
|
44848
|
+
mbr = item.getMbr();
|
|
44830
44849
|
} else {
|
|
44831
|
-
mbr.combine(
|
|
44832
|
-
if (
|
|
44833
|
-
mbr.combine(
|
|
44850
|
+
mbr.combine(item.getMbr());
|
|
44851
|
+
if (item.itemType === "Frame") {
|
|
44852
|
+
mbr.combine(item.getRichText().getMbr());
|
|
44834
44853
|
}
|
|
44835
44854
|
}
|
|
44836
44855
|
}
|
|
@@ -44861,8 +44880,8 @@ function createCanvasDrawer(board) {
|
|
|
44861
44880
|
}
|
|
44862
44881
|
function highlightNesting() {
|
|
44863
44882
|
const container = getLastCreatedCanvas();
|
|
44864
|
-
const drawnItemsMap = drawnItems?.reduce((acc,
|
|
44865
|
-
acc.set(
|
|
44883
|
+
const drawnItemsMap = drawnItems?.reduce((acc, item) => {
|
|
44884
|
+
acc.set(item.getId(), { item, mbr: item.getMbr() });
|
|
44866
44885
|
return acc;
|
|
44867
44886
|
}, new Map);
|
|
44868
44887
|
if (!container || !drawnItems) {
|
|
@@ -44897,11 +44916,11 @@ function createCanvasDrawer(board) {
|
|
|
44897
44916
|
mbr.transform(currMatrix);
|
|
44898
44917
|
});
|
|
44899
44918
|
groups.forEach((group) => {
|
|
44900
|
-
drawnItemsMap?.forEach(({ mbr, item
|
|
44901
|
-
if ("canBeNested" in
|
|
44919
|
+
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
44920
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
44902
44921
|
return;
|
|
44903
44922
|
}
|
|
44904
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) ||
|
|
44923
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
44905
44924
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
44906
44925
|
removeHighlighted(key);
|
|
44907
44926
|
highlightedDivs.set(key, div);
|
|
@@ -44962,10 +44981,10 @@ function createCanvasDrawer(board) {
|
|
|
44962
44981
|
}
|
|
44963
44982
|
|
|
44964
44983
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
44965
|
-
function getControlPointData(
|
|
44966
|
-
const itemScale = isRichText ? { x: 1, y: 1 } :
|
|
44967
|
-
const width2 =
|
|
44968
|
-
let height3 =
|
|
44984
|
+
function getControlPointData(item, index2, isRichText = false) {
|
|
44985
|
+
const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
|
|
44986
|
+
const width2 = item.getPathMbr().getWidth();
|
|
44987
|
+
let height3 = item.getPathMbr().getHeight();
|
|
44969
44988
|
const adjMapScaled = {
|
|
44970
44989
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
44971
44990
|
1: {
|
|
@@ -44980,7 +44999,7 @@ function getControlPointData(item2, index2, isRichText = false) {
|
|
|
44980
44999
|
};
|
|
44981
45000
|
return {
|
|
44982
45001
|
pointType: "Fixed",
|
|
44983
|
-
itemId:
|
|
45002
|
+
itemId: item.getId(),
|
|
44984
45003
|
relativeX: adjMapScaled[index2].x,
|
|
44985
45004
|
relativeY: adjMapScaled[index2].y
|
|
44986
45005
|
};
|
|
@@ -45115,10 +45134,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
45115
45134
|
let newHeight = height3;
|
|
45116
45135
|
let itemData;
|
|
45117
45136
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
45118
|
-
const
|
|
45119
|
-
newWidth =
|
|
45120
|
-
newHeight =
|
|
45121
|
-
itemData =
|
|
45137
|
+
const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
45138
|
+
newWidth = item.getMbr().getWidth();
|
|
45139
|
+
newHeight = item.getMbr().getHeight();
|
|
45140
|
+
itemData = item.serialize();
|
|
45122
45141
|
const { minX, minY, maxY, maxX } = offsets;
|
|
45123
45142
|
offsetX = Math.min(offsetX, maxX);
|
|
45124
45143
|
offsetX = Math.max(offsetX, minX);
|
|
@@ -45151,7 +45170,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45151
45170
|
}
|
|
45152
45171
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
45153
45172
|
let step = 1;
|
|
45154
|
-
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((
|
|
45173
|
+
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((item) => item.itemType !== "Connector").length > 0) {
|
|
45155
45174
|
const xDirection = step % 2 === 0 ? -1 : 1;
|
|
45156
45175
|
const yDirection = newItemData.itemType === "AINode" ? -1 : xDirection;
|
|
45157
45176
|
newMbr.transform(new Matrix2(iterAdjustment[index2].x * xDirection * step, iterAdjustment[index2].y * yDirection * (newItemData.itemType === "AINode" ? 1 : step)));
|
|
@@ -45284,7 +45303,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45284
45303
|
clear();
|
|
45285
45304
|
return;
|
|
45286
45305
|
}
|
|
45287
|
-
const { positions, item
|
|
45306
|
+
const { positions, item } = position4;
|
|
45288
45307
|
const cameraMatrix = board.camera.getMatrix();
|
|
45289
45308
|
const cameraMbr = board.camera.getMbr();
|
|
45290
45309
|
const positionAdjustments = {
|
|
@@ -45312,7 +45331,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45312
45331
|
};
|
|
45313
45332
|
const button = document.createElement("button");
|
|
45314
45333
|
button.classList.add("microboard-quickAddButton");
|
|
45315
|
-
if (
|
|
45334
|
+
if (item.itemType === "AINode" && index2 === 2) {
|
|
45316
45335
|
button.classList.add("microboard-invisible");
|
|
45317
45336
|
}
|
|
45318
45337
|
button.classList.add(`microboard-${adjustment.rotate}`);
|
|
@@ -45328,7 +45347,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45328
45347
|
clearTimeout(timeoutId);
|
|
45329
45348
|
}
|
|
45330
45349
|
if (button.isMouseDown) {
|
|
45331
|
-
board.tools.addConnector(true,
|
|
45350
|
+
board.tools.addConnector(true, item, pos);
|
|
45332
45351
|
} else {
|
|
45333
45352
|
quickAddItems = undefined;
|
|
45334
45353
|
selection.subject.publish(selection);
|
|
@@ -45435,11 +45454,11 @@ class AlignmentHelper {
|
|
|
45435
45454
|
return baseThickness / (zoom / 100);
|
|
45436
45455
|
}
|
|
45437
45456
|
combineMBRs(items) {
|
|
45438
|
-
return items.reduce((acc,
|
|
45457
|
+
return items.reduce((acc, item, i) => {
|
|
45439
45458
|
if (i === 0) {
|
|
45440
45459
|
return acc;
|
|
45441
45460
|
}
|
|
45442
|
-
const itemMbr =
|
|
45461
|
+
const itemMbr = item.getPathMbr();
|
|
45443
45462
|
return acc.combine(itemMbr);
|
|
45444
45463
|
}, items[0].getMbr());
|
|
45445
45464
|
}
|
|
@@ -45453,7 +45472,7 @@ class AlignmentHelper {
|
|
|
45453
45472
|
const scale = this.board.camera.getScale();
|
|
45454
45473
|
const dynamicAlignThreshold = Math.min(this.alignThreshold / scale, 8);
|
|
45455
45474
|
const childrenIds = "index" in movingItem && movingItem.index ? movingItem.getChildrenIds() : [];
|
|
45456
|
-
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (
|
|
45475
|
+
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);
|
|
45457
45476
|
const verticalAlignments = new Map;
|
|
45458
45477
|
const horizontalAlignments = new Map;
|
|
45459
45478
|
const addVerticalAlignment = (x, minY, maxY) => {
|
|
@@ -45474,11 +45493,11 @@ class AlignmentHelper {
|
|
|
45474
45493
|
horizontalAlignments.set(y, { minX, maxX });
|
|
45475
45494
|
}
|
|
45476
45495
|
};
|
|
45477
|
-
nearbyItems.forEach((
|
|
45478
|
-
if (
|
|
45496
|
+
nearbyItems.forEach((item) => {
|
|
45497
|
+
if (item === movingItem || item.itemType === "Comment") {
|
|
45479
45498
|
return;
|
|
45480
45499
|
}
|
|
45481
|
-
const itemMbr =
|
|
45500
|
+
const itemMbr = item.itemType === "Shape" ? item.getPath().getMbr() : item.getMbr();
|
|
45482
45501
|
const centerXMoving = (movingMBR.left + movingMBR.right) / 2;
|
|
45483
45502
|
const centerXItem = (itemMbr.left + itemMbr.right) / 2;
|
|
45484
45503
|
const centerYMoving = (movingMBR.top + movingMBR.bottom) / 2;
|
|
@@ -45745,20 +45764,20 @@ class AlignmentHelper {
|
|
|
45745
45764
|
}
|
|
45746
45765
|
return false;
|
|
45747
45766
|
}
|
|
45748
|
-
translateItems(
|
|
45767
|
+
translateItems(item, x, y, timeStamp) {
|
|
45749
45768
|
if (this.canvasDrawer.getLastCreatedCanvas()) {
|
|
45750
45769
|
return;
|
|
45751
45770
|
}
|
|
45752
|
-
if (Array.isArray(
|
|
45771
|
+
if (Array.isArray(item)) {
|
|
45753
45772
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45754
45773
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45755
45774
|
return;
|
|
45756
45775
|
}
|
|
45757
|
-
if (
|
|
45776
|
+
if (item.itemType === "Frame") {
|
|
45758
45777
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
45759
45778
|
this.board.selection.transformMany(translation, timeStamp);
|
|
45760
45779
|
} else {
|
|
45761
|
-
const id =
|
|
45780
|
+
const id = item.getId();
|
|
45762
45781
|
const transformMap = {};
|
|
45763
45782
|
transformMap[id] = {
|
|
45764
45783
|
class: "Transformation",
|
|
@@ -45886,12 +45905,12 @@ class Select extends Tool {
|
|
|
45886
45905
|
this.debounceUpd.setFalse();
|
|
45887
45906
|
this.snapLines = { verticalLines: [], horizontalLines: [] };
|
|
45888
45907
|
}
|
|
45889
|
-
handleSnapping(
|
|
45908
|
+
handleSnapping(item) {
|
|
45890
45909
|
if (this.board.keyboard.isShift) {
|
|
45891
45910
|
return false;
|
|
45892
45911
|
}
|
|
45893
|
-
const increasedSnapThreshold = Array.isArray(
|
|
45894
|
-
this.isSnapped = this.alignmentHelper.snapToClosestLine(
|
|
45912
|
+
const increasedSnapThreshold = Array.isArray(item) ? 40 : 35;
|
|
45913
|
+
this.isSnapped = this.alignmentHelper.snapToClosestLine(item, this.snapLines, this.beginTimeStamp, this.board.pointer.point);
|
|
45895
45914
|
if (this.isSnapped) {
|
|
45896
45915
|
if (!this.snapCursorPos) {
|
|
45897
45916
|
this.snapCursorPos = new Point(this.board.pointer.point.x, this.board.pointer.point.y);
|
|
@@ -45901,10 +45920,10 @@ class Select extends Tool {
|
|
|
45901
45920
|
if ((cursorDiffX > increasedSnapThreshold || cursorDiffY > increasedSnapThreshold) && this.initialCursorPos) {
|
|
45902
45921
|
this.isSnapped = false;
|
|
45903
45922
|
this.snapCursorPos = null;
|
|
45904
|
-
const itemCenter = Array.isArray(
|
|
45923
|
+
const itemCenter = Array.isArray(item) ? this.alignmentHelper.combineMBRs(item).getCenter() : item.getMbr().getCenter();
|
|
45905
45924
|
const translateX = this.board.pointer.point.x - this.initialCursorPos.x - itemCenter.x;
|
|
45906
45925
|
const translateY = this.board.pointer.point.y - this.initialCursorPos.y - itemCenter.y;
|
|
45907
|
-
this.alignmentHelper.translateItems(
|
|
45926
|
+
this.alignmentHelper.translateItems(item, translateX, translateY, this.beginTimeStamp);
|
|
45908
45927
|
}
|
|
45909
45928
|
}
|
|
45910
45929
|
return false;
|
|
@@ -45954,10 +45973,10 @@ class Select extends Tool {
|
|
|
45954
45973
|
angleDiff = angleDiff < 0 ? angleDiff + 360 : angleDiff;
|
|
45955
45974
|
return Math.min(angleDiff, 360 - angleDiff);
|
|
45956
45975
|
}
|
|
45957
|
-
handleShiftGuidelines(
|
|
45958
|
-
if (
|
|
45976
|
+
handleShiftGuidelines(item, mousePosition) {
|
|
45977
|
+
if (item) {
|
|
45959
45978
|
if (!this.originalCenter) {
|
|
45960
|
-
this.originalCenter = Array.isArray(
|
|
45979
|
+
this.originalCenter = Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().copy() : item.getMbr().getCenter().copy();
|
|
45961
45980
|
this.guidelines = this.alignmentHelper.generateGuidelines(this.originalCenter).lines;
|
|
45962
45981
|
}
|
|
45963
45982
|
this.mainLine = new Line(this.originalCenter, mousePosition);
|
|
@@ -45978,13 +45997,13 @@ class Select extends Tool {
|
|
|
45978
45997
|
const newEndX = this.originalCenter.x + snapDirectionX * mainLineLength;
|
|
45979
45998
|
const newEndY = this.originalCenter.y + snapDirectionY * mainLineLength;
|
|
45980
45999
|
const threshold = Infinity;
|
|
45981
|
-
const translateX = newEndX - (Array.isArray(
|
|
45982
|
-
const translateY = newEndY - (Array.isArray(
|
|
45983
|
-
if (Array.isArray(
|
|
46000
|
+
const translateX = newEndX - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().x : item.getMbr().getCenter().x);
|
|
46001
|
+
const translateY = newEndY - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().y : item.getMbr().getCenter().y);
|
|
46002
|
+
if (Array.isArray(item)) {
|
|
45984
46003
|
const translation = this.board.selection.getManyItemsTranslation(translateX, translateY);
|
|
45985
46004
|
this.board.selection.transformMany(translation, this.beginTimeStamp);
|
|
45986
46005
|
} else {
|
|
45987
|
-
|
|
46006
|
+
item.transformation.translateBy(translateX, translateY, this.beginTimeStamp);
|
|
45988
46007
|
}
|
|
45989
46008
|
}
|
|
45990
46009
|
}
|
|
@@ -46027,7 +46046,7 @@ class Select extends Tool {
|
|
|
46027
46046
|
return false;
|
|
46028
46047
|
}
|
|
46029
46048
|
this.isDownOnBoard = hover.length === 0;
|
|
46030
|
-
this.isDrawingRectangle = hover.filter((
|
|
46049
|
+
this.isDrawingRectangle = hover.filter((item) => !(item instanceof Frame2)).length === 0 && hover.filter((item) => item instanceof Frame2).filter((frame) => frame.isTextUnderPoint(pointer.point)).length === 0;
|
|
46031
46050
|
if (this.isDrawingRectangle) {
|
|
46032
46051
|
const { x, y } = pointer.point;
|
|
46033
46052
|
this.line = new Line(new Point(x, y), new Point(x, y));
|
|
@@ -46047,7 +46066,7 @@ class Select extends Tool {
|
|
|
46047
46066
|
});
|
|
46048
46067
|
return false;
|
|
46049
46068
|
}
|
|
46050
|
-
const isHoverLocked = hover.every((
|
|
46069
|
+
const isHoverLocked = hover.every((item) => item.transformation.isLocked);
|
|
46051
46070
|
if (isHoverLocked) {
|
|
46052
46071
|
return false;
|
|
46053
46072
|
}
|
|
@@ -46181,7 +46200,7 @@ class Select extends Tool {
|
|
|
46181
46200
|
const translation = selection.getManyItemsTranslation(x, y);
|
|
46182
46201
|
const translationKeys = Object.keys(translation);
|
|
46183
46202
|
const commentsSet = new Set(this.board.items.getComments().map((comment2) => comment2.getId()));
|
|
46184
|
-
if (translationKeys.filter((
|
|
46203
|
+
if (translationKeys.filter((item) => !commentsSet.has(item)).length > 10) {
|
|
46185
46204
|
const selectedMbr = this.board.selection.getMbr()?.copy();
|
|
46186
46205
|
const sumMbr = this.canvasDrawer.countSumMbr(translation);
|
|
46187
46206
|
if (sumMbr) {
|
|
@@ -46208,7 +46227,7 @@ class Select extends Tool {
|
|
|
46208
46227
|
return false;
|
|
46209
46228
|
}
|
|
46210
46229
|
const draggingMbr = draggingItem.getMbr();
|
|
46211
|
-
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((
|
|
46230
|
+
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((item) => item instanceof Frame2);
|
|
46212
46231
|
frames.forEach((frame) => {
|
|
46213
46232
|
if (frame.handleNesting(draggingItem)) {
|
|
46214
46233
|
this.nestingHighlighter.add(frame, draggingItem);
|
|
@@ -46218,7 +46237,7 @@ class Select extends Tool {
|
|
|
46218
46237
|
});
|
|
46219
46238
|
}
|
|
46220
46239
|
const hover = items.getUnderPointer();
|
|
46221
|
-
this.isHoverUnselectedItem = hover.filter((
|
|
46240
|
+
this.isHoverUnselectedItem = hover.filter((item) => item.itemType === "Placeholder").length === 1;
|
|
46222
46241
|
if (this.isHoverUnselectedItem && !this.isDraggingUnselectedItem && selection.getContext() === "None") {
|
|
46223
46242
|
selection.setContext("HoverUnderPointer");
|
|
46224
46243
|
return false;
|
|
@@ -46262,15 +46281,15 @@ class Select extends Tool {
|
|
|
46262
46281
|
}
|
|
46263
46282
|
}
|
|
46264
46283
|
updateFramesNesting(selectionMbr, selection) {
|
|
46265
|
-
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((
|
|
46266
|
-
const draggingFramesIds = selection.list().filter((
|
|
46267
|
-
selection.list().forEach((
|
|
46268
|
-
if (!(
|
|
46284
|
+
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));
|
|
46285
|
+
const draggingFramesIds = selection.list().filter((item) => item instanceof Frame2).map((frame) => frame.getId());
|
|
46286
|
+
selection.list().forEach((item) => {
|
|
46287
|
+
if (!(item instanceof Frame2) && !draggingFramesIds.includes(item.parent)) {
|
|
46269
46288
|
frames.forEach((frame) => {
|
|
46270
|
-
if (frame.handleNesting(
|
|
46271
|
-
this.nestingHighlighter.add(frame,
|
|
46289
|
+
if (frame.handleNesting(item)) {
|
|
46290
|
+
this.nestingHighlighter.add(frame, item);
|
|
46272
46291
|
} else {
|
|
46273
|
-
this.nestingHighlighter.remove(
|
|
46292
|
+
this.nestingHighlighter.remove(item);
|
|
46274
46293
|
}
|
|
46275
46294
|
});
|
|
46276
46295
|
}
|
|
@@ -46362,7 +46381,7 @@ class Select extends Tool {
|
|
|
46362
46381
|
const childrenIds = underPointer.getChildrenIds();
|
|
46363
46382
|
console.log("UNDERPOINTER", underPointer);
|
|
46364
46383
|
console.log("CHILDREN", childrenIds);
|
|
46365
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
46384
|
+
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
46366
46385
|
this.board.selection.add(itemsInFrame);
|
|
46367
46386
|
}
|
|
46368
46387
|
this.board.selection.setContext("EditUnderPointer");
|
|
@@ -46602,8 +46621,8 @@ class ShapeTool extends CustomTool {
|
|
|
46602
46621
|
resizeType = "leftBottom";
|
|
46603
46622
|
bounds = new Mbr;
|
|
46604
46623
|
isDown = false;
|
|
46605
|
-
constructor(board, name,
|
|
46606
|
-
super(board, name,
|
|
46624
|
+
constructor(board, name, item, settings) {
|
|
46625
|
+
super(board, name, item);
|
|
46607
46626
|
this.settings = settings;
|
|
46608
46627
|
this.setCursor();
|
|
46609
46628
|
}
|
|
@@ -46686,8 +46705,8 @@ class ShapeTool extends CustomTool {
|
|
|
46686
46705
|
|
|
46687
46706
|
class StickerTool extends CustomTool {
|
|
46688
46707
|
settings;
|
|
46689
|
-
constructor(board, name,
|
|
46690
|
-
super(board, name,
|
|
46708
|
+
constructor(board, name, item, settings) {
|
|
46709
|
+
super(board, name, item);
|
|
46691
46710
|
this.settings = settings;
|
|
46692
46711
|
this.setCursor();
|
|
46693
46712
|
}
|
|
@@ -46993,7 +47012,7 @@ class Tools extends ToolContext {
|
|
|
46993
47012
|
this.subject.publish(this);
|
|
46994
47013
|
}
|
|
46995
47014
|
sortFrames() {
|
|
46996
|
-
const frames = this.board.items.listAll().filter((
|
|
47015
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame2);
|
|
46997
47016
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
46998
47017
|
const mbr1 = fr1.getMbr();
|
|
46999
47018
|
const mbr2 = fr2.getMbr();
|
|
@@ -47219,24 +47238,24 @@ function validateGroupData(groupData) {
|
|
|
47219
47238
|
}
|
|
47220
47239
|
// src/Items/RegisterItem.ts
|
|
47221
47240
|
function registerItem({
|
|
47222
|
-
item
|
|
47241
|
+
item,
|
|
47223
47242
|
defaultData: defaultData2,
|
|
47224
47243
|
toolData
|
|
47225
47244
|
}) {
|
|
47226
47245
|
const { itemType } = defaultData2;
|
|
47227
|
-
itemFactories[itemType] = createItemFactory(
|
|
47246
|
+
itemFactories[itemType] = createItemFactory(item, defaultData2);
|
|
47228
47247
|
itemValidators[itemType] = createItemValidator(defaultData2);
|
|
47229
47248
|
if (toolData) {
|
|
47230
47249
|
registeredTools[toolData.name] = toolData.tool;
|
|
47231
47250
|
}
|
|
47232
47251
|
itemCommandFactories[itemType] = createItemCommandFactory(itemType);
|
|
47233
47252
|
}
|
|
47234
|
-
function createItemFactory(
|
|
47253
|
+
function createItemFactory(item, defaultData2) {
|
|
47235
47254
|
return function itemFactory(id, data, board) {
|
|
47236
47255
|
if (data.itemType !== defaultData2.itemType) {
|
|
47237
47256
|
throw new Error(`Invalid data for ${defaultData2.itemType}`);
|
|
47238
47257
|
}
|
|
47239
|
-
return new
|
|
47258
|
+
return new item(board, id, defaultData2).setId(id).deserialize(data);
|
|
47240
47259
|
};
|
|
47241
47260
|
}
|
|
47242
47261
|
function createItemValidator(defaultData2) {
|
|
@@ -47251,7 +47270,7 @@ function createItemValidator(defaultData2) {
|
|
|
47251
47270
|
}
|
|
47252
47271
|
function createItemCommandFactory(itemType) {
|
|
47253
47272
|
return function itemCommandFactory(items, operation) {
|
|
47254
|
-
return new BaseCommand(items.filter((
|
|
47273
|
+
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47255
47274
|
};
|
|
47256
47275
|
}
|
|
47257
47276
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -48276,8 +48295,8 @@ class Camera {
|
|
|
48276
48295
|
this.observableItem = null;
|
|
48277
48296
|
}
|
|
48278
48297
|
}
|
|
48279
|
-
subscribeToItem(
|
|
48280
|
-
this.observableItem =
|
|
48298
|
+
subscribeToItem(item) {
|
|
48299
|
+
this.observableItem = item;
|
|
48281
48300
|
this.observableItem.subject.subscribe(this.observeItem);
|
|
48282
48301
|
}
|
|
48283
48302
|
observeItem = () => {
|
|
@@ -48503,7 +48522,7 @@ class Camera {
|
|
|
48503
48522
|
}
|
|
48504
48523
|
addToView(mbr, inView) {
|
|
48505
48524
|
if (!mbr.isEnclosedBy(this.getMbr())) {
|
|
48506
|
-
this.viewRectangle(inView.reduce((acc,
|
|
48525
|
+
this.viewRectangle(inView.reduce((acc, item) => acc.combine(item.getMbr()), inView[0]?.getMbr() ?? new Mbr).combine(mbr));
|
|
48507
48526
|
}
|
|
48508
48527
|
}
|
|
48509
48528
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
@@ -50112,8 +50131,8 @@ class Presence {
|
|
|
50112
50131
|
<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}"/>
|
|
50113
50132
|
</svg>`;
|
|
50114
50133
|
}
|
|
50115
|
-
renderItemMbr(context,
|
|
50116
|
-
const mbr =
|
|
50134
|
+
renderItemMbr(context, item, color2, customScale) {
|
|
50135
|
+
const mbr = item.getMbr();
|
|
50117
50136
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
50118
50137
|
mbr.borderColor = color2;
|
|
50119
50138
|
mbr.render(context);
|
|
@@ -50253,8 +50272,8 @@ class Presence {
|
|
|
50253
50272
|
selectionMbr.strokeWidth = 1 / context.matrix.scaleX;
|
|
50254
50273
|
selectionMbr.borderColor = selection.color;
|
|
50255
50274
|
selectionMbr.render(context);
|
|
50256
|
-
for (const
|
|
50257
|
-
this.renderItemMbr(context,
|
|
50275
|
+
for (const item of selection.selection) {
|
|
50276
|
+
this.renderItemMbr(context, item, selection.color);
|
|
50258
50277
|
}
|
|
50259
50278
|
}
|
|
50260
50279
|
}
|
|
@@ -50287,14 +50306,14 @@ class SelectionItems {
|
|
|
50287
50306
|
items = new Map;
|
|
50288
50307
|
add(value) {
|
|
50289
50308
|
if (Array.isArray(value)) {
|
|
50290
|
-
value.forEach((
|
|
50309
|
+
value.forEach((item) => this.items.set(item.getId(), item));
|
|
50291
50310
|
} else {
|
|
50292
50311
|
this.items.set(value.getId(), value);
|
|
50293
50312
|
}
|
|
50294
50313
|
}
|
|
50295
50314
|
remove(value) {
|
|
50296
50315
|
if (Array.isArray(value)) {
|
|
50297
|
-
value.forEach((
|
|
50316
|
+
value.forEach((item) => this.items.delete(item.getId()));
|
|
50298
50317
|
} else {
|
|
50299
50318
|
this.items.delete(value.getId());
|
|
50300
50319
|
}
|
|
@@ -50324,8 +50343,8 @@ class SelectionItems {
|
|
|
50324
50343
|
if (this.isEmpty()) {
|
|
50325
50344
|
return false;
|
|
50326
50345
|
}
|
|
50327
|
-
for (const
|
|
50328
|
-
if (
|
|
50346
|
+
for (const item of this.items.values()) {
|
|
50347
|
+
if (item.itemType !== "RichText") {
|
|
50329
50348
|
return false;
|
|
50330
50349
|
}
|
|
50331
50350
|
}
|
|
@@ -50335,14 +50354,14 @@ class SelectionItems {
|
|
|
50335
50354
|
if (this.isEmpty()) {
|
|
50336
50355
|
return false;
|
|
50337
50356
|
}
|
|
50338
|
-
return Array.from(this.items).every(([,
|
|
50357
|
+
return Array.from(this.items).every(([, item]) => item.itemType === itemType);
|
|
50339
50358
|
}
|
|
50340
50359
|
isItemTypes(itemTypes) {
|
|
50341
50360
|
if (this.isEmpty()) {
|
|
50342
50361
|
return false;
|
|
50343
50362
|
}
|
|
50344
|
-
for (const
|
|
50345
|
-
if (!itemTypes.includes(
|
|
50363
|
+
for (const item of this.items.values()) {
|
|
50364
|
+
if (!itemTypes.includes(item.itemType)) {
|
|
50346
50365
|
return false;
|
|
50347
50366
|
}
|
|
50348
50367
|
}
|
|
@@ -50350,16 +50369,16 @@ class SelectionItems {
|
|
|
50350
50369
|
}
|
|
50351
50370
|
getItemTypes() {
|
|
50352
50371
|
const itemTypes = new Set;
|
|
50353
|
-
this.items.forEach((
|
|
50372
|
+
this.items.forEach((item) => itemTypes.add(item.itemType));
|
|
50354
50373
|
return Array.from(itemTypes);
|
|
50355
50374
|
}
|
|
50356
50375
|
getItemsByItemTypes(itemTypes) {
|
|
50357
|
-
return Array.from(this.items.values()).filter((
|
|
50376
|
+
return Array.from(this.items.values()).filter((item) => itemTypes.includes(item.itemType));
|
|
50358
50377
|
}
|
|
50359
50378
|
getIdsByItemTypes(itemTypes) {
|
|
50360
50379
|
const ids = [];
|
|
50361
|
-
this.items.forEach((
|
|
50362
|
-
if (itemTypes.includes(
|
|
50380
|
+
this.items.forEach((item, id) => {
|
|
50381
|
+
if (itemTypes.includes(item.itemType)) {
|
|
50363
50382
|
ids.push(id);
|
|
50364
50383
|
}
|
|
50365
50384
|
});
|
|
@@ -50369,7 +50388,7 @@ class SelectionItems {
|
|
|
50369
50388
|
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
50370
50389
|
}
|
|
50371
50390
|
listByIds(itemIdList) {
|
|
50372
|
-
return itemIdList.map((id) => this.items.get(id)).filter((
|
|
50391
|
+
return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
|
|
50373
50392
|
}
|
|
50374
50393
|
ids() {
|
|
50375
50394
|
return Array.from(this.items.keys());
|
|
@@ -50380,7 +50399,7 @@ class SelectionItems {
|
|
|
50380
50399
|
return;
|
|
50381
50400
|
}
|
|
50382
50401
|
const mbr = items[0].getMbr();
|
|
50383
|
-
items.slice(1).forEach((
|
|
50402
|
+
items.slice(1).forEach((item) => mbr.combine(item.getMbr()));
|
|
50384
50403
|
return mbr;
|
|
50385
50404
|
}
|
|
50386
50405
|
}
|
|
@@ -50585,33 +50604,33 @@ function handleMultipleItemsResize({
|
|
|
50585
50604
|
const translation = {};
|
|
50586
50605
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
50587
50606
|
board.items.getComments().forEach((comment2) => {
|
|
50588
|
-
if (items.some((
|
|
50607
|
+
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
50589
50608
|
items.push(comment2);
|
|
50590
50609
|
}
|
|
50591
50610
|
});
|
|
50592
|
-
for (const
|
|
50593
|
-
let itemX =
|
|
50594
|
-
let itemY =
|
|
50595
|
-
if (
|
|
50596
|
-
itemX =
|
|
50597
|
-
itemY =
|
|
50611
|
+
for (const item of items) {
|
|
50612
|
+
let itemX = item.getMbr().left;
|
|
50613
|
+
let itemY = item.getMbr().top;
|
|
50614
|
+
if (item.itemType === "Drawing") {
|
|
50615
|
+
itemX = item.transformation.matrix.translateX;
|
|
50616
|
+
itemY = item.transformation.matrix.translateY;
|
|
50598
50617
|
}
|
|
50599
50618
|
const deltaX = itemX - initMbr.left;
|
|
50600
50619
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
50601
50620
|
const deltaY = itemY - initMbr.top;
|
|
50602
50621
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
50603
|
-
if (
|
|
50604
|
-
translation[
|
|
50605
|
-
item
|
|
50622
|
+
if (item instanceof RichText) {
|
|
50623
|
+
translation[item.getId()] = getRichTextTranslation({
|
|
50624
|
+
item,
|
|
50606
50625
|
isWidth,
|
|
50607
50626
|
isHeight,
|
|
50608
50627
|
matrix,
|
|
50609
50628
|
translateX,
|
|
50610
50629
|
translateY
|
|
50611
50630
|
});
|
|
50612
|
-
} else if (
|
|
50613
|
-
translation[
|
|
50614
|
-
item
|
|
50631
|
+
} else if (item instanceof AINode) {
|
|
50632
|
+
translation[item.getId()] = getAINodeTranslation({
|
|
50633
|
+
item,
|
|
50615
50634
|
isWidth,
|
|
50616
50635
|
isHeight,
|
|
50617
50636
|
matrix,
|
|
@@ -50619,8 +50638,8 @@ function handleMultipleItemsResize({
|
|
|
50619
50638
|
translateY
|
|
50620
50639
|
});
|
|
50621
50640
|
} else {
|
|
50622
|
-
translation[
|
|
50623
|
-
item
|
|
50641
|
+
translation[item.getId()] = getItemTranslation({
|
|
50642
|
+
item,
|
|
50624
50643
|
isWidth,
|
|
50625
50644
|
isHeight,
|
|
50626
50645
|
matrix,
|
|
@@ -50633,7 +50652,7 @@ function handleMultipleItemsResize({
|
|
|
50633
50652
|
return translation;
|
|
50634
50653
|
}
|
|
50635
50654
|
function getRichTextTranslation({
|
|
50636
|
-
item
|
|
50655
|
+
item,
|
|
50637
50656
|
isWidth,
|
|
50638
50657
|
isHeight,
|
|
50639
50658
|
matrix,
|
|
@@ -50641,11 +50660,11 @@ function getRichTextTranslation({
|
|
|
50641
50660
|
translateY
|
|
50642
50661
|
}) {
|
|
50643
50662
|
if (isWidth) {
|
|
50644
|
-
|
|
50663
|
+
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
50645
50664
|
return {
|
|
50646
50665
|
class: "Transformation",
|
|
50647
50666
|
method: "scaleByTranslateBy",
|
|
50648
|
-
item: [
|
|
50667
|
+
item: [item.getId()],
|
|
50649
50668
|
translate: { x: matrix.translateX, y: 0 },
|
|
50650
50669
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50651
50670
|
};
|
|
@@ -50653,7 +50672,7 @@ function getRichTextTranslation({
|
|
|
50653
50672
|
return {
|
|
50654
50673
|
class: "Transformation",
|
|
50655
50674
|
method: "scaleByTranslateBy",
|
|
50656
|
-
item: [
|
|
50675
|
+
item: [item.getId()],
|
|
50657
50676
|
translate: { x: translateX, y: translateY },
|
|
50658
50677
|
scale: { x: 1, y: 1 }
|
|
50659
50678
|
};
|
|
@@ -50661,14 +50680,14 @@ function getRichTextTranslation({
|
|
|
50661
50680
|
return {
|
|
50662
50681
|
class: "Transformation",
|
|
50663
50682
|
method: "scaleByTranslateBy",
|
|
50664
|
-
item: [
|
|
50683
|
+
item: [item.getId()],
|
|
50665
50684
|
translate: { x: translateX, y: translateY },
|
|
50666
50685
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50667
50686
|
};
|
|
50668
50687
|
}
|
|
50669
50688
|
}
|
|
50670
50689
|
function getAINodeTranslation({
|
|
50671
|
-
item
|
|
50690
|
+
item,
|
|
50672
50691
|
isWidth,
|
|
50673
50692
|
isHeight,
|
|
50674
50693
|
matrix,
|
|
@@ -50676,11 +50695,11 @@ function getAINodeTranslation({
|
|
|
50676
50695
|
translateY
|
|
50677
50696
|
}) {
|
|
50678
50697
|
if (isWidth) {
|
|
50679
|
-
|
|
50698
|
+
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
50680
50699
|
return {
|
|
50681
50700
|
class: "Transformation",
|
|
50682
50701
|
method: "scaleByTranslateBy",
|
|
50683
|
-
item: [
|
|
50702
|
+
item: [item.getId()],
|
|
50684
50703
|
translate: { x: matrix.translateX, y: 0 },
|
|
50685
50704
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50686
50705
|
};
|
|
@@ -50688,7 +50707,7 @@ function getAINodeTranslation({
|
|
|
50688
50707
|
return {
|
|
50689
50708
|
class: "Transformation",
|
|
50690
50709
|
method: "scaleByTranslateBy",
|
|
50691
|
-
item: [
|
|
50710
|
+
item: [item.getId()],
|
|
50692
50711
|
translate: { x: translateX, y: translateY },
|
|
50693
50712
|
scale: { x: 1, y: 1 }
|
|
50694
50713
|
};
|
|
@@ -50696,14 +50715,14 @@ function getAINodeTranslation({
|
|
|
50696
50715
|
return {
|
|
50697
50716
|
class: "Transformation",
|
|
50698
50717
|
method: "scaleByTranslateBy",
|
|
50699
|
-
item: [
|
|
50718
|
+
item: [item.getId()],
|
|
50700
50719
|
translate: { x: translateX, y: translateY },
|
|
50701
50720
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
50702
50721
|
};
|
|
50703
50722
|
}
|
|
50704
50723
|
}
|
|
50705
50724
|
function getItemTranslation({
|
|
50706
|
-
item
|
|
50725
|
+
item,
|
|
50707
50726
|
isWidth,
|
|
50708
50727
|
isHeight,
|
|
50709
50728
|
matrix,
|
|
@@ -50711,22 +50730,22 @@ function getItemTranslation({
|
|
|
50711
50730
|
translateY,
|
|
50712
50731
|
isShiftPressed
|
|
50713
50732
|
}) {
|
|
50714
|
-
if (
|
|
50733
|
+
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
50715
50734
|
return {
|
|
50716
50735
|
class: "Transformation",
|
|
50717
50736
|
method: "scaleByTranslateBy",
|
|
50718
|
-
item: [
|
|
50737
|
+
item: [item.getId()],
|
|
50719
50738
|
translate: { x: translateX, y: translateY },
|
|
50720
50739
|
scale: { x: 1, y: 1 }
|
|
50721
50740
|
};
|
|
50722
50741
|
} else {
|
|
50723
|
-
if (
|
|
50724
|
-
|
|
50742
|
+
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
50743
|
+
item.setFrameType("Custom");
|
|
50725
50744
|
}
|
|
50726
50745
|
return {
|
|
50727
50746
|
class: "Transformation",
|
|
50728
50747
|
method: "scaleByTranslateBy",
|
|
50729
|
-
item: [
|
|
50748
|
+
item: [item.getId()],
|
|
50730
50749
|
translate: { x: translateX, y: translateY },
|
|
50731
50750
|
scale: { x: matrix.scaleX, y: matrix.scaleY }
|
|
50732
50751
|
};
|
|
@@ -50999,11 +51018,11 @@ function transformItems({
|
|
|
50999
51018
|
setSnapCursorPos
|
|
51000
51019
|
}) {
|
|
51001
51020
|
const items = selection.items.list();
|
|
51002
|
-
const includesProportionalItem = items.some((
|
|
51021
|
+
const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
|
|
51003
51022
|
if (includesProportionalItem && (isWidth || isHeight)) {
|
|
51004
51023
|
return null;
|
|
51005
51024
|
}
|
|
51006
|
-
const isIncludesFixedFrame = items.some((
|
|
51025
|
+
const isIncludesFixedFrame = items.some((item) => item instanceof Frame2 && !item.getCanChangeRatio());
|
|
51007
51026
|
const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
|
|
51008
51027
|
const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
|
|
51009
51028
|
if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
|
|
@@ -51081,23 +51100,23 @@ function updateFrameChildren({
|
|
|
51081
51100
|
nestingHighlighter
|
|
51082
51101
|
}) {
|
|
51083
51102
|
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
51084
|
-
board.selection.items.list().forEach((
|
|
51085
|
-
if ("getChildrenIds" in
|
|
51086
|
-
const currMbr =
|
|
51103
|
+
board.selection.items.list().forEach((item) => {
|
|
51104
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
51105
|
+
const currMbr = item.getMbr();
|
|
51087
51106
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
51088
51107
|
itemsToCheck.forEach((currItem) => {
|
|
51089
|
-
if (
|
|
51090
|
-
nestingHighlighter.add(
|
|
51108
|
+
if (item.handleNesting(currItem) && (currItem.parent === "Board" || currItem.parent === item.getId())) {
|
|
51109
|
+
nestingHighlighter.add(item, currItem);
|
|
51091
51110
|
} else {
|
|
51092
51111
|
nestingHighlighter.remove(currItem);
|
|
51093
51112
|
}
|
|
51094
51113
|
});
|
|
51095
51114
|
} else {
|
|
51096
51115
|
groups.forEach((group) => {
|
|
51097
|
-
if (group.handleNesting(
|
|
51098
|
-
nestingHighlighter.add(group,
|
|
51116
|
+
if (group.handleNesting(item)) {
|
|
51117
|
+
nestingHighlighter.add(group, item);
|
|
51099
51118
|
} else {
|
|
51100
|
-
nestingHighlighter.remove(
|
|
51119
|
+
nestingHighlighter.remove(item);
|
|
51101
51120
|
}
|
|
51102
51121
|
});
|
|
51103
51122
|
}
|
|
@@ -51165,9 +51184,9 @@ class Transformer extends Tool {
|
|
|
51165
51184
|
const pointer = this.board.pointer;
|
|
51166
51185
|
const camera = this.board.camera;
|
|
51167
51186
|
const items = this.selection.items;
|
|
51168
|
-
const
|
|
51187
|
+
const item = items.getSingle();
|
|
51169
51188
|
let resizeType;
|
|
51170
|
-
if (
|
|
51189
|
+
if (item && (item.itemType === "RichText" || item.itemType === "Sticker")) {
|
|
51171
51190
|
resizeType = getTextResizeType(pointer.point, camera.getScale(), mbr);
|
|
51172
51191
|
} else {
|
|
51173
51192
|
resizeType = getResizeType(pointer.point, camera.getScale(), mbr);
|
|
@@ -51421,8 +51440,8 @@ class SelectionTransformer extends Tool {
|
|
|
51421
51440
|
return;
|
|
51422
51441
|
}
|
|
51423
51442
|
if (this.selection.items.isSingle()) {
|
|
51424
|
-
const
|
|
51425
|
-
if (
|
|
51443
|
+
const item = this.selection.items.getSingle();
|
|
51444
|
+
if (item?.itemType === "Connector") {
|
|
51426
51445
|
this.tool = this.connectorTransformerTool;
|
|
51427
51446
|
return;
|
|
51428
51447
|
} else {
|
|
@@ -51505,16 +51524,16 @@ class BoardSelection {
|
|
|
51505
51524
|
this.quickAddButtons = getQuickAddButtons(this, board);
|
|
51506
51525
|
}
|
|
51507
51526
|
serialize() {
|
|
51508
|
-
const selectedItems = this.items.list().map((
|
|
51527
|
+
const selectedItems = this.items.list().map((item) => item.getId());
|
|
51509
51528
|
return JSON.stringify(selectedItems);
|
|
51510
51529
|
}
|
|
51511
51530
|
deserialize(serializedData) {
|
|
51512
51531
|
const selectedItems = JSON.parse(serializedData);
|
|
51513
51532
|
this.removeAll();
|
|
51514
51533
|
selectedItems.forEach((itemId) => {
|
|
51515
|
-
const
|
|
51516
|
-
if (
|
|
51517
|
-
this.items.add(
|
|
51534
|
+
const item = this.board.items.getById(itemId);
|
|
51535
|
+
if (item) {
|
|
51536
|
+
this.items.add(item);
|
|
51518
51537
|
}
|
|
51519
51538
|
});
|
|
51520
51539
|
}
|
|
@@ -51592,19 +51611,19 @@ class BoardSelection {
|
|
|
51592
51611
|
this.updateQueue.clear();
|
|
51593
51612
|
safeRequestAnimationFrame(this.updateScheduledObservers);
|
|
51594
51613
|
};
|
|
51595
|
-
itemObserver = (
|
|
51614
|
+
itemObserver = (item) => {
|
|
51596
51615
|
if (!this.shouldPublish) {
|
|
51597
51616
|
return;
|
|
51598
51617
|
}
|
|
51599
51618
|
this.subject.publish(this);
|
|
51600
|
-
this.itemSubject.publish(
|
|
51619
|
+
this.itemSubject.publish(item);
|
|
51601
51620
|
};
|
|
51602
51621
|
decoratedItemObserver = this.decorateObserverToScheduleUpdate(this.itemObserver);
|
|
51603
51622
|
add(value) {
|
|
51604
51623
|
this.items.add(value);
|
|
51605
51624
|
if (Array.isArray(value)) {
|
|
51606
|
-
for (const
|
|
51607
|
-
|
|
51625
|
+
for (const item of value) {
|
|
51626
|
+
item.subject.subscribe(this.itemObserver);
|
|
51608
51627
|
}
|
|
51609
51628
|
} else {
|
|
51610
51629
|
value.subject.subscribe(this.itemObserver);
|
|
@@ -51613,15 +51632,15 @@ class BoardSelection {
|
|
|
51613
51632
|
this.itemsSubject.publish([]);
|
|
51614
51633
|
}
|
|
51615
51634
|
addAll() {
|
|
51616
|
-
const items = this.board.items.listAll().filter((
|
|
51635
|
+
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
51617
51636
|
this.add(items);
|
|
51618
51637
|
this.setContext("SelectByRect");
|
|
51619
51638
|
}
|
|
51620
51639
|
remove(value) {
|
|
51621
51640
|
this.items.remove(value);
|
|
51622
51641
|
if (Array.isArray(value)) {
|
|
51623
|
-
for (const
|
|
51624
|
-
|
|
51642
|
+
for (const item of value) {
|
|
51643
|
+
item.subject.unsubscribe(this.itemObserver);
|
|
51625
51644
|
}
|
|
51626
51645
|
} else {
|
|
51627
51646
|
value.subject.unsubscribe(this.itemObserver);
|
|
@@ -51715,11 +51734,11 @@ class BoardSelection {
|
|
|
51715
51734
|
if (!this.items.isSingle()) {
|
|
51716
51735
|
return;
|
|
51717
51736
|
}
|
|
51718
|
-
const
|
|
51719
|
-
if (!
|
|
51737
|
+
const item = this.items.getSingle();
|
|
51738
|
+
if (!item) {
|
|
51720
51739
|
return;
|
|
51721
51740
|
}
|
|
51722
|
-
const text5 =
|
|
51741
|
+
const text5 = item.getRichText();
|
|
51723
51742
|
if (!text5) {
|
|
51724
51743
|
return;
|
|
51725
51744
|
}
|
|
@@ -51730,7 +51749,7 @@ class BoardSelection {
|
|
|
51730
51749
|
if (shouldReplace || moveCursorToEnd) {
|
|
51731
51750
|
text5.editor.moveCursorToEndOfTheText();
|
|
51732
51751
|
}
|
|
51733
|
-
this.setTextToEdit(
|
|
51752
|
+
this.setTextToEdit(item);
|
|
51734
51753
|
this.setContext("EditTextUnderPointer");
|
|
51735
51754
|
if (shouldSelect) {
|
|
51736
51755
|
text5.editor.selectWholeText();
|
|
@@ -51740,13 +51759,13 @@ class BoardSelection {
|
|
|
51740
51759
|
editUnderPointer() {
|
|
51741
51760
|
this.removeAll();
|
|
51742
51761
|
const stack = this.board.items.getUnderPointer();
|
|
51743
|
-
const
|
|
51744
|
-
if (
|
|
51745
|
-
this.add(
|
|
51762
|
+
const item = stack.pop();
|
|
51763
|
+
if (item) {
|
|
51764
|
+
this.add(item);
|
|
51746
51765
|
this.setTextToEdit(undefined);
|
|
51747
|
-
const text5 =
|
|
51766
|
+
const text5 = item.getRichText();
|
|
51748
51767
|
if (text5) {
|
|
51749
|
-
this.setTextToEdit(
|
|
51768
|
+
this.setTextToEdit(item);
|
|
51750
51769
|
text5.editor.selectWholeText();
|
|
51751
51770
|
this.board.items.subject.publish(this.board.items);
|
|
51752
51771
|
}
|
|
@@ -51755,26 +51774,26 @@ class BoardSelection {
|
|
|
51755
51774
|
this.setContext("None");
|
|
51756
51775
|
}
|
|
51757
51776
|
}
|
|
51758
|
-
setTextToEdit(
|
|
51777
|
+
setTextToEdit(item) {
|
|
51759
51778
|
if (this.textToEdit) {
|
|
51760
51779
|
this.textToEdit.updateElement();
|
|
51761
51780
|
this.textToEdit.enableRender();
|
|
51762
51781
|
}
|
|
51763
|
-
if (!(
|
|
51782
|
+
if (!(item && item.getRichText())) {
|
|
51764
51783
|
this.textToEdit = undefined;
|
|
51765
51784
|
return;
|
|
51766
51785
|
}
|
|
51767
|
-
const text5 =
|
|
51786
|
+
const text5 = item.getRichText();
|
|
51768
51787
|
if (!text5) {
|
|
51769
51788
|
return;
|
|
51770
51789
|
}
|
|
51771
51790
|
if (text5.isEmpty()) {
|
|
51772
|
-
const textColor = tempStorage.getFontColor(
|
|
51773
|
-
const textSize = tempStorage.getFontSize(
|
|
51774
|
-
const highlightColor = tempStorage.getFontHighlight(
|
|
51775
|
-
const styles = tempStorage.getFontStyles(
|
|
51776
|
-
const horizontalAlignment = tempStorage.getHorizontalAlignment(
|
|
51777
|
-
const verticalAlignment = tempStorage.getVerticalAlignment(
|
|
51791
|
+
const textColor = tempStorage.getFontColor(item.itemType);
|
|
51792
|
+
const textSize = tempStorage.getFontSize(item.itemType);
|
|
51793
|
+
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
51794
|
+
const styles = tempStorage.getFontStyles(item.itemType);
|
|
51795
|
+
const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
|
|
51796
|
+
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
51778
51797
|
if (textColor) {
|
|
51779
51798
|
text5.setSelectionFontColor(textColor, "None");
|
|
51780
51799
|
}
|
|
@@ -51782,7 +51801,7 @@ class BoardSelection {
|
|
|
51782
51801
|
this.emit({
|
|
51783
51802
|
class: "RichText",
|
|
51784
51803
|
method: "setFontSize",
|
|
51785
|
-
item: [
|
|
51804
|
+
item: [item.getId()],
|
|
51786
51805
|
fontSize: textSize,
|
|
51787
51806
|
context: this.getContext()
|
|
51788
51807
|
});
|
|
@@ -51794,10 +51813,10 @@ class BoardSelection {
|
|
|
51794
51813
|
const stylesArr = styles;
|
|
51795
51814
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
51796
51815
|
}
|
|
51797
|
-
if (horizontalAlignment && !(
|
|
51816
|
+
if (horizontalAlignment && !(item instanceof Sticker)) {
|
|
51798
51817
|
text5.setSelectionHorisontalAlignment(horizontalAlignment);
|
|
51799
51818
|
}
|
|
51800
|
-
if (verticalAlignment && !(
|
|
51819
|
+
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
51801
51820
|
this.setVerticalAlignment(verticalAlignment);
|
|
51802
51821
|
}
|
|
51803
51822
|
}
|
|
@@ -51830,8 +51849,8 @@ class BoardSelection {
|
|
|
51830
51849
|
}
|
|
51831
51850
|
selectEnclosedOrCrossedBy(rect) {
|
|
51832
51851
|
this.removeAll();
|
|
51833
|
-
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51834
|
-
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
51852
|
+
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => !item.transformation.isLocked);
|
|
51853
|
+
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);
|
|
51835
51854
|
if (list6.length !== 0) {
|
|
51836
51855
|
this.add(list6);
|
|
51837
51856
|
this.setContext("SelectByRect");
|
|
@@ -51845,14 +51864,14 @@ class BoardSelection {
|
|
|
51845
51864
|
canChangeText() {
|
|
51846
51865
|
return Boolean(this.items.isSingle() && this.items.getSingle()?.getRichText());
|
|
51847
51866
|
}
|
|
51848
|
-
handleItemCopy(
|
|
51849
|
-
const serializedData =
|
|
51850
|
-
const zIndex = this.board.items.index.getZIndex(
|
|
51851
|
-
if (
|
|
51867
|
+
handleItemCopy(item, copiedItemsMap) {
|
|
51868
|
+
const serializedData = item.serialize(true);
|
|
51869
|
+
const zIndex = this.board.items.index.getZIndex(item);
|
|
51870
|
+
if (item.itemType === "Comment") {
|
|
51852
51871
|
return;
|
|
51853
51872
|
}
|
|
51854
|
-
if (
|
|
51855
|
-
const connector =
|
|
51873
|
+
if (item.itemType === "Connector" && serializedData.itemType === "Connector") {
|
|
51874
|
+
const connector = item;
|
|
51856
51875
|
const startPoint = connector.getStartPoint();
|
|
51857
51876
|
const endPoint = connector.getEndPoint();
|
|
51858
51877
|
const startItemId = startPoint.pointType !== "Board" ? startPoint.item.getId() : null;
|
|
@@ -51868,19 +51887,19 @@ class BoardSelection {
|
|
|
51868
51887
|
serializedData.endPoint = new BoardPoint(endPoint.x, endPoint.y).serialize();
|
|
51869
51888
|
}
|
|
51870
51889
|
}
|
|
51871
|
-
const textItem =
|
|
51890
|
+
const textItem = item.getRichText()?.getTextString();
|
|
51872
51891
|
const copyText = conf.i18n.t("frame.copy");
|
|
51873
51892
|
const isCopyTextExist = textItem?.includes(copyText);
|
|
51874
|
-
const isChangeCopiedFrameText =
|
|
51893
|
+
const isChangeCopiedFrameText = item.itemType === "Frame" && serializedData.itemType === "Frame" && textItem !== "" && !isCopyTextExist;
|
|
51875
51894
|
if (isChangeCopiedFrameText) {
|
|
51876
51895
|
const copiedFrameText = copyText + (textItem || serializedData.text?.placeholderText);
|
|
51877
|
-
|
|
51878
|
-
|
|
51879
|
-
serializedData.text =
|
|
51880
|
-
|
|
51881
|
-
|
|
51896
|
+
item.getRichText()?.editor.clearText();
|
|
51897
|
+
item.getRichText()?.editor.addText(copiedFrameText);
|
|
51898
|
+
serializedData.text = item.getRichText()?.serialize();
|
|
51899
|
+
item.getRichText()?.editor.clearText();
|
|
51900
|
+
item.getRichText()?.editor.addText(textItem || "");
|
|
51882
51901
|
}
|
|
51883
|
-
copiedItemsMap[
|
|
51902
|
+
copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
|
|
51884
51903
|
}
|
|
51885
51904
|
copy(skipImageBlobCopy) {
|
|
51886
51905
|
const copiedItemsMap = {};
|
|
@@ -51889,12 +51908,12 @@ class BoardSelection {
|
|
|
51889
51908
|
this.handleItemCopy(single, copiedItemsMap);
|
|
51890
51909
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
51891
51910
|
}
|
|
51892
|
-
this.list().forEach((
|
|
51893
|
-
this.handleItemCopy(
|
|
51911
|
+
this.list().forEach((item) => {
|
|
51912
|
+
this.handleItemCopy(item, copiedItemsMap);
|
|
51894
51913
|
});
|
|
51895
|
-
this.list().flatMap((
|
|
51896
|
-
if (
|
|
51897
|
-
return
|
|
51914
|
+
this.list().flatMap((item) => {
|
|
51915
|
+
if (item instanceof Frame2) {
|
|
51916
|
+
return item.getChildrenIds();
|
|
51898
51917
|
}
|
|
51899
51918
|
return [];
|
|
51900
51919
|
}).forEach((id) => {
|
|
@@ -51922,11 +51941,11 @@ class BoardSelection {
|
|
|
51922
51941
|
let maxRichText = null;
|
|
51923
51942
|
let minRichText = null;
|
|
51924
51943
|
const itemType = items[0].itemType;
|
|
51925
|
-
for (const
|
|
51926
|
-
if (
|
|
51944
|
+
for (const item of items) {
|
|
51945
|
+
if (item.itemType !== itemType) {
|
|
51927
51946
|
return null;
|
|
51928
51947
|
}
|
|
51929
|
-
const richText =
|
|
51948
|
+
const richText = item.getRichText();
|
|
51930
51949
|
if (richText) {
|
|
51931
51950
|
if (!maxRichText || richText.getFontSize() > maxRichText.getFontSize()) {
|
|
51932
51951
|
maxRichText = richText;
|
|
@@ -52032,22 +52051,22 @@ class BoardSelection {
|
|
|
52032
52051
|
}
|
|
52033
52052
|
nestSelectedItems(unselectedItem, checkFrames = true) {
|
|
52034
52053
|
const selected = this.board.selection.items.list();
|
|
52035
|
-
if (unselectedItem && !selected.find((
|
|
52054
|
+
if (unselectedItem && !selected.find((item) => item.getId() === unselectedItem.getId())) {
|
|
52036
52055
|
selected.push(unselectedItem);
|
|
52037
52056
|
}
|
|
52038
|
-
const selectedMbr = selected.reduce((acc,
|
|
52057
|
+
const selectedMbr = selected.reduce((acc, item) => {
|
|
52039
52058
|
if (!acc) {
|
|
52040
|
-
return
|
|
52059
|
+
return item.getMbr();
|
|
52041
52060
|
}
|
|
52042
|
-
return acc.combine(
|
|
52061
|
+
return acc.combine(item.getMbr());
|
|
52043
52062
|
}, undefined);
|
|
52044
52063
|
if (selectedMbr) {
|
|
52045
|
-
const selectedMap = Object.fromEntries(selected.map((
|
|
52064
|
+
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
52046
52065
|
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
52047
52066
|
enclosedGroups.forEach((group) => {
|
|
52048
|
-
selected.forEach((
|
|
52049
|
-
if (group.handleNesting(
|
|
52050
|
-
selectedMap[
|
|
52067
|
+
selected.forEach((item) => {
|
|
52068
|
+
if (group.handleNesting(item)) {
|
|
52069
|
+
selectedMap[item.getId()].nested = group;
|
|
52051
52070
|
}
|
|
52052
52071
|
});
|
|
52053
52072
|
});
|
|
@@ -52071,11 +52090,11 @@ class BoardSelection {
|
|
|
52071
52090
|
if (childrenIds && checkFrames) {
|
|
52072
52091
|
const currGroup = val.item;
|
|
52073
52092
|
const currMbr = currGroup.getMbr();
|
|
52074
|
-
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((
|
|
52075
|
-
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
52093
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
52094
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
52076
52095
|
const uniqueItems = new Set;
|
|
52077
|
-
const toCheck = [...children, ...underGroup].filter((
|
|
52078
|
-
const id =
|
|
52096
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
52097
|
+
const id = item.getId();
|
|
52079
52098
|
if (uniqueItems.has(id)) {
|
|
52080
52099
|
return false;
|
|
52081
52100
|
}
|
|
@@ -52116,8 +52135,8 @@ class BoardSelection {
|
|
|
52116
52135
|
addItemToTranslation(childId);
|
|
52117
52136
|
}
|
|
52118
52137
|
}
|
|
52119
|
-
const createTranslationWithComments = (
|
|
52120
|
-
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() ===
|
|
52138
|
+
const createTranslationWithComments = (item) => {
|
|
52139
|
+
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
52121
52140
|
for (const comment2 of followedComments) {
|
|
52122
52141
|
translation[comment2.getId()] = {
|
|
52123
52142
|
class: "Transformation",
|
|
@@ -52178,21 +52197,21 @@ class BoardSelection {
|
|
|
52178
52197
|
newData: { borderColor }
|
|
52179
52198
|
};
|
|
52180
52199
|
const operations2 = {};
|
|
52181
|
-
this.items.list().forEach((
|
|
52182
|
-
if (!operations2[
|
|
52200
|
+
this.items.list().forEach((item) => {
|
|
52201
|
+
if (!operations2[item.itemType]) {
|
|
52183
52202
|
const operationCopy = { ...operation };
|
|
52184
|
-
if (
|
|
52203
|
+
if (item.itemType === "Connector") {
|
|
52185
52204
|
operationCopy.method = "setLineColor";
|
|
52186
52205
|
operationCopy.lineColor = borderColor;
|
|
52187
|
-
} else if (
|
|
52206
|
+
} else if (item.itemType === "Drawing") {
|
|
52188
52207
|
operationCopy.method = "setStrokeColor";
|
|
52189
52208
|
operationCopy.color = borderColor;
|
|
52190
52209
|
} else {
|
|
52191
52210
|
operationCopy.borderColor = borderColor;
|
|
52192
52211
|
}
|
|
52193
|
-
operations2[
|
|
52212
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52194
52213
|
} else {
|
|
52195
|
-
operations2[
|
|
52214
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52196
52215
|
}
|
|
52197
52216
|
});
|
|
52198
52217
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52207,13 +52226,13 @@ class BoardSelection {
|
|
|
52207
52226
|
newData: { borderWidth: width2 }
|
|
52208
52227
|
};
|
|
52209
52228
|
const operations2 = {};
|
|
52210
|
-
this.items.list().forEach((
|
|
52211
|
-
if (!operations2[
|
|
52229
|
+
this.items.list().forEach((item) => {
|
|
52230
|
+
if (!operations2[item.itemType]) {
|
|
52212
52231
|
const operationCopy = { ...operation };
|
|
52213
|
-
if (
|
|
52232
|
+
if (item.itemType === "Connector") {
|
|
52214
52233
|
operationCopy.method = "setLineWidth";
|
|
52215
52234
|
operationCopy.lineWidth = width2;
|
|
52216
|
-
} else if (
|
|
52235
|
+
} else if (item.itemType === "Drawing") {
|
|
52217
52236
|
operationCopy.method = "setStrokeWidth";
|
|
52218
52237
|
operationCopy.width = width2;
|
|
52219
52238
|
operationCopy.prevWidth = this.getStrokeWidth();
|
|
@@ -52221,9 +52240,9 @@ class BoardSelection {
|
|
|
52221
52240
|
operationCopy.borderWidth = width2;
|
|
52222
52241
|
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
52223
52242
|
}
|
|
52224
|
-
operations2[
|
|
52243
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52225
52244
|
} else {
|
|
52226
|
-
operations2[
|
|
52245
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52227
52246
|
}
|
|
52228
52247
|
});
|
|
52229
52248
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52239,11 +52258,11 @@ class BoardSelection {
|
|
|
52239
52258
|
newData: { backgroundColor }
|
|
52240
52259
|
};
|
|
52241
52260
|
const operations2 = {};
|
|
52242
|
-
this.items.list().forEach((
|
|
52243
|
-
if (!operations2[
|
|
52244
|
-
operations2[
|
|
52261
|
+
this.items.list().forEach((item) => {
|
|
52262
|
+
if (!operations2[item.itemType]) {
|
|
52263
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
52245
52264
|
} else {
|
|
52246
|
-
operations2[
|
|
52265
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52247
52266
|
}
|
|
52248
52267
|
});
|
|
52249
52268
|
Object.values(operations2).forEach((op) => {
|
|
@@ -52267,9 +52286,9 @@ class BoardSelection {
|
|
|
52267
52286
|
}
|
|
52268
52287
|
setFrameType(frameType) {
|
|
52269
52288
|
const items = this.items.list();
|
|
52270
|
-
items.forEach((
|
|
52271
|
-
if (
|
|
52272
|
-
|
|
52289
|
+
items.forEach((item) => {
|
|
52290
|
+
if (item instanceof Frame2) {
|
|
52291
|
+
item.setFrameType(frameType);
|
|
52273
52292
|
}
|
|
52274
52293
|
});
|
|
52275
52294
|
}
|
|
@@ -52288,21 +52307,21 @@ class BoardSelection {
|
|
|
52288
52307
|
setFontSize(size) {
|
|
52289
52308
|
const fontSize = size === "auto" ? size : toFiniteNumber(size);
|
|
52290
52309
|
const itemsOps = [];
|
|
52291
|
-
for (const
|
|
52292
|
-
const text5 =
|
|
52310
|
+
for (const item of this.items.list()) {
|
|
52311
|
+
const text5 = item.getRichText();
|
|
52293
52312
|
if (!text5) {
|
|
52294
52313
|
continue;
|
|
52295
52314
|
}
|
|
52296
52315
|
const ops = text5.setSelectionFontSize(fontSize, this.context);
|
|
52297
52316
|
itemsOps.push({
|
|
52298
|
-
item:
|
|
52317
|
+
item: item.getId(),
|
|
52299
52318
|
selection: text5.editor.getSelection(),
|
|
52300
52319
|
ops
|
|
52301
52320
|
});
|
|
52302
|
-
if (
|
|
52303
|
-
tempStorage.remove(`fontSize_${
|
|
52304
|
-
} else if (
|
|
52305
|
-
tempStorage.setFontSize(
|
|
52321
|
+
if (item.itemType === "Sticker" && fontSize === "auto") {
|
|
52322
|
+
tempStorage.remove(`fontSize_${item.itemType}`);
|
|
52323
|
+
} else if (item.itemType !== "AINode") {
|
|
52324
|
+
tempStorage.setFontSize(item.itemType, fontSize);
|
|
52306
52325
|
}
|
|
52307
52326
|
}
|
|
52308
52327
|
const emptyOps = itemsOps.filter((op) => !op.ops.length);
|
|
@@ -52325,8 +52344,8 @@ class BoardSelection {
|
|
|
52325
52344
|
setFontStyle(fontStyle) {
|
|
52326
52345
|
const isMultiple = !this.items.isSingle();
|
|
52327
52346
|
const itemsOps = [];
|
|
52328
|
-
for (const
|
|
52329
|
-
const text5 =
|
|
52347
|
+
for (const item of this.items.list()) {
|
|
52348
|
+
const text5 = item.getRichText();
|
|
52330
52349
|
if (!text5) {
|
|
52331
52350
|
continue;
|
|
52332
52351
|
}
|
|
@@ -52335,12 +52354,12 @@ class BoardSelection {
|
|
|
52335
52354
|
}
|
|
52336
52355
|
const ops = text5.setSelectionFontStyle(fontStyle, this.context);
|
|
52337
52356
|
itemsOps.push({
|
|
52338
|
-
item:
|
|
52357
|
+
item: item.getId(),
|
|
52339
52358
|
selection: text5.editor.getSelection(),
|
|
52340
52359
|
ops
|
|
52341
52360
|
});
|
|
52342
|
-
if (
|
|
52343
|
-
tempStorage.setFontStyles(
|
|
52361
|
+
if (item.itemType !== "AINode") {
|
|
52362
|
+
tempStorage.setFontStyles(item.itemType, text5.getFontStyles());
|
|
52344
52363
|
}
|
|
52345
52364
|
}
|
|
52346
52365
|
this.emitApplied({
|
|
@@ -52352,8 +52371,8 @@ class BoardSelection {
|
|
|
52352
52371
|
setFontColor(fontColor) {
|
|
52353
52372
|
const isMultiple = !this.items.isSingle();
|
|
52354
52373
|
const itemsOps = [];
|
|
52355
|
-
for (const
|
|
52356
|
-
const text5 =
|
|
52374
|
+
for (const item of this.items.list()) {
|
|
52375
|
+
const text5 = item.getRichText();
|
|
52357
52376
|
if (!text5) {
|
|
52358
52377
|
continue;
|
|
52359
52378
|
}
|
|
@@ -52362,11 +52381,11 @@ class BoardSelection {
|
|
|
52362
52381
|
}
|
|
52363
52382
|
const ops = text5.setSelectionFontColor(fontColor, this.context);
|
|
52364
52383
|
itemsOps.push({
|
|
52365
|
-
item:
|
|
52384
|
+
item: item.getId(),
|
|
52366
52385
|
selection: text5.editor.getSelection(),
|
|
52367
52386
|
ops
|
|
52368
52387
|
});
|
|
52369
|
-
tempStorage.setFontColor(
|
|
52388
|
+
tempStorage.setFontColor(item.itemType, fontColor);
|
|
52370
52389
|
}
|
|
52371
52390
|
this.emitApplied({
|
|
52372
52391
|
class: "RichText",
|
|
@@ -52395,8 +52414,8 @@ class BoardSelection {
|
|
|
52395
52414
|
setFontHighlight(fontHighlight) {
|
|
52396
52415
|
const isMultiple = !this.items.isSingle();
|
|
52397
52416
|
const itemsOps = [];
|
|
52398
|
-
for (const
|
|
52399
|
-
const text5 =
|
|
52417
|
+
for (const item of this.items.list()) {
|
|
52418
|
+
const text5 = item.getRichText();
|
|
52400
52419
|
if (!text5) {
|
|
52401
52420
|
continue;
|
|
52402
52421
|
}
|
|
@@ -52405,12 +52424,12 @@ class BoardSelection {
|
|
|
52405
52424
|
}
|
|
52406
52425
|
const ops = text5.setSelectionFontHighlight(fontHighlight, this.context);
|
|
52407
52426
|
itemsOps.push({
|
|
52408
|
-
item:
|
|
52427
|
+
item: item.getId(),
|
|
52409
52428
|
selection: text5.editor.getSelection(),
|
|
52410
52429
|
ops
|
|
52411
52430
|
});
|
|
52412
|
-
if (
|
|
52413
|
-
tempStorage.setFontHighlight(
|
|
52431
|
+
if (item.itemType !== "AINode") {
|
|
52432
|
+
tempStorage.setFontHighlight(item.itemType, fontHighlight);
|
|
52414
52433
|
}
|
|
52415
52434
|
}
|
|
52416
52435
|
this.emitApplied({
|
|
@@ -52422,8 +52441,8 @@ class BoardSelection {
|
|
|
52422
52441
|
setHorisontalAlignment(horisontalAlignment) {
|
|
52423
52442
|
const isMultiple = !this.items.isSingle();
|
|
52424
52443
|
const itemsOps = [];
|
|
52425
|
-
for (const
|
|
52426
|
-
const text5 =
|
|
52444
|
+
for (const item of this.items.list()) {
|
|
52445
|
+
const text5 = item.getRichText();
|
|
52427
52446
|
if (!text5) {
|
|
52428
52447
|
continue;
|
|
52429
52448
|
}
|
|
@@ -52432,11 +52451,11 @@ class BoardSelection {
|
|
|
52432
52451
|
}
|
|
52433
52452
|
const ops = text5.setSelectionHorisontalAlignment(horisontalAlignment, this.context);
|
|
52434
52453
|
itemsOps.push({
|
|
52435
|
-
item:
|
|
52454
|
+
item: item.getId(),
|
|
52436
52455
|
selection: text5.editor.getSelection(),
|
|
52437
52456
|
ops
|
|
52438
52457
|
});
|
|
52439
|
-
tempStorage.setHorizontalAlignment(
|
|
52458
|
+
tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
|
|
52440
52459
|
}
|
|
52441
52460
|
this.emitApplied({
|
|
52442
52461
|
class: "RichText",
|
|
@@ -52452,23 +52471,23 @@ class BoardSelection {
|
|
|
52452
52471
|
verticalAlignment
|
|
52453
52472
|
});
|
|
52454
52473
|
if (this.items.isSingle()) {
|
|
52455
|
-
const
|
|
52456
|
-
if (!
|
|
52474
|
+
const item = this.items.getSingle();
|
|
52475
|
+
if (!item) {
|
|
52457
52476
|
return;
|
|
52458
52477
|
}
|
|
52459
|
-
const text5 =
|
|
52478
|
+
const text5 = item.getRichText();
|
|
52460
52479
|
if (!text5) {
|
|
52461
52480
|
return;
|
|
52462
52481
|
}
|
|
52463
|
-
tempStorage.setVerticalAlignment(
|
|
52464
|
-
if (
|
|
52465
|
-
|
|
52482
|
+
tempStorage.setVerticalAlignment(item.itemType, verticalAlignment);
|
|
52483
|
+
if (item instanceof RichText) {
|
|
52484
|
+
item.setEditorFocus(this.context);
|
|
52466
52485
|
}
|
|
52467
52486
|
text5.setEditorFocus(this.context);
|
|
52468
52487
|
}
|
|
52469
52488
|
}
|
|
52470
52489
|
removeFromBoard() {
|
|
52471
|
-
const isLocked = this.items.list().some((
|
|
52490
|
+
const isLocked = this.items.list().some((item) => item.transformation.isLocked);
|
|
52472
52491
|
if (isLocked) {
|
|
52473
52492
|
return;
|
|
52474
52493
|
}
|
|
@@ -52491,7 +52510,7 @@ class BoardSelection {
|
|
|
52491
52510
|
}
|
|
52492
52511
|
getIsLockedSelection() {
|
|
52493
52512
|
const items = this.list();
|
|
52494
|
-
return items.some((
|
|
52513
|
+
return items.some((item) => item.transformation.isLocked);
|
|
52495
52514
|
}
|
|
52496
52515
|
isLocked() {
|
|
52497
52516
|
return false;
|
|
@@ -52518,9 +52537,9 @@ class BoardSelection {
|
|
|
52518
52537
|
}
|
|
52519
52538
|
async duplicate() {
|
|
52520
52539
|
const mediaIds = [];
|
|
52521
|
-
this.items.list().forEach((
|
|
52522
|
-
if ("getStorageId" in
|
|
52523
|
-
const storageId =
|
|
52540
|
+
this.items.list().forEach((item) => {
|
|
52541
|
+
if ("getStorageId" in item) {
|
|
52542
|
+
const storageId = item.getStorageId();
|
|
52524
52543
|
if (storageId) {
|
|
52525
52544
|
mediaIds.push(storageId);
|
|
52526
52545
|
}
|
|
@@ -52530,7 +52549,7 @@ class BoardSelection {
|
|
|
52530
52549
|
if (!canDuplicate) {
|
|
52531
52550
|
return;
|
|
52532
52551
|
}
|
|
52533
|
-
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_,
|
|
52552
|
+
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_, item]) => item.itemType !== "Group"));
|
|
52534
52553
|
this.board.duplicate(filteredItemMap);
|
|
52535
52554
|
this.setContext("EditUnderPointer");
|
|
52536
52555
|
}
|
|
@@ -52564,10 +52583,10 @@ class BoardSelection {
|
|
|
52564
52583
|
lastAssistantMessageId
|
|
52565
52584
|
};
|
|
52566
52585
|
}
|
|
52567
|
-
renderItemMbr(context,
|
|
52568
|
-
const mbr =
|
|
52586
|
+
renderItemMbr(context, item, customScale) {
|
|
52587
|
+
const mbr = item.getMbr();
|
|
52569
52588
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
52570
|
-
const selectionColor =
|
|
52589
|
+
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
52571
52590
|
mbr.borderColor = selectionColor;
|
|
52572
52591
|
mbr.render(context);
|
|
52573
52592
|
}
|
|
@@ -52583,8 +52602,8 @@ class BoardSelection {
|
|
|
52583
52602
|
}
|
|
52584
52603
|
if (!this.transformationRenderBlock) {
|
|
52585
52604
|
if (this.shouldRenderItemsMbr) {
|
|
52586
|
-
for (const
|
|
52587
|
-
this.renderItemMbr(context,
|
|
52605
|
+
for (const item of this.items.list()) {
|
|
52606
|
+
this.renderItemMbr(context, item);
|
|
52588
52607
|
}
|
|
52589
52608
|
}
|
|
52590
52609
|
this.tool.render(context);
|
|
@@ -52596,7 +52615,7 @@ class BoardSelection {
|
|
|
52596
52615
|
if (single && single instanceof AINode) {
|
|
52597
52616
|
const contextItemsIds = single.getContextItems();
|
|
52598
52617
|
if (contextItemsIds.length) {
|
|
52599
|
-
const newContextItems = this.board.items.listAll().filter((
|
|
52618
|
+
const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
|
|
52600
52619
|
contextItems.push(...newContextItems);
|
|
52601
52620
|
}
|
|
52602
52621
|
}
|
|
@@ -52614,15 +52633,15 @@ class BoardSelection {
|
|
|
52614
52633
|
}
|
|
52615
52634
|
}
|
|
52616
52635
|
}
|
|
52617
|
-
contextItems.forEach((
|
|
52618
|
-
if (
|
|
52619
|
-
const path2 =
|
|
52636
|
+
contextItems.forEach((item) => {
|
|
52637
|
+
if (item instanceof AINode) {
|
|
52638
|
+
const path2 = item.getPath();
|
|
52620
52639
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
52621
52640
|
path2.setBorderWidth(2);
|
|
52622
52641
|
path2.setBackgroundColor("none");
|
|
52623
52642
|
path2.render(context);
|
|
52624
52643
|
} else {
|
|
52625
|
-
const itemRect =
|
|
52644
|
+
const itemRect = item.getMbr();
|
|
52626
52645
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
52627
52646
|
itemRect.strokeWidth = 2;
|
|
52628
52647
|
itemRect.render(context);
|
|
@@ -53123,16 +53142,16 @@ class Board {
|
|
|
53123
53142
|
applyBoardOperation(op) {
|
|
53124
53143
|
switch (op.method) {
|
|
53125
53144
|
case "moveToZIndex": {
|
|
53126
|
-
const
|
|
53127
|
-
if (!
|
|
53145
|
+
const item = this.index.getById(op.item);
|
|
53146
|
+
if (!item) {
|
|
53128
53147
|
return;
|
|
53129
53148
|
}
|
|
53130
|
-
return this.index.moveToZIndex(
|
|
53149
|
+
return this.index.moveToZIndex(item, op.zIndex);
|
|
53131
53150
|
}
|
|
53132
53151
|
case "moveManyToZIndex": {
|
|
53133
53152
|
for (const id in op.item) {
|
|
53134
|
-
const
|
|
53135
|
-
if (!
|
|
53153
|
+
const item = this.items.getById(id);
|
|
53154
|
+
if (!item) {
|
|
53136
53155
|
delete op.item.id;
|
|
53137
53156
|
}
|
|
53138
53157
|
}
|
|
@@ -53154,11 +53173,11 @@ class Board {
|
|
|
53154
53173
|
}
|
|
53155
53174
|
return this.index.moveSecondAfterFirst(first, second);
|
|
53156
53175
|
case "bringToFront": {
|
|
53157
|
-
const items = op.item.map((
|
|
53176
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
53158
53177
|
return this.index.bringManyToFront(items);
|
|
53159
53178
|
}
|
|
53160
53179
|
case "sendToBack": {
|
|
53161
|
-
const items = op.item.map((
|
|
53180
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
53162
53181
|
return this.index.sendManyToBack(items);
|
|
53163
53182
|
}
|
|
53164
53183
|
case "add":
|
|
@@ -53182,82 +53201,82 @@ class Board {
|
|
|
53182
53201
|
applyAddItems(op) {
|
|
53183
53202
|
if (Array.isArray(op.item)) {
|
|
53184
53203
|
const data = op.data;
|
|
53185
|
-
const items = op.item.map((
|
|
53186
|
-
const created = this.createItem(
|
|
53204
|
+
const items = op.item.map((item2) => {
|
|
53205
|
+
const created = this.createItem(item2, data[item2]);
|
|
53187
53206
|
this.index.insert(created);
|
|
53188
53207
|
return created;
|
|
53189
53208
|
});
|
|
53190
|
-
items.forEach((
|
|
53191
|
-
if (
|
|
53192
|
-
const connectorData = data[
|
|
53193
|
-
|
|
53194
|
-
|
|
53209
|
+
items.forEach((item2) => {
|
|
53210
|
+
if (item2 instanceof Connector2 && data[item2.getId()]) {
|
|
53211
|
+
const connectorData = data[item2.getId()];
|
|
53212
|
+
item2.applyStartPoint(connectorData.startPoint);
|
|
53213
|
+
item2.applyEndPoint(connectorData.endPoint);
|
|
53195
53214
|
}
|
|
53196
53215
|
});
|
|
53197
53216
|
return;
|
|
53198
53217
|
}
|
|
53199
|
-
const
|
|
53200
|
-
return this.index.insert(
|
|
53218
|
+
const item = this.createItem(op.item, op.data);
|
|
53219
|
+
return this.index.insert(item);
|
|
53201
53220
|
}
|
|
53202
53221
|
applyAddLockedGroupOperation(op) {
|
|
53203
|
-
const
|
|
53204
|
-
const groupChildrenIds =
|
|
53205
|
-
this.index.insert(
|
|
53222
|
+
const item = this.createItem(op.item, op.data);
|
|
53223
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
53224
|
+
this.index.insert(item);
|
|
53206
53225
|
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
53207
53226
|
if (lastChildrenId) {
|
|
53208
53227
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
53209
|
-
this.index.moveToZIndex(
|
|
53228
|
+
this.index.moveToZIndex(item, zIndex);
|
|
53210
53229
|
}
|
|
53211
|
-
|
|
53212
|
-
|
|
53230
|
+
item.getChildren().forEach((item2) => {
|
|
53231
|
+
item2.transformation.isLocked = true;
|
|
53213
53232
|
});
|
|
53214
|
-
|
|
53233
|
+
item.transformation.isLocked = true;
|
|
53215
53234
|
}
|
|
53216
53235
|
applyRemoveOperation(op) {
|
|
53217
53236
|
const removedItems = [];
|
|
53218
|
-
this.findItemAndApply(op.item, (
|
|
53219
|
-
this.index.remove(
|
|
53220
|
-
this.selection.remove(
|
|
53221
|
-
if (
|
|
53222
|
-
|
|
53237
|
+
this.findItemAndApply(op.item, (item) => {
|
|
53238
|
+
this.index.remove(item);
|
|
53239
|
+
this.selection.remove(item);
|
|
53240
|
+
if (item instanceof Connector2) {
|
|
53241
|
+
item.clearObservedItems();
|
|
53223
53242
|
}
|
|
53224
|
-
removedItems.push(
|
|
53243
|
+
removedItems.push(item);
|
|
53225
53244
|
});
|
|
53226
53245
|
}
|
|
53227
53246
|
applyRemoveLockedGroupOperation(op) {
|
|
53228
|
-
const
|
|
53229
|
-
if (!
|
|
53247
|
+
const item = this.index.getById(op.item[0]);
|
|
53248
|
+
if (!item || !(item instanceof Group)) {
|
|
53230
53249
|
return;
|
|
53231
53250
|
}
|
|
53232
|
-
|
|
53233
|
-
|
|
53234
|
-
|
|
53251
|
+
item.getChildren().forEach((item2) => {
|
|
53252
|
+
item2.transformation.isLocked = false;
|
|
53253
|
+
item2.parent = "Board";
|
|
53235
53254
|
});
|
|
53236
|
-
|
|
53255
|
+
item.transformation.isLocked = false;
|
|
53237
53256
|
const removedItems = [];
|
|
53238
|
-
this.findItemAndApply(op.item, (
|
|
53239
|
-
this.index.remove(
|
|
53240
|
-
this.selection.remove(
|
|
53241
|
-
removedItems.push(
|
|
53257
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
53258
|
+
this.index.remove(item2);
|
|
53259
|
+
this.selection.remove(item2);
|
|
53260
|
+
removedItems.push(item2);
|
|
53242
53261
|
});
|
|
53243
53262
|
}
|
|
53244
53263
|
applyItemOperation(op) {
|
|
53245
53264
|
if ("item" in op) {
|
|
53246
|
-
this.findItemAndApply(op.item, (
|
|
53247
|
-
|
|
53265
|
+
this.findItemAndApply(op.item, (item) => {
|
|
53266
|
+
item.apply(op);
|
|
53248
53267
|
});
|
|
53249
53268
|
}
|
|
53250
53269
|
}
|
|
53251
|
-
findItemAndApply(
|
|
53252
|
-
if (Array.isArray(
|
|
53253
|
-
for (const itemId of
|
|
53270
|
+
findItemAndApply(item, apply) {
|
|
53271
|
+
if (Array.isArray(item)) {
|
|
53272
|
+
for (const itemId of item) {
|
|
53254
53273
|
const found = this.items.findById(itemId);
|
|
53255
53274
|
if (found) {
|
|
53256
53275
|
apply(found);
|
|
53257
53276
|
}
|
|
53258
53277
|
}
|
|
53259
53278
|
} else {
|
|
53260
|
-
const found = this.items.findById(
|
|
53279
|
+
const found = this.items.findById(item);
|
|
53261
53280
|
if (found) {
|
|
53262
53281
|
apply(found);
|
|
53263
53282
|
}
|
|
@@ -53266,9 +53285,9 @@ class Board {
|
|
|
53266
53285
|
handleNesting(items) {
|
|
53267
53286
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
53268
53287
|
const groupsMap = new Map;
|
|
53269
|
-
arrayed.forEach((
|
|
53270
|
-
const itemCenter =
|
|
53271
|
-
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(
|
|
53288
|
+
arrayed.forEach((item) => {
|
|
53289
|
+
const itemCenter = item.getMbr().getCenter();
|
|
53290
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
53272
53291
|
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
53273
53292
|
acc = groupItem2;
|
|
53274
53293
|
}
|
|
@@ -53278,7 +53297,7 @@ class Board {
|
|
|
53278
53297
|
if (!groupsMap.has(groupItem)) {
|
|
53279
53298
|
groupsMap.set(groupItem, []);
|
|
53280
53299
|
}
|
|
53281
|
-
groupsMap.get(groupItem)?.push(
|
|
53300
|
+
groupsMap.get(groupItem)?.push(item);
|
|
53282
53301
|
}
|
|
53283
53302
|
});
|
|
53284
53303
|
groupsMap.forEach((items2, group) => {
|
|
@@ -53299,13 +53318,13 @@ class Board {
|
|
|
53299
53318
|
}
|
|
53300
53319
|
return parser(el);
|
|
53301
53320
|
}
|
|
53302
|
-
add(
|
|
53321
|
+
add(item, timeStamp) {
|
|
53303
53322
|
const id = this.getNewItemId();
|
|
53304
53323
|
this.emit({
|
|
53305
53324
|
class: "Board",
|
|
53306
53325
|
method: "add",
|
|
53307
53326
|
item: id,
|
|
53308
|
-
data:
|
|
53327
|
+
data: item.serialize(),
|
|
53309
53328
|
timeStamp
|
|
53310
53329
|
});
|
|
53311
53330
|
const newItem = this.items.getById(id);
|
|
@@ -53315,13 +53334,13 @@ class Board {
|
|
|
53315
53334
|
this.handleNesting(newItem);
|
|
53316
53335
|
return newItem;
|
|
53317
53336
|
}
|
|
53318
|
-
addLockedGroup(
|
|
53337
|
+
addLockedGroup(item) {
|
|
53319
53338
|
const id = this.getNewItemId();
|
|
53320
53339
|
this.emit({
|
|
53321
53340
|
class: "Board",
|
|
53322
53341
|
method: "addLockedGroup",
|
|
53323
53342
|
item: id,
|
|
53324
|
-
data:
|
|
53343
|
+
data: item.serialize()
|
|
53325
53344
|
});
|
|
53326
53345
|
const newItem = this.items.getById(id);
|
|
53327
53346
|
if (!newItem) {
|
|
@@ -53330,32 +53349,32 @@ class Board {
|
|
|
53330
53349
|
this.handleNesting(newItem);
|
|
53331
53350
|
return newItem;
|
|
53332
53351
|
}
|
|
53333
|
-
remove(
|
|
53352
|
+
remove(item, withConnectors = true) {
|
|
53334
53353
|
let connectors = [];
|
|
53335
53354
|
if (withConnectors) {
|
|
53336
|
-
connectors = this.items.getLinkedConnectorsById(
|
|
53355
|
+
connectors = this.items.getLinkedConnectorsById(item.getId()).map((connector) => connector.getId());
|
|
53337
53356
|
}
|
|
53338
|
-
if ("onRemove" in
|
|
53339
|
-
|
|
53357
|
+
if ("onRemove" in item) {
|
|
53358
|
+
item.onRemove();
|
|
53340
53359
|
}
|
|
53341
53360
|
this.emit({
|
|
53342
53361
|
class: "Board",
|
|
53343
53362
|
method: "remove",
|
|
53344
|
-
item: [
|
|
53363
|
+
item: [item.getId(), ...connectors]
|
|
53345
53364
|
});
|
|
53346
53365
|
}
|
|
53347
|
-
removeLockedGroup(
|
|
53366
|
+
removeLockedGroup(item) {
|
|
53348
53367
|
this.emit({
|
|
53349
53368
|
class: "Board",
|
|
53350
53369
|
method: "removeLockedGroup",
|
|
53351
|
-
item: [
|
|
53370
|
+
item: [item.getId()]
|
|
53352
53371
|
});
|
|
53353
53372
|
}
|
|
53354
53373
|
getByZIndex(index2) {
|
|
53355
53374
|
return this.index.getByZIndex(index2);
|
|
53356
53375
|
}
|
|
53357
|
-
getZIndex(
|
|
53358
|
-
return this.index.getZIndex(
|
|
53376
|
+
getZIndex(item) {
|
|
53377
|
+
return this.index.getZIndex(item);
|
|
53359
53378
|
}
|
|
53360
53379
|
getLastZIndex() {
|
|
53361
53380
|
return this.index.getLastZIndex();
|
|
@@ -53367,11 +53386,11 @@ class Board {
|
|
|
53367
53386
|
item: items
|
|
53368
53387
|
});
|
|
53369
53388
|
}
|
|
53370
|
-
moveToZIndex(
|
|
53389
|
+
moveToZIndex(item, zIndex) {
|
|
53371
53390
|
this.emit({
|
|
53372
53391
|
class: "Board",
|
|
53373
53392
|
method: "moveToZIndex",
|
|
53374
|
-
item:
|
|
53393
|
+
item: item.getId(),
|
|
53375
53394
|
zIndex
|
|
53376
53395
|
});
|
|
53377
53396
|
}
|
|
@@ -53399,8 +53418,8 @@ class Board {
|
|
|
53399
53418
|
this.emit({
|
|
53400
53419
|
class: "Board",
|
|
53401
53420
|
method: "bringToFront",
|
|
53402
|
-
item: items.map((
|
|
53403
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53421
|
+
item: items.map((item) => item.getId()),
|
|
53422
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
53404
53423
|
});
|
|
53405
53424
|
}
|
|
53406
53425
|
sendToBack(items) {
|
|
@@ -53411,8 +53430,8 @@ class Board {
|
|
|
53411
53430
|
this.emit({
|
|
53412
53431
|
class: "Board",
|
|
53413
53432
|
method: "sendToBack",
|
|
53414
|
-
item: items.map((
|
|
53415
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
53433
|
+
item: items.map((item) => item.getId()),
|
|
53434
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
53416
53435
|
});
|
|
53417
53436
|
}
|
|
53418
53437
|
copy() {
|
|
@@ -53489,7 +53508,7 @@ class Board {
|
|
|
53489
53508
|
return added;
|
|
53490
53509
|
});
|
|
53491
53510
|
addedFrame.addChildItems(addedChildren);
|
|
53492
|
-
parsedData.data.children = addedChildren.map((
|
|
53511
|
+
parsedData.data.children = addedChildren.map((item) => item.getId());
|
|
53493
53512
|
idsMap[parsedData.data.id] = addedFrame.getId();
|
|
53494
53513
|
} else {
|
|
53495
53514
|
const added = this.add(this.createItem(this.getNewItemId(), parsedData));
|
|
@@ -53530,15 +53549,15 @@ class Board {
|
|
|
53530
53549
|
const createdConnectors = {};
|
|
53531
53550
|
const createdFrames = {};
|
|
53532
53551
|
const addItem = (itemData) => {
|
|
53533
|
-
const
|
|
53534
|
-
if (
|
|
53535
|
-
createdConnectors[itemData.id] = { item
|
|
53552
|
+
const item = this.createItem(itemData.id, itemData);
|
|
53553
|
+
if (item instanceof Connector2) {
|
|
53554
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
53536
53555
|
}
|
|
53537
|
-
if (
|
|
53538
|
-
createdFrames[
|
|
53556
|
+
if (item instanceof Frame2) {
|
|
53557
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
53539
53558
|
}
|
|
53540
|
-
this.index.insert(
|
|
53541
|
-
return
|
|
53559
|
+
this.index.insert(item);
|
|
53560
|
+
return item;
|
|
53542
53561
|
};
|
|
53543
53562
|
for (const itemData of items) {
|
|
53544
53563
|
if ("childrenMap" in itemData) {
|
|
@@ -53549,13 +53568,13 @@ class Board {
|
|
|
53549
53568
|
}
|
|
53550
53569
|
}
|
|
53551
53570
|
for (const key in createdConnectors) {
|
|
53552
|
-
const { item
|
|
53553
|
-
|
|
53554
|
-
|
|
53571
|
+
const { item, itemData } = createdConnectors[key];
|
|
53572
|
+
item.applyStartPoint(itemData.startPoint);
|
|
53573
|
+
item.applyEndPoint(itemData.endPoint);
|
|
53555
53574
|
}
|
|
53556
53575
|
for (const key in createdFrames) {
|
|
53557
|
-
const { item
|
|
53558
|
-
|
|
53576
|
+
const { item, itemData } = createdFrames[key];
|
|
53577
|
+
item.applyAddChildren(itemData.children);
|
|
53559
53578
|
}
|
|
53560
53579
|
}
|
|
53561
53580
|
deserialize(snapshot) {
|
|
@@ -53565,33 +53584,33 @@ class Board {
|
|
|
53565
53584
|
const createdFrames = {};
|
|
53566
53585
|
if (Array.isArray(items)) {
|
|
53567
53586
|
for (const itemData of items) {
|
|
53568
|
-
const
|
|
53569
|
-
if (
|
|
53570
|
-
createdConnectors[itemData.id] = { item
|
|
53587
|
+
const item = this.createItem(itemData.id, itemData);
|
|
53588
|
+
if (item instanceof Connector2) {
|
|
53589
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
53571
53590
|
}
|
|
53572
|
-
if (
|
|
53573
|
-
createdFrames[
|
|
53591
|
+
if (item instanceof Frame2) {
|
|
53592
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
53574
53593
|
}
|
|
53575
|
-
this.index.insert(
|
|
53594
|
+
this.index.insert(item);
|
|
53576
53595
|
}
|
|
53577
53596
|
} else {
|
|
53578
53597
|
for (const key in items) {
|
|
53579
53598
|
const itemData = items[key];
|
|
53580
|
-
const
|
|
53581
|
-
if (
|
|
53582
|
-
createdConnectors[key] = { item
|
|
53599
|
+
const item = this.createItem(key, itemData);
|
|
53600
|
+
if (item instanceof Connector2) {
|
|
53601
|
+
createdConnectors[key] = { item, itemData };
|
|
53583
53602
|
}
|
|
53584
|
-
this.index.insert(
|
|
53603
|
+
this.index.insert(item);
|
|
53585
53604
|
}
|
|
53586
53605
|
}
|
|
53587
53606
|
for (const key in createdConnectors) {
|
|
53588
|
-
const { item
|
|
53589
|
-
|
|
53590
|
-
|
|
53607
|
+
const { item, itemData } = createdConnectors[key];
|
|
53608
|
+
item.applyStartPoint(itemData.startPoint);
|
|
53609
|
+
item.applyEndPoint(itemData.endPoint);
|
|
53591
53610
|
}
|
|
53592
53611
|
for (const key in createdFrames) {
|
|
53593
|
-
const { item
|
|
53594
|
-
|
|
53612
|
+
const { item, itemData } = createdFrames[key];
|
|
53613
|
+
item.applyAddChildren(itemData.children);
|
|
53595
53614
|
}
|
|
53596
53615
|
this.events?.log.deserialize(events);
|
|
53597
53616
|
}
|
|
@@ -53829,7 +53848,7 @@ class Board {
|
|
|
53829
53848
|
itemsMap: newMap,
|
|
53830
53849
|
select: select2
|
|
53831
53850
|
});
|
|
53832
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
53851
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
53833
53852
|
this.handleNesting(items);
|
|
53834
53853
|
this.selection.removeAll();
|
|
53835
53854
|
this.selection.add(items);
|
|
@@ -53837,8 +53856,8 @@ class Board {
|
|
|
53837
53856
|
return;
|
|
53838
53857
|
}
|
|
53839
53858
|
removeVoidComments() {
|
|
53840
|
-
const voidComments = this.items.listAll().filter((
|
|
53841
|
-
return
|
|
53859
|
+
const voidComments = this.items.listAll().filter((item) => {
|
|
53860
|
+
return item instanceof Comment && !item.getThread().length;
|
|
53842
53861
|
});
|
|
53843
53862
|
if (voidComments) {
|
|
53844
53863
|
for (const comment2 of voidComments) {
|
|
@@ -53912,7 +53931,7 @@ class Board {
|
|
|
53912
53931
|
}
|
|
53913
53932
|
const mbr = this.selection.getMbr();
|
|
53914
53933
|
const selectedItems = this.selection.items.list();
|
|
53915
|
-
const isSelectedItemsMinWidth = selectedItems.some((
|
|
53934
|
+
const isSelectedItemsMinWidth = selectedItems.some((item) => item.getMbr().getWidth() === 0);
|
|
53916
53935
|
const right = mbr ? mbr.right : 0;
|
|
53917
53936
|
const top = mbr ? mbr.top : 0;
|
|
53918
53937
|
const width2 = mbr ? mbr.getWidth() / 10 : 10;
|
|
@@ -53954,7 +53973,7 @@ class Board {
|
|
|
53954
53973
|
method: "duplicate",
|
|
53955
53974
|
itemsMap: newMap
|
|
53956
53975
|
});
|
|
53957
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
53976
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
53958
53977
|
this.handleNesting(items);
|
|
53959
53978
|
this.selection.removeAll();
|
|
53960
53979
|
this.selection.add(items);
|
|
@@ -53975,9 +53994,9 @@ class Board {
|
|
|
53975
53994
|
if (data.itemType === "Frame") {
|
|
53976
53995
|
data.text.placeholderText = `Frame ${this.getMaxFrameSerial() + 1}`;
|
|
53977
53996
|
}
|
|
53978
|
-
const
|
|
53979
|
-
this.index.insert(
|
|
53980
|
-
items.push(
|
|
53997
|
+
const item = this.createItem(itemId, data);
|
|
53998
|
+
this.index.insert(item);
|
|
53999
|
+
items.push(item);
|
|
53981
54000
|
};
|
|
53982
54001
|
sortedItemsMap.map(([id, data]) => {
|
|
53983
54002
|
if (data.itemType === "Connector") {
|
|
@@ -53992,8 +54011,8 @@ class Board {
|
|
|
53992
54011
|
return;
|
|
53993
54012
|
});
|
|
53994
54013
|
}
|
|
53995
|
-
isOnBoard(
|
|
53996
|
-
return this.items.findById(
|
|
54014
|
+
isOnBoard(item) {
|
|
54015
|
+
return this.items.findById(item.getId()) !== undefined;
|
|
53997
54016
|
}
|
|
53998
54017
|
getMaxFrameSerial() {
|
|
53999
54018
|
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
@@ -54039,7 +54058,7 @@ function areItemsTheSame(opA, opB) {
|
|
|
54039
54058
|
const itemsB = Object.keys(opB.items);
|
|
54040
54059
|
const setA = new Set(itemsA);
|
|
54041
54060
|
const setB = new Set(itemsB);
|
|
54042
|
-
const areArraysEqual = setA.size === setB.size && [...setA].every((
|
|
54061
|
+
const areArraysEqual = setA.size === setB.size && [...setA].every((item) => setB.has(item));
|
|
54043
54062
|
return areArraysEqual;
|
|
54044
54063
|
}
|
|
54045
54064
|
if (!(Array.isArray(opA.item) && Array.isArray(opB.item))) {
|
|
@@ -55698,9 +55717,9 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
55698
55717
|
list6.applyUnconfirmed(filter);
|
|
55699
55718
|
const hasAnyOverlap = (arr1, arr2) => {
|
|
55700
55719
|
const lookup9 = new Set(arr1);
|
|
55701
|
-
return arr2.some((
|
|
55720
|
+
return arr2.some((item) => lookup9.has(item));
|
|
55702
55721
|
};
|
|
55703
|
-
const currSelection = board.selection.list().map((
|
|
55722
|
+
const currSelection = board.selection.list().map((item) => item.getId());
|
|
55704
55723
|
if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
55705
55724
|
board.selection.applyMemoizedCaretOrRange();
|
|
55706
55725
|
}
|
|
@@ -56022,27 +56041,27 @@ function handleAiChatMassage(message, board) {
|
|
|
56022
56041
|
}
|
|
56023
56042
|
}
|
|
56024
56043
|
function handleChatChunk(chunk, board) {
|
|
56025
|
-
const
|
|
56044
|
+
const item = board.items.getById(chunk.itemId);
|
|
56026
56045
|
switch (chunk.type) {
|
|
56027
56046
|
case "chunk":
|
|
56028
|
-
if (!
|
|
56047
|
+
if (!item || item.itemType !== "AINode") {
|
|
56029
56048
|
return;
|
|
56030
56049
|
}
|
|
56031
|
-
|
|
56050
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
|
|
56032
56051
|
break;
|
|
56033
56052
|
case "done":
|
|
56034
|
-
if (!
|
|
56053
|
+
if (!item || item.itemType !== "AINode") {
|
|
56035
56054
|
board.aiGeneratingOnItem = undefined;
|
|
56036
56055
|
return;
|
|
56037
56056
|
}
|
|
56038
|
-
|
|
56057
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56039
56058
|
break;
|
|
56040
56059
|
case "end":
|
|
56041
|
-
if (!
|
|
56060
|
+
if (!item || item.itemType !== "AINode") {
|
|
56042
56061
|
board.aiGeneratingOnItem = undefined;
|
|
56043
56062
|
return;
|
|
56044
56063
|
}
|
|
56045
|
-
|
|
56064
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
56046
56065
|
break;
|
|
56047
56066
|
case "error":
|
|
56048
56067
|
default:
|
|
@@ -56059,7 +56078,7 @@ function handleChatChunk(chunk, board) {
|
|
|
56059
56078
|
if (board.aiGeneratingOnItem && generatingItem) {
|
|
56060
56079
|
board.selection.removeAll();
|
|
56061
56080
|
board.selection.add(generatingItem);
|
|
56062
|
-
const rt =
|
|
56081
|
+
const rt = item?.getRichText();
|
|
56063
56082
|
if (generatingItem.itemType === "AINode" && rt) {
|
|
56064
56083
|
const editor = rt.editor;
|
|
56065
56084
|
editor.markdownProcessor.setStopProcessingMarkDownCb(null);
|
|
@@ -56192,14 +56211,14 @@ function handleImageGenerate(response, board) {
|
|
|
56192
56211
|
console.error("Image generation error:", response.message);
|
|
56193
56212
|
if (response.isExternalApiError) {
|
|
56194
56213
|
if (board.aiGeneratingOnItem) {
|
|
56195
|
-
const
|
|
56196
|
-
if (
|
|
56214
|
+
const item = board.items.getById(board.aiGeneratingOnItem);
|
|
56215
|
+
if (item) {
|
|
56197
56216
|
board.selection.removeAll();
|
|
56198
|
-
board.selection.add(
|
|
56199
|
-
const editor =
|
|
56217
|
+
board.selection.add(item);
|
|
56218
|
+
const editor = item.getRichText()?.editor;
|
|
56200
56219
|
editor?.clearText();
|
|
56201
56220
|
editor?.insertCopiedText(conf.i18n.t("AIInput.nodeErrorText"));
|
|
56202
|
-
board.camera.zoomToFit(
|
|
56221
|
+
board.camera.zoomToFit(item.getMbr(), 20);
|
|
56203
56222
|
}
|
|
56204
56223
|
}
|
|
56205
56224
|
} else {
|