microboard-temp 0.6.5 → 0.8.0

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.
Files changed (32) hide show
  1. package/dist/cjs/browser.js +252 -47
  2. package/dist/cjs/index.js +252 -47
  3. package/dist/cjs/node.js +252 -47
  4. package/dist/esm/browser.js +252 -47
  5. package/dist/esm/index.js +252 -47
  6. package/dist/esm/node.js +252 -47
  7. package/dist/types/Color/ColorValue.d.ts +54 -0
  8. package/dist/types/Color/ContrastPalette.d.ts +45 -0
  9. package/dist/types/Color/colorUtils.d.ts +32 -0
  10. package/dist/types/Color/index.d.ts +6 -0
  11. package/dist/types/Color/resolveColor.d.ts +26 -0
  12. package/dist/types/Items/Connector/Connector.d.ts +4 -3
  13. package/dist/types/Items/Connector/ConnectorOperations.d.ts +3 -2
  14. package/dist/types/Items/Drawing/Drawing.d.ts +5 -3
  15. package/dist/types/Items/Drawing/DrawingOperation.d.ts +2 -1
  16. package/dist/types/Items/Frame/Frame.d.ts +7 -6
  17. package/dist/types/Items/Frame/FrameData.d.ts +6 -5
  18. package/dist/types/Items/Frame/FrameOperation.d.ts +2 -1
  19. package/dist/types/Items/Mbr/Mbr.d.ts +3 -3
  20. package/dist/types/Items/RichText/CanvasText/Render.d.ts +2 -2
  21. package/dist/types/Items/RichText/Editor/TextNode.d.ts +3 -2
  22. package/dist/types/Items/RichText/RichText.d.ts +4 -4
  23. package/dist/types/Items/RichText/editorHelpers/selectionOps/applySelectionFontColor.d.ts +2 -1
  24. package/dist/types/Items/RichText/editorHelpers/selectionOps/setSelectionFontHighlight.d.ts +2 -1
  25. package/dist/types/Items/Shape/Shape.d.ts +9 -8
  26. package/dist/types/Items/Shape/ShapeData.d.ts +6 -5
  27. package/dist/types/Items/Shape/ShapeOperation.d.ts +3 -2
  28. package/dist/types/Items/Sticker/Sticker.d.ts +5 -4
  29. package/dist/types/Items/Sticker/StickerOperation.d.ts +4 -3
  30. package/dist/types/Settings.d.ts +7 -0
  31. package/dist/types/index.d.ts +1 -0
  32. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -608,6 +608,184 @@ var require_escape_html = __commonJS((exports, module) => {
608
608
  }
609
609
  });
610
610
 
611
+ // src/Color/ColorValue.ts
612
+ var SEMANTIC_COLOR_IDS = [
613
+ "contrastNeutral",
614
+ "contrastGray",
615
+ "contrastRed",
616
+ "contrastOrange",
617
+ "contrastYellow",
618
+ "contrastGreen",
619
+ "contrastTeal",
620
+ "contrastBlue",
621
+ "contrastPurple",
622
+ "contrastPink",
623
+ "contrastBrown"
624
+ ];
625
+ var semanticColor = (id) => ({
626
+ type: "semantic",
627
+ id
628
+ });
629
+ var fixedColor = (value) => ({
630
+ type: "fixed",
631
+ value
632
+ });
633
+ function coerceColorValue(value) {
634
+ if (typeof value === "string")
635
+ return fixedColor(value);
636
+ return value;
637
+ }
638
+ function coerceOptionalColorValue(value) {
639
+ if (value === undefined)
640
+ return;
641
+ return coerceColorValue(value);
642
+ }
643
+ // src/Color/ContrastPalette.ts
644
+ var CONTRAST_PALETTE = {
645
+ contrastNeutral: {
646
+ id: "contrastNeutral",
647
+ label: "Neutral",
648
+ light: "rgb(245, 246, 248)",
649
+ dark: "rgb(20, 21, 26)",
650
+ contrastRatio: 17.2
651
+ },
652
+ contrastGray: {
653
+ id: "contrastGray",
654
+ label: "Gray",
655
+ light: "rgb(224, 225, 229)",
656
+ dark: "rgb(55, 58, 70)",
657
+ contrastRatio: 8.6
658
+ },
659
+ contrastRed: {
660
+ id: "contrastRed",
661
+ label: "Red",
662
+ light: "rgb(255, 215, 210)",
663
+ dark: "rgb(120, 10, 10)",
664
+ contrastRatio: 8.5
665
+ },
666
+ contrastOrange: {
667
+ id: "contrastOrange",
668
+ label: "Orange",
669
+ light: "rgb(255, 229, 195)",
670
+ dark: "rgb(110, 44, 0)",
671
+ contrastRatio: 8.4
672
+ },
673
+ contrastYellow: {
674
+ id: "contrastYellow",
675
+ label: "Yellow",
676
+ light: "rgb(255, 249, 185)",
677
+ dark: "rgb(89, 71, 0)",
678
+ contrastRatio: 8.3
679
+ },
680
+ contrastGreen: {
681
+ id: "contrastGreen",
682
+ label: "Green",
683
+ light: "rgb(193, 243, 179)",
684
+ dark: "rgb(0, 74, 22)",
685
+ contrastRatio: 8.4
686
+ },
687
+ contrastTeal: {
688
+ id: "contrastTeal",
689
+ label: "Teal",
690
+ light: "rgb(176, 243, 240)",
691
+ dark: "rgb(0, 68, 64)",
692
+ contrastRatio: 8.8
693
+ },
694
+ contrastBlue: {
695
+ id: "contrastBlue",
696
+ label: "Blue",
697
+ light: "rgb(208, 222, 255)",
698
+ dark: "rgb(15, 42, 148)",
699
+ contrastRatio: 8.7
700
+ },
701
+ contrastPurple: {
702
+ id: "contrastPurple",
703
+ label: "Purple",
704
+ light: "rgb(232, 210, 255)",
705
+ dark: "rgb(62, 0, 132)",
706
+ contrastRatio: 9.8
707
+ },
708
+ contrastPink: {
709
+ id: "contrastPink",
710
+ label: "Pink",
711
+ light: "rgb(255, 212, 228)",
712
+ dark: "rgb(120, 0, 55)",
713
+ contrastRatio: 8.5
714
+ },
715
+ contrastBrown: {
716
+ id: "contrastBrown",
717
+ label: "Brown",
718
+ light: "rgb(242, 224, 200)",
719
+ dark: "rgb(74, 33, 0)",
720
+ contrastRatio: 10.7
721
+ }
722
+ };
723
+ var CONTRAST_PALETTE_LIST = [
724
+ CONTRAST_PALETTE.contrastNeutral,
725
+ CONTRAST_PALETTE.contrastGray,
726
+ CONTRAST_PALETTE.contrastRed,
727
+ CONTRAST_PALETTE.contrastOrange,
728
+ CONTRAST_PALETTE.contrastYellow,
729
+ CONTRAST_PALETTE.contrastGreen,
730
+ CONTRAST_PALETTE.contrastTeal,
731
+ CONTRAST_PALETTE.contrastBlue,
732
+ CONTRAST_PALETTE.contrastPurple,
733
+ CONTRAST_PALETTE.contrastPink,
734
+ CONTRAST_PALETTE.contrastBrown
735
+ ];
736
+ // src/Color/resolveColor.ts
737
+ function resolveColor(value, theme, role) {
738
+ if (typeof value === "string")
739
+ return value;
740
+ if (value.type === "fixed") {
741
+ return value.value;
742
+ }
743
+ const pair = CONTRAST_PALETTE[value.id];
744
+ const lightMode = theme === "light";
745
+ if (role === "background") {
746
+ return lightMode ? pair.light : pair.dark;
747
+ } else {
748
+ return lightMode ? pair.dark : pair.light;
749
+ }
750
+ }
751
+ function resolvePairedForeground(background, theme) {
752
+ if (background.type === "semantic") {
753
+ return resolveColor(background, theme, "foreground");
754
+ }
755
+ return theme === "light" ? CONTRAST_PALETTE.contrastNeutral.dark : CONTRAST_PALETTE.contrastNeutral.light;
756
+ }
757
+ // src/Color/colorUtils.ts
758
+ function srgbChannelToLinear(channel) {
759
+ const c = channel / 255;
760
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
761
+ }
762
+ function relativeLuminance(r, g, b) {
763
+ return 0.2126 * srgbChannelToLinear(r) + 0.7152 * srgbChannelToLinear(g) + 0.0722 * srgbChannelToLinear(b);
764
+ }
765
+ function contrastRatio(lum1, lum2) {
766
+ const lighter = Math.max(lum1, lum2);
767
+ const darker = Math.min(lum1, lum2);
768
+ return (lighter + 0.05) / (darker + 0.05);
769
+ }
770
+ function meetsWCAG_AA(ratio) {
771
+ return ratio >= 4.5;
772
+ }
773
+ function meetsWCAG_AAA(ratio) {
774
+ return ratio >= 7;
775
+ }
776
+ function parseCssRgb(css) {
777
+ const m = css.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)/);
778
+ if (!m)
779
+ return null;
780
+ return [parseFloat(m[1]), parseFloat(m[2]), parseFloat(m[3])];
781
+ }
782
+ function cssContrastRatio(css1, css2) {
783
+ const rgb1 = parseCssRgb(css1);
784
+ const rgb2 = parseCssRgb(css2);
785
+ if (!rgb1 || !rgb2)
786
+ return null;
787
+ return contrastRatio(relativeLuminance(...rgb1), relativeLuminance(...rgb2));
788
+ }
611
789
  // src/BoardCommand.ts
612
790
  class BoardCommand {
613
791
  board;
@@ -1201,12 +1379,14 @@ class Mbr {
1201
1379
  }
1202
1380
  render(context) {
1203
1381
  const { ctx } = context;
1204
- if (this.backgroundColor !== "none") {
1205
- ctx.fillStyle = this.backgroundColor;
1382
+ const resolvedBg = typeof this.backgroundColor === "string" ? this.backgroundColor : resolveColor(this.backgroundColor, "light", "background");
1383
+ const resolvedBorder = typeof this.borderColor === "string" ? this.borderColor : resolveColor(this.borderColor, "light", "foreground");
1384
+ if (resolvedBg !== "none") {
1385
+ ctx.fillStyle = resolvedBg;
1206
1386
  ctx.fillRect(this.left, this.top, this.getWidth(), this.getHeight());
1207
1387
  }
1208
1388
  if (this.strokeWidth) {
1209
- ctx.strokeStyle = this.borderColor;
1389
+ ctx.strokeStyle = resolvedBorder;
1210
1390
  ctx.lineWidth = this.strokeWidth;
1211
1391
  ctx.setLineDash([]);
1212
1392
  ctx.strokeRect(this.left, this.top, this.getWidth(), this.getHeight());
@@ -6765,6 +6945,7 @@ var conf = {
6765
6945
  plus: "Plus",
6766
6946
  plusAI: "PlusAI"
6767
6947
  },
6948
+ theme: "light",
6768
6949
  EVENTS_PUBLISH_INTERVAL: 100,
6769
6950
  EVENTS_RESEND_INTERVAL: 1000,
6770
6951
  SELECTION_COLOR: "rgb(71, 120, 245)",
@@ -9203,7 +9384,7 @@ function fillHighlight(ctx, textBlock) {
9203
9384
  return;
9204
9385
  }
9205
9386
  const measure = textBlock.measure;
9206
- ctx.fillStyle = textBlock.style.backgroundColor;
9387
+ ctx.fillStyle = resolveColor(textBlock.style.backgroundColor, conf.theme, "background");
9207
9388
  ctx.fillRect(textBlock.x, textBlock.y - measure.ascent, measure.width, measure.height);
9208
9389
  }
9209
9390
  function underline(ctx, textBlock) {
@@ -9215,14 +9396,13 @@ function underline(ctx, textBlock) {
9215
9396
  const style = textBlock.style;
9216
9397
  const measure = textBlock.measure;
9217
9398
  const width = measure.width - (textBlock.marginLeft || 0);
9218
- const color = style.color;
9219
- ctx.strokeStyle = color;
9399
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9220
9400
  ctx.lineWidth = textBlock.fontSize / 14;
9221
9401
  ctx.beginPath();
9222
9402
  ctx.moveTo(x, y + 2 * textBlock.fontSize / 14);
9223
9403
  ctx.lineTo(x + width, y + 2 * textBlock.fontSize / 14);
9224
9404
  ctx.stroke();
9225
- ctx.strokeStyle = style.backgroundColor ?? "black";
9405
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9226
9406
  ctx.lineWidth = 2;
9227
9407
  }
9228
9408
  function cross(ctx, textBlock) {
@@ -9235,19 +9415,18 @@ function cross(ctx, textBlock) {
9235
9415
  const measure = textBlock.measure;
9236
9416
  const width = measure.width;
9237
9417
  const height = measure.height;
9238
- const color = style.color;
9239
- ctx.strokeStyle = color;
9418
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9240
9419
  ctx.lineWidth = textBlock.fontSize / 14;
9241
9420
  ctx.beginPath();
9242
9421
  ctx.moveTo(x, y - height / 4);
9243
9422
  ctx.lineTo(x + width, y - height / 4);
9244
9423
  ctx.stroke();
9245
- ctx.strokeStyle = style.backgroundColor ?? "black";
9424
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9246
9425
  ctx.lineWidth = 2;
9247
9426
  }
9248
9427
  function fillText(ctx, textBlock) {
9249
9428
  const { text, style, x, y } = textBlock;
9250
- ctx.fillStyle = style.color;
9429
+ ctx.fillStyle = resolveColor(style.color, conf.theme, "foreground");
9251
9430
  ctx.fillText(text, x, y);
9252
9431
  if (textBlock.listMark) {
9253
9432
  ctx.fillText(textBlock.listMark, x - measureText(textBlock.listMark, style).width - 4, y);
@@ -16538,7 +16717,7 @@ function setSelectionFontHighlight(editor, format, selectionContext) {
16538
16717
  }
16539
16718
  if (format === "none") {
16540
16719
  Editor22.removeMark(editor, "fontHighlight");
16541
- } else if (marks.fontHighlight === format) {
16720
+ } else if (typeof format === "string" && marks.fontHighlight === format) {
16542
16721
  Editor22.removeMark(editor, "fontHighlight");
16543
16722
  } else {
16544
16723
  Editor22.addMark(editor, "fontHighlight", format);
@@ -22293,8 +22472,8 @@ class RichText extends BaseItem {
22293
22472
  node2.underline ? "underline" : "",
22294
22473
  node2["line-through"] ? "line-through" : ""
22295
22474
  ].filter(Boolean).join(" "),
22296
- color: node2.fontColor || conf.DEFAULT_TEXT_STYLES.fontColor,
22297
- backgroundColor: node2.fontHighlight || conf.DEFAULT_TEXT_STYLES.fontHighlight,
22475
+ color: node2.fontColor ? resolveColor(node2.fontColor, conf.theme, "foreground") : conf.DEFAULT_TEXT_STYLES.fontColor,
22476
+ backgroundColor: node2.fontHighlight ? resolveColor(node2.fontHighlight, conf.theme, "background") : conf.DEFAULT_TEXT_STYLES.fontHighlight,
22298
22477
  fontSize: node2.fontSize ? `${node2.fontSize}px` : `${conf.DEFAULT_TEXT_STYLES.fontSize}px`,
22299
22478
  fontFamily: node2.fontFamily || conf.DEFAULT_TEXT_STYLES.fontFamily
22300
22479
  });
@@ -37042,7 +37221,7 @@ class Connector2 extends BaseItem {
37042
37221
  this.endPointerStyle = endPointerStyle;
37043
37222
  this.transformation = new Transformation(this.id, this.board.events);
37044
37223
  this.linkTo = new LinkTo(this.id, this.board.events);
37045
- this.lineColor = lineColor ?? CONNECTOR_COLOR;
37224
+ this.lineColor = lineColor ?? fixedColor(CONNECTOR_COLOR);
37046
37225
  this.lineWidth = lineWidth ?? CONNECTOR_LINE_WIDTH;
37047
37226
  this.borderStyle = strokeStyle ?? CONNECTOR_BORDER_STYLE;
37048
37227
  this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, conf.i18n.t("connector.textPlaceholder", {
@@ -37459,6 +37638,12 @@ class Connector2 extends BaseItem {
37459
37638
  mbr.strokeWidth = 3;
37460
37639
  mbr.borderStyle = "solid";
37461
37640
  this.clipText(context);
37641
+ const resolvedLineColor = resolveColor(this.lineColor, conf.theme, "foreground");
37642
+ this.lines.setBorderColor(resolvedLineColor);
37643
+ this.startPointer.path.setBorderColor(resolvedLineColor);
37644
+ this.startPointer.path.setBackgroundColor(resolvedLineColor);
37645
+ this.endPointer.path.setBorderColor(resolvedLineColor);
37646
+ this.endPointer.path.setBackgroundColor(resolvedLineColor);
37462
37647
  if (!this.text.isRenderEnabled && this.board.selection.getContext() !== "EditTextUnderPointer") {
37463
37648
  this.lines.render(context);
37464
37649
  }
@@ -37549,7 +37734,7 @@ class Connector2 extends BaseItem {
37549
37734
  div.style.transformOrigin = "left top";
37550
37735
  div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
37551
37736
  div.style.position = "absolute";
37552
- div.setAttribute("data-line-color", this.lineColor);
37737
+ div.setAttribute("data-line-color", resolveColor(this.lineColor, conf.theme, "foreground"));
37553
37738
  div.setAttribute("data-line-width", this.lineWidth.toString());
37554
37739
  div.setAttribute("data-line-style", this.lineStyle);
37555
37740
  div.setAttribute("data-border-style", this.borderStyle);
@@ -37645,7 +37830,9 @@ class Connector2 extends BaseItem {
37645
37830
  this.startPointerStyle = data.startPointerStyle ?? this.startPointerStyle;
37646
37831
  this.endPointerStyle = data.endPointerStyle ?? this.endPointerStyle;
37647
37832
  this.lineStyle = data.lineStyle ?? this.lineStyle;
37648
- this.lineColor = data.lineColor ?? this.lineColor;
37833
+ if (data.lineColor != null) {
37834
+ this.lineColor = coerceColorValue(data.lineColor);
37835
+ }
37649
37836
  this.lineWidth = data.lineWidth ?? this.lineWidth;
37650
37837
  this.borderStyle = data.borderStyle ?? this.borderStyle;
37651
37838
  if (data.transformation) {
@@ -37738,16 +37925,11 @@ class Connector2 extends BaseItem {
37738
37925
  const endPoint = this.endPoint;
37739
37926
  this.lines = getLine(this.lineStyle, startPoint, endPoint, this.middlePoint).addConnectedItemType(this.itemType);
37740
37927
  this.startPointer = getStartPointer(startPoint, this.startPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
37741
- this.startPointer.path.setBorderColor(this.lineColor);
37742
37928
  this.startPointer.path.setBorderWidth(this.lineWidth);
37743
- this.startPointer.path.setBackgroundColor(this.lineColor);
37744
37929
  this.endPointer = getEndPointer(endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
37745
- this.endPointer.path.setBorderColor(this.lineColor);
37746
37930
  this.endPointer.path.setBorderWidth(this.lineWidth);
37747
- this.endPointer.path.setBackgroundColor(this.lineColor);
37748
37931
  this.offsetLines();
37749
37932
  this.lines.setBorderWidth(this.lineWidth);
37750
- this.lines.setBorderColor(this.lineColor);
37751
37933
  this.lines.setBorderStyle(this.borderStyle);
37752
37934
  this.updateTitle();
37753
37935
  }
@@ -37853,7 +38035,7 @@ class ConnectorData2 {
37853
38035
  startPointerStyle = "None";
37854
38036
  endPointerStyle = "ArrowThin";
37855
38037
  lineStyle = "straight";
37856
- lineColor = "";
38038
+ lineColor = fixedColor(CONNECTOR_COLOR);
37857
38039
  linkTo;
37858
38040
  lineWidth = 1;
37859
38041
  borderStyle = "solid";
@@ -38546,7 +38728,7 @@ class DefaultShapeData {
38546
38728
  text;
38547
38729
  linkTo;
38548
38730
  itemType = "Shape";
38549
- constructor(shapeType = "Rectangle", backgroundColor = "none", backgroundOpacity = 1, borderColor = conf.SHAPE_DEFAULT_STROKE_COLOR, borderOpacity = 1, borderStyle = "solid", borderWidth = 1, transformation = new DefaultTransformationData, text5 = new DefaultRichTextData, linkTo) {
38731
+ constructor(shapeType = "Rectangle", backgroundColor = fixedColor("none"), backgroundOpacity = 1, borderColor = fixedColor(conf.SHAPE_DEFAULT_STROKE_COLOR), borderOpacity = 1, borderStyle = "solid", borderWidth = 1, transformation = new DefaultTransformationData, text5 = new DefaultRichTextData, linkTo) {
38550
38732
  this.shapeType = shapeType;
38551
38733
  this.backgroundColor = backgroundColor;
38552
38734
  this.backgroundOpacity = backgroundOpacity;
@@ -39414,9 +39596,13 @@ class Shape extends BaseItem {
39414
39596
  if (data.linkTo) {
39415
39597
  this.linkTo.deserialize(data.linkTo);
39416
39598
  }
39417
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
39599
+ if (data.backgroundColor != null) {
39600
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
39601
+ }
39418
39602
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
39419
- this.borderColor = data.borderColor ?? this.borderColor;
39603
+ if (data.borderColor != null) {
39604
+ this.borderColor = coerceColorValue(data.borderColor);
39605
+ }
39420
39606
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
39421
39607
  this.borderStyle = data.borderStyle ?? this.borderStyle;
39422
39608
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -39523,7 +39709,6 @@ class Shape extends BaseItem {
39523
39709
  }
39524
39710
  applyBackgroundColor(backgroundColor) {
39525
39711
  this.backgroundColor = backgroundColor;
39526
- this.path.setBackgroundColor(backgroundColor);
39527
39712
  }
39528
39713
  setBackgroundColor(backgroundColor) {
39529
39714
  this.emit({
@@ -39559,7 +39744,6 @@ class Shape extends BaseItem {
39559
39744
  }
39560
39745
  applyBorderColor(borderColor) {
39561
39746
  this.borderColor = borderColor;
39562
- this.path.setBorderColor(borderColor);
39563
39747
  }
39564
39748
  setBorderColor(borderColor) {
39565
39749
  this.emit({
@@ -39667,6 +39851,8 @@ class Shape extends BaseItem {
39667
39851
  if (this.transformationRenderBlock) {
39668
39852
  return;
39669
39853
  }
39854
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
39855
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
39670
39856
  this.path.render(context);
39671
39857
  this.text.render(context);
39672
39858
  if (this.getLinkTo()) {
@@ -39767,9 +39953,7 @@ class Shape extends BaseItem {
39767
39953
  this.text.setContainer(this.textContainer.copy());
39768
39954
  this.textContainer.transform(this.transformation.toMatrix());
39769
39955
  this.path.transform(this.transformation.toMatrix());
39770
- this.path.setBackgroundColor(this.backgroundColor);
39771
39956
  this.path.setBackgroundOpacity(this.backgroundOpacity);
39772
- this.path.setBorderColor(this.borderColor);
39773
39957
  this.path.setBorderWidth(this.borderWidth);
39774
39958
  this.path.setBorderStyle(this.borderStyle);
39775
39959
  this.path.setBorderOpacity(this.borderOpacity);
@@ -39818,7 +40002,7 @@ class StickerData {
39818
40002
  linkTo;
39819
40003
  text;
39820
40004
  itemType = "Sticker";
39821
- constructor(backgroundColor = stickerColors["Sky Blue"], transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
40005
+ constructor(backgroundColor = fixedColor(stickerColors["Sky Blue"]), transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
39822
40006
  this.backgroundColor = backgroundColor;
39823
40007
  this.transformation = transformation;
39824
40008
  this.linkTo = linkTo;
@@ -39930,7 +40114,9 @@ class Sticker extends BaseItem {
39930
40114
  };
39931
40115
  }
39932
40116
  deserialize(data) {
39933
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
40117
+ if (data.backgroundColor != null) {
40118
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
40119
+ }
39934
40120
  if (data.transformation) {
39935
40121
  this.transformation.deserialize(data.transformation);
39936
40122
  }
@@ -39954,7 +40140,6 @@ class Sticker extends BaseItem {
39954
40140
  this.stickerPath.transform(this.transformation.toMatrix());
39955
40141
  this.text.setContainer(this.textContainer.copy());
39956
40142
  this.textContainer.transform(this.transformation.toMatrix());
39957
- this.stickerPath.setBackgroundColor(this.backgroundColor);
39958
40143
  this.saveStickerData();
39959
40144
  }
39960
40145
  setId(id) {
@@ -39998,7 +40183,6 @@ class Sticker extends BaseItem {
39998
40183
  }
39999
40184
  applyBackgroundColor(backgroundColor) {
40000
40185
  this.backgroundColor = backgroundColor;
40001
- this.stickerPath.setBackgroundColor(backgroundColor);
40002
40186
  }
40003
40187
  setBackgroundColor(backgroundColor) {
40004
40188
  this.emit({
@@ -40045,6 +40229,7 @@ class Sticker extends BaseItem {
40045
40229
  return;
40046
40230
  }
40047
40231
  this.renderShadow(context);
40232
+ this.stickerPath.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40048
40233
  this.stickerPath.render(context);
40049
40234
  this.text.render(context);
40050
40235
  if (this.getLinkTo()) {
@@ -40061,7 +40246,7 @@ class Sticker extends BaseItem {
40061
40246
  const unscaledWidth = itemMbr.getWidth() / scaleX;
40062
40247
  const unscaledHeight = height2 / scaleY;
40063
40248
  div.id = this.getId();
40064
- div.style.backgroundColor = this.backgroundColor;
40249
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
40065
40250
  div.style.width = `${unscaledWidth}px`;
40066
40251
  div.style.height = `${unscaledHeight}px`;
40067
40252
  div.style.transformOrigin = "top left";
@@ -40335,7 +40520,7 @@ class DefaultFrameData {
40335
40520
  canChangeRatio;
40336
40521
  linkTo;
40337
40522
  itemType = "Frame";
40338
- constructor(shapeType = "Custom", backgroundColor = FRAME_FILL_COLOR, backgroundOpacity = 1, borderColor = FRAME_BORDER_COLOR, borderOpacity = 0.08, borderStyle = "solid", borderWidth = 0.2, transformation = new DefaultTransformationData, children = [], text5 = new DefaultRichTextData([], "top", 600), canChangeRatio = true, linkTo) {
40523
+ constructor(shapeType = "Custom", backgroundColor = fixedColor(FRAME_FILL_COLOR), backgroundOpacity = 1, borderColor = fixedColor(FRAME_BORDER_COLOR), borderOpacity = 0.08, borderStyle = "solid", borderWidth = 0.2, transformation = new DefaultTransformationData, children = [], text5 = new DefaultRichTextData([], "top", 600), canChangeRatio = true, linkTo) {
40339
40524
  this.shapeType = shapeType;
40340
40525
  this.backgroundColor = backgroundColor;
40341
40526
  this.backgroundOpacity = backgroundOpacity;
@@ -40543,9 +40728,13 @@ class Frame2 extends BaseItem {
40543
40728
  this.initPath();
40544
40729
  }
40545
40730
  this.linkTo.deserialize(data.linkTo);
40546
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
40731
+ if (data.backgroundColor != null) {
40732
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
40733
+ }
40547
40734
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
40548
- this.borderColor = data.borderColor ?? this.borderColor;
40735
+ if (data.borderColor != null) {
40736
+ this.borderColor = coerceColorValue(data.borderColor);
40737
+ }
40549
40738
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
40550
40739
  this.borderStyle = data.borderStyle ?? this.borderStyle;
40551
40740
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -40583,9 +40772,7 @@ class Frame2 extends BaseItem {
40583
40772
  this.path.transform(this.transformation.toMatrix());
40584
40773
  this.textContainer.transform(this.transformation.toMatrix());
40585
40774
  }
40586
- this.path.setBackgroundColor(this.backgroundColor);
40587
40775
  this.path.setBackgroundOpacity(this.backgroundOpacity);
40588
- this.path.setBorderColor(this.borderColor);
40589
40776
  this.path.setBorderWidth(this.borderWidth);
40590
40777
  this.path.setBorderStyle(this.borderStyle);
40591
40778
  this.path.setBorderOpacity(this.borderOpacity);
@@ -40736,7 +40923,6 @@ class Frame2 extends BaseItem {
40736
40923
  }
40737
40924
  applyBackgroundColor(backgroundColor) {
40738
40925
  this.backgroundColor = backgroundColor;
40739
- this.path.setBackgroundColor(backgroundColor);
40740
40926
  }
40741
40927
  setBackgroundColor(backgroundColor) {
40742
40928
  this.emit({
@@ -40784,6 +40970,8 @@ class Frame2 extends BaseItem {
40784
40970
  if (this.transformationRenderBlock) {
40785
40971
  return;
40786
40972
  }
40973
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40974
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
40787
40975
  this.path.render(context);
40788
40976
  this.renderNewShape(context);
40789
40977
  if (this.getLinkTo()) {
@@ -40808,9 +40996,9 @@ class Frame2 extends BaseItem {
40808
40996
  renderHTML(documentFactory) {
40809
40997
  const div = documentFactory.createElement("frame-item");
40810
40998
  div.id = this.getId();
40811
- div.style.backgroundColor = this.backgroundColor;
40999
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
40812
41000
  div.style.opacity = this.backgroundOpacity.toString();
40813
- div.style.borderColor = this.borderColor;
41001
+ div.style.borderColor = resolveColor(this.borderColor, conf.theme, "foreground");
40814
41002
  div.style.borderWidth = `${this.borderWidth}px`;
40815
41003
  div.style.borderStyle = this.borderStyle;
40816
41004
  const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
@@ -42446,6 +42634,7 @@ class Drawing extends BaseItem {
42446
42634
  lines = [];
42447
42635
  linkTo;
42448
42636
  strokeWidth = 1;
42637
+ borderColor = fixedColor(conf.PEN_DEFAULT_COLOR);
42449
42638
  borderStyle = "solid";
42450
42639
  linePattern = scalePatterns(this.strokeWidth)[this.borderStyle];
42451
42640
  borderOpacity = 1;
@@ -42491,7 +42680,7 @@ class Drawing extends BaseItem {
42491
42680
  this.linkTo.deserialize(data.linkTo);
42492
42681
  this.optimizePoints();
42493
42682
  this.transformation.deserialize(data.transformation);
42494
- this.borderColor = data.strokeStyle;
42683
+ this.borderColor = coerceColorValue(data.strokeStyle);
42495
42684
  this.strokeWidth = data.strokeWidth;
42496
42685
  this.updateGeometry();
42497
42686
  return this;
@@ -42599,7 +42788,7 @@ class Drawing extends BaseItem {
42599
42788
  }
42600
42789
  const ctx = context.ctx;
42601
42790
  ctx.save();
42602
- ctx.strokeStyle = this.borderColor;
42791
+ ctx.strokeStyle = resolveColor(this.borderColor, conf.theme, "foreground");
42603
42792
  ctx.lineWidth = this.strokeWidth;
42604
42793
  ctx.lineCap = "round";
42605
42794
  ctx.setLineDash(this.linePattern);
@@ -42626,7 +42815,7 @@ class Drawing extends BaseItem {
42626
42815
  svg3.setAttribute("style", "position: absolute; overflow: visible;");
42627
42816
  const pathElement = documentFactory.createElementNS("http://www.w3.org/2000/svg", "path");
42628
42817
  pathElement.setAttribute("d", this.getPathData());
42629
- pathElement.setAttribute("stroke", this.borderColor);
42818
+ pathElement.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
42630
42819
  pathElement.setAttribute("stroke-width", `${this.strokeWidth}`);
42631
42820
  pathElement.setAttribute("fill", "none");
42632
42821
  svg3.appendChild(pathElement);
@@ -42719,7 +42908,7 @@ class Drawing extends BaseItem {
42719
42908
  case "Drawing":
42720
42909
  switch (op.method) {
42721
42910
  case "setStrokeColor":
42722
- this.borderColor = op.color;
42911
+ this.borderColor = coerceColorValue(op.color);
42723
42912
  break;
42724
42913
  case "setStrokeWidth":
42725
42914
  this.strokeWidth = op.width;
@@ -57105,12 +57294,17 @@ export {
57105
57294
  tempStorage,
57106
57295
  tagByType,
57107
57296
  stickerColors,
57297
+ srgbChannelToLinear,
57108
57298
  sha256,
57299
+ semanticColor,
57109
57300
  scalePatterns,
57110
57301
  scaleElementBy,
57111
57302
  rgbToRgba,
57303
+ resolvePairedForeground,
57304
+ resolveColor,
57112
57305
  resizeAndConvertToPng,
57113
57306
  resetElementScale,
57307
+ relativeLuminance,
57114
57308
  registerItem,
57115
57309
  quickAddItem,
57116
57310
  prepareVideo,
@@ -57119,8 +57313,11 @@ export {
57119
57313
  positionRelatively,
57120
57314
  positionAbsolutely,
57121
57315
  parsersHTML,
57316
+ parseCssRgb,
57122
57317
  omitDefaultProperties,
57123
57318
  messageRouter,
57319
+ meetsWCAG_AAA,
57320
+ meetsWCAG_AA,
57124
57321
  itemValidators,
57125
57322
  itemFactories,
57126
57323
  isShallowSimilarTo,
@@ -57147,14 +57344,19 @@ export {
57147
57344
  getControlPointData,
57148
57345
  getBlobFromDataURL,
57149
57346
  forceNumberIntoInterval,
57347
+ fixedColor,
57150
57348
  fileTosha256,
57151
57349
  exportBoardSnapshot,
57152
57350
  editModeHotkeyRegistry,
57153
57351
  decodeHtml,
57154
57352
  defaultCursors as cursors,
57353
+ cssContrastRatio,
57155
57354
  createVideoItem,
57156
57355
  createEvents,
57356
+ contrastRatio,
57157
57357
  conf,
57358
+ coerceOptionalColorValue,
57359
+ coerceColorValue,
57158
57360
  checkHotkeys,
57159
57361
  catmullRomInterpolate,
57160
57362
  captureFrame,
@@ -57180,6 +57382,7 @@ export {
57180
57382
  STEP_STROKE_WIDTH,
57181
57383
  SHAPE_LAST_TYPE_KEY,
57182
57384
  SHAPES_CATEGORIES,
57385
+ SEMANTIC_COLOR_IDS,
57183
57386
  RichText,
57184
57387
  QuadraticBezier,
57185
57388
  Presence,
@@ -57231,6 +57434,8 @@ export {
57231
57434
  Camera,
57232
57435
  CURSORS_IDLE_CLEANUP_DELAY,
57233
57436
  CURSORS_ANIMATION_DURATION,
57437
+ CONTRAST_PALETTE_LIST,
57438
+ CONTRAST_PALETTE,
57234
57439
  CONTEXT_NODE_HIGHLIGHT_COLOR,
57235
57440
  CONNECTOR_POINTER_TYPES,
57236
57441
  BoardSelection,