revert 0ffcafdf3f35f7d9ac27b6b4f65d3b283ef03a49
All checks were successful
Neutral/pipeline/head This commit looks good

revert Version 1.1.0 - Ajout de la compatibilité des images
This commit is contained in:
Raphael 2024-12-29 14:53:37 +00:00
parent ee556d859e
commit 52e1348613
3 changed files with 42 additions and 64 deletions

View File

@ -164,14 +164,7 @@ module.exports.getFile = function(root) {
try { try {
// Check if the file is an image and if it is return the base64
if(mime.lookup(root).includes("image")) {
return "data:" + mime.lookup(root) + ";base64," + fs.readFileSync(root, "base64")
} else {
return fs.readFileSync(root, "utf-8") return fs.readFileSync(root, "utf-8")
}
} catch(err) { } catch(err) {
console.log(err) console.log(err)
return "NOT_PERMITTED" return "NOT_PERMITTED"

View File

@ -1,6 +1,6 @@
{ {
"name": "neutral", "name": "neutral",
"version": "1.1.0", "version": "1.0.3",
"description": "Panel d'administration de Raphix", "description": "Panel d'administration de Raphix",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -590,7 +590,6 @@ explorer.createWindow(() => {
}) })
} else { } else {
// Make Download using result // Make Download using result
const element = document.createElement('a'); const element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(result)); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(result));
element.setAttribute('download', file.name); element.setAttribute('download', file.name);
@ -598,6 +597,7 @@ explorer.createWindow(() => {
document.body.appendChild(element); document.body.appendChild(element);
element.click(); element.click();
document.body.removeChild(element); document.body.removeChild(element);
} }
}) })
}) })
@ -614,15 +614,7 @@ explorer.createWindow(() => {
function editFile() { function editFile() {
const reqFiles = post("FX_GETFILE", file.fileDirectory) const reqFiles = post("FX_GETFILE", file.fileDirectory)
//Create a popup for the loading
View.createPopup({
title: `<i class='fa-solid fa-file-pen'></i> Editeur`,
content: `<p><i class='fa-solid fa-rotate fa-spin'></i> Chargement en cours ...</p>`
})
reqFiles.then((result) => { reqFiles.then((result) => {
View.destroyPopup(`<i class='fa-solid fa-file-pen'></i> Editeur}`)
if(result == "NOT_PERMITTED") { if(result == "NOT_PERMITTED") {
View.createPopup({ View.createPopup({
title: `<i class='fa fa-warning'></i> Erreur`, title: `<i class='fa fa-warning'></i> Erreur`,
@ -632,18 +624,9 @@ explorer.createWindow(() => {
const editor = new ViewWindow({ const editor = new ViewWindow({
title: `<i class="fa-solid fa-file-pen"></i> Editeur - ${file.fileDirectory}`, title: `<i class="fa-solid fa-file-pen"></i> Editeur - ${file.fileDirectory}`,
width: "1000px", width: "1000px",
height: "650px" height: "600px"
}) })
if(file.type == "image/png" | file.type == "image/jpeg") {
editor.setContent(`
<div style='width: 100%; text-align: center;'>
<img style='width: 500px;' src='${result}'/>
</div>`)
} else {
editor.setContent(` editor.setContent(`
<div class='fx-bar'> <div class='fx-bar'>
@ -651,8 +634,10 @@ explorer.createWindow(() => {
</div> </div>
<textarea id='${editor.getViewTitle()}_editorContent' class='fx-editor-content'>${result}</textarea> <textarea id='${editor.getViewTitle()}_editorContent' class='fx-editor-content'>${result}</textarea>
`) `)
const editorSave = getID(editor.getViewTitle() + "_save") const editorSave = getID(editor.getViewTitle() + "_save")
const editorContent = getID(editor.getViewTitle() + "_editorContent") const editorContent = getID(editor.getViewTitle() + "_editorContent")
@ -688,7 +673,7 @@ explorer.createWindow(() => {
editorContent.style.resize = "none" editorContent.style.resize = "none"
}
} }