fix(ai): prevent marked parse error from crashing chat during streaming

This commit is contained in:
t8y2
2026-06-18 10:30:28 +08:00
parent f1b8579994
commit 03e5e27c79
2 changed files with 6 additions and 8 deletions
@@ -858,7 +858,11 @@ const markedInstance = new Marked({
});
function formatInlineText(text: string): string {
return markedInstance.parse(text) as string;
try {
return markedInstance.parse(text) as string;
} catch {
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
}
const messageRenderer = computed(() => {
@@ -4024,12 +4024,6 @@ const canvasEditingCell = computed(() => {
return { rowIndex, visibleColIdx, actualColIdx: editing.col, rect };
});
const canvasSingleSelectedCell = computed(() => {
const range = selectedRange.value;
if (!range || range.startRow !== range.endRow || range.startCol !== range.endCol) return null;
return { rowIndex: range.startRow, visibleColIdx: range.startCol };
});
function canvasEffectiveViewportWidth(): number {
return canvasViewportWidth.value || canvasScrollerElement()?.clientWidth || 0;
}
@@ -6335,7 +6329,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
<div v-if="whereSuggestions.length > 0" class="fixed z-50 min-w-[180px] rounded-md border bg-popover text-popover-foreground shadow-md" :style="whereSuggestionStyle">
<div
v-for="(sug, idx) in whereSuggestions"
:key="`${sug.kind}:${sug.value}`"
:key="`${sug.kind}:${sug.value}`"
class="flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer"
:class="idx === whereSuggestionIndex ? 'bg-accent text-accent-foreground' : 'hover:bg-gray-200 dark:hover:bg-gray-800'"
@mousedown.prevent="