Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special copy/paste handler for math. #84

Merged
merged 17 commits into from
Oct 18, 2013
Merged

Conversation

izak
Copy link

@izak izak commented Oct 11, 2013

If there is math in the content we're copying, use a different custom
content-type. When pasting, if the incoming data is our custom content,
insert it directly and avoid the browser sanitising it.

If there is math in the content we're copying, use a different custom
content-type. When pasting, if the incoming data is our custom content,
insert it directly and avoid the browser sanitising it.
@kathi-fletcher
Copy link
Member

lots of 🍰 from testing.

This is incredibly sweet. And apparently this also fixes a bug where ctl-v caused the content to shift and the cursor to move making it hard to see where the paste went.

As noted by Izak, it is hard to select math that is on its own line. I am going to make a separate pivotal for that and it can be its own PR.

@TomWoodward
Copy link
Member

looks 🍰 to me

izak added 2 commits October 14, 2013 14:29
This hooks into the Copy plugin, allowing math to be copied on its own.
This means that copying something to the system clipboard also
duplicates it to our internal buffer. The math plugin might not be
the best place to put this, but it certainly needs it the most.
@izak
Copy link
Author

izak commented Oct 14, 2013

You can copy a bit of math on its own now. I added a "Copy Math" option to the mathjax context menu.

I did pick up one small problem. After pasting, the math no longer have a context menu. Need to fix that.

izak and others added 12 commits October 15, 2013 14:55
Also, use range machinery to insert pasted content. This is necessary because
InsertHtml breaks if any inserted content has no style property (math elements
doesn't), and insertIntoDOM pastes the content AFTER the selected paragraph,
when pasting content on a new line. This does the right thing by pasting it
inside the paragraph, or any other place your cursor might be.
- Bootstrappy style with span (or a).
- First dropdown text should now appear directly on top of the label
text.
- Made a few adjustments in the coffee files to fix bugs or to make
things consistent
Dunno why arrow character is really small in my machine/OS/browser. This
still looks small on my machine, but is "good enough", and looks much
better on Tom's and probably Kathi's.
Decided to still let it wrap if close to the edge. That popover still
needs attention re: the icons, but it's better for now. The change to
the .coffee file was made to prevent extra spacing from getting
underlined, but I couldn't figure out a way to comment that section of
the file, so noting it here.
- "Advanced options for this [element]" instead of "advanced options."
- "Copy [element]" instead of "Copy element"
I also removed some periods because they bugged me, but if somebody
really wants them, I won't fight it.
This allows the math plugin to handle pastes, even when the copy
plugin is doing it.
@izak
Copy link
Author

izak commented Oct 16, 2013

It occured to me that the copy/paste implemented by the copy plugin suffer from the same problems: It cannot reinitialise the math in any pasted section. I changed things a bit so that the copy plugin will use the same event handling to delegate copy/paste to the math plugin. This is now really neatly integrated I think.

# Jquery >= 1.8
$el = $el.nextUntil(selector).addBack()
else
# Jquery < 1.8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code exist somewhere else (maybe in another PR)? I thought I remember @tmsp1 mentioning jQuery < 1.8 was not possible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a ticket out of this so I can merge this. #96

@kathi-fletcher
Copy link
Member

I am now getting some bugs on this code -- see comments on https://www.pivotaltracker.com/story/show/58717134

Conflicts:
	src/plugins/oer/assorted/css/image.css
@kathi-fletcher
Copy link
Member

OK -- I am back to lots of 🍰 for this from testing. I could not replicate the weird bugs I ran into. I made a new branch and tested with master + copy-paste-math-v2.

kathi-fletcher added a commit that referenced this pull request Oct 18, 2013
Special copy/paste handler for math.
@kathi-fletcher kathi-fletcher merged commit 0903492 into master Oct 18, 2013
@kathi-fletcher kathi-fletcher deleted the copy-paste-math-v2 branch October 18, 2013 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants