symfony-expression-editor 1.0.0 → 1.1.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/CHANGELOG.md +9 -0
- package/README.md +66 -5
- package/dist/index.cjs +65 -1758
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +65 -1758
- package/example.html +32 -9
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
1.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
* Prevent form submit when there are linter errors
|
|
8
|
+
|
|
9
|
+
0.3.0
|
|
10
|
+
---
|
|
11
|
+
* Add support for `.form-control-plaintext`, `[disabled]` and `[readonly]`
|
|
12
|
+
|
|
4
13
|
0.2.0
|
|
5
14
|
---
|
|
6
15
|
* Add some animations to reduce flickering
|
package/README.md
CHANGED
|
@@ -1,16 +1,75 @@
|
|
|
1
1
|
Symfony Expression Editor Web Component
|
|
2
2
|
---
|
|
3
3
|
|
|
4
|
-
### What
|
|
5
|
-
|
|
6
4
|
Enhance regular `<textarea>` element with linting, syntax highlighting, autocompletion etc.
|
|
7
5
|
Contains styles so that it looks like built-in **Bootstrap 5.3** component. Editor styles are reactive to `data-bs-theme` attributes.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
### Full Symfony example
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
symfony new my-project # or composer create-project my-project
|
|
13
|
+
cd my-project
|
|
14
|
+
composer require twig asset-mapper form
|
|
15
|
+
bin/console importmap:require 'bootstrap/dist/css/bootstrap.min.css@5.3.3' 'symfony-expression-editor@1.0.0'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
#### Add these to `assets/app.js`:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
22
|
+
import 'symfony-expression-editor';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### `src/Controller/MyController.php`
|
|
10
26
|
|
|
11
|
-
|
|
27
|
+
```php
|
|
28
|
+
namespace App\Controller;
|
|
12
29
|
|
|
13
|
-
|
|
30
|
+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
31
|
+
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
|
32
|
+
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
33
|
+
use Symfony\Component\Routing\Attribute\Route;
|
|
34
|
+
|
|
35
|
+
class MyController extends AbstractController
|
|
36
|
+
{
|
|
37
|
+
#[Route('/')]
|
|
38
|
+
public function index()
|
|
39
|
+
{
|
|
40
|
+
return $this->render('form.html.twig', [
|
|
41
|
+
'expressionForm' => $this->createForm(FormType::class)
|
|
42
|
+
->add('expression', TextareaType::class, [
|
|
43
|
+
'attr' => [
|
|
44
|
+
'is' => 'expression-editor',
|
|
45
|
+
'data-config' => json_encode([
|
|
46
|
+
'identifiers' => [
|
|
47
|
+
['name' => 'foo'],
|
|
48
|
+
['name' => 'bar'],
|
|
49
|
+
]
|
|
50
|
+
]),
|
|
51
|
+
],
|
|
52
|
+
])
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### `templates/form.html.twig`
|
|
59
|
+
|
|
60
|
+
```twig
|
|
61
|
+
{% extends 'base.html.twig' %}
|
|
62
|
+
{% block body %}
|
|
63
|
+
<div class="m-3">
|
|
64
|
+
{{ form(expressionForm) }}
|
|
65
|
+
</div>
|
|
66
|
+
{% endblock %}
|
|
67
|
+
```
|
|
68
|
+
#### Result
|
|
69
|
+
|
|
70
|
+
<img width="355" height="119" alt="image" src="https://github.com/user-attachments/assets/3f973fd7-4e8a-4c5f-9b22-577ccfba1a12" />
|
|
71
|
+
|
|
72
|
+
### Directly from frontend
|
|
14
73
|
|
|
15
74
|
```html
|
|
16
75
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
@@ -19,3 +78,5 @@ Configuring CodeMirror and making it blend into UI can be tricky
|
|
|
19
78
|
```
|
|
20
79
|
|
|
21
80
|

|
|
81
|
+
|
|
82
|
+
_(picture above is from [example.html](example.html))_
|