@fieldnotes/core 0.40.3 → 0.41.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.d.cts CHANGED
@@ -46,6 +46,7 @@ interface NoteElement extends BaseElement {
46
46
  interface Binding {
47
47
  elementId: string;
48
48
  }
49
+ type ArrowStrokeStyle = 'solid' | 'dashed' | 'dotted';
49
50
  interface ArrowElement extends BaseElement {
50
51
  type: 'arrow';
51
52
  from: Point;
@@ -59,6 +60,8 @@ interface ArrowElement extends BaseElement {
59
60
  cachedControlPoint?: Point;
60
61
  /** Optional text rendered at the curve midpoint. */
61
62
  label?: string;
63
+ /** Line dash appearance. Absent = solid. Decoupled from binding. */
64
+ strokeStyle?: ArrowStrokeStyle;
62
65
  }
63
66
  interface ImageElement extends BaseElement {
64
67
  type: 'image';
@@ -426,6 +429,7 @@ interface ElementStyle {
426
429
  strokeWidth?: number;
427
430
  opacity?: number;
428
431
  fontSize?: number;
432
+ strokeStyle?: ArrowStrokeStyle;
429
433
  }
430
434
  declare function styleToPatch(element: CanvasElement, style: ElementStyle): Partial<CanvasElement>;
431
435
  declare function getElementStyle(element: CanvasElement): ElementStyle;
@@ -633,6 +637,7 @@ interface ArrowInput extends BaseDefaults {
633
637
  fromBinding?: Binding;
634
638
  toBinding?: Binding;
635
639
  label?: string;
640
+ strokeStyle?: ArrowStrokeStyle;
636
641
  }
637
642
  interface ImageInput extends BaseDefaults {
638
643
  position: Point;
@@ -825,6 +830,7 @@ declare class SelectTool implements Tool {
825
830
  interface ArrowToolOptions {
826
831
  color?: string;
827
832
  width?: number;
833
+ strokeStyle?: ArrowStrokeStyle;
828
834
  }
829
835
  declare class ArrowTool implements Tool {
830
836
  readonly name = "arrow";
@@ -833,6 +839,7 @@ declare class ArrowTool implements Tool {
833
839
  private end;
834
840
  private color;
835
841
  private width;
842
+ private strokeStyle;
836
843
  private fromBinding;
837
844
  private fromTarget;
838
845
  private toTarget;
@@ -1048,6 +1055,6 @@ declare class LaserTool implements Tool {
1048
1055
  private notifyOptionsChange;
1049
1056
  }
1050
1057
 
1051
- declare const VERSION = "0.40.3";
1058
+ declare const VERSION = "0.41.0";
1052
1059
 
1053
- 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 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 };
1060
+ 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 };
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ interface NoteElement extends BaseElement {
46
46
  interface Binding {
47
47
  elementId: string;
48
48
  }
49
+ type ArrowStrokeStyle = 'solid' | 'dashed' | 'dotted';
49
50
  interface ArrowElement extends BaseElement {
50
51
  type: 'arrow';
51
52
  from: Point;
@@ -59,6 +60,8 @@ interface ArrowElement extends BaseElement {
59
60
  cachedControlPoint?: Point;
60
61
  /** Optional text rendered at the curve midpoint. */
61
62
  label?: string;
63
+ /** Line dash appearance. Absent = solid. Decoupled from binding. */
64
+ strokeStyle?: ArrowStrokeStyle;
62
65
  }
63
66
  interface ImageElement extends BaseElement {
64
67
  type: 'image';
@@ -426,6 +429,7 @@ interface ElementStyle {
426
429
  strokeWidth?: number;
427
430
  opacity?: number;
428
431
  fontSize?: number;
432
+ strokeStyle?: ArrowStrokeStyle;
429
433
  }
430
434
  declare function styleToPatch(element: CanvasElement, style: ElementStyle): Partial<CanvasElement>;
431
435
  declare function getElementStyle(element: CanvasElement): ElementStyle;
@@ -633,6 +637,7 @@ interface ArrowInput extends BaseDefaults {
633
637
  fromBinding?: Binding;
634
638
  toBinding?: Binding;
635
639
  label?: string;
640
+ strokeStyle?: ArrowStrokeStyle;
636
641
  }
637
642
  interface ImageInput extends BaseDefaults {
638
643
  position: Point;
@@ -825,6 +830,7 @@ declare class SelectTool implements Tool {
825
830
  interface ArrowToolOptions {
826
831
  color?: string;
827
832
  width?: number;
833
+ strokeStyle?: ArrowStrokeStyle;
828
834
  }
829
835
  declare class ArrowTool implements Tool {
830
836
  readonly name = "arrow";
@@ -833,6 +839,7 @@ declare class ArrowTool implements Tool {
833
839
  private end;
834
840
  private color;
835
841
  private width;
842
+ private strokeStyle;
836
843
  private fromBinding;
837
844
  private fromTarget;
838
845
  private toTarget;
@@ -1048,6 +1055,6 @@ declare class LaserTool implements Tool {
1048
1055
  private notifyOptionsChange;
1049
1056
  }
1050
1057
 
1051
- declare const VERSION = "0.40.3";
1058
+ declare const VERSION = "0.41.0";
1052
1059
 
1053
- 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 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 };
1060
+ 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 };
package/dist/index.js CHANGED
@@ -587,7 +587,7 @@ function getBendFromPoint(from, to, dragPoint) {
587
587
  if (len === 0) return 0;
588
588
  const perpX = -dy / len;
589
589
  const perpY = dx / len;
590
- return (dragPoint.x - midX) * perpX + (dragPoint.y - midY) * perpY;
590
+ return 2 * ((dragPoint.x - midX) * perpX + (dragPoint.y - midY) * perpY);
591
591
  }
592
592
  function getArrowTangentAngle(from, to, bend, t) {
593
593
  const cp = getArrowControlPoint(from, to, bend);
@@ -2670,6 +2670,16 @@ function updateBoundArrow(arrow, store) {
2670
2670
  var ARROWHEAD_LENGTH = 12;
2671
2671
  var ARROWHEAD_ANGLE = Math.PI / 6;
2672
2672
  var ARROW_LABEL_FONT_SIZE = 14;
2673
+ function getArrowDashPattern(strokeStyle) {
2674
+ switch (strokeStyle) {
2675
+ case "dashed":
2676
+ return [8, 4];
2677
+ case "dotted":
2678
+ return [2, 4];
2679
+ default:
2680
+ return [];
2681
+ }
2682
+ }
2673
2683
  function renderArrow(ctx, arrow, store, labelEditingId) {
2674
2684
  const geometry = getArrowRenderGeometry(arrow);
2675
2685
  const { visualFrom, visualTo } = getVisualEndpoints(arrow, geometry, store);
@@ -2677,9 +2687,8 @@ function renderArrow(ctx, arrow, store, labelEditingId) {
2677
2687
  ctx.strokeStyle = arrow.color;
2678
2688
  ctx.lineWidth = arrow.width;
2679
2689
  ctx.lineCap = "round";
2680
- if (arrow.fromBinding || arrow.toBinding) {
2681
- ctx.setLineDash([8, 4]);
2682
- }
2690
+ const dash = getArrowDashPattern(arrow.strokeStyle);
2691
+ if (dash.length > 0) ctx.setLineDash(dash);
2683
2692
  ctx.beginPath();
2684
2693
  ctx.moveTo(visualFrom.x, visualFrom.y);
2685
2694
  if (arrow.bend !== 0) {
@@ -3599,6 +3608,7 @@ function createArrow(input) {
3599
3608
  if (input.fromBinding) result.fromBinding = input.fromBinding;
3600
3609
  if (input.toBinding) result.toBinding = input.toBinding;
3601
3610
  if (input.label !== void 0) result.label = input.label;
3611
+ if (input.strokeStyle !== void 0) result.strokeStyle = input.strokeStyle;
3602
3612
  return result;
3603
3613
  }
3604
3614
  function createImage(input) {
@@ -5002,7 +5012,8 @@ function emitArrow(arrow, store) {
5002
5012
  } else {
5003
5013
  d = `M${n(from.x)} ${n(from.y)} L${n(to.x)} ${n(to.y)}`;
5004
5014
  }
5005
- const dash = arrow.fromBinding || arrow.toBinding ? ' stroke-dasharray="8 4"' : "";
5015
+ const pattern = getArrowDashPattern(arrow.strokeStyle);
5016
+ const dash = pattern.length > 0 ? ` stroke-dasharray="${pattern.join(" ")}"` : "";
5006
5017
  let out = `<path d="${d}" fill="none" stroke="${esc(arrow.color)}" stroke-width="${n(arrow.width)}" stroke-linecap="round"${dash} />`;
5007
5018
  const angle = geometry.tangentEnd;
5008
5019
  const p1x = to.x - ARROWHEAD_LENGTH2 * Math.cos(angle - ARROWHEAD_ANGLE2);
@@ -6206,7 +6217,7 @@ function translateElementPatch(el, dx, dy) {
6206
6217
 
6207
6218
  // src/elements/element-style.ts
6208
6219
  function styleToPatch(element, style) {
6209
- const { color, fillColor, strokeWidth, opacity, fontSize } = style;
6220
+ const { color, fillColor, strokeWidth, opacity, fontSize, strokeStyle } = style;
6210
6221
  switch (element.type) {
6211
6222
  case "stroke":
6212
6223
  return {
@@ -6217,7 +6228,8 @@ function styleToPatch(element, style) {
6217
6228
  case "arrow":
6218
6229
  return {
6219
6230
  ...color !== void 0 ? { color } : {},
6220
- ...strokeWidth !== void 0 ? { width: strokeWidth } : {}
6231
+ ...strokeWidth !== void 0 ? { width: strokeWidth } : {},
6232
+ ...strokeStyle !== void 0 ? { strokeStyle } : {}
6221
6233
  };
6222
6234
  case "shape":
6223
6235
  return {
@@ -6258,7 +6270,11 @@ function getElementStyle(element) {
6258
6270
  case "stroke":
6259
6271
  return { color: element.color, strokeWidth: element.width, opacity: element.opacity };
6260
6272
  case "arrow":
6261
- return { color: element.color, strokeWidth: element.width };
6273
+ return {
6274
+ color: element.color,
6275
+ strokeWidth: element.width,
6276
+ ...element.strokeStyle !== void 0 ? { strokeStyle: element.strokeStyle } : {}
6277
+ };
6262
6278
  case "shape":
6263
6279
  return {
6264
6280
  color: element.strokeColor,
@@ -6332,6 +6348,8 @@ var SelectionOps = class {
6332
6348
  if (opacity !== void 0) result.opacity = opacity;
6333
6349
  const fontSize = sharedValue(styles.map((s) => s.fontSize));
6334
6350
  if (fontSize !== void 0) result.fontSize = fontSize;
6351
+ const strokeStyle = sharedValue(styles.map((s) => s.strokeStyle));
6352
+ if (strokeStyle !== void 0) result.strokeStyle = strokeStyle;
6335
6353
  return result;
6336
6354
  }
6337
6355
  applyStyle(style) {
@@ -8749,6 +8767,7 @@ var ArrowTool = class {
8749
8767
  end = { x: 0, y: 0 };
8750
8768
  color;
8751
8769
  width;
8770
+ strokeStyle;
8752
8771
  fromBinding;
8753
8772
  fromTarget = null;
8754
8773
  toTarget = null;
@@ -8756,9 +8775,10 @@ var ArrowTool = class {
8756
8775
  constructor(options = {}) {
8757
8776
  this.color = options.color ?? "#000000";
8758
8777
  this.width = options.width ?? 2;
8778
+ this.strokeStyle = options.strokeStyle ?? "solid";
8759
8779
  }
8760
8780
  getOptions() {
8761
- return { color: this.color, width: this.width };
8781
+ return { color: this.color, width: this.width, strokeStyle: this.strokeStyle };
8762
8782
  }
8763
8783
  onOptionsChange(listener) {
8764
8784
  this.optionListeners.add(listener);
@@ -8767,6 +8787,7 @@ var ArrowTool = class {
8767
8787
  setOptions(options) {
8768
8788
  if (options.color !== void 0) this.color = options.color;
8769
8789
  if (options.width !== void 0) this.width = options.width;
8790
+ if (options.strokeStyle !== void 0) this.strokeStyle = options.strokeStyle;
8770
8791
  this.notifyOptionsChange();
8771
8792
  }
8772
8793
  notifyOptionsChange() {
@@ -8826,6 +8847,7 @@ var ArrowTool = class {
8826
8847
  position: this.start,
8827
8848
  color: this.color,
8828
8849
  width: this.width,
8850
+ strokeStyle: this.strokeStyle,
8829
8851
  fromBinding: this.fromBinding,
8830
8852
  toBinding: this.toTarget ? { elementId: this.toTarget.id } : void 0,
8831
8853
  layerId: ctx.activeLayerId ?? ""
@@ -9693,7 +9715,7 @@ var LaserTool = class {
9693
9715
  };
9694
9716
 
9695
9717
  // src/index.ts
9696
- var VERSION = "0.40.3";
9718
+ var VERSION = "0.41.0";
9697
9719
  export {
9698
9720
  ArrowTool,
9699
9721
  AutoSave,