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/cjs/node.js CHANGED
@@ -1674,12 +1674,17 @@ __export(exports_node, {
1674
1674
  tempStorage: () => tempStorage,
1675
1675
  tagByType: () => tagByType,
1676
1676
  stickerColors: () => stickerColors,
1677
+ srgbChannelToLinear: () => srgbChannelToLinear,
1677
1678
  sha256: () => sha256,
1679
+ semanticColor: () => semanticColor,
1678
1680
  scalePatterns: () => scalePatterns,
1679
1681
  scaleElementBy: () => scaleElementBy,
1680
1682
  rgbToRgba: () => rgbToRgba,
1683
+ resolvePairedForeground: () => resolvePairedForeground,
1684
+ resolveColor: () => resolveColor,
1681
1685
  resizeAndConvertToPng: () => resizeAndConvertToPng,
1682
1686
  resetElementScale: () => resetElementScale,
1687
+ relativeLuminance: () => relativeLuminance,
1683
1688
  registerItem: () => registerItem,
1684
1689
  quickAddItem: () => quickAddItem,
1685
1690
  prepareVideo: () => prepareVideo,
@@ -1688,8 +1693,11 @@ __export(exports_node, {
1688
1693
  positionRelatively: () => positionRelatively,
1689
1694
  positionAbsolutely: () => positionAbsolutely,
1690
1695
  parsersHTML: () => parsersHTML,
1696
+ parseCssRgb: () => parseCssRgb,
1691
1697
  omitDefaultProperties: () => omitDefaultProperties,
1692
1698
  messageRouter: () => messageRouter,
1699
+ meetsWCAG_AAA: () => meetsWCAG_AAA,
1700
+ meetsWCAG_AA: () => meetsWCAG_AA,
1693
1701
  itemValidators: () => itemValidators,
1694
1702
  itemFactories: () => itemFactories,
1695
1703
  isShallowSimilarTo: () => isShallowSimilarTo,
@@ -1716,14 +1724,19 @@ __export(exports_node, {
1716
1724
  getControlPointData: () => getControlPointData,
1717
1725
  getBlobFromDataURL: () => getBlobFromDataURL,
1718
1726
  forceNumberIntoInterval: () => forceNumberIntoInterval,
1727
+ fixedColor: () => fixedColor,
1719
1728
  fileTosha256: () => fileTosha256,
1720
1729
  exportBoardSnapshot: () => exportBoardSnapshot,
1721
1730
  editModeHotkeyRegistry: () => editModeHotkeyRegistry,
1722
1731
  decodeHtml: () => decodeHtml,
1723
1732
  cursors: () => defaultCursors,
1733
+ cssContrastRatio: () => cssContrastRatio,
1724
1734
  createVideoItem: () => createVideoItem,
1725
1735
  createEvents: () => createEvents,
1736
+ contrastRatio: () => contrastRatio,
1726
1737
  conf: () => conf,
1738
+ coerceOptionalColorValue: () => coerceOptionalColorValue,
1739
+ coerceColorValue: () => coerceColorValue,
1727
1740
  checkHotkeys: () => checkHotkeys,
1728
1741
  catmullRomInterpolate: () => catmullRomInterpolate,
1729
1742
  captureFrame: () => captureFrame,
@@ -1749,6 +1762,7 @@ __export(exports_node, {
1749
1762
  STEP_STROKE_WIDTH: () => STEP_STROKE_WIDTH,
1750
1763
  SHAPE_LAST_TYPE_KEY: () => SHAPE_LAST_TYPE_KEY,
1751
1764
  SHAPES_CATEGORIES: () => SHAPES_CATEGORIES,
1765
+ SEMANTIC_COLOR_IDS: () => SEMANTIC_COLOR_IDS,
1752
1766
  RichText: () => RichText,
1753
1767
  QuadraticBezier: () => QuadraticBezier,
1754
1768
  Presence: () => Presence,
@@ -1800,6 +1814,8 @@ __export(exports_node, {
1800
1814
  Camera: () => Camera,
1801
1815
  CURSORS_IDLE_CLEANUP_DELAY: () => CURSORS_IDLE_CLEANUP_DELAY,
1802
1816
  CURSORS_ANIMATION_DURATION: () => CURSORS_ANIMATION_DURATION,
1817
+ CONTRAST_PALETTE_LIST: () => CONTRAST_PALETTE_LIST,
1818
+ CONTRAST_PALETTE: () => CONTRAST_PALETTE,
1803
1819
  CONTEXT_NODE_HIGHLIGHT_COLOR: () => CONTEXT_NODE_HIGHLIGHT_COLOR,
1804
1820
  CONNECTOR_POINTER_TYPES: () => CONNECTOR_POINTER_TYPES,
1805
1821
  BoardSelection: () => BoardSelection,
@@ -1815,6 +1831,184 @@ __export(exports_node, {
1815
1831
  });
1816
1832
  module.exports = __toCommonJS(exports_node);
1817
1833
 
1834
+ // src/Color/ColorValue.ts
1835
+ var SEMANTIC_COLOR_IDS = [
1836
+ "contrastNeutral",
1837
+ "contrastGray",
1838
+ "contrastRed",
1839
+ "contrastOrange",
1840
+ "contrastYellow",
1841
+ "contrastGreen",
1842
+ "contrastTeal",
1843
+ "contrastBlue",
1844
+ "contrastPurple",
1845
+ "contrastPink",
1846
+ "contrastBrown"
1847
+ ];
1848
+ var semanticColor = (id) => ({
1849
+ type: "semantic",
1850
+ id
1851
+ });
1852
+ var fixedColor = (value) => ({
1853
+ type: "fixed",
1854
+ value
1855
+ });
1856
+ function coerceColorValue(value) {
1857
+ if (typeof value === "string")
1858
+ return fixedColor(value);
1859
+ return value;
1860
+ }
1861
+ function coerceOptionalColorValue(value) {
1862
+ if (value === undefined)
1863
+ return;
1864
+ return coerceColorValue(value);
1865
+ }
1866
+ // src/Color/ContrastPalette.ts
1867
+ var CONTRAST_PALETTE = {
1868
+ contrastNeutral: {
1869
+ id: "contrastNeutral",
1870
+ label: "Neutral",
1871
+ light: "rgb(245, 246, 248)",
1872
+ dark: "rgb(20, 21, 26)",
1873
+ contrastRatio: 17.2
1874
+ },
1875
+ contrastGray: {
1876
+ id: "contrastGray",
1877
+ label: "Gray",
1878
+ light: "rgb(224, 225, 229)",
1879
+ dark: "rgb(55, 58, 70)",
1880
+ contrastRatio: 8.6
1881
+ },
1882
+ contrastRed: {
1883
+ id: "contrastRed",
1884
+ label: "Red",
1885
+ light: "rgb(255, 215, 210)",
1886
+ dark: "rgb(120, 10, 10)",
1887
+ contrastRatio: 8.5
1888
+ },
1889
+ contrastOrange: {
1890
+ id: "contrastOrange",
1891
+ label: "Orange",
1892
+ light: "rgb(255, 229, 195)",
1893
+ dark: "rgb(110, 44, 0)",
1894
+ contrastRatio: 8.4
1895
+ },
1896
+ contrastYellow: {
1897
+ id: "contrastYellow",
1898
+ label: "Yellow",
1899
+ light: "rgb(255, 249, 185)",
1900
+ dark: "rgb(89, 71, 0)",
1901
+ contrastRatio: 8.3
1902
+ },
1903
+ contrastGreen: {
1904
+ id: "contrastGreen",
1905
+ label: "Green",
1906
+ light: "rgb(193, 243, 179)",
1907
+ dark: "rgb(0, 74, 22)",
1908
+ contrastRatio: 8.4
1909
+ },
1910
+ contrastTeal: {
1911
+ id: "contrastTeal",
1912
+ label: "Teal",
1913
+ light: "rgb(176, 243, 240)",
1914
+ dark: "rgb(0, 68, 64)",
1915
+ contrastRatio: 8.8
1916
+ },
1917
+ contrastBlue: {
1918
+ id: "contrastBlue",
1919
+ label: "Blue",
1920
+ light: "rgb(208, 222, 255)",
1921
+ dark: "rgb(15, 42, 148)",
1922
+ contrastRatio: 8.7
1923
+ },
1924
+ contrastPurple: {
1925
+ id: "contrastPurple",
1926
+ label: "Purple",
1927
+ light: "rgb(232, 210, 255)",
1928
+ dark: "rgb(62, 0, 132)",
1929
+ contrastRatio: 9.8
1930
+ },
1931
+ contrastPink: {
1932
+ id: "contrastPink",
1933
+ label: "Pink",
1934
+ light: "rgb(255, 212, 228)",
1935
+ dark: "rgb(120, 0, 55)",
1936
+ contrastRatio: 8.5
1937
+ },
1938
+ contrastBrown: {
1939
+ id: "contrastBrown",
1940
+ label: "Brown",
1941
+ light: "rgb(242, 224, 200)",
1942
+ dark: "rgb(74, 33, 0)",
1943
+ contrastRatio: 10.7
1944
+ }
1945
+ };
1946
+ var CONTRAST_PALETTE_LIST = [
1947
+ CONTRAST_PALETTE.contrastNeutral,
1948
+ CONTRAST_PALETTE.contrastGray,
1949
+ CONTRAST_PALETTE.contrastRed,
1950
+ CONTRAST_PALETTE.contrastOrange,
1951
+ CONTRAST_PALETTE.contrastYellow,
1952
+ CONTRAST_PALETTE.contrastGreen,
1953
+ CONTRAST_PALETTE.contrastTeal,
1954
+ CONTRAST_PALETTE.contrastBlue,
1955
+ CONTRAST_PALETTE.contrastPurple,
1956
+ CONTRAST_PALETTE.contrastPink,
1957
+ CONTRAST_PALETTE.contrastBrown
1958
+ ];
1959
+ // src/Color/resolveColor.ts
1960
+ function resolveColor(value, theme, role) {
1961
+ if (typeof value === "string")
1962
+ return value;
1963
+ if (value.type === "fixed") {
1964
+ return value.value;
1965
+ }
1966
+ const pair = CONTRAST_PALETTE[value.id];
1967
+ const lightMode = theme === "light";
1968
+ if (role === "background") {
1969
+ return lightMode ? pair.light : pair.dark;
1970
+ } else {
1971
+ return lightMode ? pair.dark : pair.light;
1972
+ }
1973
+ }
1974
+ function resolvePairedForeground(background, theme) {
1975
+ if (background.type === "semantic") {
1976
+ return resolveColor(background, theme, "foreground");
1977
+ }
1978
+ return theme === "light" ? CONTRAST_PALETTE.contrastNeutral.dark : CONTRAST_PALETTE.contrastNeutral.light;
1979
+ }
1980
+ // src/Color/colorUtils.ts
1981
+ function srgbChannelToLinear(channel) {
1982
+ const c = channel / 255;
1983
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
1984
+ }
1985
+ function relativeLuminance(r, g, b) {
1986
+ return 0.2126 * srgbChannelToLinear(r) + 0.7152 * srgbChannelToLinear(g) + 0.0722 * srgbChannelToLinear(b);
1987
+ }
1988
+ function contrastRatio(lum1, lum2) {
1989
+ const lighter = Math.max(lum1, lum2);
1990
+ const darker = Math.min(lum1, lum2);
1991
+ return (lighter + 0.05) / (darker + 0.05);
1992
+ }
1993
+ function meetsWCAG_AA(ratio) {
1994
+ return ratio >= 4.5;
1995
+ }
1996
+ function meetsWCAG_AAA(ratio) {
1997
+ return ratio >= 7;
1998
+ }
1999
+ function parseCssRgb(css) {
2000
+ const m = css.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)/);
2001
+ if (!m)
2002
+ return null;
2003
+ return [parseFloat(m[1]), parseFloat(m[2]), parseFloat(m[3])];
2004
+ }
2005
+ function cssContrastRatio(css1, css2) {
2006
+ const rgb1 = parseCssRgb(css1);
2007
+ const rgb2 = parseCssRgb(css2);
2008
+ if (!rgb1 || !rgb2)
2009
+ return null;
2010
+ return contrastRatio(relativeLuminance(...rgb1), relativeLuminance(...rgb2));
2011
+ }
1818
2012
  // src/BoardCommand.ts
1819
2013
  class BoardCommand {
1820
2014
  board;
@@ -2408,12 +2602,14 @@ class Mbr {
2408
2602
  }
2409
2603
  render(context) {
2410
2604
  const { ctx } = context;
2411
- if (this.backgroundColor !== "none") {
2412
- ctx.fillStyle = this.backgroundColor;
2605
+ const resolvedBg = typeof this.backgroundColor === "string" ? this.backgroundColor : resolveColor(this.backgroundColor, "light", "background");
2606
+ const resolvedBorder = typeof this.borderColor === "string" ? this.borderColor : resolveColor(this.borderColor, "light", "foreground");
2607
+ if (resolvedBg !== "none") {
2608
+ ctx.fillStyle = resolvedBg;
2413
2609
  ctx.fillRect(this.left, this.top, this.getWidth(), this.getHeight());
2414
2610
  }
2415
2611
  if (this.strokeWidth) {
2416
- ctx.strokeStyle = this.borderColor;
2612
+ ctx.strokeStyle = resolvedBorder;
2417
2613
  ctx.lineWidth = this.strokeWidth;
2418
2614
  ctx.setLineDash([]);
2419
2615
  ctx.strokeRect(this.left, this.top, this.getWidth(), this.getHeight());
@@ -7972,6 +8168,7 @@ var conf = {
7972
8168
  plus: "Plus",
7973
8169
  plusAI: "PlusAI"
7974
8170
  },
8171
+ theme: "light",
7975
8172
  EVENTS_PUBLISH_INTERVAL: 100,
7976
8173
  EVENTS_RESEND_INTERVAL: 1000,
7977
8174
  SELECTION_COLOR: "rgb(71, 120, 245)",
@@ -10405,7 +10602,7 @@ function fillHighlight(ctx, textBlock) {
10405
10602
  return;
10406
10603
  }
10407
10604
  const measure = textBlock.measure;
10408
- ctx.fillStyle = textBlock.style.backgroundColor;
10605
+ ctx.fillStyle = resolveColor(textBlock.style.backgroundColor, conf.theme, "background");
10409
10606
  ctx.fillRect(textBlock.x, textBlock.y - measure.ascent, measure.width, measure.height);
10410
10607
  }
10411
10608
  function underline(ctx, textBlock) {
@@ -10417,14 +10614,13 @@ function underline(ctx, textBlock) {
10417
10614
  const style = textBlock.style;
10418
10615
  const measure = textBlock.measure;
10419
10616
  const width = measure.width - (textBlock.marginLeft || 0);
10420
- const color = style.color;
10421
- ctx.strokeStyle = color;
10617
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
10422
10618
  ctx.lineWidth = textBlock.fontSize / 14;
10423
10619
  ctx.beginPath();
10424
10620
  ctx.moveTo(x, y + 2 * textBlock.fontSize / 14);
10425
10621
  ctx.lineTo(x + width, y + 2 * textBlock.fontSize / 14);
10426
10622
  ctx.stroke();
10427
- ctx.strokeStyle = style.backgroundColor ?? "black";
10623
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
10428
10624
  ctx.lineWidth = 2;
10429
10625
  }
10430
10626
  function cross(ctx, textBlock) {
@@ -10437,19 +10633,18 @@ function cross(ctx, textBlock) {
10437
10633
  const measure = textBlock.measure;
10438
10634
  const width = measure.width;
10439
10635
  const height = measure.height;
10440
- const color = style.color;
10441
- ctx.strokeStyle = color;
10636
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
10442
10637
  ctx.lineWidth = textBlock.fontSize / 14;
10443
10638
  ctx.beginPath();
10444
10639
  ctx.moveTo(x, y - height / 4);
10445
10640
  ctx.lineTo(x + width, y - height / 4);
10446
10641
  ctx.stroke();
10447
- ctx.strokeStyle = style.backgroundColor ?? "black";
10642
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
10448
10643
  ctx.lineWidth = 2;
10449
10644
  }
10450
10645
  function fillText(ctx, textBlock) {
10451
10646
  const { text, style, x, y } = textBlock;
10452
- ctx.fillStyle = style.color;
10647
+ ctx.fillStyle = resolveColor(style.color, conf.theme, "foreground");
10453
10648
  ctx.fillText(text, x, y);
10454
10649
  if (textBlock.listMark) {
10455
10650
  ctx.fillText(textBlock.listMark, x - measureText(textBlock.listMark, style).width - 4, y);
@@ -19239,7 +19434,7 @@ function setSelectionFontHighlight(editor, format, selectionContext) {
19239
19434
  }
19240
19435
  if (format === "none") {
19241
19436
  import_slate24.Editor.removeMark(editor, "fontHighlight");
19242
- } else if (marks.fontHighlight === format) {
19437
+ } else if (typeof format === "string" && marks.fontHighlight === format) {
19243
19438
  import_slate24.Editor.removeMark(editor, "fontHighlight");
19244
19439
  } else {
19245
19440
  import_slate24.Editor.addMark(editor, "fontHighlight", format);
@@ -24926,8 +25121,8 @@ class RichText extends BaseItem {
24926
25121
  node2.underline ? "underline" : "",
24927
25122
  node2["line-through"] ? "line-through" : ""
24928
25123
  ].filter(Boolean).join(" "),
24929
- color: node2.fontColor || conf.DEFAULT_TEXT_STYLES.fontColor,
24930
- backgroundColor: node2.fontHighlight || conf.DEFAULT_TEXT_STYLES.fontHighlight,
25124
+ color: node2.fontColor ? resolveColor(node2.fontColor, conf.theme, "foreground") : conf.DEFAULT_TEXT_STYLES.fontColor,
25125
+ backgroundColor: node2.fontHighlight ? resolveColor(node2.fontHighlight, conf.theme, "background") : conf.DEFAULT_TEXT_STYLES.fontHighlight,
24931
25126
  fontSize: node2.fontSize ? `${node2.fontSize}px` : `${conf.DEFAULT_TEXT_STYLES.fontSize}px`,
24932
25127
  fontFamily: node2.fontFamily || conf.DEFAULT_TEXT_STYLES.fontFamily
24933
25128
  });
@@ -39676,7 +39871,7 @@ class Connector2 extends BaseItem {
39676
39871
  this.endPointerStyle = endPointerStyle;
39677
39872
  this.transformation = new Transformation(this.id, this.board.events);
39678
39873
  this.linkTo = new LinkTo(this.id, this.board.events);
39679
- this.lineColor = lineColor ?? CONNECTOR_COLOR;
39874
+ this.lineColor = lineColor ?? fixedColor(CONNECTOR_COLOR);
39680
39875
  this.lineWidth = lineWidth ?? CONNECTOR_LINE_WIDTH;
39681
39876
  this.borderStyle = strokeStyle ?? CONNECTOR_BORDER_STYLE;
39682
39877
  this.text = new RichText(board, this.getMbr(), this.id, new Transformation, this.linkTo, conf.i18n.t("connector.textPlaceholder", {
@@ -40093,6 +40288,12 @@ class Connector2 extends BaseItem {
40093
40288
  mbr.strokeWidth = 3;
40094
40289
  mbr.borderStyle = "solid";
40095
40290
  this.clipText(context);
40291
+ const resolvedLineColor = resolveColor(this.lineColor, conf.theme, "foreground");
40292
+ this.lines.setBorderColor(resolvedLineColor);
40293
+ this.startPointer.path.setBorderColor(resolvedLineColor);
40294
+ this.startPointer.path.setBackgroundColor(resolvedLineColor);
40295
+ this.endPointer.path.setBorderColor(resolvedLineColor);
40296
+ this.endPointer.path.setBackgroundColor(resolvedLineColor);
40096
40297
  if (!this.text.isRenderEnabled && this.board.selection.getContext() !== "EditTextUnderPointer") {
40097
40298
  this.lines.render(context);
40098
40299
  }
@@ -40183,7 +40384,7 @@ class Connector2 extends BaseItem {
40183
40384
  div.style.transformOrigin = "left top";
40184
40385
  div.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
40185
40386
  div.style.position = "absolute";
40186
- div.setAttribute("data-line-color", this.lineColor);
40387
+ div.setAttribute("data-line-color", resolveColor(this.lineColor, conf.theme, "foreground"));
40187
40388
  div.setAttribute("data-line-width", this.lineWidth.toString());
40188
40389
  div.setAttribute("data-line-style", this.lineStyle);
40189
40390
  div.setAttribute("data-border-style", this.borderStyle);
@@ -40279,7 +40480,9 @@ class Connector2 extends BaseItem {
40279
40480
  this.startPointerStyle = data.startPointerStyle ?? this.startPointerStyle;
40280
40481
  this.endPointerStyle = data.endPointerStyle ?? this.endPointerStyle;
40281
40482
  this.lineStyle = data.lineStyle ?? this.lineStyle;
40282
- this.lineColor = data.lineColor ?? this.lineColor;
40483
+ if (data.lineColor != null) {
40484
+ this.lineColor = coerceColorValue(data.lineColor);
40485
+ }
40283
40486
  this.lineWidth = data.lineWidth ?? this.lineWidth;
40284
40487
  this.borderStyle = data.borderStyle ?? this.borderStyle;
40285
40488
  if (data.transformation) {
@@ -40372,16 +40575,11 @@ class Connector2 extends BaseItem {
40372
40575
  const endPoint = this.endPoint;
40373
40576
  this.lines = getLine(this.lineStyle, startPoint, endPoint, this.middlePoint).addConnectedItemType(this.itemType);
40374
40577
  this.startPointer = getStartPointer(startPoint, this.startPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
40375
- this.startPointer.path.setBorderColor(this.lineColor);
40376
40578
  this.startPointer.path.setBorderWidth(this.lineWidth);
40377
- this.startPointer.path.setBackgroundColor(this.lineColor);
40378
40579
  this.endPointer = getEndPointer(endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
40379
- this.endPointer.path.setBorderColor(this.lineColor);
40380
40580
  this.endPointer.path.setBorderWidth(this.lineWidth);
40381
- this.endPointer.path.setBackgroundColor(this.lineColor);
40382
40581
  this.offsetLines();
40383
40582
  this.lines.setBorderWidth(this.lineWidth);
40384
- this.lines.setBorderColor(this.lineColor);
40385
40583
  this.lines.setBorderStyle(this.borderStyle);
40386
40584
  this.updateTitle();
40387
40585
  }
@@ -40487,7 +40685,7 @@ class ConnectorData2 {
40487
40685
  startPointerStyle = "None";
40488
40686
  endPointerStyle = "ArrowThin";
40489
40687
  lineStyle = "straight";
40490
- lineColor = "";
40688
+ lineColor = fixedColor(CONNECTOR_COLOR);
40491
40689
  linkTo;
40492
40690
  lineWidth = 1;
40493
40691
  borderStyle = "solid";
@@ -41180,7 +41378,7 @@ class DefaultShapeData {
41180
41378
  text;
41181
41379
  linkTo;
41182
41380
  itemType = "Shape";
41183
- 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) {
41381
+ 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) {
41184
41382
  this.shapeType = shapeType;
41185
41383
  this.backgroundColor = backgroundColor;
41186
41384
  this.backgroundOpacity = backgroundOpacity;
@@ -42048,9 +42246,13 @@ class Shape extends BaseItem {
42048
42246
  if (data.linkTo) {
42049
42247
  this.linkTo.deserialize(data.linkTo);
42050
42248
  }
42051
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
42249
+ if (data.backgroundColor != null) {
42250
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
42251
+ }
42052
42252
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
42053
- this.borderColor = data.borderColor ?? this.borderColor;
42253
+ if (data.borderColor != null) {
42254
+ this.borderColor = coerceColorValue(data.borderColor);
42255
+ }
42054
42256
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
42055
42257
  this.borderStyle = data.borderStyle ?? this.borderStyle;
42056
42258
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -42157,7 +42359,6 @@ class Shape extends BaseItem {
42157
42359
  }
42158
42360
  applyBackgroundColor(backgroundColor) {
42159
42361
  this.backgroundColor = backgroundColor;
42160
- this.path.setBackgroundColor(backgroundColor);
42161
42362
  }
42162
42363
  setBackgroundColor(backgroundColor) {
42163
42364
  this.emit({
@@ -42193,7 +42394,6 @@ class Shape extends BaseItem {
42193
42394
  }
42194
42395
  applyBorderColor(borderColor) {
42195
42396
  this.borderColor = borderColor;
42196
- this.path.setBorderColor(borderColor);
42197
42397
  }
42198
42398
  setBorderColor(borderColor) {
42199
42399
  this.emit({
@@ -42301,6 +42501,8 @@ class Shape extends BaseItem {
42301
42501
  if (this.transformationRenderBlock) {
42302
42502
  return;
42303
42503
  }
42504
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
42505
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
42304
42506
  this.path.render(context);
42305
42507
  this.text.render(context);
42306
42508
  if (this.getLinkTo()) {
@@ -42401,9 +42603,7 @@ class Shape extends BaseItem {
42401
42603
  this.text.setContainer(this.textContainer.copy());
42402
42604
  this.textContainer.transform(this.transformation.toMatrix());
42403
42605
  this.path.transform(this.transformation.toMatrix());
42404
- this.path.setBackgroundColor(this.backgroundColor);
42405
42606
  this.path.setBackgroundOpacity(this.backgroundOpacity);
42406
- this.path.setBorderColor(this.borderColor);
42407
42607
  this.path.setBorderWidth(this.borderWidth);
42408
42608
  this.path.setBorderStyle(this.borderStyle);
42409
42609
  this.path.setBorderOpacity(this.borderOpacity);
@@ -42452,7 +42652,7 @@ class StickerData {
42452
42652
  linkTo;
42453
42653
  text;
42454
42654
  itemType = "Sticker";
42455
- constructor(backgroundColor = stickerColors["Sky Blue"], transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
42655
+ constructor(backgroundColor = fixedColor(stickerColors["Sky Blue"]), transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
42456
42656
  this.backgroundColor = backgroundColor;
42457
42657
  this.transformation = transformation;
42458
42658
  this.linkTo = linkTo;
@@ -42564,7 +42764,9 @@ class Sticker extends BaseItem {
42564
42764
  };
42565
42765
  }
42566
42766
  deserialize(data) {
42567
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
42767
+ if (data.backgroundColor != null) {
42768
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
42769
+ }
42568
42770
  if (data.transformation) {
42569
42771
  this.transformation.deserialize(data.transformation);
42570
42772
  }
@@ -42588,7 +42790,6 @@ class Sticker extends BaseItem {
42588
42790
  this.stickerPath.transform(this.transformation.toMatrix());
42589
42791
  this.text.setContainer(this.textContainer.copy());
42590
42792
  this.textContainer.transform(this.transformation.toMatrix());
42591
- this.stickerPath.setBackgroundColor(this.backgroundColor);
42592
42793
  this.saveStickerData();
42593
42794
  }
42594
42795
  setId(id) {
@@ -42632,7 +42833,6 @@ class Sticker extends BaseItem {
42632
42833
  }
42633
42834
  applyBackgroundColor(backgroundColor) {
42634
42835
  this.backgroundColor = backgroundColor;
42635
- this.stickerPath.setBackgroundColor(backgroundColor);
42636
42836
  }
42637
42837
  setBackgroundColor(backgroundColor) {
42638
42838
  this.emit({
@@ -42679,6 +42879,7 @@ class Sticker extends BaseItem {
42679
42879
  return;
42680
42880
  }
42681
42881
  this.renderShadow(context);
42882
+ this.stickerPath.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
42682
42883
  this.stickerPath.render(context);
42683
42884
  this.text.render(context);
42684
42885
  if (this.getLinkTo()) {
@@ -42695,7 +42896,7 @@ class Sticker extends BaseItem {
42695
42896
  const unscaledWidth = itemMbr.getWidth() / scaleX;
42696
42897
  const unscaledHeight = height2 / scaleY;
42697
42898
  div.id = this.getId();
42698
- div.style.backgroundColor = this.backgroundColor;
42899
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
42699
42900
  div.style.width = `${unscaledWidth}px`;
42700
42901
  div.style.height = `${unscaledHeight}px`;
42701
42902
  div.style.transformOrigin = "top left";
@@ -42969,7 +43170,7 @@ class DefaultFrameData {
42969
43170
  canChangeRatio;
42970
43171
  linkTo;
42971
43172
  itemType = "Frame";
42972
- 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) {
43173
+ 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) {
42973
43174
  this.shapeType = shapeType;
42974
43175
  this.backgroundColor = backgroundColor;
42975
43176
  this.backgroundOpacity = backgroundOpacity;
@@ -43177,9 +43378,13 @@ class Frame2 extends BaseItem {
43177
43378
  this.initPath();
43178
43379
  }
43179
43380
  this.linkTo.deserialize(data.linkTo);
43180
- this.backgroundColor = data.backgroundColor ?? this.backgroundColor;
43381
+ if (data.backgroundColor != null) {
43382
+ this.backgroundColor = coerceColorValue(data.backgroundColor);
43383
+ }
43181
43384
  this.backgroundOpacity = data.backgroundOpacity ?? this.backgroundOpacity;
43182
- this.borderColor = data.borderColor ?? this.borderColor;
43385
+ if (data.borderColor != null) {
43386
+ this.borderColor = coerceColorValue(data.borderColor);
43387
+ }
43183
43388
  this.borderOpacity = data.borderOpacity ?? this.borderOpacity;
43184
43389
  this.borderStyle = data.borderStyle ?? this.borderStyle;
43185
43390
  this.borderWidth = data.borderWidth ?? this.borderWidth;
@@ -43217,9 +43422,7 @@ class Frame2 extends BaseItem {
43217
43422
  this.path.transform(this.transformation.toMatrix());
43218
43423
  this.textContainer.transform(this.transformation.toMatrix());
43219
43424
  }
43220
- this.path.setBackgroundColor(this.backgroundColor);
43221
43425
  this.path.setBackgroundOpacity(this.backgroundOpacity);
43222
- this.path.setBorderColor(this.borderColor);
43223
43426
  this.path.setBorderWidth(this.borderWidth);
43224
43427
  this.path.setBorderStyle(this.borderStyle);
43225
43428
  this.path.setBorderOpacity(this.borderOpacity);
@@ -43370,7 +43573,6 @@ class Frame2 extends BaseItem {
43370
43573
  }
43371
43574
  applyBackgroundColor(backgroundColor) {
43372
43575
  this.backgroundColor = backgroundColor;
43373
- this.path.setBackgroundColor(backgroundColor);
43374
43576
  }
43375
43577
  setBackgroundColor(backgroundColor) {
43376
43578
  this.emit({
@@ -43418,6 +43620,8 @@ class Frame2 extends BaseItem {
43418
43620
  if (this.transformationRenderBlock) {
43419
43621
  return;
43420
43622
  }
43623
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
43624
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
43421
43625
  this.path.render(context);
43422
43626
  this.renderNewShape(context);
43423
43627
  if (this.getLinkTo()) {
@@ -43442,9 +43646,9 @@ class Frame2 extends BaseItem {
43442
43646
  renderHTML(documentFactory) {
43443
43647
  const div = documentFactory.createElement("frame-item");
43444
43648
  div.id = this.getId();
43445
- div.style.backgroundColor = this.backgroundColor;
43649
+ div.style.backgroundColor = resolveColor(this.backgroundColor, conf.theme, "background");
43446
43650
  div.style.opacity = this.backgroundOpacity.toString();
43447
- div.style.borderColor = this.borderColor;
43651
+ div.style.borderColor = resolveColor(this.borderColor, conf.theme, "foreground");
43448
43652
  div.style.borderWidth = `${this.borderWidth}px`;
43449
43653
  div.style.borderStyle = this.borderStyle;
43450
43654
  const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
@@ -45080,6 +45284,7 @@ class Drawing extends BaseItem {
45080
45284
  lines = [];
45081
45285
  linkTo;
45082
45286
  strokeWidth = 1;
45287
+ borderColor = fixedColor(conf.PEN_DEFAULT_COLOR);
45083
45288
  borderStyle = "solid";
45084
45289
  linePattern = scalePatterns(this.strokeWidth)[this.borderStyle];
45085
45290
  borderOpacity = 1;
@@ -45125,7 +45330,7 @@ class Drawing extends BaseItem {
45125
45330
  this.linkTo.deserialize(data.linkTo);
45126
45331
  this.optimizePoints();
45127
45332
  this.transformation.deserialize(data.transformation);
45128
- this.borderColor = data.strokeStyle;
45333
+ this.borderColor = coerceColorValue(data.strokeStyle);
45129
45334
  this.strokeWidth = data.strokeWidth;
45130
45335
  this.updateGeometry();
45131
45336
  return this;
@@ -45233,7 +45438,7 @@ class Drawing extends BaseItem {
45233
45438
  }
45234
45439
  const ctx = context.ctx;
45235
45440
  ctx.save();
45236
- ctx.strokeStyle = this.borderColor;
45441
+ ctx.strokeStyle = resolveColor(this.borderColor, conf.theme, "foreground");
45237
45442
  ctx.lineWidth = this.strokeWidth;
45238
45443
  ctx.lineCap = "round";
45239
45444
  ctx.setLineDash(this.linePattern);
@@ -45260,7 +45465,7 @@ class Drawing extends BaseItem {
45260
45465
  svg3.setAttribute("style", "position: absolute; overflow: visible;");
45261
45466
  const pathElement = documentFactory.createElementNS("http://www.w3.org/2000/svg", "path");
45262
45467
  pathElement.setAttribute("d", this.getPathData());
45263
- pathElement.setAttribute("stroke", this.borderColor);
45468
+ pathElement.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
45264
45469
  pathElement.setAttribute("stroke-width", `${this.strokeWidth}`);
45265
45470
  pathElement.setAttribute("fill", "none");
45266
45471
  svg3.appendChild(pathElement);
@@ -45353,7 +45558,7 @@ class Drawing extends BaseItem {
45353
45558
  case "Drawing":
45354
45559
  switch (op.method) {
45355
45560
  case "setStrokeColor":
45356
- this.borderColor = op.color;
45561
+ this.borderColor = coerceColorValue(op.color);
45357
45562
  break;
45358
45563
  case "setStrokeWidth":
45359
45564
  this.strokeWidth = op.width;