diff --git a/src/lib/common/markdown/Markdown.svelte b/src/lib/common/markdown/Markdown.svelte index e3950a20..aa6eb7ba 100644 --- a/src/lib/common/markdown/Markdown.svelte +++ b/src/lib/common/markdown/Markdown.svelte @@ -21,8 +21,7 @@ /** @type {boolean} */ export let scrollable = false; - const scrollbarId = uuidv4(); - + const scrollbarId = `markdown-scrollbar-${uuidv4()}`; const options = { scrollbars: { visibility: 'auto', @@ -42,7 +41,7 @@ }); function initScrollbar() { - const elem = document.querySelector(`#markdown-scrollbar-${scrollbarId}`); + const elem = document.querySelector(`#${scrollbarId}`); if (elem) { // @ts-ignore const scrollbar = OverlayScrollbars(elem, options); @@ -65,7 +64,7 @@
diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 61f970bf..46bf4ba6 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -27,7 +27,8 @@ const richType = { Button: 'button_template', MultiSelect: 'multi-select_template', Generic: 'generic_template', - Upload: 'upload_template' + Upload: 'upload_template', + ProgramCode: 'program_code', } export const RichType = Object.freeze(richType); diff --git a/src/lib/helpers/http.js b/src/lib/helpers/http.js index 772494bc..0a57a962 100644 --- a/src/lib/helpers/http.js +++ b/src/lib/helpers/http.js @@ -212,7 +212,7 @@ export function replaceNewLine(text) { * @returns {string} */ export function replaceMarkdown(text) { - let res = text.replace(/#([\s]+)/g, '\\# ').replace(/[-|=]{3,}/g, ''); + let res = text.replace(/#([\s]+)/g, '\\# ').replace(/[-|=]{3,}/g, '@@@'); let regex1 = new RegExp('\\*(.*)\\*', 'g'); let regex2 = new RegExp('\\*([\\*]+)\\*', 'g'); diff --git a/src/lib/helpers/types/conversationTypes.js b/src/lib/helpers/types/conversationTypes.js index cfda9e15..4f482951 100644 --- a/src/lib/helpers/types/conversationTypes.js +++ b/src/lib/helpers/types/conversationTypes.js @@ -105,6 +105,16 @@ IRichContent.prototype.elements; */ IRichContent.prototype.quick_replies; +/** + * The language of the code rich content. + * + * @name language + * @type {string} + * @instance + */ +IRichContent.prototype.language; + + /** * @typedef {Object} TextMessage * @property {string} text diff --git a/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-js-interpreter.svelte b/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-js-interpreter.svelte new file mode 100644 index 00000000..56057155 --- /dev/null +++ b/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-js-interpreter.svelte @@ -0,0 +1,105 @@ + + +
+ {#if message?.text} +
{message.text}
+ {/if} +
+
+
+
\ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte b/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte index 47f0ab42..1367aee5 100644 --- a/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte @@ -1,7 +1,9 @@ -
-
- +{#if text} +
+
+ {#if message?.rich_content?.message?.rich_type === RichType.ProgramCode + && message?.rich_content?.message?.language === 'javascript'} + + {:else} + + {/if} +
-
\ No newline at end of file +{/if} \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte b/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte index 5db267eb..6b1792c3 100644 --- a/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte @@ -48,11 +48,11 @@ } + + {#if message?.rich_content?.editor === EditorType.File} handleConfirm(title, payload)} /> -{/if} - -{#if message?.rich_content?.editor !== EditorType.File} +{:else} {#if !isComplexElement} handleConfirm(title, payload)} /> {:else}