I'm copying rich text from a
with
and pasting it to a <a href="https://medium.com" rel="noreferrer">Medium</a> draft. Most of the formatting is preserved fine, but for some reason I don't understand all relative links are converted to absolute ones. I don't know on what step this happens. I even thought Medium could be listening to "paste" events. This would be the worst case scenario, because I'd have very little control over it. But if so, how do they have access to the URL of the page I was when I copied the content? Indeed, after checking with other browsers, I concluded it's Chrome's fault, and not Medium's. On Safari it works perfectly, on Firefox it doesn't work at all (but that's a topic for another question…).
To make things more clear, I'm trying to mimic the behavior of the <a href="https://wordpress.org/plugins/footnotes/" rel="noreferrer">footnotes plugin</a> I use on my Wordpress blog by writing a bookmarklet that does essentially the same.
Here's a demo page where you can paste text with a wiki-like syntax for inline references and parse them into proper footnotes:
<a href="https://rawgit.com/arielpontes/footnoter/master/index.html" rel="noreferrer">https://rawgit.com/arielpontes/footnoter/master/index.html</a>
In both modes of usage ([1] copy/pasting to the demo page or [2] using the bookmarklet), the resulting html has proper relative links. However, after pasting back to Medium on Chrome, they become absolute, pointing to
and breaking the functionality.
If I run the code from my local machine instead of
, however, the links are kept in relative form after paste even on Chrome.
What could possibly be going on? Is there any way to fix it?
Code:
div
Code:
contenteditable="true"
To make things more clear, I'm trying to mimic the behavior of the <a href="https://wordpress.org/plugins/footnotes/" rel="noreferrer">footnotes plugin</a> I use on my Wordpress blog by writing a bookmarklet that does essentially the same.
Here's a demo page where you can paste text with a wiki-like syntax for inline references and parse them into proper footnotes:
<a href="https://rawgit.com/arielpontes/footnoter/master/index.html" rel="noreferrer">https://rawgit.com/arielpontes/footnoter/master/index.html</a>
In both modes of usage ([1] copy/pasting to the demo page or [2] using the bookmarklet), the resulting html has proper relative links. However, after pasting back to Medium on Chrome, they become absolute, pointing to
Code:
rawgit.com
If I run the code from my local machine instead of
Code:
rawgit.com
What could possibly be going on? Is there any way to fix it?