OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 334 forks source link

ctrl+b, ctrl+i, ctrl+u should add markdown syntax #319

Open jozydapozy opened 10 years ago

jozydapozy commented 10 years ago

Now, when selecting some text and pressing for example ctrl+b will make that text bold in the editable text area, which is confusing.

This: Select some text: hello --> press ctrl+b --> **hello** would make more sense, I think.

OscarGodson commented 10 years ago

Oh, huh. That's not our code that makes it bold. Must be a browser thing. Never thought to even try that combo since I didn't write anything for it. What browser makes it bold?

And, yes, that's the plan with markdown (and make it work for any parser). There's tickets for that, leaving this open for the weird bolding of text thing.

jozydapozy commented 10 years ago

It seems like it's the default behavior of a contenteditable field in (at least) Chrome and IE. Also applies to ctrl+u (underline) and ctrl+i (italics).

arsensokolov commented 10 years ago

It is very necessary when a large amount of text editing.

zethussuen commented 10 years ago

http://www.w3.org/TR/2008/WD-html5-20080610/editing.html#execCommand

Seems like an overwritable method via contenteditable's commands API

dadambickford commented 10 years ago

Would definitely need some work but I was playing around with this a little bit in jsbin

http://jsbin.com/hetoqule/1/edit?js,output

OscarGodson commented 10 years ago

@dadambickford I think they're talking about a behavior only on Windows (im guessing since I can't repro on OS X at all) that when you select text in a contenteditable and press ctrl+b it literally makes the text bold by wrapping it in bold tags. However, we want to block that behavior and instead allow a way to set what bold/italic/etc means and have it do what you're doing in your example.

Your example is awesome and it's something we've been planning on doing a long time. Could you put that in the wiki or something under "how to make WYSIWYG markdown buttons? And, if you have more time you could create a plugin to add markdown buttons! There's a bunch of tickets requesting this and @brennannovak recently pinged me on twitter asking how to do this.

dadambickford commented 10 years ago

@OscarGodson right so I think that would just be like how we disabled the ctrl+s behavior with .preventDefault()?, and then hooking up the example to ctrl+b or a button like I was playing with. What would I need to make it into a compatible plugin?

weaming commented 9 years ago

I wish this feature