Instant update on change.
This commit is contained in:
parent
19f5dea1f6
commit
bc62e6ca2e
1 changed files with 19 additions and 18 deletions
37
index.html
37
index.html
|
|
@ -623,25 +623,8 @@ chmod 755 kbtd`;
|
|||
|
||||
// --- File Operations ---
|
||||
|
||||
async function writeFile(text) {
|
||||
try {
|
||||
const writable = await state.fileHandle.createWritable();
|
||||
await writable.write(text);
|
||||
await writable.close();
|
||||
console.log('File written successfully');
|
||||
|
||||
const file = await state.fileHandle.getFile();
|
||||
state.lastModified = file.lastModified;
|
||||
|
||||
reloadFromText(text);
|
||||
} catch (err) {
|
||||
console.error('Error writing file:', err);
|
||||
alert('Error saving file.');
|
||||
}
|
||||
}
|
||||
|
||||
function reloadFromText(text) {
|
||||
console.log('Reloading from text after write');
|
||||
console.log('Reloading from text');
|
||||
state.sections = parseMarkdown(text);
|
||||
console.log('Parsed sections:', state.sections);
|
||||
|
||||
|
|
@ -652,6 +635,24 @@ chmod 755 kbtd`;
|
|||
}
|
||||
}
|
||||
|
||||
async function writeFile(text) {
|
||||
try {
|
||||
console.log('Writing file and updating UI');
|
||||
reloadFromText(text);
|
||||
|
||||
const writable = await state.fileHandle.createWritable();
|
||||
await writable.write(text);
|
||||
await writable.close();
|
||||
console.log('File written successfully');
|
||||
|
||||
const file = await state.fileHandle.getFile();
|
||||
state.lastModified = file.lastModified;
|
||||
} catch (err) {
|
||||
console.error('Error writing file:', err);
|
||||
alert('Error saving file.');
|
||||
}
|
||||
}
|
||||
|
||||
async function updateLineInFile(lineNum, newText) {
|
||||
console.log('updateLineInFile:', lineNum, newText);
|
||||
const file = await state.fileHandle.getFile();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue