Initial Upload
Some checks failed
Create Release on Tag Push / build (push) Has been cancelled

This commit is contained in:
MassiveBox 2025-03-31 19:14:17 +02:00
parent 777f31761c
commit eaca7fc192
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
20 changed files with 469 additions and 1718 deletions

47
public/webapp/draw.js Normal file
View file

@ -0,0 +1,47 @@
const FALLBACK = "<p>Nothing here yet! Click me to open the editor.</p>"
async function getFile(path) {
const response = await fetch('/api/file/getFile', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({path: path})
});
if (!response.ok) {
console.log('Failed to fetch HTML content');
return null;
}
const blob = await response.blob();
const resTxt = await blob.text();
// if we got a 404 api response, we will return null
try {
const res = JSON.parse(resTxt);
if(res.code === 404) {
return null;
}
}catch {}
return resTxt;
}
async function getSVG(fileID) {
const resp = await getFile("/data/assets/" + fileID + '.svg');
if(resp == null) {
return FALLBACK;
}
return resp;
}
function getEditLink(fileID) {
const data = encodeURIComponent(
JSON.stringify({
id: fileID
})
)
return `siyuan://plugins/siyuan-jsdraw-pluginwhiteboard/?icon=iconDraw&title=Drawing&data=${data}`;
}