@yorab/react-paint 0.18.1 → 1.0.0-beta.1

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.
Files changed (247) hide show
  1. package/README.md +266 -22
  2. package/dist/_chunks/canvas-CDYlr833.js +1 -0
  3. package/dist/_chunks/editor-BARYd5Od.js +1 -0
  4. package/dist/canvas/components/Canvas.d.ts +15 -3
  5. package/dist/canvas/components/EditTextBox.d.ts +4 -4
  6. package/dist/canvas/constants/app.d.ts +32 -17
  7. package/dist/canvas/constants/grid.d.ts +7 -0
  8. package/dist/canvas/constants/picture.d.ts +8 -0
  9. package/dist/canvas/constants/shapes.d.ts +2 -2
  10. package/dist/canvas/constants/tools.d.ts +12 -2
  11. package/dist/canvas/constants/zoom.d.ts +4 -2
  12. package/dist/canvas/context/PaintContext.d.ts +9 -0
  13. package/dist/canvas/hooks/useAnnotationsStyle.d.ts +5 -0
  14. package/dist/canvas/hooks/useAutoScroll.d.ts +4 -0
  15. package/dist/canvas/hooks/useCanvasRenderer.d.ts +17 -0
  16. package/dist/canvas/hooks/useDrawableCanvas.d.ts +8 -5
  17. package/dist/canvas/hooks/useDropPicture.d.ts +7 -0
  18. package/dist/canvas/hooks/useKeyboard.d.ts +6 -32
  19. package/dist/canvas/hooks/usePaintState.d.ts +9 -0
  20. package/dist/canvas/hooks/usePinchZoomAndMove.d.ts +3 -13
  21. package/dist/canvas/hooks/useReactPaint.d.ts +11 -163
  22. package/dist/canvas/hooks/useResizeObserver.d.ts +1 -0
  23. package/dist/canvas/hooks/useShapeEvents.d.ts +7 -0
  24. package/dist/canvas/hooks/useZoom.d.ts +4 -17
  25. package/dist/canvas/index.d.ts +24 -17
  26. package/dist/canvas/index.js +1 -1
  27. package/dist/canvas/store/createStore.d.ts +14 -0
  28. package/dist/canvas/store/eventEmitter.d.ts +11 -0
  29. package/dist/canvas/store/internal.d.ts +5 -0
  30. package/dist/canvas/store/paintStore.d.ts +898 -0
  31. package/dist/canvas/store/selectors.d.ts +855 -0
  32. package/dist/canvas/store/shapesReducer.d.ts +66 -0
  33. package/dist/canvas/store/types.d.ts +72 -0
  34. package/dist/canvas/types/Canvas.d.ts +19 -0
  35. package/dist/{src/common → canvas}/types/Mode.d.ts +8 -15
  36. package/dist/{common → canvas}/types/Settings.d.ts +6 -1
  37. package/dist/{common → canvas}/types/Shapes.d.ts +27 -21
  38. package/dist/canvas/types/editor.d.ts +388 -0
  39. package/dist/{common → canvas}/types/tools.d.ts +10 -6
  40. package/dist/{common → canvas}/utils/array.d.ts +2 -0
  41. package/dist/canvas/utils/canvas.d.ts +18 -2
  42. package/dist/canvas/utils/click.d.ts +17 -0
  43. package/dist/canvas/utils/data.d.ts +6 -5
  44. package/dist/canvas/utils/equality.d.ts +5 -0
  45. package/dist/canvas/utils/file.d.ts +36 -266
  46. package/dist/canvas/utils/grid.d.ts +1 -1
  47. package/dist/canvas/utils/intersect.d.ts +24 -14
  48. package/dist/canvas/utils/object.d.ts +11 -0
  49. package/dist/{src/common/utils/selection.d.ts → canvas/utils/selectedShapes.d.ts} +2 -2
  50. package/dist/canvas/utils/selection/anchors.d.ts +16 -0
  51. package/dist/canvas/utils/selection/groupSelection.d.ts +3 -3
  52. package/dist/canvas/utils/selection/lineSelection.d.ts +3 -10
  53. package/dist/canvas/utils/selection/rectSelection.d.ts +6 -11
  54. package/dist/canvas/utils/selection/selectionFrame.d.ts +2 -2
  55. package/dist/canvas/utils/selection.d.ts +7 -5
  56. package/dist/canvas/utils/shapeInput.d.ts +45 -0
  57. package/dist/canvas/utils/shapePatch.d.ts +10 -0
  58. package/dist/canvas/utils/shapes/brush.d.ts +6 -6
  59. package/dist/canvas/utils/shapes/circle.d.ts +5 -5
  60. package/dist/canvas/utils/shapes/curve.d.ts +4 -4
  61. package/dist/canvas/utils/shapes/ellipse.d.ts +5 -5
  62. package/dist/canvas/utils/shapes/group.d.ts +9 -3
  63. package/dist/canvas/utils/shapes/index.d.ts +31 -5
  64. package/dist/canvas/utils/shapes/line.d.ts +5 -5
  65. package/dist/canvas/utils/shapes/path.d.ts +16 -8
  66. package/dist/canvas/utils/shapes/picture.d.ts +7 -5
  67. package/dist/canvas/utils/shapes/polygon.d.ts +4 -4
  68. package/dist/canvas/utils/shapes/rectangle.d.ts +5 -5
  69. package/dist/canvas/utils/shapes/text.d.ts +12 -6
  70. package/dist/canvas/utils/shapes/triangle.d.ts +2 -2
  71. package/dist/canvas/utils/tools.d.ts +12 -3
  72. package/dist/canvas/utils/transform.d.ts +5 -4
  73. package/dist/canvas/utils/trigo.d.ts +17 -1
  74. package/dist/canvas/utils/util.d.ts +14 -0
  75. package/dist/canvas/utils/zoom.d.ts +29 -15
  76. package/dist/editor/components/common/Button.d.ts +0 -1
  77. package/dist/editor/components/common/FileInput.d.ts +0 -1
  78. package/dist/editor/components/common/Loading.d.ts +1 -2
  79. package/dist/editor/components/common/Menu.d.ts +3 -2
  80. package/dist/editor/components/common/Modal.d.ts +1 -2
  81. package/dist/editor/components/common/Panel.d.ts +1 -2
  82. package/dist/editor/components/common/Snackbar.d.ts +2 -3
  83. package/dist/editor/components/settings/ClosedPointsField.d.ts +1 -1
  84. package/dist/editor/components/settings/ColorField.d.ts +1 -2
  85. package/dist/editor/components/settings/DeleteButton.d.ts +3 -4
  86. package/dist/editor/components/settings/FontFamilyField.d.ts +1 -2
  87. package/dist/editor/components/settings/LayoutButton.d.ts +1 -2
  88. package/dist/editor/components/settings/Layouts.d.ts +4 -15
  89. package/dist/editor/components/settings/LineArrowField.d.ts +1 -2
  90. package/dist/editor/components/settings/LineTypeField.d.ts +2 -3
  91. package/dist/editor/components/settings/RangeField.d.ts +1 -2
  92. package/dist/editor/components/settings/SelectField.d.ts +1 -2
  93. package/dist/editor/components/settings/SettingsBar.d.ts +3 -18
  94. package/dist/editor/components/settings/ToggleField.d.ts +2 -1
  95. package/dist/editor/components/settings/ZoomButton.d.ts +1 -2
  96. package/dist/editor/components/settings/ZoomPanel.d.ts +4 -0
  97. package/dist/editor/components/toolbox/ActionButton.d.ts +9 -0
  98. package/dist/editor/components/toolbox/ContextMenu.d.ts +5 -24
  99. package/dist/editor/components/toolbox/ExportModal.d.ts +1 -2
  100. package/dist/editor/components/toolbox/LoadFileTool.d.ts +4 -4
  101. package/dist/editor/components/toolbox/MenuGroup.d.ts +1 -7
  102. package/dist/editor/components/toolbox/PictureUrlInput.d.ts +2 -2
  103. package/dist/editor/components/toolbox/Tool.d.ts +3 -3
  104. package/dist/editor/components/toolbox/Toolbar.d.ts +5 -16
  105. package/dist/editor/components/toolbox/ToolbarGroup.d.ts +2 -3
  106. package/dist/editor/constants/options.d.ts +11 -1
  107. package/dist/editor/constants/snackbar.d.ts +1 -1
  108. package/dist/editor/constants/style.d.ts +0 -9
  109. package/dist/editor/constants/tools.d.ts +12 -32
  110. package/dist/editor/editor.css +1 -0
  111. package/dist/editor/hooks/useDrag.d.ts +3 -3
  112. package/dist/editor/hooks/useMenu.d.ts +3 -2
  113. package/dist/editor/hooks/usePressOutside.d.ts +7 -0
  114. package/dist/editor/hooks/useSnackbar.d.ts +1 -1
  115. package/dist/editor/index.d.ts +12 -22
  116. package/dist/editor/index.js +1 -1
  117. package/dist/editor/types/tools.d.ts +7 -0
  118. package/dist/editor/utils/dom.d.ts +1 -0
  119. package/dist/editor/utils/style.d.ts +7 -1
  120. package/dist/editor/utils/toolbar.d.ts +1 -2
  121. package/dist/editor/utils/util.d.ts +5 -0
  122. package/dist/index.d.ts +2 -5
  123. package/dist/react-paint.css +1 -1
  124. package/dist/react-paint.js +1 -1
  125. package/dist/react-paint.umd.cjs +1 -1
  126. package/package.json +37 -26
  127. package/dist/_chunks/array-DuJem3vg.js +0 -1
  128. package/dist/_chunks/canvas-DF1RWuxW.js +0 -1
  129. package/dist/_chunks/editor-DuVskl0R.js +0 -1
  130. package/dist/canvas/context/CanvasContext.d.ts +0 -55
  131. package/dist/canvas/hooks/useComponent.d.ts +0 -12
  132. package/dist/canvas/hooks/useDoubleClick.d.ts +0 -5
  133. package/dist/canvas/hooks/useEventListener.d.ts +0 -2
  134. package/dist/canvas/hooks/useShapes.d.ts +0 -44
  135. package/dist/common/hooks/useDebounce.d.ts +0 -2
  136. package/dist/common/types/Canvas.d.ts +0 -8
  137. package/dist/common/types/Mode.d.ts +0 -64
  138. package/dist/common/types/react.d.ts +0 -6
  139. package/dist/common/utils/dom.d.ts +0 -1
  140. package/dist/common/utils/object.d.ts +0 -4
  141. package/dist/common/utils/selection.d.ts +0 -4
  142. package/dist/common/utils/util.d.ts +0 -3
  143. package/dist/editor/constants/grid.d.ts +0 -7
  144. package/dist/src/canvas/components/Canvas.d.ts +0 -4
  145. package/dist/src/canvas/components/EditTextBox.d.ts +0 -13
  146. package/dist/src/canvas/constants/app.d.ts +0 -37
  147. package/dist/src/canvas/constants/grid.d.ts +0 -1
  148. package/dist/src/canvas/constants/keyboard.d.ts +0 -27
  149. package/dist/src/canvas/constants/picture.d.ts +0 -1
  150. package/dist/src/canvas/constants/rendering.d.ts +0 -3
  151. package/dist/src/canvas/constants/shapes.d.ts +0 -10
  152. package/dist/src/canvas/constants/tools.d.ts +0 -4
  153. package/dist/src/canvas/constants/zoom.d.ts +0 -5
  154. package/dist/src/canvas/context/CanvasContext.d.ts +0 -55
  155. package/dist/src/canvas/hooks/useComponent.d.ts +0 -12
  156. package/dist/src/canvas/hooks/useDoubleClick.d.ts +0 -5
  157. package/dist/src/canvas/hooks/useDrawableCanvas.d.ts +0 -6
  158. package/dist/src/canvas/hooks/useEventListener.d.ts +0 -2
  159. package/dist/src/canvas/hooks/useKeyboard.d.ts +0 -33
  160. package/dist/src/canvas/hooks/usePinchZoomAndMove.d.ts +0 -17
  161. package/dist/src/canvas/hooks/useReactPaint.d.ts +0 -164
  162. package/dist/src/canvas/hooks/useResizeObserver.d.ts +0 -6
  163. package/dist/src/canvas/hooks/useShapes.d.ts +0 -44
  164. package/dist/src/canvas/hooks/useZoom.d.ts +0 -22
  165. package/dist/src/canvas/index.d.ts +0 -19
  166. package/dist/src/canvas/utils/canvas.d.ts +0 -15
  167. package/dist/src/canvas/utils/data.d.ts +0 -5
  168. package/dist/src/canvas/utils/file.d.ts +0 -274
  169. package/dist/src/canvas/utils/grid.d.ts +0 -2
  170. package/dist/src/canvas/utils/intersect.d.ts +0 -27
  171. package/dist/src/canvas/utils/selection/groupSelection.d.ts +0 -4
  172. package/dist/src/canvas/utils/selection/lineSelection.d.ts +0 -19
  173. package/dist/src/canvas/utils/selection/rectSelection.d.ts +0 -20
  174. package/dist/src/canvas/utils/selection/selectionFrame.d.ts +0 -3
  175. package/dist/src/canvas/utils/selection.d.ts +0 -12
  176. package/dist/src/canvas/utils/shapes/brush.d.ts +0 -21
  177. package/dist/src/canvas/utils/shapes/circle.d.ts +0 -18
  178. package/dist/src/canvas/utils/shapes/curve.d.ts +0 -17
  179. package/dist/src/canvas/utils/shapes/ellipse.d.ts +0 -18
  180. package/dist/src/canvas/utils/shapes/group.d.ts +0 -33
  181. package/dist/src/canvas/utils/shapes/index.d.ts +0 -35
  182. package/dist/src/canvas/utils/shapes/line.d.ts +0 -19
  183. package/dist/src/canvas/utils/shapes/path.d.ts +0 -29
  184. package/dist/src/canvas/utils/shapes/picture.d.ts +0 -13
  185. package/dist/src/canvas/utils/shapes/polygon.d.ts +0 -18
  186. package/dist/src/canvas/utils/shapes/rectangle.d.ts +0 -22
  187. package/dist/src/canvas/utils/shapes/text.d.ts +0 -27
  188. package/dist/src/canvas/utils/shapes/triangle.d.ts +0 -4
  189. package/dist/src/canvas/utils/transform.d.ts +0 -15
  190. package/dist/src/canvas/utils/trigo.d.ts +0 -19
  191. package/dist/src/canvas/utils/zoom.d.ts +0 -58
  192. package/dist/src/common/hooks/useDebounce.d.ts +0 -2
  193. package/dist/src/common/types/Canvas.d.ts +0 -8
  194. package/dist/src/common/types/Settings.d.ts +0 -24
  195. package/dist/src/common/types/Shapes.d.ts +0 -153
  196. package/dist/src/common/types/react.d.ts +0 -6
  197. package/dist/src/common/types/tools.d.ts +0 -164
  198. package/dist/src/common/types/utils.d.ts +0 -4
  199. package/dist/src/common/utils/array.d.ts +0 -2
  200. package/dist/src/common/utils/dom.d.ts +0 -1
  201. package/dist/src/common/utils/object.d.ts +0 -4
  202. package/dist/src/common/utils/util.d.ts +0 -3
  203. package/dist/src/editor/components/common/Button.d.ts +0 -16
  204. package/dist/src/editor/components/common/FileInput.d.ts +0 -13
  205. package/dist/src/editor/components/common/Loading.d.ts +0 -6
  206. package/dist/src/editor/components/common/Menu.d.ts +0 -10
  207. package/dist/src/editor/components/common/Modal.d.ts +0 -11
  208. package/dist/src/editor/components/common/Panel.d.ts +0 -15
  209. package/dist/src/editor/components/common/Snackbar.d.ts +0 -7
  210. package/dist/src/editor/components/settings/ClosedPointsField.d.ts +0 -10
  211. package/dist/src/editor/components/settings/ColorField.d.ts +0 -15
  212. package/dist/src/editor/components/settings/DeleteButton.d.ts +0 -8
  213. package/dist/src/editor/components/settings/FontFamilyField.d.ts +0 -12
  214. package/dist/src/editor/components/settings/LayoutButton.d.ts +0 -7
  215. package/dist/src/editor/components/settings/Layouts.d.ts +0 -19
  216. package/dist/src/editor/components/settings/LineArrowField.d.ts +0 -12
  217. package/dist/src/editor/components/settings/LineTypeField.d.ts +0 -16
  218. package/dist/src/editor/components/settings/RangeField.d.ts +0 -19
  219. package/dist/src/editor/components/settings/SelectField.d.ts +0 -18
  220. package/dist/src/editor/components/settings/SettingsBar.d.ts +0 -26
  221. package/dist/src/editor/components/settings/ToggleField.d.ts +0 -13
  222. package/dist/src/editor/components/settings/ZoomButton.d.ts +0 -8
  223. package/dist/src/editor/components/toolbox/ContextMenu.d.ts +0 -25
  224. package/dist/src/editor/components/toolbox/ExportModal.d.ts +0 -7
  225. package/dist/src/editor/components/toolbox/LoadFileTool.d.ts +0 -11
  226. package/dist/src/editor/components/toolbox/MenuGroup.d.ts +0 -27
  227. package/dist/src/editor/components/toolbox/PictureUrlInput.d.ts +0 -7
  228. package/dist/src/editor/components/toolbox/Tool.d.ts +0 -11
  229. package/dist/src/editor/components/toolbox/Toolbar.d.ts +0 -26
  230. package/dist/src/editor/components/toolbox/ToolbarGroup.d.ts +0 -14
  231. package/dist/src/editor/constants/grid.d.ts +0 -7
  232. package/dist/src/editor/constants/icons.d.ts +0 -43
  233. package/dist/src/editor/constants/loading.d.ts +0 -1
  234. package/dist/src/editor/constants/options.d.ts +0 -13
  235. package/dist/src/editor/constants/snackbar.d.ts +0 -7
  236. package/dist/src/editor/constants/style.d.ts +0 -14
  237. package/dist/src/editor/constants/tools.d.ts +0 -32
  238. package/dist/src/editor/hooks/useDrag.d.ts +0 -15
  239. package/dist/src/editor/hooks/useMenu.d.ts +0 -11
  240. package/dist/src/editor/hooks/useSnackbar.d.ts +0 -10
  241. package/dist/src/editor/index.d.ts +0 -25
  242. package/dist/src/editor/types/snackbar.d.ts +0 -7
  243. package/dist/src/editor/utils/style.d.ts +0 -2
  244. package/dist/src/editor/utils/toolbar.d.ts +0 -11
  245. package/dist/src/index.d.ts +0 -5
  246. /package/dist/{common → canvas}/types/utils.d.ts +0 -0
  247. /package/dist/{canvas → editor}/hooks/useDebounce.d.ts +0 -0
@@ -1,6 +1,7 @@
1
- import type { ShapeType } from './Shapes';
1
+ import type { ShapeType } from './Shapes.js';
2
2
  export type CustomToolInput = {
3
3
  id: string;
4
+ /** SVG markup, rendered as HTML by the editor: it must be trusted, never built from what a user typed or loaded */
4
5
  icon?: string;
5
6
  label?: string;
6
7
  } & ({
@@ -36,8 +37,9 @@ export type CustomToolInput = {
36
37
  });
37
38
  export type CustomTool = {
38
39
  id: string;
39
- icon: string;
40
- label: string;
40
+ /** SVG markup, rendered as HTML by the editor: it must be trusted, never built from what a user typed or loaded */
41
+ icon?: string;
42
+ label?: string;
41
43
  } & ({
42
44
  type: 'brush';
43
45
  settings: ToolsSettingsType<'brush'>;
@@ -154,11 +156,13 @@ export type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & Se
154
156
  export type ToolsPictureSettings = SettingsOpacity;
155
157
  export type ToolsGroupSettings = Partial<SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow>;
156
158
  export type ToolsSettingsType<T extends ShapeType> = T extends 'rect' ? ToolsRectSettings : T extends 'square' ? ToolsSquareSettings : T extends 'circle' ? ToolsCircleSettings : T extends 'ellipse' ? ToolsEllipseSettings : T extends 'text' ? ToolsTextSettings : T extends 'line' ? ToolsLineSettings : T extends 'brush' ? ToolsBrushSettings : T extends 'polygon' ? ToolsPolygonSettings : T extends 'curve' ? ToolsCurveSettings : T extends 'triangle' ? ToolsTriangleSettings : T extends 'picture' ? ToolsPictureSettings : T extends 'group' ? ToolsGroupSettings : never;
157
- export type ActionsType = 'selection' | 'undo' | 'redo' | 'clear' | 'export' | 'loadfile' | 'savefile' | 'move' | 'uploadpicture' | 'addurlpicture';
159
+ /** Tools handled by the canvas besides the drawing tools. The buttons of an editor (undo, export...) are not tools */
160
+ export type ActionsType = 'selection' | 'move';
158
161
  export type ActionsTool = {
159
162
  id: string;
160
163
  type: ActionsType;
161
- icon: string;
162
- label: string;
164
+ /** SVG markup, rendered as HTML by the editor: it must be trusted, never built from what a user typed or loaded */
165
+ icon?: string;
166
+ label?: string;
163
167
  };
164
168
  export type ToolsType = CustomTool | ActionsTool;
@@ -1,2 +1,4 @@
1
1
  export declare const compact: <T>(array: (T | undefined | null)[]) => T[];
2
+ /** Copy of the array with the items inserted at the index, kept inside the array */
3
+ export declare const insertAt: <T>(array: readonly T[], index: number, ...items: T[]) => T[];
2
4
  export declare const moveItemPosition: <T>(array: T[], positionToMove: number, positionToEnd: number) => T[];
@@ -1,5 +1,6 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { Point, StyleShape } from './../../common/types/Shapes';
1
+ import type { UtilsSettings } from './../../canvas/constants/app.js';
2
+ import type { CanvasSize, Resize } from './../../canvas/types/Canvas.js';
3
+ import type { Point, StyleShape } from './../../canvas/types/Shapes.js';
3
4
  export declare const initCanvasContext: (ctx: CanvasRenderingContext2D) => void;
4
5
  export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?: {
5
6
  fillColor?: string;
@@ -13,3 +14,18 @@ export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?
13
14
  }) => void;
14
15
  export declare const transformCanvas: (ctx: CanvasRenderingContext2D, settings: UtilsSettings, rotation?: number, translation?: Point) => void;
15
16
  export declare const drawPathWithFillAndStroke: (ctx: CanvasRenderingContext2D, path: Path2D, style?: Pick<StyleShape, "fillColor" | "strokeColor">) => void;
17
+ /** Size of a canvas showing the whole drawing, scaled to the width it is displayed at */
18
+ export declare const getScaledCanvasSize: (displayWidth: number, width: number, height: number) => CanvasSize;
19
+ /** Size of a canvas at the scale 1, showing an area of the drawing as large as itself */
20
+ export declare const getUnscaledCanvasSize: (width: number, height: number) => CanvasSize;
21
+ /** The scaled canvas can be wider than its logical width */
22
+ export declare const canScaleUp: (resize: Resize) => resize is "scale" | "scaleUp";
23
+ /** The scaled canvas can be narrower than its logical width */
24
+ export declare const canScaleDown: (resize: Resize) => resize is "scaleDown" | "scale";
25
+ /** A 2D context of a canvas out of the page, to measure texts and test points when no Canvas is mounted. Null outside of a browser */
26
+ export declare const createDetachedContext: () => CanvasRenderingContext2D | null;
27
+ /**
28
+ * Measures texts without a canvas, about 0.6 em per character, so that texts can still be created outside of a browser.
29
+ * It only has the members used to measure a text
30
+ */
31
+ export declare const createApproximateTextContext: () => CanvasRenderingContext2D;
@@ -0,0 +1,17 @@
1
+ /** A press is a click when the pointer barely moves, during less than this duration */
2
+ export declare const CLICK_MAX_DURATION_MS = 500;
3
+ /** A second click closer to the first one than this delay is a double click */
4
+ export declare const DOUBLE_CLICK_DELAY_MS = 300;
5
+ /** Largest distance between the two taps of a double tap, in pixels of the screen: a finger moves more than a mouse */
6
+ export declare const DOUBLE_TAP_MAX_DISTANCE = 20;
7
+ /**
8
+ * Tells the clicks and the double clicks of the main button from the presses and the releases of the pointer. A second
9
+ * click soon after the first one, at the same place, is a double click, and a third click starts a new one. A release
10
+ * which is not a click, like the end of a drag, cancels the double click
11
+ */
12
+ export declare const createClickTracker: () => {
13
+ press: (e: PointerEvent) => void;
14
+ reset: () => void;
15
+ /** Whether the release ends a click or a double click */
16
+ release: (e: PointerEvent) => "click" | "doubleClick" | undefined;
17
+ };
@@ -1,5 +1,6 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { DrawableShape, ShapeEntity, StateData } from './../../common/types/Shapes';
3
- export declare const cleanShapesBeforeExport: (shapes: ShapeEntity[]) => DrawableShape[];
4
- export declare const buildDataToExport: (shapes: ShapeEntity[], width: number, height: number) => StateData;
5
- export declare const addDefaultAndTempShapeProps: (shape: DrawableShape, settings: UtilsSettings) => ShapeEntity;
1
+ import type { DataChanges } from './../../canvas/types/editor.js';
2
+ import type { ExportedShape, ShapeEntity, StateData } from './../../canvas/types/Shapes.js';
3
+ export declare const cleanShapesBeforeExport: (shapes: ShapeEntity[]) => ExportedShape[];
4
+ export declare const buildDataToExport: (shapes: ShapeEntity[], width: number, height: number) => Required<StateData>;
5
+ /** Changes from the previous shapes to the new ones, found by id. The new shapes are given with their export */
6
+ export declare const getDataChanges: (previousShapes: ShapeEntity[], shapes: ShapeEntity[], exportedShapes: ExportedShape[]) => DataChanges;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Compares two values, and the first level of two objects or arrays, with Object.is.
3
+ * To give to usePaintState when the selector builds an object or an array.
4
+ */
5
+ export declare const shallowEqual: <T>(a: T, b: T) => boolean;
@@ -1,274 +1,44 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { DrawableShape, ExportedDrawableShape, Point, ShapeEntity } from './../../common/types/Shapes';
1
+ import { type PictureSrcResolver, type UtilsSettings } from './../../canvas/constants/app.js';
2
+ import type { ExportImageOptions } from './../../canvas/types/editor.js';
3
+ import type { ShapeEntity } from './../../canvas/types/Shapes.js';
3
4
  export declare const addSizeAndConvertSvgToObjectUrl: (svgFileContent: string) => string;
4
5
  export declare const isSvg: (fileOrUrl: File | string) => boolean;
5
- export declare const fetchAndStringify: (url: string) => Promise<string>;
6
+ /**
7
+ * Kind of the source of a picture, which decides how it is loaded: an image data URL or a blob URL is loaded as it is, SVG
8
+ * markup is turned into a blob URL, a URL of the web is fetched. Other sources, like other data URLs or javascript:, are
9
+ * refused: the sources may come from data drawn by someone else
10
+ */
11
+ type PictureSource = {
12
+ kind: 'direct';
13
+ } | {
14
+ kind: 'svg';
15
+ } | {
16
+ kind: 'remote';
17
+ url: string;
18
+ } | {
19
+ kind: 'refused';
20
+ };
21
+ export declare const getPictureSource: (src: string) => PictureSource;
6
22
  export declare const downloadFile: (content: string, fileName: string) => void;
7
- export declare const getBase64Image: (img: HTMLImageElement) => string;
8
- export declare const getStringifiedImage: (shape: DrawableShape<"picture">) => string;
9
- export declare const getCanvasImage: ({ shapes, settings, view }: {
23
+ /** The image encoded in a data URL, or undefined when it cannot be encoded: it is not loaded, or comes from another origin */
24
+ export declare const getBase64Image: (img: HTMLImageElement) => string | undefined;
25
+ /**
26
+ * Whether the source of a picture is exported encoded from its image: only a blob URL, which does not outlive the page, is
27
+ * encoded. The other sources are loaded again as they are, see getPictureSource
28
+ */
29
+ export declare const isSourceEncodedOnExport: (src: string) => boolean;
30
+ /**
31
+ * Loads the source of a picture in its image: a URL of the web is fetched first, so that the canvas can still be exported.
32
+ * Fails after a delay, or when the image is too large. The blob URL of the image is revoked once it is loaded or has failed
33
+ */
34
+ export declare const loadPicture: (img: HTMLImageElement, src: string, resolvePictureSrc?: PictureSrcResolver) => Promise<void>;
35
+ export declare const getCanvasImage: ({ shapes, settings, options }: {
10
36
  shapes: ShapeEntity[];
11
37
  settings: UtilsSettings;
12
- view: "fitToShapes" | "defaultView" | "currentZoom";
38
+ options?: ExportImageOptions | undefined;
13
39
  }) => string;
14
40
  export declare const encodeShapesInString: (shapes: ShapeEntity[], width: number, height: number) => string;
41
+ /** Content of a file as a data URL, read without blocking the page */
42
+ export declare const readFileAsDataUrl: (file: Blob) => Promise<string>;
15
43
  export declare const decodeJson: (file: File) => Promise<unknown>;
16
- export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[], settings: UtilsSettings) => Promise<(({
17
- id: string;
18
- computed: {
19
- borders: import("./../../common/types/Shapes").Rect;
20
- outerBorders: import("./../../common/types/Shapes").Rect;
21
- center: Point;
22
- boundingBox: import("./../../common/types/Shapes").Rect;
23
- };
24
- path: Path2D;
25
- } & {
26
- rotation?: number;
27
- toolId?: string;
28
- visible?: boolean;
29
- locked?: boolean;
30
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
31
- } & import("./../../common/types/Shapes").Line & {
32
- type: "line";
33
- } & {
34
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
35
- } & {
36
- type: "line";
37
- selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
38
- arrows?: import("./../../common/types/Shapes").TriangleEntity[];
39
- }) | ({
40
- id: string;
41
- computed: {
42
- borders: import("./../../common/types/Shapes").Rect;
43
- outerBorders: import("./../../common/types/Shapes").Rect;
44
- center: Point;
45
- boundingBox: import("./../../common/types/Shapes").Rect;
46
- };
47
- path: Path2D;
48
- } & {
49
- rotation?: number;
50
- toolId?: string;
51
- visible?: boolean;
52
- locked?: boolean;
53
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
54
- } & import("./../../common/types/Shapes").Rect & {
55
- src: string;
56
- } & {
57
- type: "picture";
58
- img: HTMLImageElement;
59
- flipX?: boolean;
60
- flipY?: boolean;
61
- ratio?: number;
62
- } & {
63
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
64
- } & {
65
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
66
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
67
- }) | ({
68
- id: string;
69
- computed: {
70
- borders: import("./../../common/types/Shapes").Rect;
71
- outerBorders: import("./../../common/types/Shapes").Rect;
72
- center: Point;
73
- boundingBox: import("./../../common/types/Shapes").Rect;
74
- };
75
- path: Path2D;
76
- } & {
77
- rotation?: number;
78
- toolId?: string;
79
- visible?: boolean;
80
- locked?: boolean;
81
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
82
- } & import("./../../common/types/Shapes").Rect & {
83
- value: string[];
84
- fontSize: number;
85
- } & {
86
- type: "text";
87
- flipX?: boolean;
88
- flipY?: boolean;
89
- ratio?: number;
90
- } & {
91
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
92
- } & {
93
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
94
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
95
- }) | ({
96
- id: string;
97
- computed: {
98
- borders: import("./../../common/types/Shapes").Rect;
99
- outerBorders: import("./../../common/types/Shapes").Rect;
100
- center: Point;
101
- boundingBox: import("./../../common/types/Shapes").Rect;
102
- };
103
- path: Path2D;
104
- } & {
105
- rotation?: number;
106
- toolId?: string;
107
- visible?: boolean;
108
- locked?: boolean;
109
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
110
- } & import("./../../common/types/Shapes").Rect & {
111
- type: "rect";
112
- } & {
113
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
114
- } & {
115
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
116
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
117
- }) | ({
118
- id: string;
119
- computed: {
120
- borders: import("./../../common/types/Shapes").Rect;
121
- outerBorders: import("./../../common/types/Shapes").Rect;
122
- center: Point;
123
- boundingBox: import("./../../common/types/Shapes").Rect;
124
- };
125
- path: Path2D;
126
- } & {
127
- rotation?: number;
128
- toolId?: string;
129
- visible?: boolean;
130
- locked?: boolean;
131
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
132
- } & import("./../../common/types/Shapes").Rect & {
133
- type: "square";
134
- } & {
135
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
136
- } & {
137
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
138
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
139
- }) | ({
140
- id: string;
141
- computed: {
142
- borders: import("./../../common/types/Shapes").Rect;
143
- outerBorders: import("./../../common/types/Shapes").Rect;
144
- center: Point;
145
- boundingBox: import("./../../common/types/Shapes").Rect;
146
- };
147
- path: Path2D;
148
- } & {
149
- rotation?: number;
150
- toolId?: string;
151
- visible?: boolean;
152
- locked?: boolean;
153
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
154
- } & import("./../../common/types/Shapes").Circle & {
155
- type: "circle";
156
- } & {
157
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
158
- } & {
159
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
160
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
161
- }) | ({
162
- id: string;
163
- computed: {
164
- borders: import("./../../common/types/Shapes").Rect;
165
- outerBorders: import("./../../common/types/Shapes").Rect;
166
- center: Point;
167
- boundingBox: import("./../../common/types/Shapes").Rect;
168
- };
169
- path: Path2D;
170
- } & {
171
- rotation?: number;
172
- toolId?: string;
173
- visible?: boolean;
174
- locked?: boolean;
175
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
176
- } & import("./../../common/types/Shapes").Ellipse & {
177
- type: "ellipse";
178
- } & {
179
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
180
- } & {
181
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
182
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
183
- }) | ({
184
- id: string;
185
- computed: {
186
- borders: import("./../../common/types/Shapes").Rect;
187
- outerBorders: import("./../../common/types/Shapes").Rect;
188
- center: Point;
189
- boundingBox: import("./../../common/types/Shapes").Rect;
190
- };
191
- path: Path2D;
192
- } & {
193
- rotation?: number;
194
- toolId?: string;
195
- visible?: boolean;
196
- locked?: boolean;
197
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
198
- } & import("./../../common/types/Shapes").Polygon & {
199
- type: "polygon";
200
- } & {
201
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
202
- } & {
203
- type: "polygon" | "curve";
204
- selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
205
- }) | ({
206
- id: string;
207
- computed: {
208
- borders: import("./../../common/types/Shapes").Rect;
209
- outerBorders: import("./../../common/types/Shapes").Rect;
210
- center: Point;
211
- boundingBox: import("./../../common/types/Shapes").Rect;
212
- };
213
- path: Path2D;
214
- } & {
215
- rotation?: number;
216
- toolId?: string;
217
- visible?: boolean;
218
- locked?: boolean;
219
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
220
- } & import("./../../common/types/Shapes").Curve & {
221
- type: "curve";
222
- } & {
223
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
224
- } & {
225
- type: "polygon" | "curve";
226
- selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
227
- }) | ({
228
- id: string;
229
- computed: {
230
- borders: import("./../../common/types/Shapes").Rect;
231
- outerBorders: import("./../../common/types/Shapes").Rect;
232
- center: Point;
233
- boundingBox: import("./../../common/types/Shapes").Rect;
234
- };
235
- path: Path2D;
236
- } & {
237
- rotation?: number;
238
- toolId?: string;
239
- visible?: boolean;
240
- locked?: boolean;
241
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
242
- } & import("./../../common/types/Shapes").Brush & {
243
- type: "brush";
244
- scaleX?: number;
245
- scaleY?: number;
246
- } & {
247
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
248
- } & {
249
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
250
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
251
- }) | ({
252
- id: string;
253
- computed: {
254
- borders: import("./../../common/types/Shapes").Rect;
255
- outerBorders: import("./../../common/types/Shapes").Rect;
256
- center: Point;
257
- boundingBox: import("./../../common/types/Shapes").Rect;
258
- };
259
- path: Path2D;
260
- } & {
261
- rotation?: number;
262
- toolId?: string;
263
- visible?: boolean;
264
- locked?: boolean;
265
- style?: import("./../../common/types/Shapes").StyleShape | undefined;
266
- } & import("./../../common/types/Shapes").Rect & {
267
- type: "group";
268
- shapes: ShapeEntity[];
269
- } & {
270
- type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
271
- } & {
272
- type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
273
- selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
274
- }))[]>;
44
+ export {};
@@ -1,2 +1,2 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
1
+ import type { UtilsSettings } from './../../canvas/constants/app.js';
2
2
  export declare const drawGrid: (ctx: CanvasRenderingContext2D, settings: UtilsSettings) => void;
@@ -1,14 +1,19 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { CanvasSize } from './../../common/types/Canvas';
3
- import type { HoverModeData } from './../../common/types/Mode';
4
- import type { Point, Rect, SelectionType, ShapeEntity } from './../../common/types/Shapes';
5
- export declare const getCursorPosition: (e: MouseEvent | TouchEvent) => {
6
- clientX: number;
7
- clientY: number;
1
+ import type { UtilsSettings } from './../../canvas/constants/app.js';
2
+ import type { CanvasSize } from './../../canvas/types/Canvas.js';
3
+ import type { HoverModeData } from './../../canvas/types/Mode.js';
4
+ import type { Point, Rect, SelectionType, ShapeEntity } from './../../canvas/types/Shapes.js';
5
+ export declare const getCursorPositionInElement: (e: MouseEvent, element: HTMLElement, canvasSize: CanvasSize) => Point;
6
+ /** Place of the canvas in the viewport */
7
+ type CanvasRect = Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>;
8
+ /** Point of the drawing at a position of the viewport, the canvas being displayed in the rect */
9
+ export declare const clientToCanvasPosition: ({ clientX, clientY }: Pick<MouseEvent, "clientX" | "clientY">, { left, top, width, height }: CanvasRect, { canvasSize, canvasOffset }: UtilsSettings) => Point;
10
+ /** Position in the viewport of a point of the drawing, the canvas being displayed in the rect: the reverse of clientToCanvasPosition */
11
+ export declare const canvasToClientPosition: (point: Point, { left, top, width, height }: CanvasRect, { canvasSize, canvasOffset }: UtilsSettings) => {
12
+ x: number;
13
+ y: number;
8
14
  };
9
- export declare const getCursorPositionInElement: (e: MouseEvent | TouchEvent, element: HTMLElement, canvasSize: CanvasSize) => Point;
10
- export declare const getCursorPositionInTransformedCanvas: (e: MouseEvent | TouchEvent, canvas: HTMLElement | null, settings: UtilsSettings) => Point;
11
- export declare const isTouchGesture: (e: MouseEvent | TouchEvent) => e is TouchEvent;
15
+ export declare const getCursorPositionInTransformedCanvas: (e: Pick<MouseEvent, "clientX" | "clientY">, canvas: HTMLElement, settings: UtilsSettings) => Point;
16
+ export declare const isTouchGesture: (e: PointerEvent) => boolean;
12
17
  export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
13
18
  export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
14
19
  export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, selection: SelectionType, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
@@ -21,7 +26,12 @@ export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRendering
21
26
  export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: SelectionType, position: Point, settings: UtilsSettings) => false | HoverModeData;
22
27
  export declare function getRectIntersection(rect1: Rect, rect2: Rect): Rect | undefined;
23
28
  export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, selectionFrame: [Point, Point]) => boolean;
24
- export declare const shouldCancelLongPress: (e: MouseEvent | TouchEvent, startPosition: {
25
- clientX: number;
26
- clientY: number;
27
- }) => boolean;
29
+ type ClientPosition = Pick<MouseEvent, 'clientX' | 'clientY'>;
30
+ /** Whether the pointer has moved by more than a few pixels, or the given distance, since the start of a press */
31
+ export declare const hasPointerMoved: (e: ClientPosition, startPosition: ClientPosition, threshold?: number) => boolean;
32
+ export declare const shouldCancelLongPress: (e: PointerEvent, startPosition: ClientPosition) => boolean;
33
+ /** Visible shapes under a point, from the foreground. Locked shapes are found too */
34
+ export declare const findShapesAt: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], point: Point, settings: UtilsSettings) => ShapeEntity[];
35
+ /** The shape of the foreground under a point, as found by findShapesAt */
36
+ export declare const findShapeAt: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], point: Point, settings: UtilsSettings) => ShapeEntity | undefined;
37
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare const omit: <T extends Record<string, unknown>>(keys: string[], obj: T) => T;
2
+ export declare const set: <T extends Record<string, any> | unknown[]>(path: string | number | (string | number)[], value: unknown, obj: T) => T;
3
+ /** Copy of the object without its entries set to undefined */
4
+ export declare const omitUndefined: <T extends object>(obj: T) => T;
5
+ /** Shallow merges the options into the defaults, ignoring the options set to undefined */
6
+ export declare const withDefaults: <T extends object>(defaults: T, options: object | undefined) => T;
7
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
8
+ /** Customizer of mergeWith which replaces the arrays instead of merging them */
9
+ export declare const replaceArrays: (objValue: unknown, srcValue: unknown) => unknown;
10
+ export declare const mergeWith: (customMergeFn: (objValue: unknown, srcValue: unknown, key: string) => unknown, target: unknown, source: unknown) => unknown;
11
+ export declare const isEqual: (a: unknown, b: unknown) => boolean;
@@ -1,4 +1,4 @@
1
- import type { SelectionType, ShapeEntity } from './../../../common/types/Shapes';
2
- import type { CustomTool } from './../../../common/types/tools';
1
+ import type { SelectionType, ShapeEntity } from './../../canvas/types/Shapes.js';
2
+ import type { CustomTool } from './../../canvas/types/tools.js';
3
3
  export declare const getSelectedShapes: (selection: SelectionType | undefined) => ShapeEntity[];
4
4
  export declare const getSelectedShapesTools: (selection: SelectionType | undefined, availableTools: CustomTool[]) => CustomTool | undefined;
@@ -0,0 +1,16 @@
1
+ import type { UtilsSettings } from './../../../canvas/constants/app.js';
2
+ import type { Point, Rect, ShapeEntity } from './../../../canvas/types/Shapes.js';
3
+ /** Whether the anchors of a shape are its points, a line, a polygon or a curve, instead of its borders */
4
+ export declare const hasPointAnchors: (shape: ShapeEntity) => shape is ShapeEntity<"line" | "polygon" | "curve">;
5
+ export declare const getAnchorRadius: (settings: UtilsSettings) => number;
6
+ /** Center of the anchor of the rotation, above the borders of a selection */
7
+ export declare const getRotationAnchorCenter: (borders: Rect, settings: UtilsSettings) => Point;
8
+ /** Center of an anchor of the resize, at its position on the borders of a selection */
9
+ export declare const getResizeAnchorCenter: (borders: Rect, [ratioX, ratioY]: Point) => Point;
10
+ /** Strokes the borders of a selection */
11
+ export declare const strokeBorders: (ctx: CanvasRenderingContext2D, { x, y, width, height }: Rect) => void;
12
+ export declare const setAnchorsStyle: (ctx: CanvasRenderingContext2D, settings: UtilsSettings) => void;
13
+ /** Draws an anchor with the style of the anchors, with a halo of the given color when it is hovered */
14
+ export declare const drawAnchor: (ctx: CanvasRenderingContext2D, [x, y]: Point, settings: UtilsSettings, haloColor?: string) => void;
15
+ /** Draws the stem and the anchor of the rotation, then the anchors of the resize, around the borders of a selection */
16
+ export declare const drawRectAnchors: (ctx: CanvasRenderingContext2D, borders: Rect, settings: UtilsSettings) => void;
@@ -1,4 +1,4 @@
1
- import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { SelectionModeData } from './../../../common/types/Mode';
3
- import type { Point, ShapeEntity } from './../../../common/types/Shapes';
1
+ import type { UtilsSettings } from './../../../canvas/constants/app.js';
2
+ import type { SelectionModeData } from './../../../canvas/types/Mode.js';
3
+ import type { Point, ShapeEntity } from './../../../canvas/types/Shapes.js';
4
4
  export declare const drawSelectionGroup: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"group">, selectionColor: string, selectionWidth: number, selectionMode: SelectionModeData<number | Point>, settings: UtilsSettings, withAnchors: boolean) => void;
@@ -1,13 +1,6 @@
1
- import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { HoverModeData } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, SelectionLinesType, ShapeEntity } from './../../../common/types/Shapes';
4
- export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
5
- points: readonly Point[];
6
- }, computed: {
7
- borders: Rect;
8
- outerBorders: Rect;
9
- center: Point;
10
- }, settings: UtilsSettings) => SelectionLinesType;
1
+ import type { UtilsSettings } from './../../../canvas/constants/app.js';
2
+ import type { HoverModeData } from './../../../canvas/types/Mode.js';
3
+ import type { ShapeEntity } from './../../../canvas/types/Shapes.js';
11
4
  export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, hoverMode, settings }: {
12
5
  ctx: CanvasRenderingContext2D;
13
6
  shape: ShapeEntity<"line"> | ShapeEntity<"polygon"> | ShapeEntity<"curve">;
@@ -1,15 +1,10 @@
1
- import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { Point, Rect, SelectionDefaultType, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
- export declare const createRecSelectionPath: (path: Path2D | undefined, computed: {
5
- borders: Rect;
6
- outerBorders: Rect;
7
- center: Point;
8
- }, settings: UtilsSettings) => SelectionDefaultType;
1
+ import type { UtilsSettings } from './../../../canvas/constants/app.js';
2
+ import type { SelectionModeResize } from './../../../canvas/types/Mode.js';
3
+ import type { Point, SelectionType, ShapeEntity } from './../../../canvas/types/Shapes.js';
4
+ /** Outline of a shape drawn by its selection: its path, but for a picture or a text, which are framed by their borders */
5
+ export declare const getSelectionOutline: (shape: ShapeEntity) => Path2D | undefined;
9
6
  export declare const drawBoundingBox: (ctx: CanvasRenderingContext2D, shape: SelectionType, selectionWidth: number, settings: UtilsSettings) => void;
10
- export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: ShapeEntity & {
11
- selection?: SelectionDefaultType | undefined;
12
- }, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
7
+ export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
13
8
  export declare const resizeRectSelection: (cursorPosition: Point, originalShape: ShapeEntity, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => {
14
9
  borderX: number;
15
10
  borderHeight: number;
@@ -1,3 +1,3 @@
1
- import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { Point } from './../../../common/types/Shapes';
1
+ import type { UtilsSettings } from './../../../canvas/constants/app.js';
2
+ import type { Point } from './../../../canvas/types/Shapes.js';
3
3
  export declare const drawFrame: (ctx: CanvasRenderingContext2D, selectionFrame: [Point, Point], settings: UtilsSettings) => void;
@@ -1,12 +1,14 @@
1
- import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { HoverModeData, SelectionModeData } from './../../common/types/Mode';
3
- import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
1
+ import type { UtilsSettings } from './../../canvas/constants/app.js';
2
+ import type { HoverModeData, SelectionModeData } from './../../canvas/types/Mode.js';
3
+ import type { Point, SelectionType, ShapeEntity } from './../../canvas/types/Shapes.js';
4
+ /** Whether no gesture is running: the hovered shape is only searched and shown then */
5
+ export declare const isIdleSelectionMode: ({ mode }: SelectionModeData<Point | number>) => boolean;
4
6
  export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: SelectionType, cursorPosition: Point) => SelectionModeData<Point | number> | undefined;
5
- export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: SelectionType | undefined, isTouchGesture: boolean, withFrameSelection: boolean, behavior?: "add" | "remove" | "replace") => {
7
+ export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: SelectionType | undefined, isTouchGesture: boolean, withFrameSelection: boolean, behavior?: "add" | "toggle" | "replace", preferSelection?: boolean) => {
6
8
  mode: SelectionModeData<Point | number>;
7
9
  shape: SelectionType | undefined;
8
10
  };
9
11
  export declare const buildShapesGroup: (shapes: ShapeEntity[], settings: UtilsSettings) => SelectionType | undefined;
10
12
  export declare const applyToSelectedShape: (applyToShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity, settings: UtilsSettings) => (selection: SelectionType | undefined) => SelectionType | undefined;
11
13
  export declare const addToSelectedShapes: (selection: SelectionType | undefined, shapes: ShapeEntity[]) => ShapeEntity[];
12
- export declare const omitFromSelectedShapes: (selection: SelectionType | undefined, shape: ShapeEntity) => ShapeEntity[];
14
+ export declare const omitFromSelectedShapes: (selection: SelectionType | undefined, shapes: ShapeEntity[]) => ShapeEntity[];