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/node.js CHANGED
@@ -22002,9 +22002,19 @@ class BaseCommand {
22002
22002
  const items = this.items;
22003
22003
  return mapItemsByOperation(items, (item) => {
22004
22004
  const op = this.operation;
22005
+ let newData = {};
22006
+ if (op.prevData) {
22007
+ newData = op.prevData;
22008
+ } else {
22009
+ Object.keys(op.newData).forEach((key) => {
22010
+ if (item[key]) {
22011
+ op.newData[key] = item[key];
22012
+ }
22013
+ });
22014
+ }
22005
22015
  return {
22006
22016
  ...op,
22007
- newData: op.prevData
22017
+ newData
22008
22018
  };
22009
22019
  });
22010
22020
  }
@@ -48797,7 +48807,7 @@ class Dice extends BaseItem {
48797
48807
  if (values2) {
48798
48808
  this.values = values2;
48799
48809
  }
48800
- this.createRenderValues();
48810
+ this.updateRenderValues();
48801
48811
  this.transformPath();
48802
48812
  this.transformation.subject.subscribe(() => {
48803
48813
  this.transformPath();
@@ -48813,7 +48823,7 @@ class Dice extends BaseItem {
48813
48823
  this.path.setBorderColor(this.borderColor);
48814
48824
  this.path.setBorderWidth(this.borderWidth);
48815
48825
  }
48816
- createRenderValues() {
48826
+ updateRenderValues() {
48817
48827
  this.values.forEach((value, index2) => {
48818
48828
  if (typeof value === "number") {
48819
48829
  this.renderValues[index2] = value;
@@ -48888,7 +48898,7 @@ class Dice extends BaseItem {
48888
48898
  }
48889
48899
  deserialize(data) {
48890
48900
  super.deserialize(data);
48891
- this.createRenderValues();
48901
+ this.updateRenderValues();
48892
48902
  this.transformPath();
48893
48903
  this.subject.publish(this);
48894
48904
  return this;
@@ -48995,6 +49005,7 @@ class Dice extends BaseItem {
48995
49005
  this.valueIndex = 0;
48996
49006
  }
48997
49007
  this.values = op.newData.values;
49008
+ this.updateRenderValues();
48998
49009
  break;
48999
49010
  }
49000
49011
  break;
@@ -53065,93 +53076,85 @@ class BoardSelection {
53065
53076
  }
53066
53077
  }
53067
53078
  setStrokeColor(borderColor) {
53068
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53069
- if (shapes.length > 0) {
53070
- this.emit({
53071
- class: "Shape",
53072
- method: "setBorderColor",
53073
- item: shapes,
53074
- borderColor
53075
- });
53076
- }
53077
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
53078
- if (connectors.length > 0) {
53079
- this.emit({
53080
- class: "Connector",
53081
- method: "setLineColor",
53082
- item: connectors,
53083
- lineColor: borderColor
53084
- });
53085
- }
53086
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
53087
- if (drawings.length > 0) {
53088
- this.emit({
53089
- class: "Drawing",
53090
- method: "setStrokeColor",
53091
- item: drawings,
53092
- color: borderColor
53093
- });
53094
- }
53079
+ const operation = {
53080
+ class: "Shape",
53081
+ method: "setBorderColor",
53082
+ item: [],
53083
+ newData: { borderColor }
53084
+ };
53085
+ const operations2 = {};
53086
+ this.items.list().forEach((item) => {
53087
+ if (!operations2[item.itemType]) {
53088
+ const operationCopy = { ...operation };
53089
+ if (item.itemType === "Connector") {
53090
+ operationCopy.method = "setLineColor";
53091
+ operationCopy.lineColor = borderColor;
53092
+ } else if (item.itemType === "Drawing") {
53093
+ operationCopy.method = "setStrokeColor";
53094
+ operationCopy.color = borderColor;
53095
+ } else {
53096
+ operationCopy.borderColor = borderColor;
53097
+ }
53098
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
53099
+ } else {
53100
+ operations2[item.itemType].item.push(item.getId());
53101
+ }
53102
+ });
53103
+ Object.values(operations2).forEach((op) => {
53104
+ this.emit(op);
53105
+ });
53095
53106
  }
53096
53107
  setStrokeWidth(width2) {
53097
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53098
- if (shapes.length > 0) {
53099
- this.emit({
53100
- class: "Shape",
53101
- method: "setBorderWidth",
53102
- item: shapes,
53103
- borderWidth: width2,
53104
- prevBorderWidth: this.getStrokeWidth()
53105
- });
53106
- }
53107
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
53108
- if (connectors.length > 0) {
53109
- this.emit({
53110
- class: "Connector",
53111
- method: "setLineWidth",
53112
- item: connectors,
53113
- lineWidth: width2
53114
- });
53115
- }
53116
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
53117
- if (drawings.length > 0) {
53118
- this.emit({
53119
- class: "Drawing",
53120
- method: "setStrokeWidth",
53121
- item: drawings,
53122
- width: width2,
53123
- prevWidth: this.getStrokeWidth()
53124
- });
53125
- }
53108
+ const operation = {
53109
+ class: "Shape",
53110
+ method: "setStrokeWidth",
53111
+ item: [],
53112
+ width: width2,
53113
+ newData: { width: width2 }
53114
+ };
53115
+ const operations2 = {};
53116
+ this.items.list().forEach((item) => {
53117
+ if (!operations2[item.itemType]) {
53118
+ const operationCopy = { ...operation };
53119
+ if (item.itemType === "Connector") {
53120
+ operationCopy.method = "setLineWidth";
53121
+ operationCopy.lineWidth = width2;
53122
+ } else if (item.itemType === "Drawing") {
53123
+ operationCopy.method = "setStrokeWidth";
53124
+ operationCopy.width = width2;
53125
+ operationCopy.prevWidth = this.getStrokeWidth();
53126
+ } else {
53127
+ operationCopy.borderWidth = width2;
53128
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
53129
+ }
53130
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
53131
+ } else {
53132
+ operations2[item.itemType].item.push(item.getId());
53133
+ }
53134
+ });
53135
+ Object.values(operations2).forEach((op) => {
53136
+ this.emit(op);
53137
+ });
53126
53138
  }
53127
53139
  setFillColor(backgroundColor) {
53128
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53129
- if (shapes.length) {
53130
- this.emit({
53131
- class: "Shape",
53132
- method: "setBackgroundColor",
53133
- item: shapes,
53134
- backgroundColor
53135
- });
53136
- }
53137
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
53138
- if (stickers.length) {
53139
- this.emit({
53140
- class: "Sticker",
53141
- method: "setBackgroundColor",
53142
- item: stickers,
53143
- backgroundColor
53144
- });
53145
- }
53146
- const frames = this.items.getIdsByItemTypes(["Frame"]);
53147
- if (frames.length) {
53148
- this.emit({
53149
- class: "Frame",
53150
- method: "setBackgroundColor",
53151
- item: frames,
53152
- backgroundColor
53153
- });
53154
- }
53140
+ const operation = {
53141
+ class: "Shape",
53142
+ method: "setBackgroundColor",
53143
+ item: [],
53144
+ backgroundColor,
53145
+ newData: { backgroundColor }
53146
+ };
53147
+ const operations2 = {};
53148
+ this.items.list().forEach((item) => {
53149
+ if (!operations2[item.itemType]) {
53150
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
53151
+ } else {
53152
+ operations2[item.itemType].item.push(item.getId());
53153
+ }
53154
+ });
53155
+ Object.values(operations2).forEach((op) => {
53156
+ this.emit(op);
53157
+ });
53155
53158
  }
53156
53159
  setCanChangeRatio(canChangeRatio) {
53157
53160
  const frames = this.items.getIdsByItemTypes(["Frame"]);
@@ -19313,9 +19313,19 @@ class BaseCommand {
19313
19313
  const items = this.items;
19314
19314
  return mapItemsByOperation(items, (item) => {
19315
19315
  const op = this.operation;
19316
+ let newData = {};
19317
+ if (op.prevData) {
19318
+ newData = op.prevData;
19319
+ } else {
19320
+ Object.keys(op.newData).forEach((key) => {
19321
+ if (item[key]) {
19322
+ op.newData[key] = item[key];
19323
+ }
19324
+ });
19325
+ }
19316
19326
  return {
19317
19327
  ...op,
19318
- newData: op.prevData
19328
+ newData
19319
19329
  };
19320
19330
  });
19321
19331
  }
@@ -46107,7 +46117,7 @@ class Dice extends BaseItem {
46107
46117
  if (values2) {
46108
46118
  this.values = values2;
46109
46119
  }
46110
- this.createRenderValues();
46120
+ this.updateRenderValues();
46111
46121
  this.transformPath();
46112
46122
  this.transformation.subject.subscribe(() => {
46113
46123
  this.transformPath();
@@ -46123,7 +46133,7 @@ class Dice extends BaseItem {
46123
46133
  this.path.setBorderColor(this.borderColor);
46124
46134
  this.path.setBorderWidth(this.borderWidth);
46125
46135
  }
46126
- createRenderValues() {
46136
+ updateRenderValues() {
46127
46137
  this.values.forEach((value, index2) => {
46128
46138
  if (typeof value === "number") {
46129
46139
  this.renderValues[index2] = value;
@@ -46198,7 +46208,7 @@ class Dice extends BaseItem {
46198
46208
  }
46199
46209
  deserialize(data) {
46200
46210
  super.deserialize(data);
46201
- this.createRenderValues();
46211
+ this.updateRenderValues();
46202
46212
  this.transformPath();
46203
46213
  this.subject.publish(this);
46204
46214
  return this;
@@ -46305,6 +46315,7 @@ class Dice extends BaseItem {
46305
46315
  this.valueIndex = 0;
46306
46316
  }
46307
46317
  this.values = op.newData.values;
46318
+ this.updateRenderValues();
46308
46319
  break;
46309
46320
  }
46310
46321
  break;
@@ -50375,93 +50386,85 @@ class BoardSelection {
50375
50386
  }
50376
50387
  }
50377
50388
  setStrokeColor(borderColor) {
50378
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50379
- if (shapes.length > 0) {
50380
- this.emit({
50381
- class: "Shape",
50382
- method: "setBorderColor",
50383
- item: shapes,
50384
- borderColor
50385
- });
50386
- }
50387
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50388
- if (connectors.length > 0) {
50389
- this.emit({
50390
- class: "Connector",
50391
- method: "setLineColor",
50392
- item: connectors,
50393
- lineColor: borderColor
50394
- });
50395
- }
50396
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50397
- if (drawings.length > 0) {
50398
- this.emit({
50399
- class: "Drawing",
50400
- method: "setStrokeColor",
50401
- item: drawings,
50402
- color: borderColor
50403
- });
50404
- }
50389
+ const operation = {
50390
+ class: "Shape",
50391
+ method: "setBorderColor",
50392
+ item: [],
50393
+ newData: { borderColor }
50394
+ };
50395
+ const operations2 = {};
50396
+ this.items.list().forEach((item) => {
50397
+ if (!operations2[item.itemType]) {
50398
+ const operationCopy = { ...operation };
50399
+ if (item.itemType === "Connector") {
50400
+ operationCopy.method = "setLineColor";
50401
+ operationCopy.lineColor = borderColor;
50402
+ } else if (item.itemType === "Drawing") {
50403
+ operationCopy.method = "setStrokeColor";
50404
+ operationCopy.color = borderColor;
50405
+ } else {
50406
+ operationCopy.borderColor = borderColor;
50407
+ }
50408
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50409
+ } else {
50410
+ operations2[item.itemType].item.push(item.getId());
50411
+ }
50412
+ });
50413
+ Object.values(operations2).forEach((op) => {
50414
+ this.emit(op);
50415
+ });
50405
50416
  }
50406
50417
  setStrokeWidth(width2) {
50407
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50408
- if (shapes.length > 0) {
50409
- this.emit({
50410
- class: "Shape",
50411
- method: "setBorderWidth",
50412
- item: shapes,
50413
- borderWidth: width2,
50414
- prevBorderWidth: this.getStrokeWidth()
50415
- });
50416
- }
50417
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50418
- if (connectors.length > 0) {
50419
- this.emit({
50420
- class: "Connector",
50421
- method: "setLineWidth",
50422
- item: connectors,
50423
- lineWidth: width2
50424
- });
50425
- }
50426
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50427
- if (drawings.length > 0) {
50428
- this.emit({
50429
- class: "Drawing",
50430
- method: "setStrokeWidth",
50431
- item: drawings,
50432
- width: width2,
50433
- prevWidth: this.getStrokeWidth()
50434
- });
50435
- }
50418
+ const operation = {
50419
+ class: "Shape",
50420
+ method: "setStrokeWidth",
50421
+ item: [],
50422
+ width: width2,
50423
+ newData: { width: width2 }
50424
+ };
50425
+ const operations2 = {};
50426
+ this.items.list().forEach((item) => {
50427
+ if (!operations2[item.itemType]) {
50428
+ const operationCopy = { ...operation };
50429
+ if (item.itemType === "Connector") {
50430
+ operationCopy.method = "setLineWidth";
50431
+ operationCopy.lineWidth = width2;
50432
+ } else if (item.itemType === "Drawing") {
50433
+ operationCopy.method = "setStrokeWidth";
50434
+ operationCopy.width = width2;
50435
+ operationCopy.prevWidth = this.getStrokeWidth();
50436
+ } else {
50437
+ operationCopy.borderWidth = width2;
50438
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
50439
+ }
50440
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50441
+ } else {
50442
+ operations2[item.itemType].item.push(item.getId());
50443
+ }
50444
+ });
50445
+ Object.values(operations2).forEach((op) => {
50446
+ this.emit(op);
50447
+ });
50436
50448
  }
50437
50449
  setFillColor(backgroundColor) {
50438
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50439
- if (shapes.length) {
50440
- this.emit({
50441
- class: "Shape",
50442
- method: "setBackgroundColor",
50443
- item: shapes,
50444
- backgroundColor
50445
- });
50446
- }
50447
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50448
- if (stickers.length) {
50449
- this.emit({
50450
- class: "Sticker",
50451
- method: "setBackgroundColor",
50452
- item: stickers,
50453
- backgroundColor
50454
- });
50455
- }
50456
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50457
- if (frames.length) {
50458
- this.emit({
50459
- class: "Frame",
50460
- method: "setBackgroundColor",
50461
- item: frames,
50462
- backgroundColor
50463
- });
50464
- }
50450
+ const operation = {
50451
+ class: "Shape",
50452
+ method: "setBackgroundColor",
50453
+ item: [],
50454
+ backgroundColor,
50455
+ newData: { backgroundColor }
50456
+ };
50457
+ const operations2 = {};
50458
+ this.items.list().forEach((item) => {
50459
+ if (!operations2[item.itemType]) {
50460
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
50461
+ } else {
50462
+ operations2[item.itemType].item.push(item.getId());
50463
+ }
50464
+ });
50465
+ Object.values(operations2).forEach((op) => {
50466
+ this.emit(op);
50467
+ });
50465
50468
  }
50466
50469
  setCanChangeRatio(canChangeRatio) {
50467
50470
  const frames = this.items.getIdsByItemTypes(["Frame"]);