Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Tiptap Php Laravel Package

ueberdosis/tiptap-php

PHP utilities for working with Tiptap: parse and validate ProseMirror/Tiptap JSON, render or transform documents, and build extensions-friendly pipelines on the backend. Ideal for Laravel apps needing server-side handling of rich-text editor content.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Tight Integration with Tiptap: The package mirrors Tiptap’s JavaScript API, enabling seamless bidirectional conversion between HTML and Tiptap-compatible JSON. This aligns well with Laravel’s ecosystem, where rich-text editing (e.g., via Tiptap.js frontend) often requires server-side processing.
    • Extensibility: Supports custom extensions, schema validation, and ProseMirror-like node/mark manipulation. This is valuable for teams needing bespoke content structures (e.g., custom blocks, nested elements).
    • Sanitization: Built-in HTML sanitization addresses XSS risks, critical for user-generated content (e.g., CMS, forums).
    • Syntax Highlighting: Integrates with highlight.php or Shiki (via Node.js), adding value for technical documentation or code-heavy applications.
    • Plain Text Extraction: Useful for search indexing, metadata generation, or analytics.
  • Cons:

    • ProseMirror Schema Limitations: The README acknowledges partial schema adherence (e.g., marks in CodeBlock). Teams relying on complex nested structures may need custom extensions or workarounds.
    • Shiki Dependency: The Shiki-based highlighter requires Node.js, adding operational complexity (e.g., CI/CD, deployment). The highlight.php alternative is PHP-native but less feature-rich.
    • No Active Dependents: Lack of adopters suggests unproven scalability or niche use cases. However, this also implies fewer breaking changes.

Integration Feasibility

  • Laravel Compatibility:

    • Native PHP: Zero frontend dependencies; integrates cleanly with Laravel’s backend (e.g., API responses, Eloquent models, Blade templates).
    • Tiptap.js Synergy: Frontend Tiptap.js editors can pair with this package for full-stack consistency (e.g., serialize JSON to PHP, sanitize, then re-render).
    • Service Provider: Can be bootstrapped as a Laravel service (e.g., Tiptap::editor()), encapsulating editor configurations.
    • Middleware: Sanitization logic can be injected via middleware for incoming requests (e.g., API payloads).
  • Database Considerations:

    • Storage Format: JSON for Tiptap content is verbose. Consider:
      • Normalized Storage: Store only essential fields (e.g., content_json, plain_text) and reconstruct objects on demand.
      • Database Drivers: Use Laravel’s JSON column types (e.g., jsonb in PostgreSQL) for efficient querying.
    • Migration Path: Existing HTML content can be migrated via sanitize() or batch processing.
  • Caching:

    • Rendered HTML: Cache sanitized/rendered HTML to reduce CPU load (e.g., Cache::remember).
    • Plain Text: Cache extracted text for search or analytics pipelines.

Technical Risk

  • Schema Drift: Custom extensions may diverge from Tiptap’s schema. Mitigate with:
    • Tests: Validate output against ProseMirror’s expectations.
    • Documentation: Clearly define supported/unsupported features for developers.
  • Shiki Complexity: Node.js dependency adds risk. Alternatives:
    • Use highlight.php for simpler use cases.
    • Containerize Shiki (e.g., Docker) if Node.js is unavoidable.
  • Performance:
    • Large Documents: Deep descendants() traversals could be slow. Profile and optimize with lazy loading or chunked processing.
    • Syntax Highlighting: Shiki’s inline styles may bloat HTML. Test impact on page load times.
  • Deprecations: Dropped PHP 7.4 support may affect legacy systems. Ensure compatibility with Laravel’s supported versions (e.g., 8.0+).

Key Questions

  1. Use Case Alignment:
    • Is the primary need content conversion (HTML ↔ JSON), sanitization, or custom extensions?
    • Does the team already use Tiptap.js frontend? If not, is this a strategic investment?
  2. Schema Requirements:
    • Are there complex nested structures (e.g., tables, custom blocks) that may require extensions?
    • How critical is ProseMirror schema adherence?
  3. Operational Constraints:
    • Can Node.js be introduced for Shiki, or is highlight.php sufficient?
    • What’s the expected scale (e.g., document size, request volume)?
  4. Team Expertise:
    • Is the team familiar with ProseMirror/Tiptap’s schema? If not, budget time for learning.
    • Are developers comfortable extending PHP classes for custom logic?
  5. Long-Term Maintenance:
    • Who will maintain custom extensions or handle future package updates?
    • Is there a fallback plan if the package stagnates?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Backend: Ideal for Laravel APIs, controllers, or service layers handling rich-text content.
    • Frontend: Pairs naturally with Tiptap.js (Vue/React/Svelte) for full-stack consistency.
    • Storage: Works with Eloquent models, databases (MySQL/PostgreSQL), or filesystems.
    • Queue Jobs: Offload heavy operations (e.g., syntax highlighting) to Laravel queues.
  • Alternatives Considered:
    • Purifier: Better for HTML sanitization but lacks Tiptap-specific features.
    • DOMPDF: For PDF generation from HTML, but not for JSON ↔ HTML conversion.
    • Custom Solution: Rolling your own would require reinventing ProseMirror’s parsing logic.

Migration Path

  1. Pilot Phase:
    • Scope: Start with a single feature (e.g., HTML sanitization or JSON ↔ HTML conversion).
    • Component: Integrate into a non-critical module (e.g., blog posts, comments).
    • Validation: Compare outputs with existing tools (e.g., manual checks or Purifier).
  2. Incremental Rollout:
    • Phase 1: Replace legacy HTML sanitization with sanitize().
    • Phase 2: Add Tiptap.js frontend and sync JSON with backend.
    • Phase 3: Introduce custom extensions or syntax highlighting as needed.
  3. Data Migration:
    • Existing HTML: Use sanitize() in a batch job to convert legacy content.
    • JSON Storage: Update database schemas to store Tiptap JSON (e.g., add content_json column).
    • Backward Compatibility: Maintain dual storage (HTML + JSON) during transition.

Compatibility

  • Laravel Versions:
    • Tested with PHP 8.0+ (per package requirements). Ensure compatibility with Laravel 8.0+.
    • For older Laravel versions, check for deprecated function calls (e.g., PR #52 in 2.0.0).
  • Dependencies:
    • PHP Extensions: No special extensions required beyond Laravel’s defaults.
    • Node.js: Only needed for Shiki. Use npm ci in CI/CD to pin versions.
    • Composer: Standard installation via composer require.
  • Frontend:
    • Tiptap.js version should match the PHP package’s schema (check Tiptap’s migration guide).
    • Example: If using Tiptap 2.x, ensure PHP package aligns with its schema.

Sequencing

  1. Setup:
    • Install package: composer require ueberdosis/tiptap-php.
    • Publish config (if needed) via Laravel’s publish:vendor or create a config file.
  2. Basic Integration:
    • Inject the editor into a service container:
      $app->singleton(TiptapEditor::class, function ($app) {
          return new \Tiptap\Editor(['extensions' => [new \Tiptap\Extensions\StarterKit]]);
      });
      
    • Use in controllers:
      $html = $request->input('content');
      $json = app(TiptapEditor::class)->setContent($html)->getJSON();
      
  3. Advanced Features:
    • Add custom extensions (e.g., CodeBlockShiki) with Node.js configured in CI/CD.
    • Implement caching for rendered HTML/plain text.
  4. Testing:
    • Unit tests for conversion/sanitization logic.
    • Integration tests with Tiptap.js frontend.
    • Load tests for large documents or high traffic.

Operational Impact

Maintenance

  • Package Updates:
    • Monitor for breaking changes (e.g., ProseMirror schema updates).
    • Test updates in a staging environment before production deployment.
  • Custom Extensions:
    • Document extension logic and dependencies (e.g., Shiki’s Node.js requirements).
    • Version-control extension configurations to avoid drift.
  • Dependency Management:
    • Pin highlight.php or Shiki versions in composer.json/package.json.
    • Use Laravel’s config or environment variables for runtime configurations (e.g., Shiki theme).

Support

  • Debugging:
    • Schema Issues: Use getJSON() to inspect parsed structures and compare with Tiptap.js outputs.
    • Sanitization: Log sanitized vs. original content to identify false positives/negatives
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony