mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 15:26:36 +00:00
feat(code-editor): integrate Shiki highlighter for enhanced syntax highlighting
This commit is contained in:
parent
5ca8ef91ea
commit
fd48fa0fff
@ -8,6 +8,8 @@ import {
|
||||
import { useEffect } from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import normalizeUrl from "normalize-url";
|
||||
import { createHighlighter } from 'shiki';
|
||||
import { shikiToMonaco } from '@shikijs/monaco';
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
|
||||
const DynamicEditor = dynamic(
|
||||
@ -77,6 +79,13 @@ export default function CodeEditor() {
|
||||
defaultLanguage="c"
|
||||
defaultValue="# include<stdio.h>"
|
||||
path="file:///main.c"
|
||||
beforeMount={async (monaco) => {
|
||||
const highlighter = await createHighlighter({
|
||||
themes: ["github-light-default", "github-dark-default"],
|
||||
langs: ["c"]
|
||||
})
|
||||
shikiToMonaco(highlighter, monaco)
|
||||
}}
|
||||
onValidate={(markers) => {
|
||||
markers.forEach((marker) =>
|
||||
console.log("onValidate:", marker.message)
|
||||
|
Loading…
Reference in New Issue
Block a user