From 2edfde1990de7fd6bf5b5c5c56342f247b92c289 Mon Sep 17 00:00:00 2001 From: Shirasawa <764798966@qq.com> Date: Mon, 22 Sep 2025 16:00:46 +0800 Subject: [PATCH] feat: only retain one language supports for highlight.js to reduce bundle size --- src/lib/components/common/RichTextInput.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 468813aeaf..83f2c55133 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -139,7 +139,9 @@ import FormattingButtons from './RichTextInput/FormattingButtons.svelte'; import { PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants'; - import { all, createLowlight } from 'lowlight'; + import { createLowlight } from 'lowlight'; + import hljs from 'highlight.js'; + import type { SocketIOCollaborationProvider } from './RichTextInput/Collaboration'; export let oncompositionstart = (e) => {}; @@ -147,7 +149,10 @@ export let onChange = (e) => {}; // create a lowlight instance with all languages loaded - const lowlight = createLowlight(all); + const lowlight = createLowlight(hljs.listLanguages().reduce((obj, lang) => { + obj[lang] = () => hljs.getLanguage(lang); + return obj; + }, {} as Record)); export let editor: Editor | null = null;