66
77use OCA \Notes \AppInfo \Application ;
88
9+ use OCP \App \IAppManager ;
910use OCP \IConfig ;
1011use OCP \IL10N ;
1112use OCP \Files \IRootFolder ;
@@ -14,6 +15,7 @@ class SettingsService {
1415 private IConfig $ config ;
1516 private IL10N $ l10n ;
1617 private IRootFolder $ root ;
18+ private IAppManager $ appManager ;
1719
1820 /* Allowed attributes */
1921 private array $ attrs ;
@@ -23,11 +25,13 @@ class SettingsService {
2325 public function __construct (
2426 IConfig $ config ,
2527 IL10N $ l10n ,
26- IRootFolder $ root
28+ IRootFolder $ root ,
29+ IAppManager $ appManager
2730 ) {
2831 $ this ->config = $ config ;
2932 $ this ->l10n = $ l10n ;
3033 $ this ->root = $ root ;
34+ $ this ->appManager = $ appManager ;
3135 $ this ->attrs = [
3236 'fileSuffix ' => $ this ->getListAttrs ('fileSuffix ' , [...$ this ->defaultSuffixes , 'custom ' ]),
3337 'notesPath ' => [
@@ -48,7 +52,7 @@ public function __construct(
4852 return implode (DIRECTORY_SEPARATOR , $ path );
4953 },
5054 ],
51- 'noteMode ' => $ this ->getListAttrs ('noteMode ' , [ ' rich ' , ' edit ' , ' preview ' ] ),
55+ 'noteMode ' => $ this ->getListAttrs ('noteMode ' , $ this -> getAvailableEditorModes () ),
5256 'customSuffix ' => [
5357 'default ' => $ this ->defaultSuffixes [0 ],
5458 'validate ' => function ($ value ) {
@@ -182,4 +186,10 @@ public function getPublic(string $uid) : \stdClass {
182186 unset($ settings ->customSuffix );
183187 return $ settings ;
184188 }
189+
190+ private function getAvailableEditorModes (): array {
191+ return \OCP \Util::getVersion ()[0 ] >= 26 && $ this ->appManager ->isEnabledForUser ('text ' )
192+ ? ['rich ' , 'edit ' , 'preview ' ]
193+ : ['edit ' , 'preview ' ];
194+ }
185195}
0 commit comments