WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

ueberdosis/prosemirror-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨 We’ve done a rewrite that you probably want to check out: ueberdosis/tiptap-php

ProseMirror PHP

This package enables you to work with ProseMirror JSON in PHP. Convert it to HTML, or convert HTML to ProseMirror compatible JSON.

Latest Version on Packagist Integrate Total Downloads Sponsor

Installation

composer require ueberdosis/prosemirror-php

Usage

Convert HTML to ProseMirror JSON:

(new \ProseMirror\ProseMirror)->html('<p>Example Text</p>')->toJson();

or

\ProseMirror\ProseMirror::htmlToJson('<p>Example Text</p>');

Output:

{
    "type": "doc",
    "content": [
        {
            "type": "paragraph",
            "content": [
                {
                    "type": "text",
                    "text": "Example Text"
                }
            ]
        }
    ]
}

Convert ProseMirror JSON to HTML:

(new \ProseMirror\ProseMirror)->json([
    'type' => 'doc',
    'content' => [
        [
            'type' => 'paragraph',
            'content' => [
                [
                    'type' => 'text',
                    'text' => 'Example Text',
                ],
            ],
        ],
    ],
])->toHtml();

or

\ProseMirror\ProseMirror::jsonToHtml([
    'type' => 'doc',
    'content' => [
        [
            'type' => 'paragraph',
            'content' => [
                [
                    'type' => 'text',
                    'text' => 'Example Text',
                ],
            ],
        ],
    ],
]);

Output:

<p>Example Text</p>

Contributing

Pull Requests are welcome.

Credits

Related Packages

License

The MIT License (MIT). Please see License File for more information.

About

Work with ProseMirror JSON in PHP.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 4

  •  
  •  
  •  
  •  

Languages