- Maximale hoogte voor AI message in ChatInput nu geldig voor zowel desktop als mobile devices.
- Correctie marked component in SideBarExplanation.vue - AI messages ondersteunen nu markdown. Markdown rendering is als een centrale utility gedefinieerd.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch, onMounted } from 'vue';
|
||||
import { useComponentTranslations } from '../js/services/LanguageProvider.js';
|
||||
import { renderMarkdown } from '../js/utils/markdownRenderer.js';
|
||||
|
||||
const props = defineProps({
|
||||
originalText: {
|
||||
@@ -44,19 +45,29 @@ const { texts: translations, isLoading, error, currentLanguage } = useComponentT
|
||||
originalTexts
|
||||
);
|
||||
|
||||
const translatedText = computed(() => translations.value?.explanation || props.originalText);
|
||||
const translatedText = computed(() => {
|
||||
const candidate = translations.value?.explanation ?? props.originalText ?? '';
|
||||
return typeof candidate === 'string' ? candidate : String(candidate ?? '');
|
||||
});
|
||||
|
||||
// Render markdown content
|
||||
// Render markdown content (defensive: always pass a string and catch errors)
|
||||
const renderedExplanation = computed(() => {
|
||||
if (!translatedText.value) return '';
|
||||
|
||||
// Use marked if available, otherwise return plain text
|
||||
if (typeof window.marked === 'function') {
|
||||
return window.marked(translatedText.value);
|
||||
} else if (window.marked && typeof window.marked.parse === 'function') {
|
||||
return window.marked.parse(translatedText.value.replace(/\[\[(.*?)\]\]/g, '<strong>$1</strong>'));
|
||||
} else {
|
||||
return translatedText.value;
|
||||
const text = translatedText.value || '';
|
||||
if (!text) return '';
|
||||
try {
|
||||
return renderMarkdown(text, {
|
||||
allowInlineHTML: false,
|
||||
enableTables: true,
|
||||
enableBreaks: true,
|
||||
enableImages: false,
|
||||
enableCodeBlocks: false,
|
||||
allowInlineCode: false,
|
||||
linkTargetBlank: true,
|
||||
sidebarAccent: true
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn('Markdown render error in SideBarExplanation, falling back to plain text:', err);
|
||||
return String(text);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user