@ant-design/agentic-ui 2.18.0 → 2.19.0

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.
@@ -97,28 +97,16 @@ function _unsupported_iterable_to_array(o, minLen) {
97
97
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
98
98
  }
99
99
  import classNames from "classnames";
100
- import React, { createElement, useMemo } from "react";
100
+ import React, { createElement } from "react";
101
101
  import { Node } from "slate";
102
- import { useSlate } from "slate-react";
103
102
  import { useSelStatus } from "../../hooks/editor";
104
103
  import { useEditorStore } from "../store";
105
104
  import { DragHandle } from "../tools/DragHandle";
106
105
  import { slugify } from "../utils/dom";
107
106
  export function Head(param) {
108
107
  var element = param.element, attributes = param.attributes, children = param.children;
109
- var _editor_children_at, _editor_children, _editor_children_at1, _editor_children1;
110
- var _useEditorStore = useEditorStore(), _useEditorStore_store = _useEditorStore.store, store = _useEditorStore_store === void 0 ? {} : _useEditorStore_store, markdownContainerRef = _useEditorStore.markdownContainerRef, typewriter = _useEditorStore.typewriter;
111
- var editor = useSlate();
108
+ var _useEditorStore = useEditorStore(), _useEditorStore_store = _useEditorStore.store, store = _useEditorStore_store === void 0 ? {} : _useEditorStore_store, markdownContainerRef = _useEditorStore.markdownContainerRef;
112
109
  var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), selected = _useSelStatus[0], path = _useSelStatus[1];
113
- var isLast = useMemo(function() {
114
- if (editor.children.length === 0) return false;
115
- if (!typewriter) return false;
116
- return store.isLatestNode(element);
117
- }, [
118
- (_editor_children_at = (_editor_children = editor.children).at) === null || _editor_children_at === void 0 ? void 0 : _editor_children_at.call(_editor_children, path.at(0)),
119
- (_editor_children_at1 = (_editor_children1 = editor.children).at) === null || _editor_children_at1 === void 0 ? void 0 : _editor_children_at1.call(_editor_children1, path.at(0) + 1),
120
- typewriter
121
- ]);
122
110
  var str = Node.string(element);
123
111
  return React.useMemo(function() {
124
112
  var _obj;
@@ -127,12 +115,10 @@ export function Head(param) {
127
115
  }, _define_property(_obj, 'data-be', 'head'), _define_property(_obj, 'data-head', slugify(Node.string(element) || '')), _define_property(_obj, 'data-title', (path === null || path === void 0 ? void 0 : path[0]) === 0), _define_property(_obj, "onDragStart", function(e) {
128
116
  return store.dragStart(e, markdownContainerRef.current);
129
117
  }), _define_property(_obj, 'data-empty', !str && selected ? 'true' : undefined), _define_property(_obj, 'data-align', element.align), _define_property(_obj, 'data-drag-el', true), _define_property(_obj, "className", classNames({
130
- empty: !str,
131
- typewriter: isLast && typewriter
118
+ empty: !str
132
119
  })), _obj)), /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(DragHandle, null), children));
133
120
  }, [
134
121
  element.level,
135
- isLast,
136
122
  str,
137
123
  element.children,
138
124
  selected,
@@ -97,27 +97,17 @@ function _unsupported_iterable_to_array(o, minLen) {
97
97
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
98
98
  }
99
99
  import classNames from "classnames";
100
- import React, { useContext, useMemo } from "react";
100
+ import React, { useContext } from "react";
101
101
  import { Node } from "slate";
102
102
  import { I18nContext } from "../../../I18n";
103
103
  import { useSelStatus } from "../../hooks/editor";
104
104
  import { useEditorStore } from "../store";
105
105
  import { DragHandle } from "../tools/DragHandle";
106
106
  export var Paragraph = function(props) {
107
- var _markdownEditorRef_current_children_at, _markdownEditorRef_current, _markdownEditorRef_current_children, _markdownEditorRef_current_children_at1, _markdownEditorRef_current1, _markdownEditorRef_current_children1, _markdownEditorRef_current2;
108
- var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, typewriter = _useEditorStore.typewriter, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
107
+ var _markdownEditorRef_current;
108
+ var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
109
109
  var locale = useContext(I18nContext).locale;
110
- var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 2), selected = _useSelStatus[0], path = _useSelStatus[1];
111
- var isLast = useMemo(function() {
112
- var _markdownEditorRef_current;
113
- if (((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 0) return false;
114
- if (!typewriter) return false;
115
- return store.isLatestNode(props.element);
116
- }, [
117
- (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_children_at = (_markdownEditorRef_current_children = _markdownEditorRef_current.children).at) === null || _markdownEditorRef_current_children_at === void 0 ? void 0 : _markdownEditorRef_current_children_at.call(_markdownEditorRef_current_children, path.at(0)),
118
- (_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : (_markdownEditorRef_current_children_at1 = (_markdownEditorRef_current_children1 = _markdownEditorRef_current1.children).at) === null || _markdownEditorRef_current_children_at1 === void 0 ? void 0 : _markdownEditorRef_current_children_at1.call(_markdownEditorRef_current_children1, path.at(0) + 1),
119
- typewriter
120
- ]);
110
+ var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 1), selected = _useSelStatus[0];
121
111
  return React.useMemo(function() {
122
112
  var _markdownEditorRef_current, _props_element_children_every, _props_element_children, _props_element, _props_children;
123
113
  var str = Node.string(props.element).trim();
@@ -128,8 +118,7 @@ export var Paragraph = function(props) {
128
118
  "data-be": 'paragraph',
129
119
  "data-drag-el": true,
130
120
  className: classNames({
131
- empty: isEmpty,
132
- typewriter: isLast && typewriter
121
+ empty: isEmpty
133
122
  }),
134
123
  "data-align": props.element.align,
135
124
  "data-slate-placeholder": isEmpty ? editorProps.titlePlaceholderContent || (locale === null || locale === void 0 ? void 0 : locale.inputPlaceholder) || '请输入内容...' : undefined,
@@ -146,9 +135,7 @@ export var Paragraph = function(props) {
146
135
  props.element.align,
147
136
  readonly,
148
137
  selected,
149
- isLast,
150
- (_markdownEditorRef_current2 = markdownEditorRef.current) === null || _markdownEditorRef_current2 === void 0 ? void 0 : _markdownEditorRef_current2.children.length,
151
- editorProps.titlePlaceholderContent,
152
- typewriter
138
+ (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length,
139
+ editorProps.titlePlaceholderContent
153
140
  ]);
154
141
  };
@@ -50,32 +50,11 @@ function _object_spread_props(target, source) {
50
50
  }
51
51
  return target;
52
52
  }
53
- import { Keyframes } from "@ant-design/cssinjs";
54
53
  import { MOBILE_BREAKPOINT } from "../../Constants/mobile";
55
54
  import { resetComponent, useEditorStyleRegister } from "../../Hooks/useStyle";
56
55
  import "./code.css";
57
56
  // 导入统一的标签样式配置
58
57
  import { TAG_STYLES } from "./tagStyles";
59
- // 定义关键帧动画
60
- var typing = new Keyframes('typing', {
61
- from: {
62
- width: 0
63
- },
64
- to: {
65
- width: '100%'
66
- }
67
- });
68
- var blinkCaret = new Keyframes('blink-caret', {
69
- from: {
70
- borderColor: 'transparent'
71
- },
72
- to: {
73
- borderColor: 'transparent'
74
- },
75
- '50%': {
76
- borderColor: 'var(--color-primary-control-fill-primary)'
77
- }
78
- });
79
58
  var COMMENT_HIGHLIGHT_COLOR = 'var(--agentic-comment-highlight-color, rgba(21, 0, 255, 0.15))';
80
59
  var genStyle = function(token) {
81
60
  var _obj;
@@ -535,15 +514,6 @@ var genStyle = function(token) {
535
514
  padding: '0',
536
515
  height: '0',
537
516
  margin: 'var(--margin-8x) 0'
538
- },
539
- // 打字机效果样式
540
- '.ant-agentic-md-editor-content .typewriter:last-of-type > *:last-of-type span[data-slate-leaf]:last-of-type span[data-slate-string]': {
541
- borderRight: '0.15em solid var(--color-primary-control-fill-primary)',
542
- animationName: "".concat(typing.getName(), ", ").concat(blinkCaret.getName()),
543
- animationDuration: '3.5s, 0.5s',
544
- animationTimingFunction: 'steps(30, end), step-end',
545
- animationIterationCount: '1, infinite',
546
- animationFillMode: 'forwards, both'
547
517
  }
548
518
  }), _define_property(_obj, "".concat(token.componentCls, "-compact"), {
549
519
  'div[data-be="paragraph"]': {
@@ -127,7 +127,12 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
127
127
  // 选中状态管理
128
128
  var _React_useState = _sliced_to_array(React.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
129
129
  // 视图模式状态管理(用于HTML和Markdown)
130
- var _useState2 = _sliced_to_array(useState('code'), 2), viewMode = _useState2[0], setViewMode = _useState2[1];
130
+ // 如果是 markdown html,默认打开预览模式
131
+ var _useState2 = _sliced_to_array(useState(function() {
132
+ var _props_element_language, _props_element;
133
+ var language = (_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_language = _props_element.language) === null || _props_element_language === void 0 ? void 0 : _props_element_language.toLowerCase();
134
+ return language === 'html' || language === 'markdown' ? 'preview' : 'code';
135
+ }), 2), viewMode = _useState2[0], setViewMode = _useState2[1];
131
136
  // 使用Ace编辑器Hook
132
137
  var _AceEditor = AceEditor({
133
138
  element: props.element,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.18.0",
3
+ "version": "2.19.0",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -1,20 +0,0 @@
1
- /* The typing effect */
2
- @keyframes typing {
3
- from {
4
- width: 0;
5
- }
6
- to {
7
- width: 100%;
8
- }
9
- }
10
-
11
- /* The typewriter cursor effect */
12
- @keyframes blink-caret {
13
- from,
14
- to {
15
- border-color: transparent;
16
- }
17
- 50% {
18
- border-color: #1677ff;
19
- }
20
- }