feat: 富文本编辑

This commit is contained in:
2026-04-16 16:20:52 +08:00
parent 295cf12899
commit 6acd0ccad0
8 changed files with 150 additions and 40 deletions

View File

@@ -110,7 +110,7 @@ class ManageGuidePages extends Page
$this->nodes = $pages->map(fn(GuidePage $p) => [
'id' => $p->id,
'title' => $p->title,
'html_url' => $p->html_url,
'uri' => $p->uri,
'is_entry' => !isset($hasIncoming[$p->id]),
'options' => $p->options ?? [],
'x' => $positions[$p->id]['x'] ?? 50,
@@ -207,7 +207,7 @@ class ManageGuidePages extends Page
$page = $this->getRecord()->pages()->findOrFail($arguments['id']);
$form->fill([
'title' => $page->title,
'html_url' => $page->html_url,
'content' => $page->content,
'options' => $page->options ?? [],
]);
})
@@ -261,11 +261,13 @@ class ManageGuidePages extends Page
->required()
->maxLength(255),
Forms\Components\TextInput::make('html_url')
->label('HTML页面URL')
Forms\Components\RichEditor::make('content')
->label('页面内容')
->required()
->url()
->maxLength(500),
->fileAttachmentsDisk('public')
->fileAttachmentsDirectory('guide-pages')
->fileAttachmentsVisibility('public')
->columnSpanFull(),
Forms\Components\TagsInput::make('options')
->label('分支选项')

View File

@@ -139,7 +139,7 @@ class TerminalApiController extends Controller
$pagesMap[$page->id] = [
'id' => $page->id,
'title' => $page->title,
'html_url' => $page->html_url,
'uri' => $page->uri,
'next' => $next,
];
}

View File

@@ -9,7 +9,7 @@ class GuidePage extends Model
protected $fillable = [
'guide_id',
'title',
'html_url',
'content',
'options',
];
@@ -25,6 +25,11 @@ class GuidePage extends Model
});
}
public function getUriAttribute(): string
{
return route('guides.pages.show', $this->id);
}
public function guide()
{
return $this->belongsTo(Guide::class);