PHP code example of wangta69 / laravel-editor

1. Go to this page and download the library: Download wangta69/laravel-editor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wangta69 / laravel-editor example snippets


use Pondol\Editor\Facades\Editor;

// 1) Base64 인라인 이미지를 실제 파일로 추출 후 URL 치환 (SVG 등 XSS 위험 포맷 자동 차단)
$html = Editor::extractBase64Image(
    $request->input('content'),
    public_path('uploads/editor'),
    '/uploads/editor/'
);

// 2) Markdown -> 안전한 HTML 변환
$markdownHtml = Editor::toHtml($article->markdown_body);

// 3) Editor.js JSON -> 안전한 HTML 변환
$blockHtml = Editor::renderEditorJs($article->blocks_json);

use Pondol\Editor\Events\ImageUploaded;

Event::listen(ImageUploaded::class, function (ImageUploaded $event) {
    // $event->disk, $event->path, $event->url, $event->userId 등 활용
});

use Pondol\Editor\Traits\SmartEditor;

class PostController extends Controller
{
    use SmartEditor;

    public function uploadImage(Request $request)
    {
        $result = $this->_uploadStore($request, 'uploads/posts');
        if (! empty($result['error'])) {
            return response()->json(['success' => false]);
        }

        return $result['url'];
    }
}

Schedule::command('pondol:clean-editor-tmp --days=1')->daily();
bash
# 1) 오픈소스 에디터 정적 파일(JS/CSS) 다운로드 (필요한 것만 받으려면 --only=suneditor,easymde 사용)
php artisan pondol:install-editor assets

# 2) 설정 파일(config/pondol-editor.php), public/plugins/editor 퍼블리싱 및 storage:link 생성
php artisan pondol:install-editor full
blade
{{-- 기본 에디터 (SunEditor, Light 테마) --}}
<x-editor-components name="content" id="content_id" :value="old('content', $article->content ?? '')" />

{{-- 특정 에디터 + 다크 테마 + 심플 툴바 --}}
<x-editor-components
    template="cherry-markdown"
    name="body"
    id="body_id"
    :value="$article->body ?? ''"
    :options="['theme' => 'dark', 'preset' => 'minimal']"
/>
bash
php artisan pondol:clean-editor-tmp --days=1