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.
- package/README.md +188 -0
- package/dist/ailogo.png +0 -0
- package/dist/cd-aichat.css +1 -0
- package/dist/cd-aichat.es.js +32223 -0
- package/dist/cd-aichat.umd.js +279 -0
- package/dist/index.css +1 -0
- package/package.json +61 -0
- package/src/ailogo.png +0 -0
- package/src/components/AiChat.test.js +538 -0
- package/src/components/AiChat.vue +2206 -0
- package/src/components/AiChatWidget.test.js +312 -0
- package/src/components/AiChatWidget.vue +963 -0
- package/src/components/BurnAfterReadDialog.test.js +121 -0
- package/src/components/BurnAfterReadDialog.vue +511 -0
- package/src/components/BurnAfterReadMessage.test.js +188 -0
- package/src/components/BurnAfterReadMessage.vue +193 -0
- package/src/components/BurnIndicator.test.js +101 -0
- package/src/components/BurnIndicator.vue +164 -0
- package/src/components/ChatWindow.vue +0 -0
- package/src/components/MentionList.vue +163 -0
- package/src/components/ResourceList.vue +194 -0
- package/src/components/RichTextEditor.vue +437 -0
- package/src/components/ScheduledSendDialog.vue +476 -0
- package/src/components/ScreenshotOverlay.vue +78 -0
- package/src/components/SendButtonGroup.test.js +174 -0
- package/src/components/SendButtonGroup.vue +166 -0
- package/src/components/UserDrawer.vue +0 -0
- package/src/components/screenshot/ScreenshotsBackground/getBoundsByPoints.ts +41 -0
- package/src/components/screenshot/ScreenshotsBackground/index.scss +27 -0
- package/src/components/screenshot/ScreenshotsBackground/index.tsx +145 -0
- package/src/components/screenshot/ScreenshotsButton/index.scss +29 -0
- package/src/components/screenshot/ScreenshotsButton/index.tsx +58 -0
- package/src/components/screenshot/ScreenshotsCanvas/getBoundsByPoints.ts +55 -0
- package/src/components/screenshot/ScreenshotsCanvas/getPoints.ts +60 -0
- package/src/components/screenshot/ScreenshotsCanvas/index.scss +84 -0
- package/src/components/screenshot/ScreenshotsCanvas/index.tsx +277 -0
- package/src/components/screenshot/ScreenshotsCanvas/isPointInDraw.ts +35 -0
- package/src/components/screenshot/ScreenshotsColor/index.scss +45 -0
- package/src/components/screenshot/ScreenshotsColor/index.tsx +39 -0
- package/src/components/screenshot/ScreenshotsContext.ts +56 -0
- package/src/components/screenshot/ScreenshotsMagnifier/index.scss +61 -0
- package/src/components/screenshot/ScreenshotsMagnifier/index.tsx +126 -0
- package/src/components/screenshot/ScreenshotsOperations/index.scss +25 -0
- package/src/components/screenshot/ScreenshotsOperations/index.tsx +118 -0
- package/src/components/screenshot/ScreenshotsOption/index.scss +50 -0
- package/src/components/screenshot/ScreenshotsOption/index.tsx +150 -0
- package/src/components/screenshot/ScreenshotsSize/index.scss +28 -0
- package/src/components/screenshot/ScreenshotsSize/index.tsx +41 -0
- package/src/components/screenshot/ScreenshotsSizeColor/index.scss +8 -0
- package/src/components/screenshot/ScreenshotsSizeColor/index.tsx +25 -0
- package/src/components/screenshot/ScreenshotsTextarea/calculateNodeSize.ts +117 -0
- package/src/components/screenshot/ScreenshotsTextarea/index.scss +19 -0
- package/src/components/screenshot/ScreenshotsTextarea/index.tsx +96 -0
- package/src/components/screenshot/composeImage.ts +57 -0
- package/src/components/screenshot/exports.ts +4 -0
- package/src/components/screenshot/hooks/useBounds.ts +35 -0
- package/src/components/screenshot/hooks/useCall.ts +17 -0
- package/src/components/screenshot/hooks/useCanvasContextRef.ts +8 -0
- package/src/components/screenshot/hooks/useCanvasMousedown.ts +13 -0
- package/src/components/screenshot/hooks/useCanvasMousemove.ts +13 -0
- package/src/components/screenshot/hooks/useCanvasMouseup.ts +13 -0
- package/src/components/screenshot/hooks/useCursor.ts +34 -0
- package/src/components/screenshot/hooks/useDispatcher.ts +8 -0
- package/src/components/screenshot/hooks/useDrawSelect.ts +16 -0
- package/src/components/screenshot/hooks/useEmiter.ts +61 -0
- package/src/components/screenshot/hooks/useHistory.ts +160 -0
- package/src/components/screenshot/hooks/useLang.ts +8 -0
- package/src/components/screenshot/hooks/useOperation.ts +37 -0
- package/src/components/screenshot/hooks/useReset.ts +26 -0
- package/src/components/screenshot/hooks/useStore.ts +8 -0
- package/src/components/screenshot/icons/iconfont.scss +88 -0
- package/src/components/screenshot/icons/iconfont.ttf +0 -0
- package/src/components/screenshot/icons/iconfont.woff +0 -0
- package/src/components/screenshot/icons/iconfont.woff2 +0 -0
- package/src/components/screenshot/index.tsx +169 -0
- package/src/components/screenshot/operations/Arrow/draw.ts +56 -0
- package/src/components/screenshot/operations/Arrow/index.tsx +193 -0
- package/src/components/screenshot/operations/Brush/draw.ts +45 -0
- package/src/components/screenshot/operations/Brush/index.tsx +169 -0
- package/src/components/screenshot/operations/Cancel/index.tsx +18 -0
- package/src/components/screenshot/operations/Ellipse/draw.ts +96 -0
- package/src/components/screenshot/operations/Ellipse/index.tsx +245 -0
- package/src/components/screenshot/operations/Mosaic/index.tsx +223 -0
- package/src/components/screenshot/operations/Ok/index.tsx +37 -0
- package/src/components/screenshot/operations/Pin/index.tsx +37 -0
- package/src/components/screenshot/operations/Rectangle/draw.ts +80 -0
- package/src/components/screenshot/operations/Rectangle/index.tsx +245 -0
- package/src/components/screenshot/operations/Redo/index.tsx +22 -0
- package/src/components/screenshot/operations/Save/index.tsx +37 -0
- package/src/components/screenshot/operations/Scan/index.tsx +46 -0
- package/src/components/screenshot/operations/Search/index.tsx +39 -0
- package/src/components/screenshot/operations/Text/index.tsx +307 -0
- package/src/components/screenshot/operations/Undo/index.tsx +22 -0
- package/src/components/screenshot/operations/index.ts +34 -0
- package/src/components/screenshot/operations/utils.ts +34 -0
- package/src/components/screenshot/screenshots.scss +13 -0
- package/src/components/screenshot/types.ts +53 -0
- package/src/components/screenshot/useGetLoadedImage.ts +29 -0
- package/src/components/screenshot/var.scss +107 -0
- package/src/components/screenshot/zh_CN.ts +37 -0
- package/src/emoji/100.gif +0 -0
- package/src/emoji/101.gif +0 -0
- package/src/emoji/102.gif +0 -0
- package/src/emoji/103.gif +0 -0
- package/src/emoji/104.gif +0 -0
- package/src/emoji/105.gif +0 -0
- package/src/emoji/106.gif +0 -0
- package/src/emoji/107.gif +0 -0
- package/src/emoji/108.gif +0 -0
- package/src/emoji/109.gif +0 -0
- package/src/emoji/110.gif +0 -0
- package/src/emoji/111.gif +0 -0
- package/src/emoji/112.gif +0 -0
- package/src/emoji/113.gif +0 -0
- package/src/emoji/114.gif +0 -0
- package/src/emoji/115.gif +0 -0
- package/src/emoji/116.gif +0 -0
- package/src/emoji/117.gif +0 -0
- package/src/emoji/118.gif +0 -0
- package/src/emoji/119.gif +0 -0
- package/src/emoji/120.gif +0 -0
- package/src/emoji/121.gif +0 -0
- package/src/emoji/122.gif +0 -0
- package/src/emoji/123.gif +0 -0
- package/src/emoji/124.gif +0 -0
- package/src/emoji/125.gif +0 -0
- package/src/emoji/126.gif +0 -0
- package/src/emoji/127.gif +0 -0
- package/src/emoji/128.gif +0 -0
- package/src/emoji/129.gif +0 -0
- package/src/emoji/130.gif +0 -0
- package/src/emoji/131.gif +0 -0
- package/src/emoji/132.gif +0 -0
- package/src/emoji/133.gif +0 -0
- package/src/emoji/134.gif +0 -0
- package/src/emoji/135.gif +0 -0
- package/src/emoji/136.gif +0 -0
- package/src/emoji/137.gif +0 -0
- package/src/emoji/138.gif +0 -0
- package/src/emoji/139.gif +0 -0
- package/src/emoji/140.gif +0 -0
- package/src/emoji/141.gif +0 -0
- package/src/emoji/142.gif +0 -0
- package/src/emoji/143.gif +0 -0
- package/src/emoji/144.gif +0 -0
- package/src/emoji/145.gif +0 -0
- package/src/emoji/146.gif +0 -0
- package/src/emoji/147.gif +0 -0
- package/src/emoji/148.gif +0 -0
- package/src/emoji/149.gif +0 -0
- package/src/emoji/150.gif +0 -0
- package/src/emoji/151.gif +0 -0
- package/src/emoji/152.gif +0 -0
- package/src/emoji/153.gif +0 -0
- package/src/emoji/154.gif +0 -0
- package/src/emoji/155.gif +0 -0
- package/src/emoji/156.gif +0 -0
- package/src/emoji/157.gif +0 -0
- package/src/emoji/158.gif +0 -0
- package/src/emoji/159.gif +0 -0
- package/src/emoji/160.gif +0 -0
- package/src/emoji/161.gif +0 -0
- package/src/emoji/162.gif +0 -0
- package/src/emoji/163.gif +0 -0
- package/src/emoji/164.gif +0 -0
- package/src/emoji/165.gif +0 -0
- package/src/emoji/166.gif +0 -0
- package/src/emoji/167.gif +0 -0
- package/src/emoji/168.gif +0 -0
- package/src/emoji/169.gif +0 -0
- package/src/emoji/170.gif +0 -0
- package/src/emoji/171.gif +0 -0
- package/src/emoji/172.gif +0 -0
- package/src/emoji/173.gif +0 -0
- package/src/emoji/174.gif +0 -0
- package/src/emoji/175.gif +0 -0
- package/src/emoji/176.gif +0 -0
- package/src/emoji/177.gif +0 -0
- package/src/emoji/178.gif +0 -0
- package/src/emoji/179.gif +0 -0
- package/src/emoji/180.gif +0 -0
- package/src/emoji/181.gif +0 -0
- package/src/emoji/182.gif +0 -0
- package/src/emoji/183.gif +0 -0
- package/src/emoji/184.gif +0 -0
- package/src/emoji/185.gif +0 -0
- package/src/emoji/186.gif +0 -0
- package/src/emoji/187.gif +0 -0
- package/src/emoji/188.gif +0 -0
- package/src/emoji/189.gif +0 -0
- package/src/emoji/190.gif +0 -0
- package/src/emoji/191.gif +0 -0
- package/src/emoji/192.gif +0 -0
- package/src/emoji/193.gif +0 -0
- package/src/emoji/194.gif +0 -0
- package/src/emoji/195.gif +0 -0
- package/src/emoji/196.gif +0 -0
- package/src/emoji/197.gif +0 -0
- package/src/emoji/198.gif +0 -0
- package/src/emoji/199.gif +0 -0
- package/src/emoji/200.png +0 -0
- package/src/emoji/201.png +0 -0
- package/src/emoji/202.png +0 -0
- package/src/emoji/203.png +0 -0
- package/src/emoji/204.png +0 -0
- package/src/emoji/205.png +0 -0
- package/src/emoji/206.png +0 -0
- package/src/emoji/207.png +0 -0
- package/src/emoji/208.png +0 -0
- package/src/emoji/209.png +0 -0
- package/src/emoji/210.png +0 -0
- package/src/emoji/211.png +0 -0
- package/src/emoji/212.png +0 -0
- package/src/emoji/213.png +0 -0
- package/src/emoji/214.png +0 -0
- package/src/emoji/215.png +0 -0
- package/src/emoji/216.png +0 -0
- package/src/emoji/217.png +0 -0
- package/src/emoji/218.png +0 -0
- package/src/emoji/219.png +0 -0
- package/src/emoji2/101--Streamline-The-Team.png +0 -0
- package/src/emoji2/128--Streamline-The-Team.png +0 -0
- package/src/emoji2/134--Streamline-The-Team.png +0 -0
- package/src/emoji2/173--Streamline-The-Team.png +0 -0
- package/src/emoji2/Airplane--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Alien--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Amazed-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Amusing-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Anguished-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Anxious-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Astonished-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Backhand-Index-Pointing-Down-1--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Backhand-Index-Pointing-Left-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Backhand-Index-Pointing-Right-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Backhand-Index-Pointing-Up-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Bar-Chart--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Beaming-Face-With-Smiling-Eyes--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Boy-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Boy-2--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Boy-3--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Broken-Heart--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Clapping-Hands-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Clinking-Glasses-2--Streamline-Emoji.svg +43 -0
- package/src/emoji2/Confounded-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Confused-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Construction-Worker--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Couple-With-Heart-Woman-Man-1--Streamline-Emoji.svg +40 -0
- package/src/emoji2/Couple-With-Heart-Woman-Man-2--Streamline-Emoji.svg +40 -0
- package/src/emoji2/Cowboy-Hat-Face--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Crazy-Face--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Crossed-Fingers-1--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Crown--Streamline-Emoji.svg +35 -0
- package/src/emoji2/Crying-Face--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Delivery-Truck--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Determined-Face--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Disappointed-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Dizzy-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Downcast-Face-With-Sweat--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Drooling-Face-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Drooling-Face-2--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Ear--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Exclamation-Mark--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Exploding-Head--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Expressionless-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Face-Blowing-A-Kiss--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Savoring-Food--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Screaming-In-Fear--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Vomiting--Streamline-Emoji.svg +28 -0
- package/src/emoji2/Face-With-Head-Bandage--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Face-With-Medical-Mask--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Face-With-Monocle--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Face-With-Raised-Eyebrow--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Face-With-Rolling-Eyes--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Face-With-Steam-From-Nose--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Face-With-Symbols-On-Mouth--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Face-With-Tears-Of-Joy--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Face-With-Thermometer--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Face-With-Tongue--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Without-Mouth--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Fearful-Face--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Flexed-Biceps-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Flushed-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Folded-Hands-1--Streamline-Emoji.svg +29 -0
- package/src/emoji2/Frowning-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Fuel-Pump--Streamline-Emoji.svg +30 -0
- package/src/emoji2/Girl-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Glasses-1--Streamline-Emoji.svg +27 -0
- package/src/emoji2/Grimacing-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Grinning-Cat-Face--Streamline-Emoji.svg +32 -0
- package/src/emoji2/Grinning-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Grinning-Face-With-Sweat--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Grinning-Squinting-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Hand-With-Fingers-Splayed-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Heart-Suit--Streamline-Emoji.svg +9 -0
- package/src/emoji2/Hushed-Face-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Hushed-Face-2--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Index-Pointing-Up-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Kissing-Face-With-Closed-Eyes--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Loudly-Crying-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Lying-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Man-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Man-Facepalming-1--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Man-Gesturing-No-1--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Man-Gesturing-Ok-1--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Man-Health-Worker-1--Streamline-Emoji.svg +41 -0
- package/src/emoji2/Man-Raising-Hand-1--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Man-Shrugging-1--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Money-Mouth-Face-2--Streamline-Emoji.svg +30 -0
- package/src/emoji2/Mouth--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Nauseated-Face-2--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Neutral-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Ok-Hand-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Old-Man-1--Streamline-Emoji.svg +27 -0
- package/src/emoji2/Old-Woman-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Oncoming-Fist-1--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Person-Wearing-Turban-2--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Pile-Of-Poo--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Police-Car-Light--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Rocket--Streamline-Emoji.svg +32 -0
- package/src/emoji2/Sailboat--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Shaved-Ice--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Shortcake-2--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Shushing-Face--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Sign-Of-The-Horns-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Sleeping-Face--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Slightly-Smiling-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Smiling-Face-With-Halo--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Smiling-Face-With-Heart-Eyes--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Smirking-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Sun-With-Face--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Thumbs-Down-1--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Thumbs-Up-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Winking-Face--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Woman-Gesturing-No-1--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Woman-Gesturing-Ok-2--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Woman-Raising-Hand-1--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Womans-Sandal--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Worried-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Writing-Hand-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Zipper-Mouth-Face--Streamline-Emoji.svg +21 -0
- package/src/index.js +19 -0
- package/src/services/burn-after-read-service.js +313 -0
- package/src/services/burn-after-read-service.test.js +325 -0
- package/src/services/dify-api.js +338 -0
- package/src/services/dify-api.test.js +376 -0
- package/src/services/scheduled-send-service.js +311 -0
- package/src/services/scheduled-send-service.test.js +317 -0
- package/src/styles/index.css +2368 -0
- package/src/utils/emoji.js +125 -0
- package/src/utils/emojiData.js +267 -0
- package/src/utils/eventEmitter.js +114 -0
- package/src/utils/state.js +224 -0
- package/src/utils/state.test.js +198 -0
- package/src/utils/storage.js +122 -0
- package/src/utils/storage.test.js +162 -0
- package/src/utils/validation.js +249 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RectangleData, RectangleEditData, RectangleEditType } from '.'
|
|
2
|
+
import { HistoryItemSource } from '../../types'
|
|
3
|
+
import { drawDragCircle } from '../utils'
|
|
4
|
+
|
|
5
|
+
export function getEditedRectangleData (action: HistoryItemSource<RectangleData, RectangleEditData>) {
|
|
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 === RectangleEditType.Move) {
|
|
12
|
+
x1 += x
|
|
13
|
+
y1 += y
|
|
14
|
+
x2 += x
|
|
15
|
+
y2 += y
|
|
16
|
+
} else if (data.type === RectangleEditType.ResizeTop) {
|
|
17
|
+
y1 += y
|
|
18
|
+
} else if (data.type === RectangleEditType.ResizeRightTop) {
|
|
19
|
+
x2 += x
|
|
20
|
+
y1 += y
|
|
21
|
+
} else if (data.type === RectangleEditType.ResizeRight) {
|
|
22
|
+
x2 += x
|
|
23
|
+
} else if (data.type === RectangleEditType.ResizeRightBottom) {
|
|
24
|
+
x2 += x
|
|
25
|
+
y2 += y
|
|
26
|
+
} else if (data.type === RectangleEditType.ResizeBottom) {
|
|
27
|
+
y2 += y
|
|
28
|
+
} else if (data.type === RectangleEditType.ResizeLeftBottom) {
|
|
29
|
+
x1 += x
|
|
30
|
+
y2 += y
|
|
31
|
+
} else if (data.type === RectangleEditType.ResizeLeft) {
|
|
32
|
+
x1 += x
|
|
33
|
+
} else if (data.type === RectangleEditType.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 (
|
|
49
|
+
ctx: CanvasRenderingContext2D,
|
|
50
|
+
action: HistoryItemSource<RectangleData, RectangleEditData>
|
|
51
|
+
) {
|
|
52
|
+
const { size, color, x1, y1, x2, y2 } = getEditedRectangleData(action)
|
|
53
|
+
ctx.lineCap = 'butt'
|
|
54
|
+
ctx.lineJoin = 'miter'
|
|
55
|
+
ctx.lineWidth = size
|
|
56
|
+
ctx.strokeStyle = color
|
|
57
|
+
|
|
58
|
+
ctx.beginPath()
|
|
59
|
+
ctx.moveTo(x1, y1)
|
|
60
|
+
ctx.lineTo(x2, y1)
|
|
61
|
+
ctx.lineTo(x2, y2)
|
|
62
|
+
ctx.lineTo(x1, y2)
|
|
63
|
+
ctx.closePath()
|
|
64
|
+
ctx.stroke()
|
|
65
|
+
|
|
66
|
+
if (action.isSelected) {
|
|
67
|
+
ctx.lineWidth = 1
|
|
68
|
+
ctx.strokeStyle = '#000000'
|
|
69
|
+
ctx.fillStyle = '#ffffff'
|
|
70
|
+
|
|
71
|
+
drawDragCircle(ctx, (x1 + x2) / 2, y1)
|
|
72
|
+
drawDragCircle(ctx, x2, y1)
|
|
73
|
+
drawDragCircle(ctx, x2, (y1 + y2) / 2)
|
|
74
|
+
drawDragCircle(ctx, x2, y2)
|
|
75
|
+
drawDragCircle(ctx, (x1 + x2) / 2, y2)
|
|
76
|
+
drawDragCircle(ctx, x1, y2)
|
|
77
|
+
drawDragCircle(ctx, x1, (y1 + y2) / 2)
|
|
78
|
+
drawDragCircle(ctx, x1, y1)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -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 { HistoryItemSource, HistoryItemEdit, HistoryItemType } from '../../types'
|
|
14
|
+
import { isHit, isHitCircle } from '../utils'
|
|
15
|
+
import draw, { getEditedRectangleData } from './draw'
|
|
16
|
+
|
|
17
|
+
export interface RectangleData {
|
|
18
|
+
size: number
|
|
19
|
+
color: string
|
|
20
|
+
x1: number
|
|
21
|
+
y1: number
|
|
22
|
+
x2: number
|
|
23
|
+
y2: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export enum RectangleEditType {
|
|
27
|
+
Move,
|
|
28
|
+
ResizeTop,
|
|
29
|
+
ResizeRightTop,
|
|
30
|
+
ResizeRight,
|
|
31
|
+
ResizeRightBottom,
|
|
32
|
+
ResizeBottom,
|
|
33
|
+
ResizeLeftBottom,
|
|
34
|
+
ResizeLeft,
|
|
35
|
+
ResizeLeftTop
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface RectangleEditData {
|
|
39
|
+
type: RectangleEditType
|
|
40
|
+
x1: number
|
|
41
|
+
y1: number
|
|
42
|
+
x2: number
|
|
43
|
+
y2: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function Rectangle (): 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 rectangleRef = useRef<HistoryItemSource<RectangleData, RectangleEditData> | null>(null)
|
|
55
|
+
const rectangleEditRef = useRef<HistoryItemEdit<RectangleEditData, RectangleData> | null>(null)
|
|
56
|
+
|
|
57
|
+
const checked = operation === 'Rectangle'
|
|
58
|
+
|
|
59
|
+
const selectRectangle = useCallback(() => {
|
|
60
|
+
operationDispatcher.set('Rectangle')
|
|
61
|
+
cursorDispatcher.set('crosshair')
|
|
62
|
+
}, [operationDispatcher, cursorDispatcher])
|
|
63
|
+
|
|
64
|
+
const onSelectRectangle = useCallback(() => {
|
|
65
|
+
if (checked) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
selectRectangle()
|
|
69
|
+
historyDispatcher.clearSelect()
|
|
70
|
+
}, [checked, selectRectangle, historyDispatcher])
|
|
71
|
+
|
|
72
|
+
const onDrawSelect = useCallback(
|
|
73
|
+
(action: HistoryItemSource<unknown, unknown>, e: MouseEvent) => {
|
|
74
|
+
if (action.name !== 'Rectangle' || !canvasContextRef.current) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const source = action as HistoryItemSource<RectangleData, RectangleEditData>
|
|
79
|
+
selectRectangle()
|
|
80
|
+
|
|
81
|
+
const { x1, y1, x2, y2 } = getEditedRectangleData(source)
|
|
82
|
+
|
|
83
|
+
let type = RectangleEditType.Move
|
|
84
|
+
if (
|
|
85
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
86
|
+
x: (x1 + x2) / 2,
|
|
87
|
+
y: y1
|
|
88
|
+
})
|
|
89
|
+
) {
|
|
90
|
+
type = RectangleEditType.ResizeTop
|
|
91
|
+
} else if (
|
|
92
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
93
|
+
x: x2,
|
|
94
|
+
y: y1
|
|
95
|
+
})
|
|
96
|
+
) {
|
|
97
|
+
type = RectangleEditType.ResizeRightTop
|
|
98
|
+
} else if (
|
|
99
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
100
|
+
x: x2,
|
|
101
|
+
y: (y1 + y2) / 2
|
|
102
|
+
})
|
|
103
|
+
) {
|
|
104
|
+
type = RectangleEditType.ResizeRight
|
|
105
|
+
} else if (
|
|
106
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
107
|
+
x: x2,
|
|
108
|
+
y: y2
|
|
109
|
+
})
|
|
110
|
+
) {
|
|
111
|
+
type = RectangleEditType.ResizeRightBottom
|
|
112
|
+
} else if (
|
|
113
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
114
|
+
x: (x1 + x2) / 2,
|
|
115
|
+
y: y2
|
|
116
|
+
})
|
|
117
|
+
) {
|
|
118
|
+
type = RectangleEditType.ResizeBottom
|
|
119
|
+
} else if (
|
|
120
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
121
|
+
x: x1,
|
|
122
|
+
y: y2
|
|
123
|
+
})
|
|
124
|
+
) {
|
|
125
|
+
type = RectangleEditType.ResizeLeftBottom
|
|
126
|
+
} else if (
|
|
127
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
128
|
+
x: x1,
|
|
129
|
+
y: (y1 + y2) / 2
|
|
130
|
+
})
|
|
131
|
+
) {
|
|
132
|
+
type = RectangleEditType.ResizeLeft
|
|
133
|
+
} else if (
|
|
134
|
+
isHitCircle(canvasContextRef.current.canvas, e, {
|
|
135
|
+
x: x1,
|
|
136
|
+
y: y1
|
|
137
|
+
})
|
|
138
|
+
) {
|
|
139
|
+
type = RectangleEditType.ResizeLeftTop
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
rectangleEditRef.current = {
|
|
143
|
+
type: HistoryItemType.Edit,
|
|
144
|
+
data: {
|
|
145
|
+
type,
|
|
146
|
+
x1: e.clientX,
|
|
147
|
+
y1: e.clientY,
|
|
148
|
+
x2: e.clientX,
|
|
149
|
+
y2: e.clientY
|
|
150
|
+
},
|
|
151
|
+
source: action as HistoryItemSource<RectangleData, RectangleEditData>
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
historyDispatcher.select(action)
|
|
155
|
+
},
|
|
156
|
+
[canvasContextRef, selectRectangle, historyDispatcher]
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const onMousedown = useCallback(
|
|
160
|
+
(e: MouseEvent) => {
|
|
161
|
+
if (!checked || !canvasContextRef.current || rectangleRef.current) {
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
|
|
166
|
+
const x = e.clientX - left
|
|
167
|
+
const y = e.clientY - top
|
|
168
|
+
rectangleRef.current = {
|
|
169
|
+
name: 'Rectangle',
|
|
170
|
+
type: HistoryItemType.Source,
|
|
171
|
+
data: {
|
|
172
|
+
size,
|
|
173
|
+
color,
|
|
174
|
+
x1: x,
|
|
175
|
+
y1: y,
|
|
176
|
+
x2: x,
|
|
177
|
+
y2: y
|
|
178
|
+
},
|
|
179
|
+
editHistory: [],
|
|
180
|
+
draw,
|
|
181
|
+
isHit
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
[checked, size, color, canvasContextRef]
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
const onMousemove = useCallback(
|
|
188
|
+
(e: MouseEvent) => {
|
|
189
|
+
if (!checked || !canvasContextRef.current) {
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (rectangleEditRef.current) {
|
|
194
|
+
rectangleEditRef.current.data.x2 = e.clientX
|
|
195
|
+
rectangleEditRef.current.data.y2 = e.clientY
|
|
196
|
+
if (history.top !== rectangleEditRef.current) {
|
|
197
|
+
rectangleEditRef.current.source.editHistory.push(rectangleEditRef.current)
|
|
198
|
+
historyDispatcher.push(rectangleEditRef.current)
|
|
199
|
+
} else {
|
|
200
|
+
historyDispatcher.set(history)
|
|
201
|
+
}
|
|
202
|
+
} else if (rectangleRef.current) {
|
|
203
|
+
const { left, top } = canvasContextRef.current.canvas.getBoundingClientRect()
|
|
204
|
+
const rectangleData = rectangleRef.current.data
|
|
205
|
+
rectangleData.x2 = e.clientX - left
|
|
206
|
+
rectangleData.y2 = e.clientY - top
|
|
207
|
+
|
|
208
|
+
if (history.top !== rectangleRef.current) {
|
|
209
|
+
historyDispatcher.push(rectangleRef.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 (rectangleRef.current) {
|
|
224
|
+
historyDispatcher.clearSelect()
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
rectangleRef.current = null
|
|
228
|
+
rectangleEditRef.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_rectangle_title}
|
|
239
|
+
icon='icon-rectangle'
|
|
240
|
+
checked={checked}
|
|
241
|
+
onClick={onSelectRectangle}
|
|
242
|
+
option={<ScreenshotsSizeColor size={size} color={color} onSizeChange={setSize} onColorChange={setColor} />}
|
|
243
|
+
/>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ReactElement, useCallback } from 'react'
|
|
2
|
+
import ScreenshotsButton from '../../ScreenshotsButton'
|
|
3
|
+
import useHistory from '../../hooks/useHistory'
|
|
4
|
+
import useLang from '../../hooks/useLang'
|
|
5
|
+
|
|
6
|
+
export default function Redo (): ReactElement {
|
|
7
|
+
const lang = useLang()
|
|
8
|
+
const [history, historyDispatcher] = useHistory()
|
|
9
|
+
|
|
10
|
+
const onClick = useCallback(() => {
|
|
11
|
+
historyDispatcher.redo()
|
|
12
|
+
}, [historyDispatcher])
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ScreenshotsButton
|
|
16
|
+
title={lang.operation_redo_title}
|
|
17
|
+
icon='icon-redo'
|
|
18
|
+
disabled={!history.stack.length || history.stack.length - 1 === history.index}
|
|
19
|
+
onClick={onClick}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { ReactElement, useCallback } from 'react'
|
|
2
|
+
import composeImage from '../../composeImage'
|
|
3
|
+
import useStore from '../../hooks/useStore'
|
|
4
|
+
import useCall from '../../hooks/useCall'
|
|
5
|
+
import useCanvasContextRef from '../../hooks/useCanvasContextRef'
|
|
6
|
+
import useHistory from '../../hooks/useHistory'
|
|
7
|
+
import useReset from '../../hooks/useReset'
|
|
8
|
+
import ScreenshotsButton from '../../ScreenshotsButton'
|
|
9
|
+
|
|
10
|
+
export default function Save (): 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('onSave', blob, bounds)
|
|
31
|
+
reset()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
}, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset])
|
|
35
|
+
|
|
36
|
+
return <ScreenshotsButton title={lang.operation_save_title} icon='icon-save' onClick={onClick} />
|
|
37
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { ReactElement, useCallback } from 'react';
|
|
2
|
+
import QrScanner from 'qr-scanner';
|
|
3
|
+
import useStore from '../../hooks/useStore';
|
|
4
|
+
import useCall from '../../hooks/useCall';
|
|
5
|
+
import useCanvasContextRef from '../../hooks/useCanvasContextRef';
|
|
6
|
+
import useHistory from '../../hooks/useHistory';
|
|
7
|
+
import useReset from '../../hooks/useReset';
|
|
8
|
+
import ScreenshotsButton from '../../ScreenshotsButton';
|
|
9
|
+
import composeImage from '../../composeImage';
|
|
10
|
+
|
|
11
|
+
export default function Scan(): ReactElement {
|
|
12
|
+
const { image, width, height, history, bounds, lang } = useStore();
|
|
13
|
+
const canvasContextRef = useCanvasContextRef();
|
|
14
|
+
const [, historyDispatcher] = useHistory();
|
|
15
|
+
const call = useCall();
|
|
16
|
+
const reset = useReset();
|
|
17
|
+
|
|
18
|
+
const onClick = useCallback(() => {
|
|
19
|
+
historyDispatcher.clearSelect();
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
if (!canvasContextRef.current || !image || !bounds) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
composeImage({
|
|
25
|
+
image,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
history,
|
|
29
|
+
bounds,
|
|
30
|
+
}).then(async (blob) => {
|
|
31
|
+
try {
|
|
32
|
+
const result = await QrScanner.scanImage(blob);
|
|
33
|
+
if (result) {
|
|
34
|
+
call('onScan', result);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error:', error);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
reset();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset]);
|
|
44
|
+
|
|
45
|
+
return <ScreenshotsButton title={lang.operation_scan_title} icon="icon-scan" onClick={onClick} />;
|
|
46
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 Search(): 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('onSearch', blob);
|
|
31
|
+
reset();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}, [canvasContextRef, historyDispatcher, image, width, height, history, bounds, call, reset]);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ScreenshotsButton title={lang.operation_search_title} icon="icon-search" onClick={onClick} />
|
|
38
|
+
);
|
|
39
|
+
}
|