@ant-design/agentic-ui 2.0.14 → 2.0.16

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 (121) hide show
  1. package/dist/BackTo/BackBottom.d.ts +56 -0
  2. package/dist/BackTo/BackTop.d.ts +39 -2
  3. package/dist/BackTo/index.d.ts +20 -0
  4. package/dist/Bubble/AIBubble.js +4 -1
  5. package/dist/Bubble/List/index.js +1 -1
  6. package/dist/Bubble/MessagesContent/MarkdownPreview.js +3 -1
  7. package/dist/Bubble/UserBubble.js +1 -1
  8. package/dist/Bubble/index.d.ts +6 -0
  9. package/dist/Bubble/style.js +5 -2
  10. package/dist/ChatBootPage/CaseReply.js +1 -1
  11. package/dist/ChatBootPage/Title.js +1 -1
  12. package/dist/ChatBootPage/index.d.ts +6 -0
  13. package/dist/Components/ActionIconBox/index.js +1 -1
  14. package/dist/Components/ActionItemBox/ActionItemBox.js +1 -1
  15. package/dist/Components/ActionItemBox/index.d.ts +6 -0
  16. package/dist/Components/Button/index.d.ts +6 -0
  17. package/dist/History/components/HistoryItem.js +2 -2
  18. package/dist/History/components/NewChatComponent.js +1 -1
  19. package/dist/History/components/SearchComponent.d.ts +2 -0
  20. package/dist/History/components/SearchComponent.js +17 -3
  21. package/dist/History/index.d.ts +4 -0
  22. package/dist/History/index.js +17 -11
  23. package/dist/History/menu.d.ts +2 -0
  24. package/dist/History/menu.js +18 -5
  25. package/dist/History/style.js +1 -1
  26. package/dist/History/types/index.d.ts +6 -0
  27. package/dist/MarkdownEditor/BaseMarkdownEditor.js +1 -1
  28. package/dist/MarkdownEditor/editor/components/CommentList/index.js +1 -1
  29. package/dist/MarkdownEditor/editor/components/ContributorAvatar/index.js +1 -1
  30. package/dist/MarkdownEditor/editor/components/fntTag/index.js +1 -1
  31. package/dist/MarkdownEditor/editor/elements/Comment/index.js +1 -1
  32. package/dist/MarkdownEditor/editor/elements/FootnoteDefinition.js +1 -1
  33. package/dist/MarkdownEditor/editor/elements/FootnoteReference.js +1 -1
  34. package/dist/MarkdownEditor/editor/elements/Head.js +1 -1
  35. package/dist/MarkdownEditor/editor/elements/Image/index.js +1 -1
  36. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +2 -2
  37. package/dist/MarkdownEditor/editor/elements/List/List.js +1 -1
  38. package/dist/MarkdownEditor/editor/elements/List/ListItem.js +1 -1
  39. package/dist/MarkdownEditor/editor/elements/List/style.js +2 -2
  40. package/dist/MarkdownEditor/editor/elements/Media.js +1 -1
  41. package/dist/MarkdownEditor/editor/elements/Paragraph.js +1 -1
  42. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +1 -1
  43. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +1 -1
  44. package/dist/MarkdownEditor/editor/elements/Table/Table.js +5 -3
  45. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +3 -1
  46. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +1 -1
  47. package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +1 -1
  48. package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +1 -1
  49. package/dist/MarkdownEditor/editor/elements/TagPopup/index.d.ts +0 -22
  50. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +176 -124
  51. package/dist/MarkdownEditor/editor/elements/index.js +1 -1
  52. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +16 -12
  53. package/dist/MarkdownEditor/editor/style.js +6 -6
  54. package/dist/MarkdownEditor/editor/tools/DragHandle.js +2 -2
  55. package/dist/MarkdownEditor/editor/tools/ToolBar/ToolBar.js +1 -1
  56. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +1 -1
  57. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +1 -1
  58. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +9 -8
  59. package/dist/MarkdownInputField/AttachmentButton/index.d.ts +2 -0
  60. package/dist/MarkdownInputField/AttachmentButton/index.js +1 -1
  61. package/dist/MarkdownInputField/AttachmentButton/style.js +3 -3
  62. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +8 -0
  63. package/dist/MarkdownInputField/AttachmentButton/utils.js +10 -3
  64. package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +1 -1
  65. package/dist/MarkdownInputField/Enlargement/index.js +9 -29
  66. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +30 -27
  67. package/dist/MarkdownInputField/FileMapView/index.d.ts +4 -4
  68. package/dist/MarkdownInputField/FileMapView/index.js +25 -15
  69. package/dist/MarkdownInputField/FileUploadManager/index.js +2 -2
  70. package/dist/MarkdownInputField/MarkdownInputField.d.ts +9 -19
  71. package/dist/MarkdownInputField/MarkdownInputField.js +155 -192
  72. package/dist/MarkdownInputField/QuickActions/index.js +4 -8
  73. package/dist/MarkdownInputField/RefinePromptButton/index.js +9 -54
  74. package/dist/MarkdownInputField/SendActions/index.js +1 -1
  75. package/dist/MarkdownInputField/SendButton/index.js +1 -1
  76. package/dist/MarkdownInputField/SkillModeBar/index.js +1 -1
  77. package/dist/MarkdownInputField/TopOperatingArea/index.js +1 -1
  78. package/dist/MarkdownInputField/VoiceInput/index.js +1 -1
  79. package/dist/MarkdownInputField/style.js +40 -45
  80. package/dist/Plugins/chart/AreaChart/index.d.ts +2 -2
  81. package/dist/Plugins/chart/AreaChart/index.js +9 -29
  82. package/dist/Plugins/chart/BarChart/index.d.ts +8 -8
  83. package/dist/Plugins/chart/BarChart/index.js +9 -8
  84. package/dist/Plugins/chart/DonutChart/constants.d.ts +0 -1
  85. package/dist/Plugins/chart/DonutChart/constants.js +0 -14
  86. package/dist/Plugins/chart/DonutChart/index.js +51 -16
  87. package/dist/Plugins/chart/DonutChart/style.js +7 -0
  88. package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
  89. package/dist/Plugins/chart/FunnelChart/index.d.ts +8 -8
  90. package/dist/Plugins/chart/FunnelChart/index.js +85 -66
  91. package/dist/Plugins/chart/FunnelChart/style.js +12 -0
  92. package/dist/Plugins/chart/LineChart/index.d.ts +2 -2
  93. package/dist/Plugins/chart/LineChart/index.js +16 -19
  94. package/dist/Plugins/chart/RadarChart/index.d.ts +11 -5
  95. package/dist/Plugins/chart/RadarChart/index.js +35 -50
  96. package/dist/Plugins/chart/RadarChart/style.js +8 -0
  97. package/dist/Plugins/chart/ScatterChart/index.d.ts +23 -6
  98. package/dist/Plugins/chart/ScatterChart/index.js +58 -57
  99. package/dist/Plugins/chart/ScatterChart/style.js +8 -0
  100. package/dist/Plugins/chart/components/ChartContainer/style.js +7 -1
  101. package/dist/Plugins/chart/hooks/useChartStatistic.d.ts +0 -6
  102. package/dist/Plugins/chart/hooks/useChartStatistic.js +0 -16
  103. package/dist/Plugins/chart/index.js +2 -2
  104. package/dist/Plugins/index.d.ts +6 -0
  105. package/dist/Plugins/mermaid/index.js +1 -1
  106. package/dist/Quote/index.js +1 -1
  107. package/dist/Schema/index.d.ts +6 -0
  108. package/dist/ThoughtChainList/DotAni/index.css +1 -1
  109. package/dist/ThoughtChainList/DotAni/index.js +2 -2
  110. package/dist/ToolUseBar/ToolUseBarThink.js +1 -1
  111. package/dist/ToolUseBar/index.js +1 -1
  112. package/dist/WelcomeMessage/index.d.ts +42 -0
  113. package/dist/WelcomeMessage/index.js +1 -1
  114. package/dist/Workspace/File/PreviewComponent.js +3 -2
  115. package/dist/Workspace/File/style.js +2 -1
  116. package/dist/Workspace/RealtimeFollow/style.js +2 -7
  117. package/dist/Workspace/Task/index.js +1 -1
  118. package/dist/Workspace/style.js +2 -1
  119. package/package.json +1 -1
  120. package/dist/MarkdownInputField/Enlargement/style.d.ts +0 -10
  121. package/dist/MarkdownInputField/Enlargement/style.js +0 -75
@@ -63,7 +63,7 @@ function Head({
63
63
  onDragStart: (e) => store.dragStart(e, markdownContainerRef.current),
64
64
  ["data-empty"]: !str && selected ? "true" : void 0,
65
65
  ["data-align"]: element.align,
66
- className: classNames("ant-md-editor-drag-el", {
66
+ className: classNames("ant-agentic-md-editor-drag-el", {
67
67
  empty: !str,
68
68
  typewriter: isLast && typewriter
69
69
  })
@@ -425,7 +425,7 @@ function EditorImage({
425
425
  return /* @__PURE__ */ React.createElement(
426
426
  "div",
427
427
  __spreadProps(__spreadValues({}, attributes), {
428
- className: "ant-md-editor-drag-el",
428
+ className: "ant-agentic-md-editor-drag-el",
429
429
  "data-be": "image",
430
430
  "data-testid": "image-container",
431
431
  style: {
@@ -29,14 +29,14 @@ function LinkCard({
29
29
  }) {
30
30
  var _a, _b, _c, _d;
31
31
  const context = useContext(ConfigProvider.ConfigContext);
32
- const baseCls = context == null ? void 0 : context.getPrefixCls("md-editor-link-card");
32
+ const baseCls = context == null ? void 0 : context.getPrefixCls("agentic-md-editor-link-card");
33
33
  const { wrapSSR, hashId } = useStyle(baseCls);
34
34
  const htmlRef = React.useRef(null);
35
35
  return wrapSSR(
36
36
  /* @__PURE__ */ React.createElement("div", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(
37
37
  "div",
38
38
  {
39
- className: classNames(baseCls, "ant-md-editor-drag-el", hashId),
39
+ className: classNames(baseCls, "ant-agentic-md-editor-drag-el", hashId),
40
40
  "data-be": "link-card",
41
41
  draggable: false,
42
42
  onContextMenu: (e) => {
@@ -32,7 +32,7 @@ var List = ({
32
32
  }) => {
33
33
  const { store, markdownContainerRef } = useEditorStore();
34
34
  const context = useContext(ConfigProvider.ConfigContext);
35
- const baseCls = context.getPrefixCls("md-editor-list");
35
+ const baseCls = context.getPrefixCls("agentic-md-editor-list");
36
36
  const { wrapSSR, hashId } = useStyle(baseCls);
37
37
  return React.useMemo(() => {
38
38
  const tag = element.order ? "ol" : "ul";
@@ -195,7 +195,7 @@ var ListItem = ({
195
195
  const context = useContext(ConfigProvider.ConfigContext);
196
196
  const listItemRender = (_a = editorProps == null ? void 0 : editorProps.comment) == null ? void 0 : _a.listItemRender;
197
197
  const { hashId = "" } = useContext(ListContext) || {};
198
- const baseCls = context.getPrefixCls("md-editor-list");
198
+ const baseCls = context.getPrefixCls("agentic-md-editor-list");
199
199
  const checkbox = React.useMemo(() => {
200
200
  if (!isTask)
201
201
  return null;
@@ -39,12 +39,12 @@ var genStyle = (token) => {
39
39
  paddingTop: "0 !important",
40
40
  paddingBottom: "0 !important"
41
41
  },
42
- [`li:not(${token.componentCls}-task) > :first-child .ant-md-editor-drag-handle`]: {
42
+ [`li:not(${token.componentCls}-task) > :first-child .ant-agentic-md-editor-drag-handle`]: {
43
43
  paddingLeft: "2px",
44
44
  paddingRight: "12px",
45
45
  left: "-44px !important"
46
46
  },
47
- [`li${token.componentCls}-task > :nth-child(2) .ant-md-editor-drag-handle`]: {
47
+ [`li${token.componentCls}-task > :nth-child(2) .ant-agentic-md-editor-drag-handle`]: {
48
48
  paddingLeft: "2px",
49
49
  paddingRight: "10px",
50
50
  left: "-50px !important"
@@ -474,7 +474,7 @@ function Media({
474
474
  return /* @__PURE__ */ React.createElement("div", __spreadValues({}, attributes), /* @__PURE__ */ React.createElement(
475
475
  "div",
476
476
  {
477
- className: "ant-md-editor-drag-el",
477
+ className: "ant-agentic-md-editor-drag-el",
478
478
  "data-be": "media",
479
479
  "data-testid": "media-container",
480
480
  style: {
@@ -61,7 +61,7 @@ var Paragraph = (props) => {
61
61
  "div",
62
62
  __spreadProps(__spreadValues({}, props.attributes), {
63
63
  "data-be": "paragraph",
64
- className: classNames("ant-md-editor-drag-el", {
64
+ className: classNames("ant-agentic-md-editor-drag-el", {
65
65
  empty: isEmpty,
66
66
  typewriter: isLast && typewriter
67
67
  }),
@@ -164,7 +164,7 @@ var ReadonlyTableComponent = React.memo(({ hashId, children, element, baseCls })
164
164
  className: classNames(
165
165
  baseCls,
166
166
  hashId,
167
- getPrefixCls("md-editor-content")
167
+ getPrefixCls("agentic-md-editor-content")
168
168
  ),
169
169
  style: {
170
170
  flex: 1,
@@ -28,7 +28,7 @@ import { SlateTable } from "./Table";
28
28
  import { TablePropsProvider } from "./TableContext";
29
29
  var SimpleTable = (props) => {
30
30
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
31
- const baseCls = getPrefixCls("md-editor-content-table");
31
+ const baseCls = getPrefixCls("agentic-md-editor-content-table");
32
32
  const editor = useSlate();
33
33
  const { wrapSSR, hashId } = useTableStyle(baseCls, {});
34
34
  const tablePath = useMemo(
@@ -37,7 +37,7 @@ var SlateTable = (_a) => {
37
37
  const { readonly, markdownContainerRef } = useEditorStore();
38
38
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
39
39
  const { tablePath } = useContext(TablePropsContext);
40
- const baseCls = getPrefixCls("md-editor-content-table");
40
+ const baseCls = getPrefixCls("agentic-md-editor-content-table");
41
41
  const tableTargetRef = useRef(null);
42
42
  const [tableRef, scrollState] = useScrollShadow();
43
43
  const colWidths = useMemo(() => {
@@ -60,7 +60,9 @@ var SlateTable = (_a) => {
60
60
  const tableRows = props.element.children;
61
61
  if (!((_m = (_l = tableRows == null ? void 0 : tableRows[0]) == null ? void 0 : _l.children) == null ? void 0 : _m.length))
62
62
  return [];
63
- const containerWidth = (((_o = (_n = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _n.querySelector(".ant-md-editor-content")) == null ? void 0 : _o.clientWidth) || 400) - 32 - 12;
63
+ const containerWidth = (((_o = (_n = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _n.querySelector(
64
+ ".ant-agentic-md-editor-content"
65
+ )) == null ? void 0 : _o.clientWidth) || 400) - 32 - 12;
64
66
  const maxColumnWidth = containerWidth / 4;
65
67
  const minColumnWidth = 60;
66
68
  const columnCount = ((_q = (_p = tableRows == null ? void 0 : tableRows[0]) == null ? void 0 : _p.children) == null ? void 0 : _q.length) || 0;
@@ -113,7 +115,7 @@ var SlateTable = (_a) => {
113
115
  return;
114
116
  let maxWidth = colWidths ? (colWidths == null ? void 0 : colWidths.reduce((a, b) => a + b, 0)) + 8 : 0;
115
117
  const minWidth = (_b3 = (_a3 = markdownContainerRef == null ? void 0 : markdownContainerRef.current) == null ? void 0 : _a3.querySelector(
116
- ".ant-md-editor-content"
118
+ ".ant-agentic-md-editor-content"
117
119
  )) == null ? void 0 : _b3.clientWidth;
118
120
  const dom = tableRef.current;
119
121
  if (dom) {
@@ -38,7 +38,9 @@ var TableCellIndex = ({
38
38
  tablePath
39
39
  }) => {
40
40
  const context = useContext(ConfigProvider.ConfigContext);
41
- const baseClassName = context == null ? void 0 : context.getPrefixCls("md-editor-table-cell-index");
41
+ const baseClassName = context == null ? void 0 : context.getPrefixCls(
42
+ "agentic-md-editor-table-cell-index"
43
+ );
42
44
  const { wrapSSR, hashId } = useStyle(baseClassName);
43
45
  const editor = useSlate();
44
46
  const tableContext = useContext(TablePropsContext);
@@ -39,7 +39,7 @@ var TableCellIndexSpacer = ({
39
39
  }) => {
40
40
  const context = useContext(ConfigProvider.ConfigContext);
41
41
  const baseClassName = context == null ? void 0 : context.getPrefixCls(
42
- "md-editor-table-cell-index-spacer"
42
+ "agentic-md-editor-table-cell-index-spacer"
43
43
  );
44
44
  const { wrapSSR, hashId } = useStyle(baseClassName);
45
45
  const editor = useSlate();
@@ -11,7 +11,7 @@ var TableRowIndex = ({
11
11
  tablePath
12
12
  }) => {
13
13
  const context = useContext(ConfigProvider.ConfigContext);
14
- const baseClassName = context == null ? void 0 : context.getPrefixCls("md-editor-table-row-index");
14
+ const baseClassName = context == null ? void 0 : context.getPrefixCls("agentic-md-editor-table-row-index");
15
15
  const { wrapSSR, hashId } = useStyle(baseClassName);
16
16
  return wrapSSR(
17
17
  /* @__PURE__ */ React.createElement(
@@ -37,7 +37,7 @@ var Td = ({
37
37
  const width = element == null ? void 0 : element.width;
38
38
  useSlateSelection();
39
39
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
40
- const prefix = getPrefixCls("md-editor-table-td");
40
+ const prefix = getPrefixCls("agentic-md-editor-table-td");
41
41
  const tdRef = useRef(null);
42
42
  const { wrapSSR, hashId } = useStyle(prefix);
43
43
  const handleRef = (node) => {
@@ -100,27 +100,5 @@ export type TagPopupProps = {
100
100
  onChange?: (value: string, props: RenderProps) => void;
101
101
  type?: 'panel' | 'dropdown';
102
102
  };
103
- /**
104
- * TagPopup 组件 - 在编辑器中显示一个标签弹出选择框
105
- *
106
- * 该组件在编辑器中创建一个交互式标签选择弹出框,允许用户从预定义列表中选择标签。
107
- * 当选择一个标签时,会调用提供的回调函数并关闭弹出框。该组件与 Slate 编辑器集成,
108
- * 可以感知当前的节点路径。
109
- *
110
- * @param props - 组件属性
111
- * @param props.items - 可选的下拉菜单项列表
112
- * @param props.onSelect - 当选择一个项时的回调函数,接收所选项的键和路径
113
- * @param props.children - 触发器元素内容
114
- * @param props.dropdownRender - 自定义下拉菜单渲染函数
115
- * @param props.dropdownStyle - 下拉菜单的样式
116
- * @param props.menu - 自定义菜单配置
117
- * @param props.notFoundContent - 未找到内容时显示的内容
118
- * @param props.className - 组件的额外 CSS 类名
119
- * @param props.open - 控制下拉菜单是否打开
120
- * @param props.onOpenChange - 下拉菜单打开状态变化时的回调
121
- * @param props.text - 包含文本内容
122
- *
123
- * @returns 一个带有下拉菜单的标签弹出组件
124
- */
125
103
  export declare const TagPopup: (props: RenderProps) => React.JSX.Element;
126
104
  export {};
@@ -52,8 +52,138 @@ import React, {
52
52
  import { ReactEditor, useSlate } from "slate-react";
53
53
  import { SuggestionConnext } from "../../../../MarkdownInputField/Suggestion";
54
54
  import { useStyle } from "./style";
55
+ var getNodePath = (editor, domRef) => {
56
+ if (!domRef.current)
57
+ return null;
58
+ const slateNode = ReactEditor.toSlateNode(editor, domRef.current);
59
+ return ReactEditor.findPath(editor, slateNode);
60
+ };
61
+ var updateNodeContext = (editor, domRef, suggestionConnext, props, onSelect, pathRef) => {
62
+ const path = getNodePath(editor, domRef);
63
+ if (!path)
64
+ return;
65
+ pathRef.current = path;
66
+ if (suggestionConnext == null ? void 0 : suggestionConnext.triggerNodeContext) {
67
+ suggestionConnext.triggerNodeContext.current = __spreadProps(__spreadValues({}, props), {
68
+ text: props.text
69
+ });
70
+ }
71
+ if (suggestionConnext == null ? void 0 : suggestionConnext.onSelectRef) {
72
+ suggestionConnext.onSelectRef.current = (newValue) => {
73
+ var _a;
74
+ const currentPath = getNodePath(editor, domRef);
75
+ onSelect == null ? void 0 : onSelect(newValue, currentPath || path || []);
76
+ (_a = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a.call(suggestionConnext, false);
77
+ };
78
+ }
79
+ };
80
+ var loadItemsData = (items, props, setLoading, setSelectedItems) => __async(void 0, null, function* () {
81
+ if (typeof items !== "function")
82
+ return;
83
+ setLoading(true);
84
+ const result = yield items(props);
85
+ if (Array.isArray(result)) {
86
+ setSelectedItems(result || []);
87
+ }
88
+ setLoading(false);
89
+ });
90
+ var initializeAutoOpen = (autoOpen, type, setOpen, suggestionConnext) => {
91
+ var _a;
92
+ if (!autoOpen)
93
+ return;
94
+ if (type === "dropdown") {
95
+ setOpen(true);
96
+ return;
97
+ }
98
+ (_a = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a.call(suggestionConnext, true);
99
+ };
100
+ var handleMouseEnter = (domRef) => {
101
+ const target = domRef.current;
102
+ if (!target)
103
+ return;
104
+ target.classList.remove("no-focus");
105
+ };
106
+ var handleMouseLeave = (domRef) => {
107
+ const target = domRef.current;
108
+ if (!target)
109
+ return;
110
+ target.classList.add("no-focus");
111
+ };
112
+ var createDefaultDom = (domRef, baseCls, hashId, loading, selectedItems, children, text, placeholder) => {
113
+ const isEmpty = !(text == null ? void 0 : text.trim());
114
+ const hasItems = (selectedItems == null ? void 0 : selectedItems.length) > 0;
115
+ return /* @__PURE__ */ React.createElement(
116
+ "div",
117
+ {
118
+ ref: domRef,
119
+ className: classNames(`${baseCls}-tag-popup-input`, "no-focus", hashId, {
120
+ empty: isEmpty,
121
+ [`${baseCls}-tag-popup-input-loading`]: loading,
122
+ [`${baseCls}-tag-popup-input-has-arrow`]: hasItems
123
+ }),
124
+ onMouseEnter: () => handleMouseEnter(domRef),
125
+ onMouseLeave: () => handleMouseLeave(domRef),
126
+ title: placeholder,
127
+ contentEditable: !hasItems
128
+ },
129
+ children,
130
+ hasItems && /* @__PURE__ */ React.createElement(
131
+ ChevronDown,
132
+ {
133
+ className: classNames(`${baseCls}-tag-popup-input-arrow `, hashId, {
134
+ empty: isEmpty
135
+ })
136
+ }
137
+ )
138
+ );
139
+ };
140
+ var getRenderDom = (tagRender, props, defaultDom, onSelect, currentNodePath) => {
141
+ if (!tagRender)
142
+ return defaultDom;
143
+ return tagRender(
144
+ __spreadProps(__spreadValues({}, props), {
145
+ text: props.text,
146
+ onSelect: (value, tagNode) => {
147
+ onSelect == null ? void 0 : onSelect((value == null ? void 0 : value.trim()) || "", currentNodePath.current || [], tagNode);
148
+ }
149
+ }),
150
+ defaultDom
151
+ );
152
+ };
153
+ var handlePanelClick = (suggestionConnext, props, onSelect, currentNodePath) => {
154
+ var _a;
155
+ if (suggestionConnext == null ? void 0 : suggestionConnext.triggerNodeContext) {
156
+ suggestionConnext.triggerNodeContext.current = __spreadProps(__spreadValues({}, props), {
157
+ text: props.text
158
+ });
159
+ }
160
+ if (suggestionConnext == null ? void 0 : suggestionConnext.onSelectRef) {
161
+ suggestionConnext.onSelectRef.current = (newValue) => {
162
+ var _a2;
163
+ onSelect == null ? void 0 : onSelect((newValue == null ? void 0 : newValue.trim()) || "", currentNodePath.current || []);
164
+ (_a2 = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a2.call(suggestionConnext, false);
165
+ };
166
+ }
167
+ (_a = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a.call(suggestionConnext, true);
168
+ };
169
+ var canOpen = (props, placeholder) => {
170
+ if (!props.beforeOpenChange)
171
+ return true;
172
+ return props.beforeOpenChange(true, __spreadProps(__spreadValues({}, props), {
173
+ text: props.text,
174
+ placeholder
175
+ }));
176
+ };
177
+ var handleClick = (e, props, placeholder, type, suggestionConnext, onSelect, currentNodePath) => {
178
+ e.preventDefault();
179
+ e.stopPropagation();
180
+ if (!canOpen(props, placeholder))
181
+ return;
182
+ if (type === "dropdown")
183
+ return;
184
+ handlePanelClick(suggestionConnext, props, onSelect, currentNodePath);
185
+ };
55
186
  var TagPopup = (props) => {
56
- var _a, _b;
57
187
  const { onSelect, items, children, type } = props || {};
58
188
  const editor = useSlate();
59
189
  const [open, setOpen] = useState(false);
@@ -61,120 +191,63 @@ var TagPopup = (props) => {
61
191
  const domRef = useRef(null);
62
192
  const suggestionConnext = useContext(SuggestionConnext);
63
193
  const antdContext = useContext(ConfigProvider.ConfigContext);
64
- const baseCls = antdContext == null ? void 0 : antdContext.getPrefixCls("md-editor-tag-popup-input");
194
+ const baseCls = antdContext == null ? void 0 : antdContext.getPrefixCls(
195
+ "agentic-md-editor-tag-popup-input"
196
+ );
65
197
  const { wrapSSR, hashId } = useStyle(baseCls);
66
198
  const currentNodePath = useRef();
67
199
  useEffect(() => {
68
- if (!domRef.current)
69
- return;
70
- const slateNode = ReactEditor.toSlateNode(editor, domRef.current);
71
- const path = ReactEditor.findPath(editor, slateNode);
200
+ const path = getNodePath(editor, domRef);
72
201
  if (path) {
73
202
  currentNodePath.current = path;
74
203
  }
75
204
  }, [editor.children, props.text]);
76
205
  useEffect(() => {
77
- if (!domRef.current)
78
- return;
79
- const slateNode = ReactEditor.toSlateNode(editor, domRef.current);
80
- const path = ReactEditor.findPath(editor, slateNode);
81
- if (path) {
82
- currentNodePath.current = path;
83
- if (suggestionConnext == null ? void 0 : suggestionConnext.triggerNodeContext) {
84
- suggestionConnext.triggerNodeContext.current = __spreadProps(__spreadValues({}, props), {
85
- text: props.text
86
- });
87
- }
88
- if (suggestionConnext == null ? void 0 : suggestionConnext.onSelectRef) {
89
- suggestionConnext.onSelectRef.current = (newValue) => {
90
- var _a2;
91
- const currentPath = ReactEditor.findPath(editor, slateNode);
92
- onSelect == null ? void 0 : onSelect(newValue, currentPath || path || []);
93
- (_a2 = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a2.call(suggestionConnext, false);
94
- };
95
- }
96
- }
206
+ updateNodeContext(
207
+ editor,
208
+ domRef,
209
+ suggestionConnext,
210
+ props,
211
+ onSelect,
212
+ currentNodePath
213
+ );
97
214
  }, [props.text]);
98
215
  const [selectedItems, setSelectedItems] = useState(() => {
99
- if (typeof items === "function") {
100
- return [];
101
- }
102
- return items || [];
216
+ return typeof items === "function" ? [] : items || [];
103
217
  });
104
218
  useEffect(() => {
105
- const loadingData = () => __async(void 0, null, function* () {
106
- if (typeof items === "function") {
107
- setLoading(true);
108
- const result = yield items(props);
109
- if (Array.isArray(result)) {
110
- setSelectedItems(result || []);
111
- }
112
- setLoading(false);
113
- }
114
- });
115
- loadingData();
219
+ loadItemsData(items, props, setLoading, setSelectedItems);
116
220
  }, [open, items]);
117
221
  useEffect(() => {
118
- var _a2;
119
- (_a2 = props.onChange) == null ? void 0 : _a2.call(props, props.text || "", __spreadProps(__spreadValues({}, props), {
222
+ var _a;
223
+ (_a = props.onChange) == null ? void 0 : _a.call(props, props.text || "", __spreadProps(__spreadValues({}, props), {
120
224
  text: props.text,
121
225
  onSelect: (value) => {
122
- onSelect == null ? void 0 : onSelect(value, currentNodePath.current || []);
226
+ onSelect == null ? void 0 : onSelect((value == null ? void 0 : value.trim()) || "", currentNodePath.current || []);
123
227
  }
124
228
  }));
125
229
  }, [props.text, suggestionConnext.open]);
126
230
  useEffect(() => {
127
- if (props.autoOpen) {
128
- if (type === "dropdown") {
129
- setOpen(true);
130
- } else if (suggestionConnext == null ? void 0 : suggestionConnext.setOpen) {
131
- suggestionConnext.setOpen(true);
132
- }
133
- }
231
+ initializeAutoOpen(props.autoOpen, type, setOpen, suggestionConnext);
134
232
  }, []);
135
233
  const placeholder = props.placeholder;
136
- const defaultDom = /* @__PURE__ */ React.createElement(
137
- "div",
138
- {
139
- ref: domRef,
140
- className: classNames(`${baseCls}-tag-popup-input`, "no-focus", hashId, {
141
- empty: !((_a = props.text) == null ? void 0 : _a.trim()),
142
- [`${baseCls}-tag-popup-input-loading`]: loading,
143
- [`${baseCls}-tag-popup-input-has-arrow`]: (selectedItems == null ? void 0 : selectedItems.length) > 0
144
- }),
145
- onMouseEnter: () => {
146
- const target = domRef.current;
147
- if (!target)
148
- return;
149
- target == null ? void 0 : target.classList.remove(`no-focus`);
150
- },
151
- onMouseLeave: () => {
152
- const target = domRef.current;
153
- if (!target)
154
- return;
155
- target == null ? void 0 : target.classList.add(`no-focus`);
156
- },
157
- title: placeholder
158
- },
234
+ const defaultDom = createDefaultDom(
235
+ domRef,
236
+ baseCls,
237
+ hashId,
238
+ loading,
239
+ selectedItems,
159
240
  children,
160
- (selectedItems == null ? void 0 : selectedItems.length) > 0 ? /* @__PURE__ */ React.createElement(
161
- ChevronDown,
162
- {
163
- className: classNames(`${baseCls}-tag-popup-input-arrow `, hashId, {
164
- empty: !((_b = props.text) == null ? void 0 : _b.trim())
165
- })
166
- }
167
- ) : null
241
+ props.text,
242
+ placeholder
243
+ );
244
+ const renderDom = getRenderDom(
245
+ props.tagRender,
246
+ props,
247
+ defaultDom,
248
+ onSelect,
249
+ currentNodePath
168
250
  );
169
- let renderDom = props.tagRender ? props.tagRender(
170
- __spreadProps(__spreadValues({}, props), {
171
- text: props.text,
172
- onSelect: (value, tagNode) => {
173
- onSelect == null ? void 0 : onSelect(value, currentNodePath.current || [], tagNode);
174
- }
175
- }),
176
- defaultDom
177
- ) : defaultDom;
178
251
  return wrapSSR(
179
252
  /* @__PURE__ */ React.createElement(
180
253
  "div",
@@ -191,36 +264,15 @@ var TagPopup = (props) => {
191
264
  text: props.text,
192
265
  placeholder
193
266
  }))),
194
- onClick: (e) => {
195
- var _a2;
196
- e.preventDefault();
197
- e.stopPropagation();
198
- if (props.beforeOpenChange) {
199
- const canOpen = props.beforeOpenChange(true, __spreadProps(__spreadValues({}, props), {
200
- text: props.text,
201
- placeholder
202
- }));
203
- if (!canOpen) {
204
- return;
205
- }
206
- }
207
- if (type === "dropdown") {
208
- return;
209
- }
210
- if (suggestionConnext == null ? void 0 : suggestionConnext.triggerNodeContext) {
211
- suggestionConnext.triggerNodeContext.current = __spreadProps(__spreadValues({}, props), {
212
- text: props.text
213
- });
214
- }
215
- if (suggestionConnext == null ? void 0 : suggestionConnext.onSelectRef) {
216
- suggestionConnext.onSelectRef.current = (newValue) => {
217
- var _a3;
218
- onSelect == null ? void 0 : onSelect(newValue, currentNodePath.current || []);
219
- (_a3 = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a3.call(suggestionConnext, false);
220
- };
221
- }
222
- (_a2 = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a2.call(suggestionConnext, true);
223
- }
267
+ onClick: (e) => handleClick(
268
+ e,
269
+ props,
270
+ placeholder,
271
+ type,
272
+ suggestionConnext,
273
+ onSelect,
274
+ currentNodePath
275
+ )
224
276
  },
225
277
  type === "dropdown" ? /* @__PURE__ */ React.createElement(
226
278
  Dropdown,
@@ -231,9 +283,9 @@ var TagPopup = (props) => {
231
283
  menu: {
232
284
  items: selectedItems,
233
285
  onClick: (e) => {
234
- var _a2;
235
- onSelect == null ? void 0 : onSelect(e.key, currentNodePath.current || []);
236
- (_a2 = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _a2.call(suggestionConnext, false);
286
+ var _a, _b;
287
+ onSelect == null ? void 0 : onSelect(((_a = e.key) == null ? void 0 : _a.trim()) || "", currentNodePath.current || []);
288
+ (_b = suggestionConnext == null ? void 0 : suggestionConnext.setOpen) == null ? void 0 : _b.call(suggestionConnext, false);
237
289
  }
238
290
  }
239
291
  },
@@ -221,7 +221,7 @@ var MLeafComponent = (props) => {
221
221
  const { markdownEditorRef, markdownContainerRef, readonly, setShowComment } = useEditorStore();
222
222
  const context = useContext(ConfigProvider.ConfigContext);
223
223
  const { locale } = useContext(I18nContext);
224
- const mdEditorBaseClass = context == null ? void 0 : context.getPrefixCls("md-editor-content");
224
+ const mdEditorBaseClass = context == null ? void 0 : context.getPrefixCls("agentic-md-editor-content");
225
225
  const leaf = props.leaf;
226
226
  const style = {};
227
227
  let prefixClassName = classNames(props.hashId);
@@ -148,7 +148,7 @@ var findImageElement = (str) => {
148
148
  const muted = str.match(/muted/);
149
149
  const poster = str.match(/poster="([^"\n]+)"/);
150
150
  return {
151
- url: decodeURIComponent(videoWithSourceMatch[1]),
151
+ url: videoWithSourceMatch[1],
152
152
  height: height ? +height[1] : void 0,
153
153
  width: width ? +width[1] : void 0,
154
154
  align: align == null ? void 0 : align[1],
@@ -522,17 +522,21 @@ var processInlineHtml = (currentElement, htmlTag) => {
522
522
  } else if (mediaElement.tagName === "iframe") {
523
523
  mediaType = "iframe";
524
524
  }
525
- return EditorUtils.createMediaNode(mediaElement == null ? void 0 : mediaElement.url, mediaType, {
526
- align: mediaElement.align,
527
- alt: mediaElement.alt,
528
- height: mediaElement == null ? void 0 : mediaElement.height,
529
- width: mediaElement == null ? void 0 : mediaElement.width,
530
- controls: mediaElement == null ? void 0 : mediaElement.controls,
531
- autoplay: mediaElement == null ? void 0 : mediaElement.autoplay,
532
- loop: mediaElement == null ? void 0 : mediaElement.loop,
533
- muted: mediaElement == null ? void 0 : mediaElement.muted,
534
- poster: mediaElement == null ? void 0 : mediaElement.poster
535
- });
525
+ return EditorUtils.createMediaNode(
526
+ decodeURIComponentUrl((mediaElement == null ? void 0 : mediaElement.url) || ""),
527
+ mediaType,
528
+ {
529
+ align: mediaElement.align,
530
+ alt: mediaElement.alt,
531
+ height: mediaElement == null ? void 0 : mediaElement.height,
532
+ width: mediaElement == null ? void 0 : mediaElement.width,
533
+ controls: mediaElement == null ? void 0 : mediaElement.controls,
534
+ autoplay: mediaElement == null ? void 0 : mediaElement.autoplay,
535
+ loop: mediaElement == null ? void 0 : mediaElement.loop,
536
+ muted: mediaElement == null ? void 0 : mediaElement.muted,
537
+ poster: mediaElement == null ? void 0 : mediaElement.poster
538
+ }
539
+ );
536
540
  } else {
537
541
  return { text: currentElement.value };
538
542
  }