@ant-design/agentic-ui 2.26.0 → 2.27.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.
@@ -279,9 +279,19 @@ import { getMediaType } from "../../utils/dom";
279
279
  // 图片加载失败时显示为链接
280
280
  if (error) {
281
281
  return /*#__PURE__*/ React.createElement("a", {
282
- href: props.src,
283
282
  target: "_blank",
284
283
  rel: "noopener noreferrer",
284
+ onClick: function(e) {
285
+ var _editorProps_linkConfig, _editorProps_linkConfig1;
286
+ e.stopPropagation();
287
+ e.preventDefault();
288
+ if ((_editorProps_linkConfig = editorProps.linkConfig) === null || _editorProps_linkConfig === void 0 ? void 0 : _editorProps_linkConfig.onClick) {
289
+ if (editorProps.linkConfig.onClick(props.src || '') === false) {
290
+ return;
291
+ }
292
+ }
293
+ window.open(props.src, (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_linkConfig1 = editorProps.linkConfig) === null || _editorProps_linkConfig1 === void 0 ? void 0 : _editorProps_linkConfig1.openInNewTab) ? '_blank' : '_self');
294
+ },
285
295
  style: {
286
296
  color: '#1890ff',
287
297
  textDecoration: 'underline',
@@ -382,6 +382,7 @@ export function Media(param) {
382
382
  var _state, _state1;
383
383
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
384
384
  var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), _ = _useSelStatus[0], path = _useSelStatus[1];
385
+ var editorProps = useEditorStore().editorProps;
385
386
  var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, readonly = _useEditorStore.readonly;
386
387
  var locale = useContext(I18nContext).locale;
387
388
  var htmlRef = React.useRef(null);
@@ -594,11 +595,23 @@ export function Media(param) {
594
595
  });
595
596
  }
596
597
  if (!state().loadSuccess) {
597
- var _state1, _state2;
598
+ var _state1;
598
599
  return /*#__PURE__*/ React.createElement("a", {
599
- href: ((_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url) || (element === null || element === void 0 ? void 0 : element.url),
600
600
  target: "_blank",
601
601
  rel: "noopener noreferrer",
602
+ onClick: function(e) {
603
+ var _state, _editorProps_linkConfig, _state1, _editorProps_linkConfig1;
604
+ if (!((_state = state()) === null || _state === void 0 ? void 0 : _state.url)) return;
605
+ e.stopPropagation();
606
+ e.preventDefault();
607
+ if ((_editorProps_linkConfig = editorProps.linkConfig) === null || _editorProps_linkConfig === void 0 ? void 0 : _editorProps_linkConfig.onClick) {
608
+ var _state2;
609
+ if (editorProps.linkConfig.onClick(((_state2 = state()) === null || _state2 === void 0 ? void 0 : _state2.url) || '') === false) {
610
+ return;
611
+ }
612
+ }
613
+ window.open((_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url, (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_linkConfig1 = editorProps.linkConfig) === null || _editorProps_linkConfig1 === void 0 ? void 0 : _editorProps_linkConfig1.openInNewTab) ? '_blank' : '_self');
614
+ },
602
615
  style: {
603
616
  color: '#1890ff',
604
617
  textDecoration: 'underline',
@@ -616,7 +629,7 @@ export function Media(param) {
616
629
  style: {
617
630
  color: '#faad14'
618
631
  }
619
- }), element.alt || ((_state2 = state()) === null || _state2 === void 0 ? void 0 : _state2.url) || (element === null || element === void 0 ? void 0 : element.url) || '视频链接');
632
+ }), element.alt || ((_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url) || (element === null || element === void 0 ? void 0 : element.url) || '视频链接');
620
633
  }
621
634
  return /*#__PURE__*/ React.createElement("video", {
622
635
  "data-testid": "video-element",
@@ -645,7 +658,7 @@ export function Media(param) {
645
658
  });
646
659
  }
647
660
  if (state().type === 'audio') {
648
- var _state3;
661
+ var _state2;
649
662
  // 如果是不完整状态
650
663
  if (element.finished === false) {
651
664
  // 如果 5 秒后仍未完成,显示为文本
@@ -688,11 +701,23 @@ export function Media(param) {
688
701
  }, rawMarkdown || (element === null || element === void 0 ? void 0 : element.alt) || '音频加载中...'));
689
702
  }
690
703
  if (!state().loadSuccess) {
691
- var _state4, _state5;
704
+ var _state3;
692
705
  return /*#__PURE__*/ React.createElement("a", {
693
- href: ((_state4 = state()) === null || _state4 === void 0 ? void 0 : _state4.url) || (element === null || element === void 0 ? void 0 : element.url),
694
706
  target: "_blank",
695
707
  rel: "noopener noreferrer",
708
+ onClick: function(e) {
709
+ var _state, _editorProps_linkConfig, _state1, _editorProps_linkConfig1;
710
+ if (!(((_state = state()) === null || _state === void 0 ? void 0 : _state.url) || (element === null || element === void 0 ? void 0 : element.url))) return;
711
+ e.stopPropagation();
712
+ e.preventDefault();
713
+ if ((_editorProps_linkConfig = editorProps.linkConfig) === null || _editorProps_linkConfig === void 0 ? void 0 : _editorProps_linkConfig.onClick) {
714
+ var _state2;
715
+ if (editorProps.linkConfig.onClick(((_state2 = state()) === null || _state2 === void 0 ? void 0 : _state2.url) || (element === null || element === void 0 ? void 0 : element.url) || '') === false) {
716
+ return;
717
+ }
718
+ }
719
+ window.open(((_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url) || (element === null || element === void 0 ? void 0 : element.url), (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_linkConfig1 = editorProps.linkConfig) === null || _editorProps_linkConfig1 === void 0 ? void 0 : _editorProps_linkConfig1.openInNewTab) ? '_blank' : '_self');
720
+ },
696
721
  style: {
697
722
  color: '#1890ff',
698
723
  textDecoration: 'underline',
@@ -710,7 +735,7 @@ export function Media(param) {
710
735
  style: {
711
736
  color: '#faad14'
712
737
  }
713
- }), element.alt || ((_state5 = state()) === null || _state5 === void 0 ? void 0 : _state5.url) || (element === null || element === void 0 ? void 0 : element.url) || '音频链接');
738
+ }), element.alt || ((_state3 = state()) === null || _state3 === void 0 ? void 0 : _state3.url) || (element === null || element === void 0 ? void 0 : element.url) || '音频链接');
714
739
  }
715
740
  return /*#__PURE__*/ React.createElement("audio", {
716
741
  "data-testid": "audio-element",
@@ -719,7 +744,7 @@ export function Media(param) {
719
744
  width: '100%',
720
745
  height: 'auto'
721
746
  },
722
- src: ((_state3 = state()) === null || _state3 === void 0 ? void 0 : _state3.url) || '',
747
+ src: ((_state2 = state()) === null || _state2 === void 0 ? void 0 : _state2.url) || '',
723
748
  onError: function() {
724
749
  var _state;
725
750
  console.warn('Audio failed to load:', (_state = state()) === null || _state === void 0 ? void 0 : _state.url);
@@ -730,7 +755,7 @@ export function Media(param) {
730
755
  }, "Your browser does not support the", /*#__PURE__*/ React.createElement("code", null, "audio"), " element.");
731
756
  }
732
757
  if (state().type === 'attachment') {
733
- var _state6, _element_alt, _element_alt1, _element_otherProps1, _element_otherProps_collaborators, _element_otherProps2, _element_otherProps3;
758
+ var _state4, _element_alt, _element_alt1, _element_otherProps1, _element_otherProps_collaborators, _element_otherProps2, _element_otherProps3;
734
759
  return /*#__PURE__*/ React.createElement("div", {
735
760
  style: {
736
761
  padding: 12,
@@ -762,7 +787,7 @@ export function Media(param) {
762
787
  minWidth: 0
763
788
  }
764
789
  }, /*#__PURE__*/ React.createElement("a", {
765
- href: (_state6 = state()) === null || _state6 === void 0 ? void 0 : _state6.url,
790
+ href: (_state4 = state()) === null || _state4 === void 0 ? void 0 : _state4.url,
766
791
  style: {
767
792
  overflow: 'ellipsis',
768
793
  textOverflow: 'ellipsis',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",