initcode
This commit is contained in:
parent
59261852ca
commit
9fc2f7daee
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
.DS_Store
|
||||
phpunit.phar
|
||||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
*.project
|
||||
.idea/
|
||||
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jens Segers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
35
composer.json
Normal file
35
composer.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "aix/laravel-admin-ext-ueditor",
|
||||
"description": "UEditor extension for laravel-admin",
|
||||
"type": "library",
|
||||
"keywords": ["laravel-admin", "extension", "ueditor"],
|
||||
"homepage": "https://github.com/codingyu/UEditor",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "codingyu",
|
||||
"email": "everceyu@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"aix/laravel-admin": "1.*",
|
||||
"overtrue/laravel-ueditor": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~6.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Codingyu\\Ueditor\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Codingyu\\Ueditor\\UeditorServiceProvider"
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
14
resources/views/editor.blade.php
Normal file
14
resources/views/editor.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
<div class="{{$viewClass['form-group']}} {!! !$errors->has($errorKey) ? '' : 'has-error' !!}">
|
||||
|
||||
<label for="{{$id}}" class="{{$viewClass['label']}} control-label">{{$label}}</label>
|
||||
|
||||
<div class="{{$viewClass['field']}}">
|
||||
|
||||
@include('admin::form.error')
|
||||
|
||||
<textarea id="{{$id}}" name="{{$name}}">{!! old($column, $value) !!}</textarea>
|
||||
|
||||
@include('admin::form.help-block')
|
||||
|
||||
</div>
|
||||
</div>
|
||||
39
src/Editor.php
Normal file
39
src/Editor.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Codingyu\Ueditor;
|
||||
|
||||
use Encore\Admin\Form\Field;
|
||||
|
||||
class Editor extends Field
|
||||
{
|
||||
protected $view = 'laravel-admin-ueditor::editor';
|
||||
|
||||
protected static $js = [
|
||||
'vendor/ueditor/ueditor.config.js',
|
||||
'vendor/ueditor/ueditor.all.js',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$name = $this->formatName($this->column);
|
||||
|
||||
$config = Ueditor::config('config', []);
|
||||
|
||||
$config = json_encode(array_merge($config, $this->options));
|
||||
|
||||
$laravel_ueditor_route = config('ueditor.route.name');
|
||||
$token = csrf_token();
|
||||
|
||||
$this->script = <<<EOT
|
||||
|
||||
window.UEDITOR_CONFIG.serverUrl = '{$laravel_ueditor_route}';
|
||||
UE.delEditor("{$this->id}");
|
||||
var ue_{$this->id} = UE.getEditor('{$this->id}', {$config});
|
||||
ue_{$this->id}.ready(function() {
|
||||
ue_{$this->id}.execCommand('serverparam', '_token', '$token');
|
||||
});
|
||||
|
||||
EOT;
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
12
src/Ueditor.php
Normal file
12
src/Ueditor.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Codingyu\Ueditor;
|
||||
|
||||
use Encore\Admin\Extension;
|
||||
|
||||
class Ueditor extends Extension
|
||||
{
|
||||
public $name = 'ueditor';
|
||||
|
||||
public $views = __DIR__.'/../resources/views';
|
||||
}
|
||||
28
src/UeditorServiceProvider.php
Normal file
28
src/UeditorServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Codingyu\Ueditor;
|
||||
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Admin;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class UeditorServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function boot(Ueditor $extension)
|
||||
{
|
||||
if (!Ueditor::boot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($views = $extension->views()) {
|
||||
$this->loadViewsFrom($views, 'laravel-admin-ueditor');
|
||||
}
|
||||
|
||||
Admin::booting(function () {
|
||||
Form::extend(Ueditor::config('field_type', 'UEditor'), Editor::class);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user