SPARQL Studio API / SparqlEditor / SparqlEditor
Class: SparqlEditor
Defined in: sparql-editor-monaco/src/index.ts:75
Extends
EventEmitter
Constructors
Constructor
new SparqlEditor(
parent,conf?):SparqlEditor
Defined in: sparql-editor-monaco/src/index.ts:686
Parameters
parent
HTMLElement
conf?
value?
string
Initial query value.
createShareableLink?
(yasqe) => string
Show a button with which users can create a link to this query. Set this value to null to disable this functionality. By default, this feature is enabled, and the only the query value is appended to the link. ps. This function should return an object which is parseable by jQuery.param (http://api.jquery.com/jQuery.param/)
createShortLink?
(yasqe, longLink) => Promise<string>
consumeShareLink?
((yasqe) => void) | null
persistenceId?
string | ((yasqe) => string) | null
Change persistency settings for the YASQE query value. Setting the values to null, will disable persistancy: nothing is stored between browser sessions Setting the values to a string (or a function which returns a string), will store the query in localstorage using the specified string. By default, the ID is dynamically generated using the closest dom ID, to avoid collissions when using multiple YASQE items on one page
persistencyExpire?
number
showQueryButton?
boolean
requestConfig?
((yasqe) => RequestConfig<SparqlEditor>) | { queryArgument?: string | ((yasqe) => string); endpoint?: string | ((yasqe) => string); method?: "POST" | "GET" | ((yasqe) => "POST" | "GET"); acceptHeaderGraph?: string | ((yasqe) => string); acceptHeaderSelect?: string | ((yasqe) => string); acceptHeaderUpdate?: string | ((yasqe) => string); namedGraphs?: string[] | ((yasqe) => string[]); defaultGraphs?: string[] | ((yasqe) => string[]); args?: object[] | ((yasqe) => object[]); headers?: {[key: string]: string | undefined; } | ((yasqe) => object); withCredentials?: boolean | ((yasqe) => boolean); adjustQueryBeforeRequest?: false | ((yasqe) => string); }
pluginButtons?
() => HTMLElement | HTMLElement[]
resizeable?
boolean
editorHeight?
string
queryingDisabled?
string
theme?
"light" | "dark"
editorOptions?
{[key: string]: any; }
Custom Monaco editor options (IStandaloneEditorConstructionOptions), deep-merged over yasqe defaults. Use this to fully configure the editor, e.g. { lineNumbers: "off", wordWrap: "on", fontSize: 16, minimap: { enabled: true } }.
themes?
{ light?: {[key: string]: any; }; dark?: {[key: string]: any; }; }
Custom SPARQL theme overrides, deep-merged over the built-in light/dark themes. Use this to tweak editor colors, e.g. { dark: { colors: { "editor.background": "#000" } }, light: { semanticTokenColors: { keyword: "#005" } } }.
themes.light?
{[key: string]: any; }
themes.dark?
{[key: string]: any; }
languageServers?
object[]
The language servers the consumer makes available (yasqe is language server agnostic). The first is activated on load; when two or more are configured a switcher appears in the editor's right-click context menu. Servers are started lazily (the worker is resolved only when a server is first activated). When empty, the editor runs with Monarch syntax highlighting only.
getLanguageServerSettings?
(label) => Record<string, unknown> | undefined
Optional consumer-owned store for language server settings panel values, keyed by server label. When provided (e.g. by SparqlStudio, which persists them globally per server), it is the source of truth for pre-filling the settings panel and re-applying settings when a server (re)starts. Pairs with the languageServerSettingsChange event emitted when the user applies settings. When omitted, yasqe falls back to its own local-storage persistence.
Returns
SparqlEditor
Properties
rootEl
rootEl:
HTMLDivElement
Defined in: sparql-editor-monaco/src/index.ts:115
storage
storage:
Storage
Defined in: sparql-editor-monaco/src/index.ts:116
config
config:
Config
Defined in: sparql-editor-monaco/src/index.ts:117
persistentConfig?
optionalpersistentConfig?:PersistentConfig
Defined in: sparql-editor-monaco/src/index.ts:118
queryValid
queryValid:
boolean=true
Defined in: sparql-editor-monaco/src/index.ts:119
lastQueryDuration?
optionallastQueryDuration?:number
Defined in: sparql-editor-monaco/src/index.ts:120
languageClientWrapper?
optionallanguageClientWrapper?:LanguageClientWrapper
Defined in: sparql-editor-monaco/src/index.ts:121
vscodeApi?
optionalvscodeApi?:MonacoVscodeApiWrapper
Defined in: sparql-editor-monaco/src/index.ts:122
editor?
optionaleditor?:IStandaloneCodeEditor
Defined in: sparql-editor-monaco/src/index.ts:123
ready
ready:
Promise<void>
Defined in: sparql-editor-monaco/src/index.ts:125
Resolves once the Monaco editor has finished initializing (rejects if init fails).
activeLanguageServerIndex
activeLanguageServerIndex:
number=-1
Defined in: sparql-editor-monaco/src/index.ts:127
Index of the active language server in config.languageServers, or -1 when none is active.
Sparql
staticSparql:object
Defined in: sparql-editor-monaco/src/index.ts:1285
Statics
executeQuery
executeQuery: (
editor,config?) =>Promise<any>
Parameters
editor
config?
Returns
Promise<any>
getAjaxConfig
getAjaxConfig: (
editor,_config?) =>PopulatedAjaxConfig|undefined
Parameters
editor
_config?
Returns
PopulatedAjaxConfig | undefined
getUrlArguments
getUrlArguments: (
yasqe,_config?) =>RequestArgs
Parameters
yasqe
_config?
Returns
getAcceptHeader
getAcceptHeader: (
yasqe,_config?) =>string
Parameters
yasqe
_config?
Returns
string
getAsCurlString
getAsCurlString: (
yasqe,_config?) =>string
Parameters
yasqe
_config?
Returns
string
defaults
staticdefaults:object
Defined in: sparql-editor-monaco/src/index.ts:1290
requestConfig
requestConfig:
PlainRequestConfig
value
value:
string
Initial query value.
createShareableLink
createShareableLink: (
yasqe) =>string
Show a button with which users can create a link to this query. Set this value to null to disable this functionality. By default, this feature is enabled, and the only the query value is appended to the link. ps. This function should return an object which is parseable by jQuery.param (http://api.jquery.com/jQuery.param/)
Parameters
yasqe
SparqlEditor
Returns
string
createShortLink
createShortLink: ((
yasqe,longLink) =>Promise<string>) |undefined
consumeShareLink
consumeShareLink: ((
yasqe) =>void) |null|undefined
persistenceId
persistenceId:
string| ((yasqe) =>string) |null|undefined
Change persistency settings for the YASQE query value. Setting the values to null, will disable persistancy: nothing is stored between browser sessions Setting the values to a string (or a function which returns a string), will store the query in localstorage using the specified string. By default, the ID is dynamically generated using the closest dom ID, to avoid collissions when using multiple YASQE items on one page
persistencyExpire
persistencyExpire:
number
showQueryButton
showQueryButton:
boolean
pluginButtons
pluginButtons: (() =>
HTMLElement|HTMLElement[]) |undefined
resizeable
resizeable:
boolean
editorHeight
editorHeight:
string
queryingDisabled
queryingDisabled:
string|undefined
theme
theme:
"light"|"dark"
editorOptions
editorOptions:
Record<string,any>
Custom Monaco editor options (IStandaloneEditorConstructionOptions), deep-merged over yasqe defaults. Use this to fully configure the editor, e.g. { lineNumbers: "off", wordWrap: "on", fontSize: 16, minimap: { enabled: true } }.
themes
themes:
object
Custom SPARQL theme overrides, deep-merged over the built-in light/dark themes. Use this to tweak editor colors, e.g. { dark: { colors: { "editor.background": "#000" } }, light: { semanticTokenColors: { keyword: "#005" } } }.
themes.light?
optionallight?:Record<string,any>
themes.dark?
optionaldark?:Record<string,any>
languageServers
languageServers:
LanguageServerDef[]
The language servers the consumer makes available (yasqe is language server agnostic). The first is activated on load; when two or more are configured a switcher appears in the editor's right-click context menu. Servers are started lazily (the worker is resolved only when a server is first activated). When empty, the editor runs with Monarch syntax highlighting only.
getLanguageServerSettings?
optionalgetLanguageServerSettings?: (label) =>Record<string,unknown> |undefined
Optional consumer-owned store for language server settings panel values, keyed by server label. When provided (e.g. by SparqlStudio, which persists them globally per server), it is the source of truth for pre-filling the settings panel and re-applying settings when a server (re)starts. Pairs with the languageServerSettingsChange event emitted when the user applies settings. When omitted, yasqe falls back to its own local-storage persistence.
Parameters
label
string
Returns
Record<string, unknown> | undefined
Methods
on()
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:76
Parameters
eventName
"query"
handler
(instance, req, abortController?) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:84
Parameters
eventName
"queryAbort"
handler
(instance, req) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:86
Parameters
eventName
"queryResponse"
handler
(instance, response, duration) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:88
Parameters
eventName
"error"
handler
(instance) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:90
Parameters
eventName
"blur"
handler
(instance) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:92
Parameters
eventName
"queryBefore"
handler
(instance, config) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:94
Parameters
eventName
"queryResults"
handler
(instance, results, duration) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:96
Parameters
eventName
"autocompletionShown"
handler
(instance, widget) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:98
Parameters
eventName
"autocompletionClose"
handler
(instance) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:100
Parameters
eventName
"resize"
handler
(instance, newSize) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:102
Parameters
eventName
"languageServerChange"
handler
(instance, def, index) => void
Returns
this
Call Signature
on(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:110
Parameters
eventName
string
handler
() => void
Returns
this
off()
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:80
Parameters
eventName
"query"
handler
(instance, req, abortController?) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:85
Parameters
eventName
"queryAbort"
handler
(instance, req) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:87
Parameters
eventName
"queryResponse"
handler
(instance, response, duration) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:89
Parameters
eventName
"error"
handler
(instance) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:91
Parameters
eventName
"blur"
handler
(instance) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:93
Parameters
eventName
"queryBefore"
handler
(instance, config) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:95
Parameters
eventName
"queryResults"
handler
(instance, results, duration) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:97
Parameters
eventName
"autocompletionShown"
handler
(instance, widget) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:99
Parameters
eventName
"autocompletionClose"
handler
(instance) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:101
Parameters
eventName
"resize"
handler
(instance, newSize) => void
Returns
this
Call Signature
off(
eventName,handler):this
Defined in: sparql-editor-monaco/src/index.ts:106
Parameters
eventName
"languageServerChange"
handler
(instance, def, index) => void
Returns
this
initEditor()
initEditor(
el,conf?):Promise<void>
Defined in: sparql-editor-monaco/src/index.ts:171
Initializes the Monaco editor in the given element.
Parameters
el
HTMLElement
HTMLElement to initialize the editor in
conf?
configuration for the editor
value?
string
Initial query value.
createShareableLink?
(yasqe) => string
Show a button with which users can create a link to this query. Set this value to null to disable this functionality. By default, this feature is enabled, and the only the query value is appended to the link. ps. This function should return an object which is parseable by jQuery.param (http://api.jquery.com/jQuery.param/)
createShortLink?
(yasqe, longLink) => Promise<string>
consumeShareLink?
((yasqe) => void) | null
persistenceId?
string | ((yasqe) => string) | null
Change persistency settings for the YASQE query value. Setting the values to null, will disable persistancy: nothing is stored between browser sessions Setting the values to a string (or a function which returns a string), will store the query in localstorage using the specified string. By default, the ID is dynamically generated using the closest dom ID, to avoid collissions when using multiple YASQE items on one page
persistencyExpire?
number
showQueryButton?
boolean
requestConfig?
((yasqe) => RequestConfig<SparqlEditor>) | { queryArgument?: string | ((yasqe) => string); endpoint?: string | ((yasqe) => string); method?: "POST" | "GET" | ((yasqe) => "POST" | "GET"); acceptHeaderGraph?: string | ((yasqe) => string); acceptHeaderSelect?: string | ((yasqe) => string); acceptHeaderUpdate?: string | ((yasqe) => string); namedGraphs?: string[] | ((yasqe) => string[]); defaultGraphs?: string[] | ((yasqe) => string[]); args?: object[] | ((yasqe) => object[]); headers?: {[key: string]: string | undefined; } | ((yasqe) => object); withCredentials?: boolean | ((yasqe) => boolean); adjustQueryBeforeRequest?: false | ((yasqe) => string); }
pluginButtons?
() => HTMLElement | HTMLElement[]
resizeable?
boolean
editorHeight?
string
queryingDisabled?
string
theme?
"light" | "dark"
editorOptions?
{[key: string]: any; }
Custom Monaco editor options (IStandaloneEditorConstructionOptions), deep-merged over yasqe defaults. Use this to fully configure the editor, e.g. { lineNumbers: "off", wordWrap: "on", fontSize: 16, minimap: { enabled: true } }.
themes?
{ light?: {[key: string]: any; }; dark?: {[key: string]: any; }; }
Custom SPARQL theme overrides, deep-merged over the built-in light/dark themes. Use this to tweak editor colors, e.g. { dark: { colors: { "editor.background": "#000" } }, light: { semanticTokenColors: { keyword: "#005" } } }.
themes.light?
{[key: string]: any; }
themes.dark?
{[key: string]: any; }
languageServers?
object[]
The language servers the consumer makes available (yasqe is language server agnostic). The first is activated on load; when two or more are configured a switcher appears in the editor's right-click context menu. Servers are started lazily (the worker is resolved only when a server is first activated). When empty, the editor runs with Monarch syntax highlighting only.
getLanguageServerSettings?
(label) => Record<string, unknown> | undefined
Optional consumer-owned store for language server settings panel values, keyed by server label. When provided (e.g. by SparqlStudio, which persists them globally per server), it is the source of truth for pre-filling the settings panel and re-applying settings when a server (re)starts. Pairs with the languageServerSettingsChange event emitted when the user applies settings. When omitted, yasqe falls back to its own local-storage persistence.
Returns
Promise<void>
getValue()
getValue():
string
Defined in: sparql-editor-monaco/src/index.ts:289
Returns
string
setValue()
setValue(
newValue):void
Defined in: sparql-editor-monaco/src/index.ts:294
Parameters
newValue
string
Returns
void
refresh()
refresh():
void
Defined in: sparql-editor-monaco/src/index.ts:304
Re-layout the Monaco editor (replaces CodeMirror's refresh).
Returns
void
focus()
focus():
void
Defined in: sparql-editor-monaco/src/index.ts:309
Focus the editor input.
Returns
void
getPrefixesFromQuery()
getPrefixesFromQuery():
object
Defined in: sparql-editor-monaco/src/index.ts:317
Extract the PREFIX declarations from the current query as a { prefix: iri } map. Used by SparqlResults to resolve prefixed names in results.
Returns
object
getLanguageClient()
getLanguageClient():
MonacoLanguageClient|undefined
Defined in: sparql-editor-monaco/src/index.ts:325
The active monaco-languageclient LanguageClient, or undefined if no language server is active. Use it to send server-specific requests/notifications (yasqe stays LS-agnostic).
Returns
MonacoLanguageClient | undefined
getLanguageServers()
getLanguageServers():
object[]
Defined in: sparql-editor-monaco/src/index.ts:330
The configured language servers, as { label, description } (the switcher-facing subset).
Returns
object[]
getActiveLanguageServer()
getActiveLanguageServer():
number
Defined in: sparql-editor-monaco/src/index.ts:335
Index of the active language server in config.languageServers, or -1 when none is active.
Returns
number
notifyEndpointChange()
notifyEndpointChange(
endpoint):void
Defined in: sparql-editor-monaco/src/index.ts:344
Notify the active language server that the endpoint changed, firing only its onEndpointChange (with the active LanguageClient). SparqlStudio calls this on endpoint changes; standalone consumers can call it themselves. No-op when no server is active or it defines no handler.
Parameters
endpoint
string
Returns
void
setLanguageServer()
setLanguageServer(
target):Promise<void>
Defined in: sparql-editor-monaco/src/index.ts:356
Activate a language server by label or index. Disposes the current language client (its worker is terminated), resolves and connects the target server's worker, runs its onReady, refreshes the context-menu switcher and emits languageServerChange. The query/editor model is preserved. Switches are serialized so concurrent calls (e.g. init + a restored preference) run in order.
Parameters
target
string | number
Returns
Promise<void>
openLanguageServerSettings()
openLanguageServerSettings():
void
Defined in: sparql-editor-monaco/src/index.ts:616
Open the schema-driven settings panel for the active language server. No-op when no server is active or it exposes no configSchema/configCallback. On Apply, the collected values are de-flattened (dotted keys become nested objects) and handed to the server's configCallback.
Returns
void
setTheme()
setTheme(
theme):Promise<void>
Defined in: sparql-editor-monaco/src/index.ts:670
Switch the theme of the Monaco editor
Parameters
theme
"light" | "dark"
The theme to switch to ('light' or 'dark')
Returns
Promise<void>
getWrapperElement()
getWrapperElement():
HTMLDivElement
Defined in: sparql-editor-monaco/src/index.ts:682
Returns
HTMLDivElement
emit()
emit(
event, ...data):boolean
Defined in: sparql-editor-monaco/src/index.ts:786
Emit an event, always passing this SparqlEditor instance as the first argument to listeners (matches the documented on(event, (instance, ...data) => ...) API). So callers emit only the payload, e.g. this.emit("queryResponse", response, duration).
Parameters
event
string | symbol
data
...any[]
Returns
boolean
getStorageId()
getStorageId(
getter?):string|undefined
Defined in: sparql-editor-monaco/src/index.ts:790
Parameters
getter?
string | ((yasqe) => string) | null
Returns
string | undefined
openSharePopup()
openSharePopup():
void
Defined in: sparql-editor-monaco/src/index.ts:800
Open the "share query" popup (link input + Shorten/cURL buttons). Triggered from the right-click menu / Cmd+Ctrl+S, since the Monaco editor has no share button. No-op without createShareableLink.
Returns
void
handleLocalStorageQuotaFull()
handleLocalStorageQuotaFull(
_e):void
Defined in: sparql-editor-monaco/src/index.ts:1026
Parameters
_e
any
Returns
void
saveQuery()
saveQuery():
void
Defined in: sparql-editor-monaco/src/index.ts:1031
Returns
void
getQueryType()
getQueryType():
QueryType
Defined in: sparql-editor-monaco/src/index.ts:1043
Detect the SPARQL query form by scanning the query text. Comments and the PREFIX/BASE prologue are skipped so the first real keyword (SELECT, CONSTRUCT, INSERT, ...) is what's matched. Defaults to "SELECT" when nothing matches (e.g. an empty or still-typed query).
Returns
getQueryMode()
getQueryMode():
"update"|"query"
Defined in: sparql-editor-monaco/src/index.ts:1047
Returns
"update" | "query"
showNotification()
showNotification(
key,message):void
Defined in: sparql-editor-monaco/src/index.ts:1097
Shows notification
Parameters
key
string
reference to the notification
message
string
the message to display
Returns
void
hideNotification()
hideNotification(
key):void
Defined in: sparql-editor-monaco/src/index.ts:1121
Hides notification
Parameters
key
string
the identifier of the notification to hide
Returns
void
query()
query(
config?):Promise<any>
Defined in: sparql-editor-monaco/src/index.ts:1130
Querying
Parameters
config?
Returns
Promise<any>
getUrlParams()
getUrlParams():
ParsedQuery<string>
Defined in: sparql-editor-monaco/src/index.ts:1137
Returns
ParsedQuery<string>
configToQueryParams()
configToQueryParams():
ParsedQuery
Defined in: sparql-editor-monaco/src/index.ts:1152
Returns
ParsedQuery
queryParamsToConfig()
queryParamsToConfig(
params):void
Defined in: sparql-editor-monaco/src/index.ts:1160
Parameters
params
ParsedQuery
Returns
void
getAsCurlString()
getAsCurlString(
config?):string
Defined in: sparql-editor-monaco/src/index.ts:1166
Parameters
config?
Returns
string
getUrlArguments()
getUrlArguments(
requestConfig):RequestArgs
Defined in: sparql-editor-monaco/src/index.ts:1171
Build the SPARQL request arguments for the current query against the given request config.
Parameters
requestConfig
Returns
abortQuery()
abortQuery():
void
Defined in: sparql-editor-monaco/src/index.ts:1175
Returns
void
expandEditor()
expandEditor():
void
Defined in: sparql-editor-monaco/src/index.ts:1184
Returns
void
setSize()
setSize(
height?,width?):void
Defined in: sparql-editor-monaco/src/index.ts:1188
Parameters
height?
string
width?
string
Returns
void
destroy()
destroy():
void
Defined in: sparql-editor-monaco/src/index.ts:1245
Returns
void
clearStorage()
staticclearStorage():void
Defined in: sparql-editor-monaco/src/index.ts:1286
Returns
void