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.
@@ -19463,9 +19463,19 @@ class BaseCommand {
19463
19463
  const items = this.items;
19464
19464
  return mapItemsByOperation(items, (item) => {
19465
19465
  const op = this.operation;
19466
+ let newData = {};
19467
+ if (op.prevData) {
19468
+ newData = op.prevData;
19469
+ } else {
19470
+ Object.keys(op.newData).forEach((key) => {
19471
+ if (item[key]) {
19472
+ op.newData[key] = item[key];
19473
+ }
19474
+ });
19475
+ }
19466
19476
  return {
19467
19477
  ...op,
19468
- newData: op.prevData
19478
+ newData
19469
19479
  };
19470
19480
  });
19471
19481
  }
@@ -46257,7 +46267,7 @@ class Dice extends BaseItem {
46257
46267
  if (values2) {
46258
46268
  this.values = values2;
46259
46269
  }
46260
- this.createRenderValues();
46270
+ this.updateRenderValues();
46261
46271
  this.transformPath();
46262
46272
  this.transformation.subject.subscribe(() => {
46263
46273
  this.transformPath();
@@ -46273,7 +46283,7 @@ class Dice extends BaseItem {
46273
46283
  this.path.setBorderColor(this.borderColor);
46274
46284
  this.path.setBorderWidth(this.borderWidth);
46275
46285
  }
46276
- createRenderValues() {
46286
+ updateRenderValues() {
46277
46287
  this.values.forEach((value, index2) => {
46278
46288
  if (typeof value === "number") {
46279
46289
  this.renderValues[index2] = value;
@@ -46348,7 +46358,7 @@ class Dice extends BaseItem {
46348
46358
  }
46349
46359
  deserialize(data) {
46350
46360
  super.deserialize(data);
46351
- this.createRenderValues();
46361
+ this.updateRenderValues();
46352
46362
  this.transformPath();
46353
46363
  this.subject.publish(this);
46354
46364
  return this;
@@ -46455,6 +46465,7 @@ class Dice extends BaseItem {
46455
46465
  this.valueIndex = 0;
46456
46466
  }
46457
46467
  this.values = op.newData.values;
46468
+ this.updateRenderValues();
46458
46469
  break;
46459
46470
  }
46460
46471
  break;
@@ -50525,93 +50536,85 @@ class BoardSelection {
50525
50536
  }
50526
50537
  }
50527
50538
  setStrokeColor(borderColor) {
50528
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50529
- if (shapes.length > 0) {
50530
- this.emit({
50531
- class: "Shape",
50532
- method: "setBorderColor",
50533
- item: shapes,
50534
- borderColor
50535
- });
50536
- }
50537
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50538
- if (connectors.length > 0) {
50539
- this.emit({
50540
- class: "Connector",
50541
- method: "setLineColor",
50542
- item: connectors,
50543
- lineColor: borderColor
50544
- });
50545
- }
50546
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50547
- if (drawings.length > 0) {
50548
- this.emit({
50549
- class: "Drawing",
50550
- method: "setStrokeColor",
50551
- item: drawings,
50552
- color: borderColor
50553
- });
50554
- }
50539
+ const operation = {
50540
+ class: "Shape",
50541
+ method: "setBorderColor",
50542
+ item: [],
50543
+ newData: { borderColor }
50544
+ };
50545
+ const operations2 = {};
50546
+ this.items.list().forEach((item) => {
50547
+ if (!operations2[item.itemType]) {
50548
+ const operationCopy = { ...operation };
50549
+ if (item.itemType === "Connector") {
50550
+ operationCopy.method = "setLineColor";
50551
+ operationCopy.lineColor = borderColor;
50552
+ } else if (item.itemType === "Drawing") {
50553
+ operationCopy.method = "setStrokeColor";
50554
+ operationCopy.color = borderColor;
50555
+ } else {
50556
+ operationCopy.borderColor = borderColor;
50557
+ }
50558
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50559
+ } else {
50560
+ operations2[item.itemType].item.push(item.getId());
50561
+ }
50562
+ });
50563
+ Object.values(operations2).forEach((op) => {
50564
+ this.emit(op);
50565
+ });
50555
50566
  }
50556
50567
  setStrokeWidth(width2) {
50557
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50558
- if (shapes.length > 0) {
50559
- this.emit({
50560
- class: "Shape",
50561
- method: "setBorderWidth",
50562
- item: shapes,
50563
- borderWidth: width2,
50564
- prevBorderWidth: this.getStrokeWidth()
50565
- });
50566
- }
50567
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50568
- if (connectors.length > 0) {
50569
- this.emit({
50570
- class: "Connector",
50571
- method: "setLineWidth",
50572
- item: connectors,
50573
- lineWidth: width2
50574
- });
50575
- }
50576
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50577
- if (drawings.length > 0) {
50578
- this.emit({
50579
- class: "Drawing",
50580
- method: "setStrokeWidth",
50581
- item: drawings,
50582
- width: width2,
50583
- prevWidth: this.getStrokeWidth()
50584
- });
50585
- }
50568
+ const operation = {
50569
+ class: "Shape",
50570
+ method: "setStrokeWidth",
50571
+ item: [],
50572
+ width: width2,
50573
+ newData: { width: width2 }
50574
+ };
50575
+ const operations2 = {};
50576
+ this.items.list().forEach((item) => {
50577
+ if (!operations2[item.itemType]) {
50578
+ const operationCopy = { ...operation };
50579
+ if (item.itemType === "Connector") {
50580
+ operationCopy.method = "setLineWidth";
50581
+ operationCopy.lineWidth = width2;
50582
+ } else if (item.itemType === "Drawing") {
50583
+ operationCopy.method = "setStrokeWidth";
50584
+ operationCopy.width = width2;
50585
+ operationCopy.prevWidth = this.getStrokeWidth();
50586
+ } else {
50587
+ operationCopy.borderWidth = width2;
50588
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
50589
+ }
50590
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50591
+ } else {
50592
+ operations2[item.itemType].item.push(item.getId());
50593
+ }
50594
+ });
50595
+ Object.values(operations2).forEach((op) => {
50596
+ this.emit(op);
50597
+ });
50586
50598
  }
50587
50599
  setFillColor(backgroundColor) {
50588
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50589
- if (shapes.length) {
50590
- this.emit({
50591
- class: "Shape",
50592
- method: "setBackgroundColor",
50593
- item: shapes,
50594
- backgroundColor
50595
- });
50596
- }
50597
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50598
- if (stickers.length) {
50599
- this.emit({
50600
- class: "Sticker",
50601
- method: "setBackgroundColor",
50602
- item: stickers,
50603
- backgroundColor
50604
- });
50605
- }
50606
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50607
- if (frames.length) {
50608
- this.emit({
50609
- class: "Frame",
50610
- method: "setBackgroundColor",
50611
- item: frames,
50612
- backgroundColor
50613
- });
50614
- }
50600
+ const operation = {
50601
+ class: "Shape",
50602
+ method: "setBackgroundColor",
50603
+ item: [],
50604
+ backgroundColor,
50605
+ newData: { backgroundColor }
50606
+ };
50607
+ const operations2 = {};
50608
+ this.items.list().forEach((item) => {
50609
+ if (!operations2[item.itemType]) {
50610
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
50611
+ } else {
50612
+ operations2[item.itemType].item.push(item.getId());
50613
+ }
50614
+ });
50615
+ Object.values(operations2).forEach((op) => {
50616
+ this.emit(op);
50617
+ });
50615
50618
  }
50616
50619
  setCanChangeRatio(canChangeRatio) {
50617
50620
  const frames = this.items.getIdsByItemTypes(["Frame"]);
package/dist/cjs/index.js CHANGED
@@ -19463,9 +19463,19 @@ class BaseCommand {
19463
19463
  const items = this.items;
19464
19464
  return mapItemsByOperation(items, (item) => {
19465
19465
  const op = this.operation;
19466
+ let newData = {};
19467
+ if (op.prevData) {
19468
+ newData = op.prevData;
19469
+ } else {
19470
+ Object.keys(op.newData).forEach((key) => {
19471
+ if (item[key]) {
19472
+ op.newData[key] = item[key];
19473
+ }
19474
+ });
19475
+ }
19466
19476
  return {
19467
19477
  ...op,
19468
- newData: op.prevData
19478
+ newData
19469
19479
  };
19470
19480
  });
19471
19481
  }
@@ -46257,7 +46267,7 @@ class Dice extends BaseItem {
46257
46267
  if (values2) {
46258
46268
  this.values = values2;
46259
46269
  }
46260
- this.createRenderValues();
46270
+ this.updateRenderValues();
46261
46271
  this.transformPath();
46262
46272
  this.transformation.subject.subscribe(() => {
46263
46273
  this.transformPath();
@@ -46273,7 +46283,7 @@ class Dice extends BaseItem {
46273
46283
  this.path.setBorderColor(this.borderColor);
46274
46284
  this.path.setBorderWidth(this.borderWidth);
46275
46285
  }
46276
- createRenderValues() {
46286
+ updateRenderValues() {
46277
46287
  this.values.forEach((value, index2) => {
46278
46288
  if (typeof value === "number") {
46279
46289
  this.renderValues[index2] = value;
@@ -46348,7 +46358,7 @@ class Dice extends BaseItem {
46348
46358
  }
46349
46359
  deserialize(data) {
46350
46360
  super.deserialize(data);
46351
- this.createRenderValues();
46361
+ this.updateRenderValues();
46352
46362
  this.transformPath();
46353
46363
  this.subject.publish(this);
46354
46364
  return this;
@@ -46455,6 +46465,7 @@ class Dice extends BaseItem {
46455
46465
  this.valueIndex = 0;
46456
46466
  }
46457
46467
  this.values = op.newData.values;
46468
+ this.updateRenderValues();
46458
46469
  break;
46459
46470
  }
46460
46471
  break;
@@ -50525,93 +50536,85 @@ class BoardSelection {
50525
50536
  }
50526
50537
  }
50527
50538
  setStrokeColor(borderColor) {
50528
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50529
- if (shapes.length > 0) {
50530
- this.emit({
50531
- class: "Shape",
50532
- method: "setBorderColor",
50533
- item: shapes,
50534
- borderColor
50535
- });
50536
- }
50537
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50538
- if (connectors.length > 0) {
50539
- this.emit({
50540
- class: "Connector",
50541
- method: "setLineColor",
50542
- item: connectors,
50543
- lineColor: borderColor
50544
- });
50545
- }
50546
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50547
- if (drawings.length > 0) {
50548
- this.emit({
50549
- class: "Drawing",
50550
- method: "setStrokeColor",
50551
- item: drawings,
50552
- color: borderColor
50553
- });
50554
- }
50539
+ const operation = {
50540
+ class: "Shape",
50541
+ method: "setBorderColor",
50542
+ item: [],
50543
+ newData: { borderColor }
50544
+ };
50545
+ const operations2 = {};
50546
+ this.items.list().forEach((item) => {
50547
+ if (!operations2[item.itemType]) {
50548
+ const operationCopy = { ...operation };
50549
+ if (item.itemType === "Connector") {
50550
+ operationCopy.method = "setLineColor";
50551
+ operationCopy.lineColor = borderColor;
50552
+ } else if (item.itemType === "Drawing") {
50553
+ operationCopy.method = "setStrokeColor";
50554
+ operationCopy.color = borderColor;
50555
+ } else {
50556
+ operationCopy.borderColor = borderColor;
50557
+ }
50558
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50559
+ } else {
50560
+ operations2[item.itemType].item.push(item.getId());
50561
+ }
50562
+ });
50563
+ Object.values(operations2).forEach((op) => {
50564
+ this.emit(op);
50565
+ });
50555
50566
  }
50556
50567
  setStrokeWidth(width2) {
50557
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50558
- if (shapes.length > 0) {
50559
- this.emit({
50560
- class: "Shape",
50561
- method: "setBorderWidth",
50562
- item: shapes,
50563
- borderWidth: width2,
50564
- prevBorderWidth: this.getStrokeWidth()
50565
- });
50566
- }
50567
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50568
- if (connectors.length > 0) {
50569
- this.emit({
50570
- class: "Connector",
50571
- method: "setLineWidth",
50572
- item: connectors,
50573
- lineWidth: width2
50574
- });
50575
- }
50576
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50577
- if (drawings.length > 0) {
50578
- this.emit({
50579
- class: "Drawing",
50580
- method: "setStrokeWidth",
50581
- item: drawings,
50582
- width: width2,
50583
- prevWidth: this.getStrokeWidth()
50584
- });
50585
- }
50568
+ const operation = {
50569
+ class: "Shape",
50570
+ method: "setStrokeWidth",
50571
+ item: [],
50572
+ width: width2,
50573
+ newData: { width: width2 }
50574
+ };
50575
+ const operations2 = {};
50576
+ this.items.list().forEach((item) => {
50577
+ if (!operations2[item.itemType]) {
50578
+ const operationCopy = { ...operation };
50579
+ if (item.itemType === "Connector") {
50580
+ operationCopy.method = "setLineWidth";
50581
+ operationCopy.lineWidth = width2;
50582
+ } else if (item.itemType === "Drawing") {
50583
+ operationCopy.method = "setStrokeWidth";
50584
+ operationCopy.width = width2;
50585
+ operationCopy.prevWidth = this.getStrokeWidth();
50586
+ } else {
50587
+ operationCopy.borderWidth = width2;
50588
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
50589
+ }
50590
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50591
+ } else {
50592
+ operations2[item.itemType].item.push(item.getId());
50593
+ }
50594
+ });
50595
+ Object.values(operations2).forEach((op) => {
50596
+ this.emit(op);
50597
+ });
50586
50598
  }
50587
50599
  setFillColor(backgroundColor) {
50588
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50589
- if (shapes.length) {
50590
- this.emit({
50591
- class: "Shape",
50592
- method: "setBackgroundColor",
50593
- item: shapes,
50594
- backgroundColor
50595
- });
50596
- }
50597
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50598
- if (stickers.length) {
50599
- this.emit({
50600
- class: "Sticker",
50601
- method: "setBackgroundColor",
50602
- item: stickers,
50603
- backgroundColor
50604
- });
50605
- }
50606
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50607
- if (frames.length) {
50608
- this.emit({
50609
- class: "Frame",
50610
- method: "setBackgroundColor",
50611
- item: frames,
50612
- backgroundColor
50613
- });
50614
- }
50600
+ const operation = {
50601
+ class: "Shape",
50602
+ method: "setBackgroundColor",
50603
+ item: [],
50604
+ backgroundColor,
50605
+ newData: { backgroundColor }
50606
+ };
50607
+ const operations2 = {};
50608
+ this.items.list().forEach((item) => {
50609
+ if (!operations2[item.itemType]) {
50610
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
50611
+ } else {
50612
+ operations2[item.itemType].item.push(item.getId());
50613
+ }
50614
+ });
50615
+ Object.values(operations2).forEach((op) => {
50616
+ this.emit(op);
50617
+ });
50615
50618
  }
50616
50619
  setCanChangeRatio(canChangeRatio) {
50617
50620
  const frames = this.items.getIdsByItemTypes(["Frame"]);