microboard-temp 0.4.27 → 0.4.29
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 +90 -87
- package/dist/cjs/index.js +90 -87
- package/dist/cjs/node.js +90 -87
- package/dist/esm/browser.js +90 -87
- package/dist/esm/index.js +90 -87
- package/dist/esm/node.js +90 -87
- package/dist/types/Events/EventsOperations.d.ts +1 -1
- package/dist/types/Items/Examples/CardGame/Dice/Dice.d.ts +3 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -19306,9 +19306,19 @@ class BaseCommand {
|
|
|
19306
19306
|
const items = this.items;
|
|
19307
19307
|
return mapItemsByOperation(items, (item) => {
|
|
19308
19308
|
const op = this.operation;
|
|
19309
|
+
let newData = {};
|
|
19310
|
+
if (op.prevData) {
|
|
19311
|
+
newData = op.prevData;
|
|
19312
|
+
} else {
|
|
19313
|
+
Object.keys(op.newData).forEach((key) => {
|
|
19314
|
+
if (item[key]) {
|
|
19315
|
+
op.newData[key] = item[key];
|
|
19316
|
+
}
|
|
19317
|
+
});
|
|
19318
|
+
}
|
|
19309
19319
|
return {
|
|
19310
19320
|
...op,
|
|
19311
|
-
newData
|
|
19321
|
+
newData
|
|
19312
19322
|
};
|
|
19313
19323
|
});
|
|
19314
19324
|
}
|
|
@@ -46100,7 +46110,7 @@ class Dice extends BaseItem {
|
|
|
46100
46110
|
if (values2) {
|
|
46101
46111
|
this.values = values2;
|
|
46102
46112
|
}
|
|
46103
|
-
this.
|
|
46113
|
+
this.updateRenderValues();
|
|
46104
46114
|
this.transformPath();
|
|
46105
46115
|
this.transformation.subject.subscribe(() => {
|
|
46106
46116
|
this.transformPath();
|
|
@@ -46116,7 +46126,7 @@ class Dice extends BaseItem {
|
|
|
46116
46126
|
this.path.setBorderColor(this.borderColor);
|
|
46117
46127
|
this.path.setBorderWidth(this.borderWidth);
|
|
46118
46128
|
}
|
|
46119
|
-
|
|
46129
|
+
updateRenderValues() {
|
|
46120
46130
|
this.values.forEach((value, index2) => {
|
|
46121
46131
|
if (typeof value === "number") {
|
|
46122
46132
|
this.renderValues[index2] = value;
|
|
@@ -46191,7 +46201,7 @@ class Dice extends BaseItem {
|
|
|
46191
46201
|
}
|
|
46192
46202
|
deserialize(data) {
|
|
46193
46203
|
super.deserialize(data);
|
|
46194
|
-
this.
|
|
46204
|
+
this.updateRenderValues();
|
|
46195
46205
|
this.transformPath();
|
|
46196
46206
|
this.subject.publish(this);
|
|
46197
46207
|
return this;
|
|
@@ -46298,6 +46308,7 @@ class Dice extends BaseItem {
|
|
|
46298
46308
|
this.valueIndex = 0;
|
|
46299
46309
|
}
|
|
46300
46310
|
this.values = op.newData.values;
|
|
46311
|
+
this.updateRenderValues();
|
|
46301
46312
|
break;
|
|
46302
46313
|
}
|
|
46303
46314
|
break;
|
|
@@ -50368,93 +50379,85 @@ class BoardSelection {
|
|
|
50368
50379
|
}
|
|
50369
50380
|
}
|
|
50370
50381
|
setStrokeColor(borderColor) {
|
|
50371
|
-
const
|
|
50372
|
-
|
|
50373
|
-
|
|
50374
|
-
|
|
50375
|
-
|
|
50376
|
-
|
|
50377
|
-
|
|
50378
|
-
|
|
50379
|
-
|
|
50380
|
-
|
|
50381
|
-
|
|
50382
|
-
|
|
50383
|
-
|
|
50384
|
-
|
|
50385
|
-
|
|
50386
|
-
|
|
50387
|
-
|
|
50388
|
-
|
|
50389
|
-
|
|
50390
|
-
|
|
50391
|
-
|
|
50392
|
-
|
|
50393
|
-
|
|
50394
|
-
|
|
50395
|
-
|
|
50396
|
-
|
|
50397
|
-
}
|
|
50382
|
+
const operation = {
|
|
50383
|
+
class: "Shape",
|
|
50384
|
+
method: "setBorderColor",
|
|
50385
|
+
item: [],
|
|
50386
|
+
newData: { borderColor }
|
|
50387
|
+
};
|
|
50388
|
+
const operations2 = {};
|
|
50389
|
+
this.items.list().forEach((item) => {
|
|
50390
|
+
if (!operations2[item.itemType]) {
|
|
50391
|
+
const operationCopy = { ...operation };
|
|
50392
|
+
if (item.itemType === "Connector") {
|
|
50393
|
+
operationCopy.method = "setLineColor";
|
|
50394
|
+
operationCopy.lineColor = borderColor;
|
|
50395
|
+
} else if (item.itemType === "Drawing") {
|
|
50396
|
+
operationCopy.method = "setStrokeColor";
|
|
50397
|
+
operationCopy.color = borderColor;
|
|
50398
|
+
} else {
|
|
50399
|
+
operationCopy.borderColor = borderColor;
|
|
50400
|
+
}
|
|
50401
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
50402
|
+
} else {
|
|
50403
|
+
operations2[item.itemType].item.push(item.getId());
|
|
50404
|
+
}
|
|
50405
|
+
});
|
|
50406
|
+
Object.values(operations2).forEach((op) => {
|
|
50407
|
+
this.emit(op);
|
|
50408
|
+
});
|
|
50398
50409
|
}
|
|
50399
50410
|
setStrokeWidth(width2) {
|
|
50400
|
-
const
|
|
50401
|
-
|
|
50402
|
-
|
|
50403
|
-
|
|
50404
|
-
|
|
50405
|
-
|
|
50406
|
-
|
|
50407
|
-
|
|
50408
|
-
|
|
50409
|
-
|
|
50410
|
-
|
|
50411
|
-
|
|
50412
|
-
|
|
50413
|
-
|
|
50414
|
-
|
|
50415
|
-
|
|
50416
|
-
|
|
50417
|
-
|
|
50418
|
-
|
|
50419
|
-
|
|
50420
|
-
|
|
50421
|
-
|
|
50422
|
-
class:
|
|
50423
|
-
|
|
50424
|
-
item
|
|
50425
|
-
|
|
50426
|
-
|
|
50427
|
-
|
|
50428
|
-
|
|
50411
|
+
const operation = {
|
|
50412
|
+
class: "Shape",
|
|
50413
|
+
method: "setStrokeWidth",
|
|
50414
|
+
item: [],
|
|
50415
|
+
width: width2,
|
|
50416
|
+
newData: { width: width2 }
|
|
50417
|
+
};
|
|
50418
|
+
const operations2 = {};
|
|
50419
|
+
this.items.list().forEach((item) => {
|
|
50420
|
+
if (!operations2[item.itemType]) {
|
|
50421
|
+
const operationCopy = { ...operation };
|
|
50422
|
+
if (item.itemType === "Connector") {
|
|
50423
|
+
operationCopy.method = "setLineWidth";
|
|
50424
|
+
operationCopy.lineWidth = width2;
|
|
50425
|
+
} else if (item.itemType === "Drawing") {
|
|
50426
|
+
operationCopy.method = "setStrokeWidth";
|
|
50427
|
+
operationCopy.width = width2;
|
|
50428
|
+
operationCopy.prevWidth = this.getStrokeWidth();
|
|
50429
|
+
} else {
|
|
50430
|
+
operationCopy.borderWidth = width2;
|
|
50431
|
+
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
50432
|
+
}
|
|
50433
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
50434
|
+
} else {
|
|
50435
|
+
operations2[item.itemType].item.push(item.getId());
|
|
50436
|
+
}
|
|
50437
|
+
});
|
|
50438
|
+
Object.values(operations2).forEach((op) => {
|
|
50439
|
+
this.emit(op);
|
|
50440
|
+
});
|
|
50429
50441
|
}
|
|
50430
50442
|
setFillColor(backgroundColor) {
|
|
50431
|
-
const
|
|
50432
|
-
|
|
50433
|
-
|
|
50434
|
-
|
|
50435
|
-
|
|
50436
|
-
|
|
50437
|
-
|
|
50438
|
-
|
|
50439
|
-
|
|
50440
|
-
|
|
50441
|
-
|
|
50442
|
-
|
|
50443
|
-
|
|
50444
|
-
|
|
50445
|
-
|
|
50446
|
-
|
|
50447
|
-
|
|
50448
|
-
}
|
|
50449
|
-
const frames = this.items.getIdsByItemTypes(["Frame"]);
|
|
50450
|
-
if (frames.length) {
|
|
50451
|
-
this.emit({
|
|
50452
|
-
class: "Frame",
|
|
50453
|
-
method: "setBackgroundColor",
|
|
50454
|
-
item: frames,
|
|
50455
|
-
backgroundColor
|
|
50456
|
-
});
|
|
50457
|
-
}
|
|
50443
|
+
const operation = {
|
|
50444
|
+
class: "Shape",
|
|
50445
|
+
method: "setBackgroundColor",
|
|
50446
|
+
item: [],
|
|
50447
|
+
backgroundColor,
|
|
50448
|
+
newData: { backgroundColor }
|
|
50449
|
+
};
|
|
50450
|
+
const operations2 = {};
|
|
50451
|
+
this.items.list().forEach((item) => {
|
|
50452
|
+
if (!operations2[item.itemType]) {
|
|
50453
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
50454
|
+
} else {
|
|
50455
|
+
operations2[item.itemType].item.push(item.getId());
|
|
50456
|
+
}
|
|
50457
|
+
});
|
|
50458
|
+
Object.values(operations2).forEach((op) => {
|
|
50459
|
+
this.emit(op);
|
|
50460
|
+
});
|
|
50458
50461
|
}
|
|
50459
50462
|
setCanChangeRatio(canChangeRatio) {
|
|
50460
50463
|
const frames = this.items.getIdsByItemTypes(["Frame"]);
|
package/dist/esm/node.js
CHANGED
|
@@ -21840,9 +21840,19 @@ class BaseCommand {
|
|
|
21840
21840
|
const items = this.items;
|
|
21841
21841
|
return mapItemsByOperation(items, (item) => {
|
|
21842
21842
|
const op = this.operation;
|
|
21843
|
+
let newData = {};
|
|
21844
|
+
if (op.prevData) {
|
|
21845
|
+
newData = op.prevData;
|
|
21846
|
+
} else {
|
|
21847
|
+
Object.keys(op.newData).forEach((key) => {
|
|
21848
|
+
if (item[key]) {
|
|
21849
|
+
op.newData[key] = item[key];
|
|
21850
|
+
}
|
|
21851
|
+
});
|
|
21852
|
+
}
|
|
21843
21853
|
return {
|
|
21844
21854
|
...op,
|
|
21845
|
-
newData
|
|
21855
|
+
newData
|
|
21846
21856
|
};
|
|
21847
21857
|
});
|
|
21848
21858
|
}
|
|
@@ -48635,7 +48645,7 @@ class Dice extends BaseItem {
|
|
|
48635
48645
|
if (values2) {
|
|
48636
48646
|
this.values = values2;
|
|
48637
48647
|
}
|
|
48638
|
-
this.
|
|
48648
|
+
this.updateRenderValues();
|
|
48639
48649
|
this.transformPath();
|
|
48640
48650
|
this.transformation.subject.subscribe(() => {
|
|
48641
48651
|
this.transformPath();
|
|
@@ -48651,7 +48661,7 @@ class Dice extends BaseItem {
|
|
|
48651
48661
|
this.path.setBorderColor(this.borderColor);
|
|
48652
48662
|
this.path.setBorderWidth(this.borderWidth);
|
|
48653
48663
|
}
|
|
48654
|
-
|
|
48664
|
+
updateRenderValues() {
|
|
48655
48665
|
this.values.forEach((value, index2) => {
|
|
48656
48666
|
if (typeof value === "number") {
|
|
48657
48667
|
this.renderValues[index2] = value;
|
|
@@ -48726,7 +48736,7 @@ class Dice extends BaseItem {
|
|
|
48726
48736
|
}
|
|
48727
48737
|
deserialize(data) {
|
|
48728
48738
|
super.deserialize(data);
|
|
48729
|
-
this.
|
|
48739
|
+
this.updateRenderValues();
|
|
48730
48740
|
this.transformPath();
|
|
48731
48741
|
this.subject.publish(this);
|
|
48732
48742
|
return this;
|
|
@@ -48833,6 +48843,7 @@ class Dice extends BaseItem {
|
|
|
48833
48843
|
this.valueIndex = 0;
|
|
48834
48844
|
}
|
|
48835
48845
|
this.values = op.newData.values;
|
|
48846
|
+
this.updateRenderValues();
|
|
48836
48847
|
break;
|
|
48837
48848
|
}
|
|
48838
48849
|
break;
|
|
@@ -52903,93 +52914,85 @@ class BoardSelection {
|
|
|
52903
52914
|
}
|
|
52904
52915
|
}
|
|
52905
52916
|
setStrokeColor(borderColor) {
|
|
52906
|
-
const
|
|
52907
|
-
|
|
52908
|
-
|
|
52909
|
-
|
|
52910
|
-
|
|
52911
|
-
|
|
52912
|
-
|
|
52913
|
-
|
|
52914
|
-
|
|
52915
|
-
|
|
52916
|
-
|
|
52917
|
-
|
|
52918
|
-
|
|
52919
|
-
|
|
52920
|
-
|
|
52921
|
-
|
|
52922
|
-
|
|
52923
|
-
|
|
52924
|
-
|
|
52925
|
-
|
|
52926
|
-
|
|
52927
|
-
|
|
52928
|
-
|
|
52929
|
-
|
|
52930
|
-
|
|
52931
|
-
|
|
52932
|
-
}
|
|
52917
|
+
const operation = {
|
|
52918
|
+
class: "Shape",
|
|
52919
|
+
method: "setBorderColor",
|
|
52920
|
+
item: [],
|
|
52921
|
+
newData: { borderColor }
|
|
52922
|
+
};
|
|
52923
|
+
const operations2 = {};
|
|
52924
|
+
this.items.list().forEach((item) => {
|
|
52925
|
+
if (!operations2[item.itemType]) {
|
|
52926
|
+
const operationCopy = { ...operation };
|
|
52927
|
+
if (item.itemType === "Connector") {
|
|
52928
|
+
operationCopy.method = "setLineColor";
|
|
52929
|
+
operationCopy.lineColor = borderColor;
|
|
52930
|
+
} else if (item.itemType === "Drawing") {
|
|
52931
|
+
operationCopy.method = "setStrokeColor";
|
|
52932
|
+
operationCopy.color = borderColor;
|
|
52933
|
+
} else {
|
|
52934
|
+
operationCopy.borderColor = borderColor;
|
|
52935
|
+
}
|
|
52936
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52937
|
+
} else {
|
|
52938
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52939
|
+
}
|
|
52940
|
+
});
|
|
52941
|
+
Object.values(operations2).forEach((op) => {
|
|
52942
|
+
this.emit(op);
|
|
52943
|
+
});
|
|
52933
52944
|
}
|
|
52934
52945
|
setStrokeWidth(width2) {
|
|
52935
|
-
const
|
|
52936
|
-
|
|
52937
|
-
|
|
52938
|
-
|
|
52939
|
-
|
|
52940
|
-
|
|
52941
|
-
|
|
52942
|
-
|
|
52943
|
-
|
|
52944
|
-
|
|
52945
|
-
|
|
52946
|
-
|
|
52947
|
-
|
|
52948
|
-
|
|
52949
|
-
|
|
52950
|
-
|
|
52951
|
-
|
|
52952
|
-
|
|
52953
|
-
|
|
52954
|
-
|
|
52955
|
-
|
|
52956
|
-
|
|
52957
|
-
class:
|
|
52958
|
-
|
|
52959
|
-
item
|
|
52960
|
-
|
|
52961
|
-
|
|
52962
|
-
|
|
52963
|
-
|
|
52946
|
+
const operation = {
|
|
52947
|
+
class: "Shape",
|
|
52948
|
+
method: "setStrokeWidth",
|
|
52949
|
+
item: [],
|
|
52950
|
+
width: width2,
|
|
52951
|
+
newData: { width: width2 }
|
|
52952
|
+
};
|
|
52953
|
+
const operations2 = {};
|
|
52954
|
+
this.items.list().forEach((item) => {
|
|
52955
|
+
if (!operations2[item.itemType]) {
|
|
52956
|
+
const operationCopy = { ...operation };
|
|
52957
|
+
if (item.itemType === "Connector") {
|
|
52958
|
+
operationCopy.method = "setLineWidth";
|
|
52959
|
+
operationCopy.lineWidth = width2;
|
|
52960
|
+
} else if (item.itemType === "Drawing") {
|
|
52961
|
+
operationCopy.method = "setStrokeWidth";
|
|
52962
|
+
operationCopy.width = width2;
|
|
52963
|
+
operationCopy.prevWidth = this.getStrokeWidth();
|
|
52964
|
+
} else {
|
|
52965
|
+
operationCopy.borderWidth = width2;
|
|
52966
|
+
operationCopy.prevBorderWidth = this.getStrokeWidth();
|
|
52967
|
+
}
|
|
52968
|
+
operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
|
|
52969
|
+
} else {
|
|
52970
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52971
|
+
}
|
|
52972
|
+
});
|
|
52973
|
+
Object.values(operations2).forEach((op) => {
|
|
52974
|
+
this.emit(op);
|
|
52975
|
+
});
|
|
52964
52976
|
}
|
|
52965
52977
|
setFillColor(backgroundColor) {
|
|
52966
|
-
const
|
|
52967
|
-
|
|
52968
|
-
|
|
52969
|
-
|
|
52970
|
-
|
|
52971
|
-
|
|
52972
|
-
|
|
52973
|
-
|
|
52974
|
-
|
|
52975
|
-
|
|
52976
|
-
|
|
52977
|
-
|
|
52978
|
-
|
|
52979
|
-
|
|
52980
|
-
|
|
52981
|
-
|
|
52982
|
-
|
|
52983
|
-
}
|
|
52984
|
-
const frames = this.items.getIdsByItemTypes(["Frame"]);
|
|
52985
|
-
if (frames.length) {
|
|
52986
|
-
this.emit({
|
|
52987
|
-
class: "Frame",
|
|
52988
|
-
method: "setBackgroundColor",
|
|
52989
|
-
item: frames,
|
|
52990
|
-
backgroundColor
|
|
52991
|
-
});
|
|
52992
|
-
}
|
|
52978
|
+
const operation = {
|
|
52979
|
+
class: "Shape",
|
|
52980
|
+
method: "setBackgroundColor",
|
|
52981
|
+
item: [],
|
|
52982
|
+
backgroundColor,
|
|
52983
|
+
newData: { backgroundColor }
|
|
52984
|
+
};
|
|
52985
|
+
const operations2 = {};
|
|
52986
|
+
this.items.list().forEach((item) => {
|
|
52987
|
+
if (!operations2[item.itemType]) {
|
|
52988
|
+
operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
|
|
52989
|
+
} else {
|
|
52990
|
+
operations2[item.itemType].item.push(item.getId());
|
|
52991
|
+
}
|
|
52992
|
+
});
|
|
52993
|
+
Object.values(operations2).forEach((op) => {
|
|
52994
|
+
this.emit(op);
|
|
52995
|
+
});
|
|
52993
52996
|
}
|
|
52994
52997
|
setCanChangeRatio(canChangeRatio) {
|
|
52995
52998
|
const frames = this.items.getIdsByItemTypes(["Frame"]);
|
|
@@ -29,7 +29,7 @@ export interface BaseOperation<T extends Record<string, unknown> = {}> {
|
|
|
29
29
|
item: string[];
|
|
30
30
|
method: string;
|
|
31
31
|
newData: T;
|
|
32
|
-
prevData
|
|
32
|
+
prevData?: T;
|
|
33
33
|
}
|
|
34
34
|
export type ItemOperation = LinkToOperation | TransformationOperation | ShapeOperation | StickerOperation | RichTextOperation | ConnectorOperation | DrawingOperation | FrameOperation | PlaceholderOperation | GroupOperation | CommentOperation | ImageOperation | VideoOperation | AudioOperation;
|
|
35
35
|
export type UndoableOperation = BoardOps | ItemOperation;
|
|
@@ -14,13 +14,13 @@ export declare class Dice extends BaseItem {
|
|
|
14
14
|
readonly subject: Subject<Dice>;
|
|
15
15
|
private borderWidth;
|
|
16
16
|
valueIndex: number;
|
|
17
|
-
values: number
|
|
17
|
+
values: (number | string)[];
|
|
18
18
|
renderValues: Record<number, number | HTMLImageElement>;
|
|
19
19
|
private animationFrameId?;
|
|
20
20
|
drawingContext: DrawingContext | null;
|
|
21
|
-
constructor(board: Board, id?: string, type?: DiceType, values?: number
|
|
21
|
+
constructor(board: Board, id?: string, type?: DiceType, values?: (number | string)[]);
|
|
22
22
|
private transformPath;
|
|
23
|
-
|
|
23
|
+
updateRenderValues(): void;
|
|
24
24
|
render(context: DrawingContext): void;
|
|
25
25
|
updateMbr(): void;
|
|
26
26
|
getPath(): Path;
|