@ant-design/agentic-ui 2.29.21 → 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.
- package/dist/Bubble/MessagesContent/index.js +13 -12
- package/dist/Bubble/MessagesContent/style.d.ts +1 -1
- package/dist/Bubble/MessagesContent/style.js +11 -13
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +33 -6
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +17 -9
- package/package.json +1 -1
|
@@ -324,9 +324,10 @@ export var LOADING_FLAT = '...';
|
|
|
324
324
|
var locale = useContext(I18nContext).locale;
|
|
325
325
|
var _React_useState = _sliced_to_array(React.useState(false), 2), isExtraNull = _React_useState[0], setIsExtraNull = _React_useState[1];
|
|
326
326
|
var _React_useState1 = _sliced_to_array(React.useState([]), 2), nodeList = _React_useState1[0], setNodeList = _React_useState1[1];
|
|
327
|
-
var _useMessagesContentStyle = useMessagesContentStyle(), hashId = _useMessagesContentStyle.hashId, wrapSSR = _useMessagesContentStyle.wrapSSR;
|
|
328
327
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
329
328
|
var chatCls = getPrefixCls('agentic-ui');
|
|
329
|
+
var baseChatCls = "".concat(chatCls, "-display");
|
|
330
|
+
var _useMessagesContentStyle = useMessagesContentStyle(baseChatCls), hashId = _useMessagesContentStyle.hashId, wrapSSR = _useMessagesContentStyle.wrapSSR;
|
|
330
331
|
var funRender = useRefFunction(function(props) {
|
|
331
332
|
var node = nodeList.find(function(item) {
|
|
332
333
|
return item.placeholder === props.identifier;
|
|
@@ -368,7 +369,7 @@ export var LOADING_FLAT = '...';
|
|
|
368
369
|
var _context_thoughtChain;
|
|
369
370
|
if ((context === null || context === void 0 ? void 0 : (_context_thoughtChain = context.thoughtChain) === null || _context_thoughtChain === void 0 ? void 0 : _context_thoughtChain.alwaysRender) !== true) {
|
|
370
371
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
371
|
-
className: classNames('agent-item-default-content', "".concat(
|
|
372
|
+
className: classNames('agent-item-default-content', "".concat(baseChatCls, "-messages-content-loading"), (context === null || context === void 0 ? void 0 : context.compact) ? "".concat(baseChatCls, "-messages-content-loading-compact") : "".concat(baseChatCls, "-messages-content-loading-default"), hashId),
|
|
372
373
|
"data-testid": "message-content"
|
|
373
374
|
}, (locale === null || locale === void 0 ? void 0 : locale['chat.message.thinking']) || '思考中...'));
|
|
374
375
|
}
|
|
@@ -511,7 +512,7 @@ export var LOADING_FLAT = '...';
|
|
|
511
512
|
if (content === '...' || /*#__PURE__*/ React.isValidElement(content) || props.placement !== 'left' || (props === null || props === void 0 ? void 0 : (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : (_props_originData_extra = _props_originData1.extra) === null || _props_originData_extra === void 0 ? void 0 : (_props_originData_extra_tags = _props_originData_extra.tags) === null || _props_originData_extra_tags === void 0 ? void 0 : (_props_originData_extra_tags_includes = _props_originData_extra_tags.includes) === null || _props_originData_extra_tags_includes === void 0 ? void 0 : _props_originData_extra_tags_includes.call(_props_originData_extra_tags, 'REJECT_TO_ANSWER')) || ((_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : _props_originData2.role) === 'bot') {
|
|
512
513
|
var _props_originData11, _props_originData12;
|
|
513
514
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
514
|
-
className: classNames('agent-item-default-content', "".concat(
|
|
515
|
+
className: classNames('agent-item-default-content', "".concat(baseChatCls, "-messages-content-message"), hashId),
|
|
515
516
|
"data-testid": "message-box-content",
|
|
516
517
|
onDoubleClick: props.onDoubleClick
|
|
517
518
|
}, /*#__PURE__*/ React.createElement(MarkdownPreview, {
|
|
@@ -532,11 +533,11 @@ export var LOADING_FLAT = '...';
|
|
|
532
533
|
}
|
|
533
534
|
// answerStatus= 'EXCEPTION'时 一定是异常情况
|
|
534
535
|
if (((_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : (_props_originData_extra1 = _props_originData3.extra) === null || _props_originData_extra1 === void 0 ? void 0 : _props_originData_extra1.answerStatus) === 'EXCEPTION' || ((_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : (_props_originData_extra2 = _props_originData4.extra) === null || _props_originData_extra2 === void 0 ? void 0 : _props_originData_extra2.answerStatus) && !((_props_originData5 = props.originData) === null || _props_originData5 === void 0 ? void 0 : _props_originData5.content)) {
|
|
535
|
-
return /*#__PURE__*/ React.createElement(EXCEPTION, {
|
|
536
|
+
return wrapSSR(/*#__PURE__*/ React.createElement(EXCEPTION, {
|
|
536
537
|
content: props.originData.content,
|
|
537
538
|
originData: props.originData,
|
|
538
539
|
extra: isExtraNull ? null : extra
|
|
539
|
-
});
|
|
540
|
+
}));
|
|
540
541
|
}
|
|
541
542
|
var docInfoList = [
|
|
542
543
|
props === null || props === void 0 ? void 0 : (_props_originData6 = props.originData) === null || _props_originData6 === void 0 ? void 0 : (_props_originData_extra3 = _props_originData6.extra) === null || _props_originData_extra3 === void 0 ? void 0 : _props_originData_extra3.white_box_process
|
|
@@ -558,7 +559,7 @@ export var LOADING_FLAT = '...';
|
|
|
558
559
|
reference_url_info_list: ((_props_docListProps1 = props.docListProps) === null || _props_docListProps1 === void 0 ? void 0 : _props_docListProps1.reference_url_info_list) || ((_props_originData13 = props.originData) === null || _props_originData13 === void 0 ? void 0 : (_props_originData_extra4 = _props_originData13.extra) === null || _props_originData_extra4 === void 0 ? void 0 : _props_originData_extra4.reference_url_info_list) || []
|
|
559
560
|
}));
|
|
560
561
|
}
|
|
561
|
-
return /*#__PURE__*/ React.createElement(MarkdownPreview, {
|
|
562
|
+
return wrapSSR(/*#__PURE__*/ React.createElement(MarkdownPreview, {
|
|
562
563
|
markdownRenderConfig: props.markdownRenderConfig,
|
|
563
564
|
isFinished: (_props_originData7 = props.originData) === null || _props_originData7 === void 0 ? void 0 : _props_originData7.isFinished,
|
|
564
565
|
beforeContent: beforeContent,
|
|
@@ -574,7 +575,7 @@ export var LOADING_FLAT = '...';
|
|
|
574
575
|
if (!(item === null || item === void 0 ? void 0 : item.origin_text)) return null;
|
|
575
576
|
return /*#__PURE__*/ React.createElement(Popover, {
|
|
576
577
|
title: /*#__PURE__*/ React.createElement("div", {
|
|
577
|
-
className: classNames("".concat(
|
|
578
|
+
className: classNames("".concat(baseChatCls, "-messages-content-popover-title"), hashId),
|
|
578
579
|
style: props === null || props === void 0 ? void 0 : (_props_customConfig = props.customConfig) === null || _props_customConfig === void 0 ? void 0 : (_props_customConfig_PopoverProps = _props_customConfig.PopoverProps) === null || _props_customConfig_PopoverProps === void 0 ? void 0 : _props_customConfig_PopoverProps.titleStyle
|
|
579
580
|
}, /*#__PURE__*/ React.createElement("div", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.referenceDocument']) || '参考文档'), (item === null || item === void 0 ? void 0 : item.origin_url) ? /*#__PURE__*/ React.createElement(ActionIconBox, {
|
|
580
581
|
title: (locale === null || locale === void 0 ? void 0 : locale['chat.message.viewOriginal']) || '查看原文',
|
|
@@ -590,7 +591,7 @@ export var LOADING_FLAT = '...';
|
|
|
590
591
|
}
|
|
591
592
|
}, /*#__PURE__*/ React.createElement(ExportOutlined, null)) : null),
|
|
592
593
|
content: /*#__PURE__*/ React.createElement("div", {
|
|
593
|
-
className: classNames("".concat(
|
|
594
|
+
className: classNames("".concat(baseChatCls, "-messages-content-popover-content"), hashId),
|
|
594
595
|
style: props === null || props === void 0 ? void 0 : (_props_customConfig2 = props.customConfig) === null || _props_customConfig2 === void 0 ? void 0 : (_props_customConfig_PopoverProps1 = _props_customConfig2.PopoverProps) === null || _props_customConfig_PopoverProps1 === void 0 ? void 0 : _props_customConfig_PopoverProps1.contentStyle
|
|
595
596
|
}, /*#__PURE__*/ React.createElement(MarkdownEditor, {
|
|
596
597
|
style: {
|
|
@@ -616,12 +617,12 @@ export var LOADING_FLAT = '...';
|
|
|
616
617
|
}
|
|
617
618
|
}, item.docId)
|
|
618
619
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
619
|
-
className: classNames("".concat(
|
|
620
|
+
className: classNames("".concat(baseChatCls, "-messages-content-doc-tag"), hashId)
|
|
620
621
|
}, /*#__PURE__*/ React.createElement("img", {
|
|
621
|
-
className: classNames("".concat(
|
|
622
|
+
className: classNames("".concat(baseChatCls, "-messages-content-doc-tag-icon"), hashId),
|
|
622
623
|
src: 'https://mdn.alipayobjects.com/huamei_ptjqan/afts/img/A*kF_GTppRbp4AAAAAAAAAAAAADkN6AQ/original'
|
|
623
624
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
624
|
-
className: classNames("".concat(
|
|
625
|
+
className: classNames("".concat(baseChatCls, "-messages-content-doc-name"), hashId)
|
|
625
626
|
}, item === null || item === void 0 ? void 0 : item.doc_name))) : null)
|
|
626
627
|
}, _);
|
|
627
628
|
},
|
|
@@ -636,7 +637,7 @@ export var LOADING_FLAT = '...';
|
|
|
636
637
|
htmlRef: props.bubbleListRef,
|
|
637
638
|
content: ((_props_originData8 = props.originData) === null || _props_originData8 === void 0 ? void 0 : _props_originData8.isFinished) ? ((_props_originData9 = props.originData) === null || _props_originData9 === void 0 ? void 0 : _props_originData9.content) || (locale === null || locale === void 0 ? void 0 : locale['chat.message.generateFailed']) || '生成回答失败,请重试' : ((_props_originData10 = props.originData) === null || _props_originData10 === void 0 ? void 0 : _props_originData10.content) || '',
|
|
638
639
|
originData: props.originData
|
|
639
|
-
});
|
|
640
|
+
}));
|
|
640
641
|
}, [
|
|
641
642
|
content,
|
|
642
643
|
props === null || props === void 0 ? void 0 : (_props_originData5 = props.originData) === null || _props_originData5 === void 0 ? void 0 : _props_originData5.feedback,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function useMessagesContentStyle(): {
|
|
2
|
+
export declare function useMessagesContentStyle(componentCls: string): {
|
|
3
3
|
hashId: string;
|
|
4
4
|
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
5
5
|
} | {
|
|
@@ -54,7 +54,7 @@ import { useEditorStyleRegister } from "../../Hooks/useStyle";
|
|
|
54
54
|
var genStyle = function genStyle(token) {
|
|
55
55
|
var _obj;
|
|
56
56
|
return _obj = {}, // 加载状态容器(compact模式)
|
|
57
|
-
_define_property(_obj, "".concat(token.
|
|
57
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-loading"), {
|
|
58
58
|
lineHeight: '24px',
|
|
59
59
|
display: 'flex',
|
|
60
60
|
alignItems: 'center',
|
|
@@ -67,19 +67,19 @@ var genStyle = function genStyle(token) {
|
|
|
67
67
|
padding: 'var(--padding-3x)'
|
|
68
68
|
}
|
|
69
69
|
}), // 消息内容容器
|
|
70
|
-
_define_property(_obj, "".concat(token.
|
|
70
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-message"), {
|
|
71
71
|
lineHeight: '24px'
|
|
72
72
|
}), // 用户消息文本颜色
|
|
73
|
-
_define_property(_obj, "".concat(token.
|
|
73
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-user-text"), {
|
|
74
74
|
color: '#343A45'
|
|
75
75
|
}), // Popover 标题容器
|
|
76
|
-
_define_property(_obj, "".concat(token.
|
|
76
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-popover-title"), {
|
|
77
77
|
display: 'flex',
|
|
78
78
|
justifyContent: 'space-between',
|
|
79
79
|
alignItems: 'center',
|
|
80
80
|
fontSize: '1em'
|
|
81
81
|
}), // Popover 内容容器
|
|
82
|
-
_define_property(_obj, "".concat(token.
|
|
82
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-popover-content"), {
|
|
83
83
|
width: 400,
|
|
84
84
|
display: 'flex',
|
|
85
85
|
maxHeight: 400,
|
|
@@ -87,7 +87,7 @@ var genStyle = function genStyle(token) {
|
|
|
87
87
|
flexDirection: 'column',
|
|
88
88
|
gap: 'var(--padding-3x)'
|
|
89
89
|
}), // MarkdownEditor 容器样式
|
|
90
|
-
_define_property(_obj, "".concat(token.
|
|
90
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-markdown-editor"), {
|
|
91
91
|
padding: 0,
|
|
92
92
|
width: '100%'
|
|
93
93
|
}), // 重新生成按钮容器
|
|
@@ -97,7 +97,7 @@ var genStyle = function genStyle(token) {
|
|
|
97
97
|
cursor: 'pointer',
|
|
98
98
|
alignItems: 'center'
|
|
99
99
|
}), // 文档标签容器
|
|
100
|
-
_define_property(_obj, "".concat(token.
|
|
100
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-doc-tag"), {
|
|
101
101
|
borderRadius: 'var(--padding-5x)',
|
|
102
102
|
opacity: 1,
|
|
103
103
|
display: 'flex',
|
|
@@ -110,10 +110,10 @@ var genStyle = function genStyle(token) {
|
|
|
110
110
|
cursor: 'pointer',
|
|
111
111
|
zIndex: 1
|
|
112
112
|
}), // 文档标签图标
|
|
113
|
-
_define_property(_obj, "".concat(token.
|
|
113
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-doc-tag-icon"), {
|
|
114
114
|
width: 24
|
|
115
115
|
}), // 文档名称文本
|
|
116
|
-
_define_property(_obj, "".concat(token.
|
|
116
|
+
_define_property(_obj, "".concat(token.componentCls, "-messages-content-doc-name"), {
|
|
117
117
|
overflow: 'hidden',
|
|
118
118
|
textOverflow: 'ellipsis',
|
|
119
119
|
WebkitBoxOrient: 'vertical',
|
|
@@ -121,12 +121,10 @@ var genStyle = function genStyle(token) {
|
|
|
121
121
|
display: '-webkit-box'
|
|
122
122
|
}), _obj;
|
|
123
123
|
};
|
|
124
|
-
export function useMessagesContentStyle() {
|
|
124
|
+
export function useMessagesContentStyle(componentCls) {
|
|
125
125
|
return useEditorStyleRegister('BubbleMessageDisplay', function(token) {
|
|
126
126
|
var chatToken = _object_spread_props(_object_spread({}, token), {
|
|
127
|
-
componentCls:
|
|
128
|
-
chatCls: '',
|
|
129
|
-
antCls: ''
|
|
127
|
+
componentCls: componentCls || ''
|
|
130
128
|
});
|
|
131
129
|
return genStyle(chatToken);
|
|
132
130
|
});
|
|
@@ -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
|
-
|
|
304
|
-
var
|
|
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.
|
|
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 === '
|
|
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(
|
|
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
|
|
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:
|
|
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
|
|
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, {
|