@agentix-e/spel-editor 0.1.0 → 0.1.1
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 +1 -1
- package/dist/index.js +6 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Web-embeddable Spring Expression Language (SpEL) editor.
|
|
4
4
|
> Based on CodeMirror 6 + spel-ts v1.1.0. Framework-agnostic Web Component.
|
|
5
5
|
|
|
6
|
-
[](https://www.npmjs.com/package/@agentix-e/spel-editor)
|
|
7
7
|
|
|
8
8
|
## Quick Start
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
20
20
|
// src/spel-editor.ts
|
|
21
21
|
import { LitElement, html, css } from "lit";
|
|
22
22
|
import { customElement, property, query } from "lit/decorators.js";
|
|
23
|
-
import {
|
|
24
|
-
EditorView,
|
|
25
|
-
keymap,
|
|
26
|
-
placeholder as cmPlaceholder
|
|
27
|
-
} from "@codemirror/view";
|
|
23
|
+
import { EditorView, keymap, placeholder as cmPlaceholder } from "@codemirror/view";
|
|
28
24
|
import { EditorState } from "@codemirror/state";
|
|
29
25
|
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
30
26
|
import { closeBrackets, autocompletion } from "@codemirror/autocomplete";
|
|
@@ -184,19 +180,13 @@ function spelLanguage() {
|
|
|
184
180
|
|
|
185
181
|
// src/cm6/completion-source.ts
|
|
186
182
|
import "@codemirror/autocomplete";
|
|
187
|
-
import {
|
|
188
|
-
SpelCompletionEngine
|
|
189
|
-
} from "@agentix-e/spel-ts";
|
|
183
|
+
import { SpelCompletionEngine } from "@agentix-e/spel-ts";
|
|
190
184
|
function spelCompletion(getContextSchema) {
|
|
191
185
|
return (context) => {
|
|
192
186
|
const expression = context.state.sliceDoc();
|
|
193
187
|
const position = context.pos;
|
|
194
188
|
const schema = getContextSchema?.() ?? void 0;
|
|
195
|
-
const items = SpelCompletionEngine.getCompletions(
|
|
196
|
-
expression,
|
|
197
|
-
position,
|
|
198
|
-
schema
|
|
199
|
-
);
|
|
189
|
+
const items = SpelCompletionEngine.getCompletions(expression, position, schema);
|
|
200
190
|
const validFor = /\w*/;
|
|
201
191
|
return {
|
|
202
192
|
from: context.matchBefore(validFor)?.from ?? position,
|
|
@@ -336,7 +326,7 @@ var EDITOR_STYLES = css`
|
|
|
336
326
|
}
|
|
337
327
|
.cm-editor {
|
|
338
328
|
height: 100%;
|
|
339
|
-
font-family: var(--spel-font-family,
|
|
329
|
+
font-family: var(--spel-font-family, 'JetBrains Mono', monospace);
|
|
340
330
|
font-size: var(--spel-font-size, 14px);
|
|
341
331
|
line-height: var(--spel-line-height, 1.6);
|
|
342
332
|
}
|
|
@@ -525,10 +515,7 @@ runDiagnostics_fn = function() {
|
|
|
525
515
|
__privateSet(this, _diagnosticCache, []);
|
|
526
516
|
return;
|
|
527
517
|
}
|
|
528
|
-
__privateSet(this, _diagnosticCache, SpelDiagnosticEngine2.validate(
|
|
529
|
-
expr,
|
|
530
|
-
this.contextSchema ?? void 0
|
|
531
|
-
));
|
|
518
|
+
__privateSet(this, _diagnosticCache, SpelDiagnosticEngine2.validate(expr, this.contextSchema ?? void 0));
|
|
532
519
|
this.dispatchEvent(
|
|
533
520
|
new CustomEvent("validate", {
|
|
534
521
|
detail: { diagnostics: __privateGet(this, _diagnosticCache) },
|
|
@@ -576,9 +563,7 @@ fireChange_fn = function() {
|
|
|
576
563
|
value: this.value,
|
|
577
564
|
isValid: syntaxDiags.length === 0
|
|
578
565
|
};
|
|
579
|
-
this.dispatchEvent(
|
|
580
|
-
new CustomEvent("change", { detail, bubbles: true, composed: true })
|
|
581
|
-
);
|
|
566
|
+
this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
|
|
582
567
|
};
|
|
583
568
|
SpelEditor.styles = EDITOR_STYLES;
|
|
584
569
|
__decorateClass([
|
package/package.json
CHANGED