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