@linkurious/ogma-annotations 1.1.13 → 1.1.15

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/style.css CHANGED
@@ -1 +1 @@
1
- :root{--handle-width: 2px;--point-handle-width: calc(3 * var(--handle-width));--point-handle-border: 2px;--point-handle-total: calc( var(--point-handle-width) + var(--point-handle-border) );--handle-color: #38e}svg text{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.handle{position:absolute;background-color:var(--handle-color)}.handle.line{cursor:move}.annotation-text-handle textarea{outline:none;margin:0;border:0;width:100%;height:100%;cursor:text;padding:0;z-index:1000;resize:none;white-space:break-spaces;background:transparent;overflow:hidden}.annotation-text-handle .noevents{pointer-events:none;z-index:20}.line-handle,.point-handle{z-index:30}.line-handle.top{cursor:ns-resize;height:var(--handle-width);left:0;width:100%;top:calc(var(--handle-width) * -1)}.line-handle.bottom{cursor:ns-resize;height:var(--handle-width);width:100%;left:0;bottom:calc(var(--handle-width) * -1)}.line-handle.left{cursor:ew-resize;height:100%;top:0;left:calc(var(--handle-width) * -1);width:var(--handle-width)}.line-handle.right{cursor:ew-resize;height:100%;right:calc(var(--handle-width) * -1);top:0;width:var(--handle-width)}.line-handle.top,.line-handle.bottom,.line-handle.left,.line-handle.right{cursor:move}.point-handle{border-radius:50%;background-color:#fff;transform-origin:center;transform:translate(-50%,-50%);border:var(--point-handle-border) solid var(--handle-color);width:var(--point-handle-width);height:var(--point-handle-width)}.point-handle.top-left{transform:translate(-75%,-75%)}.point-handle.top-right{transform:translate(-25%,-75%)}.point-handle.bottom-left{transform:translate(-75%,-25%)}.point-handle.bottom-right{transform:translate(-25%,-25%)}.point-handle.top-left,.point-handle.bottom-right{cursor:nwse-resize}.point-handle.top-right,.point-handle.bottom-left{cursor:nesw-resize}.point-handle.bottom-left,.point-handle.bottom-right{top:100%}.point-handle.top-left,.point-handle.top-right{top:0}.point-handle.bottom-left,.point-handle.top-left{left:0}.point-handle.bottom-right,.point-handle.top-right{left:100%}.arrow-handle>.handle{height:var(--point-handle-width);width:var(--point-handle-width);border-radius:50%;cursor:move;transform:translate(-50%,-50%)}.arrow-handle>.line{height:var(--handle-width);border-radius:0;cursor:move}.annotations-hidden-input{position:absolute;bottom:0;left:0;visibility:hidden;display:block}.active{background-color:#38e}.annotation-text{pointer-events:visible;cursor:pointer}.annotation-text:hover>rect{stroke:var(--handle-color)}.annotation-text a{fill:var(--handle-color)}.annotation-text a:hover{text-decoration:underline}
1
+ :root{--handle-width: 2px;--point-handle-width: calc(3 * var(--handle-width));--point-handle-border: 2px;--point-handle-total: calc( var(--point-handle-width) + var(--point-handle-border) );--handle-color: #38e;--handle-background: #fff}svg text{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.handle{position:absolute;background-color:var(--handle-color)}.handle.line{cursor:move}.annotation-text-handle textarea{outline:none;margin:0;border:0;width:100%;height:100%;cursor:text;padding:0;z-index:1000;resize:none;white-space:break-spaces;background:transparent;overflow:hidden}.annotation-text-handle .noevents{pointer-events:none;z-index:20}.line-handle,.point-handle{z-index:30}.line-handle.top{cursor:ns-resize;height:var(--handle-width);left:0;width:100%;top:calc(var(--handle-width) * -1)}.line-handle.bottom{cursor:ns-resize;height:var(--handle-width);width:100%;left:0;bottom:calc(var(--handle-width) * -1)}.line-handle.left{cursor:ew-resize;height:100%;top:0;left:calc(var(--handle-width) * -1);width:var(--handle-width)}.line-handle.right{cursor:ew-resize;height:100%;right:calc(var(--handle-width) * -1);top:0;width:var(--handle-width)}.line-handle.top,.line-handle.bottom,.line-handle.left,.line-handle.right{cursor:move}.point-handle{border-radius:50%;background-color:#fff;transform-origin:center;transform:translate(-50%,-50%);border:var(--point-handle-border) solid var(--handle-color);width:var(--point-handle-width);height:var(--point-handle-width)}.point-handle.top-left{transform:translate(-55%,-55%)}.point-handle.top-right{transform:translate(-45%,-55%)}.point-handle.bottom-left{transform:translate(-55%,-45%)}.point-handle.bottom-right{transform:translate(-45%,-45%)}.point-handle.top-left,.point-handle.bottom-right{cursor:nwse-resize}.point-handle.top-right,.point-handle.bottom-left{cursor:nesw-resize}.point-handle.bottom-left,.point-handle.bottom-right{top:100%}.point-handle.top-left,.point-handle.top-right{top:0}.point-handle.bottom-left,.point-handle.top-left{left:0}.point-handle.bottom-right,.point-handle.top-right{left:100%}.arrow-handle>.handle{height:var(--point-handle-width);width:var(--point-handle-width);border-radius:50%;cursor:move;transform:translate(-50%,-50%)}.arrow-handle>.line{height:var(--handle-width);border-radius:0;cursor:move}.arrow-handle>.point{background-color:var(--handle-background);border:2px solid var(--handle-color)}.annotations-hidden-input{position:absolute;bottom:0;left:0;visibility:hidden;display:block}.active{background-color:#38e}.annotation-text{pointer-events:visible;cursor:pointer}.annotation-text:hover>rect{stroke:var(--handle-color)}.annotation-text a{fill:var(--handle-color)}.annotation-text a:hover{text-decoration:underline}
@@ -93,6 +93,7 @@ export declare class Control extends EventEmitter<FeatureEvents> {
93
93
  * @param style The new style
94
94
  */
95
95
  updateStyle<A extends Annotation>(id: Id, style: A["properties"]["style"]): this;
96
+ setScale(id: Id, scale: number, ox: number, oy: number): this;
96
97
  /**
97
98
  *
98
99
  * @returns the annotations in the controller
@@ -1,4 +1,4 @@
1
- import { Arrow, ArrowStyles } from '../../types';
1
+ import { Arrow, ArrowStyles } from "../../types";
2
2
  /**
3
3
  * @function getArrowHeight
4
4
  * @param arrow The arrow to measure
@@ -17,7 +17,6 @@ export declare abstract class Editor<T extends Annotation> extends eventEmmitter
17
17
  protected shouldDetect: boolean;
18
18
  protected isDragging: boolean;
19
19
  protected showeditorOnHover: boolean;
20
- protected maxHandleScale: number;
21
20
  constructor(ogma: Ogma, editorHtml: string);
22
21
  private _onKeyUp;
23
22
  protected _canRemove(): boolean;
@@ -30,6 +29,7 @@ export declare abstract class Editor<T extends Annotation> extends eventEmmitter
30
29
  add(options: T): T;
31
30
  updateStyle(annotation: T, style: Partial<T["properties"]["style"]>): void;
32
31
  updateGeometry(annotation: T, geometry: Partial<T["geometry"]>): void;
32
+ scale(annotation: T, scale: number, ox: number, oy: number): void;
33
33
  /**
34
34
  * @method update
35
35
  * Updates an annotation (position, color etc)
@@ -1,4 +1,3 @@
1
- import { Point } from "@linkurious/ogma";
2
1
  import type { Feature, FeatureCollection, Geometry, GeometryObject, LineString, Polygon } from "geojson";
3
2
  import { EVT_ADD, EVT_CANCEL_DRAWING, EVT_DRAG, EVT_DRAG_END, EVT_DRAG_START, EVT_HOVER, EVT_REMOVE, EVT_SELECT, EVT_UNHOVER, EVT_UNSELECT, EVT_UPDATE, EVT_LINK } from "./constants";
4
3
  export declare const isArrow: (a: AnnotationFeature<Geometry, AnnotationProps>) => a is Arrow;
@@ -17,6 +16,10 @@ export interface ArrowStyles extends StrokeOptions {
17
16
  tail?: Extremity;
18
17
  head?: Extremity;
19
18
  }
19
+ export type Point = {
20
+ x: number;
21
+ y: number;
22
+ };
20
23
  type ExportedLink = {
21
24
  id: Id;
22
25
  side: "start" | "end";
@@ -41,7 +44,7 @@ export interface TextStyle extends StrokeOptions {
41
44
  /** Helvetica, sans-serif... */
42
45
  font?: string;
43
46
  /** Font size, in pixels */
44
- fontSize?: number;
47
+ fontSize?: number | string;
45
48
  /** text color: #f00, yellow...*/
46
49
  color?: string;
47
50
  /** background color: empty for transparent #f00, yellow...*/
@@ -184,4 +187,5 @@ export type ControllerOptions = {
184
187
  maxArrowHeight: number;
185
188
  };
186
189
  export type Annotation = Arrow | Text;
190
+ export type Vector = Point;
187
191
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Point } from "@linkurious/ogma";
2
- import type { BBox } from "geojson";
2
+ import type { BBox, LineString, Polygon } from "geojson";
3
3
  import { AnnotationCollection, Arrow, Text } from "./types";
4
4
  export declare function createSVGElement<T extends SVGElement>(tag: string): T;
5
5
  export declare function getTextBbox(t: Text): BBox;
@@ -41,6 +41,7 @@ export declare function setArrowEndPoint(a: Arrow, side: "start" | "end", x: num
41
41
  export declare const getHandleId: (handle: HTMLDivElement) => number;
42
42
  type Bounds = [number, number, number, number];
43
43
  export declare function getAnnotationsBounds(annotations: AnnotationCollection): Bounds;
44
+ export declare function scaleGeometry(geometry: LineString | Polygon, scale: number, ox: number, oy: number): LineString | Polygon;
44
45
  export declare function getAttachmentPointOnNode(start: Point, nodeCenter: Point, nodeRadius: number): {
45
46
  x: number;
46
47
  y: number;
@@ -0,0 +1,15 @@
1
+ import { Vector } from "./types";
2
+ export declare const subtract: (a: Vector, b: Vector) => Vector;
3
+ export declare const length: (v: Vector) => number;
4
+ export declare const invert: (v: Vector) => Vector;
5
+ export declare const clone: (v: Vector) => {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ export declare const normalize: (v: Vector) => Vector;
10
+ export declare const add: (a: Vector, b: Vector) => Vector;
11
+ export declare const mul: (v: Vector, s: number) => Vector;
12
+ export declare const multiply: (a: Vector, b: Vector) => Vector;
13
+ export declare const rotateRadians: (v: Vector, angle: number) => Vector;
14
+ export declare const divScalar: (v: Vector, s: number) => Vector;
15
+ export declare const dot: (a: Vector, b: Vector) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-annotations",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "Headless annotation plugin for Ogma",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "scripts": {
30
30
  "prepare": "playwright install",
31
31
  "start": "npm run dev",
32
- "dev": "vite -c web/vite.config.ts",
32
+ "dev": "vite -c web/vite.config.mts",
33
33
  "build:demo": "vite build -c web/vite.config.mts",
34
34
  "prebuild": "rm -rf dist",
35
35
  "bump:patch": "bump2version patch && npm version --no-git-tag-version patch",
@@ -42,6 +42,7 @@
42
42
  "preview": "vite preview",
43
43
  "docs:build": "typedoc --plugin typedoc-plugin-markdown --out ../../docs/api src/index.ts",
44
44
  "postdocs:build": "npm run build:demo",
45
+ "test": "npm run test:unit",
45
46
  "test:unit": "vitest run -c test/unit/vitest.config.mts",
46
47
  "test:watch": "vitest watch -c test/unit/vitest.config.mts",
47
48
  "test:e2e": "vitest run -c test/e2e/vitest.config.mts",
@@ -69,13 +70,11 @@
69
70
  },
70
71
  "dependencies": {
71
72
  "@borgar/textbox": "1.6.0",
72
- "eventemitter3": "5.0.1",
73
- "vector2js": "2.0.1"
73
+ "eventemitter3": "5.0.1"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@linkurious/eslint-config-ogma": "^1.0.9",
77
77
  "@types/geojson": "7946.0.13",
78
- "@types/vector2js": "2.0.2",
79
78
  "canvas": "2.11.2",
80
79
  "eslint": "8.56.0",
81
80
  "get-port": "7.0.0",