@fieldnotes/core 0.42.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +171 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +171 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -108,6 +108,7 @@ interface GridElement extends BaseElement {
|
|
|
108
108
|
opacity: number;
|
|
109
109
|
}
|
|
110
110
|
type TemplateShape = 'circle' | 'cone' | 'line' | 'square';
|
|
111
|
+
type TemplateRenderStyle = 'cells' | 'geometric';
|
|
111
112
|
interface TemplateElement extends BaseElement {
|
|
112
113
|
type: 'template';
|
|
113
114
|
templateShape: TemplateShape;
|
|
@@ -119,6 +120,7 @@ interface TemplateElement extends BaseElement {
|
|
|
119
120
|
opacity: number;
|
|
120
121
|
feetPerCell?: number;
|
|
121
122
|
radiusFeet?: number;
|
|
123
|
+
renderStyle?: TemplateRenderStyle;
|
|
122
124
|
}
|
|
123
125
|
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement | GridElement | TemplateElement;
|
|
124
126
|
type ElementType = CanvasElement['type'];
|
|
@@ -471,6 +473,8 @@ interface ViewportOptions {
|
|
|
471
473
|
contextMenu?: boolean;
|
|
472
474
|
/** Coast (inertial glide) after a pan flick. Default `true`. */
|
|
473
475
|
panInertia?: boolean;
|
|
476
|
+
/** Show an overview minimap (bottom-right) with tap/drag-to-navigate. Default `false`. */
|
|
477
|
+
minimap?: boolean;
|
|
474
478
|
}
|
|
475
479
|
declare class Viewport {
|
|
476
480
|
private readonly container;
|
|
@@ -506,6 +510,7 @@ declare class Viewport {
|
|
|
506
510
|
private readonly gridController;
|
|
507
511
|
private readonly interactions;
|
|
508
512
|
private contextMenu;
|
|
513
|
+
private minimap;
|
|
509
514
|
private readonly htmlRenderers;
|
|
510
515
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
511
516
|
get ctx(): CanvasRenderingContext2D | null;
|
|
@@ -698,6 +703,7 @@ interface TemplateInput extends BaseDefaults {
|
|
|
698
703
|
opacity?: number;
|
|
699
704
|
feetPerCell?: number;
|
|
700
705
|
radiusFeet?: number;
|
|
706
|
+
renderStyle?: TemplateRenderStyle;
|
|
701
707
|
}
|
|
702
708
|
declare function createTemplate(input: TemplateInput): TemplateElement;
|
|
703
709
|
|
|
@@ -992,6 +998,7 @@ interface TemplateToolOptions {
|
|
|
992
998
|
strokeWidth?: number;
|
|
993
999
|
opacity?: number;
|
|
994
1000
|
feetPerCell?: number;
|
|
1001
|
+
renderStyle?: TemplateRenderStyle;
|
|
995
1002
|
}
|
|
996
1003
|
declare class TemplateTool implements Tool {
|
|
997
1004
|
readonly name = "template";
|
|
@@ -1008,6 +1015,7 @@ declare class TemplateTool implements Tool {
|
|
|
1008
1015
|
private strokeWidth;
|
|
1009
1016
|
private opacity;
|
|
1010
1017
|
private feetPerCell;
|
|
1018
|
+
private renderStyle;
|
|
1011
1019
|
private optionListeners;
|
|
1012
1020
|
constructor(options?: TemplateToolOptions);
|
|
1013
1021
|
getOptions(): TemplateToolOptions;
|
|
@@ -1057,6 +1065,6 @@ declare class LaserTool implements Tool {
|
|
|
1057
1065
|
private notifyOptionsChange;
|
|
1058
1066
|
}
|
|
1059
1067
|
|
|
1060
|
-
declare const VERSION = "0.
|
|
1068
|
+
declare const VERSION = "0.44.0";
|
|
1061
1069
|
|
|
1062
|
-
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
|
1070
|
+
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ interface GridElement extends BaseElement {
|
|
|
108
108
|
opacity: number;
|
|
109
109
|
}
|
|
110
110
|
type TemplateShape = 'circle' | 'cone' | 'line' | 'square';
|
|
111
|
+
type TemplateRenderStyle = 'cells' | 'geometric';
|
|
111
112
|
interface TemplateElement extends BaseElement {
|
|
112
113
|
type: 'template';
|
|
113
114
|
templateShape: TemplateShape;
|
|
@@ -119,6 +120,7 @@ interface TemplateElement extends BaseElement {
|
|
|
119
120
|
opacity: number;
|
|
120
121
|
feetPerCell?: number;
|
|
121
122
|
radiusFeet?: number;
|
|
123
|
+
renderStyle?: TemplateRenderStyle;
|
|
122
124
|
}
|
|
123
125
|
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement | GridElement | TemplateElement;
|
|
124
126
|
type ElementType = CanvasElement['type'];
|
|
@@ -471,6 +473,8 @@ interface ViewportOptions {
|
|
|
471
473
|
contextMenu?: boolean;
|
|
472
474
|
/** Coast (inertial glide) after a pan flick. Default `true`. */
|
|
473
475
|
panInertia?: boolean;
|
|
476
|
+
/** Show an overview minimap (bottom-right) with tap/drag-to-navigate. Default `false`. */
|
|
477
|
+
minimap?: boolean;
|
|
474
478
|
}
|
|
475
479
|
declare class Viewport {
|
|
476
480
|
private readonly container;
|
|
@@ -506,6 +510,7 @@ declare class Viewport {
|
|
|
506
510
|
private readonly gridController;
|
|
507
511
|
private readonly interactions;
|
|
508
512
|
private contextMenu;
|
|
513
|
+
private minimap;
|
|
509
514
|
private readonly htmlRenderers;
|
|
510
515
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
511
516
|
get ctx(): CanvasRenderingContext2D | null;
|
|
@@ -698,6 +703,7 @@ interface TemplateInput extends BaseDefaults {
|
|
|
698
703
|
opacity?: number;
|
|
699
704
|
feetPerCell?: number;
|
|
700
705
|
radiusFeet?: number;
|
|
706
|
+
renderStyle?: TemplateRenderStyle;
|
|
701
707
|
}
|
|
702
708
|
declare function createTemplate(input: TemplateInput): TemplateElement;
|
|
703
709
|
|
|
@@ -992,6 +998,7 @@ interface TemplateToolOptions {
|
|
|
992
998
|
strokeWidth?: number;
|
|
993
999
|
opacity?: number;
|
|
994
1000
|
feetPerCell?: number;
|
|
1001
|
+
renderStyle?: TemplateRenderStyle;
|
|
995
1002
|
}
|
|
996
1003
|
declare class TemplateTool implements Tool {
|
|
997
1004
|
readonly name = "template";
|
|
@@ -1008,6 +1015,7 @@ declare class TemplateTool implements Tool {
|
|
|
1008
1015
|
private strokeWidth;
|
|
1009
1016
|
private opacity;
|
|
1010
1017
|
private feetPerCell;
|
|
1018
|
+
private renderStyle;
|
|
1011
1019
|
private optionListeners;
|
|
1012
1020
|
constructor(options?: TemplateToolOptions);
|
|
1013
1021
|
getOptions(): TemplateToolOptions;
|
|
@@ -1057,6 +1065,6 @@ declare class LaserTool implements Tool {
|
|
|
1057
1065
|
private notifyOptionsChange;
|
|
1058
1066
|
}
|
|
1059
1067
|
|
|
1060
|
-
declare const VERSION = "0.
|
|
1068
|
+
declare const VERSION = "0.44.0";
|
|
1061
1069
|
|
|
1062
|
-
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
|
1070
|
+
export { type ActiveFormats, type AlignEdge, type ArrowElement, type ArrowStrokeStyle, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type ExportSvgOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, LaserTool, type LaserToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateRenderStyle, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|
package/dist/index.js
CHANGED
|
@@ -3121,7 +3121,7 @@ function drawHexPath(ctx, cx, cy, cellSize, orientation) {
|
|
|
3121
3121
|
// src/elements/renderers/template-renderer.ts
|
|
3122
3122
|
function renderTemplate(ctx, template, store) {
|
|
3123
3123
|
const grid = store?.getElementsByType("grid")[0];
|
|
3124
|
-
if (grid && grid.gridType === "hex") {
|
|
3124
|
+
if (grid && grid.gridType === "hex" && template.renderStyle !== "geometric") {
|
|
3125
3125
|
renderHexTemplate(ctx, template, grid.cellSize, grid.hexOrientation);
|
|
3126
3126
|
return;
|
|
3127
3127
|
}
|
|
@@ -3797,7 +3797,8 @@ function createTemplate(input) {
|
|
|
3797
3797
|
strokeWidth: input.strokeWidth ?? 2,
|
|
3798
3798
|
opacity: input.opacity ?? 0.6,
|
|
3799
3799
|
feetPerCell: input.feetPerCell,
|
|
3800
|
-
radiusFeet: input.radiusFeet
|
|
3800
|
+
radiusFeet: input.radiusFeet,
|
|
3801
|
+
...input.renderStyle !== void 0 ? { renderStyle: input.renderStyle } : {}
|
|
3801
3802
|
};
|
|
3802
3803
|
}
|
|
3803
3804
|
|
|
@@ -4277,6 +4278,135 @@ var ContextMenu = class {
|
|
|
4277
4278
|
}
|
|
4278
4279
|
};
|
|
4279
4280
|
|
|
4281
|
+
// src/canvas/minimap-transform.ts
|
|
4282
|
+
function unionBounds(a, b) {
|
|
4283
|
+
const minX = Math.min(a.x, b.x);
|
|
4284
|
+
const minY = Math.min(a.y, b.y);
|
|
4285
|
+
const maxX = Math.max(a.x + a.w, b.x + b.w);
|
|
4286
|
+
const maxY = Math.max(a.y + a.h, b.y + b.h);
|
|
4287
|
+
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
|
|
4288
|
+
}
|
|
4289
|
+
function computeMinimapTransform(mapping, miniW, miniH, padding) {
|
|
4290
|
+
const availW = Math.max(1, miniW - 2 * padding);
|
|
4291
|
+
const availH = Math.max(1, miniH - 2 * padding);
|
|
4292
|
+
const w = Math.max(mapping.w, 1);
|
|
4293
|
+
const h = Math.max(mapping.h, 1);
|
|
4294
|
+
const scale = Math.min(availW / w, availH / h);
|
|
4295
|
+
const offsetX = (miniW - mapping.w * scale) / 2 - mapping.x * scale;
|
|
4296
|
+
const offsetY = (miniH - mapping.h * scale) / 2 - mapping.y * scale;
|
|
4297
|
+
return { scale, offsetX, offsetY };
|
|
4298
|
+
}
|
|
4299
|
+
function worldToMini(t, p) {
|
|
4300
|
+
return { x: p.x * t.scale + t.offsetX, y: p.y * t.scale + t.offsetY };
|
|
4301
|
+
}
|
|
4302
|
+
function miniToWorld(t, p) {
|
|
4303
|
+
return { x: (p.x - t.offsetX) / t.scale, y: (p.y - t.offsetY) / t.scale };
|
|
4304
|
+
}
|
|
4305
|
+
|
|
4306
|
+
// src/canvas/minimap.ts
|
|
4307
|
+
var WIDTH = 200;
|
|
4308
|
+
var HEIGHT = 140;
|
|
4309
|
+
var MARGIN = 16;
|
|
4310
|
+
var PADDING = 8;
|
|
4311
|
+
var NEUTRAL = "rgba(100,116,139,0.6)";
|
|
4312
|
+
var VIEWPORT_STROKE = "#3b82f6";
|
|
4313
|
+
function elementColor(el) {
|
|
4314
|
+
return "color" in el && typeof el.color === "string" ? el.color : NEUTRAL;
|
|
4315
|
+
}
|
|
4316
|
+
var Minimap = class {
|
|
4317
|
+
constructor(deps) {
|
|
4318
|
+
this.deps = deps;
|
|
4319
|
+
const canvas = document.createElement("canvas");
|
|
4320
|
+
canvas.width = WIDTH;
|
|
4321
|
+
canvas.height = HEIGHT;
|
|
4322
|
+
Object.assign(canvas.style, {
|
|
4323
|
+
position: "absolute",
|
|
4324
|
+
right: `${MARGIN}px`,
|
|
4325
|
+
bottom: `${MARGIN}px`,
|
|
4326
|
+
width: `${WIDTH}px`,
|
|
4327
|
+
height: `${HEIGHT}px`,
|
|
4328
|
+
background: "rgba(255,255,255,0.85)",
|
|
4329
|
+
border: "1px solid rgba(0,0,0,0.15)",
|
|
4330
|
+
borderRadius: "4px",
|
|
4331
|
+
touchAction: "none",
|
|
4332
|
+
cursor: "pointer",
|
|
4333
|
+
zIndex: "10"
|
|
4334
|
+
});
|
|
4335
|
+
canvas.addEventListener("pointerdown", this.onPointerDown);
|
|
4336
|
+
canvas.addEventListener("pointermove", this.onPointerMove);
|
|
4337
|
+
canvas.addEventListener("pointerup", this.onPointerUp);
|
|
4338
|
+
this.deps.container.appendChild(canvas);
|
|
4339
|
+
this.canvas = canvas;
|
|
4340
|
+
}
|
|
4341
|
+
canvas;
|
|
4342
|
+
rafId = null;
|
|
4343
|
+
dragging = false;
|
|
4344
|
+
scheduleDraw() {
|
|
4345
|
+
if (this.rafId !== null) return;
|
|
4346
|
+
this.rafId = this.deps.requestFrame(this.draw);
|
|
4347
|
+
}
|
|
4348
|
+
destroy() {
|
|
4349
|
+
if (this.rafId !== null) {
|
|
4350
|
+
this.deps.cancelFrame(this.rafId);
|
|
4351
|
+
this.rafId = null;
|
|
4352
|
+
}
|
|
4353
|
+
this.canvas.removeEventListener("pointerdown", this.onPointerDown);
|
|
4354
|
+
this.canvas.removeEventListener("pointermove", this.onPointerMove);
|
|
4355
|
+
this.canvas.removeEventListener("pointerup", this.onPointerUp);
|
|
4356
|
+
this.canvas.remove();
|
|
4357
|
+
}
|
|
4358
|
+
currentTransform() {
|
|
4359
|
+
const viewport = this.deps.getViewportRect();
|
|
4360
|
+
const content = this.deps.getContentBounds();
|
|
4361
|
+
const mapping = content ? unionBounds(content, viewport) : viewport;
|
|
4362
|
+
return computeMinimapTransform(mapping, WIDTH, HEIGHT, PADDING);
|
|
4363
|
+
}
|
|
4364
|
+
draw = () => {
|
|
4365
|
+
this.rafId = null;
|
|
4366
|
+
const ctx = this.canvas.getContext("2d");
|
|
4367
|
+
if (!ctx) return;
|
|
4368
|
+
const t = this.currentTransform();
|
|
4369
|
+
const viewport = this.deps.getViewportRect();
|
|
4370
|
+
ctx.clearRect(0, 0, WIDTH, HEIGHT);
|
|
4371
|
+
for (const el of this.deps.getElements()) {
|
|
4372
|
+
const b = getElementBounds(el);
|
|
4373
|
+
if (!b) continue;
|
|
4374
|
+
const tl = worldToMini(t, { x: b.x, y: b.y });
|
|
4375
|
+
ctx.fillStyle = elementColor(el);
|
|
4376
|
+
ctx.fillRect(tl.x, tl.y, Math.max(1, b.w * t.scale), Math.max(1, b.h * t.scale));
|
|
4377
|
+
}
|
|
4378
|
+
const vtl = worldToMini(t, { x: viewport.x, y: viewport.y });
|
|
4379
|
+
ctx.strokeStyle = VIEWPORT_STROKE;
|
|
4380
|
+
ctx.lineWidth = 1.5;
|
|
4381
|
+
ctx.strokeRect(vtl.x, vtl.y, viewport.w * t.scale, viewport.h * t.scale);
|
|
4382
|
+
};
|
|
4383
|
+
navigateFromEvent(e) {
|
|
4384
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
4385
|
+
const point = { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
4386
|
+
const world = miniToWorld(this.currentTransform(), point);
|
|
4387
|
+
this.deps.navigateTo(world);
|
|
4388
|
+
}
|
|
4389
|
+
onPointerDown = (e) => {
|
|
4390
|
+
e.stopPropagation();
|
|
4391
|
+
e.preventDefault();
|
|
4392
|
+
this.dragging = true;
|
|
4393
|
+
this.canvas.setPointerCapture?.(e.pointerId);
|
|
4394
|
+
this.navigateFromEvent(e);
|
|
4395
|
+
};
|
|
4396
|
+
onPointerMove = (e) => {
|
|
4397
|
+
if (!this.dragging) return;
|
|
4398
|
+
e.stopPropagation();
|
|
4399
|
+
this.navigateFromEvent(e);
|
|
4400
|
+
};
|
|
4401
|
+
onPointerUp = (e) => {
|
|
4402
|
+
this.dragging = false;
|
|
4403
|
+
try {
|
|
4404
|
+
this.canvas.releasePointerCapture(e.pointerId);
|
|
4405
|
+
} catch {
|
|
4406
|
+
}
|
|
4407
|
+
};
|
|
4408
|
+
};
|
|
4409
|
+
|
|
4280
4410
|
// src/canvas/viewport-dom.ts
|
|
4281
4411
|
function createWrapper() {
|
|
4282
4412
|
const el = document.createElement("div");
|
|
@@ -6402,7 +6532,7 @@ function getElementStyle(element) {
|
|
|
6402
6532
|
}
|
|
6403
6533
|
|
|
6404
6534
|
// src/canvas/selection-ops.ts
|
|
6405
|
-
function
|
|
6535
|
+
function unionBounds2(list) {
|
|
6406
6536
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
6407
6537
|
for (const b of list) {
|
|
6408
6538
|
minX = Math.min(minX, b.x);
|
|
@@ -6497,7 +6627,7 @@ var SelectionOps = class {
|
|
|
6497
6627
|
align(edge) {
|
|
6498
6628
|
const bounded = this.boundedSelection();
|
|
6499
6629
|
if (bounded.length < 2) return;
|
|
6500
|
-
const B =
|
|
6630
|
+
const B = unionBounds2(bounded.map((e) => e.bounds));
|
|
6501
6631
|
this.deps.recorder.begin();
|
|
6502
6632
|
const moved = [];
|
|
6503
6633
|
for (const { id, el, bounds: b } of bounded) {
|
|
@@ -6904,6 +7034,27 @@ var Viewport = class {
|
|
|
6904
7034
|
});
|
|
6905
7035
|
}
|
|
6906
7036
|
this.unsubToolChange = this.toolManager.onChange(() => this.contextMenu?.close());
|
|
7037
|
+
if (options.minimap) {
|
|
7038
|
+
const visibleEls = () => this.store.getAll().filter((el) => this.layerManager.isLayerVisible(el.layerId));
|
|
7039
|
+
this.minimap = new Minimap({
|
|
7040
|
+
container: this.wrapper,
|
|
7041
|
+
getElements: visibleEls,
|
|
7042
|
+
getContentBounds: () => getElementsBoundingBox(visibleEls()),
|
|
7043
|
+
getViewportRect: () => this.camera.getVisibleRect(this.canvasEl.clientWidth, this.canvasEl.clientHeight),
|
|
7044
|
+
navigateTo: (w) => {
|
|
7045
|
+
const z = this.camera.zoom;
|
|
7046
|
+
this.camera.moveTo(
|
|
7047
|
+
this.canvasEl.clientWidth / 2 - w.x * z,
|
|
7048
|
+
this.canvasEl.clientHeight / 2 - w.y * z
|
|
7049
|
+
);
|
|
7050
|
+
},
|
|
7051
|
+
requestFrame: (cb) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(cb) : 0,
|
|
7052
|
+
cancelFrame: (id) => {
|
|
7053
|
+
if (typeof cancelAnimationFrame !== "undefined") cancelAnimationFrame(id);
|
|
7054
|
+
}
|
|
7055
|
+
});
|
|
7056
|
+
this.minimap.scheduleDraw();
|
|
7057
|
+
}
|
|
6907
7058
|
this.domNodeManager = new DomNodeManager({
|
|
6908
7059
|
domLayer: this.domLayer,
|
|
6909
7060
|
onEditRequest: (id) => this.interactions.startEditingElement(id),
|
|
@@ -6936,6 +7087,7 @@ var Viewport = class {
|
|
|
6936
7087
|
this.applyCameraTransform();
|
|
6937
7088
|
this.noteEditor.updateToolbarPosition();
|
|
6938
7089
|
this.contextMenu?.close();
|
|
7090
|
+
this.minimap?.scheduleDraw();
|
|
6939
7091
|
this.requestRender();
|
|
6940
7092
|
});
|
|
6941
7093
|
this.gridController = new GridController({
|
|
@@ -6950,6 +7102,7 @@ var Viewport = class {
|
|
|
6950
7102
|
this.store.on("add", (el) => {
|
|
6951
7103
|
if (el.type === "grid") this.gridController.syncContext();
|
|
6952
7104
|
this.renderLoop.markLayerDirty(el.layerId);
|
|
7105
|
+
this.minimap?.scheduleDraw();
|
|
6953
7106
|
this.requestRender();
|
|
6954
7107
|
}),
|
|
6955
7108
|
this.store.on("remove", (el) => {
|
|
@@ -6957,6 +7110,7 @@ var Viewport = class {
|
|
|
6957
7110
|
this.unbindArrowsFrom(el);
|
|
6958
7111
|
this.domNodeManager.removeDomNode(el.id);
|
|
6959
7112
|
this.renderLoop.markLayerDirty(el.layerId);
|
|
7113
|
+
this.minimap?.scheduleDraw();
|
|
6960
7114
|
this.requestRender();
|
|
6961
7115
|
}),
|
|
6962
7116
|
this.store.on("update", ({ previous, current }) => {
|
|
@@ -6965,17 +7119,20 @@ var Viewport = class {
|
|
|
6965
7119
|
if (previous.layerId !== current.layerId) {
|
|
6966
7120
|
this.renderLoop.markLayerDirty(previous.layerId);
|
|
6967
7121
|
}
|
|
7122
|
+
this.minimap?.scheduleDraw();
|
|
6968
7123
|
this.requestRender();
|
|
6969
7124
|
}),
|
|
6970
7125
|
this.store.on("clear", () => {
|
|
6971
7126
|
this.domNodeManager.clearDomNodes();
|
|
6972
7127
|
this.renderLoop.markAllLayersDirty();
|
|
6973
7128
|
this.gridController.syncContext();
|
|
7129
|
+
this.minimap?.scheduleDraw();
|
|
6974
7130
|
this.requestRender();
|
|
6975
7131
|
})
|
|
6976
7132
|
];
|
|
6977
7133
|
this.layerManager.on("change", () => {
|
|
6978
7134
|
this.toolContext.activeLayerId = this.layerManager.activeLayerId;
|
|
7135
|
+
this.minimap?.scheduleDraw();
|
|
6979
7136
|
this.requestRender();
|
|
6980
7137
|
});
|
|
6981
7138
|
this.interactions = new ViewportInteractions({
|
|
@@ -7035,6 +7192,7 @@ var Viewport = class {
|
|
|
7035
7192
|
gridController;
|
|
7036
7193
|
interactions;
|
|
7037
7194
|
contextMenu = null;
|
|
7195
|
+
minimap = null;
|
|
7038
7196
|
htmlRenderers = /* @__PURE__ */ new Map();
|
|
7039
7197
|
get ctx() {
|
|
7040
7198
|
return this.canvasEl.getContext("2d");
|
|
@@ -7308,6 +7466,7 @@ var Viewport = class {
|
|
|
7308
7466
|
this.arrowLabelEditor.cancel();
|
|
7309
7467
|
this.historyRecorder.destroy();
|
|
7310
7468
|
this.contextMenu?.dispose();
|
|
7469
|
+
this.minimap?.destroy();
|
|
7311
7470
|
this.wrapper.removeEventListener("pointerdown", this.interactions.onTapDown);
|
|
7312
7471
|
this.wrapper.removeEventListener("pointerup", this.interactions.onDoubleTap);
|
|
7313
7472
|
this.wrapper.removeEventListener("dragover", this.interactions.onDragOver);
|
|
@@ -9454,6 +9613,7 @@ var TemplateTool = class {
|
|
|
9454
9613
|
strokeWidth;
|
|
9455
9614
|
opacity;
|
|
9456
9615
|
feetPerCell;
|
|
9616
|
+
renderStyle;
|
|
9457
9617
|
optionListeners = /* @__PURE__ */ new Set();
|
|
9458
9618
|
constructor(options = {}) {
|
|
9459
9619
|
this.templateShape = options.templateShape ?? "circle";
|
|
@@ -9462,6 +9622,7 @@ var TemplateTool = class {
|
|
|
9462
9622
|
this.strokeWidth = options.strokeWidth ?? 2;
|
|
9463
9623
|
this.opacity = options.opacity ?? 0.6;
|
|
9464
9624
|
this.feetPerCell = options.feetPerCell ?? 5;
|
|
9625
|
+
this.renderStyle = options.renderStyle ?? "cells";
|
|
9465
9626
|
}
|
|
9466
9627
|
getOptions() {
|
|
9467
9628
|
return {
|
|
@@ -9470,7 +9631,8 @@ var TemplateTool = class {
|
|
|
9470
9631
|
strokeColor: this.strokeColor,
|
|
9471
9632
|
strokeWidth: this.strokeWidth,
|
|
9472
9633
|
opacity: this.opacity,
|
|
9473
|
-
feetPerCell: this.feetPerCell
|
|
9634
|
+
feetPerCell: this.feetPerCell,
|
|
9635
|
+
renderStyle: this.renderStyle
|
|
9474
9636
|
};
|
|
9475
9637
|
}
|
|
9476
9638
|
setOptions(options) {
|
|
@@ -9480,6 +9642,7 @@ var TemplateTool = class {
|
|
|
9480
9642
|
if (options.strokeWidth !== void 0) this.strokeWidth = options.strokeWidth;
|
|
9481
9643
|
if (options.opacity !== void 0) this.opacity = options.opacity;
|
|
9482
9644
|
if (options.feetPerCell !== void 0) this.feetPerCell = options.feetPerCell;
|
|
9645
|
+
if (options.renderStyle !== void 0) this.renderStyle = options.renderStyle;
|
|
9483
9646
|
this.notifyOptionsChange();
|
|
9484
9647
|
}
|
|
9485
9648
|
onOptionsChange(listener) {
|
|
@@ -9522,6 +9685,7 @@ var TemplateTool = class {
|
|
|
9522
9685
|
opacity: this.opacity,
|
|
9523
9686
|
feetPerCell: this.feetPerCell,
|
|
9524
9687
|
radiusFeet: radiusFeet > 0 ? radiusFeet : void 0,
|
|
9688
|
+
renderStyle: this.renderStyle,
|
|
9525
9689
|
layerId: ctx.activeLayerId ?? ""
|
|
9526
9690
|
});
|
|
9527
9691
|
ctx.store.add(element);
|
|
@@ -9537,7 +9701,7 @@ var TemplateTool = class {
|
|
|
9537
9701
|
if (!this.drawing) return;
|
|
9538
9702
|
const radius = this.computeRadius();
|
|
9539
9703
|
if (radius <= 0) return;
|
|
9540
|
-
if (this.gridType === "hex" && this.hexOrientation) {
|
|
9704
|
+
if (this.gridType === "hex" && this.hexOrientation && this.renderStyle !== "geometric") {
|
|
9541
9705
|
this.renderHexOverlay(ctx, radius);
|
|
9542
9706
|
return;
|
|
9543
9707
|
}
|
|
@@ -9810,7 +9974,7 @@ var LaserTool = class {
|
|
|
9810
9974
|
};
|
|
9811
9975
|
|
|
9812
9976
|
// src/index.ts
|
|
9813
|
-
var VERSION = "0.
|
|
9977
|
+
var VERSION = "0.44.0";
|
|
9814
9978
|
export {
|
|
9815
9979
|
ArrowTool,
|
|
9816
9980
|
AutoSave,
|