@douyinfe/semi-foundation 2.88.0 → 2.88.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,6 +1,6 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { Attachment, BaseSkill, Suggestion, Reference, Content, LeftMenuChangeProps, MessageContent } from './interface';
3
- import { isNumber, isString } from 'lodash';
3
+ import { get, isNumber, isString } from 'lodash';
4
4
  import { cssClasses } from './constants';
5
5
  import { findSkillSlotInString, getSkillSlotString, transformJSONResult } from './utils';
6
6
 
@@ -345,7 +345,9 @@ export default class AIChatInputFoundation extends BaseFoundation<AIChatInputAda
345
345
  if ((suggestionVisible || skillVisible) && ['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {
346
346
  return true;
347
347
  }
348
- if (event.key === 'Enter' && !event.shiftKey) {
348
+ const editor = this._adapter.getEditor() ?? {};
349
+ const allowHotKeySend = get(editor, 'storage.SemiAIChatInput.allowHotKeySend');
350
+ if (event.key === 'Enter' && !event.shiftKey && allowHotKeySend) {
349
351
  this.handleSend();
350
352
  return true;
351
353
  }
package/chat/chat.scss CHANGED
@@ -498,13 +498,17 @@ $module: #{$prefix}-chat;
498
498
  color: $color-chat_attachment_clear_icon;
499
499
  }
500
500
 
501
- &-process.#{$prefix}-progress-circle {
501
+ &-process.#{$prefix}-progress-circle, &-fail {
502
502
  position: absolute;
503
503
  top: 50%;
504
504
  left: 50%;
505
505
  transform: translate(-50%, -50%);
506
506
  }
507
507
 
508
+ &-fail {
509
+ color: $color-chat_attachment_fail;
510
+ }
511
+
508
512
  &-file {
509
513
  display: inline-flex;
510
514
  flex-direction: row;
package/chat/constants.ts CHANGED
@@ -49,6 +49,15 @@ const SEND_HOT_KEY = {
49
49
  SHIFT_PLUS_ENTER: 'shift+enter'
50
50
  };
51
51
 
52
+ const FILE_STATUS = {
53
+ UPLOADING: 'uploading',
54
+ SUCCESS: 'success',
55
+ UPLOAD_FAIL: 'uploadFail',
56
+ VALIDATING: 'validating',
57
+ VALID_FAIL: 'validateFail',
58
+ WAIT_UPLOAD: 'wait',
59
+ };
60
+
52
61
  const strings = {
53
62
  ROLE,
54
63
  CHAT_ALIGN,
@@ -59,6 +68,7 @@ const strings = {
59
68
  SHOW_SCROLL_GAP,
60
69
  MODE,
61
70
  SEND_HOT_KEY,
71
+ FILE_STATUS
62
72
  };
63
73
 
64
74
 
@@ -61,7 +61,15 @@ export default class InputBoxFoundation <P = Record<string, any>, S = Record<str
61
61
  getDisableSend = () => {
62
62
  const { content, attachment } = this.getStates();
63
63
  const { disableSend: disableSendInProps } = this.getProps();
64
- const disabledSend = disableSendInProps || (content.length === 0 && attachment.length === 0);
64
+ /** 不能发送的条件:(满足任1)
65
+ * 1. props 中禁止发送;2. 没有文本输入,且没有上传文件; 3.上传文件中有状态不为 success 的
66
+ * Conditions under which content cannot be sent: (any one of the following conditions must be met)
67
+ * 1. Sending is disabled in props; 2. No text input and no file upload; 3. There are files uploaded that do not have a success status.
68
+ */
69
+ const disabledSend = disableSendInProps ||
70
+ (content.length === 0 && attachment.length === 0) ||
71
+ attachment.find(item => item.status !== strings.FILE_STATUS.SUCCESS)
72
+ ;
65
73
  return disabledSend;
66
74
  }
67
75
 
@@ -28,6 +28,7 @@ $color-chat_inputBottom_sendButton_icon-disable: var(--semi-color-primary-disabl
28
28
  $color-chat_inputBox_container-border: var(--semi-color-border); // 输入框容器边框颜色
29
29
  $color-chat_attachment_clear_icon: var(--semi-color-text-2); // 附件清除图标颜色
30
30
  $color-chat_attachment_file-bg: var(--semi-color-fill-0); // 附件文件背景颜色
31
+ $color-chat_attachment_fail: var(--semi-color-danger); // 附件上传失败的提示图标颜色
31
32
  $color-chat_chatBox_user_attachment_file-bg: var(--semi-color-bg-0); // 用户聊天框附件文件背景颜色
32
33
  $color-chat_chatBox_other_attachment_file-bg: var(--semi-color-fill-2); // 聊天框附件文件背景颜色
33
34
  $color-chat_attachment_file_icon: var(--semi-color-text-2); // 附件文件图标颜色
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _isString2 = _interopRequireDefault(require("lodash/isString"));
8
8
  var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
9
+ var _get2 = _interopRequireDefault(require("lodash/get"));
9
10
  var _foundation = _interopRequireDefault(require("../base/foundation"));
10
11
  var _constants = require("./constants");
11
12
  var _utils = require("./utils");
@@ -317,6 +318,7 @@ class AIChatInputFoundation extends _foundation.default {
317
318
  this._adapter.focusEditor();
318
319
  };
319
320
  this.handRichTextArealKeyDown = (view, event) => {
321
+ var _a;
320
322
  // console.log('outer key down handle');
321
323
  const {
322
324
  suggestionVisible,
@@ -332,7 +334,9 @@ class AIChatInputFoundation extends _foundation.default {
332
334
  if ((suggestionVisible || skillVisible) && ['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {
333
335
  return true;
334
336
  }
335
- if (event.key === 'Enter' && !event.shiftKey) {
337
+ const editor = (_a = this._adapter.getEditor()) !== null && _a !== void 0 ? _a : {};
338
+ const allowHotKeySend = (0, _get2.default)(editor, 'storage.SemiAIChatInput.allowHotKeySend');
339
+ if (event.key === 'Enter' && !event.shiftKey && allowHotKeySend) {
336
340
  this.handleSend();
337
341
  return true;
338
342
  }
@@ -392,12 +392,15 @@
392
392
  right: -8px;
393
393
  color: var(--semi-color-text-2);
394
394
  }
395
- .semi-chat-attachment-process.semi-progress-circle {
395
+ .semi-chat-attachment-process.semi-progress-circle, .semi-chat-attachment-fail {
396
396
  position: absolute;
397
397
  top: 50%;
398
398
  left: 50%;
399
399
  transform: translate(-50%, -50%);
400
400
  }
401
+ .semi-chat-attachment-fail {
402
+ color: var(--semi-color-danger);
403
+ }
401
404
  .semi-chat-attachment-file {
402
405
  display: inline-flex;
403
406
  flex-direction: row;
@@ -498,13 +498,17 @@ $module: #{$prefix}-chat;
498
498
  color: $color-chat_attachment_clear_icon;
499
499
  }
500
500
 
501
- &-process.#{$prefix}-progress-circle {
501
+ &-process.#{$prefix}-progress-circle, &-fail {
502
502
  position: absolute;
503
503
  top: 50%;
504
504
  left: 50%;
505
505
  transform: translate(-50%, -50%);
506
506
  }
507
507
 
508
+ &-fail {
509
+ color: $color-chat_attachment_fail;
510
+ }
511
+
508
512
  &-file {
509
513
  display: inline-flex;
510
514
  flex-direction: row;
@@ -37,5 +37,13 @@ declare const strings: {
37
37
  ENTER: string;
38
38
  SHIFT_PLUS_ENTER: string;
39
39
  };
40
+ FILE_STATUS: {
41
+ UPLOADING: string;
42
+ SUCCESS: string;
43
+ UPLOAD_FAIL: string;
44
+ VALIDATING: string;
45
+ VALID_FAIL: string;
46
+ WAIT_UPLOAD: string;
47
+ };
40
48
  };
41
49
  export { cssClasses, strings, };
@@ -43,6 +43,14 @@ const SEND_HOT_KEY = {
43
43
  ENTER: 'enter',
44
44
  SHIFT_PLUS_ENTER: 'shift+enter'
45
45
  };
46
+ const FILE_STATUS = {
47
+ UPLOADING: 'uploading',
48
+ SUCCESS: 'success',
49
+ UPLOAD_FAIL: 'uploadFail',
50
+ VALIDATING: 'validating',
51
+ VALID_FAIL: 'validateFail',
52
+ WAIT_UPLOAD: 'wait'
53
+ };
46
54
  const strings = exports.strings = {
47
55
  ROLE,
48
56
  CHAT_ALIGN,
@@ -52,5 +60,6 @@ const strings = exports.strings = {
52
60
  SCROLL_ANIMATION_TIME,
53
61
  SHOW_SCROLL_GAP,
54
62
  MODE,
55
- SEND_HOT_KEY
63
+ SEND_HOT_KEY,
64
+ FILE_STATUS
56
65
  };
@@ -77,7 +77,12 @@ class InputBoxFoundation extends _foundation.default {
77
77
  const {
78
78
  disableSend: disableSendInProps
79
79
  } = this.getProps();
80
- const disabledSend = disableSendInProps || content.length === 0 && attachment.length === 0;
80
+ /** 不能发送的条件:(满足任1)
81
+ * 1. props 中禁止发送;2. 没有文本输入,且没有上传文件; 3.上传文件中有状态不为 success 的
82
+ * Conditions under which content cannot be sent: (any one of the following conditions must be met)
83
+ * 1. Sending is disabled in props; 2. No text input and no file upload; 3. There are files uploaded that do not have a success status.
84
+ */
85
+ const disabledSend = disableSendInProps || content.length === 0 && attachment.length === 0 || attachment.find(item => item.status !== _constants.strings.FILE_STATUS.SUCCESS);
81
86
  return disabledSend;
82
87
  };
83
88
  this.onEnterPress = e => {
@@ -28,6 +28,7 @@ $color-chat_inputBottom_sendButton_icon-disable: var(--semi-color-primary-disabl
28
28
  $color-chat_inputBox_container-border: var(--semi-color-border); // 输入框容器边框颜色
29
29
  $color-chat_attachment_clear_icon: var(--semi-color-text-2); // 附件清除图标颜色
30
30
  $color-chat_attachment_file-bg: var(--semi-color-fill-0); // 附件文件背景颜色
31
+ $color-chat_attachment_fail: var(--semi-color-danger); // 附件上传失败的提示图标颜色
31
32
  $color-chat_chatBox_user_attachment_file-bg: var(--semi-color-bg-0); // 用户聊天框附件文件背景颜色
32
33
  $color-chat_chatBox_other_attachment_file-bg: var(--semi-color-fill-2); // 聊天框附件文件背景颜色
33
34
  $color-chat_attachment_file_icon: var(--semi-color-text-2); // 附件文件图标颜色
@@ -1,5 +1,6 @@
1
1
  import _isString from "lodash/isString";
2
2
  import _isNumber from "lodash/isNumber";
3
+ import _get from "lodash/get";
3
4
  import BaseFoundation from '../base/foundation';
4
5
  import { cssClasses } from './constants';
5
6
  import { findSkillSlotInString, getSkillSlotString, transformJSONResult } from './utils';
@@ -310,6 +311,7 @@ export default class AIChatInputFoundation extends BaseFoundation {
310
311
  this._adapter.focusEditor();
311
312
  };
312
313
  this.handRichTextArealKeyDown = (view, event) => {
314
+ var _a;
313
315
  // console.log('outer key down handle');
314
316
  const {
315
317
  suggestionVisible,
@@ -325,7 +327,9 @@ export default class AIChatInputFoundation extends BaseFoundation {
325
327
  if ((suggestionVisible || skillVisible) && ['ArrowUp', 'ArrowDown', 'Enter'].includes(event.key)) {
326
328
  return true;
327
329
  }
328
- if (event.key === 'Enter' && !event.shiftKey) {
330
+ const editor = (_a = this._adapter.getEditor()) !== null && _a !== void 0 ? _a : {};
331
+ const allowHotKeySend = _get(editor, 'storage.SemiAIChatInput.allowHotKeySend');
332
+ if (event.key === 'Enter' && !event.shiftKey && allowHotKeySend) {
329
333
  this.handleSend();
330
334
  return true;
331
335
  }
@@ -392,12 +392,15 @@
392
392
  right: -8px;
393
393
  color: var(--semi-color-text-2);
394
394
  }
395
- .semi-chat-attachment-process.semi-progress-circle {
395
+ .semi-chat-attachment-process.semi-progress-circle, .semi-chat-attachment-fail {
396
396
  position: absolute;
397
397
  top: 50%;
398
398
  left: 50%;
399
399
  transform: translate(-50%, -50%);
400
400
  }
401
+ .semi-chat-attachment-fail {
402
+ color: var(--semi-color-danger);
403
+ }
401
404
  .semi-chat-attachment-file {
402
405
  display: inline-flex;
403
406
  flex-direction: row;
@@ -498,13 +498,17 @@ $module: #{$prefix}-chat;
498
498
  color: $color-chat_attachment_clear_icon;
499
499
  }
500
500
 
501
- &-process.#{$prefix}-progress-circle {
501
+ &-process.#{$prefix}-progress-circle, &-fail {
502
502
  position: absolute;
503
503
  top: 50%;
504
504
  left: 50%;
505
505
  transform: translate(-50%, -50%);
506
506
  }
507
507
 
508
+ &-fail {
509
+ color: $color-chat_attachment_fail;
510
+ }
511
+
508
512
  &-file {
509
513
  display: inline-flex;
510
514
  flex-direction: row;
@@ -37,5 +37,13 @@ declare const strings: {
37
37
  ENTER: string;
38
38
  SHIFT_PLUS_ENTER: string;
39
39
  };
40
+ FILE_STATUS: {
41
+ UPLOADING: string;
42
+ SUCCESS: string;
43
+ UPLOAD_FAIL: string;
44
+ VALIDATING: string;
45
+ VALID_FAIL: string;
46
+ WAIT_UPLOAD: string;
47
+ };
40
48
  };
41
49
  export { cssClasses, strings, };
@@ -37,6 +37,14 @@ const SEND_HOT_KEY = {
37
37
  ENTER: 'enter',
38
38
  SHIFT_PLUS_ENTER: 'shift+enter'
39
39
  };
40
+ const FILE_STATUS = {
41
+ UPLOADING: 'uploading',
42
+ SUCCESS: 'success',
43
+ UPLOAD_FAIL: 'uploadFail',
44
+ VALIDATING: 'validating',
45
+ VALID_FAIL: 'validateFail',
46
+ WAIT_UPLOAD: 'wait'
47
+ };
40
48
  const strings = {
41
49
  ROLE,
42
50
  CHAT_ALIGN,
@@ -46,6 +54,7 @@ const strings = {
46
54
  SCROLL_ANIMATION_TIME,
47
55
  SHOW_SCROLL_GAP,
48
56
  MODE,
49
- SEND_HOT_KEY
57
+ SEND_HOT_KEY,
58
+ FILE_STATUS
50
59
  };
51
60
  export { cssClasses, strings };
@@ -70,7 +70,12 @@ export default class InputBoxFoundation extends BaseFoundation {
70
70
  const {
71
71
  disableSend: disableSendInProps
72
72
  } = this.getProps();
73
- const disabledSend = disableSendInProps || content.length === 0 && attachment.length === 0;
73
+ /** 不能发送的条件:(满足任1)
74
+ * 1. props 中禁止发送;2. 没有文本输入,且没有上传文件; 3.上传文件中有状态不为 success 的
75
+ * Conditions under which content cannot be sent: (any one of the following conditions must be met)
76
+ * 1. Sending is disabled in props; 2. No text input and no file upload; 3. There are files uploaded that do not have a success status.
77
+ */
78
+ const disabledSend = disableSendInProps || content.length === 0 && attachment.length === 0 || attachment.find(item => item.status !== strings.FILE_STATUS.SUCCESS);
74
79
  return disabledSend;
75
80
  };
76
81
  this.onEnterPress = e => {
@@ -28,6 +28,7 @@ $color-chat_inputBottom_sendButton_icon-disable: var(--semi-color-primary-disabl
28
28
  $color-chat_inputBox_container-border: var(--semi-color-border); // 输入框容器边框颜色
29
29
  $color-chat_attachment_clear_icon: var(--semi-color-text-2); // 附件清除图标颜色
30
30
  $color-chat_attachment_file-bg: var(--semi-color-fill-0); // 附件文件背景颜色
31
+ $color-chat_attachment_fail: var(--semi-color-danger); // 附件上传失败的提示图标颜色
31
32
  $color-chat_chatBox_user_attachment_file-bg: var(--semi-color-bg-0); // 用户聊天框附件文件背景颜色
32
33
  $color-chat_chatBox_other_attachment_file-bg: var(--semi-color-fill-2); // 聊天框附件文件背景颜色
33
34
  $color-chat_attachment_file_icon: var(--semi-color-text-2); // 附件文件图标颜色
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.88.0",
3
+ "version": "2.88.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.88.0",
11
- "@douyinfe/semi-json-viewer-core": "2.88.0",
10
+ "@douyinfe/semi-animation": "2.88.1",
11
+ "@douyinfe/semi-json-viewer-core": "2.88.1",
12
12
  "@mdx-js/mdx": "^3.0.1",
13
13
  "async-validator": "^3.5.0",
14
14
  "classnames": "^2.2.6",
@@ -29,7 +29,7 @@
29
29
  "*.scss",
30
30
  "*.css"
31
31
  ],
32
- "gitHead": "dd7950d62f3dd702ea384d2df21baafd5912bbd6",
32
+ "gitHead": "e08d049ae7cbf936679b53146fd9041577c9422b",
33
33
  "devDependencies": {
34
34
  "@babel/plugin-transform-runtime": "^7.15.8",
35
35
  "@babel/preset-env": "^7.15.8",