return key as BR and not P
Added by Sonny E over 1 year ago
To elRET crew
first of all, very impressed with your editor! .. have been a user of the FCKeditor for many years now. But considering to switch to elRET on our projects.
Initially I have one question though.
Would is be possible to set the <return> key to display as a <br /> insetad of a <p></p> ?
Thing is most of our clients expect a simple line-break when hitting the enter/return button, and not a new paragraph.
I know that the <shift> + <return> combination does this, but is awkward for non-techie users. So if possible to set as a configuration option it would be great.
Thanks for a great Editor!
/sonny e
Replies (7)
RE: return key as BR and not P
-
Added by Dmitry Levashov over 1 year ago
Try something like this:
$(selector).elrte(options);
var editor = $(selector).elrte()[0].elrte;
editor.$doc.bind('keydown', function(e) {
e.preventDefault();
editor.selection.insertNode(self.doc.createElement('br'));
})
RE: return key as BR and not P
-
Added by Sonny E over 1 year ago
Hi Dimitri
thanks for very fast response!
where should this code you mention go ?
regards
/sonny
RE: return key as BR and not P
-
Added by Dmitry Levashov over 1 year ago
this is elrte initialization code :)
RE: return key as BR and not P - Feature Suggestion
-
Added by Will Fastie over 1 year ago
This may be a controversial suggestion. The same suggestion made at the TinyMCE forum (by someone else, not me) seemed to incur the wrath of the developer. (Note: It is possible to do this with TinyMCE but it is messy, which I think is deliberate.)
Most of the time I want well-formed HTML coming from the editor. However, from time to time I want to allow the user to do light formatting (more or less the compact toolbar option) on elements that are not paragraphs. For example, here is one line from a page at my site:
Aria - Banjos under Other Instruments
This is stored as three elements in the database - the name of the company, the link to the Web site if it exists, and a brief description (in this case "Banjos under Other Instruments"). It is the description that I want to lightly format but I do not want it to contain paragraph formatting. The reason is obvious - I am injecting the description into a paragraph that I am formatting in its entirety.
What I do now is use regular expressions to strip paragraph tags out of the content after I retrieve it from the database. But it's an extra step, one that must be taken for each field of this kind and in every place that the field might be used.
Therefore, I am proposing an option for elRTE that would return the content with line breaks rather than paragraphs and only line breaks that are explicitly entered by the user, with an added line break at the end.
RE: return key as BR and not P
-
Added by Dmitry Levashov over 1 year ago
I think, you are right, and I think on your suggestion for next version
RE: return key as BR and not P
-
Added by Will Fastie over 1 year ago
Thank you.
One correction to what I wrote above:
Therefore, I am proposing an option for elRTE that would return the content with line breaks rather than paragraphs and only line breaks that are explicitly entered by the user, without an added line break at the end.
In other words, only interior line breaks.
RE: return key as BR and not P
-
Added by The Peach 6 months ago
I just stumbled this very same issue, it would be wonderful to have the ability to select the default format as well, apart to be able to control the behaviour of the carriage return.
Thumbs up for Dmitry Levashov's solution.
(1-7/7)