Skip to content

Commit

Permalink
Fix export format
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanCacqueray committed Jan 7, 2025
1 parent dcd9000 commit 698e46b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,19 @@ yesButton.addEventListener('click', () => {
}
});

// Return the lines of a panel view.
function getDocumentText(view) {
const doc = view.viewState.state.doc;
console.log(doc);
return doc.children ? doc.children.flatmap((c) => c.text) : doc.text;
}

exportButton.addEventListener('click', () => {
const bundle = [];
const date = new Date().toISOString().substr(0, 16).replace('T', ' ');
const bundle = [`// "nudel ${date}" @by pastagang`, '//'];
editorViews.forEach((view, key) => {
bundle.push(`// panel ${key}`);
const doc = view.viewState.state.doc;
if (doc.children) {
doc.children.forEach((c) => {
bundle.push(...c.text);
});
} else {
bundle.push(doc.text);
}
bundle.push(...getDocumentText(view));
bundle.push('\n\n');
});
const txt = bundle.join('\n');
Expand Down

0 comments on commit 698e46b

Please sign in to comment.