@linkurious/ogma-annotations 2.1.0 → 2.1.2

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.
@@ -173,6 +173,15 @@ export declare interface BoxStyle extends StrokeOptions {
173
173
  */
174
174
  export declare const brighten: (color: Color) => RgbaColor;
175
175
 
176
+ /**
177
+ * Move `el` to the end of `root`'s children. SVG paint order is DOM order,
178
+ * so this is how a shape gets raised to the top of its group. Safe to call
179
+ * every render even when `el` is already last - `appendChild` on an
180
+ * existing child just re-positions it, it doesn't clone or re-trigger
181
+ * insertion.
182
+ */
183
+ export declare function bringToTop(root: Element, el: Element): void;
184
+
176
185
  /**
177
186
  * Calculate optimal zoom threshold for auto-collapse based on comment dimensions
178
187
  *
@@ -324,6 +333,14 @@ export declare interface CommentStyle extends TextStyle {
324
333
  shadow?: boolean;
325
334
  /** Expand to full width when selected (default: false) */
326
335
  expandOnSelect?: boolean;
336
+ /**
337
+ * Connector-line behavior when the attachment point moves (default: "rigid").
338
+ * - "rigid": the comment translates by the same offset as the moved
339
+ * attachment point — the arrow keeps its length/angle, whole callout moves.
340
+ * - "elastic": the comment stays put; the arrow re-anchors to the nearest
341
+ * point on the comment box, so the line can stretch/rotate.
342
+ */
343
+ connectorMode?: "rigid" | "elastic";
327
344
  }
328
345
 
329
346
  /**
@@ -556,6 +573,51 @@ export declare class Control extends default_2<FeatureEvents> {
556
573
  commentStyle?: Partial<CommentProps>;
557
574
  arrowStyle?: Partial<ArrowProperties>;
558
575
  }): this;
576
+ /**
577
+ * Enable sticky note drawing mode - drops a plain, resizable text box
578
+ * (empty content, "Quick note…" ghost placeholder, no connector arrow)
579
+ * like a Miro sticky note, unlike `enableCommentDrawing`. It's a regular
580
+ * `text` annotation, so it's placed the same interactive way as
581
+ * `enableBoxDrawing`/`enableTextDrawing`: click for a default-size square,
582
+ * or drag to size it - either way it keeps the usual corner/edge drag
583
+ * handles to resize it afterward.
584
+ *
585
+ * Call this method when the user clicks an "Add sticky note" button. The
586
+ * control will:
587
+ * 1. Wait for the next mousedown event
588
+ * 2. Create the note at that position and start the interactive
589
+ * corner-drag, already selected
590
+ * 3. On release: a plain click (no drag) gets a default square size, a
591
+ * drag gets sized to match instead - either way it drops straight
592
+ * into editing (the placeholder is just ghost text, so typing
593
+ * immediately replaces it)
594
+ * 4. Clean up automatically when done
595
+ *
596
+ * @example
597
+ * ```ts
598
+ * addStickyNoteButton.addEventListener('click', () => {
599
+ * control.enableStickyNoteDrawing({ background: '#FFEB99' });
600
+ * });
601
+ * ```
602
+ *
603
+ * @param style Sticky note style options (merged over the sticky note defaults)
604
+ * @returns this for chaining
605
+ * @see startStickyNote for low-level programmatic control
606
+ */
607
+ enableStickyNoteDrawing(style?: Partial<Text_2["properties"]["style"]>): this;
608
+ /**
609
+ * Enable erase mode: every click on an annotation deletes it immediately.
610
+ * Stays armed across multiple clicks until `disableEraseMode()` is called,
611
+ * or another drawing tool is enabled / `cancelDrawing()` is called.
612
+ *
613
+ * @returns this for chaining
614
+ * @see disableEraseMode to turn erase mode off
615
+ */
616
+ enableEraseMode(): this;
617
+ /** Turn erase mode off. No-op if it isn't active. */
618
+ disableEraseMode(): this;
619
+ /** Whether erase mode is currently active. */
620
+ isEraseModeActive(): boolean;
559
621
  /**
560
622
  * Place a pre-created annotation by moving it with the cursor.
561
623
  * The annotation follows the mouse until the user clicks to place it.
@@ -603,6 +665,21 @@ export declare class Control extends default_2<FeatureEvents> {
603
665
  commentStyle?: Partial<CommentProps>;
604
666
  arrowStyle?: Partial<ArrowProperties>;
605
667
  }): this;
668
+ /**
669
+ * **Advanced API:** Programmatically start drawing a sticky note at
670
+ * specific coordinates - same interactive corner-drag as `startBox`.
671
+ * You must handle mouse events yourself (or immediately release/complete
672
+ * it via the same events `enableStickyNoteDrawing` would).
673
+ *
674
+ * **For most use cases, use `enableStickyNoteDrawing()` instead.**
675
+ *
676
+ * @param x X coordinate for the note's top-left corner
677
+ * @param y Y coordinate for the note's top-left corner
678
+ * @param style Sticky note style options
679
+ * @returns this for chaining
680
+ * @see enableStickyNoteDrawing for the recommended high-level API
681
+ */
682
+ startStickyNote(x: number, y: number, style?: Partial<Text_2["properties"]["style"]>): this;
606
683
  /**
607
684
  * **Advanced API:** Programmatically start drawing a box at specific coordinates.
608
685
  *
@@ -1412,6 +1489,42 @@ export { getBoxSize as getTextSize }
1412
1489
  /** @private */
1413
1490
  export declare function getBrowserWindow(): HTMLElement | undefined;
1414
1491
 
1492
+ /**
1493
+ * Ids that removing `id` should take with it: `id` itself, plus every arrow
1494
+ * attached to it when it's a comment or text annotation - deleting the
1495
+ * anchor takes its connectors along, since a detached comment-arrow has
1496
+ * nothing to point at.
1497
+ *
1498
+ * @param features - The full feature map (pre-deletion)
1499
+ * @param id - The id being removed
1500
+ * @returns The complete set of ids to delete
1501
+ */
1502
+ export declare function getCascadeDeleteIds(features: Record<Id, Annotation>, id: Id): Set<Id>;
1503
+
1504
+ /**
1505
+ * Comments must always keep at least one arrow. Returns the comment's id
1506
+ * when deleting `arrowId` would leave it with none, so the caller can block
1507
+ * the deletion instead - or `null` when it's safe to proceed.
1508
+ *
1509
+ * @param features - The full feature map (pre-deletion)
1510
+ * @param arrowId - The arrow being removed
1511
+ */
1512
+ export declare function getCommentLeftOrphanedBy(features: Record<Id, Annotation>, arrowId: Id): Id | null;
1513
+
1514
+ /**
1515
+ * Get the id of the comment an arrow is connected to, if any.
1516
+ *
1517
+ * A comment is one visual annotation together with the arrow that connects
1518
+ * it - callers that raise a comment's z-order (e.g. bringing a newly
1519
+ * created/selected comment to the front) should raise this arrow along with
1520
+ * it, not just the comment bubble.
1521
+ *
1522
+ * @param arrow - The arrow feature to check
1523
+ * @returns The linked comment's id, or undefined if the arrow isn't attached
1524
+ * to a comment
1525
+ */
1526
+ export declare function getCommentLinkId(arrow: Arrow): Id | undefined;
1527
+
1415
1528
  /**
1416
1529
  * Get the position (center) of a comment
1417
1530
  *
@@ -1507,9 +1620,8 @@ export declare const isComment: (a: AnnotationFeature<Geometry, AnnotationProps>
1507
1620
  * These functions provide utilities for:
1508
1621
  * - Checking if an arrow is connected to a comment
1509
1622
  * - Determining if arrow endpoints can be detached from comments
1510
- *
1511
- * Note: The core rule "comments must have at least one arrow" is enforced
1512
- * in store/index.ts removeFeature() method, not here.
1623
+ * - Cascading a comment's delete to its arrows, and blocking deletion of a
1624
+ * comment's last remaining arrow (store/index.ts:removeFeature uses both)
1513
1625
  */
1514
1626
  /**
1515
1627
  * Check if an arrow is connected to a comment
@@ -1543,6 +1655,16 @@ export declare function isRgbaColor(color: string): color is RgbaColor;
1543
1655
  */
1544
1656
  export declare function isRgbColor(color: string): color is RgbColor;
1545
1657
 
1658
+ /**
1659
+ * Whether a comment's connector line should rigidly follow its attachment
1660
+ * point (translate the comment by the same offset) rather than elastically
1661
+ * re-anchoring to the nearest point on the comment box.
1662
+ *
1663
+ * @param comment - Comment annotation
1664
+ * @returns True unless the comment's style explicitly sets `connectorMode: "elastic"`
1665
+ */
1666
+ export declare function isRigidConnector(comment: Comment_2): boolean;
1667
+
1546
1668
  export declare const isText: (a: AnnotationFeature<Geometry, AnnotationProps>) => a is Text_2;
1547
1669
 
1548
1670
  /** @private */
@@ -1751,6 +1873,13 @@ export declare interface TextStyle extends BoxStyle {
1751
1873
  borderRadius?: number;
1752
1874
  /** When true, text maintains constant size regardless of zoom level */
1753
1875
  fixedSize?: boolean;
1876
+ /**
1877
+ * Ghost text shown (via the textarea's native `placeholder` attribute)
1878
+ * while `content` is empty - disappears the instant the user types, no
1879
+ * selection/focus tricks needed. Overrides the global
1880
+ * `ControllerOptions.textPlaceholder` for this annotation.
1881
+ */
1882
+ placeholder?: string;
1754
1883
  }
1755
1884
 
1756
1885
  /** @private */