12
12
use BookStack \Entities \Tools \BookContents ;
13
13
use BookStack \Entities \Tools \PageContent ;
14
14
use BookStack \Entities \Tools \PageEditorData ;
15
+ use BookStack \Entities \Tools \PageEditorType ;
15
16
use BookStack \Entities \Tools \TrashCan ;
16
17
use BookStack \Exceptions \MoveOperationException ;
17
18
use BookStack \Exceptions \PermissionsException ;
@@ -127,7 +128,9 @@ protected function updateTemplateStatusAndContentFromInput(Page $page, array $in
127
128
}
128
129
129
130
$ pageContent = new PageContent ($ page );
130
- $ currentEditor = $ page ->editor ?: PageEditorData::getSystemDefaultEditor ();
131
+ $ defaultEditor = PageEditorType::getSystemDefault ();
132
+ $ currentEditor = PageEditorType::forPage ($ page ) ?: $ defaultEditor ;
133
+ $ inputEditor = PageEditorType::fromRequestValue ($ input ['editor ' ] ?? '' ) ?? $ currentEditor ;
131
134
$ newEditor = $ currentEditor ;
132
135
133
136
$ haveInput = isset ($ input ['markdown ' ]) || isset ($ input ['html ' ]);
@@ -136,15 +139,15 @@ protected function updateTemplateStatusAndContentFromInput(Page $page, array $in
136
139
if ($ haveInput && $ inputEmpty ) {
137
140
$ pageContent ->setNewHTML ('' , user ());
138
141
} elseif (!empty ($ input ['markdown ' ]) && is_string ($ input ['markdown ' ])) {
139
- $ newEditor = ' markdown ' ;
142
+ $ newEditor = PageEditorType::Markdown ;
140
143
$ pageContent ->setNewMarkdown ($ input ['markdown ' ], user ());
141
144
} elseif (isset ($ input ['html ' ])) {
142
- $ newEditor = ' wysiwyg ' ;
145
+ $ newEditor = ( $ inputEditor -> isHtmlBased () ? $ inputEditor : null ) ?? ( $ defaultEditor -> isHtmlBased () ? $ defaultEditor : null ) ?? PageEditorType::WysiwygTinymce ;
143
146
$ pageContent ->setNewHTML ($ input ['html ' ], user ());
144
147
}
145
148
146
149
if ($ newEditor !== $ currentEditor && userCan ('editor-change ' )) {
147
- $ page ->editor = $ newEditor ;
150
+ $ page ->editor = $ newEditor-> value ;
148
151
}
149
152
}
150
153
0 commit comments