Trix: Wrap text with <p> instead of <div>

Created on 27 Nov 2015  路  12Comments  路  Source: basecamp/trix

Hi.

Currently the text:

Sentence 1.
Sentence 2.

is transformed to the following markup:

<div><!--block-->Sentence 1.<br>Sentence 2.</div>

Is there any way to affect Trix behaviour and have

<p><!--block-->Sentence 1.</p><p>Sentence 2.</p>

instead?

Thanks in advance!

Most helpful comment

@oskarolsson-jimdo That doesn鈥檛 work unfortunately, as carriage return still creates a br instead of a new paragraph. Return should create a new paragraph and shift-return should create a line break, just like in most word processors.

All 12 comments

That's currently not possible. I started working on a branch a while back, but haven't seen it through.

@javan Will this be implemented soon? Need it before I can use it in production.
This is the best open source editor out there :fireworks:, and I want to introduce it into our stack asap :grin:

I would also need this before I can migrate to Trix from my current editor; any plan to merge this soon?

+1
I don't want my users to be able to insert multiple blank lines (and multiple subsequent spaces while we're at it). Yes, I could strip that server-side, but then the users are surprised that the text doesn't look like they wrote it.

I had success editing the input_controller and changing line 290 to @responder?.insertBlockBreak(). I haven鈥檛 run any tests (I鈥檓 sure this would break quite a few).

@javan hoping that branch can be seen through sometime soon.. currently a production blocker for us.. would rather style <p>..</p> tags properly that the containing <div>

If I had any time for open source at the moment, I would contribute :(

@javan what about #187 ?

Is there a sensible workaround for this yet?

Is there a sensible workaround for this yet?

+1

@thelucid @trheyi
You can just change it in the blockAttributes.

Trix.config.blockAttributes.default.tagName = 'p';

The other change with separating linebreaks into separate blocks requires extensive changes.

@oskarolsson-jimdo That doesn鈥檛 work unfortunately, as carriage return still creates a br instead of a new paragraph. Return should create a new paragraph and shift-return should create a line break, just like in most word processors.

I just wanted to remove the <div> tags completely, so I did something like this to remove <div> and </div> at the end of the string in my controller.

foo.update(body: params[:body][5...-6])

Was this page helpful?
0 / 5 - 0 ratings