@nextclaw/agent-chat-ui 0.3.8 → 0.3.9
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/index.js +18 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1216,8 +1216,8 @@ function readChatComposerSnapshotFromEditorState(editorState) {
|
|
|
1216
1216
|
return {
|
|
1217
1217
|
nodes,
|
|
1218
1218
|
selection: {
|
|
1219
|
-
start: getOffsetFromPoint(selection.anchor),
|
|
1220
|
-
end: getOffsetFromPoint(selection.focus)
|
|
1219
|
+
start: Math.min(getOffsetFromPoint(selection.anchor), getOffsetFromPoint(selection.focus)),
|
|
1220
|
+
end: Math.max(getOffsetFromPoint(selection.anchor), getOffsetFromPoint(selection.focus))
|
|
1221
1221
|
}
|
|
1222
1222
|
};
|
|
1223
1223
|
});
|
|
@@ -1275,9 +1275,10 @@ function getDocumentLength(nodes) {
|
|
|
1275
1275
|
function insertToken(params) {
|
|
1276
1276
|
const { label, nodes, selection, tokenKey, tokenKind, trigger } = params;
|
|
1277
1277
|
const documentLength = getDocumentLength(nodes);
|
|
1278
|
-
const
|
|
1278
|
+
const [selectionStart, selectionEnd] = selection ? [Math.min(selection.start, selection.end), Math.max(selection.start, selection.end)] : [documentLength, documentLength];
|
|
1279
|
+
const replaceStart = trigger?.start ?? selectionStart;
|
|
1279
1280
|
return {
|
|
1280
|
-
nodes: replaceChatComposerRange(nodes, replaceStart, trigger?.end ??
|
|
1281
|
+
nodes: replaceChatComposerRange(nodes, replaceStart, trigger?.end ?? selectionEnd, [createChatComposerTokenNode({
|
|
1281
1282
|
label,
|
|
1282
1283
|
tokenKey,
|
|
1283
1284
|
tokenKind
|
|
@@ -1293,13 +1294,11 @@ function getChatComposerNodesSignature(nodes) {
|
|
|
1293
1294
|
}
|
|
1294
1295
|
function replaceChatComposerSelectionWithText(params) {
|
|
1295
1296
|
const { nodes, selection, text } = params;
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
};
|
|
1300
|
-
const nextOffset = currentSelection.start + text.length;
|
|
1297
|
+
const documentLength = getDocumentLength(nodes);
|
|
1298
|
+
const [selectionStart, selectionEnd] = selection ? [Math.min(selection.start, selection.end), Math.max(selection.start, selection.end)] : [documentLength, documentLength];
|
|
1299
|
+
const nextOffset = selectionStart + text.length;
|
|
1301
1300
|
return {
|
|
1302
|
-
nodes: replaceChatComposerRange(nodes,
|
|
1301
|
+
nodes: replaceChatComposerRange(nodes, selectionStart, selectionEnd, [createChatComposerTextNode(text)]),
|
|
1303
1302
|
selection: {
|
|
1304
1303
|
start: nextOffset,
|
|
1305
1304
|
end: nextOffset
|
|
@@ -1355,17 +1354,17 @@ function syncSelectedSkillsIntoChatComposer(params) {
|
|
|
1355
1354
|
function deleteChatComposerContent(params) {
|
|
1356
1355
|
const { direction, nodes, selection: currentSelection } = params;
|
|
1357
1356
|
const documentLength = getDocumentLength(nodes);
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
let rangeEnd = selection.end;
|
|
1364
|
-
if (selection.start === selection.end) if (direction === "backward" && selection.start > 0) rangeStart = selection.start - 1;
|
|
1365
|
-
else if (direction === "forward" && selection.end < documentLength) rangeEnd = selection.end + 1;
|
|
1357
|
+
const [selectionStart, selectionEnd] = currentSelection ? [Math.min(currentSelection.start, currentSelection.end), Math.max(currentSelection.start, currentSelection.end)] : [documentLength, documentLength];
|
|
1358
|
+
let rangeStart = selectionStart;
|
|
1359
|
+
let rangeEnd = selectionEnd;
|
|
1360
|
+
if (rangeStart === rangeEnd) if (direction === "backward" && rangeStart > 0) rangeStart -= 1;
|
|
1361
|
+
else if (direction === "forward" && rangeEnd < documentLength) rangeEnd += 1;
|
|
1366
1362
|
else return {
|
|
1367
1363
|
nodes: normalizeChatComposerNodes(nodes),
|
|
1368
|
-
selection
|
|
1364
|
+
selection: {
|
|
1365
|
+
start: rangeStart,
|
|
1366
|
+
end: rangeEnd
|
|
1367
|
+
}
|
|
1369
1368
|
};
|
|
1370
1369
|
return {
|
|
1371
1370
|
nodes: replaceChatComposerRange(nodes, rangeStart, rangeEnd, []),
|