diff --git a/code-editor/bun.lockb b/code-editor/bun.lockb index 8e46a51..0b2d609 100755 Binary files a/code-editor/bun.lockb and b/code-editor/bun.lockb differ diff --git a/code-editor/src/App.tsx b/code-editor/src/App.tsx index 2a8d28b..284c505 100644 --- a/code-editor/src/App.tsx +++ b/code-editor/src/App.tsx @@ -4,6 +4,7 @@ import { DEFAULT_EDITOR_LANGUAGE, } from "@/config"; import { useState } from "react"; +import * as monaco from "monaco-editor"; import { highlighter } from "@/lib/shiki"; import { Bot, CodeXml } from "lucide-react"; import { shikiToMonaco } from "@shikijs/monaco"; @@ -31,7 +32,7 @@ function App() { strokeWidth={2} aria-hidden="true" /> - Code + 代码 - + { shikiToMonaco(await highlighter, monaco); }} + onMount={( + editor: monaco.editor.IStandaloneCodeEditor, + monaco: Monaco + ) => { + const value = editor.getModel()?.getValue(); + if (value !== undefined) { + window.parent.postMessage( + { type: "editor-info", language, code: value }, + "*" + ); + } + }} onChange={(value) => { if (value !== undefined) { window.parent.postMessage( @@ -68,13 +93,24 @@ function App() { }} /> - + { shikiToMonaco(await highlighter, monaco); }}