Skip to main content

Python utilities for parsing, traversing, editing, and serializing TipTap JSON content.

Project description

tiptap_python_utils

Python utilities for TipTap JSON content.

tiptap_python_utils parses TipTap documents into typed Python nodes, preserves unknown/custom nodes for lossless round trips, and provides small helpers for traversal, immutable edits, visible text extraction, task queries, and shared node synchronization.

The package has no runtime dependencies.

Install

pip install tiptap_python_utils

Quick Start

from tiptap_python_utils import Content, Paragraph, Text, kind

raw = {
    "type": "doc",
    "content": [
        {
            "type": "paragraph",
            "attrs": {"id": "p1"},
            "content": [{"type": "text", "text": "Old"}],
        }
    ],
}

updated = Content.require(raw).where_id("p1").text("New").dump()

Typed Nodes

Build typed nodes directly and serialize them back to TipTap-compatible JSON:

node = Paragraph(id="p1", content=(Text(value="Hello"),))
doc = Content.wrap(node.raw())

Unknown/custom node types are preserved as Unknown nodes and round-trip without dropping extra fields.

Selection And Editing

Select nodes by id or TipTap kind:

updated = Content.require(raw).of(kind.PARAGRAPH).attr("color", "blue").dump()

Selection methods return updated immutable content:

updated = (
    Content.require(raw)
    .where_id("p1")
    .text("Updated")
    .attr("data-state", "reviewed")
    .dump()
)

Text Extraction

Extract visible text or contextual slices:

from tiptap_python_utils import Content, text_slices, visible_text, word_count

content = Content.require(raw)

plain_text = visible_text(content)
count = word_count(content)
slices = text_slices(content, context=True)

Tasks

from tiptap_python_utils import Content, has_open_tasks, open_tasks

content = Content.require(raw)

pending = has_open_tasks(content)
items = open_tasks(content)

Public API

Common imports are available from the package root:

from tiptap_python_utils import (
    Content,
    Paragraph,
    TaskItem,
    Text,
    append_node,
    has_open_tasks,
    kind,
    replace_node,
    shared_families,
    sync_shared,
    text_slices,
)

Development

python -m pip install -e ".[dev]"
pytest -q

Build and check a release artifact:

python -m build
python -m twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiptap_python_utils-0.1.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiptap_python_utils-0.1.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file tiptap_python_utils-0.1.0.tar.gz.

File metadata

  • Download URL: tiptap_python_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tiptap_python_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a138c069ec9c0f121d4b447339b57f1baff292fe9c32d5fc7e59fb893f26b4ef
MD5 c8e1f57ad4ad033b63e2903b7aebe194
BLAKE2b-256 ba00feb4b170cd939369427a70e63633eaf0fd809e3e440c7a656eb2967e232c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiptap_python_utils-0.1.0.tar.gz:

Publisher: publish.yml on tugkanpilka/tiptap-python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiptap_python_utils-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tiptap_python_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c2169046abef925c90509ece81bae6d0c8f0eb544e10cd6c208499144ebd17b
MD5 f7566efa33390ef3541acce38402745b
BLAKE2b-256 84c1bb3e7e5370a9180737e0e19dc4e2534721b27958b6ba8e49340e80e73613

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiptap_python_utils-0.1.0-py3-none-any.whl:

Publisher: publish.yml on tugkanpilka/tiptap-python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page