Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions front/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ async function newFileDiv(file) {
///////////////////////////////////////////////////////////////

function openFile(file, callback) {
console.log("Opening " + file);
if (OpenedFiles.FINDQUICKINDEX("fileLink", file) === -1) {
const fileFMT = OpenedFiles.FORMAT();
fileFMT.SET("fileLink", file);
Expand All @@ -129,7 +128,6 @@ function openFile(file, callback) {

fileFMT.SET("usesCRLF", usesCRLF);

console.log(fileData);
fileFMT.SET("data", fileData);
fileFMT.SET("savedFile", fileData);
OpenedFiles.PUSH(fileFMT);
Expand Down Expand Up @@ -607,8 +605,11 @@ async function refreshEditor() {

const option = document.createElement("option");
option.value = e.fileLink;
const splittedFileLink = e.fileLink.split("\\");
option.innerHTML = `${splittedFileLink[splittedFileLink.length - 2]}\\${splittedFileLink[splittedFileLink.length - 1]}`;
const splittedFileLink = path.normalize(e.fileLink).split(path.sep);
option.innerHTML = path.join(
splittedFileLink[splittedFileLink.length - 2],
splittedFileLink[splittedFileLink.length - 1]
);
document.getElementById("windowPicker").appendChild(option);
});

Expand Down Expand Up @@ -746,7 +747,7 @@ document.addEventListener("DOMContentLoaded", () => {
});
files.forEach((element) => {
const option = document.createElement("option");
option.value = `${element.parentPath}\\${element.name}`;
option.value = path.join(element.parentPath, element.name);
option.innerHTML = element.name;

list.appendChild(option);
Expand Down Expand Up @@ -783,10 +784,10 @@ createBtn.addEventListener("click", async () => {
filedata = fs.readFileSync(args.preset, { encoding: "utf-8" });
}

fs.writeFileSync(`${args.dir}\\${args.name}`, filedata);
fs.writeFileSync(path.join(args.dir, args.name), filedata);

openFile(`${args.dir}\\${args.name}`, () => {
loadFileIntoEditor(`${args.dir}\\${args.name}`);
openFile(path.join(args.dir, args.name), () => {
loadFileIntoEditor(path.join(args.dir, args.name));
});
document.getElementById("filenameField").value = "";
dir = null;
Expand Down
10 changes: 7 additions & 3 deletions front/editor/modules/fileStringFunctions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
const path = require("path");

function getFileNameFromLink(file) {
return file.split("\\")[file.split("\\").length - 1];
const parts = path.normalize(file).split(path.sep);
return parts[parts.length - 1];
}

function getFileDirFromLink(file) {
const parts = path.normalize(file).split(path.sep);
let fileDir = "";

file.split("\\").forEach((element, index, array) => {
parts.forEach((element, index, array) => {
if (index !== array.length - 1) {
if (index == 0) {
fileDir = element;
} else {
fileDir = `${fileDir}\\${element}`;
fileDir = path.join(fileDir, element);
}
}
});
Expand Down
1 change: 0 additions & 1 deletion install.bat

This file was deleted.

4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const createWindow = () => {
height: 600,
minWidth: 600,
minHeight: 400,
autoHideMenuBar: true, // Comment this line on development
webPreferences: { nodeIntegration: true, contextIsolation: false }
//autoHideMenuBar: true // Commented out for debugging
});

mainWindow.on("closed", () => {
Expand Down Expand Up @@ -175,7 +175,7 @@ ipcMain.handle("get-dir", async () => {
});

if (result.canceled == false && result.filePaths.length == 1) {
return { dir: result.filePaths, status: 0 };
return { dir: result.filePaths[0], status: 0 };
} else {
return { dir: null, status: -1 };
}
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Live Editor for HTML, CSS and JS",
"main": "main.js",
"scripts": {
"postinstall": "node scripts/postinstall.js",
"start": "electron ."
},
"author": "Ethan Mahlstedt",
Expand Down
3 changes: 3 additions & 0 deletions scripts/linux/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd ..
cd ..
npm start
30 changes: 30 additions & 0 deletions scripts/linux/postinstall/fix-sandbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// scripts/linux/fix-sandbox.js
const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");

module.exports = function () {
if (process.platform === "linux") {
// Correct path to node_modules/electron/dist/chrome-sandbox
const sandboxPath = path.resolve(
__dirname,
"../../../node_modules/electron/dist/chrome-sandbox"
);

console.log(
"Fixing sandbox permissions... (sudo password may be required)"
);

if (fs.existsSync(sandboxPath)) {
try {
execSync(`sudo chown root ${sandboxPath}`);
execSync(`sudo chmod 4755 ${sandboxPath}`);
console.log("✔ Sandbox permissions fixed.");
} catch (err) {
console.warn("⚠ Failed to fix sandbox permissions:", err.message);
}
} else {
console.warn("⚠ Sandbox file not found at:", sandboxPath);
}
}
};
75 changes: 75 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const fs = require("fs");
const path = require("path");
const os = require("os");

const { execSync } = require("child_process");

const platform = os.platform();
const arch = os.arch();

switch (platform) {
case "darwin":
// macOS specific code
switch (arch) {
case "x64": {
const scripts = fs.readdirSync(
path.join(__dirname, "darwin-x64", "postinstall")
);
scripts.forEach((script) => {
if (script.endsWith(".js")) {
require(
path.join(__dirname, "darwin-x64", "postinstall", script)
)();
}
});
break;
}
case "arm64": {
const scripts = fs.readdirSync(
path.join(__dirname, "darwin-arm64", "postinstall")
);
scripts.forEach((script) => {
if (script.endsWith(".js")) {
require(
path.join(__dirname, "darwin-arm64", "postinstall", script)
)();
}
});
break;
}
default:
console.log("Are you still using PowerPC?");
}
break;
case "linux": {
const scripts = fs.readdirSync(
path.join(__dirname, "linux", "postinstall")
);
scripts.forEach((script) => {
if (script.endsWith(".js")) {
require(path.join(__dirname, "linux", "postinstall", script))();
} else if (script.endsWith(".sh")) {
execSync(
`chmod +x ${path.join(__dirname, "linux", "postinstall", script)}`
);
execSync(`${path.join(__dirname, "linux", "postinstall", script)}`);
}
});
break;
}
case "win32": {
const scripts = fs.readdirSync(
path.join(__dirname, "win32", "postinstall")
);
scripts.forEach((script) => {
if (script.endsWith(".js")) {
require(path.join(__dirname, "win32", "postinstall", script))();
} else if (script.endsWith(".bat")) {
execSync(`${path.join(__dirname, "win32", "postinstall", script)}`);
}
});
break;
}
default:
console.error(`Unsupported platform: ${platform}`);
}
2 changes: 2 additions & 0 deletions build.bat → scripts/win32/build.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
cd ..
cd ..
npx electron-builder
4 changes: 4 additions & 0 deletions scripts/win32/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
cd ..
cd ..
npm i
2 changes: 2 additions & 0 deletions launch.bat → scripts/win32/launch.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
cd ..
cd ..
npm start
2 changes: 2 additions & 0 deletions lineCount.bat → scripts/win32/lineCount.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
cd ..
cd ..
cloc modules front filePresets main.js
2 changes: 2 additions & 0 deletions lint.bat → scripts/win32/lint.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
cd ..
cd ..
npx eslint .
2 changes: 2 additions & 0 deletions pretty.bat → scripts/win32/pretty.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
cd ..
cd ..
npx prettier . --write