@alifd/chat 0.3.31 → 0.3.32-beta.1

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.
@@ -1,4 +1,5 @@
1
1
  import { HTMLRendererProps } from './types';
2
+ import '../balloon/style';
2
3
  export * from './types';
3
4
  declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<HTMLRendererProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown, {}>;
4
5
  export default _default;
@@ -15,12 +15,15 @@ import { ConfigProvider } from '@alifd/next';
15
15
  import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
16
16
  import copy from 'copy-to-clipboard';
17
17
  import { Message } from '@alifd/next';
18
+ import Balloon from '../balloon';
19
+ import '../balloon/style';
18
20
  const IMAGE_MAX_HEIGHT = 222;
19
21
  const IMAGE_MAX_WIDTH = 372;
20
22
  const sanitizeHtmlOptions = {
21
23
  allowedTags: sanitizeHtml.defaults.allowedTags.concat([
22
24
  'acronym', 'audio', 'big', 'center', 'del', 'dir', 'font',
23
25
  'img', 'ins', 'source', 'strike', 'track', 'tt', 'video',
26
+ 'link-reference',
24
27
  ]),
25
28
  allowedAttributes: {
26
29
  '*': ['data-*', 'title', 'align', 'bgcolor', 'class', 'style'],
@@ -107,6 +110,23 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
107
110
  }
108
111
  if (domNode instanceof Element && domNode.attribs) {
109
112
  const { name } = domNode;
113
+ if (name === 'link-reference') {
114
+ const element = (domToReact([domNode]));
115
+ // link-reference 的子元素一定是 a 标签
116
+ const aElement = element.props.children;
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) },
120
+ 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']))));
129
+ }
110
130
  if (name === 'a') {
111
131
  const element = (domToReact([domNode]));
112
132
  const { props } = element;
@@ -256,4 +256,84 @@
256
256
  opacity: 1;
257
257
  }
258
258
  }
259
+ .link-reference-index {
260
+ font-size: 10px;
261
+ line-height: 16px;
262
+ border-radius: 4px;
263
+ color: $color-text1-3;
264
+ background-color: $color-fill1-2;
265
+ margin: 0 4px;
266
+ padding: 0 4px;
267
+ cursor: pointer;
268
+ user-select: none;
269
+ --web-kit-user-select: none;
270
+ transition: color 0.3s, background-color 0.3s;
271
+
272
+ @media (hover: hover) {
273
+ &:hover {
274
+ background-color: $color-brand1-6;
275
+ color: $color-bg-1;
276
+ }
277
+ }
278
+
279
+ // 移动端触摸反馈
280
+ &:active {
281
+ background-color: $color-brand1-6;
282
+ color: $color-bg-1;
283
+ }
284
+ }
285
+ }
286
+
287
+ .link-reference-balloon {
288
+ max-width: 168px !important;
289
+ background-color: $color-bg-1 !important;
290
+ border-radius: 6px !important;
291
+ padding: 8px !important;
292
+
293
+ .link-reference-source-icon {
294
+ flex: none;
295
+ width: 28px;
296
+ height: 16px;
297
+ position: relative;
298
+ transition: all 0.3s ease;
299
+
300
+ &::before {
301
+ content: "";
302
+ position: absolute;
303
+ top: 0;
304
+ left: 0;
305
+ width: 100%;
306
+ height: 100%;
307
+ border-radius: 4px;
308
+ display: none;
309
+ }
310
+ }
311
+
312
+ .link-reference-content {
313
+ display: flex;
314
+ align-items: center;
315
+ gap: 4px;
316
+ .link-reference-title {
317
+ overflow: hidden;
318
+ text-overflow: ellipsis;
319
+ white-space: nowrap;
320
+ }
321
+ }
322
+
323
+ .next-balloon-arrow {
324
+ display: none !important;
325
+ }
326
+ a {
327
+ cursor: pointer;
328
+ color: $color-link-1;
329
+ text-decoration: none;
330
+ &:hover {
331
+ color: $color-link-2;
332
+ text-decoration: none;
333
+ }
334
+ &:focus, &:visited {
335
+ color: $color-link-3;
336
+ text-decoration: none;
337
+ }
338
+ }
259
339
  }
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.31';
34
+ export const version = '0.3.32-beta.1';
@@ -1,4 +1,5 @@
1
1
  import { HTMLRendererProps } from './types';
2
+ import '../balloon/style';
2
3
  export * from './types';
3
4
  declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<HTMLRendererProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, unknown, {}>;
4
5
  export default _default;
@@ -18,12 +18,15 @@ const next_1 = require("@alifd/next");
18
18
  const utils_1 = require("../utils");
19
19
  const copy_to_clipboard_1 = tslib_1.__importDefault(require("copy-to-clipboard"));
20
20
  const next_2 = require("@alifd/next");
21
+ const balloon_1 = tslib_1.__importDefault(require("../balloon"));
22
+ require("../balloon/style");
21
23
  const IMAGE_MAX_HEIGHT = 222;
22
24
  const IMAGE_MAX_WIDTH = 372;
23
25
  const sanitizeHtmlOptions = {
24
26
  allowedTags: sanitize_html_1.default.defaults.allowedTags.concat([
25
27
  'acronym', 'audio', 'big', 'center', 'del', 'dir', 'font',
26
28
  'img', 'ins', 'source', 'strike', 'track', 'tt', 'video',
29
+ 'link-reference',
27
30
  ]),
28
31
  allowedAttributes: {
29
32
  '*': ['data-*', 'title', 'align', 'bgcolor', 'class', 'style'],
@@ -110,6 +113,23 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
110
113
  }
111
114
  if (domNode instanceof html_react_parser_1.Element && domNode.attribs) {
112
115
  const { name } = domNode;
116
+ if (name === 'link-reference') {
117
+ const element = ((0, html_react_parser_1.domToReact)([domNode]));
118
+ // link-reference 的子元素一定是 a 标签
119
+ const aElement = element.props.children;
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) },
123
+ 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']))));
132
+ }
113
133
  if (name === 'a') {
114
134
  const element = ((0, html_react_parser_1.domToReact)([domNode]));
115
135
  const { props } = element;
@@ -256,4 +256,84 @@
256
256
  opacity: 1;
257
257
  }
258
258
  }
259
+ .link-reference-index {
260
+ font-size: 10px;
261
+ line-height: 16px;
262
+ border-radius: 4px;
263
+ color: $color-text1-3;
264
+ background-color: $color-fill1-2;
265
+ margin: 0 4px;
266
+ padding: 0 4px;
267
+ cursor: pointer;
268
+ user-select: none;
269
+ --web-kit-user-select: none;
270
+ transition: color 0.3s, background-color 0.3s;
271
+
272
+ @media (hover: hover) {
273
+ &:hover {
274
+ background-color: $color-brand1-6;
275
+ color: $color-bg-1;
276
+ }
277
+ }
278
+
279
+ // 移动端触摸反馈
280
+ &:active {
281
+ background-color: $color-brand1-6;
282
+ color: $color-bg-1;
283
+ }
284
+ }
285
+ }
286
+
287
+ .link-reference-balloon {
288
+ max-width: 168px !important;
289
+ background-color: $color-bg-1 !important;
290
+ border-radius: 6px !important;
291
+ padding: 8px !important;
292
+
293
+ .link-reference-source-icon {
294
+ flex: none;
295
+ width: 28px;
296
+ height: 16px;
297
+ position: relative;
298
+ transition: all 0.3s ease;
299
+
300
+ &::before {
301
+ content: "";
302
+ position: absolute;
303
+ top: 0;
304
+ left: 0;
305
+ width: 100%;
306
+ height: 100%;
307
+ border-radius: 4px;
308
+ display: none;
309
+ }
310
+ }
311
+
312
+ .link-reference-content {
313
+ display: flex;
314
+ align-items: center;
315
+ gap: 4px;
316
+ .link-reference-title {
317
+ overflow: hidden;
318
+ text-overflow: ellipsis;
319
+ white-space: nowrap;
320
+ }
321
+ }
322
+
323
+ .next-balloon-arrow {
324
+ display: none !important;
325
+ }
326
+ a {
327
+ cursor: pointer;
328
+ color: $color-link-1;
329
+ text-decoration: none;
330
+ &:hover {
331
+ color: $color-link-2;
332
+ text-decoration: none;
333
+ }
334
+ &:focus, &:visited {
335
+ color: $color-link-3;
336
+ text-decoration: none;
337
+ }
338
+ }
259
339
  }
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.31';
71
+ exports.version = '0.3.32-beta.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.31",
3
+ "version": "0.3.32-beta.1",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",