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,169 @@
1
+ import React, {
2
+ MouseEvent,
3
+ ReactElement,
4
+ useCallback,
5
+ useLayoutEffect,
6
+ useRef,
7
+ useState,
8
+ } from "react";
9
+ import composeImage from "./composeImage";
10
+ import "./icons/iconfont.scss";
11
+ import "./screenshots.scss";
12
+ import ScreenshotsBackground from "./ScreenshotsBackground";
13
+ import ScreenshotsCanvas from "./ScreenshotsCanvas";
14
+ import ScreenshotsContext from "./ScreenshotsContext";
15
+ import ScreenshotsOperations from "./ScreenshotsOperations";
16
+ import { Bounds, Emiter, History } from "./types";
17
+ import useGetLoadedImage from "./useGetLoadedImage";
18
+ import zhCN, { Lang } from "./zh_CN";
19
+
20
+ export interface ScreenshotsProps {
21
+ url?: string;
22
+ width: number;
23
+ height: number;
24
+ lang?: Partial<Lang>;
25
+ className?: string;
26
+ [key: string]: unknown;
27
+ }
28
+
29
+ export default function Screenshots({
30
+ url,
31
+ width,
32
+ height,
33
+ lang,
34
+ className,
35
+ ...props
36
+ }: ScreenshotsProps): ReactElement {
37
+ const image = useGetLoadedImage(url);
38
+ const canvasContextRef = useRef<CanvasRenderingContext2D>(null);
39
+ const emiterRef = useRef<Emiter>({});
40
+ const [history, setHistory] = useState<History>({
41
+ index: -1,
42
+ stack: [],
43
+ });
44
+ const [bounds, setBounds] = useState<Bounds | null>(null);
45
+ const [cursor, setCursor] = useState<string | undefined>("move");
46
+ const [operation, setOperation] = useState<string | undefined>(undefined);
47
+
48
+ const store = {
49
+ url,
50
+ width,
51
+ height,
52
+ image,
53
+ lang: {
54
+ ...zhCN,
55
+ ...lang,
56
+ },
57
+ emiterRef,
58
+ canvasContextRef,
59
+ history,
60
+ bounds,
61
+ cursor,
62
+ operation,
63
+ };
64
+
65
+ const call = useCallback(
66
+ <T extends unknown[]>(funcName: string, ...args: T) => {
67
+ const func = props[funcName];
68
+ if (typeof func === "function") {
69
+ func(...args);
70
+ }
71
+ },
72
+ [props],
73
+ );
74
+
75
+ const dispatcher = {
76
+ call,
77
+ setHistory,
78
+ setBounds,
79
+ setCursor,
80
+ setOperation,
81
+ };
82
+
83
+ const classNames = ["screenshots"];
84
+
85
+ if (className) {
86
+ classNames.push(className);
87
+ }
88
+
89
+ const reset = () => {
90
+ emiterRef.current = {};
91
+ setHistory({
92
+ index: -1,
93
+ stack: [],
94
+ });
95
+ setBounds(null);
96
+ setCursor("move");
97
+ setOperation(undefined);
98
+ };
99
+
100
+ const onDoubleClick = useCallback(
101
+ async (e: MouseEvent) => {
102
+ if (e.button !== 0 || !image) {
103
+ return;
104
+ }
105
+ if (bounds && canvasContextRef.current) {
106
+ composeImage({
107
+ image,
108
+ width,
109
+ height,
110
+ history,
111
+ bounds,
112
+ }).then((blob) => {
113
+ call("onOk", blob, bounds);
114
+ reset();
115
+ });
116
+ } else {
117
+ const targetBounds = {
118
+ x: 0,
119
+ y: 0,
120
+ width,
121
+ height,
122
+ };
123
+ composeImage({
124
+ image,
125
+ width,
126
+ height,
127
+ history,
128
+ bounds: targetBounds,
129
+ }).then((blob) => {
130
+ call("onOk", blob, targetBounds);
131
+ reset();
132
+ });
133
+ }
134
+ },
135
+ [image, history, bounds, width, height, call],
136
+ );
137
+
138
+ const onContextMenu = useCallback(
139
+ (e: MouseEvent) => {
140
+ if (e.button !== 2) {
141
+ return;
142
+ }
143
+ e.preventDefault();
144
+ call("onCancel");
145
+ reset();
146
+ },
147
+ [call],
148
+ );
149
+
150
+ // url变化,重置截图区域
151
+ useLayoutEffect(() => {
152
+ reset();
153
+ }, [url]);
154
+
155
+ return (
156
+ <ScreenshotsContext.Provider value={{ store, dispatcher }}>
157
+ <div
158
+ className={classNames.join(" ")}
159
+ style={{ width, height }}
160
+ onDoubleClick={onDoubleClick}
161
+ onContextMenu={onContextMenu}
162
+ >
163
+ <ScreenshotsBackground />
164
+ <ScreenshotsCanvas ref={canvasContextRef} />
165
+ <ScreenshotsOperations />
166
+ </div>
167
+ </ScreenshotsContext.Provider>
168
+ );
169
+ }
@@ -0,0 +1,56 @@
1
+ import { ArrowData, ArrowEditData, ArrowEditType } from '.'
2
+ import { HistoryItemSource } from '../../types'
3
+ import { drawDragCircle } from '../utils'
4
+
5
+ export function getEditedArrowData (action: HistoryItemSource<ArrowData, ArrowEditData>) {
6
+ let { x1, y1, x2, y2 } = action.data
7
+ action.editHistory.forEach(({ data }) => {
8
+ const x = data.x2 - data.x1
9
+ const y = data.y2 - data.y1
10
+ if (data.type === ArrowEditType.Move) {
11
+ x1 += x
12
+ y1 += y
13
+ x2 += x
14
+ y2 += y
15
+ } else if (data.type === ArrowEditType.MoveStart) {
16
+ x1 += x
17
+ y1 += y
18
+ } else if (data.type === ArrowEditType.MoveEnd) {
19
+ x2 += x
20
+ y2 += y
21
+ }
22
+ })
23
+ return {
24
+ ...action.data,
25
+ x1,
26
+ x2,
27
+ y1,
28
+ y2
29
+ }
30
+ }
31
+
32
+ export default function draw (ctx: CanvasRenderingContext2D, action: HistoryItemSource<ArrowData, ArrowEditData>) {
33
+ const { size, color, x1, x2, y1, y2 } = getEditedArrowData(action)
34
+ ctx.lineCap = 'round'
35
+ ctx.lineJoin = 'bevel'
36
+ ctx.lineWidth = size
37
+ ctx.strokeStyle = color
38
+
39
+ const dx = x2 - x1
40
+ const dy = y2 - y1
41
+ // 箭头头部长度
42
+ const length = size * 3
43
+ const angle = Math.atan2(dy, dx)
44
+ ctx.beginPath()
45
+ ctx.moveTo(x1, y1)
46
+ ctx.lineTo(x2, y2)
47
+ ctx.lineTo(x2 - length * Math.cos(angle - Math.PI / 6), y2 - length * Math.sin(angle - Math.PI / 6))
48
+ ctx.moveTo(x2, y2)
49
+ ctx.lineTo(x2 - length * Math.cos(angle + Math.PI / 6), y2 - length * Math.sin(angle + Math.PI / 6))
50
+ ctx.stroke()
51
+
52
+ if (action.isSelected) {
53
+ drawDragCircle(ctx, x1, y1)
54
+ drawDragCircle(ctx, x2, y2)
55
+ }
56
+ }
@@ -0,0 +1,193 @@
1
+ import React, { ReactElement, useCallback, useRef, useState } from 'react'
2
+ import ScreenshotsButton from '../../ScreenshotsButton'
3
+ import ScreenshotsSizeColor from '../../ScreenshotsSizeColor'
4
+ import useCanvasMousedown from '../../hooks/useCanvasMousedown'
5
+ import useCanvasMousemove from '../../hooks/useCanvasMousemove'
6
+ import useCanvasMouseup from '../../hooks/useCanvasMouseup'
7
+ import { HistoryItemEdit, HistoryItemSource, HistoryItemType } from '../../types'
8
+ import useCursor from '../../hooks/useCursor'
9
+ import useOperation from '../../hooks/useOperation'
10
+ import useHistory from '../../hooks/useHistory'
11
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef'
12
+ import { isHit, isHitCircle } from '../utils'
13
+ import useDrawSelect from '../../hooks/useDrawSelect'
14
+ import draw, { getEditedArrowData } from './draw'
15
+ import useLang from '../../hooks/useLang'
16
+
17
+ export interface ArrowData {
18
+ size: number
19
+ color: string
20
+ x1: number
21
+ x2: number
22
+ y1: number
23
+ y2: number
24
+ }
25
+
26
+ export enum ArrowEditType {
27
+ Move,
28
+ MoveStart,
29
+ MoveEnd
30
+ }
31
+
32
+ export interface ArrowEditData {
33
+ type: ArrowEditType
34
+ x1: number
35
+ x2: number
36
+ y1: number
37
+ y2: number
38
+ }
39
+
40
+ export default function Arrow (): ReactElement {
41
+ const lang = useLang()
42
+ const [, cursorDispatcher] = useCursor()
43
+ const [operation, operationDispatcher] = useOperation()
44
+ const [history, historyDispatcher] = useHistory()
45
+ const canvasContextRef = useCanvasContextRef()
46
+ const [size, setSize] = useState(3)
47
+ const [color, setColor] = useState('#ee5126')
48
+ const arrowRef = useRef<HistoryItemSource<ArrowData, ArrowEditData> | null>(null)
49
+ const arrowEditRef = useRef<HistoryItemEdit<ArrowEditData, ArrowData> | null>(null)
50
+
51
+ const checked = operation === 'Arrow'
52
+
53
+ const selectArrow = useCallback(() => {
54
+ operationDispatcher.set('Arrow')
55
+ cursorDispatcher.set('default')
56
+ }, [operationDispatcher, cursorDispatcher])
57
+
58
+ const onSelectArrow = useCallback(() => {
59
+ if (checked) {
60
+ return
61
+ }
62
+ selectArrow()
63
+ historyDispatcher.clearSelect()
64
+ }, [checked, selectArrow, historyDispatcher])
65
+
66
+ const onDrawSelect = useCallback(
67
+ (action: HistoryItemSource<unknown, unknown>, e: MouseEvent) => {
68
+ if (action.name !== 'Arrow' || !canvasContextRef.current) {
69
+ return
70
+ }
71
+
72
+ const source = action as HistoryItemSource<ArrowData, ArrowEditData>
73
+ selectArrow()
74
+
75
+ const { x1, y1, x2, y2 } = getEditedArrowData(source)
76
+ let type = ArrowEditType.Move
77
+ if (
78
+ isHitCircle(canvasContextRef.current.canvas, e, {
79
+ x: x1,
80
+ y: y1
81
+ })
82
+ ) {
83
+ type = ArrowEditType.MoveStart
84
+ } else if (
85
+ isHitCircle(canvasContextRef.current.canvas, e, {
86
+ x: x2,
87
+ y: y2
88
+ })
89
+ ) {
90
+ type = ArrowEditType.MoveEnd
91
+ }
92
+
93
+ arrowEditRef.current = {
94
+ type: HistoryItemType.Edit,
95
+ data: {
96
+ type,
97
+ x1: e.clientX,
98
+ y1: e.clientY,
99
+ x2: e.clientX,
100
+ y2: e.clientY
101
+ },
102
+ source
103
+ }
104
+
105
+ historyDispatcher.select(action)
106
+ },
107
+ [canvasContextRef, selectArrow, historyDispatcher]
108
+ )
109
+
110
+ const onMousedown = useCallback(
111
+ (e: MouseEvent) => {
112
+ if (!checked || arrowRef.current || !canvasContextRef.current) {
113
+ return
114
+ }
115
+
116
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
117
+ arrowRef.current = {
118
+ name: 'Arrow',
119
+ type: HistoryItemType.Source,
120
+ data: {
121
+ size,
122
+ color,
123
+ x1: e.clientX - left,
124
+ y1: e.clientY - top,
125
+ x2: e.clientX - left,
126
+ y2: e.clientY - top
127
+ },
128
+ editHistory: [],
129
+ draw,
130
+ isHit
131
+ }
132
+ },
133
+ [checked, color, size, canvasContextRef]
134
+ )
135
+
136
+ const onMousemove = useCallback(
137
+ (e: MouseEvent) => {
138
+ if (!checked || !canvasContextRef.current) {
139
+ return
140
+ }
141
+ if (arrowEditRef.current) {
142
+ arrowEditRef.current.data.x2 = e.clientX
143
+ arrowEditRef.current.data.y2 = e.clientY
144
+ if (history.top !== arrowEditRef.current) {
145
+ arrowEditRef.current.source.editHistory.push(arrowEditRef.current)
146
+ historyDispatcher.push(arrowEditRef.current)
147
+ } else {
148
+ historyDispatcher.set(history)
149
+ }
150
+ } else if (arrowRef.current) {
151
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
152
+
153
+ arrowRef.current.data.x2 = e.clientX - left
154
+ arrowRef.current.data.y2 = e.clientY - top
155
+
156
+ if (history.top !== arrowRef.current) {
157
+ historyDispatcher.push(arrowRef.current)
158
+ } else {
159
+ historyDispatcher.set(history)
160
+ }
161
+ }
162
+ },
163
+ [checked, history, canvasContextRef, historyDispatcher]
164
+ )
165
+
166
+ const onMouseup = useCallback(() => {
167
+ if (!checked) {
168
+ return
169
+ }
170
+
171
+ if (arrowRef.current) {
172
+ historyDispatcher.clearSelect()
173
+ }
174
+
175
+ arrowRef.current = null
176
+ arrowEditRef.current = null
177
+ }, [checked, historyDispatcher])
178
+
179
+ useDrawSelect(onDrawSelect)
180
+ useCanvasMousedown(onMousedown)
181
+ useCanvasMousemove(onMousemove)
182
+ useCanvasMouseup(onMouseup)
183
+
184
+ return (
185
+ <ScreenshotsButton
186
+ title={lang.operation_arrow_title}
187
+ icon='icon-arrow'
188
+ checked={checked}
189
+ onClick={onSelectArrow}
190
+ option={<ScreenshotsSizeColor size={size} color={color} onSizeChange={setSize} onColorChange={setColor} />}
191
+ />
192
+ )
193
+ }
@@ -0,0 +1,45 @@
1
+ import { BrushData, BrushEditData } from '.';
2
+ import { HistoryItemSource } from '../../types';
3
+
4
+ export default function draw(
5
+ ctx: CanvasRenderingContext2D,
6
+ action: HistoryItemSource<BrushData, BrushEditData>,
7
+ ): void {
8
+ const { size, color, points } = action.data;
9
+ ctx.lineCap = 'round';
10
+ ctx.lineJoin = 'round';
11
+ ctx.lineWidth = size;
12
+ ctx.strokeStyle = color;
13
+
14
+ const distance = action.editHistory.reduce(
15
+ (distance, { data }) => ({
16
+ x: distance.x + data.x2 - data.x1,
17
+ y: distance.y + data.y2 - data.y1,
18
+ }),
19
+ { x: 0, y: 0 },
20
+ );
21
+
22
+ ctx.beginPath();
23
+ points.forEach((item, index) => {
24
+ if (index === 0) {
25
+ ctx.moveTo(item.x + distance.x, item.y + distance.y);
26
+ } else {
27
+ ctx.lineTo(item.x + distance.x, item.y + distance.y);
28
+ }
29
+ });
30
+ ctx.stroke();
31
+
32
+ if (action.isSelected) {
33
+ ctx.lineWidth = 1;
34
+ ctx.strokeStyle = 'rgba(0,0,0,0)';
35
+ ctx.beginPath();
36
+ points.forEach((item, index) => {
37
+ if (index === 0) {
38
+ ctx.moveTo(item.x + distance.x, item.y + distance.y);
39
+ } else {
40
+ ctx.lineTo(item.x + distance.x, item.y + distance.y);
41
+ }
42
+ });
43
+ ctx.stroke();
44
+ }
45
+ }
@@ -0,0 +1,169 @@
1
+ import React, { ReactElement, useCallback, useRef, useState } from 'react'
2
+ import useCanvasMousedown from '../../hooks/useCanvasMousedown'
3
+ import useCanvasMousemove from '../../hooks/useCanvasMousemove'
4
+ import useCanvasMouseup from '../../hooks/useCanvasMouseup'
5
+ import ScreenshotsButton from '../../ScreenshotsButton'
6
+ import ScreenshotsSizeColor from '../../ScreenshotsSizeColor'
7
+ import useCursor from '../../hooks/useCursor'
8
+ import useOperation from '../../hooks/useOperation'
9
+ import useHistory from '../../hooks/useHistory'
10
+ import useCanvasContextRef from '../../hooks/useCanvasContextRef'
11
+ import { HistoryItemEdit, HistoryItemSource, HistoryItemType, Point } from '../../types'
12
+ import useDrawSelect from '../../hooks/useDrawSelect'
13
+ import { isHit } from '../utils'
14
+ import draw from './draw'
15
+ import useLang from '../../hooks/useLang'
16
+
17
+ export interface BrushData {
18
+ size: number
19
+ color: string
20
+ points: Point[]
21
+ }
22
+
23
+ export interface BrushEditData {
24
+ x1: number
25
+ y1: number
26
+ x2: number
27
+ y2: number
28
+ }
29
+
30
+ export default function Brush (): ReactElement {
31
+ const lang = useLang()
32
+ const [, cursorDispatcher] = useCursor()
33
+ const [operation, operationDispatcher] = useOperation()
34
+ const canvasContextRef = useCanvasContextRef()
35
+ const [history, historyDispatcher] = useHistory()
36
+ const [size, setSize] = useState(3)
37
+ const [color, setColor] = useState('#ee5126')
38
+ const brushRef = useRef<HistoryItemSource<BrushData, BrushEditData> | null>(null)
39
+ const brushEditRef = useRef<HistoryItemEdit<BrushEditData, BrushData> | null>(null)
40
+
41
+ const checked = operation === 'Brush'
42
+
43
+ const selectBrush = useCallback(() => {
44
+ operationDispatcher.set('Brush')
45
+ cursorDispatcher.set('default')
46
+ }, [operationDispatcher, cursorDispatcher])
47
+
48
+ const onSelectBrush = useCallback(() => {
49
+ if (checked) {
50
+ return
51
+ }
52
+ selectBrush()
53
+ historyDispatcher.clearSelect()
54
+ }, [checked, selectBrush, historyDispatcher])
55
+
56
+ const onDrawSelect = useCallback(
57
+ (action: HistoryItemSource<unknown, unknown>, e: MouseEvent) => {
58
+ if (action.name !== 'Brush') {
59
+ return
60
+ }
61
+
62
+ selectBrush()
63
+
64
+ brushEditRef.current = {
65
+ type: HistoryItemType.Edit,
66
+ data: {
67
+ x1: e.clientX,
68
+ y1: e.clientY,
69
+ x2: e.clientX,
70
+ y2: e.clientY
71
+ },
72
+ source: action as HistoryItemSource<BrushData, BrushEditData>
73
+ }
74
+
75
+ historyDispatcher.select(action)
76
+ },
77
+ [selectBrush, historyDispatcher]
78
+ )
79
+
80
+ const onMousedown = useCallback(
81
+ (e: MouseEvent): void => {
82
+ if (!checked || brushRef.current || !canvasContextRef.current) {
83
+ return
84
+ }
85
+
86
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
87
+
88
+ brushRef.current = {
89
+ name: 'Brush',
90
+ type: HistoryItemType.Source,
91
+ data: {
92
+ size,
93
+ color,
94
+ points: [
95
+ {
96
+ x: e.clientX - left,
97
+ y: e.clientY - top
98
+ }
99
+ ]
100
+ },
101
+ editHistory: [],
102
+ draw,
103
+ isHit
104
+ }
105
+ },
106
+ [checked, canvasContextRef, size, color]
107
+ )
108
+
109
+ const onMousemove = useCallback(
110
+ (e: MouseEvent): void => {
111
+ if (!checked || !canvasContextRef.current) {
112
+ return
113
+ }
114
+
115
+ if (brushEditRef.current) {
116
+ brushEditRef.current.data.x2 = e.clientX
117
+ brushEditRef.current.data.y2 = e.clientY
118
+ if (history.top !== brushEditRef.current) {
119
+ brushEditRef.current.source.editHistory.push(brushEditRef.current)
120
+ historyDispatcher.push(brushEditRef.current)
121
+ } else {
122
+ historyDispatcher.set(history)
123
+ }
124
+ } else if (brushRef.current) {
125
+ const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
126
+
127
+ brushRef.current.data.points.push({
128
+ x: e.clientX - left,
129
+ y: e.clientY - top
130
+ })
131
+
132
+ if (history.top !== brushRef.current) {
133
+ historyDispatcher.push(brushRef.current)
134
+ } else {
135
+ historyDispatcher.set(history)
136
+ }
137
+ }
138
+ },
139
+ [checked, history, canvasContextRef, historyDispatcher]
140
+ )
141
+
142
+ const onMouseup = useCallback((): void => {
143
+ if (!checked) {
144
+ return
145
+ }
146
+
147
+ if (brushRef.current) {
148
+ historyDispatcher.clearSelect()
149
+ }
150
+
151
+ brushRef.current = null
152
+ brushEditRef.current = null
153
+ }, [checked, historyDispatcher])
154
+
155
+ useDrawSelect(onDrawSelect)
156
+ useCanvasMousedown(onMousedown)
157
+ useCanvasMousemove(onMousemove)
158
+ useCanvasMouseup(onMouseup)
159
+
160
+ return (
161
+ <ScreenshotsButton
162
+ title={lang.operation_brush_title}
163
+ icon='icon-brush'
164
+ checked={checked}
165
+ onClick={onSelectBrush}
166
+ option={<ScreenshotsSizeColor size={size} color={color} onSizeChange={setSize} onColorChange={setColor} />}
167
+ />
168
+ )
169
+ }
@@ -0,0 +1,18 @@
1
+ import React, { ReactElement, useCallback } from 'react'
2
+ import useCall from '../../hooks/useCall'
3
+ import useLang from '../../hooks/useLang'
4
+ import useReset from '../../hooks/useReset'
5
+ import ScreenshotsButton from '../../ScreenshotsButton'
6
+
7
+ export default function Cancel (): ReactElement {
8
+ const call = useCall()
9
+ const reset = useReset()
10
+ const lang = useLang()
11
+
12
+ const onClick = useCallback(() => {
13
+ call('onCancel')
14
+ reset()
15
+ }, [call, reset])
16
+
17
+ return <ScreenshotsButton title={lang.operation_cancel_title} icon='icon-cancel' onClick={onClick} />
18
+ }