fix: can not open external url in editor #143

This commit is contained in:
Lykin 2024-02-18 21:35:06 +08:00
parent df71ac7049
commit 29ffd83486
1 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker' import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker' import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js'
export const setupMonaco = () => { export const setupMonaco = () => {
window.MonacoEnvironment = { window.MonacoEnvironment = {
@ -40,4 +41,12 @@ export const setupMonaco = () => {
rules: [], rules: [],
colors: {}, colors: {},
}) })
// register default link opening behavior
monaco.editor.registerLinkOpener({
open(resource) {
BrowserOpenURL(resource.toString())
return true
},
})
} }