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
@@ -637,12 +637,17 @@ __export(exports_browser, {
637
637
  tempStorage: () => tempStorage,
638
638
  tagByType: () => tagByType,
639
639
  stickerColors: () => stickerColors,
640
+ srgbChannelToLinear: () => srgbChannelToLinear,
640
641
  sha256: () => sha256,
642
+ semanticColor: () => semanticColor,
641
643
  scalePatterns: () => scalePatterns,
642
644
  scaleElementBy: () => scaleElementBy,
643
645
  rgbToRgba: () => rgbToRgba,
646
+ resolvePairedForeground: () => resolvePairedForeground,
647
+ resolveColor: () => resolveColor,
644
648
  resizeAndConvertToPng: () => resizeAndConvertToPng,
645
649
  resetElementScale: () => resetElementScale,
650
+ relativeLuminance: () => relativeLuminance,
646
651
  registerItem: () => registerItem,
647
652
  quickAddItem: () => quickAddItem,
648
653
  prepareVideo: () => prepareVideo,
@@ -651,8 +656,11 @@ __export(exports_browser, {
651
656
  positionRelatively: () => positionRelatively,
652
657
  positionAbsolutely: () => positionAbsolutely,
653
658
  parsersHTML: () => parsersHTML,
659
+ parseCssRgb: () => parseCssRgb,
654
660
  omitDefaultProperties: () => omitDefaultProperties,
655
661
  messageRouter: () => messageRouter,
662
+ meetsWCAG_AAA: () => meetsWCAG_AAA,
663
+ meetsWCAG_AA: () => meetsWCAG_AA,
656
664
  itemValidators: () => itemValidators,
657
665
  itemFactories: () => itemFactories,
658
666
  isShallowSimilarTo: () => isShallowSimilarTo,
@@ -679,14 +687,19 @@ __export(exports_browser, {
679
687
  getControlPointData: () => getControlPointData,
680
688
  getBlobFromDataURL: () => getBlobFromDataURL,
681
689
  forceNumberIntoInterval: () => forceNumberIntoInterval,
690
+ fixedColor: () => fixedColor,
682
691
  fileTosha256: () => fileTosha256,
683
692
  exportBoardSnapshot: () => exportBoardSnapshot,
684
693
  editModeHotkeyRegistry: () => editModeHotkeyRegistry,
685
694
  decodeHtml: () => decodeHtml,
686
695
  cursors: () => defaultCursors,
696
+ cssContrastRatio: () => cssContrastRatio,
687
697
  createVideoItem: () => createVideoItem,
688
698
  createEvents: () => createEvents,
699
+ contrastRatio: () => contrastRatio,
689
700
  conf: () => conf,
701
+ coerceOptionalColorValue: () => coerceOptionalColorValue,
702
+ coerceColorValue: () => coerceColorValue,
690
703
  checkHotkeys: () => checkHotkeys,
691
704
  catmullRomInterpolate: () => catmullRomInterpolate,
692
705
  captureFrame: () => captureFrame,
@@ -712,6 +725,7 @@ __export(exports_browser, {
712
725
  STEP_STROKE_WIDTH: () => STEP_STROKE_WIDTH,
713
726
  SHAPE_LAST_TYPE_KEY: () => SHAPE_LAST_TYPE_KEY,
714
727
  SHAPES_CATEGORIES: () => SHAPES_CATEGORIES,
728
+ SEMANTIC_COLOR_IDS: () => SEMANTIC_COLOR_IDS,
715
729
  RichText: () => RichText,
716
730
  QuadraticBezier: () => QuadraticBezier,
717
731
  Presence: () => Presence,
@@ -763,6 +777,8 @@ __export(exports_browser, {
763
777
  Camera: () => Camera,
764
778
  CURSORS_IDLE_CLEANUP_DELAY: () => CURSORS_IDLE_CLEANUP_DELAY,
765
779
  CURSORS_ANIMATION_DURATION: () => CURSORS_ANIMATION_DURATION,
780
+ CONTRAST_PALETTE_LIST: () => CONTRAST_PALETTE_LIST,
781
+ CONTRAST_PALETTE: () => CONTRAST_PALETTE,
766
782
  CONTEXT_NODE_HIGHLIGHT_COLOR: () => CONTEXT_NODE_HIGHLIGHT_COLOR,
767
783
  CONNECTOR_POINTER_TYPES: () => CONNECTOR_POINTER_TYPES,
768
784
  BoardSelection: () => BoardSelection,
@@ -778,6 +794,184 @@ __export(exports_browser, {
778
794
  });
779
795
  module.exports = __toCommonJS(exports_browser);
780
796
 
797
+ // src/Color/ColorValue.ts
798
+ var SEMANTIC_COLOR_IDS = [
799
+ "contrastNeutral",
800
+ "contrastGray",
801
+ "contrastRed",
802
+ "contrastOrange",
803
+ "contrastYellow",
804
+ "contrastGreen",
805
+ "contrastTeal",
806
+ "contrastBlue",
807
+ "contrastPurple",
808
+ "contrastPink",
809
+ "contrastBrown"
810
+ ];
811
+ var semanticColor = (id) => ({
812
+ type: "semantic",
813
+ id
814
+ });
815
+ var fixedColor = (value) => ({
816
+ type: "fixed",
817
+ value
818
+ });
819
+ function coerceColorValue(value) {
820
+ if (typeof value === "string")
821
+ return fixedColor(value);
822
+ return value;
823
+ }
824
+ function coerceOptionalColorValue(value) {
825
+ if (value === undefined)
826
+ return;
827
+ return coerceColorValue(value);
828
+ }
829
+ // src/Color/ContrastPalette.ts
830
+ var CONTRAST_PALETTE = {
831
+ contrastNeutral: {
832
+ id: "contrastNeutral",
833
+ label: "Neutral",
834
+ light: "rgb(245, 246, 248)",
835
+ dark: "rgb(20, 21, 26)",
836
+ contrastRatio: 17.2
837
+ },
838
+ contrastGray: {
839
+ id: "contrastGray",
840
+ label: "Gray",
841
+ light: "rgb(224, 225, 229)",
842
+ dark: "rgb(55, 58, 70)",
843
+ contrastRatio: 8.6
844
+ },
845
+ contrastRed: {
846
+ id: "contrastRed",
847
+ label: "Red",
848
+ light: "rgb(255, 215, 210)",
849
+ dark: "rgb(120, 10, 10)",
850
+ contrastRatio: 8.5
851
+ },
852
+ contrastOrange: {
853
+ id: "contrastOrange",
854
+ label: "Orange",
855
+ light: "rgb(255, 229, 195)",
856
+ dark: "rgb(110, 44, 0)",
857
+ contrastRatio: 8.4
858
+ },
859
+ contrastYellow: {
860
+ id: "contrastYellow",
861
+ label: "Yellow",
862
+ light: "rgb(255, 249, 185)",
863
+ dark: "rgb(89, 71, 0)",
864
+ contrastRatio: 8.3
865
+ },
866
+ contrastGreen: {
867
+ id: "contrastGreen",
868
+ label: "Green",
869
+ light: "rgb(193, 243, 179)",
870
+ dark: "rgb(0, 74, 22)",
871
+ contrastRatio: 8.4
872
+ },
873
+ contrastTeal: {
874
+ id: "contrastTeal",
875
+ label: "Teal",
876
+ light: "rgb(176, 243, 240)",
877
+ dark: "rgb(0, 68, 64)",
878
+ contrastRatio: 8.8
879
+ },
880
+ contrastBlue: {
881
+ id: "contrastBlue",
882
+ label: "Blue",
883
+ light: "rgb(208, 222, 255)",
884
+ dark: "rgb(15, 42, 148)",
885
+ contrastRatio: 8.7
886
+ },
887
+ contrastPurple: {
888
+ id: "contrastPurple",
889
+ label: "Purple",
890
+ light: "rgb(232, 210, 255)",
891
+ dark: "rgb(62, 0, 132)",
892
+ contrastRatio: 9.8
893
+ },
894
+ contrastPink: {
895
+ id: "contrastPink",
896
+ label: "Pink",
897
+ light: "rgb(255, 212, 228)",
898
+ dark: "rgb(120, 0, 55)",
899
+ contrastRatio: 8.5
900
+ },
901
+ contrastBrown: {
902
+ id: "contrastBrown",
903
+ label: "Brown",
904
+ light: "rgb(242, 224, 200)",
905
+ dark: "rgb(74, 33, 0)",
906
+ contrastRatio: 10.7
907
+ }
908
+ };
909
+ var CONTRAST_PALETTE_LIST = [
910
+ CONTRAST_PALETTE.contrastNeutral,
911
+ CONTRAST_PALETTE.contrastGray,
912
+ CONTRAST_PALETTE.contrastRed,
913
+ CONTRAST_PALETTE.contrastOrange,
914
+ CONTRAST_PALETTE.contrastYellow,
915
+ CONTRAST_PALETTE.contrastGreen,
916
+ CONTRAST_PALETTE.contrastTeal,
917
+ CONTRAST_PALETTE.contrastBlue,
918
+ CONTRAST_PALETTE.contrastPurple,
919
+ CONTRAST_PALETTE.contrastPink,
920
+ CONTRAST_PALETTE.contrastBrown
921
+ ];
922
+ // src/Color/resolveColor.ts
923
+ function resolveColor(value, theme, role) {
924
+ if (typeof value === "string")
925
+ return value;
926
+ if (value.type === "fixed") {
927
+ return value.value;
928
+ }
929
+ const pair = CONTRAST_PALETTE[value.id];
930
+ const lightMode = theme === "light";
931
+ if (role === "background") {
932
+ return lightMode ? pair.light : pair.dark;
933
+ } else {
934
+ return lightMode ? pair.dark : pair.light;
935
+ }
936
+ }
937
+ function resolvePairedForeground(background, theme) {
938
+ if (background.type === "semantic") {
939
+ return resolveColor(background, theme, "foreground");
940
+ }
941
+ return theme === "light" ? CONTRAST_PALETTE.contrastNeutral.dark : CONTRAST_PALETTE.contrastNeutral.light;
942
+ }
943
+ // src/Color/colorUtils.ts
944
+ function srgbChannelToLinear(channel) {
945
+ const c = channel / 255;
946
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
947
+ }
948
+ function relativeLuminance(r, g, b) {
949
+ return 0.2126 * srgbChannelToLinear(r) + 0.7152 * srgbChannelToLinear(g) + 0.0722 * srgbChannelToLinear(b);
950
+ }
951
+ function contrastRatio(lum1, lum2) {
952
+ const lighter = Math.max(lum1, lum2);
953
+ const darker = Math.min(lum1, lum2);
954
+ return (lighter + 0.05) / (darker + 0.05);
955
+ }
956
+ function meetsWCAG_AA(ratio) {
957
+ return ratio >= 4.5;
958
+ }
959
+ function meetsWCAG_AAA(ratio) {
960
+ return ratio >= 7;
961
+ }
962
+ function parseCssRgb(css) {
963
+ const m = css.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)/);
964
+ if (!m)
965
+ return null;
966
+ return [parseFloat(m[1]), parseFloat(m[2]), parseFloat(m[3])];
967
+ }
968
+ function cssContrastRatio(css1, css2) {
969
+ const rgb1 = parseCssRgb(css1);
970
+ const rgb2 = parseCssRgb(css2);
971
+ if (!rgb1 || !rgb2)
972
+ return null;
973
+ return contrastRatio(relativeLuminance(...rgb1), relativeLuminance(...rgb2));
974
+ }
781
975
  // src/BoardCommand.ts
782
976
  class BoardCommand {
783
977
  board;
@@ -1371,12 +1565,14 @@ class Mbr {
1371
1565
  }
1372
1566
  render(context) {
1373
1567
  const { ctx } = context;
1374
- if (this.backgroundColor !== "none") {
1375
- ctx.fillStyle = this.backgroundColor;
1568
+ const resolvedBg = typeof this.backgroundColor === "string" ? this.backgroundColor : resolveColor(this.backgroundColor, "light", "background");
1569
+ const resolvedBorder = typeof this.borderColor === "string" ? this.borderColor : resolveColor(this.borderColor, "light", "foreground");
1570
+ if (resolvedBg !== "none") {
1571
+ ctx.fillStyle = resolvedBg;
1376
1572
  ctx.fillRect(this.left, this.top, this.getWidth(), this.getHeight());
1377
1573
  }
1378
1574
  if (this.strokeWidth) {
1379
- ctx.strokeStyle = this.borderColor;
1575
+ ctx.strokeStyle = resolvedBorder;
1380
1576
  ctx.lineWidth = this.strokeWidth;
1381
1577
  ctx.setLineDash([]);
1382
1578
  ctx.strokeRect(this.left, this.top, this.getWidth(), this.getHeight());
@@ -6935,6 +7131,7 @@ var conf = {
6935
7131
  plus: "Plus",
6936
7132
  plusAI: "PlusAI"
6937
7133
  },
7134
+ theme: "light",
6938
7135
  EVENTS_PUBLISH_INTERVAL: 100,
6939
7136
  EVENTS_RESEND_INTERVAL: 1000,
6940
7137
  SELECTION_COLOR: "rgb(71, 120, 245)",
@@ -9368,7 +9565,7 @@ function fillHighlight(ctx, textBlock) {
9368
9565
  return;
9369
9566
  }
9370
9567
  const measure = textBlock.measure;
9371
- ctx.fillStyle = textBlock.style.backgroundColor;
9568
+ ctx.fillStyle = resolveColor(textBlock.style.backgroundColor, conf.theme, "background");
9372
9569
  ctx.fillRect(textBlock.x, textBlock.y - measure.ascent, measure.width, measure.height);
9373
9570
  }
9374
9571
  function underline(ctx, textBlock) {
@@ -9380,14 +9577,13 @@ function underline(ctx, textBlock) {
9380
9577
  const style = textBlock.style;
9381
9578
  const measure = textBlock.measure;
9382
9579
  const width = measure.width - (textBlock.marginLeft || 0);
9383
- const color = style.color;
9384
- ctx.strokeStyle = color;
9580
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9385
9581
  ctx.lineWidth = textBlock.fontSize / 14;
9386
9582
  ctx.beginPath();
9387
9583
  ctx.moveTo(x, y + 2 * textBlock.fontSize / 14);
9388
9584
  ctx.lineTo(x + width, y + 2 * textBlock.fontSize / 14);
9389
9585
  ctx.stroke();
9390
- ctx.strokeStyle = style.backgroundColor ?? "black";
9586
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9391
9587
  ctx.lineWidth = 2;
9392
9588
  }
9393
9589
  function cross(ctx, textBlock) {
@@ -9400,19 +9596,18 @@ function cross(ctx, textBlock) {
9400
9596
  const measure = textBlock.measure;
9401
9597
  const width = measure.width;
9402
9598
  const height = measure.height;
9403
- const color = style.color;
9404
- ctx.strokeStyle = color;
9599
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9405
9600
  ctx.lineWidth = textBlock.fontSize / 14;
9406
9601
  ctx.beginPath();
9407
9602
  ctx.moveTo(x, y - height / 4);
9408
9603
  ctx.lineTo(x + width, y - height / 4);
9409
9604
  ctx.stroke();
9410
- ctx.strokeStyle = style.backgroundColor ?? "black";
9605
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9411
9606
  ctx.lineWidth = 2;
9412
9607
  }
9413
9608
  function fillText(ctx, textBlock) {
9414
9609
  const { text, style, x, y } = textBlock;
9415
- ctx.fillStyle = style.color;
9610
+ ctx.fillStyle = resolveColor(style.color, conf.theme, "foreground");
9416
9611
  ctx.fillText(text, x, y);
9417
9612
  if (textBlock.listMark) {
9418
9613
  ctx.fillText(textBlock.listMark, x - measureText(textBlock.listMark, style).width - 4, y);
@@ -16699,7 +16894,7 @@ function setSelectionFontHighlight(editor, format, selectionContext) {
16699
16894
  }
16700
16895
  if (format === "none") {
16701
16896
  import_slate25.Editor.removeMark(editor, "fontHighlight");
16702
- } else if (marks.fontHighlight === format) {
16897
+ } else if (typeof format === "string" && marks.fontHighlight === format) {
16703
16898
  import_slate25.Editor.removeMark(editor, "fontHighlight");
16704
16899
  } else {
16705
16900
  import_slate25.Editor.addMark(editor, "fontHighlight", format);
@@ -22454,8 +22649,8 @@ class RichText extends BaseItem {
22454
22649
  node2.underline ? "underline" : "",
22455
22650
  node2["line-through"] ? "line-through" : ""
22456
22651
  ].filter(Boolean).join(" "),
22457
- color: node2.fontColor || conf.DEFAULT_TEXT_STYLES.fontColor,
22458
- backgroundColor: node2.fontHighlight || conf.DEFAULT_TEXT_STYLES.fontHighlight,
22652
+ color: node2.fontColor ? resolveColor(node2.fontColor, conf.theme, "foreground") : conf.DEFAULT_TEXT_STYLES.fontColor,
22653
+ backgroundColor: node2.fontHighlight ? resolveColor(node2.fontHighlight, conf.theme, "background") : conf.DEFAULT_TEXT_STYLES.fontHighlight,
22459
22654
  fontSize: node2.fontSize ? `${node2.fontSize}px` : `${conf.DEFAULT_TEXT_STYLES.fontSize}px`,
22460
22655
  fontFamily: node2.fontFamily || conf.DEFAULT_TEXT_STYLES.fontFamily
22461
22656
  });
@@ -37203,7 +37398,7 @@ class Connector2 extends BaseItem {
37203
37398
  this.endPointerStyle = endPointerStyle;
37204
37399
  this.transformation = new Transformation(this.id, this.board.events);
37205
37400
  this.linkTo = new LinkTo(this.id, this.board.events);
37206
- this.lineColor = lineColor ?? CONNECTOR_COLOR;
37401
+ this.lineColor = lineColor ?? fixedColor(CONNECTOR_COLOR);
37207
37402
  this.lineWidth = lineWidth ?? CONNECTOR_LINE_WIDTH;
37208
37403
  this.borderStyle = strokeStyle ?? CONNECTOR_BORDER_STYLE;
37209
37404
  this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, conf.i18n.t("connector.textPlaceholder", {
@@ -37620,6 +37815,12 @@ class Connector2 extends BaseItem {
37620
37815
  mbr.strokeWidth = 3;
37621
37816
  mbr.borderStyle = "solid";
37622
37817
  this.clipText(context);
37818
+ const resolvedLineColor = resolveColor(this.lineColor, conf.theme, "foreground");
37819
+ this.lines.setBorderColor(resolvedLineColor);
37820
+ this.startPointer.path.setBorderColor(resolvedLineColor);
37821
+ this.startPointer.path.setBackgroundColor(resolvedLineColor);
37822
+ this.endPointer.path.setBorderColor(resolvedLineColor);
37823
+ this.endPointer.path.setBackgroundColor(resolvedLineColor);
37623
37824
  if (!this.text.isRenderEnabled && this.board.selection.getContext() !== "EditTextUnderPointer") {
37624
37825
  this.lines.render(context);
37625
37826
  }
@@ -37710,7 +37911,7 @@ class Connector2 extends BaseItem {
37710
37911
  div.style.transformOrigin = "left top";
37711
37912
  div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
37712
37913
  div.style.position = "absolute";
37713
- div.setAttribute("data-line-color", this.lineColor);
37914
+ div.setAttribute("data-line-color", resolveColor(this.lineColor, conf.theme, "foreground"));
37714
37915
  div.setAttribute("data-line-width", this.lineWidth.toString());
37715
37916
  div.setAttribute("data-line-style", this.lineStyle);
37716
37917
  div.setAttribute("data-border-style", this.borderStyle);
@@ -37806,7 +38007,9 @@ class Connector2 extends BaseItem {
37806
38007
  this.startPointerStyle = data.startPointerStyle ?? this.startPointerStyle;
37807
38008
  this.endPointerStyle = data.endPointerStyle ?? this.endPointerStyle;
37808
38009
  this.lineStyle = data.lineStyle ?? this.lineStyle;
37809
- this.lineColor = data.lineColor ?? this.lineColor;
38010
+ if (data.lineColor != null) {
38011
+ this.lineColor = coerceColorValue(data.lineColor);
38012
+ }
37810
38013
  this.lineWidth = data.lineWidth ?? this.lineWidth;
37811
38014
  this.borderStyle = data.borderStyle ?? this.borderStyle;
37812
38015
  if (data.transformation) {
@@ -37899,16 +38102,11 @@ class Connector2 extends BaseItem {
37899
38102
  const endPoint = this.endPoint;
37900
38103
  this.lines = getLine(this.lineStyle, startPoint, endPoint, this.middlePoint).addConnectedItemType(this.itemType);
37901
38104
  this.startPointer = getStartPointer(startPoint, this.startPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
37902
- this.startPointer.path.setBorderColor(this.lineColor);
37903
38105
  this.startPointer.path.setBorderWidth(this.lineWidth);
37904
- this.startPointer.path.setBackgroundColor(this.lineColor);
37905
38106
  this.endPointer = getEndPointer(endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
37906
- this.endPointer.path.setBorderColor(this.lineColor);
37907
38107
  this.endPointer.path.setBorderWidth(this.lineWidth);
37908
- this.endPointer.path.setBackgroundColor(this.lineColor);
37909
38108
  this.offsetLines();
37910
38109
  this.lines.setBorderWidth(this.lineWidth);
37911
- this.lines.setBorderColor(this.lineColor);
37912
38110
  this.lines.setBorderStyle(this.borderStyle);
37913
38111
  this.updateTitle();
37914
38112
  }
@@ -38014,7 +38212,7 @@ class ConnectorData2 {
38014
38212
  startPointerStyle = "None";
38015
38213
  endPointerStyle = "ArrowThin";
38016
38214
  lineStyle = "straight";
38017
- lineColor = "";
38215
+ lineColor = fixedColor(CONNECTOR_COLOR);
38018
38216
  linkTo;
38019
38217
  lineWidth = 1;
38020
38218
  borderStyle = "solid";
@@ -38707,7 +38905,7 @@ class DefaultShapeData {
38707
38905
  text;
38708
38906
  linkTo;
38709
38907
  itemType = "Shape";
38710
- 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) {
38908
+ 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) {
38711
38909
  this.shapeType = shapeType;
38712
38910
  this.backgroundColor = backgroundColor;
38713
38911
  this.backgroundOpacity = backgroundOpacity;
@@ -39575,9 +39773,13 @@ class Shape extends BaseItem {
39575
39773
  if (data.linkTo) {
39576
39774
  this.linkTo.deserialize(data.linkTo);
39577
39775
  }
39578
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
39776
+ if (data.backgroundColor != null) {
39777
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
39778
+ }
39579
39779
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
39580
- this.borderColor = data.borderColor ?? this.borderColor;
39780
+ if (data.borderColor != null) {
39781
+ this.borderColor = coerceColorValue(data.borderColor);
39782
+ }
39581
39783
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
39582
39784
  this.borderStyle = data.borderStyle ?? this.borderStyle;
39583
39785
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -39684,7 +39886,6 @@ class Shape extends BaseItem {
39684
39886
  }
39685
39887
  applyBackgroundColor(backgroundColor) {
39686
39888
  this.backgroundColor = backgroundColor;
39687
- this.path.setBackgroundColor(backgroundColor);
39688
39889
  }
39689
39890
  setBackgroundColor(backgroundColor) {
39690
39891
  this.emit({
@@ -39720,7 +39921,6 @@ class Shape extends BaseItem {
39720
39921
  }
39721
39922
  applyBorderColor(borderColor) {
39722
39923
  this.borderColor = borderColor;
39723
- this.path.setBorderColor(borderColor);
39724
39924
  }
39725
39925
  setBorderColor(borderColor) {
39726
39926
  this.emit({
@@ -39828,6 +40028,8 @@ class Shape extends BaseItem {
39828
40028
  if (this.transformationRenderBlock) {
39829
40029
  return;
39830
40030
  }
40031
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40032
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
39831
40033
  this.path.render(context);
39832
40034
  this.text.render(context);
39833
40035
  if (this.getLinkTo()) {
@@ -39928,9 +40130,7 @@ class Shape extends BaseItem {
39928
40130
  this.text.setContainer(this.textContainer.copy());
39929
40131
  this.textContainer.transform(this.transformation.toMatrix());
39930
40132
  this.path.transform(this.transformation.toMatrix());
39931
- this.path.setBackgroundColor(this.backgroundColor);
39932
40133
  this.path.setBackgroundOpacity(this.backgroundOpacity);
39933
- this.path.setBorderColor(this.borderColor);
39934
40134
  this.path.setBorderWidth(this.borderWidth);
39935
40135
  this.path.setBorderStyle(this.borderStyle);
39936
40136
  this.path.setBorderOpacity(this.borderOpacity);
@@ -39979,7 +40179,7 @@ class StickerData {
39979
40179
  linkTo;
39980
40180
  text;
39981
40181
  itemType = "Sticker";
39982
- constructor(backgroundColor = stickerColors["Sky Blue"], transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
40182
+ constructor(backgroundColor = fixedColor(stickerColors["Sky Blue"]), transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
39983
40183
  this.backgroundColor = backgroundColor;
39984
40184
  this.transformation = transformation;
39985
40185
  this.linkTo = linkTo;
@@ -40091,7 +40291,9 @@ class Sticker extends BaseItem {
40091
40291
  };
40092
40292
  }
40093
40293
  deserialize(data) {
40094
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
40294
+ if (data.backgroundColor != null) {
40295
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
40296
+ }
40095
40297
  if (data.transformation) {
40096
40298
  this.transformation.deserialize(data.transformation);
40097
40299
  }
@@ -40115,7 +40317,6 @@ class Sticker extends BaseItem {
40115
40317
  this.stickerPath.transform(this.transformation.toMatrix());
40116
40318
  this.text.setContainer(this.textContainer.copy());
40117
40319
  this.textContainer.transform(this.transformation.toMatrix());
40118
- this.stickerPath.setBackgroundColor(this.backgroundColor);
40119
40320
  this.saveStickerData();
40120
40321
  }
40121
40322
  setId(id) {
@@ -40159,7 +40360,6 @@ class Sticker extends BaseItem {
40159
40360
  }
40160
40361
  applyBackgroundColor(backgroundColor) {
40161
40362
  this.backgroundColor = backgroundColor;
40162
- this.stickerPath.setBackgroundColor(backgroundColor);
40163
40363
  }
40164
40364
  setBackgroundColor(backgroundColor) {
40165
40365
  this.emit({
@@ -40206,6 +40406,7 @@ class Sticker extends BaseItem {
40206
40406
  return;
40207
40407
  }
40208
40408
  this.renderShadow(context);
40409
+ this.stickerPath.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40209
40410
  this.stickerPath.render(context);
40210
40411
  this.text.render(context);
40211
40412
  if (this.getLinkTo()) {
@@ -40222,7 +40423,7 @@ class Sticker extends BaseItem {
40222
40423
  const unscaledWidth = itemMbr.getWidth() / scaleX;
40223
40424
  const unscaledHeight = height2 / scaleY;
40224
40425
  div.id = this.getId();
40225
- div.style.backgroundColor = this.backgroundColor;
40426
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
40226
40427
  div.style.width = `${unscaledWidth}px`;
40227
40428
  div.style.height = `${unscaledHeight}px`;
40228
40429
  div.style.transformOrigin = "top left";
@@ -40496,7 +40697,7 @@ class DefaultFrameData {
40496
40697
  canChangeRatio;
40497
40698
  linkTo;
40498
40699
  itemType = "Frame";
40499
- 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) {
40700
+ 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) {
40500
40701
  this.shapeType = shapeType;
40501
40702
  this.backgroundColor = backgroundColor;
40502
40703
  this.backgroundOpacity = backgroundOpacity;
@@ -40704,9 +40905,13 @@ class Frame2 extends BaseItem {
40704
40905
  this.initPath();
40705
40906
  }
40706
40907
  this.linkTo.deserialize(data.linkTo);
40707
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
40908
+ if (data.backgroundColor != null) {
40909
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
40910
+ }
40708
40911
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
40709
- this.borderColor = data.borderColor ?? this.borderColor;
40912
+ if (data.borderColor != null) {
40913
+ this.borderColor = coerceColorValue(data.borderColor);
40914
+ }
40710
40915
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
40711
40916
  this.borderStyle = data.borderStyle ?? this.borderStyle;
40712
40917
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -40744,9 +40949,7 @@ class Frame2 extends BaseItem {
40744
40949
  this.path.transform(this.transformation.toMatrix());
40745
40950
  this.textContainer.transform(this.transformation.toMatrix());
40746
40951
  }
40747
- this.path.setBackgroundColor(this.backgroundColor);
40748
40952
  this.path.setBackgroundOpacity(this.backgroundOpacity);
40749
- this.path.setBorderColor(this.borderColor);
40750
40953
  this.path.setBorderWidth(this.borderWidth);
40751
40954
  this.path.setBorderStyle(this.borderStyle);
40752
40955
  this.path.setBorderOpacity(this.borderOpacity);
@@ -40897,7 +41100,6 @@ class Frame2 extends BaseItem {
40897
41100
  }
40898
41101
  applyBackgroundColor(backgroundColor) {
40899
41102
  this.backgroundColor = backgroundColor;
40900
- this.path.setBackgroundColor(backgroundColor);
40901
41103
  }
40902
41104
  setBackgroundColor(backgroundColor) {
40903
41105
  this.emit({
@@ -40945,6 +41147,8 @@ class Frame2 extends BaseItem {
40945
41147
  if (this.transformationRenderBlock) {
40946
41148
  return;
40947
41149
  }
41150
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
41151
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
40948
41152
  this.path.render(context);
40949
41153
  this.renderNewShape(context);
40950
41154
  if (this.getLinkTo()) {
@@ -40969,9 +41173,9 @@ class Frame2 extends BaseItem {
40969
41173
  renderHTML(documentFactory) {
40970
41174
  const div = documentFactory.createElement("frame-item");
40971
41175
  div.id = this.getId();
40972
- div.style.backgroundColor = this.backgroundColor;
41176
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
40973
41177
  div.style.opacity = this.backgroundOpacity.toString();
40974
- div.style.borderColor = this.borderColor;
41178
+ div.style.borderColor = resolveColor(this.borderColor, conf.theme, "foreground");
40975
41179
  div.style.borderWidth = `${this.borderWidth}px`;
40976
41180
  div.style.borderStyle = this.borderStyle;
40977
41181
  const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
@@ -42607,6 +42811,7 @@ class Drawing extends BaseItem {
42607
42811
  lines = [];
42608
42812
  linkTo;
42609
42813
  strokeWidth = 1;
42814
+ borderColor = fixedColor(conf.PEN_DEFAULT_COLOR);
42610
42815
  borderStyle = "solid";
42611
42816
  linePattern = scalePatterns(this.strokeWidth)[this.borderStyle];
42612
42817
  borderOpacity = 1;
@@ -42652,7 +42857,7 @@ class Drawing extends BaseItem {
42652
42857
  this.linkTo.deserialize(data.linkTo);
42653
42858
  this.optimizePoints();
42654
42859
  this.transformation.deserialize(data.transformation);
42655
- this.borderColor = data.strokeStyle;
42860
+ this.borderColor = coerceColorValue(data.strokeStyle);
42656
42861
  this.strokeWidth = data.strokeWidth;
42657
42862
  this.updateGeometry();
42658
42863
  return this;
@@ -42760,7 +42965,7 @@ class Drawing extends BaseItem {
42760
42965
  }
42761
42966
  const ctx = context.ctx;
42762
42967
  ctx.save();
42763
- ctx.strokeStyle = this.borderColor;
42968
+ ctx.strokeStyle = resolveColor(this.borderColor, conf.theme, "foreground");
42764
42969
  ctx.lineWidth = this.strokeWidth;
42765
42970
  ctx.lineCap = "round";
42766
42971
  ctx.setLineDash(this.linePattern);
@@ -42787,7 +42992,7 @@ class Drawing extends BaseItem {
42787
42992
  svg3.setAttribute("style", "position: absolute; overflow: visible;");
42788
42993
  const pathElement = documentFactory.createElementNS("http://www.w3.org/2000/svg", "path");
42789
42994
  pathElement.setAttribute("d", this.getPathData());
42790
- pathElement.setAttribute("stroke", this.borderColor);
42995
+ pathElement.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
42791
42996
  pathElement.setAttribute("stroke-width", `${this.strokeWidth}`);
42792
42997
  pathElement.setAttribute("fill", "none");
42793
42998
  svg3.appendChild(pathElement);
@@ -42880,7 +43085,7 @@ class Drawing extends BaseItem {
42880
43085
  case "Drawing":
42881
43086
  switch (op.method) {
42882
43087
  case "setStrokeColor":
42883
- this.borderColor = op.color;
43088
+ this.borderColor = coerceColorValue(op.color);
42884
43089
  break;
42885
43090
  case "setStrokeWidth":
42886
43091
  this.strokeWidth = op.width;