[mod] static folders
This commit is contained in:
parent
bf3dd4d693
commit
f1fecbdee8
16 changed files with 12 additions and 14 deletions
28
webapp/static/clients/ace/acego.js
Normal file
28
webapp/static/clients/ace/acego.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import * as aceBuilds from 'https://esm.run/ace-builds';
|
||||
|
||||
import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm'
|
||||
|
||||
/* import 'ace-builds/src-noconflict/mode-javascript';
|
||||
import 'ace-builds/src-noconflict/theme-chrome'; */
|
||||
|
||||
/* import {AceLanguageClient} from "ace-linters/build/ace-language-client";
|
||||
|
||||
const serverData = {
|
||||
module: () => import("ace-linters/build/language-client"),
|
||||
modes: "json|json5",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
|
||||
}
|
||||
*/
|
||||
// Initialize the editor
|
||||
const editor = ace.edit("editor", {
|
||||
theme: "ace/theme/chrome",
|
||||
mode: "ace/mode/javascript",
|
||||
fontSize: "14px",
|
||||
showPrintMargin: false,
|
||||
useWorker: false // Disable web worker for this simple demo
|
||||
});
|
||||
|
||||
// Create a language provider for WebSocket
|
||||
//let languageProvider = AceLanguageClient.for(serverData);
|
||||
//languageProvider.registerEditor(editor);
|
||||
41
webapp/static/clients/ace/esm.html
Normal file
41
webapp/static/clients/ace/esm.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height" />
|
||||
<title>BaseX LSP</title>
|
||||
|
||||
</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 * as ace from "https://www.unpkg.com/ace-code@latest/src-noconflict/ace.js";
|
||||
import { Mode as JSONMode } from "ace-code/src/mode/json"; //any mode you want
|
||||
import { AceLanguageClient } from "ace-linters/build/ace-language-client";
|
||||
|
||||
// Create a web socket
|
||||
const serverData = {
|
||||
module: () => import("ace-linters/build/language-client"),
|
||||
modes: "json|json5",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/exampleServer"), // address of your websocket server
|
||||
}
|
||||
// Create an Ace editor
|
||||
let editor = ace.edit("container", {
|
||||
mode: new JSONMode() // Set the mode of the editor to JSON
|
||||
});
|
||||
|
||||
// Create a language provider for web socket
|
||||
let languageProvider = AceLanguageClient.for(serverData);
|
||||
|
||||
// Register the editor with the language provider
|
||||
languageProvider.registerEditor(editor);
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
52
webapp/static/clients/ace/index copy.html
Normal file
52
webapp/static/clients/ace/index copy.html
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>BaseX LSP</title>
|
||||
<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-builds@latest/src-noconflict/ext-modelist.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/ace-language-client.js"></script>
|
||||
<script type="module" src="acego.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>
|
||||
var modelist = ace.require('ace/ext/modelist');
|
||||
if(modelist.modesByName['json'] == undefined) {
|
||||
console.log("mode doesn't exist");
|
||||
}
|
||||
var servers = [
|
||||
{
|
||||
module: () => import("XXXXXace-linters/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>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
29
webapp/static/clients/ace/index.html
Normal file
29
webapp/static/clients/ace/index.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</html>
|
||||
42
webapp/static/clients/ace/script.js
Normal file
42
webapp/static/clients/ace/script.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
ace.require("ace/ext/language_tools"); //To allow autocompletion
|
||||
var editor = ace.edit("editor", {
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
theme: "ace/theme/chrome",
|
||||
mode: "ace/mode/html",
|
||||
fontSize: "14px",
|
||||
showPrintMargin: false,
|
||||
useWorker: false // Disable web worker for this simple demo
|
||||
});
|
||||
|
||||
//ace.require('ace/ext/settings_menu');
|
||||
editor.setTheme("ace/theme/github");
|
||||
//editor.session.setMode("ace/mode/html");
|
||||
editor.commands.addCommands([
|
||||
{
|
||||
name: "showSettingsMenu",
|
||||
bindKey: {
|
||||
win: "Ctrl-q",
|
||||
mac: "Ctrl-q"
|
||||
},
|
||||
exec: function (editor) {
|
||||
editor.showSettingsMenu();
|
||||
},
|
||||
readOnly: true
|
||||
}
|
||||
]);
|
||||
var provider = LanguageProvider.fromCdn("https://www.unpkg.com/ace-linters@latest/build/");
|
||||
provider.registerEditor(editor);
|
||||
|
||||
const serverData = {
|
||||
module: () => import("https://www.unpkg.com/ace-linters@latest/build/language-client"),
|
||||
modes: "json|json5",
|
||||
type: "socket",
|
||||
socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address
|
||||
}
|
||||
|
||||
function opts(editor) {
|
||||
const modes=editor.session.$modes;
|
||||
console.log(editor.session.$modeId);
|
||||
console.log(Object.keys(modes));
|
||||
}
|
||||
33
webapp/static/clients/ace/socket.html
Normal file
33
webapp/static/clients/ace/socket.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width,height=device-height" />
|
||||
<title>BaseX LSP</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>Socket <button onclick="foo()">send</button><a href="/dba/logs" target="_blank">dba</a></div>
|
||||
<script>
|
||||
|
||||
var socket = new WebSocket("ws://127.0.0.1:3000/ws/lsp") // address of your websocket server
|
||||
// Listen for possible errors
|
||||
socket.addEventListener("error", (event) => {
|
||||
console.log("WebSocket error: ", event);
|
||||
});
|
||||
socket.addEventListener("close", (event) => {
|
||||
console.log("closed", event.code, event.reason, event.wasClean);
|
||||
});
|
||||
socket.addEventListener("open", (event) => {
|
||||
setInterval(function ping() { socket.send('{"type":"ping","msg":"staying alive"}'); }, 100000);
|
||||
socket.send('{"type":"ping","msg":"Hello Server!"}');
|
||||
});
|
||||
function foo() {
|
||||
socket.send('{"type":"ping","msg":"foo!"}');
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
7
webapp/static/clients/ace/styles.css
Normal file
7
webapp/static/clients/ace/styles.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
header {
|
||||
background-color: aqua;
|
||||
}
|
||||
.box {
|
||||
border: 2px dotted rgb(96 139 168);
|
||||
display: flex;
|
||||
}
|
||||
6
webapp/static/clients/bootstrap@5.3.7.css
vendored
Normal file
6
webapp/static/clients/bootstrap@5.3.7.css
vendored
Normal file
File diff suppressed because one or more lines are too long
106
webapp/static/clients/codemirror/index.html
Normal file
106
webapp/static/clients/codemirror/index.html
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Codemirror6 example using BaseX LSP</title>
|
||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||
<link href="../bootstrap@5.3.7.css" rel="stylesheet"
|
||||
integrity="sha384-LN+7fdVzj6u52u30Kp6M/trliBMCMKTyK833zpbD+pXdCLuTusPj697FH4R/5mcr" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand">BaseX LSP client</a>
|
||||
<a href="/dba/logs" target="dba">#</a>
|
||||
|
||||
<form class="d-flex">
|
||||
<span id="state">🔴</span>
|
||||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp" style="width:25em" />
|
||||
<button id="connect">connect</button>
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row ">
|
||||
<div class="col-2">
|
||||
something
|
||||
</div>
|
||||
<div class="col flex-grow-1">
|
||||
<div class="row">
|
||||
<div>
|
||||
<select id="language">
|
||||
<option selected>Language</option>
|
||||
<option value="plaintext">plaintext</option>
|
||||
<option value="xquery">xquery</option>
|
||||
<option value="xml">xml</option>
|
||||
</select>
|
||||
<label for="file">File:</label><input id="iFile" type="url" value="file:///some/file.xml" />
|
||||
<button id="search">🔍</button>
|
||||
<button id="lint">⚠️</button>
|
||||
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Editor goes in here -->
|
||||
|
||||
<div id="editor"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CodeMirror 6 -->
|
||||
<script src="./lsp.bundle.js"></script>
|
||||
<script>
|
||||
|
||||
let doc = `3+1`;
|
||||
// Load saved content from localStorage when the page loads
|
||||
window.addEventListener('load', () => {
|
||||
const savedText = localStorage.getItem('code');
|
||||
if (savedText) {
|
||||
doc = savedText;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const view = lsp.createEditorView(undefined, document.getElementById("editor"));
|
||||
view.setState(lsp.createEditorState(doc, lsp.baseExts));
|
||||
|
||||
// Save content to localStorage when the page is about to unload
|
||||
window.addEventListener('beforeunload', () => {
|
||||
const doc = view.state.doc.toString();
|
||||
localStorage.setItem('code', doc);
|
||||
});
|
||||
document.getElementById("connect").onclick = e => {
|
||||
connect()
|
||||
};
|
||||
document.getElementById("search").onclick = e => {
|
||||
lsp.openSearchPanel(view);
|
||||
};
|
||||
document.getElementById("lint").onclick = e => {
|
||||
lsp.openLintPanel(view);
|
||||
};
|
||||
function connect() {
|
||||
const server = document.getElementById("iServer").value;
|
||||
const file = document.getElementById("iFile").value;
|
||||
lsp.simpleWebSocketTransport(server)
|
||||
.then(transport => {
|
||||
let link = lsp.lsp(transport, file);
|
||||
const doc = view.state.doc.toString();
|
||||
const state = lsp.createEditorState(doc, [...lsp.baseExts, link]);
|
||||
view.setState(state);
|
||||
})
|
||||
.catch(r => alert("fail"));
|
||||
};
|
||||
connect();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
36684
webapp/static/clients/codemirror/lsp.bundle.js
Normal file
36684
webapp/static/clients/codemirror/lsp.bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
webapp/static/clients/codemirror/lsp.bundle.js.map
Normal file
1
webapp/static/clients/codemirror/lsp.bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
1
webapp/static/clients/codemirror/lsp.bundle.min.js
vendored
Normal file
1
webapp/static/clients/codemirror/lsp.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
webapp/static/clients/codemirror/styles.css
Normal file
15
webapp/static/clients/codemirror/styles.css
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Set editor dimensions */
|
||||
#editor {
|
||||
height: 400px;
|
||||
|
||||
}
|
||||
|
||||
/* Stretch editor to fit inside its containing div */
|
||||
.cm-editor {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
/* header */
|
||||
nav {
|
||||
background-color: burlywood!;
|
||||
}
|
||||
BIN
webapp/static/clients/favicon.png
Normal file
BIN
webapp/static/clients/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Loading…
Add table
Add a link
Reference in a new issue