bhd-components 0.9.1 → 0.9.2

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 (180) hide show
  1. package/dist/{100c4e1e.esm.es5.development.js → a5565b8a.esm.es5.development.js} +9674 -2548
  2. package/dist/deb6cc9b.esm.es5.production.js +485 -0
  3. package/dist/index.esm.es5.development.css +379 -0
  4. package/dist/index.esm.es5.development.js +3871 -6326
  5. package/dist/index.esm.es5.production.css +1 -1
  6. package/dist/index.esm.es5.production.js +1 -1
  7. package/es2017/customerService/index.js +1 -1
  8. package/es2017/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
  9. package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
  10. package/es2017/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
  11. package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
  12. package/es2017/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
  13. package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
  14. package/es2017/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
  15. package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
  16. package/es2017/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
  17. package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
  18. package/es2017/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
  19. package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
  20. package/es2017/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
  21. package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
  22. package/es2017/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
  23. package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
  24. package/es2017/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +9 -0
  25. package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
  26. package/es2017/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +41 -0
  27. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
  28. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
  29. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
  30. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +37 -0
  31. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
  32. package/es2017/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +26 -0
  33. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
  34. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
  35. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
  36. package/es2017/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
  37. package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
  38. package/es2017/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
  39. package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
  40. package/es2017/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
  41. package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
  42. package/es2017/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
  43. package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
  44. package/es2017/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
  45. package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
  46. package/es2017/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
  47. package/es2017/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
  48. package/es2017/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
  49. package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
  50. package/es2017/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +304 -0
  51. package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
  52. package/es2017/customerService/js-screen-shot/lib/main-entrance/InitData.js +538 -0
  53. package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
  54. package/es2017/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +162 -0
  55. package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
  56. package/es2017/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
  57. package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
  58. package/es2017/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
  59. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
  60. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
  61. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
  62. package/es2017/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
  63. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
  64. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +131 -0
  65. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
  66. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
  67. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
  68. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +118 -0
  69. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
  70. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
  71. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
  72. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
  73. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
  74. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
  75. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
  76. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
  77. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
  78. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
  79. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
  80. package/es2017/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
  81. package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
  82. package/es2017/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +50 -0
  83. package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
  84. package/es2017/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +61 -0
  85. package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
  86. package/es2017/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
  87. package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
  88. package/es2017/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +32 -0
  89. package/es2017/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
  90. package/es2017/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
  91. package/es2017/customerService/js-screen-shot/main.d.ts +110 -0
  92. package/es2017/customerService/js-screen-shot/main.js +1098 -0
  93. package/esm/customerService/index.js +1 -1
  94. package/esm/customerService/js-screen-shot/assets/less/screen-shot.less +478 -0
  95. package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.d.ts +1 -0
  96. package/esm/customerService/js-screen-shot/lib/common-methods/CanvasPatch.js +15 -0
  97. package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.d.ts +2 -0
  98. package/esm/customerService/js-screen-shot/lib/common-methods/DeviceTypeVerif.js +32 -0
  99. package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.d.ts +11 -0
  100. package/esm/customerService/js-screen-shot/lib/common-methods/FixedData.js +17 -0
  101. package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.d.ts +5 -0
  102. package/esm/customerService/js-screen-shot/lib/common-methods/GetBrushSelectedName.js +18 -0
  103. package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.d.ts +4 -0
  104. package/esm/customerService/js-screen-shot/lib/common-methods/GetCanvasImgData.js +25 -0
  105. package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.d.ts +1 -0
  106. package/esm/customerService/js-screen-shot/lib/common-methods/GetColor.js +41 -0
  107. package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.d.ts +1 -0
  108. package/esm/customerService/js-screen-shot/lib/common-methods/GetSelectedCalssName.js +23 -0
  109. package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.d.ts +7 -0
  110. package/esm/customerService/js-screen-shot/lib/common-methods/GetToolRelativePosition.js +10 -0
  111. package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.d.ts +11 -0
  112. package/esm/customerService/js-screen-shot/lib/common-methods/ImgScaling.js +38 -0
  113. package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.d.ts +8 -0
  114. package/esm/customerService/js-screen-shot/lib/common-methods/SaveBorderArrInfo.js +125 -0
  115. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.d.ts +1 -0
  116. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToBase64.js +37 -0
  117. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.d.ts +1 -0
  118. package/esm/customerService/js-screen-shot/lib/common-methods/SaveCanvasToImage.js +26 -0
  119. package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.d.ts +1 -0
  120. package/esm/customerService/js-screen-shot/lib/common-methods/SelectColor.js +6 -0
  121. package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.d.ts +5 -0
  122. package/esm/customerService/js-screen-shot/lib/common-methods/SelectTextSize.js +26 -0
  123. package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.d.ts +14 -0
  124. package/esm/customerService/js-screen-shot/lib/common-methods/SetBrushSize.js +50 -0
  125. package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.d.ts +7 -0
  126. package/esm/customerService/js-screen-shot/lib/common-methods/SetSelectedClassName.js +28 -0
  127. package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.d.ts +1 -0
  128. package/esm/customerService/js-screen-shot/lib/common-methods/TakeOutHistory.js +20 -0
  129. package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.d.ts +1 -0
  130. package/esm/customerService/js-screen-shot/lib/common-methods/UpdateContainerMouseStyle.js +10 -0
  131. package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.d.ts +17 -0
  132. package/esm/customerService/js-screen-shot/lib/common-methods/ZoomCutOutBoxPosition.js +92 -0
  133. package/esm/customerService/js-screen-shot/lib/config/Toolbar.d.ts +5 -0
  134. package/esm/customerService/js-screen-shot/lib/config/Toolbar.js +46 -0
  135. package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.d.ts +24 -0
  136. package/esm/customerService/js-screen-shot/lib/main-entrance/CreateDom.js +345 -0
  137. package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.d.ts +78 -0
  138. package/esm/customerService/js-screen-shot/lib/main-entrance/InitData.js +758 -0
  139. package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.d.ts +46 -0
  140. package/esm/customerService/js-screen-shot/lib/main-entrance/PlugInParameters.js +259 -0
  141. package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.d.ts +1 -0
  142. package/esm/customerService/js-screen-shot/lib/split-methods/AddHistoryData.js +23 -0
  143. package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.d.ts +8 -0
  144. package/esm/customerService/js-screen-shot/lib/split-methods/BoundaryJudgment.js +13 -0
  145. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.d.ts +5 -0
  146. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateOptionIcoPosition.js +21 -0
  147. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.d.ts +16 -0
  148. package/esm/customerService/js-screen-shot/lib/split-methods/CalculateToolLocation.js +39 -0
  149. package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.d.ts +31 -0
  150. package/esm/customerService/js-screen-shot/lib/split-methods/DrawArrow.js +159 -0
  151. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.d.ts +11 -0
  152. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCircle.js +37 -0
  153. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.d.ts +19 -0
  154. package/esm/customerService/js-screen-shot/lib/split-methods/DrawCutOutBox.js +119 -0
  155. package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.d.ts +13 -0
  156. package/esm/customerService/js-screen-shot/lib/split-methods/DrawLineArrow.js +51 -0
  157. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.d.ts +6 -0
  158. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMasking.js +41 -0
  159. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.d.ts +12 -0
  160. package/esm/customerService/js-screen-shot/lib/split-methods/DrawMosaic.js +67 -0
  161. package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.d.ts +13 -0
  162. package/esm/customerService/js-screen-shot/lib/split-methods/DrawPencil.js +27 -0
  163. package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.d.ts +11 -0
  164. package/esm/customerService/js-screen-shot/lib/split-methods/DrawRectangle.js +22 -0
  165. package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.d.ts +10 -0
  166. package/esm/customerService/js-screen-shot/lib/split-methods/DrawText.js +24 -0
  167. package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.d.ts +10 -0
  168. package/esm/customerService/js-screen-shot/lib/split-methods/KeyboardEventHandle.js +61 -0
  169. package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.d.ts +2 -0
  170. package/esm/customerService/js-screen-shot/lib/split-methods/SetPlugInParameters.js +62 -0
  171. package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.d.ts +1 -0
  172. package/esm/customerService/js-screen-shot/lib/split-methods/ToolClickEvent.js +132 -0
  173. package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.d.ts +1 -0
  174. package/esm/customerService/js-screen-shot/lib/split-methods/drawCrossImg.js +32 -0
  175. package/esm/customerService/js-screen-shot/lib/type/ComponentType.d.ts +133 -0
  176. package/esm/customerService/js-screen-shot/lib/type/ComponentType.js +2 -0
  177. package/esm/customerService/js-screen-shot/main.d.ts +110 -0
  178. package/esm/customerService/js-screen-shot/main.js +1201 -0
  179. package/package.json +1 -1
  180. package/dist/a4d5ce04.esm.es5.production.js +0 -468
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 绘制箭头
3
+ * @param context 需要进行绘制的画布
4
+ * @param mouseStartX 鼠标按下时的x轴坐标 P1
5
+ * @param mouseStartY 鼠标按下式的y轴坐标 P1
6
+ * @param mouseX 当前鼠标x轴坐标 P2
7
+ * @param mouseY 当前鼠标y轴坐标 P2
8
+ * @param theta 箭头斜线与直线的夹角角度 (θ) P3 ---> (P1、P2) || P4 ---> P1(P1、P2)
9
+ * @param slashLength 箭头斜线的长度 P3 ---> P2 || P4 ---> P2
10
+ * @param borderWidth 边框宽度
11
+ * @param color 边框颜色
12
+ */ export function drawLineArrow(context, mouseStartX, mouseStartY, mouseX, mouseY, theta, slashLength, borderWidth, color) {
13
+ /**
14
+ * 已知:
15
+ * 1. P1、P2的坐标
16
+ * 2. 箭头斜线(P3 || P4) ---> P2直线的长度
17
+ * 3. 箭头斜线(P3 || P4) ---> (P1、P2)直线的夹角角度(θ)
18
+ * 求:
19
+ * P3、P4的坐标
20
+ */ const angle = Math.atan2(mouseStartY - mouseY, mouseStartX - mouseX) * 180 / Math.PI, angle1 = (angle + theta) * Math.PI / 180, angle2 = (angle - theta) * Math.PI / 180, topX = slashLength * Math.cos(angle1), topY = slashLength * Math.sin(angle1), botX = slashLength * Math.cos(angle2), botY = slashLength * Math.sin(angle2); // P4点的Y轴坐标
21
+ // 开始绘制
22
+ context.save();
23
+ context.beginPath();
24
+ // P3的坐标位置
25
+ let arrowX = mouseStartX - topX, arrowY = mouseStartY - topY;
26
+ // 移动笔触到P3坐标
27
+ context.moveTo(arrowX, arrowY);
28
+ // 移动笔触到P1
29
+ context.moveTo(mouseStartX, mouseStartY);
30
+ // 绘制P1到P2的直线
31
+ context.lineTo(mouseX, mouseY);
32
+ // 计算P3的位置
33
+ arrowX = mouseX + topX;
34
+ arrowY = mouseY + topY;
35
+ // 移动笔触到P3坐标
36
+ context.moveTo(arrowX, arrowY);
37
+ // 绘制P2到P3的斜线
38
+ context.lineTo(mouseX, mouseY);
39
+ // 计算P4的位置
40
+ arrowX = mouseX + botX;
41
+ arrowY = mouseY + botY;
42
+ // 绘制P2到P4的斜线
43
+ context.lineTo(arrowX, arrowY);
44
+ // 上色
45
+ context.strokeStyle = color;
46
+ context.lineWidth = borderWidth;
47
+ // 填充
48
+ context.stroke();
49
+ // 结束绘制
50
+ context.restore();
51
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 绘制蒙层
3
+ * @param context 需要进行绘制canvas
4
+ * @param imgData 屏幕截图canvas容器
5
+ */
6
+ export declare function drawMasking(context: CanvasRenderingContext2D, imgData?: HTMLCanvasElement): void;
@@ -0,0 +1,41 @@
1
+ import PlugInParameters from "../main-entrance/PlugInParameters";
2
+ /**
3
+ * 绘制蒙层
4
+ * @param context 需要进行绘制canvas
5
+ * @param imgData 屏幕截图canvas容器
6
+ */ export function drawMasking(context, imgData) {
7
+ const data = new PlugInParameters();
8
+ const plugInParameters = new PlugInParameters();
9
+ const canvasSize = plugInParameters.getCanvasSize();
10
+ const viewSize = {
11
+ width: parseFloat(window.getComputedStyle(document.body).width),
12
+ height: parseFloat(window.getComputedStyle(document.body).height)
13
+ };
14
+ const maxWidth = Math.max(viewSize.width || 0, Math.max(document.body.scrollWidth, document.documentElement.scrollWidth), Math.max(document.body.offsetWidth, document.documentElement.offsetWidth), Math.max(document.body.clientWidth, document.documentElement.clientWidth));
15
+ const maxHeight = Math.max(viewSize.height || 0, Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.documentElement.offsetHeight), Math.max(document.body.clientHeight, document.documentElement.clientHeight));
16
+ // 清除画布
17
+ context.clearRect(0, 0, maxWidth, maxHeight);
18
+ // 屏幕截图存在且展示截图数据的状态为true则进行绘制
19
+ if (imgData != null && plugInParameters.getShowScreenDataStatus()) {
20
+ // 调用者传了画布尺寸则使用,否则使用窗口宽高
21
+ if (canvasSize.canvasWidth !== 0 && canvasSize.canvasHeight !== 0) {
22
+ context.drawImage(imgData, 0, 0, canvasSize.canvasWidth, canvasSize.canvasHeight);
23
+ } else {
24
+ context.drawImage(imgData, 0, 0, maxWidth, maxHeight);
25
+ }
26
+ }
27
+ // 绘制蒙层
28
+ context.save();
29
+ const maskColor = data.getMaskColor();
30
+ context.fillStyle = "rgba(0, 0, 0, .6)";
31
+ if (maskColor) {
32
+ context.fillStyle = `rgba(${maskColor.r}, ${maskColor.g}, ${maskColor.b}, ${maskColor.a})`;
33
+ }
34
+ if (canvasSize.canvasWidth !== 0 && canvasSize.canvasHeight !== 0) {
35
+ context.fillRect(0, 0, canvasSize.canvasWidth, canvasSize.canvasHeight);
36
+ } else {
37
+ context.fillRect(0, 0, maxWidth, maxHeight);
38
+ }
39
+ // 绘制结束
40
+ context.restore();
41
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 绘制马赛克
3
+ * 实现思路:
4
+ * 1. 获取鼠标划过路径区域的图像信息
5
+ * 2. 将区域内的像素点绘制成周围相近的颜色
6
+ * @param mouseX 当前鼠标X轴坐标
7
+ * @param mouseY 当前鼠标Y轴坐标
8
+ * @param size 马赛克画笔大小
9
+ * @param degreeOfBlur 马赛克模糊度
10
+ * @param context 需要进行绘制的画布
11
+ */
12
+ export declare function drawMosaic(mouseX: number, mouseY: number, size: number, degreeOfBlur: number, context: CanvasRenderingContext2D): void;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * 获取图像指定坐标位置的颜色
3
+ * @param imgData 需要进行操作的图片
4
+ * @param x x点坐标
5
+ * @param y y点坐标
6
+ */ const getAxisColor = (imgData, x, y)=>{
7
+ const w = imgData.width;
8
+ const d = imgData.data;
9
+ const color = [];
10
+ color[0] = d[4 * (y * w + x)];
11
+ color[1] = d[4 * (y * w + x) + 1];
12
+ color[2] = d[4 * (y * w + x) + 2];
13
+ color[3] = d[4 * (y * w + x) + 3];
14
+ return color;
15
+ };
16
+ /**
17
+ * 设置图像指定坐标位置的颜色
18
+ * @param imgData 需要进行操作的图片
19
+ * @param x x点坐标
20
+ * @param y y点坐标
21
+ * @param color 颜色数组
22
+ */ const setAxisColor = (imgData, x, y, color)=>{
23
+ const w = imgData.width;
24
+ const d = imgData.data;
25
+ d[4 * (y * w + x)] = color[0];
26
+ d[4 * (y * w + x) + 1] = color[1];
27
+ d[4 * (y * w + x) + 2] = color[2];
28
+ d[4 * (y * w + x) + 3] = color[3];
29
+ };
30
+ /**
31
+ * 绘制马赛克
32
+ * 实现思路:
33
+ * 1. 获取鼠标划过路径区域的图像信息
34
+ * 2. 将区域内的像素点绘制成周围相近的颜色
35
+ * @param mouseX 当前鼠标X轴坐标
36
+ * @param mouseY 当前鼠标Y轴坐标
37
+ * @param size 马赛克画笔大小
38
+ * @param degreeOfBlur 马赛克模糊度
39
+ * @param context 需要进行绘制的画布
40
+ */ export function drawMosaic(mouseX, mouseY, size, degreeOfBlur, context) {
41
+ // 获取设备像素比
42
+ const dpr = window.devicePixelRatio || 1;
43
+ // 获取鼠标经过区域的图片像素信息
44
+ const imgData = context.getImageData(mouseX * dpr, mouseY * dpr, size * dpr, size * dpr);
45
+ // 获取图像宽高
46
+ const w = imgData.width;
47
+ const h = imgData.height;
48
+ // 等分图像宽高
49
+ const stepW = w / degreeOfBlur;
50
+ const stepH = h / degreeOfBlur;
51
+ // 循环画布像素点
52
+ for(let i = 0; i < stepH; i++){
53
+ for(let j = 0; j < stepW; j++){
54
+ // 随机获取一个小方格的随机颜色
55
+ const color = getAxisColor(imgData, j * degreeOfBlur + Math.floor(Math.random() * degreeOfBlur), i * degreeOfBlur + Math.floor(Math.random() * degreeOfBlur));
56
+ // 循环小方格的像素点
57
+ for(let k = 0; k < degreeOfBlur; k++){
58
+ for(let l = 0; l < degreeOfBlur; l++){
59
+ // 设置小方格的颜色
60
+ setAxisColor(imgData, j * degreeOfBlur + l, i * degreeOfBlur + k, color);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ // 渲染打上马赛克后的图像信息
66
+ context.putImageData(imgData, mouseX * dpr, mouseY * dpr);
67
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 画笔绘制
3
+ * @param context
4
+ * @param mouseX
5
+ * @param mouseY
6
+ * @param size
7
+ * @param color
8
+ */
9
+ export declare function drawPencil(context: CanvasRenderingContext2D, mouseX: number, mouseY: number, size: number, color: string): void;
10
+ /**
11
+ * 画笔初始化
12
+ */
13
+ export declare function initPencil(context: CanvasRenderingContext2D, mouseX: number, mouseY: number): void;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 画笔绘制
3
+ * @param context
4
+ * @param mouseX
5
+ * @param mouseY
6
+ * @param size
7
+ * @param color
8
+ */ export function drawPencil(context, mouseX, mouseY, size, color) {
9
+ // 开始绘制
10
+ context.save();
11
+ // 设置边框大小
12
+ context.lineWidth = size;
13
+ // 设置边框颜色
14
+ context.strokeStyle = color;
15
+ context.lineTo(mouseX, mouseY);
16
+ context.stroke();
17
+ // 绘制结束
18
+ context.restore();
19
+ }
20
+ /**
21
+ * 画笔初始化
22
+ */ export function initPencil(context, mouseX, mouseY) {
23
+ // 开始||清空一条路径
24
+ context.beginPath();
25
+ // 移动画笔位置
26
+ context.moveTo(mouseX, mouseY);
27
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 绘制矩形
3
+ * @param mouseX
4
+ * @param mouseY
5
+ * @param width
6
+ * @param height
7
+ * @param color 边框颜色
8
+ * @param borderWidth 边框大小
9
+ * @param context 需要进行绘制的canvas画布
10
+ */
11
+ export declare function drawRectangle(mouseX: number, mouseY: number, width: number, height: number, color: string, borderWidth: number, context: CanvasRenderingContext2D): void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 绘制矩形
3
+ * @param mouseX
4
+ * @param mouseY
5
+ * @param width
6
+ * @param height
7
+ * @param color 边框颜色
8
+ * @param borderWidth 边框大小
9
+ * @param context 需要进行绘制的canvas画布
10
+ */ export function drawRectangle(mouseX, mouseY, width, height, color, borderWidth, context) {
11
+ context.save();
12
+ // 设置边框颜色
13
+ context.strokeStyle = color;
14
+ // 设置边框大小
15
+ context.lineWidth = borderWidth;
16
+ context.beginPath();
17
+ // 绘制矩形
18
+ context.rect(mouseX, mouseY, width, height);
19
+ context.stroke();
20
+ // 绘制结束
21
+ context.restore();
22
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 绘制文本
3
+ * @param text 需要进行绘制的文字
4
+ * @param mouseX 绘制位置的X轴坐标
5
+ * @param mouseY 绘制位置的Y轴坐标
6
+ * @param color 字体颜色
7
+ * @param fontSize 字体大小
8
+ * @param context 需要你行绘制的画布
9
+ */
10
+ export declare function drawText(text: string, mouseX: number, mouseY: number, color: string, fontSize: number, context: CanvasRenderingContext2D): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 绘制文本
3
+ * @param text 需要进行绘制的文字
4
+ * @param mouseX 绘制位置的X轴坐标
5
+ * @param mouseY 绘制位置的Y轴坐标
6
+ * @param color 字体颜色
7
+ * @param fontSize 字体大小
8
+ * @param context 需要你行绘制的画布
9
+ */ export function drawText(text, mouseX, mouseY, color, fontSize, context) {
10
+ context.save();
11
+ context.lineWidth = 1;
12
+ context.fillStyle = color;
13
+ context.textBaseline = "middle";
14
+ context.font = `bold ${fontSize}px none`;
15
+ // 处理换行符并绘制多行文本
16
+ const lines = text.split("\n"); // 根据换行符拆分文本为多行
17
+ const lineHeight = fontSize * 1.4; // 设定行高为字体大小的1.4倍
18
+ lines.forEach((line, index)=>{
19
+ // 调整每行的垂直位置
20
+ const lineY = mouseY + lineHeight * index;
21
+ context.fillText(line, mouseX, lineY);
22
+ });
23
+ context.restore();
24
+ }
@@ -0,0 +1,10 @@
1
+ export default class KeyboardEventHandle {
2
+ private readonly toolController;
3
+ constructor(screenShotController: HTMLCanvasElement, toolController: HTMLDivElement);
4
+ /**
5
+ * 触发工具栏指定模块的点击事件
6
+ * @param eventName 事件名, 与截图工具栏中的data-title属性值保持一致
7
+ * @private
8
+ */
9
+ triggerEvent(eventName: string): void;
10
+ }
@@ -0,0 +1,50 @@
1
+ // 键盘按下事件处理类
2
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
+ import InitData from "../main-entrance/InitData";
4
+ class KeyboardEventHandle {
5
+ /**
6
+ * 触发工具栏指定模块的点击事件
7
+ * @param eventName 事件名, 与截图工具栏中的data-title属性值保持一致
8
+ * @private
9
+ */ triggerEvent(eventName) {
10
+ if (this.toolController == null) return;
11
+ for(let i = 0; i < this.toolController.childNodes.length; i++){
12
+ const childNode = this.toolController.childNodes[i];
13
+ const toolName = childNode.getAttribute("data-title");
14
+ if (toolName === eventName) {
15
+ // 执行参数事件
16
+ childNode.click();
17
+ }
18
+ }
19
+ }
20
+ constructor(screenShotController, toolController){
21
+ // 截图工具栏容器
22
+ _define_property(this, "toolController", null);
23
+ const data = new InitData();
24
+ const textInputContainer = document.getElementById("textInputPanel");
25
+ this.toolController = toolController;
26
+ // 调整截图容器显示权重
27
+ screenShotController.tabIndex = 9999;
28
+ // 监听全局键盘按下事件
29
+ document.body.addEventListener("keydown", (event)=>{
30
+ // 文本输入框存在时则终止
31
+ if (data.getTextEditState()) {
32
+ data.setTextEditState(false);
33
+ return;
34
+ }
35
+ if (event.code === "Escape") {
36
+ // ESC按下,触发取消截图事件
37
+ this.triggerEvent("close");
38
+ }
39
+ if (event.code === "Enter" && textInputContainer && textInputContainer.style.display !== "block") {
40
+ // Enter按下,触发确认截图事件
41
+ this.triggerEvent("confirm");
42
+ }
43
+ // 按下command+z或者ctrl+z快捷键选中撤销工具
44
+ if ((event.metaKey || event.ctrlKey) && event.code === "KeyZ") {
45
+ this.triggerEvent("undo");
46
+ }
47
+ });
48
+ }
49
+ }
50
+ export { KeyboardEventHandle as default };
@@ -0,0 +1,2 @@
1
+ import { screenShotType } from "../type/ComponentType";
2
+ export declare function setPlugInParameters(options: screenShotType): void;
@@ -0,0 +1,61 @@
1
+ import PlugInParameters from "../main-entrance/PlugInParameters";
2
+ // 为插件的全局参数设置数据
3
+ export function setPlugInParameters(options) {
4
+ const plugInParameters = new PlugInParameters();
5
+ // webrtc启用状态, 默认为true,如果设置了false则修改默认值
6
+ if ((options === null || options === void 0 ? void 0 : options.enableWebRtc) === false) {
7
+ plugInParameters.setWebRtcStatus(false);
8
+ plugInParameters.setInitStatus(false);
9
+ }
10
+ // 读取并设置参数中的视频流数据
11
+ if ((options === null || options === void 0 ? void 0 : options.screenFlow) instanceof MediaStream) {
12
+ plugInParameters.setScreenFlow(options.screenFlow);
13
+ }
14
+ // 读取参数中的画布宽高, 两者都存在时才设置
15
+ if ((options === null || options === void 0 ? void 0 : options.canvasWidth) && (options === null || options === void 0 ? void 0 : options.canvasHeight)) {
16
+ plugInParameters.setCanvasSize(options.canvasWidth, options.canvasHeight);
17
+ }
18
+ // 读取参数设置默认展示截屏数据的状态,默认为false,如果设置了true才修改
19
+ if ((options === null || options === void 0 ? void 0 : options.showScreenData) === true) {
20
+ plugInParameters.setShowScreenDataStatus(true);
21
+ }
22
+ if ((options === null || options === void 0 ? void 0 : options.maskColor) && typeof options.maskColor === "object") {
23
+ plugInParameters.setMaskColor(options.maskColor);
24
+ }
25
+ // 调用者关闭了剪切板写入,则修改全局变量(默认为true)
26
+ if ((options === null || options === void 0 ? void 0 : options.writeBase64) === false) {
27
+ plugInParameters.setWriteImgState(options.writeBase64);
28
+ }
29
+ // 调用者传入了截图dom
30
+ if (options === null || options === void 0 ? void 0 : options.screenShotDom) {
31
+ plugInParameters.setScreenShotDom(options.screenShotDom);
32
+ }
33
+ // 调用者传入了裁剪区域边框像素点颜色信息
34
+ if (options === null || options === void 0 ? void 0 : options.cutBoxBdColor) {
35
+ plugInParameters.setCutBoxBdColor(options.cutBoxBdColor);
36
+ }
37
+ // 调用者传入了保存截图回调
38
+ if (options === null || options === void 0 ? void 0 : options.saveCallback) {
39
+ plugInParameters.setSaveCallback(options.saveCallback);
40
+ }
41
+ // 设置最大撤销次数
42
+ if (options === null || options === void 0 ? void 0 : options.maxUndoNum) {
43
+ plugInParameters.setMaxUndoNum(options.maxUndoNum);
44
+ }
45
+ // 箭头绘制工具是否使用等比例绘制方式
46
+ if (options === null || options === void 0 ? void 0 : options.useRatioArrow) {
47
+ plugInParameters.setRatioArrow(options.useRatioArrow);
48
+ }
49
+ // 设置图片自适应开启状态
50
+ if (options === null || options === void 0 ? void 0 : options.imgAutoFit) {
51
+ plugInParameters.setImgAutoFit(options.imgAutoFit);
52
+ }
53
+ // 设置图片保存时的文件名称
54
+ if (options === null || options === void 0 ? void 0 : options.saveImgTitle) {
55
+ plugInParameters.setSaveImgTitle(options.saveImgTitle);
56
+ }
57
+ // 确认截图时,是否需要销毁dom
58
+ if ((options === null || options === void 0 ? void 0 : options.destroyContainer) === false) {
59
+ plugInParameters.setDestroyContainerState(options.destroyContainer);
60
+ }
61
+ }
@@ -0,0 +1 @@
1
+ export declare function toolClickEvent(toolName: string, index: number, mouseEvent: any, completeCallback: Function | undefined, closeCallback: Function | undefined): void;
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 裁剪框工具栏点击事件
3
+ * @param toolName
4
+ * @param index
5
+ * @param mouseEvent
6
+ */ import { setSelectedClassName } from "../common-methods/SetSelectedClassName";
7
+ import { calculateOptionIcoPosition } from "./CalculateOptionIcoPosition";
8
+ import InitData from "../main-entrance/InitData";
9
+ import { getCanvasImgData } from "../common-methods/GetCanvasImgData";
10
+ import { takeOutHistory } from "../common-methods/TakeOutHistory";
11
+ import { drawCutOutBox } from "./DrawCutOutBox";
12
+ import { drawText } from "./DrawText";
13
+ import { addHistory } from "./AddHistoryData";
14
+ import PlugInParameters from "../main-entrance/PlugInParameters";
15
+ export function toolClickEvent(toolName, index, mouseEvent, completeCallback, closeCallback) {
16
+ const data = new InitData();
17
+ const plugInParameters = new PlugInParameters();
18
+ const textInputController = data.getTextInputController();
19
+ const screenShotController = data.getScreenShotContainer();
20
+ const ScreenShotImageController = data.getScreenShotImageController();
21
+ data.setActiveToolName(toolName);
22
+ if (screenShotController == null || ScreenShotImageController == null) return;
23
+ // 获取canvas容器
24
+ const screenShotCanvas = screenShotController.getContext("2d");
25
+ // 工具栏尚未点击,当前属于首次点击,重新绘制一个无像素点的裁剪框
26
+ if (!data.getToolClickStatus()) {
27
+ var _data_getToolPosition, _data_getToolPosition1;
28
+ const leftValue = ((_data_getToolPosition = data.getToolPosition()) === null || _data_getToolPosition === void 0 ? void 0 : _data_getToolPosition.left) || 0;
29
+ const topValue = ((_data_getToolPosition1 = data.getToolPosition()) === null || _data_getToolPosition1 === void 0 ? void 0 : _data_getToolPosition1.top) || 0;
30
+ // 工具栏位置超出时,对其进行修正处理
31
+ if (topValue && data.getToolPositionStatus()) {
32
+ // 调整工具栏位置
33
+ data.setToolInfo(leftValue, topValue - 46);
34
+ }
35
+ // data.setToolStatus(true);
36
+ // 获取裁剪框位置信息
37
+ const cutBoxPosition = data.getCutOutBoxPosition();
38
+ // 开始绘制无像素点裁剪框
39
+ drawCutOutBox(cutBoxPosition.startX, cutBoxPosition.startY, cutBoxPosition.width, cutBoxPosition.height, screenShotCanvas, data.getBorderSize(), screenShotController, ScreenShotImageController, false);
40
+ }
41
+ // 更新当前点击的工具栏条目
42
+ data.setToolName(toolName);
43
+ // 为当前点击项添加选中时的class名
44
+ setSelectedClassName(mouseEvent, index, false);
45
+ if (toolName === "text") {
46
+ var // 颜色选择容器添加布局兼容样式
47
+ _data_getColorSelectPanel;
48
+ // 显示文字选择容器
49
+ data.setTextSizePanelStatus(true);
50
+ // 隐藏画笔尺寸选择容器
51
+ data.setBrushSelectionStatus(false);
52
+ (_data_getColorSelectPanel = data.getColorSelectPanel()) === null || _data_getColorSelectPanel === void 0 ? void 0 : _data_getColorSelectPanel.classList.add("text-select-status");
53
+ } else {
54
+ // 隐藏下拉选择框
55
+ data.setTextSizePanelStatus(false);
56
+ // 显示画笔尺寸选择容器
57
+ data.setBrushSelectionStatus(true);
58
+ }
59
+ // 显示选项面板
60
+ data.setOptionStatus(true);
61
+ // 设置选项面板位置
62
+ data.setOptionPosition(calculateOptionIcoPosition(index));
63
+ data.setRightPanel(true);
64
+ if (toolName == "mosaicPen") {
65
+ // 马赛克工具隐藏右侧颜色面板与角标
66
+ data.setRightPanel(false);
67
+ data.hiddenOptionIcoStatus();
68
+ }
69
+ // 清空文本输入区域的内容并隐藏文本输入框
70
+ if (textInputController != null && data.getTextStatus() || textInputController != null && toolName !== "text") {
71
+ const text = textInputController.innerText;
72
+ if (text && text !== "") {
73
+ const { positionX , positionY , color , size } = data.getTextInfo();
74
+ drawText(text, positionX, positionY, color, size, screenShotCanvas);
75
+ // 添加历史记录
76
+ addHistory();
77
+ }
78
+ textInputController.innerHTML = "";
79
+ data.setTextStatus(false);
80
+ }
81
+ // 初始化点击状态
82
+ data.setDragging(false);
83
+ data.setDraggingTrim(false);
84
+ // 保存图片
85
+ if (toolName == "save") {
86
+ getCanvasImgData(true);
87
+ const callback = plugInParameters.getSaveCallback();
88
+ if (callback) {
89
+ callback(0, "保存成功");
90
+ }
91
+ // 销毁组件
92
+ data.destroyDOM();
93
+ data.setInitStatus(true);
94
+ }
95
+ // 销毁组件
96
+ if (toolName == "close") {
97
+ // 触发关闭回调函数
98
+ if (closeCallback) {
99
+ closeCallback();
100
+ }
101
+ data.destroyDOM();
102
+ data.setInitStatus(true);
103
+ }
104
+ // 确认截图
105
+ if (toolName == "confirm") {
106
+ const base64 = getCanvasImgData(false);
107
+ // 触发回调函数,截图数据回传给插件调用者
108
+ if (completeCallback) {
109
+ completeCallback({
110
+ base64,
111
+ cutInfo: data.getCutOutBoxPosition()
112
+ });
113
+ }
114
+ if (!plugInParameters.getDestroyContainerState()) {
115
+ // 隐藏工具栏
116
+ // data.setToolStatus(false);
117
+ // data.setOptionStatus(false);
118
+ return;
119
+ }
120
+ // 销毁组件
121
+ data.destroyDOM();
122
+ data.setInitStatus(true);
123
+ }
124
+ // 撤销
125
+ if (toolName == "undo") {
126
+ // 隐藏画笔选项工具栏
127
+ data.setOptionStatus(false);
128
+ takeOutHistory();
129
+ }
130
+ // 设置裁剪框工具栏为点击状态
131
+ data.setToolClickStatus(true);
132
+ }
@@ -0,0 +1 @@
1
+ export declare function drawCrossImg(html: Document): Promise<string[]>;
@@ -0,0 +1,32 @@
1
+ export function drawCrossImg(html) {
2
+ const promises = [];
3
+ const imageNodes = html.querySelectorAll("img");
4
+ imageNodes.forEach((element)=>{
5
+ const href = element.getAttribute("src");
6
+ if (!href) return;
7
+ if (href && href.startsWith("base64")) return;
8
+ const promise = new Promise((resolve, reject)=>{
9
+ const img = new Image();
10
+ img.crossOrigin = "anonymous";
11
+ img.src = `${href}&time=${+new Date().getTime()}`;
12
+ img.onload = function() {
13
+ const width = element.width;
14
+ const height = element.height;
15
+ const canvas = document.createElement("canvas");
16
+ canvas.width = width;
17
+ canvas.height = height;
18
+ const ctx = canvas.getContext("2d");
19
+ ctx.drawImage(img, 0, 0, width, height);
20
+ const base64 = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL();
21
+ element.setAttribute("src", base64);
22
+ resolve("转换成功");
23
+ };
24
+ img.onerror = reject;
25
+ if (href !== null) {
26
+ img.src = href;
27
+ }
28
+ });
29
+ promises.push(promise);
30
+ });
31
+ return Promise.all(promises);
32
+ }