Meet Editor and Protect

Verbb Team Verbb Team Dec 2026 8 min read

Blog editor protect

One of the first things we wanted for Comments 4 was a better front end, and a big part of that was a proper rich-text editor for the people writing comments. That led us straight to Tiptap (opens new window), which we know well from building Vizy on it since 2021.

We wanted everyday formatting such as bold, italics, lists and quotes, plus the ability to add the things a conversation needs, like mentions, attachments, links to entries and GIFs. We built it all for Comments 4, were pretty stoked with how it turned out, and then realised a few of our upcoming projects needed exactly the same thing.

So we pulled it out into Editor (opens new window), a free, open-source package that anyone can use for front-end editing in their own Craft plugins and modules. We did the same with Comments 4's spam protection, for slightly different reasons, and that became Protect (opens new window). It checks what visitors submit for spam and abuse, because sooner or later you'll meet the visitor with very strong opinions about discount sunglasses. Here's what each one does, with a bit of code to show how they fit into a plugin.

Meet Editor

Vizy and Editor are both built on Tiptap, but they're for different people. Vizy is a field for the people editing content in the control panel. Editor is for the other side of the site, the visitors writing a reply or a review on your front end, where you want something lighter and need to trust whatever they paste in. Its server side uses Tiptap's own PHP package (opens new window) to process what they send.

Give visitors a compact toolbar for short replies, or headings and numbered lists where longer posts need them. The tools sit in a row under the text, the common ones also pop up above any words you select, and people who write in Markdown can keep typing **bold** or - for a list.

Composer
Formatting for longer replies.

Editor's Craft integration covers Asset uploads, attachments, mentions and links to entries, and your plugin decides which of them each form offers and what each person can reach. Uploads go to the Asset volumes you've configured and wait in a tray under the text, where people can add alt text or retry one that failed. Photos lose their metadata, including where they were taken, before they're stored. Mention suggestions can follow your own visibility rules.

Links stay up to date, too. Editor stores references to entries, people and Assets, not copies of their details, so URLs and file information are looked up each time the content is rendered. If an entry's URL changes after someone links to it, the link uses the new URL, and if the entry is later deleted, its text stays in place as plain text instead of becoming a broken link.

Links to Craft entries and Asset uploads, built in.

GIFs, Drafts and Other Extras

Add a GIPHY key and the toolbar gets a GIF button, with search that shows what's trending until someone types. Nothing contacts GIPHY until the search is opened, and its code only loads then too. A few more things come with every editor:

  • Saved drafts, so someone who reloads the page gets their unfinished reply back.
  • Character limits that count down the last stretch and hold the Post button once someone's over.
  • A Post button with its own posting state and a Try again when saving fails, while your own code still does the saving.
  • Four themes that take your site's colours, plus collapsed, borderless and narrow layouts.
  • Enter to send, for chat-style messages.
  • Your own Tiptap extensions, paired with a PHP extension so the server keeps their content.
Gif search dogs
Because some replies are just a GIF.

Adding Editor to Your Plugin

Editor comes with your plugin through Composer, so site owners have nothing extra to install. Your plugin boots it, then registers a context, which is the server-side config for one editor. It sets which features that editor offers, who can be mentioned and where uploads go, and every request from the browser is checked against it. This one allows basic formatting, links and mentions of anyone in a members group:

use Craft;
use craft\elements\User;
use verbb\editor\Editor;
use verbb\editor\models\EditorConfig;
use verbb\editor\models\MentionConfig;

// In your plugin's init().
Editor::bootstrap();

Craft::$app->onInit(function() {
    Editor::$plugin->getEditorConfigs()->registerConfig(new EditorConfig([
        'handle' => 'myplugin.reply',
        'features' => [
            'bold' => true,
            'italic' => true,
            'lists' => true,
            'link' => true,
            'mention' => true,
        ],
        'mentions' => new MentionConfig([
            'enabled' => true,
            'criteria' => ['group' => 'members'],
        ]),
        'authorize' => fn(User $user) => $user->can('myplugin-reply'),
    ]));
});

In your template, <verbb-editor> works like any other form field. editorAssets() loads the browser code, and options is the context's browserOptions(), which hands the editor its features, endpoints and CSRF token so you don't repeat them by hand:

{% do editorAssets() %}

<form method="post">
    {{ csrfInput() }}
    {{ actionInput('my-plugin/replies/save') }}

    <verbb-editor name="body" required aria-label="Reply" submit-label="Reply"
        data-options="{{ options|json_encode }}">
    </verbb-editor>
</form>

When the form posts, your controller passes body through normalize(), which sanitises the document and applies the context's features and limits, so nothing gets saved that the editor wouldn't have let someone write. Showing it later is a filter on the stored value:

{{ reply.body|editorHtml('myplugin.reply') }}

editorHtml outputs safe HTML using that context's rules, and editorPlain gives you the plain-text version for a notification email. If you'd rather see it before writing any code, the Playground (opens new window) runs the real editor in your browser. From there, the Editor docs (opens new window) cover uploads, page links and rendering in full, and Build a Notes Plugin with Editor (opens new window) walks through a small plugin where members post notes with links, mentions and photos. The browser package, @verbb/editor, is there too for front ends you build yourself.

Meet Protect

We wanted to rework how spam protection worked in Comments 4, mostly because of what we'd just done in Formie 4, which put honeypots, minimum submit times, replay protection, content screening and throttling in one place alongside its captcha providers. Doing all of that again for Comments meant another round of captcha integrations, spam services and rate limits, and a few of our upcoming projects were going to need the same again. Building it separately for each of them didn't appeal much.

Formie's checks are built around Formie's forms, though, and a comment, a vote or a "report this" button isn't a Formie form. So Protect takes the same kinds of checks and makes them work for any action that accepts something from the public. Where Editor is mostly about the people writing, Protect is mostly for you, the developer. Every plugin that uses it gets the same checks, set up the same way, with one result to read at the end.

Pick the checks that suit each action and run them together. Protect has a honeypot, a minimum submission time, a JavaScript check, replay protection and rate limiting built in. When those aren't enough, add a challenge from Cloudflare Turnstile (opens new window), reCAPTCHA v3 (opens new window), hCaptcha (opens new window) or Friendly Captcha (opens new window), or have Akismet (opens new window), CleanTalk (opens new window) or OOPSpam (opens new window) read what was written and say whether it looks like spam.

You don't need every provider, and the honeypot, minimum time, replay protection and rate limits all work on a form with no JavaScript at all. The JavaScript check and challenges run in the visitor's browser, so they need Protect's browser script, which Protect adds to a Twig form for you.

This plan protects a feedback form with a honeypot, a two-second minimum, a limit of five attempts per minute and replay protection:

use verbb\protect\checks\Honeypot;
use verbb\protect\checks\MinimumTime;
use verbb\protect\checks\RateLimit;
use verbb\protect\checks\ReplayProtection;
use verbb\protect\models\ProtectionPlan;
use verbb\protect\models\RateLimitRule;

$plan = (new ProtectionPlan(handle: 'example-feedback-v1'))
    ->add(new Honeypot())
    ->add(new MinimumTime(['seconds' => 2]))
    ->add(new RateLimit(['rules' => [
        new RateLimitRule(['limit' => 5, 'window' => 60]),
    ]]))
    ->add(new ReplayProtection());

Your form template renders the matching hidden fields, and your controller checks the submission against the same plan before saving. The integration guide (opens new window) covers both steps, and Protect a Feedback Form (opens new window) builds a complete feedback plugin, then adds Turnstile at the end.

Spam settings
Comments’ spam settings, using Protect’s checks.

What Protect Tells Your Code

Protect doesn't publish content, change moderation status or delete records itself. It tells your code what it found, and suspected spam, a rate limit that's been hit and a provider that can't be reached are different situations that usually need handling differently. You might hold suspected spam for moderation, ask someone to wait a minute, or decide whether comments can still go through while Turnstile is down.

Here's a partial controller example, run after your own permission and input checks:

use verbb\protect\enums\FindingType;
use yii\web\HttpException;

// $result comes from Protect::getInstance()->check($context, $plan).
if (($retryAfter = $result->retryAfter()) !== null) {
    throw new HttpException(429, 'Please wait before trying again.');
}

if ($result->hasErrors()) {
    // An operational error, such as an unreachable provider. Your outage policy decides this.
    throw new HttpException(503, 'Verification is temporarily unavailable.');
}

if ($result->hasFinding(FindingType::SpamDetected)) {
    $holdForModeration = true;
} elseif ($result->hasAdverseFindings()) {
    throw new HttpException(400, 'Refresh the form and try again.');
}

Because it isn't tied to a message, Protect works for actions with no text at all, like a vote or a report button, and you can add your own checks or providers when a project needs something specific. For a form your own JavaScript submits, the @verbb/protect browser package mounts any challenge and collects the evidence to send with it, while your own code keeps control of submitting and showing feedback.

Rate limit
Turnstile running alongside the form.

Give Them a Go

Both packages are free and MIT licensed, with their source on GitHub. Comments 4 depends on them too, so we've got every reason to keep them in good shape.

Editor and Protect need Craft 5.10 or later and PHP 8.2 or later, and their browser packages are on npm. They're developer packages that you add to your own plugin or module with Composer, so you won't find them in the Plugin Store. Start with the Editor docs (opens new window) or the Protect docs (opens new window), and tell us what you build with them, or what's missing.