[mod] tidy
This commit is contained in:
parent
b0e18a87ac
commit
529b57d628
8 changed files with 19 additions and 29 deletions
|
@ -1,6 +1,5 @@
|
||||||
import module namespace hnd="lsp/handlers" at "../webapp/lsp/handlers.xqm";
|
import module namespace lsp-diags = 'lsp-diags' at "../webapp/lsp/providers/diagnostics.xqm";
|
||||||
import module namespace syms="lsp/symbols" at "../webapp/lsp/providers/documentSymbols.xqm";
|
|
||||||
declare variable $src:="sample.docs/parse-pdfbox.xml";
|
declare variable $src:="sample.docs/parse-pdfbox.xml";
|
||||||
declare variable $parse:=doc($src)/*;
|
declare variable $parse:=doc($src)/*;
|
||||||
|
declare variable $text:=unparsed-text("sample.docs/pdfbox3-bad.xqm");
|
||||||
hnd:diags($parse )
|
lsp-diags:list("file",$text,$parse )
|
||||||
|
|
|
@ -34,7 +34,7 @@ declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||||
|
|
||||||
declare namespace RandomAccessReadBuffer="java:org.apache.pdfbox.io.RandomAccessReadBuffer";
|
declare namespace RandomAccessReadBuffer="java:org.apache.pdfbox.io.RandomAccessReadBuffer";
|
||||||
declare namespace RandomAccessReadBufferedFile = "java:org.apache.pdfbox.io.RandomAccessReadBufferedFile";
|
declare namespace RandomAccessReadBufferedFile = "java:org.apache.pdfbox.io.RandomAccessReadBufferedFile";
|
||||||
declare namespace PDRectangle="org.apache.pdfbox.pdmodel.common.PDRectangle";
|
declare namespace PDRectangle="java:org.apache.pdfbox.pdmodel.common.PDRectangle";
|
||||||
|
|
||||||
declare namespace File ="java:java.io.File";
|
declare namespace File ="java:java.io.File";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
xquery version '3.1';
|
xquery version '3.1';
|
||||||
(:~
|
(:~
|
||||||
|
A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ ,
|
||||||
requires pdfbox jars on classpath, in lib/custom or xar
|
requires pdfbox jars on classpath, in lib/custom or xar
|
||||||
@note following the java source the terms outline and bookmark
|
@note following the java source the terms outline and bookmark
|
||||||
refer to the same concept. Also label and (page)range are used interchangably
|
refer to the same concept. Also label and (page)range are used interchangably
|
||||||
|
@ -286,8 +287,7 @@ as map(*)*{
|
||||||
=>PDDocumentCatalog:getDocumentOutline()
|
=>PDDocumentCatalog:getDocumentOutline()
|
||||||
|
|
||||||
return if(exists($outline))
|
return if(exists($outline))
|
||||||
then pdfbox:outline($pdf,PDOutlineItem:getFirstChild($outline))
|
then pdfbox:outline($pdf,PDOutlineItem:getFirstChild($outline))
|
||||||
else ()
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -364,7 +364,6 @@ as item()?
|
||||||
then PDDocument:getDocumentCatalog($pdf)
|
then PDDocument:getDocumentCatalog($pdf)
|
||||||
=>PDDocumentCatalog:getPages()
|
=>PDDocumentCatalog:getPages()
|
||||||
=>PDPageTree:indexOf($page)
|
=>PDPageTree:indexOf($page)
|
||||||
else ()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
(:~ Return new PDF doc with pages from $start to $end as xs:base64Binary, (1 based)
|
(:~ Return new PDF doc with pages from $start to $end as xs:base64Binary, (1 based)
|
||||||
|
@ -436,7 +435,7 @@ as xs:string?{
|
||||||
return string-join(($page,
|
return string-join(($page,
|
||||||
if(empty($style)) then "-" else $style,
|
if(empty($style)) then "-" else $style,
|
||||||
if(($start eq 1)) then "" else $start,
|
if(($start eq 1)) then "" else $start,
|
||||||
if(exists($prefix)) then '*' || $prefix else () (:TODO double " :)
|
if(exists($prefix)) then '*' || $prefix (:TODO double " :)
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@ import module namespace docs="lsp/docs" at "docs.xqm";
|
||||||
import module namespace rpc = 'rpc' at 'jsonrpc.xqm';
|
import module namespace rpc = 'rpc' at 'jsonrpc.xqm';
|
||||||
import module namespace lspt = 'lsp-typedefs' at 'lsp-typedefs.xqm';
|
import module namespace lspt = 'lsp-typedefs' at 'lsp-typedefs.xqm';
|
||||||
import module namespace pos="lsp/position" at "position.xqm";
|
import module namespace pos="lsp/position" at "position.xqm";
|
||||||
|
import module namespace syms="lsp/symbols" at "providers/documentSymbols.xqm";
|
||||||
|
|
||||||
declare variable $lsp-text:methods:=map{
|
declare variable $lsp-text:methods:=map{
|
||||||
"textDocument/didOpen": lsp-text:didOpen#1,
|
"textDocument/didOpen": lsp-text:didOpen#1,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import module namespace hnd="lsp/handlers" at "../handlers.xqm";
|
||||||
import module namespace lspt = 'lsp-typedefs' at "../lsp-typedefs.xqm";
|
import module namespace lspt = 'lsp-typedefs' at "../lsp-typedefs.xqm";
|
||||||
|
|
||||||
declare function syms:list($parse as element(),$syms as lspt:DocumentSymbol* :=() )
|
declare function syms:list($parse as element(),$syms as lspt:DocumentSymbol* :=() )
|
||||||
{
|
as lspt:DocumentSymbol*{
|
||||||
let $actions as hnd:actionMap :={
|
let $actions as hnd:actionMap :={
|
||||||
"ContextValueDecl": syms:action#2,
|
"ContextValueDecl": syms:action#2,
|
||||||
"VarDecl": syms:VarDecl#2,
|
"VarDecl": syms:VarDecl#2,
|
||||||
|
@ -18,6 +18,7 @@ declare function syms:list($parse as element(),$syms as lspt:DocumentSymbol* :=(
|
||||||
return $result?result
|
return $result?result
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(:~ just trace :)
|
||||||
declare function syms:action($parse as element(),$state as hnd:Result )
|
declare function syms:action($parse as element(),$state as hnd:Result )
|
||||||
as hnd:Result{
|
as hnd:Result{
|
||||||
hnd:Result($state?result,true()) ,message(name($parse),"ACTION: ")
|
hnd:Result($state?result,true()) ,message(name($parse),"ACTION: ")
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
<button type="button" class="btn-close" aria-label="Close"
|
<button type="button" class="btn-close" aria-label="Close"
|
||||||
onclick="$('popHelp').hidePopover(); "></button>
|
onclick="$('popHelp').hidePopover(); "></button>
|
||||||
</header>
|
</header>
|
||||||
<div id=popHelpInfo" class="modal-body">
|
<div id="popHelpInfo" class="modal-body">
|
||||||
TODO
|
TODO
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -30,18 +30,7 @@ class ListComponent extends HTMLElement {
|
||||||
get data() {
|
get data() {
|
||||||
return this.#data;
|
return this.#data;
|
||||||
}
|
}
|
||||||
select(e) {
|
|
||||||
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
|
|
||||||
e.currentTarget.className = 'selected';
|
|
||||||
console.log('Item clicked:', item, listItem);
|
|
||||||
// You can dispatch a custom event here if needed.
|
|
||||||
this.dispatchEvent(new CustomEvent('itemSelected', {
|
|
||||||
detail: item,
|
|
||||||
bubbles: true,
|
|
||||||
composed: true
|
|
||||||
}));
|
|
||||||
|
|
||||||
}
|
|
||||||
/* Render the list items #data */
|
/* Render the list items #data */
|
||||||
render() {
|
render() {
|
||||||
const list = document.createElement('ul');
|
const list = document.createElement('ul');
|
||||||
|
@ -52,10 +41,10 @@ class ListComponent extends HTMLElement {
|
||||||
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
|
this.#shadow.querySelectorAll('li.selected').forEach(item => { item.className = ''; });
|
||||||
e.currentTarget.className = 'selected';
|
e.currentTarget.className = 'selected';
|
||||||
const i=e.currentTarget.getAttribute("data-index")
|
const i=e.currentTarget.getAttribute("data-index")
|
||||||
console.log('Item index clicked:', i);
|
console.log('Item index clicked:', i,this.#data[i]);
|
||||||
// You can dispatch a custom event here if needed.
|
// You can dispatch a custom event here if needed.
|
||||||
this.dispatchEvent(new CustomEvent('itemSelected', {
|
this.dispatchEvent(new CustomEvent('itemSelected', {
|
||||||
detail: i,
|
detail: this.#data[i],
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
composed: true
|
composed: true
|
||||||
}));
|
}));
|
||||||
|
@ -76,7 +65,8 @@ class ListComponent extends HTMLElement {
|
||||||
const style = document.createElement('style');
|
const style = document.createElement('style');
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
@import url("../codicon@0.0.40/codicon.css");
|
@import url("../codicon@0.0.40/codicon.css");
|
||||||
ul { list-style-type: none; padding:0;margin:0; }
|
ul { list-style-type: none; padding:0;margin:0;max-height:80cqh;overflow: auto;
|
||||||
|
background-color: #f8f9fa;font-size: 80%;}
|
||||||
li { padding: 0 0 0 2px; border-bottom: 1px solid #ccc; cursor: pointer; width:100%; }
|
li { padding: 0 0 0 2px; border-bottom: 1px solid #ccc; cursor: pointer; width:100%; }
|
||||||
li:not(.selected) :hover { background-color: #ccc; }
|
li:not(.selected) :hover { background-color: #ccc; }
|
||||||
.selected { background-color: #0d6efd;color: #ffff;}
|
.selected { background-color: #0d6efd;color: #ffff;}
|
||||||
|
|
|
@ -93,9 +93,9 @@ $("cmd").onclick = e => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$("symList").onclick = e => {
|
$("symList").addEventListener("itemSelected", e => {
|
||||||
console.log("SYM CLICK");
|
console.log("SYM itemSelected",e.detail);
|
||||||
};
|
});
|
||||||
|
|
||||||
$("lint").onclick = async e => {
|
$("lint").onclick = async e => {
|
||||||
console.log("word", view.state.wordAt(1));
|
console.log("word", view.state.wordAt(1));
|
||||||
|
|
Loading…
Add table
Reference in a new issue