@mxmweb/rtext 1.4.4 → 1.5.3
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/adopters/ChatMessageAdapter.d.ts +16 -0
- package/assets/style.css +1 -1
- package/containers/ThoughtChainContainer.d.ts +10 -0
- package/core/UnifiedRichText.d.ts +3 -0
- package/core/converters/slateConverters.d.ts +5 -0
- package/core/editor/editorCommands.d.ts +145 -0
- package/core/editor/useEditorCommands.d.ts +34 -0
- package/core/hooks/useMobileParagraphSelection.d.ts +12 -0
- package/core/richElements/styles.d.ts +1 -0
- package/elements/ThoughtChainSection.d.ts +10 -0
- package/examples/webvieweditor/index.d.ts +7 -0
- package/index.js +9292 -8491
- package/lib_enter.d.ts +2 -0
- package/mockserverdata.d.ts +27 -57
- package/package.json +1 -1
- package/stats.html +1 -1
- package/utils/thought_chain_mapper.d.ts +3 -1
|
@@ -7,6 +7,16 @@ export interface ThoughtChainContainerProps {
|
|
|
7
7
|
mode?: ThoughtChainRenderMode;
|
|
8
8
|
/** 对话级别状态码,可选,用于整体标题展示 */
|
|
9
9
|
status?: number;
|
|
10
|
+
/**
|
|
11
|
+
* 是否仅展示「模型思考」节点且不展示时间轴
|
|
12
|
+
* 2026-01-06 新增:用于兼容 enableCot = 0 的老数据,只渲染 businessType === "think" 的内容。
|
|
13
|
+
*/
|
|
14
|
+
simpleThinkOnly?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 思维链总耗时(毫秒),从后端 SSE 流中的 chainRespTime 字段获取
|
|
17
|
+
* 2026-01-06 新增:优先使用此值计算思维链用时,如果没有则回退到累加各节点的 respTime
|
|
18
|
+
*/
|
|
19
|
+
chainRespTime?: number;
|
|
10
20
|
}
|
|
11
21
|
declare const ThoughtChainContainer: React.FC<ThoughtChainContainerProps>;
|
|
12
22
|
export default ThoughtChainContainer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { Editor } from 'slate';
|
|
2
3
|
import { RenderElementProps, RenderLeafProps } from 'slate-react';
|
|
3
4
|
export declare enum DataType {
|
|
4
5
|
SLATE = "slate",
|
|
@@ -54,6 +55,8 @@ export interface UnifiedRichTextProps {
|
|
|
54
55
|
onRetriveTagClick?: (leaf: any, attributes: any) => void;
|
|
55
56
|
/** 事件发射器 */
|
|
56
57
|
eventsEmit?: (event: string, data: any) => void;
|
|
58
|
+
/** 编辑器就绪回调,用于获取编辑器实例 */
|
|
59
|
+
onEditorReady?: (editor: Editor) => void;
|
|
57
60
|
/** 额外的 props,会传递给 renderElement */
|
|
58
61
|
extraProps?: Record<string, any>;
|
|
59
62
|
/** 自定义样式 */
|
|
@@ -51,5 +51,10 @@ export interface BlockQuoteElement extends BaseElement {
|
|
|
51
51
|
type: 'block-quote';
|
|
52
52
|
}
|
|
53
53
|
export type CustomElement = ParagraphElement | HeadingOneElement | HeadingTwoElement | HeadingThreeElement | ListElement | ListItemElement | TableElement | TableRowElement | TableCellElement | ImageElement | CodeBlockElement | BlockQuoteElement;
|
|
54
|
+
/**
|
|
55
|
+
* 将 Slate 节点序列化为 Markdown 格式
|
|
56
|
+
* @param nodes - Slate 节点数组
|
|
57
|
+
* @returns Markdown 字符串
|
|
58
|
+
*/
|
|
54
59
|
export declare const serializeToMarkdown: (nodes: CustomElement[]) => string;
|
|
55
60
|
export declare const serializeToHtml: (nodes: CustomElement[]) => string;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 编辑器命令工具函数
|
|
4
|
+
* 提供基于 Slate 的富文本编辑器操作接口
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 切换粗体格式
|
|
8
|
+
* @param editor - Slate 编辑器实例
|
|
9
|
+
*/
|
|
10
|
+
export declare const toggleBold: (editor: Editor) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 切换斜体格式
|
|
13
|
+
* @param editor - Slate 编辑器实例
|
|
14
|
+
*/
|
|
15
|
+
export declare const toggleItalic: (editor: Editor) => void;
|
|
16
|
+
/**
|
|
17
|
+
* 切换下划线格式
|
|
18
|
+
* @param editor - Slate 编辑器实例
|
|
19
|
+
*/
|
|
20
|
+
export declare const toggleUnderline: (editor: Editor) => void;
|
|
21
|
+
/**
|
|
22
|
+
* 切换删除线格式
|
|
23
|
+
* @param editor - Slate 编辑器实例
|
|
24
|
+
*/
|
|
25
|
+
export declare const toggleStrikethrough: (editor: Editor) => void;
|
|
26
|
+
/**
|
|
27
|
+
* 切换行内代码格式
|
|
28
|
+
* @param editor - Slate 编辑器实例
|
|
29
|
+
*/
|
|
30
|
+
export declare const toggleCode: (editor: Editor) => void;
|
|
31
|
+
/**
|
|
32
|
+
* 切换标题格式
|
|
33
|
+
* @param editor - Slate 编辑器实例
|
|
34
|
+
* @param level - 标题级别 (1, 2, 3)
|
|
35
|
+
*/
|
|
36
|
+
export declare const toggleHeading: (editor: Editor, level: 1 | 2 | 3) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 切换无序列表
|
|
39
|
+
* @param editor - Slate 编辑器实例
|
|
40
|
+
*/
|
|
41
|
+
export declare const toggleBulletList: (editor: Editor) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 切换有序列表
|
|
44
|
+
* @param editor - Slate 编辑器实例
|
|
45
|
+
*/
|
|
46
|
+
export declare const toggleNumberedList: (editor: Editor) => void;
|
|
47
|
+
/**
|
|
48
|
+
* 切换引用块格式
|
|
49
|
+
* @param editor - Slate 编辑器实例
|
|
50
|
+
*/
|
|
51
|
+
export declare const toggleBlockQuote: (editor: Editor) => void;
|
|
52
|
+
/**
|
|
53
|
+
* 插入链接
|
|
54
|
+
* @param editor - Slate 编辑器实例
|
|
55
|
+
* @param url - 链接地址
|
|
56
|
+
* @param text - 链接文本(可选,默认使用当前选中文本)
|
|
57
|
+
*/
|
|
58
|
+
export declare const insertLink: (editor: Editor, url: string, text?: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* 插入图片
|
|
61
|
+
* @param editor - Slate 编辑器实例
|
|
62
|
+
* @param url - 图片地址
|
|
63
|
+
* @param alt - 图片替代文本(可选)
|
|
64
|
+
*/
|
|
65
|
+
export declare const insertImage: (editor: Editor, url: string, alt?: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* 插入表格
|
|
68
|
+
* @param editor - Slate 编辑器实例
|
|
69
|
+
* @param rows - 行数
|
|
70
|
+
* @param cols - 列数
|
|
71
|
+
*/
|
|
72
|
+
export declare const insertTable: (editor: Editor, rows?: number, cols?: number) => void;
|
|
73
|
+
/**
|
|
74
|
+
* 插入代码块
|
|
75
|
+
* @param editor - Slate 编辑器实例
|
|
76
|
+
* @param language - 编程语言(可选)
|
|
77
|
+
*/
|
|
78
|
+
export declare const insertCodeBlock: (editor: Editor, language?: string) => void;
|
|
79
|
+
/**
|
|
80
|
+
* 设置文本对齐方式
|
|
81
|
+
* @param editor - Slate 编辑器实例
|
|
82
|
+
* @param align - 对齐方式
|
|
83
|
+
*/
|
|
84
|
+
export declare const setAlignment: (editor: Editor, align: "left" | "center" | "right") => void;
|
|
85
|
+
/**
|
|
86
|
+
* 检查粗体是否激活
|
|
87
|
+
* @param editor - Slate 编辑器实例
|
|
88
|
+
* @returns 是否激活
|
|
89
|
+
*/
|
|
90
|
+
export declare const isBoldActive: (editor: Editor) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 检查斜体是否激活
|
|
93
|
+
* @param editor - Slate 编辑器实例
|
|
94
|
+
* @returns 是否激活
|
|
95
|
+
*/
|
|
96
|
+
export declare const isItalicActive: (editor: Editor) => boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 检查下划线是否激活
|
|
99
|
+
* @param editor - Slate 编辑器实例
|
|
100
|
+
* @returns 是否激活
|
|
101
|
+
*/
|
|
102
|
+
export declare const isUnderlineActive: (editor: Editor) => boolean;
|
|
103
|
+
/**
|
|
104
|
+
* 检查删除线是否激活
|
|
105
|
+
* @param editor - Slate 编辑器实例
|
|
106
|
+
* @returns 是否激活
|
|
107
|
+
*/
|
|
108
|
+
export declare const isStrikethroughActive: (editor: Editor) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* 检查行内代码是否激活
|
|
111
|
+
* @param editor - Slate 编辑器实例
|
|
112
|
+
* @returns 是否激活
|
|
113
|
+
*/
|
|
114
|
+
export declare const isCodeActive: (editor: Editor) => boolean;
|
|
115
|
+
/**
|
|
116
|
+
* 检查标题是否激活
|
|
117
|
+
* @param editor - Slate 编辑器实例
|
|
118
|
+
* @param level - 标题级别(可选,不传则检查任意级别)
|
|
119
|
+
* @returns 是否激活
|
|
120
|
+
*/
|
|
121
|
+
export declare const isHeadingActive: (editor: Editor, level?: 1 | 2 | 3) => boolean;
|
|
122
|
+
/**
|
|
123
|
+
* 检查无序列表是否激活
|
|
124
|
+
* @param editor - Slate 编辑器实例
|
|
125
|
+
* @returns 是否激活
|
|
126
|
+
*/
|
|
127
|
+
export declare const isBulletListActive: (editor: Editor) => boolean;
|
|
128
|
+
/**
|
|
129
|
+
* 检查有序列表是否激活
|
|
130
|
+
* @param editor - Slate 编辑器实例
|
|
131
|
+
* @returns 是否激活
|
|
132
|
+
*/
|
|
133
|
+
export declare const isNumberedListActive: (editor: Editor) => boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 检查引用块是否激活
|
|
136
|
+
* @param editor - Slate 编辑器实例
|
|
137
|
+
* @returns 是否激活
|
|
138
|
+
*/
|
|
139
|
+
export declare const isBlockQuoteActive: (editor: Editor) => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* 获取当前对齐方式
|
|
142
|
+
* @param editor - Slate 编辑器实例
|
|
143
|
+
* @returns 对齐方式
|
|
144
|
+
*/
|
|
145
|
+
export declare const getAlignment: (editor: Editor) => "left" | "center" | "right" | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 编辑器命令 Hook
|
|
4
|
+
* 提供便捷的编辑器操作接口和状态查询
|
|
5
|
+
*
|
|
6
|
+
* @param editor - Slate 编辑器实例,如果为 null 则所有操作都不会执行
|
|
7
|
+
* @returns 编辑器操作函数和状态查询函数
|
|
8
|
+
*/
|
|
9
|
+
export declare const useEditorCommands: (editor: Editor | null) => {
|
|
10
|
+
toggleBold: () => void;
|
|
11
|
+
toggleItalic: () => void;
|
|
12
|
+
toggleUnderline: () => void;
|
|
13
|
+
toggleStrikethrough: () => void;
|
|
14
|
+
toggleCode: () => void;
|
|
15
|
+
toggleHeading: (level: 1 | 2 | 3) => void;
|
|
16
|
+
toggleBulletList: () => void;
|
|
17
|
+
toggleNumberedList: () => void;
|
|
18
|
+
toggleBlockQuote: () => void;
|
|
19
|
+
insertLink: (url: string, text?: string) => void;
|
|
20
|
+
insertImage: (url: string, alt?: string) => void;
|
|
21
|
+
insertTable: (rows?: number, cols?: number) => void;
|
|
22
|
+
insertCodeBlock: (language?: string) => void;
|
|
23
|
+
setAlignment: (align: "left" | "center" | "right") => void;
|
|
24
|
+
isBoldActive: () => boolean;
|
|
25
|
+
isItalicActive: () => boolean;
|
|
26
|
+
isUnderlineActive: () => boolean;
|
|
27
|
+
isStrikethroughActive: () => boolean;
|
|
28
|
+
isCodeActive: () => boolean;
|
|
29
|
+
isHeadingActive: (level?: 1 | 2 | 3) => boolean;
|
|
30
|
+
isBulletListActive: () => boolean;
|
|
31
|
+
isNumberedListActive: () => boolean;
|
|
32
|
+
isBlockQuoteActive: () => boolean;
|
|
33
|
+
getAlignment: () => "left" | "center" | "right" | null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
/**
|
|
3
|
+
* 移动端文本选取 Hook
|
|
4
|
+
* 实现类似 iOS 文本编辑器的行为:
|
|
5
|
+
* 1. 点击一个位置:移动光标到该位置
|
|
6
|
+
* 2. 长按文本:选择该文本(通过原生选择)
|
|
7
|
+
* 3. 长按段落结尾处:选择整个段落
|
|
8
|
+
*
|
|
9
|
+
* @param editor - Slate 编辑器实例
|
|
10
|
+
* @param enabled - 是否启用移动端文本选取
|
|
11
|
+
*/
|
|
12
|
+
export declare const useMobileParagraphSelection: (editor: Editor | null, enabled?: boolean) => import('react').MutableRefObject<HTMLDivElement | null>;
|
|
@@ -9,6 +9,16 @@ export interface ThoughtChainSectionProps {
|
|
|
9
9
|
nodes: ThoughtNode[];
|
|
10
10
|
/** 渲染模式:实时 / 历史,只影响细节样式与动效 */
|
|
11
11
|
mode?: ThoughtChainRenderMode;
|
|
12
|
+
/**
|
|
13
|
+
* 是否展示时间轴 UI(竖线等)
|
|
14
|
+
* 2026-01-06 新增:用于在 enableCot = 0 时只展示「模型思考」内容,而不展示时间轴。
|
|
15
|
+
*/
|
|
16
|
+
showTimeline?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 是否展示区块头部(图标 + “模型思考完成”这一行)
|
|
19
|
+
* 2026-01-06 新增:在 enableCot = 0 的简单模式下关闭,直接输出内容。
|
|
20
|
+
*/
|
|
21
|
+
showHeader?: boolean;
|
|
12
22
|
}
|
|
13
23
|
declare const ThoughtChainSection: React.FC<ThoughtChainSectionProps>;
|
|
14
24
|
export default ThoughtChainSection;
|