prosemirror


Nameprosemirror JSON
Version 0.5.1 PyPI version JSON
download
home_pageNone
SummaryPython implementation of core ProseMirror modules for collaborative editing
upload_time2024-11-18 19:40:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseBSD-3-Clause
keywords prosemirror collaborative editing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # prosemirror-py

[![CI](https://github.com/fellowapp/prosemirror-py/actions/workflows/test.yml/badge.svg)](https://github.com/fellowapp/prosemirror-py/actions/workflows/test.yml)
[![Code Coverage](https://codecov.io/gh/fellowapp/prosemirror-py/branch/master/graph/badge.svg?style=flat)](https://codecov.io/gh/fellowapp/prosemirror-py)
[![PyPI Package](https://img.shields.io/pypi/v/prosemirror.svg?style=flat)](https://pypi.org/project/prosemirror/)
[![License](https://img.shields.io/pypi/l/prosemirror.svg?style=flat)](https://github.com/fellowapp/prosemirror-py/blob/master/LICENSE.md)
[![Fellow Careers](https://img.shields.io/badge/fellow.app-hiring-576cf7.svg?style=flat)](https://fellow.app/careers/)

This package provides Python implementations of the following
[ProseMirror](https://prosemirror.net/) packages:

- [`prosemirror-model`](https://github.com/ProseMirror/prosemirror-model) version 1.18.1
- [`prosemirror-transform`](https://github.com/ProseMirror/prosemirror-transform) version 1.8.0
- [`prosemirror-test-builder`](https://github.com/ProseMirror/prosemirror-test-builder)
- [`prosemirror-schema-basic`](https://github.com/ProseMirror/prosemirror-schema-basic) version 1.1.2
- [`prosemirror-schema-list`](https://github.com/ProseMirror/prosemirror-schema-list)

The original implementation has been followed as closely as possible during
translation to simplify keeping this package up-to-date with any upstream
changes.

## Why?

ProseMirror provides a powerful toolkit for building rich-text editors, but it's
JavaScript-only. Until now, the only option for manipulating and working with
ProseMirror documents from Python was to embed a JS runtime. With this
translation, you can now define schemas, parse documents, and apply transforms
directly via a native Python API.

## Status

The full ProseMirror test suite has been translated and passes. This project
only supports Python 3. The code has type annotations to support mypy or other
typechecking tools.

## Usage

Since this library is a direct port, the best place to learn how to use it is
the [official ProseMirror documentation](https://prosemirror.net/docs/guide/).
Here is a simple example using the included "basic" schema:

```python
from prosemirror.transform import Transform
from prosemirror.schema.basic import schema

# Create a document containing a single paragraph with the text "Hello, world!"
doc = schema.node("doc", {}, [
    schema.node("paragraph", {}, [
        schema.text("Hello, world!")
    ])
])

# Create a Transform which will be applied to the document.
tr = Transform(doc)

# Delete the text from position 3 to 5. Adds a ReplaceStep to the transform.
tr.delete(3, 5)

# Make the first three characters bold. Adds an AddMarkStep to the transform.
tr.add_mark(1, 4, schema.mark("strong"))

# This transform can be converted to JSON to be sent and applied elsewhere.
assert [step.to_json() for step in tr.steps] == [{
    'stepType': 'replace',
    'from': 3,
    'to': 5
}, {
    'stepType': 'addMark',
    'mark': {'type': 'strong', 'attrs': {}},
    'from': 1,
    'to': 4
}]

# The resulting document can also be converted to JSON.
assert tr.doc.to_json() == {
    'type': 'doc',
    'content': [{
        'type': 'paragraph',
        'content': [{
            'type': 'text',
            'marks': [{'type': 'strong', 'attrs': {}}],
            'text': 'Heo'
        }, {
            'type': 'text',
            'text': ', world!'
        }]
    }]
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prosemirror",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "prosemirror, collaborative, editing",
    "author": null,
    "author_email": "Samuel Cormier-Iijima <sam@fellow.co>, Shen Li <dustet@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/83/82/4b303ac63b7396cf3fa9481d6a0e06a345cde8f36fd2c0608f6f1f5d8392/prosemirror-0.5.1.tar.gz",
    "platform": null,
    "description": "# prosemirror-py\n\n[![CI](https://github.com/fellowapp/prosemirror-py/actions/workflows/test.yml/badge.svg)](https://github.com/fellowapp/prosemirror-py/actions/workflows/test.yml)\n[![Code Coverage](https://codecov.io/gh/fellowapp/prosemirror-py/branch/master/graph/badge.svg?style=flat)](https://codecov.io/gh/fellowapp/prosemirror-py)\n[![PyPI Package](https://img.shields.io/pypi/v/prosemirror.svg?style=flat)](https://pypi.org/project/prosemirror/)\n[![License](https://img.shields.io/pypi/l/prosemirror.svg?style=flat)](https://github.com/fellowapp/prosemirror-py/blob/master/LICENSE.md)\n[![Fellow Careers](https://img.shields.io/badge/fellow.app-hiring-576cf7.svg?style=flat)](https://fellow.app/careers/)\n\nThis package provides Python implementations of the following\n[ProseMirror](https://prosemirror.net/) packages:\n\n- [`prosemirror-model`](https://github.com/ProseMirror/prosemirror-model) version 1.18.1\n- [`prosemirror-transform`](https://github.com/ProseMirror/prosemirror-transform) version 1.8.0\n- [`prosemirror-test-builder`](https://github.com/ProseMirror/prosemirror-test-builder)\n- [`prosemirror-schema-basic`](https://github.com/ProseMirror/prosemirror-schema-basic) version 1.1.2\n- [`prosemirror-schema-list`](https://github.com/ProseMirror/prosemirror-schema-list)\n\nThe original implementation has been followed as closely as possible during\ntranslation to simplify keeping this package up-to-date with any upstream\nchanges.\n\n## Why?\n\nProseMirror provides a powerful toolkit for building rich-text editors, but it's\nJavaScript-only. Until now, the only option for manipulating and working with\nProseMirror documents from Python was to embed a JS runtime. With this\ntranslation, you can now define schemas, parse documents, and apply transforms\ndirectly via a native Python API.\n\n## Status\n\nThe full ProseMirror test suite has been translated and passes. This project\nonly supports Python 3. The code has type annotations to support mypy or other\ntypechecking tools.\n\n## Usage\n\nSince this library is a direct port, the best place to learn how to use it is\nthe [official ProseMirror documentation](https://prosemirror.net/docs/guide/).\nHere is a simple example using the included \"basic\" schema:\n\n```python\nfrom prosemirror.transform import Transform\nfrom prosemirror.schema.basic import schema\n\n# Create a document containing a single paragraph with the text \"Hello, world!\"\ndoc = schema.node(\"doc\", {}, [\n    schema.node(\"paragraph\", {}, [\n        schema.text(\"Hello, world!\")\n    ])\n])\n\n# Create a Transform which will be applied to the document.\ntr = Transform(doc)\n\n# Delete the text from position 3 to 5. Adds a ReplaceStep to the transform.\ntr.delete(3, 5)\n\n# Make the first three characters bold. Adds an AddMarkStep to the transform.\ntr.add_mark(1, 4, schema.mark(\"strong\"))\n\n# This transform can be converted to JSON to be sent and applied elsewhere.\nassert [step.to_json() for step in tr.steps] == [{\n    'stepType': 'replace',\n    'from': 3,\n    'to': 5\n}, {\n    'stepType': 'addMark',\n    'mark': {'type': 'strong', 'attrs': {}},\n    'from': 1,\n    'to': 4\n}]\n\n# The resulting document can also be converted to JSON.\nassert tr.doc.to_json() == {\n    'type': 'doc',\n    'content': [{\n        'type': 'paragraph',\n        'content': [{\n            'type': 'text',\n            'marks': [{'type': 'strong', 'attrs': {}}],\n            'text': 'Heo'\n        }, {\n            'type': 'text',\n            'text': ', world!'\n        }]\n    }]\n}\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Python implementation of core ProseMirror modules for collaborative editing",
    "version": "0.5.1",
    "project_urls": null,
    "split_keywords": [
        "prosemirror",
        " collaborative",
        " editing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7c420294e196b2161a1f57753871ca9c6f062184ccb6c25e7bcdccddb292154",
                "md5": "637a39b4c64a67e1c47616fbda5cb38b",
                "sha256": "a30902657893906ddc1803d3e0b0b318dc7a082c5a1a3c44c3f6697371539bb5"
            },
            "downloads": -1,
            "filename": "prosemirror-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "637a39b4c64a67e1c47616fbda5cb38b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 61729,
            "upload_time": "2024-11-18T19:40:45",
            "upload_time_iso_8601": "2024-11-18T19:40:45.243712Z",
            "url": "https://files.pythonhosted.org/packages/a7/c4/20294e196b2161a1f57753871ca9c6f062184ccb6c25e7bcdccddb292154/prosemirror-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83824b303ac63b7396cf3fa9481d6a0e06a345cde8f36fd2c0608f6f1f5d8392",
                "md5": "7a74e7750004fdc50df5cc6ebafe0139",
                "sha256": "08e8c253ffdfac97f630d81a033e5a422cdb8d1b05df2a581574ba6838eaac85"
            },
            "downloads": -1,
            "filename": "prosemirror-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7a74e7750004fdc50df5cc6ebafe0139",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 71512,
            "upload_time": "2024-11-18T19:40:46",
            "upload_time_iso_8601": "2024-11-18T19:40:46.793642Z",
            "url": "https://files.pythonhosted.org/packages/83/82/4b303ac63b7396cf3fa9481d6a0e06a345cde8f36fd2c0608f6f1f5d8392/prosemirror-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 19:40:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "prosemirror"
}
        
Elapsed time: 2.87699s