bhd-components 0.9.1 → 0.9.3

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 (237) hide show
  1. package/README.md +1 -1
  2. package/dist/index.esm.es5.development.css +833 -363
  3. package/dist/index.esm.es5.development.js +4159 -6606
  4. package/dist/index.esm.es5.production.css +1 -1
  5. package/dist/index.esm.es5.production.js +1 -1
  6. package/dist/vendor.esm.es5.development.css +119 -0
  7. package/dist/{100c4e1e.esm.es5.development.js → vendor.esm.es5.development.js} +16857 -8463
  8. package/dist/vendor.esm.es5.production.css +11 -0
  9. package/dist/vendor.esm.es5.production.js +485 -0
  10. package/es2017/bhdAppLayout/components/BhdTableSimple/index.js +1 -1
  11. package/es2017/bhdAppLayout/components/BhdTableSimple/index/347/232/204/345/211/257/346/234/254.js +2 -2
  12. package/es2017/bhdAppLayout/index.js +16 -16
  13. package/es2017/bhdDatePicker/index.d.ts +1 -2
  14. package/es2017/bhdDatePicker/index.js +253 -256
  15. package/es2017/bhdDatePicker/index.module.less +120 -8
  16. package/es2017/bhdSelect/index.js +4 -4
  17. package/es2017/bhdTipModal/index.js +6 -6
  18. package/es2017/customerService/contactsList.d.ts +2 -2
  19. package/es2017/customerService/contactsList.js +2 -2
  20. package/es2017/customerService/function.js +2 -1
  21. package/es2017/customerService/historyFun.d.ts +2 -2
  22. package/es2017/customerService/historyFun.js +2 -2
  23. package/es2017/customerService/index.d.ts +2 -2
  24. package/es2017/customerService/index.js +6 -6
  25. package/es2017/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
  26. package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
  27. package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
  28. package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
  29. package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
  30. package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
  31. package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
  32. package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
  33. package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
  34. package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
  35. package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
  36. package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
  37. package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
  38. package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
  39. package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
  40. package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
  41. package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +9 -0
  42. package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
  43. package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +41 -0
  44. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
  45. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
  46. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
  47. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +38 -0
  48. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
  49. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +27 -0
  50. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
  51. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
  52. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
  53. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
  54. package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
  55. package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
  56. package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
  57. package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
  58. package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
  59. package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
  60. package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
  61. package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
  62. package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
  63. package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
  64. package/es2017/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
  65. package/es2017/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
  66. package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
  67. package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +305 -0
  68. package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
  69. package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.js +538 -0
  70. package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
  71. package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +162 -0
  72. package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
  73. package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
  74. package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
  75. package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
  76. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
  77. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
  78. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
  79. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
  80. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
  81. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +131 -0
  82. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
  83. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
  84. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
  85. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +119 -0
  86. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
  87. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
  88. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
  89. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
  90. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
  91. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
  92. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
  93. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
  94. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
  95. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
  96. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
  97. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
  98. package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
  99. package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +50 -0
  100. package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
  101. package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +62 -0
  102. package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
  103. package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
  104. package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
  105. package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +33 -0
  106. package/es2017/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
  107. package/es2017/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
  108. package/es2017/customerService/js-screen-shot/main.d.ts +110 -0
  109. package/es2017/customerService/js-screen-shot/main.js +1101 -0
  110. package/es2017/customerService/screenshotTool.d.ts +2 -2
  111. package/es2017/customerService/screenshotTool.js +2 -2
  112. package/es2017/customerService/teacherList.d.ts +2 -2
  113. package/es2017/customerService/teacherList.js +2 -2
  114. package/es2017/i18n/en_US.js +4 -1
  115. package/es2017/i18n/zh_CN.js +4 -1
  116. package/es2017/icons/index.js +2 -2
  117. package/es2017/index.js +14 -14
  118. package/es2017/provider/index.js +2 -2
  119. package/es2017/table/index.js +4 -4
  120. package/es2017/tableSelect/index.js +3 -3
  121. package/es2017/textTootip/index.js +1 -1
  122. package/es2017/titleBar/index.js +3 -3
  123. package/es2017/viewImage/index.js +13 -13
  124. package/esm/bhdAppLayout/index.js +15 -15
  125. package/esm/bhdDatePicker/index.d.ts +1 -2
  126. package/esm/bhdDatePicker/index.js +254 -257
  127. package/esm/bhdDatePicker/index.module.less +120 -8
  128. package/esm/bhdSelect/index.js +1 -1
  129. package/esm/bhdTipModal/index.js +1 -1
  130. package/esm/customerService/contactsList.d.ts +2 -2
  131. package/esm/customerService/contactsList.js +1 -1
  132. package/esm/customerService/function.js +2 -1
  133. package/esm/customerService/historyFun.d.ts +2 -2
  134. package/esm/customerService/historyFun.js +1 -1
  135. package/esm/customerService/index.d.ts +2 -2
  136. package/esm/customerService/index.js +2 -2
  137. package/esm/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
  138. package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
  139. package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
  140. package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
  141. package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
  142. package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
  143. package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
  144. package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
  145. package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
  146. package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
  147. package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
  148. package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
  149. package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
  150. package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
  151. package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
  152. package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
  153. package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +10 -0
  154. package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
  155. package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +38 -0
  156. package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
  157. package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
  158. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
  159. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +38 -0
  160. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
  161. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +27 -0
  162. package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
  163. package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
  164. package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
  165. package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
  166. package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
  167. package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
  168. package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
  169. package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
  170. package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
  171. package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
  172. package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
  173. package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
  174. package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
  175. package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
  176. package/esm/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
  177. package/esm/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
  178. package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
  179. package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +346 -0
  180. package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
  181. package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.js +758 -0
  182. package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
  183. package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +259 -0
  184. package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
  185. package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
  186. package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
  187. package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
  188. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
  189. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
  190. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
  191. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
  192. package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
  193. package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +159 -0
  194. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
  195. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
  196. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
  197. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +120 -0
  198. package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
  199. package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
  200. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
  201. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
  202. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
  203. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
  204. package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
  205. package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
  206. package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
  207. package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
  208. package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
  209. package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
  210. package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
  211. package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +61 -0
  212. package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
  213. package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +63 -0
  214. package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
  215. package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
  216. package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
  217. package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +33 -0
  218. package/esm/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
  219. package/esm/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
  220. package/esm/customerService/js-screen-shot/main.d.ts +110 -0
  221. package/esm/customerService/js-screen-shot/main.js +1204 -0
  222. package/esm/customerService/screenshotTool.d.ts +2 -2
  223. package/esm/customerService/screenshotTool.js +1 -1
  224. package/esm/customerService/teacherList.d.ts +2 -2
  225. package/esm/customerService/teacherList.js +1 -1
  226. package/esm/i18n/en_US.js +4 -1
  227. package/esm/i18n/zh_CN.js +4 -1
  228. package/esm/icons/index.js +1 -1
  229. package/esm/index.js +14 -14
  230. package/esm/tableSelect/index.js +1 -1
  231. package/esm/viewImage/index.js +3 -3
  232. package/package.json +1 -1
  233. package/dist/a4d5ce04.esm.es5.production.js +0 -468
  234. package/dist/vendor.esm.es5.development.esm.es5.development.css +0 -119
  235. package/dist/vendor.esm.es5.production.esm.es5.production.css +0 -11
  236. package/es2017/customerService/screenShotPlugin.esm.js +0 -6515
  237. package/esm/customerService/screenShotPlugin.esm.js +0 -6516
@@ -0,0 +1,1101 @@
1
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import CreateDom from "./lib/main-entrance/CreateDom";
4
+ // 导入截图所需样式
5
+ import "./assets/less/screen-shot.less";
6
+ import InitData from "./lib/main-entrance/InitData";
7
+ import { drawMasking } from "./lib/split-methods/DrawMasking";
8
+ import { fixedData, nonNegativeData } from "./lib/common-methods/FixedData";
9
+ import { drawPencil, initPencil } from "./lib/split-methods/DrawPencil";
10
+ import { drawText } from "./lib/split-methods/DrawText";
11
+ import { drawRectangle } from "./lib/split-methods/DrawRectangle";
12
+ import { drawCircle } from "./lib/split-methods/DrawCircle";
13
+ import { DrawArrow } from "./lib/split-methods/DrawArrow";
14
+ import { drawMosaic } from "./lib/split-methods/DrawMosaic";
15
+ import { drawCutOutBox } from "./lib/split-methods/DrawCutOutBox";
16
+ import { zoomCutOutBoxPosition } from "./lib/common-methods/ZoomCutOutBoxPosition";
17
+ import { saveBorderArrInfo } from "./lib/common-methods/SaveBorderArrInfo";
18
+ import { calculateToolLocation } from "./lib/split-methods/CalculateToolLocation";
19
+ import html2canvas from "html2canvas";
20
+ import PlugInParameters from "./lib/main-entrance/PlugInParameters";
21
+ import { getDrawBoundaryStatus } from "./lib/split-methods/BoundaryJudgment";
22
+ import KeyboardEventHandle from "./lib/split-methods/KeyboardEventHandle";
23
+ import { setPlugInParameters } from "./lib/split-methods/SetPlugInParameters";
24
+ import { drawCrossImg } from "./lib/split-methods/drawCrossImg";
25
+ import { getCanvas2dCtx } from "./lib/common-methods/CanvasPatch";
26
+ import { updateContainerMouseStyle } from "./lib/common-methods/UpdateContainerMouseStyle";
27
+ import { addHistory } from "./lib/split-methods/AddHistoryData";
28
+ import { isPC, isTouchDevice } from "./lib/common-methods/DeviceTypeVerif";
29
+ import { drawLineArrow } from "./lib/split-methods/DrawLineArrow";
30
+ class ScreenShot {
31
+ // 获取截图区域canvas容器
32
+ getCanvasController() {
33
+ return this.screenShotContainer;
34
+ }
35
+ // 销毁组件方法
36
+ destroyComponents() {
37
+ this.data.destroyDOM();
38
+ this.data.setInitStatus(true);
39
+ }
40
+ // 确认截图方法
41
+ completeScreenshot() {
42
+ if (this.keyboardEventHandle) {
43
+ this.keyboardEventHandle.triggerEvent("confirm");
44
+ }
45
+ }
46
+ // 注册右键事件
47
+ registerForRightClickEvent(container) {
48
+ container.addEventListener("contextmenu", (e)=>{
49
+ e.preventDefault();
50
+ // 调用者传入了自定义事件则执行
51
+ if (this.customRightClickEvent.handleFn) {
52
+ this.customRightClickEvent.handleFn();
53
+ return;
54
+ }
55
+ // 销毁组件
56
+ this.destroyComponents();
57
+ });
58
+ }
59
+ // 加载截图组件
60
+ load(triggerCallback, cancelCallback) {
61
+ const canvasSize = this.plugInParameters.getCanvasSize();
62
+ const viewSize = {
63
+ width: parseFloat(window.getComputedStyle(document.body).width),
64
+ height: parseFloat(window.getComputedStyle(document.body).height)
65
+ };
66
+ // 设置截图区域canvas宽高
67
+ this.data.setScreenShotInfo(viewSize.width, viewSize.height);
68
+ // 设置截图容器位置
69
+ this.data.setScreenShotPosition(this.position.left, this.position.top);
70
+ // 设置截图图片存放容器宽高
71
+ this.screenShotImageController.width = viewSize.width;
72
+ this.screenShotImageController.height = viewSize.height;
73
+ // 用户有传宽高则使用用户传进来的
74
+ if (canvasSize.canvasWidth !== 0 && canvasSize.canvasHeight !== 0) {
75
+ this.data.setScreenShotInfo(canvasSize.canvasWidth, canvasSize.canvasHeight);
76
+ this.screenShotImageController.width = canvasSize.canvasWidth;
77
+ this.screenShotImageController.height = canvasSize.canvasHeight;
78
+ }
79
+ // 获取截图区域canvas容器画布
80
+ if (this.screenShotContainer == null) return;
81
+ const context = getCanvas2dCtx(this.screenShotContainer, this.screenShotImageController.width, this.screenShotImageController.height);
82
+ if (context == null) return;
83
+ // 显示截图区域容器
84
+ this.data.showScreenShotPanel();
85
+ if (!this.plugInParameters.getWebRtcStatus()) {
86
+ // 判断用户是否自己传入截屏图片
87
+ if (this.imgSrc != null) {
88
+ this.drawPictures(triggerCallback, context, this.imgSrc);
89
+ return;
90
+ }
91
+ // html2canvas截屏
92
+ html2canvas(this.screenShotDom ? this.screenShotDom : document.body, {
93
+ onclone: this.loadCrossImg ? drawCrossImg : undefined,
94
+ proxy: this.proxyUrl,
95
+ useCORS: this.useCORS
96
+ }).then((canvas)=>{
97
+ // 装载截图的dom为null则退出
98
+ if (this.screenShotContainer == null) return;
99
+ // 存储html2canvas截取的内容
100
+ this.screenShotImageController = canvas;
101
+ // 初始化截图容器
102
+ this.initScreenShot(triggerCallback, context, canvas);
103
+ }).catch((err)=>{
104
+ if (triggerCallback != null) {
105
+ // 获取页面元素成功,执行回调函数
106
+ triggerCallback({
107
+ code: -1,
108
+ msg: err
109
+ });
110
+ }
111
+ });
112
+ return;
113
+ }
114
+ // 调用者有传入屏幕流数据则使用
115
+ if (this.plugInParameters.getScreenFlow()) {
116
+ this.sendStream(this.plugInParameters.getScreenFlow(), cancelCallback, triggerCallback);
117
+ return;
118
+ }
119
+ // 隐藏光标
120
+ document.body.classList.add("no-cursor");
121
+ // 使用webrtc实现截屏
122
+ this.screenShot(cancelCallback, triggerCallback);
123
+ }
124
+ loadScreenFlowData(triggerCallback) {
125
+ setTimeout(()=>{
126
+ var _this_screenShotImageController, _this_screenShotImageController1;
127
+ // 获取截图区域canvas容器画布
128
+ if (this.screenShotContainer == null) return;
129
+ const canvasSize = this.plugInParameters.getCanvasSize();
130
+ let containerWidth = (_this_screenShotImageController = this.screenShotImageController) === null || _this_screenShotImageController === void 0 ? void 0 : _this_screenShotImageController.width;
131
+ let containerHeight = (_this_screenShotImageController1 = this.screenShotImageController) === null || _this_screenShotImageController1 === void 0 ? void 0 : _this_screenShotImageController1.height;
132
+ // 用户有传宽高时,则使用用户的
133
+ if (canvasSize.canvasWidth !== 0 && canvasSize.canvasHeight !== 0) {
134
+ containerWidth = canvasSize.canvasWidth;
135
+ containerHeight = canvasSize.canvasHeight;
136
+ }
137
+ let imgContainerWidth = containerWidth;
138
+ let imgContainerHeight = containerHeight;
139
+ if (this.wrcWindowMode) {
140
+ imgContainerWidth = containerWidth * this.dpr;
141
+ imgContainerHeight = containerHeight * this.dpr;
142
+ }
143
+ const context = getCanvas2dCtx(this.screenShotContainer, containerWidth, containerHeight);
144
+ const imgContext = getCanvas2dCtx(this.screenShotImageController, imgContainerWidth, imgContainerHeight);
145
+ if (context == null || imgContext == null) return;
146
+ // 赋值截图区域canvas画布
147
+ this.screenShotCanvas = context;
148
+ const { videoWidth, videoHeight } = this.videoController;
149
+ if (this.wrcWindowMode) {
150
+ // 从窗口视频流中获取body内容
151
+ const bodyImgData = this.getWindowContentData(videoWidth, videoHeight, containerWidth * this.dpr, containerHeight * this.dpr);
152
+ if (bodyImgData == null) return;
153
+ // 将body内容绘制到图片容器里
154
+ imgContext.putImageData(bodyImgData, 0, 0);
155
+ } else {
156
+ var // console.log("对视频容器的内容进行裁剪", {
157
+ // wrcImgPosition: this.wrcImgPosition,
158
+ // containerWidth,
159
+ // containerHeight,
160
+ // videoWidth,
161
+ // videoHeight,
162
+ // fixWidth,
163
+ // fixHeight
164
+ // });
165
+ _imgContext;
166
+ // 对webrtc源提供的图像宽高进行修复
167
+ let fixWidth = containerWidth;
168
+ let fixHeight = videoHeight * containerWidth / videoWidth;
169
+ if (fixHeight > containerHeight) {
170
+ fixWidth = containerWidth * containerHeight / fixHeight;
171
+ fixHeight = containerHeight;
172
+ }
173
+ // 对视频容器的内容进行裁剪
174
+ fixWidth = this.wrcImgPosition.w > 0 ? this.wrcImgPosition.w : fixWidth;
175
+ fixHeight = this.wrcImgPosition.h > 0 ? this.wrcImgPosition.h : fixHeight;
176
+ (_imgContext = imgContext) === null || _imgContext === void 0 ? void 0 : _imgContext.drawImage(this.videoController, this.wrcImgPosition.x, this.wrcImgPosition.y, fixWidth, fixHeight);
177
+ // // 要保存的字符串
178
+ // const stringData = imgContext.canvas.toDataURL("png");
179
+ // // dada 表示要转换的字符串数据,type 表示要转换的数据格式
180
+ // const blob = new Blob([stringData], {
181
+ // type: "text/plain;charset=utf-8"
182
+ // });
183
+ // // 根据 blob生成 url链接
184
+ // const objectURL = URL.createObjectURL(blob);
185
+ // // 创建一个 a 标签Tag
186
+ // const aTag = document.createElement("a");
187
+ // // 设置文件的下载地址
188
+ // aTag.href = objectURL;
189
+ // // 设置保存后的文件名称
190
+ // aTag.download = `${new Date().getTime()}.txt`;
191
+ // // 给 a 标签添加点击事件
192
+ // aTag.click();
193
+ // // 释放一个之前已经存在的、通过调用 URL.createObjectURL() 创建的 URL 对象。
194
+ // // 当你结束使用某个 URL 对象之后,应该通过调用这个方法来让浏览器知道不用在内存中继续保留对这个文件的引用了。
195
+ // URL.revokeObjectURL(objectURL);
196
+ // 隐藏滚动条会出现部分内容未截取到,需要进行修复
197
+ const diffHeight = containerHeight - fixHeight;
198
+ if (this.hiddenScrollBar.state && diffHeight > 0 && this.hiddenScrollBar.fillState) {
199
+ console.log("填充容器的剩余部分");
200
+ // 填充容器的剩余部分
201
+ imgContext.beginPath();
202
+ let fillWidth = containerWidth;
203
+ let fillHeight = diffHeight;
204
+ if (this.hiddenScrollBar.fillWidth > 0) {
205
+ fillWidth = this.hiddenScrollBar.fillWidth;
206
+ }
207
+ if (this.hiddenScrollBar.fillHeight > 0) {
208
+ fillHeight = this.hiddenScrollBar.fillHeight;
209
+ }
210
+ imgContext.rect(0, fixHeight, fillWidth, fillHeight);
211
+ imgContext.fillStyle = this.hiddenScrollBar.color;
212
+ imgContext.fill();
213
+ }
214
+ }
215
+ // 初始化截图容器
216
+ this.initScreenShot(undefined, context, this.screenShotImageController);
217
+ let displaySurface = null;
218
+ let displayLabel = null;
219
+ if (this.captureStream) {
220
+ var _this_captureStream_getVideoTracks__getSettings;
221
+ // 获取当前选择的窗口类型
222
+ displaySurface = (_this_captureStream_getVideoTracks__getSettings = this.captureStream.getVideoTracks()[0].getSettings()) === null || _this_captureStream_getVideoTracks__getSettings === void 0 ? void 0 : _this_captureStream_getVideoTracks__getSettings.displaySurface;
223
+ // 获取当前选择的标签页标识
224
+ displayLabel = this.captureStream.getVideoTracks()[0].label;
225
+ }
226
+ // 执行截图成功回调
227
+ if (triggerCallback) {
228
+ triggerCallback({
229
+ code: 0,
230
+ msg: "截图加载完成",
231
+ displaySurface,
232
+ displayLabel
233
+ });
234
+ }
235
+ // 停止捕捉屏幕
236
+ this.stopCapture();
237
+ // 重置光标状态
238
+ document.body.classList.remove("no-cursor");
239
+ }, this.wrcReplyTime);
240
+ }
241
+ // 调整插件容器层级
242
+ adjustContainerLevels(level) {
243
+ if (this.screenShotContainer == null || this.toolController == null || this.textInputController == null || this.optionIcoController == null || this.optionController == null || // this.cutBoxSizeContainer == null ||
244
+ level <= 0) {
245
+ return;
246
+ }
247
+ this.screenShotContainer.style.zIndex = `${level}`;
248
+ this.toolController.style.zIndex = `${level + 1}`;
249
+ this.textInputController.style.zIndex = `${level + 1}`;
250
+ this.optionIcoController.style.zIndex = `${level + 1}`;
251
+ this.optionController.style.zIndex = `${level + 1}`;
252
+ // this.cutBoxSizeContainer.style.zIndex = `${level + 1}`;
253
+ }
254
+ // 初始化裁剪框
255
+ initCropBox(cropBoxInfo) {
256
+ const startX = cropBoxInfo.x;
257
+ const startY = cropBoxInfo.y;
258
+ const width = cropBoxInfo.w;
259
+ const height = cropBoxInfo.h;
260
+ if (this.screenShotContainer == null) return;
261
+ this.drawGraphPosition = {
262
+ startX,
263
+ startY,
264
+ width,
265
+ height
266
+ };
267
+ this.data.setCutOutBoxPosition(startX, startY, width, height);
268
+ drawCutOutBox(startX, startY, width, height, this.screenShotCanvas, this.data.getBorderSize(), this.screenShotContainer, this.screenShotImageController);
269
+ // 保存边框节点信息
270
+ this.cutOutBoxBorderArr = saveBorderArrInfo(this.data.getBorderSize(), this.drawGraphPosition);
271
+ // 修改鼠标状态为拖动
272
+ this.screenShotContainer.style.cursor = "move";
273
+ // 显示截图工具栏
274
+ // this.data.setToolStatus(true);
275
+ // // 显示裁剪框尺寸显示容器
276
+ // this.data.setCutBoxSizeStatus(true);
277
+ if (this.toolController != null) {
278
+ // 渲染截图工具栏
279
+ this.showToolBar();
280
+ }
281
+ }
282
+ /**
283
+ * 从窗口数据流中截取页面body内容
284
+ * @param videoWidth 窗口宽度
285
+ * @param videoHeight 窗口高度
286
+ * @param containerWidth body内容宽度
287
+ * @param containerHeight body内容高度
288
+ * @private
289
+ */ getWindowContentData(videoWidth, videoHeight, containerWidth, containerHeight) {
290
+ const videoCanvas = document.createElement("canvas");
291
+ videoCanvas.width = videoWidth;
292
+ videoCanvas.height = videoHeight;
293
+ const videoContext = getCanvas2dCtx(videoCanvas, videoWidth, videoHeight);
294
+ if (videoContext) {
295
+ videoContext.drawImage(this.videoController, 0, 0);
296
+ const startX = 0;
297
+ const startY = videoHeight - containerHeight;
298
+ const width = containerWidth;
299
+ const height = videoHeight - startY;
300
+ // 获取裁剪框区域图片信息;
301
+ return videoContext.getImageData(startX * this.dpr, startY * this.dpr, width * this.dpr, height * this.dpr);
302
+ }
303
+ return null;
304
+ }
305
+ // 为指定容器绑定快捷键
306
+ registerContainerShortcuts(container) {
307
+ container.addEventListener("keydown", (event)=>{
308
+ if (this.screenShotCanvas == null) return;
309
+ // command/ctrl + enter 将输入框的文字绘制到画布内
310
+ // 按下ESC时如果有内容则绘制
311
+ if ((event.metaKey || event.ctrlKey) && event.code === "Enter" || event.code === "Escape") {
312
+ this.data.setTextEditState(true);
313
+ const text = container.innerText;
314
+ if (!text || text === "") {
315
+ // 隐藏输入框
316
+ this.data.setTextStatus(false);
317
+ return;
318
+ }
319
+ drawText(text, this.textInputPosition.mouseX, this.textInputPosition.mouseY, this.data.getSelectedColor(), this.data.getFontSize(), this.screenShotCanvas);
320
+ // 清空文本输入区域的内容
321
+ container.innerHTML = "";
322
+ // 隐藏输入框
323
+ this.data.setTextStatus(false);
324
+ // 保存绘制记录
325
+ addHistory();
326
+ }
327
+ });
328
+ }
329
+ showToolBar() {
330
+ if (this.toolController == null || this.screenShotContainer == null) return;
331
+ // 计算截图工具栏位置
332
+ const toolLocation = calculateToolLocation(this.drawGraphPosition, this.toolController.offsetWidth, this.screenShotContainer.width / this.dpr, this.placement, this.position);
333
+ const containerHeight = this.screenShotContainer.height / this.dpr;
334
+ // 工具栏的位置超出截图容器时,调整工具栏位置防止超出
335
+ if (toolLocation.mouseY > containerHeight - 64) {
336
+ toolLocation.mouseY -= this.drawGraphPosition.height + 64;
337
+ // 超出屏幕顶部时
338
+ if (toolLocation.mouseY < 0) {
339
+ const containerHeight = parseInt(this.screenShotContainer.style.height);
340
+ toolLocation.mouseY = containerHeight - this.fullScreenDiffHeight;
341
+ }
342
+ // 设置工具栏超出状态为true
343
+ this.data.setToolPositionStatus(true);
344
+ // // 隐藏裁剪框尺寸显示容器
345
+ // this.data.setCutBoxSizeStatus(false);
346
+ }
347
+ // 当前截取的是全屏,则修改工具栏的位置到截图容器最底部,防止超出
348
+ if (this.getFullScreenStatus) {
349
+ const containerHeight = parseInt(this.screenShotContainer.style.height);
350
+ // 重新计算工具栏的x轴位置
351
+ const toolPositionX = (this.drawGraphPosition.width / this.dpr - this.toolController.offsetWidth) / 2;
352
+ toolLocation.mouseY = containerHeight - this.fullScreenDiffHeight;
353
+ toolLocation.mouseX = toolPositionX;
354
+ }
355
+ // 显示并设置截图工具栏位置
356
+ this.data.setToolInfo(toolLocation.mouseX + this.position.left, toolLocation.mouseY + this.position.top);
357
+ // // 设置裁剪框尺寸显示容器位置
358
+ // this.data.setCutBoxSizePosition(
359
+ // this.drawGraphPosition.startX,
360
+ // this.drawGraphPosition.startY - 35
361
+ // );
362
+ // // 渲染裁剪框尺寸
363
+ // this.data.setCutBoxSize(
364
+ // this.drawGraphPosition.width,
365
+ // this.drawGraphPosition.height
366
+ // );
367
+ // 状态重置
368
+ this.getFullScreenStatus = false;
369
+ }
370
+ setGlobalParameter() {
371
+ this.screenShotContainer = this.data.getScreenShotContainer();
372
+ this.toolController = this.data.getToolController();
373
+ this.textInputController = this.data.getTextInputController();
374
+ this.optionController = this.data.getOptionController();
375
+ this.optionIcoController = this.data.getOptionIcoController();
376
+ // this.cutBoxSizeContainer = this.data.getCutBoxSizeContainer() as HTMLDivElement | null;
377
+ }
378
+ setOptionalParameter(options) {
379
+ var _options, _options1, _options2, _options3, _options4, _options5, _options6, _options7, _options8, _options9, _options10, _options11, _options12, _options13, _options14;
380
+ // 单击截取全屏启用状态,默认为false
381
+ if (((_options = options) === null || _options === void 0 ? void 0 : _options.clickCutFullScreen) === true) {
382
+ this.clickCutFullScreen = true;
383
+ }
384
+ // 判断调用者是否传了截图进来
385
+ if (((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.imgSrc) != null) {
386
+ this.imgSrc = options.imgSrc;
387
+ }
388
+ // 是否加载跨域图片
389
+ if (((_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.loadCrossImg) === true) {
390
+ this.loadCrossImg = true;
391
+ }
392
+ // 跨域时的代理服务器地址
393
+ if ((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.proxyUrl) {
394
+ this.proxyUrl = options.proxyUrl;
395
+ }
396
+ if ((_options4 = options) === null || _options4 === void 0 ? void 0 : _options4.useCORS) {
397
+ this.useCORS = options.useCORS;
398
+ }
399
+ // 设置截图容器的位置信息
400
+ if (((_options5 = options) === null || _options5 === void 0 ? void 0 : _options5.position) != null) {
401
+ var _options_position, _options_position1;
402
+ if (((_options_position = options.position) === null || _options_position === void 0 ? void 0 : _options_position.top) != null) {
403
+ this.position.top = options.position.top;
404
+ }
405
+ if (((_options_position1 = options.position) === null || _options_position1 === void 0 ? void 0 : _options_position1.left) != null) {
406
+ this.position.left = options.position.left;
407
+ }
408
+ }
409
+ // 截图容器dom
410
+ if ((_options6 = options) === null || _options6 === void 0 ? void 0 : _options6.screenShotDom) {
411
+ this.screenShotDom = options.screenShotDom;
412
+ }
413
+ // webrtc截图等待时间
414
+ if ((_options7 = options) === null || _options7 === void 0 ? void 0 : _options7.wrcReplyTime) {
415
+ this.wrcReplyTime = options.wrcReplyTime;
416
+ }
417
+ // 是否初始化裁剪框
418
+ if ((_options8 = options) === null || _options8 === void 0 ? void 0 : _options8.cropBoxInfo) {
419
+ this.cropBoxInfo = options.cropBoxInfo;
420
+ }
421
+ // 是否需要更改工具栏的展示位置
422
+ if ((_options9 = options) === null || _options9 === void 0 ? void 0 : _options9.toolPosition) {
423
+ this.placement = options.toolPosition;
424
+ }
425
+ // 是否需要对webrtc模式下捕获到的内容进行裁剪
426
+ if ((_options10 = options) === null || _options10 === void 0 ? void 0 : _options10.wrcImgPosition) {
427
+ const { x, y } = options.wrcImgPosition;
428
+ // 坐标需要取负数才能正确的裁剪
429
+ this.wrcImgPosition.x = Math.abs(x) * -1;
430
+ this.wrcImgPosition.y = Math.abs(y) * -1;
431
+ }
432
+ // 是否隐藏滚动条
433
+ if (((_options11 = options) === null || _options11 === void 0 ? void 0 : _options11.hiddenScrollBar) != null) {
434
+ const { state, color, fillWidth, fillHeight, fillState } = options.hiddenScrollBar;
435
+ this.hiddenScrollBar = {
436
+ state,
437
+ color: color ? color : "#000000",
438
+ fillWidth: fillWidth ? fillWidth : 0,
439
+ fillHeight: fillHeight ? fillHeight : 0,
440
+ fillState: fillState ? fillState : false
441
+ };
442
+ if (state) {
443
+ this.data.setResetScrollbarState(true);
444
+ // 设置页面宽高并隐藏滚动条
445
+ document.documentElement.classList.add("hidden-screen-shot-scroll");
446
+ document.body.classList.add("hidden-screen-shot-scroll");
447
+ }
448
+ }
449
+ // 是否启用窗口截图模式
450
+ if (((_options12 = options) === null || _options12 === void 0 ? void 0 : _options12.wrcWindowMode) != null) {
451
+ this.wrcWindowMode = options.wrcWindowMode;
452
+ }
453
+ if (((_options13 = options) === null || _options13 === void 0 ? void 0 : _options13.curTabState) != null) {
454
+ this.curTabState = options.curTabState;
455
+ }
456
+ if (((_options14 = options) === null || _options14 === void 0 ? void 0 : _options14.customRightClickEvent) != null) {
457
+ this.customRightClickEvent = options.customRightClickEvent;
458
+ }
459
+ }
460
+ /**
461
+ * 操作裁剪框
462
+ * @param currentX 裁剪框当前x轴坐标
463
+ * @param currentY 裁剪框当前y轴坐标
464
+ * @param startX 鼠标x轴坐标
465
+ * @param startY 鼠标y轴坐标
466
+ * @param width 裁剪框宽度
467
+ * @param height 裁剪框高度
468
+ * @param context 需要进行绘制的canvas画布
469
+ * @private
470
+ */ operatingCutOutBox(currentX, currentY, startX, startY, width, height, context) {
471
+ // canvas元素不存在
472
+ if (this.screenShotContainer == null) {
473
+ return;
474
+ }
475
+ // 获取鼠标按下时的坐标
476
+ const { moveStartX, moveStartY } = this.movePosition;
477
+ // 裁剪框边框节点事件存在且裁剪框未进行操作,则对鼠标样式进行修改
478
+ if (this.cutOutBoxBorderArr.length > 0 && !this.data.getDraggingTrim()) {
479
+ // 标识鼠标是否在裁剪框内
480
+ let flag = false;
481
+ // 判断鼠标位置
482
+ context.beginPath();
483
+ for(let i = 0; i < this.cutOutBoxBorderArr.length; i++){
484
+ context.rect(this.cutOutBoxBorderArr[i].x, this.cutOutBoxBorderArr[i].y, this.cutOutBoxBorderArr[i].width, this.cutOutBoxBorderArr[i].height);
485
+ // 当前坐标点处于8个可操作点上,修改鼠标指针样式
486
+ if (context.isPointInPath(currentX * this.dpr, currentY * this.dpr)) {
487
+ switch(this.cutOutBoxBorderArr[i].index){
488
+ case 1:
489
+ if (this.data.getToolClickStatus()) {
490
+ // 修改截图容器内的鼠标样式
491
+ updateContainerMouseStyle(this.screenShotContainer, this.data.getActiveToolName());
492
+ } else {
493
+ this.screenShotContainer.style.cursor = "move";
494
+ }
495
+ break;
496
+ case 2:
497
+ // 工具栏被点击则不改变指针样式
498
+ if (this.data.getToolClickStatus()) break;
499
+ this.screenShotContainer.style.cursor = "ns-resize";
500
+ break;
501
+ case 3:
502
+ if (this.data.getToolClickStatus()) break;
503
+ this.screenShotContainer.style.cursor = "ew-resize";
504
+ break;
505
+ case 4:
506
+ if (this.data.getToolClickStatus()) break;
507
+ this.screenShotContainer.style.cursor = "nwse-resize";
508
+ break;
509
+ case 5:
510
+ if (this.data.getToolClickStatus()) break;
511
+ this.screenShotContainer.style.cursor = "nesw-resize";
512
+ break;
513
+ default:
514
+ break;
515
+ }
516
+ this.borderOption = this.cutOutBoxBorderArr[i].option;
517
+ flag = true;
518
+ break;
519
+ }
520
+ }
521
+ this.mouseInsideCropBox = flag;
522
+ context.closePath();
523
+ if (!flag) {
524
+ // 鼠标移出裁剪框重置鼠标样式
525
+ this.screenShotContainer.style.cursor = "default";
526
+ // 重置当前操作的边框节点为null
527
+ this.borderOption = null;
528
+ }
529
+ }
530
+ // 裁剪框正在被操作
531
+ if (this.data.getDraggingTrim()) {
532
+ // 当前操作节点为1时则为移动裁剪框
533
+ if (this.borderOption === 1) {
534
+ // 计算要移动的x轴坐标
535
+ let x = fixedData(currentX - (moveStartX - startX), width, this.screenShotContainer.width);
536
+ // 计算要移动的y轴坐标
537
+ let y = fixedData(currentY - (moveStartY - startY), height, this.screenShotContainer.height);
538
+ // 计算画布面积
539
+ const containerWidth = this.screenShotContainer.width / this.dpr;
540
+ const containerHeight = this.screenShotContainer.height / this.dpr;
541
+ // 计算裁剪框在画布上所占的面积
542
+ const cutOutBoxSizeX = x + width;
543
+ const cutOutBoxSizeY = y + height;
544
+ // 超出画布的可视区域,进行位置修正
545
+ if (cutOutBoxSizeX > containerWidth) {
546
+ x = containerWidth - width;
547
+ }
548
+ if (cutOutBoxSizeY > containerHeight) {
549
+ y = containerHeight - height;
550
+ }
551
+ // 重新绘制裁剪框
552
+ this.tempGraphPosition = drawCutOutBox(x, y, width, height, context, this.data.getBorderSize(), this.screenShotContainer, this.screenShotImageController);
553
+ } else {
554
+ // 裁剪框其他8个点的拖拽事件
555
+ const { tempStartX, tempStartY, tempWidth, tempHeight } = zoomCutOutBoxPosition(currentX, currentY, startX, startY, width, height, this.borderOption);
556
+ // 绘制裁剪框
557
+ this.tempGraphPosition = drawCutOutBox(tempStartX, tempStartY, tempWidth, tempHeight, context, this.data.getBorderSize(), this.screenShotContainer, this.screenShotImageController);
558
+ }
559
+ }
560
+ }
561
+ /**
562
+ * 显示最新的画布状态
563
+ * @private
564
+ */ showLastHistory() {
565
+ if (this.screenShotCanvas != null) {
566
+ const context = this.screenShotCanvas;
567
+ if (this.data.getHistory().length <= 0) {
568
+ addHistory();
569
+ }
570
+ context.putImageData(this.data.getHistory()[this.data.getHistory().length - 1]["data"], 0, 0);
571
+ }
572
+ }
573
+ // 为截图容器添加鼠标||触摸的事件监听
574
+ setScreenShotContainerEventListener() {
575
+ var // 设置触摸监听
576
+ _this_screenShotContainer, _this_screenShotContainer1, _this_screenShotContainer2;
577
+ if (isPC()) {
578
+ var // 添加鼠标事件监听
579
+ _this_screenShotContainer3, _this_screenShotContainer4, _this_screenShotContainer5;
580
+ (_this_screenShotContainer3 = this.screenShotContainer) === null || _this_screenShotContainer3 === void 0 ? void 0 : _this_screenShotContainer3.addEventListener("mousedown", this.mouseDownEvent);
581
+ (_this_screenShotContainer4 = this.screenShotContainer) === null || _this_screenShotContainer4 === void 0 ? void 0 : _this_screenShotContainer4.addEventListener("mousemove", this.mouseMoveEvent);
582
+ (_this_screenShotContainer5 = this.screenShotContainer) === null || _this_screenShotContainer5 === void 0 ? void 0 : _this_screenShotContainer5.addEventListener("mouseup", this.mouseUpEvent);
583
+ }
584
+ // 设备不支持触摸事件则退出
585
+ if (!isTouchDevice()) return;
586
+ (_this_screenShotContainer = this.screenShotContainer) === null || _this_screenShotContainer === void 0 ? void 0 : _this_screenShotContainer.addEventListener("touchstart", this.mouseDownEvent, false);
587
+ (_this_screenShotContainer1 = this.screenShotContainer) === null || _this_screenShotContainer1 === void 0 ? void 0 : _this_screenShotContainer1.addEventListener("touchmove", this.mouseMoveEvent, false);
588
+ (_this_screenShotContainer2 = this.screenShotContainer) === null || _this_screenShotContainer2 === void 0 ? void 0 : _this_screenShotContainer2.addEventListener("touchend", this.mouseUpEvent, false);
589
+ }
590
+ /**
591
+ * 向截图容器中绘制图片
592
+ * @param triggerCallback
593
+ * @param context
594
+ * @param imgSrc
595
+ * @private
596
+ */ drawPictures(triggerCallback, context, imgSrc) {
597
+ const imgContainer = new Image();
598
+ imgContainer.src = imgSrc;
599
+ imgContainer.width = this.screenShotImageController.width;
600
+ imgContainer.height = this.screenShotImageController.height;
601
+ imgContainer.crossOrigin = "Anonymous";
602
+ imgContainer.onload = ()=>{
603
+ var // 将用户传递的图片绘制到图片容器里
604
+ _this_screenShotImageController_getContext;
605
+ // 装载截图的dom为null则退出
606
+ if (this.screenShotContainer == null) return;
607
+ (_this_screenShotImageController_getContext = this.screenShotImageController.getContext("2d")) === null || _this_screenShotImageController_getContext === void 0 ? void 0 : _this_screenShotImageController_getContext.drawImage(imgContainer, 0, 0, this.screenShotImageController.width, this.screenShotImageController.height);
608
+ // 初始化截图容器
609
+ this.initScreenShot(triggerCallback, context, this.screenShotImageController);
610
+ };
611
+ }
612
+ /**
613
+ * 初始化截图容器
614
+ * @param triggerCallback
615
+ * @param context
616
+ * @param screenShotContainer
617
+ * @private
618
+ */ initScreenShot(triggerCallback, context, screenShotContainer) {
619
+ if (triggerCallback != null) {
620
+ // 加载成功,执行回调函数
621
+ triggerCallback({
622
+ code: 0,
623
+ msg: "截图加载完成"
624
+ });
625
+ }
626
+ // 赋值截图区域canvas画布
627
+ this.screenShotCanvas = context;
628
+ // 存储屏幕截图
629
+ this.data.setScreenShotImageController(screenShotContainer);
630
+ // 绘制蒙层
631
+ drawMasking(context, screenShotContainer);
632
+ // 截图容器添加鼠标点击/触摸事件的监听
633
+ this.setScreenShotContainerEventListener();
634
+ // 是否初始化裁剪框
635
+ if (this.cropBoxInfo != null && Object.keys(this.cropBoxInfo).length == 4) {
636
+ this.initCropBox(this.cropBoxInfo);
637
+ }
638
+ }
639
+ constructor(options){
640
+ var _options, _options1, _options2, _options3;
641
+ // 当前实例的响应式data数据
642
+ _define_property(this, "data", void 0);
643
+ // video容器用于存放屏幕MediaStream流
644
+ _define_property(this, "videoController", void 0);
645
+ // 截图区域canvas容器
646
+ _define_property(this, "screenShotContainer", void 0);
647
+ _define_property(this, "screenShotDom", null);
648
+ // 截图工具栏dom
649
+ _define_property(this, "toolController", void 0);
650
+ // 截图图片存放容器
651
+ _define_property(this, "screenShotImageController", void 0);
652
+ // 截图区域画布
653
+ _define_property(this, "screenShotCanvas", void 0);
654
+ // 文本区域dom
655
+ _define_property(this, "textInputController", void 0);
656
+ // 截图工具栏画笔选项dom
657
+ _define_property(this, "optionController", void 0);
658
+ _define_property(this, "optionIcoController", void 0);
659
+ // private cutBoxSizeContainer: HTMLDivElement | null | undefined;
660
+ _define_property(this, "plugInParameters", void 0);
661
+ _define_property(this, "wrcReplyTime", 500);
662
+ _define_property(this, "keyboardEventHandle", null);
663
+ // 图形位置参数
664
+ _define_property(this, "drawGraphPosition", {
665
+ startX: 0,
666
+ startY: 0,
667
+ width: 0,
668
+ height: 0
669
+ });
670
+ // 临时图形位置参数
671
+ _define_property(this, "tempGraphPosition", {
672
+ startX: 0,
673
+ startY: 0,
674
+ width: 0,
675
+ height: 0
676
+ });
677
+ _define_property(this, "wrcImgPosition", {
678
+ x: 0,
679
+ y: 0,
680
+ w: 0,
681
+ h: 0
682
+ });
683
+ // 是否隐藏页面滚动条
684
+ _define_property(this, "hiddenScrollBar", {
685
+ color: "#000000",
686
+ fillState: false,
687
+ state: false,
688
+ fillWidth: 0,
689
+ fillHeight: 0
690
+ });
691
+ _define_property(this, "wrcWindowMode", false);
692
+ _define_property(this, "curTabState", true);
693
+ // 裁剪框边框节点坐标事件
694
+ _define_property(this, "cutOutBoxBorderArr", []);
695
+ // 当前操作的边框节点
696
+ _define_property(this, "borderOption", null);
697
+ // 点击裁剪框时的鼠标坐标
698
+ _define_property(this, "movePosition", {
699
+ moveStartX: 0,
700
+ moveStartY: 0
701
+ });
702
+ // 鼠标拖动状态
703
+ _define_property(this, "dragFlag", false);
704
+ // 单击截取屏启用状态
705
+ _define_property(this, "clickCutFullScreen", false);
706
+ // 全屏截取状态
707
+ _define_property(this, "getFullScreenStatus", false);
708
+ // 上一个裁剪框坐标信息
709
+ _define_property(this, "drawGraphPrevX", 0);
710
+ _define_property(this, "drawGraphPrevY", 0);
711
+ // 马赛克涂抹区域大小
712
+ _define_property(this, "degreeOfBlur", 5);
713
+ _define_property(this, "dpr", window.devicePixelRatio || 1);
714
+ // 截全屏时工具栏展示的位置要减去的高度
715
+ _define_property(this, "fullScreenDiffHeight", 60);
716
+ // 截图容器位置信息
717
+ _define_property(this, "position", {
718
+ left: 0,
719
+ top: 0
720
+ });
721
+ _define_property(this, "imgSrc", null);
722
+ _define_property(this, "loadCrossImg", false);
723
+ // 鼠标是否在裁剪框内
724
+ _define_property(this, "mouseInsideCropBox", false);
725
+ _define_property(this, "proxyUrl", undefined);
726
+ _define_property(this, "useCORS", false);
727
+ _define_property(this, "drawStatus", false);
728
+ // webrtc模式下的屏幕流数据
729
+ _define_property(this, "captureStream", null);
730
+ _define_property(this, "cropBoxInfo", null);
731
+ // 文本输入框位置
732
+ _define_property(this, "textInputPosition", {
733
+ mouseX: 0,
734
+ mouseY: 0
735
+ });
736
+ // 工具栏显示位置
737
+ _define_property(this, "placement", "center");
738
+ // 递增变粗箭头的实现
739
+ _define_property(this, "drawArrow", new DrawArrow());
740
+ _define_property(this, "customRightClickEvent", {
741
+ state: false
742
+ });
743
+ _define_property(this, "sendStream", (stream, cancelCallback, triggerCallback)=>{
744
+ if (stream instanceof MediaStream) {
745
+ this.videoController.srcObject = stream;
746
+ this.loadScreenFlowData(triggerCallback);
747
+ } else {
748
+ if (cancelCallback != null) {
749
+ cancelCallback({
750
+ code: -1,
751
+ msg: "视频流接入失败"
752
+ });
753
+ }
754
+ // 销毁截图组件
755
+ this.data.destroyDOM();
756
+ throw `视频流接入失败`;
757
+ }
758
+ return stream;
759
+ });
760
+ // 开始捕捉屏幕
761
+ _define_property(this, "startCapture", async (cancelCallback)=>{
762
+ let captureStream = null;
763
+ let mediaWidth = this.screenShotImageController.width * this.dpr;
764
+ let mediaHeight = this.screenShotImageController.height * this.dpr;
765
+ // let curTabState = this.curTabState;
766
+ let displayConfig = {};
767
+ // 窗口模式启用时则
768
+ if (this.wrcWindowMode) {
769
+ mediaWidth = window.screen.width * this.dpr;
770
+ mediaHeight = window.screen.height * this.dpr;
771
+ // curTabState = true;
772
+ displayConfig = {
773
+ displaySurface: "window"
774
+ };
775
+ }
776
+ try {
777
+ // console.log("开始捕捉屏幕", { mediaWidth, mediaHeight });
778
+ // 捕获屏幕
779
+ captureStream = await navigator.mediaDevices.getDisplayMedia({
780
+ audio: false,
781
+ video: _object_spread({
782
+ width: mediaWidth,
783
+ height: mediaHeight
784
+ }, displayConfig),
785
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
786
+ // @ts-ignore
787
+ // 当前标签页默认true true:不需要选择 false:需要自己选择
788
+ preferCurrentTab: this.curTabState
789
+ });
790
+ // 将MediaStream输出至video标签
791
+ this.videoController.srcObject = captureStream;
792
+ // 储存屏幕流数据
793
+ this.captureStream = captureStream;
794
+ } catch (err) {
795
+ if (cancelCallback != null) {
796
+ cancelCallback({
797
+ code: -1,
798
+ msg: "浏览器不支持webrtc或者用户未授权",
799
+ errorInfo: err
800
+ });
801
+ }
802
+ // 销毁截图组件
803
+ this.data.destroyDOM();
804
+ throw `浏览器不支持webrtc或者用户未授权( ${err} )`;
805
+ }
806
+ return captureStream;
807
+ });
808
+ // 停止捕捉屏幕
809
+ _define_property(this, "stopCapture", ()=>{
810
+ const srcObject = this.videoController.srcObject;
811
+ if (srcObject && "getTracks" in srcObject) {
812
+ const tracks = srcObject.getTracks();
813
+ tracks.forEach((track)=>track.stop());
814
+ this.videoController.srcObject = null;
815
+ }
816
+ });
817
+ // 截屏
818
+ _define_property(this, "screenShot", (cancelCallback, triggerCallback)=>{
819
+ // 开始捕捉屏幕
820
+ this.startCapture(cancelCallback).then(()=>{
821
+ this.loadScreenFlowData(triggerCallback);
822
+ });
823
+ });
824
+ // 鼠标按下事件
825
+ _define_property(this, "mouseDownEvent", (event)=>{
826
+ // 隐藏颜色选择面板
827
+ this.data.setColorPanelStatus(false);
828
+ // 隐藏文字大小选择面板
829
+ this.data.setTextSizeOptionStatus(false);
830
+ // 非鼠标左键按下则终止
831
+ if (event instanceof MouseEvent && event.button != 0) return;
832
+ // 当前处于移动端触摸时,需要在按下时判断当前坐标点是否处于裁剪框内,主动更新draggingTrim状态(移动端的move事件只会在按下时才会触发)
833
+ if (isTouchDevice() && event instanceof TouchEvent && this.screenShotCanvas) {
834
+ this.operatingCutOutBox(event.touches[0].pageX, event.touches[0].pageY, this.tempGraphPosition.startX, this.tempGraphPosition.startY, this.tempGraphPosition.width, this.tempGraphPosition.height, this.screenShotCanvas);
835
+ }
836
+ // 当前操作的是撤销
837
+ if (this.data.getToolName() == "undo") return;
838
+ this.data.setDragging(true);
839
+ this.drawStatus = false;
840
+ // 重置工具栏超出状态
841
+ this.data.setToolPositionStatus(false);
842
+ const mouseX = nonNegativeData(event instanceof MouseEvent ? event.offsetX : event.touches[0].pageX);
843
+ const mouseY = nonNegativeData(event instanceof MouseEvent ? event.offsetY : event.touches[0].pageY);
844
+ // 如果当前操作的是截图工具栏
845
+ if (this.data.getToolClickStatus()) {
846
+ // 记录当前鼠标开始坐标
847
+ this.drawGraphPosition.startX = mouseX;
848
+ this.drawGraphPosition.startY = mouseY;
849
+ }
850
+ // 当前操作的是画笔
851
+ if (this.data.getToolName() == "brush" && this.screenShotCanvas) {
852
+ // 初始化画笔
853
+ initPencil(this.screenShotCanvas, mouseX, mouseY);
854
+ }
855
+ // 当前操作的文本
856
+ if (this.data.getToolName() == "text" && this.textInputController && this.screenShotContainer && this.screenShotCanvas) {
857
+ if (!this.mouseInsideCropBox) {
858
+ return;
859
+ }
860
+ // 显示文本输入区域
861
+ this.data.setTextStatus(true);
862
+ // 判断输入框位置是否变化
863
+ if (this.textInputPosition.mouseX != 0 && this.textInputPosition.mouseY != 0 && this.textInputPosition.mouseX != mouseX && this.textInputPosition.mouseY != mouseY) {
864
+ drawText(this.textInputController.innerText, this.textInputPosition.mouseX, this.textInputPosition.mouseY, this.data.getSelectedColor(), this.data.getFontSize(), this.screenShotCanvas);
865
+ // 输入框内容不为空时则隐藏
866
+ if (this.textInputController.innerText !== "") {
867
+ // 隐藏输入框
868
+ this.data.setTextStatus(false);
869
+ }
870
+ // 清空文本输入区域的内容
871
+ this.textInputController.innerHTML = "";
872
+ // 保存绘制记录
873
+ addHistory();
874
+ }
875
+ // 计算文本框显示位置, 需要加上截图容器的位置信息
876
+ const textMouseX = mouseX + this.position.left;
877
+ // 设置文本框位置等信息
878
+ this.textInputController.style.left = textMouseX + "px";
879
+ this.textInputController.style.fontSize = this.data.getFontSize() + "px";
880
+ this.textInputController.style.fontFamily = "none";
881
+ this.textInputController.style.color = this.data.getSelectedColor();
882
+ // 部分操作需要等dom渲染完毕执行
883
+ setTimeout(()=>{
884
+ if (this.textInputController) {
885
+ // 获取输入框容器的高度
886
+ const containerHeight = this.textInputController.offsetHeight;
887
+ // 输入框容器y轴的位置需要在坐标的基础上再加上容器高度的一半,容器的位置就正好居中于光标
888
+ // canvas渲染的时候就不会出现位置不一致的问题了
889
+ const textMouseY = mouseY - Math.floor(containerHeight / 2) + this.position.top;
890
+ this.textInputController.style.top = textMouseY + "px";
891
+ // 获取焦点
892
+ this.textInputController.focus();
893
+ // 记录当前输入框位置
894
+ this.textInputPosition = {
895
+ mouseX: mouseX,
896
+ mouseY: mouseY
897
+ };
898
+ this.data.setTextInfo({
899
+ positionX: mouseX,
900
+ positionY: mouseY,
901
+ color: this.data.getSelectedColor(),
902
+ size: this.data.getFontSize()
903
+ });
904
+ }
905
+ });
906
+ }
907
+ // 如果操作的是裁剪框
908
+ if (this.borderOption) {
909
+ // 设置为拖动状态
910
+ this.data.setDraggingTrim(true);
911
+ // 记录移动时的起始点坐标
912
+ this.movePosition.moveStartX = mouseX;
913
+ this.movePosition.moveStartY = mouseY;
914
+ } else {
915
+ // 保存当前裁剪框的坐标
916
+ this.drawGraphPrevX = this.drawGraphPosition.startX;
917
+ this.drawGraphPrevY = this.drawGraphPosition.startY;
918
+ // 绘制裁剪框,记录当前鼠标开始坐标
919
+ this.drawGraphPosition.startX = mouseX;
920
+ this.drawGraphPosition.startY = mouseY;
921
+ }
922
+ });
923
+ // 鼠标移动事件
924
+ _define_property(this, "mouseMoveEvent", (event)=>{
925
+ if (this.screenShotCanvas == null || this.screenShotContainer == null || this.data.getToolName() == "undo") {
926
+ return;
927
+ }
928
+ // 去除默认事件
929
+ event.preventDefault();
930
+ // 工具栏未选择且鼠标处于按下状态时
931
+ if (!this.data.getToolClickStatus() && this.data.getDragging()) {
932
+ // 修改拖动状态为true;
933
+ this.dragFlag = true;
934
+ // 隐藏截图工具栏
935
+ // this.data.setToolStatus(false);
936
+ // 隐藏裁剪框尺寸显示容器
937
+ // this.data.setCutBoxSizeStatus(false);
938
+ }
939
+ // 获取当前绘制中的工具位置信息
940
+ const { startX, startY, width, height } = this.drawGraphPosition;
941
+ // 获取当前鼠标坐标
942
+ const currentX = nonNegativeData(event instanceof MouseEvent ? event.offsetX : event.touches[0].pageX);
943
+ const currentY = nonNegativeData(event instanceof MouseEvent ? event.offsetY : event.touches[0].pageY);
944
+ // 绘制中工具的临时宽高
945
+ const tempWidth = currentX - startX;
946
+ const tempHeight = currentY - startY;
947
+ // 工具栏绘制
948
+ if (this.data.getToolClickStatus() && this.data.getDragging()) {
949
+ // 获取裁剪框位置信息
950
+ const cutBoxPosition = this.data.getCutOutBoxPosition();
951
+ // 绘制中工具的起始x、y坐标不能小于裁剪框的起始坐标
952
+ // 绘制中工具的起始x、y坐标不能大于裁剪框的结束标作
953
+ // 当前鼠标的x坐标不能小于裁剪框起始x坐标,不能大于裁剪框的结束坐标
954
+ // 当前鼠标的y坐标不能小于裁剪框起始y坐标,不能大于裁剪框的结束坐标
955
+ if (!getDrawBoundaryStatus(startX, startY, cutBoxPosition) || !getDrawBoundaryStatus(currentX, currentY, cutBoxPosition)) return;
956
+ // 当前操作的不是马赛克则显示最后一次画布绘制时的状态
957
+ if (this.data.getToolName() != "mosaicPen") {
958
+ this.showLastHistory();
959
+ this.drawStatus = true;
960
+ }
961
+ switch(this.data.getToolName()){
962
+ case "square":
963
+ drawRectangle(startX, startY, tempWidth, tempHeight, this.data.getSelectedColor(), this.data.getPenSize(), this.screenShotCanvas);
964
+ break;
965
+ case "round":
966
+ drawCircle(this.screenShotCanvas, currentX, currentY, startX, startY, this.data.getPenSize(), this.data.getSelectedColor());
967
+ break;
968
+ case "right-top":
969
+ // 绘制等比例箭头
970
+ if (this.plugInParameters.getRatioArrow()) {
971
+ drawLineArrow(this.screenShotCanvas, startX, startY, currentX, currentY, 30, 10, this.data.getPenSize(), this.data.getSelectedColor());
972
+ return;
973
+ }
974
+ this.drawArrow.draw(this.screenShotCanvas, startX, startY, currentX, currentY, this.data.getSelectedColor(), this.data.getPenSize());
975
+ break;
976
+ case "brush":
977
+ // 画笔绘制
978
+ drawPencil(this.screenShotCanvas, currentX, currentY, this.data.getPenSize(), this.data.getSelectedColor());
979
+ break;
980
+ case "mosaicPen":
981
+ // 当前为马赛克工具则修改绘制状态
982
+ // 前面做了判断,此处需要特殊处理
983
+ if (!this.drawStatus) {
984
+ this.showLastHistory();
985
+ this.drawStatus = true;
986
+ }
987
+ // 绘制马赛克,为了确保鼠标位置在绘制区域中间,所以对x、y坐标进行-10处理
988
+ drawMosaic(currentX - 10, currentY - 10, this.data.getMosaicPenSize(), this.degreeOfBlur, this.screenShotCanvas);
989
+ break;
990
+ default:
991
+ break;
992
+ }
993
+ return;
994
+ }
995
+ // 执行裁剪框操作函数
996
+ this.operatingCutOutBox(currentX, currentY, startX, startY, width, height, this.screenShotCanvas);
997
+ // 如果鼠标未点击或者当前操作的是裁剪框都return
998
+ if (!this.data.getDragging() || this.data.getDraggingTrim()) return;
999
+ // 绘制裁剪框
1000
+ this.tempGraphPosition = drawCutOutBox(startX, startY, tempWidth, tempHeight, this.screenShotCanvas, this.data.getBorderSize(), this.screenShotContainer, this.screenShotImageController);
1001
+ });
1002
+ // 鼠标抬起事件
1003
+ _define_property(this, "mouseUpEvent", ()=>{
1004
+ // 当前操作的是撤销
1005
+ if (this.data.getToolName() == "undo") return;
1006
+ // 绘制结束
1007
+ this.data.setDragging(false);
1008
+ this.data.setDraggingTrim(false);
1009
+ // 截图容器判空
1010
+ if (this.screenShotCanvas == null || this.screenShotContainer == null) {
1011
+ return;
1012
+ }
1013
+ // 工具栏未点击且鼠标未拖动且单击截屏状态为false则复原裁剪框位置
1014
+ if (!this.data.getToolClickStatus() && !this.dragFlag && !this.clickCutFullScreen) {
1015
+ // 复原裁剪框的坐标
1016
+ this.drawGraphPosition.startX = this.drawGraphPrevX;
1017
+ this.drawGraphPosition.startY = this.drawGraphPrevY;
1018
+ return;
1019
+ }
1020
+ // 调用者尚未拖拽生成选区
1021
+ // 鼠标尚未拖动
1022
+ // 单击截取屏幕状态为true
1023
+ // 则截取整个屏幕
1024
+ const cutBoxPosition = this.data.getCutOutBoxPosition();
1025
+ if (cutBoxPosition.width === 0 && cutBoxPosition.height === 0 && cutBoxPosition.startX === 0 && cutBoxPosition.startY === 0 && !this.dragFlag && this.clickCutFullScreen) {
1026
+ const borderSize = this.data.getBorderSize();
1027
+ this.getFullScreenStatus = true;
1028
+ // 设置裁剪框位置为全屏
1029
+ this.tempGraphPosition = drawCutOutBox(0, 0, this.screenShotContainer.width - borderSize / 2, this.screenShotContainer.height - borderSize / 2, this.screenShotCanvas, borderSize, this.screenShotContainer, this.screenShotImageController);
1030
+ }
1031
+ if (this.screenShotContainer == null || this.screenShotCanvas == null) {
1032
+ return;
1033
+ }
1034
+ // 工具栏已点击且进行了绘制
1035
+ if (this.data.getToolClickStatus() && this.drawStatus) {
1036
+ // 保存绘制记录
1037
+ addHistory();
1038
+ return;
1039
+ } else if (this.data.getToolClickStatus() && !this.drawStatus) {
1040
+ // 工具栏点击了但尚未进行绘制
1041
+ return;
1042
+ }
1043
+ // 保存绘制后的图形位置信息
1044
+ this.drawGraphPosition = this.tempGraphPosition;
1045
+ // 如果工具栏未点击则保存裁剪框位置
1046
+ if (!this.data.getToolClickStatus()) {
1047
+ const { startX, startY, width, height } = this.drawGraphPosition;
1048
+ this.data.setCutOutBoxPosition(startX, startY, width, height);
1049
+ }
1050
+ // 保存边框节点信息
1051
+ this.cutOutBoxBorderArr = saveBorderArrInfo(this.data.getBorderSize(), this.drawGraphPosition);
1052
+ // 鼠标按下且拖动时重新渲染工具栏
1053
+ if (this.screenShotContainer != null && this.dragFlag || this.clickCutFullScreen) {
1054
+ // 修改鼠标状态为拖动
1055
+ this.screenShotContainer.style.cursor = "move";
1056
+ // 显示截图工具栏
1057
+ // this.data.setToolStatus(true);
1058
+ // // 显示裁剪框尺寸显示容器
1059
+ // this.data.setCutBoxSizeStatus(true);
1060
+ // 复原拖动状态
1061
+ this.dragFlag = false;
1062
+ if (this.toolController != null) {
1063
+ this.showToolBar();
1064
+ }
1065
+ }
1066
+ });
1067
+ this.plugInParameters = new PlugInParameters();
1068
+ // 提取options中的有用参数设置到全局参数中
1069
+ setPlugInParameters(options);
1070
+ // 创建截图所需dom并设置回调函数
1071
+ new CreateDom(options);
1072
+ // 创建并获取webrtc模式所需要的辅助dom
1073
+ this.videoController = document.createElement("video");
1074
+ this.videoController.autoplay = true;
1075
+ this.screenShotImageController = document.createElement("canvas");
1076
+ // 实例化响应式data
1077
+ this.data = new InitData();
1078
+ // 设置插件的可选参数
1079
+ this.setOptionalParameter(options);
1080
+ // 获取截图区域canvas容器(获取的同时也会为InitData中的全局变量赋值)
1081
+ this.setGlobalParameter();
1082
+ // 修改截图容器可滚动状态
1083
+ this.data.setNoScrollStatus((_options = options) === null || _options === void 0 ? void 0 : _options.noScroll);
1084
+ // 加载截图组件
1085
+ this.load((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.triggerCallback, (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.cancelCallback);
1086
+ if (this.toolController == null || this.screenShotContainer == null || this.textInputController == null) {
1087
+ return;
1088
+ }
1089
+ // 截图组件加载完毕后,对层级进行调整
1090
+ this.adjustContainerLevels(((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.level) ? options.level : 0);
1091
+ // 创建键盘事件监听
1092
+ this.keyboardEventHandle = new KeyboardEventHandle(this.screenShotContainer, this.toolController);
1093
+ // 给输入容器设置快捷键监听
1094
+ this.registerContainerShortcuts(this.textInputController);
1095
+ if (this.customRightClickEvent.state) {
1096
+ // 给截图容器添加右键事件监听
1097
+ this.registerForRightClickEvent(this.screenShotContainer);
1098
+ }
1099
+ }
1100
+ }
1101
+ export { ScreenShot as default };