cmprmsd / overleaf-image-helper Goto Github PK
View Code? Open in Web Editor NEWAdds functionality to paste screenshots from your clipboard to Overleaf cloud and on-premise.
License: GNU General Public License v3.0
Adds functionality to paste screenshots from your clipboard to Overleaf cloud and on-premise.
License: GNU General Public License v3.0
The @match within the script detects that I'm in an overleaf project and gets enabled, however, I can't seem to be able to use the Ctrl+V image pasting functionality.
I checked the browser console and I got the following error:
I'm not super experienced with Javascript so I don't have any ideas for fixes immediately.
I just enrolled in overleaf's beta version and it looks like it broke the script
Hi,
I just tried to paste some images to my .tex file in the online version of Overleaf.
It seems that it doesn't work anymore.
Is it just in my browser or has anyone else the same problem?
Best regards,
Fabian
Hi,
I just noticed that this Tampermonkey addon is also available on Firefox. I tested it and it seems to work fine.
Could you also mention this in the script readme?
Anyway, great work. Thanks to you I can finally make notes in Overleaf as I previously did in Google Docs.
Did not have time to have a closer look. tryed it in chrome and firefox
It seems that the uploadImage function is running into an error at the following line:
xhr.onreadystatechange = function () {
After that line is executed, the xhr.status variable becomes 422, and the function throws an error. I logged the lines before in the console:
var xhr = new XMLHttpRequest();
var domain = "https://www.overleaf.com";
var path = document.location.pathname + "/upload?folder_id=" + _ide.fileTreeManager.findEntityByPath("assets").id + "&_csrf=" + csrfToken;
var url = path;
// var url = document.location.pathname + "/upload?folder_id=" + _ide.fileTreeManager.findEntityByPath("assets").id + "&_csrf=" + csrfToken;
let formData = new FormData();
formData.append("qqfile", imageBlob, "my_image.png");
xhr.open("POST", url, true);
// xhr.setRequestHeader("Content-Type", "application/json");
console.log('imageBlob:', imageBlob);
console.log('hash:', hash);
console.log('url:', url);
console.log('formData:', formData);
formData.forEach((value, key) => {
console.log(key + ': ' + (value instanceof File ? value.name : value));
});
console.log(xhr.status)
xhr.onreadystatechange = function () {
console.log(xhr.status)
if (xhr.readyState === 4 && xhr.status === 200) {
var json = JSON.parse(xhr.responseText);
console.log(json)
console.log(json.entity_id + " Asset created :)");
}
};
And I got this output:
I thought it might be server-side, but in the error description it says the client should update the request before sending again:
Any thoughts on how to proceed with this?
Whenever I try to console.log(document.querySelector('.ace_editor'))
, it returns null
when using the new Overleaf Editor. The problem can be circumvented by selecting Source (Legacy)
just above the editor window, but this is not ideal. It appears the old Ace Editor has been replaced by CodeMirror6:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.