@ant-design/agentic-ui 2.29.30 → 2.29.32
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/AIBubble.d.ts +2 -0
- package/dist/Bubble/AIBubble.js +11 -11
- package/dist/Bubble/Avatar/index.js +3 -3
- package/dist/Bubble/List/PureBubbleList.js +3 -3
- package/dist/Bubble/List/index.js +3 -3
- package/dist/Bubble/PureBubble.js +9 -9
- package/dist/Bubble/Title.js +3 -3
- package/dist/Bubble/UserBubble.js +9 -9
- package/dist/Components/ActionIconBox/index.js +3 -3
- package/dist/Components/TextAnimate/index.js +1 -0
- package/dist/Components/lotties/TextLoading/index.js +2 -2
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.d.ts +5 -0
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.js +2 -1
- package/dist/MarkdownEditor/editor/plugins/elements.js +34 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/arrow.js +3 -3
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +2 -3
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.d.ts +2 -2
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +14 -11
- package/dist/MarkdownEditor/editor/plugins/useHighlight.js +2 -1
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +12 -5
- package/dist/MarkdownEditor/editor/plugins/withListsPlugin.js +7 -9
- package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +5 -4
- package/dist/MarkdownEditor/editor/tools/ToolBar/BaseBar.js +5 -5
- package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +3 -1
- package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +4 -4
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ClearFormatButton.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ColorPickerButton.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormatButton.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/FormattingTools.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/HeadingDropdown.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/LinkButton.js +2 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/UndoRedoButtons.js +3 -3
- package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.js +1 -1
- package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.js +1 -1
- package/dist/MarkdownEditor/editor/utils/editorUtils.js +8 -6
- package/dist/MarkdownEditor/editor/utils/isMarkdown.js +4 -4
- package/dist/MarkdownEditor/editor/utils/keyboard.js +3 -2
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +11 -42
- package/dist/MarkdownInputField/QuickActions/index.js +2 -2
- package/dist/MarkdownInputField/RefinePromptButton/env.d.ts +4 -0
- package/dist/MarkdownInputField/RefinePromptButton/env.js +5 -0
- package/dist/MarkdownInputField/RefinePromptButton/index.js +2 -1
- package/dist/Plugins/chart/BarChart/index.js +6 -6
- package/dist/Plugins/chart/ChartMark/Area.js +2 -1
- package/dist/Plugins/chart/ChartMark/Bar.js +2 -1
- package/dist/Plugins/chart/ChartMark/Column.js +2 -1
- package/dist/Plugins/chart/ChartMark/Line.js +2 -1
- package/dist/Plugins/chart/ChartMark/Pie.js +2 -1
- package/dist/Plugins/chart/ChartRender.js +9 -1
- package/dist/Plugins/chart/DonutChart/index.js +2 -1
- package/dist/Plugins/chart/env.d.ts +4 -0
- package/dist/Plugins/chart/env.js +5 -0
- package/dist/Plugins/code/components/AceEditor.js +2 -0
- package/dist/Plugins/code/index.d.ts +1 -0
- package/dist/Plugins/code/index.js +1 -1
- package/dist/Plugins/mermaid/Mermaid.js +2 -2
- package/dist/Plugins/mermaid/env.d.ts +4 -0
- package/dist/Plugins/mermaid/env.js +5 -0
- package/dist/ToolUseBar/BarItem/Content.js +13 -13
- package/dist/ToolUseBar/BarItem/index.js +7 -7
- package/dist/WelcomeMessage/index.js +4 -4
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@ import { MutableRefObject } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { BubbleProps } from './type';
|
|
4
4
|
export declare const runRender: (render: any, props: BubbleProps, defaultDom: React.ReactNode, ...rest: undefined[]) => any;
|
|
5
|
+
/** @internal 供单测覆盖 placement !== 'left' 等分支 */
|
|
6
|
+
export declare const shouldRenderBeforeContent: (placement: string, role: string | undefined, thoughtChainConfig: any, taskListLength: number) => boolean;
|
|
5
7
|
/**
|
|
6
8
|
* AIBubble 组件
|
|
7
9
|
*
|
package/dist/Bubble/AIBubble.js
CHANGED
|
@@ -214,7 +214,7 @@ function _ts_generator(thisArg, body) {
|
|
|
214
214
|
}
|
|
215
215
|
import { memo, useContext } from "react";
|
|
216
216
|
import { ConfigProvider, Flex } from "antd";
|
|
217
|
-
import
|
|
217
|
+
import clsx from "clsx";
|
|
218
218
|
import React from "react";
|
|
219
219
|
import { BubbleAvatar } from "./Avatar";
|
|
220
220
|
import { BubbleBeforeNode } from "./BubbleBeforeNode";
|
|
@@ -247,7 +247,7 @@ var getTaskList = function getTaskList(originData) {
|
|
|
247
247
|
return item === null || item === void 0 ? void 0 : item.info;
|
|
248
248
|
});
|
|
249
249
|
};
|
|
250
|
-
var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, role, thoughtChainConfig, taskListLength) {
|
|
250
|
+
/** @internal 供单测覆盖 placement !== 'left' 等分支 */ export var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, role, thoughtChainConfig, taskListLength) {
|
|
251
251
|
if (placement !== 'left') return false;
|
|
252
252
|
if (role === 'bot') return false;
|
|
253
253
|
if ((thoughtChainConfig === null || thoughtChainConfig === void 0 ? void 0 : thoughtChainConfig.enable) === false) return false;
|
|
@@ -286,7 +286,7 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
286
286
|
bubbleNameClassName: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleNameClassName,
|
|
287
287
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemTitleClassName,
|
|
288
288
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemTitleStyle,
|
|
289
|
-
prefixClass:
|
|
289
|
+
prefixClass: clsx("".concat(prefixClass, "-bubble-title")),
|
|
290
290
|
title: (avatar === null || avatar === void 0 ? void 0 : avatar.title) || (avatar === null || avatar === void 0 ? void 0 : avatar.name),
|
|
291
291
|
placement: placement,
|
|
292
292
|
time: time
|
|
@@ -336,7 +336,7 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
336
336
|
maxWidth: '100%',
|
|
337
337
|
width: '100%'
|
|
338
338
|
}, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle),
|
|
339
|
-
className:
|
|
339
|
+
className: clsx("".concat(prefixClass, "-bubble-after"), "".concat(prefixClass, "-bubble-after-").concat(placement), "".concat(prefixClass, "-bubble-after-ai"), hashId),
|
|
340
340
|
"data-testid": "message-after"
|
|
341
341
|
}, /*#__PURE__*/ React.createElement(BubbleFileView, {
|
|
342
342
|
placement: placement,
|
|
@@ -359,7 +359,7 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
359
359
|
bubble: props
|
|
360
360
|
}
|
|
361
361
|
}, /*#__PURE__*/ React.createElement(Flex, {
|
|
362
|
-
className:
|
|
362
|
+
className: clsx(hashId, className, "".concat(prefixClass, "-bubble"), "".concat(prefixClass, "-bubble-").concat(placement), "".concat(prefixClass, "-bubble-ai"), _define_property({}, "".concat(prefixClass, "-bubble-compact"), compact), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleClassName),
|
|
363
363
|
style: style,
|
|
364
364
|
vertical: true,
|
|
365
365
|
id: props.id,
|
|
@@ -367,9 +367,9 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
367
367
|
gap: 12
|
|
368
368
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
369
369
|
style: style,
|
|
370
|
-
className:
|
|
370
|
+
className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), hashId)
|
|
371
371
|
}, preMessageSameRole ? null : /*#__PURE__*/ React.createElement("div", {
|
|
372
|
-
className:
|
|
372
|
+
className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-ai"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId, _define_property({}, "".concat(prefixClass, "-bubble-avatar-title-pure"), props.pure))
|
|
373
373
|
}, avatarDom, titleDom), /*#__PURE__*/ React.createElement("div", {
|
|
374
374
|
style: {
|
|
375
375
|
display: 'flex',
|
|
@@ -377,17 +377,17 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
377
377
|
flexDirection: 'column',
|
|
378
378
|
alignItems: 'flex-start'
|
|
379
379
|
},
|
|
380
|
-
className:
|
|
380
|
+
className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), "".concat(prefixClass, "-bubble-container-ai"), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleContainerClassName, hashId),
|
|
381
381
|
"data-testid": "chat-message"
|
|
382
382
|
}, contentBeforeDom ? /*#__PURE__*/ React.createElement("div", {
|
|
383
383
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle,
|
|
384
|
-
className:
|
|
384
|
+
className: clsx("".concat(prefixClass, "-bubble-before"), "".concat(prefixClass, "-bubble-before-").concat(placement), "".concat(prefixClass, "-bubble-before-ai"), hashId),
|
|
385
385
|
"data-testid": "message-before"
|
|
386
386
|
}, contentBeforeDom) : null, /*#__PURE__*/ React.createElement("div", {
|
|
387
387
|
style: _object_spread({
|
|
388
388
|
minWidth: standalone ? 'min(16px,100%)' : '0px'
|
|
389
389
|
}, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemContentStyle),
|
|
390
|
-
className:
|
|
390
|
+
className: clsx("".concat(prefixClass, "-bubble-content"), "".concat(prefixClass, "-bubble-content-").concat(placement), "".concat(prefixClass, "-bubble-content-ai"), _define_property({}, "".concat(prefixClass, "-bubble-content-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemContentClassName, hashId),
|
|
391
391
|
onDoubleClick: props.onDoubleClick,
|
|
392
392
|
"data-testid": "message-content"
|
|
393
393
|
}, childrenDom), contentAfterDom)))));
|
|
@@ -409,7 +409,7 @@ var shouldRenderBeforeContent = function shouldRenderBeforeContent(placement, ro
|
|
|
409
409
|
}),
|
|
410
410
|
title: titleDom,
|
|
411
411
|
header: /*#__PURE__*/ React.createElement("div", {
|
|
412
|
-
className:
|
|
412
|
+
className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-ai"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId)
|
|
413
413
|
}, avatarDom, titleDom),
|
|
414
414
|
extra: (props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig1 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig1 === void 0 ? void 0 : _props_bubbleRenderConfig1.extraRender) === false ? null : /*#__PURE__*/ React.createElement(BubbleExtra, {
|
|
415
415
|
pure: true,
|
|
@@ -87,7 +87,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
87
87
|
return target;
|
|
88
88
|
}
|
|
89
89
|
import { Avatar, theme } from "antd";
|
|
90
|
-
import
|
|
90
|
+
import classNames from "clsx";
|
|
91
91
|
import React from "react";
|
|
92
92
|
import { isEmoji } from "./isEmoji";
|
|
93
93
|
/**
|
|
@@ -128,12 +128,12 @@ import { isEmoji } from "./isEmoji";
|
|
|
128
128
|
var isBase64 = Boolean(avatar === null || avatar === void 0 ? void 0 : avatar.startsWith('data'));
|
|
129
129
|
if (typeof avatar === 'string' && isEmoji(String(avatar))) {
|
|
130
130
|
return /*#__PURE__*/ React.createElement("div", {
|
|
131
|
-
className:
|
|
131
|
+
className: classNames("".concat(prefixCls, "-emoji"), hashId)
|
|
132
132
|
}, avatar);
|
|
133
133
|
}
|
|
134
134
|
var text = String(isImage ? title : avatar);
|
|
135
135
|
var avatarProps = {
|
|
136
|
-
className:
|
|
136
|
+
className: classNames(className, "".concat(prefixCls), hashId),
|
|
137
137
|
shape: shape,
|
|
138
138
|
size: size,
|
|
139
139
|
style: onClick ? style : _object_spread({
|
|
@@ -53,7 +53,7 @@ function _object_spread_props(target, source) {
|
|
|
53
53
|
import SkeletonList from "./SkeletonList";
|
|
54
54
|
import { useContext, useMemo, useRef } from "react";
|
|
55
55
|
import { ConfigProvider } from "antd";
|
|
56
|
-
import
|
|
56
|
+
import clsx from "clsx";
|
|
57
57
|
import { nanoid } from "nanoid";
|
|
58
58
|
import React from "react";
|
|
59
59
|
import { LazyElement } from "../../MarkdownEditor/editor/components/LazyElement";
|
|
@@ -167,7 +167,7 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
167
167
|
]);
|
|
168
168
|
if (isLoading) {
|
|
169
169
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
170
|
-
className:
|
|
170
|
+
className: clsx(prefixClass, "".concat(prefixClass, "-loading"), className, hashId),
|
|
171
171
|
ref: bubbleListRef,
|
|
172
172
|
style: {
|
|
173
173
|
padding: 24
|
|
@@ -176,7 +176,7 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
176
176
|
}
|
|
177
177
|
var _obj;
|
|
178
178
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
179
|
-
className:
|
|
179
|
+
className: clsx("".concat(prefixClass), className, hashId, (_obj = {}, _define_property(_obj, "".concat(prefixClass, "-readonly"), props.readonly), _define_property(_obj, "".concat(prefixClass, "-compact"), compact), _obj)),
|
|
180
180
|
"data-chat-list": bubbleList.length,
|
|
181
181
|
style: style,
|
|
182
182
|
ref: bubbleListRef,
|
|
@@ -54,7 +54,7 @@ import SkeletonList from "./SkeletonList";
|
|
|
54
54
|
export { PureBubbleList } from "./PureBubbleList";
|
|
55
55
|
import { useContext, useMemo, useRef } from "react";
|
|
56
56
|
import { ConfigProvider } from "antd";
|
|
57
|
-
import
|
|
57
|
+
import clsx from "clsx";
|
|
58
58
|
import { nanoid } from "nanoid";
|
|
59
59
|
import React from "react";
|
|
60
60
|
import { LazyElement } from "../../MarkdownEditor/editor/components/LazyElement";
|
|
@@ -231,7 +231,7 @@ import { useStyle } from "./style";
|
|
|
231
231
|
props.lazy
|
|
232
232
|
]);
|
|
233
233
|
if (loading) return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
234
|
-
className:
|
|
234
|
+
className: clsx(prefixClass, "".concat(prefixClass, "-loading"), className, hashId),
|
|
235
235
|
ref: bubbleListRef,
|
|
236
236
|
style: {
|
|
237
237
|
padding: 24
|
|
@@ -239,7 +239,7 @@ import { useStyle } from "./style";
|
|
|
239
239
|
}, /*#__PURE__*/ React.createElement(SkeletonList, null)));
|
|
240
240
|
var _obj;
|
|
241
241
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
242
|
-
className:
|
|
242
|
+
className: clsx("".concat(prefixClass), className, hashId, (_obj = {}, _define_property(_obj, "".concat(prefixClass, "-readonly"), props.readonly), _define_property(_obj, "".concat(prefixClass, "-compact"), compact), _obj)),
|
|
243
243
|
"data-chat-list": bubbleList.length,
|
|
244
244
|
style: style,
|
|
245
245
|
ref: bubbleListRef,
|
|
@@ -262,7 +262,7 @@ function _ts_generator(thisArg, body) {
|
|
|
262
262
|
}
|
|
263
263
|
import { memo, useContext } from "react";
|
|
264
264
|
import { ConfigProvider, Flex } from "antd";
|
|
265
|
-
import
|
|
265
|
+
import clsx from "clsx";
|
|
266
266
|
import React from "react";
|
|
267
267
|
import { BaseMarkdownEditor } from "../MarkdownEditor/BaseMarkdownEditor";
|
|
268
268
|
import { runRender } from "./AIBubble";
|
|
@@ -297,7 +297,7 @@ export var PureBubble = /*#__PURE__*/ memo(function(props) {
|
|
|
297
297
|
bubbleNameClassName: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleNameClassName,
|
|
298
298
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemTitleClassName,
|
|
299
299
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemTitleStyle,
|
|
300
|
-
prefixClass:
|
|
300
|
+
prefixClass: clsx("".concat(prefixClass, "-bubble-title")),
|
|
301
301
|
title: (avatar === null || avatar === void 0 ? void 0 : avatar.title) || (avatar === null || avatar === void 0 ? void 0 : avatar.name),
|
|
302
302
|
placement: placement,
|
|
303
303
|
time: time
|
|
@@ -455,7 +455,7 @@ export var PureBubble = /*#__PURE__*/ memo(function(props) {
|
|
|
455
455
|
bubble: props
|
|
456
456
|
}
|
|
457
457
|
}, /*#__PURE__*/ React.createElement(Flex, {
|
|
458
|
-
className:
|
|
458
|
+
className: clsx(hashId, className, "".concat(prefixClass, "-bubble"), "".concat(prefixClass, "-bubble-").concat(placement), "".concat(prefixClass, "-bubble-pure"), _define_property({}, "".concat(prefixClass, "-bubble-compact"), compact), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleClassName),
|
|
459
459
|
style: style,
|
|
460
460
|
vertical: true,
|
|
461
461
|
id: props.id,
|
|
@@ -463,9 +463,9 @@ export var PureBubble = /*#__PURE__*/ memo(function(props) {
|
|
|
463
463
|
gap: 12
|
|
464
464
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
465
465
|
style: style,
|
|
466
|
-
className:
|
|
466
|
+
className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), hashId)
|
|
467
467
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
468
|
-
className:
|
|
468
|
+
className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-pure"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId, _define_property({}, "".concat(prefixClass, "-bubble-avatar-title-compact"), compact))
|
|
469
469
|
}, isRightPlacement ? titleDom : avatarDom, isRightPlacement ? avatarDom : titleDom), /*#__PURE__*/ React.createElement("div", {
|
|
470
470
|
style: _object_spread({
|
|
471
471
|
display: 'flex',
|
|
@@ -473,14 +473,14 @@ export var PureBubble = /*#__PURE__*/ memo(function(props) {
|
|
|
473
473
|
flexDirection: 'column',
|
|
474
474
|
alignItems: isRightPlacement ? 'flex-end' : 'flex-start'
|
|
475
475
|
}, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemContentStyle),
|
|
476
|
-
className:
|
|
476
|
+
className: clsx("".concat(prefixClass, "-bubble-content-wrapper"), hashId, classNames === null || classNames === void 0 ? void 0 : classNames.bubbleContainerClassName),
|
|
477
477
|
"data-testid": "chat-message"
|
|
478
478
|
}, contentBeforeDom ? /*#__PURE__*/ React.createElement("div", {
|
|
479
479
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle,
|
|
480
|
-
className:
|
|
480
|
+
className: clsx("".concat(prefixClass, "-bubble-before"), "".concat(prefixClass, "-bubble-before-").concat(placement), hashId),
|
|
481
481
|
"data-testid": "message-before"
|
|
482
482
|
}, contentBeforeDom) : null, /*#__PURE__*/ React.createElement("div", {
|
|
483
|
-
className:
|
|
483
|
+
className: clsx("".concat(prefixClass, "-bubble-content"), "".concat(prefixClass, "-bubble-content-").concat(placement), "".concat(prefixClass, "-bubble-content-pure"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemContentClassName, hashId),
|
|
484
484
|
onDoubleClick: props.onDoubleClick,
|
|
485
485
|
"data-testid": "message-content"
|
|
486
486
|
}, messageContent), contentAfterDom)))));
|
|
@@ -499,7 +499,7 @@ export var PureBubble = /*#__PURE__*/ memo(function(props) {
|
|
|
499
499
|
avatar: avatarDom,
|
|
500
500
|
title: titleDom,
|
|
501
501
|
header: /*#__PURE__*/ React.createElement("div", {
|
|
502
|
-
className:
|
|
502
|
+
className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-pure"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId)
|
|
503
503
|
}, isRightPlacement ? titleDom : avatarDom, isRightPlacement ? avatarDom : titleDom),
|
|
504
504
|
extra: extraDom,
|
|
505
505
|
messageContent: messageContent,
|
package/dist/Bubble/Title.js
CHANGED
|
@@ -51,7 +51,7 @@ function _object_spread_props(target, source) {
|
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
53
|
import { Flex } from "antd";
|
|
54
|
-
import
|
|
54
|
+
import classNames from "clsx";
|
|
55
55
|
import React from "react";
|
|
56
56
|
import { resetComponent, useEditorStyleRegister } from "../Hooks/useStyle";
|
|
57
57
|
import { formatTime } from "../Utils/formatTime";
|
|
@@ -112,14 +112,14 @@ var useStyle = function useStyle(prefixCls) {
|
|
|
112
112
|
alignItems: 'center'
|
|
113
113
|
}, style);
|
|
114
114
|
return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Flex, {
|
|
115
|
-
className:
|
|
115
|
+
className: classNames(hashId, prefixClass, className),
|
|
116
116
|
style: flexStyle,
|
|
117
117
|
gap: TITLE_GAP,
|
|
118
118
|
"data-testid": "bubble-title"
|
|
119
119
|
}, title && /*#__PURE__*/ React.createElement("span", {
|
|
120
120
|
className: bubbleNameClassName
|
|
121
121
|
}, title), time && /*#__PURE__*/ React.createElement("time", {
|
|
122
|
-
className:
|
|
122
|
+
className: classNames("".concat(prefixClass, "-time"), hashId),
|
|
123
123
|
"data-testid": "bubble-time"
|
|
124
124
|
}, formatTime(time))), quote));
|
|
125
125
|
};
|
|
@@ -74,7 +74,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
74
74
|
}
|
|
75
75
|
import { memo, useContext } from "react";
|
|
76
76
|
import { ConfigProvider, Flex } from "antd";
|
|
77
|
-
import
|
|
77
|
+
import clsx from "clsx";
|
|
78
78
|
import React from "react";
|
|
79
79
|
import { Quote } from "../Quote";
|
|
80
80
|
import { BubbleConfigContext } from "./BubbleConfigProvide";
|
|
@@ -140,7 +140,7 @@ var getContentStyle = function getContentStyle(standalone, customStyle) {
|
|
|
140
140
|
bubbleNameClassName: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleNameClassName,
|
|
141
141
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemTitleClassName,
|
|
142
142
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemTitleStyle,
|
|
143
|
-
prefixClass:
|
|
143
|
+
prefixClass: clsx("".concat(prefixClass, "-bubble-title")),
|
|
144
144
|
title: '',
|
|
145
145
|
placement: placement,
|
|
146
146
|
time: time
|
|
@@ -183,7 +183,7 @@ var getContentStyle = function getContentStyle(standalone, customStyle) {
|
|
|
183
183
|
bubble: props
|
|
184
184
|
}
|
|
185
185
|
}, /*#__PURE__*/ React.createElement(Flex, {
|
|
186
|
-
className:
|
|
186
|
+
className: clsx(hashId, className, "".concat(prefixClass, "-bubble"), "".concat(prefixClass, "-bubble-").concat(placement), "".concat(prefixClass, "-bubble-user"), _define_property({}, "".concat(prefixClass, "-bubble-compact"), compact), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleClassName),
|
|
187
187
|
style: style,
|
|
188
188
|
vertical: true,
|
|
189
189
|
id: props.id,
|
|
@@ -191,25 +191,25 @@ var getContentStyle = function getContentStyle(standalone, customStyle) {
|
|
|
191
191
|
gap: BUBBLE_GAP
|
|
192
192
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
193
193
|
style: style,
|
|
194
|
-
className:
|
|
194
|
+
className: clsx("".concat(prefixClass, "-bubble-container"), hashId)
|
|
195
195
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
196
196
|
style: contentContainerStyle,
|
|
197
|
-
className:
|
|
197
|
+
className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), "".concat(prefixClass, "-bubble-container-user"), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleContainerClassName, hashId),
|
|
198
198
|
"data-testid": "chat-message"
|
|
199
199
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
200
|
-
className:
|
|
200
|
+
className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-ai"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId, (_obj = {}, _define_property(_obj, "".concat(prefixClass, "-bubble-avatar-title-pure"), props.pure), _define_property(_obj, "".concat(prefixClass, "-bubble-avatar-title-quote"), quote === null || quote === void 0 ? void 0 : quote.quoteDescription), _obj))
|
|
201
201
|
}, titleDom), contentBeforeDom && /*#__PURE__*/ React.createElement("div", {
|
|
202
202
|
style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle,
|
|
203
|
-
className:
|
|
203
|
+
className: clsx("".concat(prefixClass, "-bubble-before"), "".concat(prefixClass, "-bubble-before-").concat(placement), "".concat(prefixClass, "-bubble-before-user"), hashId),
|
|
204
204
|
"data-testid": "message-before"
|
|
205
205
|
}, contentBeforeDom), /*#__PURE__*/ React.createElement("div", {
|
|
206
206
|
style: contentStyle,
|
|
207
|
-
className:
|
|
207
|
+
className: clsx("".concat(prefixClass, "-bubble-content"), "".concat(prefixClass, "-bubble-content-").concat(placement), "".concat(prefixClass, "-bubble-content-user"), _define_property({}, "".concat(prefixClass, "-bubble-content-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemContentClassName, hashId),
|
|
208
208
|
onDoubleClick: props.onDoubleClick,
|
|
209
209
|
"data-testid": "message-content"
|
|
210
210
|
}, childrenDom), hasFileMap && /*#__PURE__*/ React.createElement("div", {
|
|
211
211
|
style: fileViewStyle,
|
|
212
|
-
className:
|
|
212
|
+
className: clsx("".concat(prefixClass, "-bubble-after"), "".concat(prefixClass, "-bubble-after-").concat(placement), "".concat(prefixClass, "-bubble-after-ai"), hashId),
|
|
213
213
|
"data-testid": "message-after"
|
|
214
214
|
}, /*#__PURE__*/ React.createElement(BubbleFileView, {
|
|
215
215
|
bubbleListRef: props.bubbleListRef,
|
|
@@ -226,7 +226,7 @@ function _ts_generator(thisArg, body) {
|
|
|
226
226
|
}
|
|
227
227
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
228
228
|
import { ConfigProvider, Tooltip } from "antd";
|
|
229
|
-
import
|
|
229
|
+
import classNames from "clsx";
|
|
230
230
|
import { isFunction } from "lodash-es";
|
|
231
231
|
import { useMergedState } from "rc-util";
|
|
232
232
|
import React, { useContext, useEffect, useMemo, useState } from "react";
|
|
@@ -349,7 +349,7 @@ import { useStyle } from "./style";
|
|
|
349
349
|
role: "button",
|
|
350
350
|
tabIndex: 0,
|
|
351
351
|
"aria-label": (_props_title1 = props.title) === null || _props_title1 === void 0 ? void 0 : _props_title1.toString(),
|
|
352
|
-
className:
|
|
352
|
+
className: classNames(prefixCls, hashId, props.className, (_obj = {}, _define_property(_obj, "".concat(prefixCls, "-danger"), props.type === 'danger'), _define_property(_obj, "".concat(prefixCls, "-primary"), props.type === 'primary'), _define_property(_obj, "".concat(prefixCls, "-border-less"), props.borderLess), _define_property(_obj, "".concat(prefixCls, "-active"), props.active), _define_property(_obj, "".concat(prefixCls, "-transform"), props.transform), _define_property(_obj, "".concat(prefixCls, "-").concat(props.theme || 'light'), props.theme || 'light'), _define_property(_obj, "".concat(prefixCls, "-noPadding"), props.noPadding), _obj)),
|
|
353
353
|
onClick: function onClick(e) {
|
|
354
354
|
return _async_to_generator(function() {
|
|
355
355
|
var _props_onClick, error;
|
|
@@ -473,7 +473,7 @@ import { useStyle } from "./style";
|
|
|
473
473
|
tabIndex: 0,
|
|
474
474
|
"aria-label": (_props_title2 = props.title) === null || _props_title2 === void 0 ? void 0 : _props_title2.toString(),
|
|
475
475
|
title: (_props_title3 = props.title) === null || _props_title3 === void 0 ? void 0 : _props_title3.toString(),
|
|
476
|
-
className:
|
|
476
|
+
className: classNames(prefixCls, hashId, props.className, (_obj1 = {}, _define_property(_obj1, "".concat(prefixCls, "-danger"), props.type === 'danger'), _define_property(_obj1, "".concat(prefixCls, "-primary"), props.type === 'primary'), _define_property(_obj1, "".concat(prefixCls, "-border-less"), props.borderLess), _define_property(_obj1, "".concat(prefixCls, "-active"), props.active), _define_property(_obj1, "".concat(prefixCls, "-transform"), props.transform), _define_property(_obj1, "".concat(prefixCls, "-").concat(props.theme || 'light'), props.theme || 'light'), _define_property(_obj1, "".concat(prefixCls, "-noPadding"), props.noPadding), _obj1)),
|
|
477
477
|
onClick: function onClick(e) {
|
|
478
478
|
return _async_to_generator(function() {
|
|
479
479
|
var _props_onClick, error;
|
|
@@ -424,6 +424,7 @@ export var resolveSegments = function resolveSegments(children, by) {
|
|
|
424
424
|
toArray(children).forEach(function(item) {
|
|
425
425
|
if (isString(item) || isNumber(item)) {
|
|
426
426
|
var itemString = item.toString();
|
|
427
|
+
if (itemString === '') return;
|
|
427
428
|
switch(by){
|
|
428
429
|
case 'word':
|
|
429
430
|
var _result;
|
|
@@ -27,7 +27,7 @@ function _object_spread(target) {
|
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
29
|
import { ConfigProvider } from "antd";
|
|
30
|
-
import
|
|
30
|
+
import classNames from "clsx";
|
|
31
31
|
import React, { useContext } from "react";
|
|
32
32
|
import { useStyle } from "./style";
|
|
33
33
|
/**
|
|
@@ -73,7 +73,7 @@ import { useStyle } from "./style";
|
|
|
73
73
|
}, style);
|
|
74
74
|
var _obj;
|
|
75
75
|
return wrapSSR(/*#__PURE__*/ React.createElement("span", {
|
|
76
|
-
className:
|
|
76
|
+
className: classNames(prefixCls, hashId, className, (_obj = {}, _define_property(_obj, "".concat(prefixCls, "-disabled"), disabled), _define_property(_obj, "".concat(prefixCls, "-dark"), theme === 'dark'), _define_property(_obj, "".concat(prefixCls, "-light"), theme === 'light'), _obj)),
|
|
77
77
|
style: containerStyle,
|
|
78
78
|
"data-testid": "text-loading",
|
|
79
79
|
"aria-label": text,
|
|
@@ -6,5 +6,10 @@ interface CommentLeafProps {
|
|
|
6
6
|
leaf: RenderLeafProps['leaf'];
|
|
7
7
|
comment: MarkdownEditorProps['comment'];
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 比较函数,用于优化 CommentLeaf 组件的渲染性能
|
|
11
|
+
* @internal 供 React.memo 及单测使用
|
|
12
|
+
*/
|
|
13
|
+
export declare const areCommentLeafPropsEqual: (prevProps: CommentLeafProps, nextProps: CommentLeafProps) => boolean;
|
|
9
14
|
export declare const CommentLeaf: React.MemoExoticComponent<({ children, leaf, comment, }: CommentLeafProps) => React.JSX.Element>;
|
|
10
15
|
export {};
|
|
@@ -4,7 +4,8 @@ import { useEditorStore } from "../../store";
|
|
|
4
4
|
import { CommentView } from "../Comment";
|
|
5
5
|
/**
|
|
6
6
|
* 比较函数,用于优化 CommentLeaf 组件的渲染性能
|
|
7
|
-
|
|
7
|
+
* @internal 供 React.memo 及单测使用
|
|
8
|
+
*/ export var areCommentLeafPropsEqual = function areCommentLeafPropsEqual(prevProps, nextProps) {
|
|
8
9
|
// 首先进行快速引用比较
|
|
9
10
|
if (prevProps.leaf === nextProps.leaf && prevProps.children === nextProps.children && prevProps.comment === nextProps.comment) {
|
|
10
11
|
return true;
|
|
@@ -3,6 +3,9 @@ function _array_like_to_array(arr, len) {
|
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
6
9
|
function _array_without_holes(arr) {
|
|
7
10
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
11
|
}
|
|
@@ -22,6 +25,33 @@ function _define_property(obj, key, value) {
|
|
|
22
25
|
function _iterable_to_array(iter) {
|
|
23
26
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
27
|
}
|
|
28
|
+
function _iterable_to_array_limit(arr, i) {
|
|
29
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
|
+
if (_i == null) return;
|
|
31
|
+
var _arr = [];
|
|
32
|
+
var _n = true;
|
|
33
|
+
var _d = false;
|
|
34
|
+
var _s, _e;
|
|
35
|
+
try {
|
|
36
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
37
|
+
_arr.push(_s.value);
|
|
38
|
+
if (i && _arr.length === i) break;
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
_d = true;
|
|
42
|
+
_e = err;
|
|
43
|
+
} finally{
|
|
44
|
+
try {
|
|
45
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
46
|
+
} finally{
|
|
47
|
+
if (_d) throw _e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return _arr;
|
|
51
|
+
}
|
|
52
|
+
function _non_iterable_rest() {
|
|
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.");
|
|
54
|
+
}
|
|
25
55
|
function _non_iterable_spread() {
|
|
26
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.");
|
|
27
57
|
}
|
|
@@ -64,6 +94,9 @@ function _object_spread_props(target, source) {
|
|
|
64
94
|
}
|
|
65
95
|
return target;
|
|
66
96
|
}
|
|
97
|
+
function _sliced_to_array(arr, i) {
|
|
98
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
|
+
}
|
|
67
100
|
function _to_consumable_array(arr) {
|
|
68
101
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
69
102
|
}
|
|
@@ -96,7 +129,7 @@ export var insertAfter = function insertAfter(editor, path) {
|
|
|
96
129
|
var matchText = function matchText(insert, matchString) {
|
|
97
130
|
return function(ctx) {
|
|
98
131
|
var sel = ctx.sel, editor = ctx.editor, match = ctx.match, startText = ctx.startText;
|
|
99
|
-
var
|
|
132
|
+
var _Editor_leaf = _sliced_to_array(Editor.leaf(editor, sel.anchor), 1), leaf = _Editor_leaf[0];
|
|
100
133
|
if (EditorUtils.isDirtLeaf(leaf)) return false;
|
|
101
134
|
if (matchString) {
|
|
102
135
|
var preStr = Node.string(leaf) + matchString;
|
|
@@ -84,7 +84,7 @@ import { EditorUtils } from "../../utils/editorUtils";
|
|
|
84
84
|
if (isHotkey('left', e)) {
|
|
85
85
|
e.preventDefault();
|
|
86
86
|
e.stopPropagation();
|
|
87
|
-
var
|
|
87
|
+
var _Editor_leaf = _sliced_to_array(Editor.leaf(editor, sel.focus), 1), leaf = _Editor_leaf[0];
|
|
88
88
|
var dirt = EditorUtils.isDirtLeaf(leaf);
|
|
89
89
|
var pre = Editor.previous(editor, {
|
|
90
90
|
at: sel.focus.path
|
|
@@ -112,7 +112,7 @@ import { EditorUtils } from "../../utils/editorUtils";
|
|
|
112
112
|
e.stopPropagation();
|
|
113
113
|
if (!isMod(e)) {
|
|
114
114
|
var _leaf_text, _leaf_text1;
|
|
115
|
-
var
|
|
115
|
+
var _Editor_leaf1 = _sliced_to_array(Editor.leaf(editor, sel.focus), 1), leaf1 = _Editor_leaf1[0];
|
|
116
116
|
var dirt1 = EditorUtils.isDirtLeaf(leaf1);
|
|
117
117
|
var next = Editor.next(editor, {
|
|
118
118
|
at: sel.focus.path
|
|
@@ -137,7 +137,7 @@ import { EditorUtils } from "../../utils/editorUtils";
|
|
|
137
137
|
EditorUtils.moveAfterSpace(editor, sel.focus.path);
|
|
138
138
|
} else {
|
|
139
139
|
var _leaf_text2;
|
|
140
|
-
var
|
|
140
|
+
var _Editor_leaf2 = _sliced_to_array(Editor.leaf(editor, sel.focus), 1), leaf2 = _Editor_leaf2[0];
|
|
141
141
|
if (sel.focus.offset === ((_leaf_text2 = leaf2.text) === null || _leaf_text2 === void 0 ? void 0 : _leaf_text2.length) && Editor.hasPath(editor, Path.next(sel.focus.path)) && Editor.isVoid(editor, Node.get(editor, Path.next(sel.focus.path)))) {
|
|
142
142
|
if (Editor.hasPath(editor, Path.next(Path.next(sel.focus.path)))) {
|
|
143
143
|
Transforms.select(editor, Editor.start(editor, Path.next(Path.next(sel.focus.path))));
|
|
@@ -118,8 +118,8 @@ export var BackspaceKey = /*#__PURE__*/ function() {
|
|
|
118
118
|
value: function clearStyle(sel) {
|
|
119
119
|
var _leaf_text;
|
|
120
120
|
var start = Range.start(sel);
|
|
121
|
-
var
|
|
122
|
-
if (((_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.length) === 1 && EditorUtils.isDirtLeaf(leaf)) {
|
|
121
|
+
var _Editor_leaf = _sliced_to_array(Editor.leaf(this.editor, start), 1), leaf = _Editor_leaf[0];
|
|
122
|
+
if ((leaf === null || leaf === void 0 ? void 0 : (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.length) === 1 && EditorUtils.isDirtLeaf(leaf)) {
|
|
123
123
|
EditorUtils.clearMarks(this.editor);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -171,7 +171,6 @@ export var BackspaceKey = /*#__PURE__*/ function() {
|
|
|
171
171
|
var listItem = parent1[0];
|
|
172
172
|
var firstChild = Element.isElement(listItem) && listItem.children.length > 0 ? listItem.children[0] : null;
|
|
173
173
|
var isEmptyListItem = firstChild && Element.isElement(firstChild) && firstChild.type === 'paragraph' && Node.string(firstChild).trim() === '' && listItem.children.length === 1; // 只有第一个段落,没有嵌套列表
|
|
174
|
-
console.log('isEmptyListItem', isEmptyListItem);
|
|
175
174
|
// 如果 list-item 为空,优先执行删除逻辑
|
|
176
175
|
if (isEmptyListItem) {
|
|
177
176
|
// 使用新的拆分逻辑处理空的list-item
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Editor } from 'slate';
|
|
3
3
|
export declare class MatchKey {
|
|
4
|
-
private readonly
|
|
5
|
-
constructor(
|
|
4
|
+
private readonly editorRef;
|
|
5
|
+
constructor(editorRef: React.MutableRefObject<Editor | null>);
|
|
6
6
|
private createParams;
|
|
7
7
|
run(e: React.KeyboardEvent): boolean;
|
|
8
8
|
}
|
|
@@ -84,20 +84,20 @@ import { Editor, Element, Node, Range } from "slate";
|
|
|
84
84
|
import { TextMatchNodes } from "../elements";
|
|
85
85
|
export var MatchKey = /*#__PURE__*/ function() {
|
|
86
86
|
"use strict";
|
|
87
|
-
function MatchKey(
|
|
87
|
+
function MatchKey(editorRef) {
|
|
88
88
|
_class_call_check(this, MatchKey);
|
|
89
|
-
_define_property(this, "
|
|
90
|
-
this.
|
|
89
|
+
_define_property(this, "editorRef", void 0);
|
|
90
|
+
this.editorRef = editorRef;
|
|
91
91
|
}
|
|
92
92
|
_create_class(MatchKey, [
|
|
93
93
|
{
|
|
94
94
|
key: "createParams",
|
|
95
|
-
value: function createParams(node, match) {
|
|
95
|
+
value: function createParams(editor, node, match) {
|
|
96
96
|
return {
|
|
97
97
|
el: node[0],
|
|
98
98
|
path: node[1],
|
|
99
|
-
editor:
|
|
100
|
-
sel:
|
|
99
|
+
editor: editor,
|
|
100
|
+
sel: editor.selection,
|
|
101
101
|
match: match,
|
|
102
102
|
startText: match[0]
|
|
103
103
|
};
|
|
@@ -107,7 +107,9 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
107
107
|
key: "run",
|
|
108
108
|
value: function run(e) {
|
|
109
109
|
var _node_;
|
|
110
|
-
var
|
|
110
|
+
var editor = this.editorRef.current;
|
|
111
|
+
if (!editor) return false;
|
|
112
|
+
var _Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
|
|
111
113
|
match: function match(n) {
|
|
112
114
|
return Element.isElement(n);
|
|
113
115
|
},
|
|
@@ -116,7 +118,7 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
116
118
|
if (!node || [
|
|
117
119
|
'code'
|
|
118
120
|
].includes(node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type)) return false;
|
|
119
|
-
var sel =
|
|
121
|
+
var sel = editor.selection;
|
|
120
122
|
if (!sel || !Range.isCollapsed(sel)) return false;
|
|
121
123
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122
124
|
try {
|
|
@@ -124,14 +126,15 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
124
126
|
var n = _step.value;
|
|
125
127
|
if (_type_of(n.matchKey) === 'object' ? n.matchKey.test(e.key) : n.matchKey === e.key) {
|
|
126
128
|
if (n.checkAllow && !n.checkAllow({
|
|
127
|
-
editor:
|
|
129
|
+
editor: editor,
|
|
128
130
|
node: node,
|
|
129
131
|
sel: sel
|
|
130
132
|
})) continue;
|
|
131
|
-
var
|
|
133
|
+
var _Editor_leaf = _sliced_to_array(Editor.leaf(editor, sel.anchor), 1), leafNode = _Editor_leaf[0];
|
|
134
|
+
var str = Node.string(leafNode).slice(0, sel.anchor.offset) + e.key;
|
|
132
135
|
var m = str.match(n.reg);
|
|
133
136
|
if (m) {
|
|
134
|
-
if (n.run(this.createParams(node, m))) {
|
|
137
|
+
if (n.run(this.createParams(editor, node, m))) {
|
|
135
138
|
e.preventDefault();
|
|
136
139
|
return true;
|
|
137
140
|
}
|