fabric-vectr 6.7.16 → 6.7.17

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 (601) hide show
  1. package/dist/dist/index.d.mts +13871 -0
  2. package/dist/dist/index.d.mts.map +1 -0
  3. package/dist/dist/index.mjs +26926 -0
  4. package/dist/dist/index.mjs.map +1 -0
  5. package/dist/dist/src/util/internals/cloneStyles.d.mts +2 -0
  6. package/dist/dist/src/util/internals/cloneStyles.d.mts.map +1 -0
  7. package/dist/dist/src/util/internals/cloneStyles.mjs +15 -0
  8. package/dist/dist/src/util/internals/cloneStyles.mjs.map +1 -0
  9. package/dist/extensions/aligning_guidelines/constant.js +9 -0
  10. package/dist/extensions/aligning_guidelines/constant.js.map +1 -0
  11. package/dist/extensions/aligning_guidelines/index.js +132 -0
  12. package/dist/extensions/aligning_guidelines/index.js.map +1 -0
  13. package/dist/extensions/aligning_guidelines/typedefs.js +2 -0
  14. package/dist/extensions/aligning_guidelines/typedefs.js.map +1 -0
  15. package/dist/extensions/aligning_guidelines/util/basic.js +12 -0
  16. package/dist/extensions/aligning_guidelines/util/basic.js.map +1 -0
  17. package/dist/extensions/aligning_guidelines/util/basic.spec.d.ts +2 -0
  18. package/dist/extensions/aligning_guidelines/util/basic.spec.d.ts.map +1 -0
  19. package/dist/extensions/aligning_guidelines/util/basic.spec.js +30 -0
  20. package/dist/extensions/aligning_guidelines/util/basic.spec.js.map +1 -0
  21. package/dist/extensions/aligning_guidelines/util/collect-line.js +129 -0
  22. package/dist/extensions/aligning_guidelines/util/collect-line.js.map +1 -0
  23. package/dist/extensions/aligning_guidelines/util/collect-point.js +78 -0
  24. package/dist/extensions/aligning_guidelines/util/collect-point.js.map +1 -0
  25. package/dist/extensions/aligning_guidelines/util/draw.js +67 -0
  26. package/dist/extensions/aligning_guidelines/util/draw.js.map +1 -0
  27. package/dist/extensions/aligning_guidelines/util/get-objects-by-target.js +44 -0
  28. package/dist/extensions/aligning_guidelines/util/get-objects-by-target.js.map +1 -0
  29. package/dist/extensions/data_updaters/origins/index.js +36 -0
  30. package/dist/extensions/data_updaters/origins/index.js.map +1 -0
  31. package/dist/extensions/data_updaters/origins/index.spec.d.ts +2 -0
  32. package/dist/extensions/data_updaters/origins/index.spec.d.ts.map +1 -0
  33. package/dist/extensions/data_updaters/origins/index.spec.js +94 -0
  34. package/dist/extensions/data_updaters/origins/index.spec.js.map +1 -0
  35. package/dist/extensions/index.js +3 -0
  36. package/dist/extensions/index.js.map +1 -0
  37. package/dist/fabric.js +101 -0
  38. package/dist/fabric.js.map +1 -0
  39. package/dist/index.js +2 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.min.js +1 -1
  42. package/dist/index.min.js.map +1 -1
  43. package/dist/index.min.mjs +1 -1
  44. package/dist/index.min.mjs.map +1 -1
  45. package/dist/index.mjs +2 -2
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/index.node.cjs +2 -2
  48. package/dist/index.node.cjs.map +1 -1
  49. package/dist/index.node.js +37 -0
  50. package/dist/index.node.js.map +1 -0
  51. package/dist/index.node.mjs +2 -2
  52. package/dist/index.node.mjs.map +1 -1
  53. package/dist/package.json +178 -0
  54. package/dist/package.json.min.mjs +1 -1
  55. package/dist/package.json.mjs +1 -1
  56. package/dist/src/ClassRegistry.js +49 -0
  57. package/dist/src/ClassRegistry.js.map +1 -0
  58. package/dist/src/Collection.js +295 -0
  59. package/dist/src/Collection.js.map +1 -0
  60. package/dist/src/CommonMethods.js +58 -0
  61. package/dist/src/CommonMethods.js.map +1 -0
  62. package/dist/src/EventTypeDefs.js +2 -0
  63. package/dist/src/EventTypeDefs.js.map +1 -0
  64. package/dist/src/Intersection.js +250 -0
  65. package/dist/src/Intersection.js.map +1 -0
  66. package/dist/src/LayoutManager/ActiveSelectionLayoutManager.js +47 -0
  67. package/dist/src/LayoutManager/ActiveSelectionLayoutManager.js.map +1 -0
  68. package/dist/src/LayoutManager/LayoutManager.js +238 -0
  69. package/dist/src/LayoutManager/LayoutManager.js.map +1 -0
  70. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.js +60 -0
  71. package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.js.map +1 -0
  72. package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.js +18 -0
  73. package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.js.map +1 -0
  74. package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.js +17 -0
  75. package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.js.map +1 -0
  76. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.js +80 -0
  77. package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.js.map +1 -0
  78. package/dist/src/LayoutManager/LayoutStrategies/utils.js +28 -0
  79. package/dist/src/LayoutManager/LayoutStrategies/utils.js.map +1 -0
  80. package/dist/src/LayoutManager/constants.js +7 -0
  81. package/dist/src/LayoutManager/constants.js.map +1 -0
  82. package/dist/src/LayoutManager/index.js +7 -0
  83. package/dist/src/LayoutManager/index.js.map +1 -0
  84. package/dist/src/LayoutManager/types.js +2 -0
  85. package/dist/src/LayoutManager/types.js.map +1 -0
  86. package/dist/src/Observable.js +107 -0
  87. package/dist/src/Observable.js.map +1 -0
  88. package/dist/src/Pattern/Pattern.js +152 -0
  89. package/dist/src/Pattern/Pattern.js.map +1 -0
  90. package/dist/src/Pattern/index.js +3 -0
  91. package/dist/src/Pattern/index.js.map +1 -0
  92. package/dist/src/Pattern/types.js +2 -0
  93. package/dist/src/Pattern/types.js.map +1 -0
  94. package/dist/src/Point.js +330 -0
  95. package/dist/src/Point.js.map +1 -0
  96. package/dist/src/Shadow.js +125 -0
  97. package/dist/src/Shadow.js.map +1 -0
  98. package/dist/src/benchmarks/boundingBoxFromPoint.d.mts +2 -0
  99. package/dist/src/benchmarks/boundingBoxFromPoint.d.mts.map +1 -0
  100. package/dist/src/benchmarks/boundingBoxFromPoint.mjs +54 -0
  101. package/dist/src/benchmarks/boundingBoxFromPoint.mjs.map +1 -0
  102. package/dist/src/benchmarks/calcCornerCoords.d.mts +2 -0
  103. package/dist/src/benchmarks/calcCornerCoords.d.mts.map +1 -0
  104. package/dist/src/benchmarks/calcCornerCoords.mjs +78 -0
  105. package/dist/src/benchmarks/calcCornerCoords.mjs.map +1 -0
  106. package/dist/src/benchmarks/calcTransformMatrix.d.mts +2 -0
  107. package/dist/src/benchmarks/calcTransformMatrix.d.mts.map +1 -0
  108. package/dist/src/benchmarks/calcTransformMatrix.mjs +71 -0
  109. package/dist/src/benchmarks/calcTransformMatrix.mjs.map +1 -0
  110. package/dist/src/benchmarks/cloneStyles.d.mts +2 -0
  111. package/dist/src/benchmarks/cloneStyles.d.mts.map +1 -0
  112. package/dist/src/benchmarks/cloneStyles.mjs +56 -0
  113. package/dist/src/benchmarks/cloneStyles.mjs.map +1 -0
  114. package/dist/src/benchmarks/pathCloning.d.mts +2 -0
  115. package/dist/src/benchmarks/pathCloning.d.mts.map +1 -0
  116. package/dist/src/benchmarks/pathCloning.mjs +94 -0
  117. package/dist/src/benchmarks/pathCloning.mjs.map +1 -0
  118. package/dist/src/benchmarks/pathData.d.mts +3 -0
  119. package/dist/src/benchmarks/pathData.d.mts.map +1 -0
  120. package/dist/src/benchmarks/pathData.mjs +3 -0
  121. package/dist/src/benchmarks/pathData.mjs.map +1 -0
  122. package/dist/src/benchmarks/raycasting.d.mts +2 -0
  123. package/dist/src/benchmarks/raycasting.d.mts.map +1 -0
  124. package/dist/src/benchmarks/raycasting.mjs +134 -0
  125. package/dist/src/benchmarks/raycasting.mjs.map +1 -0
  126. package/dist/src/benchmarks/transformMatrixKey.d.mts +2 -0
  127. package/dist/src/benchmarks/transformMatrixKey.d.mts.map +1 -0
  128. package/dist/src/benchmarks/transformMatrixKey.mjs +81 -0
  129. package/dist/src/benchmarks/transformMatrixKey.mjs.map +1 -0
  130. package/dist/src/brushes/BaseBrush.js +121 -0
  131. package/dist/src/brushes/BaseBrush.js.map +1 -0
  132. package/dist/src/brushes/CircleBrush.js +117 -0
  133. package/dist/src/brushes/CircleBrush.js.map +1 -0
  134. package/dist/src/brushes/PatternBrush.js +49 -0
  135. package/dist/src/brushes/PatternBrush.js.map +1 -0
  136. package/dist/src/brushes/PencilBrush.js +259 -0
  137. package/dist/src/brushes/PencilBrush.js.map +1 -0
  138. package/dist/src/brushes/SprayBrush.js +174 -0
  139. package/dist/src/brushes/SprayBrush.js.map +1 -0
  140. package/dist/src/brushes/typedefs.js +2 -0
  141. package/dist/src/brushes/typedefs.js.map +1 -0
  142. package/dist/src/cache.js +69 -0
  143. package/dist/src/cache.js.map +1 -0
  144. package/dist/src/canvas/Canvas.js +1366 -0
  145. package/dist/src/canvas/Canvas.js.map +1 -0
  146. package/dist/src/canvas/CanvasOptions.js +31 -0
  147. package/dist/src/canvas/CanvasOptions.js.map +1 -0
  148. package/dist/src/canvas/DOMManagers/CanvasDOMManager.js +97 -0
  149. package/dist/src/canvas/DOMManagers/CanvasDOMManager.js.map +1 -0
  150. package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.js +63 -0
  151. package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.js.map +1 -0
  152. package/dist/src/canvas/DOMManagers/util.js +56 -0
  153. package/dist/src/canvas/DOMManagers/util.js.map +1 -0
  154. package/dist/src/canvas/SelectableCanvas.js +1141 -0
  155. package/dist/src/canvas/SelectableCanvas.js.map +1 -0
  156. package/dist/src/canvas/StaticCanvas.js +1085 -0
  157. package/dist/src/canvas/StaticCanvas.js.map +1 -0
  158. package/dist/src/canvas/StaticCanvasOptions.js +23 -0
  159. package/dist/src/canvas/StaticCanvasOptions.js.map +1 -0
  160. package/dist/src/canvas/TextEditingManager.js +54 -0
  161. package/dist/src/canvas/TextEditingManager.js.map +1 -0
  162. package/dist/src/canvas/canvas_gestures.mixin.js +181 -0
  163. package/dist/src/canvas/canvas_gestures.mixin.js.map +1 -0
  164. package/dist/src/color/Color.js +301 -0
  165. package/dist/src/color/Color.js.map +1 -0
  166. package/dist/src/color/color_map.js +155 -0
  167. package/dist/src/color/color_map.js.map +1 -0
  168. package/dist/src/color/constants.js +111 -0
  169. package/dist/src/color/constants.js.map +1 -0
  170. package/dist/src/color/typedefs.js +2 -0
  171. package/dist/src/color/typedefs.js.map +1 -0
  172. package/dist/src/color/util.js +73 -0
  173. package/dist/src/color/util.js.map +1 -0
  174. package/dist/src/config.js +140 -0
  175. package/dist/src/config.js.map +1 -0
  176. package/dist/src/constants.js +38 -0
  177. package/dist/src/constants.js.map +1 -0
  178. package/dist/src/controls/Control.js +241 -0
  179. package/dist/src/controls/Control.js.map +1 -0
  180. package/dist/src/controls/changeWidth.js +31 -0
  181. package/dist/src/controls/changeWidth.js.map +1 -0
  182. package/dist/src/controls/commonControls.js +91 -0
  183. package/dist/src/controls/commonControls.js.map +1 -0
  184. package/dist/src/controls/controlRendering.js +81 -0
  185. package/dist/src/controls/controlRendering.js.map +1 -0
  186. package/dist/src/controls/drag.js +22 -0
  187. package/dist/src/controls/drag.js.map +1 -0
  188. package/dist/src/controls/fireEvent.js +9 -0
  189. package/dist/src/controls/fireEvent.js.map +1 -0
  190. package/dist/src/controls/index.js +14 -0
  191. package/dist/src/controls/index.js.map +1 -0
  192. package/dist/src/controls/pathControl.js +137 -0
  193. package/dist/src/controls/pathControl.js.map +1 -0
  194. package/dist/src/controls/polyControl.js +66 -0
  195. package/dist/src/controls/polyControl.js.map +1 -0
  196. package/dist/src/controls/rotate.js +57 -0
  197. package/dist/src/controls/rotate.js.map +1 -0
  198. package/dist/src/controls/scale.js +190 -0
  199. package/dist/src/controls/scale.js.map +1 -0
  200. package/dist/src/controls/scaleSkew.js +66 -0
  201. package/dist/src/controls/scaleSkew.js.map +1 -0
  202. package/dist/src/controls/skew.js +147 -0
  203. package/dist/src/controls/skew.js.map +1 -0
  204. package/dist/src/controls/util.js +89 -0
  205. package/dist/src/controls/util.js.map +1 -0
  206. package/dist/src/controls/wrapWithFireEvent.js +22 -0
  207. package/dist/src/controls/wrapWithFireEvent.js.map +1 -0
  208. package/dist/src/controls/wrapWithFixedAnchor.js +16 -0
  209. package/dist/src/controls/wrapWithFixedAnchor.js.map +1 -0
  210. package/dist/src/env/browser.js +18 -0
  211. package/dist/src/env/browser.js.map +1 -0
  212. package/dist/src/env/index.js +37 -0
  213. package/dist/src/env/index.js.map +1 -0
  214. package/dist/src/env/node.js +37 -0
  215. package/dist/src/env/node.js.map +1 -0
  216. package/dist/src/env/types.js +2 -0
  217. package/dist/src/env/types.js.map +1 -0
  218. package/dist/src/filters/BaseFilter.js +304 -0
  219. package/dist/src/filters/BaseFilter.js.map +1 -0
  220. package/dist/src/filters/BlendColor.js +147 -0
  221. package/dist/src/filters/BlendColor.js.map +1 -0
  222. package/dist/src/filters/BlendImage.js +149 -0
  223. package/dist/src/filters/BlendImage.js.map +1 -0
  224. package/dist/src/filters/Blur.js +167 -0
  225. package/dist/src/filters/Blur.js.map +1 -0
  226. package/dist/src/filters/Boilerplate.js +61 -0
  227. package/dist/src/filters/Boilerplate.js.map +1 -0
  228. package/dist/src/filters/Brightness.js +51 -0
  229. package/dist/src/filters/Brightness.js.map +1 -0
  230. package/dist/src/filters/Canvas2dFilterBackend.js +51 -0
  231. package/dist/src/filters/Canvas2dFilterBackend.js.map +1 -0
  232. package/dist/src/filters/ColorMatrix.js +92 -0
  233. package/dist/src/filters/ColorMatrix.js.map +1 -0
  234. package/dist/src/filters/ColorMatrixFilters.js +45 -0
  235. package/dist/src/filters/ColorMatrixFilters.js.map +1 -0
  236. package/dist/src/filters/Composed.js +55 -0
  237. package/dist/src/filters/Composed.js.map +1 -0
  238. package/dist/src/filters/Contrast.js +51 -0
  239. package/dist/src/filters/Contrast.js.map +1 -0
  240. package/dist/src/filters/Convolute.js +132 -0
  241. package/dist/src/filters/Convolute.js.map +1 -0
  242. package/dist/src/filters/FilterBackend.js +34 -0
  243. package/dist/src/filters/FilterBackend.js.map +1 -0
  244. package/dist/src/filters/GLProbes/GLProbe.js +3 -0
  245. package/dist/src/filters/GLProbes/GLProbe.js.map +1 -0
  246. package/dist/src/filters/GLProbes/NodeGLProbe.js +15 -0
  247. package/dist/src/filters/GLProbes/NodeGLProbe.js.map +1 -0
  248. package/dist/src/filters/GLProbes/WebGLProbe.js +39 -0
  249. package/dist/src/filters/GLProbes/WebGLProbe.js.map +1 -0
  250. package/dist/src/filters/Gamma.js +80 -0
  251. package/dist/src/filters/Gamma.js.map +1 -0
  252. package/dist/src/filters/Grayscale.js +69 -0
  253. package/dist/src/filters/Grayscale.js.map +1 -0
  254. package/dist/src/filters/HueRotation.js +61 -0
  255. package/dist/src/filters/HueRotation.js.map +1 -0
  256. package/dist/src/filters/Invert.js +58 -0
  257. package/dist/src/filters/Invert.js.map +1 -0
  258. package/dist/src/filters/Noise.js +54 -0
  259. package/dist/src/filters/Noise.js.map +1 -0
  260. package/dist/src/filters/Pixelate.js +66 -0
  261. package/dist/src/filters/Pixelate.js.map +1 -0
  262. package/dist/src/filters/RemoveColor.js +74 -0
  263. package/dist/src/filters/RemoveColor.js.map +1 -0
  264. package/dist/src/filters/Resize.js +399 -0
  265. package/dist/src/filters/Resize.js.map +1 -0
  266. package/dist/src/filters/Saturation.js +55 -0
  267. package/dist/src/filters/Saturation.js.map +1 -0
  268. package/dist/src/filters/Vibrance.js +57 -0
  269. package/dist/src/filters/Vibrance.js.map +1 -0
  270. package/dist/src/filters/WebGLFilterBackend.js +269 -0
  271. package/dist/src/filters/WebGLFilterBackend.js.map +1 -0
  272. package/dist/src/filters/filters.js +21 -0
  273. package/dist/src/filters/filters.js.map +1 -0
  274. package/dist/src/filters/index.js +7 -0
  275. package/dist/src/filters/index.js.map +1 -0
  276. package/dist/src/filters/shaders/baseFilter.js +16 -0
  277. package/dist/src/filters/shaders/baseFilter.js.map +1 -0
  278. package/dist/src/filters/shaders/blendColor.js +32 -0
  279. package/dist/src/filters/shaders/blendColor.js.map +1 -0
  280. package/dist/src/filters/shaders/blendImage.js +42 -0
  281. package/dist/src/filters/shaders/blendImage.js.map +1 -0
  282. package/dist/src/filters/shaders/blur.js +31 -0
  283. package/dist/src/filters/shaders/blur.js.map +1 -0
  284. package/dist/src/filters/shaders/brightness.js +12 -0
  285. package/dist/src/filters/shaders/brightness.js.map +1 -0
  286. package/dist/src/filters/shaders/colorMatrix.js +13 -0
  287. package/dist/src/filters/shaders/colorMatrix.js.map +1 -0
  288. package/dist/src/filters/shaders/constrast.js +12 -0
  289. package/dist/src/filters/shaders/constrast.js.map +1 -0
  290. package/dist/src/filters/shaders/convolute.js +155 -0
  291. package/dist/src/filters/shaders/convolute.js.map +1 -0
  292. package/dist/src/filters/shaders/gamma.js +16 -0
  293. package/dist/src/filters/shaders/gamma.js.map +1 -0
  294. package/dist/src/filters/shaders/grayscale.js +35 -0
  295. package/dist/src/filters/shaders/grayscale.js.map +1 -0
  296. package/dist/src/filters/shaders/invert.js +20 -0
  297. package/dist/src/filters/shaders/invert.js.map +1 -0
  298. package/dist/src/filters/shaders/noise.js +17 -0
  299. package/dist/src/filters/shaders/noise.js.map +1 -0
  300. package/dist/src/filters/shaders/pixelate.js +20 -0
  301. package/dist/src/filters/shaders/pixelate.js.map +1 -0
  302. package/dist/src/filters/shaders/removeColor.js +14 -0
  303. package/dist/src/filters/shaders/removeColor.js.map +1 -0
  304. package/dist/src/filters/shaders/saturation.js +16 -0
  305. package/dist/src/filters/shaders/saturation.js.map +1 -0
  306. package/dist/src/filters/shaders/vibrance.js +17 -0
  307. package/dist/src/filters/shaders/vibrance.js.map +1 -0
  308. package/dist/src/filters/typedefs.js +2 -0
  309. package/dist/src/filters/typedefs.js.map +1 -0
  310. package/dist/src/filters/utils.js +36 -0
  311. package/dist/src/filters/utils.js.map +1 -0
  312. package/dist/src/gradient/Gradient.d.ts.map +1 -1
  313. package/dist/src/gradient/Gradient.js +244 -0
  314. package/dist/src/gradient/Gradient.js.map +1 -0
  315. package/dist/src/gradient/Gradient.min.mjs +1 -1
  316. package/dist/src/gradient/Gradient.min.mjs.map +1 -1
  317. package/dist/src/gradient/Gradient.mjs +2 -1
  318. package/dist/src/gradient/Gradient.mjs.map +1 -1
  319. package/dist/src/gradient/constants.js +12 -0
  320. package/dist/src/gradient/constants.js.map +1 -0
  321. package/dist/src/gradient/index.js +3 -0
  322. package/dist/src/gradient/index.js.map +1 -0
  323. package/dist/src/gradient/parser/misc.js +11 -0
  324. package/dist/src/gradient/parser/misc.js.map +1 -0
  325. package/dist/src/gradient/parser/parseColorStops.js +42 -0
  326. package/dist/src/gradient/parser/parseColorStops.js.map +1 -0
  327. package/dist/src/gradient/parser/parseCoords.js +60 -0
  328. package/dist/src/gradient/parser/parseCoords.js.map +1 -0
  329. package/dist/src/gradient/typedefs.js +2 -0
  330. package/dist/src/gradient/typedefs.js.map +1 -0
  331. package/dist/src/mixins/eraser_brush.mixin.js +732 -0
  332. package/dist/src/mixins/eraser_brush.mixin.js.map +1 -0
  333. package/dist/src/parkinglot/canvas_animation.mixin.js +102 -0
  334. package/dist/src/parkinglot/canvas_animation.mixin.js.map +1 -0
  335. package/dist/src/parkinglot/straighten.js +53 -0
  336. package/dist/src/parkinglot/straighten.js.map +1 -0
  337. package/dist/src/parser/applyViewboxTransform.js +146 -0
  338. package/dist/src/parser/applyViewboxTransform.js.map +1 -0
  339. package/dist/src/parser/attributes.js +27 -0
  340. package/dist/src/parser/attributes.js.map +1 -0
  341. package/dist/src/parser/constants.js +70 -0
  342. package/dist/src/parser/constants.js.map +1 -0
  343. package/dist/src/parser/doesSomeParentMatch.js +15 -0
  344. package/dist/src/parser/doesSomeParentMatch.js.map +1 -0
  345. package/dist/src/parser/elementMatchesRule.js +15 -0
  346. package/dist/src/parser/elementMatchesRule.js.map +1 -0
  347. package/dist/src/parser/elements_parser.js +164 -0
  348. package/dist/src/parser/elements_parser.js.map +1 -0
  349. package/dist/src/parser/getCSSRules.js +62 -0
  350. package/dist/src/parser/getCSSRules.js.map +1 -0
  351. package/dist/src/parser/getGlobalStylesForElement.js +17 -0
  352. package/dist/src/parser/getGlobalStylesForElement.js.map +1 -0
  353. package/dist/src/parser/getGradientDefs.js +30 -0
  354. package/dist/src/parser/getGradientDefs.js.map +1 -0
  355. package/dist/src/parser/getMultipleNodes.js +10 -0
  356. package/dist/src/parser/getMultipleNodes.js.map +1 -0
  357. package/dist/src/parser/getPatternDefs.js +70 -0
  358. package/dist/src/parser/getPatternDefs.js.map +1 -0
  359. package/dist/src/parser/getSvgRegex.js +4 -0
  360. package/dist/src/parser/getSvgRegex.js.map +1 -0
  361. package/dist/src/parser/getTagName.js +2 -0
  362. package/dist/src/parser/getTagName.js.map +1 -0
  363. package/dist/src/parser/hasInvalidAncestor.js +17 -0
  364. package/dist/src/parser/hasInvalidAncestor.js.map +1 -0
  365. package/dist/src/parser/loadSVGFromString.js +23 -0
  366. package/dist/src/parser/loadSVGFromString.js.map +1 -0
  367. package/dist/src/parser/loadSVGFromURL.js +39 -0
  368. package/dist/src/parser/loadSVGFromURL.js.map +1 -0
  369. package/dist/src/parser/normalizeAttr.js +3 -0
  370. package/dist/src/parser/normalizeAttr.js.map +1 -0
  371. package/dist/src/parser/normalizeValue.js +79 -0
  372. package/dist/src/parser/normalizeValue.js.map +1 -0
  373. package/dist/src/parser/parseAttributes.js +66 -0
  374. package/dist/src/parser/parseAttributes.js.map +1 -0
  375. package/dist/src/parser/parseFontDeclaration.js +38 -0
  376. package/dist/src/parser/parseFontDeclaration.js.map +1 -0
  377. package/dist/src/parser/parsePointsAttribute.js +28 -0
  378. package/dist/src/parser/parsePointsAttribute.js.map +1 -0
  379. package/dist/src/parser/parseSVGDocument.js +74 -0
  380. package/dist/src/parser/parseSVGDocument.js.map +1 -0
  381. package/dist/src/parser/parseStyleAttribute.js +23 -0
  382. package/dist/src/parser/parseStyleAttribute.js.map +1 -0
  383. package/dist/src/parser/parseStyleObject.js +15 -0
  384. package/dist/src/parser/parseStyleObject.js.map +1 -0
  385. package/dist/src/parser/parseStyleString.js +18 -0
  386. package/dist/src/parser/parseStyleString.js.map +1 -0
  387. package/dist/src/parser/parseTransformAttribute.js +76 -0
  388. package/dist/src/parser/parseTransformAttribute.js.map +1 -0
  389. package/dist/src/parser/parseUseDirectives.js +76 -0
  390. package/dist/src/parser/parseUseDirectives.js.map +1 -0
  391. package/dist/src/parser/percent.js +21 -0
  392. package/dist/src/parser/percent.js.map +1 -0
  393. package/dist/src/parser/recursivelyParseGradientsXlink.js +36 -0
  394. package/dist/src/parser/recursivelyParseGradientsXlink.js.map +1 -0
  395. package/dist/src/parser/selectorMatches.js +24 -0
  396. package/dist/src/parser/selectorMatches.js.map +1 -0
  397. package/dist/src/parser/setStrokeFillOpacity.js +35 -0
  398. package/dist/src/parser/setStrokeFillOpacity.js.map +1 -0
  399. package/dist/src/parser/typedefs.js +2 -0
  400. package/dist/src/parser/typedefs.js.map +1 -0
  401. package/dist/src/shapes/ActiveSelection.js +195 -0
  402. package/dist/src/shapes/ActiveSelection.js.map +1 -0
  403. package/dist/src/shapes/Circle.js +155 -0
  404. package/dist/src/shapes/Circle.js.map +1 -0
  405. package/dist/src/shapes/Ellipse.js +120 -0
  406. package/dist/src/shapes/Ellipse.js.map +1 -0
  407. package/dist/src/shapes/Group.js +549 -0
  408. package/dist/src/shapes/Group.js.map +1 -0
  409. package/dist/src/shapes/IText/DraggableTextDelegate.js +326 -0
  410. package/dist/src/shapes/IText/DraggableTextDelegate.js.map +1 -0
  411. package/dist/src/shapes/IText/IText.js +545 -0
  412. package/dist/src/shapes/IText/IText.js.map +1 -0
  413. package/dist/src/shapes/IText/ITextBehavior.js +848 -0
  414. package/dist/src/shapes/IText/ITextBehavior.js.map +1 -0
  415. package/dist/src/shapes/IText/ITextClickBehavior.js +196 -0
  416. package/dist/src/shapes/IText/ITextClickBehavior.js.map +1 -0
  417. package/dist/src/shapes/IText/ITextKeyBehavior.js +522 -0
  418. package/dist/src/shapes/IText/ITextKeyBehavior.js.map +1 -0
  419. package/dist/src/shapes/IText/constants.js +47 -0
  420. package/dist/src/shapes/IText/constants.js.map +1 -0
  421. package/dist/src/shapes/Image.js +589 -0
  422. package/dist/src/shapes/Image.js.map +1 -0
  423. package/dist/src/shapes/Line.js +195 -0
  424. package/dist/src/shapes/Line.js.map +1 -0
  425. package/dist/src/shapes/Object/FabricObject.js +12 -0
  426. package/dist/src/shapes/Object/FabricObject.js.map +1 -0
  427. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.js +255 -0
  428. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.js.map +1 -0
  429. package/dist/src/shapes/Object/InteractiveObject.js +478 -0
  430. package/dist/src/shapes/Object/InteractiveObject.js.map +1 -0
  431. package/dist/src/shapes/Object/Object.js +1392 -0
  432. package/dist/src/shapes/Object/Object.js.map +1 -0
  433. package/dist/src/shapes/Object/ObjectGeometry.js +537 -0
  434. package/dist/src/shapes/Object/ObjectGeometry.js.map +1 -0
  435. package/dist/src/shapes/Object/defaultValues.js +109 -0
  436. package/dist/src/shapes/Object/defaultValues.js.map +1 -0
  437. package/dist/src/shapes/Object/types/BaseProps.js +2 -0
  438. package/dist/src/shapes/Object/types/BaseProps.js.map +1 -0
  439. package/dist/src/shapes/Object/types/BorderProps.js +2 -0
  440. package/dist/src/shapes/Object/types/BorderProps.js.map +1 -0
  441. package/dist/src/shapes/Object/types/ControlProps.js +2 -0
  442. package/dist/src/shapes/Object/types/ControlProps.js.map +1 -0
  443. package/dist/src/shapes/Object/types/FabricObjectProps.js +2 -0
  444. package/dist/src/shapes/Object/types/FabricObjectProps.js.map +1 -0
  445. package/dist/src/shapes/Object/types/FillStrokeProps.js +2 -0
  446. package/dist/src/shapes/Object/types/FillStrokeProps.js.map +1 -0
  447. package/dist/src/shapes/Object/types/LockInteractionProps.js +2 -0
  448. package/dist/src/shapes/Object/types/LockInteractionProps.js.map +1 -0
  449. package/dist/src/shapes/Object/types/ObjectProps.js +2 -0
  450. package/dist/src/shapes/Object/types/ObjectProps.js.map +1 -0
  451. package/dist/src/shapes/Object/types/ObjectTransformProps.js +2 -0
  452. package/dist/src/shapes/Object/types/ObjectTransformProps.js.map +1 -0
  453. package/dist/src/shapes/Object/types/SerializedObjectProps.js +2 -0
  454. package/dist/src/shapes/Object/types/SerializedObjectProps.js.map +1 -0
  455. package/dist/src/shapes/Object/types/index.js +2 -0
  456. package/dist/src/shapes/Object/types/index.js.map +1 -0
  457. package/dist/src/shapes/Path.js +267 -0
  458. package/dist/src/shapes/Path.js.map +1 -0
  459. package/dist/src/shapes/Polygon.js +12 -0
  460. package/dist/src/shapes/Polygon.js.map +1 -0
  461. package/dist/src/shapes/Polyline.js +307 -0
  462. package/dist/src/shapes/Polyline.js.map +1 -0
  463. package/dist/src/shapes/Rect.js +131 -0
  464. package/dist/src/shapes/Rect.js.map +1 -0
  465. package/dist/src/shapes/Text/StyledText.js +261 -0
  466. package/dist/src/shapes/Text/StyledText.js.map +1 -0
  467. package/dist/src/shapes/Text/Text.js +1258 -0
  468. package/dist/src/shapes/Text/Text.js.map +1 -0
  469. package/dist/src/shapes/Text/TextSVGExportMixin.js +339 -0
  470. package/dist/src/shapes/Text/TextSVGExportMixin.js.map +1 -0
  471. package/dist/src/shapes/Text/constants.js +94 -0
  472. package/dist/src/shapes/Text/constants.js.map +1 -0
  473. package/dist/src/shapes/Textbox.js +910 -0
  474. package/dist/src/shapes/Textbox.js.map +1 -0
  475. package/dist/src/shapes/Triangle.js +47 -0
  476. package/dist/src/shapes/Triangle.js.map +1 -0
  477. package/dist/src/typedefs.js +2 -0
  478. package/dist/src/typedefs.js.map +1 -0
  479. package/dist/src/util/animation/AnimationBase.js +94 -0
  480. package/dist/src/util/animation/AnimationBase.js.map +1 -0
  481. package/dist/src/util/animation/AnimationFrameProvider.js +8 -0
  482. package/dist/src/util/animation/AnimationFrameProvider.js.map +1 -0
  483. package/dist/src/util/animation/AnimationRegistry.js +49 -0
  484. package/dist/src/util/animation/AnimationRegistry.js.map +1 -0
  485. package/dist/src/util/animation/ArrayAnimation.js +18 -0
  486. package/dist/src/util/animation/ArrayAnimation.js.map +1 -0
  487. package/dist/src/util/animation/ColorAnimation.js +43 -0
  488. package/dist/src/util/animation/ColorAnimation.js.map +1 -0
  489. package/dist/src/util/animation/ValueAnimation.js +18 -0
  490. package/dist/src/util/animation/ValueAnimation.js.map +1 -0
  491. package/dist/src/util/animation/animate.js +19 -0
  492. package/dist/src/util/animation/animate.js.map +1 -0
  493. package/dist/src/util/animation/easing.js +265 -0
  494. package/dist/src/util/animation/easing.js.map +1 -0
  495. package/dist/src/util/animation/index.js +3 -0
  496. package/dist/src/util/animation/index.js.map +1 -0
  497. package/dist/src/util/animation/types.js +2 -0
  498. package/dist/src/util/animation/types.js.map +1 -0
  499. package/dist/src/util/applyMixins.js +14 -0
  500. package/dist/src/util/applyMixins.js.map +1 -0
  501. package/dist/src/util/dom_event.js +21 -0
  502. package/dist/src/util/dom_event.js.map +1 -0
  503. package/dist/src/util/dom_misc.js +42 -0
  504. package/dist/src/util/dom_misc.js.map +1 -0
  505. package/dist/src/util/dom_style.js +19 -0
  506. package/dist/src/util/dom_style.js.map +1 -0
  507. package/dist/src/util/index.js +36 -0
  508. package/dist/src/util/index.js.map +1 -0
  509. package/dist/src/util/internals/applyCanvasTransform.js +15 -0
  510. package/dist/src/util/internals/applyCanvasTransform.js.map +1 -0
  511. package/dist/src/util/internals/cleanupSvgAttribute.js +8 -0
  512. package/dist/src/util/internals/cleanupSvgAttribute.js.map +1 -0
  513. package/dist/src/util/internals/cloneDeep.js +8 -0
  514. package/dist/src/util/internals/cloneDeep.js.map +1 -0
  515. package/dist/src/util/internals/cloneStyles.js +11 -0
  516. package/dist/src/util/internals/cloneStyles.js.map +1 -0
  517. package/dist/src/util/internals/console.js +14 -0
  518. package/dist/src/util/internals/console.js.map +1 -0
  519. package/dist/src/util/internals/dom_request.js +39 -0
  520. package/dist/src/util/internals/dom_request.js.map +1 -0
  521. package/dist/src/util/internals/findRight.js +9 -0
  522. package/dist/src/util/internals/findRight.js.map +1 -0
  523. package/dist/src/util/internals/getRandomInt.js +8 -0
  524. package/dist/src/util/internals/getRandomInt.js.map +1 -0
  525. package/dist/src/util/internals/ifNaN.js +10 -0
  526. package/dist/src/util/internals/ifNaN.js.map +1 -0
  527. package/dist/src/util/internals/removeFromArray.js +15 -0
  528. package/dist/src/util/internals/removeFromArray.js.map +1 -0
  529. package/dist/src/util/internals/uid.js +3 -0
  530. package/dist/src/util/internals/uid.js.map +1 -0
  531. package/dist/src/util/lang_string.js +93 -0
  532. package/dist/src/util/lang_string.js.map +1 -0
  533. package/dist/src/util/misc/boundingBoxFromPoints.js +26 -0
  534. package/dist/src/util/misc/boundingBoxFromPoints.js.map +1 -0
  535. package/dist/src/util/misc/capValue.js +2 -0
  536. package/dist/src/util/misc/capValue.js.map +1 -0
  537. package/dist/src/util/misc/cos.js +23 -0
  538. package/dist/src/util/misc/cos.js.map +1 -0
  539. package/dist/src/util/misc/dom.js +55 -0
  540. package/dist/src/util/misc/dom.js.map +1 -0
  541. package/dist/src/util/misc/findScaleTo.js +19 -0
  542. package/dist/src/util/misc/findScaleTo.js.map +1 -0
  543. package/dist/src/util/misc/groupSVGElements.js +15 -0
  544. package/dist/src/util/misc/groupSVGElements.js.map +1 -0
  545. package/dist/src/util/misc/isTransparent.js +23 -0
  546. package/dist/src/util/misc/isTransparent.js.map +1 -0
  547. package/dist/src/util/misc/matrix.js +238 -0
  548. package/dist/src/util/misc/matrix.js.map +1 -0
  549. package/dist/src/util/misc/mergeClipPaths.js +39 -0
  550. package/dist/src/util/misc/mergeClipPaths.js.map +1 -0
  551. package/dist/src/util/misc/objectEnlive.js +136 -0
  552. package/dist/src/util/misc/objectEnlive.js.map +1 -0
  553. package/dist/src/util/misc/objectTransforms.js +89 -0
  554. package/dist/src/util/misc/objectTransforms.js.map +1 -0
  555. package/dist/src/util/misc/pick.js +23 -0
  556. package/dist/src/util/misc/pick.js.map +1 -0
  557. package/dist/src/util/misc/planeChange.js +68 -0
  558. package/dist/src/util/misc/planeChange.js.map +1 -0
  559. package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.js +105 -0
  560. package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.js.map +1 -0
  561. package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.js +219 -0
  562. package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.js.map +1 -0
  563. package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.js +42 -0
  564. package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.js.map +1 -0
  565. package/dist/src/util/misc/projectStroke/index.js +61 -0
  566. package/dist/src/util/misc/projectStroke/index.js.map +1 -0
  567. package/dist/src/util/misc/projectStroke/types.js +2 -0
  568. package/dist/src/util/misc/projectStroke/types.js.map +1 -0
  569. package/dist/src/util/misc/radiansDegreesConversion.js +14 -0
  570. package/dist/src/util/misc/radiansDegreesConversion.js.map +1 -0
  571. package/dist/src/util/misc/resolveOrigin.js +17 -0
  572. package/dist/src/util/misc/resolveOrigin.js.map +1 -0
  573. package/dist/src/util/misc/rotatePoint.js +10 -0
  574. package/dist/src/util/misc/rotatePoint.js.map +1 -0
  575. package/dist/src/util/misc/sin.js +25 -0
  576. package/dist/src/util/misc/sin.js.map +1 -0
  577. package/dist/src/util/misc/svgExport.js +13 -0
  578. package/dist/src/util/misc/svgExport.js.map +1 -0
  579. package/dist/src/util/misc/svgParsing.js +129 -0
  580. package/dist/src/util/misc/svgParsing.js.map +1 -0
  581. package/dist/src/util/misc/textStyles.js +107 -0
  582. package/dist/src/util/misc/textStyles.js.map +1 -0
  583. package/dist/src/util/misc/toFixed.js +8 -0
  584. package/dist/src/util/misc/toFixed.js.map +1 -0
  585. package/dist/src/util/misc/vectors.js +77 -0
  586. package/dist/src/util/misc/vectors.js.map +1 -0
  587. package/dist/src/util/path/index.js +743 -0
  588. package/dist/src/util/path/index.js.map +1 -0
  589. package/dist/src/util/path/regex.js +33 -0
  590. package/dist/src/util/path/regex.js.map +1 -0
  591. package/dist/src/util/path/typechecks.js +67 -0
  592. package/dist/src/util/path/typechecks.js.map +1 -0
  593. package/dist/src/util/path/typedefs.js +2 -0
  594. package/dist/src/util/path/typedefs.js.map +1 -0
  595. package/dist/src/util/transform_matrix_removal.js +46 -0
  596. package/dist/src/util/transform_matrix_removal.js.map +1 -0
  597. package/dist/src/util/typeAssertions.js +21 -0
  598. package/dist/src/util/typeAssertions.js.map +1 -0
  599. package/dist-extensions/src/gradient/Gradient.d.ts.map +1 -1
  600. package/package.json +1 -1
  601. package/src/gradient/Gradient.ts +5 -2
@@ -0,0 +1,1366 @@
1
+ import { classRegistry } from '../ClassRegistry';
2
+ import { NONE } from '../constants';
3
+ import { Point } from '../Point';
4
+ import { isTouchEvent, stopEvent } from '../util/dom_event';
5
+ import { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';
6
+ import { sendPointToPlane } from '../util/misc/planeChange';
7
+ import { isActiveSelection } from '../util/typeAssertions';
8
+ import { SelectableCanvas } from './SelectableCanvas';
9
+ import { TextEditingManager } from './TextEditingManager';
10
+ const addEventOptions = { passive: false };
11
+ const getEventPoints = (canvas, e) => {
12
+ const viewportPoint = canvas.getViewportPoint(e);
13
+ const scenePoint = canvas.getScenePoint(e);
14
+ return {
15
+ viewportPoint,
16
+ scenePoint,
17
+ pointer: viewportPoint,
18
+ absolutePointer: scenePoint,
19
+ };
20
+ };
21
+ // just to be clear, the utils are now deprecated and those are here exactly as minifier helpers
22
+ // because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.
23
+ // few bytes but why give it away.
24
+ const addListener = (el, ...args) => el.addEventListener(...args);
25
+ const removeListener = (el, ...args) => el.removeEventListener(...args);
26
+ const syntheticEventConfig = {
27
+ mouse: {
28
+ in: 'over',
29
+ out: 'out',
30
+ targetIn: 'mouseover',
31
+ targetOut: 'mouseout',
32
+ canvasIn: 'mouse:over',
33
+ canvasOut: 'mouse:out',
34
+ },
35
+ drag: {
36
+ in: 'enter',
37
+ out: 'leave',
38
+ targetIn: 'dragenter',
39
+ targetOut: 'dragleave',
40
+ canvasIn: 'drag:enter',
41
+ canvasOut: 'drag:leave',
42
+ },
43
+ };
44
+ export class Canvas extends SelectableCanvas {
45
+ /**
46
+ * a boolean that keeps track of the click state during a cycle of mouse down/up.
47
+ * If a mouse move occurs it becomes false.
48
+ * Is true by default, turns false on mouse move.
49
+ * Used to determine if a mouseUp is a click
50
+ */
51
+ _isClick;
52
+ textEditingManager = new TextEditingManager(this);
53
+ constructor(el, options = {}) {
54
+ super(el, options);
55
+ // bind event handlers
56
+ [
57
+ '_onMouseDown',
58
+ '_onTouchStart',
59
+ '_onMouseMove',
60
+ '_onMouseUp',
61
+ '_onTouchEnd',
62
+ '_onResize',
63
+ // '_onGesture',
64
+ // '_onDrag',
65
+ // '_onShake',
66
+ // '_onLongPress',
67
+ // '_onOrientationChange',
68
+ '_onMouseWheel',
69
+ '_onMouseOut',
70
+ '_onMouseEnter',
71
+ '_onContextMenu',
72
+ '_onClick',
73
+ '_onDragStart',
74
+ '_onDragEnd',
75
+ '_onDragProgress',
76
+ '_onDragOver',
77
+ '_onDragEnter',
78
+ '_onDragLeave',
79
+ '_onDrop',
80
+ ].forEach((eventHandler) => {
81
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
82
+ this[eventHandler] = this[eventHandler].bind(this);
83
+ });
84
+ // register event handlers
85
+ this.addOrRemove(addListener, 'add');
86
+ }
87
+ /**
88
+ * return an event prefix pointer or mouse.
89
+ * @private
90
+ */
91
+ _getEventPrefix() {
92
+ return this.enablePointerEvents ? 'pointer' : 'mouse';
93
+ }
94
+ addOrRemove(functor, _eventjsFunctor) {
95
+ const canvasElement = this.upperCanvasEl, eventTypePrefix = this._getEventPrefix();
96
+ functor(getWindowFromElement(canvasElement), 'resize', this._onResize);
97
+ functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);
98
+ functor(canvasElement, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
99
+ functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);
100
+ functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);
101
+ functor(canvasElement, 'wheel', this._onMouseWheel);
102
+ functor(canvasElement, 'contextmenu', this._onContextMenu);
103
+ functor(canvasElement, 'click', this._onClick);
104
+ // decide if to remove in fabric 7.0
105
+ functor(canvasElement, 'dblclick', this._onClick);
106
+ functor(canvasElement, 'dragstart', this._onDragStart);
107
+ functor(canvasElement, 'dragend', this._onDragEnd);
108
+ functor(canvasElement, 'dragover', this._onDragOver);
109
+ functor(canvasElement, 'dragenter', this._onDragEnter);
110
+ functor(canvasElement, 'dragleave', this._onDragLeave);
111
+ functor(canvasElement, 'drop', this._onDrop);
112
+ if (!this.enablePointerEvents) {
113
+ functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);
114
+ }
115
+ // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {
116
+ // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);
117
+ // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);
118
+ // eventjs[eventjsFunctor](
119
+ // canvasElement,
120
+ // 'orientation',
121
+ // this._onOrientationChange
122
+ // );
123
+ // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);
124
+ // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);
125
+ // }
126
+ }
127
+ /**
128
+ * Removes all event listeners, used when disposing the instance
129
+ */
130
+ removeListeners() {
131
+ this.addOrRemove(removeListener, 'remove');
132
+ // if you dispose on a mouseDown, before mouse up, you need to clean document to...
133
+ const eventTypePrefix = this._getEventPrefix();
134
+ const doc = getDocumentFromElement(this.upperCanvasEl);
135
+ removeListener(doc, `${eventTypePrefix}up`, this._onMouseUp);
136
+ removeListener(doc, 'touchend', this._onTouchEnd, addEventOptions);
137
+ removeListener(doc, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
138
+ removeListener(doc, 'touchmove', this._onMouseMove, addEventOptions);
139
+ clearTimeout(this._willAddMouseDown);
140
+ }
141
+ /**
142
+ * @private
143
+ * @param {Event} [e] Event object fired on wheel event
144
+ */
145
+ _onMouseWheel(e) {
146
+ this.__onMouseWheel(e);
147
+ }
148
+ /**
149
+ * @private
150
+ * @param {Event} e Event object fired on mousedown
151
+ */
152
+ _onMouseOut(e) {
153
+ const target = this._hoveredTarget;
154
+ const shared = {
155
+ e,
156
+ ...getEventPoints(this, e),
157
+ };
158
+ this.fire('mouse:out', { ...shared, target });
159
+ this._hoveredTarget = undefined;
160
+ target && target.fire('mouseout', { ...shared });
161
+ this._hoveredTargets.forEach((nestedTarget) => {
162
+ this.fire('mouse:out', { ...shared, target: nestedTarget });
163
+ nestedTarget && nestedTarget.fire('mouseout', { ...shared });
164
+ });
165
+ this._hoveredTargets = [];
166
+ }
167
+ /**
168
+ * @private
169
+ * @param {Event} e Event object fired on mouseenter
170
+ */
171
+ _onMouseEnter(e) {
172
+ // This find target and consequent 'mouse:over' is used to
173
+ // clear old instances on hovered target.
174
+ // calling findTarget has the side effect of killing target.__corner.
175
+ // as a short term fix we are not firing this if we are currently transforming.
176
+ // as a long term fix we need to separate the action of finding a target with the
177
+ // side effects we added to it.
178
+ if (!this._currentTransform && !this.findTarget(e)) {
179
+ this.fire('mouse:over', {
180
+ e,
181
+ ...getEventPoints(this, e),
182
+ });
183
+ this._hoveredTarget = undefined;
184
+ this._hoveredTargets = [];
185
+ }
186
+ }
187
+ /**
188
+ * supports native like text dragging
189
+ * @private
190
+ * @param {DragEvent} e
191
+ */
192
+ _onDragStart(e) {
193
+ this._isClick = false;
194
+ const activeObject = this.getActiveObject();
195
+ if (activeObject && activeObject.onDragStart(e)) {
196
+ this._dragSource = activeObject;
197
+ const options = { e, target: activeObject };
198
+ this.fire('dragstart', options);
199
+ activeObject.fire('dragstart', options);
200
+ addListener(this.upperCanvasEl, 'drag', this._onDragProgress);
201
+ return;
202
+ }
203
+ stopEvent(e);
204
+ }
205
+ /**
206
+ * First we clear top context where the effects are being rendered.
207
+ * Then we render the effects.
208
+ * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.
209
+ * @private
210
+ */
211
+ _renderDragEffects(e, source, target) {
212
+ let dirty = false;
213
+ // clear top context
214
+ const dropTarget = this._dropTarget;
215
+ if (dropTarget && dropTarget !== source && dropTarget !== target) {
216
+ dropTarget.clearContextTop();
217
+ dirty = true;
218
+ }
219
+ source?.clearContextTop();
220
+ target !== source && target?.clearContextTop();
221
+ // render effects
222
+ const ctx = this.contextTop;
223
+ ctx.save();
224
+ ctx.transform(...this.viewportTransform);
225
+ if (source) {
226
+ ctx.save();
227
+ source.transform(ctx);
228
+ source.renderDragSourceEffect(e);
229
+ ctx.restore();
230
+ dirty = true;
231
+ }
232
+ if (target) {
233
+ ctx.save();
234
+ target.transform(ctx);
235
+ target.renderDropTargetEffect(e);
236
+ ctx.restore();
237
+ dirty = true;
238
+ }
239
+ ctx.restore();
240
+ dirty && (this.contextTopDirty = true);
241
+ }
242
+ /**
243
+ * supports native like text dragging
244
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag
245
+ * @private
246
+ * @param {DragEvent} e
247
+ */
248
+ _onDragEnd(e) {
249
+ const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE, dropTarget = didDrop ? this._activeObject : undefined, options = {
250
+ e,
251
+ target: this._dragSource,
252
+ subTargets: this.targets,
253
+ dragSource: this._dragSource,
254
+ didDrop,
255
+ dropTarget: dropTarget,
256
+ };
257
+ removeListener(this.upperCanvasEl, 'drag', this._onDragProgress);
258
+ this.fire('dragend', options);
259
+ this._dragSource && this._dragSource.fire('dragend', options);
260
+ delete this._dragSource;
261
+ // we need to call mouse up synthetically because the browser won't
262
+ this._onMouseUp(e);
263
+ }
264
+ /**
265
+ * fire `drag` event on canvas and drag source
266
+ * @private
267
+ * @param {DragEvent} e
268
+ */
269
+ _onDragProgress(e) {
270
+ const options = {
271
+ e,
272
+ target: this._dragSource,
273
+ dragSource: this._dragSource,
274
+ dropTarget: this._draggedoverTarget,
275
+ };
276
+ this.fire('drag', options);
277
+ this._dragSource && this._dragSource.fire('drag', options);
278
+ }
279
+ /**
280
+ * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.
281
+ * Override at will
282
+ */
283
+ findDragTargets(e) {
284
+ this.targets = [];
285
+ const target = this._searchPossibleTargets(this.getSearchTargets(), this.getViewportPoint(e));
286
+ return {
287
+ target,
288
+ targets: [...this.targets],
289
+ };
290
+ }
291
+ /**
292
+ * prevent default to allow drop event to be fired
293
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets
294
+ * @private
295
+ * @param {DragEvent} [e] Event object fired on Event.js shake
296
+ */
297
+ _onDragOver(e) {
298
+ const eventType = 'dragover';
299
+ const { target, targets } = this.findDragTargets(e);
300
+ const dragSource = this._dragSource;
301
+ const options = {
302
+ e,
303
+ target,
304
+ subTargets: targets,
305
+ dragSource,
306
+ canDrop: false,
307
+ dropTarget: undefined,
308
+ };
309
+ let dropTarget;
310
+ // fire on canvas
311
+ this.fire(eventType, options);
312
+ // make sure we fire dragenter events before dragover
313
+ // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it
314
+ this._fireEnterLeaveEvents(target, options);
315
+ if (target) {
316
+ if (target.canDrop(e)) {
317
+ dropTarget = target;
318
+ }
319
+ target.fire(eventType, options);
320
+ }
321
+ // propagate the event to subtargets
322
+ for (let i = 0; i < targets.length; i++) {
323
+ const subTarget = targets[i];
324
+ // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)
325
+ // TODO: verify if those should loop in inverse order then?
326
+ // what is the order of subtargets?
327
+ if (subTarget.canDrop(e)) {
328
+ dropTarget = subTarget;
329
+ }
330
+ subTarget.fire(eventType, options);
331
+ }
332
+ // render drag effects now that relations between source and target is clear
333
+ this._renderDragEffects(e, dragSource, dropTarget);
334
+ this._dropTarget = dropTarget;
335
+ }
336
+ /**
337
+ * fire `dragleave` on `dragover` targets
338
+ * @private
339
+ * @param {Event} [e] Event object fired on Event.js shake
340
+ */
341
+ _onDragEnter(e) {
342
+ const { target, targets } = this.findDragTargets(e);
343
+ const options = {
344
+ e,
345
+ target,
346
+ subTargets: targets,
347
+ dragSource: this._dragSource,
348
+ };
349
+ this.fire('dragenter', options);
350
+ // fire dragenter on targets
351
+ this._fireEnterLeaveEvents(target, options);
352
+ }
353
+ /**
354
+ * fire `dragleave` on `dragover` targets
355
+ * @private
356
+ * @param {Event} [e] Event object fired on Event.js shake
357
+ */
358
+ _onDragLeave(e) {
359
+ const options = {
360
+ e,
361
+ target: this._draggedoverTarget,
362
+ subTargets: this.targets,
363
+ dragSource: this._dragSource,
364
+ };
365
+ this.fire('dragleave', options);
366
+ // fire dragleave on targets
367
+ this._fireEnterLeaveEvents(undefined, options);
368
+ this._renderDragEffects(e, this._dragSource);
369
+ this._dropTarget = undefined;
370
+ // clear targets
371
+ this.targets = [];
372
+ this._hoveredTargets = [];
373
+ }
374
+ /**
375
+ * `drop:before` is a an event that allows you to schedule logic
376
+ * before the `drop` event. Prefer `drop` event always, but if you need
377
+ * to run some drop-disabling logic on an event, since there is no way
378
+ * to handle event handlers ordering, use `drop:before`
379
+ * @private
380
+ * @param {Event} e
381
+ */
382
+ _onDrop(e) {
383
+ const { target, targets } = this.findDragTargets(e);
384
+ const options = this._basicEventHandler('drop:before', {
385
+ e,
386
+ target,
387
+ subTargets: targets,
388
+ dragSource: this._dragSource,
389
+ ...getEventPoints(this, e),
390
+ });
391
+ // will be set by the drop target
392
+ options.didDrop = false;
393
+ // will be set by the drop target, used in case options.target refuses the drop
394
+ options.dropTarget = undefined;
395
+ // fire `drop`
396
+ this._basicEventHandler('drop', options);
397
+ // inform canvas of the drop
398
+ // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it
399
+ // use for side effects
400
+ this.fire('drop:after', options);
401
+ }
402
+ /**
403
+ * @private
404
+ * @param {Event} e Event object fired on mousedown
405
+ */
406
+ _onContextMenu(e) {
407
+ const target = this.findTarget(e), subTargets = this.targets || [];
408
+ const options = this._basicEventHandler('contextmenu:before', {
409
+ e,
410
+ target,
411
+ subTargets,
412
+ });
413
+ // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves
414
+ this.stopContextMenu && stopEvent(e);
415
+ this._basicEventHandler('contextmenu', options);
416
+ return false;
417
+ }
418
+ /**
419
+ * @private
420
+ * @param {Event} e Event object fired on mousedown
421
+ */
422
+ _onClick(e) {
423
+ const clicks = e.detail;
424
+ if (clicks > 3 || clicks < 2)
425
+ return;
426
+ this._cacheTransformEventData(e);
427
+ clicks == 2 && e.type === 'dblclick' && this._onDblClick(e);
428
+ clicks == 3 && this._handleEvent(e, 'tripleclick');
429
+ this._resetTransformEventData();
430
+ }
431
+ /**
432
+ * Double-click to select the child nodes of the locked group
433
+ * @param e
434
+ */
435
+ _onDblClick(e) {
436
+ if (this.dblClickLock(e)) {
437
+ // Immediately select the clicked child object after locking
438
+ this._resetTransformEventData();
439
+ this.__onMouseDown(e);
440
+ this.__onMouseUp(e);
441
+ return;
442
+ }
443
+ this._handleEvent(e, 'dblclick');
444
+ }
445
+ /**
446
+ * Return a the id of an event.
447
+ * returns either the pointerId or the identifier or 0 for the mouse event
448
+ * @private
449
+ * @param {Event} evt Event object
450
+ */
451
+ getPointerId(evt) {
452
+ const changedTouches = evt.changedTouches;
453
+ if (changedTouches) {
454
+ return changedTouches[0] && changedTouches[0].identifier;
455
+ }
456
+ if (this.enablePointerEvents) {
457
+ return evt.pointerId;
458
+ }
459
+ return -1;
460
+ }
461
+ /**
462
+ * Determines if an event has the id of the event that is considered main
463
+ * @private
464
+ * @param {evt} event Event object
465
+ */
466
+ _isMainEvent(evt) {
467
+ if (evt.isPrimary === true) {
468
+ return true;
469
+ }
470
+ if (evt.isPrimary === false) {
471
+ return false;
472
+ }
473
+ if (evt.type === 'touchend' && evt.touches.length === 0) {
474
+ return true;
475
+ }
476
+ if (evt.changedTouches) {
477
+ return (evt.changedTouches[0].identifier === this.mainTouchId);
478
+ }
479
+ return true;
480
+ }
481
+ /**
482
+ * @private
483
+ * @param {Event} e Event object fired on mousedown
484
+ */
485
+ _onTouchStart(e) {
486
+ // we will prevent scrolling if allowTouchScrolling is not enabled and
487
+ let shouldPreventScrolling = !this.allowTouchScrolling;
488
+ const currentActiveObject = this._activeObject;
489
+ if (this.mainTouchId === undefined) {
490
+ this.mainTouchId = this.getPointerId(e);
491
+ }
492
+ this.__onMouseDown(e);
493
+ // after executing fabric logic for mouse down let's see
494
+ // if we didn't change target or if we are drawing
495
+ // we want to prevent scrolling anyway
496
+ if (this.isDrawingMode ||
497
+ (currentActiveObject && this._target === currentActiveObject)) {
498
+ shouldPreventScrolling = true;
499
+ }
500
+ // prevent default, will block scrolling from start
501
+ shouldPreventScrolling && e.preventDefault();
502
+ this._resetTransformEventData();
503
+ const canvasElement = this.upperCanvasEl, eventTypePrefix = this._getEventPrefix();
504
+ const doc = getDocumentFromElement(canvasElement);
505
+ addListener(doc, 'touchend', this._onTouchEnd, addEventOptions);
506
+ // if we scroll don't register the touch move event
507
+ shouldPreventScrolling &&
508
+ addListener(doc, 'touchmove', this._onMouseMove, addEventOptions);
509
+ // Unbind mousedown to prevent double triggers from touch devices
510
+ removeListener(canvasElement, `${eventTypePrefix}down`, this._onMouseDown);
511
+ }
512
+ /**
513
+ * @private
514
+ * @param {Event} e Event object fired on mousedown
515
+ */
516
+ _onMouseDown(e) {
517
+ this.__onMouseDown(e);
518
+ this._resetTransformEventData();
519
+ const canvasElement = this.upperCanvasEl, eventTypePrefix = this._getEventPrefix();
520
+ removeListener(canvasElement, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
521
+ const doc = getDocumentFromElement(canvasElement);
522
+ addListener(doc, `${eventTypePrefix}up`, this._onMouseUp);
523
+ addListener(doc, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
524
+ }
525
+ /**
526
+ * @private
527
+ * @param {Event} e Event object fired on mousedown
528
+ */
529
+ _onTouchEnd(e) {
530
+ if (e.touches.length > 0) {
531
+ // if there are still touches stop here
532
+ return;
533
+ }
534
+ this.__onMouseUp(e);
535
+ this._resetTransformEventData();
536
+ delete this.mainTouchId;
537
+ const eventTypePrefix = this._getEventPrefix();
538
+ const doc = getDocumentFromElement(this.upperCanvasEl);
539
+ removeListener(doc, 'touchend', this._onTouchEnd, addEventOptions);
540
+ removeListener(doc, 'touchmove', this._onMouseMove, addEventOptions);
541
+ if (this._willAddMouseDown) {
542
+ clearTimeout(this._willAddMouseDown);
543
+ }
544
+ this._willAddMouseDown = setTimeout(() => {
545
+ // Wait 400ms before rebinding mousedown to prevent double triggers
546
+ // from touch devices
547
+ addListener(this.upperCanvasEl, `${eventTypePrefix}down`, this._onMouseDown);
548
+ this._willAddMouseDown = 0;
549
+ }, 400);
550
+ }
551
+ /**
552
+ * @private
553
+ * @param {Event} e Event object fired on mouseup
554
+ */
555
+ _onMouseUp(e) {
556
+ this.__onMouseUp(e);
557
+ this._resetTransformEventData();
558
+ const canvasElement = this.upperCanvasEl, eventTypePrefix = this._getEventPrefix();
559
+ if (this._isMainEvent(e)) {
560
+ const doc = getDocumentFromElement(this.upperCanvasEl);
561
+ removeListener(doc, `${eventTypePrefix}up`, this._onMouseUp);
562
+ removeListener(doc, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
563
+ addListener(canvasElement, `${eventTypePrefix}move`, this._onMouseMove, addEventOptions);
564
+ }
565
+ }
566
+ /**
567
+ * @private
568
+ * @param {Event} e Event object fired on mousemove
569
+ */
570
+ _onMouseMove(e) {
571
+ const activeObject = this.getActiveObject();
572
+ !this.allowTouchScrolling &&
573
+ (!activeObject ||
574
+ // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before
575
+ // we must not prevent the event's default behavior in order for the window to start dragging
576
+ !activeObject.shouldStartDragging(e)) &&
577
+ e.preventDefault &&
578
+ e.preventDefault();
579
+ this.__onMouseMove(e);
580
+ }
581
+ /**
582
+ * @private
583
+ */
584
+ _onResize() {
585
+ this.calcOffset();
586
+ this._resetTransformEventData();
587
+ }
588
+ /**
589
+ * Decides whether the canvas should be redrawn in mouseup and mousedown events.
590
+ * @private
591
+ * @param {Object} target
592
+ */
593
+ _shouldRender(target) {
594
+ const activeObject = this.getActiveObject();
595
+ // if just one of them is available or if they are both but are different objects
596
+ // this covers: switch of target, from target to no target, selection of target
597
+ // multiSelection with key and mouse
598
+ return (!!activeObject !== !!target ||
599
+ (activeObject && target && activeObject !== target));
600
+ }
601
+ /**
602
+ * Method that defines the actions when mouse is released on canvas.
603
+ * The method resets the currentTransform parameters, store the image corner
604
+ * position in the image object and render the canvas on top.
605
+ * @private
606
+ * @param {Event} e Event object fired on mouseup
607
+ */
608
+ __onMouseUp(e) {
609
+ this._cacheTransformEventData(e);
610
+ this._handleEvent(e, 'up:before');
611
+ const transform = this._currentTransform;
612
+ const isClick = this._isClick;
613
+ const target = this._target;
614
+ // if right/middle click just fire events and return
615
+ // target undefined will make the _handleEvent search the target
616
+ const { button } = e;
617
+ if (button) {
618
+ ((this.fireMiddleClick && button === 1) ||
619
+ (this.fireRightClick && button === 2)) &&
620
+ this._handleEvent(e, 'up');
621
+ this._resetTransformEventData();
622
+ return;
623
+ }
624
+ if (this.isDrawingMode && this._isCurrentlyDrawing) {
625
+ this._onMouseUpInDrawingMode(e);
626
+ return;
627
+ }
628
+ if (!this._isMainEvent(e)) {
629
+ return;
630
+ }
631
+ let shouldRender = false;
632
+ if (transform) {
633
+ this._finalizeCurrentTransform(e);
634
+ shouldRender = transform.actionPerformed;
635
+ }
636
+ if (!isClick) {
637
+ const targetWasActive = target === this._activeObject;
638
+ this.handleSelection(e);
639
+ if (!shouldRender) {
640
+ shouldRender =
641
+ this._shouldRender(target) ||
642
+ (!targetWasActive && target === this._activeObject);
643
+ }
644
+ }
645
+ let pointer, corner;
646
+ if (target) {
647
+ const found = target.findControl(this.getViewportPoint(e), isTouchEvent(e));
648
+ const { key, control } = found || {};
649
+ corner = key;
650
+ if (target.selectable &&
651
+ target !== this._activeObject &&
652
+ target.activeOn === 'up') {
653
+ this.setActiveObject(target, e);
654
+ shouldRender = true;
655
+ }
656
+ else if (control) {
657
+ const mouseUpHandler = control.getMouseUpHandler(e, target, control);
658
+ if (mouseUpHandler) {
659
+ pointer = this.getScenePoint(e);
660
+ mouseUpHandler.call(control, e, transform, pointer.x, pointer.y);
661
+ }
662
+ }
663
+ target.isMoving = false;
664
+ }
665
+ // if we are ending up a transform on a different control or a new object
666
+ // fire the original mouse up from the corner that started the transform
667
+ if (transform &&
668
+ (transform.target !== target || transform.corner !== corner)) {
669
+ const originalControl = transform.target && transform.target.controls[transform.corner], originalMouseUpHandler = originalControl &&
670
+ originalControl.getMouseUpHandler(e, transform.target, originalControl);
671
+ pointer = pointer || this.getScenePoint(e);
672
+ originalMouseUpHandler &&
673
+ originalMouseUpHandler.call(originalControl, e, transform, pointer.x, pointer.y);
674
+ }
675
+ this._setCursorFromEvent(e, target);
676
+ this._handleEvent(e, 'up');
677
+ this._groupSelector = null;
678
+ this._currentTransform = null;
679
+ // reset the target information about which corner is selected
680
+ target && (target.__corner = undefined);
681
+ if (shouldRender) {
682
+ this.requestRenderAll();
683
+ }
684
+ else if (!isClick && !this._activeObject?.isEditing) {
685
+ this.renderTop();
686
+ }
687
+ // 框选不改变locked对象,不框选时如果没有点击到可以锁定组,设置锁定组为null
688
+ if (isClick && !this.getActiveObject())
689
+ this.isolatedObject = null;
690
+ }
691
+ _basicEventHandler(eventType, options) {
692
+ const { target, subTargets = [] } = options;
693
+ this.fire(eventType, options);
694
+ target && target.fire(eventType, options);
695
+ for (let i = 0; i < subTargets.length; i++) {
696
+ subTargets[i] !== target && subTargets[i].fire(eventType, options);
697
+ }
698
+ return options;
699
+ }
700
+ /**
701
+ * @private
702
+ * Handle event firing for target and subtargets
703
+ * @param {TPointerEvent} e event from mouse
704
+ * @param {TPointerEventNames} eventType
705
+ */
706
+ _handleEvent(e, eventType, extraData) {
707
+ const target = this._target, targets = this.targets || [], options = {
708
+ e,
709
+ target,
710
+ subTargets: targets,
711
+ ...getEventPoints(this, e),
712
+ transform: this._currentTransform,
713
+ ...(eventType === 'up:before' || eventType === 'up'
714
+ ? {
715
+ isClick: this._isClick,
716
+ currentTarget: this.findTarget(e),
717
+ // set by the preceding `findTarget` call
718
+ currentSubTargets: this.targets,
719
+ }
720
+ : {}),
721
+ ...(eventType === 'down:before' || eventType === 'down'
722
+ ? extraData
723
+ : {}),
724
+ };
725
+ this.fire(`mouse:${eventType}`, options);
726
+ // this may be a little be more complicated of what we want to handle
727
+ target && target.fire(`mouse${eventType}`, options);
728
+ for (let i = 0; i < targets.length; i++) {
729
+ targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);
730
+ }
731
+ }
732
+ /**
733
+ * @private
734
+ * @param {Event} e Event object fired on mousedown
735
+ */
736
+ _onMouseDownInDrawingMode(e) {
737
+ this._isCurrentlyDrawing = true;
738
+ if (this.getActiveObject()) {
739
+ this.discardActiveObject(e);
740
+ this.requestRenderAll();
741
+ }
742
+ // TODO: this is a scene point so it should be renamed
743
+ const pointer = this.getScenePoint(e);
744
+ this.freeDrawingBrush &&
745
+ this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });
746
+ this._handleEvent(e, 'down', { alreadySelected: false });
747
+ }
748
+ /**
749
+ * @private
750
+ * @param {Event} e Event object fired on mousemove
751
+ */
752
+ _onMouseMoveInDrawingMode(e) {
753
+ if (this._isCurrentlyDrawing) {
754
+ const pointer = this.getScenePoint(e);
755
+ this.freeDrawingBrush &&
756
+ this.freeDrawingBrush.onMouseMove(pointer, {
757
+ e,
758
+ // this is an absolute pointer, the naming is wrong
759
+ pointer,
760
+ });
761
+ }
762
+ this.setCursor(this.freeDrawingCursor);
763
+ this._handleEvent(e, 'move');
764
+ }
765
+ /**
766
+ * @private
767
+ * @param {Event} e Event object fired on mouseup
768
+ */
769
+ _onMouseUpInDrawingMode(e) {
770
+ const pointer = this.getScenePoint(e);
771
+ if (this.freeDrawingBrush) {
772
+ this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({
773
+ e: e,
774
+ // this is an absolute pointer, the naming is wrong
775
+ pointer,
776
+ });
777
+ }
778
+ else {
779
+ this._isCurrentlyDrawing = false;
780
+ }
781
+ this._handleEvent(e, 'up');
782
+ }
783
+ /**
784
+ * Change to other isolated object when click on current group's parent
785
+ * When click empty space or other object, cancel isolated state
786
+ * @param e
787
+ * @returns
788
+ */
789
+ switchIsolateObject(e) {
790
+ if (!this.isolatedObject || this._fixedSearchTargets)
791
+ return false;
792
+ let isolatedObject = null;
793
+ if (this.isolatedObject.parent) {
794
+ const parents = [];
795
+ let currentObj = this.isolatedObject;
796
+ while (currentObj.parent) {
797
+ parents.push(currentObj.parent);
798
+ currentObj = currentObj.parent;
799
+ }
800
+ // check topmost parent, if it was clicked, find the nearest child object to isolate
801
+ const topmostParent = parents[parents.length - 1];
802
+ this.setFixedSearchTargets([topmostParent]);
803
+ let target = this.findTarget(e);
804
+ // parent was clicked
805
+ if (target) {
806
+ parents.some((parent) => {
807
+ this.setFixedSearchTargets(parent.getObjects());
808
+ target = this.findTarget(e);
809
+ if (target) {
810
+ isolatedObject = parent;
811
+ // The newly created group object has its child node coords initialized, otherwise it cannot be selected.
812
+ parent.getObjects().forEach((o) => {
813
+ o.setCoords();
814
+ });
815
+ return true;
816
+ }
817
+ return false;
818
+ });
819
+ }
820
+ this.setFixedSearchTargets(null);
821
+ }
822
+ if (isolatedObject) {
823
+ this.isolatedObject = isolatedObject;
824
+ // use __onMouseDown select other object immediately after unlocking
825
+ this._resetTransformEventData();
826
+ this.__onMouseDown(e);
827
+ return true;
828
+ }
829
+ return false;
830
+ }
831
+ /**
832
+ * Method that defines the actions when mouse is clicked on canvas.
833
+ * The method inits the currentTransform parameters and renders all the
834
+ * canvas so the current image can be placed on the top canvas and the rest
835
+ * in on the container one.
836
+ * @private
837
+ * @param {Event} e Event object fired on mousedown
838
+ */
839
+ __onMouseDown(e) {
840
+ this._isClick = true;
841
+ this._cacheTransformEventData(e);
842
+ this._handleEvent(e, 'down:before');
843
+ let target = this._target;
844
+ let alreadySelected = !!target && target === this._activeObject;
845
+ // if right/middle click just fire events
846
+ const { button } = e;
847
+ if (button) {
848
+ ((this.fireMiddleClick && button === 1) ||
849
+ (this.fireRightClick && button === 2)) &&
850
+ this._handleEvent(e, 'down', {
851
+ alreadySelected,
852
+ });
853
+ this._resetTransformEventData();
854
+ return;
855
+ }
856
+ if (this.isDrawingMode) {
857
+ this._onMouseDownInDrawingMode(e);
858
+ return;
859
+ }
860
+ if (!this._isMainEvent(e)) {
861
+ return;
862
+ }
863
+ // ignore if some object is being transformed at this moment
864
+ if (this._currentTransform) {
865
+ return;
866
+ }
867
+ let shouldRender = this._shouldRender(target);
868
+ let grouped = false;
869
+ if (this.handleMultiSelection(e, target)) {
870
+ // active object might have changed while grouping
871
+ target = this._activeObject;
872
+ grouped = true;
873
+ shouldRender = true;
874
+ }
875
+ else if (this._shouldClearSelection(e, target)) {
876
+ const objs = this.getActiveObjects();
877
+ // holding the selection key keeps the current selection alive so that the
878
+ // following box selection (or click) can add to it instead of replacing it
879
+ const additive = !!objs.length && !!this.selection && this._isSelectionKeyPressed(e);
880
+ if (!additive) {
881
+ this.discardActiveObject(e);
882
+ // 多选取消,重置Coords, 防止无法再次选中
883
+ objs.forEach((obj) => obj.setCoords());
884
+ if (!target && this.switchIsolateObject(e)) {
885
+ return;
886
+ }
887
+ }
888
+ }
889
+ // we start a group selector rectangle if
890
+ // selection is enabled
891
+ // and there is no target, or the following 3 conditions are satisfied:
892
+ // target is not selectable ( otherwise we selected it )
893
+ // target is not editing
894
+ // target is not already selected ( otherwise we drag )
895
+ if (this.selection &&
896
+ (!target ||
897
+ (!target.selectable &&
898
+ !target.isEditing &&
899
+ target !== this._activeObject))) {
900
+ const p = this.getScenePoint(e);
901
+ this._groupSelector = {
902
+ x: p.x,
903
+ y: p.y,
904
+ deltaY: 0,
905
+ deltaX: 0,
906
+ // capture the modifier now: releasing the key during the drag
907
+ // must not turn an additive selection into a replacing one
908
+ ...(this._isSelectionKeyPressed(e) ? { additive: true } : {}),
909
+ };
910
+ }
911
+ // check again because things could have changed
912
+ alreadySelected = !!target && target === this._activeObject;
913
+ if (target) {
914
+ if (target.selectable && target.activeOn === 'down') {
915
+ this.setActiveObject(target, e);
916
+ }
917
+ const handle = target.findControl(this.getViewportPoint(e), isTouchEvent(e));
918
+ if (target === this._activeObject && (handle || !grouped)) {
919
+ this._setupCurrentTransform(e, target, alreadySelected);
920
+ const control = handle ? handle.control : undefined, pointer = this.getScenePoint(e), mouseDownHandler = control && control.getMouseDownHandler(e, target, control);
921
+ mouseDownHandler &&
922
+ mouseDownHandler.call(control, e, this._currentTransform, pointer.x, pointer.y);
923
+ }
924
+ }
925
+ // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering
926
+ // run before firing the `down` event to give the dev a chance to populate it themselves
927
+ shouldRender && (this._objectsToRender = undefined);
928
+ this._handleEvent(e, 'down', { alreadySelected: alreadySelected });
929
+ // we must renderAll so that we update the visuals
930
+ shouldRender && this.requestRenderAll();
931
+ }
932
+ /**
933
+ * reset cache form common information needed during event processing
934
+ * @private
935
+ */
936
+ _resetTransformEventData() {
937
+ this._target = this._pointer = this._absolutePointer = undefined;
938
+ }
939
+ /**
940
+ * Cache common information needed during event processing
941
+ * @private
942
+ * @param {Event} e Event object fired on event
943
+ */
944
+ _cacheTransformEventData(e) {
945
+ // reset in order to avoid stale caching
946
+ this._resetTransformEventData();
947
+ this._pointer = this.getViewportPoint(e);
948
+ this._absolutePointer = sendPointToPlane(this._pointer, undefined, this.viewportTransform);
949
+ this._target = this._currentTransform
950
+ ? this._currentTransform.target
951
+ : this.findTarget(e);
952
+ }
953
+ /**
954
+ * Method that defines the actions when mouse is hovering the canvas.
955
+ * The currentTransform parameter will define whether the user is rotating/scaling/translating
956
+ * an image or neither of them (only hovering). A group selection is also possible and would cancel
957
+ * all any other type of action.
958
+ * In case of an image transformation only the top canvas will be rendered.
959
+ * @private
960
+ * @param {Event} e Event object fired on mousemove
961
+ */
962
+ __onMouseMove(e) {
963
+ this._isClick = false;
964
+ this._cacheTransformEventData(e);
965
+ this._handleEvent(e, 'move:before');
966
+ if (this.isDrawingMode) {
967
+ this._onMouseMoveInDrawingMode(e);
968
+ return;
969
+ }
970
+ if (!this._isMainEvent(e)) {
971
+ return;
972
+ }
973
+ const groupSelector = this._groupSelector;
974
+ // We initially clicked in an empty area, so we draw a box for multiple selection
975
+ if (groupSelector) {
976
+ const pointer = this.getScenePoint(e);
977
+ groupSelector.deltaX = pointer.x - groupSelector.x;
978
+ groupSelector.deltaY = pointer.y - groupSelector.y;
979
+ this.renderTop();
980
+ }
981
+ else if (!this._currentTransform) {
982
+ const target = this.findTarget(e);
983
+ this._setCursorFromEvent(e, target);
984
+ this._fireOverOutEvents(e, target);
985
+ }
986
+ else {
987
+ this._transformObject(e);
988
+ }
989
+ this.textEditingManager.onMouseMove(e);
990
+ this._handleEvent(e, 'move');
991
+ this._resetTransformEventData();
992
+ }
993
+ /**
994
+ * Manage the mouseout, mouseover events for the fabric object on the canvas
995
+ * @param {Fabric.Object} target the target where the target from the mousemove event
996
+ * @param {Event} e Event object fired on mousemove
997
+ * @private
998
+ */
999
+ _fireOverOutEvents(e, target) {
1000
+ const _hoveredTarget = this._hoveredTarget, _hoveredTargets = this._hoveredTargets, targets = this.targets, length = Math.max(_hoveredTargets.length, targets.length);
1001
+ this.fireSyntheticInOutEvents('mouse', {
1002
+ e,
1003
+ target,
1004
+ oldTarget: _hoveredTarget,
1005
+ fireCanvas: true,
1006
+ });
1007
+ for (let i = 0; i < length; i++) {
1008
+ this.fireSyntheticInOutEvents('mouse', {
1009
+ e,
1010
+ target: targets[i],
1011
+ oldTarget: _hoveredTargets[i],
1012
+ });
1013
+ }
1014
+ this._hoveredTarget = target;
1015
+ this._hoveredTargets = this.targets.concat();
1016
+ }
1017
+ /**
1018
+ * Manage the dragEnter, dragLeave events for the fabric objects on the canvas
1019
+ * @param {Fabric.Object} target the target where the target from the onDrag event
1020
+ * @param {Object} data Event object fired on dragover
1021
+ * @private
1022
+ */
1023
+ _fireEnterLeaveEvents(target, data) {
1024
+ const draggedoverTarget = this._draggedoverTarget, _hoveredTargets = this._hoveredTargets, targets = this.targets, length = Math.max(_hoveredTargets.length, targets.length);
1025
+ this.fireSyntheticInOutEvents('drag', {
1026
+ ...data,
1027
+ target,
1028
+ oldTarget: draggedoverTarget,
1029
+ fireCanvas: true,
1030
+ });
1031
+ for (let i = 0; i < length; i++) {
1032
+ this.fireSyntheticInOutEvents('drag', {
1033
+ ...data,
1034
+ target: targets[i],
1035
+ oldTarget: _hoveredTargets[i],
1036
+ });
1037
+ }
1038
+ this._draggedoverTarget = target;
1039
+ }
1040
+ /**
1041
+ * Manage the synthetic in/out events for the fabric objects on the canvas
1042
+ * @param {Fabric.Object} target the target where the target from the supported events
1043
+ * @param {Object} data Event object fired
1044
+ * @param {Object} config configuration for the function to work
1045
+ * @param {String} config.targetName property on the canvas where the old target is stored
1046
+ * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out
1047
+ * @param {String} config.evtOut name of the event to fire for out
1048
+ * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in
1049
+ * @param {String} config.evtIn name of the event to fire for in
1050
+ * @private
1051
+ */
1052
+ fireSyntheticInOutEvents(type, { target, oldTarget, fireCanvas, e, ...data }) {
1053
+ const { targetIn, targetOut, canvasIn, canvasOut } = syntheticEventConfig[type];
1054
+ const targetChanged = oldTarget !== target;
1055
+ if (oldTarget && targetChanged) {
1056
+ const outOpt = {
1057
+ ...data,
1058
+ e,
1059
+ target: oldTarget,
1060
+ nextTarget: target,
1061
+ ...getEventPoints(this, e),
1062
+ };
1063
+ fireCanvas && this.fire(canvasOut, outOpt);
1064
+ oldTarget.fire(targetOut, outOpt);
1065
+ }
1066
+ if (target && targetChanged) {
1067
+ const inOpt = {
1068
+ ...data,
1069
+ e,
1070
+ target,
1071
+ previousTarget: oldTarget,
1072
+ ...getEventPoints(this, e),
1073
+ };
1074
+ fireCanvas && this.fire(canvasIn, inOpt);
1075
+ target.fire(targetIn, inOpt);
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Method that defines actions when an Event Mouse Wheel
1080
+ * @param {Event} e Event object fired on mouseup
1081
+ */
1082
+ __onMouseWheel(e) {
1083
+ this._cacheTransformEventData(e);
1084
+ this._handleEvent(e, 'wheel');
1085
+ this._resetTransformEventData();
1086
+ }
1087
+ /**
1088
+ * @private
1089
+ * @param {Event} e Event fired on mousemove
1090
+ */
1091
+ _transformObject(e) {
1092
+ const scenePoint = this.getScenePoint(e), transform = this._currentTransform, target = transform.target,
1093
+ // transform pointer to target's containing coordinate plane
1094
+ // both pointer and object should agree on every point
1095
+ localPointer = target.group
1096
+ ? sendPointToPlane(scenePoint, undefined, target.group.calcTransformMatrix())
1097
+ : scenePoint;
1098
+ transform.shiftKey = e.shiftKey;
1099
+ transform.altKey = !!this.centeredKey && e[this.centeredKey];
1100
+ this._performTransformAction(e, transform, localPointer);
1101
+ transform.actionPerformed && this.requestRenderAll();
1102
+ }
1103
+ /**
1104
+ * @private
1105
+ */
1106
+ _performTransformAction(e, transform, pointer) {
1107
+ const { action, actionHandler, target } = transform;
1108
+ const actionPerformed = !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);
1109
+ actionPerformed && target.setCoords();
1110
+ // this object could be created from the function in the control handlers
1111
+ if (action === 'drag' && actionPerformed) {
1112
+ transform.target.isMoving = true;
1113
+ this.setCursor(transform.target.moveCursor || this.moveCursor);
1114
+ }
1115
+ transform.actionPerformed = transform.actionPerformed || actionPerformed;
1116
+ }
1117
+ /**
1118
+ * Sets the cursor depending on where the canvas is being hovered.
1119
+ * Note: very buggy in Opera
1120
+ * @param {Event} e Event object
1121
+ * @param {Object} target Object that the mouse is hovering, if so.
1122
+ */
1123
+ _setCursorFromEvent(e, target) {
1124
+ if (!target) {
1125
+ this.setCursor(this.defaultCursor);
1126
+ return;
1127
+ }
1128
+ let hoverCursor = target.hoverCursor || this.hoverCursor;
1129
+ const activeSelection = isActiveSelection(this._activeObject)
1130
+ ? this._activeObject
1131
+ : null,
1132
+ // only show proper corner when group selection is not active
1133
+ corner = (!activeSelection || target.group !== activeSelection) &&
1134
+ // here we call findTargetCorner always with undefined for the touch parameter.
1135
+ // we assume that if you are using a cursor you do not need to interact with
1136
+ // the bigger touch area.
1137
+ target.findControl(this.getViewportPoint(e));
1138
+ if (!corner) {
1139
+ if (target.subTargetCheck) {
1140
+ // hoverCursor should come from top-most subTarget,
1141
+ // so we walk the array backwards
1142
+ this.targets
1143
+ .concat()
1144
+ .reverse()
1145
+ .map((_target) => {
1146
+ hoverCursor = _target.hoverCursor || hoverCursor;
1147
+ });
1148
+ }
1149
+ this.setCursor(hoverCursor);
1150
+ }
1151
+ else {
1152
+ const control = corner.control;
1153
+ this.setCursor(control.cursorStyleHandler(e, control, target));
1154
+ }
1155
+ }
1156
+ /**
1157
+ * ## Handles multiple selection
1158
+ * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)
1159
+ * - sets the active object in case it is not set or in case there is a single active object left under active selection.
1160
+ * ---
1161
+ * - If the active object is the active selection we add/remove `target` from it
1162
+ * - If not, add the active object and `target` to the active selection and make it the active object.
1163
+ * @private
1164
+ * @param {TPointerEvent} e Event object
1165
+ * @param {FabricObject} target target of event to select/deselect
1166
+ * @returns true if grouping occurred
1167
+ */
1168
+ handleMultiSelection(e, target) {
1169
+ const activeObject = this._activeObject;
1170
+ const isAS = isActiveSelection(activeObject);
1171
+ if (
1172
+ // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.
1173
+ !!activeObject &&
1174
+ this._isSelectionKeyPressed(e) &&
1175
+ this.selection &&
1176
+ // on top of that the user also has to hit a target that is selectable.
1177
+ !!target &&
1178
+ target.selectable &&
1179
+ // group target and active object only if they are different objects
1180
+ // else we try to find a subtarget of `ActiveSelection`
1181
+ (activeObject !== target || isAS) &&
1182
+ // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`
1183
+ // if it is then we want to remove `target` from it
1184
+ (isAS ||
1185
+ (!target.isDescendantOf(activeObject) &&
1186
+ !activeObject.isDescendantOf(target))) &&
1187
+ // target accepts selection
1188
+ !target.onSelect({ e }) &&
1189
+ // make sure we are not on top of a control
1190
+ !activeObject.getActiveControl()) {
1191
+ if (isAS) {
1192
+ const prevActiveObjects = activeObject.getObjects();
1193
+ if (target === activeObject) {
1194
+ const pointer = this.getViewportPoint(e);
1195
+ target =
1196
+ // first search under active selection for a target to add
1197
+ // will search from top level to bottom
1198
+ this.searchPossibleTargets(this.getSearchTargets(), pointer) ||
1199
+ // if not found, search active objects for a target to remove
1200
+ this.searchPossibleTargets(prevActiveObjects, pointer);
1201
+ // if nothing is found bail out
1202
+ if (!target || !target.selectable) {
1203
+ return false;
1204
+ }
1205
+ }
1206
+ if (target.group === activeObject) {
1207
+ // `target` is part of active selection => remove it
1208
+ activeObject.remove(target);
1209
+ target.setCoords();
1210
+ this._hoveredTarget = target;
1211
+ this._hoveredTargets = [...this.targets];
1212
+ // if after removing an object we are left with one only...
1213
+ if (activeObject.size() === 1) {
1214
+ // activate last remaining object
1215
+ // deselecting the active selection will remove the remaining object from it
1216
+ this._setActiveObject(activeObject.item(0), e);
1217
+ }
1218
+ }
1219
+ else {
1220
+ // `target` isn't part of active selection => add it
1221
+ activeObject.multiSelectAdd(target);
1222
+ this._hoveredTarget = activeObject;
1223
+ this._hoveredTargets = [...this.targets];
1224
+ }
1225
+ this._fireSelectionEvents(prevActiveObjects, e);
1226
+ }
1227
+ else {
1228
+ activeObject.isEditing &&
1229
+ activeObject.exitEditing();
1230
+ // add the active object and the target to the active selection and set it as the active object
1231
+ const klass = classRegistry.getClass('ActiveSelection');
1232
+ const newActiveSelection = new klass([], {
1233
+ /**
1234
+ * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}
1235
+ * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref
1236
+ */
1237
+ canvas: this,
1238
+ });
1239
+ newActiveSelection.multiSelectAdd(activeObject, target);
1240
+ this._hoveredTarget = newActiveSelection;
1241
+ // ISSUE 4115: should we consider subTargets here?
1242
+ // this._hoveredTargets = [];
1243
+ // this._hoveredTargets = this.targets.concat();
1244
+ this._setActiveObject(newActiveSelection, e);
1245
+ this._fireSelectionEvents([activeObject], e);
1246
+ }
1247
+ return true;
1248
+ }
1249
+ return false;
1250
+ }
1251
+ /**
1252
+ * ## Handles selection
1253
+ * - selects objects that are contained in (and possibly intersecting) the selection bounding box
1254
+ * - sets the active object
1255
+ * ---
1256
+ * runs on mouse up after a mouse move
1257
+ */
1258
+ handleSelection(e) {
1259
+ if (!this.selection || !this._groupSelector) {
1260
+ return false;
1261
+ }
1262
+ const { x, y, deltaX, deltaY, additive } = this._groupSelector, point1 = new Point(x, y), point2 = point1.add(new Point(deltaX, deltaY)), tl = point1.min(point2), br = point1.max(point2), size = br.subtract(tl);
1263
+ // the box only collects the first level objects of the current selection scope,
1264
+ // meaning the children of the isolated group, or the canvas root objects
1265
+ const collectedObjects = this.collectObjects(this.getSearchTargets(), {
1266
+ left: tl.x,
1267
+ top: tl.y,
1268
+ width: size.x,
1269
+ height: size.y,
1270
+ }, { includeIntersecting: !this.selectionFullyContained });
1271
+ // cleanup
1272
+ this._groupSelector = null;
1273
+ // the selection key was held while dragging and there is something to add to:
1274
+ // keep the current selection and merge the collected objects into it
1275
+ if (additive && this.getActiveObjects().length) {
1276
+ this.addToActiveSelection(e, collectedObjects);
1277
+ return true;
1278
+ }
1279
+ const objects =
1280
+ // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down
1281
+ // should it be handled as is?
1282
+ point1.eq(point2)
1283
+ ? collectedObjects[0]
1284
+ ? [collectedObjects[0]]
1285
+ : []
1286
+ : collectedObjects.length > 1
1287
+ ? collectedObjects
1288
+ .filter((object) => !object.onSelect({ e }))
1289
+ .reverse()
1290
+ : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case
1291
+ collectedObjects;
1292
+ // set active object
1293
+ if (objects.length === 1) {
1294
+ // set as active object
1295
+ this.setActiveObject(objects[0], e);
1296
+ }
1297
+ else if (objects.length > 1) {
1298
+ // add to active selection and make it the active object
1299
+ const klass = classRegistry.getClass('ActiveSelection');
1300
+ this.setActiveObject(new klass(objects, { canvas: this }), e);
1301
+ }
1302
+ return true;
1303
+ }
1304
+ /**
1305
+ * Merges the objects collected by a box selection into the current selection.
1306
+ * Only objects belonging to the current selection scope are taken into account:
1307
+ * the first level children of the isolated group, or the canvas root objects
1308
+ * when no group is isolated. Previously selected objects outside of that scope
1309
+ * are removed from the selection, since a selection can't mix objects coming
1310
+ * from different containers.
1311
+ * @private
1312
+ */
1313
+ addToActiveSelection(e, collectedObjects) {
1314
+ const prevActiveObjects = this.getActiveObjects(), scope = this.getSearchTargets(), kept = prevActiveObjects.filter((object) => scope.includes(object)), dropped = prevActiveObjects.filter((object) => !scope.includes(object)), added = collectedObjects.filter((object) => !prevActiveObjects.includes(object) && !object.onSelect({ e }));
1315
+ if (!kept.length && !added.length) {
1316
+ // the box didn't add anything and nothing of the current selection
1317
+ // belongs to this scope
1318
+ dropped.length && this.discardActiveObject(e);
1319
+ return;
1320
+ }
1321
+ const activeObject = this._activeObject;
1322
+ if (isActiveSelection(activeObject)) {
1323
+ dropped.length && activeObject.remove(...dropped);
1324
+ added.length && activeObject.multiSelectAdd(...added);
1325
+ if (activeObject.size() === 1) {
1326
+ // deselecting the active selection returns the last remaining object to the canvas
1327
+ this._setActiveObject(activeObject.item(0), e);
1328
+ }
1329
+ this._fireSelectionEvents(prevActiveObjects, e);
1330
+ return;
1331
+ }
1332
+ const objects = kept.concat(added);
1333
+ if (objects.length === 1) {
1334
+ objects[0] !== activeObject && this.setActiveObject(objects[0], e);
1335
+ return;
1336
+ }
1337
+ // build the active selection out of the kept and the newly collected objects
1338
+ const klass = classRegistry.getClass('ActiveSelection');
1339
+ const newActiveSelection = new klass([], {
1340
+ /**
1341
+ * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}
1342
+ * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref
1343
+ */
1344
+ canvas: this,
1345
+ });
1346
+ newActiveSelection.multiSelectAdd(...objects);
1347
+ this._setActiveObject(newActiveSelection, e);
1348
+ this._fireSelectionEvents(prevActiveObjects, e);
1349
+ }
1350
+ /**
1351
+ * @override clear {@link textEditingManager}
1352
+ */
1353
+ clear() {
1354
+ this.textEditingManager.clear();
1355
+ super.clear();
1356
+ }
1357
+ /**
1358
+ * @override clear {@link textEditingManager}
1359
+ */
1360
+ destroy() {
1361
+ this.removeListeners();
1362
+ this.textEditingManager.dispose();
1363
+ super.destroy();
1364
+ }
1365
+ }
1366
+ //# sourceMappingURL=Canvas.js.map