[fix] working editor
This commit is contained in:
parent
f31520b45c
commit
16c0a1c8c4
7 changed files with 203 additions and 50 deletions
|
|
@ -2,58 +2,27 @@
|
|||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>BaseX LSP</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"ace": "https://esm.sh/ace-builds@latest",
|
||||
"ace-linters/": "https://esm.sh/ace-linters@latest"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script type="module" src="acego.js"></script> -->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height" />
|
||||
<title>BaseX LSP Demo WIP</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ace.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-builds@latest/src-noconflict/ext-language_tools.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-linters@latest/build/ace-linters.js"></script>
|
||||
<script src="https://www.unpkg.com/ace-linters@latest/build/service-manager.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>something<button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
|
||||
<div id="editor" style="height: 100px">some text</div>
|
||||
<script type="module">
|
||||
import ace from 'ace';
|
||||
import AceLanguageClient from "https://esm.sh/ace-linters@latest/build/ace-language-client";
|
||||
|
||||
ace.config.set('basePath', 'https://esm.sh/ace-builds@latest/src-noconflict');
|
||||
const ed = ace.edit("editor", {
|
||||
mode: "ace/mode/json",
|
||||
theme: "ace/theme/github"
|
||||
});
|
||||
|
||||
|
||||
var servers = [
|
||||
{
|
||||
module: () => import("https://esm.sh/ace-linters@latest/build/language-client"),
|
||||
modes: "json",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"),
|
||||
}
|
||||
];
|
||||
let languageProvider = AceLanguageClient.for(servers);
|
||||
|
||||
ace.require("ace/ext/language_tools"); //To allow autocompletion
|
||||
var editor = ace.edit("editor", {
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
mode: "json"
|
||||
});
|
||||
|
||||
languageProvider.registerEditor(editor);
|
||||
// editor.session.setMode("astro"); // mode now contains "ace/mode/javascript".
|
||||
function foo(){
|
||||
servers[0].socket.send("TTTTT")
|
||||
alert("hi")
|
||||
}
|
||||
</script>
|
||||
<header>something
|
||||
<button onclick="opts(editor)">console</button>
|
||||
<button onclick="editor.showSettingsMenu();">Settings</button>
|
||||
<a href="/dba/logs" target="_blank">dba</a>
|
||||
</header>
|
||||
<div>
|
||||
<div id="settings" style="height: 100px">sett</div>
|
||||
<div id="editor" style="height: 100px">some text</div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue