@ant-design/agentic-ui 2.29.22 → 2.29.23

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.
@@ -6,6 +6,9 @@ function _array_like_to_array(arr, len) {
6
6
  function _array_with_holes(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
9
12
  function _define_property(obj, key, value) {
10
13
  if (key in obj) {
11
14
  Object.defineProperty(obj, key, {
@@ -19,6 +22,9 @@ function _define_property(obj, key, value) {
19
22
  }
20
23
  return obj;
21
24
  }
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27
+ }
22
28
  function _iterable_to_array_limit(arr, i) {
23
29
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
24
30
  if (_i == null) return;
@@ -46,6 +52,9 @@ function _iterable_to_array_limit(arr, i) {
46
52
  function _non_iterable_rest() {
47
53
  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
54
  }
55
+ function _non_iterable_spread() {
56
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
57
+ }
49
58
  function _object_spread(target) {
50
59
  for(var i = 1; i < arguments.length; i++){
51
60
  var source = arguments[i] != null ? arguments[i] : {};
@@ -124,6 +133,9 @@ function _object_without_properties_loose(source, excluded) {
124
133
  function _sliced_to_array(arr, i) {
125
134
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
126
135
  }
136
+ function _to_consumable_array(arr) {
137
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
138
+ }
127
139
  function _unsupported_iterable_to_array(o, minLen) {
128
140
  if (!o) return;
129
141
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -139,7 +151,7 @@ import { Subject } from "rxjs";
139
151
  import { createEditor } from "slate";
140
152
  import { withHistory } from "slate-history";
141
153
  import { withReact } from "slate-react";
142
- import { I18nProvide } from "../I18n";
154
+ import { I18nContext, I18nProvide } from "../I18n";
143
155
  import { CommentList } from "./editor/components/CommentList";
144
156
  import { SlateMarkdownEditor } from "./editor/Editor";
145
157
  import { parserMdToSchema } from "./editor/parser/parserMdToSchema";
@@ -172,6 +184,15 @@ var composeEditors = function composeEditors(editor, plugins) {
172
184
  }
173
185
  return editor;
174
186
  };
187
+ var I18nBoundary = function I18nBoundary(param) {
188
+ var children = param.children;
189
+ var outerI18n = useContext(I18nContext);
190
+ var hasOuterI18nProvider = Boolean((outerI18n === null || outerI18n === void 0 ? void 0 : outerI18n.setLanguage) || (outerI18n === null || outerI18n === void 0 ? void 0 : outerI18n.setLocale));
191
+ if (hasOuterI18nProvider) {
192
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
193
+ }
194
+ return /*#__PURE__*/ React.createElement(I18nProvide, null, children);
195
+ };
175
196
  /**
176
197
  * BaseMarkdownEditor 组件 - 基础Markdown编辑器组件
177
198
  *
@@ -300,16 +321,22 @@ var composeEditors = function composeEditors(editor, plugins) {
300
321
  /**
301
322
  * 初始化 schema
302
323
  */ var initSchemaValue = useMemo(function() {
303
- var _parserMdToSchema;
304
- var list = (_parserMdToSchema = parserMdToSchema(initValue, props.plugins)) === null || _parserMdToSchema === void 0 ? void 0 : _parserMdToSchema.schema;
324
+ // 安全地获取解析结果,确保 list 始终是数组
325
+ var parseResult = parserMdToSchema(initValue || '', props.plugins);
326
+ var list = (parseResult === null || parseResult === void 0 ? void 0 : parseResult.schema) || [];
327
+ // 如果不是只读模式,添加一个空段落以便编辑
305
328
  if (!props.readonly) {
306
- list.push(EditorUtils.p);
329
+ list = _to_consumable_array(list).concat([
330
+ EditorUtils.p
331
+ ]);
307
332
  }
333
+ // 优先使用外部传入的 initSchemaValue,否则根据 initValue 决定
308
334
  var schema = props.initSchemaValue || (initValue ? list : JSON.parse(JSON.stringify([
309
335
  EditorUtils.p
310
336
  ])));
337
+ // 过滤掉无效的空节点
311
338
  return schema === null || schema === void 0 ? void 0 : schema.filter(function(item) {
312
- if (item.type === 'p' && item.children.length === 0) {
339
+ if (item.type === 'paragraph' && item.children.length === 0) {
313
340
  return false;
314
341
  }
315
342
  if ((item.type === 'list' || item.type === 'bulleted-list' || item.type === 'numbered-list') && item.children.length === 0) {
@@ -369,7 +396,7 @@ var composeEditors = function composeEditors(editor, plugins) {
369
396
  }, []);
370
397
  var _useState6 = _sliced_to_array(useState(null), 2), domRect = _useState6[0], setDomRect = _useState6[1];
371
398
  var _obj;
372
- return wrapSSR(/*#__PURE__*/ React.createElement(I18nProvide, null, /*#__PURE__*/ React.createElement(PluginContext.Provider, {
399
+ return wrapSSR(/*#__PURE__*/ React.createElement(I18nBoundary, null, /*#__PURE__*/ React.createElement(PluginContext.Provider, {
373
400
  value: props.plugins || []
374
401
  }, /*#__PURE__*/ React.createElement(EditorStoreContext.Provider, {
375
402
  value: {
@@ -2,12 +2,17 @@ import { Dropdown } from "antd";
2
2
  import classnames from "classnames";
3
3
  import React from "react";
4
4
  import { ToolBarItem } from "./ToolBarItem";
5
- var HeatTextMap = {
6
- 1: '大标题',
7
- 2: '段落标题',
8
- 3: '小标题',
9
- 4: '正文',
10
- Text: '正文'
5
+ var HeadingLocaleKeyMap = {
6
+ 1: 'largeTitle',
7
+ 2: 'paragraphTitle',
8
+ 3: 'smallTitle',
9
+ 4: 'bodyText',
10
+ Text: 'bodyText'
11
+ };
12
+ var getHeadingText = function getHeadingText(i18n, level) {
13
+ var _i18n_locale;
14
+ var localeKey = HeadingLocaleKeyMap[level];
15
+ return (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale[localeKey]) || localeKey;
11
16
  };
12
17
  export var HeadingDropdown = /*#__PURE__*/ React.memo(function(param) {
13
18
  var baseClassName = param.baseClassName, hashId = param.hashId, i18n = param.i18n, node = param.node, hideTools = param.hideTools, onHeadingChange = param.onHeadingChange;
@@ -22,8 +27,9 @@ export var HeadingDropdown = /*#__PURE__*/ React.memo(function(param) {
22
27
  if (hideTools === null || hideTools === void 0 ? void 0 : hideTools.includes(item)) {
23
28
  return null;
24
29
  }
30
+ var level = item === 'Text' ? 'Text' : Number(item.slice(1));
25
31
  return {
26
- label: HeatTextMap[item.replace('H', '')] || item,
32
+ label: getHeadingText(i18n, level),
27
33
  key: "head-".concat(item),
28
34
  onClick: function onClick() {
29
35
  return onHeadingChange(index + 1);
@@ -32,15 +38,17 @@ export var HeadingDropdown = /*#__PURE__*/ React.memo(function(param) {
32
38
  }).filter(Boolean);
33
39
  }, [
34
40
  hideTools,
41
+ i18n,
35
42
  onHeadingChange
36
43
  ]);
37
44
  var currentText = React.useMemo(function() {
38
45
  var _node_;
39
46
  if (node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.level) {
40
- return HeatTextMap[node[0].level + ''] || "H".concat(node[0].level);
47
+ return getHeadingText(i18n, node[0].level);
41
48
  }
42
- return '正文';
49
+ return getHeadingText(i18n, 'Text');
43
50
  }, [
51
+ i18n,
44
52
  node
45
53
  ]);
46
54
  return /*#__PURE__*/ React.createElement(Dropdown, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.22",
3
+ "version": "2.29.23",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",