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/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
  }
@@ -46100,7 +46110,7 @@ class Dice extends BaseItem {
46100
46110
  if (values2) {
46101
46111
  this.values = values2;
46102
46112
  }
46103
- this.createRenderValues();
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
- createRenderValues() {
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.createRenderValues();
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
50372
- if (shapes.length > 0) {
50373
- this.emit({
50374
- class: "Shape",
50375
- method: "setBorderColor",
50376
- item: shapes,
50377
- borderColor
50378
- });
50379
- }
50380
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50381
- if (connectors.length > 0) {
50382
- this.emit({
50383
- class: "Connector",
50384
- method: "setLineColor",
50385
- item: connectors,
50386
- lineColor: borderColor
50387
- });
50388
- }
50389
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50390
- if (drawings.length > 0) {
50391
- this.emit({
50392
- class: "Drawing",
50393
- method: "setStrokeColor",
50394
- item: drawings,
50395
- color: borderColor
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
50401
- if (shapes.length > 0) {
50402
- this.emit({
50403
- class: "Shape",
50404
- method: "setBorderWidth",
50405
- item: shapes,
50406
- borderWidth: width2,
50407
- prevBorderWidth: this.getStrokeWidth()
50408
- });
50409
- }
50410
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
50411
- if (connectors.length > 0) {
50412
- this.emit({
50413
- class: "Connector",
50414
- method: "setLineWidth",
50415
- item: connectors,
50416
- lineWidth: width2
50417
- });
50418
- }
50419
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
50420
- if (drawings.length > 0) {
50421
- this.emit({
50422
- class: "Drawing",
50423
- method: "setStrokeWidth",
50424
- item: drawings,
50425
- width: width2,
50426
- prevWidth: this.getStrokeWidth()
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
50432
- if (shapes.length) {
50433
- this.emit({
50434
- class: "Shape",
50435
- method: "setBackgroundColor",
50436
- item: shapes,
50437
- backgroundColor
50438
- });
50439
- }
50440
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
50441
- if (stickers.length) {
50442
- this.emit({
50443
- class: "Sticker",
50444
- method: "setBackgroundColor",
50445
- item: stickers,
50446
- backgroundColor
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: op.prevData
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.createRenderValues();
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
- createRenderValues() {
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.createRenderValues();
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
52907
- if (shapes.length > 0) {
52908
- this.emit({
52909
- class: "Shape",
52910
- method: "setBorderColor",
52911
- item: shapes,
52912
- borderColor
52913
- });
52914
- }
52915
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
52916
- if (connectors.length > 0) {
52917
- this.emit({
52918
- class: "Connector",
52919
- method: "setLineColor",
52920
- item: connectors,
52921
- lineColor: borderColor
52922
- });
52923
- }
52924
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
52925
- if (drawings.length > 0) {
52926
- this.emit({
52927
- class: "Drawing",
52928
- method: "setStrokeColor",
52929
- item: drawings,
52930
- color: borderColor
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
52936
- if (shapes.length > 0) {
52937
- this.emit({
52938
- class: "Shape",
52939
- method: "setBorderWidth",
52940
- item: shapes,
52941
- borderWidth: width2,
52942
- prevBorderWidth: this.getStrokeWidth()
52943
- });
52944
- }
52945
- const connectors = this.items.getIdsByItemTypes(["Connector"]);
52946
- if (connectors.length > 0) {
52947
- this.emit({
52948
- class: "Connector",
52949
- method: "setLineWidth",
52950
- item: connectors,
52951
- lineWidth: width2
52952
- });
52953
- }
52954
- const drawings = this.items.getIdsByItemTypes(["Drawing"]);
52955
- if (drawings.length > 0) {
52956
- this.emit({
52957
- class: "Drawing",
52958
- method: "setStrokeWidth",
52959
- item: drawings,
52960
- width: width2,
52961
- prevWidth: this.getStrokeWidth()
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 shapes = this.items.getIdsByItemTypes(["Shape"]);
52967
- if (shapes.length) {
52968
- this.emit({
52969
- class: "Shape",
52970
- method: "setBackgroundColor",
52971
- item: shapes,
52972
- backgroundColor
52973
- });
52974
- }
52975
- const stickers = this.items.getIdsByItemTypes(["Sticker"]);
52976
- if (stickers.length) {
52977
- this.emit({
52978
- class: "Sticker",
52979
- method: "setBackgroundColor",
52980
- item: stickers,
52981
- backgroundColor
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: 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;
@@ -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[] | string[];
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[] | string[]);
21
+ constructor(board: Board, id?: string, type?: DiceType, values?: (number | string)[]);
22
22
  private transformPath;
23
- createRenderValues(): void;
23
+ updateRenderValues(): void;
24
24
  render(context: DrawingContext): void;
25
25
  updateMbr(): void;
26
26
  getPath(): Path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.27",
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",