diff --git a/frontend/package.json b/frontend/package.json index dab34cc4e8c..9f8aca23f02 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,6 +19,7 @@ "file-saver": "^2.0.5", "he": "^1.2.0", "highlight.js": "^11.9.0", + "highlightjs-svelte": "^1.0.6", "i18next": "^23.11.3", "i18next-browser-languagedetector": "^7.2.1", "js-levenshtein": "^1.1.6", @@ -75,4 +76,4 @@ "tailwindcss": "^3.3.1", "vite": "^4.3.0" } -} \ No newline at end of file +} diff --git a/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx b/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx index cfaffc43535..3d94297a4ce 100644 --- a/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx +++ b/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedChats/MarkdownRenderer.jsx @@ -1,9 +1,11 @@ import { useState } from "react"; import MarkdownIt from "markdown-it"; import hljs from "highlight.js"; +import hljs_svelte from "highlightjs-svelte"; import { CaretDown } from "@phosphor-icons/react"; import "highlight.js/styles/github-dark.css"; import DOMPurify from "@/utils/chat/purify"; +hljs_svelte(hljs); const md = new MarkdownIt({ html: true, diff --git a/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx b/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx index 07418ceb1e5..717095f14b7 100644 --- a/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx +++ b/frontend/src/pages/GeneralSettings/ChatEmbedWidgets/EmbedConfigs/EmbedRow/CodeSnippetModal/index.jsx @@ -2,8 +2,10 @@ import React, { useState } from "react"; import { CheckCircle, CopySimple, X } from "@phosphor-icons/react"; import showToast from "@/utils/toast"; import hljs from "highlight.js"; +import hljs_svelte from "highlightjs-svelte"; import "@/utils/chat/themes/github-dark.css"; import "@/utils/chat/themes/github.css"; +hljs_svelte(hljs); export default function CodeSnippetModal({ embed, closeModal }) { return ( diff --git a/frontend/src/pages/GeneralSettings/Chats/MarkdownRenderer.jsx b/frontend/src/pages/GeneralSettings/Chats/MarkdownRenderer.jsx index cfaffc43535..3d94297a4ce 100644 --- a/frontend/src/pages/GeneralSettings/Chats/MarkdownRenderer.jsx +++ b/frontend/src/pages/GeneralSettings/Chats/MarkdownRenderer.jsx @@ -1,9 +1,11 @@ import { useState } from "react"; import MarkdownIt from "markdown-it"; import hljs from "highlight.js"; +import hljs_svelte from "highlightjs-svelte"; import { CaretDown } from "@phosphor-icons/react"; import "highlight.js/styles/github-dark.css"; import DOMPurify from "@/utils/chat/purify"; +hljs_svelte(hljs); const md = new MarkdownIt({ html: true, diff --git a/frontend/src/utils/chat/markdown.js b/frontend/src/utils/chat/markdown.js index 27e077a5206..bd33cad7949 100644 --- a/frontend/src/utils/chat/markdown.js +++ b/frontend/src/utils/chat/markdown.js @@ -3,9 +3,11 @@ import markdownIt from "markdown-it"; import markdownItKatexPlugin from "./plugins/markdown-katex"; import Appearance from "@/models/appearance"; import hljs from "highlight.js"; +import hljs_svelte from "highlightjs-svelte"; import "./themes/github-dark.css"; import "./themes/github.css"; import { v4 } from "uuid"; +hljs_svelte(hljs); const markdown = markdownIt({ html: Appearance.get("renderHTML") ?? false, diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 1f709c6281a..d7a5fd2c6a6 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2122,6 +2122,11 @@ highlight.js@^11.9.0: resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.10.0.tgz#6e3600dc4b33d6dc23d5bd94fbf72405f5892b92" integrity sha512-SYVnVFswQER+zu1laSya563s+F8VDGt7o35d4utbamowvUNLLMovFqwCLSocpZTz3MgaSRA1IbqRWZv97dtErQ== +highlightjs-svelte@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/highlightjs-svelte/-/highlightjs-svelte-1.0.6.tgz#e8bfc616478f8acecdef73e7e15a65b083c1ef40" + integrity sha512-aXuBPz8df3sOXg90q8rRcBLyxIR8ozPU39a6tJ2rpJUjjd9brRIr55aC0IccW4gsPhQxZ+B3rFugdXsg9/ckDw== + hoist-non-react-statics@^3.2.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" @@ -3583,7 +3588,16 @@ string-natural-compare@^3.0.1: resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4" integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -3655,7 +3669,14 @@ string.prototype.trimstart@^1.0.8: define-properties "^1.2.1" es-object-atoms "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -4196,7 +4217,16 @@ word-wrap@^1.2.5: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==