diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 7d109b70a..164becd4d 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -54,6 +54,7 @@ class HomeController extends Controller /** * Get a js representation of the current translations * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response + * @throws \Exception */ public function getTranslations() { $locale = app()->getLocale(); @@ -86,4 +87,13 @@ class HomeController extends Controller ]); } + /** + * Get custom head HTML, Used in ajax calls to show in editor. + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function customHeadContent() + { + return view('partials/custom-head-content'); + } + } diff --git a/resources/assets/js/pages/page-form.js b/resources/assets/js/pages/page-form.js index 73a6c976d..904403fc1 100644 --- a/resources/assets/js/pages/page-form.js +++ b/resources/assets/js/pages/page-form.js @@ -97,6 +97,17 @@ function registerEditorShortcuts(editor) { } +/** + * Load custom HTML head content from the settings into the editor. + * @param editor + */ +function loadCustomHeadContent(editor) { + window.$http.get(window.baseUrl('/custom-head-content')).then(resp => { + if (!resp.data) return; + let head = editor.getDoc().querySelector('head'); + head.innerHTML += resp.data; + }); +} /** * Create and enable our custom code plugin @@ -322,6 +333,9 @@ module.exports = { args.content = ''; } }, + init_instance_callback: function(editor) { + loadCustomHeadContent(editor); + }, setup: function (editor) { editor.on('init ExecCommand change input NodeChange ObjectResized', editorChange); diff --git a/resources/assets/sass/_forms.scss b/resources/assets/sass/_forms.scss index 700c15336..802a075a2 100644 --- a/resources/assets/sass/_forms.scss +++ b/resources/assets/sass/_forms.scss @@ -63,9 +63,10 @@ padding: 0 $-m 0; margin-left: -1px; overflow-y: scroll; - .page-content { - margin: 0 auto; - } + } + .markdown-display.page-content { + margin: 0 auto; + max-width: 100%; } } .editor-toolbar { diff --git a/resources/views/pages/form.blade.php b/resources/views/pages/form.blade.php index 12f2f3e97..f450452ce 100644 --- a/resources/views/pages/form.blade.php +++ b/resources/views/pages/form.blade.php @@ -97,8 +97,7 @@
{{ trans('entities.pages_md_preview') }}
-
-
+
diff --git a/resources/views/partials/custom-head-content.blade.php b/resources/views/partials/custom-head-content.blade.php new file mode 100644 index 000000000..b245b7ad6 --- /dev/null +++ b/resources/views/partials/custom-head-content.blade.php @@ -0,0 +1,5 @@ +@if(setting('app-custom-head', false)) + + {!! setting('app-custom-head') !!} + +@endif \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 8bff3b2ec..f5e59f109 100644 --- a/routes/web.php +++ b/routes/web.php @@ -135,6 +135,7 @@ Route::group(['middleware' => 'auth'], function () { // Other Pages Route::get('/', 'HomeController@index'); Route::get('/home', 'HomeController@index'); + Route::get('/custom-head-content', 'HomeController@customHeadContent'); // Settings Route::group(['prefix' => 'settings'], function() {