Skip to content
Merged
Changes from 1 commit
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
Next Next commit
feat: Expose text processing API in text
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Aug 9, 2023
commit 526302d056c0c1fbf33f8a44fed526f7201889e1
16 changes: 16 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
namespace OCA\Text\Service;

use OCP\AppFramework\Services\IInitialState;
use OCP\TextProcessing\IManager;
use OCP\TextProcessing\IProvider;
use OCP\TextProcessing\ITaskType;
use OCP\Translation\ITranslationManager;

class InitialStateProvider {
public function __construct(
private IInitialState $initialState,
private ConfigService $configService,
private ITranslationManager $translationManager,
private IManager $textProcessingManager,
private ?string $userId
) {
}
Expand Down Expand Up @@ -44,6 +48,18 @@ public function provideState(): void {
'translation_languages',
$this->translationManager->getLanguages()
);

$this->initialState->provideInitialState(
'textprocessing',
array_map(function(string $className) {
/** @var class-string<ITaskType> $className */
$type = \OCP\Server::get($className);
return [
'task' => $className,
'name' => $type->getName(),
];
}, $this->textProcessingManager->getAvailableTaskTypes()),
);
}

public function provideFileId(int $fileId): void {
Expand Down