@markup-canvas/core 1.0.5 → 1.0.7

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 (34) hide show
  1. package/README.md +42 -2
  2. package/dist/lib/MarkupCanvas.d.ts +1 -0
  3. package/dist/lib/canvas/setupCanvasContainer.d.ts +2 -1
  4. package/dist/lib/helpers/index.d.ts +1 -0
  5. package/dist/lib/helpers/withTheme.d.ts +4 -0
  6. package/dist/lib/rulers/constants.d.ts +3 -6
  7. package/dist/lib/rulers/ticks/createHorizontalTick.d.ts +1 -1
  8. package/dist/lib/rulers/ticks/createVerticalTick.d.ts +1 -1
  9. package/dist/lib/rulers/updateRulerTheme.d.ts +13 -0
  10. package/dist/markup-canvas.cjs.js +170 -54
  11. package/dist/markup-canvas.esm.js +170 -54
  12. package/dist/markup-canvas.umd.js +151 -47
  13. package/dist/markup-canvas.umd.min.js +1 -1
  14. package/dist/types/config.d.ts +11 -2
  15. package/dist/types/rulers.d.ts +2 -0
  16. package/package.json +4 -4
  17. package/src/lib/MarkupCanvas.ts +19 -1
  18. package/src/lib/canvas/createCanvas.ts +1 -1
  19. package/src/lib/canvas/setupCanvasContainer.ts +9 -1
  20. package/src/lib/config/constants.ts +24 -9
  21. package/src/lib/config/presets/editor-preset.ts +23 -7
  22. package/src/lib/helpers/index.ts +1 -0
  23. package/src/lib/helpers/withTheme.ts +17 -0
  24. package/src/lib/rulers/constants.ts +3 -6
  25. package/src/lib/rulers/createCornerBox.ts +9 -4
  26. package/src/lib/rulers/createGridOverlay.ts +5 -2
  27. package/src/lib/rulers/createHorizontalRuler.ts +9 -4
  28. package/src/lib/rulers/createRulers.ts +20 -0
  29. package/src/lib/rulers/createVerticalRuler.ts +9 -4
  30. package/src/lib/rulers/ticks/createHorizontalTick.ts +10 -8
  31. package/src/lib/rulers/ticks/createVerticalTick.ts +10 -8
  32. package/src/lib/rulers/updateRulerTheme.ts +54 -0
  33. package/src/types/config.ts +18 -3
  34. package/src/types/rulers.ts +2 -0
@@ -1,7 +1,9 @@
1
1
  import { checkContainerDimensions } from "@/lib/canvas/checkContainerDimensions";
2
2
  import { CANVAS_CONTAINER_CLASS } from "@/lib/constants";
3
+ import { getThemeValue } from "@/lib/helpers/index.js";
4
+ import type { MarkupCanvasConfig } from "@/types/index.js";
3
5
 
4
- export function setupCanvasContainer(container: HTMLElement): void {
6
+ export function setupCanvasContainer(container: HTMLElement, config?: Required<MarkupCanvasConfig>): void {
5
7
  const currentPosition = getComputedStyle(container).position;
6
8
  if (currentPosition === "static") {
7
9
  container.style.position = "relative";
@@ -10,6 +12,12 @@ export function setupCanvasContainer(container: HTMLElement): void {
10
12
  container.style.cursor = "grab";
11
13
  container.style.overscrollBehavior = "none";
12
14
 
15
+ // Apply canvas background color
16
+ if (config) {
17
+ const backgroundColor = getThemeValue(config, "canvasBackgroundColor");
18
+ container.style.backgroundColor = backgroundColor;
19
+ }
20
+
13
21
  if (!container.hasAttribute("tabindex")) {
14
22
  container.setAttribute("tabindex", "0");
15
23
  }
@@ -38,20 +38,35 @@ export const DEFAULT_CONFIG: Required<MarkupCanvasConfig> = {
38
38
 
39
39
  // Visual elements
40
40
  enableRulers: true,
41
- enableGrid: true,
42
- gridColor: "rgba(0, 123, 255, 0.1)",
43
-
44
- // Ruler styling
45
- rulerBackgroundColor: "rgba(255, 255, 255, 0.95)",
46
- rulerBorderColor: "#ddd",
47
- rulerTextColor: "#666",
48
- rulerMajorTickColor: "#999",
49
- rulerMinorTickColor: "#ccc",
41
+ enableGrid: false,
42
+ showRulers: true,
43
+ showGrid: false,
50
44
  rulerFontSize: 9,
51
45
  rulerFontFamily: "Monaco, Menlo, monospace",
52
46
  rulerUnits: "px",
53
47
  rulerSize: 20,
54
48
 
49
+ // Canvas styling
50
+ canvasBackgroundColor: "rgba(250, 250, 250, 1)",
51
+ canvasBackgroundColorDark: "rgba(40, 40, 40, 1)",
52
+
53
+ // Ruler styling (light theme)
54
+ rulerBackgroundColor: "rgba(255, 255, 255, 0.95)",
55
+ rulerBorderColor: "rgba(221, 221, 221, 1)",
56
+ rulerTextColor: "rgba(102, 102, 102, 1)",
57
+ rulerTickColor: "rgba(204, 204, 204, 1)",
58
+ gridColor: "rgba(232, 86, 193, 0.5)",
59
+
60
+ // Ruler styling (dark theme)
61
+ rulerBackgroundColorDark: "rgba(30, 30, 30, 0.95)",
62
+ rulerBorderColorDark: "rgba(68, 68, 68, 1)",
63
+ rulerTextColorDark: "rgba(170, 170, 170, 1)",
64
+ rulerTickColorDark: "rgba(56, 56, 56, 1)",
65
+ gridColorDark: "rgba(232, 86, 193, 0.5)",
66
+
67
+ // Theme
68
+ themeMode: "light",
69
+
55
70
  // Callbacks
56
71
  onTransformUpdate: () => {},
57
72
  };
@@ -39,19 +39,35 @@ export const EDITOR_PRESET: Required<MarkupCanvasConfig> = {
39
39
  // Visual elements
40
40
  enableRulers: true,
41
41
  enableGrid: false,
42
- gridColor: "rgba(0, 123, 255, 0.1)",
42
+ showRulers: true,
43
+ showGrid: false,
43
44
 
44
- // Ruler styling
45
- rulerBackgroundColor: "rgba(255, 255, 255, 0.4)",
46
- rulerBorderColor: "#ddd",
47
- rulerTextColor: "oklch(70.5% 0.015 286.067)",
48
- rulerMajorTickColor: "oklch(87.1% 0.006 286.286)",
49
- rulerMinorTickColor: "oklch(92% 0.004 286.32)",
50
45
  rulerFontSize: 9,
51
46
  rulerFontFamily: "Monaco, Menlo, monospace",
52
47
  rulerUnits: "px",
53
48
  rulerSize: 20,
54
49
 
50
+ // Canvas styling
51
+ canvasBackgroundColor: "oklch(98.5% 0 0)",
52
+ canvasBackgroundColorDark: "oklch(21% 0.006 285.885)",
53
+
54
+ // Ruler styling
55
+ rulerBackgroundColor: "oklch(100% 0 0 / 0.4)",
56
+ rulerBorderColor: "oklch(98.5% 0 0)",
57
+ rulerTextColor: "oklch(70.5% 0.015 286.067)",
58
+ rulerTickColor: "oklch(70.5% 0.015 286.067)",
59
+ gridColor: "rgba(232, 86, 193, 0.5)",
60
+
61
+ // Ruler styling (dark theme)
62
+ rulerBackgroundColorDark: "oklch(27.4% 0.006 286.033)",
63
+ rulerBorderColorDark: "oklch(37% 0.013 285.805)",
64
+ rulerTextColorDark: "oklch(55.2% 0.016 285.938)",
65
+ rulerTickColorDark: "oklch(55.2% 0.016 285.938)",
66
+ gridColorDark: "rgba(232, 86, 193, 0.5)",
67
+
68
+ // Theme
69
+ themeMode: "light",
70
+
55
71
  // Callbacks
56
72
  onTransformUpdate: () => {},
57
73
  };
@@ -10,3 +10,4 @@ export {
10
10
  withRulerSize,
11
11
  } from "./withRulerCheck.js";
12
12
  export { withRulerOffset } from "./withRulerOffset.js";
13
+ export { getThemeValue } from "./withTheme.js";
@@ -0,0 +1,17 @@
1
+ import type { MarkupCanvasConfig } from "@/types";
2
+
3
+ type ThemeColorKey =
4
+ | "canvasBackgroundColor"
5
+ | "rulerBackgroundColor"
6
+ | "rulerBorderColor"
7
+ | "rulerTextColor"
8
+ | "rulerTickColor"
9
+ | "gridColor";
10
+
11
+ export function getThemeValue(config: Required<MarkupCanvasConfig>, key: ThemeColorKey): string {
12
+ if (config.themeMode === "dark") {
13
+ const darkKey = `${key}Dark` as keyof Required<MarkupCanvasConfig>;
14
+ return config[darkKey] as string;
15
+ }
16
+ return config[key as keyof Required<MarkupCanvasConfig>] as string;
17
+ }
@@ -6,12 +6,9 @@ export const RULER_Z_INDEX = {
6
6
  } as const;
7
7
 
8
8
  export const TICK_SETTINGS = {
9
- MAJOR_HEIGHT: 6,
10
- MINOR_HEIGHT: 4,
11
- MAJOR_WIDTH: 8,
12
- MINOR_WIDTH: 4,
13
- MAJOR_MULTIPLIER: 5,
14
- LABEL_INTERVAL: 100,
9
+ TICK_HEIGHT: 4,
10
+ TICK_WIDTH: 4,
11
+ TICK_LABEL_INTERVAL: 100,
15
12
  } as const;
16
13
 
17
14
  export const GRID_SETTINGS = {
@@ -1,25 +1,30 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import type { MarkupCanvasConfig } from "@/types/index.js";
2
3
  import { RULER_Z_INDEX } from "./constants";
3
4
 
4
5
  export function createCornerBox(config: Required<MarkupCanvasConfig>): HTMLElement {
5
6
  const corner = document.createElement("div");
6
7
  corner.className = "canvas-ruler corner-box";
8
+ const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
9
+ const borderColor = getThemeValue(config, "rulerBorderColor");
10
+ const textColor = getThemeValue(config, "rulerTextColor");
11
+
7
12
  corner.style.cssText = `
8
13
  position: absolute;
9
14
  top: 0;
10
15
  left: 0;
11
16
  width: ${config.rulerSize}px;
12
17
  height: ${config.rulerSize}px;
13
- background: ${config.rulerBackgroundColor};
14
- border-right: 1px solid ${config.rulerBorderColor};
15
- border-bottom: 1px solid ${config.rulerBorderColor};
18
+ background: ${backgroundColor};
19
+ border-right: 1px solid ${borderColor};
20
+ border-bottom: 1px solid ${borderColor};
16
21
  z-index: ${RULER_Z_INDEX.CORNER};
17
22
  display: flex;
18
23
  align-items: center;
19
24
  justify-content: center;
20
25
  font-family: ${config.rulerFontFamily};
21
26
  font-size: ${config.rulerFontSize - 2}px;
22
- color: ${config.rulerTextColor};
27
+ color: ${textColor};
23
28
  pointer-events: none;
24
29
  `;
25
30
  corner.textContent = config.rulerUnits;
@@ -1,9 +1,12 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import type { MarkupCanvasConfig } from "@/types/index.js";
2
3
  import { RULER_Z_INDEX } from "./constants";
3
4
 
4
5
  export function createGridOverlay(config: Required<MarkupCanvasConfig>): HTMLElement {
5
6
  const grid = document.createElement("div");
6
7
  grid.className = "canvas-ruler grid-overlay";
8
+ const gridColor = getThemeValue(config, "gridColor");
9
+
7
10
  grid.style.cssText = `
8
11
  position: absolute;
9
12
  top: ${config.rulerSize}px;
@@ -13,8 +16,8 @@ export function createGridOverlay(config: Required<MarkupCanvasConfig>): HTMLEle
13
16
  pointer-events: none;
14
17
  z-index: ${RULER_Z_INDEX.GRID};
15
18
  background-image:
16
- linear-gradient(${config.gridColor} 1px, transparent 1px),
17
- linear-gradient(90deg, ${config.gridColor} 1px, transparent 1px);
19
+ linear-gradient(${gridColor} 1px, transparent 1px),
20
+ linear-gradient(90deg, ${gridColor} 1px, transparent 1px);
18
21
  background-size: 100px 100px;
19
22
  opacity: 0.5;
20
23
  `;
@@ -1,23 +1,28 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import type { MarkupCanvasConfig } from "@/types/index.js";
2
3
  import { RULER_Z_INDEX } from "./constants";
3
4
 
4
5
  export function createHorizontalRuler(config: Required<MarkupCanvasConfig>): HTMLElement {
5
6
  const ruler = document.createElement("div");
6
7
  ruler.className = "canvas-ruler horizontal-ruler";
8
+ const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
9
+ const borderColor = getThemeValue(config, "rulerBorderColor");
10
+ const textColor = getThemeValue(config, "rulerTextColor");
11
+
7
12
  ruler.style.cssText = `
8
13
  position: absolute;
9
14
  top: 0;
10
15
  left: ${config.rulerSize}px;
11
16
  right: 0;
12
17
  height: ${config.rulerSize}px;
13
- background: ${config.rulerBackgroundColor};
14
- border-bottom: 1px solid ${config.rulerBorderColor};
15
- border-right: 1px solid ${config.rulerBorderColor};
18
+ background: ${backgroundColor};
19
+ border-bottom: 1px solid ${borderColor};
20
+ border-right: 1px solid ${borderColor};
16
21
  z-index: ${RULER_Z_INDEX.RULERS};
17
22
  pointer-events: none;
18
23
  font-family: ${config.rulerFontFamily};
19
24
  font-size: ${config.rulerFontSize}px;
20
- color: ${config.rulerTextColor};
25
+ color: ${textColor};
21
26
  overflow: hidden;
22
27
  `;
23
28
  return ruler;
@@ -3,6 +3,7 @@ import type { RulerElements } from "@/types/rulers.js";
3
3
  import { createRulerElements } from "./createRulerElements.js";
4
4
  import { setupRulerEvents } from "./setupRulerEvents.js";
5
5
  import { updateRulers } from "./updateRulers.js";
6
+ import { updateRulerTheme } from "./updateRulerTheme.js";
6
7
 
7
8
  export function createRulers(canvas: Canvas, config: Required<MarkupCanvasConfig>): RulerSystem | null {
8
9
  if (!canvas?.container) {
@@ -25,6 +26,15 @@ export function createRulers(canvas: Canvas, config: Required<MarkupCanvasConfig
25
26
 
26
27
  safeUpdate();
27
28
 
29
+ if (!config.showRulers) {
30
+ elements.horizontalRuler.style.display = "none";
31
+ elements.verticalRuler.style.display = "none";
32
+ elements.cornerBox.style.display = "none";
33
+ }
34
+ if (!config.showGrid && elements.gridOverlay) {
35
+ elements.gridOverlay.style.display = "none";
36
+ }
37
+
28
38
  return {
29
39
  horizontalRuler: elements.horizontalRuler,
30
40
  verticalRuler: elements.verticalRuler,
@@ -33,6 +43,16 @@ export function createRulers(canvas: Canvas, config: Required<MarkupCanvasConfig
33
43
 
34
44
  update: safeUpdate,
35
45
 
46
+ updateTheme: (newConfig: Required<MarkupCanvasConfig>) => {
47
+ if (isDestroyed) return;
48
+
49
+ // Update all ruler theme colors
50
+ updateRulerTheme(elements, newConfig);
51
+
52
+ // Re-render rulers to update tick colors
53
+ safeUpdate();
54
+ },
55
+
36
56
  show: () => {
37
57
  if (elements.horizontalRuler) elements.horizontalRuler.style.display = "block";
38
58
  if (elements.verticalRuler) elements.verticalRuler.style.display = "block";
@@ -1,23 +1,28 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import type { MarkupCanvasConfig } from "@/types/index.js";
2
3
  import { RULER_Z_INDEX } from "./constants";
3
4
 
4
5
  export function createVerticalRuler(config: Required<MarkupCanvasConfig>): HTMLElement {
5
6
  const ruler = document.createElement("div");
6
7
  ruler.className = "canvas-ruler vertical-ruler";
8
+ const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
9
+ const borderColor = getThemeValue(config, "rulerBorderColor");
10
+ const textColor = getThemeValue(config, "rulerTextColor");
11
+
7
12
  ruler.style.cssText = `
8
13
  position: absolute;
9
14
  top: ${config.rulerSize}px;
10
15
  left: 0;
11
16
  bottom: 0;
12
17
  width: ${config.rulerSize}px;
13
- background: ${config.rulerBackgroundColor};
14
- border-right: 1px solid ${config.rulerBorderColor};
15
- border-bottom: 1px solid ${config.rulerBorderColor};
18
+ background: ${backgroundColor};
19
+ border-right: 1px solid ${borderColor};
20
+ border-bottom: 1px solid ${borderColor};
16
21
  z-index: ${RULER_Z_INDEX.RULERS};
17
22
  pointer-events: none;
18
23
  font-family: ${config.rulerFontFamily};
19
24
  font-size: ${config.rulerFontSize}px;
20
- color: ${config.rulerTextColor};
25
+ color: ${textColor};
21
26
  overflow: hidden;
22
27
  `;
23
28
  return ruler;
@@ -1,3 +1,4 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import { TICK_SETTINGS } from "@/lib/rulers/constants.js";
2
3
  import type { MarkupCanvasConfig } from "@/types/index.js";
3
4
 
@@ -5,34 +6,35 @@ export function createHorizontalTick(
5
6
  container: HTMLElement | DocumentFragment,
6
7
  position: number,
7
8
  pixelPos: number,
8
- tickSpacing: number,
9
+ _tickSpacing: number,
9
10
  config: Required<MarkupCanvasConfig>
10
11
  ): void {
11
12
  const tick = document.createElement("div");
12
- const isMajor = position % (tickSpacing * TICK_SETTINGS.MAJOR_MULTIPLIER) === 0;
13
- const tickHeight = isMajor ? TICK_SETTINGS.MAJOR_HEIGHT : TICK_SETTINGS.MINOR_HEIGHT;
13
+ const tickColor = getThemeValue(config, "rulerTickColor");
14
14
 
15
15
  tick.style.cssText = `
16
16
  position: absolute;
17
17
  left: ${pixelPos}px;
18
18
  bottom: 0;
19
19
  width: 1px;
20
- height: ${tickHeight}px;
21
- background: ${isMajor ? config.rulerMajorTickColor : config.rulerMinorTickColor};
20
+ height: ${TICK_SETTINGS.TICK_HEIGHT}px;
21
+ background: ${tickColor};
22
22
  `;
23
23
 
24
24
  container.appendChild(tick);
25
25
 
26
- const shouldShowLabel = isMajor || position % TICK_SETTINGS.LABEL_INTERVAL === 0;
26
+ const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
27
27
  if (shouldShowLabel) {
28
28
  const label = document.createElement("div");
29
+ const textColor = getThemeValue(config, "rulerTextColor");
30
+
29
31
  label.style.cssText = `
30
32
  position: absolute;
31
33
  left: ${pixelPos}px;
32
- bottom: ${tickHeight}px;
34
+ bottom: ${TICK_SETTINGS.TICK_HEIGHT + 2}px;
33
35
  font-size: ${config.rulerFontSize}px;
34
36
  line-height: 1;
35
- color: ${config.rulerTextColor};
37
+ color: ${textColor};
36
38
  white-space: nowrap;
37
39
  pointer-events: none;
38
40
  `;
@@ -1,3 +1,4 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
1
2
  import { TICK_SETTINGS } from "@/lib/rulers/constants.js";
2
3
  import type { MarkupCanvasConfig } from "@/types/index.js";
3
4
 
@@ -5,34 +6,35 @@ export function createVerticalTick(
5
6
  container: HTMLElement | DocumentFragment,
6
7
  position: number,
7
8
  pixelPos: number,
8
- tickSpacing: number,
9
+ _tickSpacing: number,
9
10
  config: Required<MarkupCanvasConfig>
10
11
  ): void {
11
12
  const tick = document.createElement("div");
12
- const isMajor = position % (tickSpacing * TICK_SETTINGS.MAJOR_MULTIPLIER) === 0;
13
- const tickWidth = isMajor ? TICK_SETTINGS.MAJOR_WIDTH : TICK_SETTINGS.MINOR_WIDTH;
13
+ const tickColor = getThemeValue(config, "rulerTickColor");
14
14
 
15
15
  tick.style.cssText = `
16
16
  position: absolute;
17
17
  top: ${pixelPos}px;
18
18
  right: 0;
19
- width: ${tickWidth}px;
19
+ width: ${TICK_SETTINGS.TICK_WIDTH}px;
20
20
  height: 1px;
21
- background: ${isMajor ? config.rulerMajorTickColor : config.rulerMinorTickColor};
21
+ background: ${tickColor};
22
22
  `;
23
23
 
24
24
  container.appendChild(tick);
25
25
 
26
- const shouldShowLabel = isMajor || position % TICK_SETTINGS.LABEL_INTERVAL === 0;
26
+ const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
27
27
  if (shouldShowLabel) {
28
28
  const label = document.createElement("div");
29
+ const textColor = getThemeValue(config, "rulerTextColor");
30
+
29
31
  label.style.cssText = `
30
32
  position: absolute;
31
33
  top: ${pixelPos - 6}px;
32
- right: ${tickWidth + 6}px;
34
+ right: ${TICK_SETTINGS.TICK_WIDTH + 6}px;
33
35
  font-size: ${config.rulerFontSize}px;
34
36
  line-height: 1;
35
- color: ${config.rulerTextColor};
37
+ color: ${textColor};
36
38
  white-space: nowrap;
37
39
  pointer-events: none;
38
40
  transform: rotate(-90deg);
@@ -0,0 +1,54 @@
1
+ import { getThemeValue } from "@/lib/helpers/index.js";
2
+ import type { MarkupCanvasConfig } from "@/types/index.js";
3
+
4
+ export interface RulerThemeUpdater {
5
+ horizontalRuler?: HTMLElement;
6
+ verticalRuler?: HTMLElement;
7
+ cornerBox?: HTMLElement;
8
+ gridOverlay?: HTMLElement;
9
+ }
10
+
11
+ /**
12
+ * Updates all ruler elements with new theme colors
13
+ * @param elements - The ruler elements to update
14
+ * @param config - The canvas config containing theme and color settings
15
+ */
16
+ export function updateRulerTheme(elements: RulerThemeUpdater, config: Required<MarkupCanvasConfig>): void {
17
+ // Get theme-aware colors
18
+ const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
19
+ const borderColor = getThemeValue(config, "rulerBorderColor");
20
+ const textColor = getThemeValue(config, "rulerTextColor");
21
+ const gridColor = getThemeValue(config, "gridColor");
22
+
23
+ // Update horizontal ruler
24
+ if (elements.horizontalRuler) {
25
+ elements.horizontalRuler.style.background = backgroundColor;
26
+ elements.horizontalRuler.style.borderBottomColor = borderColor;
27
+ elements.horizontalRuler.style.borderRightColor = borderColor;
28
+ elements.horizontalRuler.style.color = textColor;
29
+ }
30
+
31
+ // Update vertical ruler
32
+ if (elements.verticalRuler) {
33
+ elements.verticalRuler.style.background = backgroundColor;
34
+ elements.verticalRuler.style.borderRightColor = borderColor;
35
+ elements.verticalRuler.style.borderBottomColor = borderColor;
36
+ elements.verticalRuler.style.color = textColor;
37
+ }
38
+
39
+ // Update corner box
40
+ if (elements.cornerBox) {
41
+ elements.cornerBox.style.background = backgroundColor;
42
+ elements.cornerBox.style.borderRightColor = borderColor;
43
+ elements.cornerBox.style.borderBottomColor = borderColor;
44
+ elements.cornerBox.style.color = textColor;
45
+ }
46
+
47
+ // Update grid overlay
48
+ if (elements.gridOverlay) {
49
+ elements.gridOverlay.style.backgroundImage = `
50
+ linear-gradient(${gridColor} 1px, transparent 1px),
51
+ linear-gradient(90deg, ${gridColor} 1px, transparent 1px)
52
+ `;
53
+ }
54
+ }
@@ -37,19 +37,34 @@ export interface MarkupCanvasConfig {
37
37
  // Visual elements
38
38
  enableRulers?: boolean;
39
39
  enableGrid?: boolean;
40
+ showRulers?: boolean;
41
+ showGrid?: boolean;
40
42
  gridColor?: string;
41
43
 
42
- // Ruler styling
44
+ // Canvas styling
45
+ canvasBackgroundColor?: string;
46
+ canvasBackgroundColorDark?: string;
47
+
48
+ // Ruler styling (light theme)
43
49
  rulerBackgroundColor?: string;
44
50
  rulerBorderColor?: string;
45
51
  rulerTextColor?: string;
46
- rulerMajorTickColor?: string;
47
- rulerMinorTickColor?: string;
52
+ rulerTickColor?: string;
48
53
  rulerFontSize?: number;
49
54
  rulerFontFamily?: string;
50
55
  rulerUnits?: string;
51
56
  rulerSize?: number;
52
57
 
58
+ // Ruler styling (dark theme)
59
+ rulerBackgroundColorDark?: string;
60
+ rulerBorderColorDark?: string;
61
+ rulerTextColorDark?: string;
62
+ rulerTickColorDark?: string;
63
+ gridColorDark?: string;
64
+
65
+ // Theme
66
+ themeMode?: "light" | "dark";
67
+
53
68
  // Callbacks
54
69
  onTransformUpdate?: (transform: Transform) => void;
55
70
  }
@@ -1,4 +1,5 @@
1
1
  import type { CanvasBounds, Transform } from "./canvas.js";
2
+ import type { MarkupCanvasConfig } from "./config.js";
2
3
 
3
4
  export interface RulerSystem {
4
5
  horizontalRuler: HTMLElement;
@@ -6,6 +7,7 @@ export interface RulerSystem {
6
7
  cornerBox: HTMLElement;
7
8
  gridOverlay?: HTMLElement;
8
9
  update: () => void;
10
+ updateTheme: (config: Required<MarkupCanvasConfig>) => void;
9
11
  show: () => void;
10
12
  hide: () => void;
11
13
  toggleGrid: () => void;