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