niccolox

niccolox

Does anyone have good suggestions for HTML editors which integrate nicely into Phoenix Liveview?

I am especially interested in the inline editing of forms.

Think Wordpress Gutenburg type UX

Showing Posts 1 to 10

Sebb

Sebb

maybe this Dev Community - DevDojo

Never used.

wmnnd

wmnnd

I’m currently working on adding Editor.js to Keila (see e.g. here). The concept is similar to the Gutenberg editor, although the UI is not quite as smooth yet. It is, however, very easy to work with.

If you really like Gutenberg, you might actually be able to use it in your Phoenix project. Check out the work of the Drupal Gutenberg project, g-editor, and this other standalone version which use Gutenberg without Wordpress.

romenigld

romenigld

I don’t watched but it has this conference talking about the editors in PHX LiveView:

In home I will watch.

niccolox

niccolox OP

thank you gentlemen, I’ll check out these (I’ve looked at editor.js and I love the experience, but I don’t want to parse JSON or diffs) and want to use Elixir Phoenix Live View primitives as much as possible

shamanime

shamanime

We’ve been using https://trix-editor.org with a Hook without issues so far.

romenigld

romenigld

Could you show how was the installation with hook using Trix?

shamanime

shamanime

The hook:

import Trix from "trix";

export default {
  mounted() {
    const element = document.querySelector("trix-editor");
    element.editor.element.addEventListener("trix-change", (e) => {
      this.el.dispatchEvent(new Event("change", { bubbles: true }));
    });
    element.editor.element.addEventListener("trix-initialize", () => {
      element.editor.element.focus();
      var length = element.editor.getDocument().toString().length;
      window.setTimeout(() => {
        element.editor.setSelectedRange(length, length);
      }, 1);
    });
    this.handleEvent("updateContent", (data) => {
      element.editor.loadHTML(data.content || "");
    });
  },
};

(the hook can be simplified, I use the setTimeout because in one of my forms there’s an auto-save feature that sends an event to the LV after a given period of time and if the user is typing on the editor while the auto-save event fires the cursor was being reset to the beginning of the text, this works around it)

The HTML:

      <div>
        <%= label(f, :body, gettext("Body")) %>
        <%= hidden_input(f, :body, phx_hook: "TrixEditor") %>
        <div id="richtext" phx-update="ignore">
          <trix-editor input={input_id(f, :body)} class="trix-content">
          </trix-editor>
        </div>
        <%= error_tag(f, :body) %>
      </div>
22
Post #8
romenigld

romenigld

thank you for share @shamanime.
And another question.
For the upload of the image files you do something?
You preferred to use the installation by npm or including it from an npm CDN in the <head> of your page?

shamanime

shamanime

We installed from npm and the only configuration we have is in our app.css:

@import "../node_modules/trix/dist/trix.css";

Where Next? Top

Trending in Discussions Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
jtormey
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews