bergie / hallo

Simple rich text editor (contentEditable) for jQuery UI
http://hallojs.org/
MIT License
2.43k stars 314 forks source link

Show the toolbar on clicking the element #184

Closed marcobarbosa closed 11 years ago

marcobarbosa commented 11 years ago

Simple patch, Please review it if there is a more proper way.

When I click an editable element, I expect the toolbar to appear.

It's not obvious that you have these plugin options (bold, italic, etc..) when you need to select it first.

bergie commented 11 years ago

@marcobarbosa the idea of the contextual toolbar is to only appear when it has something to do (so, when there is a selection). If you want a toolbar that is always visible when the element is focused, use the fixed toolbar.

marcobarbosa commented 11 years ago

I would assume that when you "click" an element you do have something to do.

Clicking a paragraph means I want to edit it.

Having a fixed toolbar is a good alternative but to particular designs you can't enforce that.

Thanks for the reply though.

bergie commented 11 years ago

@marcobarbosa when you click the element, Hallo activates and you can edit :-) And there should be some events and CSS classes you can utilize to make this clearer visually.

I'd like to keep the contextual toolbar working as it is (this was the original UX design of Hallo). However, toolbars in Hallo are just plugins, and so if you were to submit a third toolbar that is somewhere between fixed and contextual, I'd be happy to accept that patch.

marcobarbosa commented 11 years ago

Ok, though I disagree I'll respect your design decision :)

I'm happy to make a plugin. I've read the doc and it seems simple but I'm not sure if plugin fits here.

How would I access the events and the element of contextual.coffee in a plugin?

For example, I need access to the element to bind the click event and also the updatePosition method.

Seems like the best way would be a third toolbar instead of a plugin.

What do you think?

bergie commented 11 years ago

@marcobarbosa great! Just copy the contents of contextual.coffee to a new file, and start modifying it. You can configure Hallo to use your toolbar by passing its widget name.

marcobarbosa commented 11 years ago

Ok, here it is: https://github.com/bergie/hallo/pull/185

It's a copy and paste so I don't know :)

Ideally I would "inherit" from contextual, right? Then just change the bindEvents function.