Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paragraphs instead of <br> #34

Closed
phil-opp opened this issue Oct 16, 2011 · 23 comments
Closed

paragraphs instead of <br> #34

phil-opp opened this issue Oct 16, 2011 · 23 comments

Comments

@phil-opp
Copy link

Why mercury inserts a
when pressing enter? A new paragraph would be better...

@zeroedin
Copy link

IMO make this a configurable defaulting to paragraph. Another helpful idea would be shift+enter to do a line break.

@phil-opp
Copy link
Author

+1 (just like ckeditor or the default functionality on contenteditable fields)

@ghost ghost assigned jejacks0n Oct 22, 2011
@JeanMertz
Copy link

Not sure if Mercury overrides the default browser behavior, but I know that different browsers implement this their own way. I don't know which one, but there was one browser that actually inserts br tags, while others insert p tags (and Firefox takes the crown, inserting a p (or br) tag with some ugly meta-data set on it)

@phil-opp
Copy link
Author

my chrome inserts a p by default. But in mercury it inserts a br.... I would vote for zeroedins idea... ;)

@JeanMertz
Copy link

I agree that enter should result in a p tag, and shift + enter returns a br tag.

@Petah
Copy link

Petah commented Nov 10, 2011

What if I press enter in an li or a div or in nothing...

@davidhorsak
Copy link

I agree with @JeanMertz +1

@swistak
Copy link
Contributor

swistak commented May 25, 2012

I think this can be configures with @document.execCommand('insertBrOnReturn', false, false) at least on firefox.

@jejacks0n
Copy link
Owner

Yeah, but that's the problem.. not all of the browsers adhere to those "rules", so to get the behavior to be as close as possible across the board we always try and insert br tags. I'd say anyone who wants to can play around with that and let me know how it feels.

In general it's advised to use one client (browser) across the board when editing content, so I'd say give it a go and see how it turns out?

@swistak
Copy link
Contributor

swistak commented May 25, 2012

Yes. I just tested it out, and looks like Chrome and FF at least (newest versions) will respect

pageEditor.document.execCommand('insertBrOnReturn', false, false)

and will split current element (p, div, li etc.) into two when enter is pressed. ( pageEditor refers to instance of PageEditor so this code must be run after PageEditor is initialized).

Maybe it should be added as a configuration option?

@swistak
Copy link
Contributor

swistak commented May 25, 2012

There's also very similar issue with styleWithCss I was very suprised that Mercury emmits <font color=""> to change color of the text for example or <b> tags. But I've found there's no universal support for this, and It's sometimes actually simpler to use tags instead of working with styles. Only downside of current approach i see is that we get nested tags <i> inside <b> etc.

@jack-y
Copy link

jack-y commented Aug 17, 2012

...and please "< b r / >" instead of "< b r >" . Needed by html validators.

@swistak
Copy link
Contributor

swistak commented Aug 21, 2012

If editor emmits <br /> or <br> is dependant on html mode. If validator shows error on this using <!html> doctype then validator is incorrect as for html there's no need to do self closing tags, only xhtml requires that. And if it's xhtml then it's <br />(not space) not <br/>

@jejacks0n
Copy link
Owner

All, it's much appreciated that you're all keeping up with this.

I'll point you to the relevant bits of code in Mercury and you all can potentially provide some insights as to when/how it's not doing what you're looking for.

On line 37 of full.js.coffee (the full html region) you'll see we attempt to tell the client browser to always insert BR tags on return.. If your client is misbehaving on this for some reason it's a bug report for them -- or we try come up with some work around (and here's where I'd need your input).

On line 149 of the same file we do some custom handling. This code is likely the cause of the issues you're seeing?

Try to fork the project, or tweak it in line (to remove the webkit check) and see if this changes the behavior to your liking.

Thanks all, since I don't have the issue personally I'm hoping you all can work with me to try and resolve it.

@gvarela
Copy link
Collaborator

gvarela commented Jan 18, 2013

Closing since no one seems to want to contribute to this.

@gvarela gvarela closed this as completed Jan 18, 2013
@jrissler
Copy link

This is still an issue, I think most users when using a wysiwyg editor expect paragraphs, not a div with lots of breaks inserted.

@jejacks0n
Copy link
Owner

Awesome, I'll let you add that. Thanks for the input and contribution. :)

@swistak
Copy link
Contributor

swistak commented Apr 30, 2013

@jrissler Look at my comment above - it's easy enough to enable - you just need one line of code I've provided.

@jrissler
Copy link

@swistak Thanks :)

@brandnewmedia
Copy link

Can someone please point me to how/where I implement @swistak's one line fix mentioned above?

Thanks.

@swistak
Copy link
Contributor

swistak commented May 19, 2013

You can call it anywhere AFTER initializing mercury. IMO best way to do it is to modify layout for mercury and do

      <!-- Instantiate the PageEditor -->
      pageEditor = new Mercury.FormPageEditor('form.mercury-form', options);
      pageEditor.document.execCommand('insertBrOnReturn', false, false)

@brandnewmedia
Copy link

I tried:

// Instantiate the PageEditor
var editor = new Mercury.PageEditor(pageSaveUrl, {
saveStyle: 'form',
saveMethod: pageSaveMethod,
visible: true
});
editor.document.execCommand('insertBrOnReturn', false, false);

but in Chrome (v 26.0.1410.65) get:
Uncaught TypeError: Cannot call method 'execCommand' of undefined

Any tips appreciated.

@umuro
Copy link

umuro commented Oct 30, 2013

I am intending to use Mercury to edit xhtml in an epub. There I need <\p/> tag. instead of


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests