@alifd/chat 0.3.46-beta.7 → 0.3.46-beta.8

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.
@@ -13,11 +13,21 @@ import { PREFIX_DEFAULT } from '../utils';
13
13
  import { useThrottle } from '../utils/hooks/useThrottle';
14
14
  import Icon from '../icon';
15
15
  import Empty from './empty';
16
- const CONTAINER_HEIGHT = 103; // 每次超出展示区域的基础移动距离
17
16
  const Document = forwardRef((props, ref) => {
18
- const { className, title = '', content, generating = true, onPreview, onCopy, onDownload, renderDownloadAction, showPreviewButton = true, showCopyButton = true, showDownloadButton = true } = props, rest = __rest(props, ["className", "title", "content", "generating", "onPreview", "onCopy", "onDownload", "renderDownloadAction", "showPreviewButton", "showCopyButton", "showDownloadButton"]);
17
+ const { className, title = '', content, generating = true, onPreview, onCopy, onDownload, renderDownloadAction, showPreviewButton = true, showCopyButton = true, showDownloadButton = true, contentHeight = 128 } = props, rest = __rest(props, ["className", "title", "content", "generating", "onPreview", "onCopy", "onDownload", "renderDownloadAction", "showPreviewButton", "showCopyButton", "showDownloadButton", "contentHeight"]);
18
+ const CONTAINER_HEIGHT = contentHeight - 25; // 每次超出展示区域的基础移动距离
19
+ const INITIAL_HEIGHT = 128; // 初始高度
19
20
  const contentTextRef = useRef(null);
20
21
  const [translateY, setTranslateY] = useState(0);
22
+ // 添加当前高度状态,当 contentHeight > 128 时,从 128 开始逐步增长到 contentHeight
23
+ const [currentHeight, setCurrentHeight] = useState(() => {
24
+ if (generating) {
25
+ return contentHeight > INITIAL_HEIGHT ? INITIAL_HEIGHT : contentHeight;
26
+ }
27
+ else {
28
+ return contentHeight;
29
+ }
30
+ });
21
31
  // 递归查找最底部的元素
22
32
  const findBottommostElement = (element) => {
23
33
  // 获取所有子元素
@@ -45,6 +55,19 @@ const Document = forwardRef((props, ref) => {
45
55
  const bottommostRect = bottommostElement.getBoundingClientRect();
46
56
  const bottommostTop = bottommostRect.top - contentRect.top;
47
57
  const bottommostBottom = bottommostTop + bottommostRect.height;
58
+ // 当 contentHeight > INITIAL_HEIGHT 时,优先处理高度增长逻辑
59
+ if (contentHeight > INITIAL_HEIGHT && currentHeight < contentHeight) {
60
+ const currentContainer = currentHeight - 25;
61
+ // 如果内容超出了当前容器高度,且当前高度还没达到最大高度
62
+ if (bottommostBottom > currentContainer) {
63
+ // 计算需要增加的高度
64
+ const neededHeight = Math.min(contentHeight, // 不超过最大高度
65
+ currentHeight + (bottommostBottom - currentContainer) // 增加所需高度
66
+ );
67
+ setCurrentHeight(neededHeight);
68
+ return;
69
+ }
70
+ }
48
71
  // 判断最后一个元素是否至少部分可见(与窗口有重叠)
49
72
  const isInWindow = bottommostBottom + translateY < CONTAINER_HEIGHT && bottommostTop + translateY > 0;
50
73
  if (!isInWindow) {
@@ -53,7 +76,7 @@ const Document = forwardRef((props, ref) => {
53
76
  return;
54
77
  }
55
78
  return;
56
- }, [translateY]);
79
+ }, [translateY, contentHeight, currentHeight]);
57
80
  // 使用节流处理滚动位置计算,避免频繁调用
58
81
  const throttledCalculateScrollPosition = useThrottle(calculateScrollPosition, 200);
59
82
  // 监听DOM变化,支持React组件内容
@@ -109,7 +132,9 @@ const Document = forwardRef((props, ref) => {
109
132
  }
110
133
  return (React.createElement("div", { className: cs(`${PREFIX_DEFAULT}document-content`, {
111
134
  [`${PREFIX_DEFAULT}document-content-generating`]: generating,
112
- }) },
135
+ }), style: {
136
+ height: currentHeight,
137
+ } },
113
138
  React.createElement("div", { className: `${PREFIX_DEFAULT}document-mask` }),
114
139
  React.createElement("div", { className: `${PREFIX_DEFAULT}document-content-inner` },
115
140
  React.createElement("div", { ref: contentTextRef, className: `${PREFIX_DEFAULT}document-content-text`, style: {
@@ -149,6 +149,7 @@
149
149
  border-left: 0.5px solid var(--color-line1-2, #DEE0E5);
150
150
  border-radius: 0 0 var(--corner-2, 8px) var(--corner-2, 8px);
151
151
  height: 128px;
152
+ transition: height 0.2s ease-out;
152
153
 
153
154
  &-hidden {
154
155
  height: 0;
@@ -198,4 +199,4 @@
198
199
  100% {
199
200
  background-position: -240% 0;
200
201
  }
201
- }
202
+ }
@@ -59,5 +59,10 @@ export interface DocumentProps extends HTMLAttributesWeak {
59
59
  * @en Custom class name
60
60
  */
61
61
  className?: string;
62
+ /**
63
+ * 自定义内容高度
64
+ * @en Content height
65
+ */
66
+ contentHeight?: number;
62
67
  }
63
68
  export {};
@@ -207,43 +207,43 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
207
207
  const parserOptions = {
208
208
  // @ts-expect-error html-react-parser 的类型定义不完整
209
209
  replace: domNode => {
210
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
211
211
  // 处理文本节点
212
212
  if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
213
213
  return processTextNode(domNode);
214
214
  }
215
- //domNode instanceof Element && 先去掉这个判断,现在会被这个判断阻拦
215
+ //domNode instanceof Element 先去掉这个判断,现在有些情况会被这个判断阻拦,导致后续标签逻辑不被执行
216
216
  // @ts-expect-error html-react-parser 的类型定义不完整
217
217
  if (domNode === null || domNode === void 0 ? void 0 : domNode.attribs) { //
218
218
  const { name = '' } = domNode;
219
219
  if (name === 'link-reference') {
220
220
  const element = (domToReact([domNode]));
221
221
  // link-reference 的子元素一定是 a 标签
222
- const aElement = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
222
+ const aElement = (_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a.children;
223
223
  // a 标签的子元素一定是 span 节点
224
224
  const spanElement = (_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.children;
225
225
  const handleUrlClick = () => {
226
- var _a;
226
+ var _a, _b, _c;
227
227
  if (!((_a = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _a === void 0 ? void 0 : _a.href)) {
228
228
  return;
229
229
  }
230
230
  if (handleOpenLink) {
231
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
231
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink((_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.href);
232
232
  }
233
233
  else {
234
- defaultOpenLink(aElement.props.href);
234
+ defaultOpenLink((_c = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _c === void 0 ? void 0 : _c.href);
235
235
  }
236
236
  };
237
237
  return (React.createElement(Balloon, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['hover'], trigger: React.createElement("span", { className: "link-reference-index", onClick: handleUrlClick }, (_c = spanElement === null || spanElement === void 0 ? void 0 : spanElement.props) === null || _c === void 0 ? void 0 : _c.children) },
238
238
  React.createElement("div", { className: "link-reference-content" },
239
- React.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
240
- React.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
239
+ React.createElement("img", { className: "link-reference-source-icon", src: ((_d = element === null || element === void 0 ? void 0 : element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
240
+ React.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element === null || element === void 0 ? void 0 : element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element === null || element === void 0 ? void 0 : element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
241
241
  }
242
242
  if (name === 'a') {
243
243
  const element = (domToReact([domNode]));
244
244
  const { props } = element;
245
- if ((props === null || props === void 0 ? void 0 : props.href) && ((_g = props === null || props === void 0 ? void 0 : props.href) === null || _g === void 0 ? void 0 : _g.startsWith('message://'))) {
246
- const msgValue = decodeURIComponent(props.href.slice(10));
245
+ if ((_g = props === null || props === void 0 ? void 0 : props.href) === null || _g === void 0 ? void 0 : _g.startsWith('message://')) {
246
+ const msgValue = decodeURIComponent((_h = props === null || props === void 0 ? void 0 : props.href) === null || _h === void 0 ? void 0 : _h.slice(10));
247
247
  return React.cloneElement(element, {
248
248
  onClick: () => {
249
249
  if (sendTextMessage) {
@@ -255,7 +255,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
255
255
  href: undefined
256
256
  });
257
257
  }
258
- if ((props === null || props === void 0 ? void 0 : props.href) && ((_h = props === null || props === void 0 ? void 0 : props.href) === null || _h === void 0 ? void 0 : _h.startsWith('copy://'))) {
258
+ if ((_j = props === null || props === void 0 ? void 0 : props.href) === null || _j === void 0 ? void 0 : _j.startsWith('copy://')) {
259
259
  const copyValue = decodeURIComponent(props.href.slice(7));
260
260
  return React.cloneElement(element, {
261
261
  onClick: () => {
@@ -270,14 +270,14 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
270
270
  }
271
271
  return React.cloneElement(element, {
272
272
  onClick: () => {
273
- if (!(props === null || props === void 0 ? void 0 : props.href)) {
273
+ if (!props.href) {
274
274
  return;
275
275
  }
276
276
  if (handleOpenLink) {
277
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(props === null || props === void 0 ? void 0 : props.href);
277
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(props.href);
278
278
  return;
279
279
  }
280
- defaultOpenLink(props === null || props === void 0 ? void 0 : props.href);
280
+ defaultOpenLink(props.href);
281
281
  },
282
282
  href: undefined
283
283
  });
@@ -288,8 +288,9 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
288
288
  return renderImage(element === null || element === void 0 ? void 0 : element.props);
289
289
  }
290
290
  // 换成统一的图片渲染
291
- return React.createElement(Img, Object.assign({}, element.props, { imageClassName: (_j = element.props) === null || _j === void 0 ? void 0 : _j.className, enablePreview: imagePreview, onImageClick: () => {
292
- handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
291
+ return React.createElement(Img, Object.assign({}, element === null || element === void 0 ? void 0 : element.props, { imageClassName: (_k = element === null || element === void 0 ? void 0 : element.props) === null || _k === void 0 ? void 0 : _k.className, enablePreview: imagePreview, onImageClick: () => {
292
+ var _a;
293
+ handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick((_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a.src);
293
294
  } }));
294
295
  }
295
296
  }
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- const defaultURL = 'https://down-cdn.dingtalk.com/ddmedia/iwElAqNwbmcDBgTRAgAF0QIABrDEUWC2t02MZgY_99mvaK0AB9MAAAAAqqG6sAgACapvcGVuLnRvb2xzCgAL0gABF7E.png_620x10000q90.jpg';
2
+ const defaultURL = 'https://img.alicdn.com/imgextra/i4/O1CN01XqHsDa1lIccYqE7UE_!!6000000004796-2-tps-371-200.png';
3
3
  function decodeMediaId(mediaId) {
4
4
  const decodeFromBase64 = e => {
5
5
  var n = window.atob(e), r = n.length, o = new Uint8Array(r);
package/es/index.js CHANGED
@@ -39,4 +39,4 @@ export { default as Checkbox } from './checkbox';
39
39
  export { default as ErrorNotice } from './error-notice';
40
40
  export { default as Document } from './document';
41
41
  export * from './types';
42
- export const version = '0.3.46-beta.7';
42
+ export const version = '0.3.46-beta.8';
@@ -15,11 +15,21 @@ const utils_1 = require("../utils");
15
15
  const useThrottle_1 = require("../utils/hooks/useThrottle");
16
16
  const icon_1 = tslib_1.__importDefault(require("../icon"));
17
17
  const empty_1 = tslib_1.__importDefault(require("./empty"));
18
- const CONTAINER_HEIGHT = 103; // 每次超出展示区域的基础移动距离
19
18
  const Document = (0, react_1.forwardRef)((props, ref) => {
20
- const { className, title = '', content, generating = true, onPreview, onCopy, onDownload, renderDownloadAction, showPreviewButton = true, showCopyButton = true, showDownloadButton = true } = props, rest = tslib_1.__rest(props, ["className", "title", "content", "generating", "onPreview", "onCopy", "onDownload", "renderDownloadAction", "showPreviewButton", "showCopyButton", "showDownloadButton"]);
19
+ const { className, title = '', content, generating = true, onPreview, onCopy, onDownload, renderDownloadAction, showPreviewButton = true, showCopyButton = true, showDownloadButton = true, contentHeight = 128 } = props, rest = tslib_1.__rest(props, ["className", "title", "content", "generating", "onPreview", "onCopy", "onDownload", "renderDownloadAction", "showPreviewButton", "showCopyButton", "showDownloadButton", "contentHeight"]);
20
+ const CONTAINER_HEIGHT = contentHeight - 25; // 每次超出展示区域的基础移动距离
21
+ const INITIAL_HEIGHT = 128; // 初始高度
21
22
  const contentTextRef = (0, react_1.useRef)(null);
22
23
  const [translateY, setTranslateY] = (0, react_1.useState)(0);
24
+ // 添加当前高度状态,当 contentHeight > 128 时,从 128 开始逐步增长到 contentHeight
25
+ const [currentHeight, setCurrentHeight] = (0, react_1.useState)(() => {
26
+ if (generating) {
27
+ return contentHeight > INITIAL_HEIGHT ? INITIAL_HEIGHT : contentHeight;
28
+ }
29
+ else {
30
+ return contentHeight;
31
+ }
32
+ });
23
33
  // 递归查找最底部的元素
24
34
  const findBottommostElement = (element) => {
25
35
  // 获取所有子元素
@@ -47,6 +57,19 @@ const Document = (0, react_1.forwardRef)((props, ref) => {
47
57
  const bottommostRect = bottommostElement.getBoundingClientRect();
48
58
  const bottommostTop = bottommostRect.top - contentRect.top;
49
59
  const bottommostBottom = bottommostTop + bottommostRect.height;
60
+ // 当 contentHeight > INITIAL_HEIGHT 时,优先处理高度增长逻辑
61
+ if (contentHeight > INITIAL_HEIGHT && currentHeight < contentHeight) {
62
+ const currentContainer = currentHeight - 25;
63
+ // 如果内容超出了当前容器高度,且当前高度还没达到最大高度
64
+ if (bottommostBottom > currentContainer) {
65
+ // 计算需要增加的高度
66
+ const neededHeight = Math.min(contentHeight, // 不超过最大高度
67
+ currentHeight + (bottommostBottom - currentContainer) // 增加所需高度
68
+ );
69
+ setCurrentHeight(neededHeight);
70
+ return;
71
+ }
72
+ }
50
73
  // 判断最后一个元素是否至少部分可见(与窗口有重叠)
51
74
  const isInWindow = bottommostBottom + translateY < CONTAINER_HEIGHT && bottommostTop + translateY > 0;
52
75
  if (!isInWindow) {
@@ -55,7 +78,7 @@ const Document = (0, react_1.forwardRef)((props, ref) => {
55
78
  return;
56
79
  }
57
80
  return;
58
- }, [translateY]);
81
+ }, [translateY, contentHeight, currentHeight]);
59
82
  // 使用节流处理滚动位置计算,避免频繁调用
60
83
  const throttledCalculateScrollPosition = (0, useThrottle_1.useThrottle)(calculateScrollPosition, 200);
61
84
  // 监听DOM变化,支持React组件内容
@@ -111,7 +134,9 @@ const Document = (0, react_1.forwardRef)((props, ref) => {
111
134
  }
112
135
  return (react_1.default.createElement("div", { className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}document-content`, {
113
136
  [`${utils_1.PREFIX_DEFAULT}document-content-generating`]: generating,
114
- }) },
137
+ }), style: {
138
+ height: currentHeight,
139
+ } },
115
140
  react_1.default.createElement("div", { className: `${utils_1.PREFIX_DEFAULT}document-mask` }),
116
141
  react_1.default.createElement("div", { className: `${utils_1.PREFIX_DEFAULT}document-content-inner` },
117
142
  react_1.default.createElement("div", { ref: contentTextRef, className: `${utils_1.PREFIX_DEFAULT}document-content-text`, style: {
@@ -149,6 +149,7 @@
149
149
  border-left: 0.5px solid var(--color-line1-2, #DEE0E5);
150
150
  border-radius: 0 0 var(--corner-2, 8px) var(--corner-2, 8px);
151
151
  height: 128px;
152
+ transition: height 0.2s ease-out;
152
153
 
153
154
  &-hidden {
154
155
  height: 0;
@@ -198,4 +199,4 @@
198
199
  100% {
199
200
  background-position: -240% 0;
200
201
  }
201
- }
202
+ }
@@ -59,5 +59,10 @@ export interface DocumentProps extends HTMLAttributesWeak {
59
59
  * @en Custom class name
60
60
  */
61
61
  className?: string;
62
+ /**
63
+ * 自定义内容高度
64
+ * @en Content height
65
+ */
66
+ contentHeight?: number;
62
67
  }
63
68
  export {};
@@ -210,43 +210,43 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
210
210
  const parserOptions = {
211
211
  // @ts-expect-error html-react-parser 的类型定义不完整
212
212
  replace: domNode => {
213
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
213
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
214
214
  // 处理文本节点
215
215
  if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
216
216
  return processTextNode(domNode);
217
217
  }
218
- //domNode instanceof Element && 先去掉这个判断,现在会被这个判断阻拦
218
+ //domNode instanceof Element 先去掉这个判断,现在有些情况会被这个判断阻拦,导致后续标签逻辑不被执行
219
219
  // @ts-expect-error html-react-parser 的类型定义不完整
220
220
  if (domNode === null || domNode === void 0 ? void 0 : domNode.attribs) { //
221
221
  const { name = '' } = domNode;
222
222
  if (name === 'link-reference') {
223
223
  const element = ((0, html_react_parser_1.domToReact)([domNode]));
224
224
  // link-reference 的子元素一定是 a 标签
225
- const aElement = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
225
+ const aElement = (_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a.children;
226
226
  // a 标签的子元素一定是 span 节点
227
227
  const spanElement = (_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.children;
228
228
  const handleUrlClick = () => {
229
- var _a;
229
+ var _a, _b, _c;
230
230
  if (!((_a = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _a === void 0 ? void 0 : _a.href)) {
231
231
  return;
232
232
  }
233
233
  if (handleOpenLink) {
234
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
234
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink((_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.href);
235
235
  }
236
236
  else {
237
- defaultOpenLink(aElement.props.href);
237
+ defaultOpenLink((_c = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _c === void 0 ? void 0 : _c.href);
238
238
  }
239
239
  };
240
240
  return (react_1.default.createElement(balloon_1.default, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['hover'], trigger: react_1.default.createElement("span", { className: "link-reference-index", onClick: handleUrlClick }, (_c = spanElement === null || spanElement === void 0 ? void 0 : spanElement.props) === null || _c === void 0 ? void 0 : _c.children) },
241
241
  react_1.default.createElement("div", { className: "link-reference-content" },
242
- react_1.default.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
243
- react_1.default.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
242
+ react_1.default.createElement("img", { className: "link-reference-source-icon", src: ((_d = element === null || element === void 0 ? void 0 : element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
243
+ react_1.default.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element === null || element === void 0 ? void 0 : element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element === null || element === void 0 ? void 0 : element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
244
244
  }
245
245
  if (name === 'a') {
246
246
  const element = ((0, html_react_parser_1.domToReact)([domNode]));
247
247
  const { props } = element;
248
- if ((props === null || props === void 0 ? void 0 : props.href) && ((_g = props === null || props === void 0 ? void 0 : props.href) === null || _g === void 0 ? void 0 : _g.startsWith('message://'))) {
249
- const msgValue = decodeURIComponent(props.href.slice(10));
248
+ if ((_g = props === null || props === void 0 ? void 0 : props.href) === null || _g === void 0 ? void 0 : _g.startsWith('message://')) {
249
+ const msgValue = decodeURIComponent((_h = props === null || props === void 0 ? void 0 : props.href) === null || _h === void 0 ? void 0 : _h.slice(10));
250
250
  return react_1.default.cloneElement(element, {
251
251
  onClick: () => {
252
252
  if (sendTextMessage) {
@@ -258,7 +258,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
258
258
  href: undefined
259
259
  });
260
260
  }
261
- if ((props === null || props === void 0 ? void 0 : props.href) && ((_h = props === null || props === void 0 ? void 0 : props.href) === null || _h === void 0 ? void 0 : _h.startsWith('copy://'))) {
261
+ if ((_j = props === null || props === void 0 ? void 0 : props.href) === null || _j === void 0 ? void 0 : _j.startsWith('copy://')) {
262
262
  const copyValue = decodeURIComponent(props.href.slice(7));
263
263
  return react_1.default.cloneElement(element, {
264
264
  onClick: () => {
@@ -273,14 +273,14 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
273
273
  }
274
274
  return react_1.default.cloneElement(element, {
275
275
  onClick: () => {
276
- if (!(props === null || props === void 0 ? void 0 : props.href)) {
276
+ if (!props.href) {
277
277
  return;
278
278
  }
279
279
  if (handleOpenLink) {
280
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(props === null || props === void 0 ? void 0 : props.href);
280
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(props.href);
281
281
  return;
282
282
  }
283
- defaultOpenLink(props === null || props === void 0 ? void 0 : props.href);
283
+ defaultOpenLink(props.href);
284
284
  },
285
285
  href: undefined
286
286
  });
@@ -291,8 +291,9 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
291
291
  return renderImage(element === null || element === void 0 ? void 0 : element.props);
292
292
  }
293
293
  // 换成统一的图片渲染
294
- return react_1.default.createElement(img_1.default, Object.assign({}, element.props, { imageClassName: (_j = element.props) === null || _j === void 0 ? void 0 : _j.className, enablePreview: imagePreview, onImageClick: () => {
295
- handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
294
+ return react_1.default.createElement(img_1.default, Object.assign({}, element === null || element === void 0 ? void 0 : element.props, { imageClassName: (_k = element === null || element === void 0 ? void 0 : element.props) === null || _k === void 0 ? void 0 : _k.className, enablePreview: imagePreview, onImageClick: () => {
295
+ var _a;
296
+ handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick((_a = element === null || element === void 0 ? void 0 : element.props) === null || _a === void 0 ? void 0 : _a.src);
296
297
  } }));
297
298
  }
298
299
  }
@@ -2,7 +2,7 @@
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getImageURL = getImageURL;
5
- const defaultURL = 'https://down-cdn.dingtalk.com/ddmedia/iwElAqNwbmcDBgTRAgAF0QIABrDEUWC2t02MZgY_99mvaK0AB9MAAAAAqqG6sAgACapvcGVuLnRvb2xzCgAL0gABF7E.png_620x10000q90.jpg';
5
+ const defaultURL = 'https://img.alicdn.com/imgextra/i4/O1CN01XqHsDa1lIccYqE7UE_!!6000000004796-2-tps-371-200.png';
6
6
  function decodeMediaId(mediaId) {
7
7
  const decodeFromBase64 = e => {
8
8
  var n = window.atob(e), r = n.length, o = new Uint8Array(r);
package/lib/index.js CHANGED
@@ -84,4 +84,4 @@ Object.defineProperty(exports, "ErrorNotice", { enumerable: true, get: function
84
84
  var document_1 = require("./document");
85
85
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return tslib_1.__importDefault(document_1).default; } });
86
86
  tslib_1.__exportStar(require("./types"), exports);
87
- exports.version = '0.3.46-beta.7';
87
+ exports.version = '0.3.46-beta.8';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.46-beta.7",
3
+ "version": "0.3.46-beta.8",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",