Skip to content

Commit c43379f

Browse files
authored
Merge pull request #8083 from nextcloud/chore/config-lexicon
chore: Add config lexicon
2 parents f767ac1 + 79d0bdb commit c43379f

5 files changed

Lines changed: 94 additions & 3 deletions

File tree

composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
1010
'OCA\\Text\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
1111
'OCA\\Text\\Command\\ResetDocument' => $baseDir . '/../lib/Command/ResetDocument.php',
12+
'OCA\\Text\\ConfigLexicon' => $baseDir . '/../lib/ConfigLexicon.php',
1213
'OCA\\Text\\Controller\\AiController' => $baseDir . '/../lib/Controller/AiController.php',
1314
'OCA\\Text\\Controller\\AttachmentController' => $baseDir . '/../lib/Controller/AttachmentController.php',
1415
'OCA\\Text\\Controller\\ISessionAwareController' => $baseDir . '/../lib/Controller/ISessionAwareController.php',

composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ComposerStaticInitText
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
2525
'OCA\\Text\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
2626
'OCA\\Text\\Command\\ResetDocument' => __DIR__ . '/..' . '/../lib/Command/ResetDocument.php',
27+
'OCA\\Text\\ConfigLexicon' => __DIR__ . '/..' . '/../lib/ConfigLexicon.php',
2728
'OCA\\Text\\Controller\\AiController' => __DIR__ . '/..' . '/../lib/Controller/AiController.php',
2829
'OCA\\Text\\Controller\\AttachmentController' => __DIR__ . '/..' . '/../lib/Controller/AttachmentController.php',
2930
'OCA\\Text\\Controller\\ISessionAwareController' => __DIR__ . '/..' . '/../lib/Controller/ISessionAwareController.php',

lib/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public function __construct(array $params = []) {
5050
}
5151

5252
public function register(IRegistrationContext $context): void {
53+
$context->registerConfigLexicon(\OCA\Text\ConfigLexicon::class);
54+
5355
$context->registerEventListener(RegisterDirectEditorEvent::class, RegisterDirectEditorEventListener::class);
5456
$context->registerEventListener(LoadViewer::class, LoadViewerListener::class);
5557
$context->registerEventListener(LoadAdditionalScriptsEvent::class, FilesLoadAdditionalScriptsListener::class);

lib/ConfigLexicon.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\Text;
11+
12+
use OCP\Config\Lexicon\Entry;
13+
use OCP\Config\Lexicon\ILexicon;
14+
use OCP\Config\Lexicon\Strictness;
15+
use OCP\Config\ValueType;
16+
17+
class ConfigLexicon implements ILexicon {
18+
public function getStrictness(): Strictness {
19+
return Strictness::WARNING;
20+
}
21+
22+
public function getAppConfigs(): array {
23+
return [
24+
new Entry(
25+
key: 'default_file_extension',
26+
type: ValueType::STRING,
27+
defaultRaw: 'md',
28+
definition: 'Default file extension for new text files (usually `md` or `txt`)',
29+
lazy: false,
30+
),
31+
new Entry(
32+
key: 'open_read_only_enabled',
33+
type: ValueType::BOOL,
34+
defaultRaw: false,
35+
definition: 'Whether files are opened in read-only mode per default',
36+
lazy: false,
37+
),
38+
new Entry(
39+
key: 'rich_editing_enabled',
40+
type: ValueType::BOOL,
41+
defaultRaw: true,
42+
definition: 'Whether rich editing is enabled',
43+
lazy: false,
44+
),
45+
new Entry(
46+
key: 'workspace_available',
47+
type: ValueType::BOOL,
48+
defaultRaw: true,
49+
definition: 'Whether folder descriptions are available',
50+
lazy: false,
51+
),
52+
new Entry(
53+
key: 'notify_push',
54+
type: ValueType::BOOL,
55+
defaultRaw: true,
56+
definition: 'Whether notify_push is used for real-time synchronization',
57+
lazy: false,
58+
),
59+
new Entry(
60+
key: 'offline_readonly_delay',
61+
type: ValueType::INT,
62+
defaultRaw: 5 * 60,
63+
definition: 'Delay before editor switches to read-onl when offline (in seconds)',
64+
lazy: false,
65+
),
66+
];
67+
}
68+
69+
public function getUserConfigs(): array {
70+
return [
71+
new Entry(
72+
key: 'workspace_enabled',
73+
type: ValueType::BOOL,
74+
defaultRaw: true,
75+
definition: 'Whether folder description is enabled for the user',
76+
lazy: false,
77+
),
78+
new Entry(
79+
key: 'is_full_width_editor',
80+
type: ValueType::BOOL,
81+
defaultRaw: false,
82+
definition: 'Whether the editor should be displayed in full width mode',
83+
lazy: false,
84+
),
85+
];
86+
}
87+
}

lib/Service/ConfigService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ public function getDefaultFileExtension(): string {
2525
}
2626

2727
public function isOpenReadOnlyEnabled(): bool {
28-
return $this->appConfig->getValueString(Application::APP_NAME, 'open_read_only_enabled', '0') === '1';
28+
return $this->appConfig->getValueBool(Application::APP_NAME, 'open_read_only_enabled');
2929
}
3030

3131
public function isRichEditingEnabled(): bool {
32-
return ($this->appConfig->getValueString(Application::APP_NAME, 'rich_editing_enabled', '1') === '1');
32+
return $this->appConfig->getValueBool(Application::APP_NAME, 'rich_editing_enabled', true);
3333
}
3434

3535
public function isRichWorkspaceAvailable(): bool {
3636
if ($this->config->getSystemValueBool('enable_non-accessible_features', true) === false) {
3737
return false;
3838
}
39-
return $this->appConfig->getValueString(Application::APP_NAME, 'workspace_available', '1') === '1';
39+
return $this->appConfig->getValueBool(Application::APP_NAME, 'workspace_available', true);
4040
}
4141

4242
public function isRichWorkspaceEnabledForUser(?string $userId): bool {

0 commit comments

Comments
 (0)