Skip to content

Commit c4916f4

Browse files
committed
wip
1 parent 3c42ccb commit c4916f4

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/Plugins/JumpAnchorRichContentPlugin.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ public function getEditorTools(): array
4545
RichEditorTool::make('jumpAnchor')
4646
->action(arguments: '{ anchorId: $getEditor().getAttributes(\'jumpAnchor\')?.[\'data-anchor-id\'] }')
4747
->icon(Heroicon::Hashtag)
48-
->label('Add Jump Anchor'),
48+
->label(__('Add Jump Anchor')),
4949
];
5050
}
5151

5252
public function getEditorActions(): array
5353
{
5454
return [
5555
Action::make('jumpAnchor')
56-
->modalHeading('Add Jump Anchor')
57-
->modalDescription('Add an anchor to the selected text that can be used for navigation.')
56+
->modalHeading(__('Add Jump Anchor'))
57+
->modalDescription(__('Add an anchor to the selected text that can be used for navigation.'))
5858
->modalWidth(Width::Medium)
5959
->modalSubmitActionLabel(__('Save'))
6060
->fillForm(fn (array $arguments): array => [
@@ -64,11 +64,11 @@ public function getEditorActions(): array
6464
])
6565
->schema([
6666
TextInput::make('anchorId')
67-
->label('Anchor ID')
68-
->placeholder('e.g., section-1, my-anchor')
67+
->label(__('Anchor ID'))
68+
->placeholder(__('e.g., section-1, my-anchor'))
6969
->required()
7070
->rules(['regex:/^[a-zA-Z0-9-_]+$/'])
71-
// ->helperText('The ID that will be assigned to the span element (e.g., "section-1" for id="section-1")')
71+
// ->helperText(__('The ID that will be assigned to the span element (e.g., "section-1" for id="section-1")'))
7272
->live()
7373
->afterStateUpdated(function ($state, callable $set) {
7474
// Generate a slug-like ID if empty

tests/JumpAnchorPluginTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ protected function setUp(): void
2121
return new \Filament\Support\Assets\AssetManager;
2222
});
2323

24-
// Mock the translator service
25-
$translator = \Mockery::mock(\Illuminate\Contracts\Translation\Translator::class);
26-
$translator->shouldReceive('get')->andReturn('Jump Anchor');
27-
$translator->shouldReceive('choice')->andReturn('Jump Anchor');
28-
$translator->shouldReceive('trans')->andReturn('Jump Anchor');
29-
$translator->shouldReceive('transChoice')->andReturn('Jump Anchor');
24+
// Mock the translator service for __() functions
25+
$translator = Mockery::mock(\Illuminate\Contracts\Translation\Translator::class);
26+
$translator->shouldReceive('get')->andReturnUsing(function ($key, $replace = [], $locale = null) {
27+
return $key; // Return the key as-is for testing
28+
});
29+
$translator->shouldReceive('choice')->andReturnUsing(function ($key, $number, $replace = [], $locale = null) {
30+
return $key;
31+
});
32+
$translator->shouldReceive('trans')->andReturnUsing(function ($key, $replace = [], $locale = null) {
33+
return $key;
34+
});
35+
$translator->shouldReceive('transChoice')->andReturnUsing(function ($key, $number, $replace = [], $locale = null) {
36+
return $key;
37+
});
3038

3139
$app->singleton('translator', function () use ($translator) {
3240
return $translator;

0 commit comments

Comments
 (0)