microboard-temp 0.4.99 → 0.4.101
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 +29 -22
- package/dist/cjs/index.js +29 -22
- package/dist/cjs/node.js +29 -22
- package/dist/esm/browser.js +29 -22
- package/dist/esm/index.js +29 -22
- package/dist/esm/node.js +29 -22
- package/dist/types/Events/Command.d.ts +4 -4
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -19468,11 +19468,13 @@ class AudioCommand {
|
|
|
19468
19468
|
|
|
19469
19469
|
// src/Events/Command.ts
|
|
19470
19470
|
class BaseCommand {
|
|
19471
|
-
|
|
19471
|
+
board;
|
|
19472
|
+
itemIds;
|
|
19472
19473
|
operation;
|
|
19473
19474
|
reverse;
|
|
19474
|
-
constructor(
|
|
19475
|
-
this.
|
|
19475
|
+
constructor(board, itemIds, operation) {
|
|
19476
|
+
this.board = board;
|
|
19477
|
+
this.itemIds = itemIds;
|
|
19476
19478
|
this.operation = operation;
|
|
19477
19479
|
this.reverse = this.getReverse();
|
|
19478
19480
|
}
|
|
@@ -19481,49 +19483,57 @@ class BaseCommand {
|
|
|
19481
19483
|
return this;
|
|
19482
19484
|
}
|
|
19483
19485
|
apply() {
|
|
19484
|
-
for (const
|
|
19486
|
+
for (const itemId of this.itemIds) {
|
|
19487
|
+
const item = this.board.items.getById(itemId);
|
|
19488
|
+
if (!item) {
|
|
19489
|
+
continue;
|
|
19490
|
+
}
|
|
19485
19491
|
item.apply(this.operation);
|
|
19486
19492
|
}
|
|
19487
19493
|
}
|
|
19488
19494
|
revert() {
|
|
19489
|
-
for (const {
|
|
19495
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19496
|
+
const item = this.board.items.getById(itemId);
|
|
19497
|
+
if (!item) {
|
|
19498
|
+
continue;
|
|
19499
|
+
}
|
|
19490
19500
|
item.apply(operation);
|
|
19491
19501
|
}
|
|
19492
19502
|
}
|
|
19493
19503
|
getReverse() {
|
|
19494
|
-
const items = this.items;
|
|
19495
19504
|
switch (this.operation.method) {
|
|
19496
19505
|
case "addChildren":
|
|
19497
|
-
return
|
|
19498
|
-
return {
|
|
19506
|
+
return this.itemIds.map((itemId) => {
|
|
19507
|
+
return { itemId, operation: {
|
|
19499
19508
|
...this.operation,
|
|
19500
|
-
|
|
19501
|
-
};
|
|
19509
|
+
method: "removeChildren"
|
|
19510
|
+
} };
|
|
19502
19511
|
});
|
|
19503
19512
|
case "removeChildren":
|
|
19504
|
-
return
|
|
19505
|
-
return {
|
|
19513
|
+
return this.itemIds.map((itemId) => {
|
|
19514
|
+
return { itemId, operation: {
|
|
19506
19515
|
...this.operation,
|
|
19507
|
-
|
|
19508
|
-
};
|
|
19516
|
+
method: "addChildren"
|
|
19517
|
+
} };
|
|
19509
19518
|
});
|
|
19510
19519
|
default:
|
|
19511
|
-
return
|
|
19520
|
+
return this.itemIds.map((itemId) => {
|
|
19512
19521
|
const op = this.operation;
|
|
19513
19522
|
let newData = {};
|
|
19514
19523
|
if (op.prevData) {
|
|
19515
19524
|
newData = { ...op.prevData };
|
|
19516
19525
|
} else {
|
|
19526
|
+
const item = this.board.items.getById(itemId);
|
|
19517
19527
|
Object.keys(op.newData).forEach((key) => {
|
|
19518
19528
|
if (item[key]) {
|
|
19519
19529
|
newData[key] = item[key];
|
|
19520
19530
|
}
|
|
19521
19531
|
});
|
|
19522
19532
|
}
|
|
19523
|
-
return {
|
|
19533
|
+
return { itemId, operation: {
|
|
19524
19534
|
...op,
|
|
19525
19535
|
newData
|
|
19526
|
-
};
|
|
19536
|
+
} };
|
|
19527
19537
|
});
|
|
19528
19538
|
}
|
|
19529
19539
|
}
|
|
@@ -40549,9 +40559,6 @@ class Frame2 extends BaseItem {
|
|
|
40549
40559
|
case "RichText":
|
|
40550
40560
|
this.text.apply(op);
|
|
40551
40561
|
break;
|
|
40552
|
-
case "LinkTo":
|
|
40553
|
-
this.linkTo.apply(op);
|
|
40554
|
-
break;
|
|
40555
40562
|
default:
|
|
40556
40563
|
return;
|
|
40557
40564
|
}
|
|
@@ -47495,8 +47502,8 @@ function createItemValidator(defaultData2) {
|
|
|
47495
47502
|
};
|
|
47496
47503
|
}
|
|
47497
47504
|
function createItemCommandFactory(itemType) {
|
|
47498
|
-
return function itemCommandFactory(items, operation) {
|
|
47499
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47505
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47506
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47500
47507
|
};
|
|
47501
47508
|
}
|
|
47502
47509
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/cjs/index.js
CHANGED
|
@@ -19468,11 +19468,13 @@ class AudioCommand {
|
|
|
19468
19468
|
|
|
19469
19469
|
// src/Events/Command.ts
|
|
19470
19470
|
class BaseCommand {
|
|
19471
|
-
|
|
19471
|
+
board;
|
|
19472
|
+
itemIds;
|
|
19472
19473
|
operation;
|
|
19473
19474
|
reverse;
|
|
19474
|
-
constructor(
|
|
19475
|
-
this.
|
|
19475
|
+
constructor(board, itemIds, operation) {
|
|
19476
|
+
this.board = board;
|
|
19477
|
+
this.itemIds = itemIds;
|
|
19476
19478
|
this.operation = operation;
|
|
19477
19479
|
this.reverse = this.getReverse();
|
|
19478
19480
|
}
|
|
@@ -19481,49 +19483,57 @@ class BaseCommand {
|
|
|
19481
19483
|
return this;
|
|
19482
19484
|
}
|
|
19483
19485
|
apply() {
|
|
19484
|
-
for (const
|
|
19486
|
+
for (const itemId of this.itemIds) {
|
|
19487
|
+
const item = this.board.items.getById(itemId);
|
|
19488
|
+
if (!item) {
|
|
19489
|
+
continue;
|
|
19490
|
+
}
|
|
19485
19491
|
item.apply(this.operation);
|
|
19486
19492
|
}
|
|
19487
19493
|
}
|
|
19488
19494
|
revert() {
|
|
19489
|
-
for (const {
|
|
19495
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19496
|
+
const item = this.board.items.getById(itemId);
|
|
19497
|
+
if (!item) {
|
|
19498
|
+
continue;
|
|
19499
|
+
}
|
|
19490
19500
|
item.apply(operation);
|
|
19491
19501
|
}
|
|
19492
19502
|
}
|
|
19493
19503
|
getReverse() {
|
|
19494
|
-
const items = this.items;
|
|
19495
19504
|
switch (this.operation.method) {
|
|
19496
19505
|
case "addChildren":
|
|
19497
|
-
return
|
|
19498
|
-
return {
|
|
19506
|
+
return this.itemIds.map((itemId) => {
|
|
19507
|
+
return { itemId, operation: {
|
|
19499
19508
|
...this.operation,
|
|
19500
|
-
|
|
19501
|
-
};
|
|
19509
|
+
method: "removeChildren"
|
|
19510
|
+
} };
|
|
19502
19511
|
});
|
|
19503
19512
|
case "removeChildren":
|
|
19504
|
-
return
|
|
19505
|
-
return {
|
|
19513
|
+
return this.itemIds.map((itemId) => {
|
|
19514
|
+
return { itemId, operation: {
|
|
19506
19515
|
...this.operation,
|
|
19507
|
-
|
|
19508
|
-
};
|
|
19516
|
+
method: "addChildren"
|
|
19517
|
+
} };
|
|
19509
19518
|
});
|
|
19510
19519
|
default:
|
|
19511
|
-
return
|
|
19520
|
+
return this.itemIds.map((itemId) => {
|
|
19512
19521
|
const op = this.operation;
|
|
19513
19522
|
let newData = {};
|
|
19514
19523
|
if (op.prevData) {
|
|
19515
19524
|
newData = { ...op.prevData };
|
|
19516
19525
|
} else {
|
|
19526
|
+
const item = this.board.items.getById(itemId);
|
|
19517
19527
|
Object.keys(op.newData).forEach((key) => {
|
|
19518
19528
|
if (item[key]) {
|
|
19519
19529
|
newData[key] = item[key];
|
|
19520
19530
|
}
|
|
19521
19531
|
});
|
|
19522
19532
|
}
|
|
19523
|
-
return {
|
|
19533
|
+
return { itemId, operation: {
|
|
19524
19534
|
...op,
|
|
19525
19535
|
newData
|
|
19526
|
-
};
|
|
19536
|
+
} };
|
|
19527
19537
|
});
|
|
19528
19538
|
}
|
|
19529
19539
|
}
|
|
@@ -40549,9 +40559,6 @@ class Frame2 extends BaseItem {
|
|
|
40549
40559
|
case "RichText":
|
|
40550
40560
|
this.text.apply(op);
|
|
40551
40561
|
break;
|
|
40552
|
-
case "LinkTo":
|
|
40553
|
-
this.linkTo.apply(op);
|
|
40554
|
-
break;
|
|
40555
40562
|
default:
|
|
40556
40563
|
return;
|
|
40557
40564
|
}
|
|
@@ -47495,8 +47502,8 @@ function createItemValidator(defaultData2) {
|
|
|
47495
47502
|
};
|
|
47496
47503
|
}
|
|
47497
47504
|
function createItemCommandFactory(itemType) {
|
|
47498
|
-
return function itemCommandFactory(items, operation) {
|
|
47499
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47505
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47506
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47500
47507
|
};
|
|
47501
47508
|
}
|
|
47502
47509
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/cjs/node.js
CHANGED
|
@@ -22007,11 +22007,13 @@ class AudioCommand {
|
|
|
22007
22007
|
|
|
22008
22008
|
// src/Events/Command.ts
|
|
22009
22009
|
class BaseCommand {
|
|
22010
|
-
|
|
22010
|
+
board;
|
|
22011
|
+
itemIds;
|
|
22011
22012
|
operation;
|
|
22012
22013
|
reverse;
|
|
22013
|
-
constructor(
|
|
22014
|
-
this.
|
|
22014
|
+
constructor(board, itemIds, operation) {
|
|
22015
|
+
this.board = board;
|
|
22016
|
+
this.itemIds = itemIds;
|
|
22015
22017
|
this.operation = operation;
|
|
22016
22018
|
this.reverse = this.getReverse();
|
|
22017
22019
|
}
|
|
@@ -22020,49 +22022,57 @@ class BaseCommand {
|
|
|
22020
22022
|
return this;
|
|
22021
22023
|
}
|
|
22022
22024
|
apply() {
|
|
22023
|
-
for (const
|
|
22025
|
+
for (const itemId of this.itemIds) {
|
|
22026
|
+
const item = this.board.items.getById(itemId);
|
|
22027
|
+
if (!item) {
|
|
22028
|
+
continue;
|
|
22029
|
+
}
|
|
22024
22030
|
item.apply(this.operation);
|
|
22025
22031
|
}
|
|
22026
22032
|
}
|
|
22027
22033
|
revert() {
|
|
22028
|
-
for (const {
|
|
22034
|
+
for (const { itemId, operation } of this.reverse) {
|
|
22035
|
+
const item = this.board.items.getById(itemId);
|
|
22036
|
+
if (!item) {
|
|
22037
|
+
continue;
|
|
22038
|
+
}
|
|
22029
22039
|
item.apply(operation);
|
|
22030
22040
|
}
|
|
22031
22041
|
}
|
|
22032
22042
|
getReverse() {
|
|
22033
|
-
const items = this.items;
|
|
22034
22043
|
switch (this.operation.method) {
|
|
22035
22044
|
case "addChildren":
|
|
22036
|
-
return
|
|
22037
|
-
return {
|
|
22045
|
+
return this.itemIds.map((itemId) => {
|
|
22046
|
+
return { itemId, operation: {
|
|
22038
22047
|
...this.operation,
|
|
22039
|
-
|
|
22040
|
-
};
|
|
22048
|
+
method: "removeChildren"
|
|
22049
|
+
} };
|
|
22041
22050
|
});
|
|
22042
22051
|
case "removeChildren":
|
|
22043
|
-
return
|
|
22044
|
-
return {
|
|
22052
|
+
return this.itemIds.map((itemId) => {
|
|
22053
|
+
return { itemId, operation: {
|
|
22045
22054
|
...this.operation,
|
|
22046
|
-
|
|
22047
|
-
};
|
|
22055
|
+
method: "addChildren"
|
|
22056
|
+
} };
|
|
22048
22057
|
});
|
|
22049
22058
|
default:
|
|
22050
|
-
return
|
|
22059
|
+
return this.itemIds.map((itemId) => {
|
|
22051
22060
|
const op = this.operation;
|
|
22052
22061
|
let newData = {};
|
|
22053
22062
|
if (op.prevData) {
|
|
22054
22063
|
newData = { ...op.prevData };
|
|
22055
22064
|
} else {
|
|
22065
|
+
const item = this.board.items.getById(itemId);
|
|
22056
22066
|
Object.keys(op.newData).forEach((key) => {
|
|
22057
22067
|
if (item[key]) {
|
|
22058
22068
|
newData[key] = item[key];
|
|
22059
22069
|
}
|
|
22060
22070
|
});
|
|
22061
22071
|
}
|
|
22062
|
-
return {
|
|
22072
|
+
return { itemId, operation: {
|
|
22063
22073
|
...op,
|
|
22064
22074
|
newData
|
|
22065
|
-
};
|
|
22075
|
+
} };
|
|
22066
22076
|
});
|
|
22067
22077
|
}
|
|
22068
22078
|
}
|
|
@@ -43022,9 +43032,6 @@ class Frame2 extends BaseItem {
|
|
|
43022
43032
|
case "RichText":
|
|
43023
43033
|
this.text.apply(op);
|
|
43024
43034
|
break;
|
|
43025
|
-
case "LinkTo":
|
|
43026
|
-
this.linkTo.apply(op);
|
|
43027
|
-
break;
|
|
43028
43035
|
default:
|
|
43029
43036
|
return;
|
|
43030
43037
|
}
|
|
@@ -49968,8 +49975,8 @@ function createItemValidator(defaultData2) {
|
|
|
49968
49975
|
};
|
|
49969
49976
|
}
|
|
49970
49977
|
function createItemCommandFactory(itemType) {
|
|
49971
|
-
return function itemCommandFactory(items, operation) {
|
|
49972
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49978
|
+
return function itemCommandFactory(items, operation, board) {
|
|
49979
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
49973
49980
|
};
|
|
49974
49981
|
}
|
|
49975
49982
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/browser.js
CHANGED
|
@@ -19317,11 +19317,13 @@ class AudioCommand {
|
|
|
19317
19317
|
|
|
19318
19318
|
// src/Events/Command.ts
|
|
19319
19319
|
class BaseCommand {
|
|
19320
|
-
|
|
19320
|
+
board;
|
|
19321
|
+
itemIds;
|
|
19321
19322
|
operation;
|
|
19322
19323
|
reverse;
|
|
19323
|
-
constructor(
|
|
19324
|
-
this.
|
|
19324
|
+
constructor(board, itemIds, operation) {
|
|
19325
|
+
this.board = board;
|
|
19326
|
+
this.itemIds = itemIds;
|
|
19325
19327
|
this.operation = operation;
|
|
19326
19328
|
this.reverse = this.getReverse();
|
|
19327
19329
|
}
|
|
@@ -19330,49 +19332,57 @@ class BaseCommand {
|
|
|
19330
19332
|
return this;
|
|
19331
19333
|
}
|
|
19332
19334
|
apply() {
|
|
19333
|
-
for (const
|
|
19335
|
+
for (const itemId of this.itemIds) {
|
|
19336
|
+
const item = this.board.items.getById(itemId);
|
|
19337
|
+
if (!item) {
|
|
19338
|
+
continue;
|
|
19339
|
+
}
|
|
19334
19340
|
item.apply(this.operation);
|
|
19335
19341
|
}
|
|
19336
19342
|
}
|
|
19337
19343
|
revert() {
|
|
19338
|
-
for (const {
|
|
19344
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19345
|
+
const item = this.board.items.getById(itemId);
|
|
19346
|
+
if (!item) {
|
|
19347
|
+
continue;
|
|
19348
|
+
}
|
|
19339
19349
|
item.apply(operation);
|
|
19340
19350
|
}
|
|
19341
19351
|
}
|
|
19342
19352
|
getReverse() {
|
|
19343
|
-
const items = this.items;
|
|
19344
19353
|
switch (this.operation.method) {
|
|
19345
19354
|
case "addChildren":
|
|
19346
|
-
return
|
|
19347
|
-
return {
|
|
19355
|
+
return this.itemIds.map((itemId) => {
|
|
19356
|
+
return { itemId, operation: {
|
|
19348
19357
|
...this.operation,
|
|
19349
|
-
|
|
19350
|
-
};
|
|
19358
|
+
method: "removeChildren"
|
|
19359
|
+
} };
|
|
19351
19360
|
});
|
|
19352
19361
|
case "removeChildren":
|
|
19353
|
-
return
|
|
19354
|
-
return {
|
|
19362
|
+
return this.itemIds.map((itemId) => {
|
|
19363
|
+
return { itemId, operation: {
|
|
19355
19364
|
...this.operation,
|
|
19356
|
-
|
|
19357
|
-
};
|
|
19365
|
+
method: "addChildren"
|
|
19366
|
+
} };
|
|
19358
19367
|
});
|
|
19359
19368
|
default:
|
|
19360
|
-
return
|
|
19369
|
+
return this.itemIds.map((itemId) => {
|
|
19361
19370
|
const op = this.operation;
|
|
19362
19371
|
let newData = {};
|
|
19363
19372
|
if (op.prevData) {
|
|
19364
19373
|
newData = { ...op.prevData };
|
|
19365
19374
|
} else {
|
|
19375
|
+
const item = this.board.items.getById(itemId);
|
|
19366
19376
|
Object.keys(op.newData).forEach((key) => {
|
|
19367
19377
|
if (item[key]) {
|
|
19368
19378
|
newData[key] = item[key];
|
|
19369
19379
|
}
|
|
19370
19380
|
});
|
|
19371
19381
|
}
|
|
19372
|
-
return {
|
|
19382
|
+
return { itemId, operation: {
|
|
19373
19383
|
...op,
|
|
19374
19384
|
newData
|
|
19375
|
-
};
|
|
19385
|
+
} };
|
|
19376
19386
|
});
|
|
19377
19387
|
}
|
|
19378
19388
|
}
|
|
@@ -40398,9 +40408,6 @@ class Frame2 extends BaseItem {
|
|
|
40398
40408
|
case "RichText":
|
|
40399
40409
|
this.text.apply(op);
|
|
40400
40410
|
break;
|
|
40401
|
-
case "LinkTo":
|
|
40402
|
-
this.linkTo.apply(op);
|
|
40403
|
-
break;
|
|
40404
40411
|
default:
|
|
40405
40412
|
return;
|
|
40406
40413
|
}
|
|
@@ -47344,8 +47351,8 @@ function createItemValidator(defaultData2) {
|
|
|
47344
47351
|
};
|
|
47345
47352
|
}
|
|
47346
47353
|
function createItemCommandFactory(itemType) {
|
|
47347
|
-
return function itemCommandFactory(items, operation) {
|
|
47348
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47354
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47355
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47349
47356
|
};
|
|
47350
47357
|
}
|
|
47351
47358
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/index.js
CHANGED
|
@@ -19310,11 +19310,13 @@ class AudioCommand {
|
|
|
19310
19310
|
|
|
19311
19311
|
// src/Events/Command.ts
|
|
19312
19312
|
class BaseCommand {
|
|
19313
|
-
|
|
19313
|
+
board;
|
|
19314
|
+
itemIds;
|
|
19314
19315
|
operation;
|
|
19315
19316
|
reverse;
|
|
19316
|
-
constructor(
|
|
19317
|
-
this.
|
|
19317
|
+
constructor(board, itemIds, operation) {
|
|
19318
|
+
this.board = board;
|
|
19319
|
+
this.itemIds = itemIds;
|
|
19318
19320
|
this.operation = operation;
|
|
19319
19321
|
this.reverse = this.getReverse();
|
|
19320
19322
|
}
|
|
@@ -19323,49 +19325,57 @@ class BaseCommand {
|
|
|
19323
19325
|
return this;
|
|
19324
19326
|
}
|
|
19325
19327
|
apply() {
|
|
19326
|
-
for (const
|
|
19328
|
+
for (const itemId of this.itemIds) {
|
|
19329
|
+
const item = this.board.items.getById(itemId);
|
|
19330
|
+
if (!item) {
|
|
19331
|
+
continue;
|
|
19332
|
+
}
|
|
19327
19333
|
item.apply(this.operation);
|
|
19328
19334
|
}
|
|
19329
19335
|
}
|
|
19330
19336
|
revert() {
|
|
19331
|
-
for (const {
|
|
19337
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19338
|
+
const item = this.board.items.getById(itemId);
|
|
19339
|
+
if (!item) {
|
|
19340
|
+
continue;
|
|
19341
|
+
}
|
|
19332
19342
|
item.apply(operation);
|
|
19333
19343
|
}
|
|
19334
19344
|
}
|
|
19335
19345
|
getReverse() {
|
|
19336
|
-
const items = this.items;
|
|
19337
19346
|
switch (this.operation.method) {
|
|
19338
19347
|
case "addChildren":
|
|
19339
|
-
return
|
|
19340
|
-
return {
|
|
19348
|
+
return this.itemIds.map((itemId) => {
|
|
19349
|
+
return { itemId, operation: {
|
|
19341
19350
|
...this.operation,
|
|
19342
|
-
|
|
19343
|
-
};
|
|
19351
|
+
method: "removeChildren"
|
|
19352
|
+
} };
|
|
19344
19353
|
});
|
|
19345
19354
|
case "removeChildren":
|
|
19346
|
-
return
|
|
19347
|
-
return {
|
|
19355
|
+
return this.itemIds.map((itemId) => {
|
|
19356
|
+
return { itemId, operation: {
|
|
19348
19357
|
...this.operation,
|
|
19349
|
-
|
|
19350
|
-
};
|
|
19358
|
+
method: "addChildren"
|
|
19359
|
+
} };
|
|
19351
19360
|
});
|
|
19352
19361
|
default:
|
|
19353
|
-
return
|
|
19362
|
+
return this.itemIds.map((itemId) => {
|
|
19354
19363
|
const op = this.operation;
|
|
19355
19364
|
let newData = {};
|
|
19356
19365
|
if (op.prevData) {
|
|
19357
19366
|
newData = { ...op.prevData };
|
|
19358
19367
|
} else {
|
|
19368
|
+
const item = this.board.items.getById(itemId);
|
|
19359
19369
|
Object.keys(op.newData).forEach((key) => {
|
|
19360
19370
|
if (item[key]) {
|
|
19361
19371
|
newData[key] = item[key];
|
|
19362
19372
|
}
|
|
19363
19373
|
});
|
|
19364
19374
|
}
|
|
19365
|
-
return {
|
|
19375
|
+
return { itemId, operation: {
|
|
19366
19376
|
...op,
|
|
19367
19377
|
newData
|
|
19368
|
-
};
|
|
19378
|
+
} };
|
|
19369
19379
|
});
|
|
19370
19380
|
}
|
|
19371
19381
|
}
|
|
@@ -40391,9 +40401,6 @@ class Frame2 extends BaseItem {
|
|
|
40391
40401
|
case "RichText":
|
|
40392
40402
|
this.text.apply(op);
|
|
40393
40403
|
break;
|
|
40394
|
-
case "LinkTo":
|
|
40395
|
-
this.linkTo.apply(op);
|
|
40396
|
-
break;
|
|
40397
40404
|
default:
|
|
40398
40405
|
return;
|
|
40399
40406
|
}
|
|
@@ -47337,8 +47344,8 @@ function createItemValidator(defaultData2) {
|
|
|
47337
47344
|
};
|
|
47338
47345
|
}
|
|
47339
47346
|
function createItemCommandFactory(itemType) {
|
|
47340
|
-
return function itemCommandFactory(items, operation) {
|
|
47341
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47347
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47348
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47342
47349
|
};
|
|
47343
47350
|
}
|
|
47344
47351
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/node.js
CHANGED
|
@@ -21844,11 +21844,13 @@ class AudioCommand {
|
|
|
21844
21844
|
|
|
21845
21845
|
// src/Events/Command.ts
|
|
21846
21846
|
class BaseCommand {
|
|
21847
|
-
|
|
21847
|
+
board;
|
|
21848
|
+
itemIds;
|
|
21848
21849
|
operation;
|
|
21849
21850
|
reverse;
|
|
21850
|
-
constructor(
|
|
21851
|
-
this.
|
|
21851
|
+
constructor(board, itemIds, operation) {
|
|
21852
|
+
this.board = board;
|
|
21853
|
+
this.itemIds = itemIds;
|
|
21852
21854
|
this.operation = operation;
|
|
21853
21855
|
this.reverse = this.getReverse();
|
|
21854
21856
|
}
|
|
@@ -21857,49 +21859,57 @@ class BaseCommand {
|
|
|
21857
21859
|
return this;
|
|
21858
21860
|
}
|
|
21859
21861
|
apply() {
|
|
21860
|
-
for (const
|
|
21862
|
+
for (const itemId of this.itemIds) {
|
|
21863
|
+
const item = this.board.items.getById(itemId);
|
|
21864
|
+
if (!item) {
|
|
21865
|
+
continue;
|
|
21866
|
+
}
|
|
21861
21867
|
item.apply(this.operation);
|
|
21862
21868
|
}
|
|
21863
21869
|
}
|
|
21864
21870
|
revert() {
|
|
21865
|
-
for (const {
|
|
21871
|
+
for (const { itemId, operation } of this.reverse) {
|
|
21872
|
+
const item = this.board.items.getById(itemId);
|
|
21873
|
+
if (!item) {
|
|
21874
|
+
continue;
|
|
21875
|
+
}
|
|
21866
21876
|
item.apply(operation);
|
|
21867
21877
|
}
|
|
21868
21878
|
}
|
|
21869
21879
|
getReverse() {
|
|
21870
|
-
const items = this.items;
|
|
21871
21880
|
switch (this.operation.method) {
|
|
21872
21881
|
case "addChildren":
|
|
21873
|
-
return
|
|
21874
|
-
return {
|
|
21882
|
+
return this.itemIds.map((itemId) => {
|
|
21883
|
+
return { itemId, operation: {
|
|
21875
21884
|
...this.operation,
|
|
21876
|
-
|
|
21877
|
-
};
|
|
21885
|
+
method: "removeChildren"
|
|
21886
|
+
} };
|
|
21878
21887
|
});
|
|
21879
21888
|
case "removeChildren":
|
|
21880
|
-
return
|
|
21881
|
-
return {
|
|
21889
|
+
return this.itemIds.map((itemId) => {
|
|
21890
|
+
return { itemId, operation: {
|
|
21882
21891
|
...this.operation,
|
|
21883
|
-
|
|
21884
|
-
};
|
|
21892
|
+
method: "addChildren"
|
|
21893
|
+
} };
|
|
21885
21894
|
});
|
|
21886
21895
|
default:
|
|
21887
|
-
return
|
|
21896
|
+
return this.itemIds.map((itemId) => {
|
|
21888
21897
|
const op = this.operation;
|
|
21889
21898
|
let newData = {};
|
|
21890
21899
|
if (op.prevData) {
|
|
21891
21900
|
newData = { ...op.prevData };
|
|
21892
21901
|
} else {
|
|
21902
|
+
const item = this.board.items.getById(itemId);
|
|
21893
21903
|
Object.keys(op.newData).forEach((key) => {
|
|
21894
21904
|
if (item[key]) {
|
|
21895
21905
|
newData[key] = item[key];
|
|
21896
21906
|
}
|
|
21897
21907
|
});
|
|
21898
21908
|
}
|
|
21899
|
-
return {
|
|
21909
|
+
return { itemId, operation: {
|
|
21900
21910
|
...op,
|
|
21901
21911
|
newData
|
|
21902
|
-
};
|
|
21912
|
+
} };
|
|
21903
21913
|
});
|
|
21904
21914
|
}
|
|
21905
21915
|
}
|
|
@@ -42859,9 +42869,6 @@ class Frame2 extends BaseItem {
|
|
|
42859
42869
|
case "RichText":
|
|
42860
42870
|
this.text.apply(op);
|
|
42861
42871
|
break;
|
|
42862
|
-
case "LinkTo":
|
|
42863
|
-
this.linkTo.apply(op);
|
|
42864
|
-
break;
|
|
42865
42872
|
default:
|
|
42866
42873
|
return;
|
|
42867
42874
|
}
|
|
@@ -49805,8 +49812,8 @@ function createItemValidator(defaultData2) {
|
|
|
49805
49812
|
};
|
|
49806
49813
|
}
|
|
49807
49814
|
function createItemCommandFactory(itemType) {
|
|
49808
|
-
return function itemCommandFactory(items, operation) {
|
|
49809
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49815
|
+
return function itemCommandFactory(items, operation, board) {
|
|
49816
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
49810
49817
|
};
|
|
49811
49818
|
}
|
|
49812
49819
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Board } from 'Board';
|
|
2
2
|
import { BaseOperation, ItemOperation, Operation } from './EventsOperations';
|
|
3
3
|
import { Item, TransformationOperation } from 'Items';
|
|
4
|
-
import { BaseItem } from "../Items/BaseItem";
|
|
5
4
|
export interface Command {
|
|
6
5
|
apply(): void;
|
|
7
6
|
revert(): void;
|
|
8
7
|
merge?: (op: any) => Command;
|
|
9
8
|
}
|
|
10
9
|
export declare class BaseCommand {
|
|
11
|
-
|
|
10
|
+
private board;
|
|
11
|
+
itemIds: string[];
|
|
12
12
|
operation: BaseOperation;
|
|
13
13
|
private reverse;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(board: Board, itemIds: string[], operation: BaseOperation);
|
|
15
15
|
merge(op: BaseOperation): this;
|
|
16
16
|
apply(): void;
|
|
17
17
|
revert(): void;
|
|
18
18
|
getReverse(): {
|
|
19
|
-
|
|
19
|
+
itemId: string;
|
|
20
20
|
operation: BaseOperation;
|
|
21
21
|
}[];
|
|
22
22
|
}
|