]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/PageEditorData.php
Guest create page: name field autofocus
[bookstack] / app / Entities / Tools / PageEditorData.php
index 3e11641750c9a6cfe6c30f6d7e1ed345da27aa35..2342081bbb52376b807c4f24fa275b1705a9e1e8 100644 (file)
@@ -94,10 +94,7 @@ class PageEditorData
      */
     protected function getEditorType(Page $page): string
     {
-        $emptyPage = empty($page->html) && empty($page->markdown);
-        $pageType = (!empty($page->html) && empty($page->markdown)) ? 'wysiwyg' : 'markdown';
-        $systemDefault = setting('app-editor') === 'wysiwyg' ? 'wysiwyg' : 'markdown';
-        $editorType = $emptyPage ? $systemDefault : $pageType;
+        $editorType = $page->editor ?: self::getSystemDefaultEditor();
 
         // Use requested editor if valid and if we have permission
         $requestedType = explode('-', $this->requestedEditor)[0];
@@ -108,4 +105,11 @@ class PageEditorData
         return $editorType;
     }
 
-}
\ No newline at end of file
+    /**
+     * Get the configured system default editor.
+     */
+    public static function getSystemDefaultEditor(): string
+    {
+        return setting('app-editor') === 'markdown' ? 'markdown' : 'wysiwyg';
+    }
+}