@alifd/chat 0.3.32-beta.1 → 0.3.32-beta.3

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.
@@ -103,7 +103,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
103
103
  const parserOptions = {
104
104
  // @ts-ignore
105
105
  replace: domNode => {
106
- var _a;
106
+ var _a, _b, _c, _d, _e, _f;
107
107
  // 处理文本节点
108
108
  if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
109
109
  return processTextNode(domNode);
@@ -113,19 +113,25 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
113
113
  if (name === 'link-reference') {
114
114
  const element = (domToReact([domNode]));
115
115
  // link-reference 的子元素一定是 a 标签
116
- const aElement = element.props.children;
116
+ const aElement = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
117
117
  // a 标签的子元素一定是 span 节点
118
- const spanElement = aElement.props.children;
119
- return (React.createElement(Balloon, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['click'], trigger: React.createElement("span", { className: "link-reference-index" }, spanElement.props.children) },
118
+ const spanElement = (_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.children;
119
+ const handleUrlClick = () => {
120
+ var _a;
121
+ if (!((_a = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _a === void 0 ? void 0 : _a.href)) {
122
+ return;
123
+ }
124
+ if (handleOpenLink) {
125
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
126
+ }
127
+ else {
128
+ defaultOpenLink(aElement.props.href);
129
+ }
130
+ };
131
+ 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) },
120
132
  React.createElement("div", { className: "link-reference-content" },
121
- React.createElement("img", { className: "link-reference-source-icon", src: element.props['data-source-icon'] }),
122
- React.createElement("a", { className: "link-reference-title", onClick: () => {
123
- if (handleOpenLink) {
124
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
125
- return;
126
- }
127
- defaultOpenLink(aElement.props.href);
128
- } }, element.props['data-title']))));
133
+ React.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
134
+ React.createElement("a", { className: "link-reference-title", onClick: handleUrlClick }, ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || ''))));
129
135
  }
130
136
  if (name === 'a') {
131
137
  const element = (domToReact([domNode]));
@@ -179,7 +185,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
179
185
  return renderImage(element.props);
180
186
  }
181
187
  // 换成统一的图片渲染
182
- return React.createElement(Img, Object.assign({}, element.props, { imageClassName: (_a = element.props) === null || _a === void 0 ? void 0 : _a.className, enablePreview: imagePreview, onImageClick: () => {
188
+ return React.createElement(Img, Object.assign({}, element.props, { imageClassName: (_f = element.props) === null || _f === void 0 ? void 0 : _f.className, enablePreview: imagePreview, onImageClick: () => {
183
189
  handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
184
190
  } }));
185
191
  }
@@ -257,8 +257,11 @@
257
257
  }
258
258
  }
259
259
  .link-reference-index {
260
+ display: inline-block;
260
261
  font-size: 10px;
261
262
  line-height: 16px;
263
+ height: 16px;
264
+ vertical-align: text-bottom;
262
265
  border-radius: 4px;
263
266
  color: $color-text1-3;
264
267
  background-color: $color-fill1-2;
package/es/index.js CHANGED
@@ -31,4 +31,4 @@ export { default as RadioGroup } from './radio-group';
31
31
  export { default as CheckboxGroup } from './checkbox-group';
32
32
  export { default as Select } from './select';
33
33
  export { default as Flip } from './flip';
34
- export const version = '0.3.32-beta.1';
34
+ export const version = '0.3.32-beta.3';
@@ -106,7 +106,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
106
106
  const parserOptions = {
107
107
  // @ts-ignore
108
108
  replace: domNode => {
109
- var _a;
109
+ var _a, _b, _c, _d, _e, _f;
110
110
  // 处理文本节点
111
111
  if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
112
112
  return processTextNode(domNode);
@@ -116,19 +116,25 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
116
116
  if (name === 'link-reference') {
117
117
  const element = ((0, html_react_parser_1.domToReact)([domNode]));
118
118
  // link-reference 的子元素一定是 a 标签
119
- const aElement = element.props.children;
119
+ const aElement = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
120
120
  // a 标签的子元素一定是 span 节点
121
- const spanElement = aElement.props.children;
122
- return (react_1.default.createElement(balloon_1.default, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['click'], trigger: react_1.default.createElement("span", { className: "link-reference-index" }, spanElement.props.children) },
121
+ const spanElement = (_b = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _b === void 0 ? void 0 : _b.children;
122
+ const handleUrlClick = () => {
123
+ var _a;
124
+ if (!((_a = aElement === null || aElement === void 0 ? void 0 : aElement.props) === null || _a === void 0 ? void 0 : _a.href)) {
125
+ return;
126
+ }
127
+ if (handleOpenLink) {
128
+ handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
129
+ }
130
+ else {
131
+ defaultOpenLink(aElement.props.href);
132
+ }
133
+ };
134
+ 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) },
123
135
  react_1.default.createElement("div", { className: "link-reference-content" },
124
- react_1.default.createElement("img", { className: "link-reference-source-icon", src: element.props['data-source-icon'] }),
125
- react_1.default.createElement("a", { className: "link-reference-title", onClick: () => {
126
- if (handleOpenLink) {
127
- handleOpenLink === null || handleOpenLink === void 0 ? void 0 : handleOpenLink(aElement.props.href);
128
- return;
129
- }
130
- defaultOpenLink(aElement.props.href);
131
- } }, element.props['data-title']))));
136
+ react_1.default.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
137
+ react_1.default.createElement("a", { className: "link-reference-title", onClick: handleUrlClick }, ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || ''))));
132
138
  }
133
139
  if (name === 'a') {
134
140
  const element = ((0, html_react_parser_1.domToReact)([domNode]));
@@ -182,7 +188,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
182
188
  return renderImage(element.props);
183
189
  }
184
190
  // 换成统一的图片渲染
185
- return react_1.default.createElement(img_1.default, Object.assign({}, element.props, { imageClassName: (_a = element.props) === null || _a === void 0 ? void 0 : _a.className, enablePreview: imagePreview, onImageClick: () => {
191
+ return react_1.default.createElement(img_1.default, Object.assign({}, element.props, { imageClassName: (_f = element.props) === null || _f === void 0 ? void 0 : _f.className, enablePreview: imagePreview, onImageClick: () => {
186
192
  handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
187
193
  } }));
188
194
  }
@@ -257,8 +257,11 @@
257
257
  }
258
258
  }
259
259
  .link-reference-index {
260
+ display: inline-block;
260
261
  font-size: 10px;
261
262
  line-height: 16px;
263
+ height: 16px;
264
+ vertical-align: text-bottom;
262
265
  border-radius: 4px;
263
266
  color: $color-text1-3;
264
267
  background-color: $color-fill1-2;
package/lib/index.js CHANGED
@@ -68,4 +68,4 @@ var select_1 = require("./select");
68
68
  Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return tslib_1.__importDefault(select_1).default; } });
69
69
  var flip_1 = require("./flip");
70
70
  Object.defineProperty(exports, "Flip", { enumerable: true, get: function () { return tslib_1.__importDefault(flip_1).default; } });
71
- exports.version = '0.3.32-beta.1';
71
+ exports.version = '0.3.32-beta.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.32-beta.1",
3
+ "version": "0.3.32-beta.3",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",