Skip to content
Brok UI

Loading…

No results

Editor Blocks

Open + Pro variants

platejs.org-inspired rich-text editors — a full document surface, a compact composer, a commented document and an AI-assisted draft.

Preview

1 of 5

resources/views/blocks/editor-document.blade.php Blade
@props([
    'heading'  => 'Document Editor',
    'eyebrow'  => 'Draft',
])

<x-ui.section space="lg">
    <div class="mx-auto w-full max-w-3xl px-4 sm:px-6">

        {{-- Eyebrow / heading --}}
        <div class="mb-6">
            <p class="mb-2 text-xs font-medium uppercase tracking-widest text-muted-foreground">
                {{ __($eyebrow) }}
            </p>
            <h2 class="text-2xl font-semibold tracking-tight text-foreground">
                {{ __($heading) }}
            </h2>
        </div>

        {{-- Full-page document editor --}}
        <x-ui.editor
            placeholder="{{ __('Start writing your document…') }}"
            ariaLabel="{{ __('Document editor') }}"
        >
            {{-- Toolbar slot --}}
            <x-slot:toolbar>
                <x-ui.editor-toolbar />
            </x-slot:toolbar>

            {{-- Floating selection toolbar: an overlay in the tools slot, beside
                 the editable region rather than inside it. --}}
            <x-slot:tools>
                <x-ui.editor-toolbar variant="floating" />
            </x-slot:tools>

            {{-- Seeded document content — plain HTML; editor styles raw child elements --}}
            <h1>{{ __('Getting Started with the Rich-Text Editor') }}</h1>

            <p>
                {{ __('This editor supports the full range of inline marks: ') }}
                <strong>{{ __('bold text') }}</strong>{{ __(', ') }}
                <em>{{ __('italic text') }}</em>{{ __(', ') }}
                <u>{{ __('underlined text') }}</u>{{ __(', and ') }}
                <a href="#">{{ __('inline links') }}</a>{{ __('. Combine them freely within a paragraph.') }}
            </p>

            <p>
                {{ __('You can also insert inline ') }}<code>{{ __('code snippets') }}</code>{{ __(' mid-sentence to reference variables, functions, or terminal commands without breaking the reading flow.') }}
            </p>

            {{-- Info alert note using the alert primitive --}}
            <x-ui.alert variant="default" class="my-4">
                <x-ui.alert.title>{{ __('Pro tip') }}</x-ui.alert.title>
                <x-ui.alert.description>
                    {{ __('Select any text to reveal the floating toolbar with quick-access formatting buttons.') }}
                </x-ui.alert.description>
            </x-ui.alert>

            <h2>{{ __('Block-Level Formatting') }}</h2>

            <p>
                {{ __('Use the toolbar block-type picker to switch paragraphs into headings, blockquotes, or code blocks. Here is a pull quote:') }}
            </p>

            <blockquote>{{ __('Good writing is clear thinking made visible.') }}</blockquote>

            <h2>{{ __('Lists') }}</h2>

            <p>{{ __('Unordered list:') }}</p>
            <ul>
                <li>{{ __('Write with confidence') }}</li>
                <li>{{ __('Format without leaving the keyboard') }}</li>
                <li>{{ __('Paste content cleanly') }}</li>
            </ul>

            <p>{{ __('Ordered list:') }}</p>
            <ol>
                <li>{{ __('Open the editor') }}</li>
                <li>{{ __('Select a block type from the toolbar') }}</li>
                <li>{{ __('Start writing') }}</li>
            </ol>

            <h2>{{ __('Code Blocks') }}</h2>

            <p>{{ __('Longer multi-line code lives in a fenced code block:') }}</p>
            <pre>{{ __('function greet(name) {
    return `Hello, ${name}!`;
}

console.log(greet(\'World\'));') }}</pre>

            {{-- Footer slot --}}
            <x-slot:footer>
                <span class="text-muted-foreground">
                    {{ __('Draft') }} &mdash; {{ __('Last edited just now') }}
                </span>
                <span class="ms-auto text-muted-foreground">
                    {{ __('Ctrl+B bold, Ctrl+I italic, Ctrl+K link') }}
                </span>
            </x-slot:footer>
        </x-ui.editor>

    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/editor-document

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/editor-document writes only the generated targets below. The CLI validates each file hash before writing and prompts before replacing local changes unless --force is used.

Version
1.0.6
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/editor-document.blade.php

Registry dependencies

alert editor editor-toolbar section

Package dependencies

composer: jml/brok:^0.2

npm: alpinejs

Use with AI

A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.

editor-document.md
# Brok UI block: Editor (`editor-document`)

A full-page document editor demo with a fixed formatting toolbar, floating selection toolbar, rich seeded content covering every supported element, and an inline info alert note.

Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.

## Install

```bash
php artisan ui:add blocks/editor-document
```

## Render it

```blade
<x-blocks.editor-document />
```

## Props

- `heading` (string, default `Document Editor`)
- `eyebrow` (string, default `Draft`)

## Use when

- Demoing a full-page rich text document editor with a fixed formatting toolbar and seeded content covering every supported element.
- Showing a floating selection toolbar that appears when text is selected, alongside an inline info alert.

## Avoid when

- Use editor-minimal for a compact inline comment composer, or editor-rich for a kitchen-sink editor with tables and media.

## Rules

- Render the installed block with `<x-blocks.editor-document />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.

## Links

- Docs: https://brokui.dev/blocks/editor-document
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/editor-document.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

Guidance

Use when

  • Demoing a full-page rich text document editor with a fixed formatting toolbar and seeded content covering every supported element.
  • Showing a floating selection toolbar that appears when text is selected, alongside an inline info alert.

Avoid when

  • Use editor-minimal for a compact inline comment composer, or editor-rich for a kitchen-sink editor with tables and media.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.

Usage

Render the block as a component, passing data where useful:

resources/views/welcome.blade.php Blade
<x-blocks.editor-document />

Built from primitives

Composes <brok:*> Semantic tokens Re-themeable RTL-ready

This block composes installed <brok:*> primitives and semantic design tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by editing CSS variables; flip the preview to RTL to confirm it mirrors.

Source

The exact, editable file ui:add writes into your app. The preview above renders this same source — there are no preview-only blocks.

resources/views/blocks/editor-document.blade.php Blade
@props([
    'heading'  => 'Document Editor',
    'eyebrow'  => 'Draft',
])

<x-ui.section space="lg">
    <div class="mx-auto w-full max-w-3xl px-4 sm:px-6">

        {{-- Eyebrow / heading --}}
        <div class="mb-6">
            <p class="mb-2 text-xs font-medium uppercase tracking-widest text-muted-foreground">
                {{ __($eyebrow) }}
            </p>
            <h2 class="text-2xl font-semibold tracking-tight text-foreground">
                {{ __($heading) }}
            </h2>
        </div>

        {{-- Full-page document editor --}}
        <x-ui.editor
            placeholder="{{ __('Start writing your document…') }}"
            ariaLabel="{{ __('Document editor') }}"
        >
            {{-- Toolbar slot --}}
            <x-slot:toolbar>
                <x-ui.editor-toolbar />
            </x-slot:toolbar>

            {{-- Floating selection toolbar: an overlay in the tools slot, beside
                 the editable region rather than inside it. --}}
            <x-slot:tools>
                <x-ui.editor-toolbar variant="floating" />
            </x-slot:tools>

            {{-- Seeded document content — plain HTML; editor styles raw child elements --}}
            <h1>{{ __('Getting Started with the Rich-Text Editor') }}</h1>

            <p>
                {{ __('This editor supports the full range of inline marks: ') }}
                <strong>{{ __('bold text') }}</strong>{{ __(', ') }}
                <em>{{ __('italic text') }}</em>{{ __(', ') }}
                <u>{{ __('underlined text') }}</u>{{ __(', and ') }}
                <a href="#">{{ __('inline links') }}</a>{{ __('. Combine them freely within a paragraph.') }}
            </p>

            <p>
                {{ __('You can also insert inline ') }}<code>{{ __('code snippets') }}</code>{{ __(' mid-sentence to reference variables, functions, or terminal commands without breaking the reading flow.') }}
            </p>

            {{-- Info alert note using the alert primitive --}}
            <x-ui.alert variant="default" class="my-4">
                <x-ui.alert.title>{{ __('Pro tip') }}</x-ui.alert.title>
                <x-ui.alert.description>
                    {{ __('Select any text to reveal the floating toolbar with quick-access formatting buttons.') }}
                </x-ui.alert.description>
            </x-ui.alert>

            <h2>{{ __('Block-Level Formatting') }}</h2>

            <p>
                {{ __('Use the toolbar block-type picker to switch paragraphs into headings, blockquotes, or code blocks. Here is a pull quote:') }}
            </p>

            <blockquote>{{ __('Good writing is clear thinking made visible.') }}</blockquote>

            <h2>{{ __('Lists') }}</h2>

            <p>{{ __('Unordered list:') }}</p>
            <ul>
                <li>{{ __('Write with confidence') }}</li>
                <li>{{ __('Format without leaving the keyboard') }}</li>
                <li>{{ __('Paste content cleanly') }}</li>
            </ul>

            <p>{{ __('Ordered list:') }}</p>
            <ol>
                <li>{{ __('Open the editor') }}</li>
                <li>{{ __('Select a block type from the toolbar') }}</li>
                <li>{{ __('Start writing') }}</li>
            </ol>

            <h2>{{ __('Code Blocks') }}</h2>

            <p>{{ __('Longer multi-line code lives in a fenced code block:') }}</p>
            <pre>{{ __('function greet(name) {
    return `Hello, ${name}!`;
}

console.log(greet(\'World\'));') }}</pre>

            {{-- Footer slot --}}
            <x-slot:footer>
                <span class="text-muted-foreground">
                    {{ __('Draft') }} &mdash; {{ __('Last edited just now') }}
                </span>
                <span class="ms-auto text-muted-foreground">
                    {{ __('Ctrl+B bold, Ctrl+I italic, Ctrl+K link') }}
                </span>
            </x-slot:footer>
        </x-ui.editor>

    </div>
</x-ui.section>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.6
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0