From 9dd1bde863e8757b482a6f729176c557135b19de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Tue, 4 Nov 2025 12:08:31 -0300 Subject: [PATCH] Enhance placeholder picker functionality: Added support for custom placeholders in the placeholder picker component, allowing dynamic loading of custom blade files. Updated localization for both English and Turkish languages to include new placeholder types, improving user experience and flexibility in template customization. --- lang/en/placeholder-picker.php | 2 + lang/tr/placeholder-picker.php | 2 + .../views/components/custom/example.blade.php | 6 -- ...avbar-other.blade.php => navbar.blade.php} | 2 +- .../views/components/custom/test.blade.php | 6 -- .../components/placeholder-picker.blade.php | 56 ++++++++++--------- 6 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 resources/views/components/custom/example.blade.php rename resources/views/components/custom/{navbar-other.blade.php => navbar.blade.php} (98%) delete mode 100644 resources/views/components/custom/test.blade.php diff --git a/lang/en/placeholder-picker.php b/lang/en/placeholder-picker.php index b4ed6e5..48b4085 100644 --- a/lang/en/placeholder-picker.php +++ b/lang/en/placeholder-picker.php @@ -4,6 +4,7 @@ return [ 'title' => 'Placeholder Variables', 'click_to_insert' => 'Click to insert into editor', 'special_placeholders' => 'Special Placeholders', + 'custom_placeholders' => 'Custom Placeholders', 'search_placeholder' => 'Search placeholders...', 'no_results' => 'No results found', @@ -31,5 +32,6 @@ return [ 'type_toggle' => 'Toggle', 'type_color' => 'Color', 'type_tags' => 'Tags', + 'type_custom' => 'Custom', ]; diff --git a/lang/tr/placeholder-picker.php b/lang/tr/placeholder-picker.php index 29a2d86..a3085ab 100644 --- a/lang/tr/placeholder-picker.php +++ b/lang/tr/placeholder-picker.php @@ -4,6 +4,7 @@ return [ 'title' => 'Placeholder Değişkenleri', 'click_to_insert' => 'Tıklayarak editöre ekle', 'special_placeholders' => 'Özel Placeholder\'lar', + 'custom_placeholders' => 'Özel Placeholder\'lar', 'search_placeholder' => 'Placeholder ara...', 'no_results' => 'Arama sonucu bulunamadı', @@ -31,5 +32,6 @@ return [ 'type_toggle' => 'Aç/Kapa', 'type_color' => 'Renk', 'type_tags' => 'Etiketler', + 'type_custom' => 'Özel', ]; diff --git a/resources/views/components/custom/example.blade.php b/resources/views/components/custom/example.blade.php deleted file mode 100644 index 9bfb1bc..0000000 --- a/resources/views/components/custom/example.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -
-

Örnek Custom Component

-

Bu component'i template içinde {custom.example} yazarak kullanabilirsiniz.

-

Bu dosyayı dilediğiniz gibi özelleştirebilir ve yeniden kullanabilirsiniz.

-
- diff --git a/resources/views/components/custom/navbar-other.blade.php b/resources/views/components/custom/navbar.blade.php similarity index 98% rename from resources/views/components/custom/navbar-other.blade.php rename to resources/views/components/custom/navbar.blade.php index 7a732e5..1b352fd 100644 --- a/resources/views/components/custom/navbar-other.blade.php +++ b/resources/views/components/custom/navbar.blade.php @@ -14,4 +14,4 @@ - asdad \ No newline at end of file + \ No newline at end of file diff --git a/resources/views/components/custom/test.blade.php b/resources/views/components/custom/test.blade.php deleted file mode 100644 index 12f977a..0000000 --- a/resources/views/components/custom/test.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -
-

Custom Test Component

-

Bu bir örnek custom component'tir. Bu dosyayı dilediğiniz gibi özelleştirebilirsiniz.

-

Template içinde {custom.test} yazarak bu component'i çağırabilirsiniz.

-
- diff --git a/resources/views/components/placeholder-picker.blade.php b/resources/views/components/placeholder-picker.blade.php index 127ded4..3673209 100644 --- a/resources/views/components/placeholder-picker.blade.php +++ b/resources/views/components/placeholder-picker.blade.php @@ -26,6 +26,37 @@ 'tags' => ['label' => __('placeholder-picker.type_tags'), 'examples' => ['tags', 'keywords', 'labels']], ]; + // Custom klasöründeki blade dosyalarını tespit et ve placeholder types'a ekle + $customPlaceholders = []; + $customPath = resource_path('views/components/custom'); + + if (is_dir($customPath)) { + $files = scandir($customPath); + + foreach ($files as $file) { + // . ve .. dizinlerini atla + if ($file === '.' || $file === '..') { + continue; + } + + // Sadece .blade.php uzantılı dosyaları al + $filePath = $customPath . DIRECTORY_SEPARATOR . $file; + if (is_file($filePath) && str_ends_with($file, '.blade.php')) { + $name = str_replace('.blade.php', '', $file); + $customPlaceholders[] = $name; + } + } + sort($customPlaceholders); + + // Custom placeholder'ları placeholder types'a ekle + if (!empty($customPlaceholders)) { + $placeholderTypes['custom'] = [ + 'label' => __('placeholder-picker.type_custom'), + 'examples' => $customPlaceholders + ]; + } + } + // Field name'i component'ten al $fieldName = $fieldName ?? 'html_content'; @endphp @@ -105,31 +136,6 @@ - -
-

- {{ __('placeholder-picker.special_placeholders') }} -

-
- - {menu} - - - {staticMenu} - -
-
-