bhd-components 0.11.13 → 0.11.14

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.
@@ -44,6 +44,7 @@ export interface msgActionProps {
44
44
 
45
45
  export interface contentConfigProps {
46
46
  className?: string;
47
+ htmlStyle?:"richText"|"ai_body";// markdown转html的样式 内置支持 richText(new_yun) ai_body(bigme)
47
48
  msgAction?: string[] | msgActionProps;
48
49
  // transformItem:(item: any) => dataItemType;
49
50
  getList: (
@@ -78,6 +79,9 @@ export interface contentConfigProps {
78
79
  onSendedHelloMsg?: () => void; //发送招呼语之后
79
80
  onInit?: () => void; //组件初始化
80
81
  renderLoading?: (type:"init"|"loadMore",initLoadNode:React.ReactNode,loadMoreNode:React.ReactNode) => React.ReactNode;
82
+ renderItemBottom?: (item: dataItemType) => React.ReactNode;
83
+ renderItemTop?: (item: dataItemType) => React.ReactNode;
84
+
81
85
  }
82
86
 
83
87
  // content props
@@ -93,6 +97,7 @@ export interface contentProps {
93
97
  export interface footerConfigProps {
94
98
  placeholder?: string; // placeholder 默认值为“请输入内容”
95
99
  className?: string;
100
+ textAreaProps?:object;
96
101
  maxLength?: number | ((value: string) => boolean); //字符长度 默认500
97
102
  renderAction?: (
98
103
  sendBtn: React.ReactNode,
@@ -105,7 +110,7 @@ export interface footerConfigProps {
105
110
  renderTopContent?: () => React.ReactNode;
106
111
  inputingText?: string;
107
112
  canStopMessage?: boolean;//是否允许停止消息 默认为true
108
- speed:number;// 控制文字每次输出的速度 默认为0 即不控制
113
+ speed?:number;// 控制文字每次输出的速度 默认为0 即不控制
109
114
  }
110
115
 
111
116
  export interface onOpenProps {
@@ -32,7 +32,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
32
32
  var footerConfig = props.footerConfig, prefix = props.prefix, errorCallback = props.errorCallback, apiRef = props.apiRef;
33
33
  var _footerConfig_placeholder = footerConfig.placeholder, placeholder = _footerConfig_placeholder === void 0 ? defaultProps.placeholder : _footerConfig_placeholder, _footerConfig_className = footerConfig.className, className = _footerConfig_className === void 0 ? defaultProps.className : _footerConfig_className, _footerConfig_maxLength = footerConfig.maxLength, maxLength = _footerConfig_maxLength === void 0 ? defaultProps.maxLength : _footerConfig_maxLength, renderAction = footerConfig.renderAction, fileUpload = footerConfig.fileUpload, sendMsgAjaxParams = footerConfig.sendMsgAjaxParams, _footerConfig_onClickStop = footerConfig.onClickStop, onClickStop = _footerConfig_onClickStop === void 0 ? function() {} : _footerConfig_onClickStop, _footerConfig_conversionContent = footerConfig.conversionContent, conversionContent = _footerConfig_conversionContent === void 0 ? function(str) {
34
34
  return str;
35
- } : _footerConfig_conversionContent, renderTopContent = footerConfig.renderTopContent, _footerConfig_inputingText = footerConfig.inputingText, inputingText = _footerConfig_inputingText === void 0 ? "正在输入..." : _footerConfig_inputingText, _footerConfig_canStopMessage = footerConfig.canStopMessage, canStopMessage = _footerConfig_canStopMessage === void 0 ? true : _footerConfig_canStopMessage, _footerConfig_speed = footerConfig.speed, speed = _footerConfig_speed === void 0 ? 0 : _footerConfig_speed;
35
+ } : _footerConfig_conversionContent, renderTopContent = footerConfig.renderTopContent, _footerConfig_inputingText = footerConfig.inputingText, inputingText = _footerConfig_inputingText === void 0 ? "正在输入..." : _footerConfig_inputingText, _footerConfig_canStopMessage = footerConfig.canStopMessage, canStopMessage = _footerConfig_canStopMessage === void 0 ? true : _footerConfig_canStopMessage, _footerConfig_speed = footerConfig.speed, speed = _footerConfig_speed === void 0 ? 0 : _footerConfig_speed, _footerConfig_textAreaProps = footerConfig.textAreaProps, textAreaProps = _footerConfig_textAreaProps === void 0 ? {} : _footerConfig_textAreaProps;
36
36
  if (speed < 0) {
37
37
  speed = 0;
38
38
  }
@@ -503,7 +503,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
503
503
  /*#__PURE__*/ _jsxs("div", {
504
504
  className: getCls("footerInput"),
505
505
  children: [
506
- /*#__PURE__*/ _jsx(TextArea, {
506
+ /*#__PURE__*/ _jsx(TextArea, _object_spread({
507
507
  value: textValue,
508
508
  onChange: function(e) {
509
509
  setTextValue(e.target.value);
@@ -514,7 +514,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
514
514
  maxRows: 6
515
515
  },
516
516
  onPressEnter: onPressEnter
517
- }),
517
+ }, textAreaProps)),
518
518
  /*#__PURE__*/ _jsx(References, {
519
519
  prefix: prefix,
520
520
  referencesSource: referencesSource,
@@ -95,7 +95,8 @@ var remarkable = new Remarkable({
95
95
  return hljs.highlightAuto(str).value;
96
96
  } catch (err) {}
97
97
  return ""; // use external default escaping
98
- }
98
+ },
99
+ breaks: true
99
100
  });
100
101
  var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
101
102
  var prefix = props.prefix, contentConfig = props.contentConfig, apiRef = props.apiRef;
@@ -103,7 +104,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
103
104
  "copy",
104
105
  "reference"
105
106
  ] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage, _contentConfig_onVoteChange = contentConfig.onVoteChange, onVoteChange = _contentConfig_onVoteChange === void 0 ? function() {} : _contentConfig_onVoteChange, _contentConfig_onRefresh = contentConfig.onRefresh, onRefresh = _contentConfig_onRefresh === void 0 ? function() {} : _contentConfig_onRefresh, helloMsg = contentConfig.helloMsg, _contentConfig_showTime = contentConfig.showTime, showTime = _contentConfig_showTime === void 0 ? true : _contentConfig_showTime, _contentConfig_fileCustomRender = contentConfig.fileCustomRender, fileCustomRender = _contentConfig_fileCustomRender === void 0 ? {} : _contentConfig_fileCustomRender, _contentConfig_onInit = contentConfig.// onSendedHelloMsg = () => {},
106
- onInit, onInit = _contentConfig_onInit === void 0 ? function() {} : _contentConfig_onInit, renderLoading = contentConfig.renderLoading;
107
+ onInit, onInit = _contentConfig_onInit === void 0 ? function() {} : _contentConfig_onInit, renderLoading = contentConfig.renderLoading, renderItemBottom = contentConfig.renderItemBottom, renderItemTop = contentConfig.renderItemTop, _contentConfig_htmlStyle = contentConfig.htmlStyle, htmlStyle = _contentConfig_htmlStyle === void 0 ? "richText" : _contentConfig_htmlStyle;
107
108
  var loadMoreProps = contentConfig.loadMore || true;
108
109
  var virtuosoRef = useRef(null);
109
110
  var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
@@ -384,19 +385,21 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
384
385
  return onMouseLeave(item);
385
386
  },
386
387
  children: [
388
+ renderItemTop && renderItemTop(item),
387
389
  renderAction("floatTop", item),
388
390
  /*#__PURE__*/ _jsxs("div", {
389
391
  className: "".concat(getCls("msgItem-content")),
390
392
  children: [
391
393
  /*#__PURE__*/ _jsx("div", {
392
- className: "".concat(getCls("msgItem-text")),
394
+ className: "".concat(htmlStyle === "richText" ? getCls("msgItem-text") : getCls("msgItem-text-aibody")),
393
395
  children: contentNode
394
396
  }),
395
397
  renderAction("bottom", item)
396
398
  ]
397
399
  }),
398
400
  item.location === "left" && renderAction("floatBottom", item),
399
- renderReference(item)
401
+ renderReference(item),
402
+ renderItemBottom && renderItemBottom(item)
400
403
  ]
401
404
  })
402
405
  });
@@ -637,6 +640,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
637
640
  };
638
641
  var markToHtml = function(markStr, id) {
639
642
  var html = remarkable.render(markStr);
643
+ if (htmlStyle === "ai_body") {
644
+ html = html.replace(/<table/g, '<div class="ai-table-wrap"><table').replace(/<\/table>/g, "</table></div>");
645
+ }
640
646
  var position = 0;
641
647
  html = html.replace(new RegExp("<pre", "ig"), function() {
642
648
  position++;