listpage-next 0.0.167 → 0.0.169

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.
Files changed (58) hide show
  1. package/dist/demos/demo8.js +42 -21
  2. package/dist/features/ChatClient/components/ChatContent/BubbleList.d.ts +4 -8
  3. package/dist/features/ChatClient/components/ChatContent/BubbleList.js +8 -28
  4. package/dist/features/ChatClient/components/ChatContent/ClientContentBody.d.ts +4 -2
  5. package/dist/features/ChatClient/components/ChatContent/ClientContentBody.js +6 -6
  6. package/dist/features/ChatClient/components/ChatContent/ClientContentHeader.js +27 -22
  7. package/dist/features/ChatClient/components/ChatContent/index.d.ts +6 -4
  8. package/dist/features/ChatClient/components/ChatContent/index.js +4 -3
  9. package/dist/features/ChatClient/components/ChatSender/index.js +10 -8
  10. package/dist/features/ChatClient/components/Logo/index.d.ts +1 -1
  11. package/dist/features/ChatClient/components/Logo/index.js +9 -9
  12. package/dist/features/ChatClient/index.d.ts +1 -4
  13. package/dist/features/ChatClient/index.js +1 -4
  14. package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +11 -0
  15. package/dist/features/ChatClient/ui/Bubble/BubbleList.js +34 -0
  16. package/dist/features/ChatClient/{components → ui}/Bubble/index.d.ts +2 -0
  17. package/dist/features/ChatClient/{components → ui}/Bubble/index.js +2 -0
  18. package/dist/features/ChatClient/ui/EditorContent/constants.d.ts +3 -0
  19. package/dist/features/ChatClient/ui/EditorContent/constants.js +4 -0
  20. package/dist/features/ChatClient/ui/EditorContent/editor.d.ts +13 -0
  21. package/dist/features/ChatClient/ui/EditorContent/editor.js +97 -0
  22. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.d.ts +2 -0
  23. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.js +44 -0
  24. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.d.ts +4 -0
  25. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.js +54 -0
  26. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.d.ts +24 -0
  27. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.js +331 -0
  28. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.d.ts +3 -0
  29. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.js +83 -0
  30. package/dist/features/ChatClient/ui/EditorContent/index.d.ts +2 -0
  31. package/dist/features/ChatClient/ui/EditorContent/index.js +2 -0
  32. package/dist/features/ChatClient/ui/EditorContent/utils.d.ts +7 -0
  33. package/dist/features/ChatClient/ui/EditorContent/utils.js +10 -0
  34. package/dist/features/ChatClient/ui/index.d.ts +4 -0
  35. package/dist/features/ChatClient/ui/index.js +4 -0
  36. package/dist/features/ChatClient/utils/parseSse.d.ts +1 -1
  37. package/dist/features/ChatClient/utils/parseSse.js +1 -1
  38. package/package.json +12 -2
  39. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.d.ts +0 -0
  40. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.js +0 -0
  41. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.d.ts +0 -0
  42. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.js +0 -0
  43. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.d.ts +0 -0
  44. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.js +0 -0
  45. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.d.ts +0 -0
  46. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.js +0 -0
  47. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.d.ts +0 -0
  48. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.js +0 -0
  49. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.d.ts +0 -0
  50. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.js +0 -0
  51. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.d.ts +0 -0
  52. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.js +1 -1
  53. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.d.ts +0 -0
  54. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.js +0 -0
  55. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.d.ts +0 -0
  56. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.js +0 -0
  57. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.d.ts +0 -0
  58. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.js +0 -0
@@ -0,0 +1,54 @@
1
+ import { Node, mergeAttributes } from "@tiptap/core";
2
+ import { ReactNodeViewRenderer } from "@tiptap/react";
3
+ import component from "./component.js";
4
+ import { ensureTrailingText, keyDownHandlePlugin } from "../plugins.js";
5
+ import { getCustomSlotAttribute } from "../../utils.js";
6
+ const REACT_COMPONENT_NODE_NAME = 'inputSlot';
7
+ const inputSlot = Node.create({
8
+ name: 'inputSlot',
9
+ group: 'inline',
10
+ inline: true,
11
+ content: 'inline*',
12
+ atom: false,
13
+ selectable: true,
14
+ draggable: false,
15
+ parseHTML () {
16
+ return [
17
+ {
18
+ tag: 'input-slot',
19
+ getAttrs: (element)=>({
20
+ placeholder: element.getAttribute('placeholder')
21
+ })
22
+ }
23
+ ];
24
+ },
25
+ renderHTML ({ HTMLAttributes }) {
26
+ return [
27
+ 'input-slot',
28
+ mergeAttributes(HTMLAttributes),
29
+ 0
30
+ ];
31
+ },
32
+ addAttributes () {
33
+ return {
34
+ placeholder: {
35
+ default: '',
36
+ parseHTML: (element)=>element.getAttribute('placeholder') || '',
37
+ renderHTML: (attributes)=>({
38
+ placeholder: attributes.placeholder
39
+ })
40
+ },
41
+ isCustomSlot: getCustomSlotAttribute()
42
+ };
43
+ },
44
+ addNodeView () {
45
+ return ReactNodeViewRenderer(component);
46
+ },
47
+ addProseMirrorPlugins () {
48
+ return [
49
+ ensureTrailingText(this.editor.schema),
50
+ keyDownHandlePlugin(this.editor.schema)
51
+ ];
52
+ }
53
+ });
54
+ export { REACT_COMPONENT_NODE_NAME, inputSlot as default };
@@ -0,0 +1,24 @@
1
+ import { EditorState, Plugin, Transaction } from 'prosemirror-state';
2
+ import { EditorView } from '@tiptap/pm/view';
3
+ /**
4
+ * @param newState
5
+ * @returns
6
+ * handleZeroWidthCharLogic 用于插入零宽字符或者删除多余的零宽字符
7
+ * 为什么需要插入零宽字符?
8
+ * 1. 保证自定义节点前后的光标高度正常,光标高度和内容相关,解决自定义节点是最后一个节点,
9
+ * 光标高度会和自定义节点占据高度一致,和文本中光标高度不一致的问题
10
+ * 2. 保证对于可编辑的 inline 节点(比如 input-slot),为最后一个节点时候,光标可以聚焦到该节点后
11
+ * Why do we need to insert zero-width characters?
12
+ * 1. Ensure that the cursor height before and after the custom node is normal.
13
+ * The cursor height is related to the content. Solve the problem that when the custom node is the last node,
14
+ * the cursor height will be consistent with the height occupied by the custom node, and inconsistent with the cursor height in the text.
15
+ * 2. Ensure that for an editable inline node (such as input-slot), when it is the last node, the cursor can focus after the node.
16
+ */
17
+ export declare function handleZeroWidthCharLogic(newState: EditorState): Transaction | null;
18
+ export declare function ensureTrailingText(schema: any): Plugin;
19
+ export declare function keyDownHandlePlugin(schema: any): Plugin;
20
+ export declare function handlePasteLogic(view: EditorView, event: ClipboardEvent): boolean;
21
+ export declare function removeZeroWidthChar($from: any, tr: Transaction): boolean;
22
+ export declare function removeZeroWidthCharForComposition($from: any, tr: Transaction): Transaction | null;
23
+ export declare function handleCompositionEndLogic(view: EditorView): void;
24
+ export declare function handleTextInputLogic(view: EditorView, from: number, to: number, text: string): boolean;
@@ -0,0 +1,331 @@
1
+ import { Plugin, PluginKey, TextSelection } from "prosemirror-state";
2
+ import { strings } from "../constants.js";
3
+ function handleZeroWidthCharLogic(newState) {
4
+ let todoPositions = [];
5
+ let { tr } = newState;
6
+ newState.doc.descendants((node, pos, parent)=>{
7
+ if ('paragraph' === node.type.name && node.childCount > 0) {
8
+ const { lastChild, firstChild } = node;
9
+ if (firstChild && firstChild.attrs.isCustomSlot) todoPositions.push(pos + 1);
10
+ if (lastChild && lastChild.attrs.isCustomSlot) {
11
+ const paragraphEndPos = pos + node.nodeSize - 1;
12
+ const prevChar = tr.doc.textBetween(paragraphEndPos - 1, paragraphEndPos, '', '');
13
+ if (prevChar !== strings.ZERO_WIDTH_CHAR) todoPositions.push(paragraphEndPos);
14
+ }
15
+ if (lastChild === firstChild && lastChild?.isText && lastChild.text === strings.ZERO_WIDTH_CHAR) todoPositions.push([
16
+ 'remove',
17
+ pos + 1
18
+ ]);
19
+ }
20
+ if ('inputSlot' === node.type.name && 0 === node.content.size) todoPositions.push(pos + 1);
21
+ if (node.attrs.isCustomSlot) {
22
+ let nodeIndex = -1;
23
+ if (parent) {
24
+ parent.forEach((child, offset, i)=>{
25
+ if (child === node) nodeIndex = i;
26
+ });
27
+ if (nodeIndex > -1 && nodeIndex < parent.childCount - 1) {
28
+ const nextSibling = parent.child(nodeIndex + 1);
29
+ if (nextSibling.attrs.isCustomSlot) todoPositions.push(pos + node.nodeSize);
30
+ }
31
+ }
32
+ }
33
+ });
34
+ if (todoPositions.length > 0) {
35
+ todoPositions.sort((a, b)=>{
36
+ const aOrder = Array.isArray(a) ? a[1] : a;
37
+ const bOrder = Array.isArray(b) ? b[1] : b;
38
+ return bOrder - aOrder;
39
+ }).forEach((insertPos)=>{
40
+ tr = Array.isArray(insertPos) && 'remove' === insertPos[0] ? tr.delete(insertPos[1], insertPos[1] + 1) : tr.insertText(strings.ZERO_WIDTH_CHAR, insertPos, insertPos);
41
+ });
42
+ return tr;
43
+ }
44
+ return null;
45
+ }
46
+ function ensureTrailingText(schema) {
47
+ return new Plugin({
48
+ appendTransaction (transactions, oldState, newState) {
49
+ const docChanged = transactions.some((tr)=>tr.docChanged);
50
+ if (!docChanged) return null;
51
+ return handleZeroWidthCharLogic(newState);
52
+ }
53
+ });
54
+ }
55
+ function keyDownHandlePlugin(schema) {
56
+ return new Plugin({
57
+ key: new PluginKey('prevent-empty-inline-node'),
58
+ props: {
59
+ handleKeyDown (view, event) {
60
+ const { state, dispatch } = view;
61
+ const { selection } = state;
62
+ const { $from, $to } = selection;
63
+ const node = $from.node();
64
+ if ('ArrowLeft' === event.key && 'inputSlot' !== node.type.name) {
65
+ if ($from.nodeBefore && $from.nodeBefore.isText && $from.nodeBefore.text) {
66
+ if ($from.nodeBefore.text === strings.ZERO_WIDTH_CHAR) {
67
+ const parent = $from.parent;
68
+ const index = $from.index();
69
+ if (index >= 2) {
70
+ const secondBeforeCursorNode = parent.child(index - 2);
71
+ if (secondBeforeCursorNode.attrs.isCustomSlot) {
72
+ const nextCursorPos = $from.pos - 2;
73
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextCursorPos)));
74
+ event.preventDefault();
75
+ return true;
76
+ }
77
+ } else if (1 === index && 0 !== $from.pos) {
78
+ const nextCursorPos = $from.before() - 1;
79
+ nextCursorPos > 0 && dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextCursorPos)));
80
+ event.preventDefault();
81
+ return true;
82
+ }
83
+ } else if ($from.nodeBefore.text.endsWith(strings.ZERO_WIDTH_CHAR)) {
84
+ const nextCursorPos = $from.pos - 2;
85
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextCursorPos)));
86
+ event.preventDefault();
87
+ return true;
88
+ }
89
+ }
90
+ }
91
+ if ('ArrowRight' === event.key && 'inputSlot' !== node.type.name) {
92
+ if ($from.nodeAfter && $from.nodeAfter.isText) {
93
+ if ($from.nodeAfter.text === strings.ZERO_WIDTH_CHAR) {
94
+ const parent = $from.parent;
95
+ const index = $from.index();
96
+ if (index < parent.children.length - 1) {
97
+ const secondAfterCursorNode = parent.child(index + 1);
98
+ if (secondAfterCursorNode.attrs.isCustomSlot) {
99
+ const newPos = $from.pos + 2;
100
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, newPos)));
101
+ event.preventDefault();
102
+ return true;
103
+ }
104
+ } else if (index === parent.children.length - 1 && state.doc.lastChild !== node) {
105
+ const nextCursorPos = $from.after() + 1;
106
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextCursorPos)));
107
+ event.preventDefault();
108
+ return true;
109
+ }
110
+ } else if ($from.nodeBefore && $from.nodeBefore.isText && $from.nodeBefore.text?.startsWith(strings.ZERO_WIDTH_CHAR)) {
111
+ const nextCursorPos = $from.pos + 2;
112
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, nextCursorPos)));
113
+ event.preventDefault();
114
+ return true;
115
+ }
116
+ }
117
+ }
118
+ if ('Backspace' === event.key && selection.empty) {
119
+ const beforeNode = $from.nodeBefore;
120
+ const afterNode = $from.nodeAfter;
121
+ if ($from.nodeBefore && $from.nodeBefore.isText && $from.nodeBefore.text?.length === 1 && $from.nodeBefore.text !== strings.ZERO_WIDTH_CHAR && $from.nodeAfter && $from.nodeAfter.attrs.isCustomSlot) {
122
+ const begin = $from.pos - $from.nodeBefore.nodeSize;
123
+ const end = $from.pos;
124
+ let tr = state.tr.delete(begin, end);
125
+ tr = tr.insertText(strings.ZERO_WIDTH_CHAR, begin, begin);
126
+ dispatch(tr);
127
+ event.preventDefault();
128
+ return true;
129
+ }
130
+ if (beforeNode && beforeNode.attrs.isCustomSlot) {
131
+ const parent = $from.parent;
132
+ const index = $from.index();
133
+ const initalStart = $from.pos - beforeNode.nodeSize;
134
+ const intialEnd = $from.pos;
135
+ let deleteStart = initalStart;
136
+ let deleteEnd = intialEnd;
137
+ if (index > 1) {
138
+ const prevPrevNode = parent.child(index - 2);
139
+ if (prevPrevNode && prevPrevNode.isText && prevPrevNode.text.endsWith(strings.ZERO_WIDTH_CHAR)) deleteStart -= 1;
140
+ }
141
+ if (afterNode && afterNode.isText && afterNode.text.startsWith(strings.ZERO_WIDTH_CHAR)) deleteEnd += 1;
142
+ if (deleteStart !== initalStart || deleteEnd !== intialEnd) {
143
+ const tr = state.tr.delete(deleteStart, deleteEnd);
144
+ dispatch(tr);
145
+ event.preventDefault();
146
+ return true;
147
+ }
148
+ }
149
+ if (afterNode && afterNode.isText && afterNode.text === strings.ZERO_WIDTH_CHAR) {
150
+ const index = $from.index();
151
+ if (0 === index && 1 !== $from.pos) {
152
+ const startPos = selection.from - 2;
153
+ const tr = state.tr.delete(startPos, selection.to + 1);
154
+ dispatch(tr);
155
+ event.preventDefault();
156
+ return true;
157
+ }
158
+ }
159
+ if (beforeNode && beforeNode.isText && beforeNode.text === strings.ZERO_WIDTH_CHAR) {
160
+ const parent = $from.parent;
161
+ const index = $from.index();
162
+ if (index > 1) {
163
+ const prevPrevNode = parent.child(index - 2);
164
+ if (prevPrevNode.attrs.isCustomSlot) {
165
+ const deleteStart = $from.pos - beforeNode.nodeSize - prevPrevNode.nodeSize;
166
+ const tr = state.tr.delete(deleteStart, $from.pos);
167
+ dispatch(tr);
168
+ event.preventDefault();
169
+ return true;
170
+ }
171
+ } else if (1 === index && 'inputSlot' !== node.type.name) {
172
+ if (1 !== $from.pos) {
173
+ const startPos = selection.from - 1 - 2;
174
+ const tr = state.tr.delete(startPos, selection.to);
175
+ dispatch(tr);
176
+ event.preventDefault();
177
+ return true;
178
+ }
179
+ }
180
+ } else if ('inputSlot' === node.type.name && $from.pos === $from.start()) {
181
+ const grandParent = $from.node($from.depth - 1);
182
+ let parentPrevNode = null;
183
+ const parentIndex = $from.index($from.depth - 1);
184
+ if (parentIndex > 0) {
185
+ parentPrevNode = grandParent.child(parentIndex - 1);
186
+ if (parentPrevNode && parentPrevNode.isText && parentPrevNode.text.endsWith(strings.ZERO_WIDTH_CHAR)) {
187
+ const pos = $from.pos - 2;
188
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, pos)));
189
+ event.preventDefault();
190
+ return true;
191
+ }
192
+ }
193
+ const pos = $from.pos - 1;
194
+ let tr = state.tr.insertText(strings.ZERO_WIDTH_CHAR, pos, pos + 1);
195
+ tr = tr.setSelection(TextSelection.create(tr.doc, pos));
196
+ dispatch(tr);
197
+ event.preventDefault();
198
+ return true;
199
+ }
200
+ }
201
+ if ('Backspace' === event.key && !selection.empty) {
202
+ let startPos = selection.from;
203
+ let endPos = selection.to;
204
+ const nodeBefore = $from.nodeBefore;
205
+ const nodeAfter = $from.nodeAfter;
206
+ if (nodeBefore && nodeBefore.isText && nodeBefore.text?.endsWith(strings.ZERO_WIDTH_CHAR)) startPos -= 1;
207
+ if (nodeAfter && nodeAfter.isText && nodeAfter.text?.startsWith(strings.ZERO_WIDTH_CHAR)) endPos += 1;
208
+ if (startPos !== selection.from || endPos !== selection.to) {
209
+ let tr = state.tr.delete(startPos, endPos);
210
+ dispatch(tr);
211
+ event.preventDefault();
212
+ return true;
213
+ }
214
+ }
215
+ if ('inputSlot' === node.type.name) {
216
+ if (node.textContent === strings.ZERO_WIDTH_CHAR && ('ArrowLeft' === event.key || 'ArrowRight' === event.key)) {
217
+ const pos = 'ArrowLeft' === event.key ? $from.before() : $from.after();
218
+ if (selection.from - pos !== 1 && selection.from - pos !== -1) {
219
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, pos)));
220
+ event.preventDefault();
221
+ return true;
222
+ }
223
+ }
224
+ if ($from.pos === $from.end() && 1 === node.textContent.length && node.textContent !== strings.ZERO_WIDTH_CHAR && 'Backspace' === event.key) {
225
+ const pos = $from.pos - 1;
226
+ dispatch(state.tr.insertText(strings.ZERO_WIDTH_CHAR, pos, pos + 1));
227
+ event.preventDefault();
228
+ return true;
229
+ }
230
+ if (!selection.empty && $from.parent === node && selection.from === $from.start() && selection.to >= $from.end() && 'Backspace' === event.key) {
231
+ const tr = state.tr;
232
+ if (selection.to > $from.end()) tr.delete($from.end(), selection.to);
233
+ tr.insertText(strings.ZERO_WIDTH_CHAR, $from.start(), $from.end());
234
+ const pos = $from.start() + 1;
235
+ tr.setSelection(TextSelection.create(tr.doc, pos));
236
+ dispatch(tr);
237
+ event.preventDefault();
238
+ return true;
239
+ }
240
+ if (node.textContent === strings.ZERO_WIDTH_CHAR && 'Backspace' === event.key) {
241
+ const pos = $from.before();
242
+ dispatch(state.tr.delete(pos, pos + node.nodeSize));
243
+ event.preventDefault();
244
+ return true;
245
+ }
246
+ }
247
+ return false;
248
+ }
249
+ }
250
+ });
251
+ }
252
+ function handlePasteLogic(view, event) {
253
+ const types = event.clipboardData?.types || [];
254
+ const html = event.clipboardData?.getData('text/html');
255
+ if (types.includes('text/html') && [
256
+ '<input-slot',
257
+ '<select-slot',
258
+ '<skill-slot'
259
+ ].some((slot)=>html?.includes(slot)) || types.includes('application/x-prosemirror-slice')) return false;
260
+ const text = event.clipboardData?.getData('text/plain');
261
+ if (text) {
262
+ const { state, dispatch } = view;
263
+ const $from = state.selection.$from;
264
+ let tr = state.tr;
265
+ removeZeroWidthChar($from, tr);
266
+ const lines = text.split('\n');
267
+ let finalCursorPos = null;
268
+ if (1 === lines.length) {
269
+ tr = tr.insertText(lines[0], tr.selection.from, tr.selection.to);
270
+ finalCursorPos = tr.selection.$to.pos;
271
+ } else {
272
+ tr = tr.insertText(lines[0], tr.selection.from, tr.selection.to);
273
+ let pos = tr.selection.$to.pos;
274
+ for(let i = 1; i < lines.length; i++){
275
+ const paragraph = state.schema.nodes.paragraph.create({}, lines[i] ? state.schema.text(lines[i]) : null);
276
+ tr = tr.insert(pos, paragraph);
277
+ pos += paragraph.nodeSize;
278
+ }
279
+ finalCursorPos = pos;
280
+ }
281
+ if (null !== finalCursorPos) tr = tr.setSelection(TextSelection.create(tr.doc, finalCursorPos));
282
+ tr = tr.scrollIntoView();
283
+ dispatch(tr);
284
+ event.preventDefault();
285
+ return true;
286
+ }
287
+ return false;
288
+ }
289
+ function removeZeroWidthChar($from, tr) {
290
+ if ($from.nodeBefore && $from.nodeBefore.isText && $from.nodeBefore.text === strings.ZERO_WIDTH_CHAR) {
291
+ tr = tr.delete($from.pos - $from.nodeBefore.nodeSize, $from.pos);
292
+ return true;
293
+ }
294
+ if ($from.nodeAfter && $from.nodeAfter.isText && $from.nodeAfter.text === strings.ZERO_WIDTH_CHAR) {
295
+ tr = tr.delete($from.pos, $from.pos + $from.nodeAfter.nodeSize);
296
+ return true;
297
+ }
298
+ return false;
299
+ }
300
+ function removeZeroWidthCharForComposition($from, tr) {
301
+ if ($from.nodeBefore && $from.nodeBefore.isText) {
302
+ const text = $from.nodeBefore.text;
303
+ if (text?.startsWith(strings.ZERO_WIDTH_CHAR)) {
304
+ const removeStart = $from.pos - $from.nodeBefore.nodeSize;
305
+ const removeEnd = removeStart + 1;
306
+ tr = tr.delete(removeStart, removeEnd);
307
+ return tr;
308
+ }
309
+ }
310
+ return null;
311
+ }
312
+ function handleCompositionEndLogic(view) {
313
+ const { state, dispatch } = view;
314
+ const $from = state.selection.$from;
315
+ let tr = state.tr;
316
+ let modified = removeZeroWidthCharForComposition($from, tr);
317
+ if (modified) dispatch(tr);
318
+ }
319
+ function handleTextInputLogic(view, from, to, text) {
320
+ const { state, dispatch } = view;
321
+ const $from = state.selection.$from;
322
+ let tr = state.tr;
323
+ let modified = removeZeroWidthChar($from, tr);
324
+ if (modified) {
325
+ tr = tr.insertText(text, tr.selection.from, tr.selection.to);
326
+ dispatch(tr);
327
+ return true;
328
+ }
329
+ return false;
330
+ }
331
+ export { ensureTrailingText, handleCompositionEndLogic, handlePasteLogic, handleTextInputLogic, handleZeroWidthCharLogic, keyDownHandlePlugin, removeZeroWidthChar, removeZeroWidthCharForComposition };
@@ -0,0 +1,3 @@
1
+ import { Node } from '@tiptap/core';
2
+ declare const SkillSlot: Node<any, any>;
3
+ export default SkillSlot;
@@ -0,0 +1,83 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Tag } from "antd";
4
+ import { Node, mergeAttributes } from "@tiptap/core";
5
+ import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
6
+ import { styled } from "styled-components";
7
+ import { getCustomSlotAttribute } from "../../utils.js";
8
+ function SkillSlotComponent(props) {
9
+ const { node, editor } = props;
10
+ const value = node.attrs.label ?? node.attrs.value ?? '';
11
+ const onRemove = (e)=>{
12
+ e.preventDefault();
13
+ e.stopPropagation();
14
+ editor?.commands.clearContent();
15
+ };
16
+ if ('' === value) return null;
17
+ return /*#__PURE__*/ jsx(NodeViewWrapperStyled, {
18
+ children: /*#__PURE__*/ jsx(Tag, {
19
+ closable: true,
20
+ color: "blue",
21
+ onClose: onRemove,
22
+ children: value
23
+ })
24
+ });
25
+ }
26
+ const SkillSlot = Node.create({
27
+ name: 'skillSlot',
28
+ inline: true,
29
+ group: 'inline',
30
+ atom: true,
31
+ selectable: false,
32
+ addAttributes () {
33
+ return {
34
+ value: {
35
+ default: '',
36
+ parseHTML: (element)=>element.getAttribute('data-value'),
37
+ renderHTML: (attributes)=>({
38
+ 'data-value': attributes.value
39
+ })
40
+ },
41
+ label: {
42
+ parseHTML: (element)=>element.getAttribute('data-label'),
43
+ renderHTML: (attributes)=>({
44
+ 'data-label': attributes.label
45
+ })
46
+ },
47
+ hasTemplate: {
48
+ parseHTML: (element)=>element.getAttribute('data-template'),
49
+ renderHTML: (attributes)=>({
50
+ 'data-template': attributes.hasTemplate
51
+ })
52
+ },
53
+ isCustomSlot: getCustomSlotAttribute()
54
+ };
55
+ },
56
+ parseHTML () {
57
+ return [
58
+ {
59
+ tag: 'skill-slot'
60
+ }
61
+ ];
62
+ },
63
+ renderHTML ({ HTMLAttributes: htmlAttributes }) {
64
+ return [
65
+ 'skill-slot',
66
+ mergeAttributes(htmlAttributes)
67
+ ];
68
+ },
69
+ addNodeView () {
70
+ return ReactNodeViewRenderer(SkillSlotComponent);
71
+ }
72
+ });
73
+ const skillSlot = SkillSlot;
74
+ const NodeViewWrapperStyled = styled(NodeViewWrapper)`
75
+ display: inline-block;
76
+ margin: 2px;
77
+
78
+ .ant-tag {
79
+ margin: 0;
80
+ display: flex;
81
+ }
82
+ `;
83
+ export { skillSlot as default };
@@ -0,0 +1,2 @@
1
+ export { EditorContent } from './editor';
2
+ export type { EditorContentProps } from './editor';
@@ -0,0 +1,2 @@
1
+ import { EditorContent } from "./editor.js";
2
+ export { EditorContent };
@@ -0,0 +1,7 @@
1
+ export declare function getCustomSlotAttribute(): {
2
+ default: boolean;
3
+ parseHTML: (element: any) => boolean;
4
+ renderHTML: (attributes: any) => {
5
+ 'data-custom-slot': boolean | undefined;
6
+ };
7
+ };
@@ -0,0 +1,10 @@
1
+ function getCustomSlotAttribute() {
2
+ return {
3
+ default: true,
4
+ parseHTML: (element)=>true,
5
+ renderHTML: (attributes)=>({
6
+ 'data-custom-slot': attributes.isCustomSlot ? true : void 0
7
+ })
8
+ };
9
+ }
10
+ export { getCustomSlotAttribute };
@@ -0,0 +1,4 @@
1
+ export * from './Bubble';
2
+ export * from './ChatSplitter';
3
+ export * from './ChatDialog';
4
+ export * from './EditorContent';
@@ -0,0 +1,4 @@
1
+ export * from "./Bubble/index.js";
2
+ export * from "./ChatSplitter/index.js";
3
+ export * from "./ChatDialog/index.js";
4
+ export * from "./EditorContent/index.js";
@@ -1,5 +1,5 @@
1
1
  export type Callbacks<Event = string, Data = any> = {
2
- onCompelet?: () => void;
2
+ onComplete?: () => void;
3
3
  onError?: (error: any) => void;
4
4
  onMessage?: (type: Event, data: Data) => void;
5
5
  };
@@ -20,7 +20,7 @@ async function parseSubjectStream(stream, callbacks) {
20
20
  }
21
21
  }
22
22
  }
23
- callbacks.onCompelet?.();
23
+ callbacks.onComplete?.();
24
24
  } catch (error) {
25
25
  callbacks.onError?.(error);
26
26
  } finally{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -67,6 +67,16 @@
67
67
  "mobx-react-lite": "~4.1.1",
68
68
  "rc-virtual-list": "~3.19.2",
69
69
  "react-draggable": "~4.5.0",
70
- "markdown-it": "~14.1.0"
70
+ "markdown-it": "~14.1.0",
71
+ "@douyinfe/semi-ui": "~2.88.0",
72
+ "@tiptap/react": "~3.10.7",
73
+ "@tiptap/extension-document": "~3.10.7",
74
+ "@tiptap/extension-text": "~3.10.7",
75
+ "@tiptap/extensions": "~3.10.7",
76
+ "@tiptap/extension-paragraph": "~3.10.7",
77
+ "@tiptap/extension-hard-break": "~3.10.7",
78
+ "@tiptap/core": "~3.10.7",
79
+ "@tiptap/pm": "~3.10.7",
80
+ "prosemirror-state": "~1.4.4"
71
81
  }
72
82
  }
@@ -1,8 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import react_draggable from "react-draggable";
2
3
  import { useMemo, useRef } from "react";
3
4
  import { useExtra } from "./useExtra.js";
4
5
  import { CardBody, CardExtra, CardHeader, CardTitle, Container } from "./styles.js";
5
- import react_draggable from "react-draggable";
6
6
  const ChatDialog = (props)=>{
7
7
  const { style, children, title, draggable = true } = props;
8
8
  const containerRef = useRef(null);