feat: [document] 범용 블록 빌더 Phase 1 구현

- block-editor.blade.php: 3패널 UI (Palette + Canvas + Properties)
- Alpine.js blockEditor() 컴포넌트 (CRUD, Undo/Redo, SortableJS)
- 기본 Block 6종: heading, paragraph, table, columns, divider, spacer
- 폼 필드 Block 7종: text, number, date, select, checkbox, textarea, signature
- BlockRendererService: JSON → HTML 렌더링 서비스
- 컨트롤러 분기: builder_type = 'block' → 블록 빌더 뷰
- 라우트 추가: block-create, block-edit
- API store/update에 schema JSON 처리 추가
- index 페이지에 블록 빌더 진입 버튼 추가
- 목록에 builder_type 뱃지 표시
This commit is contained in:
김보곤
2026-02-28 19:31:57 +09:00
parent cf5b62ba06
commit 97bdc5fbb3
11 changed files with 1484 additions and 7 deletions

View File

@@ -58,6 +58,11 @@ public function edit(int $id): View
'links.linkValues',
])->findOrFail($id);
// 블록 빌더 타입이면 block-editor로 리다이렉트
if ($template->isBlockBuilder()) {
return $this->blockEdit($id);
}
// JavaScript용 데이터 변환
$templateData = $this->prepareTemplateData($template);
@@ -72,6 +77,56 @@ public function edit(int $id): View
]);
}
/**
* 블록 빌더 - 새 양식 생성
*/
public function blockCreate(Request $request): View
{
if ($request->header('HX-Request')) {
return response('', 200)->header('HX-Redirect', route('document-templates.block-create'));
}
return view('document-templates.block-editor', [
'template' => null,
'templateId' => 0,
'isCreate' => true,
'categories' => $this->getCategories(),
'initialSchema' => [
'_name' => '새 문서양식',
'_category' => '',
'version' => '1.0',
'page' => ['size' => 'A4', 'orientation' => 'portrait', 'margin' => [20, 15, 20, 15]],
'blocks' => [],
],
]);
}
/**
* 블록 빌더 - 양식 수정
*/
public function blockEdit(int $id): View
{
$template = DocumentTemplate::findOrFail($id);
$schema = $template->schema ?? [
'version' => '1.0',
'page' => $template->page_config ?? ['size' => 'A4', 'orientation' => 'portrait', 'margin' => [20, 15, 20, 15]],
'blocks' => [],
];
// 뷰에서 사용할 메타 정보 주입
$schema['_name'] = $template->name;
$schema['_category'] = $template->category ?? '';
return view('document-templates.block-editor', [
'template' => $template,
'templateId' => $template->id,
'isCreate' => false,
'categories' => $this->getCategories(),
'initialSchema' => $schema,
]);
}
/**
* 현재 선택된 테넌트 조회
*/