diff --git a/frontend/package.json b/frontend/package.json index a1ce7f9..1857eeb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,6 +17,7 @@ "dependencies": { "@fontsource/roboto": "^5.2.10", "@mdi/font": "7.4.47", + "highlight.js": "^11.11.1", "markdown-it": "^14.3.0", "pinia": "^3.0.4", "vue": "^3.5.30", diff --git a/frontend/src/components/category/CreateCategoryDialog.vue b/frontend/src/components/category/CreateCategoryDialog.vue new file mode 100644 index 0000000..1617834 --- /dev/null +++ b/frontend/src/components/category/CreateCategoryDialog.vue @@ -0,0 +1,90 @@ + + + diff --git a/frontend/src/composables/useMarkdown.ts b/frontend/src/composables/useMarkdown.ts new file mode 100644 index 0000000..d464e68 --- /dev/null +++ b/frontend/src/composables/useMarkdown.ts @@ -0,0 +1,30 @@ +import MarkdownIt from 'markdown-it' +import hljs from 'highlight.js' + +// Déclaré hors de la fonction = instancié une seule fois pour toute l'application +const md = new MarkdownIt({ + html: false, + linkify: true, + typographer: true, + breaks: true, +}) + +md.set({ + highlight: (str: string, lang: string): string => { + if (lang && hljs.getLanguage(lang)) { + try { + return `
${hljs.highlight(str, {
+          language: lang,
+          ignoreIllegals: true
+        }).value}
` + } catch (__) { + } + } + return `
${md.utils.escapeHtml(str)}
` + } +}) + +export function useMarkdown() { + const renderMarkdown = (content: string) => md.render(content) + return {renderMarkdown} +} \ No newline at end of file diff --git a/frontend/src/pages/server/channel/index.vue b/frontend/src/pages/server/channel/index.vue index 046f9f5..05c5d77 100644 --- a/frontend/src/pages/server/channel/index.vue +++ b/frontend/src/pages/server/channel/index.vue @@ -1,10 +1,11 @@