Skip to content

Commit

Permalink
feat: send parsed note into same note as parent note (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
aexshafii authored Jan 29, 2025
1 parent 4322084 commit 1e063bf
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/plugin/views/assistant/organizer/chunks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@ export const AtomicNotes: React.FC<DocumentChunksProps> = ({ plugin, activeFile
}
};

const addToInbox = async (title: string, chunkContent: string) => {
const createFileInSameFolder = async (title: string, chunkContent: string) => {
try {
await plugin.createFileInInbox(title, chunkContent);
// Get the parent folder path of the active file
const folderPath = activeFile.parent?.path || "";

// Create a sanitized filename
const sanitizedTitle = title.replace(/[\\/:*?"<>|]/g, "-");
const newFileName = `${sanitizedTitle}.md`;
const fullPath = `${folderPath}/${newFileName}`;

// Create the new file in the same folder
await plugin.app.vault.create(fullPath, chunkContent);
} catch (error) {
logger.error("Error adding to inbox:", error);
logger.error("Error creating file in folder:", error);
}
};

Expand All @@ -54,9 +63,9 @@ export const AtomicNotes: React.FC<DocumentChunksProps> = ({ plugin, activeFile
<p>{chunk.content}</p>
<button
className="bg-accent text-accent-foreground px-2 py-1"
onClick={() => addToInbox(concept, chunk.content)}
onClick={() => createFileInSameFolder(concept, chunk.content)}
>
Add to Inbox
Create Note
</button>
</div>
))}
Expand Down

0 comments on commit 1e063bf

Please sign in to comment.