mckenziearts/livewire-markdown-editor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mckenziearts/livewire-markdown-editor

Composer 安装命令:

composer require mckenziearts/livewire-markdown-editor

包简介

GitHub-style markdown editor for Laravel with Livewire and Alpine.js

README 文档

README

Markdown Livewire Banner

Build Status Total Downloads Latest Stable Version License

GitHub-style Markdown editor for Laravel with Livewire and Alpine.js. This module provides a complete, standalone Markdown editing experience with full dark mode support.

Dependencies

  • Laravel 11+
  • Livewire 3.6+
  • Tailwind CSS 4.1
  • League CommonMark
  • GitHub Markdown Toolbar Element
  • GitHub Text Expander Element

Features

  • 🎨 GitHub-style toolbar with all formatting options
  • 📝 Live markdown preview
  • 🌓 Full dark mode support
  • 📎 File upload with automatic Markdown insertion
  • ✨ GitHub Flavored Markdown (GFM) support
  • 🔖 Spatie Shiki Highlight code blocks
  • 📋 Tables, task lists, and more
  • 🔄 Livewire integration with two-way binding
  • 🎯 Multiple editor instances support

Installation

Livewire Markdown editor can be installed via composer from your project root:

composer require mckenziearts/livewire-markdown-editor

Include the Markdown formatting buttons for text inputs Editor into your project:

npm install --save @github/markdown-toolbar-element @github/text-expander-element

2. Load assets

Add the module's JavaScript to your main resources/js/app.js:

import '../../vendor/mckenziearts/livewire-markdown-editor/resources/js/markdown-editor.js';

And the CSS file to your main resources/css/app.css:

@import "../../vendor/mckenziearts/livewire-markdown-editor/resources/css/markdown-editor.css";

Then build:

npm run build

3. Register the module

The service provider is auto-discovered via Laravel's package discovery.

Usage

Basic Usage

<livewire:markdown-editor wire:model="content" />

With Custom Configuration

<livewire:markdown-editor
    wire:model="comment"
    placeholder="Write your comment..."
    :rows="15"
    :show-toolbar="true"
    :show-upload="true"
/>

In Livewire Components

use Livewire\Component;

class CreatePost extends Component
{
    public string $content = '';

    public function save()
    {
        $this->validate([
            'content' => 'required|min:10',
        ]);

        // $this->content contains the markdown
    }

    public function render()
    {
        return view('livewire.create-post');
    }
}
<div>
    <livewire:markdown-editor wire:model="content" />

    <button wire:click="save">Save</button>
</div>

Component Properties

Property Type Default Description
content string '' The markdown content (use with wire:model)
placeholder string 'Leave a comment...' Textarea placeholder text
class string null Textarea custom classes
rows int 10 Number of textarea rows
showToolbar bool true Show/hide the markdown toolbar
showUpload bool true Show/hide the file upload button

Toolbar Features

  • Heading - Insert heading
  • Bold - Make text bold
  • Italic - Make text italic
  • Quote - Insert blockquote
  • Code - Insert code block
  • Link - Insert link
  • Unordered List - Insert bullet list
  • Ordered List - Insert numbered list
  • Task List - Insert checklist
  • File Upload - Upload and insert files/images

File Uploads

Files are automatically uploaded to the configured disk when selected. Images are inserted as ![filename](url) and other files as [filename](url).

Make sure your storage is properly configured:

php artisan storage:link

Security

To prevent arbitrary file upload vulnerabilities (stored XSS, phishing page hosting, malware distribution), only images are accepted by default. Uploaded files are stored under a randomly generated filename with the validated extension, and the original client-provided filename is sanitized before being inserted into the markdown output.

You can customize the allowed file types and max size via the upload config key:

// config/livewire-markdown-editor.php
'upload' => [
    'max_size' => 4096, // kilobytes
    'allowed_extensions' => ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif'],
    'images_only' => true,
],

If you need to allow non-image files, extend allowed_extensions and set images_only to false. When using a public cloud disk (S3, Spaces, R2, Scaleway), review the bucket policy to ensure non-whitelisted Content-Types cannot be served inline.

If you do not use file uploads at all, disable the feature entirely:

<livewire:markdown-editor
    wire:model="content"
    :show-upload="false"
/>

Markdown Support

The editor supports full GitHub Flavored Markdown including:

  • Headings
  • Bold, italic, strikethrough
  • Links and images
  • Code blocks with syntax highlighting
  • Task lists
  • Blockquotes
  • Horizontal rules

Dark Mode

Dark mode is fully supported and automatically follows your Tailwind CSS dark mode configuration.

Customization

Publishing Views

php artisan vendor:publish --tag=livewire-markdown-editor-views

Views will be published to resources/views/vendor/livewire-markdown-editor/.

Publishing Assets

php artisan vendor:publish --tag=livewire-markdown-editor-assets

License

Distributed under the MIT license. See LICENSE for details.

mckenziearts/livewire-markdown-editor 适用场景与选型建议

mckenziearts/livewire-markdown-editor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 948 次下载、GitHub Stars 达 7, 最近一次更新时间为 2026 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「markdown」 「laravel」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mckenziearts/livewire-markdown-editor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mckenziearts/livewire-markdown-editor 我们能提供哪些服务?
定制开发 / 二次开发

基于 mckenziearts/livewire-markdown-editor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 948
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-07