Remove dead code
This commit is contained in:
parent
826b9222d3
commit
547c13b0b5
|
|
@ -258,11 +258,6 @@ export class ChatPanel {
|
|||
}
|
||||
}
|
||||
|
||||
processMessageContent(content: string): string {
|
||||
// Простейшая обработка Markdown для изображений
|
||||
return content.replace(/<img([^>]*?)>/g, '<img$1 style="max-width: 100%; height: auto;">').replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляет историю чата и перерисовывает её.
|
||||
* @param {ChatHistoryItem[]} newHistory - Новый массив элементов истории чата.
|
||||
|
|
@ -618,73 +613,6 @@ export class ChatPanel {
|
|||
selection.addRange(range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Заменяет текст на HTML элемент
|
||||
*/
|
||||
private replaceTextWithElement(match: ReferenceMatch, element: HTMLElement): void {
|
||||
const selection = window.getSelection();
|
||||
if (!selection || selection.rangeCount === 0) return;
|
||||
|
||||
// Находим текстовый узел с совпадением
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this.messageInput);
|
||||
range.setEnd(selection.focusNode!, selection.focusOffset); // Устанавливаем конец диапазона на текущую позицию курсора
|
||||
|
||||
let textBeforeMatch = '';
|
||||
let nodeBeforeMatch: Node | null = null;
|
||||
let offsetBeforeMatch = 0;
|
||||
|
||||
// Проходим по дочерним элементам до match.startIndex
|
||||
const walker = document.createTreeWalker(this.messageInput, NodeFilter.SHOW_TEXT);
|
||||
let node: Node | null;
|
||||
let currentLength = 0;
|
||||
|
||||
while ((node = walker.nextNode())) {
|
||||
const nodeText = node.textContent || '';
|
||||
if (currentLength + nodeText.length >= match.startIndex) {
|
||||
nodeBeforeMatch = node;
|
||||
offsetBeforeMatch = match.startIndex - currentLength;
|
||||
break;
|
||||
}
|
||||
currentLength += nodeText.length;
|
||||
}
|
||||
|
||||
if (!nodeBeforeMatch) {
|
||||
console.warn('Не удалось найти текстовый узел для начала замены.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Удаляем диапазон, соответствующий тексту ссылки
|
||||
const deleteRange = document.createRange();
|
||||
deleteRange.setStart(nodeBeforeMatch, offsetBeforeMatch);
|
||||
|
||||
// Расширяем диапазон удаления до конца 'fullMatch'
|
||||
let remainingLengthToDelete = match.fullMatch.length;
|
||||
let currentNode = nodeBeforeMatch;
|
||||
let currentOffset = offsetBeforeMatch;
|
||||
|
||||
while (currentNode && remainingLengthToDelete > 0) {
|
||||
const nodeText = currentNode.textContent || '';
|
||||
const canDelete = Math.min(remainingLengthToDelete, nodeText.length - currentOffset);
|
||||
remainingLengthToDelete -= canDelete;
|
||||
currentOffset += canDelete;
|
||||
|
||||
if (remainingLengthToDelete > 0) {
|
||||
// Если не всё удалено в текущем узле, переходим к следующему
|
||||
currentNode = walker.nextNode();
|
||||
currentOffset = 0; // Начинаем с начала следующего узла
|
||||
}
|
||||
}
|
||||
deleteRange.setEnd(currentNode || nodeBeforeMatch, currentOffset);
|
||||
deleteRange.deleteContents();
|
||||
|
||||
// Вставляем новый элемент на место удаленного текста
|
||||
deleteRange.insertNode(element);
|
||||
|
||||
// Очищаем выделение
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает позицию курсора в тексте
|
||||
* (теперь используем findNodesAndOffsetsForMatch для более точного определения текстового смещения)
|
||||
|
|
@ -937,22 +865,6 @@ export class ChatPanel {
|
|||
regenerateButton.addEventListener('click', async () => {
|
||||
this.props.plugin.eventBus.emit('regenerate-message', { graphId, nodeId });
|
||||
});
|
||||
|
||||
// Кнопка "Попробовать снова"
|
||||
/*const retryButton = toolsetContainer.createEl('button', {
|
||||
cls: 'text-token-text-secondary hover:bg-token-bg-secondary rounded-lg',
|
||||
attr: {
|
||||
'aria-label': 'Попробовать снова',
|
||||
'aria-pressed': 'false',
|
||||
'data-testid': 'refresh-turn-action-button',
|
||||
'data-state': 'closed',
|
||||
},
|
||||
});
|
||||
const retryIconContainer = retryButton.createSpan({ cls: 'flex items-center justify-center touch:w-10 h-8 w-8' });
|
||||
setIcon(retryIconContainer, 'refresh-cw'); // Используем импортированную функцию setIcon
|
||||
retryButton.addEventListener('click', () => {
|
||||
this.copyMessageContent(messageContent);
|
||||
});*/ // TODO: реализовать переотправку сообщения
|
||||
}
|
||||
|
||||
private copyMessageContent(content: string): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ export class ChatView extends ItemView {
|
|||
chatContainer: HTMLDivElement;
|
||||
chatPanel: ChatPanel | null;
|
||||
availableModels: string[];
|
||||
// TODO: сделать аккуратнее - добавлен таймер для обновления заголовков
|
||||
titleUpdateTimer: NodeJS.Timeout | null;
|
||||
|
||||
constructor(leaf: WorkspaceLeaf, plugin: LLMAgentPlugin) {
|
||||
super(leaf);
|
||||
|
|
@ -30,7 +28,6 @@ export class ChatView extends ItemView {
|
|||
this.currentNode = null;
|
||||
this.chatPanel = null;
|
||||
this.availableModels = [];
|
||||
this.titleUpdateTimer = null;
|
||||
}
|
||||
|
||||
getViewType(): string {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user