@fieldnotes/core 0.38.2 → 0.38.4

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.d.cts CHANGED
@@ -482,9 +482,7 @@ declare class Viewport {
482
482
  private readonly onHtmlElementMount?;
483
483
  private readonly dropHandler?;
484
484
  private readonly gridController;
485
- private readonly doubleTapDetector;
486
- private tapDownX;
487
- private tapDownY;
485
+ private readonly interactions;
488
486
  private contextMenu;
489
487
  constructor(container: HTMLElement, options?: ViewportOptions);
490
488
  get ctx(): CanvasRenderingContext2D | null;
@@ -562,17 +560,7 @@ declare class Viewport {
562
560
  getRenderStats(): RenderStatsSnapshot;
563
561
  logPerformance(intervalMs?: number): () => void;
564
562
  destroy(): void;
565
- private startEditingElement;
566
- private fitNoteHeight;
567
- private onTextEditStop;
568
- private onTapDown;
569
- private onDoubleTap;
570
- private findArrowAt;
571
- private startArrowLabelEdit;
572
- private hitTestWorld;
573
563
  stopInteracting(): void;
574
- private onDragOver;
575
- private onDrop;
576
564
  private unbindArrowsFrom;
577
565
  private applyCameraTransform;
578
566
  private syncCanvasSize;
@@ -1005,6 +993,6 @@ declare class TemplateTool implements Tool {
1005
993
  private notifyOptionsChange;
1006
994
  }
1007
995
 
1008
- declare const VERSION = "0.38.2";
996
+ declare const VERSION = "0.38.4";
1009
997
 
1010
998
  export { type ActiveFormats, type AlignEdge, type ArrowElement, 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 FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, 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, 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
@@ -482,9 +482,7 @@ declare class Viewport {
482
482
  private readonly onHtmlElementMount?;
483
483
  private readonly dropHandler?;
484
484
  private readonly gridController;
485
- private readonly doubleTapDetector;
486
- private tapDownX;
487
- private tapDownY;
485
+ private readonly interactions;
488
486
  private contextMenu;
489
487
  constructor(container: HTMLElement, options?: ViewportOptions);
490
488
  get ctx(): CanvasRenderingContext2D | null;
@@ -562,17 +560,7 @@ declare class Viewport {
562
560
  getRenderStats(): RenderStatsSnapshot;
563
561
  logPerformance(intervalMs?: number): () => void;
564
562
  destroy(): void;
565
- private startEditingElement;
566
- private fitNoteHeight;
567
- private onTextEditStop;
568
- private onTapDown;
569
- private onDoubleTap;
570
- private findArrowAt;
571
- private startArrowLabelEdit;
572
- private hitTestWorld;
573
563
  stopInteracting(): void;
574
- private onDragOver;
575
- private onDrop;
576
564
  private unbindArrowsFrom;
577
565
  private applyCameraTransform;
578
566
  private syncCanvasSize;
@@ -1005,6 +993,6 @@ declare class TemplateTool implements Tool {
1005
993
  private notifyOptionsChange;
1006
994
  }
1007
995
 
1008
- declare const VERSION = "0.38.2";
996
+ declare const VERSION = "0.38.4";
1009
997
 
1010
998
  export { type ActiveFormats, type AlignEdge, type ArrowElement, 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 FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, 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, 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
@@ -2176,7 +2176,12 @@ var ElementStore = class {
2176
2176
  if (!existing) return;
2177
2177
  this.sortedCache = null;
2178
2178
  this._versions.set(id, (this._versions.get(id) ?? 0) + 1);
2179
- const updated = { ...existing, ...partial, id: existing.id, type: existing.type };
2179
+ const updated = {
2180
+ ...existing,
2181
+ ...partial,
2182
+ id: existing.id,
2183
+ type: existing.type
2184
+ };
2180
2185
  if (updated.type === "stroke" && existing.type === "stroke") {
2181
2186
  transferStrokeRenderData(existing, updated);
2182
2187
  transferStrokeBounds(existing, updated);
@@ -5978,9 +5983,158 @@ var GridController = class {
5978
5983
  }
5979
5984
  };
5980
5985
 
5986
+ // src/canvas/viewport-interactions.ts
5987
+ var ARROW_HIT_THRESHOLD = 10;
5988
+ var ViewportInteractions = class {
5989
+ constructor(deps) {
5990
+ this.deps = deps;
5991
+ }
5992
+ doubleTapDetector = new DoubleTapDetector();
5993
+ tapDownX = 0;
5994
+ tapDownY = 0;
5995
+ startEditingElement(id) {
5996
+ const element = this.deps.store.getById(id);
5997
+ if (!element || element.type !== "note" && element.type !== "text") return;
5998
+ this.deps.renderLoop.flush();
5999
+ const node = this.deps.domNodeManager.getNode(id);
6000
+ if (node) {
6001
+ this.deps.noteEditor.startEditing(node, id, this.deps.store);
6002
+ }
6003
+ }
6004
+ fitNoteHeight(elementId) {
6005
+ const element = this.deps.store.getById(elementId);
6006
+ if (!element || element.type !== "note") return;
6007
+ if (isNoteContentEmpty(element.text)) return;
6008
+ const node = this.deps.domNodeManager.getNode(elementId);
6009
+ if (!node) return;
6010
+ const measured = node.scrollHeight;
6011
+ if (measured > element.size.h) {
6012
+ this.deps.store.update(elementId, { size: { w: element.size.w, h: measured } });
6013
+ }
6014
+ }
6015
+ onTextEditStop(elementId) {
6016
+ const element = this.deps.store.getById(elementId);
6017
+ if (!element) return;
6018
+ if (element.type === "note") {
6019
+ if (isNoteContentEmpty(element.text)) {
6020
+ this.deps.store.remove(elementId);
6021
+ return;
6022
+ }
6023
+ this.fitNoteHeight(elementId);
6024
+ return;
6025
+ }
6026
+ if (element.type !== "text") return;
6027
+ if (!element.text || element.text.trim() === "") {
6028
+ this.deps.store.remove(elementId);
6029
+ return;
6030
+ }
6031
+ const node = this.deps.domNodeManager.getNode(elementId);
6032
+ if (node && "size" in element) {
6033
+ const measured = node.scrollHeight;
6034
+ if (measured !== element.size.h) {
6035
+ this.deps.store.update(elementId, { size: { w: element.size.w, h: measured } });
6036
+ }
6037
+ }
6038
+ }
6039
+ onTapDown = (e) => {
6040
+ this.tapDownX = e.clientX;
6041
+ this.tapDownY = e.clientY;
6042
+ };
6043
+ onDoubleTap = (e) => {
6044
+ const dx = e.clientX - this.tapDownX;
6045
+ const dy = e.clientY - this.tapDownY;
6046
+ const moved = Math.sqrt(dx * dx + dy * dy);
6047
+ if (moved > 10) return;
6048
+ if (!this.doubleTapDetector.feed(e)) return;
6049
+ if (typeof document.elementFromPoint !== "function") return;
6050
+ const el = document.elementFromPoint(e.clientX, e.clientY);
6051
+ const nodeEl = el?.closest("[data-element-id]");
6052
+ if (nodeEl) {
6053
+ const elementId = nodeEl.dataset["elementId"];
6054
+ if (elementId) {
6055
+ const element = this.deps.store.getById(elementId);
6056
+ if (element?.type === "note" || element?.type === "text") {
6057
+ this.startEditingElement(elementId);
6058
+ return;
6059
+ }
6060
+ }
6061
+ }
6062
+ const rect = this.deps.wrapper.getBoundingClientRect();
6063
+ const screen = { x: e.clientX - rect.left, y: e.clientY - rect.top };
6064
+ const world = this.deps.camera.screenToWorld(screen);
6065
+ const hit = this.hitTestWorld(world);
6066
+ if (hit?.type === "html") {
6067
+ this.deps.interactMode.startInteracting(hit.id);
6068
+ return;
6069
+ }
6070
+ const arrow = this.findArrowAt(world);
6071
+ if (arrow) {
6072
+ this.startArrowLabelEdit(arrow);
6073
+ }
6074
+ };
6075
+ findArrowAt(world) {
6076
+ const candidates = this.deps.store.queryPoint(world).reverse();
6077
+ for (const el of candidates) {
6078
+ if (el.type === "arrow" && isNearBezier(world, el.from, el.to, el.bend, ARROW_HIT_THRESHOLD)) {
6079
+ return el;
6080
+ }
6081
+ }
6082
+ return void 0;
6083
+ }
6084
+ startArrowLabelEdit(arrow) {
6085
+ this.deps.arrowLabelEditor.startEditing({
6086
+ arrow,
6087
+ layer: this.deps.domLayer,
6088
+ store: this.deps.store,
6089
+ recorder: this.deps.recorder,
6090
+ onDone: () => {
6091
+ this.deps.renderer.setLabelEditingId(null);
6092
+ this.deps.requestRender();
6093
+ }
6094
+ });
6095
+ this.deps.renderer.setLabelEditingId(arrow.id);
6096
+ }
6097
+ hitTestWorld(world) {
6098
+ const candidates = this.deps.store.queryPoint(world).reverse();
6099
+ for (const el of candidates) {
6100
+ if (!("size" in el)) continue;
6101
+ const { x, y } = el.position;
6102
+ const { w, h } = el.size;
6103
+ if (world.x >= x && world.x <= x + w && world.y >= y && world.y <= y + h) {
6104
+ return el;
6105
+ }
6106
+ }
6107
+ return null;
6108
+ }
6109
+ onDragOver = (e) => {
6110
+ e.preventDefault();
6111
+ };
6112
+ onDrop = (e) => {
6113
+ e.preventDefault();
6114
+ const rect = this.deps.wrapper.getBoundingClientRect();
6115
+ const screenPos = { x: e.clientX - rect.left, y: e.clientY - rect.top };
6116
+ const worldPos = this.deps.camera.screenToWorld(screenPos);
6117
+ if (this.deps.dropHandler) {
6118
+ this.deps.dropHandler(e, worldPos);
6119
+ return;
6120
+ }
6121
+ const files = e.dataTransfer?.files;
6122
+ if (!files) return;
6123
+ for (const file of files) {
6124
+ if (!file.type.startsWith("image/")) continue;
6125
+ const reader = new FileReader();
6126
+ reader.onload = () => {
6127
+ const src = reader.result;
6128
+ if (typeof src !== "string") return;
6129
+ this.deps.addImage(src, worldPos);
6130
+ };
6131
+ reader.readAsDataURL(file);
6132
+ }
6133
+ };
6134
+ };
6135
+
5981
6136
  // src/canvas/viewport.ts
5982
6137
  var EMPTY_IDS = [];
5983
- var ARROW_HIT_THRESHOLD = 10;
5984
6138
  function noop() {
5985
6139
  }
5986
6140
  var Viewport = class {
@@ -6015,7 +6169,7 @@ var Viewport = class {
6015
6169
  toolbar: options.toolbar,
6016
6170
  placeholder: options.placeholder
6017
6171
  });
6018
- this.noteEditor.setOnStop((id) => this.onTextEditStop(id));
6172
+ this.noteEditor.setOnStop((id) => this.interactions.onTextEditStop(id));
6019
6173
  this.arrowLabelEditor = new ArrowLabelEditor();
6020
6174
  this.noteEditor.setHistoryHooks(
6021
6175
  () => this.historyRecorder.begin(),
@@ -6042,8 +6196,8 @@ var Viewport = class {
6042
6196
  store: this.store,
6043
6197
  requestRender: () => this.requestRender(),
6044
6198
  switchTool: (name) => this.toolManager.setTool(name, this.toolContext),
6045
- editElement: (id) => this.startEditingElement(id),
6046
- fitNoteHeight: (id) => this.fitNoteHeight(id),
6199
+ editElement: (id) => this.interactions.startEditingElement(id),
6200
+ fitNoteHeight: (id) => this.interactions.fitNoteHeight(id),
6047
6201
  setCursor: (cursor) => {
6048
6202
  this.wrapper.style.cursor = cursor;
6049
6203
  },
@@ -6079,7 +6233,7 @@ var Viewport = class {
6079
6233
  this.unsubToolChange = this.toolManager.onChange(() => this.contextMenu?.close());
6080
6234
  this.domNodeManager = new DomNodeManager({
6081
6235
  domLayer: this.domLayer,
6082
- onEditRequest: (id) => this.startEditingElement(id),
6236
+ onEditRequest: (id) => this.interactions.startEditingElement(id),
6083
6237
  isEditingElement: (id) => this.noteEditor.isEditing && this.noteEditor.editingElementId === id,
6084
6238
  getVersion: (id) => this.store.getVersion(id)
6085
6239
  });
@@ -6151,10 +6305,26 @@ var Viewport = class {
6151
6305
  this.toolContext.activeLayerId = this.layerManager.activeLayerId;
6152
6306
  this.requestRender();
6153
6307
  });
6154
- this.wrapper.addEventListener("pointerdown", this.onTapDown);
6155
- this.wrapper.addEventListener("pointerup", this.onDoubleTap);
6156
- this.wrapper.addEventListener("dragover", this.onDragOver);
6157
- this.wrapper.addEventListener("drop", this.onDrop);
6308
+ this.interactions = new ViewportInteractions({
6309
+ store: this.store,
6310
+ camera: this.camera,
6311
+ wrapper: this.wrapper,
6312
+ domLayer: this.domLayer,
6313
+ renderLoop: this.renderLoop,
6314
+ domNodeManager: this.domNodeManager,
6315
+ noteEditor: this.noteEditor,
6316
+ arrowLabelEditor: this.arrowLabelEditor,
6317
+ interactMode: this.interactMode,
6318
+ renderer: this.renderer,
6319
+ recorder: this.historyRecorder,
6320
+ requestRender: () => this.requestRender(),
6321
+ addImage: (src, position) => this.addImage(src, position),
6322
+ dropHandler: this.dropHandler
6323
+ });
6324
+ this.wrapper.addEventListener("pointerdown", this.interactions.onTapDown);
6325
+ this.wrapper.addEventListener("pointerup", this.interactions.onDoubleTap);
6326
+ this.wrapper.addEventListener("dragover", this.interactions.onDragOver);
6327
+ this.wrapper.addEventListener("drop", this.interactions.onDrop);
6158
6328
  this.observeResize();
6159
6329
  this.syncCanvasSize();
6160
6330
  this.renderLoop.start();
@@ -6190,9 +6360,7 @@ var Viewport = class {
6190
6360
  onHtmlElementMount;
6191
6361
  dropHandler;
6192
6362
  gridController;
6193
- doubleTapDetector = new DoubleTapDetector();
6194
- tapDownX = 0;
6195
- tapDownY = 0;
6363
+ interactions;
6196
6364
  contextMenu = null;
6197
6365
  get ctx() {
6198
6366
  return this.canvasEl.getContext("2d");
@@ -6453,10 +6621,10 @@ var Viewport = class {
6453
6621
  this.arrowLabelEditor.cancel();
6454
6622
  this.historyRecorder.destroy();
6455
6623
  this.contextMenu?.dispose();
6456
- this.wrapper.removeEventListener("pointerdown", this.onTapDown);
6457
- this.wrapper.removeEventListener("pointerup", this.onDoubleTap);
6458
- this.wrapper.removeEventListener("dragover", this.onDragOver);
6459
- this.wrapper.removeEventListener("drop", this.onDrop);
6624
+ this.wrapper.removeEventListener("pointerdown", this.interactions.onTapDown);
6625
+ this.wrapper.removeEventListener("pointerup", this.interactions.onDoubleTap);
6626
+ this.wrapper.removeEventListener("dragover", this.interactions.onDragOver);
6627
+ this.wrapper.removeEventListener("drop", this.interactions.onDrop);
6460
6628
  this.inputHandler.destroy();
6461
6629
  this.unsubCamera();
6462
6630
  this.unsubToolChange();
@@ -6465,148 +6633,9 @@ var Viewport = class {
6465
6633
  this.resizeObserver = null;
6466
6634
  this.wrapper.remove();
6467
6635
  }
6468
- startEditingElement(id) {
6469
- const element = this.store.getById(id);
6470
- if (!element || element.type !== "note" && element.type !== "text") return;
6471
- this.renderLoop.flush();
6472
- const node = this.domNodeManager.getNode(id);
6473
- if (node) {
6474
- this.noteEditor.startEditing(node, id, this.store);
6475
- }
6476
- }
6477
- fitNoteHeight(elementId) {
6478
- const element = this.store.getById(elementId);
6479
- if (!element || element.type !== "note") return;
6480
- if (isNoteContentEmpty(element.text)) return;
6481
- const node = this.domNodeManager.getNode(elementId);
6482
- if (!node) return;
6483
- const measured = node.scrollHeight;
6484
- if (measured > element.size.h) {
6485
- this.store.update(elementId, { size: { w: element.size.w, h: measured } });
6486
- }
6487
- }
6488
- onTextEditStop(elementId) {
6489
- const element = this.store.getById(elementId);
6490
- if (!element) return;
6491
- if (element.type === "note") {
6492
- if (isNoteContentEmpty(element.text)) {
6493
- this.store.remove(elementId);
6494
- return;
6495
- }
6496
- this.fitNoteHeight(elementId);
6497
- return;
6498
- }
6499
- if (element.type !== "text") return;
6500
- if (!element.text || element.text.trim() === "") {
6501
- this.store.remove(elementId);
6502
- return;
6503
- }
6504
- const node = this.domNodeManager.getNode(elementId);
6505
- if (node && "size" in element) {
6506
- const measured = node.scrollHeight;
6507
- if (measured !== element.size.h) {
6508
- this.store.update(elementId, { size: { w: element.size.w, h: measured } });
6509
- }
6510
- }
6511
- }
6512
- onTapDown = (e) => {
6513
- this.tapDownX = e.clientX;
6514
- this.tapDownY = e.clientY;
6515
- };
6516
- onDoubleTap = (e) => {
6517
- const dx = e.clientX - this.tapDownX;
6518
- const dy = e.clientY - this.tapDownY;
6519
- const moved = Math.sqrt(dx * dx + dy * dy);
6520
- if (moved > 10) return;
6521
- if (!this.doubleTapDetector.feed(e)) return;
6522
- if (typeof document.elementFromPoint !== "function") return;
6523
- const el = document.elementFromPoint(e.clientX, e.clientY);
6524
- const nodeEl = el?.closest("[data-element-id]");
6525
- if (nodeEl) {
6526
- const elementId = nodeEl.dataset["elementId"];
6527
- if (elementId) {
6528
- const element = this.store.getById(elementId);
6529
- if (element?.type === "note" || element?.type === "text") {
6530
- this.startEditingElement(elementId);
6531
- return;
6532
- }
6533
- }
6534
- }
6535
- const rect = this.wrapper.getBoundingClientRect();
6536
- const screen = { x: e.clientX - rect.left, y: e.clientY - rect.top };
6537
- const world = this.camera.screenToWorld(screen);
6538
- const hit = this.hitTestWorld(world);
6539
- if (hit?.type === "html") {
6540
- this.interactMode.startInteracting(hit.id);
6541
- return;
6542
- }
6543
- const arrow = this.findArrowAt(world);
6544
- if (arrow) {
6545
- this.startArrowLabelEdit(arrow);
6546
- }
6547
- };
6548
- findArrowAt(world) {
6549
- const candidates = this.store.queryPoint(world).reverse();
6550
- for (const el of candidates) {
6551
- if (el.type === "arrow" && isNearBezier(world, el.from, el.to, el.bend, ARROW_HIT_THRESHOLD)) {
6552
- return el;
6553
- }
6554
- }
6555
- return void 0;
6556
- }
6557
- startArrowLabelEdit(arrow) {
6558
- this.arrowLabelEditor.startEditing({
6559
- arrow,
6560
- layer: this.domLayer,
6561
- store: this.store,
6562
- recorder: this.historyRecorder,
6563
- onDone: () => {
6564
- this.renderer.setLabelEditingId(null);
6565
- this.requestRender();
6566
- }
6567
- });
6568
- this.renderer.setLabelEditingId(arrow.id);
6569
- }
6570
- hitTestWorld(world) {
6571
- const candidates = this.store.queryPoint(world).reverse();
6572
- for (const el of candidates) {
6573
- if (!("size" in el)) continue;
6574
- const { x, y } = el.position;
6575
- const { w, h } = el.size;
6576
- if (world.x >= x && world.x <= x + w && world.y >= y && world.y <= y + h) {
6577
- return el;
6578
- }
6579
- }
6580
- return null;
6581
- }
6582
6636
  stopInteracting() {
6583
6637
  this.interactMode.stopInteracting();
6584
6638
  }
6585
- onDragOver = (e) => {
6586
- e.preventDefault();
6587
- };
6588
- onDrop = (e) => {
6589
- e.preventDefault();
6590
- const rect = this.wrapper.getBoundingClientRect();
6591
- const screenPos = { x: e.clientX - rect.left, y: e.clientY - rect.top };
6592
- const worldPos = this.camera.screenToWorld(screenPos);
6593
- if (this.dropHandler) {
6594
- this.dropHandler(e, worldPos);
6595
- return;
6596
- }
6597
- const files = e.dataTransfer?.files;
6598
- if (!files) return;
6599
- for (const file of files) {
6600
- if (!file.type.startsWith("image/")) continue;
6601
- const reader = new FileReader();
6602
- reader.onload = () => {
6603
- const src = reader.result;
6604
- if (typeof src !== "string") return;
6605
- this.addImage(src, worldPos);
6606
- };
6607
- reader.readAsDataURL(file);
6608
- }
6609
- };
6610
6639
  unbindArrowsFrom(removedElement) {
6611
6640
  const boundArrows = findBoundArrows(removedElement.id, this.store);
6612
6641
  const bounds = getElementBounds(removedElement);
@@ -8963,7 +8992,7 @@ var TemplateTool = class {
8963
8992
  };
8964
8993
 
8965
8994
  // src/index.ts
8966
- var VERSION = "0.38.2";
8995
+ var VERSION = "0.38.4";
8967
8996
  export {
8968
8997
  ArrowTool,
8969
8998
  AutoSave,