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/cjs/node.js
CHANGED
|
@@ -1539,8 +1539,8 @@ var require_tinyqueue = __commonJS((exports2, module2) => {
|
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
};
|
|
1542
|
-
TinyQueue.prototype.push = function push(
|
|
1543
|
-
this.data.push(
|
|
1542
|
+
TinyQueue.prototype.push = function push(item) {
|
|
1543
|
+
this.data.push(item);
|
|
1544
1544
|
this.length++;
|
|
1545
1545
|
this._up(this.length - 1);
|
|
1546
1546
|
};
|
|
@@ -1564,24 +1564,24 @@ var require_tinyqueue = __commonJS((exports2, module2) => {
|
|
|
1564
1564
|
var ref = this;
|
|
1565
1565
|
var data = ref.data;
|
|
1566
1566
|
var compare = ref.compare;
|
|
1567
|
-
var
|
|
1567
|
+
var item = data[pos];
|
|
1568
1568
|
while (pos > 0) {
|
|
1569
1569
|
var parent = pos - 1 >> 1;
|
|
1570
1570
|
var current = data[parent];
|
|
1571
|
-
if (compare(
|
|
1571
|
+
if (compare(item, current) >= 0) {
|
|
1572
1572
|
break;
|
|
1573
1573
|
}
|
|
1574
1574
|
data[pos] = current;
|
|
1575
1575
|
pos = parent;
|
|
1576
1576
|
}
|
|
1577
|
-
data[pos] =
|
|
1577
|
+
data[pos] = item;
|
|
1578
1578
|
};
|
|
1579
1579
|
TinyQueue.prototype._down = function _down(pos) {
|
|
1580
1580
|
var ref = this;
|
|
1581
1581
|
var data = ref.data;
|
|
1582
1582
|
var compare = ref.compare;
|
|
1583
1583
|
var halfLength = this.length >> 1;
|
|
1584
|
-
var
|
|
1584
|
+
var item = data[pos];
|
|
1585
1585
|
while (pos < halfLength) {
|
|
1586
1586
|
var left = (pos << 1) + 1;
|
|
1587
1587
|
var best = data[left];
|
|
@@ -1590,13 +1590,13 @@ var require_tinyqueue = __commonJS((exports2, module2) => {
|
|
|
1590
1590
|
left = right;
|
|
1591
1591
|
best = data[right];
|
|
1592
1592
|
}
|
|
1593
|
-
if (compare(best,
|
|
1593
|
+
if (compare(best, item) >= 0) {
|
|
1594
1594
|
break;
|
|
1595
1595
|
}
|
|
1596
1596
|
data[pos] = best;
|
|
1597
1597
|
pos = left;
|
|
1598
1598
|
}
|
|
1599
|
-
data[pos] =
|
|
1599
|
+
data[pos] = item;
|
|
1600
1600
|
};
|
|
1601
1601
|
function defaultCompare2(a, b) {
|
|
1602
1602
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -1838,8 +1838,8 @@ class BoardCommand {
|
|
|
1838
1838
|
switch (operation.method) {
|
|
1839
1839
|
case "bringToFront": {
|
|
1840
1840
|
for (const id in operation.prevZIndex) {
|
|
1841
|
-
const
|
|
1842
|
-
if (!
|
|
1841
|
+
const item = this.board.items.getById(id);
|
|
1842
|
+
if (!item) {
|
|
1843
1843
|
delete operation.prevZIndex.id;
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
@@ -1851,8 +1851,8 @@ class BoardCommand {
|
|
|
1851
1851
|
}
|
|
1852
1852
|
case "sendToBack": {
|
|
1853
1853
|
for (const id in operation.prevZIndex) {
|
|
1854
|
-
const
|
|
1855
|
-
if (!
|
|
1854
|
+
const item = this.board.items.getById(id);
|
|
1855
|
+
if (!item) {
|
|
1856
1856
|
delete operation.prevZIndex.id;
|
|
1857
1857
|
}
|
|
1858
1858
|
}
|
|
@@ -1866,11 +1866,11 @@ class BoardCommand {
|
|
|
1866
1866
|
case "moveSecondBeforeFirst":
|
|
1867
1867
|
case "moveToZIndex": {
|
|
1868
1868
|
const items = this.board.items;
|
|
1869
|
-
const
|
|
1870
|
-
if (!
|
|
1869
|
+
const item = items.getById(operation.item);
|
|
1870
|
+
if (!item) {
|
|
1871
1871
|
throw new Error("Get reverse board operation. Item not found");
|
|
1872
1872
|
}
|
|
1873
|
-
const zIndex = this.board.getZIndex(
|
|
1873
|
+
const zIndex = this.board.getZIndex(item);
|
|
1874
1874
|
return {
|
|
1875
1875
|
class: "Board",
|
|
1876
1876
|
method: "moveToZIndex",
|
|
@@ -1880,8 +1880,8 @@ class BoardCommand {
|
|
|
1880
1880
|
}
|
|
1881
1881
|
case "moveManyToZIndex": {
|
|
1882
1882
|
for (const id in operation.item) {
|
|
1883
|
-
const
|
|
1884
|
-
if (!
|
|
1883
|
+
const item = this.board.items.getById(id);
|
|
1884
|
+
if (!item) {
|
|
1885
1885
|
delete operation.item.id;
|
|
1886
1886
|
}
|
|
1887
1887
|
}
|
|
@@ -1898,15 +1898,15 @@ class BoardCommand {
|
|
|
1898
1898
|
const items = this.board.items;
|
|
1899
1899
|
const reverse = [];
|
|
1900
1900
|
for (const itemId of operation.item) {
|
|
1901
|
-
const
|
|
1902
|
-
if (!
|
|
1901
|
+
const item = items.getById(itemId);
|
|
1902
|
+
if (!item) {
|
|
1903
1903
|
throw new Error("Get reverse board operation. Item not found");
|
|
1904
1904
|
}
|
|
1905
1905
|
reverse.push({
|
|
1906
1906
|
class: "Board",
|
|
1907
1907
|
method: "add",
|
|
1908
1908
|
item: itemId,
|
|
1909
|
-
data:
|
|
1909
|
+
data: item.serialize()
|
|
1910
1910
|
});
|
|
1911
1911
|
}
|
|
1912
1912
|
return reverse;
|
|
@@ -1929,32 +1929,32 @@ class BoardCommand {
|
|
|
1929
1929
|
const items = this.board.items;
|
|
1930
1930
|
const reverse = [];
|
|
1931
1931
|
for (const itemId of operation.item) {
|
|
1932
|
-
const
|
|
1933
|
-
if (!
|
|
1932
|
+
const item = items.getById(itemId);
|
|
1933
|
+
if (!item || item.itemType !== "Group") {
|
|
1934
1934
|
throw new Error("Get reverse board operation. Item not found");
|
|
1935
1935
|
}
|
|
1936
1936
|
reverse.push({
|
|
1937
1937
|
class: "Board",
|
|
1938
1938
|
method: "addLockedGroup",
|
|
1939
1939
|
item: itemId,
|
|
1940
|
-
data:
|
|
1940
|
+
data: item.serialize()
|
|
1941
1941
|
});
|
|
1942
1942
|
}
|
|
1943
1943
|
return reverse;
|
|
1944
1944
|
}
|
|
1945
1945
|
case "duplicate":
|
|
1946
1946
|
case "paste": {
|
|
1947
|
-
const
|
|
1947
|
+
const item = [];
|
|
1948
1948
|
const map = operation.itemsMap;
|
|
1949
1949
|
for (const key in map) {
|
|
1950
1950
|
if (map.hasOwnProperty(key)) {
|
|
1951
|
-
|
|
1951
|
+
item.push(key);
|
|
1952
1952
|
}
|
|
1953
1953
|
}
|
|
1954
1954
|
return {
|
|
1955
1955
|
class: "Board",
|
|
1956
1956
|
method: "remove",
|
|
1957
|
-
item
|
|
1957
|
+
item
|
|
1958
1958
|
};
|
|
1959
1959
|
}
|
|
1960
1960
|
}
|
|
@@ -8272,11 +8272,11 @@ class SubjectOperation {
|
|
|
8272
8272
|
}
|
|
8273
8273
|
|
|
8274
8274
|
// src/Items/ItemsCommandUtils.ts
|
|
8275
|
-
function mapItemsByOperation(
|
|
8276
|
-
const items = Array.isArray(
|
|
8277
|
-
return items.map((
|
|
8278
|
-
const operation = getCallback(
|
|
8279
|
-
return { item:
|
|
8275
|
+
function mapItemsByOperation(item, getCallback) {
|
|
8276
|
+
const items = Array.isArray(item) ? item : [item];
|
|
8277
|
+
return items.map((item2) => {
|
|
8278
|
+
const operation = getCallback(item2);
|
|
8279
|
+
return { item: item2, operation };
|
|
8280
8280
|
});
|
|
8281
8281
|
}
|
|
8282
8282
|
|
|
@@ -8301,8 +8301,8 @@ class TransformationCommand {
|
|
|
8301
8301
|
}
|
|
8302
8302
|
}
|
|
8303
8303
|
revert() {
|
|
8304
|
-
this.reverse.forEach(({ item
|
|
8305
|
-
|
|
8304
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
8305
|
+
item.apply(operation);
|
|
8306
8306
|
});
|
|
8307
8307
|
}
|
|
8308
8308
|
getReverse() {
|
|
@@ -9044,8 +9044,8 @@ class Path {
|
|
|
9044
9044
|
}
|
|
9045
9045
|
getIntersectionPoints(segment) {
|
|
9046
9046
|
let intersections = [];
|
|
9047
|
-
for (const
|
|
9048
|
-
intersections = intersections.concat(
|
|
9047
|
+
for (const item of this.segments) {
|
|
9048
|
+
intersections = intersections.concat(item.getIntersectionPoints(segment));
|
|
9049
9049
|
}
|
|
9050
9050
|
return intersections;
|
|
9051
9051
|
}
|
|
@@ -9110,8 +9110,8 @@ class Path {
|
|
|
9110
9110
|
}
|
|
9111
9111
|
isOpenEnclosedOrCrossedBy(rectangle) {
|
|
9112
9112
|
let is = false;
|
|
9113
|
-
for (const
|
|
9114
|
-
is = is ||
|
|
9113
|
+
for (const item of this.segments) {
|
|
9114
|
+
is = is || item.isEnclosedOrCrossedBy(rectangle);
|
|
9115
9115
|
}
|
|
9116
9116
|
return is;
|
|
9117
9117
|
}
|
|
@@ -9524,8 +9524,8 @@ class ConnectorCommand {
|
|
|
9524
9524
|
}
|
|
9525
9525
|
}
|
|
9526
9526
|
revert() {
|
|
9527
|
-
for (const { item
|
|
9528
|
-
|
|
9527
|
+
for (const { item, operation } of this.reverse) {
|
|
9528
|
+
item.apply(operation);
|
|
9529
9529
|
}
|
|
9530
9530
|
}
|
|
9531
9531
|
getReverse() {
|
|
@@ -9682,11 +9682,11 @@ class SessionStorage {
|
|
|
9682
9682
|
}
|
|
9683
9683
|
get(key) {
|
|
9684
9684
|
const boardId = this.getBoardId() || "";
|
|
9685
|
-
const
|
|
9686
|
-
if (!
|
|
9685
|
+
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
9686
|
+
if (!item) {
|
|
9687
9687
|
return;
|
|
9688
9688
|
}
|
|
9689
|
-
return JSON.parse(
|
|
9689
|
+
return JSON.parse(item);
|
|
9690
9690
|
}
|
|
9691
9691
|
remove(key) {
|
|
9692
9692
|
const boardId = this.getBoardId() || "";
|
|
@@ -10466,8 +10466,8 @@ class LinkToCommand {
|
|
|
10466
10466
|
}
|
|
10467
10467
|
}
|
|
10468
10468
|
revert() {
|
|
10469
|
-
this.reverse.forEach(({ item
|
|
10470
|
-
|
|
10469
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
10470
|
+
item.apply(operation);
|
|
10471
10471
|
});
|
|
10472
10472
|
}
|
|
10473
10473
|
getReverse() {
|
|
@@ -11552,9 +11552,9 @@ function handleSplitListItem(editor) {
|
|
|
11552
11552
|
import_slate4.Transforms.insertNodes(editor, {
|
|
11553
11553
|
type: listType,
|
|
11554
11554
|
listLevel: listNode.listLevel || 0,
|
|
11555
|
-
children: itemsAfter.map((
|
|
11555
|
+
children: itemsAfter.map((item) => ({
|
|
11556
11556
|
type: "list_item",
|
|
11557
|
-
children:
|
|
11557
|
+
children: item.children
|
|
11558
11558
|
}))
|
|
11559
11559
|
}, { at: newListPath });
|
|
11560
11560
|
}
|
|
@@ -15412,10 +15412,10 @@ function initializeDocument(effects) {
|
|
|
15412
15412
|
return start;
|
|
15413
15413
|
function start(code) {
|
|
15414
15414
|
if (continued < stack.length) {
|
|
15415
|
-
const
|
|
15416
|
-
self2.containerState =
|
|
15417
|
-
ok(
|
|
15418
|
-
return effects.attempt(
|
|
15415
|
+
const item = stack[continued];
|
|
15416
|
+
self2.containerState = item[1];
|
|
15417
|
+
ok(item[0].continuation, "expected `continuation` to be defined on container construct");
|
|
15418
|
+
return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
|
|
15419
15419
|
}
|
|
15420
15420
|
return checkNewContainers(code);
|
|
15421
15421
|
}
|
|
@@ -16391,17 +16391,17 @@ class SpliceBuffer {
|
|
|
16391
16391
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16392
16392
|
return this.left.pop();
|
|
16393
16393
|
}
|
|
16394
|
-
push(
|
|
16394
|
+
push(item) {
|
|
16395
16395
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16396
|
-
this.left.push(
|
|
16396
|
+
this.left.push(item);
|
|
16397
16397
|
}
|
|
16398
16398
|
pushMany(items) {
|
|
16399
16399
|
this.setCursor(Number.POSITIVE_INFINITY);
|
|
16400
16400
|
chunkedPush(this.left, items);
|
|
16401
16401
|
}
|
|
16402
|
-
unshift(
|
|
16402
|
+
unshift(item) {
|
|
16403
16403
|
this.setCursor(0);
|
|
16404
|
-
this.right.push(
|
|
16404
|
+
this.right.push(item);
|
|
16405
16405
|
}
|
|
16406
16406
|
unshiftMany(items) {
|
|
16407
16407
|
this.setCursor(0);
|
|
@@ -18432,8 +18432,8 @@ function initializeFactory(field) {
|
|
|
18432
18432
|
if (list2) {
|
|
18433
18433
|
ok(Array.isArray(list2), "expected `disable.null` to be populated");
|
|
18434
18434
|
while (++index2 < list2.length) {
|
|
18435
|
-
const
|
|
18436
|
-
if (!
|
|
18435
|
+
const item = list2[index2];
|
|
18436
|
+
if (!item.previous || item.previous.call(self2, self2.previous)) {
|
|
18437
18437
|
return true;
|
|
18438
18438
|
}
|
|
18439
18439
|
}
|
|
@@ -19264,14 +19264,14 @@ function compiler(options) {
|
|
|
19264
19264
|
length++;
|
|
19265
19265
|
}
|
|
19266
19266
|
if (event[1].type === types.listItemPrefix) {
|
|
19267
|
-
const
|
|
19267
|
+
const item = {
|
|
19268
19268
|
type: "listItem",
|
|
19269
19269
|
_spread: false,
|
|
19270
19270
|
start: Object.assign({}, event[1].start),
|
|
19271
19271
|
end: undefined
|
|
19272
19272
|
};
|
|
19273
|
-
listItem2 =
|
|
19274
|
-
events.splice(index2, 0, ["enter",
|
|
19273
|
+
listItem2 = item;
|
|
19274
|
+
events.splice(index2, 0, ["enter", item, event[2]]);
|
|
19275
19275
|
index2++;
|
|
19276
19276
|
length++;
|
|
19277
19277
|
firstBlankLineIndex = undefined;
|
|
@@ -19903,14 +19903,14 @@ class MarkdownProcessor {
|
|
|
19903
19903
|
if (err || !file) {
|
|
19904
19904
|
throw err;
|
|
19905
19905
|
}
|
|
19906
|
-
const nodes = file.result.map((
|
|
19906
|
+
const nodes = file.result.map((item) => {
|
|
19907
19907
|
setNodeStyles({
|
|
19908
|
-
node:
|
|
19908
|
+
node: item,
|
|
19909
19909
|
editor: this.editor,
|
|
19910
19910
|
horisontalAlignment: "left",
|
|
19911
|
-
isPaddingTopNeeded:
|
|
19911
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
19912
19912
|
});
|
|
19913
|
-
return
|
|
19913
|
+
return item;
|
|
19914
19914
|
});
|
|
19915
19915
|
if (isNewParagraphNeeded) {
|
|
19916
19916
|
nodes.push(createParagraphNode("", this.editor));
|
|
@@ -20888,8 +20888,8 @@ class ShapeCommand {
|
|
|
20888
20888
|
}
|
|
20889
20889
|
}
|
|
20890
20890
|
revert() {
|
|
20891
|
-
for (const { item
|
|
20892
|
-
|
|
20891
|
+
for (const { item, operation } of this.reverse) {
|
|
20892
|
+
item.apply(operation);
|
|
20893
20893
|
}
|
|
20894
20894
|
}
|
|
20895
20895
|
getReverse() {
|
|
@@ -20971,8 +20971,8 @@ class RichTextCommand {
|
|
|
20971
20971
|
}
|
|
20972
20972
|
}
|
|
20973
20973
|
revert() {
|
|
20974
|
-
for (const { item
|
|
20975
|
-
const richText = this.board.items.getById(
|
|
20974
|
+
for (const { item, operation } of this.reverse) {
|
|
20975
|
+
const richText = this.board.items.getById(item);
|
|
20976
20976
|
if (!richText) {
|
|
20977
20977
|
continue;
|
|
20978
20978
|
}
|
|
@@ -20991,12 +20991,12 @@ class RichTextCommand {
|
|
|
20991
20991
|
case "setSelectionFontColor":
|
|
20992
20992
|
case "setSelectionBlockType":
|
|
20993
20993
|
const inverseOps = this.operation.ops.map((op) => import_slate33.Operation.inverse(op)).reverse();
|
|
20994
|
-
return items.map((
|
|
20994
|
+
return items.map((item) => {
|
|
20995
20995
|
const operation = {
|
|
20996
20996
|
...this.operation,
|
|
20997
20997
|
ops: inverseOps
|
|
20998
20998
|
};
|
|
20999
|
-
return { item
|
|
20999
|
+
return { item, operation };
|
|
21000
21000
|
});
|
|
21001
21001
|
case "setFontColor":
|
|
21002
21002
|
return items.map((id) => ({
|
|
@@ -21088,13 +21088,13 @@ class RichTextGroupCommand {
|
|
|
21088
21088
|
this.reverseOps = this.getReverse();
|
|
21089
21089
|
}
|
|
21090
21090
|
apply() {
|
|
21091
|
-
for (const { item
|
|
21092
|
-
|
|
21091
|
+
for (const { item, operation } of this.forwardOps) {
|
|
21092
|
+
item.applyCommand(operation);
|
|
21093
21093
|
}
|
|
21094
21094
|
}
|
|
21095
21095
|
revert() {
|
|
21096
|
-
for (const { item
|
|
21097
|
-
|
|
21096
|
+
for (const { item, operation } of this.reverseOps) {
|
|
21097
|
+
item.applyCommand(operation);
|
|
21098
21098
|
}
|
|
21099
21099
|
}
|
|
21100
21100
|
getForward() {
|
|
@@ -21209,8 +21209,8 @@ class DrawingCommand {
|
|
|
21209
21209
|
item;
|
|
21210
21210
|
operation;
|
|
21211
21211
|
reverse;
|
|
21212
|
-
constructor(
|
|
21213
|
-
this.item =
|
|
21212
|
+
constructor(item, operation) {
|
|
21213
|
+
this.item = item;
|
|
21214
21214
|
this.operation = operation;
|
|
21215
21215
|
this.reverse = this.getReverse();
|
|
21216
21216
|
}
|
|
@@ -21219,52 +21219,52 @@ class DrawingCommand {
|
|
|
21219
21219
|
return this;
|
|
21220
21220
|
}
|
|
21221
21221
|
apply() {
|
|
21222
|
-
for (const
|
|
21223
|
-
|
|
21222
|
+
for (const item of this.item) {
|
|
21223
|
+
item.apply(this.operation);
|
|
21224
21224
|
}
|
|
21225
21225
|
}
|
|
21226
21226
|
revert() {
|
|
21227
|
-
for (const { item
|
|
21228
|
-
|
|
21227
|
+
for (const { item, operation } of this.reverse) {
|
|
21228
|
+
item.apply(operation);
|
|
21229
21229
|
}
|
|
21230
21230
|
}
|
|
21231
21231
|
getReverse() {
|
|
21232
21232
|
const reverse = [];
|
|
21233
|
-
for (const
|
|
21234
|
-
reverse.push({ item
|
|
21233
|
+
for (const item of this.item) {
|
|
21234
|
+
reverse.push({ item, operation: this.getReverseOperation(item) });
|
|
21235
21235
|
}
|
|
21236
21236
|
return reverse;
|
|
21237
21237
|
}
|
|
21238
|
-
getReverseOperation(
|
|
21238
|
+
getReverseOperation(item) {
|
|
21239
21239
|
switch (this.operation.method) {
|
|
21240
21240
|
case "setStrokeColor":
|
|
21241
21241
|
return {
|
|
21242
21242
|
class: "Drawing",
|
|
21243
21243
|
method: "setStrokeColor",
|
|
21244
|
-
item: [
|
|
21245
|
-
color:
|
|
21244
|
+
item: [item.getId()],
|
|
21245
|
+
color: item.getStrokeColor()
|
|
21246
21246
|
};
|
|
21247
21247
|
case "setStrokeWidth":
|
|
21248
21248
|
return {
|
|
21249
21249
|
class: "Drawing",
|
|
21250
21250
|
method: "setStrokeWidth",
|
|
21251
|
-
item: [
|
|
21251
|
+
item: [item.getId()],
|
|
21252
21252
|
width: this.operation.prevWidth,
|
|
21253
|
-
prevWidth:
|
|
21253
|
+
prevWidth: item.getStrokeWidth()
|
|
21254
21254
|
};
|
|
21255
21255
|
case "setStrokeOpacity":
|
|
21256
21256
|
return {
|
|
21257
21257
|
class: "Drawing",
|
|
21258
21258
|
method: "setStrokeOpacity",
|
|
21259
|
-
item: [
|
|
21260
|
-
opacity:
|
|
21259
|
+
item: [item.getId()],
|
|
21260
|
+
opacity: item.getStrokeOpacity()
|
|
21261
21261
|
};
|
|
21262
21262
|
case "setStrokeStyle":
|
|
21263
21263
|
return {
|
|
21264
21264
|
class: "Drawing",
|
|
21265
21265
|
method: "setStrokeStyle",
|
|
21266
|
-
item: [
|
|
21267
|
-
style:
|
|
21266
|
+
item: [item.getId()],
|
|
21267
|
+
style: item.getBorderStyle()
|
|
21268
21268
|
};
|
|
21269
21269
|
}
|
|
21270
21270
|
}
|
|
@@ -21286,8 +21286,8 @@ class StickerCommand {
|
|
|
21286
21286
|
}
|
|
21287
21287
|
}
|
|
21288
21288
|
revert() {
|
|
21289
|
-
for (const { item
|
|
21290
|
-
|
|
21289
|
+
for (const { item, operation } of this.reverse) {
|
|
21290
|
+
item.apply(operation);
|
|
21291
21291
|
}
|
|
21292
21292
|
}
|
|
21293
21293
|
getReverse() {
|
|
@@ -21319,8 +21319,8 @@ class FrameCommand {
|
|
|
21319
21319
|
}
|
|
21320
21320
|
}
|
|
21321
21321
|
revert() {
|
|
21322
|
-
for (const { item
|
|
21323
|
-
|
|
21322
|
+
for (const { item, operation } of this.reverse) {
|
|
21323
|
+
item.apply(operation);
|
|
21324
21324
|
}
|
|
21325
21325
|
}
|
|
21326
21326
|
getReverse() {
|
|
@@ -21362,21 +21362,23 @@ class FrameCommand {
|
|
|
21362
21362
|
};
|
|
21363
21363
|
});
|
|
21364
21364
|
default:
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21365
|
+
return mapItemsByOperation(frame, (item) => {
|
|
21366
|
+
const op = this.operation;
|
|
21367
|
+
let newData = {};
|
|
21368
|
+
if (op.prevData) {
|
|
21369
|
+
newData = { ...op.prevData };
|
|
21370
|
+
} else {
|
|
21371
|
+
Object.keys(op.newData).forEach((key) => {
|
|
21372
|
+
if (item[key]) {
|
|
21373
|
+
newData[key] = item[key];
|
|
21374
|
+
}
|
|
21375
|
+
});
|
|
21376
|
+
}
|
|
21377
|
+
return {
|
|
21378
|
+
...op,
|
|
21379
|
+
newData
|
|
21380
|
+
};
|
|
21381
|
+
});
|
|
21380
21382
|
}
|
|
21381
21383
|
}
|
|
21382
21384
|
}
|
|
@@ -21397,8 +21399,8 @@ class CommentCommand {
|
|
|
21397
21399
|
}
|
|
21398
21400
|
}
|
|
21399
21401
|
revert() {
|
|
21400
|
-
this.reverse.forEach(({ item
|
|
21401
|
-
|
|
21402
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
21403
|
+
item.apply(operation);
|
|
21402
21404
|
});
|
|
21403
21405
|
}
|
|
21404
21406
|
getReverse() {
|
|
@@ -21859,8 +21861,8 @@ class GroupCommand {
|
|
|
21859
21861
|
}
|
|
21860
21862
|
}
|
|
21861
21863
|
revert() {
|
|
21862
|
-
for (const { item
|
|
21863
|
-
|
|
21864
|
+
for (const { item, operation } of this.reverse) {
|
|
21865
|
+
item.apply(operation);
|
|
21864
21866
|
}
|
|
21865
21867
|
}
|
|
21866
21868
|
getReverse() {
|
|
@@ -21913,8 +21915,8 @@ class PlaceholderCommand {
|
|
|
21913
21915
|
}
|
|
21914
21916
|
}
|
|
21915
21917
|
revert() {
|
|
21916
|
-
for (const { item
|
|
21917
|
-
|
|
21918
|
+
for (const { item, operation } of this.reverse) {
|
|
21919
|
+
item.apply(operation);
|
|
21918
21920
|
}
|
|
21919
21921
|
}
|
|
21920
21922
|
getReverse() {
|
|
@@ -22008,34 +22010,51 @@ class BaseCommand {
|
|
|
22008
22010
|
return this;
|
|
22009
22011
|
}
|
|
22010
22012
|
apply() {
|
|
22011
|
-
for (const
|
|
22012
|
-
|
|
22013
|
+
for (const item of this.items) {
|
|
22014
|
+
item.apply(this.operation);
|
|
22013
22015
|
}
|
|
22014
22016
|
}
|
|
22015
22017
|
revert() {
|
|
22016
|
-
for (const { item
|
|
22017
|
-
|
|
22018
|
+
for (const { item, operation } of this.reverse) {
|
|
22019
|
+
item.apply(operation);
|
|
22018
22020
|
}
|
|
22019
22021
|
}
|
|
22020
22022
|
getReverse() {
|
|
22021
22023
|
const items = this.items;
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
|
|
22024
|
+
switch (this.operation.method) {
|
|
22025
|
+
case "addChildren":
|
|
22026
|
+
return mapItemsByOperation(items, (item) => {
|
|
22027
|
+
return {
|
|
22028
|
+
...this.operation,
|
|
22029
|
+
newData: { childIds: item.getChildrenIds() }
|
|
22030
|
+
};
|
|
22031
|
+
});
|
|
22032
|
+
case "removeChildren":
|
|
22033
|
+
return mapItemsByOperation(items, (item) => {
|
|
22034
|
+
return {
|
|
22035
|
+
...this.operation,
|
|
22036
|
+
newData: { childIds: item.getChildrenIds() }
|
|
22037
|
+
};
|
|
22038
|
+
});
|
|
22039
|
+
default:
|
|
22040
|
+
return mapItemsByOperation(items, (item) => {
|
|
22041
|
+
const op = this.operation;
|
|
22042
|
+
let newData = {};
|
|
22043
|
+
if (op.prevData) {
|
|
22044
|
+
newData = { ...op.prevData };
|
|
22045
|
+
} else {
|
|
22046
|
+
Object.keys(op.newData).forEach((key) => {
|
|
22047
|
+
if (item[key]) {
|
|
22048
|
+
newData[key] = item[key];
|
|
22049
|
+
}
|
|
22050
|
+
});
|
|
22031
22051
|
}
|
|
22052
|
+
return {
|
|
22053
|
+
...op,
|
|
22054
|
+
newData
|
|
22055
|
+
};
|
|
22032
22056
|
});
|
|
22033
|
-
|
|
22034
|
-
return {
|
|
22035
|
-
...op,
|
|
22036
|
-
newData
|
|
22037
|
-
};
|
|
22038
|
-
});
|
|
22057
|
+
}
|
|
22039
22058
|
}
|
|
22040
22059
|
}
|
|
22041
22060
|
var itemCommandFactories = {
|
|
@@ -22055,37 +22074,37 @@ var itemCommandFactories = {
|
|
|
22055
22074
|
LinkTo: createLinkToCommand
|
|
22056
22075
|
};
|
|
22057
22076
|
function createConnectorCommand(items, operation) {
|
|
22058
|
-
return new ConnectorCommand(items.filter((
|
|
22077
|
+
return new ConnectorCommand(items.filter((item) => item.itemType === "Connector"), operation);
|
|
22059
22078
|
}
|
|
22060
22079
|
function createShapeCommand(items, operation) {
|
|
22061
|
-
return new ShapeCommand(items.filter((
|
|
22080
|
+
return new ShapeCommand(items.filter((item) => item.itemType === "Shape"), operation);
|
|
22062
22081
|
}
|
|
22063
22082
|
function createDrawingCommand(items, operation) {
|
|
22064
|
-
return new DrawingCommand(items.filter((
|
|
22083
|
+
return new DrawingCommand(items.filter((item) => item.itemType === "Drawing"), operation);
|
|
22065
22084
|
}
|
|
22066
22085
|
function createCommentCommand(items, operation) {
|
|
22067
|
-
return new CommentCommand(items.filter((
|
|
22086
|
+
return new CommentCommand(items.filter((item) => item.itemType === "Comment"), operation);
|
|
22068
22087
|
}
|
|
22069
22088
|
function createStickerCommand(items, operation) {
|
|
22070
|
-
return new StickerCommand(items.filter((
|
|
22089
|
+
return new StickerCommand(items.filter((item) => item.itemType === "Sticker"), operation);
|
|
22071
22090
|
}
|
|
22072
22091
|
function createFrameCommand(items, operation) {
|
|
22073
|
-
return new FrameCommand(items.filter((
|
|
22092
|
+
return new FrameCommand(items.filter((item) => item.itemType === "Frame"), operation);
|
|
22074
22093
|
}
|
|
22075
22094
|
function createPlaceholderCommand(items, operation) {
|
|
22076
|
-
return new PlaceholderCommand(items.filter((
|
|
22095
|
+
return new PlaceholderCommand(items.filter((item) => item.itemType === "Placeholder"), operation);
|
|
22077
22096
|
}
|
|
22078
22097
|
function createGroupCommand(items, operation) {
|
|
22079
|
-
return new GroupCommand(items.filter((
|
|
22098
|
+
return new GroupCommand(items.filter((item) => item.itemType === "Group"), operation);
|
|
22080
22099
|
}
|
|
22081
22100
|
function createImageCommand(items, operation) {
|
|
22082
|
-
return new ImageCommand(items.filter((
|
|
22101
|
+
return new ImageCommand(items.filter((item) => item.itemType === "Image"), operation);
|
|
22083
22102
|
}
|
|
22084
22103
|
function createVideoCommand(items, operation) {
|
|
22085
|
-
return new VideoCommand(items.filter((
|
|
22104
|
+
return new VideoCommand(items.filter((item) => item.itemType === "Video"), operation);
|
|
22086
22105
|
}
|
|
22087
22106
|
function createAudioCommand(items, operation) {
|
|
22088
|
-
return new AudioCommand(items.filter((
|
|
22107
|
+
return new AudioCommand(items.filter((item) => item.itemType === "Audio"), operation);
|
|
22089
22108
|
}
|
|
22090
22109
|
function createRichTextCommand(items, operation, board) {
|
|
22091
22110
|
if (!board) {
|
|
@@ -22093,8 +22112,8 @@ function createRichTextCommand(items, operation, board) {
|
|
|
22093
22112
|
}
|
|
22094
22113
|
if (operation.method === "groupEdit") {
|
|
22095
22114
|
const texts = [];
|
|
22096
|
-
for (const { item
|
|
22097
|
-
const found = board.items.findById(
|
|
22115
|
+
for (const { item } of operation.itemsOps) {
|
|
22116
|
+
const found = board.items.findById(item);
|
|
22098
22117
|
const text3 = found?.getRichText();
|
|
22099
22118
|
if (text3) {
|
|
22100
22119
|
texts.push(text3);
|
|
@@ -22102,14 +22121,14 @@ function createRichTextCommand(items, operation, board) {
|
|
|
22102
22121
|
}
|
|
22103
22122
|
return new RichTextGroupCommand(texts, operation);
|
|
22104
22123
|
} else {
|
|
22105
|
-
return new RichTextCommand(board, items.map((
|
|
22124
|
+
return new RichTextCommand(board, items.map((item) => item.getId()), operation);
|
|
22106
22125
|
}
|
|
22107
22126
|
}
|
|
22108
22127
|
function createTransformationCommand(items, operation) {
|
|
22109
|
-
return new TransformationCommand(items.map((
|
|
22128
|
+
return new TransformationCommand(items.map((item) => item.transformation), operation);
|
|
22110
22129
|
}
|
|
22111
22130
|
function createLinkToCommand(items, operation) {
|
|
22112
|
-
return new LinkToCommand(items.map((
|
|
22131
|
+
return new LinkToCommand(items.map((item) => item.linkTo), operation);
|
|
22113
22132
|
}
|
|
22114
22133
|
function createCommand(board, operation) {
|
|
22115
22134
|
try {
|
|
@@ -22127,13 +22146,13 @@ function createCommand(board, operation) {
|
|
|
22127
22146
|
default: {
|
|
22128
22147
|
const itemType = operation.class;
|
|
22129
22148
|
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);
|
|
22130
|
-
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((
|
|
22131
|
-
if (typeof
|
|
22132
|
-
console.warn(`Item with ID ${
|
|
22149
|
+
const items = itemIdList.map((itemId) => board.items.findById(itemId) ?? itemId).filter((item) => {
|
|
22150
|
+
if (typeof item === "string") {
|
|
22151
|
+
console.warn(`Item with ID ${item} not found for operation ${operation.class}.${operation.method}`);
|
|
22133
22152
|
return false;
|
|
22134
22153
|
}
|
|
22135
|
-
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" &&
|
|
22136
|
-
console.warn(`Item with ID ${
|
|
22154
|
+
if (operation.class !== "Transformation" && operation.class !== "RichText" && operation.class !== "LinkTo" && item.itemType !== operation.class) {
|
|
22155
|
+
console.warn(`Item with ID ${item} is not of operation type: ${itemType}.`);
|
|
22137
22156
|
return false;
|
|
22138
22157
|
}
|
|
22139
22158
|
return true;
|
|
@@ -22434,20 +22453,20 @@ class RBush {
|
|
|
22434
22453
|
}
|
|
22435
22454
|
return this;
|
|
22436
22455
|
}
|
|
22437
|
-
insert(
|
|
22438
|
-
if (
|
|
22439
|
-
this._insert(
|
|
22456
|
+
insert(item) {
|
|
22457
|
+
if (item)
|
|
22458
|
+
this._insert(item, this.data.height - 1);
|
|
22440
22459
|
return this;
|
|
22441
22460
|
}
|
|
22442
22461
|
clear() {
|
|
22443
22462
|
this.data = createNode([]);
|
|
22444
22463
|
return this;
|
|
22445
22464
|
}
|
|
22446
|
-
remove(
|
|
22447
|
-
if (!
|
|
22465
|
+
remove(item, equalsFn) {
|
|
22466
|
+
if (!item)
|
|
22448
22467
|
return this;
|
|
22449
22468
|
let node2 = this.data;
|
|
22450
|
-
const bbox = this.toBBox(
|
|
22469
|
+
const bbox = this.toBBox(item);
|
|
22451
22470
|
const path2 = [];
|
|
22452
22471
|
const indexes = [];
|
|
22453
22472
|
let i, parent, goingUp;
|
|
@@ -22459,7 +22478,7 @@ class RBush {
|
|
|
22459
22478
|
goingUp = true;
|
|
22460
22479
|
}
|
|
22461
22480
|
if (node2.leaf) {
|
|
22462
|
-
const index2 = findItem(
|
|
22481
|
+
const index2 = findItem(item, node2.children, equalsFn);
|
|
22463
22482
|
if (index2 !== -1) {
|
|
22464
22483
|
node2.children.splice(index2, 1);
|
|
22465
22484
|
path2.push(node2);
|
|
@@ -22482,8 +22501,8 @@ class RBush {
|
|
|
22482
22501
|
}
|
|
22483
22502
|
return this;
|
|
22484
22503
|
}
|
|
22485
|
-
toBBox(
|
|
22486
|
-
return
|
|
22504
|
+
toBBox(item) {
|
|
22505
|
+
return item;
|
|
22487
22506
|
}
|
|
22488
22507
|
compareMinX(a, b) {
|
|
22489
22508
|
return a.minX - b.minX;
|
|
@@ -22566,11 +22585,11 @@ class RBush {
|
|
|
22566
22585
|
}
|
|
22567
22586
|
return node2;
|
|
22568
22587
|
}
|
|
22569
|
-
_insert(
|
|
22570
|
-
const bbox = isNode ?
|
|
22588
|
+
_insert(item, level, isNode) {
|
|
22589
|
+
const bbox = isNode ? item : this.toBBox(item);
|
|
22571
22590
|
const insertPath = [];
|
|
22572
22591
|
const node2 = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
22573
|
-
node2.children.push(
|
|
22592
|
+
node2.children.push(item);
|
|
22574
22593
|
extend2(node2, bbox);
|
|
22575
22594
|
while (level >= 0) {
|
|
22576
22595
|
if (insertPath[level].children.length > this._maxEntries) {
|
|
@@ -22669,11 +22688,11 @@ class RBush {
|
|
|
22669
22688
|
}
|
|
22670
22689
|
}
|
|
22671
22690
|
}
|
|
22672
|
-
function findItem(
|
|
22691
|
+
function findItem(item, items, equalsFn) {
|
|
22673
22692
|
if (!equalsFn)
|
|
22674
|
-
return items.indexOf(
|
|
22693
|
+
return items.indexOf(item);
|
|
22675
22694
|
for (let i = 0;i < items.length; i++) {
|
|
22676
|
-
if (equalsFn(
|
|
22695
|
+
if (equalsFn(item, items[i]))
|
|
22677
22696
|
return i;
|
|
22678
22697
|
}
|
|
22679
22698
|
return -1;
|
|
@@ -22835,10 +22854,10 @@ class RTreeIndex {
|
|
|
22835
22854
|
return container ? container.item : undefined;
|
|
22836
22855
|
}
|
|
22837
22856
|
remove(id) {
|
|
22838
|
-
const
|
|
22839
|
-
if (
|
|
22857
|
+
const item = this.map.get(id);
|
|
22858
|
+
if (item) {
|
|
22840
22859
|
this.map.delete(id);
|
|
22841
|
-
this.tree.remove(
|
|
22860
|
+
this.tree.remove(item);
|
|
22842
22861
|
}
|
|
22843
22862
|
}
|
|
22844
22863
|
list() {
|
|
@@ -22910,11 +22929,11 @@ class Container extends Mbr {
|
|
|
22910
22929
|
item;
|
|
22911
22930
|
layer;
|
|
22912
22931
|
zIndex;
|
|
22913
|
-
constructor(id,
|
|
22914
|
-
const rect =
|
|
22932
|
+
constructor(id, item, layer, zIndex) {
|
|
22933
|
+
const rect = item.getMbrWithChildren();
|
|
22915
22934
|
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
22916
22935
|
this.id = id;
|
|
22917
|
-
this.item =
|
|
22936
|
+
this.item = item;
|
|
22918
22937
|
this.layer = layer;
|
|
22919
22938
|
this.zIndex = zIndex;
|
|
22920
22939
|
}
|
|
@@ -22931,7 +22950,7 @@ class LayeredIndex {
|
|
|
22931
22950
|
this.getZIndex = this.getZIndex.bind(this);
|
|
22932
22951
|
this.layers.newOnTop();
|
|
22933
22952
|
}
|
|
22934
|
-
isT(
|
|
22953
|
+
isT(item) {
|
|
22935
22954
|
return true;
|
|
22936
22955
|
}
|
|
22937
22956
|
findById(id) {
|
|
@@ -22995,8 +23014,8 @@ class LayeredIndex {
|
|
|
22995
23014
|
}
|
|
22996
23015
|
getContainersFromItems(items) {
|
|
22997
23016
|
const containers = [];
|
|
22998
|
-
for (const
|
|
22999
|
-
const container = this.map.get(
|
|
23017
|
+
for (const item of items) {
|
|
23018
|
+
const container = this.map.get(item.getId());
|
|
23000
23019
|
if (container) {
|
|
23001
23020
|
containers.push(container);
|
|
23002
23021
|
}
|
|
@@ -23073,9 +23092,9 @@ class LayeredIndex {
|
|
|
23073
23092
|
}
|
|
23074
23093
|
}
|
|
23075
23094
|
}
|
|
23076
|
-
insert(
|
|
23077
|
-
const toInsert = new Container(
|
|
23078
|
-
const bounds =
|
|
23095
|
+
insert(item) {
|
|
23096
|
+
const toInsert = new Container(item.getId(), item, 0, this.getZIndex(item));
|
|
23097
|
+
const bounds = item.getMbrWithChildren();
|
|
23079
23098
|
const inBounds = this.getRectsEnclosedOrCrossedBy(bounds);
|
|
23080
23099
|
if (inBounds.length === 0) {
|
|
23081
23100
|
return this.insertContainer(toInsert);
|
|
@@ -23142,20 +23161,20 @@ class LayeredIndex {
|
|
|
23142
23161
|
}
|
|
23143
23162
|
}
|
|
23144
23163
|
}
|
|
23145
|
-
change(
|
|
23146
|
-
const id =
|
|
23164
|
+
change(item) {
|
|
23165
|
+
const id = item.getId();
|
|
23147
23166
|
const container = this.map.get(id);
|
|
23148
23167
|
if (container) {
|
|
23149
23168
|
const layer = this.layers.get(container.layer);
|
|
23150
23169
|
if (layer) {
|
|
23151
23170
|
layer.remove(id);
|
|
23152
23171
|
this.map.delete(id);
|
|
23153
|
-
this.insert(
|
|
23172
|
+
this.insert(item);
|
|
23154
23173
|
}
|
|
23155
23174
|
}
|
|
23156
23175
|
}
|
|
23157
|
-
remove(
|
|
23158
|
-
const id =
|
|
23176
|
+
remove(item) {
|
|
23177
|
+
const id = item.getId();
|
|
23159
23178
|
const container = this.map.get(id);
|
|
23160
23179
|
if (container) {
|
|
23161
23180
|
const layer = this.layers.get(container.layer);
|
|
@@ -23181,13 +23200,13 @@ class LayeredIndex {
|
|
|
23181
23200
|
return items;
|
|
23182
23201
|
}
|
|
23183
23202
|
batchInsert(items) {
|
|
23184
|
-
for (const
|
|
23185
|
-
this.insert(
|
|
23203
|
+
for (const item of items) {
|
|
23204
|
+
this.insert(item);
|
|
23186
23205
|
}
|
|
23187
23206
|
}
|
|
23188
23207
|
batchChange(items) {
|
|
23189
|
-
for (const
|
|
23190
|
-
this.change(
|
|
23208
|
+
for (const item of items) {
|
|
23209
|
+
this.change(item);
|
|
23191
23210
|
}
|
|
23192
23211
|
}
|
|
23193
23212
|
}
|
|
@@ -23196,8 +23215,8 @@ class LayeredIndex {
|
|
|
23196
23215
|
class SpatialIndex {
|
|
23197
23216
|
subject = new Subject;
|
|
23198
23217
|
itemsArray = [];
|
|
23199
|
-
itemsIndex = new LayeredIndex((
|
|
23200
|
-
return this.itemsArray.indexOf(
|
|
23218
|
+
itemsIndex = new LayeredIndex((item) => {
|
|
23219
|
+
return this.itemsArray.indexOf(item);
|
|
23201
23220
|
});
|
|
23202
23221
|
Mbr = new Mbr;
|
|
23203
23222
|
items;
|
|
@@ -23206,79 +23225,79 @@ class SpatialIndex {
|
|
|
23206
23225
|
}
|
|
23207
23226
|
clear() {
|
|
23208
23227
|
this.itemsArray = [];
|
|
23209
|
-
this.itemsIndex = new LayeredIndex((
|
|
23210
|
-
return this.itemsArray.indexOf(
|
|
23228
|
+
this.itemsIndex = new LayeredIndex((item) => {
|
|
23229
|
+
return this.itemsArray.indexOf(item);
|
|
23211
23230
|
});
|
|
23212
23231
|
this.Mbr = new Mbr;
|
|
23213
23232
|
}
|
|
23214
|
-
insert(
|
|
23215
|
-
this.itemsArray.push(
|
|
23216
|
-
this.itemsIndex.insert(
|
|
23233
|
+
insert(item) {
|
|
23234
|
+
this.itemsArray.push(item);
|
|
23235
|
+
this.itemsIndex.insert(item);
|
|
23217
23236
|
if (conf.isNode()) {
|
|
23218
23237
|
return;
|
|
23219
23238
|
}
|
|
23220
23239
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23221
|
-
this.Mbr =
|
|
23240
|
+
this.Mbr = item.getMbr().copy();
|
|
23222
23241
|
} else {
|
|
23223
|
-
this.Mbr.combine([
|
|
23242
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23224
23243
|
}
|
|
23225
|
-
|
|
23244
|
+
item.subject.subscribe(this.change);
|
|
23226
23245
|
this.subject.publish(this.items);
|
|
23227
23246
|
}
|
|
23228
|
-
change = (
|
|
23229
|
-
this.itemsIndex.change(
|
|
23247
|
+
change = (item) => {
|
|
23248
|
+
this.itemsIndex.change(item);
|
|
23230
23249
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23231
|
-
this.Mbr =
|
|
23250
|
+
this.Mbr = item.getMbrWithChildren().copy();
|
|
23232
23251
|
} else {
|
|
23233
|
-
this.Mbr.combine([
|
|
23252
|
+
this.Mbr.combine([item.getMbrWithChildren()]);
|
|
23234
23253
|
}
|
|
23235
23254
|
this.subject.publish(this.items);
|
|
23236
23255
|
};
|
|
23237
|
-
remove(
|
|
23238
|
-
if ("index" in
|
|
23239
|
-
|
|
23256
|
+
remove(item) {
|
|
23257
|
+
if ("index" in item && item.index) {
|
|
23258
|
+
item.removeChildItems(item.index.list());
|
|
23240
23259
|
}
|
|
23241
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
23242
|
-
this.itemsIndex.remove(
|
|
23260
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23261
|
+
this.itemsIndex.remove(item);
|
|
23243
23262
|
this.Mbr = new Mbr;
|
|
23244
|
-
this.itemsArray.forEach((
|
|
23263
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
|
|
23245
23264
|
this.subject.publish(this.items);
|
|
23246
23265
|
}
|
|
23247
23266
|
copy() {
|
|
23248
|
-
return this.getItemsWithIncludedChildren(this.itemsArray).map((
|
|
23249
|
-
...
|
|
23250
|
-
id:
|
|
23267
|
+
return this.getItemsWithIncludedChildren(this.itemsArray).map((item) => ({
|
|
23268
|
+
...item.serialize(true),
|
|
23269
|
+
id: item.getId()
|
|
23251
23270
|
}));
|
|
23252
23271
|
}
|
|
23253
23272
|
getItemsWithIncludedChildren(items) {
|
|
23254
|
-
return items.flatMap((
|
|
23255
|
-
if ("index" in
|
|
23256
|
-
return [
|
|
23273
|
+
return items.flatMap((item) => {
|
|
23274
|
+
if ("index" in item && item.index) {
|
|
23275
|
+
return [item, ...item.index.list()];
|
|
23257
23276
|
}
|
|
23258
|
-
return
|
|
23277
|
+
return item;
|
|
23259
23278
|
});
|
|
23260
23279
|
}
|
|
23261
|
-
getItemChildren(
|
|
23262
|
-
if ("index" in
|
|
23263
|
-
return
|
|
23280
|
+
getItemChildren(item) {
|
|
23281
|
+
if ("index" in item && item.index) {
|
|
23282
|
+
return item.index.list();
|
|
23264
23283
|
}
|
|
23265
23284
|
return [];
|
|
23266
23285
|
}
|
|
23267
|
-
getItemParent(
|
|
23268
|
-
if (
|
|
23286
|
+
getItemParent(item) {
|
|
23287
|
+
if (item.parent === "Board") {
|
|
23269
23288
|
return;
|
|
23270
23289
|
}
|
|
23271
|
-
return this.getById(
|
|
23290
|
+
return this.getById(item.parent);
|
|
23272
23291
|
}
|
|
23273
|
-
moveToZIndex(
|
|
23274
|
-
const index2 = this.itemsArray.indexOf(
|
|
23292
|
+
moveToZIndex(item, zIndex) {
|
|
23293
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23275
23294
|
this.itemsArray.splice(index2, 1);
|
|
23276
|
-
this.itemsArray.splice(zIndex, 0,
|
|
23277
|
-
this.change(
|
|
23295
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
23296
|
+
this.change(item);
|
|
23278
23297
|
this.subject.publish(this.items);
|
|
23279
23298
|
}
|
|
23280
23299
|
moveManyToZIndex(itemsRecord) {
|
|
23281
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
23300
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
23282
23301
|
const zIndex = Object.values(itemsRecord);
|
|
23283
23302
|
for (let i = 0;i < zIndex.length; i++) {
|
|
23284
23303
|
const index2 = zIndex[i];
|
|
@@ -23286,39 +23305,39 @@ class SpatialIndex {
|
|
|
23286
23305
|
}
|
|
23287
23306
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23288
23307
|
}
|
|
23289
|
-
sendToBack(
|
|
23290
|
-
const index2 = this.itemsArray.indexOf(
|
|
23308
|
+
sendToBack(item, shouldPublish = true) {
|
|
23309
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23291
23310
|
this.itemsArray.splice(index2, 1);
|
|
23292
|
-
this.itemsArray.unshift(
|
|
23293
|
-
this.itemsIndex.change(
|
|
23311
|
+
this.itemsArray.unshift(item);
|
|
23312
|
+
this.itemsIndex.change(item);
|
|
23294
23313
|
if (shouldPublish) {
|
|
23295
23314
|
this.subject.publish(this.items);
|
|
23296
23315
|
}
|
|
23297
23316
|
}
|
|
23298
23317
|
sendManyToBack(items) {
|
|
23299
23318
|
const newItems = [...items];
|
|
23300
|
-
this.itemsArray.forEach((
|
|
23301
|
-
if (!items.includes(
|
|
23302
|
-
newItems.push(
|
|
23319
|
+
this.itemsArray.forEach((item) => {
|
|
23320
|
+
if (!items.includes(item)) {
|
|
23321
|
+
newItems.push(item);
|
|
23303
23322
|
}
|
|
23304
23323
|
});
|
|
23305
23324
|
this.itemsArray = newItems;
|
|
23306
23325
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23307
23326
|
}
|
|
23308
|
-
bringToFront(
|
|
23309
|
-
const index2 = this.itemsArray.indexOf(
|
|
23327
|
+
bringToFront(item, shouldPublish = true) {
|
|
23328
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23310
23329
|
this.itemsArray.splice(index2, 1);
|
|
23311
|
-
this.itemsArray.push(
|
|
23312
|
-
this.itemsIndex.change(
|
|
23330
|
+
this.itemsArray.push(item);
|
|
23331
|
+
this.itemsIndex.change(item);
|
|
23313
23332
|
if (shouldPublish) {
|
|
23314
23333
|
this.subject.publish(this.items);
|
|
23315
23334
|
}
|
|
23316
23335
|
}
|
|
23317
23336
|
bringManyToFront(items) {
|
|
23318
23337
|
const newItems = [];
|
|
23319
|
-
this.itemsArray.forEach((
|
|
23320
|
-
if (!items.includes(
|
|
23321
|
-
newItems.push(
|
|
23338
|
+
this.itemsArray.forEach((item) => {
|
|
23339
|
+
if (!items.includes(item)) {
|
|
23340
|
+
newItems.push(item);
|
|
23322
23341
|
}
|
|
23323
23342
|
});
|
|
23324
23343
|
newItems.push(...items);
|
|
@@ -23344,9 +23363,9 @@ class SpatialIndex {
|
|
|
23344
23363
|
this.subject.publish(this.items);
|
|
23345
23364
|
}
|
|
23346
23365
|
getById(id) {
|
|
23347
|
-
const
|
|
23348
|
-
if (
|
|
23349
|
-
return
|
|
23366
|
+
const item = this.getItemsWithIncludedChildren(this.itemsArray).find((item2) => item2.getId() === id);
|
|
23367
|
+
if (item) {
|
|
23368
|
+
return item;
|
|
23350
23369
|
}
|
|
23351
23370
|
}
|
|
23352
23371
|
findById(id) {
|
|
@@ -23356,10 +23375,10 @@ class SpatialIndex {
|
|
|
23356
23375
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23357
23376
|
const items = this.itemsIndex.getEnclosed(mbr);
|
|
23358
23377
|
const children = [];
|
|
23359
|
-
const clearItems = items.filter((
|
|
23360
|
-
if ("index" in
|
|
23361
|
-
children.push(...
|
|
23362
|
-
if (!
|
|
23378
|
+
const clearItems = items.filter((item) => {
|
|
23379
|
+
if ("index" in item && item.index) {
|
|
23380
|
+
children.push(...item.index.getEnclosed(left, top, right, bottom));
|
|
23381
|
+
if (!item.getMbr().isEnclosedBy(mbr)) {
|
|
23363
23382
|
return false;
|
|
23364
23383
|
}
|
|
23365
23384
|
}
|
|
@@ -23371,10 +23390,10 @@ class SpatialIndex {
|
|
|
23371
23390
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23372
23391
|
const items = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
23373
23392
|
const children = [];
|
|
23374
|
-
const clearItems = items.filter((
|
|
23375
|
-
if ("index" in
|
|
23376
|
-
children.push(...
|
|
23377
|
-
if (!
|
|
23393
|
+
const clearItems = items.filter((item) => {
|
|
23394
|
+
if ("index" in item && item.index) {
|
|
23395
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
23396
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
23378
23397
|
return false;
|
|
23379
23398
|
}
|
|
23380
23399
|
}
|
|
@@ -23385,10 +23404,10 @@ class SpatialIndex {
|
|
|
23385
23404
|
getUnderPoint(point3, tolerance = 5) {
|
|
23386
23405
|
const items = this.itemsIndex.getUnderPoint(point3, tolerance);
|
|
23387
23406
|
const children = [];
|
|
23388
|
-
const clearItems = items.filter((
|
|
23389
|
-
if ("index" in
|
|
23390
|
-
children.push(...
|
|
23391
|
-
if (!
|
|
23407
|
+
const clearItems = items.filter((item) => {
|
|
23408
|
+
if ("index" in item && item.index) {
|
|
23409
|
+
children.push(...item.index.getUnderPoint(point3, tolerance));
|
|
23410
|
+
if (!item.getMbr().isUnderPoint(point3)) {
|
|
23392
23411
|
return false;
|
|
23393
23412
|
}
|
|
23394
23413
|
}
|
|
@@ -23400,10 +23419,10 @@ class SpatialIndex {
|
|
|
23400
23419
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23401
23420
|
const items = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
23402
23421
|
const children = [];
|
|
23403
|
-
const clearItems = items.filter((
|
|
23404
|
-
if ("index" in
|
|
23405
|
-
children.push(...
|
|
23406
|
-
if (!
|
|
23422
|
+
const clearItems = items.filter((item) => {
|
|
23423
|
+
if ("index" in item && item.index) {
|
|
23424
|
+
children.push(...item.index.getEnclosedOrCrossed(left, top, right, bottom));
|
|
23425
|
+
if (!item.getMbr().isEnclosedOrCrossedBy(mbr)) {
|
|
23407
23426
|
return false;
|
|
23408
23427
|
}
|
|
23409
23428
|
}
|
|
@@ -23415,26 +23434,26 @@ class SpatialIndex {
|
|
|
23415
23434
|
return this.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
23416
23435
|
}
|
|
23417
23436
|
getComments() {
|
|
23418
|
-
return this.itemsArray.filter((
|
|
23437
|
+
return this.itemsArray.filter((item) => item instanceof Comment);
|
|
23419
23438
|
}
|
|
23420
23439
|
getMbr() {
|
|
23421
23440
|
return this.Mbr;
|
|
23422
23441
|
}
|
|
23423
23442
|
getNearestTo(point3, maxItems, filter, maxDistance) {
|
|
23424
23443
|
const allItems = this.getItemsWithIncludedChildren(this.itemsArray);
|
|
23425
|
-
const filtered = allItems.filter((
|
|
23426
|
-
const withDistance = filtered.map((
|
|
23427
|
-
item
|
|
23428
|
-
distance: point3.getDistance(
|
|
23444
|
+
const filtered = allItems.filter((item) => filter(item));
|
|
23445
|
+
const withDistance = filtered.map((item) => ({
|
|
23446
|
+
item,
|
|
23447
|
+
distance: point3.getDistance(item.getMbr().getCenter())
|
|
23429
23448
|
})).filter(({ distance }) => distance <= maxDistance);
|
|
23430
23449
|
withDistance.sort((a, b) => a.distance - b.distance);
|
|
23431
|
-
return withDistance.slice(0, maxItems).map(({ item
|
|
23450
|
+
return withDistance.slice(0, maxItems).map(({ item }) => item);
|
|
23432
23451
|
}
|
|
23433
23452
|
list() {
|
|
23434
23453
|
return this.getItemsWithIncludedChildren(this.itemsArray).concat();
|
|
23435
23454
|
}
|
|
23436
|
-
getZIndex(
|
|
23437
|
-
const index2 = this.itemsArray.indexOf(
|
|
23455
|
+
getZIndex(item) {
|
|
23456
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23438
23457
|
if (index2 === -1) {
|
|
23439
23458
|
return this.getLastZIndex();
|
|
23440
23459
|
}
|
|
@@ -23464,14 +23483,14 @@ class Items {
|
|
|
23464
23483
|
this.pointer = pointer;
|
|
23465
23484
|
this.subject = subject;
|
|
23466
23485
|
}
|
|
23467
|
-
update(
|
|
23468
|
-
this.index.change(
|
|
23486
|
+
update(item) {
|
|
23487
|
+
this.index.change(item);
|
|
23469
23488
|
}
|
|
23470
23489
|
listAll() {
|
|
23471
23490
|
return this.index.list();
|
|
23472
23491
|
}
|
|
23473
23492
|
listGroupItems() {
|
|
23474
|
-
return this.index.list().filter((
|
|
23493
|
+
return this.index.list().filter((item) => ("index" in item) && item.index);
|
|
23475
23494
|
}
|
|
23476
23495
|
getById(id) {
|
|
23477
23496
|
return this.index.getById(id);
|
|
@@ -23486,7 +23505,7 @@ class Items {
|
|
|
23486
23505
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
23487
23506
|
}
|
|
23488
23507
|
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
23489
|
-
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
23508
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.index);
|
|
23490
23509
|
}
|
|
23491
23510
|
getUnderPoint(point3, tolerance = 5) {
|
|
23492
23511
|
return this.index.getUnderPoint(point3, tolerance);
|
|
@@ -23514,28 +23533,28 @@ class Items {
|
|
|
23514
23533
|
const unmodifiedSize = size;
|
|
23515
23534
|
size = 16;
|
|
23516
23535
|
const tolerated = this.index.getEnclosedOrCrossed(x - size, y - size, x + size, y + size);
|
|
23517
|
-
const groups = tolerated.filter((
|
|
23536
|
+
const groups = tolerated.filter((item) => item.itemType === "Group");
|
|
23518
23537
|
if (groups.length > 0) {
|
|
23519
23538
|
return groups;
|
|
23520
23539
|
}
|
|
23521
|
-
let enclosed = tolerated.some((
|
|
23540
|
+
let enclosed = tolerated.some((item) => item instanceof Connector2) ? tolerated : this.index.getEnclosedOrCrossed(x, y, x, y);
|
|
23522
23541
|
const underPointer = this.getUnderPoint(new Point(x, y), size);
|
|
23523
23542
|
if (enclosed.length === 0) {
|
|
23524
23543
|
enclosed = underPointer;
|
|
23525
23544
|
}
|
|
23526
|
-
if (underPointer.some((
|
|
23545
|
+
if (underPointer.some((item) => item.itemType === "Drawing")) {
|
|
23527
23546
|
enclosed = [...underPointer, ...enclosed];
|
|
23528
23547
|
}
|
|
23529
|
-
const { nearest } = enclosed.reduce((acc,
|
|
23530
|
-
const area =
|
|
23531
|
-
if (
|
|
23548
|
+
const { nearest } = enclosed.reduce((acc, item) => {
|
|
23549
|
+
const area = item.getMbr().getHeight() * item.getMbr().getWidth();
|
|
23550
|
+
if (item.itemType === "Drawing" && !item.isPointNearLine(this.pointer.point)) {
|
|
23532
23551
|
return acc;
|
|
23533
23552
|
}
|
|
23534
|
-
const isItemTransparent =
|
|
23535
|
-
const itemZIndex = this.getZIndex(
|
|
23553
|
+
const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
|
|
23554
|
+
const itemZIndex = this.getZIndex(item);
|
|
23536
23555
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
23537
23556
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
23538
|
-
return { nearest:
|
|
23557
|
+
return { nearest: item, area };
|
|
23539
23558
|
}
|
|
23540
23559
|
return acc;
|
|
23541
23560
|
}, { nearest: undefined, area: Infinity });
|
|
@@ -23547,8 +23566,8 @@ class Items {
|
|
|
23547
23566
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
23548
23567
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
23549
23568
|
}
|
|
23550
|
-
getZIndex(
|
|
23551
|
-
return this.index.getZIndex(
|
|
23569
|
+
getZIndex(item) {
|
|
23570
|
+
return this.index.getZIndex(item);
|
|
23552
23571
|
}
|
|
23553
23572
|
getByZIndex(index2) {
|
|
23554
23573
|
return this.index.getByZIndex(index2);
|
|
@@ -23557,11 +23576,11 @@ class Items {
|
|
|
23557
23576
|
return this.index.getLastZIndex();
|
|
23558
23577
|
}
|
|
23559
23578
|
getLinkedConnectorsById(id) {
|
|
23560
|
-
return this.listAll().filter((
|
|
23561
|
-
if (!(
|
|
23579
|
+
return this.listAll().filter((item) => {
|
|
23580
|
+
if (!(item instanceof Connector2)) {
|
|
23562
23581
|
return false;
|
|
23563
23582
|
}
|
|
23564
|
-
const { startItem, endItem } =
|
|
23583
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
23565
23584
|
if (startItem?.getId() === id || endItem?.getId() === id) {
|
|
23566
23585
|
return true;
|
|
23567
23586
|
}
|
|
@@ -23572,11 +23591,11 @@ class Items {
|
|
|
23572
23591
|
if (!startPointerItemId && !endPointerItemId) {
|
|
23573
23592
|
return [];
|
|
23574
23593
|
}
|
|
23575
|
-
return this.listAll().filter((
|
|
23576
|
-
if (!(
|
|
23594
|
+
return this.listAll().filter((item) => {
|
|
23595
|
+
if (!(item instanceof Connector2) || !item.isConnected()) {
|
|
23577
23596
|
return false;
|
|
23578
23597
|
}
|
|
23579
|
-
const { startItem, endItem } =
|
|
23598
|
+
const { startItem, endItem } = item.getConnectedItems();
|
|
23580
23599
|
if (startPointerItemId && endPointerItemId) {
|
|
23581
23600
|
if (startPointerItemId && startItem && startItem.getId() === startPointerItemId && endPointerItemId && endItem && endItem.getId() === endPointerItemId) {
|
|
23582
23601
|
return true;
|
|
@@ -23594,9 +23613,9 @@ class Items {
|
|
|
23594
23613
|
}
|
|
23595
23614
|
render(context) {
|
|
23596
23615
|
const items = this.getItemsInView();
|
|
23597
|
-
items.forEach((
|
|
23598
|
-
if (
|
|
23599
|
-
|
|
23616
|
+
items.forEach((item) => {
|
|
23617
|
+
if (item.parent === "Board") {
|
|
23618
|
+
item.render(context);
|
|
23600
23619
|
}
|
|
23601
23620
|
});
|
|
23602
23621
|
}
|
|
@@ -23609,17 +23628,17 @@ class Items {
|
|
|
23609
23628
|
return this.getHTML(documentFactory, items);
|
|
23610
23629
|
}
|
|
23611
23630
|
getHTML(documentFactory, items) {
|
|
23612
|
-
const lowestCoordinates = items.map((
|
|
23631
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
23613
23632
|
left: Math.min(acc.left, mbr.left),
|
|
23614
23633
|
top: Math.min(acc.top, mbr.top)
|
|
23615
23634
|
}), { left: 0, top: 0 });
|
|
23616
23635
|
const groups = [];
|
|
23617
23636
|
const rest = [];
|
|
23618
|
-
items.forEach((
|
|
23619
|
-
if ("index" in
|
|
23620
|
-
groups.push(
|
|
23637
|
+
items.forEach((item) => {
|
|
23638
|
+
if ("index" in item && item.index) {
|
|
23639
|
+
groups.push(item);
|
|
23621
23640
|
} else {
|
|
23622
|
-
rest.push(
|
|
23641
|
+
rest.push(item);
|
|
23623
23642
|
}
|
|
23624
23643
|
});
|
|
23625
23644
|
const childrenMap = new Map;
|
|
@@ -23629,34 +23648,34 @@ class Items {
|
|
|
23629
23648
|
translateElementBy(html, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
23630
23649
|
return html;
|
|
23631
23650
|
});
|
|
23632
|
-
const restHTML = rest.map((
|
|
23633
|
-
if (
|
|
23634
|
-
const startX = parseFloat(
|
|
23635
|
-
const startY = parseFloat(
|
|
23636
|
-
const endX = parseFloat(
|
|
23637
|
-
const endY = parseFloat(
|
|
23638
|
-
|
|
23639
|
-
|
|
23640
|
-
|
|
23641
|
-
|
|
23642
|
-
}
|
|
23643
|
-
return translateElementBy(
|
|
23644
|
-
});
|
|
23645
|
-
for (const
|
|
23646
|
-
const parentFrameId = childrenMap.get(
|
|
23651
|
+
const restHTML = rest.map((item) => ("renderHTML" in item) && item.renderHTML(documentFactory)).filter((item) => !!item).map((item) => {
|
|
23652
|
+
if (item.tagName.toLowerCase() === "connector-item") {
|
|
23653
|
+
const startX = parseFloat(item.getAttribute("data-start-point-x") || "0");
|
|
23654
|
+
const startY = parseFloat(item.getAttribute("data-start-point-y") || "0");
|
|
23655
|
+
const endX = parseFloat(item.getAttribute("data-end-point-x") || "0");
|
|
23656
|
+
const endY = parseFloat(item.getAttribute("data-end-point-y") || "0");
|
|
23657
|
+
item.setAttribute("data-start-point-x", (startX - lowestCoordinates.left).toString());
|
|
23658
|
+
item.setAttribute("data-start-point-y", (startY - lowestCoordinates.top).toString());
|
|
23659
|
+
item.setAttribute("data-end-point-x", (endX - lowestCoordinates.left).toString());
|
|
23660
|
+
item.setAttribute("data-end-point-y", (endY - lowestCoordinates.top).toString());
|
|
23661
|
+
}
|
|
23662
|
+
return translateElementBy(item, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
23663
|
+
});
|
|
23664
|
+
for (const item of restHTML) {
|
|
23665
|
+
const parentFrameId = childrenMap.get(item.id);
|
|
23647
23666
|
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
23648
23667
|
if (group) {
|
|
23649
|
-
positionRelatively(
|
|
23650
|
-
group.appendChild(
|
|
23668
|
+
positionRelatively(item, group);
|
|
23669
|
+
group.appendChild(item);
|
|
23651
23670
|
}
|
|
23652
23671
|
}
|
|
23653
23672
|
let result = "";
|
|
23654
23673
|
for (const group of GroupsHTML) {
|
|
23655
23674
|
result += group.outerHTML;
|
|
23656
23675
|
}
|
|
23657
|
-
for (const
|
|
23658
|
-
if (!childrenMap.get(
|
|
23659
|
-
result +=
|
|
23676
|
+
for (const item of restHTML) {
|
|
23677
|
+
if (!childrenMap.get(item.id)) {
|
|
23678
|
+
result += item.outerHTML;
|
|
23660
23679
|
}
|
|
23661
23680
|
}
|
|
23662
23681
|
return result;
|
|
@@ -23676,52 +23695,52 @@ class SimpleSpatialIndex {
|
|
|
23676
23695
|
this.itemsArray = [];
|
|
23677
23696
|
this.Mbr = new Mbr;
|
|
23678
23697
|
}
|
|
23679
|
-
insert(
|
|
23680
|
-
this.itemsArray.push(
|
|
23698
|
+
insert(item) {
|
|
23699
|
+
this.itemsArray.push(item);
|
|
23681
23700
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23682
|
-
this.Mbr =
|
|
23701
|
+
this.Mbr = item.getMbr().copy();
|
|
23683
23702
|
} else {
|
|
23684
|
-
this.Mbr.combine([
|
|
23703
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23685
23704
|
}
|
|
23686
|
-
|
|
23705
|
+
item.subject.subscribe(this.change);
|
|
23687
23706
|
this.subject.publish(this.items);
|
|
23688
23707
|
}
|
|
23689
|
-
change = (
|
|
23708
|
+
change = (item) => {
|
|
23690
23709
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
23691
|
-
this.Mbr =
|
|
23710
|
+
this.Mbr = item.getMbr().copy();
|
|
23692
23711
|
} else {
|
|
23693
|
-
this.Mbr.combine([
|
|
23712
|
+
this.Mbr.combine([item.getMbr()]);
|
|
23694
23713
|
}
|
|
23695
23714
|
this.subject.publish(this.items);
|
|
23696
23715
|
};
|
|
23697
|
-
remove(
|
|
23698
|
-
if ("index" in
|
|
23699
|
-
|
|
23716
|
+
remove(item) {
|
|
23717
|
+
if ("index" in item && item.index) {
|
|
23718
|
+
item.removeChildItems(item.index.list());
|
|
23700
23719
|
}
|
|
23701
|
-
if (
|
|
23702
|
-
const parentFrame = this.items.getById(
|
|
23703
|
-
parentFrame?.removeChildItems(
|
|
23720
|
+
if (item.parent !== "Board") {
|
|
23721
|
+
const parentFrame = this.items.getById(item.parent);
|
|
23722
|
+
parentFrame?.removeChildItems(item);
|
|
23704
23723
|
}
|
|
23705
|
-
this.itemsArray.splice(this.itemsArray.indexOf(
|
|
23724
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
23706
23725
|
this.Mbr = new Mbr;
|
|
23707
|
-
this.itemsArray.forEach((
|
|
23726
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
23708
23727
|
this.subject.publish(this.items);
|
|
23709
23728
|
}
|
|
23710
23729
|
copy() {
|
|
23711
|
-
return this.itemsArray.map((
|
|
23712
|
-
...
|
|
23713
|
-
id:
|
|
23730
|
+
return this.itemsArray.map((item) => ({
|
|
23731
|
+
...item.serialize(true),
|
|
23732
|
+
id: item.getId()
|
|
23714
23733
|
}));
|
|
23715
23734
|
}
|
|
23716
|
-
moveToZIndex(
|
|
23717
|
-
const index2 = this.itemsArray.indexOf(
|
|
23735
|
+
moveToZIndex(item, zIndex) {
|
|
23736
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23718
23737
|
this.itemsArray.splice(index2, 1);
|
|
23719
|
-
this.itemsArray.splice(zIndex, 0,
|
|
23720
|
-
this.change(
|
|
23738
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
23739
|
+
this.change(item);
|
|
23721
23740
|
this.subject.publish(this.items);
|
|
23722
23741
|
}
|
|
23723
23742
|
moveManyToZIndex(itemsRecord) {
|
|
23724
|
-
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((
|
|
23743
|
+
const items = Object.keys(itemsRecord).map((id) => this.items.getById(id)).filter((item) => item !== undefined);
|
|
23725
23744
|
const zIndex = Object.values(itemsRecord);
|
|
23726
23745
|
for (let i = 0;i < zIndex.length; i++) {
|
|
23727
23746
|
const index2 = zIndex[i];
|
|
@@ -23729,37 +23748,37 @@ class SimpleSpatialIndex {
|
|
|
23729
23748
|
}
|
|
23730
23749
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23731
23750
|
}
|
|
23732
|
-
sendToBack(
|
|
23733
|
-
const index2 = this.itemsArray.indexOf(
|
|
23751
|
+
sendToBack(item, shouldPublish = true) {
|
|
23752
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23734
23753
|
this.itemsArray.splice(index2, 1);
|
|
23735
|
-
this.itemsArray.unshift(
|
|
23754
|
+
this.itemsArray.unshift(item);
|
|
23736
23755
|
if (shouldPublish) {
|
|
23737
23756
|
this.subject.publish(this.items);
|
|
23738
23757
|
}
|
|
23739
23758
|
}
|
|
23740
23759
|
sendManyToBack(items) {
|
|
23741
23760
|
const newItems = [...items];
|
|
23742
|
-
this.itemsArray.forEach((
|
|
23743
|
-
if (!items.includes(
|
|
23744
|
-
newItems.push(
|
|
23761
|
+
this.itemsArray.forEach((item) => {
|
|
23762
|
+
if (!items.includes(item)) {
|
|
23763
|
+
newItems.push(item);
|
|
23745
23764
|
}
|
|
23746
23765
|
});
|
|
23747
23766
|
this.itemsArray = newItems;
|
|
23748
23767
|
this.itemsArray.forEach(this.change.bind(this));
|
|
23749
23768
|
}
|
|
23750
|
-
bringToFront(
|
|
23751
|
-
const index2 = this.itemsArray.indexOf(
|
|
23769
|
+
bringToFront(item, shouldPublish = true) {
|
|
23770
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
23752
23771
|
this.itemsArray.splice(index2, 1);
|
|
23753
|
-
this.itemsArray.push(
|
|
23772
|
+
this.itemsArray.push(item);
|
|
23754
23773
|
if (shouldPublish) {
|
|
23755
23774
|
this.subject.publish(this.items);
|
|
23756
23775
|
}
|
|
23757
23776
|
}
|
|
23758
23777
|
bringManyToFront(items) {
|
|
23759
23778
|
const newItems = [];
|
|
23760
|
-
this.itemsArray.forEach((
|
|
23761
|
-
if (!items.includes(
|
|
23762
|
-
newItems.push(
|
|
23779
|
+
this.itemsArray.forEach((item) => {
|
|
23780
|
+
if (!items.includes(item)) {
|
|
23781
|
+
newItems.push(item);
|
|
23763
23782
|
}
|
|
23764
23783
|
});
|
|
23765
23784
|
newItems.push(...items);
|
|
@@ -23785,9 +23804,9 @@ class SimpleSpatialIndex {
|
|
|
23785
23804
|
this.subject.publish(this.items);
|
|
23786
23805
|
}
|
|
23787
23806
|
getById(id) {
|
|
23788
|
-
const
|
|
23789
|
-
if (
|
|
23790
|
-
return
|
|
23807
|
+
const item = this.itemsArray.find((item2) => item2.getId() === id);
|
|
23808
|
+
if (item) {
|
|
23809
|
+
return item;
|
|
23791
23810
|
}
|
|
23792
23811
|
}
|
|
23793
23812
|
findById(id) {
|
|
@@ -23796,9 +23815,9 @@ class SimpleSpatialIndex {
|
|
|
23796
23815
|
getEnclosed(left, top, right, bottom) {
|
|
23797
23816
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23798
23817
|
const items = [];
|
|
23799
|
-
this.itemsArray.forEach((
|
|
23800
|
-
if (
|
|
23801
|
-
items.push(
|
|
23818
|
+
this.itemsArray.forEach((item) => {
|
|
23819
|
+
if (item.isEnclosedBy(mbr)) {
|
|
23820
|
+
items.push(item);
|
|
23802
23821
|
}
|
|
23803
23822
|
});
|
|
23804
23823
|
return items;
|
|
@@ -23806,18 +23825,18 @@ class SimpleSpatialIndex {
|
|
|
23806
23825
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
23807
23826
|
const mbr = new Mbr(left, top, right, bottom);
|
|
23808
23827
|
const items = [];
|
|
23809
|
-
this.itemsArray.forEach((
|
|
23810
|
-
if (
|
|
23811
|
-
items.push(
|
|
23828
|
+
this.itemsArray.forEach((item) => {
|
|
23829
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
23830
|
+
items.push(item);
|
|
23812
23831
|
}
|
|
23813
23832
|
});
|
|
23814
23833
|
return items;
|
|
23815
23834
|
}
|
|
23816
23835
|
getUnderPoint(point3, tolerace = 5) {
|
|
23817
23836
|
const items = [];
|
|
23818
|
-
this.itemsArray.forEach((
|
|
23819
|
-
if (
|
|
23820
|
-
items.push(
|
|
23837
|
+
this.itemsArray.forEach((item) => {
|
|
23838
|
+
if (item.isUnderPoint(point3, tolerace)) {
|
|
23839
|
+
items.push(item);
|
|
23821
23840
|
}
|
|
23822
23841
|
});
|
|
23823
23842
|
return items;
|
|
@@ -23828,8 +23847,8 @@ class SimpleSpatialIndex {
|
|
|
23828
23847
|
list() {
|
|
23829
23848
|
return this.itemsArray.concat();
|
|
23830
23849
|
}
|
|
23831
|
-
getZIndex(
|
|
23832
|
-
return this.itemsArray.indexOf(
|
|
23850
|
+
getZIndex(item) {
|
|
23851
|
+
return this.itemsArray.indexOf(item);
|
|
23833
23852
|
}
|
|
23834
23853
|
getLastZIndex() {
|
|
23835
23854
|
return this.itemsArray.length - 1;
|
|
@@ -23843,8 +23862,8 @@ class SimpleSpatialIndex {
|
|
|
23843
23862
|
}
|
|
23844
23863
|
}
|
|
23845
23864
|
render(context) {
|
|
23846
|
-
this.itemsArray.forEach((
|
|
23847
|
-
|
|
23865
|
+
this.itemsArray.forEach((item) => {
|
|
23866
|
+
item.render(context);
|
|
23848
23867
|
});
|
|
23849
23868
|
}
|
|
23850
23869
|
}
|
|
@@ -23895,7 +23914,7 @@ class BaseItem extends Mbr {
|
|
|
23895
23914
|
if (!this.index) {
|
|
23896
23915
|
return null;
|
|
23897
23916
|
}
|
|
23898
|
-
return this.index.items.listAll().map((
|
|
23917
|
+
return this.index.items.listAll().map((item) => item.getId());
|
|
23899
23918
|
}
|
|
23900
23919
|
addChildItems(children) {
|
|
23901
23920
|
if (!this.index) {
|
|
@@ -23933,17 +23952,17 @@ class BaseItem extends Mbr {
|
|
|
23933
23952
|
this.addChildItems(itemsToAdd);
|
|
23934
23953
|
this.removeChildItems(itemsToRemove);
|
|
23935
23954
|
}
|
|
23936
|
-
handleNesting(
|
|
23937
|
-
const isItem = "itemType" in
|
|
23938
|
-
const itemMbr = isItem ?
|
|
23939
|
-
if (
|
|
23955
|
+
handleNesting(item, options) {
|
|
23956
|
+
const isItem = "itemType" in item;
|
|
23957
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
23958
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
23940
23959
|
return false;
|
|
23941
23960
|
}
|
|
23942
|
-
if (options?.cancelIfChild && isItem &&
|
|
23961
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
23943
23962
|
return false;
|
|
23944
23963
|
}
|
|
23945
23964
|
const mbr = this.getMbr().copy();
|
|
23946
|
-
if (
|
|
23965
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
23947
23966
|
if (mbr.isInside(itemMbr.getCenter())) {
|
|
23948
23967
|
if (!options || !options.onlyForOut) {
|
|
23949
23968
|
return true;
|
|
@@ -26240,8 +26259,8 @@ function isChild(value) {
|
|
|
26240
26259
|
if (!Array.isArray(value2))
|
|
26241
26260
|
return true;
|
|
26242
26261
|
const list2 = value2;
|
|
26243
|
-
for (const
|
|
26244
|
-
if (typeof
|
|
26262
|
+
for (const item of list2) {
|
|
26263
|
+
if (typeof item !== "number" && typeof item !== "string") {
|
|
26245
26264
|
return true;
|
|
26246
26265
|
}
|
|
26247
26266
|
}
|
|
@@ -26280,8 +26299,8 @@ function addProperty(schema, properties, key, value) {
|
|
|
26280
26299
|
}
|
|
26281
26300
|
if (Array.isArray(result)) {
|
|
26282
26301
|
const finalResult = [];
|
|
26283
|
-
for (const
|
|
26284
|
-
finalResult.push(parsePrimitive(info, info.property,
|
|
26302
|
+
for (const item of result) {
|
|
26303
|
+
finalResult.push(parsePrimitive(info, info.property, item));
|
|
26285
26304
|
}
|
|
26286
26305
|
result = finalResult;
|
|
26287
26306
|
}
|
|
@@ -37348,8 +37367,8 @@ function list5(node2, parent, state, info) {
|
|
|
37348
37367
|
if (checkRule(state) === bullet && firstListItem) {
|
|
37349
37368
|
let index2 = -1;
|
|
37350
37369
|
while (++index2 < node2.children.length) {
|
|
37351
|
-
const
|
|
37352
|
-
if (
|
|
37370
|
+
const item = node2.children[index2];
|
|
37371
|
+
if (item && item.type === "listItem" && item.children && item.children[0] && item.children[0].type === "thematicBreak") {
|
|
37353
37372
|
useDifferentMarker = true;
|
|
37354
37373
|
break;
|
|
37355
37374
|
}
|
|
@@ -38010,12 +38029,12 @@ async function convertMarkdownToSlate(text5) {
|
|
|
38010
38029
|
...nodes.filter((node2) => node2.type !== "list_item")
|
|
38011
38030
|
];
|
|
38012
38031
|
}
|
|
38013
|
-
return nodes.map((
|
|
38032
|
+
return nodes.map((item) => {
|
|
38014
38033
|
setNodeStyles({
|
|
38015
|
-
node:
|
|
38016
|
-
isPaddingTopNeeded:
|
|
38034
|
+
node: item,
|
|
38035
|
+
isPaddingTopNeeded: item.type !== "code_block"
|
|
38017
38036
|
});
|
|
38018
|
-
return
|
|
38037
|
+
return item;
|
|
38019
38038
|
});
|
|
38020
38039
|
}
|
|
38021
38040
|
function detectListType(text5) {
|
|
@@ -38428,17 +38447,17 @@ class FloatingPoint extends Point {
|
|
|
38428
38447
|
relativePoint;
|
|
38429
38448
|
pointType = "Floating";
|
|
38430
38449
|
edge;
|
|
38431
|
-
constructor(
|
|
38450
|
+
constructor(item, relativePoint) {
|
|
38432
38451
|
super();
|
|
38433
|
-
this.item =
|
|
38452
|
+
this.item = item;
|
|
38434
38453
|
this.relativePoint = relativePoint;
|
|
38435
38454
|
if (relativePoint.y <= 0) {
|
|
38436
38455
|
this.edge = "top";
|
|
38437
|
-
} else if (relativePoint.y >=
|
|
38456
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
38438
38457
|
this.edge = "bottom";
|
|
38439
38458
|
} else if (relativePoint.x <= 0) {
|
|
38440
38459
|
this.edge = "left";
|
|
38441
|
-
} else if (relativePoint.x >=
|
|
38460
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
38442
38461
|
this.edge = "right";
|
|
38443
38462
|
}
|
|
38444
38463
|
this.recalculatePoint();
|
|
@@ -38469,17 +38488,17 @@ class FixedPoint extends Point {
|
|
|
38469
38488
|
relativePoint;
|
|
38470
38489
|
pointType = "Fixed";
|
|
38471
38490
|
edge;
|
|
38472
|
-
constructor(
|
|
38491
|
+
constructor(item, relativePoint) {
|
|
38473
38492
|
super();
|
|
38474
|
-
this.item =
|
|
38493
|
+
this.item = item;
|
|
38475
38494
|
this.relativePoint = relativePoint;
|
|
38476
38495
|
if (relativePoint.y <= 0) {
|
|
38477
38496
|
this.edge = "top";
|
|
38478
|
-
} else if (relativePoint.y >=
|
|
38497
|
+
} else if (relativePoint.y >= item.getMbr().getHeight()) {
|
|
38479
38498
|
this.edge = "bottom";
|
|
38480
38499
|
} else if (relativePoint.x <= 0) {
|
|
38481
38500
|
this.edge = "left";
|
|
38482
|
-
} else if (relativePoint.x >=
|
|
38501
|
+
} else if (relativePoint.x >= item.getMbr().getWidth()) {
|
|
38483
38502
|
this.edge = "right";
|
|
38484
38503
|
}
|
|
38485
38504
|
this.recalculatePoint();
|
|
@@ -38510,16 +38529,16 @@ class FixedConnectorPoint extends Point {
|
|
|
38510
38529
|
tangent;
|
|
38511
38530
|
segmentIndex;
|
|
38512
38531
|
pointType = "FixedConnector";
|
|
38513
|
-
constructor(
|
|
38532
|
+
constructor(item, tangent, segmentIndex) {
|
|
38514
38533
|
super();
|
|
38515
|
-
this.item =
|
|
38534
|
+
this.item = item;
|
|
38516
38535
|
this.tangent = tangent;
|
|
38517
38536
|
this.segmentIndex = segmentIndex;
|
|
38518
38537
|
this.recalculatePoint();
|
|
38519
38538
|
}
|
|
38520
38539
|
recalculatePoint() {
|
|
38521
|
-
const
|
|
38522
|
-
const segments =
|
|
38540
|
+
const item = this.item;
|
|
38541
|
+
const segments = item.getPaths().getSegments();
|
|
38523
38542
|
const segment = segments.length > this.segmentIndex ? segments[this.segmentIndex] : segments[segments.length - 1];
|
|
38524
38543
|
const point5 = segment.getPoint(this.tangent);
|
|
38525
38544
|
this.x = point5.x;
|
|
@@ -38544,38 +38563,38 @@ function getControlPoint(data, findItem2) {
|
|
|
38544
38563
|
if (data.pointType === "Board") {
|
|
38545
38564
|
return new BoardPoint(Math.round(data.x), Math.round(data.y));
|
|
38546
38565
|
} else {
|
|
38547
|
-
const
|
|
38548
|
-
if (!
|
|
38566
|
+
const item = findItem2(data.itemId);
|
|
38567
|
+
if (!item) {
|
|
38549
38568
|
console.warn(`getControlPoint(): item not found for ${data.itemId}`);
|
|
38550
38569
|
return new BoardPoint(0, 0);
|
|
38551
38570
|
}
|
|
38552
38571
|
switch (data.pointType) {
|
|
38553
38572
|
case "FixedConnector":
|
|
38554
|
-
if (
|
|
38555
|
-
return new FixedConnectorPoint(
|
|
38573
|
+
if (item instanceof Connector2) {
|
|
38574
|
+
return new FixedConnectorPoint(item, data.tangent, data.segment);
|
|
38556
38575
|
} else {
|
|
38557
38576
|
throw new Error(`getControlPoint(): item must be a connector`);
|
|
38558
38577
|
}
|
|
38559
38578
|
case "Floating":
|
|
38560
|
-
return new FloatingPoint(
|
|
38579
|
+
return new FloatingPoint(item, new Point(data.relativeX, data.relativeY));
|
|
38561
38580
|
case "Fixed":
|
|
38562
|
-
return new FixedPoint(
|
|
38581
|
+
return new FixedPoint(item, new Point(data.relativeX, data.relativeY));
|
|
38563
38582
|
}
|
|
38564
38583
|
}
|
|
38565
38584
|
}
|
|
38566
|
-
function toRelativePoint(point5,
|
|
38567
|
-
const matrix =
|
|
38585
|
+
function toRelativePoint(point5, item) {
|
|
38586
|
+
const matrix = item.transformation?.matrix || new Matrix2;
|
|
38568
38587
|
const inverse = matrix.getInverse();
|
|
38569
38588
|
point5 = point5.copy();
|
|
38570
38589
|
point5.transform(inverse);
|
|
38571
38590
|
return point5;
|
|
38572
38591
|
}
|
|
38573
|
-
function fromRelativePoint(relativePoint,
|
|
38574
|
-
const matrix =
|
|
38592
|
+
function fromRelativePoint(relativePoint, item, edge) {
|
|
38593
|
+
const matrix = item.transformation?.matrix.copy() || new Matrix2;
|
|
38575
38594
|
const point5 = relativePoint.copy();
|
|
38576
38595
|
point5.transform(matrix);
|
|
38577
|
-
if (
|
|
38578
|
-
const itemMbr =
|
|
38596
|
+
if (item instanceof RichText || item instanceof AINode) {
|
|
38597
|
+
const itemMbr = item.getMbr();
|
|
38579
38598
|
const { x: centerX, y: centerY } = itemMbr.getCenter();
|
|
38580
38599
|
switch (edge) {
|
|
38581
38600
|
case "left":
|
|
@@ -38587,7 +38606,7 @@ function fromRelativePoint(relativePoint, item2, edge) {
|
|
|
38587
38606
|
case "bottom":
|
|
38588
38607
|
return new Point(centerX, itemMbr.bottom);
|
|
38589
38608
|
default:
|
|
38590
|
-
return
|
|
38609
|
+
return item.getMbr().getClosestEdgeCenterPoint(point5);
|
|
38591
38610
|
}
|
|
38592
38611
|
}
|
|
38593
38612
|
return point5;
|
|
@@ -39936,7 +39955,7 @@ class Connector2 extends BaseItem {
|
|
|
39936
39955
|
return this;
|
|
39937
39956
|
}
|
|
39938
39957
|
getConnectorById(items, connectorId) {
|
|
39939
|
-
return items.find((
|
|
39958
|
+
return items.find((item) => item instanceof Connector2 && item.getId() === connectorId);
|
|
39940
39959
|
}
|
|
39941
39960
|
updateTitle() {
|
|
39942
39961
|
const selection = this.board.selection;
|
|
@@ -42573,8 +42592,8 @@ async function exportBoardSnapshot({
|
|
|
42573
42592
|
context.matrix.applyToContext(context.ctx);
|
|
42574
42593
|
const { left, top, right, bottom } = selection;
|
|
42575
42594
|
const inView = board.items.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
|
|
42576
|
-
for (const
|
|
42577
|
-
|
|
42595
|
+
for (const item of inView) {
|
|
42596
|
+
item.render(context);
|
|
42578
42597
|
}
|
|
42579
42598
|
const blob = await offscreenCanvas.convertToBlob({ type: "image/png" });
|
|
42580
42599
|
const dataUrl = await convertBlobToDataUrl(blob);
|
|
@@ -42772,7 +42791,7 @@ class Frame2 extends BaseItem {
|
|
|
42772
42791
|
return this.id;
|
|
42773
42792
|
}
|
|
42774
42793
|
getChildrenIds() {
|
|
42775
|
-
return this.index?.list().map((
|
|
42794
|
+
return this.index?.list().map((item) => item.getId()) || [];
|
|
42776
42795
|
}
|
|
42777
42796
|
updateMbr() {
|
|
42778
42797
|
const rect = this.path.getMbr().copy();
|
|
@@ -43007,11 +43026,11 @@ class Frame2 extends BaseItem {
|
|
|
43007
43026
|
}
|
|
43008
43027
|
});
|
|
43009
43028
|
const currMbr = this.getMbr();
|
|
43010
|
-
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((
|
|
43011
|
-
if (
|
|
43012
|
-
if (this.handleNesting(
|
|
43013
|
-
this.applyAddChildren([
|
|
43014
|
-
|
|
43029
|
+
this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).forEach((item) => {
|
|
43030
|
+
if (item.parent === "Board") {
|
|
43031
|
+
if (this.handleNesting(item)) {
|
|
43032
|
+
this.applyAddChildren([item.getId()]);
|
|
43033
|
+
item.parent = this.getId();
|
|
43015
43034
|
}
|
|
43016
43035
|
}
|
|
43017
43036
|
});
|
|
@@ -45209,9 +45228,9 @@ class Group extends BaseItem {
|
|
|
45209
45228
|
if (data.children) {
|
|
45210
45229
|
data.children.forEach((childId) => {
|
|
45211
45230
|
this.applyAddChild(childId);
|
|
45212
|
-
const
|
|
45213
|
-
if (
|
|
45214
|
-
|
|
45231
|
+
const item = this.board.items.getById(childId);
|
|
45232
|
+
if (item) {
|
|
45233
|
+
item.parent = this.getId();
|
|
45215
45234
|
}
|
|
45216
45235
|
});
|
|
45217
45236
|
}
|
|
@@ -45241,11 +45260,11 @@ class Group extends BaseItem {
|
|
|
45241
45260
|
let right = Number.MIN_SAFE_INTEGER;
|
|
45242
45261
|
let bottom = Number.MIN_SAFE_INTEGER;
|
|
45243
45262
|
const mbrs = this.children.flatMap((childId) => {
|
|
45244
|
-
const
|
|
45245
|
-
if (!
|
|
45263
|
+
const item = this.board.items.getById(childId);
|
|
45264
|
+
if (!item) {
|
|
45246
45265
|
return [];
|
|
45247
45266
|
}
|
|
45248
|
-
const mbr2 =
|
|
45267
|
+
const mbr2 = item.getMbr();
|
|
45249
45268
|
if (!mbr2) {
|
|
45250
45269
|
return [];
|
|
45251
45270
|
}
|
|
@@ -45280,7 +45299,7 @@ class Group extends BaseItem {
|
|
|
45280
45299
|
return this.children;
|
|
45281
45300
|
}
|
|
45282
45301
|
getChildren() {
|
|
45283
|
-
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((
|
|
45302
|
+
return this.children.map((itemId) => this.board.items.getById(itemId)).filter((item) => item !== undefined);
|
|
45284
45303
|
}
|
|
45285
45304
|
updateMbr() {
|
|
45286
45305
|
const rect = this.getMbr();
|
|
@@ -45293,9 +45312,9 @@ class Group extends BaseItem {
|
|
|
45293
45312
|
setChildren(items) {
|
|
45294
45313
|
items.forEach((itemId) => {
|
|
45295
45314
|
this.addChild(itemId);
|
|
45296
|
-
const
|
|
45297
|
-
if (
|
|
45298
|
-
|
|
45315
|
+
const item = this.board.items.getById(itemId);
|
|
45316
|
+
if (item) {
|
|
45317
|
+
item.parent = this.getId();
|
|
45299
45318
|
}
|
|
45300
45319
|
});
|
|
45301
45320
|
this.updateMbr();
|
|
@@ -45303,9 +45322,9 @@ class Group extends BaseItem {
|
|
|
45303
45322
|
removeChildren() {
|
|
45304
45323
|
this.children.forEach((itemId) => {
|
|
45305
45324
|
this.removeChild(itemId);
|
|
45306
|
-
const
|
|
45307
|
-
if (
|
|
45308
|
-
|
|
45325
|
+
const item = this.board.items.getById(itemId);
|
|
45326
|
+
if (item) {
|
|
45327
|
+
item.parent = this.parent;
|
|
45309
45328
|
}
|
|
45310
45329
|
});
|
|
45311
45330
|
this.updateMbr();
|
|
@@ -45638,16 +45657,16 @@ class Anchor extends Mbr {
|
|
|
45638
45657
|
}
|
|
45639
45658
|
}
|
|
45640
45659
|
// src/Items/Connector/ConnectorSnap.ts
|
|
45641
|
-
function getFixedPoint(
|
|
45642
|
-
if (
|
|
45643
|
-
const nearestSegmentData =
|
|
45660
|
+
function getFixedPoint(item, point5) {
|
|
45661
|
+
if (item instanceof Connector2) {
|
|
45662
|
+
const nearestSegmentData = item.getPaths().getNearestEdgeAndPointTo(point5);
|
|
45644
45663
|
const segment = nearestSegmentData.segment;
|
|
45645
45664
|
const index2 = nearestSegmentData.index;
|
|
45646
45665
|
const tangent = segment.getParameter(point5);
|
|
45647
|
-
return new FixedConnectorPoint(
|
|
45666
|
+
return new FixedConnectorPoint(item, tangent, index2);
|
|
45648
45667
|
} else {
|
|
45649
|
-
const relativePoint = toRelativePoint(point5,
|
|
45650
|
-
return new FixedPoint(
|
|
45668
|
+
const relativePoint = toRelativePoint(point5, item);
|
|
45669
|
+
return new FixedPoint(item, relativePoint);
|
|
45651
45670
|
}
|
|
45652
45671
|
}
|
|
45653
45672
|
|
|
@@ -45700,20 +45719,20 @@ class ConnectorSnap {
|
|
|
45700
45719
|
}
|
|
45701
45720
|
this.setSnap();
|
|
45702
45721
|
const pointer = this.board.pointer.point;
|
|
45703
|
-
const { anchor, item
|
|
45704
|
-
if (!
|
|
45722
|
+
const { anchor, item, point: point5 } = this.snap;
|
|
45723
|
+
if (!item) {
|
|
45705
45724
|
const pointer2 = this.board.pointer.point;
|
|
45706
45725
|
this.controlPoint = new BoardPoint(pointer2.x, pointer2.y);
|
|
45707
45726
|
} else if (anchor) {
|
|
45708
|
-
this.controlPoint = getFixedPoint(
|
|
45727
|
+
this.controlPoint = getFixedPoint(item, anchor.getCenter());
|
|
45709
45728
|
} else if (point5) {
|
|
45710
|
-
const nearest2 =
|
|
45711
|
-
this.controlPoint = getFixedPoint(
|
|
45729
|
+
const nearest2 = item.getNearestEdgePointTo(pointer);
|
|
45730
|
+
this.controlPoint = getFixedPoint(item, nearest2);
|
|
45712
45731
|
} else {
|
|
45713
45732
|
if (this.hover.isTimeoutElapsed) {
|
|
45714
|
-
this.controlPoint = getFixedPoint(
|
|
45733
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
45715
45734
|
} else {
|
|
45716
|
-
this.controlPoint = getFixedPoint(
|
|
45735
|
+
this.controlPoint = getFixedPoint(item, pointer);
|
|
45717
45736
|
}
|
|
45718
45737
|
}
|
|
45719
45738
|
}
|
|
@@ -45774,23 +45793,23 @@ class ConnectorSnap {
|
|
|
45774
45793
|
}
|
|
45775
45794
|
return nearest;
|
|
45776
45795
|
}
|
|
45777
|
-
getClosestPointOnItem(
|
|
45778
|
-
const nearestEdgePoint =
|
|
45779
|
-
return getFixedPoint(
|
|
45796
|
+
getClosestPointOnItem(item, position4) {
|
|
45797
|
+
const nearestEdgePoint = item.getNearestEdgePointTo(position4);
|
|
45798
|
+
return getFixedPoint(item, nearestEdgePoint);
|
|
45780
45799
|
}
|
|
45781
|
-
isNearBorder(
|
|
45782
|
-
if (!
|
|
45800
|
+
isNearBorder(item) {
|
|
45801
|
+
if (!item) {
|
|
45783
45802
|
return false;
|
|
45784
45803
|
}
|
|
45785
45804
|
const pointer = this.board.pointer.point;
|
|
45786
|
-
const point5 =
|
|
45805
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
45787
45806
|
const distance = pointer.getDistance(point5);
|
|
45788
45807
|
return distance < this.distance.border / this.board.camera.getScale();
|
|
45789
45808
|
}
|
|
45790
45809
|
setSnap() {
|
|
45791
|
-
const
|
|
45792
|
-
const path2 =
|
|
45793
|
-
if (!
|
|
45810
|
+
const item = this.snap.item;
|
|
45811
|
+
const path2 = item && "getPath" in item ? item?.getPath() : null;
|
|
45812
|
+
if (!item || !path2) {
|
|
45794
45813
|
this.snap.path = null;
|
|
45795
45814
|
this.snap.anchors = [];
|
|
45796
45815
|
this.snap.anchor = null;
|
|
@@ -45801,11 +45820,11 @@ class ConnectorSnap {
|
|
|
45801
45820
|
if (this.snap.item === this.hover.item && !this.hover.isTimeoutElapsed) {
|
|
45802
45821
|
path2.setBackgroundColor(this.color.snapBackgroundHighlight);
|
|
45803
45822
|
}
|
|
45804
|
-
this.setAnchors(
|
|
45823
|
+
this.setAnchors(item);
|
|
45805
45824
|
}
|
|
45806
45825
|
}
|
|
45807
|
-
setAnchors(
|
|
45808
|
-
const points =
|
|
45826
|
+
setAnchors(item) {
|
|
45827
|
+
const points = item.getSnapAnchorPoints();
|
|
45809
45828
|
if (!points) {
|
|
45810
45829
|
return;
|
|
45811
45830
|
}
|
|
@@ -45839,10 +45858,10 @@ class ConnectorSnap {
|
|
|
45839
45858
|
}
|
|
45840
45859
|
setPoint() {
|
|
45841
45860
|
const pointer = this.board.pointer.point;
|
|
45842
|
-
const { item
|
|
45843
|
-
if (
|
|
45861
|
+
const { item, anchor } = this.snap;
|
|
45862
|
+
if (item) {
|
|
45844
45863
|
if (!anchor) {
|
|
45845
|
-
const point5 =
|
|
45864
|
+
const point5 = item.getNearestEdgePointTo(pointer);
|
|
45846
45865
|
if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
|
|
45847
45866
|
this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
|
|
45848
45867
|
} else {
|
|
@@ -46215,12 +46234,12 @@ class NestingHighlighter extends Tool {
|
|
|
46215
46234
|
this.toHighlight.push({ groupItem, children: array });
|
|
46216
46235
|
}
|
|
46217
46236
|
}
|
|
46218
|
-
addSingleItem(
|
|
46219
|
-
this.toHighlight.push({ children: [
|
|
46237
|
+
addSingleItem(item) {
|
|
46238
|
+
this.toHighlight.push({ children: [item] });
|
|
46220
46239
|
}
|
|
46221
|
-
remove(
|
|
46240
|
+
remove(item) {
|
|
46222
46241
|
this.toHighlight.forEach((group) => {
|
|
46223
|
-
group.children = group.children.filter((child) => child !==
|
|
46242
|
+
group.children = group.children.filter((child) => child !== item);
|
|
46224
46243
|
});
|
|
46225
46244
|
this.toHighlight = this.toHighlight.filter((group) => group.children.length > 0);
|
|
46226
46245
|
}
|
|
@@ -46287,7 +46306,7 @@ class AddFrame extends BoardTool {
|
|
|
46287
46306
|
this.mbr.borderColor = "blue";
|
|
46288
46307
|
this.nestingHighlighter.clear();
|
|
46289
46308
|
const enclosedOrCrossed = this.board.items.getEnclosedOrCrossed(this.mbr.left, this.mbr.top, this.mbr.right, this.mbr.bottom);
|
|
46290
|
-
const inside = enclosedOrCrossed.filter((
|
|
46309
|
+
const inside = enclosedOrCrossed.filter((item) => !(item instanceof Frame2) && item.parent === "Board" && this.mbr.isInside(item.getMbr().getCenter()));
|
|
46291
46310
|
this.nestingHighlighter.add(this.frame, inside);
|
|
46292
46311
|
this.initTransformation();
|
|
46293
46312
|
this.board.tools.publish();
|
|
@@ -46308,7 +46327,7 @@ class AddFrame extends BoardTool {
|
|
|
46308
46327
|
localStorage.setItem("lastFrameScale", JSON.stringify(this.frame.transformation.getScale()));
|
|
46309
46328
|
}
|
|
46310
46329
|
const currMbr = this.frame.getMbr();
|
|
46311
|
-
const frameChildren = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
46330
|
+
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));
|
|
46312
46331
|
this.applyAddChildren(frameChildren);
|
|
46313
46332
|
if (this.shape !== "Custom") {
|
|
46314
46333
|
this.applyCanChangeRatio(false);
|
|
@@ -46324,7 +46343,7 @@ class AddFrame extends BoardTool {
|
|
|
46324
46343
|
return true;
|
|
46325
46344
|
}
|
|
46326
46345
|
addNextTo() {
|
|
46327
|
-
const framesInView = this.board.items.getItemsInView().filter((
|
|
46346
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame2);
|
|
46328
46347
|
if (framesInView.length === 0) {
|
|
46329
46348
|
if (this.shape === "Custom") {
|
|
46330
46349
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -46362,7 +46381,7 @@ class AddFrame extends BoardTool {
|
|
|
46362
46381
|
this.board.camera.viewRectangle(this.frame.getMbr());
|
|
46363
46382
|
}
|
|
46364
46383
|
const frameMbr = this.frame.getMbr();
|
|
46365
|
-
this.board.items.getEnclosedOrCrossed(frameMbr.left, frameMbr.top, frameMbr.right, frameMbr.bottom).filter((
|
|
46384
|
+
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]));
|
|
46366
46385
|
const frame = this.board.add(this.frame);
|
|
46367
46386
|
frame.text.editor.moveCursorToEndOfTheText();
|
|
46368
46387
|
this.nestingHighlighter.clear();
|
|
@@ -46867,13 +46886,13 @@ class Eraser extends BoardTool {
|
|
|
46867
46886
|
}
|
|
46868
46887
|
removeUnderPointOrLine() {
|
|
46869
46888
|
const segments = this.drawing.getLines();
|
|
46870
|
-
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((
|
|
46871
|
-
return
|
|
46872
|
-
return line.getDistance(this.board.pointer.point) <=
|
|
46889
|
+
const items = this.board.items.getUnderPointer(this.strokeWidth / 2).filter((item) => {
|
|
46890
|
+
return item.itemType === "Drawing" && item.getLines().find((line) => {
|
|
46891
|
+
return line.getDistance(this.board.pointer.point) <= item.strokeWidth / 2 + this.strokeWidth / 2;
|
|
46873
46892
|
});
|
|
46874
46893
|
});
|
|
46875
|
-
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((
|
|
46876
|
-
return
|
|
46894
|
+
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) => {
|
|
46895
|
+
return item.itemType === "Drawing" && item.getLines().some((line) => {
|
|
46877
46896
|
return segments.some((segment) => segment.hasIntersectionPoint(line));
|
|
46878
46897
|
});
|
|
46879
46898
|
}));
|
|
@@ -47325,20 +47344,20 @@ function createCanvasDrawer(board) {
|
|
|
47325
47344
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
47326
47345
|
context.matrix.applyToContext(context.ctx);
|
|
47327
47346
|
const items = Object.keys(translation).map((id) => {
|
|
47328
|
-
const
|
|
47329
|
-
if (
|
|
47330
|
-
if (
|
|
47331
|
-
return
|
|
47347
|
+
const item = board2.items.getById(id);
|
|
47348
|
+
if (item) {
|
|
47349
|
+
if (item.itemType !== "Frame") {
|
|
47350
|
+
return item;
|
|
47332
47351
|
}
|
|
47333
|
-
|
|
47334
|
-
return
|
|
47352
|
+
item.render(context);
|
|
47353
|
+
return item;
|
|
47335
47354
|
}
|
|
47336
47355
|
return;
|
|
47337
|
-
}).filter((
|
|
47338
|
-
items.forEach((
|
|
47339
|
-
if (
|
|
47340
|
-
|
|
47341
|
-
board2.selection.renderItemMbr(context,
|
|
47356
|
+
}).filter((item) => !!item);
|
|
47357
|
+
items.forEach((item) => {
|
|
47358
|
+
if (item.itemType !== "Frame") {
|
|
47359
|
+
item.render(context);
|
|
47360
|
+
board2.selection.renderItemMbr(context, item, board2.camera.getMatrix().scaleX);
|
|
47342
47361
|
}
|
|
47343
47362
|
});
|
|
47344
47363
|
return { canvas: container, items };
|
|
@@ -47399,10 +47418,10 @@ function createCanvasDrawer(board) {
|
|
|
47399
47418
|
if (lastTranslationKeys) {
|
|
47400
47419
|
board.selection.shouldPublish = false;
|
|
47401
47420
|
lastTranslationKeys.forEach((id) => {
|
|
47402
|
-
const
|
|
47403
|
-
if (
|
|
47404
|
-
|
|
47405
|
-
|
|
47421
|
+
const item = board.items.getById(id);
|
|
47422
|
+
if (item) {
|
|
47423
|
+
item.transformationRenderBlock = undefined;
|
|
47424
|
+
item.subject.publish(item);
|
|
47406
47425
|
}
|
|
47407
47426
|
});
|
|
47408
47427
|
lastTranslationKeys = undefined;
|
|
@@ -47434,9 +47453,9 @@ function createCanvasDrawer(board) {
|
|
|
47434
47453
|
lastCreatedCanvas = cnvs;
|
|
47435
47454
|
lastTranslationKeys = Object.keys(translation);
|
|
47436
47455
|
lastTranslationKeys.forEach((id) => {
|
|
47437
|
-
const
|
|
47438
|
-
if (
|
|
47439
|
-
|
|
47456
|
+
const item = board.items.getById(id);
|
|
47457
|
+
if (item) {
|
|
47458
|
+
item.transformationRenderBlock = true;
|
|
47440
47459
|
}
|
|
47441
47460
|
});
|
|
47442
47461
|
board.selection.transformationRenderBlock = true;
|
|
@@ -47446,14 +47465,14 @@ function createCanvasDrawer(board) {
|
|
|
47446
47465
|
}
|
|
47447
47466
|
function countSumMbr(translation) {
|
|
47448
47467
|
return Object.keys(translation).reduce((mbr, id) => {
|
|
47449
|
-
const
|
|
47450
|
-
if (
|
|
47468
|
+
const item = board.items.getById(id);
|
|
47469
|
+
if (item) {
|
|
47451
47470
|
if (!mbr) {
|
|
47452
|
-
mbr =
|
|
47471
|
+
mbr = item.getMbr();
|
|
47453
47472
|
} else {
|
|
47454
|
-
mbr.combine(
|
|
47455
|
-
if (
|
|
47456
|
-
mbr.combine(
|
|
47473
|
+
mbr.combine(item.getMbr());
|
|
47474
|
+
if (item.itemType === "Frame") {
|
|
47475
|
+
mbr.combine(item.getRichText().getMbr());
|
|
47457
47476
|
}
|
|
47458
47477
|
}
|
|
47459
47478
|
}
|
|
@@ -47484,8 +47503,8 @@ function createCanvasDrawer(board) {
|
|
|
47484
47503
|
}
|
|
47485
47504
|
function highlightNesting() {
|
|
47486
47505
|
const container = getLastCreatedCanvas();
|
|
47487
|
-
const drawnItemsMap = drawnItems?.reduce((acc,
|
|
47488
|
-
acc.set(
|
|
47506
|
+
const drawnItemsMap = drawnItems?.reduce((acc, item) => {
|
|
47507
|
+
acc.set(item.getId(), { item, mbr: item.getMbr() });
|
|
47489
47508
|
return acc;
|
|
47490
47509
|
}, new Map);
|
|
47491
47510
|
if (!container || !drawnItems) {
|
|
@@ -47520,11 +47539,11 @@ function createCanvasDrawer(board) {
|
|
|
47520
47539
|
mbr.transform(currMatrix);
|
|
47521
47540
|
});
|
|
47522
47541
|
groups.forEach((group) => {
|
|
47523
|
-
drawnItemsMap?.forEach(({ mbr, item
|
|
47524
|
-
if ("canBeNested" in
|
|
47542
|
+
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
47543
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
47525
47544
|
return;
|
|
47526
47545
|
}
|
|
47527
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) ||
|
|
47546
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
47528
47547
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
47529
47548
|
removeHighlighted(key);
|
|
47530
47549
|
highlightedDivs.set(key, div);
|
|
@@ -47585,10 +47604,10 @@ function createCanvasDrawer(board) {
|
|
|
47585
47604
|
}
|
|
47586
47605
|
|
|
47587
47606
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
47588
|
-
function getControlPointData(
|
|
47589
|
-
const itemScale = isRichText ? { x: 1, y: 1 } :
|
|
47590
|
-
const width2 =
|
|
47591
|
-
let height3 =
|
|
47607
|
+
function getControlPointData(item, index2, isRichText = false) {
|
|
47608
|
+
const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
|
|
47609
|
+
const width2 = item.getPathMbr().getWidth();
|
|
47610
|
+
let height3 = item.getPathMbr().getHeight();
|
|
47592
47611
|
const adjMapScaled = {
|
|
47593
47612
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
47594
47613
|
1: {
|
|
@@ -47603,7 +47622,7 @@ function getControlPointData(item2, index2, isRichText = false) {
|
|
|
47603
47622
|
};
|
|
47604
47623
|
return {
|
|
47605
47624
|
pointType: "Fixed",
|
|
47606
|
-
itemId:
|
|
47625
|
+
itemId: item.getId(),
|
|
47607
47626
|
relativeX: adjMapScaled[index2].x,
|
|
47608
47627
|
relativeY: adjMapScaled[index2].y
|
|
47609
47628
|
};
|
|
@@ -47738,10 +47757,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
47738
47757
|
let newHeight = height3;
|
|
47739
47758
|
let itemData;
|
|
47740
47759
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
47741
|
-
const
|
|
47742
|
-
newWidth =
|
|
47743
|
-
newHeight =
|
|
47744
|
-
itemData =
|
|
47760
|
+
const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
47761
|
+
newWidth = item.getMbr().getWidth();
|
|
47762
|
+
newHeight = item.getMbr().getHeight();
|
|
47763
|
+
itemData = item.serialize();
|
|
47745
47764
|
const { minX, minY, maxY, maxX } = offsets;
|
|
47746
47765
|
offsetX = Math.min(offsetX, maxX);
|
|
47747
47766
|
offsetX = Math.max(offsetX, minX);
|
|
@@ -47774,7 +47793,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47774
47793
|
}
|
|
47775
47794
|
const newMbr = new Mbr(newItemData.transformation?.translateX, newItemData.transformation?.translateY, (newItemData.transformation?.translateX || 0) + newWidth, (newItemData.transformation?.translateY || 0) + newHeight);
|
|
47776
47795
|
let step = 1;
|
|
47777
|
-
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((
|
|
47796
|
+
while (board.index.getItemsEnclosedOrCrossed(newMbr.left, newMbr.top, newMbr.right, newMbr.bottom).filter((item) => item.itemType !== "Connector").length > 0) {
|
|
47778
47797
|
const xDirection = step % 2 === 0 ? -1 : 1;
|
|
47779
47798
|
const yDirection = newItemData.itemType === "AINode" ? -1 : xDirection;
|
|
47780
47799
|
newMbr.transform(new Matrix2(iterAdjustment[index2].x * xDirection * step, iterAdjustment[index2].y * yDirection * (newItemData.itemType === "AINode" ? 1 : step)));
|
|
@@ -47907,7 +47926,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47907
47926
|
clear();
|
|
47908
47927
|
return;
|
|
47909
47928
|
}
|
|
47910
|
-
const { positions, item
|
|
47929
|
+
const { positions, item } = position4;
|
|
47911
47930
|
const cameraMatrix = board.camera.getMatrix();
|
|
47912
47931
|
const cameraMbr = board.camera.getMbr();
|
|
47913
47932
|
const positionAdjustments = {
|
|
@@ -47935,7 +47954,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47935
47954
|
};
|
|
47936
47955
|
const button = document.createElement("button");
|
|
47937
47956
|
button.classList.add("microboard-quickAddButton");
|
|
47938
|
-
if (
|
|
47957
|
+
if (item.itemType === "AINode" && index2 === 2) {
|
|
47939
47958
|
button.classList.add("microboard-invisible");
|
|
47940
47959
|
}
|
|
47941
47960
|
button.classList.add(`microboard-${adjustment.rotate}`);
|
|
@@ -47951,7 +47970,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
47951
47970
|
clearTimeout(timeoutId);
|
|
47952
47971
|
}
|
|
47953
47972
|
if (button.isMouseDown) {
|
|
47954
|
-
board.tools.addConnector(true,
|
|
47973
|
+
board.tools.addConnector(true, item, pos);
|
|
47955
47974
|
} else {
|
|
47956
47975
|
quickAddItems = undefined;
|
|
47957
47976
|
selection.subject.publish(selection);
|
|
@@ -48058,11 +48077,11 @@ class AlignmentHelper {
|
|
|
48058
48077
|
return baseThickness / (zoom / 100);
|
|
48059
48078
|
}
|
|
48060
48079
|
combineMBRs(items) {
|
|
48061
|
-
return items.reduce((acc,
|
|
48080
|
+
return items.reduce((acc, item, i) => {
|
|
48062
48081
|
if (i === 0) {
|
|
48063
48082
|
return acc;
|
|
48064
48083
|
}
|
|
48065
|
-
const itemMbr =
|
|
48084
|
+
const itemMbr = item.getPathMbr();
|
|
48066
48085
|
return acc.combine(itemMbr);
|
|
48067
48086
|
}, items[0].getMbr());
|
|
48068
48087
|
}
|
|
@@ -48076,7 +48095,7 @@ class AlignmentHelper {
|
|
|
48076
48095
|
const scale = this.board.camera.getScale();
|
|
48077
48096
|
const dynamicAlignThreshold = Math.min(this.alignThreshold / scale, 8);
|
|
48078
48097
|
const childrenIds = "index" in movingItem && movingItem.index ? movingItem.getChildrenIds() : [];
|
|
48079
|
-
const nearbyItems = this.canvasDrawer.getLastCreatedCanvas() ? this.spatialIndex.getNearestTo(movingMBR.getCenter(), 20, (
|
|
48098
|
+
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);
|
|
48080
48099
|
const verticalAlignments = new Map;
|
|
48081
48100
|
const horizontalAlignments = new Map;
|
|
48082
48101
|
const addVerticalAlignment = (x, minY, maxY) => {
|
|
@@ -48097,11 +48116,11 @@ class AlignmentHelper {
|
|
|
48097
48116
|
horizontalAlignments.set(y, { minX, maxX });
|
|
48098
48117
|
}
|
|
48099
48118
|
};
|
|
48100
|
-
nearbyItems.forEach((
|
|
48101
|
-
if (
|
|
48119
|
+
nearbyItems.forEach((item) => {
|
|
48120
|
+
if (item === movingItem || item.itemType === "Comment") {
|
|
48102
48121
|
return;
|
|
48103
48122
|
}
|
|
48104
|
-
const itemMbr =
|
|
48123
|
+
const itemMbr = item.itemType === "Shape" ? item.getPath().getMbr() : item.getMbr();
|
|
48105
48124
|
const centerXMoving = (movingMBR.left + movingMBR.right) / 2;
|
|
48106
48125
|
const centerXItem = (itemMbr.left + itemMbr.right) / 2;
|
|
48107
48126
|
const centerYMoving = (movingMBR.top + movingMBR.bottom) / 2;
|
|
@@ -48368,20 +48387,20 @@ class AlignmentHelper {
|
|
|
48368
48387
|
}
|
|
48369
48388
|
return false;
|
|
48370
48389
|
}
|
|
48371
|
-
translateItems(
|
|
48390
|
+
translateItems(item, x, y, timeStamp) {
|
|
48372
48391
|
if (this.canvasDrawer.getLastCreatedCanvas()) {
|
|
48373
48392
|
return;
|
|
48374
48393
|
}
|
|
48375
|
-
if (Array.isArray(
|
|
48394
|
+
if (Array.isArray(item)) {
|
|
48376
48395
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
48377
48396
|
this.board.selection.transformMany(translation, timeStamp);
|
|
48378
48397
|
return;
|
|
48379
48398
|
}
|
|
48380
|
-
if (
|
|
48399
|
+
if (item.itemType === "Frame") {
|
|
48381
48400
|
const translation = this.board.selection.getManyItemsTranslation(x, y);
|
|
48382
48401
|
this.board.selection.transformMany(translation, timeStamp);
|
|
48383
48402
|
} else {
|
|
48384
|
-
const id =
|
|
48403
|
+
const id = item.getId();
|
|
48385
48404
|
const transformMap = {};
|
|
48386
48405
|
transformMap[id] = {
|
|
48387
48406
|
class: "Transformation",
|
|
@@ -48509,12 +48528,12 @@ class Select extends Tool {
|
|
|
48509
48528
|
this.debounceUpd.setFalse();
|
|
48510
48529
|
this.snapLines = { verticalLines: [], horizontalLines: [] };
|
|
48511
48530
|
}
|
|
48512
|
-
handleSnapping(
|
|
48531
|
+
handleSnapping(item) {
|
|
48513
48532
|
if (this.board.keyboard.isShift) {
|
|
48514
48533
|
return false;
|
|
48515
48534
|
}
|
|
48516
|
-
const increasedSnapThreshold = Array.isArray(
|
|
48517
|
-
this.isSnapped = this.alignmentHelper.snapToClosestLine(
|
|
48535
|
+
const increasedSnapThreshold = Array.isArray(item) ? 40 : 35;
|
|
48536
|
+
this.isSnapped = this.alignmentHelper.snapToClosestLine(item, this.snapLines, this.beginTimeStamp, this.board.pointer.point);
|
|
48518
48537
|
if (this.isSnapped) {
|
|
48519
48538
|
if (!this.snapCursorPos) {
|
|
48520
48539
|
this.snapCursorPos = new Point(this.board.pointer.point.x, this.board.pointer.point.y);
|
|
@@ -48524,10 +48543,10 @@ class Select extends Tool {
|
|
|
48524
48543
|
if ((cursorDiffX > increasedSnapThreshold || cursorDiffY > increasedSnapThreshold) && this.initialCursorPos) {
|
|
48525
48544
|
this.isSnapped = false;
|
|
48526
48545
|
this.snapCursorPos = null;
|
|
48527
|
-
const itemCenter = Array.isArray(
|
|
48546
|
+
const itemCenter = Array.isArray(item) ? this.alignmentHelper.combineMBRs(item).getCenter() : item.getMbr().getCenter();
|
|
48528
48547
|
const translateX = this.board.pointer.point.x - this.initialCursorPos.x - itemCenter.x;
|
|
48529
48548
|
const translateY = this.board.pointer.point.y - this.initialCursorPos.y - itemCenter.y;
|
|
48530
|
-
this.alignmentHelper.translateItems(
|
|
48549
|
+
this.alignmentHelper.translateItems(item, translateX, translateY, this.beginTimeStamp);
|
|
48531
48550
|
}
|
|
48532
48551
|
}
|
|
48533
48552
|
return false;
|
|
@@ -48577,10 +48596,10 @@ class Select extends Tool {
|
|
|
48577
48596
|
angleDiff = angleDiff < 0 ? angleDiff + 360 : angleDiff;
|
|
48578
48597
|
return Math.min(angleDiff, 360 - angleDiff);
|
|
48579
48598
|
}
|
|
48580
|
-
handleShiftGuidelines(
|
|
48581
|
-
if (
|
|
48599
|
+
handleShiftGuidelines(item, mousePosition) {
|
|
48600
|
+
if (item) {
|
|
48582
48601
|
if (!this.originalCenter) {
|
|
48583
|
-
this.originalCenter = Array.isArray(
|
|
48602
|
+
this.originalCenter = Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().copy() : item.getMbr().getCenter().copy();
|
|
48584
48603
|
this.guidelines = this.alignmentHelper.generateGuidelines(this.originalCenter).lines;
|
|
48585
48604
|
}
|
|
48586
48605
|
this.mainLine = new Line(this.originalCenter, mousePosition);
|
|
@@ -48601,13 +48620,13 @@ class Select extends Tool {
|
|
|
48601
48620
|
const newEndX = this.originalCenter.x + snapDirectionX * mainLineLength;
|
|
48602
48621
|
const newEndY = this.originalCenter.y + snapDirectionY * mainLineLength;
|
|
48603
48622
|
const threshold = Infinity;
|
|
48604
|
-
const translateX = newEndX - (Array.isArray(
|
|
48605
|
-
const translateY = newEndY - (Array.isArray(
|
|
48606
|
-
if (Array.isArray(
|
|
48623
|
+
const translateX = newEndX - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().x : item.getMbr().getCenter().x);
|
|
48624
|
+
const translateY = newEndY - (Array.isArray(item) ? this.board.selection.getMbr()?.getCenter().y : item.getMbr().getCenter().y);
|
|
48625
|
+
if (Array.isArray(item)) {
|
|
48607
48626
|
const translation = this.board.selection.getManyItemsTranslation(translateX, translateY);
|
|
48608
48627
|
this.board.selection.transformMany(translation, this.beginTimeStamp);
|
|
48609
48628
|
} else {
|
|
48610
|
-
|
|
48629
|
+
item.transformation.translateBy(translateX, translateY, this.beginTimeStamp);
|
|
48611
48630
|
}
|
|
48612
48631
|
}
|
|
48613
48632
|
}
|
|
@@ -48650,7 +48669,7 @@ class Select extends Tool {
|
|
|
48650
48669
|
return false;
|
|
48651
48670
|
}
|
|
48652
48671
|
this.isDownOnBoard = hover.length === 0;
|
|
48653
|
-
this.isDrawingRectangle = hover.filter((
|
|
48672
|
+
this.isDrawingRectangle = hover.filter((item) => !(item instanceof Frame2)).length === 0 && hover.filter((item) => item instanceof Frame2).filter((frame) => frame.isTextUnderPoint(pointer.point)).length === 0;
|
|
48654
48673
|
if (this.isDrawingRectangle) {
|
|
48655
48674
|
const { x, y } = pointer.point;
|
|
48656
48675
|
this.line = new Line(new Point(x, y), new Point(x, y));
|
|
@@ -48670,7 +48689,7 @@ class Select extends Tool {
|
|
|
48670
48689
|
});
|
|
48671
48690
|
return false;
|
|
48672
48691
|
}
|
|
48673
|
-
const isHoverLocked = hover.every((
|
|
48692
|
+
const isHoverLocked = hover.every((item) => item.transformation.isLocked);
|
|
48674
48693
|
if (isHoverLocked) {
|
|
48675
48694
|
return false;
|
|
48676
48695
|
}
|
|
@@ -48804,7 +48823,7 @@ class Select extends Tool {
|
|
|
48804
48823
|
const translation = selection.getManyItemsTranslation(x, y);
|
|
48805
48824
|
const translationKeys = Object.keys(translation);
|
|
48806
48825
|
const commentsSet = new Set(this.board.items.getComments().map((comment2) => comment2.getId()));
|
|
48807
|
-
if (translationKeys.filter((
|
|
48826
|
+
if (translationKeys.filter((item) => !commentsSet.has(item)).length > 10) {
|
|
48808
48827
|
const selectedMbr = this.board.selection.getMbr()?.copy();
|
|
48809
48828
|
const sumMbr = this.canvasDrawer.countSumMbr(translation);
|
|
48810
48829
|
if (sumMbr) {
|
|
@@ -48831,7 +48850,7 @@ class Select extends Tool {
|
|
|
48831
48850
|
return false;
|
|
48832
48851
|
}
|
|
48833
48852
|
const draggingMbr = draggingItem.getMbr();
|
|
48834
|
-
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((
|
|
48853
|
+
const frames = this.board.items.getEnclosedOrCrossed(draggingMbr.left, draggingMbr.top, draggingMbr.right, draggingMbr.bottom).filter((item) => item instanceof Frame2);
|
|
48835
48854
|
frames.forEach((frame) => {
|
|
48836
48855
|
if (frame.handleNesting(draggingItem)) {
|
|
48837
48856
|
this.nestingHighlighter.add(frame, draggingItem);
|
|
@@ -48841,7 +48860,7 @@ class Select extends Tool {
|
|
|
48841
48860
|
});
|
|
48842
48861
|
}
|
|
48843
48862
|
const hover = items.getUnderPointer();
|
|
48844
|
-
this.isHoverUnselectedItem = hover.filter((
|
|
48863
|
+
this.isHoverUnselectedItem = hover.filter((item) => item.itemType === "Placeholder").length === 1;
|
|
48845
48864
|
if (this.isHoverUnselectedItem && !this.isDraggingUnselectedItem && selection.getContext() === "None") {
|
|
48846
48865
|
selection.setContext("HoverUnderPointer");
|
|
48847
48866
|
return false;
|
|
@@ -48885,15 +48904,15 @@ class Select extends Tool {
|
|
|
48885
48904
|
}
|
|
48886
48905
|
}
|
|
48887
48906
|
updateFramesNesting(selectionMbr, selection) {
|
|
48888
|
-
const frames = this.board.items.getEnclosedOrCrossed(selectionMbr.left, selectionMbr.top, selectionMbr.right, selectionMbr.bottom).filter((
|
|
48889
|
-
const draggingFramesIds = selection.list().filter((
|
|
48890
|
-
selection.list().forEach((
|
|
48891
|
-
if (!(
|
|
48907
|
+
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));
|
|
48908
|
+
const draggingFramesIds = selection.list().filter((item) => item instanceof Frame2).map((frame) => frame.getId());
|
|
48909
|
+
selection.list().forEach((item) => {
|
|
48910
|
+
if (!(item instanceof Frame2) && !draggingFramesIds.includes(item.parent)) {
|
|
48892
48911
|
frames.forEach((frame) => {
|
|
48893
|
-
if (frame.handleNesting(
|
|
48894
|
-
this.nestingHighlighter.add(frame,
|
|
48912
|
+
if (frame.handleNesting(item)) {
|
|
48913
|
+
this.nestingHighlighter.add(frame, item);
|
|
48895
48914
|
} else {
|
|
48896
|
-
this.nestingHighlighter.remove(
|
|
48915
|
+
this.nestingHighlighter.remove(item);
|
|
48897
48916
|
}
|
|
48898
48917
|
});
|
|
48899
48918
|
}
|
|
@@ -48985,7 +49004,7 @@ class Select extends Tool {
|
|
|
48985
49004
|
const childrenIds = underPointer.getChildrenIds();
|
|
48986
49005
|
console.log("UNDERPOINTER", underPointer);
|
|
48987
49006
|
console.log("CHILDREN", childrenIds);
|
|
48988
|
-
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((
|
|
49007
|
+
const itemsInFrame = this.board.items.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => childrenIds && childrenIds.includes(item.getId()));
|
|
48989
49008
|
this.board.selection.add(itemsInFrame);
|
|
48990
49009
|
}
|
|
48991
49010
|
this.board.selection.setContext("EditUnderPointer");
|
|
@@ -49225,8 +49244,8 @@ class ShapeTool extends CustomTool {
|
|
|
49225
49244
|
resizeType = "leftBottom";
|
|
49226
49245
|
bounds = new Mbr;
|
|
49227
49246
|
isDown = false;
|
|
49228
|
-
constructor(board, name,
|
|
49229
|
-
super(board, name,
|
|
49247
|
+
constructor(board, name, item, settings) {
|
|
49248
|
+
super(board, name, item);
|
|
49230
49249
|
this.settings = settings;
|
|
49231
49250
|
this.setCursor();
|
|
49232
49251
|
}
|
|
@@ -49309,8 +49328,8 @@ class ShapeTool extends CustomTool {
|
|
|
49309
49328
|
|
|
49310
49329
|
class StickerTool extends CustomTool {
|
|
49311
49330
|
settings;
|
|
49312
|
-
constructor(board, name,
|
|
49313
|
-
super(board, name,
|
|
49331
|
+
constructor(board, name, item, settings) {
|
|
49332
|
+
super(board, name, item);
|
|
49314
49333
|
this.settings = settings;
|
|
49315
49334
|
this.setCursor();
|
|
49316
49335
|
}
|
|
@@ -49616,7 +49635,7 @@ class Tools extends ToolContext {
|
|
|
49616
49635
|
this.subject.publish(this);
|
|
49617
49636
|
}
|
|
49618
49637
|
sortFrames() {
|
|
49619
|
-
const frames = this.board.items.listAll().filter((
|
|
49638
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame2);
|
|
49620
49639
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
49621
49640
|
const mbr1 = fr1.getMbr();
|
|
49622
49641
|
const mbr2 = fr2.getMbr();
|
|
@@ -49842,24 +49861,24 @@ function validateGroupData(groupData) {
|
|
|
49842
49861
|
}
|
|
49843
49862
|
// src/Items/RegisterItem.ts
|
|
49844
49863
|
function registerItem({
|
|
49845
|
-
item
|
|
49864
|
+
item,
|
|
49846
49865
|
defaultData: defaultData2,
|
|
49847
49866
|
toolData
|
|
49848
49867
|
}) {
|
|
49849
49868
|
const { itemType } = defaultData2;
|
|
49850
|
-
itemFactories[itemType] = createItemFactory(
|
|
49869
|
+
itemFactories[itemType] = createItemFactory(item, defaultData2);
|
|
49851
49870
|
itemValidators[itemType] = createItemValidator(defaultData2);
|
|
49852
49871
|
if (toolData) {
|
|
49853
49872
|
registeredTools[toolData.name] = toolData.tool;
|
|
49854
49873
|
}
|
|
49855
49874
|
itemCommandFactories[itemType] = createItemCommandFactory(itemType);
|
|
49856
49875
|
}
|
|
49857
|
-
function createItemFactory(
|
|
49876
|
+
function createItemFactory(item, defaultData2) {
|
|
49858
49877
|
return function itemFactory(id, data, board) {
|
|
49859
49878
|
if (data.itemType !== defaultData2.itemType) {
|
|
49860
49879
|
throw new Error(`Invalid data for ${defaultData2.itemType}`);
|
|
49861
49880
|
}
|
|
49862
|
-
return new
|
|
49881
|
+
return new item(board, id, defaultData2).setId(id).deserialize(data);
|
|
49863
49882
|
};
|
|
49864
49883
|
}
|
|
49865
49884
|
function createItemValidator(defaultData2) {
|
|
@@ -49874,7 +49893,7 @@ function createItemValidator(defaultData2) {
|
|
|
49874
49893
|
}
|
|
49875
49894
|
function createItemCommandFactory(itemType) {
|
|
49876
49895
|
return function itemCommandFactory(items, operation) {
|
|
49877
|
-
return new BaseCommand(items.filter((
|
|
49896
|
+
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49878
49897
|
};
|
|
49879
49898
|
}
|
|
49880
49899
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -50899,8 +50918,8 @@ class Camera {
|
|
|
50899
50918
|
this.observableItem = null;
|
|
50900
50919
|
}
|
|
50901
50920
|
}
|
|
50902
|
-
subscribeToItem(
|
|
50903
|
-
this.observableItem =
|
|
50921
|
+
subscribeToItem(item) {
|
|
50922
|
+
this.observableItem = item;
|
|
50904
50923
|
this.observableItem.subject.subscribe(this.observeItem);
|
|
50905
50924
|
}
|
|
50906
50925
|
observeItem = () => {
|
|
@@ -51126,7 +51145,7 @@ class Camera {
|
|
|
51126
51145
|
}
|
|
51127
51146
|
addToView(mbr, inView) {
|
|
51128
51147
|
if (!mbr.isEnclosedBy(this.getMbr())) {
|
|
51129
|
-
this.viewRectangle(inView.reduce((acc,
|
|
51148
|
+
this.viewRectangle(inView.reduce((acc, item) => acc.combine(item.getMbr()), inView[0]?.getMbr() ?? new Mbr).combine(mbr));
|
|
51130
51149
|
}
|
|
51131
51150
|
}
|
|
51132
51151
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
@@ -52735,8 +52754,8 @@ class Presence {
|
|
|
52735
52754
|
<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}"/>
|
|
52736
52755
|
</svg>`;
|
|
52737
52756
|
}
|
|
52738
|
-
renderItemMbr(context,
|
|
52739
|
-
const mbr =
|
|
52757
|
+
renderItemMbr(context, item, color2, customScale) {
|
|
52758
|
+
const mbr = item.getMbr();
|
|
52740
52759
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
52741
52760
|
mbr.borderColor = color2;
|
|
52742
52761
|
mbr.render(context);
|
|
@@ -52876,8 +52895,8 @@ class Presence {
|
|
|
52876
52895
|
selectionMbr.strokeWidth = 1 / context.matrix.scaleX;
|
|
52877
52896
|
selectionMbr.borderColor = selection.color;
|
|
52878
52897
|
selectionMbr.render(context);
|
|
52879
|
-
for (const
|
|
52880
|
-
this.renderItemMbr(context,
|
|
52898
|
+
for (const item of selection.selection) {
|
|
52899
|
+
this.renderItemMbr(context, item, selection.color);
|
|
52881
52900
|
}
|
|
52882
52901
|
}
|
|
52883
52902
|
}
|
|
@@ -52910,14 +52929,14 @@ class SelectionItems {
|
|
|
52910
52929
|
items = new Map;
|
|
52911
52930
|
add(value) {
|
|
52912
52931
|
if (Array.isArray(value)) {
|
|
52913
|
-
value.forEach((
|
|
52932
|
+
value.forEach((item) => this.items.set(item.getId(), item));
|
|
52914
52933
|
} else {
|
|
52915
52934
|
this.items.set(value.getId(), value);
|
|
52916
52935
|
}
|
|
52917
52936
|
}
|
|
52918
52937
|
remove(value) {
|
|
52919
52938
|
if (Array.isArray(value)) {
|
|
52920
|
-
value.forEach((
|
|
52939
|
+
value.forEach((item) => this.items.delete(item.getId()));
|
|
52921
52940
|
} else {
|
|
52922
52941
|
this.items.delete(value.getId());
|
|
52923
52942
|
}
|
|
@@ -52947,8 +52966,8 @@ class SelectionItems {
|
|
|
52947
52966
|
if (this.isEmpty()) {
|
|
52948
52967
|
return false;
|
|
52949
52968
|
}
|
|
52950
|
-
for (const
|
|
52951
|
-
if (
|
|
52969
|
+
for (const item of this.items.values()) {
|
|
52970
|
+
if (item.itemType !== "RichText") {
|
|
52952
52971
|
return false;
|
|
52953
52972
|
}
|
|
52954
52973
|
}
|
|
@@ -52958,14 +52977,14 @@ class SelectionItems {
|
|
|
52958
52977
|
if (this.isEmpty()) {
|
|
52959
52978
|
return false;
|
|
52960
52979
|
}
|
|
52961
|
-
return Array.from(this.items).every(([,
|
|
52980
|
+
return Array.from(this.items).every(([, item]) => item.itemType === itemType);
|
|
52962
52981
|
}
|
|
52963
52982
|
isItemTypes(itemTypes) {
|
|
52964
52983
|
if (this.isEmpty()) {
|
|
52965
52984
|
return false;
|
|
52966
52985
|
}
|
|
52967
|
-
for (const
|
|
52968
|
-
if (!itemTypes.includes(
|
|
52986
|
+
for (const item of this.items.values()) {
|
|
52987
|
+
if (!itemTypes.includes(item.itemType)) {
|
|
52969
52988
|
return false;
|
|
52970
52989
|
}
|
|
52971
52990
|
}
|
|
@@ -52973,16 +52992,16 @@ class SelectionItems {
|
|
|
52973
52992
|
}
|
|
52974
52993
|
getItemTypes() {
|
|
52975
52994
|
const itemTypes = new Set;
|
|
52976
|
-
this.items.forEach((
|
|
52995
|
+
this.items.forEach((item) => itemTypes.add(item.itemType));
|
|
52977
52996
|
return Array.from(itemTypes);
|
|
52978
52997
|
}
|
|
52979
52998
|
getItemsByItemTypes(itemTypes) {
|
|
52980
|
-
return Array.from(this.items.values()).filter((
|
|
52999
|
+
return Array.from(this.items.values()).filter((item) => itemTypes.includes(item.itemType));
|
|
52981
53000
|
}
|
|
52982
53001
|
getIdsByItemTypes(itemTypes) {
|
|
52983
53002
|
const ids = [];
|
|
52984
|
-
this.items.forEach((
|
|
52985
|
-
if (itemTypes.includes(
|
|
53003
|
+
this.items.forEach((item, id) => {
|
|
53004
|
+
if (itemTypes.includes(item.itemType)) {
|
|
52986
53005
|
ids.push(id);
|
|
52987
53006
|
}
|
|
52988
53007
|
});
|
|
@@ -52992,7 +53011,7 @@ class SelectionItems {
|
|
|
52992
53011
|
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
52993
53012
|
}
|
|
52994
53013
|
listByIds(itemIdList) {
|
|
52995
|
-
return itemIdList.map((id) => this.items.get(id)).filter((
|
|
53014
|
+
return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
|
|
52996
53015
|
}
|
|
52997
53016
|
ids() {
|
|
52998
53017
|
return Array.from(this.items.keys());
|
|
@@ -53003,7 +53022,7 @@ class SelectionItems {
|
|
|
53003
53022
|
return;
|
|
53004
53023
|
}
|
|
53005
53024
|
const mbr = items[0].getMbr();
|
|
53006
|
-
items.slice(1).forEach((
|
|
53025
|
+
items.slice(1).forEach((item) => mbr.combine(item.getMbr()));
|
|
53007
53026
|
return mbr;
|
|
53008
53027
|
}
|
|
53009
53028
|
}
|
|
@@ -53208,33 +53227,33 @@ function handleMultipleItemsResize({
|
|
|
53208
53227
|
const translation = {};
|
|
53209
53228
|
const items = itemsToResize ? itemsToResize : board.selection.items.list();
|
|
53210
53229
|
board.items.getComments().forEach((comment2) => {
|
|
53211
|
-
if (items.some((
|
|
53230
|
+
if (items.some((item) => item.getId() === comment2.getItemToFollow())) {
|
|
53212
53231
|
items.push(comment2);
|
|
53213
53232
|
}
|
|
53214
53233
|
});
|
|
53215
|
-
for (const
|
|
53216
|
-
let itemX =
|
|
53217
|
-
let itemY =
|
|
53218
|
-
if (
|
|
53219
|
-
itemX =
|
|
53220
|
-
itemY =
|
|
53234
|
+
for (const item of items) {
|
|
53235
|
+
let itemX = item.getMbr().left;
|
|
53236
|
+
let itemY = item.getMbr().top;
|
|
53237
|
+
if (item.itemType === "Drawing") {
|
|
53238
|
+
itemX = item.transformation.matrix.translateX;
|
|
53239
|
+
itemY = item.transformation.matrix.translateY;
|
|
53221
53240
|
}
|
|
53222
53241
|
const deltaX = itemX - initMbr.left;
|
|
53223
53242
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
53224
53243
|
const deltaY = itemY - initMbr.top;
|
|
53225
53244
|
const translateY = deltaY * matrix.scaleY - deltaY + matrix.translateY;
|
|
53226
|
-
if (
|
|
53227
|
-
translation[
|
|
53228
|
-
item
|
|
53245
|
+
if (item instanceof RichText) {
|
|
53246
|
+
translation[item.getId()] = getRichTextTranslation({
|
|
53247
|
+
item,
|
|
53229
53248
|
isWidth,
|
|
53230
53249
|
isHeight,
|
|
53231
53250
|
matrix,
|
|
53232
53251
|
translateX,
|
|
53233
53252
|
translateY
|
|
53234
53253
|
});
|
|
53235
|
-
} else if (
|
|
53236
|
-
translation[
|
|
53237
|
-
item
|
|
53254
|
+
} else if (item instanceof AINode) {
|
|
53255
|
+
translation[item.getId()] = getAINodeTranslation({
|
|
53256
|
+
item,
|
|
53238
53257
|
isWidth,
|
|
53239
53258
|
isHeight,
|
|
53240
53259
|
matrix,
|
|
@@ -53242,8 +53261,8 @@ function handleMultipleItemsResize({
|
|
|
53242
53261
|
translateY
|
|
53243
53262
|
});
|
|
53244
53263
|
} else {
|
|
53245
|
-
translation[
|
|
53246
|
-
item
|
|
53264
|
+
translation[item.getId()] = getItemTranslation({
|
|
53265
|
+
item,
|
|
53247
53266
|
isWidth,
|
|
53248
53267
|
isHeight,
|
|
53249
53268
|
matrix,
|
|
@@ -53256,7 +53275,7 @@ function handleMultipleItemsResize({
|
|
|
53256
53275
|
return translation;
|
|
53257
53276
|
}
|
|
53258
53277
|
function getRichTextTranslation({
|
|
53259
|
-
item
|
|
53278
|
+
item,
|
|
53260
53279
|
isWidth,
|
|
53261
53280
|
isHeight,
|
|
53262
53281
|
matrix,
|
|
@@ -53264,11 +53283,11 @@ function getRichTextTranslation({
|
|
|
53264
53283
|
translateY
|
|
53265
53284
|
}) {
|
|
53266
53285
|
if (isWidth) {
|
|
53267
|
-
|
|
53286
|
+
item.editor.setMaxWidth(item.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
53268
53287
|
return {
|
|
53269
53288
|
class: "Transformation",
|
|
53270
53289
|
method: "scaleByTranslateBy",
|
|
53271
|
-
item: [
|
|
53290
|
+
item: [item.getId()],
|
|
53272
53291
|
translate: { x: matrix.translateX, y: 0 },
|
|
53273
53292
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53274
53293
|
};
|
|
@@ -53276,7 +53295,7 @@ function getRichTextTranslation({
|
|
|
53276
53295
|
return {
|
|
53277
53296
|
class: "Transformation",
|
|
53278
53297
|
method: "scaleByTranslateBy",
|
|
53279
|
-
item: [
|
|
53298
|
+
item: [item.getId()],
|
|
53280
53299
|
translate: { x: translateX, y: translateY },
|
|
53281
53300
|
scale: { x: 1, y: 1 }
|
|
53282
53301
|
};
|
|
@@ -53284,14 +53303,14 @@ function getRichTextTranslation({
|
|
|
53284
53303
|
return {
|
|
53285
53304
|
class: "Transformation",
|
|
53286
53305
|
method: "scaleByTranslateBy",
|
|
53287
|
-
item: [
|
|
53306
|
+
item: [item.getId()],
|
|
53288
53307
|
translate: { x: translateX, y: translateY },
|
|
53289
53308
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53290
53309
|
};
|
|
53291
53310
|
}
|
|
53292
53311
|
}
|
|
53293
53312
|
function getAINodeTranslation({
|
|
53294
|
-
item
|
|
53313
|
+
item,
|
|
53295
53314
|
isWidth,
|
|
53296
53315
|
isHeight,
|
|
53297
53316
|
matrix,
|
|
@@ -53299,11 +53318,11 @@ function getAINodeTranslation({
|
|
|
53299
53318
|
translateY
|
|
53300
53319
|
}) {
|
|
53301
53320
|
if (isWidth) {
|
|
53302
|
-
|
|
53321
|
+
item.text.editor.setMaxWidth(item.text.getWidth() / item.transformation.getScale().x * matrix.scaleX);
|
|
53303
53322
|
return {
|
|
53304
53323
|
class: "Transformation",
|
|
53305
53324
|
method: "scaleByTranslateBy",
|
|
53306
|
-
item: [
|
|
53325
|
+
item: [item.getId()],
|
|
53307
53326
|
translate: { x: matrix.translateX, y: 0 },
|
|
53308
53327
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53309
53328
|
};
|
|
@@ -53311,7 +53330,7 @@ function getAINodeTranslation({
|
|
|
53311
53330
|
return {
|
|
53312
53331
|
class: "Transformation",
|
|
53313
53332
|
method: "scaleByTranslateBy",
|
|
53314
|
-
item: [
|
|
53333
|
+
item: [item.getId()],
|
|
53315
53334
|
translate: { x: translateX, y: translateY },
|
|
53316
53335
|
scale: { x: 1, y: 1 }
|
|
53317
53336
|
};
|
|
@@ -53319,14 +53338,14 @@ function getAINodeTranslation({
|
|
|
53319
53338
|
return {
|
|
53320
53339
|
class: "Transformation",
|
|
53321
53340
|
method: "scaleByTranslateBy",
|
|
53322
|
-
item: [
|
|
53341
|
+
item: [item.getId()],
|
|
53323
53342
|
translate: { x: translateX, y: translateY },
|
|
53324
53343
|
scale: { x: matrix.scaleX, y: matrix.scaleX }
|
|
53325
53344
|
};
|
|
53326
53345
|
}
|
|
53327
53346
|
}
|
|
53328
53347
|
function getItemTranslation({
|
|
53329
|
-
item
|
|
53348
|
+
item,
|
|
53330
53349
|
isWidth,
|
|
53331
53350
|
isHeight,
|
|
53332
53351
|
matrix,
|
|
@@ -53334,22 +53353,22 @@ function getItemTranslation({
|
|
|
53334
53353
|
translateY,
|
|
53335
53354
|
isShiftPressed
|
|
53336
53355
|
}) {
|
|
53337
|
-
if (
|
|
53356
|
+
if (item instanceof Sticker && (isWidth || isHeight)) {
|
|
53338
53357
|
return {
|
|
53339
53358
|
class: "Transformation",
|
|
53340
53359
|
method: "scaleByTranslateBy",
|
|
53341
|
-
item: [
|
|
53360
|
+
item: [item.getId()],
|
|
53342
53361
|
translate: { x: translateX, y: translateY },
|
|
53343
53362
|
scale: { x: 1, y: 1 }
|
|
53344
53363
|
};
|
|
53345
53364
|
} else {
|
|
53346
|
-
if (
|
|
53347
|
-
|
|
53365
|
+
if (item instanceof Frame2 && item.getCanChangeRatio() && isShiftPressed && item.getFrameType() !== "Custom") {
|
|
53366
|
+
item.setFrameType("Custom");
|
|
53348
53367
|
}
|
|
53349
53368
|
return {
|
|
53350
53369
|
class: "Transformation",
|
|
53351
53370
|
method: "scaleByTranslateBy",
|
|
53352
|
-
item: [
|
|
53371
|
+
item: [item.getId()],
|
|
53353
53372
|
translate: { x: translateX, y: translateY },
|
|
53354
53373
|
scale: { x: matrix.scaleX, y: matrix.scaleY }
|
|
53355
53374
|
};
|
|
@@ -53622,11 +53641,11 @@ function transformItems({
|
|
|
53622
53641
|
setSnapCursorPos
|
|
53623
53642
|
}) {
|
|
53624
53643
|
const items = selection.items.list();
|
|
53625
|
-
const includesProportionalItem = items.some((
|
|
53644
|
+
const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
|
|
53626
53645
|
if (includesProportionalItem && (isWidth || isHeight)) {
|
|
53627
53646
|
return null;
|
|
53628
53647
|
}
|
|
53629
|
-
const isIncludesFixedFrame = items.some((
|
|
53648
|
+
const isIncludesFixedFrame = items.some((item) => item instanceof Frame2 && !item.getCanChangeRatio());
|
|
53630
53649
|
const shouldBeProportionalResize = isIncludesFixedFrame || includesProportionalItem || isShiftPressed || !isWidth && !isHeight;
|
|
53631
53650
|
const resize = shouldBeProportionalResize ? getProportionalResize(resizeType, board.pointer.point, mbr, oppositePoint) : getResize(resizeType, board.pointer.point, mbr, oppositePoint);
|
|
53632
53651
|
if (canvasDrawer.getLastCreatedCanvas() && !debounceUpd.shouldUpd()) {
|
|
@@ -53704,23 +53723,23 @@ function updateFrameChildren({
|
|
|
53704
53723
|
nestingHighlighter
|
|
53705
53724
|
}) {
|
|
53706
53725
|
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
53707
|
-
board.selection.items.list().forEach((
|
|
53708
|
-
if ("getChildrenIds" in
|
|
53709
|
-
const currMbr =
|
|
53726
|
+
board.selection.items.list().forEach((item) => {
|
|
53727
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
53728
|
+
const currMbr = item.getMbr();
|
|
53710
53729
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
53711
53730
|
itemsToCheck.forEach((currItem) => {
|
|
53712
|
-
if (
|
|
53713
|
-
nestingHighlighter.add(
|
|
53731
|
+
if (item.handleNesting(currItem) && (currItem.parent === "Board" || currItem.parent === item.getId())) {
|
|
53732
|
+
nestingHighlighter.add(item, currItem);
|
|
53714
53733
|
} else {
|
|
53715
53734
|
nestingHighlighter.remove(currItem);
|
|
53716
53735
|
}
|
|
53717
53736
|
});
|
|
53718
53737
|
} else {
|
|
53719
53738
|
groups.forEach((group) => {
|
|
53720
|
-
if (group.handleNesting(
|
|
53721
|
-
nestingHighlighter.add(group,
|
|
53739
|
+
if (group.handleNesting(item)) {
|
|
53740
|
+
nestingHighlighter.add(group, item);
|
|
53722
53741
|
} else {
|
|
53723
|
-
nestingHighlighter.remove(
|
|
53742
|
+
nestingHighlighter.remove(item);
|
|
53724
53743
|
}
|
|
53725
53744
|
});
|
|
53726
53745
|
}
|
|
@@ -53788,9 +53807,9 @@ class Transformer extends Tool {
|
|
|
53788
53807
|
const pointer = this.board.pointer;
|
|
53789
53808
|
const camera = this.board.camera;
|
|
53790
53809
|
const items = this.selection.items;
|
|
53791
|
-
const
|
|
53810
|
+
const item = items.getSingle();
|
|
53792
53811
|
let resizeType;
|
|
53793
|
-
if (
|
|
53812
|
+
if (item && (item.itemType === "RichText" || item.itemType === "Sticker")) {
|
|
53794
53813
|
resizeType = getTextResizeType(pointer.point, camera.getScale(), mbr);
|
|
53795
53814
|
} else {
|
|
53796
53815
|
resizeType = getResizeType(pointer.point, camera.getScale(), mbr);
|
|
@@ -54044,8 +54063,8 @@ class SelectionTransformer extends Tool {
|
|
|
54044
54063
|
return;
|
|
54045
54064
|
}
|
|
54046
54065
|
if (this.selection.items.isSingle()) {
|
|
54047
|
-
const
|
|
54048
|
-
if (
|
|
54066
|
+
const item = this.selection.items.getSingle();
|
|
54067
|
+
if (item?.itemType === "Connector") {
|
|
54049
54068
|
this.tool = this.connectorTransformerTool;
|
|
54050
54069
|
return;
|
|
54051
54070
|
} else {
|
|
@@ -54128,16 +54147,16 @@ class BoardSelection {
|
|
|
54128
54147
|
this.quickAddButtons = getQuickAddButtons(this, board);
|
|
54129
54148
|
}
|
|
54130
54149
|
serialize() {
|
|
54131
|
-
const selectedItems = this.items.list().map((
|
|
54150
|
+
const selectedItems = this.items.list().map((item) => item.getId());
|
|
54132
54151
|
return JSON.stringify(selectedItems);
|
|
54133
54152
|
}
|
|
54134
54153
|
deserialize(serializedData) {
|
|
54135
54154
|
const selectedItems = JSON.parse(serializedData);
|
|
54136
54155
|
this.removeAll();
|
|
54137
54156
|
selectedItems.forEach((itemId) => {
|
|
54138
|
-
const
|
|
54139
|
-
if (
|
|
54140
|
-
this.items.add(
|
|
54157
|
+
const item = this.board.items.getById(itemId);
|
|
54158
|
+
if (item) {
|
|
54159
|
+
this.items.add(item);
|
|
54141
54160
|
}
|
|
54142
54161
|
});
|
|
54143
54162
|
}
|
|
@@ -54215,19 +54234,19 @@ class BoardSelection {
|
|
|
54215
54234
|
this.updateQueue.clear();
|
|
54216
54235
|
safeRequestAnimationFrame(this.updateScheduledObservers);
|
|
54217
54236
|
};
|
|
54218
|
-
itemObserver = (
|
|
54237
|
+
itemObserver = (item) => {
|
|
54219
54238
|
if (!this.shouldPublish) {
|
|
54220
54239
|
return;
|
|
54221
54240
|
}
|
|
54222
54241
|
this.subject.publish(this);
|
|
54223
|
-
this.itemSubject.publish(
|
|
54242
|
+
this.itemSubject.publish(item);
|
|
54224
54243
|
};
|
|
54225
54244
|
decoratedItemObserver = this.decorateObserverToScheduleUpdate(this.itemObserver);
|
|
54226
54245
|
add(value) {
|
|
54227
54246
|
this.items.add(value);
|
|
54228
54247
|
if (Array.isArray(value)) {
|
|
54229
|
-
for (const
|
|
54230
|
-
|
|
54248
|
+
for (const item of value) {
|
|
54249
|
+
item.subject.subscribe(this.itemObserver);
|
|
54231
54250
|
}
|
|
54232
54251
|
} else {
|
|
54233
54252
|
value.subject.subscribe(this.itemObserver);
|
|
@@ -54236,15 +54255,15 @@ class BoardSelection {
|
|
|
54236
54255
|
this.itemsSubject.publish([]);
|
|
54237
54256
|
}
|
|
54238
54257
|
addAll() {
|
|
54239
|
-
const items = this.board.items.listAll().filter((
|
|
54258
|
+
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
54240
54259
|
this.add(items);
|
|
54241
54260
|
this.setContext("SelectByRect");
|
|
54242
54261
|
}
|
|
54243
54262
|
remove(value) {
|
|
54244
54263
|
this.items.remove(value);
|
|
54245
54264
|
if (Array.isArray(value)) {
|
|
54246
|
-
for (const
|
|
54247
|
-
|
|
54265
|
+
for (const item of value) {
|
|
54266
|
+
item.subject.unsubscribe(this.itemObserver);
|
|
54248
54267
|
}
|
|
54249
54268
|
} else {
|
|
54250
54269
|
value.subject.unsubscribe(this.itemObserver);
|
|
@@ -54338,11 +54357,11 @@ class BoardSelection {
|
|
|
54338
54357
|
if (!this.items.isSingle()) {
|
|
54339
54358
|
return;
|
|
54340
54359
|
}
|
|
54341
|
-
const
|
|
54342
|
-
if (!
|
|
54360
|
+
const item = this.items.getSingle();
|
|
54361
|
+
if (!item) {
|
|
54343
54362
|
return;
|
|
54344
54363
|
}
|
|
54345
|
-
const text5 =
|
|
54364
|
+
const text5 = item.getRichText();
|
|
54346
54365
|
if (!text5) {
|
|
54347
54366
|
return;
|
|
54348
54367
|
}
|
|
@@ -54353,7 +54372,7 @@ class BoardSelection {
|
|
|
54353
54372
|
if (shouldReplace || moveCursorToEnd) {
|
|
54354
54373
|
text5.editor.moveCursorToEndOfTheText();
|
|
54355
54374
|
}
|
|
54356
|
-
this.setTextToEdit(
|
|
54375
|
+
this.setTextToEdit(item);
|
|
54357
54376
|
this.setContext("EditTextUnderPointer");
|
|
54358
54377
|
if (shouldSelect) {
|
|
54359
54378
|
text5.editor.selectWholeText();
|
|
@@ -54363,13 +54382,13 @@ class BoardSelection {
|
|
|
54363
54382
|
editUnderPointer() {
|
|
54364
54383
|
this.removeAll();
|
|
54365
54384
|
const stack = this.board.items.getUnderPointer();
|
|
54366
|
-
const
|
|
54367
|
-
if (
|
|
54368
|
-
this.add(
|
|
54385
|
+
const item = stack.pop();
|
|
54386
|
+
if (item) {
|
|
54387
|
+
this.add(item);
|
|
54369
54388
|
this.setTextToEdit(undefined);
|
|
54370
|
-
const text5 =
|
|
54389
|
+
const text5 = item.getRichText();
|
|
54371
54390
|
if (text5) {
|
|
54372
|
-
this.setTextToEdit(
|
|
54391
|
+
this.setTextToEdit(item);
|
|
54373
54392
|
text5.editor.selectWholeText();
|
|
54374
54393
|
this.board.items.subject.publish(this.board.items);
|
|
54375
54394
|
}
|
|
@@ -54378,26 +54397,26 @@ class BoardSelection {
|
|
|
54378
54397
|
this.setContext("None");
|
|
54379
54398
|
}
|
|
54380
54399
|
}
|
|
54381
|
-
setTextToEdit(
|
|
54400
|
+
setTextToEdit(item) {
|
|
54382
54401
|
if (this.textToEdit) {
|
|
54383
54402
|
this.textToEdit.updateElement();
|
|
54384
54403
|
this.textToEdit.enableRender();
|
|
54385
54404
|
}
|
|
54386
|
-
if (!(
|
|
54405
|
+
if (!(item && item.getRichText())) {
|
|
54387
54406
|
this.textToEdit = undefined;
|
|
54388
54407
|
return;
|
|
54389
54408
|
}
|
|
54390
|
-
const text5 =
|
|
54409
|
+
const text5 = item.getRichText();
|
|
54391
54410
|
if (!text5) {
|
|
54392
54411
|
return;
|
|
54393
54412
|
}
|
|
54394
54413
|
if (text5.isEmpty()) {
|
|
54395
|
-
const textColor = tempStorage.getFontColor(
|
|
54396
|
-
const textSize = tempStorage.getFontSize(
|
|
54397
|
-
const highlightColor = tempStorage.getFontHighlight(
|
|
54398
|
-
const styles = tempStorage.getFontStyles(
|
|
54399
|
-
const horizontalAlignment = tempStorage.getHorizontalAlignment(
|
|
54400
|
-
const verticalAlignment = tempStorage.getVerticalAlignment(
|
|
54414
|
+
const textColor = tempStorage.getFontColor(item.itemType);
|
|
54415
|
+
const textSize = tempStorage.getFontSize(item.itemType);
|
|
54416
|
+
const highlightColor = tempStorage.getFontHighlight(item.itemType);
|
|
54417
|
+
const styles = tempStorage.getFontStyles(item.itemType);
|
|
54418
|
+
const horizontalAlignment = tempStorage.getHorizontalAlignment(item.itemType);
|
|
54419
|
+
const verticalAlignment = tempStorage.getVerticalAlignment(item.itemType);
|
|
54401
54420
|
if (textColor) {
|
|
54402
54421
|
text5.setSelectionFontColor(textColor, "None");
|
|
54403
54422
|
}
|
|
@@ -54405,7 +54424,7 @@ class BoardSelection {
|
|
|
54405
54424
|
this.emit({
|
|
54406
54425
|
class: "RichText",
|
|
54407
54426
|
method: "setFontSize",
|
|
54408
|
-
item: [
|
|
54427
|
+
item: [item.getId()],
|
|
54409
54428
|
fontSize: textSize,
|
|
54410
54429
|
context: this.getContext()
|
|
54411
54430
|
});
|
|
@@ -54417,10 +54436,10 @@ class BoardSelection {
|
|
|
54417
54436
|
const stylesArr = styles;
|
|
54418
54437
|
text5.setSelectionFontStyle(stylesArr, "None");
|
|
54419
54438
|
}
|
|
54420
|
-
if (horizontalAlignment && !(
|
|
54439
|
+
if (horizontalAlignment && !(item instanceof Sticker)) {
|
|
54421
54440
|
text5.setSelectionHorisontalAlignment(horizontalAlignment);
|
|
54422
54441
|
}
|
|
54423
|
-
if (verticalAlignment && !(
|
|
54442
|
+
if (verticalAlignment && !(item instanceof Sticker)) {
|
|
54424
54443
|
this.setVerticalAlignment(verticalAlignment);
|
|
54425
54444
|
}
|
|
54426
54445
|
}
|
|
@@ -54453,8 +54472,8 @@ class BoardSelection {
|
|
|
54453
54472
|
}
|
|
54454
54473
|
selectEnclosedOrCrossedBy(rect) {
|
|
54455
54474
|
this.removeAll();
|
|
54456
|
-
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
54457
|
-
const list6 = this.board.items.getEnclosedOrCrossed(rect.left, rect.top, rect.right, rect.bottom).filter((
|
|
54475
|
+
const enclosedFrames = this.board.items.getEnclosed(rect.left, rect.top, rect.right, rect.bottom).filter((item) => !item.transformation.isLocked);
|
|
54476
|
+
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);
|
|
54458
54477
|
if (list6.length !== 0) {
|
|
54459
54478
|
this.add(list6);
|
|
54460
54479
|
this.setContext("SelectByRect");
|
|
@@ -54468,14 +54487,14 @@ class BoardSelection {
|
|
|
54468
54487
|
canChangeText() {
|
|
54469
54488
|
return Boolean(this.items.isSingle() && this.items.getSingle()?.getRichText());
|
|
54470
54489
|
}
|
|
54471
|
-
handleItemCopy(
|
|
54472
|
-
const serializedData =
|
|
54473
|
-
const zIndex = this.board.items.index.getZIndex(
|
|
54474
|
-
if (
|
|
54490
|
+
handleItemCopy(item, copiedItemsMap) {
|
|
54491
|
+
const serializedData = item.serialize(true);
|
|
54492
|
+
const zIndex = this.board.items.index.getZIndex(item);
|
|
54493
|
+
if (item.itemType === "Comment") {
|
|
54475
54494
|
return;
|
|
54476
54495
|
}
|
|
54477
|
-
if (
|
|
54478
|
-
const connector =
|
|
54496
|
+
if (item.itemType === "Connector" && serializedData.itemType === "Connector") {
|
|
54497
|
+
const connector = item;
|
|
54479
54498
|
const startPoint = connector.getStartPoint();
|
|
54480
54499
|
const endPoint = connector.getEndPoint();
|
|
54481
54500
|
const startItemId = startPoint.pointType !== "Board" ? startPoint.item.getId() : null;
|
|
@@ -54491,19 +54510,19 @@ class BoardSelection {
|
|
|
54491
54510
|
serializedData.endPoint = new BoardPoint(endPoint.x, endPoint.y).serialize();
|
|
54492
54511
|
}
|
|
54493
54512
|
}
|
|
54494
|
-
const textItem =
|
|
54513
|
+
const textItem = item.getRichText()?.getTextString();
|
|
54495
54514
|
const copyText = conf.i18n.t("frame.copy");
|
|
54496
54515
|
const isCopyTextExist = textItem?.includes(copyText);
|
|
54497
|
-
const isChangeCopiedFrameText =
|
|
54516
|
+
const isChangeCopiedFrameText = item.itemType === "Frame" && serializedData.itemType === "Frame" && textItem !== "" && !isCopyTextExist;
|
|
54498
54517
|
if (isChangeCopiedFrameText) {
|
|
54499
54518
|
const copiedFrameText = copyText + (textItem || serializedData.text?.placeholderText);
|
|
54500
|
-
|
|
54501
|
-
|
|
54502
|
-
serializedData.text =
|
|
54503
|
-
|
|
54504
|
-
|
|
54519
|
+
item.getRichText()?.editor.clearText();
|
|
54520
|
+
item.getRichText()?.editor.addText(copiedFrameText);
|
|
54521
|
+
serializedData.text = item.getRichText()?.serialize();
|
|
54522
|
+
item.getRichText()?.editor.clearText();
|
|
54523
|
+
item.getRichText()?.editor.addText(textItem || "");
|
|
54505
54524
|
}
|
|
54506
|
-
copiedItemsMap[
|
|
54525
|
+
copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
|
|
54507
54526
|
}
|
|
54508
54527
|
copy(skipImageBlobCopy) {
|
|
54509
54528
|
const copiedItemsMap = {};
|
|
@@ -54512,12 +54531,12 @@ class BoardSelection {
|
|
|
54512
54531
|
this.handleItemCopy(single, copiedItemsMap);
|
|
54513
54532
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
54514
54533
|
}
|
|
54515
|
-
this.list().forEach((
|
|
54516
|
-
this.handleItemCopy(
|
|
54534
|
+
this.list().forEach((item) => {
|
|
54535
|
+
this.handleItemCopy(item, copiedItemsMap);
|
|
54517
54536
|
});
|
|
54518
|
-
this.list().flatMap((
|
|
54519
|
-
if (
|
|
54520
|
-
return
|
|
54537
|
+
this.list().flatMap((item) => {
|
|
54538
|
+
if (item instanceof Frame2) {
|
|
54539
|
+
return item.getChildrenIds();
|
|
54521
54540
|
}
|
|
54522
54541
|
return [];
|
|
54523
54542
|
}).forEach((id) => {
|
|
@@ -54545,11 +54564,11 @@ class BoardSelection {
|
|
|
54545
54564
|
let maxRichText = null;
|
|
54546
54565
|
let minRichText = null;
|
|
54547
54566
|
const itemType = items[0].itemType;
|
|
54548
|
-
for (const
|
|
54549
|
-
if (
|
|
54567
|
+
for (const item of items) {
|
|
54568
|
+
if (item.itemType !== itemType) {
|
|
54550
54569
|
return null;
|
|
54551
54570
|
}
|
|
54552
|
-
const richText =
|
|
54571
|
+
const richText = item.getRichText();
|
|
54553
54572
|
if (richText) {
|
|
54554
54573
|
if (!maxRichText || richText.getFontSize() > maxRichText.getFontSize()) {
|
|
54555
54574
|
maxRichText = richText;
|
|
@@ -54655,22 +54674,22 @@ class BoardSelection {
|
|
|
54655
54674
|
}
|
|
54656
54675
|
nestSelectedItems(unselectedItem, checkFrames = true) {
|
|
54657
54676
|
const selected = this.board.selection.items.list();
|
|
54658
|
-
if (unselectedItem && !selected.find((
|
|
54677
|
+
if (unselectedItem && !selected.find((item) => item.getId() === unselectedItem.getId())) {
|
|
54659
54678
|
selected.push(unselectedItem);
|
|
54660
54679
|
}
|
|
54661
|
-
const selectedMbr = selected.reduce((acc,
|
|
54680
|
+
const selectedMbr = selected.reduce((acc, item) => {
|
|
54662
54681
|
if (!acc) {
|
|
54663
|
-
return
|
|
54682
|
+
return item.getMbr();
|
|
54664
54683
|
}
|
|
54665
|
-
return acc.combine(
|
|
54684
|
+
return acc.combine(item.getMbr());
|
|
54666
54685
|
}, undefined);
|
|
54667
54686
|
if (selectedMbr) {
|
|
54668
|
-
const selectedMap = Object.fromEntries(selected.map((
|
|
54687
|
+
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
54669
54688
|
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
54670
54689
|
enclosedGroups.forEach((group) => {
|
|
54671
|
-
selected.forEach((
|
|
54672
|
-
if (group.handleNesting(
|
|
54673
|
-
selectedMap[
|
|
54690
|
+
selected.forEach((item) => {
|
|
54691
|
+
if (group.handleNesting(item)) {
|
|
54692
|
+
selectedMap[item.getId()].nested = group;
|
|
54674
54693
|
}
|
|
54675
54694
|
});
|
|
54676
54695
|
});
|
|
@@ -54694,11 +54713,11 @@ class BoardSelection {
|
|
|
54694
54713
|
if (childrenIds && checkFrames) {
|
|
54695
54714
|
const currGroup = val.item;
|
|
54696
54715
|
const currMbr = currGroup.getMbr();
|
|
54697
|
-
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((
|
|
54698
|
-
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((
|
|
54716
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
54717
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
54699
54718
|
const uniqueItems = new Set;
|
|
54700
|
-
const toCheck = [...children, ...underGroup].filter((
|
|
54701
|
-
const id =
|
|
54719
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
54720
|
+
const id = item.getId();
|
|
54702
54721
|
if (uniqueItems.has(id)) {
|
|
54703
54722
|
return false;
|
|
54704
54723
|
}
|
|
@@ -54739,8 +54758,8 @@ class BoardSelection {
|
|
|
54739
54758
|
addItemToTranslation(childId);
|
|
54740
54759
|
}
|
|
54741
54760
|
}
|
|
54742
|
-
const createTranslationWithComments = (
|
|
54743
|
-
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() ===
|
|
54761
|
+
const createTranslationWithComments = (item) => {
|
|
54762
|
+
const followedComments = this.board.items.getComments().filter((comment2) => comment2.getItemToFollow() === item.getId());
|
|
54744
54763
|
for (const comment2 of followedComments) {
|
|
54745
54764
|
translation[comment2.getId()] = {
|
|
54746
54765
|
class: "Transformation",
|
|
@@ -54801,21 +54820,21 @@ class BoardSelection {
|
|
|
54801
54820
|
newData: { borderColor }
|
|
54802
54821
|
};
|
|
54803
54822
|
const operations2 = {};
|
|
54804
|
-
this.items.list().forEach((
|
|
54805
|
-
if (!operations2[
|
|
54823
|
+
this.items.list().forEach((item) => {
|
|
54824
|
+
if (!operations2[item.itemType]) {
|
|
54806
54825
|
const operationCopy = { ...operation };
|
|
54807
|
-
if (
|
|
54826
|
+
if (item.itemType === "Connector") {
|
|
54808
54827
|
operationCopy.method = "setLineColor";
|
|
54809
54828
|
operationCopy.lineColor = borderColor;
|
|
54810
|
-
} else if (
|
|
54829
|
+
} else if (item.itemType === "Drawing") {
|
|
54811
54830
|
operationCopy.method = "setStrokeColor";
|
|
54812
54831
|
operationCopy.color = borderColor;
|
|
54813
54832
|
} else {
|
|
54814
54833
|
operationCopy.borderColor = borderColor;
|
|
54815
54834
|
}
|
|
54816
|
-
operations2[
|
|
54835
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
54817
54836
|
} else {
|
|
54818
|
-
operations2[
|
|
54837
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54819
54838
|
}
|
|
54820
54839
|
});
|
|
54821
54840
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54830,13 +54849,13 @@ class BoardSelection {
|
|
|
54830
54849
|
newData: { borderWidth: width2 }
|
|
54831
54850
|
};
|
|
54832
54851
|
const operations2 = {};
|
|
54833
|
-
this.items.list().forEach((
|
|
54834
|
-
if (!operations2[
|
|
54852
|
+
this.items.list().forEach((item) => {
|
|
54853
|
+
if (!operations2[item.itemType]) {
|
|
54835
54854
|
const operationCopy = { ...operation };
|
|
54836
|
-
if (
|
|
54855
|
+
if (item.itemType === "Connector") {
|
|
54837
54856
|
operationCopy.method = "setLineWidth";
|
|
54838
54857
|
operationCopy.lineWidth = width2;
|
|
54839
|
-
} else if (
|
|
54858
|
+
} else if (item.itemType === "Drawing") {
|
|
54840
54859
|
operationCopy.method = "setStrokeWidth";
|
|
54841
54860
|
operationCopy.width = width2;
|
|
54842
54861
|
operationCopy.prevWidth = this.getStrokeWidth();
|
|
@@ -54844,9 +54863,9 @@ class BoardSelection {
|
|
|
54844
54863
|
operationCopy.borderWidth = width2;
|
|
54845
54864
|
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
54846
54865
|
}
|
|
54847
|
-
operations2[
|
|
54866
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
54848
54867
|
} else {
|
|
54849
|
-
operations2[
|
|
54868
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54850
54869
|
}
|
|
54851
54870
|
});
|
|
54852
54871
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54862,11 +54881,11 @@ class BoardSelection {
|
|
|
54862
54881
|
newData: { backgroundColor }
|
|
54863
54882
|
};
|
|
54864
54883
|
const operations2 = {};
|
|
54865
|
-
this.items.list().forEach((
|
|
54866
|
-
if (!operations2[
|
|
54867
|
-
operations2[
|
|
54884
|
+
this.items.list().forEach((item) => {
|
|
54885
|
+
if (!operations2[item.itemType]) {
|
|
54886
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
54868
54887
|
} else {
|
|
54869
|
-
operations2[
|
|
54888
|
+
operations2[item.itemType].item.push(item.getId());
|
|
54870
54889
|
}
|
|
54871
54890
|
});
|
|
54872
54891
|
Object.values(operations2).forEach((op) => {
|
|
@@ -54890,9 +54909,9 @@ class BoardSelection {
|
|
|
54890
54909
|
}
|
|
54891
54910
|
setFrameType(frameType) {
|
|
54892
54911
|
const items = this.items.list();
|
|
54893
|
-
items.forEach((
|
|
54894
|
-
if (
|
|
54895
|
-
|
|
54912
|
+
items.forEach((item) => {
|
|
54913
|
+
if (item instanceof Frame2) {
|
|
54914
|
+
item.setFrameType(frameType);
|
|
54896
54915
|
}
|
|
54897
54916
|
});
|
|
54898
54917
|
}
|
|
@@ -54911,21 +54930,21 @@ class BoardSelection {
|
|
|
54911
54930
|
setFontSize(size) {
|
|
54912
54931
|
const fontSize = size === "auto" ? size : toFiniteNumber(size);
|
|
54913
54932
|
const itemsOps = [];
|
|
54914
|
-
for (const
|
|
54915
|
-
const text5 =
|
|
54933
|
+
for (const item of this.items.list()) {
|
|
54934
|
+
const text5 = item.getRichText();
|
|
54916
54935
|
if (!text5) {
|
|
54917
54936
|
continue;
|
|
54918
54937
|
}
|
|
54919
54938
|
const ops = text5.setSelectionFontSize(fontSize, this.context);
|
|
54920
54939
|
itemsOps.push({
|
|
54921
|
-
item:
|
|
54940
|
+
item: item.getId(),
|
|
54922
54941
|
selection: text5.editor.getSelection(),
|
|
54923
54942
|
ops
|
|
54924
54943
|
});
|
|
54925
|
-
if (
|
|
54926
|
-
tempStorage.remove(`fontSize_${
|
|
54927
|
-
} else if (
|
|
54928
|
-
tempStorage.setFontSize(
|
|
54944
|
+
if (item.itemType === "Sticker" && fontSize === "auto") {
|
|
54945
|
+
tempStorage.remove(`fontSize_${item.itemType}`);
|
|
54946
|
+
} else if (item.itemType !== "AINode") {
|
|
54947
|
+
tempStorage.setFontSize(item.itemType, fontSize);
|
|
54929
54948
|
}
|
|
54930
54949
|
}
|
|
54931
54950
|
const emptyOps = itemsOps.filter((op) => !op.ops.length);
|
|
@@ -54948,8 +54967,8 @@ class BoardSelection {
|
|
|
54948
54967
|
setFontStyle(fontStyle) {
|
|
54949
54968
|
const isMultiple = !this.items.isSingle();
|
|
54950
54969
|
const itemsOps = [];
|
|
54951
|
-
for (const
|
|
54952
|
-
const text5 =
|
|
54970
|
+
for (const item of this.items.list()) {
|
|
54971
|
+
const text5 = item.getRichText();
|
|
54953
54972
|
if (!text5) {
|
|
54954
54973
|
continue;
|
|
54955
54974
|
}
|
|
@@ -54958,12 +54977,12 @@ class BoardSelection {
|
|
|
54958
54977
|
}
|
|
54959
54978
|
const ops = text5.setSelectionFontStyle(fontStyle, this.context);
|
|
54960
54979
|
itemsOps.push({
|
|
54961
|
-
item:
|
|
54980
|
+
item: item.getId(),
|
|
54962
54981
|
selection: text5.editor.getSelection(),
|
|
54963
54982
|
ops
|
|
54964
54983
|
});
|
|
54965
|
-
if (
|
|
54966
|
-
tempStorage.setFontStyles(
|
|
54984
|
+
if (item.itemType !== "AINode") {
|
|
54985
|
+
tempStorage.setFontStyles(item.itemType, text5.getFontStyles());
|
|
54967
54986
|
}
|
|
54968
54987
|
}
|
|
54969
54988
|
this.emitApplied({
|
|
@@ -54975,8 +54994,8 @@ class BoardSelection {
|
|
|
54975
54994
|
setFontColor(fontColor) {
|
|
54976
54995
|
const isMultiple = !this.items.isSingle();
|
|
54977
54996
|
const itemsOps = [];
|
|
54978
|
-
for (const
|
|
54979
|
-
const text5 =
|
|
54997
|
+
for (const item of this.items.list()) {
|
|
54998
|
+
const text5 = item.getRichText();
|
|
54980
54999
|
if (!text5) {
|
|
54981
55000
|
continue;
|
|
54982
55001
|
}
|
|
@@ -54985,11 +55004,11 @@ class BoardSelection {
|
|
|
54985
55004
|
}
|
|
54986
55005
|
const ops = text5.setSelectionFontColor(fontColor, this.context);
|
|
54987
55006
|
itemsOps.push({
|
|
54988
|
-
item:
|
|
55007
|
+
item: item.getId(),
|
|
54989
55008
|
selection: text5.editor.getSelection(),
|
|
54990
55009
|
ops
|
|
54991
55010
|
});
|
|
54992
|
-
tempStorage.setFontColor(
|
|
55011
|
+
tempStorage.setFontColor(item.itemType, fontColor);
|
|
54993
55012
|
}
|
|
54994
55013
|
this.emitApplied({
|
|
54995
55014
|
class: "RichText",
|
|
@@ -55018,8 +55037,8 @@ class BoardSelection {
|
|
|
55018
55037
|
setFontHighlight(fontHighlight) {
|
|
55019
55038
|
const isMultiple = !this.items.isSingle();
|
|
55020
55039
|
const itemsOps = [];
|
|
55021
|
-
for (const
|
|
55022
|
-
const text5 =
|
|
55040
|
+
for (const item of this.items.list()) {
|
|
55041
|
+
const text5 = item.getRichText();
|
|
55023
55042
|
if (!text5) {
|
|
55024
55043
|
continue;
|
|
55025
55044
|
}
|
|
@@ -55028,12 +55047,12 @@ class BoardSelection {
|
|
|
55028
55047
|
}
|
|
55029
55048
|
const ops = text5.setSelectionFontHighlight(fontHighlight, this.context);
|
|
55030
55049
|
itemsOps.push({
|
|
55031
|
-
item:
|
|
55050
|
+
item: item.getId(),
|
|
55032
55051
|
selection: text5.editor.getSelection(),
|
|
55033
55052
|
ops
|
|
55034
55053
|
});
|
|
55035
|
-
if (
|
|
55036
|
-
tempStorage.setFontHighlight(
|
|
55054
|
+
if (item.itemType !== "AINode") {
|
|
55055
|
+
tempStorage.setFontHighlight(item.itemType, fontHighlight);
|
|
55037
55056
|
}
|
|
55038
55057
|
}
|
|
55039
55058
|
this.emitApplied({
|
|
@@ -55045,8 +55064,8 @@ class BoardSelection {
|
|
|
55045
55064
|
setHorisontalAlignment(horisontalAlignment) {
|
|
55046
55065
|
const isMultiple = !this.items.isSingle();
|
|
55047
55066
|
const itemsOps = [];
|
|
55048
|
-
for (const
|
|
55049
|
-
const text5 =
|
|
55067
|
+
for (const item of this.items.list()) {
|
|
55068
|
+
const text5 = item.getRichText();
|
|
55050
55069
|
if (!text5) {
|
|
55051
55070
|
continue;
|
|
55052
55071
|
}
|
|
@@ -55055,11 +55074,11 @@ class BoardSelection {
|
|
|
55055
55074
|
}
|
|
55056
55075
|
const ops = text5.setSelectionHorisontalAlignment(horisontalAlignment, this.context);
|
|
55057
55076
|
itemsOps.push({
|
|
55058
|
-
item:
|
|
55077
|
+
item: item.getId(),
|
|
55059
55078
|
selection: text5.editor.getSelection(),
|
|
55060
55079
|
ops
|
|
55061
55080
|
});
|
|
55062
|
-
tempStorage.setHorizontalAlignment(
|
|
55081
|
+
tempStorage.setHorizontalAlignment(item.itemType, horisontalAlignment);
|
|
55063
55082
|
}
|
|
55064
55083
|
this.emitApplied({
|
|
55065
55084
|
class: "RichText",
|
|
@@ -55075,23 +55094,23 @@ class BoardSelection {
|
|
|
55075
55094
|
verticalAlignment
|
|
55076
55095
|
});
|
|
55077
55096
|
if (this.items.isSingle()) {
|
|
55078
|
-
const
|
|
55079
|
-
if (!
|
|
55097
|
+
const item = this.items.getSingle();
|
|
55098
|
+
if (!item) {
|
|
55080
55099
|
return;
|
|
55081
55100
|
}
|
|
55082
|
-
const text5 =
|
|
55101
|
+
const text5 = item.getRichText();
|
|
55083
55102
|
if (!text5) {
|
|
55084
55103
|
return;
|
|
55085
55104
|
}
|
|
55086
|
-
tempStorage.setVerticalAlignment(
|
|
55087
|
-
if (
|
|
55088
|
-
|
|
55105
|
+
tempStorage.setVerticalAlignment(item.itemType, verticalAlignment);
|
|
55106
|
+
if (item instanceof RichText) {
|
|
55107
|
+
item.setEditorFocus(this.context);
|
|
55089
55108
|
}
|
|
55090
55109
|
text5.setEditorFocus(this.context);
|
|
55091
55110
|
}
|
|
55092
55111
|
}
|
|
55093
55112
|
removeFromBoard() {
|
|
55094
|
-
const isLocked = this.items.list().some((
|
|
55113
|
+
const isLocked = this.items.list().some((item) => item.transformation.isLocked);
|
|
55095
55114
|
if (isLocked) {
|
|
55096
55115
|
return;
|
|
55097
55116
|
}
|
|
@@ -55114,7 +55133,7 @@ class BoardSelection {
|
|
|
55114
55133
|
}
|
|
55115
55134
|
getIsLockedSelection() {
|
|
55116
55135
|
const items = this.list();
|
|
55117
|
-
return items.some((
|
|
55136
|
+
return items.some((item) => item.transformation.isLocked);
|
|
55118
55137
|
}
|
|
55119
55138
|
isLocked() {
|
|
55120
55139
|
return false;
|
|
@@ -55141,9 +55160,9 @@ class BoardSelection {
|
|
|
55141
55160
|
}
|
|
55142
55161
|
async duplicate() {
|
|
55143
55162
|
const mediaIds = [];
|
|
55144
|
-
this.items.list().forEach((
|
|
55145
|
-
if ("getStorageId" in
|
|
55146
|
-
const storageId =
|
|
55163
|
+
this.items.list().forEach((item) => {
|
|
55164
|
+
if ("getStorageId" in item) {
|
|
55165
|
+
const storageId = item.getStorageId();
|
|
55147
55166
|
if (storageId) {
|
|
55148
55167
|
mediaIds.push(storageId);
|
|
55149
55168
|
}
|
|
@@ -55153,7 +55172,7 @@ class BoardSelection {
|
|
|
55153
55172
|
if (!canDuplicate) {
|
|
55154
55173
|
return;
|
|
55155
55174
|
}
|
|
55156
|
-
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_,
|
|
55175
|
+
const filteredItemMap = Object.fromEntries(Object.entries(this.copy(true)).filter(([_, item]) => item.itemType !== "Group"));
|
|
55157
55176
|
this.board.duplicate(filteredItemMap);
|
|
55158
55177
|
this.setContext("EditUnderPointer");
|
|
55159
55178
|
}
|
|
@@ -55187,10 +55206,10 @@ class BoardSelection {
|
|
|
55187
55206
|
lastAssistantMessageId
|
|
55188
55207
|
};
|
|
55189
55208
|
}
|
|
55190
|
-
renderItemMbr(context,
|
|
55191
|
-
const mbr =
|
|
55209
|
+
renderItemMbr(context, item, customScale) {
|
|
55210
|
+
const mbr = item.getMbr();
|
|
55192
55211
|
mbr.strokeWidth = !customScale ? 1 / context.matrix.scaleX : 1 / customScale;
|
|
55193
|
-
const selectionColor =
|
|
55212
|
+
const selectionColor = item.transformation.isLocked ? conf.SELECTION_LOCKED_COLOR : conf.SELECTION_COLOR;
|
|
55194
55213
|
mbr.borderColor = selectionColor;
|
|
55195
55214
|
mbr.render(context);
|
|
55196
55215
|
}
|
|
@@ -55206,8 +55225,8 @@ class BoardSelection {
|
|
|
55206
55225
|
}
|
|
55207
55226
|
if (!this.transformationRenderBlock) {
|
|
55208
55227
|
if (this.shouldRenderItemsMbr) {
|
|
55209
|
-
for (const
|
|
55210
|
-
this.renderItemMbr(context,
|
|
55228
|
+
for (const item of this.items.list()) {
|
|
55229
|
+
this.renderItemMbr(context, item);
|
|
55211
55230
|
}
|
|
55212
55231
|
}
|
|
55213
55232
|
this.tool.render(context);
|
|
@@ -55219,7 +55238,7 @@ class BoardSelection {
|
|
|
55219
55238
|
if (single && single instanceof AINode) {
|
|
55220
55239
|
const contextItemsIds = single.getContextItems();
|
|
55221
55240
|
if (contextItemsIds.length) {
|
|
55222
|
-
const newContextItems = this.board.items.listAll().filter((
|
|
55241
|
+
const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
|
|
55223
55242
|
contextItems.push(...newContextItems);
|
|
55224
55243
|
}
|
|
55225
55244
|
}
|
|
@@ -55237,15 +55256,15 @@ class BoardSelection {
|
|
|
55237
55256
|
}
|
|
55238
55257
|
}
|
|
55239
55258
|
}
|
|
55240
|
-
contextItems.forEach((
|
|
55241
|
-
if (
|
|
55242
|
-
const path2 =
|
|
55259
|
+
contextItems.forEach((item) => {
|
|
55260
|
+
if (item instanceof AINode) {
|
|
55261
|
+
const path2 = item.getPath();
|
|
55243
55262
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
55244
55263
|
path2.setBorderWidth(2);
|
|
55245
55264
|
path2.setBackgroundColor("none");
|
|
55246
55265
|
path2.render(context);
|
|
55247
55266
|
} else {
|
|
55248
|
-
const itemRect =
|
|
55267
|
+
const itemRect = item.getMbr();
|
|
55249
55268
|
itemRect.borderColor = CONTEXT_NODE_HIGHLIGHT_COLOR;
|
|
55250
55269
|
itemRect.strokeWidth = 2;
|
|
55251
55270
|
itemRect.render(context);
|
|
@@ -55746,16 +55765,16 @@ class Board {
|
|
|
55746
55765
|
applyBoardOperation(op) {
|
|
55747
55766
|
switch (op.method) {
|
|
55748
55767
|
case "moveToZIndex": {
|
|
55749
|
-
const
|
|
55750
|
-
if (!
|
|
55768
|
+
const item = this.index.getById(op.item);
|
|
55769
|
+
if (!item) {
|
|
55751
55770
|
return;
|
|
55752
55771
|
}
|
|
55753
|
-
return this.index.moveToZIndex(
|
|
55772
|
+
return this.index.moveToZIndex(item, op.zIndex);
|
|
55754
55773
|
}
|
|
55755
55774
|
case "moveManyToZIndex": {
|
|
55756
55775
|
for (const id in op.item) {
|
|
55757
|
-
const
|
|
55758
|
-
if (!
|
|
55776
|
+
const item = this.items.getById(id);
|
|
55777
|
+
if (!item) {
|
|
55759
55778
|
delete op.item.id;
|
|
55760
55779
|
}
|
|
55761
55780
|
}
|
|
@@ -55777,11 +55796,11 @@ class Board {
|
|
|
55777
55796
|
}
|
|
55778
55797
|
return this.index.moveSecondAfterFirst(first, second);
|
|
55779
55798
|
case "bringToFront": {
|
|
55780
|
-
const items = op.item.map((
|
|
55799
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
55781
55800
|
return this.index.bringManyToFront(items);
|
|
55782
55801
|
}
|
|
55783
55802
|
case "sendToBack": {
|
|
55784
|
-
const items = op.item.map((
|
|
55803
|
+
const items = op.item.map((item) => this.items.getById(item)).filter((item) => item !== undefined);
|
|
55785
55804
|
return this.index.sendManyToBack(items);
|
|
55786
55805
|
}
|
|
55787
55806
|
case "add":
|
|
@@ -55805,82 +55824,82 @@ class Board {
|
|
|
55805
55824
|
applyAddItems(op) {
|
|
55806
55825
|
if (Array.isArray(op.item)) {
|
|
55807
55826
|
const data = op.data;
|
|
55808
|
-
const items = op.item.map((
|
|
55809
|
-
const created = this.createItem(
|
|
55827
|
+
const items = op.item.map((item2) => {
|
|
55828
|
+
const created = this.createItem(item2, data[item2]);
|
|
55810
55829
|
this.index.insert(created);
|
|
55811
55830
|
return created;
|
|
55812
55831
|
});
|
|
55813
|
-
items.forEach((
|
|
55814
|
-
if (
|
|
55815
|
-
const connectorData = data[
|
|
55816
|
-
|
|
55817
|
-
|
|
55832
|
+
items.forEach((item2) => {
|
|
55833
|
+
if (item2 instanceof Connector2 && data[item2.getId()]) {
|
|
55834
|
+
const connectorData = data[item2.getId()];
|
|
55835
|
+
item2.applyStartPoint(connectorData.startPoint);
|
|
55836
|
+
item2.applyEndPoint(connectorData.endPoint);
|
|
55818
55837
|
}
|
|
55819
55838
|
});
|
|
55820
55839
|
return;
|
|
55821
55840
|
}
|
|
55822
|
-
const
|
|
55823
|
-
return this.index.insert(
|
|
55841
|
+
const item = this.createItem(op.item, op.data);
|
|
55842
|
+
return this.index.insert(item);
|
|
55824
55843
|
}
|
|
55825
55844
|
applyAddLockedGroupOperation(op) {
|
|
55826
|
-
const
|
|
55827
|
-
const groupChildrenIds =
|
|
55828
|
-
this.index.insert(
|
|
55845
|
+
const item = this.createItem(op.item, op.data);
|
|
55846
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
55847
|
+
this.index.insert(item);
|
|
55829
55848
|
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
55830
55849
|
if (lastChildrenId) {
|
|
55831
55850
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
55832
|
-
this.index.moveToZIndex(
|
|
55851
|
+
this.index.moveToZIndex(item, zIndex);
|
|
55833
55852
|
}
|
|
55834
|
-
|
|
55835
|
-
|
|
55853
|
+
item.getChildren().forEach((item2) => {
|
|
55854
|
+
item2.transformation.isLocked = true;
|
|
55836
55855
|
});
|
|
55837
|
-
|
|
55856
|
+
item.transformation.isLocked = true;
|
|
55838
55857
|
}
|
|
55839
55858
|
applyRemoveOperation(op) {
|
|
55840
55859
|
const removedItems = [];
|
|
55841
|
-
this.findItemAndApply(op.item, (
|
|
55842
|
-
this.index.remove(
|
|
55843
|
-
this.selection.remove(
|
|
55844
|
-
if (
|
|
55845
|
-
|
|
55860
|
+
this.findItemAndApply(op.item, (item) => {
|
|
55861
|
+
this.index.remove(item);
|
|
55862
|
+
this.selection.remove(item);
|
|
55863
|
+
if (item instanceof Connector2) {
|
|
55864
|
+
item.clearObservedItems();
|
|
55846
55865
|
}
|
|
55847
|
-
removedItems.push(
|
|
55866
|
+
removedItems.push(item);
|
|
55848
55867
|
});
|
|
55849
55868
|
}
|
|
55850
55869
|
applyRemoveLockedGroupOperation(op) {
|
|
55851
|
-
const
|
|
55852
|
-
if (!
|
|
55870
|
+
const item = this.index.getById(op.item[0]);
|
|
55871
|
+
if (!item || !(item instanceof Group)) {
|
|
55853
55872
|
return;
|
|
55854
55873
|
}
|
|
55855
|
-
|
|
55856
|
-
|
|
55857
|
-
|
|
55874
|
+
item.getChildren().forEach((item2) => {
|
|
55875
|
+
item2.transformation.isLocked = false;
|
|
55876
|
+
item2.parent = "Board";
|
|
55858
55877
|
});
|
|
55859
|
-
|
|
55878
|
+
item.transformation.isLocked = false;
|
|
55860
55879
|
const removedItems = [];
|
|
55861
|
-
this.findItemAndApply(op.item, (
|
|
55862
|
-
this.index.remove(
|
|
55863
|
-
this.selection.remove(
|
|
55864
|
-
removedItems.push(
|
|
55880
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
55881
|
+
this.index.remove(item2);
|
|
55882
|
+
this.selection.remove(item2);
|
|
55883
|
+
removedItems.push(item2);
|
|
55865
55884
|
});
|
|
55866
55885
|
}
|
|
55867
55886
|
applyItemOperation(op) {
|
|
55868
55887
|
if ("item" in op) {
|
|
55869
|
-
this.findItemAndApply(op.item, (
|
|
55870
|
-
|
|
55888
|
+
this.findItemAndApply(op.item, (item) => {
|
|
55889
|
+
item.apply(op);
|
|
55871
55890
|
});
|
|
55872
55891
|
}
|
|
55873
55892
|
}
|
|
55874
|
-
findItemAndApply(
|
|
55875
|
-
if (Array.isArray(
|
|
55876
|
-
for (const itemId of
|
|
55893
|
+
findItemAndApply(item, apply) {
|
|
55894
|
+
if (Array.isArray(item)) {
|
|
55895
|
+
for (const itemId of item) {
|
|
55877
55896
|
const found = this.items.findById(itemId);
|
|
55878
55897
|
if (found) {
|
|
55879
55898
|
apply(found);
|
|
55880
55899
|
}
|
|
55881
55900
|
}
|
|
55882
55901
|
} else {
|
|
55883
|
-
const found = this.items.findById(
|
|
55902
|
+
const found = this.items.findById(item);
|
|
55884
55903
|
if (found) {
|
|
55885
55904
|
apply(found);
|
|
55886
55905
|
}
|
|
@@ -55889,9 +55908,9 @@ class Board {
|
|
|
55889
55908
|
handleNesting(items) {
|
|
55890
55909
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
55891
55910
|
const groupsMap = new Map;
|
|
55892
|
-
arrayed.forEach((
|
|
55893
|
-
const itemCenter =
|
|
55894
|
-
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(
|
|
55911
|
+
arrayed.forEach((item) => {
|
|
55912
|
+
const itemCenter = item.getMbr().getCenter();
|
|
55913
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
55895
55914
|
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
55896
55915
|
acc = groupItem2;
|
|
55897
55916
|
}
|
|
@@ -55901,7 +55920,7 @@ class Board {
|
|
|
55901
55920
|
if (!groupsMap.has(groupItem)) {
|
|
55902
55921
|
groupsMap.set(groupItem, []);
|
|
55903
55922
|
}
|
|
55904
|
-
groupsMap.get(groupItem)?.push(
|
|
55923
|
+
groupsMap.get(groupItem)?.push(item);
|
|
55905
55924
|
}
|
|
55906
55925
|
});
|
|
55907
55926
|
groupsMap.forEach((items2, group) => {
|
|
@@ -55922,13 +55941,13 @@ class Board {
|
|
|
55922
55941
|
}
|
|
55923
55942
|
return parser(el);
|
|
55924
55943
|
}
|
|
55925
|
-
add(
|
|
55944
|
+
add(item, timeStamp) {
|
|
55926
55945
|
const id = this.getNewItemId();
|
|
55927
55946
|
this.emit({
|
|
55928
55947
|
class: "Board",
|
|
55929
55948
|
method: "add",
|
|
55930
55949
|
item: id,
|
|
55931
|
-
data:
|
|
55950
|
+
data: item.serialize(),
|
|
55932
55951
|
timeStamp
|
|
55933
55952
|
});
|
|
55934
55953
|
const newItem = this.items.getById(id);
|
|
@@ -55938,13 +55957,13 @@ class Board {
|
|
|
55938
55957
|
this.handleNesting(newItem);
|
|
55939
55958
|
return newItem;
|
|
55940
55959
|
}
|
|
55941
|
-
addLockedGroup(
|
|
55960
|
+
addLockedGroup(item) {
|
|
55942
55961
|
const id = this.getNewItemId();
|
|
55943
55962
|
this.emit({
|
|
55944
55963
|
class: "Board",
|
|
55945
55964
|
method: "addLockedGroup",
|
|
55946
55965
|
item: id,
|
|
55947
|
-
data:
|
|
55966
|
+
data: item.serialize()
|
|
55948
55967
|
});
|
|
55949
55968
|
const newItem = this.items.getById(id);
|
|
55950
55969
|
if (!newItem) {
|
|
@@ -55953,32 +55972,32 @@ class Board {
|
|
|
55953
55972
|
this.handleNesting(newItem);
|
|
55954
55973
|
return newItem;
|
|
55955
55974
|
}
|
|
55956
|
-
remove(
|
|
55975
|
+
remove(item, withConnectors = true) {
|
|
55957
55976
|
let connectors = [];
|
|
55958
55977
|
if (withConnectors) {
|
|
55959
|
-
connectors = this.items.getLinkedConnectorsById(
|
|
55978
|
+
connectors = this.items.getLinkedConnectorsById(item.getId()).map((connector) => connector.getId());
|
|
55960
55979
|
}
|
|
55961
|
-
if ("onRemove" in
|
|
55962
|
-
|
|
55980
|
+
if ("onRemove" in item) {
|
|
55981
|
+
item.onRemove();
|
|
55963
55982
|
}
|
|
55964
55983
|
this.emit({
|
|
55965
55984
|
class: "Board",
|
|
55966
55985
|
method: "remove",
|
|
55967
|
-
item: [
|
|
55986
|
+
item: [item.getId(), ...connectors]
|
|
55968
55987
|
});
|
|
55969
55988
|
}
|
|
55970
|
-
removeLockedGroup(
|
|
55989
|
+
removeLockedGroup(item) {
|
|
55971
55990
|
this.emit({
|
|
55972
55991
|
class: "Board",
|
|
55973
55992
|
method: "removeLockedGroup",
|
|
55974
|
-
item: [
|
|
55993
|
+
item: [item.getId()]
|
|
55975
55994
|
});
|
|
55976
55995
|
}
|
|
55977
55996
|
getByZIndex(index2) {
|
|
55978
55997
|
return this.index.getByZIndex(index2);
|
|
55979
55998
|
}
|
|
55980
|
-
getZIndex(
|
|
55981
|
-
return this.index.getZIndex(
|
|
55999
|
+
getZIndex(item) {
|
|
56000
|
+
return this.index.getZIndex(item);
|
|
55982
56001
|
}
|
|
55983
56002
|
getLastZIndex() {
|
|
55984
56003
|
return this.index.getLastZIndex();
|
|
@@ -55990,11 +56009,11 @@ class Board {
|
|
|
55990
56009
|
item: items
|
|
55991
56010
|
});
|
|
55992
56011
|
}
|
|
55993
|
-
moveToZIndex(
|
|
56012
|
+
moveToZIndex(item, zIndex) {
|
|
55994
56013
|
this.emit({
|
|
55995
56014
|
class: "Board",
|
|
55996
56015
|
method: "moveToZIndex",
|
|
55997
|
-
item:
|
|
56016
|
+
item: item.getId(),
|
|
55998
56017
|
zIndex
|
|
55999
56018
|
});
|
|
56000
56019
|
}
|
|
@@ -56022,8 +56041,8 @@ class Board {
|
|
|
56022
56041
|
this.emit({
|
|
56023
56042
|
class: "Board",
|
|
56024
56043
|
method: "bringToFront",
|
|
56025
|
-
item: items.map((
|
|
56026
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
56044
|
+
item: items.map((item) => item.getId()),
|
|
56045
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
56027
56046
|
});
|
|
56028
56047
|
}
|
|
56029
56048
|
sendToBack(items) {
|
|
@@ -56034,8 +56053,8 @@ class Board {
|
|
|
56034
56053
|
this.emit({
|
|
56035
56054
|
class: "Board",
|
|
56036
56055
|
method: "sendToBack",
|
|
56037
|
-
item: items.map((
|
|
56038
|
-
prevZIndex: Object.fromEntries(boardItems.map((
|
|
56056
|
+
item: items.map((item) => item.getId()),
|
|
56057
|
+
prevZIndex: Object.fromEntries(boardItems.map((item) => [item.getId(), boardItems.indexOf(item)]))
|
|
56039
56058
|
});
|
|
56040
56059
|
}
|
|
56041
56060
|
copy() {
|
|
@@ -56112,7 +56131,7 @@ class Board {
|
|
|
56112
56131
|
return added;
|
|
56113
56132
|
});
|
|
56114
56133
|
addedFrame.addChildItems(addedChildren);
|
|
56115
|
-
parsedData.data.children = addedChildren.map((
|
|
56134
|
+
parsedData.data.children = addedChildren.map((item) => item.getId());
|
|
56116
56135
|
idsMap[parsedData.data.id] = addedFrame.getId();
|
|
56117
56136
|
} else {
|
|
56118
56137
|
const added = this.add(this.createItem(this.getNewItemId(), parsedData));
|
|
@@ -56153,15 +56172,15 @@ class Board {
|
|
|
56153
56172
|
const createdConnectors = {};
|
|
56154
56173
|
const createdFrames = {};
|
|
56155
56174
|
const addItem = (itemData) => {
|
|
56156
|
-
const
|
|
56157
|
-
if (
|
|
56158
|
-
createdConnectors[itemData.id] = { item
|
|
56175
|
+
const item = this.createItem(itemData.id, itemData);
|
|
56176
|
+
if (item instanceof Connector2) {
|
|
56177
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
56159
56178
|
}
|
|
56160
|
-
if (
|
|
56161
|
-
createdFrames[
|
|
56179
|
+
if (item instanceof Frame2) {
|
|
56180
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
56162
56181
|
}
|
|
56163
|
-
this.index.insert(
|
|
56164
|
-
return
|
|
56182
|
+
this.index.insert(item);
|
|
56183
|
+
return item;
|
|
56165
56184
|
};
|
|
56166
56185
|
for (const itemData of items) {
|
|
56167
56186
|
if ("childrenMap" in itemData) {
|
|
@@ -56172,13 +56191,13 @@ class Board {
|
|
|
56172
56191
|
}
|
|
56173
56192
|
}
|
|
56174
56193
|
for (const key in createdConnectors) {
|
|
56175
|
-
const { item
|
|
56176
|
-
|
|
56177
|
-
|
|
56194
|
+
const { item, itemData } = createdConnectors[key];
|
|
56195
|
+
item.applyStartPoint(itemData.startPoint);
|
|
56196
|
+
item.applyEndPoint(itemData.endPoint);
|
|
56178
56197
|
}
|
|
56179
56198
|
for (const key in createdFrames) {
|
|
56180
|
-
const { item
|
|
56181
|
-
|
|
56199
|
+
const { item, itemData } = createdFrames[key];
|
|
56200
|
+
item.applyAddChildren(itemData.children);
|
|
56182
56201
|
}
|
|
56183
56202
|
}
|
|
56184
56203
|
deserialize(snapshot) {
|
|
@@ -56188,33 +56207,33 @@ class Board {
|
|
|
56188
56207
|
const createdFrames = {};
|
|
56189
56208
|
if (Array.isArray(items)) {
|
|
56190
56209
|
for (const itemData of items) {
|
|
56191
|
-
const
|
|
56192
|
-
if (
|
|
56193
|
-
createdConnectors[itemData.id] = { item
|
|
56210
|
+
const item = this.createItem(itemData.id, itemData);
|
|
56211
|
+
if (item instanceof Connector2) {
|
|
56212
|
+
createdConnectors[itemData.id] = { item, itemData };
|
|
56194
56213
|
}
|
|
56195
|
-
if (
|
|
56196
|
-
createdFrames[
|
|
56214
|
+
if (item instanceof Frame2) {
|
|
56215
|
+
createdFrames[item.getId()] = { item, itemData };
|
|
56197
56216
|
}
|
|
56198
|
-
this.index.insert(
|
|
56217
|
+
this.index.insert(item);
|
|
56199
56218
|
}
|
|
56200
56219
|
} else {
|
|
56201
56220
|
for (const key in items) {
|
|
56202
56221
|
const itemData = items[key];
|
|
56203
|
-
const
|
|
56204
|
-
if (
|
|
56205
|
-
createdConnectors[key] = { item
|
|
56222
|
+
const item = this.createItem(key, itemData);
|
|
56223
|
+
if (item instanceof Connector2) {
|
|
56224
|
+
createdConnectors[key] = { item, itemData };
|
|
56206
56225
|
}
|
|
56207
|
-
this.index.insert(
|
|
56226
|
+
this.index.insert(item);
|
|
56208
56227
|
}
|
|
56209
56228
|
}
|
|
56210
56229
|
for (const key in createdConnectors) {
|
|
56211
|
-
const { item
|
|
56212
|
-
|
|
56213
|
-
|
|
56230
|
+
const { item, itemData } = createdConnectors[key];
|
|
56231
|
+
item.applyStartPoint(itemData.startPoint);
|
|
56232
|
+
item.applyEndPoint(itemData.endPoint);
|
|
56214
56233
|
}
|
|
56215
56234
|
for (const key in createdFrames) {
|
|
56216
|
-
const { item
|
|
56217
|
-
|
|
56235
|
+
const { item, itemData } = createdFrames[key];
|
|
56236
|
+
item.applyAddChildren(itemData.children);
|
|
56218
56237
|
}
|
|
56219
56238
|
this.events?.log.deserialize(events);
|
|
56220
56239
|
}
|
|
@@ -56452,7 +56471,7 @@ class Board {
|
|
|
56452
56471
|
itemsMap: newMap,
|
|
56453
56472
|
select: select2
|
|
56454
56473
|
});
|
|
56455
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
56474
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
56456
56475
|
this.handleNesting(items);
|
|
56457
56476
|
this.selection.removeAll();
|
|
56458
56477
|
this.selection.add(items);
|
|
@@ -56460,8 +56479,8 @@ class Board {
|
|
|
56460
56479
|
return;
|
|
56461
56480
|
}
|
|
56462
56481
|
removeVoidComments() {
|
|
56463
|
-
const voidComments = this.items.listAll().filter((
|
|
56464
|
-
return
|
|
56482
|
+
const voidComments = this.items.listAll().filter((item) => {
|
|
56483
|
+
return item instanceof Comment && !item.getThread().length;
|
|
56465
56484
|
});
|
|
56466
56485
|
if (voidComments) {
|
|
56467
56486
|
for (const comment2 of voidComments) {
|
|
@@ -56535,7 +56554,7 @@ class Board {
|
|
|
56535
56554
|
}
|
|
56536
56555
|
const mbr = this.selection.getMbr();
|
|
56537
56556
|
const selectedItems = this.selection.items.list();
|
|
56538
|
-
const isSelectedItemsMinWidth = selectedItems.some((
|
|
56557
|
+
const isSelectedItemsMinWidth = selectedItems.some((item) => item.getMbr().getWidth() === 0);
|
|
56539
56558
|
const right = mbr ? mbr.right : 0;
|
|
56540
56559
|
const top = mbr ? mbr.top : 0;
|
|
56541
56560
|
const width2 = mbr ? mbr.getWidth() / 10 : 10;
|
|
@@ -56577,7 +56596,7 @@ class Board {
|
|
|
56577
56596
|
method: "duplicate",
|
|
56578
56597
|
itemsMap: newMap
|
|
56579
56598
|
});
|
|
56580
|
-
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((
|
|
56599
|
+
const items = Object.keys(newMap).map((id) => this.items.getById(id)).filter((item) => typeof item !== "undefined");
|
|
56581
56600
|
this.handleNesting(items);
|
|
56582
56601
|
this.selection.removeAll();
|
|
56583
56602
|
this.selection.add(items);
|
|
@@ -56598,9 +56617,9 @@ class Board {
|
|
|
56598
56617
|
if (data.itemType === "Frame") {
|
|
56599
56618
|
data.text.placeholderText = `Frame ${this.getMaxFrameSerial() + 1}`;
|
|
56600
56619
|
}
|
|
56601
|
-
const
|
|
56602
|
-
this.index.insert(
|
|
56603
|
-
items.push(
|
|
56620
|
+
const item = this.createItem(itemId, data);
|
|
56621
|
+
this.index.insert(item);
|
|
56622
|
+
items.push(item);
|
|
56604
56623
|
};
|
|
56605
56624
|
sortedItemsMap.map(([id, data]) => {
|
|
56606
56625
|
if (data.itemType === "Connector") {
|
|
@@ -56615,8 +56634,8 @@ class Board {
|
|
|
56615
56634
|
return;
|
|
56616
56635
|
});
|
|
56617
56636
|
}
|
|
56618
|
-
isOnBoard(
|
|
56619
|
-
return this.items.findById(
|
|
56637
|
+
isOnBoard(item) {
|
|
56638
|
+
return this.items.findById(item.getId()) !== undefined;
|
|
56620
56639
|
}
|
|
56621
56640
|
getMaxFrameSerial() {
|
|
56622
56641
|
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
@@ -56662,7 +56681,7 @@ function areItemsTheSame(opA, opB) {
|
|
|
56662
56681
|
const itemsB = Object.keys(opB.items);
|
|
56663
56682
|
const setA = new Set(itemsA);
|
|
56664
56683
|
const setB = new Set(itemsB);
|
|
56665
|
-
const areArraysEqual = setA.size === setB.size && [...setA].every((
|
|
56684
|
+
const areArraysEqual = setA.size === setB.size && [...setA].every((item) => setB.has(item));
|
|
56666
56685
|
return areArraysEqual;
|
|
56667
56686
|
}
|
|
56668
56687
|
if (!(Array.isArray(opA.item) && Array.isArray(opB.item))) {
|
|
@@ -58321,9 +58340,9 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
58321
58340
|
list6.applyUnconfirmed(filter);
|
|
58322
58341
|
const hasAnyOverlap = (arr1, arr2) => {
|
|
58323
58342
|
const lookup9 = new Set(arr1);
|
|
58324
|
-
return arr2.some((
|
|
58343
|
+
return arr2.some((item) => lookup9.has(item));
|
|
58325
58344
|
};
|
|
58326
|
-
const currSelection = board.selection.list().map((
|
|
58345
|
+
const currSelection = board.selection.list().map((item) => item.getId());
|
|
58327
58346
|
if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
58328
58347
|
board.selection.applyMemoizedCaretOrRange();
|
|
58329
58348
|
}
|
|
@@ -58645,27 +58664,27 @@ function handleAiChatMassage(message, board) {
|
|
|
58645
58664
|
}
|
|
58646
58665
|
}
|
|
58647
58666
|
function handleChatChunk(chunk, board) {
|
|
58648
|
-
const
|
|
58667
|
+
const item = board.items.getById(chunk.itemId);
|
|
58649
58668
|
switch (chunk.type) {
|
|
58650
58669
|
case "chunk":
|
|
58651
|
-
if (!
|
|
58670
|
+
if (!item || item.itemType !== "AINode") {
|
|
58652
58671
|
return;
|
|
58653
58672
|
}
|
|
58654
|
-
|
|
58673
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown(chunk.content || "");
|
|
58655
58674
|
break;
|
|
58656
58675
|
case "done":
|
|
58657
|
-
if (!
|
|
58676
|
+
if (!item || item.itemType !== "AINode") {
|
|
58658
58677
|
board.aiGeneratingOnItem = undefined;
|
|
58659
58678
|
return;
|
|
58660
58679
|
}
|
|
58661
|
-
|
|
58680
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
58662
58681
|
break;
|
|
58663
58682
|
case "end":
|
|
58664
|
-
if (!
|
|
58683
|
+
if (!item || item.itemType !== "AINode") {
|
|
58665
58684
|
board.aiGeneratingOnItem = undefined;
|
|
58666
58685
|
return;
|
|
58667
58686
|
}
|
|
58668
|
-
|
|
58687
|
+
item.getRichText()?.editor.markdownProcessor.processMarkdown("StopProcessingMarkdown");
|
|
58669
58688
|
break;
|
|
58670
58689
|
case "error":
|
|
58671
58690
|
default:
|
|
@@ -58682,7 +58701,7 @@ function handleChatChunk(chunk, board) {
|
|
|
58682
58701
|
if (board.aiGeneratingOnItem && generatingItem) {
|
|
58683
58702
|
board.selection.removeAll();
|
|
58684
58703
|
board.selection.add(generatingItem);
|
|
58685
|
-
const rt =
|
|
58704
|
+
const rt = item?.getRichText();
|
|
58686
58705
|
if (generatingItem.itemType === "AINode" && rt) {
|
|
58687
58706
|
const editor = rt.editor;
|
|
58688
58707
|
editor.markdownProcessor.setStopProcessingMarkDownCb(null);
|
|
@@ -58815,14 +58834,14 @@ function handleImageGenerate(response, board) {
|
|
|
58815
58834
|
console.error("Image generation error:", response.message);
|
|
58816
58835
|
if (response.isExternalApiError) {
|
|
58817
58836
|
if (board.aiGeneratingOnItem) {
|
|
58818
|
-
const
|
|
58819
|
-
if (
|
|
58837
|
+
const item = board.items.getById(board.aiGeneratingOnItem);
|
|
58838
|
+
if (item) {
|
|
58820
58839
|
board.selection.removeAll();
|
|
58821
|
-
board.selection.add(
|
|
58822
|
-
const editor =
|
|
58840
|
+
board.selection.add(item);
|
|
58841
|
+
const editor = item.getRichText()?.editor;
|
|
58823
58842
|
editor?.clearText();
|
|
58824
58843
|
editor?.insertCopiedText(conf.i18n.t("AIInput.nodeErrorText"));
|
|
58825
|
-
board.camera.zoomToFit(
|
|
58844
|
+
board.camera.zoomToFit(item.getMbr(), 20);
|
|
58826
58845
|
}
|
|
58827
58846
|
}
|
|
58828
58847
|
} else {
|