Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24c4cf4
commit 1fc866a
Showing
15 changed files
with
634 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,139 @@ | ||
<?php | ||
|
||
Itf()->add('create-topic-comment-handle-middleware-end', 0, \App\Plugins\Comment\src\Handler\Middleware\Create\Topic\EndMiddleware::class); | ||
|
||
Itf()->add('comment-topic-create-editor-external_plugins', 0, [ | ||
'sfPreview' => file_hash('plugins/Topic/js/editor/plugins/sfPreview.js'), | ||
]); | ||
Itf()->add('comment-topic-edit-editor-external_plugins', 0, [ | ||
'sfPreview' => file_hash('plugins/Topic/js/editor/plugins/sfPreview.js'), | ||
]); | ||
Itf()->add('comment-topic-create-editor-plugins', 0, ['importcss', 'searchreplace', 'autolink', 'autosave', 'directionality', 'code', 'visualblocks', 'visualchars', 'image', 'link', 'media', 'codesample', 'table', 'charmap', 'pagebreak', 'nonbreaking', 'advlist', 'lists', 'wordcount', 'charmap', 'quickbars']); | ||
Itf()->add('comment-topic-edit-editor-plugins', 0, ['importcss', 'searchreplace', 'autolink', 'autosave', 'directionality', 'code', 'visualblocks', 'visualchars', 'image', 'link', 'media', 'codesample', 'table', 'charmap', 'pagebreak', 'nonbreaking', 'advlist', 'lists', 'wordcount', 'charmap', 'quickbars']); | ||
|
||
Itf()->add('comment-topic-create-editor-toolbar', 0, ['undo', 'redo', '|', 'blocks', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'outdent', 'indent', 'numlist', 'bullist', '|', 'forecolor', 'backcolor', 'removeformat', 'insertfile', 'image', 'media', 'link', 'sfPreview', 'restoredraft', 'codesample', '|', 'ltr', 'rtl']); | ||
Itf()->add('comment-topic-edit-editor-toolbar', 0, ['undo', 'redo', '|', 'blocks', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'outdent', 'indent', 'numlist', 'bullist', '|', 'forecolor', 'backcolor', 'removeformat', 'insertfile', 'image', 'media', 'link', 'sfPreview', 'restoredraft', 'codesample', '|', 'ltr', 'rtl']); | ||
|
||
|
||
$editor_menu =[ | ||
'file' => [ | ||
'title' => 'File', | ||
'items' => [ | ||
'newdocument', | ||
'restoredraft', | ||
'|', | ||
'sfPreview', | ||
'export', | ||
'|', | ||
'deleteallconversations', | ||
], | ||
], | ||
'edit' => [ | ||
'title' => 'Edit', | ||
'items' => [ | ||
'undo', | ||
'redo', | ||
'|', | ||
'cut', | ||
'copy', | ||
'paste', | ||
'pastetext', | ||
'|', | ||
'selectall', | ||
'|', | ||
'searchreplace', | ||
], | ||
], | ||
'view' => [ | ||
'title' => 'View', | ||
'items' => [ | ||
'code', | ||
'|', | ||
'visualaid', | ||
'visualchars', | ||
'visualblocks', | ||
'|', | ||
'spellchecker', | ||
'|', | ||
'preview', | ||
'|', | ||
'showcomments', | ||
], | ||
], | ||
'insert' => [ | ||
'title' => 'Insert', | ||
'items' => [ | ||
'image', | ||
'link', | ||
'media', | ||
'addcomment', | ||
'pageembed', | ||
'template', | ||
'codesample', | ||
'inserttable', | ||
'|', | ||
'charmap', | ||
'emoticons', | ||
'hr', | ||
'|', | ||
'pagebreak', | ||
'nonbreaking', | ||
'anchor', | ||
'tableofcontents', | ||
], | ||
], | ||
'format' => [ | ||
'title' => 'Format', | ||
'items' => [ | ||
'bold', | ||
'italic', | ||
'underline', | ||
'strikethrough', | ||
'superscript', | ||
'subscript', | ||
'codeformat', | ||
'|', | ||
'styles', | ||
'blocks', | ||
'fontfamily', | ||
'fontsize', | ||
'align', | ||
'lineheight', | ||
'|', | ||
'forecolor', | ||
'backcolor', | ||
'|', | ||
'language', | ||
'|', | ||
'removeformat', | ||
], | ||
], | ||
'tools' => [ | ||
'title' => 'Tools', | ||
'items' => [ | ||
'spellchecker', | ||
'spellcheckerlanguage', | ||
'|', | ||
'a11ycheck', | ||
'code', | ||
'wordcount', | ||
], | ||
], | ||
'table' => [ | ||
'title' => 'Table', | ||
'items' => [ | ||
'inserttable', | ||
'|', | ||
'cell', | ||
'row', | ||
'column', | ||
'|', | ||
'advtablesort', | ||
'|', | ||
'tableprops', | ||
'deletetable', | ||
], | ||
], | ||
]; | ||
Itf()->add('comment-topic-create-editor-menu', 0, $editor_menu); | ||
Itf()->add('comment-topic-edit-editor-menu', 0, $editor_menu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
app/Plugins/Comment/resources/views/topic/create.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
@extends('App::app') | ||
@section('title','评论帖子【'.\Hyperf\Utils\Str::limit($topic->title,25).'】') | ||
@section('content') | ||
<div class="row row-cards justify-content-center"> | ||
<div class="col-lg-12"> | ||
<ol class="breadcrumb breadcrumb-arrows" aria-label="breadcrumbs"> | ||
<li class="breadcrumb-item"><a href="/">首页</a></li> | ||
<li class="breadcrumb-item"><a href="/tags/{{$topic->tag->id}}.html"> | ||
{!! $topic->tag->icon !!} | ||
{{$topic->tag->name}} | ||
</a> | ||
</li> | ||
<li class="breadcrumb-item"><a href="/{{$topic->id}}.html"> | ||
{{\Hyperf\Utils\Str::limit($topic->title,25)}} | ||
</a> | ||
</li> | ||
<li class="breadcrumb-item active" aria-current="page"><a href="#">回帖</a></li> | ||
</ol> | ||
</div> | ||
<div class="col-lg-12"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title">回帖</h3> | ||
</div> | ||
<div class="card-body"> | ||
<form action="/topic/create/comment/{{$topic->id}}" method="post"> | ||
<x-csrf/> | ||
<input type="hidden" name="no_content" value="1"> | ||
<input type="hidden" name="topic_id" value="{{$topic->id}}"> | ||
<div class="mb-3"> | ||
<label for="" class="form-label"></label> | ||
<textarea name="content" id="content" rows="3"></textarea> | ||
</div> | ||
<div class="mb-3 d-flex flex-row-reverse"> | ||
<button class="btn btn-primary" type="submit">回帖</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection | ||
|
||
|
||
@section('scripts') | ||
<script src="{{file_hash("js/axios.min.js")}}"></script> | ||
<script src="{{file_hash('tabler/libs/tinymce/tinymce.min.js')}}"></script> | ||
<script defer> | ||
const target = document.getElementsByTagName("html")[0] | ||
const body_className = document.getElementsByTagName("html")[0].getAttribute("data-theme"); | ||
const observer = new MutationObserver(function (mutations) { | ||
mutations.forEach(function (mutation) { | ||
if (body_className !== document.getElementsByTagName("html")[0].getAttribute("data-theme")) { | ||
location.reload() | ||
} | ||
}); | ||
}); | ||
|
||
observer.observe(target, {attributes: true}); | ||
|
||
const image_upload_handler = (blobInfo, progress) => new Promise((resolve, reject) => { | ||
const formData = new FormData(); | ||
formData.append('file', blobInfo.blob(), blobInfo.filename()); | ||
formData.append('_token', csrf_token); | ||
axios.post("/user/upload/image",formData,{ | ||
'Content-type' : 'multipart/form-data' | ||
}).then(function(r){ | ||
console.log(r) | ||
const data = r.data; | ||
if(data.success){ | ||
resolve(data.result.url); | ||
return ; | ||
} | ||
reject({message:'HTTP Error: ' + data.result.msg + ', Error Code: '+data.code,remove: true}); | ||
}).catch(function(e){ | ||
console.log(e) | ||
}) | ||
|
||
}); | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
let options = { | ||
selector: '#content', | ||
height: 450, | ||
menu:{!! \App\Plugins\Comment\src\Lib\Edit\Editor::menu() !!}, | ||
menubar:"{!! \App\Plugins\Comment\src\Lib\Edit\Editor::menubar() !!}", | ||
statusbar: true, | ||
elementpath: true, | ||
promotion: false, | ||
plugins: {!! \App\Plugins\Comment\src\Lib\Edit\Editor::plugins() !!}, | ||
language: "zh-Hans", | ||
toolbar: "{!! \App\Plugins\Comment\src\Lib\Edit\Editor::toolbar() !!}", | ||
link_default_target: '_blank', | ||
toolbar_mode: 'sliding', | ||
image_advtab: true, | ||
automatic_uploads: true, | ||
convert_urls:false, | ||
external_plugins:{!! \App\Plugins\Comment\src\Lib\Edit\Editor::externalPlugins() !!}, | ||
images_upload_handler: image_upload_handler, | ||
init_instance_callback: (editor) => { | ||
@if(request()->has('restoredraft')) | ||
editor.plugins.autosave.restoreDraft() | ||
@endif | ||
}, | ||
mobile:{ | ||
menu:{!! \App\Plugins\Comment\src\Lib\Edit\Editor::menu() !!}, | ||
menubar:"{!! \App\Plugins\Comment\src\Lib\Edit\Editor::menubar() !!}", | ||
toolbar_mode: 'scrolling' | ||
}, | ||
autosave_ask_before_unload: true, | ||
autosave_interval: '1s', | ||
autosave_prefix: '{{config('codefec.app.name')}}-comment-{path}{query}-{id}-', | ||
autosave_restore_when_empty: false, | ||
autosave_retention: '1400m', | ||
branding:false, | ||
content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }' | ||
} | ||
if (document.body.className === 'theme-dark') { | ||
options.skin = 'oxide-dark'; | ||
options.content_css = 'dark'; | ||
} | ||
tinyMCE.init(options); | ||
}); | ||
</script> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.