From 9fc2f7daee50f4f31e621e72066ccc73516cd197 Mon Sep 17 00:00:00 2001 From: chenc <1458513@qq.com> Date: Wed, 21 Sep 2022 14:12:17 +0800 Subject: [PATCH] initcode --- .gitignore | 7 ++++++ LICENSE | 20 ++++++++++++++++ composer.json | 35 ++++++++++++++++++++++++++++ resources/views/editor.blade.php | 14 ++++++++++++ src/Editor.php | 39 ++++++++++++++++++++++++++++++++ src/Ueditor.php | 12 ++++++++++ src/UeditorServiceProvider.php | 28 +++++++++++++++++++++++ 7 files changed, 155 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 composer.json create mode 100644 resources/views/editor.blade.php create mode 100644 src/Editor.php create mode 100644 src/Ueditor.php create mode 100644 src/UeditorServiceProvider.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d4b362 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +phpunit.phar +/vendor +composer.phar +composer.lock +*.project +.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..229071a --- /dev/null +++ b/LICENSE @@ -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. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a98c5a7 --- /dev/null +++ b/composer.json @@ -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" + ] + + } + } +} diff --git a/resources/views/editor.blade.php b/resources/views/editor.blade.php new file mode 100644 index 0000000..05e0a97 --- /dev/null +++ b/resources/views/editor.blade.php @@ -0,0 +1,14 @@ +
+ + + +
+ + @include('admin::form.error') + + + + @include('admin::form.help-block') + +
+
\ No newline at end of file diff --git a/src/Editor.php b/src/Editor.php new file mode 100644 index 0000000..4cbffc1 --- /dev/null +++ b/src/Editor.php @@ -0,0 +1,39 @@ +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 = <<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(); + } +} diff --git a/src/Ueditor.php b/src/Ueditor.php new file mode 100644 index 0000000..70fb600 --- /dev/null +++ b/src/Ueditor.php @@ -0,0 +1,12 @@ +views()) { + $this->loadViewsFrom($views, 'laravel-admin-ueditor'); + } + + Admin::booting(function () { + Form::extend(Ueditor::config('field_type', 'UEditor'), Editor::class); + }); + } +}