bhd-components 0.7.40 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runt
6
6
  import React, { useEffect, useState, useRef } from "react";
7
7
  import { Modal, Drawer, Input, Tooltip } from "antd";
8
8
  import ViewImage from "../viewImage";
9
- // import html2canvas from "html2canvas";
10
9
  import cssStyle from "./index.module.less";
11
10
  import cssStyleOnline from "./index2.module.less";
12
11
  var styles = cssStyle;
@@ -22,7 +21,7 @@ import TeacherList from "./teacherList";
22
21
  import { parseDate } from "../utils/Date";
23
22
  import { Remarkable } from "remarkable";
24
23
  import hljs from "highlight.js";
25
- import "highlight.js/styles/default.css";
24
+ import "highlight.js/styles/github.css";
26
25
  import { render } from "react-dom";
27
26
  import Provider from "../provider";
28
27
  var TextArea = Input.TextArea;
@@ -108,6 +107,112 @@ var CustomerService = function(props) {
108
107
  initShowType
109
108
  ]);
110
109
  useEffect(function() {
110
+ var handlerHtml2canvas = function handlerHtml2canvas() {
111
+ console.log("kkkkkkkkkkk");
112
+ try {
113
+ newShowType.current = true;
114
+ setImgBese64("");
115
+ var plugin = new screenShotPlugin({
116
+ clickCutFullScreen: true,
117
+ enableWebRtc: true,
118
+ loadCrossImg: true,
119
+ canvasWidth: window.innerWidth,
120
+ canvasHeight: window.innerHeight,
121
+ level: -1,
122
+ hiddenToolIco: true,
123
+ screenShotDom: document.body,
124
+ cropBoxInfo: {
125
+ x: 0,
126
+ y: 0,
127
+ w: window.innerWidth,
128
+ h: window.innerHeight
129
+ },
130
+ wrcReplyTime: 20,
131
+ wrcWindowMode: true,
132
+ hiddenScrollBar: {
133
+ state: true
134
+ },
135
+ completeCallback: function(param) {
136
+ var base64 = param.base64;
137
+ // console.log(
138
+ // "截图组件加载完毕调用此方法来完成框选区域的截图",
139
+ // base64
140
+ // );
141
+ setImgBese64(base64);
142
+ },
143
+ triggerCallback: function() {
144
+ // 截图组件加载完毕调用此方法来完成框选区域的截图
145
+ plugin.completeScreenshot();
146
+ },
147
+ cancelCallback: function(err) {
148
+ if (err.code === -1) {
149
+ console.log(err);
150
+ newShowType.current = false;
151
+ if (saveShowType != -1) {
152
+ setShowType(saveShowType);
153
+ } else {
154
+ setShowType(1);
155
+ }
156
+ setShowScreenshot(false);
157
+ onCancel();
158
+ }
159
+ }
160
+ });
161
+ // modernScreenshot
162
+ // .domToPng(document.querySelector("body"))
163
+ // .then((dataUrl:any) => {
164
+ // console.log(dataUrl);
165
+ // setImgBese64(dataUrl);
166
+ // });
167
+ // domtoimage
168
+ // .toPng(document.body)
169
+ // .then(function (dataUrl:any) {
170
+ // setImgBese64(dataUrl);
171
+ // })
172
+ // .catch(function (error:any) {
173
+ // console.error("oops, something went wrong!", error);
174
+ // });
175
+ // //排除
176
+ // new screenShotPlugin({
177
+ // enableWebRtc: true,
178
+ // canvasWidth:window.innerWidth,
179
+ // canvasHeight:window.innerHeight,
180
+ // level:9999999,
181
+ // completeCallback: function (info:any) {
182
+ // console.log(info);
183
+ // setImgBese64(info.base64);
184
+ // },
185
+ // closeCallback: function () {
186
+ // },
187
+ // });
188
+ // html2canvas(document.body,{//__docusaurus
189
+ // useCORS: true, // 支持跨域图片截图
190
+ // allowTaint: true, // 污染处理
191
+ // scale: 1 ,// 图片比例
192
+ // logging:false,
193
+ // // foreignObjectRendering:true,
194
+ // ignoreElements:(element: { compareDocumentPosition: (arg0: string) => number; })=>{
195
+ // if(element.compareDocumentPosition(screenshotAreaId)===2)return true
196
+ // return false
197
+ // },
198
+ // windowWidth:window.innerWidth,
199
+ // windowHeight:window.innerHeight
200
+ // })
201
+ // .then(function (canvas:any) {
202
+ // // document.body.appendChild(canvas);
203
+ // // console.log(canvas,99999);
204
+ // // var base64URL = canvas.toDataURL('image/jpeg')
205
+ // let base64URL = canvas.toDataURL("image/jpg", 1.0)
206
+ // // console.log(base64URL);
207
+ // setImgBese64(base64URL);
208
+ // // svgNodesToRemove.forEach(item=>{
209
+ // // item.remove()
210
+ // // })
211
+ // });
212
+ } catch (error) {
213
+ console.log(error);
214
+ }
215
+ };
111
216
  var handleScroll = function handleScroll() {
112
217
  var container = document.getElementById(showType == 1 || showType == 3 ? "chat_content" : "chat_content_modal");
113
218
  var scrollTop = container.scrollTop;
@@ -156,30 +261,9 @@ var CustomerService = function(props) {
156
261
  };
157
262
  //|| showScreenshot
158
263
  if (showType == 5 || showScreenshot) {
159
- try {
160
- newShowType.current = true;
161
- setImgBese64("");
162
- // let dom = document.getElementById(screenshotAreaId);
163
- html2canvas(screenshotAreaId, {
164
- useCORS: true,
165
- // allowTaint: true, // 污染处理
166
- scale: 1,
167
- // logging:true,
168
- ignoreElements: function(element) {
169
- if (element.compareDocumentPosition(screenshotAreaId) === 2) return true;
170
- return false;
171
- }
172
- }).then(function(canvas) {
173
- // document.body.appendChild(canvas);
174
- console.log(canvas, 99999);
175
- // var base64URL = canvas.toDataURL('image/jpeg')
176
- var base64URL = canvas.toDataURL("image/jpg", 1.0);
177
- console.log(base64URL);
178
- setImgBese64(base64URL);
179
- });
180
- } catch (error) {
181
- console.log(error);
182
- }
264
+ console.log("bbbbbbbbbbbbbb");
265
+ handlerHtml2canvas();
266
+ // window.addEventListener('resize',handlerHtml2canvas)
183
267
  }
184
268
  if (showType != 1 && !firstLoad && pageCount > 0) {
185
269
  setFirstLoad(true);
@@ -194,6 +278,7 @@ var CustomerService = function(props) {
194
278
  if (content) {
195
279
  content.removeEventListener("scroll", handleScroll);
196
280
  }
281
+ window.removeEventListener("resize", handlerHtml2canvas);
197
282
  };
198
283
  }, [
199
284
  historyMessageList,
@@ -1722,11 +1807,18 @@ var CustomerService = function(props) {
1722
1807
  /*#__PURE__*/ _jsxs("div", {
1723
1808
  className: styles.operate,
1724
1809
  children: [
1725
- /*#__PURE__*/ _jsx("i", {
1810
+ /*#__PURE__*/ _jsxs("i", {
1811
+ className: styles.popover_main,
1726
1812
  onClick: function() {
1727
1813
  setShowHistory(true);
1728
1814
  },
1729
- children: /*#__PURE__*/ _jsx(CustomRecord, {})
1815
+ children: [
1816
+ /*#__PURE__*/ _jsx(CustomRecord, {}),
1817
+ /*#__PURE__*/ _jsx("span", {
1818
+ className: styles.popover,
1819
+ children: "历史记录"
1820
+ })
1821
+ ]
1730
1822
  }),
1731
1823
  /*#__PURE__*/ _jsx("span", {
1732
1824
  className: styles.line
@@ -1746,20 +1838,14 @@ var CustomerService = function(props) {
1746
1838
  })
1747
1839
  ]
1748
1840
  }),
1749
- /*#__PURE__*/ _jsxs("i", {
1841
+ /*#__PURE__*/ _jsx("i", {
1750
1842
  className: styles.popover_main,
1751
1843
  onClick: function() {
1752
1844
  onEvent(serverName + serverUrl(), "click_智能问答_退出全屏", "提交");
1753
1845
  setShowType(3);
1754
1846
  setFirstLoad(false); //重启滚动条在最上方
1755
1847
  },
1756
- children: [
1757
- /*#__PURE__*/ _jsx(CloseOutlined, {}),
1758
- /*#__PURE__*/ _jsx("span", {
1759
- className: styles.popover,
1760
- children: "退出全屏"
1761
- })
1762
- ]
1848
+ children: /*#__PURE__*/ _jsx(CloseOutlined, {})
1763
1849
  })
1764
1850
  ]
1765
1851
  })
@@ -3450,6 +3536,9 @@ var CustomerService = function(props) {
3450
3536
  }),
3451
3537
  (showType == 4 || showType == 5) && /*#__PURE__*/ _jsxs("div", {
3452
3538
  className: "".concat(styles.ChatWindow_Drawer),
3539
+ style: {
3540
+ display: "".concat(!showScreenshot ? "none" : "flex")
3541
+ },
3453
3542
  id: "",
3454
3543
  children: [
3455
3544
  /*#__PURE__*/ _jsx("div", {
@@ -1177,8 +1177,8 @@
1177
1177
  max-height: 36px;
1178
1178
  word-break: break-all;
1179
1179
 
1180
- display: flex;
1181
- align-items: center;
1180
+ //display: flex;
1181
+ //align-items: center;
1182
1182
  img{
1183
1183
  margin-right: 8px;
1184
1184
  width: 60px;
@@ -1866,7 +1866,7 @@
1866
1866
  width: 417px;
1867
1867
  height: calc(100% - 48px);
1868
1868
  right: 0;
1869
- top: 48px;
1869
+ top: 38px;
1870
1870
  border-radius: 0;
1871
1871
  background: transparent;
1872
1872
  overflow: visible;
@@ -1918,7 +1918,7 @@
1918
1918
  background-color: transparent !important;
1919
1919
  // background-color: burlywood;
1920
1920
  .ReactCrop{
1921
-
1921
+ cursor: default !important;
1922
1922
  }
1923
1923
  :global{
1924
1924
  .ReactCrop__child-wrapper{
@@ -1935,6 +1935,7 @@
1935
1935
  height: 100% !important;
1936
1936
  top: 0 !important;
1937
1937
  left: 0 !important;
1938
+ cursor: default !important;
1938
1939
  }
1939
1940
 
1940
1941
  }
@@ -1175,8 +1175,8 @@
1175
1175
  max-height: 36px;
1176
1176
  word-break: break-all;
1177
1177
 
1178
- display: flex;
1179
- align-items: center;
1178
+ //display: flex;
1179
+ //align-items: center;
1180
1180
  img{
1181
1181
  margin-right: 8px;
1182
1182
  width: 60px;
@@ -1860,7 +1860,7 @@
1860
1860
  width: 417px;
1861
1861
  height: calc(100% - 48px);
1862
1862
  right: 0;
1863
- top: 48px;
1863
+ top: 38px;
1864
1864
  border-radius: 0;
1865
1865
  background: transparent;
1866
1866
  overflow: visible;
@@ -1904,7 +1904,7 @@
1904
1904
  background-color: transparent !important;
1905
1905
  // background-color: burlywood;
1906
1906
  .ReactCrop{
1907
-
1907
+ cursor: default !important;
1908
1908
  }
1909
1909
  :global{
1910
1910
  .ReactCrop__child-wrapper{
@@ -1912,7 +1912,8 @@
1912
1912
  width: 100% !important;
1913
1913
  height: 100% !important;
1914
1914
  top: 0 !important;
1915
- left: 0 !important
1915
+ left: 0 !important;
1916
+ cursor: default !important;
1916
1917
  }
1917
1918
  }
1918
1919
  :global{
@@ -34,10 +34,10 @@ var ScreenshotTool = /*#__PURE__*/ forwardRef(function(props, ref) {
34
34
  image.src = imgBese64; // 将'your_image_url'替换为你自己的图片URL
35
35
  // 等待图片加载完成后再进行操作
36
36
  image.onload = function() {
37
- var x = completedCrop.x; // 起始点x坐标
38
- var y = completedCrop.y; // 起始点y坐标
39
- var width = completedCrop.width; // 需要裁剪的区域宽度
40
- var height = completedCrop.height; // 需要裁剪的区域高度
37
+ var x = parseInt((completedCrop.x * devicePixelRatio).toString()); // 起始点x坐标
38
+ var y = parseInt((completedCrop.y * devicePixelRatio).toString()); // 起始点y坐标
39
+ var width = parseInt((completedCrop.width * devicePixelRatio).toString()); // 需要裁剪的区域宽度
40
+ var height = parseInt((completedCrop.height * devicePixelRatio).toString()); // 需要裁剪的区域高度
41
41
  // 设置canvas大小与裁剪区域相同
42
42
  canvas.width = width;
43
43
  canvas.height = height;
@@ -56,18 +56,20 @@ var ScreenshotTool = /*#__PURE__*/ forwardRef(function(props, ref) {
56
56
  var _useState = _sliced_to_array(useState(), 2), crop = _useState[0], setCrop = _useState[1];
57
57
  var _useState1 = _sliced_to_array(useState(), 2), completedCrop = _useState1[0], setCompletedCrop = _useState1[1];
58
58
  var _useState2 = _sliced_to_array(useState(16 / 9), 2), aspect = _useState2[0], setAspect = _useState2[1];
59
- var _useState3 = _sliced_to_array(useState({
59
+ var _useState3 = _sliced_to_array(useState(window.devicePixelRatio), 2), devicePixelRatio = _useState3[0], setDevicePixelRatio = _useState3[1];
60
+ var _useState4 = _sliced_to_array(useState(true), 2), isFirst = _useState4[0], setIsFirst = _useState4[1];
61
+ var _useState5 = _sliced_to_array(useState({
60
62
  top: 0,
61
63
  left: 0
62
- }), 2), btnPosition = _useState3[0], setBtnPosition = _useState3[1];
63
- var _useState4 = _sliced_to_array(useState(false), 2), showBtn = _useState4[0], setShowBtn = _useState4[1];
64
+ }), 2), btnPosition = _useState5[0], setBtnPosition = _useState5[1];
65
+ var _useState6 = _sliced_to_array(useState(false), 2), showBtn = _useState6[0], setShowBtn = _useState6[1];
64
66
  var savePosition = function(e) {
65
67
  // console.log(e,'位置位置');
66
68
  var x = e.x;
67
69
  var y = e.y;
68
70
  var h = e.height;
69
71
  var w = e.width;
70
- var top = y + h + 8;
72
+ var top = y + h + (isFirst ? 21 : 8);
71
73
  var left = x + w - 88;
72
74
  if (top + 42 > window.innerHeight) {
73
75
  top = top - 50;
@@ -77,6 +79,7 @@ var ScreenshotTool = /*#__PURE__*/ forwardRef(function(props, ref) {
77
79
  left: left
78
80
  });
79
81
  setShowBtn(true);
82
+ setIsFirst(false);
80
83
  };
81
84
  return /*#__PURE__*/ _jsxs("div", {
82
85
  className: styles.screenshot_Modal,
@@ -102,6 +105,9 @@ var ScreenshotTool = /*#__PURE__*/ forwardRef(function(props, ref) {
102
105
  minWidth: 100,
103
106
  children: /*#__PURE__*/ _jsx("img", {
104
107
  alt: "Crop me",
108
+ style: {
109
+ display: "none"
110
+ },
105
111
  src: imgBese64,
106
112
  onLoad: onImageLoad
107
113
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.7.40",
3
+ "version": "0.8.0",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",