microboard-temp 0.4.28 → 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
  }
@@ -50526,93 +50536,85 @@ class BoardSelection {
50526
50536
  }
50527
50537
  }
50528
50538
  setStrokeColor(borderColor) {
50529
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50530
- if (shapes.length > 0) {
50531
- this.emit({
50532
- class: "Shape",
50533
- method: "setBorderColor",
50534
- item: shapes,
50535
- borderColor
50536
- });
50537
- }
50538
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50539
- if (connectors.length > 0) {
50540
- this.emit({
50541
- class: "Connector",
50542
- method: "setLineColor",
50543
- item: connectors,
50544
- lineColor: borderColor
50545
- });
50546
- }
50547
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50548
- if (drawings.length > 0) {
50549
- this.emit({
50550
- class: "Drawing",
50551
- method: "setStrokeColor",
50552
- item: drawings,
50553
- color: borderColor
50554
- });
50555
- }
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
+ });
50556
50566
  }
50557
50567
  setStrokeWidth(width2) {
50558
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50559
- if (shapes.length > 0) {
50560
- this.emit({
50561
- class: "Shape",
50562
- method: "setBorderWidth",
50563
- item: shapes,
50564
- borderWidth: width2,
50565
- prevBorderWidth: this.getStrokeWidth()
50566
- });
50567
- }
50568
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50569
- if (connectors.length > 0) {
50570
- this.emit({
50571
- class: "Connector",
50572
- method: "setLineWidth",
50573
- item: connectors,
50574
- lineWidth: width2
50575
- });
50576
- }
50577
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50578
- if (drawings.length > 0) {
50579
- this.emit({
50580
- class: "Drawing",
50581
- method: "setStrokeWidth",
50582
- item: drawings,
50583
- width: width2,
50584
- prevWidth: this.getStrokeWidth()
50585
- });
50586
- }
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
+ });
50587
50598
  }
50588
50599
  setFillColor(backgroundColor) {
50589
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50590
- if (shapes.length) {
50591
- this.emit({
50592
- class: "Shape",
50593
- method: "setBackgroundColor",
50594
- item: shapes,
50595
- backgroundColor
50596
- });
50597
- }
50598
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50599
- if (stickers.length) {
50600
- this.emit({
50601
- class: "Sticker",
50602
- method: "setBackgroundColor",
50603
- item: stickers,
50604
- backgroundColor
50605
- });
50606
- }
50607
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50608
- if (frames.length) {
50609
- this.emit({
50610
- class: "Frame",
50611
- method: "setBackgroundColor",
50612
- item: frames,
50613
- backgroundColor
50614
- });
50615
- }
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
+ });
50616
50618
  }
50617
50619
  setCanChangeRatio(canChangeRatio) {
50618
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
  }
@@ -50526,93 +50536,85 @@ class BoardSelection {
50526
50536
  }
50527
50537
  }
50528
50538
  setStrokeColor(borderColor) {
50529
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50530
- if (shapes.length > 0) {
50531
- this.emit({
50532
- class: "Shape",
50533
- method: "setBorderColor",
50534
- item: shapes,
50535
- borderColor
50536
- });
50537
- }
50538
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50539
- if (connectors.length > 0) {
50540
- this.emit({
50541
- class: "Connector",
50542
- method: "setLineColor",
50543
- item: connectors,
50544
- lineColor: borderColor
50545
- });
50546
- }
50547
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50548
- if (drawings.length > 0) {
50549
- this.emit({
50550
- class: "Drawing",
50551
- method: "setStrokeColor",
50552
- item: drawings,
50553
- color: borderColor
50554
- });
50555
- }
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
+ });
50556
50566
  }
50557
50567
  setStrokeWidth(width2) {
50558
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50559
- if (shapes.length > 0) {
50560
- this.emit({
50561
- class: "Shape",
50562
- method: "setBorderWidth",
50563
- item: shapes,
50564
- borderWidth: width2,
50565
- prevBorderWidth: this.getStrokeWidth()
50566
- });
50567
- }
50568
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50569
- if (connectors.length > 0) {
50570
- this.emit({
50571
- class: "Connector",
50572
- method: "setLineWidth",
50573
- item: connectors,
50574
- lineWidth: width2
50575
- });
50576
- }
50577
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50578
- if (drawings.length > 0) {
50579
- this.emit({
50580
- class: "Drawing",
50581
- method: "setStrokeWidth",
50582
- item: drawings,
50583
- width: width2,
50584
- prevWidth: this.getStrokeWidth()
50585
- });
50586
- }
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
+ });
50587
50598
  }
50588
50599
  setFillColor(backgroundColor) {
50589
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50590
- if (shapes.length) {
50591
- this.emit({
50592
- class: "Shape",
50593
- method: "setBackgroundColor",
50594
- item: shapes,
50595
- backgroundColor
50596
- });
50597
- }
50598
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50599
- if (stickers.length) {
50600
- this.emit({
50601
- class: "Sticker",
50602
- method: "setBackgroundColor",
50603
- item: stickers,
50604
- backgroundColor
50605
- });
50606
- }
50607
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50608
- if (frames.length) {
50609
- this.emit({
50610
- class: "Frame",
50611
- method: "setBackgroundColor",
50612
- item: frames,
50613
- backgroundColor
50614
- });
50615
- }
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
+ });
50616
50618
  }
50617
50619
  setCanChangeRatio(canChangeRatio) {
50618
50620
  const frames = this.items.getIdsByItemTypes(["Frame"]);
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
  }
@@ -53066,93 +53076,85 @@ class BoardSelection {
53066
53076
  }
53067
53077
  }
53068
53078
  setStrokeColor(borderColor) {
53069
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53070
- if (shapes.length > 0) {
53071
- this.emit({
53072
- class: "Shape",
53073
- method: "setBorderColor",
53074
- item: shapes,
53075
- borderColor
53076
- });
53077
- }
53078
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
53079
- if (connectors.length > 0) {
53080
- this.emit({
53081
- class: "Connector",
53082
- method: "setLineColor",
53083
- item: connectors,
53084
- lineColor: borderColor
53085
- });
53086
- }
53087
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
53088
- if (drawings.length > 0) {
53089
- this.emit({
53090
- class: "Drawing",
53091
- method: "setStrokeColor",
53092
- item: drawings,
53093
- color: borderColor
53094
- });
53095
- }
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
+ });
53096
53106
  }
53097
53107
  setStrokeWidth(width2) {
53098
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53099
- if (shapes.length > 0) {
53100
- this.emit({
53101
- class: "Shape",
53102
- method: "setBorderWidth",
53103
- item: shapes,
53104
- borderWidth: width2,
53105
- prevBorderWidth: this.getStrokeWidth()
53106
- });
53107
- }
53108
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
53109
- if (connectors.length > 0) {
53110
- this.emit({
53111
- class: "Connector",
53112
- method: "setLineWidth",
53113
- item: connectors,
53114
- lineWidth: width2
53115
- });
53116
- }
53117
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
53118
- if (drawings.length > 0) {
53119
- this.emit({
53120
- class: "Drawing",
53121
- method: "setStrokeWidth",
53122
- item: drawings,
53123
- width: width2,
53124
- prevWidth: this.getStrokeWidth()
53125
- });
53126
- }
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
+ });
53127
53138
  }
53128
53139
  setFillColor(backgroundColor) {
53129
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
53130
- if (shapes.length) {
53131
- this.emit({
53132
- class: "Shape",
53133
- method: "setBackgroundColor",
53134
- item: shapes,
53135
- backgroundColor
53136
- });
53137
- }
53138
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
53139
- if (stickers.length) {
53140
- this.emit({
53141
- class: "Sticker",
53142
- method: "setBackgroundColor",
53143
- item: stickers,
53144
- backgroundColor
53145
- });
53146
- }
53147
- const frames = this.items.getIdsByItemTypes(["Frame"]);
53148
- if (frames.length) {
53149
- this.emit({
53150
- class: "Frame",
53151
- method: "setBackgroundColor",
53152
- item: frames,
53153
- backgroundColor
53154
- });
53155
- }
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
+ });
53156
53158
  }
53157
53159
  setCanChangeRatio(canChangeRatio) {
53158
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
  }
@@ -50376,93 +50386,85 @@ class BoardSelection {
50376
50386
  }
50377
50387
  }
50378
50388
  setStrokeColor(borderColor) {
50379
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50380
- if (shapes.length > 0) {
50381
- this.emit({
50382
- class: "Shape",
50383
- method: "setBorderColor",
50384
- item: shapes,
50385
- borderColor
50386
- });
50387
- }
50388
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50389
- if (connectors.length > 0) {
50390
- this.emit({
50391
- class: "Connector",
50392
- method: "setLineColor",
50393
- item: connectors,
50394
- lineColor: borderColor
50395
- });
50396
- }
50397
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50398
- if (drawings.length > 0) {
50399
- this.emit({
50400
- class: "Drawing",
50401
- method: "setStrokeColor",
50402
- item: drawings,
50403
- color: borderColor
50404
- });
50405
- }
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
+ });
50406
50416
  }
50407
50417
  setStrokeWidth(width2) {
50408
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50409
- if (shapes.length > 0) {
50410
- this.emit({
50411
- class: "Shape",
50412
- method: "setBorderWidth",
50413
- item: shapes,
50414
- borderWidth: width2,
50415
- prevBorderWidth: this.getStrokeWidth()
50416
- });
50417
- }
50418
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50419
- if (connectors.length > 0) {
50420
- this.emit({
50421
- class: "Connector",
50422
- method: "setLineWidth",
50423
- item: connectors,
50424
- lineWidth: width2
50425
- });
50426
- }
50427
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50428
- if (drawings.length > 0) {
50429
- this.emit({
50430
- class: "Drawing",
50431
- method: "setStrokeWidth",
50432
- item: drawings,
50433
- width: width2,
50434
- prevWidth: this.getStrokeWidth()
50435
- });
50436
- }
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
+ });
50437
50448
  }
50438
50449
  setFillColor(backgroundColor) {
50439
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50440
- if (shapes.length) {
50441
- this.emit({
50442
- class: "Shape",
50443
- method: "setBackgroundColor",
50444
- item: shapes,
50445
- backgroundColor
50446
- });
50447
- }
50448
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50449
- if (stickers.length) {
50450
- this.emit({
50451
- class: "Sticker",
50452
- method: "setBackgroundColor",
50453
- item: stickers,
50454
- backgroundColor
50455
- });
50456
- }
50457
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50458
- if (frames.length) {
50459
- this.emit({
50460
- class: "Frame",
50461
- method: "setBackgroundColor",
50462
- item: frames,
50463
- backgroundColor
50464
- });
50465
- }
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
+ });
50466
50468
  }
50467
50469
  setCanChangeRatio(canChangeRatio) {
50468
50470
  const frames = this.items.getIdsByItemTypes(["Frame"]);
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: op.prevData
19321
+ newData
19312
19322
  };
19313
19323
  });
19314
19324
  }
@@ -50369,93 +50379,85 @@ class BoardSelection {
50369
50379
  }
50370
50380
  }
50371
50381
  setStrokeColor(borderColor) {
50372
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50373
- if (shapes.length > 0) {
50374
- this.emit({
50375
- class: "Shape",
50376
- method: "setBorderColor",
50377
- item: shapes,
50378
- borderColor
50379
- });
50380
- }
50381
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50382
- if (connectors.length > 0) {
50383
- this.emit({
50384
- class: "Connector",
50385
- method: "setLineColor",
50386
- item: connectors,
50387
- lineColor: borderColor
50388
- });
50389
- }
50390
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50391
- if (drawings.length > 0) {
50392
- this.emit({
50393
- class: "Drawing",
50394
- method: "setStrokeColor",
50395
- item: drawings,
50396
- color: borderColor
50397
- });
50398
- }
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
+ });
50399
50409
  }
50400
50410
  setStrokeWidth(width2) {
50401
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50402
- if (shapes.length > 0) {
50403
- this.emit({
50404
- class: "Shape",
50405
- method: "setBorderWidth",
50406
- item: shapes,
50407
- borderWidth: width2,
50408
- prevBorderWidth: this.getStrokeWidth()
50409
- });
50410
- }
50411
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50412
- if (connectors.length > 0) {
50413
- this.emit({
50414
- class: "Connector",
50415
- method: "setLineWidth",
50416
- item: connectors,
50417
- lineWidth: width2
50418
- });
50419
- }
50420
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50421
- if (drawings.length > 0) {
50422
- this.emit({
50423
- class: "Drawing",
50424
- method: "setStrokeWidth",
50425
- item: drawings,
50426
- width: width2,
50427
- prevWidth: this.getStrokeWidth()
50428
- });
50429
- }
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
+ });
50430
50441
  }
50431
50442
  setFillColor(backgroundColor) {
50432
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
50433
- if (shapes.length) {
50434
- this.emit({
50435
- class: "Shape",
50436
- method: "setBackgroundColor",
50437
- item: shapes,
50438
- backgroundColor
50439
- });
50440
- }
50441
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50442
- if (stickers.length) {
50443
- this.emit({
50444
- class: "Sticker",
50445
- method: "setBackgroundColor",
50446
- item: stickers,
50447
- backgroundColor
50448
- });
50449
- }
50450
- const frames = this.items.getIdsByItemTypes(["Frame"]);
50451
- if (frames.length) {
50452
- this.emit({
50453
- class: "Frame",
50454
- method: "setBackgroundColor",
50455
- item: frames,
50456
- backgroundColor
50457
- });
50458
- }
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
+ });
50459
50461
  }
50460
50462
  setCanChangeRatio(canChangeRatio) {
50461
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: op.prevData
21855
+ newData
21846
21856
  };
21847
21857
  });
21848
21858
  }
@@ -52904,93 +52914,85 @@ class BoardSelection {
52904
52914
  }
52905
52915
  }
52906
52916
  setStrokeColor(borderColor) {
52907
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
52908
- if (shapes.length > 0) {
52909
- this.emit({
52910
- class: "Shape",
52911
- method: "setBorderColor",
52912
- item: shapes,
52913
- borderColor
52914
- });
52915
- }
52916
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
52917
- if (connectors.length > 0) {
52918
- this.emit({
52919
- class: "Connector",
52920
- method: "setLineColor",
52921
- item: connectors,
52922
- lineColor: borderColor
52923
- });
52924
- }
52925
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
52926
- if (drawings.length > 0) {
52927
- this.emit({
52928
- class: "Drawing",
52929
- method: "setStrokeColor",
52930
- item: drawings,
52931
- color: borderColor
52932
- });
52933
- }
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
+ });
52934
52944
  }
52935
52945
  setStrokeWidth(width2) {
52936
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
52937
- if (shapes.length > 0) {
52938
- this.emit({
52939
- class: "Shape",
52940
- method: "setBorderWidth",
52941
- item: shapes,
52942
- borderWidth: width2,
52943
- prevBorderWidth: this.getStrokeWidth()
52944
- });
52945
- }
52946
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
52947
- if (connectors.length > 0) {
52948
- this.emit({
52949
- class: "Connector",
52950
- method: "setLineWidth",
52951
- item: connectors,
52952
- lineWidth: width2
52953
- });
52954
- }
52955
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
52956
- if (drawings.length > 0) {
52957
- this.emit({
52958
- class: "Drawing",
52959
- method: "setStrokeWidth",
52960
- item: drawings,
52961
- width: width2,
52962
- prevWidth: this.getStrokeWidth()
52963
- });
52964
- }
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
+ });
52965
52976
  }
52966
52977
  setFillColor(backgroundColor) {
52967
- const shapes = this.items.getIdsByItemTypes(["Shape"]);
52968
- if (shapes.length) {
52969
- this.emit({
52970
- class: "Shape",
52971
- method: "setBackgroundColor",
52972
- item: shapes,
52973
- backgroundColor
52974
- });
52975
- }
52976
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
52977
- if (stickers.length) {
52978
- this.emit({
52979
- class: "Sticker",
52980
- method: "setBackgroundColor",
52981
- item: stickers,
52982
- backgroundColor
52983
- });
52984
- }
52985
- const frames = this.items.getIdsByItemTypes(["Frame"]);
52986
- if (frames.length) {
52987
- this.emit({
52988
- class: "Frame",
52989
- method: "setBackgroundColor",
52990
- item: frames,
52991
- backgroundColor
52992
- });
52993
- }
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
+ });
52994
52996
  }
52995
52997
  setCanChangeRatio(canChangeRatio) {
52996
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: T;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",