GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Tiptap Docs
  • UI Components
  • Website
  • Sign up
  • Tiptap Editor
  • Quick start
  • Vanilla JavaScript
  • React
  • Next.js
  • Vue 3
  • Vue 2
  • Nuxt
  • Svelte
  • Alpine

This view

  • Original page
  • New address

GeezerVison is showing tiptap.dev — PHP | Tiptap Editor Docs

You can use Tiptap with Laravel, Livewire, Inertia.js, Alpine.js, Tailwind CSS, and even—yes, you read that right—inside PHP.

We provide an official PHP package to work with Tiptap content. You can transform Tiptap-compatible JSON to HTML and vice versa, sanitize your content, or just modify it.

Laravel Livewire

my-livewire-component.blade.php

<!--
  In your livewire component you could add an
  autosave method to handle saving the content
  from the editor every 10 seconds if you wanted
-->
<x-editor wire:model="foo" wire:poll.10000ms="autosave"></x-editor>

Hint

The .defer modifier is no longer available in Livewire v3, as updating the state is deferred by default. Use the .live modifier if you need to update the state server-side, as it changes.

editor.blade.php

<div
  x-data="setupEditor(
    $wire.entangle('{{ $attributes->wire('model')->value() }}').defer
  )"
  x-init="() => init($refs.editor)"
  wire:ignore
  {{ $attributes->whereDoesntStartWith('wire:model') }}
>
  <div x-ref="editor"></div>
</div>

index.js

import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

window.setupEditor = function (content) {
  let editor

  return {
    content: content,

    init(element) {
      editor = new Editor({
        element: element,
        extensions: [StarterKit],
        content: this.content,
        onUpdate: ({ editor }) => {
          this.content = editor.getHTML()
        },
      })

      this.$watch('content', (content) => {
        // If the new content matches Tiptap's then we just skip.
        if (content === editor.getHTML()) return

        /*
          Otherwise, it means that an external source
          is modifying the data on this Alpine component,
          which could be Livewire itself.
          In this case, we only need to update Tiptap's
          content and we're done.
          For more information on the `setContent()` method, see:
            https://www.tiptap.dev/api/commands/set-content
        */
        editor.commands.setContent(content, false)
      })
    },
  }
}

Next steps

  • Configure your editor
  • Add styles to your editor
  • Learn more about Tiptaps concepts
  • Learn how to persist the editor state
  • Start building your own extensions
PreviouslyAlpine
Next upCDN
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.