@ant-design/agentic-ui 2.30.23 → 2.30.25
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/MarkdownEditor/editor/plugins/index.d.ts +1 -0
- package/dist/MarkdownEditor/editor/plugins/index.js +1 -0
- package/dist/MarkdownEditor/editor/plugins/withListsPlugin.js +5 -4
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +2 -1
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.d.ts +8 -0
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +330 -0
- package/dist/MarkdownEditor/editor/store.d.ts +1 -3
- package/dist/MarkdownEditor/editor/store.js +4 -0
- package/dist/MarkdownInputField/MarkdownInputField.js +1 -1
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +3 -0
- package/package.json +1 -1
|
@@ -5,5 +5,6 @@ export * from './withInlineNodes';
|
|
|
5
5
|
export * from './withLinkAndMediaPlugin';
|
|
6
6
|
export * from './withListsPlugin';
|
|
7
7
|
export * from './withMarkdown';
|
|
8
|
+
export * from './withSanitizeInvalidChildren';
|
|
8
9
|
export * from './withSchemaPlugin';
|
|
9
10
|
export * from './withVoidNodes';
|
|
@@ -5,5 +5,6 @@ export * from "./withInlineNodes";
|
|
|
5
5
|
export * from "./withLinkAndMediaPlugin";
|
|
6
6
|
export * from "./withListsPlugin";
|
|
7
7
|
export * from "./withMarkdown";
|
|
8
|
+
export * from "./withSanitizeInvalidChildren";
|
|
8
9
|
export * from "./withSchemaPlugin";
|
|
9
10
|
export * from "./withVoidNodes";
|
|
@@ -115,8 +115,9 @@ import { Editor, Element, Node, Transforms } from "slate";
|
|
|
115
115
|
}
|
|
116
116
|
// 规则 2: list-item 的子节点结构规范化
|
|
117
117
|
if (Element.isElement(node) && node.type === 'list-item') {
|
|
118
|
+
var listItemChildren = Array.isArray(node.children) ? node.children : [];
|
|
118
119
|
// 确保 list-item 至少有一个子节点
|
|
119
|
-
if (
|
|
120
|
+
if (listItemChildren.length === 0) {
|
|
120
121
|
Transforms.insertNodes(editor, {
|
|
121
122
|
type: 'paragraph',
|
|
122
123
|
children: [
|
|
@@ -132,7 +133,7 @@ import { Editor, Element, Node, Transforms } from "slate";
|
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
135
|
// 确保第一个子节点是块级元素(paragraph 或其他块级元素)
|
|
135
|
-
var firstChild =
|
|
136
|
+
var firstChild = listItemChildren[0];
|
|
136
137
|
if (Element.isElement(firstChild) && !Editor.isBlock(editor, firstChild) && firstChild.type !== 'paragraph') {
|
|
137
138
|
// 如果不是块级元素,包裹为 paragraph
|
|
138
139
|
Transforms.wrapNodes(editor, {
|
|
@@ -147,8 +148,8 @@ import { Editor, Element, Node, Transforms } from "slate";
|
|
|
147
148
|
}
|
|
148
149
|
// 确保 list-item 的子节点中,除了第一个块级元素外,其他都是列表类型
|
|
149
150
|
// 允许的结构: [paragraph, bulleted-list?, numbered-list?]
|
|
150
|
-
for(var i = 1; i <
|
|
151
|
-
var child1 =
|
|
151
|
+
for(var i = 1; i < listItemChildren.length; i++){
|
|
152
|
+
var child1 = listItemChildren[i];
|
|
152
153
|
if (Element.isElement(child1)) {
|
|
153
154
|
if (!isListType(child1)) {
|
|
154
155
|
if (Editor.isBlock(editor, child1)) {
|
|
@@ -4,6 +4,7 @@ import { withInlineNodes } from "./withInlineNodes";
|
|
|
4
4
|
import { withLinkAndMediaPlugin } from "./withLinkAndMediaPlugin";
|
|
5
5
|
import { withListsPlugin } from "./withListsPlugin";
|
|
6
6
|
import { withSchemaPlugin } from "./withSchemaPlugin";
|
|
7
|
+
import { withSanitizeInvalidChildren } from "./withSanitizeInvalidChildren";
|
|
7
8
|
import { withVoidNodes } from "./withVoidNodes";
|
|
8
9
|
/**
|
|
9
10
|
* 为Slate编辑器添加Markdown支持的插件函数
|
|
@@ -22,5 +23,5 @@ import { withVoidNodes } from "./withVoidNodes";
|
|
|
22
23
|
*
|
|
23
24
|
* 插件按顺序应用,每个插件都会增强编辑器的特定功能。
|
|
24
25
|
*/ export var withMarkdown = function withMarkdown(editor) {
|
|
25
|
-
return withCodeTagPlugin(withSchemaPlugin(withLinkAndMediaPlugin(withCardPlugin(withListsPlugin(withVoidNodes(withInlineNodes(editor)))))));
|
|
26
|
+
return withSanitizeInvalidChildren(withCodeTagPlugin(withSchemaPlugin(withLinkAndMediaPlugin(withCardPlugin(withListsPlugin(withVoidNodes(withInlineNodes(editor))))))));
|
|
26
27
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
import { HistoryEditor } from 'slate-history';
|
|
3
|
+
/**
|
|
4
|
+
* 外部或合并后的 value 可能在 `children` 中混入 `undefined` / `null`;
|
|
5
|
+
* Slate 的 `Node.string` 会对每个子节点调用 `Text.isText`,遇 `undefined` 即抛错。
|
|
6
|
+
* 在 normalize 最外层剔除非法子节点,避免编辑器与 toMarkdown 崩溃。
|
|
7
|
+
*/
|
|
8
|
+
export declare const withSanitizeInvalidChildren: (editor: Editor) => import("slate").BaseEditor & import("slate-react").ReactEditor & HistoryEditor;
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function _iterable_to_array_limit(arr, i) {
|
|
23
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
+
if (_i == null) return;
|
|
25
|
+
var _arr = [];
|
|
26
|
+
var _n = true;
|
|
27
|
+
var _d = false;
|
|
28
|
+
var _s, _e;
|
|
29
|
+
try {
|
|
30
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
31
|
+
_arr.push(_s.value);
|
|
32
|
+
if (i && _arr.length === i) break;
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_d = true;
|
|
36
|
+
_e = err;
|
|
37
|
+
} finally{
|
|
38
|
+
try {
|
|
39
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
+
} finally{
|
|
41
|
+
if (_d) throw _e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return _arr;
|
|
45
|
+
}
|
|
46
|
+
function _non_iterable_rest() {
|
|
47
|
+
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
|
+
}
|
|
49
|
+
function _object_spread(target) {
|
|
50
|
+
for(var i = 1; i < arguments.length; i++){
|
|
51
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
52
|
+
var ownKeys = Object.keys(source);
|
|
53
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
54
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
ownKeys.forEach(function(key) {
|
|
59
|
+
_define_property(target, key, source[key]);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
function ownKeys(object, enumerableOnly) {
|
|
65
|
+
var keys = Object.keys(object);
|
|
66
|
+
if (Object.getOwnPropertySymbols) {
|
|
67
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
68
|
+
if (enumerableOnly) {
|
|
69
|
+
symbols = symbols.filter(function(sym) {
|
|
70
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
keys.push.apply(keys, symbols);
|
|
74
|
+
}
|
|
75
|
+
return keys;
|
|
76
|
+
}
|
|
77
|
+
function _object_spread_props(target, source) {
|
|
78
|
+
source = source != null ? source : {};
|
|
79
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
80
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
81
|
+
} else {
|
|
82
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
83
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _object_without_properties(source, excluded) {
|
|
89
|
+
if (source == null) return {};
|
|
90
|
+
var target = {}, sourceKeys, key, i;
|
|
91
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
92
|
+
sourceKeys = Reflect.ownKeys(source);
|
|
93
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
94
|
+
key = sourceKeys[i];
|
|
95
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
96
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
97
|
+
target[key] = source[key];
|
|
98
|
+
}
|
|
99
|
+
return target;
|
|
100
|
+
}
|
|
101
|
+
target = _object_without_properties_loose(source, excluded);
|
|
102
|
+
if (Object.getOwnPropertySymbols) {
|
|
103
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
104
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
105
|
+
key = sourceKeys[i];
|
|
106
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
107
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
108
|
+
target[key] = source[key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return target;
|
|
112
|
+
}
|
|
113
|
+
function _object_without_properties_loose(source, excluded) {
|
|
114
|
+
if (source == null) return {};
|
|
115
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
116
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
117
|
+
key = sourceKeys[i];
|
|
118
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
119
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
120
|
+
target[key] = source[key];
|
|
121
|
+
}
|
|
122
|
+
return target;
|
|
123
|
+
}
|
|
124
|
+
function _sliced_to_array(arr, i) {
|
|
125
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
126
|
+
}
|
|
127
|
+
function _type_of(obj) {
|
|
128
|
+
"@swc/helpers - typeof";
|
|
129
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
130
|
+
}
|
|
131
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
132
|
+
if (!o) return;
|
|
133
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
134
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
135
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
136
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
137
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
138
|
+
}
|
|
139
|
+
import { Editor, Node, Transforms } from "slate";
|
|
140
|
+
import { HistoryEditor } from "slate-history";
|
|
141
|
+
import { EditorUtils } from "../utils/editorUtils";
|
|
142
|
+
var isValidChild = function isValidChild(child) {
|
|
143
|
+
return child !== undefined && child !== null && Node.isNode(child);
|
|
144
|
+
};
|
|
145
|
+
var getChildList = function getChildList(node) {
|
|
146
|
+
if (!('children' in node)) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
var children = node.children;
|
|
150
|
+
return Array.isArray(children) ? children : [];
|
|
151
|
+
};
|
|
152
|
+
var createDefaultBlock = function createDefaultBlock() {
|
|
153
|
+
return {
|
|
154
|
+
type: 'paragraph',
|
|
155
|
+
children: [
|
|
156
|
+
{
|
|
157
|
+
text: ''
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
var rebuildElement = function rebuildElement(node) {
|
|
163
|
+
var children = getChildList(node).filter(isValidChild);
|
|
164
|
+
if (children.length === 0 && 'type' in node && node.type) {
|
|
165
|
+
children = [
|
|
166
|
+
{
|
|
167
|
+
text: ''
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
var _drop = node.children, rest = _object_without_properties(node, [
|
|
172
|
+
"children"
|
|
173
|
+
]);
|
|
174
|
+
return _object_spread_props(_object_spread({}, rest), {
|
|
175
|
+
children: children
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
var runWithoutHistory = function runWithoutHistory(editor, fn) {
|
|
179
|
+
if (HistoryEditor.isHistoryEditor(editor)) {
|
|
180
|
+
HistoryEditor.withoutSaving(editor, fn);
|
|
181
|
+
} else {
|
|
182
|
+
fn();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Slate 的 `Node.nodes` / `Editor.normalize` 在遍历时假定非文本节点必有数组型 `children`。
|
|
187
|
+
* 若仅有 `type` 而缺少 `children`,会在进入自定义 `normalizeNode` 之前就抛错,必须先修树。
|
|
188
|
+
*/ var rebuildOrDefaultBlock = function rebuildOrDefaultBlock(raw) {
|
|
189
|
+
if (raw && (typeof raw === "undefined" ? "undefined" : _type_of(raw)) === 'object' && //@ts-ignore
|
|
190
|
+
!(Node === null || Node === void 0 ? void 0 : Node.isText(raw)) && typeof raw.type === 'string') {
|
|
191
|
+
return rebuildElement(raw);
|
|
192
|
+
}
|
|
193
|
+
return createDefaultBlock();
|
|
194
|
+
};
|
|
195
|
+
var repairBrokenChildArrays = function repairBrokenChildArrays(editor) {
|
|
196
|
+
if (!Array.isArray(editor.children)) {
|
|
197
|
+
/* eslint-disable no-param-reassign */ editor.children = [
|
|
198
|
+
createDefaultBlock()
|
|
199
|
+
];
|
|
200
|
+
/* eslint-enable no-param-reassign */ return true;
|
|
201
|
+
}
|
|
202
|
+
if (editor.children.length === 0) {
|
|
203
|
+
EditorUtils.replaceEditorContent(editor, [
|
|
204
|
+
createDefaultBlock()
|
|
205
|
+
]);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
for(var i = 0; i < editor.children.length; i++){
|
|
209
|
+
var child = editor.children[i];
|
|
210
|
+
if (!isValidChild(child)) {
|
|
211
|
+
/* eslint-disable no-param-reassign */ editor.children[i] = rebuildOrDefaultBlock(child);
|
|
212
|
+
/* eslint-enable no-param-reassign */ return true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
var fixBranch = function fixBranch1(node) {
|
|
216
|
+
var _Node_isText;
|
|
217
|
+
if (!node || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
//@ts-ignore
|
|
221
|
+
if (Node === null || Node === void 0 ? void 0 : (_Node_isText = Node.isText) === null || _Node_isText === void 0 ? void 0 : _Node_isText.call(Node, node)) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
var rawChildren = node.children;
|
|
225
|
+
if (!Array.isArray(rawChildren)) {
|
|
226
|
+
Object.assign(node, rebuildElement(node));
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
if (rawChildren === null || rawChildren === void 0 ? void 0 : rawChildren.some(function(c) {
|
|
230
|
+
return !isValidChild(c);
|
|
231
|
+
})) {
|
|
232
|
+
var fixedChildren = rawChildren.filter(isValidChild);
|
|
233
|
+
node.children = fixedChildren.length === 0 ? [
|
|
234
|
+
{
|
|
235
|
+
text: ''
|
|
236
|
+
}
|
|
237
|
+
] : fixedChildren;
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
for(var i = 0; i < rawChildren.length; i++){
|
|
241
|
+
if (fixBranch(rawChildren[i])) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
};
|
|
247
|
+
for(var i1 = 0; i1 < editor.children.length; i1++){
|
|
248
|
+
if (fixBranch(editor.children[i1])) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* 外部或合并后的 value 可能在 `children` 中混入 `undefined` / `null`;
|
|
256
|
+
* Slate 的 `Node.string` 会对每个子节点调用 `Text.isText`,遇 `undefined` 即抛错。
|
|
257
|
+
* 在 normalize 最外层剔除非法子节点,避免编辑器与 toMarkdown 崩溃。
|
|
258
|
+
*/ export var withSanitizeInvalidChildren = function withSanitizeInvalidChildren(editor) {
|
|
259
|
+
var normalizeNode = editor.normalizeNode, normalize = editor.normalize;
|
|
260
|
+
editor.normalize = function(options) {
|
|
261
|
+
var guard = 0;
|
|
262
|
+
while(guard < 100 && repairBrokenChildArrays(editor)){
|
|
263
|
+
guard += 1;
|
|
264
|
+
}
|
|
265
|
+
return normalize.call(editor, options);
|
|
266
|
+
};
|
|
267
|
+
editor.normalizeNode = function(entry) {
|
|
268
|
+
var _Node_isText;
|
|
269
|
+
var _entry = _sliced_to_array(entry, 2), node = _entry[0], path = _entry[1];
|
|
270
|
+
// `Node.isNode` is true for text leaves, but they have no `children`; never call `.some` on them.
|
|
271
|
+
//@ts-ignore
|
|
272
|
+
if (Node === null || Node === void 0 ? void 0 : (_Node_isText = Node.isText) === null || _Node_isText === void 0 ? void 0 : _Node_isText.call(Node, node)) {
|
|
273
|
+
normalizeNode(entry);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (Editor.isEditor(node) && path.length === 0) {
|
|
277
|
+
var childList = getChildList(node);
|
|
278
|
+
var hasInvalid = childList.some(function(c) {
|
|
279
|
+
return !isValidChild(c);
|
|
280
|
+
});
|
|
281
|
+
if (hasInvalid || childList.length === 0) {
|
|
282
|
+
var nextNodes = childList.length === 0 ? [
|
|
283
|
+
createDefaultBlock()
|
|
284
|
+
] : childList.map(function(c) {
|
|
285
|
+
return isValidChild(c) ? c : rebuildOrDefaultBlock(c);
|
|
286
|
+
});
|
|
287
|
+
EditorUtils.replaceEditorContent(editor, nextNodes);
|
|
288
|
+
normalizeNode(entry);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
normalizeNode(entry);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
//@ts-ignore
|
|
295
|
+
if (!Editor.isEditor(node) && !Node.isText(node)) {
|
|
296
|
+
var rawChildren = node.children;
|
|
297
|
+
if (!Array.isArray(rawChildren)) {
|
|
298
|
+
Object.assign(node, rebuildElement(node));
|
|
299
|
+
normalizeNode(entry);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//@ts-ignore
|
|
304
|
+
if (Node.isElement(node)) {
|
|
305
|
+
var childList1 = getChildList(node);
|
|
306
|
+
var hasInvalid1 = childList1.some(function(c) {
|
|
307
|
+
return !isValidChild(c);
|
|
308
|
+
});
|
|
309
|
+
if (hasInvalid1) {
|
|
310
|
+
var applyRebuild = function applyRebuild() {
|
|
311
|
+
Editor.withoutNormalizing(editor, function() {
|
|
312
|
+
var rebuilt = rebuildElement(node);
|
|
313
|
+
Transforms.removeNodes(editor, {
|
|
314
|
+
at: path,
|
|
315
|
+
voids: true
|
|
316
|
+
});
|
|
317
|
+
Transforms.insertNodes(editor, rebuilt, {
|
|
318
|
+
at: path,
|
|
319
|
+
voids: true
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
runWithoutHistory(editor, applyRebuild);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
normalizeNode(entry);
|
|
328
|
+
};
|
|
329
|
+
return editor;
|
|
330
|
+
};
|
|
@@ -435,6 +435,10 @@ export var EditorStoreContext = createContext(null);
|
|
|
435
435
|
value: function setMDContent(md, plugins, options) {
|
|
436
436
|
var _ref, _ref1, _ref2, _ref3;
|
|
437
437
|
if (md === undefined) return;
|
|
438
|
+
if (!md) {
|
|
439
|
+
this.clearContent();
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
438
442
|
if (this._shouldSkipSetContent(md)) return;
|
|
439
443
|
this.cancelSetMDContent();
|
|
440
444
|
var chunkSize = (_ref = options === null || options === void 0 ? void 0 : options.chunkSize) !== null && _ref !== void 0 ? _ref : 5000;
|
|
@@ -140,7 +140,6 @@ import { useLocale } from "../I18n";
|
|
|
140
140
|
import { BaseMarkdownEditor } from "../MarkdownEditor";
|
|
141
141
|
import { BorderBeamAnimation } from "./BorderBeamAnimation";
|
|
142
142
|
import { useFileUploadManager } from "./FileUploadManager";
|
|
143
|
-
import { resolveSendDisabled } from "./SendButton";
|
|
144
143
|
import { useMarkdownInputFieldActions } from "./hooks/useMarkdownInputFieldActions";
|
|
145
144
|
import { useMarkdownInputFieldHandlers } from "./hooks/useMarkdownInputFieldHandlers";
|
|
146
145
|
import { useMarkdownInputFieldLayout } from "./hooks/useMarkdownInputFieldLayout";
|
|
@@ -148,6 +147,7 @@ import { useMarkdownInputFieldRefs } from "./hooks/useMarkdownInputFieldRefs";
|
|
|
148
147
|
import { useMarkdownInputFieldState } from "./hooks/useMarkdownInputFieldState";
|
|
149
148
|
import { useMarkdownInputFieldStyles } from "./hooks/useMarkdownInputFieldStyles";
|
|
150
149
|
import { QuickActions } from "./QuickActions";
|
|
150
|
+
import { resolveSendDisabled } from "./SendButton";
|
|
151
151
|
import { SkillModeBar } from "./SkillModeBar";
|
|
152
152
|
import { useStyle } from "./style";
|
|
153
153
|
import { Suggestion } from "./Suggestion";
|
|
@@ -94,6 +94,9 @@ import { ReactEditor } from "slate-react";
|
|
|
94
94
|
// ReactEditor.isFocused can throw if the editor is being torn down
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
if (props.value === undefined || props.value === '') {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
97
100
|
(_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : (_markdownEditorRef_current_store = _markdownEditorRef_current1.store) === null || _markdownEditorRef_current_store === void 0 ? void 0 : _markdownEditorRef_current_store.setMDContent((_props_value = props.value) !== null && _props_value !== void 0 ? _props_value : '');
|
|
98
101
|
}, [
|
|
99
102
|
props.value
|