dae/ankiqt — pull request #7 by aaronharsh (2012-01-30 05:21:36+00:00)
Title: Cloze UI bugfixes

Hi Damien,

I had some free time this afternoon and took a look at the cloze bug. Here are a couple commits that I believe fix the bugs you mailed me about.

The first commit ("extractContents" -> "cloneContents") takes care of the undo and selection problems. The second one gets rid of the space-chopping issue. I think the code I removed in the third commit was made irrelevant by the first commit.

There's still a minor undo bug in the wrap() function -- the "setFormat('removeFormat')" call at the beginning of wrap() takes up a slot in the undo history, If you undo two after Clozing the first undo will undo the cloze, and the second undo undoes the removeFormat (which won't have any visible effect unless the closed text had something other than the default format).

I'm not sure how to keep that from happening. The removeFormat call looks like it's necessary to keep Webkit from inserting a spurious " " at the beginning of formatted text during the inserthtml call, and without it I'm not sure how to keep the from being inserted.

In any case, let me know if you have any problems with the code, or if there's anything you'd like me to clean up. Stuff like this is great for me -- I'm glad to tackle it when I've got a couple hours free.

Thanks again for all the work you put into Anki.