]> BookStack Code Mirror - bookstack/blob - resources/views/pages/parts/markdown-editor.blade.php
Refactored markdown editor logic
[bookstack] / resources / views / pages / parts / markdown-editor.blade.php
1 <div id="markdown-editor" component="markdown-editor"
2      option:markdown-editor:page-id="{{ $model->id ?? 0 }}"
3      option:markdown-editor:text-direction="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"
4      option:markdown-editor:image-upload-error-text="{{ trans('errors.image_upload_error') }}"
5      option:markdown-editor:server-upload-limit-text="{{ trans('errors.server_upload_limit') }}"
6      class="flex-fill flex code-fill">
7
8     <div class="markdown-editor-wrap active">
9         <div class="editor-toolbar">
10             <span class="float left editor-toolbar-label">{{ trans('entities.pages_md_editor') }}</span>
11             <div class="float right buttons">
12                 @if(config('services.drawio'))
13                     <button class="text-button" type="button" data-action="insertDrawing">@icon('drawing'){{ trans('entities.pages_md_insert_drawing') }}</button>
14                     <span class="mx-xs text-muted">|</span>
15                 @endif
16                 <button class="text-button" type="button" data-action="insertImage">@icon('image'){{ trans('entities.pages_md_insert_image') }}</button>
17                 <span class="mx-xs text-muted">|</span>
18                 <button class="text-button" type="button" data-action="insertLink">@icon('link'){{ trans('entities.pages_md_insert_link') }}</button>
19                 <span class="mx-xs text-muted">|</span>
20                 <button class="text-button" type="button" data-action="fullscreen">@icon('fullscreen'){{ trans('common.fullscreen') }}</button>
21             </div>
22         </div>
23
24         <div markdown-input class="flex flex-fill">
25             <textarea id="markdown-editor-input"
26                       refs="markdown-editor@input"
27                       @if($errors->has('markdown')) class="text-neg" @endif
28                       name="markdown"
29                       rows="5">@if(isset($model) || old('markdown')){{ old('markdown') ?? ($model->markdown === '' ? $model->html : $model->markdown) }}@endif</textarea>
30         </div>
31
32     </div>
33
34     <div class="markdown-editor-wrap">
35         <div class="editor-toolbar">
36             <div class="editor-toolbar-label">{{ trans('entities.pages_md_preview') }}</div>
37         </div>
38         <iframe src="about:blank"
39                 refs="markdown-editor@display"
40                 class="markdown-display"
41                 sandbox="allow-same-origin"></iframe>
42     </div>
43 </div>
44
45
46
47 @if($errors->has('markdown'))
48     <div class="text-neg text-small">{{ $errors->first('markdown') }}</div>
49 @endif