1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Switched to database-based tracking for page editor

- Works better to avoid bad assumptions when showing the editor based
  upon content type.
- Also updated some previous tests to cleaner format.
This commit is contained in:
Dan Brown
2022-04-23 23:20:46 +01:00
parent bec61a56c0
commit 0c5723d76e
8 changed files with 122 additions and 77 deletions

View 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,12 @@ class PageEditorData
return $editorType;
}
/**
* Get the configured system default editor.
*/
public static function getSystemDefaultEditor(): string
{
return setting('app-editor') === 'markdown' ? 'markdown' : 'wysiwyg';
}
}