Merge pull request #169 from andzejsp/main

More bugfixes
This commit is contained in:
Saifeddine ALOUI 2023-05-10 12:16:01 +02:00 committed by GitHub
commit 3ccb003758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 72 deletions

1
web/dist/assets/index-6cb502cf.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GPT4All - WEBUI</title>
<script type="module" crossorigin src="/assets/index-559a76be.js"></script>
<link rel="stylesheet" href="/assets/index-c63da122.css">
<script type="module" crossorigin src="/assets/index-9638e0a4.js"></script>
<link rel="stylesheet" href="/assets/index-6cb502cf.css">
</head>
<body>
<div id="app"></div>

View File

@ -1,89 +1,101 @@
<template>
<div>
<div v-html="renderedMarkdown" class=""></div>
</div>
</template>
<div>
<div v-html="renderedMarkdown" class=""></div>
</div>
</template>
<script>
import MarkdownIt from 'markdown-it';
import emoji from 'markdown-it-emoji';
import hljs from 'highlight.js';
export default {
props: {
markdownText: {
type: String,
required: true
<script>
import MarkdownIt from 'markdown-it';
import emoji from 'markdown-it-emoji';
import hljs from 'highlight.js';
export default {
name: 'MarkdownRenderer',
props: {
markdownText: {
type: String,
required: true
}
},
data() {
return {
renderedMarkdown: ''
};
},
mounted() {
const markdownIt = new MarkdownIt({
html: false, // Enable HTML tags in source
xhtmlOut: true, // Use '/' to close single tags (<br />).
// This is only for full CommonMark compatibility.
breaks: true, // Convert '\n' in paragraphs into <br>
// langPrefix: 'language-', // CSS language prefix for fenced blocks. Can be
// useful for external highlighters.
linkify: true, // Autoconvert URL-like text to links
// Enable some language-neutral replacement + quotes beautification
// For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js
typographer: true,
highlight: (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return (
'<pre class="hljs rounded-lg dark:bg-bg-dark-code-block bg-bg-light-code-block shadow-lg"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>'
);
} catch (__) { }
}
return (
'<pre class="hljs rounded-lg dark:bg-bg-dark-code-block bg-bg-light-code-block shadow-lg"><code>' +
markdownIt.utils.escapeHtml(str) +
'</code></pre>'
);
}
},
data() {
return {
renderedMarkdown: ''
};
},
mounted() {
}).use(emoji);
this.renderedMarkdown = markdownIt.render(this.markdownText);
},
watch: {
markdownText(newText) {
const markdownIt = new MarkdownIt({
highlight: (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return (
'<pre class="hljs rounded-lg dark:bg-primary shadow-lg"><code>' +
'<pre class="hljs rounded-lg dark:bg-bg-dark-code-block bg-bg-light-code-block shadow-lg"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>'
);
} catch (__) {}
} catch (__) { }
}
return (
'<pre class="hljs rounded-lg dark:bg-primary shadow-lg"><code>' +
'<pre class="hljs rounded-lg dark:bg-bg-dark-code-block bg-bg-light-code-block shadow-lg"><code>' +
markdownIt.utils.escapeHtml(str) +
'</code></pre>'
);
}
}).use(emoji);
this.renderedMarkdown = markdownIt.render(this.markdownText);
},
watch: {
markdownText(newText) {
const markdownIt = new MarkdownIt({
highlight: (str, lang) => {
if (lang && hljs.getLanguage(lang)) {
try {
return (
'<pre class="hljs rounded-lg dark:bg-primary shadow-lg"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>'
);
} catch (__) {}
}
return (
'<pre class="hljs rounded-lg dark:bg-primary shadow-lg"><code>' +
markdownIt.utils.escapeHtml(str) +
'</code></pre>'
);
}
}).use(emoji);
this.renderedMarkdown = markdownIt.render(newText);
}
this.renderedMarkdown = markdownIt.render(newText);
}
};
</script>
<style>
/* Add styles for code highlighting */
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #f5f5f5;
}
};
</script>
.hljs code {
display: inline;
padding: 0;
border: none;
background: none;
}
</style>
<style>
/* Add styles for code highlighting */
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #f5f5f5;
}
.hljs code {
display: inline;
padding: 0;
border: none;
background: none;
}
</style>

View File

@ -13,7 +13,7 @@
</div>
<div class="-mt-4 ml-10 mr-0 pt-1 px-2 ">
<!-- CONTENT/MESSAGE -->
<markdown-renderer v-if="!editMsgMode" :markdown-text="message.content"></markdown-renderer>
<MarkdownRenderer v-if="!editMsgMode" :markdown-text="message.content"></MarkdownRenderer>
<textarea v-if="editMsgMode" rows="4"
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Enter message here..." v-model="new_message_content"></textarea>

View File

@ -12,8 +12,10 @@ module.exports = {
"bg-dark": "#132e59",
"bg-dark-tone": "#25477d",
"bg-dark-tone-panel": "#4367a3",
"bg-dark-code-block": "#2254a7",
"bg-light": "#e2edff",
"bg-light-tone": "#b9d2f7",
"bg-light-code-block": "#cad7ed",
"bg-light-tone-panel": "#8fb5ef",
"bg-dark-discussion": "#435E8A",
"bg-dark-discussion-odd": "#284471",