Skip to content
TallCraftUI

Markdown

This component is powered by EasyMDE. It's automatically uploads images to local storage or s3 disks.

Setup

Blade
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
</head>
If you're using local disk storage, remember to execute this command.
Terminal
php artisan storage:link

Basic usage

Blade
<x-markdown wire:model="content" />
Please note that image uploads are limited to authenticated users for security reasons.

Image upload settings

By default, images are uploaded to the markdown/ folder on your local public disk. You can customize this setting.
Blade
<x-markdown disk="s3" folder="assets/markdown" />

Customizing

You can also customize the default settings for the markdown component in the config/tallcraftui.php file.
Blade
@php
$config = [
'spellChecker' => true,
'toolbar' => ['heading', 'bold', 'italic', '|', 'preview'],
'maxHeight' => '150px',
];
@endphp
 
<x-markdown wire:model="content2" :config="$config" />

Manage markdown image uploads

To manage markdown image uploads, use the HasMarkdownImages trait. This trait simplifies the process by automatically handling image updates and deletions based on content changes. The default configuration utilizes the content column for markdown and the public disk for image storage. You can override these settings by adding the following code to your model.
PHP
use Developermithu\Tallcraftui\Traits\HasMarkdownImages;
 
class Post extends Model
{
use HasMarkdownImages;
 
protected string $markdownColumn = 'description';
protected string $markdownImageDisk = 's3';
 
//
}
 
// <x-markdown wire:model="description" disk="s3" />

API reference

Props are read from the component classes in TallCraftUI 3.0.0-beta.1. Write them in kebab-case and pass booleans as bare attributes, for example <x-button outline />. Other attributes, such as class or wire:model, are passed to the component's element.

<x-markdown>

View source
Prop Type Default
label string null
hint string null
inline bool false
disk string 'public'
folder string 'markdown'
config array null