trix icon indicating copy to clipboard operation
trix copied to clipboard

Wrap text with <p> instead of <div>

Open buzdyk opened this issue 11 years ago • 12 comments

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!

buzdyk avatar Nov 27 '15 22:11 buzdyk

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

javan avatar Nov 28 '15 00:11 javan

@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:

pranjaltech avatar Dec 18 '15 20:12 pranjaltech

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

ghost avatar Jan 19 '16 08:01 ghost

+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.

mb21 avatar Jan 28 '16 13:01 mb21

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

gscottolson avatar Feb 02 '16 18:02 gscottolson

@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 :(

lukerollans avatar Apr 12 '16 12:04 lukerollans

@javan what about #187 ?

lukerollans avatar Apr 12 '16 12:04 lukerollans

Is there a sensible workaround for this yet?

ghost avatar Jan 30 '19 14:01 ghost

Is there a sensible workaround for this yet?

+1

trheyi avatar Feb 05 '19 14:02 trheyi

@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 avatar Feb 13 '19 16:02 oskarolsson-jimdo

@oskarolsson-jimdo That doesn’t 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.

ghost avatar Feb 13 '19 17:02 ghost

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])

aet08 avatar Jul 24 '19 19:07 aet08