listpage-next 0.0.168 → 0.0.170
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/demos/demo8.js +42 -21
- package/dist/features/ChatClient/components/ChatContent/BubbleList.d.ts +4 -8
- package/dist/features/ChatClient/components/ChatContent/BubbleList.js +8 -28
- package/dist/features/ChatClient/components/ChatContent/ClientContentBody.d.ts +4 -2
- package/dist/features/ChatClient/components/ChatContent/ClientContentBody.js +6 -6
- package/dist/features/ChatClient/components/ChatContent/index.d.ts +6 -4
- package/dist/features/ChatClient/components/ChatContent/index.js +4 -3
- package/dist/features/ChatClient/components/ChatSender/index.js +10 -8
- package/dist/features/ChatClient/components/HistoryConversation/index.d.ts +3 -9
- package/dist/features/ChatClient/components/HistoryConversation/index.js +20 -73
- package/dist/features/ChatClient/components/HistoryConversation/styles.d.ts +0 -5
- package/dist/features/ChatClient/components/HistoryConversation/styles.js +17 -45
- package/dist/features/ChatClient/components/Logo/index.d.ts +1 -1
- package/dist/features/ChatClient/components/Logo/index.js +9 -9
- package/dist/features/ChatClient/index.d.ts +1 -4
- package/dist/features/ChatClient/index.js +1 -4
- package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +13 -0
- package/dist/features/ChatClient/ui/Bubble/BubbleList.js +41 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/index.d.ts +2 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/index.js +2 -0
- package/dist/features/ChatClient/ui/ConversationList/index.d.ts +21 -0
- package/dist/features/ChatClient/ui/ConversationList/index.js +85 -0
- package/dist/features/ChatClient/ui/ConversationList/styles.d.ts +5 -0
- package/dist/features/ChatClient/ui/ConversationList/styles.js +30 -0
- package/dist/features/ChatClient/ui/EditorContent/constants.d.ts +3 -0
- package/dist/features/ChatClient/ui/EditorContent/constants.js +4 -0
- package/dist/features/ChatClient/ui/EditorContent/editor.d.ts +13 -0
- package/dist/features/ChatClient/ui/EditorContent/editor.js +97 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.d.ts +2 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.js +44 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.d.ts +4 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.js +54 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.d.ts +24 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.js +331 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.d.ts +3 -0
- package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.js +83 -0
- package/dist/features/ChatClient/ui/EditorContent/index.d.ts +2 -0
- package/dist/features/ChatClient/ui/EditorContent/index.js +2 -0
- package/dist/features/ChatClient/ui/EditorContent/utils.d.ts +7 -0
- package/dist/features/ChatClient/ui/EditorContent/utils.js +10 -0
- package/dist/features/ChatClient/ui/index.d.ts +5 -0
- package/dist/features/ChatClient/ui/index.js +5 -0
- package/dist/features/ChatClient/utils/parseSse.d.ts +1 -1
- package/dist/features/ChatClient/utils/parseSse.js +1 -1
- package/package.json +11 -2
- package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.js +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.js +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.js +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.js +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.js +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.js +0 -0
- package/dist/features/ChatClient/{components → ui}/ChatDialog/index.d.ts +0 -0
- package/dist/features/ChatClient/{components → ui}/ChatDialog/index.js +1 -1
- /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.d.ts +0 -0
- /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.js +0 -0
- /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.d.ts +0 -0
- /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.js +0 -0
- /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.d.ts +0 -0
- /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.js +0 -0
|
@@ -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,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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.170",
|
|
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,15 @@
|
|
|
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
|
+
"@tiptap/react": "~3.10.7",
|
|
72
|
+
"@tiptap/extension-document": "~3.10.7",
|
|
73
|
+
"@tiptap/extension-text": "~3.10.7",
|
|
74
|
+
"@tiptap/extensions": "~3.10.7",
|
|
75
|
+
"@tiptap/extension-paragraph": "~3.10.7",
|
|
76
|
+
"@tiptap/extension-hard-break": "~3.10.7",
|
|
77
|
+
"@tiptap/core": "~3.10.7",
|
|
78
|
+
"@tiptap/pm": "~3.10.7",
|
|
79
|
+
"prosemirror-state": "~1.4.4"
|
|
71
80
|
}
|
|
72
81
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|