"Custom blocks" that aren't... blocks?

What I'm trying to do: I want users of a RichEditor to be able to insert a tag (much like a mergeTag) that accepts parameters (like a customBlock), which is replaced at runtime with a hyperlink generated by a backend method accepting those parameters. What I did: I created a new RichContentCustomBlock subclass and implemented the required methods. When rendering content, I use
RichContentManager::make($my_content)->customBlocks(...)->render()
RichContentManager::make($my_content)->customBlocks(...)->render()
to "expand" the blocks. My issue: No mater what I return from toHtml, the blocks are always enclosed in <p> tags, which prevents the expanded hyperlinks from seamlessly embedding into my page content. Question: How can I accomplish "inline" blocks that won't insert a new paragraph into existing text? It sounds like I should be using merge tags instead, but they don't appear to accept parameters, which is required for my use-case.
2 Replies
DelosDigital
DelosDigital2mo ago
Same need here; CustomBlock is an excellent tool, but sometimes you need to insert things that are no blocks. For instance, it would be great to insert notes (like ending notes or footnotes) but the placeholder should be an inline object, probably with a little different UI. Anyway, I solved my problem creating a new tiptap plugin. Not big deal.
Dennis Koch
Dennis Koch2mo ago
I think that's the best way. Register a custom plugin for stuff that's not covered by core.

Did you find this page helpful?