@markup-canvas/core 1.0.6 → 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.
- package/README.md +42 -2
- package/dist/lib/MarkupCanvas.d.ts +1 -0
- package/dist/lib/canvas/setupCanvasContainer.d.ts +2 -1
- package/dist/lib/helpers/index.d.ts +1 -0
- package/dist/lib/helpers/withTheme.d.ts +4 -0
- package/dist/lib/rulers/constants.d.ts +3 -6
- package/dist/lib/rulers/ticks/createHorizontalTick.d.ts +1 -1
- package/dist/lib/rulers/ticks/createVerticalTick.d.ts +1 -1
- package/dist/lib/rulers/updateRulerTheme.d.ts +8 -0
- package/dist/markup-canvas.cjs.js +149 -54
- package/dist/markup-canvas.esm.js +149 -54
- package/dist/markup-canvas.umd.js +130 -47
- package/dist/markup-canvas.umd.min.js +1 -1
- package/dist/types/config.d.ts +11 -2
- package/dist/types/rulers.d.ts +2 -0
- package/package.json +4 -4
- package/src/lib/MarkupCanvas.ts +19 -1
- package/src/lib/canvas/createCanvas.ts +1 -1
- package/src/lib/canvas/setupCanvasContainer.ts +9 -1
- package/src/lib/config/constants.ts +24 -9
- package/src/lib/config/presets/editor-preset.ts +23 -7
- package/src/lib/helpers/index.ts +1 -0
- package/src/lib/helpers/withTheme.ts +17 -0
- package/src/lib/rulers/constants.ts +3 -6
- package/src/lib/rulers/createCornerBox.ts +5 -4
- package/src/lib/rulers/createGridOverlay.ts +3 -2
- package/src/lib/rulers/createHorizontalRuler.ts +5 -4
- package/src/lib/rulers/createRulers.ts +19 -0
- package/src/lib/rulers/createVerticalRuler.ts +5 -4
- package/src/lib/rulers/ticks/createHorizontalTick.ts +8 -8
- package/src/lib/rulers/ticks/createVerticalTick.ts +8 -8
- package/src/lib/rulers/updateRulerTheme.ts +46 -0
- package/src/types/config.ts +18 -3
- package/src/types/rulers.ts +2 -0
|
@@ -38,20 +38,35 @@ export const DEFAULT_CONFIG: Required<MarkupCanvasConfig> = {
|
|
|
38
38
|
|
|
39
39
|
// Visual elements
|
|
40
40
|
enableRulers: true,
|
|
41
|
-
enableGrid:
|
|
42
|
-
|
|
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(240, 240, 240, 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(104, 104, 104, 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
|
-
|
|
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: "transparent",
|
|
52
|
+
canvasBackgroundColorDark: "transparent",
|
|
53
|
+
|
|
54
|
+
// Ruler styling
|
|
55
|
+
rulerBackgroundColor: "oklch(100% 0 0 / 0.4)",
|
|
56
|
+
rulerBorderColor: "oklch(96.7% 0.001 286.375)",
|
|
57
|
+
rulerTextColor: "oklch(70.5% 0.015 286.067)",
|
|
58
|
+
rulerTickColor: "oklch(92% 0.004 286.32)",
|
|
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(44.2% 0.017 285.786)",
|
|
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
|
};
|
package/src/lib/helpers/index.ts
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 = {
|
|
@@ -4,22 +4,23 @@ import { RULER_Z_INDEX } from "./constants";
|
|
|
4
4
|
export function createCornerBox(config: Required<MarkupCanvasConfig>): HTMLElement {
|
|
5
5
|
const corner = document.createElement("div");
|
|
6
6
|
corner.className = "canvas-ruler corner-box";
|
|
7
|
+
|
|
7
8
|
corner.style.cssText = `
|
|
8
9
|
position: absolute;
|
|
9
10
|
top: 0;
|
|
10
11
|
left: 0;
|
|
11
12
|
width: ${config.rulerSize}px;
|
|
12
13
|
height: ${config.rulerSize}px;
|
|
13
|
-
background:
|
|
14
|
-
border-right: 1px solid
|
|
15
|
-
border-bottom: 1px solid
|
|
14
|
+
background: var(--ruler-background-color);
|
|
15
|
+
border-right: 1px solid var(--ruler-border-color);
|
|
16
|
+
border-bottom: 1px solid var(--ruler-border-color);
|
|
16
17
|
z-index: ${RULER_Z_INDEX.CORNER};
|
|
17
18
|
display: flex;
|
|
18
19
|
align-items: center;
|
|
19
20
|
justify-content: center;
|
|
20
21
|
font-family: ${config.rulerFontFamily};
|
|
21
22
|
font-size: ${config.rulerFontSize - 2}px;
|
|
22
|
-
color:
|
|
23
|
+
color: var(--ruler-text-color);
|
|
23
24
|
pointer-events: none;
|
|
24
25
|
`;
|
|
25
26
|
corner.textContent = config.rulerUnits;
|
|
@@ -4,6 +4,7 @@ import { RULER_Z_INDEX } from "./constants";
|
|
|
4
4
|
export function createGridOverlay(config: Required<MarkupCanvasConfig>): HTMLElement {
|
|
5
5
|
const grid = document.createElement("div");
|
|
6
6
|
grid.className = "canvas-ruler grid-overlay";
|
|
7
|
+
|
|
7
8
|
grid.style.cssText = `
|
|
8
9
|
position: absolute;
|
|
9
10
|
top: ${config.rulerSize}px;
|
|
@@ -13,8 +14,8 @@ export function createGridOverlay(config: Required<MarkupCanvasConfig>): HTMLEle
|
|
|
13
14
|
pointer-events: none;
|
|
14
15
|
z-index: ${RULER_Z_INDEX.GRID};
|
|
15
16
|
background-image:
|
|
16
|
-
linear-gradient(
|
|
17
|
-
linear-gradient(90deg,
|
|
17
|
+
linear-gradient(var(--grid-color) 1px, transparent 1px),
|
|
18
|
+
linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
|
|
18
19
|
background-size: 100px 100px;
|
|
19
20
|
opacity: 0.5;
|
|
20
21
|
`;
|
|
@@ -4,20 +4,21 @@ import { RULER_Z_INDEX } from "./constants";
|
|
|
4
4
|
export function createHorizontalRuler(config: Required<MarkupCanvasConfig>): HTMLElement {
|
|
5
5
|
const ruler = document.createElement("div");
|
|
6
6
|
ruler.className = "canvas-ruler horizontal-ruler";
|
|
7
|
+
|
|
7
8
|
ruler.style.cssText = `
|
|
8
9
|
position: absolute;
|
|
9
10
|
top: 0;
|
|
10
11
|
left: ${config.rulerSize}px;
|
|
11
12
|
right: 0;
|
|
12
13
|
height: ${config.rulerSize}px;
|
|
13
|
-
background:
|
|
14
|
-
border-bottom: 1px solid
|
|
15
|
-
border-right: 1px solid
|
|
14
|
+
background: var(--ruler-background-color);
|
|
15
|
+
border-bottom: 1px solid var(--ruler-border-color);
|
|
16
|
+
border-right: 1px solid var(--ruler-border-color);
|
|
16
17
|
z-index: ${RULER_Z_INDEX.RULERS};
|
|
17
18
|
pointer-events: none;
|
|
18
19
|
font-family: ${config.rulerFontFamily};
|
|
19
20
|
font-size: ${config.rulerFontSize}px;
|
|
20
|
-
color:
|
|
21
|
+
color: var(--ruler-text-color);
|
|
21
22
|
overflow: hidden;
|
|
22
23
|
`;
|
|
23
24
|
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) {
|
|
@@ -23,8 +24,19 @@ export function createRulers(canvas: Canvas, config: Required<MarkupCanvasConfig
|
|
|
23
24
|
elements = createRulerElements(canvas.container, config);
|
|
24
25
|
cleanupEvents = setupRulerEvents(canvas, safeUpdate);
|
|
25
26
|
|
|
27
|
+
updateRulerTheme(elements, config);
|
|
28
|
+
|
|
26
29
|
safeUpdate();
|
|
27
30
|
|
|
31
|
+
if (!config.showRulers) {
|
|
32
|
+
elements.horizontalRuler.style.display = "none";
|
|
33
|
+
elements.verticalRuler.style.display = "none";
|
|
34
|
+
elements.cornerBox.style.display = "none";
|
|
35
|
+
}
|
|
36
|
+
if (!config.showGrid && elements.gridOverlay) {
|
|
37
|
+
elements.gridOverlay.style.display = "none";
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
return {
|
|
29
41
|
horizontalRuler: elements.horizontalRuler,
|
|
30
42
|
verticalRuler: elements.verticalRuler,
|
|
@@ -33,6 +45,13 @@ export function createRulers(canvas: Canvas, config: Required<MarkupCanvasConfig
|
|
|
33
45
|
|
|
34
46
|
update: safeUpdate,
|
|
35
47
|
|
|
48
|
+
updateTheme: (newConfig: Required<MarkupCanvasConfig>) => {
|
|
49
|
+
if (isDestroyed) return;
|
|
50
|
+
|
|
51
|
+
// Update all ruler theme colors
|
|
52
|
+
updateRulerTheme(elements, newConfig);
|
|
53
|
+
},
|
|
54
|
+
|
|
36
55
|
show: () => {
|
|
37
56
|
if (elements.horizontalRuler) elements.horizontalRuler.style.display = "block";
|
|
38
57
|
if (elements.verticalRuler) elements.verticalRuler.style.display = "block";
|
|
@@ -4,20 +4,21 @@ import { RULER_Z_INDEX } from "./constants";
|
|
|
4
4
|
export function createVerticalRuler(config: Required<MarkupCanvasConfig>): HTMLElement {
|
|
5
5
|
const ruler = document.createElement("div");
|
|
6
6
|
ruler.className = "canvas-ruler vertical-ruler";
|
|
7
|
+
|
|
7
8
|
ruler.style.cssText = `
|
|
8
9
|
position: absolute;
|
|
9
10
|
top: ${config.rulerSize}px;
|
|
10
11
|
left: 0;
|
|
11
12
|
bottom: 0;
|
|
12
13
|
width: ${config.rulerSize}px;
|
|
13
|
-
background:
|
|
14
|
-
border-right: 1px solid
|
|
15
|
-
border-bottom: 1px solid
|
|
14
|
+
background: var(--ruler-background-color);
|
|
15
|
+
border-right: 1px solid var(--ruler-border-color);
|
|
16
|
+
border-bottom: 1px solid var(--ruler-border-color);
|
|
16
17
|
z-index: ${RULER_Z_INDEX.RULERS};
|
|
17
18
|
pointer-events: none;
|
|
18
19
|
font-family: ${config.rulerFontFamily};
|
|
19
20
|
font-size: ${config.rulerFontSize}px;
|
|
20
|
-
color:
|
|
21
|
+
color: var(--ruler-text-color);
|
|
21
22
|
overflow: hidden;
|
|
22
23
|
`;
|
|
23
24
|
return ruler;
|
|
@@ -5,34 +5,34 @@ export function createHorizontalTick(
|
|
|
5
5
|
container: HTMLElement | DocumentFragment,
|
|
6
6
|
position: number,
|
|
7
7
|
pixelPos: number,
|
|
8
|
-
|
|
8
|
+
_tickSpacing: number,
|
|
9
9
|
config: Required<MarkupCanvasConfig>
|
|
10
10
|
): void {
|
|
11
11
|
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;
|
|
14
12
|
|
|
13
|
+
tick.className = "tick";
|
|
15
14
|
tick.style.cssText = `
|
|
16
15
|
position: absolute;
|
|
17
16
|
left: ${pixelPos}px;
|
|
18
17
|
bottom: 0;
|
|
19
18
|
width: 1px;
|
|
20
|
-
height: ${
|
|
21
|
-
background:
|
|
19
|
+
height: ${TICK_SETTINGS.TICK_HEIGHT}px;
|
|
20
|
+
background: var(--ruler-tick-color);
|
|
22
21
|
`;
|
|
23
22
|
|
|
24
23
|
container.appendChild(tick);
|
|
25
24
|
|
|
26
|
-
const shouldShowLabel =
|
|
25
|
+
const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
|
|
27
26
|
if (shouldShowLabel) {
|
|
28
27
|
const label = document.createElement("div");
|
|
28
|
+
|
|
29
29
|
label.style.cssText = `
|
|
30
30
|
position: absolute;
|
|
31
31
|
left: ${pixelPos}px;
|
|
32
|
-
bottom: ${
|
|
32
|
+
bottom: ${TICK_SETTINGS.TICK_HEIGHT + 2}px;
|
|
33
33
|
font-size: ${config.rulerFontSize}px;
|
|
34
34
|
line-height: 1;
|
|
35
|
-
color:
|
|
35
|
+
color: var(--ruler-text-color);
|
|
36
36
|
white-space: nowrap;
|
|
37
37
|
pointer-events: none;
|
|
38
38
|
`;
|
|
@@ -5,34 +5,34 @@ export function createVerticalTick(
|
|
|
5
5
|
container: HTMLElement | DocumentFragment,
|
|
6
6
|
position: number,
|
|
7
7
|
pixelPos: number,
|
|
8
|
-
|
|
8
|
+
_tickSpacing: number,
|
|
9
9
|
config: Required<MarkupCanvasConfig>
|
|
10
10
|
): void {
|
|
11
11
|
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;
|
|
14
12
|
|
|
13
|
+
tick.className = "tick";
|
|
15
14
|
tick.style.cssText = `
|
|
16
15
|
position: absolute;
|
|
17
16
|
top: ${pixelPos}px;
|
|
18
17
|
right: 0;
|
|
19
|
-
width: ${
|
|
18
|
+
width: ${TICK_SETTINGS.TICK_WIDTH}px;
|
|
20
19
|
height: 1px;
|
|
21
|
-
background:
|
|
20
|
+
background: var(--ruler-tick-color);
|
|
22
21
|
`;
|
|
23
22
|
|
|
24
23
|
container.appendChild(tick);
|
|
25
24
|
|
|
26
|
-
const shouldShowLabel =
|
|
25
|
+
const shouldShowLabel = position % TICK_SETTINGS.TICK_LABEL_INTERVAL === 0;
|
|
27
26
|
if (shouldShowLabel) {
|
|
28
27
|
const label = document.createElement("div");
|
|
28
|
+
|
|
29
29
|
label.style.cssText = `
|
|
30
30
|
position: absolute;
|
|
31
31
|
top: ${pixelPos - 6}px;
|
|
32
|
-
right: ${
|
|
32
|
+
right: ${TICK_SETTINGS.TICK_WIDTH + 6}px;
|
|
33
33
|
font-size: ${config.rulerFontSize}px;
|
|
34
34
|
line-height: 1;
|
|
35
|
-
color:
|
|
35
|
+
color: var(--ruler-text-color);
|
|
36
36
|
white-space: nowrap;
|
|
37
37
|
pointer-events: none;
|
|
38
38
|
transform: rotate(-90deg);
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export function updateRulerTheme(elements: RulerThemeUpdater, config: Required<MarkupCanvasConfig>): void {
|
|
12
|
+
// Get theme-aware colors
|
|
13
|
+
const backgroundColor = getThemeValue(config, "rulerBackgroundColor");
|
|
14
|
+
const borderColor = getThemeValue(config, "rulerBorderColor");
|
|
15
|
+
const textColor = getThemeValue(config, "rulerTextColor");
|
|
16
|
+
const tickColor = getThemeValue(config, "rulerTickColor");
|
|
17
|
+
const gridColor = getThemeValue(config, "gridColor");
|
|
18
|
+
|
|
19
|
+
// Update horizontal ruler with CSS variables
|
|
20
|
+
if (elements.horizontalRuler) {
|
|
21
|
+
elements.horizontalRuler.style.setProperty("--ruler-background-color", backgroundColor);
|
|
22
|
+
elements.horizontalRuler.style.setProperty("--ruler-border-color", borderColor);
|
|
23
|
+
elements.horizontalRuler.style.setProperty("--ruler-text-color", textColor);
|
|
24
|
+
elements.horizontalRuler.style.setProperty("--ruler-tick-color", tickColor);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Update vertical ruler with CSS variables
|
|
28
|
+
if (elements.verticalRuler) {
|
|
29
|
+
elements.verticalRuler.style.setProperty("--ruler-background-color", backgroundColor);
|
|
30
|
+
elements.verticalRuler.style.setProperty("--ruler-border-color", borderColor);
|
|
31
|
+
elements.verticalRuler.style.setProperty("--ruler-text-color", textColor);
|
|
32
|
+
elements.verticalRuler.style.setProperty("--ruler-tick-color", tickColor);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Update corner box with CSS variables
|
|
36
|
+
if (elements.cornerBox) {
|
|
37
|
+
elements.cornerBox.style.setProperty("--ruler-background-color", backgroundColor);
|
|
38
|
+
elements.cornerBox.style.setProperty("--ruler-border-color", borderColor);
|
|
39
|
+
elements.cornerBox.style.setProperty("--ruler-text-color", textColor);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Update grid overlay with CSS variables
|
|
43
|
+
if (elements.gridOverlay) {
|
|
44
|
+
elements.gridOverlay.style.setProperty("--grid-color", gridColor);
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/types/config.ts
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
|
|
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
|
}
|
package/src/types/rulers.ts
CHANGED
|
@@ -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;
|