Skip to content

Commit f7c7a58

Browse files
committed
init
0 parents  commit f7c7a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3243
-0
lines changed

LICENSE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Copyright © 2020 by Andrey Zakurdaev All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7+
Neither the name of Yii Software LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Editor.js Widget for Yii 2
2+
3+
`Editor.js Widget` is a wrapper for [Editor.js](https://github.com/codex-team/editor.js), next generation block styled editor.
4+
5+
## Install
6+
7+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
8+
9+
Either run
10+
11+
```bash
12+
$ php composer.phar require --prefer-dist zakurdaev/yii2-editorjs-widget "*"
13+
```
14+
15+
or add
16+
17+
```json
18+
"zakurdaev/yii2-editorjs-widget": "*"
19+
```
20+
21+
to the `require` section of your `composer.json` file.
22+
23+
24+
## Usage
25+
26+
Once the extension is installed, simply use it in your code:
27+
28+
### Like a widget
29+
30+
```php
31+
echo \zakurdaev\editorjs\EditorJsWidget::widget([
32+
'selector' => 'redactor'
33+
]);
34+
```
35+
36+
### Like an ActiveForm widget
37+
38+
```php
39+
use \zakurdaev\editorjs\EditorJsWidget;
40+
41+
echo $form->field($model, 'content_json')->widget(EditorJsWidget::class, [
42+
'selectorForm' => $form->id
43+
])->label();
44+
```
45+
### Supported block
46+
The plugin is able to support all blocks for Editor.js. You can use the standard Asset or use Asset CDN or write your own.
47+
48+
#### EditorJsAsset
49+
Include:
50+
* editorjs/header v2.4.1
51+
* editorjs/paragraph v2.6.1
52+
* editorjs/image v2.3.4
53+
* editorjs/list v1.4.0
54+
* editorjs/table v1.2.2
55+
* editorjs/quote v2.3.0
56+
* editorjs/warning v1.1.1
57+
* editorjs/code v2.4.1
58+
* editorjs/embed v2.3.1
59+
* editorjs/delimiter v1.1.0
60+
* editorjs/inline-code v1.3.1
61+
62+
#### Custom Asset
63+
```php
64+
use \zakurdaev\editorjs\EditorJsWidget;
65+
66+
echo $form->field($model, 'content_json')->widget(EditorJsWidget::class, [
67+
'selectorForm' => $form->id,
68+
'assetClass' => 'YOUR/PATH/TO/ASSET'
69+
])->label();
70+
```
71+
72+
73+
### Upload image by file and url
74+
75+
Widget supports image loading for [Editor.js Image Block](https://github.com/editor-js/image).
76+
77+
```php
78+
// SiteController.php
79+
public function actions()
80+
{
81+
return [
82+
'upload-file' => [
83+
'class' => UploadImageAction::class,
84+
'mode' => UploadImageAction::MODE_FILE,
85+
'url' => 'https://example.com/upload_dir/',
86+
'path' => '@app/web/upload_dir',
87+
'validatorOptions' => [
88+
'maxWidth' => 1000,
89+
'maxHeight' => 1000
90+
]
91+
],
92+
'fetch-url' => [
93+
'class' => UploadImageAction::class,
94+
'mode' => UploadImageAction::MODE_URL,
95+
'url' => 'https://example.com/upload_dir/',
96+
'path' => '@app/web/upload_dir'
97+
]
98+
];
99+
}
100+
101+
// view.php
102+
echo \zakurdaev\editorjs\EditorJsWidget::widget([
103+
'selector' => 'redactor',
104+
'endpoints' => [
105+
'uploadImageByFile' => Url::to(['/site/upload-file']),
106+
'uploadImageByUrl' => Url::to(['/site/fetch-url']),
107+
],
108+
]);
109+
```
110+
111+
## License
112+
The BSD License (BSD).Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "zakurdaev/yii2-editorjs-widget",
3+
"description": "Use editor.js in form. Module for Yii2",
4+
"type": "yii2-extension",
5+
"license": "BSD-3-Clause",
6+
"version": "1.0.0",
7+
"homepage": "https://github.com/zakurdaev/yii2-editorjs-widget",
8+
"authors": [
9+
{
10+
"name": "Andrey Zakurdaev",
11+
"email": "andrey@zakurdaev.pro"
12+
}
13+
],
14+
"keywords": [
15+
"editor.js",
16+
"redactor",
17+
"wysiwyg",
18+
"yii2",
19+
"yii 2",
20+
"yii2 widget"
21+
],
22+
"support": {
23+
"issues": "https://github.com/zakurdaev/yii2-editorjs-widget/issues?state=open",
24+
"source": "https://github.com/zakurdaev/yii2-editorjs-widget"
25+
},
26+
"require": {
27+
"php": ">=7.0",
28+
"yiisoft/yii2": "~2.0.0",
29+
"codex-team/editor.js": "*"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"zakurdaev\\editorjs\\": "src"
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)