microboard-temp 0.4.28 → 0.4.30

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
  }
@@ -46365,6 +46375,18 @@ class Dice extends BaseItem {
46365
46375
  }
46366
46376
  return { min: this.values[0], max: this.values[this.values.length - 1] };
46367
46377
  }
46378
+ getBackgroundColor() {
46379
+ return this.backgroundColor;
46380
+ }
46381
+ getBorderStyle() {
46382
+ return this.borderStyle;
46383
+ }
46384
+ getStrokeColor() {
46385
+ return this.borderColor;
46386
+ }
46387
+ getStrokeWidth() {
46388
+ return this.borderWidth;
46389
+ }
46368
46390
  applyBackgroundColor(backgroundColor) {
46369
46391
  this.backgroundColor = backgroundColor;
46370
46392
  this.path.setBackgroundColor(backgroundColor);
@@ -50305,28 +50327,20 @@ class BoardSelection {
50305
50327
  return color2;
50306
50328
  }
50307
50329
  getFillColor() {
50308
- const tmp = this.items.getItemsByItemTypes([
50309
- "Shape",
50310
- "Sticker",
50311
- "Frame"
50312
- ])[0];
50313
- return tmp?.getBackgroundColor() || defaultShapeData2.backgroundColor;
50330
+ const tmp = this.items.list()[0];
50331
+ return "getBackgroundColor" in tmp ? tmp.getBackgroundColor() : defaultShapeData2.backgroundColor;
50314
50332
  }
50315
50333
  getBorderStyle() {
50316
- const shape = this.items.getItemsByItemTypes([
50317
- "Shape",
50318
- "Drawing",
50319
- "Connector"
50320
- ])[0];
50321
- return shape?.getBorderStyle() || defaultShapeData2.borderStyle;
50334
+ const shape = this.items.list()[0];
50335
+ return "getBorderStyle" in shape ? shape.getBorderStyle() : defaultShapeData2.borderStyle;
50322
50336
  }
50323
50337
  getStrokeColor() {
50324
- const shape = this.items.getItemsByItemTypes(["Shape", "Drawing"])[0];
50325
- return shape?.getStrokeColor() || defaultShapeData2.borderColor;
50338
+ const shape = this.items.list()[0];
50339
+ return "getStrokeColor" in shape ? shape.getStrokeColor() : defaultShapeData2.borderColor;
50326
50340
  }
50327
50341
  getStrokeWidth() {
50328
- const shape = this.items.getItemsByItemTypes(["Shape", "Drawing"])[0];
50329
- return shape?.getStrokeWidth() || defaultShapeData2.borderWidth;
50342
+ const shape = this.items.list()[0];
50343
+ return "getStrokeWidth" in shape ? shape.getStrokeWidth() : defaultShapeData2.borderWidth;
50330
50344
  }
50331
50345
  getConnectorLineWidth() {
50332
50346
  const connector = this.items.getItemsByItemTypes(["Connector"])[0];
@@ -50526,93 +50540,85 @@ class BoardSelection {
50526
50540
  }
50527
50541
  }
50528
50542
  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
- }
50543
+ const operation = {
50544
+ class: "Shape",
50545
+ method: "setBorderColor",
50546
+ item: [],
50547
+ newData: { borderColor }
50548
+ };
50549
+ const operations2 = {};
50550
+ this.items.list().forEach((item) => {
50551
+ if (!operations2[item.itemType]) {
50552
+ const operationCopy = { ...operation };
50553
+ if (item.itemType === "Connector") {
50554
+ operationCopy.method = "setLineColor";
50555
+ operationCopy.lineColor = borderColor;
50556
+ } else if (item.itemType === "Drawing") {
50557
+ operationCopy.method = "setStrokeColor";
50558
+ operationCopy.color = borderColor;
50559
+ } else {
50560
+ operationCopy.borderColor = borderColor;
50561
+ }
50562
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50563
+ } else {
50564
+ operations2[item.itemType].item.push(item.getId());
50565
+ }
50566
+ });
50567
+ Object.values(operations2).forEach((op) => {
50568
+ this.emit(op);
50569
+ });
50556
50570
  }
50557
50571
  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
- }
50572
+ const operation = {
50573
+ class: "Shape",
50574
+ method: "setStrokeWidth",
50575
+ item: [],
50576
+ width: width2,
50577
+ newData: { width: width2 }
50578
+ };
50579
+ const operations2 = {};
50580
+ this.items.list().forEach((item) => {
50581
+ if (!operations2[item.itemType]) {
50582
+ const operationCopy = { ...operation };
50583
+ if (item.itemType === "Connector") {
50584
+ operationCopy.method = "setLineWidth";
50585
+ operationCopy.lineWidth = width2;
50586
+ } else if (item.itemType === "Drawing") {
50587
+ operationCopy.method = "setStrokeWidth";
50588
+ operationCopy.width = width2;
50589
+ operationCopy.prevWidth = this.getStrokeWidth();
50590
+ } else {
50591
+ operationCopy.borderWidth = width2;
50592
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
50593
+ }
50594
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50595
+ } else {
50596
+ operations2[item.itemType].item.push(item.getId());
50597
+ }
50598
+ });
50599
+ Object.values(operations2).forEach((op) => {
50600
+ this.emit(op);
50601
+ });
50587
50602
  }
50588
50603
  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
- }
50604
+ const operation = {
50605
+ class: "Shape",
50606
+ method: "setBackgroundColor",
50607
+ item: [],
50608
+ backgroundColor,
50609
+ newData: { backgroundColor }
50610
+ };
50611
+ const operations2 = {};
50612
+ this.items.list().forEach((item) => {
50613
+ if (!operations2[item.itemType]) {
50614
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
50615
+ } else {
50616
+ operations2[item.itemType].item.push(item.getId());
50617
+ }
50618
+ });
50619
+ Object.values(operations2).forEach((op) => {
50620
+ this.emit(op);
50621
+ });
50616
50622
  }
50617
50623
  setCanChangeRatio(canChangeRatio) {
50618
50624
  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
  }
@@ -46365,6 +46375,18 @@ class Dice extends BaseItem {
46365
46375
  }
46366
46376
  return { min: this.values[0], max: this.values[this.values.length - 1] };
46367
46377
  }
46378
+ getBackgroundColor() {
46379
+ return this.backgroundColor;
46380
+ }
46381
+ getBorderStyle() {
46382
+ return this.borderStyle;
46383
+ }
46384
+ getStrokeColor() {
46385
+ return this.borderColor;
46386
+ }
46387
+ getStrokeWidth() {
46388
+ return this.borderWidth;
46389
+ }
46368
46390
  applyBackgroundColor(backgroundColor) {
46369
46391
  this.backgroundColor = backgroundColor;
46370
46392
  this.path.setBackgroundColor(backgroundColor);
@@ -50305,28 +50327,20 @@ class BoardSelection {
50305
50327
  return color2;
50306
50328
  }
50307
50329
  getFillColor() {
50308
- const tmp = this.items.getItemsByItemTypes([
50309
- "Shape",
50310
- "Sticker",
50311
- "Frame"
50312
- ])[0];
50313
- return tmp?.getBackgroundColor() || defaultShapeData2.backgroundColor;
50330
+ const tmp = this.items.list()[0];
50331
+ return "getBackgroundColor" in tmp ? tmp.getBackgroundColor() : defaultShapeData2.backgroundColor;
50314
50332
  }
50315
50333
  getBorderStyle() {
50316
- const shape = this.items.getItemsByItemTypes([
50317
- "Shape",
50318
- "Drawing",
50319
- "Connector"
50320
- ])[0];
50321
- return shape?.getBorderStyle() || defaultShapeData2.borderStyle;
50334
+ const shape = this.items.list()[0];
50335
+ return "getBorderStyle" in shape ? shape.getBorderStyle() : defaultShapeData2.borderStyle;
50322
50336
  }
50323
50337
  getStrokeColor() {
50324
- const shape = this.items.getItemsByItemTypes(["Shape", "Drawing"])[0];
50325
- return shape?.getStrokeColor() || defaultShapeData2.borderColor;
50338
+ const shape = this.items.list()[0];
50339
+ return "getStrokeColor" in shape ? shape.getStrokeColor() : defaultShapeData2.borderColor;
50326
50340
  }
50327
50341
  getStrokeWidth() {
50328
- const shape = this.items.getItemsByItemTypes(["Shape", "Drawing"])[0];
50329
- return shape?.getStrokeWidth() || defaultShapeData2.borderWidth;
50342
+ const shape = this.items.list()[0];
50343
+ return "getStrokeWidth" in shape ? shape.getStrokeWidth() : defaultShapeData2.borderWidth;
50330
50344
  }
50331
50345
  getConnectorLineWidth() {
50332
50346
  const connector = this.items.getItemsByItemTypes(["Connector"])[0];
@@ -50526,93 +50540,85 @@ class BoardSelection {
50526
50540
  }
50527
50541
  }
50528
50542
  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
- }
50543
+ const operation = {
50544
+ class: "Shape",
50545
+ method: "setBorderColor",
50546
+ item: [],
50547
+ newData: { borderColor }
50548
+ };
50549
+ const operations2 = {};
50550
+ this.items.list().forEach((item) => {
50551
+ if (!operations2[item.itemType]) {
50552
+ const operationCopy = { ...operation };
50553
+ if (item.itemType === "Connector") {
50554
+ operationCopy.method = "setLineColor";
50555
+ operationCopy.lineColor = borderColor;
50556
+ } else if (item.itemType === "Drawing") {
50557
+ operationCopy.method = "setStrokeColor";
50558
+ operationCopy.color = borderColor;
50559
+ } else {
50560
+ operationCopy.borderColor = borderColor;
50561
+ }
50562
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50563
+ } else {
50564
+ operations2[item.itemType].item.push(item.getId());
50565
+ }
50566
+ });
50567
+ Object.values(operations2).forEach((op) => {
50568
+ this.emit(op);
50569
+ });
50556
50570
  }
50557
50571
  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
- }
50572
+ const operation = {
50573
+ class: "Shape",
50574
+ method: "setStrokeWidth",
50575
+ item: [],
50576
+ width: width2,
50577
+ newData: { width: width2 }
50578
+ };
50579
+ const operations2 = {};
50580
+ this.items.list().forEach((item) => {
50581
+ if (!operations2[item.itemType]) {
50582
+ const operationCopy = { ...operation };
50583
+ if (item.itemType === "Connector") {
50584
+ operationCopy.method = "setLineWidth";
50585
+ operationCopy.lineWidth = width2;
50586
+ } else if (item.itemType === "Drawing") {
50587
+ operationCopy.method = "setStrokeWidth";
50588
+ operationCopy.width = width2;
50589
+ operationCopy.prevWidth = this.getStrokeWidth();
50590
+ } else {
50591
+ operationCopy.borderWidth = width2;
50592
+ operationCopy.prevBorderWidth = this.getStrokeWidth();
50593
+ }
50594
+ operations2[item.itemType] = { ...operationCopy, class: item.itemType, item: [item.getId()] };
50595
+ } else {
50596
+ operations2[item.itemType].item.push(item.getId());
50597
+ }
50598
+ });
50599
+ Object.values(operations2).forEach((op) => {
50600
+ this.emit(op);
50601
+ });
50587
50602
  }
50588
50603
  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
- }
50604
+ const operation = {
50605
+ class: "Shape",
50606
+ method: "setBackgroundColor",
50607
+ item: [],
50608
+ backgroundColor,
50609
+ newData: { backgroundColor }
50610
+ };
50611
+ const operations2 = {};
50612
+ this.items.list().forEach((item) => {
50613
+ if (!operations2[item.itemType]) {
50614
+ operations2[item.itemType] = { ...operation, class: item.itemType, item: [item.getId()] };
50615
+ } else {
50616
+ operations2[item.itemType].item.push(item.getId());
50617
+ }
50618
+ });
50619
+ Object.values(operations2).forEach((op) => {
50620
+ this.emit(op);
50621
+ });
50616
50622
  }
50617
50623
  setCanChangeRatio(canChangeRatio) {
50618
50624
  const frames = this.items.getIdsByItemTypes(["Frame"]);