@markup-canvas/core 1.0.7 → 1.0.8

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.
@@ -5,9 +5,4 @@ export interface RulerThemeUpdater {
5
5
  cornerBox?: HTMLElement;
6
6
  gridOverlay?: HTMLElement;
7
7
  }
8
- /**
9
- * Updates all ruler elements with new theme colors
10
- * @param elements - The ruler elements to update
11
- * @param config - The canvas config containing theme and color settings
12
- */
13
8
  export declare function updateRulerTheme(elements: RulerThemeUpdater, config: Required<MarkupCanvasConfig>): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Markup Canvas
3
3
  * High-performance markup canvas with zoom and pan capabilities
4
- * @version 1.0.7
4
+ * @version 1.0.8
5
5
  */
6
6
  'use strict';
7
7
 
@@ -47,17 +47,17 @@ const EDITOR_PRESET = {
47
47
  rulerUnits: "px",
48
48
  rulerSize: 20,
49
49
  // Canvas styling
50
- canvasBackgroundColor: "oklch(98.5% 0 0)",
51
- canvasBackgroundColorDark: "oklch(21% 0.006 285.885)",
50
+ canvasBackgroundColor: "transparent",
51
+ canvasBackgroundColorDark: "transparent",
52
52
  // Ruler styling
53
53
  rulerBackgroundColor: "oklch(100% 0 0 / 0.4)",
54
- rulerBorderColor: "oklch(98.5% 0 0)",
54
+ rulerBorderColor: "oklch(96.7% 0.001 286.375)",
55
55
  rulerTextColor: "oklch(70.5% 0.015 286.067)",
56
- rulerTickColor: "oklch(70.5% 0.015 286.067)",
56
+ rulerTickColor: "oklch(92% 0.004 286.32)",
57
57
  gridColor: "rgba(232, 86, 193, 0.5)",
58
58
  // Ruler styling (dark theme)
59
59
  rulerBackgroundColorDark: "oklch(27.4% 0.006 286.033)",
60
- rulerBorderColorDark: "oklch(37% 0.013 285.805)",
60
+ rulerBorderColorDark: "oklch(44.2% 0.017 285.786)",
61
61
  rulerTextColorDark: "oklch(55.2% 0.016 285.938)",
62
62
  rulerTickColorDark: "oklch(55.2% 0.016 285.938)",
63
63
  gridColorDark: "rgba(232, 86, 193, 0.5)",
@@ -349,7 +349,7 @@ const DEFAULT_CONFIG = {
349
349
  canvasBackgroundColorDark: "rgba(40, 40, 40, 1)",
350
350
  // Ruler styling (light theme)
351
351
  rulerBackgroundColor: "rgba(255, 255, 255, 0.95)",
352
- rulerBorderColor: "rgba(221, 221, 221, 1)",
352
+ rulerBorderColor: "rgba(240, 240, 240, 1)",
353
353
  rulerTextColor: "rgba(102, 102, 102, 1)",
354
354
  rulerTickColor: "rgba(204, 204, 204, 1)",
355
355
  gridColor: "rgba(232, 86, 193, 0.5)",
@@ -357,7 +357,7 @@ const DEFAULT_CONFIG = {
357
357
  rulerBackgroundColorDark: "rgba(30, 30, 30, 0.95)",
358
358
  rulerBorderColorDark: "rgba(68, 68, 68, 1)",
359
359
  rulerTextColorDark: "rgba(170, 170, 170, 1)",
360
- rulerTickColorDark: "rgba(56, 56, 56, 1)",
360
+ rulerTickColorDark: "rgba(104, 104, 104, 1)",
361
361
  gridColorDark: "rgba(232, 86, 193, 0.5)",
362
362
  // Theme
363
363
  themeMode: "light",
@@ -1380,25 +1380,22 @@ const GRID_SETTINGS = {
1380
1380
  function createCornerBox(config) {
1381
1381
  const corner = document.createElement("div");
1382
1382
  corner.className = "canvas-ruler corner-box";
1383
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1384
- const borderColor = getThemeValue(config, "rulerBorderColor");
1385
- const textColor = getThemeValue(config, "rulerTextColor");
1386
1383
  corner.style.cssText = `
1387
1384
  position: absolute;
1388
1385
  top: 0;
1389
1386
  left: 0;
1390
1387
  width: ${config.rulerSize}px;
1391
1388
  height: ${config.rulerSize}px;
1392
- background: ${backgroundColor};
1393
- border-right: 1px solid ${borderColor};
1394
- border-bottom: 1px solid ${borderColor};
1389
+ background: var(--ruler-background-color);
1390
+ border-right: 1px solid var(--ruler-border-color);
1391
+ border-bottom: 1px solid var(--ruler-border-color);
1395
1392
  z-index: ${RULER_Z_INDEX.CORNER};
1396
1393
  display: flex;
1397
1394
  align-items: center;
1398
1395
  justify-content: center;
1399
1396
  font-family: ${config.rulerFontFamily};
1400
1397
  font-size: ${config.rulerFontSize - 2}px;
1401
- color: ${textColor};
1398
+ color: var(--ruler-text-color);
1402
1399
  pointer-events: none;
1403
1400
  `;
1404
1401
  corner.textContent = config.rulerUnits;
@@ -1408,7 +1405,6 @@ function createCornerBox(config) {
1408
1405
  function createGridOverlay(config) {
1409
1406
  const grid = document.createElement("div");
1410
1407
  grid.className = "canvas-ruler grid-overlay";
1411
- const gridColor = getThemeValue(config, "gridColor");
1412
1408
  grid.style.cssText = `
1413
1409
  position: absolute;
1414
1410
  top: ${config.rulerSize}px;
@@ -1418,8 +1414,8 @@ function createGridOverlay(config) {
1418
1414
  pointer-events: none;
1419
1415
  z-index: ${RULER_Z_INDEX.GRID};
1420
1416
  background-image:
1421
- linear-gradient(${gridColor} 1px, transparent 1px),
1422
- linear-gradient(90deg, ${gridColor} 1px, transparent 1px);
1417
+ linear-gradient(var(--grid-color) 1px, transparent 1px),
1418
+ linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
1423
1419
  background-size: 100px 100px;
1424
1420
  opacity: 0.5;
1425
1421
  `;
@@ -1429,23 +1425,20 @@ function createGridOverlay(config) {
1429
1425
  function createHorizontalRuler(config) {
1430
1426
  const ruler = document.createElement("div");
1431
1427
  ruler.className = "canvas-ruler horizontal-ruler";
1432
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1433
- const borderColor = getThemeValue(config, "rulerBorderColor");
1434
- const textColor = getThemeValue(config, "rulerTextColor");
1435
1428
  ruler.style.cssText = `
1436
1429
  position: absolute;
1437
1430
  top: 0;
1438
1431
  left: ${config.rulerSize}px;
1439
1432
  right: 0;
1440
1433
  height: ${config.rulerSize}px;
1441
- background: ${backgroundColor};
1442
- border-bottom: 1px solid ${borderColor};
1443
- border-right: 1px solid ${borderColor};
1434
+ background: var(--ruler-background-color);
1435
+ border-bottom: 1px solid var(--ruler-border-color);
1436
+ border-right: 1px solid var(--ruler-border-color);
1444
1437
  z-index: ${RULER_Z_INDEX.RULERS};
1445
1438
  pointer-events: none;
1446
1439
  font-family: ${config.rulerFontFamily};
1447
1440
  font-size: ${config.rulerFontSize}px;
1448
- color: ${textColor};
1441
+ color: var(--ruler-text-color);
1449
1442
  overflow: hidden;
1450
1443
  `;
1451
1444
  return ruler;
@@ -1454,23 +1447,20 @@ function createHorizontalRuler(config) {
1454
1447
  function createVerticalRuler(config) {
1455
1448
  const ruler = document.createElement("div");
1456
1449
  ruler.className = "canvas-ruler vertical-ruler";
1457
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1458
- const borderColor = getThemeValue(config, "rulerBorderColor");
1459
- const textColor = getThemeValue(config, "rulerTextColor");
1460
1450
  ruler.style.cssText = `
1461
1451
  position: absolute;
1462
1452
  top: ${config.rulerSize}px;
1463
1453
  left: 0;
1464
1454
  bottom: 0;
1465
1455
  width: ${config.rulerSize}px;
1466
- background: ${backgroundColor};
1467
- border-right: 1px solid ${borderColor};
1468
- border-bottom: 1px solid ${borderColor};
1456
+ background: var(--ruler-background-color);
1457
+ border-right: 1px solid var(--ruler-border-color);
1458
+ border-bottom: 1px solid var(--ruler-border-color);
1469
1459
  z-index: ${RULER_Z_INDEX.RULERS};
1470
1460
  pointer-events: none;
1471
1461
  font-family: ${config.rulerFontFamily};
1472
1462
  font-size: ${config.rulerFontSize}px;
1473
- color: ${textColor};
1463
+ color: var(--ruler-text-color);
1474
1464
  overflow: hidden;
1475
1465
  `;
1476
1466
  return ruler;
@@ -1542,27 +1532,26 @@ function calculateTickSpacing(contentSize, canvasSize) {
1542
1532
 
1543
1533
  function createHorizontalTick(container, position, pixelPos, _tickSpacing, config) {
1544
1534
  const tick = document.createElement("div");
1545
- const tickColor = getThemeValue(config, "rulerTickColor");
1535
+ tick.className = "tick";
1546
1536
  tick.style.cssText = `
1547
1537
  position: absolute;
1548
1538
  left: ${pixelPos}px;
1549
1539
  bottom: 0;
1550
1540
  width: 1px;
1551
1541
  height: ${TICK_SETTINGS.TICK_HEIGHT}px;
1552
- background: ${tickColor};
1542
+ background: var(--ruler-tick-color);
1553
1543
  `;
1554
1544
  container.appendChild(tick);
1555
1545
  const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
1556
1546
  if (shouldShowLabel) {
1557
1547
  const label = document.createElement("div");
1558
- const textColor = getThemeValue(config, "rulerTextColor");
1559
1548
  label.style.cssText = `
1560
1549
  position: absolute;
1561
1550
  left: ${pixelPos}px;
1562
1551
  bottom: ${TICK_SETTINGS.TICK_HEIGHT + 2}px;
1563
1552
  font-size: ${config.rulerFontSize}px;
1564
1553
  line-height: 1;
1565
- color: ${textColor};
1554
+ color: var(--ruler-text-color);
1566
1555
  white-space: nowrap;
1567
1556
  pointer-events: none;
1568
1557
  `;
@@ -1590,27 +1579,26 @@ function updateHorizontalRuler(ruler, contentLeft, contentRight, canvasWidth, sc
1590
1579
 
1591
1580
  function createVerticalTick(container, position, pixelPos, _tickSpacing, config) {
1592
1581
  const tick = document.createElement("div");
1593
- const tickColor = getThemeValue(config, "rulerTickColor");
1582
+ tick.className = "tick";
1594
1583
  tick.style.cssText = `
1595
1584
  position: absolute;
1596
1585
  top: ${pixelPos}px;
1597
1586
  right: 0;
1598
1587
  width: ${TICK_SETTINGS.TICK_WIDTH}px;
1599
1588
  height: 1px;
1600
- background: ${tickColor};
1589
+ background: var(--ruler-tick-color);
1601
1590
  `;
1602
1591
  container.appendChild(tick);
1603
1592
  const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
1604
1593
  if (shouldShowLabel) {
1605
1594
  const label = document.createElement("div");
1606
- const textColor = getThemeValue(config, "rulerTextColor");
1607
1595
  label.style.cssText = `
1608
1596
  position: absolute;
1609
1597
  top: ${pixelPos - 6}px;
1610
1598
  right: ${TICK_SETTINGS.TICK_WIDTH + 6}px;
1611
1599
  font-size: ${config.rulerFontSize}px;
1612
1600
  line-height: 1;
1613
- color: ${textColor};
1601
+ color: var(--ruler-text-color);
1614
1602
  white-space: nowrap;
1615
1603
  pointer-events: none;
1616
1604
  transform: rotate(-90deg);
@@ -1656,44 +1644,36 @@ function updateRulers(canvas, horizontalRuler, verticalRuler, gridOverlay, confi
1656
1644
  }
1657
1645
  }
1658
1646
 
1659
- /**
1660
- * Updates all ruler elements with new theme colors
1661
- * @param elements - The ruler elements to update
1662
- * @param config - The canvas config containing theme and color settings
1663
- */
1664
1647
  function updateRulerTheme(elements, config) {
1665
1648
  // Get theme-aware colors
1666
1649
  const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1667
1650
  const borderColor = getThemeValue(config, "rulerBorderColor");
1668
1651
  const textColor = getThemeValue(config, "rulerTextColor");
1652
+ const tickColor = getThemeValue(config, "rulerTickColor");
1669
1653
  const gridColor = getThemeValue(config, "gridColor");
1670
- // Update horizontal ruler
1654
+ // Update horizontal ruler with CSS variables
1671
1655
  if (elements.horizontalRuler) {
1672
- elements.horizontalRuler.style.background = backgroundColor;
1673
- elements.horizontalRuler.style.borderBottomColor = borderColor;
1674
- elements.horizontalRuler.style.borderRightColor = borderColor;
1675
- elements.horizontalRuler.style.color = textColor;
1656
+ elements.horizontalRuler.style.setProperty("--ruler-background-color", backgroundColor);
1657
+ elements.horizontalRuler.style.setProperty("--ruler-border-color", borderColor);
1658
+ elements.horizontalRuler.style.setProperty("--ruler-text-color", textColor);
1659
+ elements.horizontalRuler.style.setProperty("--ruler-tick-color", tickColor);
1676
1660
  }
1677
- // Update vertical ruler
1661
+ // Update vertical ruler with CSS variables
1678
1662
  if (elements.verticalRuler) {
1679
- elements.verticalRuler.style.background = backgroundColor;
1680
- elements.verticalRuler.style.borderRightColor = borderColor;
1681
- elements.verticalRuler.style.borderBottomColor = borderColor;
1682
- elements.verticalRuler.style.color = textColor;
1663
+ elements.verticalRuler.style.setProperty("--ruler-background-color", backgroundColor);
1664
+ elements.verticalRuler.style.setProperty("--ruler-border-color", borderColor);
1665
+ elements.verticalRuler.style.setProperty("--ruler-text-color", textColor);
1666
+ elements.verticalRuler.style.setProperty("--ruler-tick-color", tickColor);
1683
1667
  }
1684
- // Update corner box
1668
+ // Update corner box with CSS variables
1685
1669
  if (elements.cornerBox) {
1686
- elements.cornerBox.style.background = backgroundColor;
1687
- elements.cornerBox.style.borderRightColor = borderColor;
1688
- elements.cornerBox.style.borderBottomColor = borderColor;
1689
- elements.cornerBox.style.color = textColor;
1670
+ elements.cornerBox.style.setProperty("--ruler-background-color", backgroundColor);
1671
+ elements.cornerBox.style.setProperty("--ruler-border-color", borderColor);
1672
+ elements.cornerBox.style.setProperty("--ruler-text-color", textColor);
1690
1673
  }
1691
- // Update grid overlay
1674
+ // Update grid overlay with CSS variables
1692
1675
  if (elements.gridOverlay) {
1693
- elements.gridOverlay.style.backgroundImage = `
1694
- linear-gradient(${gridColor} 1px, transparent 1px),
1695
- linear-gradient(90deg, ${gridColor} 1px, transparent 1px)
1696
- `;
1676
+ elements.gridOverlay.style.setProperty("--grid-color", gridColor);
1697
1677
  }
1698
1678
  }
1699
1679
 
@@ -1713,6 +1693,7 @@ function createRulers(canvas, config) {
1713
1693
  try {
1714
1694
  elements = createRulerElements(canvas.container, config);
1715
1695
  cleanupEvents = setupRulerEvents(canvas, safeUpdate);
1696
+ updateRulerTheme(elements, config);
1716
1697
  safeUpdate();
1717
1698
  if (!config.showRulers) {
1718
1699
  elements.horizontalRuler.style.display = "none";
@@ -1733,8 +1714,6 @@ function createRulers(canvas, config) {
1733
1714
  return;
1734
1715
  // Update all ruler theme colors
1735
1716
  updateRulerTheme(elements, newConfig);
1736
- // Re-render rulers to update tick colors
1737
- safeUpdate();
1738
1717
  },
1739
1718
  show: () => {
1740
1719
  if (elements.horizontalRuler)
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Markup Canvas
3
3
  * High-performance markup canvas with zoom and pan capabilities
4
- * @version 1.0.7
4
+ * @version 1.0.8
5
5
  */
6
6
  const EDITOR_PRESET = {
7
7
  // Canvas dimensions
@@ -43,17 +43,17 @@ const EDITOR_PRESET = {
43
43
  rulerUnits: "px",
44
44
  rulerSize: 20,
45
45
  // Canvas styling
46
- canvasBackgroundColor: "oklch(98.5% 0 0)",
47
- canvasBackgroundColorDark: "oklch(21% 0.006 285.885)",
46
+ canvasBackgroundColor: "transparent",
47
+ canvasBackgroundColorDark: "transparent",
48
48
  // Ruler styling
49
49
  rulerBackgroundColor: "oklch(100% 0 0 / 0.4)",
50
- rulerBorderColor: "oklch(98.5% 0 0)",
50
+ rulerBorderColor: "oklch(96.7% 0.001 286.375)",
51
51
  rulerTextColor: "oklch(70.5% 0.015 286.067)",
52
- rulerTickColor: "oklch(70.5% 0.015 286.067)",
52
+ rulerTickColor: "oklch(92% 0.004 286.32)",
53
53
  gridColor: "rgba(232, 86, 193, 0.5)",
54
54
  // Ruler styling (dark theme)
55
55
  rulerBackgroundColorDark: "oklch(27.4% 0.006 286.033)",
56
- rulerBorderColorDark: "oklch(37% 0.013 285.805)",
56
+ rulerBorderColorDark: "oklch(44.2% 0.017 285.786)",
57
57
  rulerTextColorDark: "oklch(55.2% 0.016 285.938)",
58
58
  rulerTickColorDark: "oklch(55.2% 0.016 285.938)",
59
59
  gridColorDark: "rgba(232, 86, 193, 0.5)",
@@ -345,7 +345,7 @@ const DEFAULT_CONFIG = {
345
345
  canvasBackgroundColorDark: "rgba(40, 40, 40, 1)",
346
346
  // Ruler styling (light theme)
347
347
  rulerBackgroundColor: "rgba(255, 255, 255, 0.95)",
348
- rulerBorderColor: "rgba(221, 221, 221, 1)",
348
+ rulerBorderColor: "rgba(240, 240, 240, 1)",
349
349
  rulerTextColor: "rgba(102, 102, 102, 1)",
350
350
  rulerTickColor: "rgba(204, 204, 204, 1)",
351
351
  gridColor: "rgba(232, 86, 193, 0.5)",
@@ -353,7 +353,7 @@ const DEFAULT_CONFIG = {
353
353
  rulerBackgroundColorDark: "rgba(30, 30, 30, 0.95)",
354
354
  rulerBorderColorDark: "rgba(68, 68, 68, 1)",
355
355
  rulerTextColorDark: "rgba(170, 170, 170, 1)",
356
- rulerTickColorDark: "rgba(56, 56, 56, 1)",
356
+ rulerTickColorDark: "rgba(104, 104, 104, 1)",
357
357
  gridColorDark: "rgba(232, 86, 193, 0.5)",
358
358
  // Theme
359
359
  themeMode: "light",
@@ -1376,25 +1376,22 @@ const GRID_SETTINGS = {
1376
1376
  function createCornerBox(config) {
1377
1377
  const corner = document.createElement("div");
1378
1378
  corner.className = "canvas-ruler corner-box";
1379
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1380
- const borderColor = getThemeValue(config, "rulerBorderColor");
1381
- const textColor = getThemeValue(config, "rulerTextColor");
1382
1379
  corner.style.cssText = `
1383
1380
  position: absolute;
1384
1381
  top: 0;
1385
1382
  left: 0;
1386
1383
  width: ${config.rulerSize}px;
1387
1384
  height: ${config.rulerSize}px;
1388
- background: ${backgroundColor};
1389
- border-right: 1px solid ${borderColor};
1390
- border-bottom: 1px solid ${borderColor};
1385
+ background: var(--ruler-background-color);
1386
+ border-right: 1px solid var(--ruler-border-color);
1387
+ border-bottom: 1px solid var(--ruler-border-color);
1391
1388
  z-index: ${RULER_Z_INDEX.CORNER};
1392
1389
  display: flex;
1393
1390
  align-items: center;
1394
1391
  justify-content: center;
1395
1392
  font-family: ${config.rulerFontFamily};
1396
1393
  font-size: ${config.rulerFontSize - 2}px;
1397
- color: ${textColor};
1394
+ color: var(--ruler-text-color);
1398
1395
  pointer-events: none;
1399
1396
  `;
1400
1397
  corner.textContent = config.rulerUnits;
@@ -1404,7 +1401,6 @@ function createCornerBox(config) {
1404
1401
  function createGridOverlay(config) {
1405
1402
  const grid = document.createElement("div");
1406
1403
  grid.className = "canvas-ruler grid-overlay";
1407
- const gridColor = getThemeValue(config, "gridColor");
1408
1404
  grid.style.cssText = `
1409
1405
  position: absolute;
1410
1406
  top: ${config.rulerSize}px;
@@ -1414,8 +1410,8 @@ function createGridOverlay(config) {
1414
1410
  pointer-events: none;
1415
1411
  z-index: ${RULER_Z_INDEX.GRID};
1416
1412
  background-image:
1417
- linear-gradient(${gridColor} 1px, transparent 1px),
1418
- linear-gradient(90deg, ${gridColor} 1px, transparent 1px);
1413
+ linear-gradient(var(--grid-color) 1px, transparent 1px),
1414
+ linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
1419
1415
  background-size: 100px 100px;
1420
1416
  opacity: 0.5;
1421
1417
  `;
@@ -1425,23 +1421,20 @@ function createGridOverlay(config) {
1425
1421
  function createHorizontalRuler(config) {
1426
1422
  const ruler = document.createElement("div");
1427
1423
  ruler.className = "canvas-ruler horizontal-ruler";
1428
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1429
- const borderColor = getThemeValue(config, "rulerBorderColor");
1430
- const textColor = getThemeValue(config, "rulerTextColor");
1431
1424
  ruler.style.cssText = `
1432
1425
  position: absolute;
1433
1426
  top: 0;
1434
1427
  left: ${config.rulerSize}px;
1435
1428
  right: 0;
1436
1429
  height: ${config.rulerSize}px;
1437
- background: ${backgroundColor};
1438
- border-bottom: 1px solid ${borderColor};
1439
- border-right: 1px solid ${borderColor};
1430
+ background: var(--ruler-background-color);
1431
+ border-bottom: 1px solid var(--ruler-border-color);
1432
+ border-right: 1px solid var(--ruler-border-color);
1440
1433
  z-index: ${RULER_Z_INDEX.RULERS};
1441
1434
  pointer-events: none;
1442
1435
  font-family: ${config.rulerFontFamily};
1443
1436
  font-size: ${config.rulerFontSize}px;
1444
- color: ${textColor};
1437
+ color: var(--ruler-text-color);
1445
1438
  overflow: hidden;
1446
1439
  `;
1447
1440
  return ruler;
@@ -1450,23 +1443,20 @@ function createHorizontalRuler(config) {
1450
1443
  function createVerticalRuler(config) {
1451
1444
  const ruler = document.createElement("div");
1452
1445
  ruler.className = "canvas-ruler vertical-ruler";
1453
- const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1454
- const borderColor = getThemeValue(config, "rulerBorderColor");
1455
- const textColor = getThemeValue(config, "rulerTextColor");
1456
1446
  ruler.style.cssText = `
1457
1447
  position: absolute;
1458
1448
  top: ${config.rulerSize}px;
1459
1449
  left: 0;
1460
1450
  bottom: 0;
1461
1451
  width: ${config.rulerSize}px;
1462
- background: ${backgroundColor};
1463
- border-right: 1px solid ${borderColor};
1464
- border-bottom: 1px solid ${borderColor};
1452
+ background: var(--ruler-background-color);
1453
+ border-right: 1px solid var(--ruler-border-color);
1454
+ border-bottom: 1px solid var(--ruler-border-color);
1465
1455
  z-index: ${RULER_Z_INDEX.RULERS};
1466
1456
  pointer-events: none;
1467
1457
  font-family: ${config.rulerFontFamily};
1468
1458
  font-size: ${config.rulerFontSize}px;
1469
- color: ${textColor};
1459
+ color: var(--ruler-text-color);
1470
1460
  overflow: hidden;
1471
1461
  `;
1472
1462
  return ruler;
@@ -1538,27 +1528,26 @@ function calculateTickSpacing(contentSize, canvasSize) {
1538
1528
 
1539
1529
  function createHorizontalTick(container, position, pixelPos, _tickSpacing, config) {
1540
1530
  const tick = document.createElement("div");
1541
- const tickColor = getThemeValue(config, "rulerTickColor");
1531
+ tick.className = "tick";
1542
1532
  tick.style.cssText = `
1543
1533
  position: absolute;
1544
1534
  left: ${pixelPos}px;
1545
1535
  bottom: 0;
1546
1536
  width: 1px;
1547
1537
  height: ${TICK_SETTINGS.TICK_HEIGHT}px;
1548
- background: ${tickColor};
1538
+ background: var(--ruler-tick-color);
1549
1539
  `;
1550
1540
  container.appendChild(tick);
1551
1541
  const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
1552
1542
  if (shouldShowLabel) {
1553
1543
  const label = document.createElement("div");
1554
- const textColor = getThemeValue(config, "rulerTextColor");
1555
1544
  label.style.cssText = `
1556
1545
  position: absolute;
1557
1546
  left: ${pixelPos}px;
1558
1547
  bottom: ${TICK_SETTINGS.TICK_HEIGHT + 2}px;
1559
1548
  font-size: ${config.rulerFontSize}px;
1560
1549
  line-height: 1;
1561
- color: ${textColor};
1550
+ color: var(--ruler-text-color);
1562
1551
  white-space: nowrap;
1563
1552
  pointer-events: none;
1564
1553
  `;
@@ -1586,27 +1575,26 @@ function updateHorizontalRuler(ruler, contentLeft, contentRight, canvasWidth, sc
1586
1575
 
1587
1576
  function createVerticalTick(container, position, pixelPos, _tickSpacing, config) {
1588
1577
  const tick = document.createElement("div");
1589
- const tickColor = getThemeValue(config, "rulerTickColor");
1578
+ tick.className = "tick";
1590
1579
  tick.style.cssText = `
1591
1580
  position: absolute;
1592
1581
  top: ${pixelPos}px;
1593
1582
  right: 0;
1594
1583
  width: ${TICK_SETTINGS.TICK_WIDTH}px;
1595
1584
  height: 1px;
1596
- background: ${tickColor};
1585
+ background: var(--ruler-tick-color);
1597
1586
  `;
1598
1587
  container.appendChild(tick);
1599
1588
  const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
1600
1589
  if (shouldShowLabel) {
1601
1590
  const label = document.createElement("div");
1602
- const textColor = getThemeValue(config, "rulerTextColor");
1603
1591
  label.style.cssText = `
1604
1592
  position: absolute;
1605
1593
  top: ${pixelPos - 6}px;
1606
1594
  right: ${TICK_SETTINGS.TICK_WIDTH + 6}px;
1607
1595
  font-size: ${config.rulerFontSize}px;
1608
1596
  line-height: 1;
1609
- color: ${textColor};
1597
+ color: var(--ruler-text-color);
1610
1598
  white-space: nowrap;
1611
1599
  pointer-events: none;
1612
1600
  transform: rotate(-90deg);
@@ -1652,44 +1640,36 @@ function updateRulers(canvas, horizontalRuler, verticalRuler, gridOverlay, confi
1652
1640
  }
1653
1641
  }
1654
1642
 
1655
- /**
1656
- * Updates all ruler elements with new theme colors
1657
- * @param elements - The ruler elements to update
1658
- * @param config - The canvas config containing theme and color settings
1659
- */
1660
1643
  function updateRulerTheme(elements, config) {
1661
1644
  // Get theme-aware colors
1662
1645
  const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
1663
1646
  const borderColor = getThemeValue(config, "rulerBorderColor");
1664
1647
  const textColor = getThemeValue(config, "rulerTextColor");
1648
+ const tickColor = getThemeValue(config, "rulerTickColor");
1665
1649
  const gridColor = getThemeValue(config, "gridColor");
1666
- // Update horizontal ruler
1650
+ // Update horizontal ruler with CSS variables
1667
1651
  if (elements.horizontalRuler) {
1668
- elements.horizontalRuler.style.background = backgroundColor;
1669
- elements.horizontalRuler.style.borderBottomColor = borderColor;
1670
- elements.horizontalRuler.style.borderRightColor = borderColor;
1671
- elements.horizontalRuler.style.color = textColor;
1652
+ elements.horizontalRuler.style.setProperty("--ruler-background-color", backgroundColor);
1653
+ elements.horizontalRuler.style.setProperty("--ruler-border-color", borderColor);
1654
+ elements.horizontalRuler.style.setProperty("--ruler-text-color", textColor);
1655
+ elements.horizontalRuler.style.setProperty("--ruler-tick-color", tickColor);
1672
1656
  }
1673
- // Update vertical ruler
1657
+ // Update vertical ruler with CSS variables
1674
1658
  if (elements.verticalRuler) {
1675
- elements.verticalRuler.style.background = backgroundColor;
1676
- elements.verticalRuler.style.borderRightColor = borderColor;
1677
- elements.verticalRuler.style.borderBottomColor = borderColor;
1678
- elements.verticalRuler.style.color = textColor;
1659
+ elements.verticalRuler.style.setProperty("--ruler-background-color", backgroundColor);
1660
+ elements.verticalRuler.style.setProperty("--ruler-border-color", borderColor);
1661
+ elements.verticalRuler.style.setProperty("--ruler-text-color", textColor);
1662
+ elements.verticalRuler.style.setProperty("--ruler-tick-color", tickColor);
1679
1663
  }
1680
- // Update corner box
1664
+ // Update corner box with CSS variables
1681
1665
  if (elements.cornerBox) {
1682
- elements.cornerBox.style.background = backgroundColor;
1683
- elements.cornerBox.style.borderRightColor = borderColor;
1684
- elements.cornerBox.style.borderBottomColor = borderColor;
1685
- elements.cornerBox.style.color = textColor;
1666
+ elements.cornerBox.style.setProperty("--ruler-background-color", backgroundColor);
1667
+ elements.cornerBox.style.setProperty("--ruler-border-color", borderColor);
1668
+ elements.cornerBox.style.setProperty("--ruler-text-color", textColor);
1686
1669
  }
1687
- // Update grid overlay
1670
+ // Update grid overlay with CSS variables
1688
1671
  if (elements.gridOverlay) {
1689
- elements.gridOverlay.style.backgroundImage = `
1690
- linear-gradient(${gridColor} 1px, transparent 1px),
1691
- linear-gradient(90deg, ${gridColor} 1px, transparent 1px)
1692
- `;
1672
+ elements.gridOverlay.style.setProperty("--grid-color", gridColor);
1693
1673
  }
1694
1674
  }
1695
1675
 
@@ -1709,6 +1689,7 @@ function createRulers(canvas, config) {
1709
1689
  try {
1710
1690
  elements = createRulerElements(canvas.container, config);
1711
1691
  cleanupEvents = setupRulerEvents(canvas, safeUpdate);
1692
+ updateRulerTheme(elements, config);
1712
1693
  safeUpdate();
1713
1694
  if (!config.showRulers) {
1714
1695
  elements.horizontalRuler.style.display = "none";
@@ -1729,8 +1710,6 @@ function createRulers(canvas, config) {
1729
1710
  return;
1730
1711
  // Update all ruler theme colors
1731
1712
  updateRulerTheme(elements, newConfig);
1732
- // Re-render rulers to update tick colors
1733
- safeUpdate();
1734
1713
  },
1735
1714
  show: () => {
1736
1715
  if (elements.horizontalRuler)