prosemirror


Nameprosemirror JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryPython implementation of core ProseMirror modules for collaborative editing
upload_time2024-04-22 13:30:58
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)
[![Python Version](https://img.shields.io/pypi/pyversions/prosemirror.svg?style=flat)](https://pypi.org/project/prosemirror/)
[![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/e6/b0/915a0c16a50469fe423a0467da8a4039c99e18b3a9c52e415471508fce7c/prosemirror-0.5.0.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[![Python Version](https://img.shields.io/pypi/pyversions/prosemirror.svg?style=flat)](https://pypi.org/project/prosemirror/)\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.0",
    "project_urls": null,
    "split_keywords": [
        "prosemirror",
        " collaborative",
        " editing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e73ff4347b1185d359a056b6e7c95fb2d35f363b36dca00c49863aefff92383f",
                "md5": "01ba2ce5b864f45e045ac83545a0bb74",
                "sha256": "b6a6c5056788025a55b7fe86db7c586cd4e45b1c9ba4d5f0a14d927038591c8d"
            },
            "downloads": -1,
            "filename": "prosemirror-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "01ba2ce5b864f45e045ac83545a0bb74",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 61717,
            "upload_time": "2024-04-22T13:30:57",
            "upload_time_iso_8601": "2024-04-22T13:30:57.025771Z",
            "url": "https://files.pythonhosted.org/packages/e7/3f/f4347b1185d359a056b6e7c95fb2d35f363b36dca00c49863aefff92383f/prosemirror-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6b0915a0c16a50469fe423a0467da8a4039c99e18b3a9c52e415471508fce7c",
                "md5": "d4d2bd75b595c56027286f71a79e24e2",
                "sha256": "03084f2473c3bae416ecd954b3b28bd122d3007f45f84f11cd16ec4671eb6a22"
            },
            "downloads": -1,
            "filename": "prosemirror-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d4d2bd75b595c56027286f71a79e24e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 71443,
            "upload_time": "2024-04-22T13:30:58",
            "upload_time_iso_8601": "2024-04-22T13:30:58.223134Z",
            "url": "https://files.pythonhosted.org/packages/e6/b0/915a0c16a50469fe423a0467da8a4039c99e18b3a9c52e415471508fce7c/prosemirror-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-22 13:30:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "prosemirror"
}
        
Elapsed time: 0.25178s