Преглед изворни кода

260225 文章時間、調色盤加色減色、目前字數計算

OMEGA\lulufj.ho пре 1 месец
родитељ
комит
461784774f

+ 51
- 5
app/Filament/Resources/NewsResource.php Прегледај датотеку

@@ -38,6 +38,7 @@ use Malzariey\FilamentLexicalEditor\Enums\ToolbarItem;
38 38
 use Malzariey\FilamentLexicalEditor\FilamentLexicalEditor;
39 39
 use SolutionForest\FilamentTranslateField\Forms\Component\Translate;
40 40
 use RalphJSmit\Filament\SEO\SEO;
41
+use Illuminate\Support\HtmlString;
41 42
 
42 43
 class NewsResource extends Resource
43 44
 {
@@ -72,7 +73,7 @@ class NewsResource extends Resource
72 73
                     ])->columnSpanFull()->columns(2),
73 74
                     Group::make()->schema([
74 75
                         DatePicker::make('post_date')
75
-                        ->label("發布日期")
76
+                        ->label("文章日期")
76 77
                         ->closeOnDateSelection()->required(),
77 78
                         DateTimePicker::make('start_date')
78 79
                         ->label("預約發布時間")
@@ -92,13 +93,58 @@ class NewsResource extends Resource
92 93
                     Translate::make()->schema(fn (string $locale) => [
93 94
                         TextInput::make('title')
94 95
                         ->label("標題")
96
+                        ->reactive()
97
+                        ->afterStateHydrated(function ($state, callable $set) {
98
+                            $set('title_length', mb_strlen($state ?? ''));
99
+                        })
100
+                        ->afterStateUpdated(function ($state, callable $set) {
101
+                            $set('title_length', mb_strlen($state ?? ''));
102
+                        })
103
+                        ->helperText(function (callable $get) {
104
+                            $length = $get('title_length') ?? 0;
105
+                            $max = 24;
106
+
107
+                            $divClass = 'text-limit-amount';
108
+
109
+                            return new HtmlString("
110
+                                <div class='{$divClass} text-sm'>
111
+                                    目前字數:{$length} / {$max}
112
+                                </div>
113
+                            ");
114
+                        })
95 115
                         ->columnSpan(1),
96 116
                         TextInput::make('written_by')
97 117
                         ->label("發佈者")->columnSpan(1),
98
-                        Textarea::make("description")->rows(5)->columnSpanFull()->label("短文"),
118
+                        
119
+
120
+                        Textarea::make("description")
121
+                        ->rows(5)
122
+                        ->columnSpanFull()
123
+                        ->label("短文")
124
+                        
125
+                        ->reactive()
126
+                        ->afterStateHydrated(function ($state, callable $set) {
127
+                            $set('description_length', mb_strlen($state ?? ''));
128
+                        })
129
+                        ->afterStateUpdated(function ($state, callable $set) {
130
+                            $set('description_length', mb_strlen($state ?? ''));
131
+                        })
132
+                        ->helperText(function (callable $get) {
133
+                            $length = $get('description_length') ?? 0;
134
+                            $max = 84;
135
+
136
+                            $divClass = 'text-limit-amount';
137
+
138
+                            return new HtmlString("
139
+                                <div class='{$divClass} text-sm'>
140
+                                    目前字數:{$length} / {$max}
141
+                                </div>
142
+                            ");
143
+                        })
99 144
                     ])->locales(["zh_TW", "en"])
100 145
                     ->id("main")
101 146
                     ->columnSpanFull()->columns(3),
147
+                    
102 148
                     TextInput::make('order')->label("排序")->integer()->default(0),
103 149
                 ])->columns(3),
104 150
                 Section::make("SEO")->schema([
@@ -165,7 +211,7 @@ class NewsResource extends Resource
165 211
                                     ToolbarItem::BOLD, ToolbarItem::ITALIC, ToolbarItem::UNDERLINE,
166 212
                                     ToolbarItem::LINK, ToolbarItem::TEXT_COLOR, ToolbarItem::BACKGROUND_COLOR,
167 213
                                     ToolbarItem::SUBSCRIPT, ToolbarItem::LOWERCASE, ToolbarItem::DIVIDER,
168
-                                    ToolbarItem::UPPERCASE, ToolbarItem::CLEAR, ToolbarItem::HR
214
+                                    ToolbarItem::UPPERCASE, ToolbarItem::CLEAR, ToolbarItem::HR, ToolbarItem::FONT_FAMILY
169 215
                                 ])
170 216
                                 ->live(onBlur: true)
171 217
                                 ->columnSpanFull(),
@@ -179,7 +225,7 @@ class NewsResource extends Resource
179 225
                                     ToolbarItem::BOLD, ToolbarItem::ITALIC, ToolbarItem::UNDERLINE,
180 226
                                     ToolbarItem::LINK, ToolbarItem::TEXT_COLOR, ToolbarItem::BACKGROUND_COLOR,
181 227
                                     ToolbarItem::SUBSCRIPT, ToolbarItem::LOWERCASE, ToolbarItem::DIVIDER,
182
-                                    ToolbarItem::UPPERCASE, ToolbarItem::CLEAR, ToolbarItem::HR
228
+                                    ToolbarItem::UPPERCASE, ToolbarItem::CLEAR, ToolbarItem::HR, ToolbarItem::FONT_FAMILY
183 229
                                 ])
184 230
                                 ->columnSpanFull(),
185 231
                         ])->visible(fn (Get $get):bool => $get("paragraph_type") == 2),
@@ -253,7 +299,7 @@ class NewsResource extends Resource
253 299
                 TextColumn::make("newsCategory.name")->label("分類")->alignCenter(),
254 300
                 TextColumn::make("title")->label("標題")->alignCenter(),
255 301
                 TextColumn::make("written_by")->label("發佈者")->alignCenter(),
256
-                TextColumn::make("post_date")->label("發佈時間")->dateTime('Y/m/d')->alignCenter(),
302
+                TextColumn::make("post_date")->label("文章時間")->dateTime('Y/m/d')->alignCenter(),
257 303
                 ImageColumn::make("news_img_pc_url")->label("列表圖")->alignCenter(),
258 304
                 TextColumn::make("list_audit_state")->label("狀態")->badge()
259 305
                 ->color(fn (string $state): string => match ($state) {

+ 4
- 0
public/css/malzariey/filament-lexical-editor/filament-lexical-editor-styles.css Прегледај датотеку

@@ -6272,4 +6272,8 @@ button.font-increment {
6272 6272
 .dark\:invert:is(.dark *) {
6273 6273
   --tw-invert: invert(100%);
6274 6274
   filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
6275
+}
6276
+
6277
+div.relative.w-52.h-11.py-1:has(select.font-family) {
6278
+  display: none !important;
6275 6279
 }

+ 1
- 1
public/js/malzariey/filament-lexical-editor/components/lexical-component.js
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку