jqh 5 years ago
parent
commit
e8a9b9cd56
2 changed files with 25 additions and 5 deletions
  1. 12 2
      src/Form/Field/Editor.php
  2. 13 3
      src/Form/Field/Markdown.php

+ 12 - 2
src/Form/Field/Editor.php

@@ -83,7 +83,7 @@ class Editor extends Field
      */
     public function imageUrl(string $url)
     {
-        return $this->options(['images_upload_url' => admin_url($url)]);
+        return $this->options(['images_upload_url' => $this->formatUrl(admin_url($url))]);
     }
 
     /**
@@ -133,9 +133,19 @@ class Editor extends Field
      * @return string
      */
     protected function defaultImageUploadUrl()
+    {
+        return $this->formatUrl(route('dcat.api.tinymce.upload'));
+    }
+
+    /**
+     * @param string $url
+     *
+     * @return string
+     */
+    protected function formatUrl(string $url)
     {
         return Helper::urlWithQuery(
-            route('dcat.api.tinymce.upload'),
+            $url,
             [
                 '_token' => csrf_token(),
                 'disk'   => $this->disk,

+ 13 - 3
src/Form/Field/Markdown.php

@@ -113,7 +113,7 @@ class Markdown extends Field
      */
     public function imageUrl(string $url)
     {
-        return $this->options(['imageUploadURL' => admin_url($url)]);
+        return $this->options(['imageUploadURL' => $this->formatUrl(admin_url($url))]);
     }
 
     /**
@@ -146,7 +146,7 @@ class Markdown extends Field
 
         $this->options['onload'] = JavaScript::make(
             <<<JS
-function () {
+function () {
     this.setMarkdown($('#{$this->id}-template').html());
 }
 JS
@@ -165,9 +165,19 @@ JS
      * @return string
      */
     protected function defaultImageUploadUrl()
+    {
+        return $this->formatUrl(route('dcat.api.editor-md.upload'));
+    }
+
+    /**
+     * @param string $url
+     *
+     * @return string
+     */
+    protected function formatUrl(string $url)
     {
         return Helper::urlWithQuery(
-            route('dcat.api.editor-md.upload'),
+            $url,
             [
                 '_token' => csrf_token(),
                 'disk'   => $this->disk,