Skip to content

Commit fb59e26

Browse files
authored
Merge pull request #984 from nextcloud/bugfix/noid/editor-25
2 parents aacd2ce + 270c39f commit fb59e26

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

lib/Service/SettingsService.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use OCA\Notes\AppInfo\Application;
88

9+
use OCP\App\IAppManager;
910
use OCP\IConfig;
1011
use OCP\IL10N;
1112
use 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
}

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default {
101101
deletedNotes: [],
102102
refreshTimer: null,
103103
helpVisible: false,
104-
editorHint: loadState('notes', 'editorHint', '') === 'yes' && window.oc_appswebroots.text,
104+
editorHint: loadState('notes', 'editorHint', '') === 'yes' && window.OCA.Text?.createEditor,
105105
}
106106
},
107107

src/components/AppSettings.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export default {
8383
},
8484
8585
created() {
86+
if (!window.OCA.Text?.createEditor) {
87+
this.noteModes.splice(0, 1)
88+
}
8689
},
8790
8891
methods: {

0 commit comments

Comments
 (0)