Download the PHP package cheinisch/markdown-editor without Composer

On this page you can find all versions of the php package cheinisch/markdown-editor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package markdown-editor

Markdown PHP Editor

A simple Markdown editor (HTML/JS/CSS) for easy embedding in PHP apps.

Editor Editor view

With active preview Editor with active preview

Requirements

Installation

Copy src/MarkdownEditor.php and public/markdown-editor.js into your project — no further dependencies required.

Composer

Usage

With Composer autoloading:

Render order matters: renderHead() must appear inside <head>, render() inside <body>, and renderFoot() must come after render() — ideally just before </body>. The JavaScript loaded by renderFoot() queries the editor element by ID; if it runs before render() has written the DOM, the editor will silently fail to initialise.

External dependencies: renderHead() loads three libraries from public CDNs — Tailwind CSS (with typography plugin), marked.js, and DOMPurify. No SRI hashes are set. If your Content Security Policy restricts external scripts, you will need to self-host these files and call renderHead() manually or skip it and include equivalent tags yourself.


Loading & Saving Content

The editor provides two independent mechanisms for persisting content. Both are optional and can be combined.

1. localStorage — Browser-side Auto-save

Activating this option saves the editor content to the browser's localStorage on every keystroke and restores it automatically on the next page load.

How it works:

Note: localStorage is scoped to the browser and origin. It is suitable for draft/autosave scenarios but not for sharing content between users or devices.


2. field — Sync with a <textarea> (Form Integration)

This option links the editor to a named <textarea> element so content is submitted as part of a regular HTML form. This is the recommended approach when saving to a database or server-side file.

How it works:

If the <textarea> does not exist yet, the editor creates a hidden one automatically with the given ID. The hidden element is still included in the form submit.

Edit form example:

Create form example:


3. Combining localStorage and field

Both options can be active at the same time. A common pattern is to use localStorage as a crash-safe draft buffer while the form submit handles the actual persistence:

With this setup, unsaved drafts survive accidental page reloads, and the definitive save still goes through the form.

Tip: After a successful form submit, clear the localStorage draft server-side via JavaScript or by passing the saved content back into the textarea, so the editor loads the canonical version instead of a stale draft.


Default behaviour (no option set)

If neither localStorage nor field is configured, the editor starts empty on every page load and content is lost on reload. This is useful for standalone demos or one-shot tools where persistence is handled entirely by custom JavaScript outside the editor.


render() Options

All options are optional.


Image Library

The library modal lets users browse and insert images (and other files) directly from the editor. It supports two integration modes.

Mode A — fsPath (built-in handler, no extra endpoint needed)

Pass fsPath instead of path to let the editor manage the HTTP endpoint automatically. The directory is registered in the PHP session and served by the bundled md-handler.php. This is the quickest setup.

webPath is derived automatically from $_SERVER['DOCUMENT_ROOT']. You can override it explicitly if your setup differs:

Note: fsPath mode requires an active PHP session. The editor calls session_start() automatically if no session is running yet.

Mode B — Custom endpoint

Point path at your own PHP file that calls MarkdownEditor::handleRequest(). Use this when you need authentication, logging, or custom storage logic.

GET /api/media/blog returns a JSON array:

POST /api/media/blog accepts a multipart/form-data request with a file field and returns the saved file as JSON.

File insertion behaviour

When a user selects a file from the library and clicks "Insert", the editor inserts a Markdown snippet at the current cursor position:

The distinction is made automatically based on file extension.


Keyboard Shortcuts

Shortcut Action
Ctrl+B Bold
Ctrl+I Italic
Ctrl+U Underline
Ctrl+Z Undo
Ctrl+Y / Ctrl+Shift+Z Redo
Ctrl+S Save (submits surrounding form, or fires md-save event)
Tab Indent selection (4 spaces)
Shift+Tab Outdent selection

Formatting shortcuts apply to the selected text, or insert placeholder syntax at the cursor if nothing is selected.

Ctrl+S calls form.requestSubmit() on the nearest parent <form> if one exists, and always fires a md-save CustomEvent on the editor element so you can hook in custom save logic:


All versions of markdown-editor with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
composer-plugin-api Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cheinisch/markdown-editor contains the following files

Loading the files please wait ...