sepehr 8d95f34fcc fix: Add debounced Undo/Redo system to avoid character-by-character history
- Add debounced state updates for title and content (500ms delay)
- Immediate UI updates with delayed history saving
- Prevent one-letter-per-undo issue
- Add cleanup for debounce timers on unmount
2026-01-04 14:28:11 +01:00

36 lines
1016 B
JavaScript

// src/utils/filepath.ts
var getFilePath = (options) => {
let filename = options.filename;
const defaultDocument = options.defaultDocument || "index.html";
if (filename.endsWith("/")) {
filename = filename.concat(defaultDocument);
} else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) {
filename = filename.concat("/" + defaultDocument);
}
const path = getFilePathWithoutDefaultDocument({
root: options.root,
filename
});
return path;
};
var getFilePathWithoutDefaultDocument = (options) => {
let root = options.root || "";
let filename = options.filename;
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
return;
}
filename = filename.replace(/^\.?[\/\\]/, "");
filename = filename.replace(/\\/, "/");
root = root.replace(/\/$/, "");
let path = root ? root + "/" + filename : filename;
path = path.replace(/^\.?\//, "");
if (root[0] !== "/" && path[0] === "/") {
return;
}
return path;
};
export {
getFilePath,
getFilePathWithoutDefaultDocument
};