Skip to content

Markdown Editor Plugin

View Plugin

The DmfMarkdownEditor plugin replaces the standard WYSIWYG editor with a powerful Markdown editor for selected content areas in the Shopware Administration. With live preview, configurable toolbar, and automatic HTML-to-Markdown conversion.

On this page:


Requirements

  • Shopware 6.7.0 or higher
  • PHP 8.2 or higher

Installation

bash
composer require dmf/sw6-plugin-markdown-editor
bin/console plugin:install --activate DmfMarkdownEditor
bin/build-js.sh
bin/console cache:clear

Features

  • Selective Replacement: Only specific content areas use Markdown
  • Automatic Conversion: Existing HTML content is automatically converted to Markdown
  • Live Preview: Real-time rendering of Markdown content
  • Configurable Toolbar: Select the tools you need
  • GitHub Flavored Markdown: Tables, task lists, code blocks
  • Button Tool: Create Bootstrap buttons directly in the editor
  • Twig Filter: |markdown for storefront output
  • Dark/Light Mode: Adapts to admin theme

Supported Content Areas

The Markdown editor is automatically enabled for these areas:

Content AreaAutomatically Enabled
Product descriptionYes
Category descriptionYes
Manufacturer descriptionYes
CMS Text elementYes
Custom Fields (HTML/Text Editor)Yes
Custom componentsVia use-markdown="true" prop

All other text editors (e.g., customer group registration text) continue to use the standard WYSIWYG editor.


Configuration

Path: Settings → Extensions → DmfMarkdownEditor

Toolbar Items

Select the toolbar items to display:

ItemDescription
boldBold (text)
italicItalic (text)
underlineUnderlined
strikeThroughStrikethrough (text)
titleHeadings (H1-H6)
subSubscript
supSuperscript
quoteBlockquote
unorderedListBullet list
orderedListNumbered list
taskTask list
linkInsert link
imageInsert image
tableInsert table
codeCode block
codeRowInline code
revokeUndo
nextRedo
previewToggle preview
fullscreenFullscreen mode
catalogTable of contents
mermaidMermaid diagrams
katexMath formulas

Editor Settings

SettingDescriptionDefault
Editor LanguageInterface languagede-DE
Show Preview on StartShow preview panel on openfalse
Show Line NumbersDisplay line numbers in codetrue
Min HeightMinimum editor height in pixels300

Preview Themes

ThemeDescription
githubGitHub style (recommended)
vuepressVuePress documentation style
defaultDefault md-editor-v3 style
mk-cutePlayful style
smart-blueProfessional blue
cyanosisCyan accents

Button Tool

The editor includes a special Button Tool for creating Bootstrap buttons.

Syntax

markdown
[Button Text](url){.btn .btn-primary}

Available Button Variants

VariantClassesDescription
Primary.btn .btn-primaryPrimary action
Secondary.btn .btn-secondarySecondary action
Link.btn .btn-linkLink style
Outline Primary.btn .btn-outline-primaryOutlined primary
Outline Secondary.btn .btn-outline-secondaryOutlined secondary
Ghost.btn .btn-ghostTransparent button

Usage

  1. Click the BTN icon in the toolbar
  2. Select a button variant from the dropdown
  3. Replace "Button Text" with your text
  4. Replace "url" with your target link

Storefront Usage

Twig Filter

Use the |markdown filter to render Markdown as HTML:

twig
{# In product templates #}
{{ product.description|markdown }}

{# In custom fields #}
{{ product.translated.customFields.my_markdown_field|markdown }}

{# As function #}
{{ render_markdown(someVariable) }}

PHP Service

php
use Dmf\MarkdownEditor\Service\MarkdownRendererService;

class MyService
{
    public function __construct(
        private readonly MarkdownRendererService $markdownRenderer
    ) {}

    public function convertMarkdown(string $markdown): string
    {
        return $this->markdownRenderer->render($markdown);
    }
}

Markdown for Custom Components

Via use-markdown Prop

Enable Markdown for an existing sw-text-editor:

twig
<sw-text-editor
    :value="myContent"
    :use-markdown="true"
    @update:value="onContentChange"
/>

Direct Component Usage

twig
<dmf-markdown-editor
    v-model="myContent"
    label="Description"
    placeholder="Enter markdown..."
    preview-theme="github"
/>

Markdown Syntax Reference

Basic Formatting

markdown
**bold** or __bold__
*italic* or _italic_
~~strikethrough~~
`inline code`

Headings

markdown
# H1
## H2
### H3
#### H4
##### H5
###### H6

Lists

markdown
- Bullet point
- Another point

1. Numbered item
2. Another item

- [x] Task completed
- [ ] Task pending
markdown
[Link text](https://example.com)
![Alt text](image.jpg)

Buttons

markdown
[Primary Button](https://example.com){.btn .btn-primary}
[Secondary Button](/page){.btn .btn-secondary}
[Link Button](#anchor){.btn .btn-link}

Code Blocks

markdown
```javascript
const hello = 'world';
```

Tables

markdown
| Column 1 | Column 2 |
|----------|----------|
| Cell 1   | Cell 2   |

Blockquotes

markdown
> This is a quote
> Multiple lines

Troubleshooting

Editor not loading

  1. Install NPM dependencies: bin/build-js.sh
  2. Rebuild admin: bin/build-administration.sh
  3. Clear cache: bin/console cache:clear

Toolbar items not showing

  1. Check plugin configuration in Admin
  2. Ensure items are selected
  3. Clear browser cache

Markdown not rendering in storefront

  1. Use the |markdown filter: {<!-- -->{ content|markdown }<!-- -->}
  2. Ensure content is actual Markdown, not HTML

WYSIWYG editor showing instead of Markdown

The Markdown editor only appears for supported content areas. For custom text editors, add the use-markdown="true" prop.