优化功能
This commit is contained in:
48
resources/views/admin/partials/markdown-editor.blade.php
Normal file
48
resources/views/admin/partials/markdown-editor.blade.php
Normal file
@@ -0,0 +1,48 @@
|
||||
@php
|
||||
$inputName = $field ?? 'body';
|
||||
$previewElementId = $previewId ?? 'preview-'.str_replace(['[', ']', '.'], '-', $inputName);
|
||||
$inputValue = old($inputName, $value ?? '');
|
||||
$isRequired = (bool) ($required ?? false);
|
||||
$editorRows = (int) ($rows ?? 14);
|
||||
@endphp
|
||||
|
||||
<div class="editor-shell">
|
||||
<div class="editor-card">
|
||||
<div class="editor-card-head">
|
||||
<span>
|
||||
{{ $label ?? '正文内容' }}
|
||||
@if($isRequired)
|
||||
<span class="required-star">*</span>
|
||||
@endif
|
||||
</span>
|
||||
<button class="btn btn-sm btn-outline-primary js-md-upload-advanced-btn" type="button" data-editor-target="{{ $inputName }}">
|
||||
<i class="bi bi-image me-1"></i>上传图片
|
||||
</button>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<textarea
|
||||
class="form-control js-md-editor-modern"
|
||||
name="{{ $inputName }}"
|
||||
rows="{{ $editorRows }}"
|
||||
data-preview-target="#{{ $previewElementId }}"
|
||||
placeholder="{{ $placeholder ?? '支持 Markdown 语法,建议使用标题和列表组织内容。' }}"
|
||||
@if($isRequired) required @endif
|
||||
@if(!empty($minlength)) minlength="{{ (int) $minlength }}" @endif
|
||||
>{{ $inputValue }}</textarea>
|
||||
|
||||
@if(!empty($hint))
|
||||
<div class="form-hint">{{ $hint }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="preview-card">
|
||||
<div class="preview-card-head">
|
||||
<span>实时预览</span>
|
||||
<span class="text-muted">自动渲染</span>
|
||||
</div>
|
||||
<div class="preview-content js-md-preview" id="{{ $previewElementId }}">
|
||||
<div class="preview-placeholder">在左侧输入 Markdown 内容,这里会实时显示预览。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user