Skip to content

Commit a2a2643

Browse files
Merge pull request #5 from alaminfirdows/2.x
Release Version 2.x
2 parents f791e68 + 93ef9b3 commit a2a2643

File tree

6 files changed

+77
-54
lines changed

6 files changed

+77
-54
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,22 @@ $post = Post::find(1);
6060
echo $post->body;
6161
```
6262

63+
## Versioning
64+
65+
| Laravel | Supported |
66+
| ------- | --------- |
67+
| 10.x | ✅ 2.x |
68+
| 9.x | ✅ 1.1 |
69+
| 8.x | ✅ 1.0 |
70+
6371
## Contributing
6472

6573
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
6674

6775
## Credits
6876

69-
- [Al-Amin Firdows](https://github.com/alaminfirdows)
70-
- [All Contributors](../../contributors)
77+
- [Al-Amin Firdows](https://github.com/alaminfirdows)
78+
- [All Contributors](../../contributors)
7179

7280
## License
7381

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.4|^8",
14-
"codex-team/editor.js": "dev-master",
15-
"illuminate/support": "^6|^7|^8|^9"
13+
"php": "^7.2|^8.1",
14+
"codex-team/editor.js": "v2.0.7",
15+
"illuminate/support": "^8.0|^9.0|^10.0"
1616
},
1717
"require-dev": {
1818
"orchestra/testbench": "^6.0",

config/laravel_editorjs.php

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
<?php
22

33
return [
4-
'config' => [
4+
'config' => [
55
'tools' => [
66
'paragraph' => [
7-
'text' => [
8-
'type' => 'string',
9-
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
7+
'text' => [
8+
'type' => 'string',
9+
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
1010
],
1111
],
12-
'header' => [
13-
'text' => [
14-
'type' => 'string',
12+
'header' => [
13+
'text' => [
14+
'type' => 'string',
1515
'allowedTags' => 'a[href],mark[class]',
1616
],
1717
'level' => [1, 2, 3, 4, 5, 6],
1818
],
19-
'list' => [
20-
'style' => [
19+
'list' => [
20+
'type' => [
2121
0 => 'ordered',
2222
1 => 'unordered',
2323
],
2424
'items' => [
2525
'type' => 'array',
2626
'data' => [
2727
'-' => [
28-
'type' => 'string',
28+
'type' => 'string',
2929
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
3030
],
3131
],
3232
],
3333
],
34-
'linkTool' => [
34+
'linkTool' => [
3535
'link' => 'string',
3636
'meta' => [
3737
'type' => 'array',
3838
'data' => [
39-
'title' => [
39+
'title' => [
4040
'type' => 'string',
4141
],
4242
'description' => [
4343
'type' => 'string',
4444
],
45-
'url' => [
46-
'type' => 'string',
45+
'url' => [
46+
'type' => 'string',
4747
'required' => false,
4848
],
49-
'domain' => [
50-
'type' => 'string',
49+
'domain' => [
50+
'type' => 'string',
5151
'required' => false,
5252
],
53-
'image' => [
54-
'type' => 'array',
53+
'image' => [
54+
'type' => 'array',
5555
'required' => false,
56-
'data' => [
56+
'data' => [
5757
'url' => [
5858
'type' => 'string',
5959
],
@@ -62,73 +62,85 @@
6262
],
6363
],
6464
],
65-
'image' => [
66-
'file' => [
65+
'image' => [
66+
'file' => [
6767
'type' => 'array',
6868
'data' => [
69-
'width' => [
70-
'type' => 'integer',
69+
'width' => [
70+
'type' => 'integer',
7171
'required' => false,
7272
],
7373
'height' => [
74-
'type' => 'integer',
74+
'type' => 'integer',
7575
'required' => false,
7676
],
77-
'url' => 'string',
77+
'url' => 'string',
7878
],
7979
],
80-
'caption' => [
81-
'type' => 'string',
80+
'caption' => [
81+
'type' => 'string',
8282
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
8383
],
84-
'withBorder' => 'boolean',
84+
'withBorder' => 'boolean',
8585
'withBackground' => 'boolean',
86-
'stretched' => 'boolean',
86+
'stretched' => 'boolean',
8787
],
88-
'table' => [
88+
'table' => [
8989
'withHeadings' => 'boolean',
90-
'content' => [
90+
'content' => [
9191
'type' => 'array',
9292
'data' => [
9393
'-' => [
9494
'type' => 'array',
9595
'data' => [
9696
'-' => [
97-
'type' => 'string',
97+
'type' => 'string',
9898
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
9999
],
100100
],
101101
],
102102
],
103103
],
104104
],
105-
'quote' => [
106-
'text' => [
107-
'type' => 'string',
105+
'quote' => [
106+
'text' => [
107+
'type' => 'string',
108108
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
109109
],
110-
'caption' => [
111-
'type' => 'string',
110+
'caption' => [
111+
'type' => 'string',
112112
'allowedTags' => 'i,b,a[href],code[class],mark[class]',
113113
],
114114
'alignment' => [
115115
0 => 'left',
116116
1 => 'center',
117117
],
118118
],
119-
'code' => [
119+
'code' => [
120120
'code' => [
121-
'type' => 'string',
121+
'type' => 'string',
122122
'allowedTags' => '*',
123123
],
124124
],
125125
'delimiter' => [],
126-
'raw' => [
126+
'raw' => [
127127
'html' => [
128-
'type' => 'string',
128+
'type' => 'string',
129129
'allowedTags' => '*',
130130
],
131131
],
132+
// 'attaches' => [
133+
// 'file' => [
134+
// 'type' => 'array',
135+
// 'data' => [
136+
// 'url' => 'string',
137+
// 'size' => 'integer',
138+
// 'name' => 'string',
139+
// 'extension' => 'string',
140+
// ],
141+
// ],
142+
// 'title' => 'string',
143+
// ]
132144
],
133145
],
134-
];
146+
];

resources/views/blocks/list.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@php
22
$tag = 'ul';
3-
if('ordered' === $data['style']){
3+
if('ordered' === $data['type']){
44
$tag = 'ol';
55
}
66
@endphp
@@ -9,4 +9,4 @@
99
@foreach($data['items'] as $item)
1010
<li>{{ $item }}</li>
1111
@endforeach
12-
</{{ $tag }}>
12+
</{{ $tag }}>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p style="color: red">{{ __('Block Not Found!') }}</p>
1+
<p style="color: red">{{ "{$type}: " . __('Block Not Found!') }}</p>

src/LaravelEditorJs.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LaravelEditorJs
1515
* @param string $data
1616
* @return string
1717
*/
18-
public function render(string $data): string
18+
public function render(string $data) : string
1919
{
2020
try {
2121
$configJson = json_encode(config('laravel_editorjs.config') ?: []);
@@ -28,16 +28,19 @@ public function render(string $data): string
2828

2929
$viewName = "laravel_editorjs::blocks." . Str::snake($block['type'], '-');
3030

31-
if (!View::exists($viewName)) {
31+
if (! View::exists($viewName)) {
3232
$viewName = 'laravel_editorjs::blocks.not-found';
3333
}
3434

35-
$renderedBlocks[] = View::make($viewName, ['data' => $block['data']])->render();
35+
$renderedBlocks[] = View::make($viewName, [
36+
'type' => $block['type'],
37+
'data' => $block['data']
38+
])->render();
3639
}
3740

3841
return implode($renderedBlocks);
3942
} catch (EditorJSException $e) {
4043
throw new \Exception($e->getMessage());
4144
}
4245
}
43-
}
46+
}

0 commit comments

Comments
 (0)