XF 2.4 Tiptap: A new editor for XenForo

2.4 editor flare.webp
Rich text editors are hard. When you drill down into how they actually work, it's a wonder why there are so many of them, and why developers would willingly spend a significant part of their life working on one. At XenForo we have been through ... counts on fingers ... three different rich text editors in our history, so if we're being generous we can at least attest to what a feat of engineering they are and how difficult they can be to get right -- and all we have to do is implement them.

That's no easy feat either, though. We have an increasing number of features that we need from an editor, we have a layer of conversion from HTML to BB code (and back again), and we have an overall user base of millions of members across all of our customers who all seem intent on breaking our editor in weird and wonderful ways. So picking a new editor is fraught with risk and challenges. Sometimes, even when we pick the right editor, it doesn't always stay that way.

Over recent years we've been keeping a close eye on the developments within the rich text editor space and while there are a few interesting projects, there is only one very clear winner, and that is Tiptap.

What is Tiptap?​

Tiptap is a completely modular, open source and headless editor framework. Headless means that there is no provided user interface. Modular means you can enable only the functionality that you need. It is so modular that, technically, you don't even have to enable paragraphs or text (though that might impede its usefulness). It also has a fantastic extension system that allows us to not only create our own extensions, but also extend existing extensions! (more on that later).

Tiptap, which is itself powered by the amazing ProseMirror toolkit, does not simply attempt to decorate input with arbitrary HTML like most rich text editors. Rather, it has a very strict (but extendable) schema made up of Marks and Nodes. Marks are inline formatting (such as bold and italic) and Nodes are block-level formatting (such as paragraphs, quotes, and code blocks).

Your first look​

Strap in, because there's lots to show you. But first, an artist's representation of how it might look in either light or dark styles:

2.4 editor gradient.webp


The overall look and feel of the editor isn't 100% finalised at this point, but the current iteration, as pictured above, does lean into being familiar. One of the notable changes currently is that we have moved the toolbar to the bottom of the editor, making the controls more accessible, particularly on smartphones.

Want it at the top? No problem, that's a single line of CSS to make that happen.

The toolbar is, as ever, managed entirely through the existing editor button manager in the admin control panel, so the toolbar itself can be made as full-featured or as minimalist as you like.

Great for users and power users alike​

For a lot of things, you might not even need to use the toolbar. The brave amongst you might even choose to disable the toolbar entirely, thanks to the simplicity with which many editor features can be used.

As part of the overall schema that powers Tiptap, "input rules" can be defined by developers for each extension, which, in short, are "Markdown-style" editing:



Power users will not only be able to use Markdown-style syntax to produce content - which is enabled for a significant amount of editor functionality - but they will also be able to see the formatting change in real-time.

What you see is really what you get​

In fact, all core editor functions have a visual representation of their content, whereas they might not have previously. We are putting an end to seeing raw BB code syntax in the editor (unless you type it yourself, which still works):



This level of visual clarity for what your final content will look like extends even to code blocks, which are now fully syntax highlighted in the editor. The syntax highlighting is provided by highlight.js. As a result, we have upgraded our BB code syntax highlighting for code blocks to also use highlight.js going forward. We are including more languages (and more relevant languages) by default, and it remains easy to add additional ones to fit your particular niche.



It truly is a "what you see is what you get" experience, and to underline that even more, wait until you see what happens when you paste an embeddable link (best viewed full screen):



A consistent UI powered by XenForo​

As we mentioned earlier, Tiptap is a completely headless editor, meaning we have built the entirety of the UI that you can see. This is now more consistent and more in line with the default XenForo styling than ever. With our previous editors, there was always a hybrid of different UI pieces: some from the editor itself, others that we bolted on. For example, in our current editor implementation there are three distinct UI components we use - Froala pop-ups (insert link), overlays (insert media) and menus (emoji). With the new editor, everything you see is crafted from default XenForo functionality and styling, ensuring consistency:
CleanShot 2024-12-17 at 16.36.31.gif


By the way, the "Insert image" menu of the editor now supports multiple file uploads, including when dragging and dropping!

An exciting experimental editing experience​

While the new UI for the new editor will be very familiar to most, because we now have full control over what the editor can do, we are also experimenting with more innovative methods for writing content. Let's have a sneak peek now at what that might look like (best viewed full screen):



We haven't yet fully decided what form this new editing experience will take. It might be something that is user-selectable, admin-selectable or something that can be enabled as a hybrid with the toolbar. Your thoughts on this approach are welcome!

Extending the editor​

All of this additional functionality is possible, not only with the strong foundations provided by both ProseMirror and Tiptap, but also through an extremely flexible and well thought out system enabling us to build our own functionality. By virtue of that, add-on developers are going to have a great experience bringing new features to our new editor.

For those of you less focused on development, this might not be quite as interesting. But let's just take a look at an example extension that adds some functionality to the editor:



While this is not (currently) shipping as a built-in feature (we haven't even created an associated BB code to render it in posts), we wanted to share it as an example of how easy and intuitive Tiptap is. Here's the sample Tiptap extension code we wrote that powers the functionality seen in the previous video:

JavaScript:
XF.EditorExtensions.registerExtension(({ Node, InputRule }) =>
{
    const inputRegex = /^!!!(highlight|important|success|warning|error)[\s\n]$/

    return Node.create({
        name: 'blockMessage',

        group: 'block',

        content: 'block+',

        defining: true,

        addAttributes()
        {
            return {
                style: {
                    default: 'highlight',
                    parseHTML: element => element.getAttribute('data-style'),
                    renderHTML: attributes =>
                    {
                        return {
                            'data-style': attributes.style,
                        }
                    },
                }
            }
        },

        parseHTML()
        {
            return [
                {
                    tag: 'div[data-type="block-message"]',
                },
            ]
        },

        renderHTML({ node })
        {
            return [
                'div',
                {
                    'data-style': node.attrs.style ?? 'highlight',
                    'class': 'blockMessage blockMessage--iconic blockMessage--' + (node.attrs.style ?? 'highlight'),
                },
                [
                    'div',
                    {},
                    0,
                ],
            ]
        },

        addInputRules()
        {
            return [
                new InputRule({
                    find: inputRegex,
                    handler: ({ state, range, match }) =>
                    {
                        const { from, to } = range
                        const tr = state.tr

                        const node = this.type.createAndFill({
                            style: match[1]?.trim(),
                        })
                        tr.replaceRangeWith(from, to, node)
                    },
                }),
            ]
        },
    })
})

A full breakdown of exactly how this works is beyond the scope of this post, but feel free to spend some time understanding it and the editor docs. If you have existing editor-based add-ons, the great news is that as long as you have some basic understanding of JavaScript, you should be able to produce your own extensions. We are not implementing any additional frameworks; everything is based on vanilla JavaScript.

One more thing...​

The astute amongst you might have already noticed that new lines work differently in the new editor compared to the current one, and there's a very good reason for that. We are pleased to announce that, finally, we are going to be using paragraph (<p>) tags properly starting with XenForo 2.4.

Hitting enter/return in the new editor now creates a new paragraph (with appropriate spacing). This may take a few moments to get used to, as hitting enter/return will now produce new line spacing equivalent to pressing enter/return twice currently. You can insert a "hard break" (producing a <br /> tag) with Shift + Enter. While this might require a brief adjustment, it is now consistent with how many applications and office suite tools work, so we don't expect it to take long.

The correct use of paragraphs doesn't stop with the editor, as we now correctly render content with paragraphs too!

HTML:
<h2 class="bbHeading">A brand new editor experience!</h2>
<div class="bbImageWrapper " title="Happy Season 9 GIF by The Office">
    <img src="https://media3.giphy.com/media/o75ajIFH0QnQC3nCeD/200.gif" class="bbImage">
</div>
<p>You might <b>recognise</b> the concept from applications such as <a href="https://notion.so" target="_blank">Notion</a>. You can add nodes from anywhere!</p>

<p>You can duplicate nodes. And move them around!</p>

<blockquote>
    <p>I've never had so much fun in an editor!</p>
</blockquote>

We haven't even changed the underlying BB code syntax. This is achieved with a brand new BB code parser which intelligently detects the correct boundaries for paragraphs and is able to distinguish between line breaks and paragraphs.

More coming soon!​

Thank you for joining us on this first look into the new editor we're implementing in XenForo 2.4. We're excited to get this in your hands in 2025. In the meantime we have some additional things for the editor that we're still wiring up:
  • Improvements to the developer experience for implementing custom editor functionality, BB code and custom buttons
  • Making use of the new editor elsewhere in XenForo
  • Further improvements to the UI and UX
  • Finalising the introduction of the experimental experience as an option
This will be the final Have you seen...? thread for 2024 and we will be back in the new year with even more to show you as we approach the final stages of this release.
 
Not in Tiptap
2 * 3 * 5 = 30, with spaces, is a problem though. At least on the test site that's been linked to here.

If possible, providing access to a list of input rules in TipTap to trigger enabling/disabling would be ideal, though I imagine it isn't made easy to disable the built-in input rules when compared to turning an extension on/off.
 
The real question is, will the whiteboard/drawing be in 2.4 or will we have to manage to add it ourselves?

I'd love for a "node" to be a whiteboard. (I have no use for math/LaTeX, but drawing contests might be fun).

This could also solve all these grievances of math/LaTeX as you could just draw out the equations, especially if the users have a mobile device/pen.

1734660339961.webp


(Pardon my crap drawing, I'm new to using a mouse)
 
What I'm guessing is happening here is that the dev team hard-coded Markdown parsing into the editor, so to actually have an option to disable the parsing would now require having to rewrite a bunch of code.

As to where I stand, I agree with the users here. I don't like Markdown at all as it constantly gets in the way, so it's disabled on my site. I understand BBCode technically is more clunky, but it is a lot more precise. It never comes into the picture until you explicitly call it.

I've used Markdown on Reddit for a while and I heavily disliked it the entire time and still do. I'd constantly have to use "\" to force the editor to behave at times.

Some other notes I have, though the forced Markdown is definitely the biggest complaint I have:

1. Not a fan of the automatic <p> tags. Invision does this and it can get annoying at times. All word processors I use always do a standard line break on Enter. Never a full paragraph. Again, see above about precision over automatic efficiency. Some examples include:

Code:
1. Listing 1
2. Listing 2
3. Listing 3
...

Code:
> Separate line of text.
> Another line of text.
> Yet another line of text.
...

I think this should be a very easy fix though. Just switch the functionality to do paragraphs instead of line breaks on a Shift+Enter or just a toggle for it in the user options.

2. How quotes are handled needs to be looked into. In the past on 2.1.x and below, quotes added using the toolbar button would simply add the the plain-text BBCode tags and nothing more. While, again, slightly clunky, it was at least always clear where the quote boundaries were and you could add an author to the quote easily without needing to switch to the plain text editor. With automatically parsed quotes though, all that becomes harder and adding a quote author becomes impossible without switching to the plain text editor. I think though I'd be happy just getting an option to add a quote author in WYSIWYG mode.

-

With all that said, I'm sure the developers have been under a lot of stress trying to get this new editor out, and I'm also sure the last thing they wanted to hear was that some of that work was not something users here wanted. I get it. But as @alfaNova said, our expectations from XenForo are always high. If we didn't care, we wouldn't say anything. <3
 
Last edited:
No one uses pages…?
We use them quite a bit, but not extensively.

All word processors I use always do a standard line break on Enter. Never a full paragraph.
I don't know which word processors you are refering to, but at least
  • Microsoft Word 2019
  • Wordpad
  • LibreOffice Writer 24.8.4.2
on my Windows 10 system create a new paragraph on Enter and a line break on Shift-Enter.

Just switch the functionality to do paragraphs instead of line breaks on a Shift+Enter
I'd be totally against this as it would be the exact opposite of common word processor behaviour (as outlined above)
Using Sthift-Enter to create line breaks is common, so if XenForo introduces the possibility to use either paragraphs or line breaks in the editor (until now only line breaks are possible) it IMHO should be Enter for paragraph and Shift-Enter for line break and not the other way round.

That being said, I do share your concerns about paragraphs and always-on markdown support.

Our users are usually somewhat older and don't adapt to changes that well, especially such kinda breaking changes in editor behaviour.
For this reason we've currenlty disabled markdown support on pretty much all our forums as we got significant complaints from our users about the editor doing weird things when markdown support was enabled.

I might be wrong (and I'd be happy if this was the case), but I expect we will, again, get similar complaints if markdown is always enabled.

While it might be true that it is easy to fix things that go wrong due to automatic markdown processing, IMHO this just should not be necessary - users should not be required to write their content in a specific way to please the editor - the editor should process their input as they intend to.

XenForo 2.1-2.3 already has a setting wether or not to support markdown, please keep this with 2.4 so we can just leave markdown support disabled.
 
Last edited:
Our users are usually somewhat older and don't adapt to changes that well, especially such kinda breaking changes in editor behaviour.
For this reason we've currenlty disabled markdown support on pretty much all our forums as we got significant complaints from our users about the editor doing weird things when markdown support was enabled.
I think this is general user behaviour; sometimes, adapting to changes can be difficult. It doesn't matter if they are young or old but generally, people want to write quickly without any difficulties. If they experience any problem I am sure they will stop contributing threads without saying anything. So, the new editor should be super easy for users.
 
I don't know which word processors you are refering to, but at least
  • Microsoft Word 2019
  • Wordpad
  • LibreOffice Writer 24.8.4.2
on my Windows 10 system create a new paragraph on Enter and a line break on Shift-Enter.

Suddenly, I remember now what you're referring to. Yeah, you're correct. Sorry, I'm used to the old-school word processors in the 2000s where it would not add a space between paragraphs of the same style, and I always set my own modern word processors to do such as well first thing. I've since forgotten about the now-default behavior.

I'd be totally against this as it would be the exact opposite of common word processor behaviour (as outlined above)

No no, I mean add a quick option to switch them around somewhere in the settings.

I won't pretend like it's not convenient sometimes to have it make a new paragraph on a single Enter press, but I personally don't find it convenient as it gets in the way of my typing muscle memory and sometimes I do use single line breaks regardless.

We use them quite a bit, but not extensively.

I think I already argued about this in a past thread, but I will contribute the same unpopular opinion I did in the past and say that I don't see what the practical use of pages is. It can make content look prettier, more like a book/magazine, but that's about it, and it also makes Ctrl+F word searches more clunky.
 
A few real life examples from one of our forums where Always-On markdown seemingly (tested with tiptap.dev) causes issues:

Code:
# 77 <---- schöne Grüße von Klaus! 

# Und ja ich arbeite und ziehe deswegen meinen katzen nur selten Babyklamotten an und gebe ihnen das Fläschchen #

# Das Altern und selbstständige Handeln der anderen Sims lässt sich ausstellen

# Diese Einstellungen betreffen jedoch auch die Sims der gespielten Familie

# Fazit

# Sabi

# 1kg Fleisch
# 10g easyBARF
# 5g Calciumcarbonat
# 2g Taurin
# KEIN Salz
# Fett je nach Fettgehalt des Fleisches

# 194: Die letzten hundert Meter der Straße nach Hause laufen, weil man sieht das sein Schatz schon zu Hause ist.
# 195: In 7 Wochen ENDLICH im 3. Lehrjahr zu sein =)
# 196: Auf dem Kalenderblatt einen weiteren Tag durchstreichen, nmoch 170 Tage bis zum Ärztekonzert

# Zu 90-95% aus Fleischanteilen bestehen
# Keine oder nur sinnvolle Nebenerzeugnisse enthalten, die genau deklariert sind (z.B. 5% Leber)
# Ein Calzium-Phosphor Verhältnis von ca. 1,15:1 aufweisen
# Alle notwenigen Vitamine und Mineralstoffe enthalten
# 5-10% Ballasstoffe in Form von Gemüse oder Getreide enthalten
# Keine unsinnigen Füllstoffe wie Zellulose enthalten
# Keine schädlichen oder giftigen Stoffe enthalten (BHT, Knoblauch)
# Keine umstrittenen Stoffe enthalten (Methionin, Vitamin C)
# Keine bekanntermaßen allergieauslösenden Stoffe enthalten (Weizen, Soja)
# Möglichst schonend hergestellt worden sein
# Das Fleisch sollte von Tieren aus artgerechter Haltung stammen
# Die Tagesdosis für eine 4-Kilo-Durchschnittskatze sollte unter 1 € kosten (inkl Versandkosten)
# Um Abwechslung ins Katzenfutter zu bekommen, in verschiedenen Sorten angeboten werden.
# In verschiedenen Dosengrößen erhältlich sein (200gr und 400gr)

# Taschenbuch: 349 Seiten
# Verlag: Dtv (1999)
# ISBN-10: 3423202696
# ISBN-13: 978-3423202695

Especially recipes seem to use # some text a lot, we certainly wouldn't want every ingredient to become a heading.
Book reviews also seem to include # ISBN pretty often.

I played a bit with tiptap.dev and yeah, automatic formatting (like heading due to #) can be removed easily.
But really, having to remove an automatically added heading just because I want to type # something is inconvenient - IMHO we really shouldn't make it more difficult for users to use the editor.
 
You can insert a "hard break" (producing a <br /> tag) with Shift + Enter.
While this might require a brief adjustment, it is now consistent with how many applications and office suite tools work, so we don't expect it to take long.
The vast majority of our users use mobile devices by now.

How can I create a "hard break" / new line on a mobile device with TipTap?
I've tried this on tiptap.dev but didn't get it working so far.

Until now users could easily create a "hard break" / new line by just pressing enter on their mobile device virtual keyboard.

If this does get significantly more complicated now this IMHO will become a real showstopper.
 
Last edited:
Until now users could easily create a "hard break" / new line by just pressing enter on ther mobile virtual keyboard.

If this does get significantly more complicated now this IMHO will become a real showstopper.
What are your use cases that you need just a single break?
 
What are your use cases that you need just a single break?
There are countless scenarios, here are just a few I know from our forums
  • Ingredients in a recipe where you do not want every single one to be a paragraph on its own or use a list
  • Names of (photo) contest winners where you do not want every single one to be a paragraph on its own or use a list
  • Text with images in one paragraph
  • Poems
  • Song lyrics
But even if there is no real "usecase":
If users want to insert a newline (for whatever reason, it's not really our job to judge that, isn't it?) they IMHO should be able to do so easily - as it was since XenForo 1.0.

XenForo (with the exception of articles to some extend) is not like WordPress or some kind of CMS for editorial content where all the bells and whistles are more than appropriate and appreciated, it's for user generated content that should be as easy as possible to submit (in many cases even a plain textarea with no formatting options at all might be fully sufficient (and thus easier to use) as already pointed out rightfully by @digitalpoint).

A new editor should make life easier for everyone, not complicate tasks.
 
Last edited:
YES! A WYSIWYG editor on the admin end for pages and help pages would be AWESOME! My HTML is very rusty. Lol

Wait, what? What are we talking about now? lol I thought it was a suggestion for pagination of individual forum posts.

The vast majority of our users use mobile devices by now.

How can I create a "hard break" / new line on a mobile device with TipTap?
I've tried this on tiptap.dev but didn't get it working so far.

Until now users could easily create a "hard break" / new line by just pressing enter on their mobile device virtual keyboard.

If this does get significantly more complicated now this IMHO will become a real showstopper.

Did you try pressing the uppercase (^) button and then enter?
 
Back
Top Bottom