@ldforge/editor 0.1.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/controls.d.ts +2 -0
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +2 -0
- package/dist/controls.js.map +1 -1
- package/dist/editor-height.d.ts +8 -0
- package/dist/editor-height.d.ts.map +1 -0
- package/dist/editor-height.js +34 -0
- package/dist/editor-height.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +347 -33
- package/dist/index.js.map +1 -1
- package/dist/renderer-info.d.ts +4 -0
- package/dist/renderer-info.d.ts.map +1 -0
- package/dist/renderer-info.js +41 -0
- package/dist/renderer-info.js.map +1 -0
- package/dist/renderer-wizard.d.ts.map +1 -1
- package/dist/renderer-wizard.js +109 -25
- package/dist/renderer-wizard.js.map +1 -1
- package/dist/share.d.ts +16 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +113 -0
- package/dist/share.js.map +1 -0
- package/dist/sparql/completion.d.ts.map +1 -1
- package/dist/sparql/completion.js +5 -0
- package/dist/sparql/completion.js.map +1 -1
- package/dist/styles.css +496 -82
- package/dist/tab-api.d.ts +7 -1
- package/dist/tab-api.d.ts.map +1 -1
- package/dist/tab-api.js +29 -1
- package/dist/tab-api.js.map +1 -1
- package/dist/theme.d.ts +4 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +73 -0
- package/dist/theme.js.map +1 -0
- package/docs/api/configuration.md +72 -21
- package/docs/api/editor.md +184 -19
- package/docs/api/overview.md +8 -0
- package/docs/api/plugins.md +6 -2
- package/docs/api/tab.md +37 -9
- package/docs/api/transport.md +19 -2
- package/docs/renderers.md +29 -1
- package/package.json +3 -3
- package/src/controls.ts +4 -0
- package/src/editor-height.ts +42 -0
- package/src/index.ts +440 -30
- package/src/renderer-info.ts +52 -0
- package/src/renderer-wizard.ts +114 -25
- package/src/share.ts +125 -0
- package/src/sparql/completion.ts +5 -0
- package/src/styles.css +496 -82
- package/src/tab-api.ts +44 -4
- package/src/theme.ts +87 -0
package/dist/tab-api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ChangeSpec } from '@codemirror/state';
|
|
1
2
|
import type { Locale } from '@ldforge/core';
|
|
2
3
|
import type { FormatOptions } from './sparql/format.js';
|
|
3
4
|
import type { QueryWorkspace } from './query-tabs.js';
|
|
@@ -23,6 +24,10 @@ export interface QueryTabHandle {
|
|
|
23
24
|
setQuery(query: string): void;
|
|
24
25
|
/** Lazy local formatting. Rejects on invalid syntax, deletion or newer text edits. */
|
|
25
26
|
formatQuery(options?: FormatOptions): Promise<string>;
|
|
27
|
+
/** Detached declared aliases; the last declaration wins for duplicate aliases. */
|
|
28
|
+
getPrefixes(): Record<string, string>;
|
|
29
|
+
/** Remove all declarations of an alias, leaving uses and surrounding text intact. */
|
|
30
|
+
removePrefix(prefix: string): void;
|
|
26
31
|
/** Returns the actual alias, or undefined for an unknown shorthand (with a warning). */
|
|
27
32
|
addPrefix(prefix: string, namespace?: string): string | undefined;
|
|
28
33
|
/** Trim and store a name; an empty name restores the localized default. */
|
|
@@ -49,7 +54,7 @@ export interface TabAdapter {
|
|
|
49
54
|
snapshot(): QueryWorkspace;
|
|
50
55
|
locale(): Locale;
|
|
51
56
|
assertAlive(): void;
|
|
52
|
-
setQuery(id: string, query: string): void;
|
|
57
|
+
setQuery(id: string, query: string, changes?: ChangeSpec): void;
|
|
53
58
|
rename(id: string, name: string): void;
|
|
54
59
|
activate(id: string): void;
|
|
55
60
|
delete(id: string): boolean;
|
|
@@ -64,6 +69,7 @@ export interface TabAdapter {
|
|
|
64
69
|
export declare function queryWithPrefix(query: string, preferred: string, namespace: string): {
|
|
65
70
|
query: string;
|
|
66
71
|
prefix: string;
|
|
72
|
+
changes?: ChangeSpec;
|
|
67
73
|
};
|
|
68
74
|
export declare function createTabApi(adapter: TabAdapter): {
|
|
69
75
|
collection: TabCollection;
|
package/dist/tab-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-api.d.ts","sourceRoot":"","sources":["../src/tab-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tab-api.d.ts","sourceRoot":"","sources":["../src/tab-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AACD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IACtD,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AACD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,4FAA4F;IAC5F,QAAQ,IAAI,MAAM,CAAC;IACnB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sFAAsF;IACtF,WAAW,CAAC,OAAO,C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AM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;CACjD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,CAgBzD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG;IACjD,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,IAAI,IAAI,CAAC;CACd,CA0KA"}
|
package/dist/tab-api.js
CHANGED
|
@@ -19,6 +19,7 @@ export function queryWithPrefix(query, preferred, namespace) {
|
|
|
19
19
|
return {
|
|
20
20
|
query: query.slice(0, edit.from) + edit.insert + query.slice(edit.from),
|
|
21
21
|
prefix,
|
|
22
|
+
changes: edit,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
export function createTabApi(adapter) {
|
|
@@ -79,6 +80,33 @@ export function createTabApi(adapter) {
|
|
|
79
80
|
adapter.setQuery(id, formatted);
|
|
80
81
|
return formatted;
|
|
81
82
|
},
|
|
83
|
+
getPrefixes() {
|
|
84
|
+
return Object.fromEntries(prefixDeclarations(EditorState.create({ doc: record(id).query })).map(({ prefix, iri }) => [prefix, iri]));
|
|
85
|
+
},
|
|
86
|
+
removePrefix(prefix) {
|
|
87
|
+
const original = record(id).query;
|
|
88
|
+
const declarations = prefixDeclarations(EditorState.create({ doc: original })).filter((entry) => entry.prefix === prefix);
|
|
89
|
+
if (!declarations.length)
|
|
90
|
+
return;
|
|
91
|
+
// A standalone declaration owns its line ending. Keep comments and
|
|
92
|
+
// other statements on shared lines intact.
|
|
93
|
+
let query = original;
|
|
94
|
+
const changes = [];
|
|
95
|
+
for (const declaration of declarations.reverse()) {
|
|
96
|
+
let { from, to } = declaration;
|
|
97
|
+
const lineStart = original.lastIndexOf('\n', from - 1) + 1;
|
|
98
|
+
const newline = original.indexOf('\n', to);
|
|
99
|
+
const lineEnd = newline < 0 ? original.length : newline;
|
|
100
|
+
if (/^[ \t]*$/.test(original.slice(lineStart, from)) &&
|
|
101
|
+
/^[ \t\r]*$/.test(original.slice(to, lineEnd))) {
|
|
102
|
+
from = lineStart;
|
|
103
|
+
to = newline < 0 ? lineEnd : newline + 1;
|
|
104
|
+
}
|
|
105
|
+
changes.push({ from, to });
|
|
106
|
+
query = query.slice(0, from) + query.slice(to);
|
|
107
|
+
}
|
|
108
|
+
adapter.setQuery(id, query, changes.reverse());
|
|
109
|
+
},
|
|
82
110
|
addPrefix(prefix, namespace) {
|
|
83
111
|
const original = record(id).query;
|
|
84
112
|
const iri = resolve(prefix, namespace);
|
|
@@ -86,7 +114,7 @@ export function createTabApi(adapter) {
|
|
|
86
114
|
return undefined;
|
|
87
115
|
const result = queryWithPrefix(original, prefix, iri);
|
|
88
116
|
if (result.query !== original)
|
|
89
|
-
adapter.setQuery(id, result.query);
|
|
117
|
+
adapter.setQuery(id, result.query, result.changes);
|
|
90
118
|
return result.prefix;
|
|
91
119
|
},
|
|
92
120
|
rename(title) {
|
package/dist/tab-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-api.js","sourceRoot":"","sources":["../src/tab-api.ts"],"names":[],"mappings":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AM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACpE,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Per-instance tokens. Undefined restores stylesheet defaults and host CSS overrides. */
|
|
2
|
+
export declare function themeTokens(value?: string): Record<string, string>;
|
|
3
|
+
export declare function applyTheme(root: HTMLElement, previous: Record<string, string>, next: Record<string, string>): void;
|
|
4
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AA+CA,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BlE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,IAAI,CAKN"}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
function parseColor(value) {
|
|
2
|
+
if (!/^#(?:[\da-f]{3}|[\da-f]{6})$/i.test(value))
|
|
3
|
+
throw new TypeError('themeMainColor must be an opaque #RGB or #RRGGBB color.');
|
|
4
|
+
const hex = value.length === 4
|
|
5
|
+
? value
|
|
6
|
+
.slice(1)
|
|
7
|
+
.split('')
|
|
8
|
+
.map((digit) => digit + digit)
|
|
9
|
+
.join('')
|
|
10
|
+
: value.slice(1);
|
|
11
|
+
return [
|
|
12
|
+
Number.parseInt(hex.slice(0, 2), 16),
|
|
13
|
+
Number.parseInt(hex.slice(2, 4), 16),
|
|
14
|
+
Number.parseInt(hex.slice(4, 6), 16),
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function mix(color, target, amount) {
|
|
18
|
+
const channel = (index) => Math.round(color[index] * (1 - amount) + target[index] * amount);
|
|
19
|
+
return [channel(0), channel(1), channel(2)];
|
|
20
|
+
}
|
|
21
|
+
function hex(color) {
|
|
22
|
+
return ('#' + color.map((value) => value.toString(16).padStart(2, '0')).join(''));
|
|
23
|
+
}
|
|
24
|
+
function luminance(color) {
|
|
25
|
+
const linear = color.map((value) => {
|
|
26
|
+
const channel = value / 255;
|
|
27
|
+
return channel <= 0.04045
|
|
28
|
+
? channel / 12.92
|
|
29
|
+
: ((channel + 0.055) / 1.055) ** 2.4;
|
|
30
|
+
});
|
|
31
|
+
return ((linear[0] ?? 0) * 0.2126 +
|
|
32
|
+
(linear[1] ?? 0) * 0.7152 +
|
|
33
|
+
(linear[2] ?? 0) * 0.0722);
|
|
34
|
+
}
|
|
35
|
+
const white = [255, 255, 255];
|
|
36
|
+
const black = [0, 0, 0];
|
|
37
|
+
/** Per-instance tokens. Undefined restores stylesheet defaults and host CSS overrides. */
|
|
38
|
+
export function themeTokens(value) {
|
|
39
|
+
if (value === undefined)
|
|
40
|
+
return {};
|
|
41
|
+
const main = parseColor(value);
|
|
42
|
+
let ink = main;
|
|
43
|
+
// A 7:1 white contrast leaves room for the tinted selected/hover surfaces.
|
|
44
|
+
for (let step = 1; 1.05 / (luminance(ink) + 0.05) < 7 && step <= 20; step++)
|
|
45
|
+
ink = mix(main, black, step / 20);
|
|
46
|
+
const lightContrast = 1.05 / (luminance(main) + 0.05);
|
|
47
|
+
const darkContrast = (luminance(main) + 0.05) / 0.05;
|
|
48
|
+
return {
|
|
49
|
+
accent: hex(main),
|
|
50
|
+
'accent-fill': hex(main),
|
|
51
|
+
'on-accent': lightContrast >= darkContrast ? '#ffffff' : '#000000',
|
|
52
|
+
'accent-text': hex(ink),
|
|
53
|
+
text: hex(mix(main, black, 0.8)),
|
|
54
|
+
muted: hex(mix(ink, white, 0.12)),
|
|
55
|
+
surface: '#ffffff',
|
|
56
|
+
'surface-subtle': hex(mix(main, white, 0.97)),
|
|
57
|
+
'surface-tinted': hex(mix(main, white, 0.94)),
|
|
58
|
+
hover: hex(mix(main, white, 0.9)),
|
|
59
|
+
selected: hex(mix(main, white, 0.85)),
|
|
60
|
+
border: hex(mix(main, white, 0.72)),
|
|
61
|
+
'border-strong': hex(mix(main, white, 0.4)),
|
|
62
|
+
focus: hex(ink),
|
|
63
|
+
shadow: hex(mix(main, black, 0.65)) + '26',
|
|
64
|
+
backdrop: hex(mix(main, black, 0.65)) + '55',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function applyTheme(root, previous, next) {
|
|
68
|
+
for (const name of Object.keys(previous))
|
|
69
|
+
root.style.removeProperty('--ldforge-' + name);
|
|
70
|
+
for (const [name, value] of Object.entries(next))
|
|
71
|
+
root.style.setProperty('--ldforge-' + name, value);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAEA,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,yDAAyD,CAC1D,CAAC;IACJ,MAAM,GAAG,GACP,KAAK,CAAC,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,KAAK;aACF,KAAK,CAAC,CAAC,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UAAU,UAAU,CACxB,IAAiB,EACjB,QAAgC,EAChC,IAA4B;IAE5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACjD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
# Editor configuration
|
|
2
2
|
|
|
3
|
-
`createEditor(container, options)` accepts an `HTMLElement` and an `EditorOptions` object. Configuration is read at mount time. Recreate the editor to change result/settings plugin sets or built-in control visibility, except the plugin wizard which also
|
|
3
|
+
`createEditor(container, options)` accepts an `HTMLElement` and an `EditorOptions` object. Configuration is read at mount time. Recreate the editor to change result/settings plugin sets or built-in control visibility, except the plugin wizard and result plugin presentation, which also have runtime visibility methods. Toolbar actions and groups can also change through `editor.getToolBar()`. Query text, tabs and language have runtime methods.
|
|
4
4
|
|
|
5
5
|
## EditorOptions
|
|
6
6
|
|
|
7
|
-
| Property
|
|
8
|
-
|
|
|
9
|
-
| `prefixesCollapsed`
|
|
10
|
-
| `
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
7
|
+
| Property | Type | Default | Behavior |
|
|
8
|
+
| -------------------- | --------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `prefixesCollapsed` | `boolean` | `false` | Initially folds PREFIX declarations on each tab. Fold state is view-only; see [ForgeEditor](editor.md#collapsible-prefix-declarations) for the runtime API. |
|
|
10
|
+
| `themeMainColor` | `string` | Existing green theme | Optional opaque `#RGB` or `#RRGGBB` accent; derives instance-scoped UI tokens. See [Theming](editor.md#theme-colors). |
|
|
11
|
+
| `executor` | `QueryExecutor` | Required | Runs queries and receives an abort signal. |
|
|
12
|
+
| `query` | `string` | `''` | Initial first-tab text when no valid workspace is restored. |
|
|
13
|
+
| `workspace` | `QueryWorkspace` | One tab | Restored tabs and active ID. Takes precedence over `query`. Invalid runtime data falls back to the initial query. Validate persisted JSON with `parseQueryWorkspace`. |
|
|
14
|
+
| `controls` | `EditorControls \| false` | All controls enabled | Toggles built-in UI. `false` hides every built-in control, including tabs. Custom buttons remain visible. |
|
|
15
|
+
| `locale` | `'auto' \| 'en' \| 'nl'` | `'auto'` | Project default. Auto uses the first supported browser language, then English. |
|
|
16
|
+
| `userLocale` | `'auto' \| 'en' \| 'nl'` | `'auto'` | Restored user override. Auto follows the project setting. |
|
|
17
|
+
| `sparql` | `SparqlOptions` | Built-in catalogs | Namespace and predicate completion configuration. |
|
|
18
|
+
| `toolbar` | `ToolbarOptions` | `{}` | Optional custom group presentation and initial group actions. Existing groups stay adjacent buttons unless configured as dropdowns; see [Toolbar](toolbar.md). |
|
|
19
|
+
| `buttons` | `readonly ButtonPlugin[]` | Combined Run/Stop | Replaces the default action list. Include createRunButton() to retain Run/Stop; createCancelButton() is optional. |
|
|
20
|
+
| `editorRows` | `number` | `15` | Query viewport in visual lines; minimum when growing. Positive safe integer. |
|
|
21
|
+
| `autoGrow` | `boolean` | `true` | Grow the query editor with content; false uses a fixed scrolling viewport. Demo explicitly uses false. |
|
|
22
|
+
| `onAutoGrowChange` | `(enabled: boolean) => void` | None | Called when the height mode changes via the checkbox or API. |
|
|
23
|
+
| `onEditorRowsChange` | `(rows: number) => void` | None | Called when the visible-row count changes via the API. |
|
|
24
|
+
| `availablePlugins` | `boolean` | `true` | Show the dropdown of remaining registered result plugins. |
|
|
25
|
+
| `visiblePlugins` | `readonly (string \| ResultRendererPlugin)[]` | `['table', 'json']` | Initially pinned registered plugins; an explicit array replaces the defaults. |
|
|
26
|
+
| `renderers` | `readonly ResultRendererPlugin[]` | `[]` | Ordered result views. No implicit renderer is installed. |
|
|
27
|
+
| `settings` | `readonly SettingsPlugin[]` | `[]` | Host-owned panels under the gear button. Not mounted when `controls.settings` is false. |
|
|
28
|
+
| `extensions` | `readonly Extension[]` | `[]` | Additional CodeMirror 6 extensions, recreated on a tab switch. |
|
|
29
|
+
| `onQueryChange` | `(query: string) => void` | None | Called when active text changes or another tab becomes active. Inactive text edits do not call it. |
|
|
30
|
+
| `onWorkspaceChange` | `(workspace: QueryWorkspace) => void` | None | Receives a detached snapshot after edits, prefix insertion/removal, formatting, rename, create, delete or selection changes. Initial mount does not emit unless a host plugin mutates state. |
|
|
31
|
+
| `onLocaleChange` | `(preference: LocalePreference) => void` | None | Called after user/API language changes. The host can persist this preference. |
|
|
32
|
+
| `onWarning` | `(warning: EditorWarning) => void` | `console.warn` | Reports unknown shorthand prefixes without changing the query. |
|
|
33
|
+
|
|
34
|
+
`availablePlugins?: boolean` controls the result renderer dropdown and defaults to `true`.
|
|
35
|
+
`visiblePlugins?: readonly (string | ResultRendererPlugin)[]` sets the renderers pinned
|
|
36
|
+
on the result bar, defaulting to `['table', 'json']`. Supply registered IDs or plugin
|
|
37
|
+
objects. An explicit list replaces those defaults; unregistered IDs throw before mounting.
|
|
38
|
+
Pinned plugins remain disabled when `supports(result)` returns false. The active
|
|
39
|
+
renderer is always shown, even when it is not pinned. Visibility does not register,
|
|
40
|
+
select, execute or load a renderer. See [runtime methods](editor.md#result-plugin-visibility).
|
|
26
41
|
|
|
27
42
|
Callbacks are synchronous host code. Keep them short and handle storage failures inside your callback. Exceptions from host callbacks are not silently ignored.
|
|
28
43
|
|
|
@@ -38,8 +53,10 @@ Every property is optional and defaults to `true`.
|
|
|
38
53
|
| `cancel` | The action with reserved ID `cancel`, including `createCancelButton()`. |
|
|
39
54
|
| `prefixFolding` | Gutter arrows to fold and unfold PREFIX declarations. Hiding these leaves the folding API and keyboard shortcuts available. |
|
|
40
55
|
| `prefixes` | Prefix search icon and its entry point. |
|
|
56
|
+
| `autoGrow` | Show the full query checkbox in settings; height APIs remain available when hidden. |
|
|
41
57
|
| `fontSize` | Query text-size field in settings; API remains available when hidden. |
|
|
42
58
|
| `loadingIndicator` | Spinner in results while a query runs; defaults to true. |
|
|
59
|
+
| `share` | Share-link icon in the right toolbar. Defaults to true; sharing APIs remain available when hidden. |
|
|
43
60
|
| `rendererWizard` | Plugin wizard icon; defaults to true. API remains available when hidden. |
|
|
44
61
|
| `format` | Format-query icon. |
|
|
45
62
|
| `settings` | Gear icon and settings plugin mounting. Hides access to the language selector too. |
|
|
@@ -49,7 +66,7 @@ Every property is optional and defaults to `true`.
|
|
|
49
66
|
| `renameTab` | Rename icon and double-click renaming. |
|
|
50
67
|
| `closeTab` | Tab close buttons. |
|
|
51
68
|
|
|
52
|
-
The core tools group is ordered **Prefixes → Format query → Plugin wizard → Settings**, with icons, localized accessible names and tooltips. Run/Stop is separate from custom project actions. Custom plugin buttons use their `group` identifier; a project cannot accidentally merge its buttons into the core action group just by using the same group name.
|
|
69
|
+
The core tools group is ordered **Prefixes → Format query → Plugin wizard → Copy share link → Settings**, with icons, localized accessible names and tooltips. Run/Stop is separate from custom project actions. Custom plugin buttons use their `group` identifier; a project cannot accidentally merge its buttons into the core action group just by using the same group name.
|
|
53
70
|
|
|
54
71
|
```ts
|
|
55
72
|
// Only hide these controls; all public methods remain available.
|
|
@@ -140,3 +157,37 @@ the demo's default. Storage failures leave current-session controls usable.
|
|
|
140
157
|
`controls.loadingIndicator: false` disables the default query spinner. Runtime
|
|
141
158
|
methods are `isLoadingIndicatorEnabled()` and `setLoadingIndicatorEnabled(boolean)`.
|
|
142
159
|
These affect presentation only; running queries and the stop action remain active.
|
|
160
|
+
|
|
161
|
+
Prefix inspection/removal needs no configuration. `getPrefixes()` reads query
|
|
162
|
+
declarations, independently of the `sparql.prefixes` completion catalog (including
|
|
163
|
+
when that catalog is disabled). See [ForgeEditor](editor.md#inspecting-and-removing-prefixes).
|
|
164
|
+
|
|
165
|
+
`shareBaseUrl` optionally sets the absolute recipient page URL. By default sharing uses the current page URL, removes ordinary page fragments, preserves hash-based application routes, preserves its other parameters and replaces `query` with the encoded query. Hosts should read that parameter when initializing their editor; the demo opens the shared query without automatically executing it and preserves existing saved tabs.
|
|
166
|
+
|
|
167
|
+
`shareEndpoint` accepts an endpoint URL or a callback returning the current applied endpoint. When sharing, this is added as `# sparql-endpoint=…` if the query does not already declare one. The demo reads its active connection at copy time. Authentication headers are not part of the shared URL.
|
|
168
|
+
|
|
169
|
+
## Query editor height
|
|
170
|
+
|
|
171
|
+
`editorRows?: number` sets the query viewport in visual lines (positive safe integer,
|
|
172
|
+
default **15**). Wrapped lines occupy additional visual rows. With `autoGrow: false`,
|
|
173
|
+
the height stays fixed and the query scrolls internally. Font size changes preserve
|
|
174
|
+
the configured visible-row count. With `autoGrow: true`, rows define the minimum
|
|
175
|
+
height and the editor grows with its content. Library default: `autoGrow: true`,
|
|
176
|
+
preserving the growing editor for existing integrations.
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
// In createEditor options:
|
|
180
|
+
// editorRows: 15,
|
|
181
|
+
// autoGrow: false,
|
|
182
|
+
// onAutoGrowChange: (enabled) => savePreference(enabled),
|
|
183
|
+
// onEditorRowsChange: (rows) => saveRowPreference(rows),
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The demo explicitly starts with 15 rows and auto-grow off. The **Show the full query**
|
|
187
|
+
(**Hele query tonen**) checkbox is behind the gear button. Its preference
|
|
188
|
+
is restored from `localStorage` under `ldforge.demo.auto-grow.v1`; unavailable
|
|
189
|
+
storage leaves the current session usable. Hide only the checkbox with
|
|
190
|
+
`controls: { autoGrow: false }`; `controls.settings: false` hides the whole panel.
|
|
191
|
+
The height API remains available. Options apply to the query editor across tabs,
|
|
192
|
+
not the JSON result editor or other result renderers. Runtime methods and callbacks
|
|
193
|
+
are described in [ForgeEditor](editor.md#query-editor-height).
|
package/docs/api/editor.md
CHANGED
|
@@ -4,25 +4,34 @@ Returned by `createEditor(container: HTMLElement, options: EditorOptions): Forge
|
|
|
4
4
|
|
|
5
5
|
## Methods
|
|
6
6
|
|
|
7
|
-
| Method
|
|
8
|
-
|
|
|
9
|
-
| `setPrefixesCollapsed(collapsed)`
|
|
10
|
-
| `arePrefixesCollapsed()`
|
|
11
|
-
| `togglePrefixes()`
|
|
12
|
-
| `getTabs()`
|
|
13
|
-
| `getToolBar()`
|
|
14
|
-
| `getWorkspace()`
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
7
|
+
| Method | Returns | Behavior |
|
|
8
|
+
| --------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `setPrefixesCollapsed(collapsed)` | `void` | Collapses or expands every PREFIX group in the active query. Presentation only; source, execution and persistence retain every declaration. Throws after destruction. |
|
|
10
|
+
| `arePrefixesCollapsed()` | `boolean` | True when every PREFIX group is folded; false for expanded/partially folded queries or queries without declarations. Throws after destruction. |
|
|
11
|
+
| `togglePrefixes()` | `boolean` | Toggles all PREFIX groups and returns the resulting collapsed state. Returns false when no declarations exist. Throws after destruction. |
|
|
12
|
+
| `getTabs()` | `TabCollection` | The same live, indexable collection each time. Throws after destruction. |
|
|
13
|
+
| `getToolBar()` | `ToolbarApi` | Live toolbar API for standalone buttons, adjacent groups and dropdowns. See [Toolbar](toolbar.md). |
|
|
14
|
+
| `getWorkspace()` | `QueryWorkspace` | Detached plain-data snapshot for persistence. |
|
|
15
|
+
| `getRenderers()` | `readonly ResultRendererPlugin[]` | Registered renderers in registration order, without loading their external libraries. |
|
|
16
|
+
| `showAvailablePlugins()` / `hideAvailablePlugins()` | `void` | Show or hide the result renderer dropdown. |
|
|
17
|
+
| `showPlugin(plugin)` / `hidePlugin(plugin)` | `void` | Pin or unpin a registered ID or renderer descriptor. The active renderer remains visible. |
|
|
18
|
+
| `getEditorRows()` / `setEditorRows(rows)` | `number` / `void` | Read or set the query viewport's positive safe-integer row count. |
|
|
19
|
+
| `isAutoGrowEnabled()` / `setAutoGrow(enabled)` | `boolean` / `void` | Read or change query height mode; the Show the full query checkbox stays synchronized. |
|
|
20
|
+
| `getShareLink()` | `string` | Returns the active query URL with the selected renderer in its header, without editing. |
|
|
21
|
+
| `copyShareLink()` | `Promise<string>` | Copies the URL to the clipboard; after success, saves its renderer header in one undoable edit if the active query is unchanged. Requires browser clipboard access. |
|
|
22
|
+
| `getQuery()` | `string` | Active tab's current text. |
|
|
23
|
+
| `setQuery(query)` | `void` | Replaces active text in one undoable edit and emits host callbacks. A no-op after destruction. |
|
|
24
|
+
| `formatQuery(options?)` | `Promise<string>` | Formats the tab active when called. Equivalent to `getTabs().getActive().formatQuery(options)`. |
|
|
25
|
+
| `getPrefixes()` | `Record<string, string>` | Detached snapshot of explicitly declared aliases and namespaces; excludes the completion catalog. |
|
|
26
|
+
| `removePrefix(prefix)` | `void` | Removes all declarations of this alias. A missing alias is a no-op. |
|
|
27
|
+
| `addPrefix(prefix, namespace?)` | `string \| undefined` | Adds to the active tab and returns the actual alias; undefined means unknown shorthand. |
|
|
28
|
+
| `getState()` | `QueryState` | Latest execution state. See [Transport and results](transport.md). |
|
|
29
|
+
| `run()` | `Promise<void>` | Executes active text. Resolves after the request settles; failures are recorded in state instead of rejecting. Throws/rejects if the controller is destroyed. |
|
|
30
|
+
| `cancel()` | `void` | Aborts pending work and resets execution state to idle. |
|
|
31
|
+
| `getLocale()` | `'en' \| 'nl'` | Resolved language for this IDE. |
|
|
32
|
+
| `setLocale(preference)` | `void` | Sets user override; auto restores the project/browser default. Calls `onLocaleChange`. A no-op after destruction. |
|
|
33
|
+
| `focus()` | `void` | Focuses CodeMirror. Use only while mounted. |
|
|
34
|
+
| `destroy()` | `void` | Idempotent. Aborts requests, disposes result/settings resources and CodeMirror, and removes the IDE section. Does not remove the caller's container. |
|
|
26
35
|
|
|
27
36
|
Use a handle only while mounted. In particular, tab methods deliberately throw after destruction rather than recreating detached state. A formatting operation pending during deletion/destruction rejects without writing back.
|
|
28
37
|
|
|
@@ -152,3 +161,159 @@ const size = editor.getFontSize();
|
|
|
152
161
|
The text-size field is under the gear button; default and Reset are 12 px. The
|
|
153
162
|
host can supply `fontSize` and `onFontSizeChange` for persistence. The demo uses
|
|
154
163
|
localStorage. Text-size and spinner API methods throw after editor destruction.
|
|
164
|
+
|
|
165
|
+
## Inspecting and removing prefixes
|
|
166
|
+
|
|
167
|
+
Declarations are parsed structurally: PREFIX-like text in comments, literals and
|
|
168
|
+
IRIs is ignored. With duplicate alias declarations, the last declaration wins in
|
|
169
|
+
the snapshot; removal deletes all declarations of that alias. The empty string
|
|
170
|
+
addresses the default prefix. Namespaces are returned as written inside the IRI
|
|
171
|
+
brackets, without resolving BASE or decoding escapes.
|
|
172
|
+
|
|
173
|
+
Removal deletes the whole line, including its line ending, when a declaration
|
|
174
|
+
is alone on that line. On shared lines it removes only the declaration, retaining
|
|
175
|
+
comments and other statements. Existing blank separator lines and the query body
|
|
176
|
+
are preserved. Uses of the removed alias are left intact, so the query may need a
|
|
177
|
+
replacement declaration before execution. Active edits participate in undo/redo
|
|
178
|
+
and emit the normal query/workspace callbacks. Inactive tab edits emit only the
|
|
179
|
+
workspace callback and never select the tab. As with other tab edits, inactive
|
|
180
|
+
tabs store text only; undo history resets on tab switches. Manual edits and tab
|
|
181
|
+
switches invoke the normal callbacks, where hosts can read a fresh snapshot.
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
const tab = editor.getTabs().getActive();
|
|
185
|
+
const declared = tab.getPrefixes();
|
|
186
|
+
if (declared.ex !== undefined) tab.removePrefix('ex');
|
|
187
|
+
else tab.addPrefix('ex', 'https://example.org/');
|
|
188
|
+
console.log(editor.getPrefixes()); // Current active query declarations.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Theme colors
|
|
192
|
+
|
|
193
|
+
`EditorOptions.themeMainColor?: string` sets an instance's main color. Supply an
|
|
194
|
+
opaque hex color (`#RGB` or `#RRGGBB`); names, alpha colors, CSS expressions and
|
|
195
|
+
other formats throw `TypeError`. Validation occurs before mounting, and invalid
|
|
196
|
+
runtime changes leave the current theme intact. No additional dependencies load.
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
const editor = createEditor(container, {
|
|
200
|
+
executor,
|
|
201
|
+
themeMainColor: '#1a80b9',
|
|
202
|
+
});
|
|
203
|
+
editor.setThemeMainColor('#743ca6');
|
|
204
|
+
console.log(editor.getThemeMainColor()); // Last configured value, or undefined.
|
|
205
|
+
editor.setThemeMainColor(); // Restore the existing stylesheet/host CSS theme.
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`getThemeMainColor(): string | undefined` and
|
|
209
|
+
`setThemeMainColor(color?: string): void` throw after destruction. Changing a
|
|
210
|
+
theme never changes query text, history, execution, or persistence callbacks.
|
|
211
|
+
Hosts own persistence. Multiple editors can use different colors on one page.
|
|
212
|
+
|
|
213
|
+
With no option, the existing green styling is retained. A supplied color derives
|
|
214
|
+
light surfaces, borders, hover/selected backgrounds, focus and text colors on the
|
|
215
|
+
editor root. Filled actions use the exact main color and whichever of black or
|
|
216
|
+
white has the higher contrast (at least 4.5:1). Accent text is darkened separately
|
|
217
|
+
for readability on light surfaces. This is a light UI theme; syntax colors,
|
|
218
|
+
semantic error/warning colors and visualization data palettes remain independent.
|
|
219
|
+
Host-authored result CSS and external visualization widgets may supply their own
|
|
220
|
+
colors.
|
|
221
|
+
|
|
222
|
+
### Shared CSS variables
|
|
223
|
+
|
|
224
|
+
Renderer/settings plugins mounted inside the editor inherit these variables,
|
|
225
|
+
including in the modal wizard. They update automatically after a runtime change.
|
|
226
|
+
|
|
227
|
+
| Variable | Purpose |
|
|
228
|
+
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
229
|
+
| `--ldforge-accent` | Exact main color; filled actions and accents. Default `#075e55`. |
|
|
230
|
+
| `--ldforge-accent-fill` | Main color for secondary filled controls; falls back to legacy component greens when unset. |
|
|
231
|
+
| `--ldforge-on-accent` | Black or white foreground on the main color. |
|
|
232
|
+
| `--ldforge-accent-text` | Readable accent text on light surfaces. |
|
|
233
|
+
| `--ldforge-text`, `--ldforge-muted` | Main and secondary UI text. |
|
|
234
|
+
| `--ldforge-surface` | White base surface. |
|
|
235
|
+
| `--ldforge-surface-subtle`, `--ldforge-surface-tinted` | Coordinated light surfaces. |
|
|
236
|
+
| `--ldforge-hover`, `--ldforge-selected` | Hover and selection surfaces. |
|
|
237
|
+
| `--ldforge-border`, `--ldforge-border-strong` | Regular and emphasized borders. Default regular border `#d6dedd`. |
|
|
238
|
+
| `--ldforge-focus` | Focus outline on light surfaces. |
|
|
239
|
+
| `--ldforge-shadow`, `--ldforge-backdrop` | Translucent shadow/backdrop colors. |
|
|
240
|
+
|
|
241
|
+
The configuration writes tokens inline on the `.ldforge` root. Reset removes
|
|
242
|
+
these inline tokens and restores CSS overrides/defaults. Without a configured
|
|
243
|
+
theme, tokens other than the existing accent and border may be unset: use
|
|
244
|
+
fallbacks to retain your plugin's current appearance, for example:
|
|
245
|
+
|
|
246
|
+
```css
|
|
247
|
+
.my-settings-panel {
|
|
248
|
+
color: var(--ldforge-text, #182e2b);
|
|
249
|
+
background: var(--ldforge-surface-tinted, #f2f6f4);
|
|
250
|
+
border: 1px solid var(--ldforge-border, #d6dedd);
|
|
251
|
+
}
|
|
252
|
+
.my-settings-panel a {
|
|
253
|
+
color: var(--ldforge-accent-text, var(--ldforge-accent, #075e55));
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
A manual override of only `--ldforge-accent` remains supported but does not derive
|
|
258
|
+
the complete palette; use `themeMainColor` for coordinated colors. Plugin content
|
|
259
|
+
ported outside the editor root must explicitly inherit/copy these variables.
|
|
260
|
+
|
|
261
|
+
## Result plugin visibility
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
const maps = createGeoRenderer(); // import from @ldforge/geo
|
|
265
|
+
const editor = createEditor(container, {
|
|
266
|
+
executor,
|
|
267
|
+
renderers: [createTableRenderer(), createJsonRenderer(), maps],
|
|
268
|
+
availablePlugins: true, // Default: show the dropdown.
|
|
269
|
+
visiblePlugins: ['table', 'json', maps],
|
|
270
|
+
});
|
|
271
|
+
editor.hideAvailablePlugins();
|
|
272
|
+
editor.showAvailablePlugins();
|
|
273
|
+
editor.showPlugin(maps); // Also accepts the registered ID: 'geo'.
|
|
274
|
+
editor.hidePlugin('geo');
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
`showAvailablePlugins()` / `hideAvailablePlugins()` control only the dropdown.
|
|
278
|
+
`showPlugin(plugin)` pins a registered renderer on the bar; `hidePlugin(plugin)`
|
|
279
|
+
returns it to the dropdown. Both accept a registered ID or a plugin descriptor.
|
|
280
|
+
The active renderer remains visible after unpinning until another view is selected.
|
|
281
|
+
An unavailable pinned renderer is visible but disabled according to `supports(result)`.
|
|
282
|
+
These methods do not execute the query, remount the result, change the selected view,
|
|
283
|
+
or load visualization libraries. Calls are idempotent; unknown renderer IDs throw
|
|
284
|
+
`TypeError`, and all four methods throw after destruction. Defaults pin Table and JSON;
|
|
285
|
+
`visiblePlugins` replaces that initial list. Dropdown visibility defaults to `true`.
|
|
286
|
+
No built-in catalogue is used: third-party renderers follow the same rules.
|
|
287
|
+
|
|
288
|
+
## Query editor height
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
const editor = createEditor(container, {
|
|
292
|
+
executor,
|
|
293
|
+
editorRows: 15,
|
|
294
|
+
autoGrow: false,
|
|
295
|
+
onAutoGrowChange: (enabled) => console.log('Auto-grow:', enabled),
|
|
296
|
+
onEditorRowsChange: (rows) => console.log('Visible rows:', rows),
|
|
297
|
+
});
|
|
298
|
+
editor.setEditorRows(20);
|
|
299
|
+
editor.getEditorRows(); // 20
|
|
300
|
+
editor.setAutoGrow(true);
|
|
301
|
+
editor.isAutoGrowEnabled(); // true
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`getEditorRows()` / `setEditorRows(rows)` read or set the viewport's visual-row
|
|
305
|
+
count. Values must be positive safe integers; invalid values throw `RangeError`
|
|
306
|
+
and leave the current value intact. `isAutoGrowEnabled()` / `setAutoGrow(enabled)`
|
|
307
|
+
read or set growth behavior. When disabled, scrolling stays inside a fixed query
|
|
308
|
+
viewport; when enabled, `editorRows` is the minimum and the editor grows to fit.
|
|
309
|
+
The **Show the full query** (**Hele query tonen**) checkbox under Settings stays synchronized with API changes. All four methods
|
|
310
|
+
throw after destruction. Row count defaults to 15; library auto-grow defaults to
|
|
311
|
+
true. The demo explicitly uses false and persists the user's checkbox choice.
|
|
312
|
+
|
|
313
|
+
Changes preserve query text, selection, history, folds, tabs, execution and results;
|
|
314
|
+
they resize the same CodeMirror view. The settings are per editor instance and
|
|
315
|
+
apply to all its query tabs, including wrapped lines. Result renderers keep their
|
|
316
|
+
own height behavior. `onAutoGrowChange(enabled)` and `onEditorRowsChange(rows)`
|
|
317
|
+
run only when the corresponding value changes, not on initial mount. Persistence
|
|
318
|
+
belongs to the host. Hide the checkbox with `controls: { autoGrow: false }` while
|
|
319
|
+
retaining all methods.
|