cd-aichat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/README.md +188 -0
  2. package/dist/ailogo.png +0 -0
  3. package/dist/cd-aichat.css +1 -0
  4. package/dist/cd-aichat.es.js +32223 -0
  5. package/dist/cd-aichat.umd.js +279 -0
  6. package/dist/index.css +1 -0
  7. package/package.json +61 -0
  8. package/src/ailogo.png +0 -0
  9. package/src/components/AiChat.test.js +538 -0
  10. package/src/components/AiChat.vue +2206 -0
  11. package/src/components/AiChatWidget.test.js +312 -0
  12. package/src/components/AiChatWidget.vue +963 -0
  13. package/src/components/BurnAfterReadDialog.test.js +121 -0
  14. package/src/components/BurnAfterReadDialog.vue +511 -0
  15. package/src/components/BurnAfterReadMessage.test.js +188 -0
  16. package/src/components/BurnAfterReadMessage.vue +193 -0
  17. package/src/components/BurnIndicator.test.js +101 -0
  18. package/src/components/BurnIndicator.vue +164 -0
  19. package/src/components/ChatWindow.vue +0 -0
  20. package/src/components/MentionList.vue +163 -0
  21. package/src/components/ResourceList.vue +194 -0
  22. package/src/components/RichTextEditor.vue +437 -0
  23. package/src/components/ScheduledSendDialog.vue +476 -0
  24. package/src/components/ScreenshotOverlay.vue +78 -0
  25. package/src/components/SendButtonGroup.test.js +174 -0
  26. package/src/components/SendButtonGroup.vue +166 -0
  27. package/src/components/UserDrawer.vue +0 -0
  28. package/src/components/screenshot/ScreenshotsBackground/getBoundsByPoints.ts +41 -0
  29. package/src/components/screenshot/ScreenshotsBackground/index.scss +27 -0
  30. package/src/components/screenshot/ScreenshotsBackground/index.tsx +145 -0
  31. package/src/components/screenshot/ScreenshotsButton/index.scss +29 -0
  32. package/src/components/screenshot/ScreenshotsButton/index.tsx +58 -0
  33. package/src/components/screenshot/ScreenshotsCanvas/getBoundsByPoints.ts +55 -0
  34. package/src/components/screenshot/ScreenshotsCanvas/getPoints.ts +60 -0
  35. package/src/components/screenshot/ScreenshotsCanvas/index.scss +84 -0
  36. package/src/components/screenshot/ScreenshotsCanvas/index.tsx +277 -0
  37. package/src/components/screenshot/ScreenshotsCanvas/isPointInDraw.ts +35 -0
  38. package/src/components/screenshot/ScreenshotsColor/index.scss +45 -0
  39. package/src/components/screenshot/ScreenshotsColor/index.tsx +39 -0
  40. package/src/components/screenshot/ScreenshotsContext.ts +56 -0
  41. package/src/components/screenshot/ScreenshotsMagnifier/index.scss +61 -0
  42. package/src/components/screenshot/ScreenshotsMagnifier/index.tsx +126 -0
  43. package/src/components/screenshot/ScreenshotsOperations/index.scss +25 -0
  44. package/src/components/screenshot/ScreenshotsOperations/index.tsx +118 -0
  45. package/src/components/screenshot/ScreenshotsOption/index.scss +50 -0
  46. package/src/components/screenshot/ScreenshotsOption/index.tsx +150 -0
  47. package/src/components/screenshot/ScreenshotsSize/index.scss +28 -0
  48. package/src/components/screenshot/ScreenshotsSize/index.tsx +41 -0
  49. package/src/components/screenshot/ScreenshotsSizeColor/index.scss +8 -0
  50. package/src/components/screenshot/ScreenshotsSizeColor/index.tsx +25 -0
  51. package/src/components/screenshot/ScreenshotsTextarea/calculateNodeSize.ts +117 -0
  52. package/src/components/screenshot/ScreenshotsTextarea/index.scss +19 -0
  53. package/src/components/screenshot/ScreenshotsTextarea/index.tsx +96 -0
  54. package/src/components/screenshot/composeImage.ts +57 -0
  55. package/src/components/screenshot/exports.ts +4 -0
  56. package/src/components/screenshot/hooks/useBounds.ts +35 -0
  57. package/src/components/screenshot/hooks/useCall.ts +17 -0
  58. package/src/components/screenshot/hooks/useCanvasContextRef.ts +8 -0
  59. package/src/components/screenshot/hooks/useCanvasMousedown.ts +13 -0
  60. package/src/components/screenshot/hooks/useCanvasMousemove.ts +13 -0
  61. package/src/components/screenshot/hooks/useCanvasMouseup.ts +13 -0
  62. package/src/components/screenshot/hooks/useCursor.ts +34 -0
  63. package/src/components/screenshot/hooks/useDispatcher.ts +8 -0
  64. package/src/components/screenshot/hooks/useDrawSelect.ts +16 -0
  65. package/src/components/screenshot/hooks/useEmiter.ts +61 -0
  66. package/src/components/screenshot/hooks/useHistory.ts +160 -0
  67. package/src/components/screenshot/hooks/useLang.ts +8 -0
  68. package/src/components/screenshot/hooks/useOperation.ts +37 -0
  69. package/src/components/screenshot/hooks/useReset.ts +26 -0
  70. package/src/components/screenshot/hooks/useStore.ts +8 -0
  71. package/src/components/screenshot/icons/iconfont.scss +88 -0
  72. package/src/components/screenshot/icons/iconfont.ttf +0 -0
  73. package/src/components/screenshot/icons/iconfont.woff +0 -0
  74. package/src/components/screenshot/icons/iconfont.woff2 +0 -0
  75. package/src/components/screenshot/index.tsx +169 -0
  76. package/src/components/screenshot/operations/Arrow/draw.ts +56 -0
  77. package/src/components/screenshot/operations/Arrow/index.tsx +193 -0
  78. package/src/components/screenshot/operations/Brush/draw.ts +45 -0
  79. package/src/components/screenshot/operations/Brush/index.tsx +169 -0
  80. package/src/components/screenshot/operations/Cancel/index.tsx +18 -0
  81. package/src/components/screenshot/operations/Ellipse/draw.ts +96 -0
  82. package/src/components/screenshot/operations/Ellipse/index.tsx +245 -0
  83. package/src/components/screenshot/operations/Mosaic/index.tsx +223 -0
  84. package/src/components/screenshot/operations/Ok/index.tsx +37 -0
  85. package/src/components/screenshot/operations/Pin/index.tsx +37 -0
  86. package/src/components/screenshot/operations/Rectangle/draw.ts +80 -0
  87. package/src/components/screenshot/operations/Rectangle/index.tsx +245 -0
  88. package/src/components/screenshot/operations/Redo/index.tsx +22 -0
  89. package/src/components/screenshot/operations/Save/index.tsx +37 -0
  90. package/src/components/screenshot/operations/Scan/index.tsx +46 -0
  91. package/src/components/screenshot/operations/Search/index.tsx +39 -0
  92. package/src/components/screenshot/operations/Text/index.tsx +307 -0
  93. package/src/components/screenshot/operations/Undo/index.tsx +22 -0
  94. package/src/components/screenshot/operations/index.ts +34 -0
  95. package/src/components/screenshot/operations/utils.ts +34 -0
  96. package/src/components/screenshot/screenshots.scss +13 -0
  97. package/src/components/screenshot/types.ts +53 -0
  98. package/src/components/screenshot/useGetLoadedImage.ts +29 -0
  99. package/src/components/screenshot/var.scss +107 -0
  100. package/src/components/screenshot/zh_CN.ts +37 -0
  101. package/src/emoji/100.gif +0 -0
  102. package/src/emoji/101.gif +0 -0
  103. package/src/emoji/102.gif +0 -0
  104. package/src/emoji/103.gif +0 -0
  105. package/src/emoji/104.gif +0 -0
  106. package/src/emoji/105.gif +0 -0
  107. package/src/emoji/106.gif +0 -0
  108. package/src/emoji/107.gif +0 -0
  109. package/src/emoji/108.gif +0 -0
  110. package/src/emoji/109.gif +0 -0
  111. package/src/emoji/110.gif +0 -0
  112. package/src/emoji/111.gif +0 -0
  113. package/src/emoji/112.gif +0 -0
  114. package/src/emoji/113.gif +0 -0
  115. package/src/emoji/114.gif +0 -0
  116. package/src/emoji/115.gif +0 -0
  117. package/src/emoji/116.gif +0 -0
  118. package/src/emoji/117.gif +0 -0
  119. package/src/emoji/118.gif +0 -0
  120. package/src/emoji/119.gif +0 -0
  121. package/src/emoji/120.gif +0 -0
  122. package/src/emoji/121.gif +0 -0
  123. package/src/emoji/122.gif +0 -0
  124. package/src/emoji/123.gif +0 -0
  125. package/src/emoji/124.gif +0 -0
  126. package/src/emoji/125.gif +0 -0
  127. package/src/emoji/126.gif +0 -0
  128. package/src/emoji/127.gif +0 -0
  129. package/src/emoji/128.gif +0 -0
  130. package/src/emoji/129.gif +0 -0
  131. package/src/emoji/130.gif +0 -0
  132. package/src/emoji/131.gif +0 -0
  133. package/src/emoji/132.gif +0 -0
  134. package/src/emoji/133.gif +0 -0
  135. package/src/emoji/134.gif +0 -0
  136. package/src/emoji/135.gif +0 -0
  137. package/src/emoji/136.gif +0 -0
  138. package/src/emoji/137.gif +0 -0
  139. package/src/emoji/138.gif +0 -0
  140. package/src/emoji/139.gif +0 -0
  141. package/src/emoji/140.gif +0 -0
  142. package/src/emoji/141.gif +0 -0
  143. package/src/emoji/142.gif +0 -0
  144. package/src/emoji/143.gif +0 -0
  145. package/src/emoji/144.gif +0 -0
  146. package/src/emoji/145.gif +0 -0
  147. package/src/emoji/146.gif +0 -0
  148. package/src/emoji/147.gif +0 -0
  149. package/src/emoji/148.gif +0 -0
  150. package/src/emoji/149.gif +0 -0
  151. package/src/emoji/150.gif +0 -0
  152. package/src/emoji/151.gif +0 -0
  153. package/src/emoji/152.gif +0 -0
  154. package/src/emoji/153.gif +0 -0
  155. package/src/emoji/154.gif +0 -0
  156. package/src/emoji/155.gif +0 -0
  157. package/src/emoji/156.gif +0 -0
  158. package/src/emoji/157.gif +0 -0
  159. package/src/emoji/158.gif +0 -0
  160. package/src/emoji/159.gif +0 -0
  161. package/src/emoji/160.gif +0 -0
  162. package/src/emoji/161.gif +0 -0
  163. package/src/emoji/162.gif +0 -0
  164. package/src/emoji/163.gif +0 -0
  165. package/src/emoji/164.gif +0 -0
  166. package/src/emoji/165.gif +0 -0
  167. package/src/emoji/166.gif +0 -0
  168. package/src/emoji/167.gif +0 -0
  169. package/src/emoji/168.gif +0 -0
  170. package/src/emoji/169.gif +0 -0
  171. package/src/emoji/170.gif +0 -0
  172. package/src/emoji/171.gif +0 -0
  173. package/src/emoji/172.gif +0 -0
  174. package/src/emoji/173.gif +0 -0
  175. package/src/emoji/174.gif +0 -0
  176. package/src/emoji/175.gif +0 -0
  177. package/src/emoji/176.gif +0 -0
  178. package/src/emoji/177.gif +0 -0
  179. package/src/emoji/178.gif +0 -0
  180. package/src/emoji/179.gif +0 -0
  181. package/src/emoji/180.gif +0 -0
  182. package/src/emoji/181.gif +0 -0
  183. package/src/emoji/182.gif +0 -0
  184. package/src/emoji/183.gif +0 -0
  185. package/src/emoji/184.gif +0 -0
  186. package/src/emoji/185.gif +0 -0
  187. package/src/emoji/186.gif +0 -0
  188. package/src/emoji/187.gif +0 -0
  189. package/src/emoji/188.gif +0 -0
  190. package/src/emoji/189.gif +0 -0
  191. package/src/emoji/190.gif +0 -0
  192. package/src/emoji/191.gif +0 -0
  193. package/src/emoji/192.gif +0 -0
  194. package/src/emoji/193.gif +0 -0
  195. package/src/emoji/194.gif +0 -0
  196. package/src/emoji/195.gif +0 -0
  197. package/src/emoji/196.gif +0 -0
  198. package/src/emoji/197.gif +0 -0
  199. package/src/emoji/198.gif +0 -0
  200. package/src/emoji/199.gif +0 -0
  201. package/src/emoji/200.png +0 -0
  202. package/src/emoji/201.png +0 -0
  203. package/src/emoji/202.png +0 -0
  204. package/src/emoji/203.png +0 -0
  205. package/src/emoji/204.png +0 -0
  206. package/src/emoji/205.png +0 -0
  207. package/src/emoji/206.png +0 -0
  208. package/src/emoji/207.png +0 -0
  209. package/src/emoji/208.png +0 -0
  210. package/src/emoji/209.png +0 -0
  211. package/src/emoji/210.png +0 -0
  212. package/src/emoji/211.png +0 -0
  213. package/src/emoji/212.png +0 -0
  214. package/src/emoji/213.png +0 -0
  215. package/src/emoji/214.png +0 -0
  216. package/src/emoji/215.png +0 -0
  217. package/src/emoji/216.png +0 -0
  218. package/src/emoji/217.png +0 -0
  219. package/src/emoji/218.png +0 -0
  220. package/src/emoji/219.png +0 -0
  221. package/src/emoji2/101--Streamline-The-Team.png +0 -0
  222. package/src/emoji2/128--Streamline-The-Team.png +0 -0
  223. package/src/emoji2/134--Streamline-The-Team.png +0 -0
  224. package/src/emoji2/173--Streamline-The-Team.png +0 -0
  225. package/src/emoji2/Airplane--Streamline-Emoji.svg +24 -0
  226. package/src/emoji2/Alien--Streamline-Emoji.svg +21 -0
  227. package/src/emoji2/Amazed-Face--Streamline-Emoji.svg +16 -0
  228. package/src/emoji2/Amusing-Face--Streamline-Emoji.svg +20 -0
  229. package/src/emoji2/Anguished-Face--Streamline-Emoji.svg +19 -0
  230. package/src/emoji2/Anxious-Face--Streamline-Emoji.svg +17 -0
  231. package/src/emoji2/Astonished-Face--Streamline-Emoji.svg +20 -0
  232. package/src/emoji2/Backhand-Index-Pointing-Down-1--Streamline-Emoji.svg +12 -0
  233. package/src/emoji2/Backhand-Index-Pointing-Left-1--Streamline-Emoji.svg +13 -0
  234. package/src/emoji2/Backhand-Index-Pointing-Right-1--Streamline-Emoji.svg +13 -0
  235. package/src/emoji2/Backhand-Index-Pointing-Up-1--Streamline-Emoji.svg +14 -0
  236. package/src/emoji2/Bar-Chart--Streamline-Emoji.svg +22 -0
  237. package/src/emoji2/Beaming-Face-With-Smiling-Eyes--Streamline-Emoji.svg +20 -0
  238. package/src/emoji2/Boy-1--Streamline-Emoji.svg +17 -0
  239. package/src/emoji2/Boy-2--Streamline-Emoji.svg +17 -0
  240. package/src/emoji2/Boy-3--Streamline-Emoji.svg +17 -0
  241. package/src/emoji2/Broken-Heart--Streamline-Emoji.svg +12 -0
  242. package/src/emoji2/Clapping-Hands-1--Streamline-Emoji.svg +23 -0
  243. package/src/emoji2/Clinking-Glasses-2--Streamline-Emoji.svg +43 -0
  244. package/src/emoji2/Confounded-Face--Streamline-Emoji.svg +17 -0
  245. package/src/emoji2/Confused-Face--Streamline-Emoji.svg +15 -0
  246. package/src/emoji2/Construction-Worker--Streamline-Emoji.svg +21 -0
  247. package/src/emoji2/Couple-With-Heart-Woman-Man-1--Streamline-Emoji.svg +40 -0
  248. package/src/emoji2/Couple-With-Heart-Woman-Man-2--Streamline-Emoji.svg +40 -0
  249. package/src/emoji2/Cowboy-Hat-Face--Streamline-Emoji.svg +22 -0
  250. package/src/emoji2/Crazy-Face--Streamline-Emoji.svg +25 -0
  251. package/src/emoji2/Crossed-Fingers-1--Streamline-Emoji.svg +25 -0
  252. package/src/emoji2/Crown--Streamline-Emoji.svg +35 -0
  253. package/src/emoji2/Crying-Face--Streamline-Emoji.svg +26 -0
  254. package/src/emoji2/Delivery-Truck--Streamline-Emoji.svg +31 -0
  255. package/src/emoji2/Determined-Face--Streamline-Emoji.svg +25 -0
  256. package/src/emoji2/Disappointed-Face--Streamline-Emoji.svg +15 -0
  257. package/src/emoji2/Dizzy-Face--Streamline-Emoji.svg +20 -0
  258. package/src/emoji2/Downcast-Face-With-Sweat--Streamline-Emoji.svg +18 -0
  259. package/src/emoji2/Drooling-Face-1--Streamline-Emoji.svg +19 -0
  260. package/src/emoji2/Drooling-Face-2--Streamline-Emoji.svg +18 -0
  261. package/src/emoji2/Ear--Streamline-Emoji.svg +14 -0
  262. package/src/emoji2/Exclamation-Mark--Streamline-Emoji.svg +12 -0
  263. package/src/emoji2/Exploding-Head--Streamline-Emoji.svg +24 -0
  264. package/src/emoji2/Expressionless-Face--Streamline-Emoji.svg +15 -0
  265. package/src/emoji2/Face-Blowing-A-Kiss--Streamline-Emoji.svg +18 -0
  266. package/src/emoji2/Face-Savoring-Food--Streamline-Emoji.svg +18 -0
  267. package/src/emoji2/Face-Screaming-In-Fear--Streamline-Emoji.svg +18 -0
  268. package/src/emoji2/Face-Vomiting--Streamline-Emoji.svg +28 -0
  269. package/src/emoji2/Face-With-Head-Bandage--Streamline-Emoji.svg +25 -0
  270. package/src/emoji2/Face-With-Medical-Mask--Streamline-Emoji.svg +23 -0
  271. package/src/emoji2/Face-With-Monocle--Streamline-Emoji.svg +26 -0
  272. package/src/emoji2/Face-With-Raised-Eyebrow--Streamline-Emoji.svg +17 -0
  273. package/src/emoji2/Face-With-Rolling-Eyes--Streamline-Emoji.svg +17 -0
  274. package/src/emoji2/Face-With-Steam-From-Nose--Streamline-Emoji.svg +19 -0
  275. package/src/emoji2/Face-With-Symbols-On-Mouth--Streamline-Emoji.svg +22 -0
  276. package/src/emoji2/Face-With-Tears-Of-Joy--Streamline-Emoji.svg +34 -0
  277. package/src/emoji2/Face-With-Thermometer--Streamline-Emoji.svg +31 -0
  278. package/src/emoji2/Face-With-Tongue--Streamline-Emoji.svg +18 -0
  279. package/src/emoji2/Face-Without-Mouth--Streamline-Emoji.svg +14 -0
  280. package/src/emoji2/Fearful-Face--Streamline-Emoji.svg +18 -0
  281. package/src/emoji2/Flexed-Biceps-1--Streamline-Emoji.svg +13 -0
  282. package/src/emoji2/Flushed-Face--Streamline-Emoji.svg +19 -0
  283. package/src/emoji2/Folded-Hands-1--Streamline-Emoji.svg +29 -0
  284. package/src/emoji2/Frowning-Face--Streamline-Emoji.svg +15 -0
  285. package/src/emoji2/Fuel-Pump--Streamline-Emoji.svg +30 -0
  286. package/src/emoji2/Girl-1--Streamline-Emoji.svg +23 -0
  287. package/src/emoji2/Glasses-1--Streamline-Emoji.svg +27 -0
  288. package/src/emoji2/Grimacing-Face--Streamline-Emoji.svg +19 -0
  289. package/src/emoji2/Grinning-Cat-Face--Streamline-Emoji.svg +32 -0
  290. package/src/emoji2/Grinning-Face--Streamline-Emoji.svg +16 -0
  291. package/src/emoji2/Grinning-Face-With-Sweat--Streamline-Emoji.svg +19 -0
  292. package/src/emoji2/Grinning-Squinting-Face--Streamline-Emoji.svg +16 -0
  293. package/src/emoji2/Hand-With-Fingers-Splayed-1--Streamline-Emoji.svg +14 -0
  294. package/src/emoji2/Heart-Suit--Streamline-Emoji.svg +9 -0
  295. package/src/emoji2/Hushed-Face-1--Streamline-Emoji.svg +17 -0
  296. package/src/emoji2/Hushed-Face-2--Streamline-Emoji.svg +15 -0
  297. package/src/emoji2/Index-Pointing-Up-1--Streamline-Emoji.svg +17 -0
  298. package/src/emoji2/Kissing-Face-With-Closed-Eyes--Streamline-Emoji.svg +18 -0
  299. package/src/emoji2/Loudly-Crying-Face--Streamline-Emoji.svg +16 -0
  300. package/src/emoji2/Lying-Face--Streamline-Emoji.svg +15 -0
  301. package/src/emoji2/Man-1--Streamline-Emoji.svg +17 -0
  302. package/src/emoji2/Man-Facepalming-1--Streamline-Emoji.svg +21 -0
  303. package/src/emoji2/Man-Gesturing-No-1--Streamline-Emoji.svg +34 -0
  304. package/src/emoji2/Man-Gesturing-Ok-1--Streamline-Emoji.svg +25 -0
  305. package/src/emoji2/Man-Health-Worker-1--Streamline-Emoji.svg +41 -0
  306. package/src/emoji2/Man-Raising-Hand-1--Streamline-Emoji.svg +26 -0
  307. package/src/emoji2/Man-Shrugging-1--Streamline-Emoji.svg +31 -0
  308. package/src/emoji2/Money-Mouth-Face-2--Streamline-Emoji.svg +30 -0
  309. package/src/emoji2/Mouth--Streamline-Emoji.svg +12 -0
  310. package/src/emoji2/Nauseated-Face-2--Streamline-Emoji.svg +19 -0
  311. package/src/emoji2/Neutral-Face--Streamline-Emoji.svg +15 -0
  312. package/src/emoji2/Ok-Hand-1--Streamline-Emoji.svg +14 -0
  313. package/src/emoji2/Old-Man-1--Streamline-Emoji.svg +27 -0
  314. package/src/emoji2/Old-Woman-1--Streamline-Emoji.svg +23 -0
  315. package/src/emoji2/Oncoming-Fist-1--Streamline-Emoji.svg +15 -0
  316. package/src/emoji2/Person-Wearing-Turban-2--Streamline-Emoji.svg +20 -0
  317. package/src/emoji2/Pile-Of-Poo--Streamline-Emoji.svg +15 -0
  318. package/src/emoji2/Police-Car-Light--Streamline-Emoji.svg +26 -0
  319. package/src/emoji2/Rocket--Streamline-Emoji.svg +32 -0
  320. package/src/emoji2/Sailboat--Streamline-Emoji.svg +18 -0
  321. package/src/emoji2/Shaved-Ice--Streamline-Emoji.svg +21 -0
  322. package/src/emoji2/Shortcake-2--Streamline-Emoji.svg +18 -0
  323. package/src/emoji2/Shushing-Face--Streamline-Emoji.svg +21 -0
  324. package/src/emoji2/Sign-Of-The-Horns-1--Streamline-Emoji.svg +19 -0
  325. package/src/emoji2/Sleeping-Face--Streamline-Emoji.svg +21 -0
  326. package/src/emoji2/Slightly-Smiling-Face--Streamline-Emoji.svg +15 -0
  327. package/src/emoji2/Smiling-Face-With-Halo--Streamline-Emoji.svg +20 -0
  328. package/src/emoji2/Smiling-Face-With-Heart-Eyes--Streamline-Emoji.svg +21 -0
  329. package/src/emoji2/Smirking-Face--Streamline-Emoji.svg +17 -0
  330. package/src/emoji2/Sun-With-Face--Streamline-Emoji.svg +24 -0
  331. package/src/emoji2/Thumbs-Down-1--Streamline-Emoji.svg +20 -0
  332. package/src/emoji2/Thumbs-Up-1--Streamline-Emoji.svg +19 -0
  333. package/src/emoji2/Winking-Face--Streamline-Emoji.svg +18 -0
  334. package/src/emoji2/Woman-Gesturing-No-1--Streamline-Emoji.svg +34 -0
  335. package/src/emoji2/Woman-Gesturing-Ok-2--Streamline-Emoji.svg +25 -0
  336. package/src/emoji2/Woman-Raising-Hand-1--Streamline-Emoji.svg +26 -0
  337. package/src/emoji2/Womans-Sandal--Streamline-Emoji.svg +13 -0
  338. package/src/emoji2/Worried-Face--Streamline-Emoji.svg +17 -0
  339. package/src/emoji2/Writing-Hand-1--Streamline-Emoji.svg +17 -0
  340. package/src/emoji2/Zipper-Mouth-Face--Streamline-Emoji.svg +21 -0
  341. package/src/index.js +19 -0
  342. package/src/services/burn-after-read-service.js +313 -0
  343. package/src/services/burn-after-read-service.test.js +325 -0
  344. package/src/services/dify-api.js +338 -0
  345. package/src/services/dify-api.test.js +376 -0
  346. package/src/services/scheduled-send-service.js +311 -0
  347. package/src/services/scheduled-send-service.test.js +317 -0
  348. package/src/styles/index.css +2368 -0
  349. package/src/utils/emoji.js +125 -0
  350. package/src/utils/emojiData.js +267 -0
  351. package/src/utils/eventEmitter.js +114 -0
  352. package/src/utils/state.js +224 -0
  353. package/src/utils/state.test.js +198 -0
  354. package/src/utils/storage.js +122 -0
  355. package/src/utils/storage.test.js +162 -0
  356. package/src/utils/validation.js +249 -0
@@ -0,0 +1,96 @@
1
+ import { EllipseData, EllipseEditData, EllipseEditType } from '.'
2
+ import { HistoryItemSource } from '../../types'
3
+ import { drawDragCircle } from '../utils'
4
+
5
+ export function getEditedEllipseData (action: HistoryItemSource<EllipseData, EllipseEditData>) {
6
+ let { x1, y1, x2, y2 } = action.data
7
+
8
+ action.editHistory.forEach(({ data }) => {
9
+ const x = data.x2 - data.x1
10
+ const y = data.y2 - data.y1
11
+ if (data.type === EllipseEditType.Move) {
12
+ x1 += x
13
+ y1 += y
14
+ x2 += x
15
+ y2 += y
16
+ } else if (data.type === EllipseEditType.ResizeTop) {
17
+ y1 += y
18
+ } else if (data.type === EllipseEditType.ResizeRightTop) {
19
+ x2 += x
20
+ y1 += y
21
+ } else if (data.type === EllipseEditType.ResizeRight) {
22
+ x2 += x
23
+ } else if (data.type === EllipseEditType.ResizeRightBottom) {
24
+ x2 += x
25
+ y2 += y
26
+ } else if (data.type === EllipseEditType.ResizeBottom) {
27
+ y2 += y
28
+ } else if (data.type === EllipseEditType.ResizeLeftBottom) {
29
+ x1 += x
30
+ y2 += y
31
+ } else if (data.type === EllipseEditType.ResizeLeft) {
32
+ x1 += x
33
+ } else if (data.type === EllipseEditType.ResizeLeftTop) {
34
+ x1 += x
35
+ y1 += y
36
+ }
37
+ })
38
+
39
+ return {
40
+ ...action.data,
41
+ x1,
42
+ x2,
43
+ y1,
44
+ y2
45
+ }
46
+ }
47
+
48
+ export default function draw (ctx: CanvasRenderingContext2D, action: HistoryItemSource<EllipseData, EllipseEditData>) {
49
+ const { size, color, x1, y1, x2, y2 } = getEditedEllipseData(action)
50
+ ctx.lineCap = 'butt'
51
+ ctx.lineJoin = 'miter'
52
+ ctx.lineWidth = size
53
+ ctx.strokeStyle = color
54
+
55
+ const x = (x1 + x2) / 2
56
+ const y = (y1 + y2) / 2
57
+ const rx = Math.abs(x2 - x1) / 2
58
+ const ry = Math.abs(y2 - y1) / 2
59
+ const k = 0.5522848
60
+ // 水平控制点偏移量
61
+ const ox = rx * k
62
+ // 垂直控制点偏移量
63
+ const oy = ry * k
64
+ // 从椭圆的左端点开始顺时针绘制四条三次贝塞尔曲线
65
+ ctx.beginPath()
66
+ ctx.moveTo(x - rx, y)
67
+ ctx.bezierCurveTo(x - rx, y - oy, x - ox, y - ry, x, y - ry)
68
+ ctx.bezierCurveTo(x + ox, y - ry, x + rx, y - oy, x + rx, y)
69
+ ctx.bezierCurveTo(x + rx, y + oy, x + ox, y + ry, x, y + ry)
70
+ ctx.bezierCurveTo(x - ox, y + ry, x - rx, y + oy, x - rx, y)
71
+ ctx.closePath()
72
+ ctx.stroke()
73
+
74
+ if (action.isSelected) {
75
+ ctx.lineWidth = 1
76
+ ctx.strokeStyle = '#000000'
77
+ ctx.fillStyle = '#ffffff'
78
+
79
+ ctx.beginPath()
80
+ ctx.moveTo(x1, y1)
81
+ ctx.lineTo(x2, y1)
82
+ ctx.lineTo(x2, y2)
83
+ ctx.lineTo(x1, y2)
84
+ ctx.closePath()
85
+ ctx.stroke()
86
+
87
+ drawDragCircle(ctx, (x1 + x2) / 2, y1)
88
+ drawDragCircle(ctx, x2, y1)
89
+ drawDragCircle(ctx, x2, (y1 + y2) / 2)
90
+ drawDragCircle(ctx, x2, y2)
91
+ drawDragCircle(ctx, (x1 + x2) / 2, y2)
92
+ drawDragCircle(ctx, x1, y2)
93
+ drawDragCircle(ctx, x1, (y1 + y2) / 2)
94
+ drawDragCircle(ctx, x1, y1)
95
+ }
96
+ }
@@ -0,0 +1,245 @@
1
+ import React, { ReactElement, useCallback, useRef, useState } from 'react'
2
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef'
3
+ import useCanvasMousedown from '../../hooks/useCanvasMousedown'
4
+ import useCanvasMousemove from '../../hooks/useCanvasMousemove'
5
+ import useCanvasMouseup from '../../hooks/useCanvasMouseup'
6
+ import useCursor from '../../hooks/useCursor'
7
+ import useDrawSelect from '../../hooks/useDrawSelect'
8
+ import useHistory from '../../hooks/useHistory'
9
+ import useLang from '../../hooks/useLang'
10
+ import useOperation from '../../hooks/useOperation'
11
+ import ScreenshotsButton from '../../ScreenshotsButton'
12
+ import ScreenshotsSizeColor from '../../ScreenshotsSizeColor'
13
+ import { HistoryItemEdit, HistoryItemSource, HistoryItemType } from '../../types'
14
+ import { isHit, isHitCircle } from '../utils'
15
+ import draw, { getEditedEllipseData } from './draw'
16
+
17
+ export interface EllipseData {
18
+ size: number
19
+ color: string
20
+ x1: number
21
+ y1: number
22
+ x2: number
23
+ y2: number
24
+ }
25
+
26
+ export enum EllipseEditType {
27
+ Move,
28
+ ResizeTop,
29
+ ResizeRightTop,
30
+ ResizeRight,
31
+ ResizeRightBottom,
32
+ ResizeBottom,
33
+ ResizeLeftBottom,
34
+ ResizeLeft,
35
+ ResizeLeftTop
36
+ }
37
+
38
+ export interface EllipseEditData {
39
+ type: EllipseEditType
40
+ x1: number
41
+ y1: number
42
+ x2: number
43
+ y2: number
44
+ }
45
+
46
+ export default function Ellipse (): ReactElement {
47
+ const lang = useLang()
48
+ const [history, historyDispatcher] = useHistory()
49
+ const [operation, operationDispatcher] = useOperation()
50
+ const [, cursorDispatcher] = useCursor()
51
+ const canvasContextRef = useCanvasContextRef()
52
+ const [size, setSize] = useState(3)
53
+ const [color, setColor] = useState('#ee5126')
54
+ const ellipseRef = useRef<HistoryItemSource<EllipseData, EllipseEditData> | null>(null)
55
+ const ellipseEditRef = useRef<HistoryItemEdit<EllipseEditData, EllipseData> | null>(null)
56
+
57
+ const checked = operation === 'Ellipse'
58
+
59
+ const selectEllipse = useCallback(() => {
60
+ operationDispatcher.set('Ellipse')
61
+ cursorDispatcher.set('crosshair')
62
+ }, [operationDispatcher, cursorDispatcher])
63
+
64
+ const onSelectEllipse = useCallback(() => {
65
+ if (checked) {
66
+ return
67
+ }
68
+ selectEllipse()
69
+ historyDispatcher.clearSelect()
70
+ }, [checked, selectEllipse, historyDispatcher])
71
+
72
+ const onDrawSelect = useCallback(
73
+ (action: HistoryItemSource<unknown, unknown>, e: MouseEvent) => {
74
+ if (action.name !== 'Ellipse' || !canvasContextRef.current) {
75
+ return
76
+ }
77
+
78
+ const source = action as HistoryItemSource<EllipseData, EllipseEditData>
79
+
80
+ selectEllipse()
81
+
82
+ const { x1, y1, x2, y2 } = getEditedEllipseData(source)
83
+
84
+ let type = EllipseEditType.Move
85
+ if (
86
+ isHitCircle(canvasContextRef.current.canvas, e, {
87
+ x: (x1 + x2) / 2,
88
+ y: y1
89
+ })
90
+ ) {
91
+ type = EllipseEditType.ResizeTop
92
+ } else if (
93
+ isHitCircle(canvasContextRef.current.canvas, e, {
94
+ x: x2,
95
+ y: y1
96
+ })
97
+ ) {
98
+ type = EllipseEditType.ResizeRightTop
99
+ } else if (
100
+ isHitCircle(canvasContextRef.current.canvas, e, {
101
+ x: x2,
102
+ y: (y1 + y2) / 2
103
+ })
104
+ ) {
105
+ type = EllipseEditType.ResizeRight
106
+ } else if (
107
+ isHitCircle(canvasContextRef.current.canvas, e, {
108
+ x: x2,
109
+ y: y2
110
+ })
111
+ ) {
112
+ type = EllipseEditType.ResizeRightBottom
113
+ } else if (
114
+ isHitCircle(canvasContextRef.current.canvas, e, {
115
+ x: (x1 + x2) / 2,
116
+ y: y2
117
+ })
118
+ ) {
119
+ type = EllipseEditType.ResizeBottom
120
+ } else if (
121
+ isHitCircle(canvasContextRef.current.canvas, e, {
122
+ x: x1,
123
+ y: y2
124
+ })
125
+ ) {
126
+ type = EllipseEditType.ResizeLeftBottom
127
+ } else if (
128
+ isHitCircle(canvasContextRef.current.canvas, e, {
129
+ x: x1,
130
+ y: (y1 + y2) / 2
131
+ })
132
+ ) {
133
+ type = EllipseEditType.ResizeLeft
134
+ } else if (
135
+ isHitCircle(canvasContextRef.current.canvas, e, {
136
+ x: x1,
137
+ y: y1
138
+ })
139
+ ) {
140
+ type = EllipseEditType.ResizeLeftTop
141
+ }
142
+
143
+ ellipseEditRef.current = {
144
+ type: HistoryItemType.Edit,
145
+ data: {
146
+ type,
147
+ x1: e.clientX,
148
+ y1: e.clientY,
149
+ x2: e.clientX,
150
+ y2: e.clientY
151
+ },
152
+ source
153
+ }
154
+
155
+ historyDispatcher.select(action)
156
+ },
157
+ [canvasContextRef, selectEllipse, historyDispatcher]
158
+ )
159
+
160
+ const onMousedown = useCallback(
161
+ (e: MouseEvent) => {
162
+ if (!checked || !canvasContextRef.current || ellipseRef.current) {
163
+ return
164
+ }
165
+
166
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
167
+ const x = e.clientX - left
168
+ const y = e.clientY - top
169
+ ellipseRef.current = {
170
+ name: 'Ellipse',
171
+ type: HistoryItemType.Source,
172
+ data: {
173
+ size,
174
+ color,
175
+ x1: x,
176
+ y1: y,
177
+ x2: x,
178
+ y2: y
179
+ },
180
+ editHistory: [],
181
+ draw,
182
+ isHit
183
+ }
184
+ },
185
+ [checked, size, color, canvasContextRef]
186
+ )
187
+
188
+ const onMousemove = useCallback(
189
+ (e: MouseEvent) => {
190
+ if (!checked || !canvasContextRef.current) {
191
+ return
192
+ }
193
+
194
+ if (ellipseEditRef.current) {
195
+ ellipseEditRef.current.data.x2 = e.clientX
196
+ ellipseEditRef.current.data.y2 = e.clientY
197
+ if (history.top !== ellipseEditRef.current) {
198
+ ellipseEditRef.current.source.editHistory.push(ellipseEditRef.current)
199
+ historyDispatcher.push(ellipseEditRef.current)
200
+ } else {
201
+ historyDispatcher.set(history)
202
+ }
203
+ } else if (ellipseRef.current) {
204
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
205
+ ellipseRef.current.data.x2 = e.clientX - left
206
+ ellipseRef.current.data.y2 = e.clientY - top
207
+
208
+ if (history.top !== ellipseRef.current) {
209
+ historyDispatcher.push(ellipseRef.current)
210
+ } else {
211
+ historyDispatcher.set(history)
212
+ }
213
+ }
214
+ },
215
+ [checked, canvasContextRef, history, historyDispatcher]
216
+ )
217
+
218
+ const onMouseup = useCallback(() => {
219
+ if (!checked) {
220
+ return
221
+ }
222
+
223
+ if (ellipseRef.current) {
224
+ historyDispatcher.clearSelect()
225
+ }
226
+
227
+ ellipseRef.current = null
228
+ ellipseEditRef.current = null
229
+ }, [checked, historyDispatcher])
230
+
231
+ useDrawSelect(onDrawSelect)
232
+ useCanvasMousedown(onMousedown)
233
+ useCanvasMousemove(onMousemove)
234
+ useCanvasMouseup(onMouseup)
235
+
236
+ return (
237
+ <ScreenshotsButton
238
+ title={lang.operation_ellipse_title}
239
+ icon='icon-ellipse'
240
+ checked={checked}
241
+ onClick={onSelectEllipse}
242
+ option={<ScreenshotsSizeColor size={size} color={color} onSizeChange={setSize} onColorChange={setColor} />}
243
+ />
244
+ )
245
+ }
@@ -0,0 +1,223 @@
1
+ import React, { ReactElement, useCallback, useEffect, useRef, useState } from 'react'
2
+ import ScreenshotsButton from '../../ScreenshotsButton'
3
+ import ScreenshotsSize from '../../ScreenshotsSize'
4
+ import useCanvasMousedown from '../../hooks/useCanvasMousedown'
5
+ import useCanvasMousemove from '../../hooks/useCanvasMousemove'
6
+ import useCanvasMouseup from '../../hooks/useCanvasMouseup'
7
+ import { HistoryItemSource, HistoryItemType } from '../../types'
8
+ import useOperation from '../../hooks/useOperation'
9
+ import useCursor from '../../hooks/useCursor'
10
+ import useStore from '../../hooks/useStore'
11
+ import useBounds from '../../hooks/useBounds'
12
+ import useHistory from '../../hooks/useHistory'
13
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef'
14
+ import useLang from '../../hooks/useLang'
15
+
16
+ export interface MosaicTile {
17
+ x: number
18
+ y: number
19
+ color: number[]
20
+ }
21
+
22
+ export interface MosaicData {
23
+ size: number
24
+ tiles: MosaicTile[]
25
+ }
26
+
27
+ function getColor (x: number, y: number, imageData: ImageData): number[] {
28
+ if (!imageData) {
29
+ return [0, 0, 0, 0]
30
+ }
31
+ const { data, width } = imageData
32
+
33
+ const index = y * width * 4 + x * 4
34
+
35
+ return Array.from(data.slice(index, index + 4))
36
+ }
37
+
38
+ function draw (ctx: CanvasRenderingContext2D, action: HistoryItemSource<MosaicData, null>) {
39
+ const { tiles, size } = action.data
40
+ tiles.forEach(tile => {
41
+ const r = Math.round(tile.color[0])
42
+ const g = Math.round(tile.color[1])
43
+ const b = Math.round(tile.color[2])
44
+ const a = tile.color[3] / 255
45
+
46
+ ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`
47
+ ctx.fillRect(tile.x - size / 2, tile.y - size / 2, size, size)
48
+ })
49
+ }
50
+
51
+ export default function Mosaic (): ReactElement {
52
+ const lang = useLang()
53
+ const { image, width, height } = useStore()
54
+ const [operation, operationDispatcher] = useOperation()
55
+ const canvasContextRef = useCanvasContextRef()
56
+ const [history, historyDispatcher] = useHistory()
57
+ const [bounds] = useBounds()
58
+ const [, cursorDispatcher] = useCursor()
59
+ const [size, setSize] = useState(3)
60
+ const imageDataRef = useRef<ImageData | null>(null)
61
+ const mosaicRef = useRef<HistoryItemSource<MosaicData, null> | null>(null)
62
+
63
+ const checked = operation === 'Mosaic'
64
+
65
+ const selectMosaic = useCallback(() => {
66
+ operationDispatcher.set('Mosaic')
67
+ cursorDispatcher.set('crosshair')
68
+ }, [operationDispatcher, cursorDispatcher])
69
+
70
+ const onSelectMosaic = useCallback(() => {
71
+ if (checked) {
72
+ return
73
+ }
74
+ selectMosaic()
75
+ historyDispatcher.clearSelect()
76
+ }, [checked, selectMosaic, historyDispatcher])
77
+
78
+ const onMousedown = useCallback(
79
+ (e: MouseEvent): void => {
80
+ if (!checked || mosaicRef.current || !imageDataRef.current || !canvasContextRef.current) {
81
+ return
82
+ }
83
+
84
+ const rect = canvasContextRef.current.canvas.getBoundingClientRect()
85
+ const x = e.clientX - rect.x
86
+ const y = e.clientY - rect.y
87
+ const mosaicSize = size * 2
88
+ mosaicRef.current = {
89
+ name: 'Mosaic',
90
+ type: HistoryItemType.Source,
91
+ data: {
92
+ size: mosaicSize,
93
+ tiles: [
94
+ {
95
+ x,
96
+ y,
97
+ color: getColor(x, y, imageDataRef.current)
98
+ }
99
+ ]
100
+ },
101
+ editHistory: [],
102
+ draw
103
+ }
104
+ },
105
+ [checked, size, canvasContextRef]
106
+ )
107
+
108
+ const onMousemove = useCallback(
109
+ (e: MouseEvent): void => {
110
+ if (!checked || !mosaicRef.current || !canvasContextRef.current || !imageDataRef.current) {
111
+ return
112
+ }
113
+
114
+ const rect = canvasContextRef.current.canvas.getBoundingClientRect()
115
+ const x = e.clientX - rect.x
116
+ const y = e.clientY - rect.y
117
+
118
+ const mosaicSize = mosaicRef.current.data.size
119
+ const mosaicTiles = mosaicRef.current.data.tiles
120
+
121
+ let lastTile = mosaicTiles[mosaicTiles.length - 1]
122
+
123
+ if (!lastTile) {
124
+ mosaicTiles.push({
125
+ x,
126
+ y,
127
+ color: getColor(x, y, imageDataRef.current)
128
+ })
129
+ } else {
130
+ const dx = lastTile.x - x
131
+ const dy = lastTile.y - y
132
+ // 减小点的个数
133
+ let length = Math.sqrt(dx ** 2 + dy ** 2)
134
+ const sin = -dy / length
135
+ const cos = -dx / length
136
+
137
+ while (length > mosaicSize) {
138
+ const cx = Math.floor(lastTile.x + mosaicSize * cos)
139
+ const cy = Math.floor(lastTile.y + mosaicSize * sin)
140
+ lastTile = {
141
+ x: cx,
142
+ y: cy,
143
+ color: getColor(cx, cy, imageDataRef.current)
144
+ }
145
+ mosaicTiles.push(lastTile)
146
+ length -= mosaicSize
147
+ }
148
+
149
+ // 最后一个位置补充一块
150
+ if (length > mosaicSize / 2) {
151
+ mosaicTiles.push({
152
+ x,
153
+ y,
154
+ color: getColor(x, y, imageDataRef.current)
155
+ })
156
+ }
157
+ }
158
+
159
+ if (history.top !== mosaicRef.current) {
160
+ historyDispatcher.push(mosaicRef.current)
161
+ } else {
162
+ historyDispatcher.set(history)
163
+ }
164
+ },
165
+ [checked, canvasContextRef, history, historyDispatcher]
166
+ )
167
+
168
+ const onMouseup = useCallback(() => {
169
+ if (!checked) {
170
+ return
171
+ }
172
+
173
+ mosaicRef.current = null
174
+ }, [checked])
175
+
176
+ useCanvasMousedown(onMousedown)
177
+ useCanvasMousemove(onMousemove)
178
+ useCanvasMouseup(onMouseup)
179
+
180
+ useEffect(() => {
181
+ if (!bounds || !image || !checked) {
182
+ return
183
+ }
184
+
185
+ const $canvas = document.createElement('canvas')
186
+
187
+ const canvasContext = $canvas.getContext('2d')
188
+
189
+ if (!canvasContext) {
190
+ return
191
+ }
192
+
193
+ $canvas.width = bounds.width
194
+ $canvas.height = bounds.height
195
+
196
+ const rx = image.naturalWidth / width
197
+ const ry = image.naturalHeight / height
198
+
199
+ canvasContext.drawImage(
200
+ image,
201
+ bounds.x * rx,
202
+ bounds.y * ry,
203
+ bounds.width * rx,
204
+ bounds.height * ry,
205
+ 0,
206
+ 0,
207
+ bounds.width,
208
+ bounds.height
209
+ )
210
+
211
+ imageDataRef.current = canvasContext.getImageData(0, 0, bounds.width, bounds.height)
212
+ }, [width, height, bounds, image, checked])
213
+
214
+ return (
215
+ <ScreenshotsButton
216
+ title={lang.operation_mosaic_title}
217
+ icon='icon-mosaic'
218
+ checked={checked}
219
+ onClick={onSelectMosaic}
220
+ option={<ScreenshotsSize value={size} onChange={setSize} />}
221
+ />
222
+ )
223
+ }
@@ -0,0 +1,37 @@
1
+ import React, { ReactElement, useCallback } from 'react'
2
+ import useStore from '../../hooks/useStore'
3
+ import useCall from '../../hooks/useCall'
4
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef'
5
+ import useHistory from '../../hooks/useHistory'
6
+ import useReset from '../../hooks/useReset'
7
+ import ScreenshotsButton from '../../ScreenshotsButton'
8
+ import composeImage from '../../composeImage'
9
+
10
+ export default function Ok (): ReactElement {
11
+ const { image, width, height, history, bounds, lang } = useStore()
12
+ const canvasContextRef = useCanvasContextRef()
13
+ const [, historyDispatcher] = useHistory()
14
+ const call = useCall()
15
+ const reset = useReset()
16
+
17
+ const onClick = useCallback(() => {
18
+ historyDispatcher.clearSelect()
19
+ setTimeout(() => {
20
+ if (!canvasContextRef.current || !image || !bounds) {
21
+ return
22
+ }
23
+ composeImage({
24
+ image,
25
+ width,
26
+ height,
27
+ history,
28
+ bounds
29
+ }).then(blob => {
30
+ call('onOk', blob, bounds)
31
+ reset()
32
+ })
33
+ })
34
+ }, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset])
35
+
36
+ return <ScreenshotsButton title={lang.operation_ok_title} icon='icon-ok' onClick={onClick} />
37
+ }
@@ -0,0 +1,37 @@
1
+ import React, { ReactElement, useCallback } from 'react';
2
+ import useStore from '../../hooks/useStore';
3
+ import useCall from '../../hooks/useCall';
4
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef';
5
+ import useHistory from '../../hooks/useHistory';
6
+ import useReset from '../../hooks/useReset';
7
+ import ScreenshotsButton from '../../ScreenshotsButton';
8
+ import composeImage from '../../composeImage';
9
+
10
+ export default function Pin(): ReactElement {
11
+ const { image, width, height, history, bounds, lang } = useStore();
12
+ const canvasContextRef = useCanvasContextRef();
13
+ const [, historyDispatcher] = useHistory();
14
+ const call = useCall();
15
+ const reset = useReset();
16
+
17
+ const onClick = useCallback(() => {
18
+ historyDispatcher.clearSelect();
19
+ setTimeout(() => {
20
+ if (!canvasContextRef.current || !image || !bounds) {
21
+ return;
22
+ }
23
+ composeImage({
24
+ image,
25
+ width,
26
+ height,
27
+ history,
28
+ bounds,
29
+ }).then((blob) => {
30
+ call('onPin', blob, bounds);
31
+ reset();
32
+ });
33
+ });
34
+ }, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset]);
35
+
36
+ return <ScreenshotsButton title={lang.operation_pin_title} icon="icon-pin" onClick={onClick} />;
37
+ }