Skip to content

Commit

Permalink
feat: add / remove pane
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Jan 22, 2025
1 parent b398f96 commit 12d9c4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<button id="menu-button">☰ Menu</button>
<div id="menu-content">
<button id="settings-button">⚙ Settings</button>
<button id="add-pane-button">+ add Pane</button>
<button id="remove-pane-button">- scrap Pane</button>
<button id="export-button">⇓ Export</button>
<a class="button" href="https://github.com/pastagang/nudel" target="_blank">♨ Source</a>
<button id="about-button">? About</button>
Expand Down
16 changes: 16 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,19 @@ addEventListener(
},
{ passive: false, capture: true },
);

// add / remove panes
document.getElementById('add-pane-button').addEventListener('click', () => {
if (!session) return;
const documents = session.getDocuments();
const newDocs = [
...documents.map((doc) => ({ id: doc.id, target: doc.target })),
{ id: String(documents.length + 1), target: 'strudel' },
];
session.setActiveDocuments(newDocs);
});
document.getElementById('remove-pane-button').addEventListener('click', () => {
if (!session) return;
const documents = session.getDocuments();
session.setActiveDocuments([...documents.map((doc) => ({ id: doc.id, target: doc.target })).slice(0, -1)]);
});

0 comments on commit 12d9c4a

Please sign in to comment.