-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
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.
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. |
looks 🍰 to me |
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.
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. |
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.
…w do this automatically.
This defaults to text/html.
This allows the math plugin to handle pastes, even when the copy plugin is doing it.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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
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. |
Special copy/paste handler for math.
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.