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
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ There are a couple of ways to use Commentions with Filament.

1. Register the component in your Filament Infolists:

> This works for Filament 3 and 4.
> This works for Filament 3, 4 and 5.

```php
CommentsEntry::make('comments')
Expand All @@ -85,7 +85,7 @@ For Filament 3:
]),
```

For Filament 4:
For Filament 4-5:

```php
\Filament\Schemas\Components\Section::make('Comments')
Expand All @@ -108,7 +108,7 @@ use Kirschbaum\Commentions\Filament\Actions\CommentsTableAction;
])
```

If you are using Filament 4, you should use `CommentsAction` in `recordActions` instead:
If you are using Filament 4-5, you should use `CommentsAction` in `recordActions` instead:

```php
use Kirschbaum\Commentions\Filament\Actions\CommentsAction;
Expand All @@ -121,7 +121,7 @@ use Kirschbaum\Commentions\Filament\Actions\CommentsAction;

3. Or as a header action:

> This works for Filament 3 and 4.
> This works for Filament 3, 4 and 5.

```php
use Kirschbaum\Commentions\Filament\Actions\CommentsAction;
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function getHeaderActions(): array
SubscriptionTableAction::make(),
])

// In record actions (Filament 4)
// In record actions (Filament 4 and 5)
->recordActions([
SubscriptionAction::make(),
])
Expand Down Expand Up @@ -375,6 +375,7 @@ use Kirschbaum\Commentions\Filament\Actions\CommentsAction;

])
```

Advanced Usage:

```php
Expand All @@ -392,6 +393,18 @@ Infolists\Components\Section::make('Comments')

When pagination is enabled, a "Show more" button is displayed to load additional comments incrementally.

#### Threaded comments
Enable in the .env:
```bash
COMMENTIONS_THREADING_ENABLED=true
````

Optional: set the nested depth (default is 3):
```bash
COMMENTIONS_THREADING_MAX_DEPTH=3
````
*Recommended to not change the depth after the initial setup.

#### Configuring the User model and the mentionables

If your `User` model lives in a different namespace than `App\Models\User`, you can configure it in `config/commentions.php`:
Expand Down Expand Up @@ -860,7 +873,7 @@ public function getComments(?int $limit = null): Collection
createdAt: $statusHistory->created_at,
));

$comments = $this->comments()->latest()->with('author')->get();
$comments = $this->commentsQuery()->latest()->get();

$mergedCollection = $statusHistory->merge($comments);

Expand Down
16 changes: 16 additions & 0 deletions config/commentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@
],
],

/*
|--------------------------------------------------------------------------
| Threading
|--------------------------------------------------------------------------
|
| Nested (threaded) comment replies. Disabled by default. `max_depth` is
| the deepest reply level allowed — top-level comments are depth 0, so a
| max_depth of 3 permits replies down to depth 3.
|
*/
'threading' => [
'enabled' => env('COMMENTIONS_THREADING_ENABLED', false),

'max_depth' => (int) env('COMMENTIONS_THREADING_MAX_DEPTH', 3),
],

/*
|--------------------------------------------------------------------------
| Subscriptions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
Comment thread
lisa-fehr marked this conversation as resolved.

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
$table = config('commentions.tables.comments', 'comments');

Schema::table($table, function (Blueprint $blueprint) use ($table) {
$blueprint->foreignId('parent_id')
->nullable()
->after('id')
->constrained($table)
->cascadeOnDelete();
});
}

public function down(): void
{
Schema::table(config('commentions.tables.comments', 'comments'), function (Blueprint $blueprint) {
$blueprint->dropConstrainedForeignId('parent_id');
});
}
};
51 changes: 51 additions & 0 deletions resources/css/commentions.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,54 @@
.tip-tap-container.tip-tap-toolbar-enabled .tiptap pre code, .commentions-comment-body.tip-tap-toolbar-enabled pre code, .tip-tap-container.tip-tap-toolbar-enabled .tiptap .comm-pre code, .commentions-comment-body.tip-tap-toolbar-enabled .comm-pre code {
@apply comm:block comm:w-max comm:min-w-full comm:bg-transparent comm:p-0 comm:text-inherit;
}

/*
* Threaded reply connector — a Facebook-style curved elbow line.
* Rendered by the `.commentions-thread` element inside each reply (depth > 0),
* which sits absolutely inside the reply row's left padding gutter.
*/
.commentions-thread {
position: absolute;
inset: 0 auto 0 0;
width: 1.5rem;
pointer-events: none;
}

.commentions-thread::before,
.commentions-thread::after {
content: "";
position: absolute;
left: 0.5rem;
}

/* Vertical trunk running the full height of the reply row. */
.commentions-thread::before {
top: 0;
bottom: 0;
width: 2px;
background-color: #d1d5db;
}

/* Curved elbow branching off the trunk into the reply's avatar. */
.commentions-thread::after {
top: 0;
width: 1rem;
height: 1.5rem;
border-left: 2px solid #d1d5db;
border-bottom: 2px solid #d1d5db;
border-bottom-left-radius: 0.75rem;
}

/* The last reply ends the trunk at its own elbow rather than running on. */
.commentions-replies > :last-child .commentions-thread::before {
bottom: auto;
height: 1.5rem;
}

:where(.dark, .dark *) .commentions-thread::before {
background-color: #4b5563;
}

:where(.dark, .dark *) .commentions-thread::after {
border-color: #4b5563;
}
2 changes: 1 addition & 1 deletion resources/dist/commentions.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions resources/lang/ar/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@

'cancel' => 'إلغاء',
'delete' => 'حذف',
'reply' => 'رد',
'edit' => 'تعديل',
'replies_count' => [
'none' => 'لا توجد ردود',
'one' => 'رد واحد',
'many' => ':count ردود',
],
'hide_replies' => 'إخفاء الردود',
'save' => 'حفظ',
'comment' => 'تعليق',
'add_reaction' => 'إضافة رد فعل',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/en/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'cancel' => 'Cancel',
'delete' => 'Delete',
'edit' => 'Edit',
'reply' => 'Reply',
'replies_count' => '{0} No replies|{1} :count reply|[2,*] :count replies',
'hide_replies' => 'Hide replies',
Comment thread
lisa-fehr marked this conversation as resolved.
'save' => 'Save',
'comment' => 'Comment',
'add_reaction' => 'Add Reaction',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/es/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'cancel' => 'Cancelar',
'delete' => 'Eliminar',
'edit' => 'Editar',
'reply' => 'Responder',
'replies_count' => '{0} No hay respuestas|{1} :count respuesta|[2,*] :count respuestas',
'hide_replies' => 'Ocultar respuestas',
'save' => 'Guardar',
'comment' => 'Comentar',
'add_reaction' => 'Agregar reacción',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/fr/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'cancel' => 'Annuler',
'delete' => 'Supprimer',
'edit' => 'Modifier',
'reply' => 'Répondre',
'replies_count' => '{0} Aucune réponse|{1} :count réponse|[2,*] :count réponses',
'hide_replies' => 'Masquer les réponses',
'save' => 'Enregistrer',
'comment' => 'Commenter',
'add_reaction' => 'Ajouter une réaction',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/nl/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'cancel' => 'Annuleren',
'delete' => 'Verwijderen',
'edit' => 'Bewerken',
'reply' => 'Beantwoorden',
'replies_count' => '{0} Geen reacties|{1} :count reactie|[2,*] :count reacties',
'hide_replies' => 'Reacties verbergen',
'save' => 'Opslaan',
'comment' => 'Opmerking',
'add_reaction' => 'Reactie toevoegen',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/ro/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'cancel' => 'Anulare',
'delete' => 'Șterge',
'edit' => 'Editează',
'reply' => 'Răspunde',
'replies_count' => '{0} Niciun răspuns|{1} :count răspuns|[2,*] :count răspunsuri',
'hide_replies' => 'Ascunde răspunsurile',
'save' => 'Salvare',
'comment' => 'Comentariu',
'add_reaction' => 'Adaugă reacție',
Expand Down
1 change: 1 addition & 0 deletions resources/views/comment-list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class="comm:w-8 comm:h-8 comm:text-gray-400 comm:dark:text-gray-500"
:ratings-enabled="$ratingsEnabled"
:max-rating="$maxRating"
:toolbar-buttons="$toolbarButtons"
:attachments-enabled="$this->attachmentsAreEnabled()"
:readonly="$this->isReadonly()"
/>
@endforeach
Expand Down
Loading
Loading