Skip to content

Commit

Permalink
Move File Lang
Browse files Browse the repository at this point in the history
  • Loading branch information
notAreYouScared committed Jan 25, 2025
1 parent 84e9b01 commit 26892bb
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions app/Filament/Server/Resources/FileResource/Pages/EditFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,6 @@ public function form(Form $form): Form

return $form
->schema([
Select::make('lang')
->label('')
->placeholder('File Language')
->options(EditorLanguages::class)
->live()
->afterStateUpdated(fn ($state) => $this->dispatch('setLanguage', lang: $state))
->default(function () {
$ext = pathinfo($this->path, PATHINFO_EXTENSION);

if ($ext === 'yml') {
return 'yaml';
}

return $ext;
}),
Section::make('Editing: ' . $this->path)
->footerActions([
Action::make('save_and_close')
Expand Down Expand Up @@ -129,6 +114,24 @@ public function form(Form $form): Form
])
->footerActionsAlignment(Alignment::End)
->schema([
Select::make('lang')
->label('Syntax Highlighting')
->options(EditorLanguages::class)
->live()
->afterStateUpdated(fn ($state) => $this->dispatch('setLanguage', lang: $state))
->default(function () {
$ext = pathinfo($this->path, PATHINFO_EXTENSION);

if ($ext === 'yml') {
return 'yaml';
}

if (!in_array($ext, (array) EditorLanguages::class)) {
return 'plaintext';
}

return $ext;
}),
MonacoEditor::make('editor')
->label('')
->placeholderText('')
Expand All @@ -141,7 +144,7 @@ public function form(Form $form): Form
abort(404, $this->path . ' not found.');
}
})
->language(fn (Get $get) => $get('lang') ?? 'plaintext')
->language(fn (Get $get) => $get('lang'))
->view('filament.plugins.monaco-editor'),
]),
]);
Expand Down

0 comments on commit 26892bb

Please sign in to comment.