diff --git a/extend/catcher/library/form/Form.php b/extend/catcher/library/form/Form.php index bfcfa4d..1be6599 100644 --- a/extend/catcher/library/form/Form.php +++ b/extend/catcher/library/form/Form.php @@ -153,9 +153,9 @@ abstract class Form * @time 2021年03月03日 * @return string */ - protected static function uploadImageUrl(): string + public static function uploadImageUrl(): string { - return env('app.domain') . '/cms/upload/image'; + return env('app.domain') . '/upload/image'; } /** @@ -164,24 +164,19 @@ abstract class Form * @time 2021年03月10日 * @return string */ - protected static function uploadImageFile(): string + public static function uploadFileUrl(): string { - return env('app.domain') . '/cms/upload/file'; + return env('app.domain') . '/upload/file'; } + /** - * 上传图片地址 + * auth token * - * @time 2021年03月03日 - * @return string + * @time 2021年04月11日 + * @return string[] */ - protected static function uploadFileUrl(): string - { - return env('app.domain') . '/cms/upload/file'; - } - - - protected static function authorization(): array + public static function authorization(): array { return [ 'authorization' => 'Bearer ' . request()->user()->remember_token, diff --git a/extend/catcher/library/form/components/Editor.php b/extend/catcher/library/form/components/Editor.php index 19fd2c6..729d426 100644 --- a/extend/catcher/library/form/components/Editor.php +++ b/extend/catcher/library/form/components/Editor.php @@ -1,6 +1,7 @@ 'editor' ]; + protected $defaultPlugins = ['advlist anchor autolink autosave lists code codesample colorpicker colorpicker contextmenu directionality emoticons fullscreen hr image imagetools insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textcolor textpattern visualblocks visualchars wordcount']; + + protected $defaultToolbars = ['searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample', 'hr bullist numlist link image charmap preview anchor pagebreak insertdatetime media table emoticons forecolor backcolor fullscreen']; + + /** + * 初始化 + * + * @time 2021年04月11日 + * @return Editor|void + */ + protected function init(): Editor + { + return $this->plugins() + ->toolbars() + ->language() + ->initContent() + ->uploadConf(); + } + public function createValidate() { // TODO: Implement createValidate() method. return Elm::validateStr(); } + + + /** + * set plugins + * + * @time 2021年04月11日 + * @param array $plugins + * @return Editor + */ + public function plugins(array $plugins = []): Editor + { + $this->props([ + 'plugins' => count($plugins) ? $plugins : $this->defaultPlugins, + ]); + + return $this; + } + + + /** + * set toolbars + * + * @time 2021年04月11日 + * @param array $toolbars + * @return Editor + */ + public function toolbars(array $toolbars = []): Editor + { + $this->props([ + 'toolbar' => count($toolbars) ? $toolbars : $this->defaultToolbars, + ]); + + return $this; + } + + /** + * 设置语言 + * 支持 'es_MX', 'en', 'zh_CN', 'ja' + * @time 2021年04月11日 + * @param string $language + * @return $this + */ + public function language(string $language = 'zh_CN'): Editor + { + $this->props([ + 'language' => $language + ]); + + return $this; + } + + + /** + * 编辑器高度 + * + * @time 2021年04月11日 + * @param int $height + * @return $this + */ + public function height(int $height = 500): Editor + { + $this->props([ + 'height' => $height + ]); + + return $this; + } + + /** + * 宽度设置 + * + * @time 2021年04月11日 + * @param string $width + * @return $this + */ + public function width($width = 'auto'): Editor + { + $this->props([ + 'width' => $width + ]); + + return $this; + } + + /** + * 编辑器默认内容 + * + * @time 2021年04月11日 + * @param string $content + * @return $this + */ + public function initContent(string $content = ''): Editor + { + $this->props([ + 'initContent' => $content + ]); + + return $this; + } + + /** + * 上传配置 + * + * @time 2021年04月11日 + * @return $this + */ + public function uploadConf(): Editor + { + $this->props([ + 'uploadConf' => array_merge([ + 'url' => Form::uploadImageUrl(), + 'size' => 0.1, + ], Form::authorization()) + ]); + + return $this; + } } \ No newline at end of file