[mod] outline

This commit is contained in:
Andy Bunce 2025-10-30 18:39:12 +00:00
parent fc56a3d505
commit 559828340e
3 changed files with 28 additions and 16 deletions

View file

@ -143,7 +143,18 @@
</details>
<details id="symPanel">
<summary>OutLine <i class='codicon codicon-kebab-vertical' style="float:right"></i></summary>
<summary>OutLine
<quiet-dropdown id="dropdown__checkboxes" style="display:inline-block;float:right;">
<quiet-icon name="dots-vertical" slot="trigger"></quiet-icon>
<quiet-dropdown-item type="checkbox" value="canvas" checked>Follow cursor</quiet-dropdown-item>
<quiet-divider></quiet-divider>
<quiet-dropdown-item type="checkbox" value="position" checked>sort by:
Position</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="name">sort by: Name</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="category">sort by: Category</quiet-dropdown-item>
</quiet-dropdown>
</summary>
<qd-list id="symList" style="flex-grow:1;"></qd-list>
</details>
@ -165,7 +176,8 @@
</select>
<div>
<label for="iFile">File:</label>
<input id="iFile" type="url" value="file:///some/file.xqm" style="width:10em;display:inline-block;" />
<input id="iFile" type="url" value="file:///some/file.xqm"
style="width:10em;display:inline-block;" />
<label for="symbols">Symbols:</label>
<select id="symbols" disabled="disabled" style="width:10em;display:inline-block;"></select>
@ -180,8 +192,6 @@
<quiet-dropdown-item type="checkbox" value="position" checked>sort by: Position</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="name">sort by: Name</quiet-dropdown-item>
<quiet-dropdown-item type="checkbox" value="category">sort by: Category</quiet-dropdown-item>
</quiet-dropdown>

View file

@ -1,10 +1,11 @@
const view = new lsp.EditorView({
extensions: lsp.baseExts,
parent: document.getElementById("editor")
});
let doc = "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n";
var client; // https://codemirror.net/docs/ref/#lsp-client
var extLsp; // https://codemirror.net/docs/ref/#lsp-client.LSPPlugin
var workspace = {
"file:///some/file.xqm": null
};
@ -68,14 +69,15 @@ $("cmdList").onclick = e => {
});
$("popHelpInfo").innerHTML = `<ul>${result}</ul>`
$("popCmds").showPopover()
};
$("symList").addEventListener("itemSelected", e => {
const sel = e.detail.selectionRange;
const plugin=lsp.LSPPlugin.get(view)
if(!plugin) return;
const sel = e.detail.range // or selectionRange;
console.log("SYM selection range", sel);
const an = extLsp.fromPosition(sel.start)
const hd = extLsp.fromPosition(sel.end)
const an = plugin.fromPosition(sel.start)
const hd = plugin.fromPosition(sel.end)
view.dispatch({ selection: { anchor: an, head: hd}, scrollIntoView: true });
});
@ -159,7 +161,7 @@ function connect() {
client.connect(transport);
$("popConnect").hidePopover();
$("tConnect").checked=true;
extLsp = client.plugin(file, "xquery");
const extLsp = client.plugin(file, "xquery");
view.dispatch({
effects: lsp.StateEffect.appendConfig.of(