@ant-design/agentic-ui 2.29.49 → 2.29.53

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.
Files changed (45) hide show
  1. package/dist/Bubble/List/PureBubbleList.d.ts +1 -1
  2. package/dist/Bubble/List/PureBubbleList.js +9 -6
  3. package/dist/Bubble/MessagesContent/index.js +2 -2
  4. package/dist/Constants/mobile.d.ts +1 -1
  5. package/dist/Constants/mobile.js +1 -1
  6. package/dist/MarkdownEditor/BaseMarkdownEditor.js +1 -1
  7. package/dist/MarkdownEditor/editor/Editor.js +22 -0
  8. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +20 -4
  9. package/dist/MarkdownEditor/editor/elements/Table/Table.js +5 -4
  10. package/dist/MarkdownEditor/editor/plugins/withLinkAndMediaPlugin.js +28 -0
  11. package/dist/MarkdownEditor/editor/style.js +12 -12
  12. package/dist/MarkdownEditor/editor/utils/dom.js +9 -1
  13. package/dist/MarkdownEditor/editor/utils/media.js +17 -7
  14. package/dist/MarkdownEditor/style.js +35 -36
  15. package/dist/MarkdownEditor/types.d.ts +29 -0
  16. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +4 -1
  17. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.d.ts +6 -0
  18. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +56 -2
  19. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +4 -4
  20. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +27 -6
  21. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +4 -24
  22. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +12 -5
  23. package/dist/MarkdownInputField/AttachmentButton/types.d.ts +1 -0
  24. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +8 -0
  25. package/dist/MarkdownInputField/AttachmentButton/utils.js +7 -1
  26. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +22 -3
  27. package/dist/MarkdownInputField/FileMapView/index.js +13 -0
  28. package/dist/MarkdownInputField/FileMapView/style.js +22 -14
  29. package/dist/MarkdownInputField/MarkdownInputField.js +20 -9
  30. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +6 -4
  31. package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +14 -1
  32. package/dist/Plugins/chart/ChartStatistic/index.d.ts +32 -5
  33. package/dist/Plugins/chart/ChartStatistic/index.js +35 -74
  34. package/dist/Plugins/chart/ChartStatistic/style.js +20 -2
  35. package/dist/Plugins/chart/index.d.ts +1 -1
  36. package/dist/ThoughtChainList/index.js +17 -17
  37. package/dist/ToolUseBar/style.js +3 -0
  38. package/dist/ToolUseBarThink/index.js +6 -3
  39. package/dist/ToolUseBarThink/style.js +1 -0
  40. package/dist/Workspace/RealtimeFollow/index.d.ts +4 -0
  41. package/dist/Workspace/RealtimeFollow/index.js +2 -2
  42. package/dist/Workspace/index.js +5 -1
  43. package/dist/index.d.ts +0 -1
  44. package/dist/index.js +1 -1
  45. package/package.json +1 -2
@@ -79,5 +79,5 @@ export interface PureBubbleListProps {
79
79
  shouldLazyLoad?: (index: number, total: number) => boolean;
80
80
  };
81
81
  }
82
- export declare const PureBubbleList: React.FC<PureBubbleListProps>;
82
+ export declare const PureBubbleList: React.NamedExoticComponent<PureBubbleListProps>;
83
83
  export default PureBubbleList;
@@ -61,7 +61,7 @@ import { BubbleConfigContext } from "../BubbleConfigProvide";
61
61
  import { LOADING_FLAT } from "../MessagesContent";
62
62
  import { PureAIBubble, PureUserBubble } from "../PureBubble";
63
63
  import { useStyle } from "./style";
64
- export var PureBubbleList = function PureBubbleList(props) {
64
+ export var PureBubbleList = /*#__PURE__*/ React.memo(function(props) {
65
65
  var bubbleList = props.bubbleList, bubbleListRef = props.bubbleListRef, bubbleRenderConfig = props.bubbleRenderConfig, className = props.className, classNames = props.classNames, docListProps = props.docListProps, isLoading = props.isLoading, markdownRenderConfig = props.markdownRenderConfig, onAvatarClick = props.onAvatarClick, onCancelLike = props.onCancelLike, onLikeCancel = props.onLikeCancel, onDisLike = props.onDisLike, onDislike = props.onDislike, onDoubleClick = props.onDoubleClick, onLike = props.onLike, onReply = props.onReply, onScroll = props.onScroll, onTouchMove = props.onTouchMove, onWheel = props.onWheel, shouldShowCopy = props.shouldShowCopy, shouldShowVoice = props.shouldShowVoice, style = props.style, styles = props.styles, userMeta = props.userMeta, assistantMeta = props.assistantMeta;
66
66
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
67
67
  var compact = (useContext(BubbleConfigContext) || {}).compact;
@@ -72,7 +72,7 @@ export var PureBubbleList = function PureBubbleList(props) {
72
72
  props.style
73
73
  ];
74
74
  }, [
75
- JSON.stringify(props.style)
75
+ props.style
76
76
  ]);
77
77
  // 为 loading 项生成唯一的 key,使用 ref 缓存以确保稳定性
78
78
  var loadingKeysRef = useRef(new Map());
@@ -84,8 +84,10 @@ export var PureBubbleList = function PureBubbleList(props) {
84
84
  var placement = item.role === 'user' ? 'right' : 'left';
85
85
  var BubbleComponent = placement === 'right' ? PureUserBubble : PureAIBubble;
86
86
  var isLast = index === bubbleList.length - 1;
87
- item.isLatest = isLast;
88
- item.isLast = isLast;
87
+ var originDataWithFlags = _object_spread_props(_object_spread({}, item), {
88
+ isLatest: isLast,
89
+ isLast: isLast
90
+ });
89
91
  // 如果 id 是 LOADING_FLAT,使用 uuid 作为 key
90
92
  // 使用 index 和 createAt 的组合作为缓存 key,确保同一项在重新渲染时保持相同的 key
91
93
  var itemKey = item.id;
@@ -103,7 +105,7 @@ export var PureBubbleList = function PureBubbleList(props) {
103
105
  preMessage: bubbleList[index - 1],
104
106
  id: item.id,
105
107
  style: _object_spread({}, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemStyle),
106
- originData: item,
108
+ originData: originDataWithFlags,
107
109
  placement: placement,
108
110
  time: item.updateAt || item.createAt,
109
111
  deps: deps,
@@ -188,5 +190,6 @@ export var PureBubbleList = function PureBubbleList(props) {
188
190
  return onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(event, (bubbleListRef === null || bubbleListRef === void 0 ? void 0 : bubbleListRef.current) || null);
189
191
  }
190
192
  }, listDom));
191
- };
193
+ });
194
+ PureBubbleList.displayName = 'PureBubbleList';
192
195
  export default PureBubbleList;
@@ -363,7 +363,7 @@ export var LOADING_FLAT = '...';
363
363
  (_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : _props_originData4.isLast,
364
364
  contentAfterDom
365
365
  ]);
366
- var memo = useMemo(function() {
366
+ var messageContent = useMemo(function() {
367
367
  var _props_originData, _props_bubbleRenderConfig, _props_bubbleRenderConfig1, _props_bubbleRenderConfig2, _props_bubbleRenderConfig3, _props_bubbleRenderConfig_extraRender, _props_bubbleRenderConfig4, _props_originData_extra_tags_includes, _props_originData_extra_tags, _props_originData_extra, _props_originData1, _props_originData2, _props_originData_extra1, _props_originData3, _props_originData_extra2, _props_originData4, _props_originData5, _props_originData_extra3, _props_originData6, _props_docListProps, _props_originData7, _props_markdownRenderConfig, _props_originData8, _props_originData9, _props_originData10;
368
368
  if (content === LOADING_FLAT || !((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isFinished) && !content) {
369
369
  var _context_thoughtChain;
@@ -649,5 +649,5 @@ export var LOADING_FLAT = '...';
649
649
  (_props_bubbleRenderConfig2 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig2 === void 0 ? void 0 : _props_bubbleRenderConfig2.beforeMessageRender,
650
650
  (_props_bubbleRenderConfig3 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig3 === void 0 ? void 0 : _props_bubbleRenderConfig3.afterMessageRender
651
651
  ]);
652
- return memo;
652
+ return messageContent;
653
653
  };
@@ -6,7 +6,7 @@
6
6
  export declare const TABLE_COL_WIDTH_MIN_COLUMNS = 5;
7
7
  /** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */
8
8
  export declare const TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
9
- /** 表格默认列宽 (px),与 style.ts 中 --table-cell-min-width (120px) 保持一致 */
9
+ /** 表格默认列宽 (px),与 style.ts 中 --agentic-ui-table-cell-min-width (120px) 保持一致 */
10
10
  export declare const TABLE_DEFAULT_COL_WIDTH = 120;
11
11
  /** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */
12
12
  export declare const TABLE_LAST_COL_MIN_WIDTH = 80;
@@ -8,7 +8,7 @@ var MOBILE_TABLE_MIN_CELL_WIDTH = 96;
8
8
  * - 列数 >= 5:使用 TABLE_DEFAULT_COL_WIDTH 固定宽度
9
9
  */ export var TABLE_COL_WIDTH_MIN_COLUMNS = 5;
10
10
  /** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */ export var TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
11
- /** 表格默认列宽 (px),与 style.ts 中 --table-cell-min-width (120px) 保持一致 */ export var TABLE_DEFAULT_COL_WIDTH = 120;
11
+ /** 表格默认列宽 (px),与 style.ts 中 --agentic-ui-table-cell-min-width (120px) 保持一致 */ export var TABLE_DEFAULT_COL_WIDTH = 120;
12
12
  /** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */ export var TABLE_LAST_COL_MIN_WIDTH = 80;
13
13
  export var MOBILE_PADDING = "clamp(".concat(MOBILE_PADDING_MIN, ", ").concat(MOBILE_PADDING_SCALE, ", ").concat(MOBILE_PADDING_MAX, ")");
14
14
  export var MOBILE_BREAKPOINT = '768px';
@@ -461,7 +461,7 @@ var I18nBoundary = function I18nBoundary(param) {
461
461
  style: _object_spread({
462
462
  height: !readonly && (toolBar === null || toolBar === void 0 ? void 0 : toolBar.enable) ? "calc(100% - 56px)" : '100%'
463
463
  }, (contentStyle === null || contentStyle === void 0 ? void 0 : contentStyle.padding) !== undefined ? {
464
- '--content-padding': "".concat(typeof contentStyle.padding === 'number' ? "".concat(contentStyle.padding, "px") : contentStyle.padding),
464
+ '--agentic-ui-content-padding': "".concat(typeof contentStyle.padding === 'number' ? "".concat(contentStyle.padding, "px") : contentStyle.padding),
465
465
  padding: contentStyle.padding
466
466
  } : {}, contentStyle),
467
467
  ref: function ref(dom) {
@@ -874,6 +874,28 @@ var defaultAllowedTypes = [
874
874
  2
875
875
  ];
876
876
  selection = markdownEditorRef.current.selection;
877
+ // plainTextOnly 时仅插入纯文本,不做 HTML/Markdown/链接解析
878
+ if (pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.plainTextOnly) {
879
+ if (selection) {
880
+ Transforms.insertText(markdownEditorRef.current, text1, {
881
+ at: selection
882
+ });
883
+ } else {
884
+ Transforms.insertNodes(markdownEditorRef.current, [
885
+ {
886
+ type: 'paragraph',
887
+ children: [
888
+ {
889
+ text: text1
890
+ }
891
+ ]
892
+ }
893
+ ]);
894
+ }
895
+ return [
896
+ 2
897
+ ];
898
+ }
877
899
  // 如果是表格或者代码块,直接插入文本
878
900
  if (shouldInsertTextDirectly(markdownEditorRef.current, selection)) {
879
901
  Transforms.insertText(markdownEditorRef.current, text1);
@@ -46,6 +46,21 @@ function _iterable_to_array_limit(arr, i) {
46
46
  function _non_iterable_rest() {
47
47
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
48
  }
49
+ function _object_spread(target) {
50
+ for(var i = 1; i < arguments.length; i++){
51
+ var source = arguments[i] != null ? arguments[i] : {};
52
+ var ownKeys = Object.keys(source);
53
+ if (typeof Object.getOwnPropertySymbols === "function") {
54
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
55
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
56
+ }));
57
+ }
58
+ ownKeys.forEach(function(key) {
59
+ _define_property(target, key, source[key]);
60
+ });
61
+ }
62
+ return target;
63
+ }
49
64
  function _sliced_to_array(arr, i) {
50
65
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
51
66
  }
@@ -81,7 +96,7 @@ import { useReadonlyTableColWidths } from "./utils/useReadonlyTableColWidths";
81
96
  download: 'csv',
82
97
  fullScreen: 'modal',
83
98
  copy: 'md'
84
- } : _ref_actions;
99
+ } : _ref_actions, tableCssVariables = _ref.cssVariables;
85
100
  var tableTargetRef = useRef(null);
86
101
  var containerRef = useRef(null);
87
102
  var modelTargetRef = useRef(null);
@@ -172,7 +187,8 @@ import { useReadonlyTableColWidths } from "./utils/useReadonlyTableColWidths";
172
187
  ]);
173
188
  return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
174
189
  ref: containerRef,
175
- className: classNames(baseCls)
190
+ className: classNames(baseCls),
191
+ style: tableCssVariables
176
192
  }, tableDom), popoverContent, previewOpen && /*#__PURE__*/ React.createElement(Modal, {
177
193
  title: (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.previewTitle) || (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.previewTable) || '预览表格',
178
194
  open: previewOpen,
@@ -189,12 +205,12 @@ import { useReadonlyTableColWidths } from "./utils/useReadonlyTableColWidths";
189
205
  }
190
206
  }, /*#__PURE__*/ React.createElement("div", {
191
207
  className: classNames(baseCls, getPrefixCls('agentic-md-editor-content')),
192
- style: {
208
+ style: _object_spread({
193
209
  flex: 1,
194
210
  minWidth: 0,
195
211
  overflow: 'auto',
196
212
  width: 'calc(80vw - 64px)'
197
- },
213
+ }, tableCssVariables),
198
214
  ref: modelTargetRef,
199
215
  onMouseDown: function onMouseDown(e) {
200
216
  e.preventDefault();
@@ -185,8 +185,9 @@ import useScrollShadow from "./useScrollShadow";
185
185
  var children = _0.children, props = _object_without_properties(_0, [
186
186
  "children"
187
187
  ]);
188
- var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
189
- var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef;
188
+ var _editorProps_tableConfig, _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
189
+ var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef, editorProps = _useEditorStore.editorProps;
190
+ var tableCssVariables = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.cssVariables;
190
191
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
191
192
  var tablePath = useContext(TablePropsContext).tablePath;
192
193
  var baseCls = getPrefixCls('agentic-md-editor-content-table');
@@ -341,9 +342,9 @@ import useScrollShadow from "./useScrollShadow";
341
342
  return /*#__PURE__*/ React.createElement("div", {
342
343
  className: classNames(baseCls),
343
344
  ref: tableRef,
344
- style: _object_spread_props(_object_spread({}, boxShadowStyle), {
345
+ style: _object_spread(_object_spread_props(_object_spread({}, boxShadowStyle), {
345
346
  position: 'relative'
346
- }),
347
+ }), tableCssVariables),
347
348
  onDragStart: function onDragStart(e) {
348
349
  // 阻止拖拽开始时的文字选择
349
350
  e.preventDefault();
@@ -1,4 +1,8 @@
1
1
  import { Node, Path, Transforms } from "slate";
2
+ import { Text } from "slate";
3
+ /**
4
+ * 连续空格跳出链接的阈值(输入第二个空格时跳出 data-url)
5
+ */ var SPACES_TO_EXIT_LINK = 2;
2
6
  /**
3
7
  * 处理链接卡片和媒体相关节点的操作
4
8
  *
@@ -10,8 +14,32 @@ import { Node, Path, Transforms } from "slate";
10
14
  * 处理以下链接和媒体相关操作:
11
15
  * - 拆分链接卡片或媒体节点 (split_node)
12
16
  * - 删除链接卡片内的节点 (remove_node)
17
+ * - 链接内连续输入两个空格时跳出链接 (insert_text)
13
18
  */ var handleLinkAndMediaOperation = function handleLinkAndMediaOperation(editor, operation) {
14
19
  var _operation_properties, _operation_properties1;
20
+ if (operation.type === 'insert_text' && /^\s+$/.test(operation.text)) {
21
+ var currentNode = Node.get(editor, operation.path);
22
+ if (Text.isText(currentNode) && (currentNode === null || currentNode === void 0 ? void 0 : currentNode.url)) {
23
+ var _ref, _operation_offset, _ref1;
24
+ var _editor_selection_anchor, _editor_selection, _textAfterInsert_match_, _textAfterInsert_match;
25
+ var text = currentNode.text || '';
26
+ var offset = (_ref = (_operation_offset = operation.offset) !== null && _operation_offset !== void 0 ? _operation_offset : (_editor_selection = editor.selection) === null || _editor_selection === void 0 ? void 0 : (_editor_selection_anchor = _editor_selection.anchor) === null || _editor_selection_anchor === void 0 ? void 0 : _editor_selection_anchor.offset) !== null && _ref !== void 0 ? _ref : 0;
27
+ var isAtEnd = offset >= text.length;
28
+ var textAfterInsert = text.slice(0, offset) + operation.text;
29
+ var trailingSpaces = (_ref1 = (_textAfterInsert_match = textAfterInsert.match(/\s*$/)) === null || _textAfterInsert_match === void 0 ? void 0 : (_textAfterInsert_match_ = _textAfterInsert_match[0]) === null || _textAfterInsert_match_ === void 0 ? void 0 : _textAfterInsert_match_.length) !== null && _ref1 !== void 0 ? _ref1 : 0;
30
+ if (isAtEnd && trailingSpaces >= SPACES_TO_EXIT_LINK) {
31
+ Transforms.insertNodes(editor, [
32
+ {
33
+ text: operation.text
34
+ }
35
+ ], {
36
+ at: Path.next(operation.path),
37
+ select: true
38
+ });
39
+ return true;
40
+ }
41
+ }
42
+ }
15
43
  if (operation.type === 'split_node' && (((_operation_properties = operation.properties) === null || _operation_properties === void 0 ? void 0 : _operation_properties.type) === 'link-card' || ((_operation_properties1 = operation.properties) === null || _operation_properties1 === void 0 ? void 0 : _operation_properties1.type) === 'media')) {
16
44
  var node = Node.get(editor, operation.path);
17
45
  if ([
@@ -55,19 +55,19 @@ import { resetComponent, useEditorStyleRegister } from "../../Hooks/useStyle";
55
55
  import "./code.css";
56
56
  // 导入统一的标签样式配置
57
57
  import { TAG_STYLES } from "./tagStyles";
58
- var COMMENT_HIGHLIGHT_COLOR = 'var(--agentic-comment-highlight-color, rgba(21, 0, 255, 0.15))';
58
+ var COMMENT_HIGHLIGHT_COLOR = 'var(--agentic-ui-comment-highlight-color, rgba(21, 0, 255, 0.15))';
59
59
  /** Jinja 语法高亮 CSS 变量名,在 .ant-agentic-md-editor-content 上覆盖即可定制 */ var JINJA_CSS_VAR = {
60
- variable: '--agentic-md-editor-color-jinja-variable',
61
- tag: '--agentic-md-editor-color-jinja-tag',
62
- comment: '--agentic-md-editor-color-jinja-comment',
63
- keyword: '--agentic-md-editor-color-jinja-keyword',
64
- string: '--agentic-md-editor-color-jinja-string',
65
- number: '--agentic-md-editor-color-jinja-number',
66
- filter: '--agentic-md-editor-color-jinja-filter',
67
- variableName: '--agentic-md-editor-color-jinja-variable-name',
68
- placeholder: '--agentic-md-editor-color-jinja-placeholder',
69
- placeholderBg: '--agentic-md-editor-color-jinja-placeholder-bg',
70
- delimiter: '--agentic-md-editor-color-jinja-delimiter'
60
+ variable: '--agentic-ui-md-editor-color-jinja-variable',
61
+ tag: '--agentic-ui-md-editor-color-jinja-tag',
62
+ comment: '--agentic-ui-md-editor-color-jinja-comment',
63
+ keyword: '--agentic-ui-md-editor-color-jinja-keyword',
64
+ string: '--agentic-ui-md-editor-color-jinja-string',
65
+ number: '--agentic-ui-md-editor-color-jinja-number',
66
+ filter: '--agentic-ui-md-editor-color-jinja-filter',
67
+ variableName: '--agentic-ui-md-editor-color-jinja-variable-name',
68
+ placeholder: '--agentic-ui-md-editor-color-jinja-placeholder',
69
+ placeholderBg: '--agentic-ui-md-editor-color-jinja-placeholder-bg',
70
+ delimiter: '--agentic-ui-md-editor-color-jinja-delimiter'
71
71
  };
72
72
  var genStyle = function genStyle(token) {
73
73
  var _obj, _obj1;
@@ -69,7 +69,15 @@ var rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;
69
69
  if (alt.startsWith('attachment:')) return 'attachment';
70
70
  }
71
71
  name = name || '';
72
- if (name === null || name === void 0 ? void 0 : (_name_startsWith = name.startsWith) === null || _name_startsWith === void 0 ? void 0 : _name_startsWith.call(name, 'data:')) return 'image';
72
+ if (name === null || name === void 0 ? void 0 : (_name_startsWith = name.startsWith) === null || _name_startsWith === void 0 ? void 0 : _name_startsWith.call(name, 'data:')) {
73
+ var _mimeMatch_;
74
+ var mimeMatch = name.match(/^data:([^/]+)\/[^;]+/);
75
+ var mainType = mimeMatch === null || mimeMatch === void 0 ? void 0 : (_mimeMatch_ = mimeMatch[1]) === null || _mimeMatch_ === void 0 ? void 0 : _mimeMatch_.toLowerCase();
76
+ if (mainType === 'image') return 'image';
77
+ if (mainType === 'video') return 'video';
78
+ if (mainType === 'audio') return 'audio';
79
+ return 'other';
80
+ }
73
81
  var originName = name.split('?')[0];
74
82
  var ext = (_originName_toLowerCase_match = originName.toLowerCase().match(/\.\w+$/)) === null || _originName_toLowerCase_match === void 0 ? void 0 : _originName_toLowerCase_match[0];
75
83
  if (!ext && originName !== name) return 'image';
@@ -156,7 +156,7 @@ import { ReactEditor } from "slate-react";
156
156
  import { getMediaType } from "./dom";
157
157
  export var getRemoteMediaType = function getRemoteMediaType(url) {
158
158
  return _async_to_generator(function() {
159
- var m, type, contentType, controller, res, e;
159
+ var _mimeMatch_, mimeMatch, mainType, type, contentType, controller, res, e;
160
160
  return _ts_generator(this, function(_state) {
161
161
  switch(_state.label){
162
162
  case 0:
@@ -169,10 +169,20 @@ export var getRemoteMediaType = function getRemoteMediaType(url) {
169
169
  'other'
170
170
  ];
171
171
  if (url.startsWith('data:')) {
172
- m = url.match(/data:image\/(\w+);base64,(.*)/);
173
- if (m) return [
172
+ ;
173
+ mimeMatch = url.match(/^data:([^/]+)\/[^;]+/);
174
+ mainType = mimeMatch === null || mimeMatch === void 0 ? void 0 : (_mimeMatch_ = mimeMatch[1]) === null || _mimeMatch_ === void 0 ? void 0 : _mimeMatch_.toLowerCase();
175
+ if (mainType === 'image') return [
176
+ 2,
177
+ 'image'
178
+ ];
179
+ if (mainType === 'video') return [
180
+ 2,
181
+ 'video'
182
+ ];
183
+ if (mainType === 'audio') return [
174
184
  2,
175
- m[1]
185
+ 'audio'
176
186
  ];
177
187
  return [
178
188
  2,
@@ -230,7 +240,7 @@ export var getRemoteMediaType = function getRemoteMediaType(url) {
230
240
  };
231
241
  export var convertRemoteImages = function convertRemoteImages(node, store) {
232
242
  return _async_to_generator(function() {
233
- var _store_editor, schema, stack, _item_children, item, _item_url, _item_url1, ext, m, _stack;
243
+ var _store_editor, schema, stack, _item_children, item, _item_url, _item_url1, ext, dataUrlType, _stack;
234
244
  return _ts_generator(this, function(_state) {
235
245
  schema = (store === null || store === void 0 ? void 0 : (_store_editor = store.editor) === null || _store_editor === void 0 ? void 0 : _store_editor.children) || [];
236
246
  if (schema) {
@@ -254,8 +264,8 @@ export var convertRemoteImages = function convertRemoteImages(node, store) {
254
264
  }
255
265
  }
256
266
  } else if (item === null || item === void 0 ? void 0 : (_item_url1 = item.url) === null || _item_url1 === void 0 ? void 0 : _item_url1.startsWith('data:')) {
257
- m = item === null || item === void 0 ? void 0 : item.url.match(/data:image\/(\w+);base64,(.*)/);
258
- if (m) {
267
+ dataUrlType = getMediaType(item === null || item === void 0 ? void 0 : item.url);
268
+ if (dataUrlType === 'image' || dataUrlType === 'video' || dataUrlType === 'audio') {
259
269
  try {
260
270
  Transforms.setNodes(store === null || store === void 0 ? void 0 : store.editor, {
261
271
  url: item === null || item === void 0 ? void 0 : item.url
@@ -101,14 +101,14 @@ var genStyle = function genStyle(token) {
101
101
  '&-container': _define_property({
102
102
  // 默认 padding,可以通过 contentStyle 覆盖
103
103
  // 使用 CSS 变量,允许通过内联样式覆盖
104
- padding: 'var(--content-padding, 4px 20px)',
104
+ padding: 'var(--agentic-ui-content-padding, 4px 20px)',
105
105
  overflow: 'auto',
106
106
  display: 'flex',
107
107
  position: 'relative',
108
108
  gap: 24,
109
109
  outline: 'none'
110
110
  }, "@media (max-width: ".concat(MOBILE_BREAKPOINT, ")"), {
111
- padding: 'var(--content-padding, 4px 4px)'
111
+ padding: 'var(--agentic-ui-content-padding, 4px 4px)'
112
112
  }),
113
113
  '&-content': {},
114
114
  '&-focus': {
@@ -365,18 +365,17 @@ var genStyle = function genStyle(token) {
365
365
  }
366
366
  }
367
367
  }), // --- Table ---
368
+ // 表格样式使用 CSS 变量 + fallback,支持通过父级 style 或 ConfigProvider 覆盖:
369
+ // --agentic-ui-table-border-radius, --agentic-ui-table-border-color,
370
+ // --agentic-ui-table-header-bg, --agentic-ui-table-hover-bg,
371
+ // --agentic-ui-table-cell-bg, --agentic-ui-table-cell-min-width,
372
+ // --agentic-ui-table-cell-padding
368
373
  _define_property(_obj2, "".concat(token.componentCls, "-content-table"), {
369
374
  width: '100%',
370
375
  overflow: 'auto',
371
376
  flex: 1,
372
377
  minWidth: 0,
373
378
  position: 'relative',
374
- '--table-border-radius': '8px',
375
- '--table-border-color': '#E7E9E8',
376
- '--table-header-bg': '#f7f7f9',
377
- '--table-odd-row-bg': 'rgba(35,35,38,.04)',
378
- '--table-hover-bg': 'rgba(0, 0, 0, 0.04)',
379
- '--table-cell-min-width': '120px',
380
379
  '&-container': _define_property({
381
380
  display: 'flex',
382
381
  gap: 1,
@@ -419,14 +418,14 @@ var genStyle = function genStyle(token) {
419
418
  }, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-table"), {
420
419
  width: '100%',
421
420
  minWidth: 'max-content'
422
- }), _define_property(_obj1, "position", 'relative'), _define_property(_obj1, "fontVariant", 'tabular-nums'), _define_property(_obj1, "borderRadius", 'var(--table-border-radius)'), _define_property(_obj1, "border", '1px solid var(--table-border-color)'), _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
421
+ }), _define_property(_obj1, "position", 'relative'), _define_property(_obj1, "fontVariant", 'tabular-nums'), _define_property(_obj1, "borderRadius", 'var(--agentic-ui-table-border-radius, 8px)'), _define_property(_obj1, "border", '1px solid var(--agentic-ui-table-border-color, #E7E9E8)'), _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
423
422
  border: 'none',
424
423
  borderRadius: 'none',
425
424
  'tr:not(.config-tr) td:not(.config-td)': {
426
425
  borderLeft: 'none'
427
426
  },
428
427
  'tr:not(.config-tr):last-child td:not(.config-td)': {
429
- borderBottom: '1px solid var(--table-border-color)'
428
+ borderBottom: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)'
430
429
  },
431
430
  'tr:not(.config-tr):first-child th:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:first-child:not(.config-td):not([colspan]):not([rowspan])': {
432
431
  borderTopLeftRadius: 'unset'
@@ -441,23 +440,23 @@ var genStyle = function genStyle(token) {
441
440
  borderBottomRightRadius: 'unset'
442
441
  }
443
442
  }), _define_property(_obj1, 'th.config-th,td.config-td', {
444
- borderBottom: '1px solid var(--table-border-color)',
445
- borderLeft: '1px solid var(--table-border-color)'
443
+ borderBottom: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
444
+ borderLeft: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)'
446
445
  }), _define_property(_obj1, 'tr td.config-td:first-child', {
447
446
  borderLeft: 'none'
448
447
  }), _define_property(_obj1, 'th:not(.config-td)', {
449
- backgroundColor: 'var(--table-header-bg)',
450
- borderBottom: '1px solid var(--table-border-color)',
448
+ backgroundColor: 'var(--agentic-ui-table-header-bg, #f7f7f9)',
449
+ borderBottom: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
451
450
  textWrap: 'nowrap',
452
451
  verticalAlign: 'top',
453
- padding: 'var(--table-cell-padding, 16px 12px)',
452
+ padding: 'var(--agentic-ui-table-cell-padding, 16px 12px)',
454
453
  textAlign: 'left',
455
454
  lineHeight: '24px',
456
455
  fontSize: '1em',
457
456
  fontWeight: 600,
458
457
  borderTop: 'none',
459
- minWidth: 'var(--table-cell-min-width)',
460
- width: 'var(--table-cell-min-width)',
458
+ minWidth: 'var(--agentic-ui-table-cell-min-width, 120px)',
459
+ width: 'var(--agentic-ui-table-cell-min-width, 120px)',
461
460
  whiteSpace: 'nowrap',
462
461
  overflow: 'hidden',
463
462
  textOverflow: 'ellipsis',
@@ -465,13 +464,13 @@ var genStyle = function genStyle(token) {
465
464
  background: 'inherit'
466
465
  }), _define_property(_obj1, 'td:not(.config-td)', {
467
466
  verticalAlign: 'top',
468
- padding: 'var(--table-cell-padding, 16px 12px)',
467
+ padding: 'var(--agentic-ui-table-cell-padding, 16px 12px)',
469
468
  textAlign: 'left',
470
469
  position: 'relative',
471
470
  lineHeight: '24px',
472
471
  fontSize: '1em',
473
- minWidth: 'var(--table-cell-min-width)',
474
- width: 'var(--table-cell-min-width)',
472
+ minWidth: 'var(--agentic-ui-table-cell-min-width, 120px)',
473
+ width: 'var(--agentic-ui-table-cell-min-width, 120px)',
475
474
  whiteSpace: 'nowrap',
476
475
  overflow: 'hidden',
477
476
  textOverflow: 'ellipsis',
@@ -487,8 +486,8 @@ var genStyle = function genStyle(token) {
487
486
  borderTop: 'none'
488
487
  },
489
488
  'td:not(.config-td)': {
490
- borderBottom: '1px solid var(--table-border-color)',
491
- borderLeft: '1px solid var(--table-border-color)',
489
+ borderBottom: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
490
+ borderLeft: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
492
491
  '&:first-child': {
493
492
  fontSize: '1em',
494
493
  lineHeight: '24px',
@@ -502,32 +501,32 @@ var genStyle = function genStyle(token) {
502
501
  borderBottom: 'none'
503
502
  }
504
503
  }), _define_property(_obj1, 'tbody tr:not(.config-tr):hover', {
505
- background: 'linear-gradient(var(--table-hover-bg), var(--table-hover-bg)), linear-gradient(white, white)'
504
+ background: 'linear-gradient(var(--agentic-ui-table-hover-bg, rgba(0, 0, 0, 0.04)), var(--agentic-ui-table-hover-bg, rgba(0, 0, 0, 0.04))), linear-gradient(var(--agentic-ui-table-cell-bg, #ffffff), var(--agentic-ui-table-cell-bg, #ffffff))'
506
505
  }), // 表格圆角处理
507
506
  _define_property(_obj1, 'th:not(.config-td), td:not(.config-td)', {
508
507
  borderRadius: '0'
509
508
  }), _define_property(_obj1, 'tr:not(.config-tr):first-child th:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:first-child:not(.config-td):not([colspan]):not([rowspan])', {
510
- borderTopLeftRadius: 'var(--table-border-radius)'
509
+ borderTopLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)'
511
510
  }), _define_property(_obj1, 'tr:not(.config-tr):first-child th:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:last-child:not(.config-td):not([colspan]):not([rowspan])', {
512
- borderTopRightRadius: 'var(--table-border-radius)'
511
+ borderTopRightRadius: 'var(--agentic-ui-table-border-radius, 8px)'
513
512
  }), _define_property(_obj1, 'tr:not(.config-tr):last-child td:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:first-child:not(.config-td):not([colspan]):not([rowspan])', {
514
- borderBottomLeftRadius: 'var(--table-border-radius)'
513
+ borderBottomLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)'
515
514
  }), _define_property(_obj1, 'tr:not(.config-tr):last-child td:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:last-child:not(.config-td):not([colspan]):not([rowspan])', {
516
- borderBottomRightRadius: 'var(--table-border-radius)'
515
+ borderBottomRightRadius: 'var(--agentic-ui-table-border-radius, 8px)'
517
516
  }), // 处理合并单元格的圆角
518
517
  _define_property(_obj1, 'tr:not(.config-tr):first-child th:not(.config-td)[colspan]:first-child, tr:not(.config-tr):first-child td:not(.config-td)[colspan]:first-child,tr:not(.config-tr):first-child th:not(.config-td)[rowspan]:first-child, tr:not(.config-tr):first-child td:not(.config-td)[rowspan]:first-child', {
519
- borderTopLeftRadius: 'var(--table-border-radius)'
518
+ borderTopLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)'
520
519
  }), _define_property(_obj1, 'tr:not(.config-tr):first-child th:not(.config-td)[colspan]:last-child, tr:not(.config-tr):first-child td:not(.config-td)[colspan]:last-child,tr:not(.config-tr):first-child th:not(.config-td)[rowspan]:last-child, tr:not(.config-tr):first-child td:not(.config-td)[rowspan]:last-child', {
521
- borderTopRightRadius: 'var(--table-border-radius)'
520
+ borderTopRightRadius: 'var(--agentic-ui-table-border-radius, 8px)'
522
521
  }), _define_property(_obj1, 'tr:not(.config-tr):last-child td:not(.config-td)[colspan]:first-child, tr:not(.config-tr):last-child th:not(.config-td)[colspan]:first-child,tr:not(.config-tr):last-child td:not(.config-td)[rowspan]:first-child, tr:not(.config-tr):last-child th:not(.config-td)[rowspan]:first-child', {
523
- borderBottomLeftRadius: 'var(--table-border-radius)'
522
+ borderBottomLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)'
524
523
  }), _define_property(_obj1, 'tr:not(.config-tr):last-child td:not(.config-td)[colspan]:last-child, tr:not(.config-tr):last-child th:not(.config-td)[colspan]:last-child,tr:not(.config-tr):last-child td:not(.config-td)[rowspan]:last-child, tr:not(.config-tr):last-child th:not(.config-td)[rowspan]:last-child', {
525
- borderBottomRightRadius: 'var(--table-border-radius)'
524
+ borderBottomRightRadius: 'var(--agentic-ui-table-border-radius, 8px)'
526
525
  }), _define_property(_obj1, 'tr:not(.config-tr):first-child:last-child th:not(.config-td)[colspan]:first-child:last-child, tr:not(.config-tr):first-child:last-child td:not(.config-td)[colspan]:first-child:last-child', {
527
- borderRadius: 'var(--table-border-radius)'
526
+ borderRadius: 'var(--agentic-ui-table-border-radius, 8px)'
528
527
  }), _define_property(_obj1, 'th:not(.config-td)[rowspan]:first-child:last-child, td:not(.config-td)[rowspan]:first-child:last-child', {
529
- borderTopLeftRadius: 'var(--table-border-radius)',
530
- borderBottomLeftRadius: 'var(--table-border-radius)'
528
+ borderTopLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)',
529
+ borderBottomLeftRadius: 'var(--agentic-ui-table-border-radius, 8px)'
531
530
  }), _define_property(_obj1, "@media (max-width: ".concat(MOBILE_BREAKPOINT, ")"), {
532
531
  'th:not(.config-td), td:not(.config-td)': {
533
532
  padding: "".concat(MOBILE_PADDING)
@@ -597,7 +596,7 @@ var genStyle = function genStyle(token) {
597
596
  zIndex: 1000,
598
597
  justifyContent: 'center',
599
598
  fontSize: 12,
600
- border: '1px solid var(--table-border-color)',
599
+ border: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
601
600
  width: '20px',
602
601
  height: '20px',
603
602
  cursor: 'pointer',
@@ -651,7 +650,7 @@ var genStyle = function genStyle(token) {
651
650
  alignItems: 'center',
652
651
  justifyContent: 'center',
653
652
  fontSize: 12,
654
- border: '1px solid var(--table-border-color)',
653
+ border: '1px solid var(--agentic-ui-table-border-color, #E7E9E8)',
655
654
  width: '20px',
656
655
  height: '20px',
657
656
  cursor: 'pointer',
@@ -337,10 +337,20 @@ export type MarkdownEditorProps = {
337
337
  };
338
338
  /**
339
339
  * 样式
340
+ * @description 支持通过 CSS 变量自定义表格等渲染样式,可覆盖的变量包括:
341
+ * - `--agentic-ui-table-border-radius` 表格圆角,默认 8px
342
+ * - `--agentic-ui-table-border-color` 表格边框颜色,默认 #E7E9E8
343
+ * - `--agentic-ui-table-header-bg` 表头背景色,默认 #f7f7f9
344
+ * - `--agentic-ui-table-hover-bg` 行悬停背景色,默认 rgba(0,0,0,0.04)
345
+ * - `--agentic-ui-table-cell-bg` 单元格背景色,默认 #ffffff
346
+ * - `--agentic-ui-table-cell-min-width` 单元格最小宽度,默认 120px
347
+ * - `--agentic-ui-table-cell-padding` 单元格内边距,默认 16px 12px
348
+ * @example style={{ ['--agentic-ui-table-border-color']: '#ddd', ['--agentic-ui-table-header-bg']: '#f0f0f0' } as React.CSSProperties}
340
349
  */
341
350
  style?: React.CSSProperties;
342
351
  /**
343
352
  * 内容样式
353
+ * @description 支持 `--agentic-ui-content-padding` 等 CSS 变量
344
354
  */
345
355
  contentStyle?: React.CSSProperties;
346
356
  /**
@@ -363,6 +373,20 @@ export type MarkdownEditorProps = {
363
373
  };
364
374
  pure?: boolean;
365
375
  previewTitle?: string;
376
+ /**
377
+ * 表格 CSS 变量覆盖,支持通过配置自定义表格样式
378
+ * @example
379
+ * ```tsx
380
+ * tableConfig={{
381
+ * cssVariables: {
382
+ * '--agentic-ui-table-border-color': '#d9d9d9',
383
+ * '--agentic-ui-table-header-bg': '#fafafa',
384
+ * '--agentic-ui-table-cell-min-width': '150px',
385
+ * },
386
+ * }}
387
+ * ```
388
+ */
389
+ cssVariables?: Record<`--${string}`, string>;
366
390
  };
367
391
  /**
368
392
  * 粘贴配置
@@ -370,6 +394,11 @@ export type MarkdownEditorProps = {
370
394
  pasteConfig?: {
371
395
  enabled?: boolean;
372
396
  allowedTypes?: string[];
397
+ /**
398
+ * 仅插入纯文本,不解析 HTML/Markdown/链接等
399
+ * @default false
400
+ */
401
+ plainTextOnly?: boolean;
373
402
  };
374
403
  /**
375
404
  * Jinja 配置:语法高亮与模板面板(输入 `{}` 触发)
@@ -97,7 +97,10 @@ export var SupportedFileFormats = {
97
97
  'jpg',
98
98
  'jpeg',
99
99
  'png',
100
- 'gif'
100
+ 'gif',
101
+ 'bmp',
102
+ 'webp',
103
+ 'svg'
101
104
  ]
102
105
  },
103
106
  document: {
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  import { AttachmentFile } from '../types';
3
+ /** 无 url/previewUrl 时展示文件大小与格式的占位块(内容未拿到) */
4
+ export declare const FileMetaPlaceholder: React.FC<{
5
+ file: AttachmentFile;
6
+ className?: string;
7
+ style?: React.CSSProperties;
8
+ }>;
3
9
  export declare const AttachmentFileIcon: React.FC<{
4
10
  file: AttachmentFile;
5
11
  className: string;