@markup-canvas/core 1.0.4 → 1.0.5

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 (57) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/lib/helpers/withRulerCheck.d.ts +4 -4
  3. package/dist/lib/helpers/withRulerOffset.d.ts +1 -1
  4. package/dist/lib/rulers/constants.d.ts +0 -1
  5. package/dist/lib/rulers/createCornerBox.d.ts +2 -2
  6. package/dist/lib/rulers/createGridOverlay.d.ts +2 -2
  7. package/dist/lib/rulers/createHorizontalRuler.d.ts +2 -2
  8. package/dist/lib/rulers/createRulerElements.d.ts +2 -3
  9. package/dist/lib/rulers/createVerticalRuler.d.ts +2 -2
  10. package/dist/lib/rulers/index.d.ts +1 -1
  11. package/dist/lib/rulers/ticks/createHorizontalTick.d.ts +2 -2
  12. package/dist/lib/rulers/ticks/createVerticalTick.d.ts +2 -2
  13. package/dist/lib/rulers/updateHorizontalRuler.d.ts +2 -2
  14. package/dist/lib/rulers/updateRulers.d.ts +2 -2
  15. package/dist/lib/rulers/updateVerticalRuler.d.ts +2 -2
  16. package/dist/markup-canvas.cjs.js +89 -95
  17. package/dist/markup-canvas.esm.js +89 -95
  18. package/dist/markup-canvas.umd.js +87 -94
  19. package/dist/markup-canvas.umd.min.js +1 -1
  20. package/dist/types/config.d.ts +1 -0
  21. package/dist/types/index.d.ts +1 -1
  22. package/dist/types/rulers.d.ts +6 -12
  23. package/package.json +1 -1
  24. package/src/index.ts +0 -1
  25. package/src/lib/canvas/createCanvas.ts +1 -2
  26. package/src/lib/canvas/getCanvasBounds.ts +2 -2
  27. package/src/lib/canvas/getCanvasMethods.ts +1 -3
  28. package/src/lib/canvas/setupTransformLayer.ts +1 -2
  29. package/src/lib/config/constants.ts +2 -1
  30. package/src/lib/config/createMarkupCanvasConfig.ts +5 -0
  31. package/src/lib/config/presets/editor-preset.ts +2 -1
  32. package/src/lib/events/keyboard/setupKeyboardEvents.ts +1 -1
  33. package/src/lib/events/keyboard/setupKeyboardNavigation.ts +1 -1
  34. package/src/lib/events/mouse/handleClickToZoom.ts +1 -1
  35. package/src/lib/events/touch/handleTouchMove.ts +1 -1
  36. package/src/lib/events/wheel/handleWheel.ts +1 -1
  37. package/src/lib/helpers/withRulerCheck.ts +9 -8
  38. package/src/lib/helpers/withRulerOffset.ts +3 -4
  39. package/src/lib/matrix/getZoomToMouseTransform.ts +1 -2
  40. package/src/lib/rulers/constants.ts +0 -2
  41. package/src/lib/rulers/createCornerBox.ts +12 -12
  42. package/src/lib/rulers/createGridOverlay.ts +5 -5
  43. package/src/lib/rulers/createHorizontalRuler.ts +11 -11
  44. package/src/lib/rulers/createRulerElements.ts +3 -4
  45. package/src/lib/rulers/createRulers.ts +3 -16
  46. package/src/lib/rulers/createVerticalRuler.ts +11 -11
  47. package/src/lib/rulers/index.ts +1 -1
  48. package/src/lib/rulers/ticks/createHorizontalTick.ts +6 -5
  49. package/src/lib/rulers/ticks/createVerticalTick.ts +6 -5
  50. package/src/lib/rulers/updateHorizontalRuler.ts +2 -2
  51. package/src/lib/rulers/updateRulers.ts +4 -5
  52. package/src/lib/rulers/updateVerticalRuler.ts +2 -2
  53. package/src/types/config.ts +1 -0
  54. package/src/types/index.ts +1 -1
  55. package/src/types/rulers.ts +6 -13
  56. package/dist/lib/rulers/RulerElements.d.ts +0 -6
  57. package/src/lib/rulers/RulerElements.ts +0 -6
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { EDITOR_PRESET } from "./lib/config/presets";
2
2
  export { MarkupCanvas, MarkupCanvas as default } from "./lib/MarkupCanvas.js";
3
- export type { BaseCanvas, Canvas, CanvasBounds, CanvasOptions, GestureInfo, MarkupCanvasConfig, MarkupCanvasEvents, MouseDragControls, Point, RulerCanvas, RulerOptions, RulerSystem, TouchState, Transform, ZoomBoundaryOptions, ZoomBoundaryResult, } from "./types/index.js";
3
+ export type { BaseCanvas, Canvas, CanvasBounds, CanvasOptions, GestureInfo, MarkupCanvasConfig, MarkupCanvasEvents, MouseDragControls, Point, RulerCanvas, RulerSystem, TouchState, Transform, ZoomBoundaryOptions, ZoomBoundaryResult, } from "./types/index.js";
@@ -3,16 +3,16 @@ export declare function withRulerCheck<T>(canvas: {
3
3
  }, operation: (hasRulers: boolean) => T): T;
4
4
  export declare function withRulerSize<T>(canvas: {
5
5
  container: HTMLElement;
6
- }, operation: (rulerSize: number) => T): T;
6
+ }, rulerSize: number, operation: (rulerSize: number) => T): T;
7
7
  export declare function withRulerAdjustment(canvas: {
8
8
  container: HTMLElement;
9
- }, value: number, operation?: (adjustedValue: number) => void): number;
9
+ }, rulerSize: number, value: number, operation?: (adjustedValue: number) => void): number;
10
10
  export declare function withRulerOffsets<T>(canvas: {
11
11
  container: HTMLElement;
12
- }, x: number, y: number, operation: (adjustedX: number, adjustedY: number) => T): T;
12
+ }, rulerSize: number, x: number, y: number, operation: (adjustedX: number, adjustedY: number) => T): T;
13
13
  export declare function withRulerOffsetObject<T, C extends {
14
14
  x: number;
15
15
  y: number;
16
16
  }>(canvas: {
17
17
  container: HTMLElement;
18
- }, coords: C, operation: (adjusted: C) => T): T;
18
+ }, rulerSize: number, coords: C, operation: (adjusted: C) => T): T;
@@ -1,3 +1,3 @@
1
1
  export declare function withRulerOffset<T>(canvas: {
2
2
  container: HTMLElement;
3
- }, x: number, y: number, operation: (adjustedX: number, adjustedY: number) => T): T;
3
+ }, x: number, y: number, rulerSize: number, operation: (adjustedX: number, adjustedY: number) => T): T;
@@ -1,4 +1,3 @@
1
- export declare const RULER_SIZE = 24;
2
1
  export declare const RULER_Z_INDEX: {
3
2
  readonly GRID: 100;
4
3
  readonly RULERS: 1000;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createCornerBox(config: Required<RulerOptions>): HTMLElement;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createCornerBox(config: Required<MarkupCanvasConfig>): HTMLElement;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createGridOverlay(config: Required<RulerOptions>): HTMLElement;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createGridOverlay(config: Required<MarkupCanvasConfig>): HTMLElement;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createHorizontalRuler(config: Required<RulerOptions>): HTMLElement;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createHorizontalRuler(config: Required<MarkupCanvasConfig>): HTMLElement;
@@ -1,3 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- import type { RulerElements } from "./RulerElements.js";
3
- export declare function createRulerElements(container: HTMLElement, config: Required<RulerOptions>): RulerElements;
1
+ import type { MarkupCanvasConfig, RulerElements } from "@/types/index.js";
2
+ export declare function createRulerElements(container: HTMLElement, config: Required<MarkupCanvasConfig>): RulerElements;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createVerticalRuler(config: Required<RulerOptions>): HTMLElement;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createVerticalRuler(config: Required<MarkupCanvasConfig>): HTMLElement;
@@ -1,2 +1,2 @@
1
- export type { RulerOptions, RulerSystem } from "@/types/index.js";
1
+ export type { RulerSystem } from "@/types/index.js";
2
2
  export { createRulers } from "./createRulers.js";
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createHorizontalTick(container: HTMLElement | DocumentFragment, position: number, pixelPos: number, tickSpacing: number, config: Required<RulerOptions>): void;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createHorizontalTick(container: HTMLElement | DocumentFragment, position: number, pixelPos: number, tickSpacing: number, config: Required<MarkupCanvasConfig>): void;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function createVerticalTick(container: HTMLElement | DocumentFragment, position: number, pixelPos: number, tickSpacing: number, config: Required<RulerOptions>): void;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function createVerticalTick(container: HTMLElement | DocumentFragment, position: number, pixelPos: number, tickSpacing: number, config: Required<MarkupCanvasConfig>): void;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function updateHorizontalRuler(ruler: HTMLElement, contentLeft: number, contentRight: number, canvasWidth: number, scale: number, config: Required<RulerOptions>): void;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function updateHorizontalRuler(ruler: HTMLElement, contentLeft: number, contentRight: number, canvasWidth: number, scale: number, config: Required<MarkupCanvasConfig>): void;
@@ -1,2 +1,2 @@
1
- import type { RulerCanvas as Canvas, RulerOptions } from "@/types/index.js";
2
- export declare function updateRulers(canvas: Canvas, horizontalRuler: HTMLElement, verticalRuler: HTMLElement, gridOverlay: HTMLElement | undefined, config: Required<RulerOptions>): void;
1
+ import type { RulerCanvas as Canvas, MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function updateRulers(canvas: Canvas, horizontalRuler: HTMLElement, verticalRuler: HTMLElement, gridOverlay: HTMLElement | undefined, config: Required<MarkupCanvasConfig>): void;
@@ -1,2 +1,2 @@
1
- import type { RulerOptions } from "@/types/index.js";
2
- export declare function updateVerticalRuler(ruler: HTMLElement, contentTop: number, contentBottom: number, canvasHeight: number, scale: number, config: Required<RulerOptions>): void;
1
+ import type { MarkupCanvasConfig } from "@/types/index.js";
2
+ export declare function updateVerticalRuler(ruler: HTMLElement, contentTop: number, contentBottom: number, canvasHeight: number, scale: number, 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.4
4
+ * @version 1.0.5
5
5
  */
6
6
  'use strict';
7
7
 
@@ -47,9 +47,10 @@ const EDITOR_PRESET = {
47
47
  rulerTextColor: "oklch(70.5% 0.015 286.067)",
48
48
  rulerMajorTickColor: "oklch(87.1% 0.006 286.286)",
49
49
  rulerMinorTickColor: "oklch(92% 0.004 286.32)",
50
- rulerFontSize: 8,
50
+ rulerFontSize: 9,
51
51
  rulerFontFamily: "Monaco, Menlo, monospace",
52
52
  rulerUnits: "px",
53
+ rulerSize: 20,
53
54
  // Callbacks
54
55
  onTransformUpdate: () => { },
55
56
  };
@@ -82,31 +83,10 @@ function setupContentLayer(contentLayer) {
82
83
  contentLayer.style.pointerEvents = "auto";
83
84
  }
84
85
 
85
- // Rulers
86
- const RULER_SIZE = 24;
87
- const RULER_Z_INDEX = {
88
- GRID: 100,
89
- RULERS: 1000,
90
- CORNER: 1001,
91
- };
92
- const TICK_SETTINGS = {
93
- MAJOR_HEIGHT: 6,
94
- MINOR_HEIGHT: 4,
95
- MAJOR_WIDTH: 8,
96
- MINOR_WIDTH: 4,
97
- MAJOR_MULTIPLIER: 5,
98
- LABEL_INTERVAL: 100,
99
- };
100
- const GRID_SETTINGS = {
101
- BASE_SIZE: 100,
102
- MIN_SIZE: 20,
103
- MAX_SIZE: 200,
104
- };
105
-
106
86
  // Sets up the transform layer with proper styles and dimensions
107
87
  function setupTransformLayer(transformLayer, config) {
108
88
  transformLayer.style.position = "absolute";
109
- const rulerOffset = RULER_SIZE;
89
+ const rulerOffset = config.rulerSize;
110
90
  transformLayer.style.top = `${rulerOffset}px`;
111
91
  transformLayer.style.left = `${rulerOffset}px`;
112
92
  transformLayer.style.width = `${config.width}px`;
@@ -165,7 +145,7 @@ function createMatrix(scale, translateX, translateY) {
165
145
  }
166
146
 
167
147
  function getZoomToMouseTransform(mouseX, mouseY, currentTransform, zoomFactor, config) {
168
- const rulerOffset = config.enableRulers ? -RULER_SIZE : 0;
148
+ const rulerOffset = config.enableRulers ? -config.rulerSize : 0;
169
149
  const transform = currentTransform || {
170
150
  scale: DEFAULT_ZOOM,
171
151
  translateX: rulerOffset,
@@ -275,20 +255,20 @@ function withRAFThrottle(func) {
275
255
  return throttled;
276
256
  }
277
257
 
278
- function withRulerSize(canvas, operation) {
258
+ function withRulerSize(canvas, rulerSize, operation) {
279
259
  const hasRulers = canvas.container.querySelector(".canvas-ruler") !== null;
280
- const rulerSize = hasRulers ? RULER_SIZE : 0;
281
- return operation(rulerSize);
260
+ const finalRulerSize = hasRulers ? rulerSize : 0;
261
+ return operation(finalRulerSize);
282
262
  }
283
- function withRulerOffsets(canvas, x, y, operation) {
284
- return withRulerSize(canvas, (rulerSize) => {
263
+ function withRulerOffsets(canvas, rulerSize, x, y, operation) {
264
+ return withRulerSize(canvas, rulerSize, (rulerSize) => {
285
265
  const adjustedX = x - rulerSize;
286
266
  const adjustedY = y - rulerSize;
287
267
  return operation(adjustedX, adjustedY);
288
268
  });
289
269
  }
290
- function withRulerOffsetObject(canvas, coords, operation) {
291
- return withRulerSize(canvas, (rulerSize) => {
270
+ function withRulerOffsetObject(canvas, rulerSize, coords, operation) {
271
+ return withRulerSize(canvas, rulerSize, (rulerSize) => {
292
272
  const adjusted = {
293
273
  ...coords,
294
274
  x: coords.x - rulerSize,
@@ -298,10 +278,10 @@ function withRulerOffsetObject(canvas, coords, operation) {
298
278
  });
299
279
  }
300
280
 
301
- function withRulerOffset(canvas, x, y, operation) {
281
+ function withRulerOffset(canvas, x, y, rulerSize, operation) {
302
282
  const hasRulers = canvas.container.querySelector(".canvas-ruler") !== null;
303
- const adjustedX = hasRulers ? x - RULER_SIZE : x;
304
- const adjustedY = hasRulers ? y - RULER_SIZE : y;
283
+ const adjustedX = hasRulers ? x - rulerSize : x;
284
+ const adjustedY = hasRulers ? y - rulerSize : y;
305
285
  return operation(adjustedX, adjustedY);
306
286
  }
307
287
 
@@ -345,9 +325,10 @@ const DEFAULT_CONFIG = {
345
325
  rulerTextColor: "#666",
346
326
  rulerMajorTickColor: "#999",
347
327
  rulerMinorTickColor: "#ccc",
348
- rulerFontSize: 10,
328
+ rulerFontSize: 9,
349
329
  rulerFontFamily: "Monaco, Menlo, monospace",
350
330
  rulerUnits: "px",
331
+ rulerSize: 20,
351
332
  // Callbacks
352
333
  onTransformUpdate: () => { },
353
334
  };
@@ -366,8 +347,8 @@ function getCanvasBounds(canvas) {
366
347
  const totalWidth = containerRect.width || container.clientWidth || 0;
367
348
  const totalHeight = containerRect.height || container.clientHeight || 0;
368
349
  // Calculate canvas dimensions accounting for rulers
369
- const canvasWidth = withRulerSize({ container }, (rulerSize) => Math.max(0, totalWidth - rulerSize));
370
- const canvasHeight = withRulerSize({ container }, (rulerSize) => Math.max(0, totalHeight - rulerSize));
350
+ const canvasWidth = withRulerSize({ container }, config.rulerSize, (rulerSize) => Math.max(0, totalWidth - rulerSize));
351
+ const canvasHeight = withRulerSize({ container }, config.rulerSize, (rulerSize) => Math.max(0, totalHeight - rulerSize));
371
352
  // Get content dimensions
372
353
  const contentWidth = config.width || DEFAULT_CONFIG.width;
373
354
  const contentHeight = config.height || DEFAULT_CONFIG.height;
@@ -514,7 +495,6 @@ function getCanvasMethods() {
514
495
  },
515
496
  // Handle canvas resize
516
497
  handleResize: function () {
517
- this.container.getBoundingClientRect();
518
498
  return true;
519
499
  },
520
500
  // Set zoom level
@@ -537,7 +517,7 @@ function getCanvasMethods() {
537
517
  // Reset view with animation
538
518
  resetView: function () {
539
519
  return withTransition(this.transformLayer, this.config, () => {
540
- return withRulerSize(this, (rulerSize) => {
520
+ return withRulerSize(this, this.config.rulerSize, (rulerSize) => {
541
521
  const resetTransform = {
542
522
  scale: 1.0,
543
523
  translateX: rulerSize * -1,
@@ -610,7 +590,7 @@ function createCanvas(container, config) {
610
590
  if (config.enableAcceleration) {
611
591
  enableHardwareAcceleration(transformLayer);
612
592
  }
613
- const rulerOffset = config.enableRulers ? -RULER_SIZE : 0;
593
+ const rulerOffset = config.enableRulers ? -config.rulerSize : 0;
614
594
  const initialTransform = {
615
595
  scale: DEFAULT_ZOOM,
616
596
  translateX: rulerOffset,
@@ -680,6 +660,10 @@ function createMarkupCanvasConfig(options = {}) {
680
660
  console.warn("Invalid rulerFontSize, using default");
681
661
  config.rulerFontSize = DEFAULT_CONFIG.rulerFontSize;
682
662
  }
663
+ if (typeof config.rulerSize !== "number" || config.rulerSize <= 0) {
664
+ console.warn("Invalid rulerSize, using default");
665
+ config.rulerSize = DEFAULT_CONFIG.rulerSize;
666
+ }
683
667
  return config;
684
668
  }
685
669
 
@@ -750,7 +734,7 @@ function setupKeyboardEvents(canvas, config) {
750
734
  const rect = canvas.container.getBoundingClientRect();
751
735
  const rawMouseX = event.clientX - rect.left;
752
736
  const rawMouseY = event.clientY - rect.top;
753
- withRulerOffsets(canvas, rawMouseX, rawMouseY, (adjustedX, adjustedY) => {
737
+ withRulerOffsets(canvas, config.rulerSize, rawMouseX, rawMouseY, (adjustedX, adjustedY) => {
754
738
  lastMouseX = adjustedX;
755
739
  lastMouseY = adjustedY;
756
740
  });
@@ -950,7 +934,7 @@ function handleClickToZoom(event, canvas, config, mouseDownTime, hasDragged, isD
950
934
  const rect = canvas.container.getBoundingClientRect();
951
935
  const rawClickX = event.clientX - rect.left;
952
936
  const rawClickY = event.clientY - rect.top;
953
- const { clickX, clickY } = withRulerOffset(canvas, rawClickX, rawClickY, (adjustedX, adjustedY) => ({
937
+ const { clickX, clickY } = withRulerOffset(canvas, rawClickX, rawClickY, config.rulerSize, (adjustedX, adjustedY) => ({
954
938
  clickX: adjustedX,
955
939
  clickY: adjustedY,
956
940
  }));
@@ -1177,7 +1161,7 @@ function handleTouchMove(event, canvas, touchState) {
1177
1161
  let centerX = currentCenter.x - rect.left;
1178
1162
  let centerY = currentCenter.y - rect.top;
1179
1163
  // Account for ruler offset if rulers are present
1180
- const adjustedCenter = withRulerOffsetObject(canvas, { x: centerX, y: centerY }, (adjusted) => adjusted);
1164
+ const adjustedCenter = withRulerOffsetObject(canvas, canvas.config.rulerSize, { x: centerX, y: centerY }, (adjusted) => adjusted);
1181
1165
  centerX = adjustedCenter.x;
1182
1166
  centerY = adjustedCenter.y;
1183
1167
  // Touch zoom uses global transition settings
@@ -1292,7 +1276,7 @@ function handleWheel(event, canvas, config) {
1292
1276
  const rawMouseX = event.clientX - rect.left;
1293
1277
  const rawMouseY = event.clientY - rect.top;
1294
1278
  // Account for ruler offset
1295
- const { mouseX, mouseY } = withRulerOffset(canvas, rawMouseX, rawMouseY, (adjustedX, adjustedY) => ({
1279
+ const { mouseX, mouseY } = withRulerOffset(canvas, rawMouseX, rawMouseY, config.rulerSize, (adjustedX, adjustedY) => ({
1296
1280
  mouseX: adjustedX,
1297
1281
  mouseY: adjustedY,
1298
1282
  }));
@@ -1339,6 +1323,26 @@ function setupWheelEvents(canvas, config) {
1339
1323
  };
1340
1324
  }
1341
1325
 
1326
+ // Rulers
1327
+ const RULER_Z_INDEX = {
1328
+ GRID: 100,
1329
+ RULERS: 1000,
1330
+ CORNER: 1001,
1331
+ };
1332
+ const TICK_SETTINGS = {
1333
+ MAJOR_HEIGHT: 6,
1334
+ MINOR_HEIGHT: 4,
1335
+ MAJOR_WIDTH: 8,
1336
+ MINOR_WIDTH: 4,
1337
+ MAJOR_MULTIPLIER: 5,
1338
+ LABEL_INTERVAL: 100,
1339
+ };
1340
+ const GRID_SETTINGS = {
1341
+ BASE_SIZE: 100,
1342
+ MIN_SIZE: 20,
1343
+ MAX_SIZE: 200,
1344
+ };
1345
+
1342
1346
  function createCornerBox(config) {
1343
1347
  const corner = document.createElement("div");
1344
1348
  corner.className = "canvas-ruler corner-box";
@@ -1346,21 +1350,21 @@ function createCornerBox(config) {
1346
1350
  position: absolute;
1347
1351
  top: 0;
1348
1352
  left: 0;
1349
- width: ${RULER_SIZE}px;
1350
- height: ${RULER_SIZE}px;
1351
- background: ${config.backgroundColor};
1352
- border-right: 1px solid ${config.borderColor};
1353
- border-bottom: 1px solid ${config.borderColor};
1353
+ width: ${config.rulerSize}px;
1354
+ height: ${config.rulerSize}px;
1355
+ background: ${config.rulerBackgroundColor};
1356
+ border-right: 1px solid ${config.rulerBorderColor};
1357
+ border-bottom: 1px solid ${config.rulerBorderColor};
1354
1358
  z-index: ${RULER_Z_INDEX.CORNER};
1355
1359
  display: flex;
1356
1360
  align-items: center;
1357
1361
  justify-content: center;
1358
- font-family: ${config.fontFamily};
1359
- font-size: ${config.fontSize - 2}px;
1360
- color: ${config.textColor};
1362
+ font-family: ${config.rulerFontFamily};
1363
+ font-size: ${config.rulerFontSize - 2}px;
1364
+ color: ${config.rulerTextColor};
1361
1365
  pointer-events: none;
1362
1366
  `;
1363
- corner.textContent = config.units;
1367
+ corner.textContent = config.rulerUnits;
1364
1368
  return corner;
1365
1369
  }
1366
1370
 
@@ -1369,8 +1373,8 @@ function createGridOverlay(config) {
1369
1373
  grid.className = "canvas-ruler grid-overlay";
1370
1374
  grid.style.cssText = `
1371
1375
  position: absolute;
1372
- top: ${RULER_SIZE}px;
1373
- left: ${RULER_SIZE}px;
1376
+ top: ${config.rulerSize}px;
1377
+ left: ${config.rulerSize}px;
1374
1378
  right: 0;
1375
1379
  bottom: 0;
1376
1380
  pointer-events: none;
@@ -1390,17 +1394,17 @@ function createHorizontalRuler(config) {
1390
1394
  ruler.style.cssText = `
1391
1395
  position: absolute;
1392
1396
  top: 0;
1393
- left: ${RULER_SIZE}px;
1397
+ left: ${config.rulerSize}px;
1394
1398
  right: 0;
1395
- height: ${RULER_SIZE}px;
1396
- background: ${config.backgroundColor};
1397
- border-bottom: 1px solid ${config.borderColor};
1398
- border-right: 1px solid ${config.borderColor};
1399
+ height: ${config.rulerSize}px;
1400
+ background: ${config.rulerBackgroundColor};
1401
+ border-bottom: 1px solid ${config.rulerBorderColor};
1402
+ border-right: 1px solid ${config.rulerBorderColor};
1399
1403
  z-index: ${RULER_Z_INDEX.RULERS};
1400
1404
  pointer-events: none;
1401
- font-family: ${config.fontFamily};
1402
- font-size: ${config.fontSize}px;
1403
- color: ${config.textColor};
1405
+ font-family: ${config.rulerFontFamily};
1406
+ font-size: ${config.rulerFontSize}px;
1407
+ color: ${config.rulerTextColor};
1404
1408
  overflow: hidden;
1405
1409
  `;
1406
1410
  return ruler;
@@ -1411,18 +1415,18 @@ function createVerticalRuler(config) {
1411
1415
  ruler.className = "canvas-ruler vertical-ruler";
1412
1416
  ruler.style.cssText = `
1413
1417
  position: absolute;
1414
- top: ${RULER_SIZE}px;
1418
+ top: ${config.rulerSize}px;
1415
1419
  left: 0;
1416
1420
  bottom: 0;
1417
- width: ${RULER_SIZE}px;
1418
- background: ${config.backgroundColor};
1419
- border-right: 1px solid ${config.borderColor};
1420
- border-bottom: 1px solid ${config.borderColor};
1421
+ width: ${config.rulerSize}px;
1422
+ background: ${config.rulerBackgroundColor};
1423
+ border-right: 1px solid ${config.rulerBorderColor};
1424
+ border-bottom: 1px solid ${config.rulerBorderColor};
1421
1425
  z-index: ${RULER_Z_INDEX.RULERS};
1422
1426
  pointer-events: none;
1423
- font-family: ${config.fontFamily};
1424
- font-size: ${config.fontSize}px;
1425
- color: ${config.textColor};
1427
+ font-family: ${config.rulerFontFamily};
1428
+ font-size: ${config.rulerFontSize}px;
1429
+ color: ${config.rulerTextColor};
1426
1430
  overflow: hidden;
1427
1431
  `;
1428
1432
  return ruler;
@@ -1432,7 +1436,7 @@ function createRulerElements(container, config) {
1432
1436
  const horizontalRuler = createHorizontalRuler(config);
1433
1437
  const verticalRuler = createVerticalRuler(config);
1434
1438
  const cornerBox = createCornerBox(config);
1435
- const gridOverlay = config.showGrid ? createGridOverlay(config) : undefined;
1439
+ const gridOverlay = config.enableGrid ? createGridOverlay(config) : undefined;
1436
1440
  container.appendChild(horizontalRuler);
1437
1441
  container.appendChild(verticalRuler);
1438
1442
  container.appendChild(cornerBox);
@@ -1502,7 +1506,7 @@ function createHorizontalTick(container, position, pixelPos, tickSpacing, config
1502
1506
  bottom: 0;
1503
1507
  width: 1px;
1504
1508
  height: ${tickHeight}px;
1505
- background: ${isMajor ? config.majorTickColor : config.minorTickColor};
1509
+ background: ${isMajor ? config.rulerMajorTickColor : config.rulerMinorTickColor};
1506
1510
  `;
1507
1511
  container.appendChild(tick);
1508
1512
  const shouldShowLabel = isMajor || position % TICK_SETTINGS.LABEL_INTERVAL === 0;
@@ -1512,8 +1516,9 @@ function createHorizontalTick(container, position, pixelPos, tickSpacing, config
1512
1516
  position: absolute;
1513
1517
  left: ${pixelPos}px;
1514
1518
  bottom: ${tickHeight}px;
1515
- font-size: ${config.fontSize}px;
1516
- color: ${config.textColor};
1519
+ font-size: ${config.rulerFontSize}px;
1520
+ line-height: 1;
1521
+ color: ${config.rulerTextColor};
1517
1522
  white-space: nowrap;
1518
1523
  pointer-events: none;
1519
1524
  `;
@@ -1549,7 +1554,7 @@ function createVerticalTick(container, position, pixelPos, tickSpacing, config)
1549
1554
  right: 0;
1550
1555
  width: ${tickWidth}px;
1551
1556
  height: 1px;
1552
- background: ${isMajor ? config.majorTickColor : config.minorTickColor};
1557
+ background: ${isMajor ? config.rulerMajorTickColor : config.rulerMinorTickColor};
1553
1558
  `;
1554
1559
  container.appendChild(tick);
1555
1560
  const shouldShowLabel = isMajor || position % TICK_SETTINGS.LABEL_INTERVAL === 0;
@@ -1559,8 +1564,9 @@ function createVerticalTick(container, position, pixelPos, tickSpacing, config)
1559
1564
  position: absolute;
1560
1565
  top: ${pixelPos - 6}px;
1561
1566
  right: ${tickWidth + 6}px;
1562
- font-size: ${config.fontSize}px;
1563
- color: ${config.textColor};
1567
+ font-size: ${config.rulerFontSize}px;
1568
+ line-height: 1;
1569
+ color: ${config.rulerTextColor};
1564
1570
  white-space: nowrap;
1565
1571
  pointer-events: none;
1566
1572
  transform: rotate(-90deg);
@@ -1593,8 +1599,8 @@ function updateRulers(canvas, horizontalRuler, verticalRuler, gridOverlay, confi
1593
1599
  const scale = bounds.scale || 1;
1594
1600
  const translateX = bounds.translateX || 0;
1595
1601
  const translateY = bounds.translateY || 0;
1596
- const canvasWidth = bounds.width - RULER_SIZE;
1597
- const canvasHeight = bounds.height - RULER_SIZE;
1602
+ const canvasWidth = bounds.width - config.rulerSize;
1603
+ const canvasHeight = bounds.height - config.rulerSize;
1598
1604
  const contentLeft = -translateX / scale;
1599
1605
  const contentTop = -translateY / scale;
1600
1606
  const contentRight = contentLeft + canvasWidth / scale;
@@ -1614,25 +1620,13 @@ function createRulers(canvas, config) {
1614
1620
  let elements;
1615
1621
  let cleanupEvents = null;
1616
1622
  let isDestroyed = false;
1617
- const rulerOptions = {
1618
- backgroundColor: config.rulerBackgroundColor,
1619
- borderColor: config.rulerBorderColor,
1620
- textColor: config.rulerTextColor,
1621
- majorTickColor: config.rulerMajorTickColor,
1622
- minorTickColor: config.rulerMinorTickColor,
1623
- fontSize: config.rulerFontSize,
1624
- fontFamily: config.rulerFontFamily,
1625
- showGrid: config.enableGrid,
1626
- gridColor: config.gridColor,
1627
- units: config.rulerUnits,
1628
- };
1629
1623
  const safeUpdate = () => {
1630
1624
  if (isDestroyed || !elements.horizontalRuler || !elements.verticalRuler)
1631
1625
  return;
1632
- updateRulers(canvas, elements.horizontalRuler, elements.verticalRuler, elements.gridOverlay, rulerOptions);
1626
+ updateRulers(canvas, elements.horizontalRuler, elements.verticalRuler, elements.gridOverlay, config);
1633
1627
  };
1634
1628
  try {
1635
- elements = createRulerElements(canvas.container, rulerOptions);
1629
+ elements = createRulerElements(canvas.container, config);
1636
1630
  cleanupEvents = setupRulerEvents(canvas, safeUpdate);
1637
1631
  safeUpdate();
1638
1632
  return {