NOW MANAGED ON CODEBERG
Enabled custom HTML head content to work within editors
Dan Brownd7edc389a6f4
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex 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.jsindex 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.scssindex 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.phpindex 12f2f3e97..f450452ce 100644--- a/resources/views/pages/form.blade.php+++ b/resources/views/pages/form.blade.php@@ -97,8 +97,7 @@<div class="editor-toolbar"><div class="">{{ trans('entities.pages_md_preview') }}</div></div>- <div class="markdown-display">- <div class="page-content"></div>+ <div class="markdown-display page-content"></div></div><input type="hidden" name="html"/>diff --git a/resources/views/partials/custom-head-content.blade.php b/resources/views/partials/custom-head-content.blade.phpnew file mode 100644index 000000000..b245b7ad6--- /dev/null+++ b/resources/views/partials/custom-head-content.blade.php@@ -0,0 +1,5 @@+@if(setting('app-custom-head', false))+ <!-- Custom user content -->+ {!! setting('app-custom-head') !!}+ <!-- End custom user content -->+@endif\ No newline at end of filediff --git a/routes/web.php b/routes/web.phpindex 8bff3b2ec..f5e59f109 100644--- a/routes/web.php+++ b/routes/web.php@@ -135,6 +135,7 @@ Route::group(['middleware' => 'auth'], function () {// Other PagesRoute::get('/', 'HomeController@index');Route::get('/home', 'HomeController@index');+ Route::get('/custom-head-content', 'HomeController@customHeadContent');// SettingsRoute::group(['prefix' => 'settings'], function() {