jejacks0n / mercury

Mercury Editor: The Rails WYSIWYG editor that allows embedding full page editing capabilities directly inline.
http://jejacks0n.github.com/mercury
Other
2.63k stars 531 forks source link

Uploading image inside table cell, wrong insertion point #53

Closed JeanMertz closed 12 years ago

JeanMertz commented 12 years ago

When I'm working inside a table cell, and I try to upload an image, I seem to get weird behavior with regards to the place of insertion.

It seems, when you first create a table with a few cells, that each cell has a whitespace in it. Not sure if this is the case, but at least it's possible to move the cursor one position to the right and/or left inside a cell, without leaving that cell, making it clear that there is some kind of character in there (nbsp maybe?).

When you move the cursor to the utmost right of the cell, and drag an image over the page, the image is actually inserted inside the next cell. If you move the cursor to the utmost left of the cell, the image is inserted correctly in the current cell.

Any thoughts on this?

jejacks0n commented 12 years ago

Yeah. You'll see this differently in the different browsers I expect. I would initially guess that it might be related to how selections (and what they select) differ. Webkit has one style, and gecko has a slightly different take. Webkit seems to select outside of some nodes.

I'd also guess you're using Webkit when you see that?

JeanMertz commented 12 years ago

I am, Safari 5.1.1 to be exact. This is very unintuitive to the end-user. I had a use-case like this where I wanted to display a few company logo's, three in each row, 4 rows long. So I figured I'd make a table and simply upload the image to each cell, but this bug made that very hard, until I figured out what was causing this.

To me (us, programmers), once we know how to work around it, it's no longer an issue. But to the people which this Editor probably mostly targets (Word users, non-technical), this makes no sense.

So, any thoughts how we could solve this problem? Perhaps check if the parent element from the cursor's position is a td tag and move the cursor to the start of the tag?

jejacks0n commented 12 years ago

Yeah, you're right. I'll see if there's anything we could try. In general this has caused issues. Like Webkit was selecting a textnode when you would double click on an image to edit its properties.

jejacks0n commented 12 years ago

I looked into this, and yes, it's because of the weird selection issues that exist in safari.. I'd bet I can find a bug report that fits this issue.

I don't see an easy fix off hand.. so I'm going to leave it as is for now. If you put the cursor before the space it works ok.. and the spaces are there so you can get your cursor into the cell without it being super painful. I wish there was a better fix, and I'll leave this open in case someone else wants to take a look at it.

JeanMertz commented 12 years ago

I'll see if I can find the time to look into this next week. I'm actually implementing Mercury in my own CMS for my local clients so while we can understand these bugs and work around them, the people I will expose this editor to often have no clue about the Internet and only understand Word. So for those users, small issues like these can be dealbreakers

JeanMertz commented 12 years ago

By the way, the most hacky solution I can think of would be to act on mouse down inside a cell and move the cursor at the start when only a space is present