PR CI / ledger (pull_request) Successful in 3s
PR CI / flow (pull_request) Successful in 5s
PR CI / ui (pull_request) Successful in 18s
PR CI / test (lowest) (pull_request) Successful in 47s
PR CI / test (stable) (pull_request) Successful in 49s
PR CI / security (pull_request) Successful in 51s
PR CI / pr-ci (pull_request) Successful in 2s
PR CI / release-automerge (pull_request) Successful in 4s
19 lines
564 B
PHP
19 lines
564 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Http\Controllers;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use IriksIT\Manager\Support\Markdown;
|
|
|
|
/** The preview of the editor: the text as the site renders it (raw HTML is escaped there, so the answer is safe to show). */
|
|
class MarkdownController
|
|
{
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$data = $request->validate(['text' => ['nullable', 'string', 'max:200000']]);
|
|
|
|
return response()->json(['html' => Markdown::toHtml((string) ($data['text'] ?? ''))]);
|
|
}
|
|
}
|