Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jinyonson
news
Commits
0c1e9bf4
Commit
0c1e9bf4
authored
Oct 31, 2018
by
jinyonson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文章编辑器
parent
66da9c77
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
158 additions
and
14 deletions
+158
-14
uEditor.php
app/Admin/Extensions/Form/uEditor.php
+1
-1
PHPEditor.php
app/Admin/Extensions/PHPEditor.php
+44
-0
WangEditor.php
app/Admin/Extensions/WangEditor.php
+38
-0
bootstrap.php
app/Admin/bootstrap.php
+19
-3
routes.php
app/Admin/routes.php
+3
-0
ArticleController.php
app/Http/Controllers/Admin/ArticleController.php
+16
-1
composer.lock
composer.lock
+5
-5
UEditorUpload.php
config/UEditorUpload.php
+1
-1
php-editor.blade.php
resources/views/admin/php-editor.blade.php
+13
-0
uEditor.blade.php
resources/views/admin/uEditor.blade.php
+1
-3
wang-editor.blade.php
resources/views/admin/wang-editor.blade.php
+17
-0
No files found.
app/Admin/Extensions/Form/uEditor.php
View file @
0c1e9bf4
...
...
@@ -27,7 +27,7 @@ class uEditor extends Field
autotypeset: {indent: true, imageBlockLine: 'center'}
});
ue.ready(function () {
ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');
ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');
});
EOT;
return
parent
::
render
();
...
...
app/Admin/Extensions/PHPEditor.php
0 → 100644
View file @
0c1e9bf4
<?php
namespace
App\Admin\Extensions
;
use
Encore\Admin\Form\Field
;
class
PHPEditor
extends
Field
{
protected
$view
=
'admin.php-editor'
;
protected
static
$css
=
[
'/packages/codemirror-5.41.0/lib/codemirror.css'
,
];
protected
static
$js
=
[
'/packages/codemirror-5.41.0/lib/codemirror.js'
,
'/packages/codemirror-5.41.0/addon/edit/matchbrackets.js'
,
'/packages/codemirror-5.41.0/mode/htmlmixed/htmlmixed.js'
,
'/packages/codemirror-5.41.0/mode/xml/xml.js'
,
'/packages/codemirror-5.41.0/mode/javascript/javascript.js'
,
'/packages/codemirror-5.41.0/mode/css/css.js'
,
'/packages/codemirror-5.41.0/mode/clike/clike.js'
,
'/packages/codemirror-5.41.0/mode/php/php.js'
,
];
public
function
render
()
{
$this
->
script
=
<<<EOT
CodeMirror.fromTextArea(document.getElementById("{$this->id}"), {
lineNumbers: true,
mode: "text/x-php",
extraKeys: {
"Tab": function(cm){
cm.replaceSelection(" " , "end");
}
}
});
EOT;
return
parent
::
render
();
}
}
\ No newline at end of file
app/Admin/Extensions/WangEditor.php
0 → 100644
View file @
0c1e9bf4
<?php
namespace
App\Admin\Extensions
;
use
Encore\Admin\Form\Field
;
class
WangEditor
extends
Field
{
protected
$view
=
'admin.wang-editor'
;
protected
static
$css
=
[
'/vendor/wangEditor-3.1.1/release/wangEditor.min.css'
,
];
protected
static
$js
=
[
'/vendor/wangEditor-3.1.1/release/wangEditor.min.js'
,
];
public
function
render
()
{
$name
=
$this
->
formatName
(
$this
->
column
);
$this
->
script
=
<<<EOT
var E = window.wangEditor
var editor = new E('#{$this->id}');
editor.customConfig.zIndex = 0
editor.customConfig.uploadImgShowBase64 = true
editor.customConfig.onchange = function (html) {
$('input[name=\'$name\']').val(html);
}
editor.create()
EOT;
return
parent
::
render
();
}
}
\ No newline at end of file
app/Admin/bootstrap.php
View file @
0c1e9bf4
...
...
@@ -18,9 +18,25 @@
*
*/
use
App\Admin\Extensions\Form\uEditor
;
//use App\Admin\Extensions\Form\uEditor;
//use Encore\Admin\Form;
//use App\Admin\Extensions\PHPEditor;
//use App\Admin\Extensions\WangEditor;
//
//
//
//##Encore\Admin\Form::forget(['map', 'editor']);
//
//
//Form::extend('php', PHPEditor::class);
//Form::extend('editor', WangEditor::class);
//
//Form::extend('ueditor', uEditor::class);
use
App\Admin\Extensions\WangEditor
;
use
Encore\Admin\Form
;
Form
::
extend
(
'ueditor'
,
uEditor
::
class
);
Form
::
extend
(
'editor'
,
WangEditor
::
class
);
Encore\Admin\Form
::
forget
([
'map'
,
'editor'
]);
app/Admin/routes.php
View file @
0c1e9bf4
...
...
@@ -9,10 +9,13 @@ Route::group([
'namespace'
=>
config
(
'admin.route.namespace'
),
'middleware'
=>
config
(
'admin.route.middleware'
),
],
function
(
Router
$router
)
{
$router
->
post
(
'/upload/pictures'
,
'UploadController@pictures'
);
$router
->
get
(
'/'
,
'HomeController@index'
);
//$router->get('/article', 'ArticleController@index');
$router
->
resource
(
'/article'
,
'ArticleController'
);
$router
->
resource
(
'/articlecat'
,
'ArticlecatController'
);
///upload/picturesRoute::post('/uploadFile', 'UploadsController@uploadImg');
});
app/Http/Controllers/Admin/ArticleController.php
View file @
0c1e9bf4
...
...
@@ -116,9 +116,24 @@ class ArticleController extends Controller
//$form->select('articlecats_id','分类')->options(Articlecat::getSelectOptions());
$form
->
select
(
'articlecats_id'
,
'分类'
)
->
options
(
Articlecat
::
selectOptions
());
$form
->
text
(
'message'
,
'描述'
);
$form
->
ueditor
(
'content'
,
'内容'
)
->
rules
(
'required'
);
//$form->ueditor('content', '内容')->rules('required');
$form
->
editor
(
'content'
,
'内容'
);
//$form->editor('content','内容');
$form
->
switch
(
'is_show'
,
'是否显示'
);
$form
->
number
(
'sort_order'
,
'排序'
);
return
$form
;
}
public
function
uploadImg
(
Request
$request
)
{
$disk
=
\Storage
::
disk
(
'qiniu'
);
//使用七牛云上传
$time
=
date
(
'Y/m/d-H:i:s-'
);
$filename
=
$disk
->
put
(
$time
,
$request
->
file
(
'img'
));
//上传
if
(
!
$filename
)
{
return
json_response
(
-
1
,
'上传失败'
);
}
$img_url
=
$disk
->
getDriver
()
->
downloadUrl
(
$filename
);
//获取下载链接
return
json_response
(
200
,
'上传成功'
,
$img_url
);
}
}
composer.lock
View file @
0c1e9bf4
...
...
@@ -4785,16 +4785,16 @@
},
{
"name": "phpunit/php-token-stream",
"version": "3.0.
0
",
"version": "3.0.
1
",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "
21ad88bbba7c3d93530d93994e0a33cd45f02ace
"
"reference": "
c99e3be9d3e85f60646f152f9002d46ed7770d18
"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/
21ad88bbba7c3d93530d93994e0a33cd45f02ace
",
"reference": "
21ad88bbba7c3d93530d93994e0a33cd45f02ace
",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/
c99e3be9d3e85f60646f152f9002d46ed7770d18
",
"reference": "
c99e3be9d3e85f60646f152f9002d46ed7770d18
",
"shasum": "",
"mirrors": [
{
...
...
@@ -4836,7 +4836,7 @@
"keywords": [
"tokenizer"
],
"time": "2018-
02-01T13:16:43
+00:00"
"time": "2018-
10-30T05:52:18
+00:00"
},
{
"name": "phpunit/phpunit",
...
...
config/UEditorUpload.php
View file @
0c1e9bf4
...
...
@@ -18,7 +18,7 @@ return [
*/
'core'
=>
[
'route'
=>
[
//
'middleware' => 'auth',
//
'middleware' => 'auth',
],
'mode'
=>
'local'
,
//上传方式,local 为本地 qiniu 为七牛
...
...
resources/views/admin/php-editor.blade.php
0 → 100644
View file @
0c1e9bf4
<div
class=
"form-group {!! !$errors->has($label) ?: 'has-error' !!}"
>
<label
for=
"{{$id}}"
class=
"col-sm-2 control-label"
>
{{$label}}
</label>
<div
class=
"col-sm-6"
>
@include('admin::form.error')
<textarea
class=
"form-control"
id=
"{{$id}}"
name=
"{{$name}}"
placeholder=
"{{ trans('admin::lang.input') }} {{$label}}"
{!!
$
attributes
!!}
>
{{ old($column, $value) }}
</textarea>
</div>
</div>
\ No newline at end of file
resources/views/admin/uEditor.blade.php
View file @
0c1e9bf4
...
...
@@ -2,9 +2,7 @@
<label
for=
"{{$id}}"
class=
"col-sm-2 control-label"
>
{{$label}}
</label>
<div
class=
"col-sm-8"
>
@include('admin::form.error')
<textarea
type=
'text/plain'
style=
"height:400px;"
id=
'ueditor'
id=
"{{$id}}"
name=
"{{$name}}"
placeholder=
"{{ $placeholder }}"
{!!
$
attributes
!!}
class=
'ueditor'
>
{!! old($column, $value) !!}
</textarea>
<textarea
type=
'text/plain'
style=
"height:400px;"
id=
'ueditor'
id=
"{{$id}}"
name=
"{{$name}}"
placeholder=
"{{ $placeholder }}"
{!!
$
attributes
!!}
class=
'ueditor'
>
{!! old($column, $value) !!}
</textarea>
@include('admin::form.help-block')
</div>
</div>
resources/views/admin/wang-editor.blade.php
0 → 100644
View file @
0c1e9bf4
<div
class=
"form-group {!! !$errors->has($label) ?: 'has-error' !!}"
>
<label
for=
"{{$id}}"
class=
"col-sm-2 control-label"
>
{{$label}}
</label>
<div
class=
"{{$viewClass['field']}}"
>
@include('admin::form.error')
<div
id=
"{{$id}}"
style=
"width: 100%; height: 100%;"
>
<p>
{!! old($column, $value) !!}
</p>
</div>
<input
type=
"hidden"
name=
"{{$name}}"
value=
"{{ old($column, $value) }}"
/>
</div>
</div>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment