编辑器资源本地化
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,6 +18,9 @@ tsconfig.tsbuildinfo
|
|||||||
out/
|
out/
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
|
# Monaco editor local files (copied from node_modules)
|
||||||
|
public/vs
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri",
|
||||||
|
"postinstall": "cp -r node_modules/monaco-editor/min/vs public/vs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "^1.1.0",
|
"@base-ui/react": "^1.1.0",
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import type { editor as MonacoEditorNs } from "monaco-editor"
|
|||||||
import { defineMonacoThemes, useMonacoThemeSync } from "@/lib/monaco-themes"
|
import { defineMonacoThemes, useMonacoThemeSync } from "@/lib/monaco-themes"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
import "@/lib/monaco-local"
|
||||||
|
|
||||||
const MonacoDiffEditor = dynamic(
|
const MonacoDiffEditor = dynamic(
|
||||||
async () => {
|
async () => {
|
||||||
const mod = await import("@monaco-editor/react")
|
const mod = await import("@monaco-editor/react")
|
||||||
@@ -171,6 +173,8 @@ export function DiffViewer({
|
|||||||
modified={modified}
|
modified={modified}
|
||||||
language={language}
|
language={language}
|
||||||
theme={editorTheme}
|
theme={editorTheme}
|
||||||
|
keepCurrentOriginalModel
|
||||||
|
keepCurrentModifiedModel
|
||||||
beforeMount={defineMonacoThemes}
|
beforeMount={defineMonacoThemes}
|
||||||
onMount={handleEditorMount}
|
onMount={handleEditorMount}
|
||||||
loading={
|
loading={
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ interface HunkPreviewLine {
|
|||||||
marker: RowMarker
|
marker: RowMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import "@/lib/monaco-local"
|
||||||
|
|
||||||
const MonacoEditor = dynamic(async () => import("@monaco-editor/react"), {
|
const MonacoEditor = dynamic(async () => import("@monaco-editor/react"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -291,6 +291,8 @@ function setEditorHiddenAreas(
|
|||||||
hiddenAreaEditor.setHiddenAreas?.(ranges)
|
hiddenAreaEditor.setHiddenAreas?.(ranges)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import "@/lib/monaco-local"
|
||||||
|
|
||||||
const MonacoEditor = dynamic(async () => import("@monaco-editor/react"), {
|
const MonacoEditor = dynamic(async () => import("@monaco-editor/react"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import {
|
|||||||
} from "./merge-diff"
|
} from "./merge-diff"
|
||||||
import { useSyncScroll } from "./use-sync-scroll"
|
import { useSyncScroll } from "./use-sync-scroll"
|
||||||
|
|
||||||
|
import "@/lib/monaco-local"
|
||||||
|
|
||||||
const MonacoEditor = dynamic(
|
const MonacoEditor = dynamic(
|
||||||
async () => {
|
async () => {
|
||||||
const mod = await import("@monaco-editor/react")
|
const mod = await import("@monaco-editor/react")
|
||||||
|
|||||||
3
src/lib/monaco-local.ts
Normal file
3
src/lib/monaco-local.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { loader } from "@monaco-editor/react"
|
||||||
|
|
||||||
|
loader.config({ paths: { vs: "/vs" } })
|
||||||
Reference in New Issue
Block a user