Make copy-paste always do the right thing
Make copy-paste always do the right thing

Summary:
In D19447 we added copy-paste functionality to Perseus. However, I avoided the
issue of widget name conflicts by more or less ignoring the paste if it caused
a conflict.

{F161196 size=full}

In this diff, I add to the copy-paste functionality by renumbering pasted
widgets so that they never have a conflict. Basically, I find the highest
numbered widgets of the types we're about to paste in and make sure all the
widgets to be pasted are numbered higher.

For example, if I have a section with a single widget called "Image 2", and I'm
about to paste in an image widget and a dropdown widget, before the paste goes
through we'll renumber the widgets to be "Image 3" and "Dropdown 1".

{F161198 size=full}

This also means that we can now duplicate widgets by copy-pasting.

{F161200 size=full}

You can see from the gifs above that the numbering of pasted widgets in the
titles of the widget editor is weird. This doesn't affect editing the widgets
and goes away on a refresh, so I left it as a TODO.

Test Plan:
Go to a [Perseus link](http://localhost:9000/article.html#content=%5B%7B%22content%22%3A%22Hi%20I%27m%20a%20particle%21%5Cn%5Cn%5B%5B%E2%98%83%20image%201%5D%5D%5Cn%5Cn%5B%5B%E2%98%83%20dropdown%201%5D%5D%5Cn%22%2C%22images%22%3A%7B%7D%2C%22widgets%22%3A%7B%22image%201%22%3A%7B%22type%22%3A%22image%22%2C%22alignment%22%3A%22block%22%2C%22graded%22%3Atrue%2C%22options%22%3A%7B%22title%22%3A%22%22%2C%22range%22%3A%5B%5B0%2C10%5D%2C%5B0%2C10%5D%5D%2C%22box%22%3A%5B960%2C646%5D%2C%22backgroundImage%22%3A%7B%22url%22%3A%22http%3A%2F%2Fi.imgur.com%2FHUK6LyH.jpg%22%2C%22width%22%3A960%2C%22height%22%3A646%7D%2C%22labels%22%3A%5B%5D%2C%22alt%22%3A%22%22%2C%22caption%22%3A%22%22%7D%2C%22version%22%3A%7B%22major%22%3A0%2C%22minor%22%3A0%7D%7D%2C%22dropdown%201%22%3A%7B%22type%22%3A%22dropdown%22%2C%22alignment%22%3A%22default%22%2C%22graded%22%3Atrue%2C%22options%22%3A%7B%22placeholder%22%3A%22%22%2C%22choices%22%3A%5B%7B%22content%22%3A%22Hello%22%2C%22correct%22%3Atrue%7D%2C%7B%22content%22%3A%22World%22%2C%22correct%22%3Afalse%7D%5D%7D%2C%22version%22%3A%7B%22major%22%3A0%2C%22minor%22%3A0%7D%7D%7D%7D%5D) and verify that:
- Copy and paste from one section to a blank section works
- Copy and paste from one section to another section with nonconflicting widgets works
- Copy and paste from one section to a section with conflicting widgets works
- Copying widgets, then copying text from somewhere else and pasting it in Perseus works
- Copy and paste to duplicate widgets works

Reviewers: aria, alex

Reviewed By: aria, alex

Subscribers: aria, kevindangoor

Differential Revision: https://phabricator.khanacademy.org/D19804

learningequality/perseus,alexristich/perseus,iamchenxin/perseus,iamchenxin/perseus,ariabuckles/perseus,ariabuckles/perseus,sachgits/perseus,sachgits/perseus,learningequality/perseus,ariabuckles/perseus,ariabuckles/perseus,alexristich/perseus