Добавить SHiNE теги в DM и безопасный рендер превью

This commit is contained in:
AidarKC
2026-07-10 18:57:44 +04:00
parent 076b43e542
commit 0d2d7b6dc5
10 changed files with 358 additions and 18 deletions
+8 -4
View File
@@ -20,6 +20,7 @@ import { startOutgoingCall } from '../services/call-service.js';
import { openSpeechInputModal } from '../components/speech-input-modal.js';
import { isSpeechToTextConfigured, isTextToSpeechConfigured, speakTextBySettings } from '../services/speech-tools-service.js';
import { showToast } from '../services/channels-ux.js';
import { parseDmTechBlocks, sanitizeUserDmTextForSend } from '../services/dm-tech-blocks.js';
export const pageMeta = { id: 'chat-view', title: 'Чат' };
const CONVERSATION_CLEAR_NOTICE_TEXT = 'История переписки очищена с этого места';
@@ -483,12 +484,14 @@ function renderLog(list, chatId, { onOpenActions, markAsRead = true, scrollMode
}
const bubble = document.createElement('div');
const bubbleKind = String(msg?.kind || '').trim();
const parsedText = parseDmTechBlocks(String(msg?.text || ''));
const autoKind = parsedText.callSummary ? 'call-tech' : '';
const bubbleKind = String(msg?.kind || autoKind || '').trim();
bubble.className = `bubble ${msg.from}${bubbleKind ? ` ${bubbleKind}` : ''}`;
const textNode = document.createElement('div');
textNode.className = 'bubble-text';
textNode.textContent = msg.text || '';
textNode.textContent = parsedText.displayText || '';
bubble.append(textNode);
const metaNode = document.createElement('div');
@@ -582,7 +585,8 @@ export function render({ navigate, route }) {
showTtsMissingConfigDialog(navigate);
return;
}
await speakTextBySettings(String(msg?.text || ''), state.entrySettings);
const parsedText = parseDmTechBlocks(String(msg?.text || ''));
await speakTextBySettings(String(parsedText.displayText || ''), state.entrySettings);
};
const handleStartCall = async () => {
@@ -888,7 +892,7 @@ export function render({ navigate, route }) {
};
const sendTextMessage = async (rawText) => {
const text = String(rawText || '').trim();
const text = sanitizeUserDmTextForSend(String(rawText || '')).trim();
if (!text) return;
const editing = activeEdit;
const tempId = editing ? '' : addOutgoingPendingMessage(chatId, text);