Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'OCA\\Text\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\Text\\Command\\ResetDocument' => $baseDir . '/../lib/Command/ResetDocument.php',
'OCA\\Text\\ConfigLexicon' => $baseDir . '/../lib/ConfigLexicon.php',
'OCA\\Text\\Controller\\AttachmentController' => $baseDir . '/../lib/Controller/AttachmentController.php',
'OCA\\Text\\Controller\\ISessionAwareController' => $baseDir . '/../lib/Controller/ISessionAwareController.php',
'OCA\\Text\\Controller\\NavigationController' => $baseDir . '/../lib/Controller/NavigationController.php',
Expand Down
1 change: 1 addition & 0 deletions composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ComposerStaticInitText
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'OCA\\Text\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\Text\\Command\\ResetDocument' => __DIR__ . '/..' . '/../lib/Command/ResetDocument.php',
'OCA\\Text\\ConfigLexicon' => __DIR__ . '/..' . '/../lib/ConfigLexicon.php',
'OCA\\Text\\Controller\\AttachmentController' => __DIR__ . '/..' . '/../lib/Controller/AttachmentController.php',
'OCA\\Text\\Controller\\ISessionAwareController' => __DIR__ . '/..' . '/../lib/Controller/ISessionAwareController.php',
'OCA\\Text\\Controller\\NavigationController' => __DIR__ . '/..' . '/../lib/Controller/NavigationController.php',
Expand Down
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function __construct(array $params = []) {
}

public function register(IRegistrationContext $context): void {
$context->registerConfigLexicon(\OCA\Text\ConfigLexicon::class);

$context->registerEventListener(RegisterDirectEditorEvent::class, RegisterDirectEditorEventListener::class);
$context->registerEventListener(LoadViewer::class, LoadViewerListener::class);
$context->registerEventListener(LoadAdditionalScriptsEvent::class, FilesLoadAdditionalScriptsListener::class);
Expand Down
80 changes: 80 additions & 0 deletions lib/ConfigLexicon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Text;

use OCP\Config\Lexicon\Entry;
use OCP\Config\Lexicon\ILexicon;
use OCP\Config\Lexicon\Strictness;
use OCP\Config\ValueType;

class ConfigLexicon implements ILexicon {
public function getStrictness(): Strictness {
return Strictness::WARNING;
}

public function getAppConfigs(): array {
return [
new Entry(
key: 'default_file_extension',
type: ValueType::STRING,
defaultRaw: 'md',
definition: 'Default file extension for new text files',
lazy: false,
),
new Entry(
key: 'open_read_only_enabled',
type: ValueType::BOOL,
defaultRaw: false,
definition: 'Whether opening files in read-only mode is enabled',
lazy: false,
),
new Entry(
key: 'rich_editing_enabled',
type: ValueType::BOOL,
defaultRaw: true,
definition: 'Whether rich editing is enabled',
lazy: false,
),
new Entry(
key: 'workspace_available',
type: ValueType::BOOL,
defaultRaw: true,
definition: 'Whether rich workspace feature is available',
lazy: false,
),
new Entry(
key: 'notify_push',
type: ValueType::BOOL,
defaultRaw: true,
definition: 'Whether notify_push synchronization is enabled',
lazy: false,
),
];
}

public function getUserConfigs(): array {
return [
new Entry(
key: 'workspace_enabled',
type: ValueType::BOOL,
defaultRaw: true,
definition: 'Whether rich workspace is enabled for the user',
lazy: false,
),
new Entry(
key: 'is_full_width_editor',
type: ValueType::BOOL,
defaultRaw: false,
definition: 'Whether the editor should be displayed in full width mode',
lazy: false,
),
];
}
}
6 changes: 3 additions & 3 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public function getDefaultFileExtension(): string {
}

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

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

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

public function isRichWorkspaceEnabledForUser(?string $userId): bool {
Expand Down
Loading