1.0.0 • Published 8 months ago
@valtzu/codemirror-lang-el v1.0.0
Symfony Expression Language support for CodeMirror 6
Features
Linting
- Lint variable & function names
- Lint object properties & methods, even on expression result
- Lint argument count
- Lint argument types
Autocompletion
- Complete variables & functions
- Complete object properties & methods, even on expression result
- Complete operator keywords (like starts with)
- Show list of all available keywords (using Ctrl+spaceby default)
Hover tooltip
- Show description about a variable / function / object member / keyword
Function argument hints
- Show function argument name when the editor cursor is exactly at starting position of the argument
Installation
Symfony AssetMapper
bin/console importmap:require @valtzu/codemirror-lang-elnpm
npm install @valtzu/codemirror-lang-elYarn
yarn add @valtzu/codemirror-lang-elConfiguration
See CONFIGURATION.md
Example
<div id="editor"></div>
<script type="module">
    import { EditorView, basicSetup } from "codemirror";
    import { acceptCompletion } from "@codemirror/autocomplete";
    import { keymap } from "@codemirror/view";
    import { expressionlanguage } from "@valtzu/codemirror-lang-el";
    import { defaultKeymap } from "@codemirror/commands";
    let editor = new EditorView({
        extensions: [
            basicSetup,
            keymap.of([...defaultKeymap, {key: "Tab", run: acceptCompletion}]),
            expressionlanguage({
                types: {
                    "User": {
                        identifiers: [
                            { name: "self", type: ["User"], info: 'Self-reference for property-access demonstration purposes' },
                            { name: "name", type: ["string"] },
                            { name: "age", type: ["int"], info: "Years since birthday", detail: "years" },
                        ],
                        functions: [
                            { name: "isActive", returnType: ["bool"] },
                            { name: "getGroup", args: [], returnType: ["Group"], info: 'Get the user group' },
                        ],
                    },
                    "Group": {
                        identifiers: [{ name: "name", type: ["string"] }]
                    }
                },
                identifiers: [
                    { name: "user", type: ["User"], info: 'This is the user' },
                ],
                functions: [
                    { name: "is_granted", args: [{name: "attributes", type: ["string"]}, {name: "object", type: ["object"], optional: true}], info: 'Check if subject has permission to the object', returnType: ['bool'] },
                ],
            })
        ],
        parent: document.getElementById('editor'),
        doc: 'is_granted(user, user.self.getGroup())',
    });
</script>Contributing
Contributions are welcome.
1.0.0
8 months ago
0.10.0
9 months ago
0.9.0
9 months ago
0.8.0
10 months ago
0.7.0
1 year ago
0.6.2
1 year ago
0.6.1
1 year ago
0.6.0
1 year ago
0.5.3
1 year ago
0.5.2
2 years ago
0.5.1
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.4.2
2 years ago
0.3.0
2 years ago
0.2.3
2 years ago
0.2.2
2 years ago
0.2.1
2 years ago
0.1.13
2 years ago