Skip to content

Commit 7ce373f

Browse files
committed
Wysiwyg@upload changed to support vue-admin-front@1.3.0+
1 parent 0176e88 commit 7ce373f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Http/Controllers/Wysiwyg.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
class Wysiwyg extends Base
1212
{
13-
public function upload(ImageManager $intervention): string
13+
public function upload()
1414
{
15-
$funcNum = $this->req->get('CKEditorFuncNum');
1615
try {
1716
$this->req->validate(['upload' => config('api_admin.wysiwyg.image_upload_rules', 'image')]);
1817
$file = $this->req->file('upload');
@@ -27,14 +26,13 @@ public function upload(ImageManager $intervention): string
2726
$interventionImage->fit($size[0], $size[1] ?? null);
2827
$interventionImage->save($target);
2928
}
30-
return '<script>window.parent.CKEDITOR.tools.callFunction(\'' . $funcNum . '\', \'' . $image->getPath() . '\');</script>';
29+
return $this->jsonResponse(['url' => $image->getPath()]);
3130
} catch (ValidationException $e) {
32-
return '<script>window.parent.CKEDITOR.tools.callFunction(\'' . $funcNum . '\', null, ' .
33-
json_encode(implode(', ', $e->errors())) . ');</script>';
31+
return $this->jsonResponse(['error' => ['message' => implode(', ', $e->errors())]]);
3432
} catch (FileException $e) {
35-
return '<script>window.parent.CKEDITOR.tools.callFunction(\'' . $funcNum . '\', null, \'Could not upload image...\');</script>';
33+
return $this->jsonResponse(['error' => ['message' => trans('admin_api::messaages.wysiwyg_upload_file_error')]]);
3634
} catch (\Throwable $e) {
37-
return '<script>window.parent.CKEDITOR.tools.callFunction(\'' . $funcNum . '\', null, \'Something went wrong...\');</script>';
35+
return $this->jsonResponse(['error' => ['message' => trans('admin_api::messaages.wysiwyg_upload_server_error')]]);
3836
}
3937
}
4038

0 commit comments

Comments
 (0)