Fix add custom prompt when no folder exists, update readme
This commit is contained in:
Logan Yang 2024-09-06 06:29:38 -07:00 committed by GitHub
parent a4cf65ee0e
commit 5f10defe9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 23 additions and 7 deletions

View file

@ -22,6 +22,12 @@ SPECIAL THANKS TO OUR TOP SPONSORS:
[Changelog](https://github.com/logancyang/obsidian-copilot/releases)
#### Announcement 🚨
We are migrating off of PouchDB for better Obsidian Sync and mobile support (starting from v2.6.3). Your existing custom prompts MUST be dumped to markdown using the command _"Copilot: Dump custom prompts to markdown files"_. After running it you should be able to use your Add/Edit/Apply/Delete custom prompts as usual.
Please make sure you run it, or you will lose all your old prompts when PouchDB is removed!
#### v2.6.0: MOBILE SUPPORT is here! 🎉🎉🎉
<a href="https://youtu.be/l-x_QwSNghE" target="_blank"><img src="./images/thumbnail-260.png" width="700" /></a>

View file

@ -1,7 +1,7 @@
{
"id": "copilot",
"name": "Copilot",
"version": "2.6.3",
"version": "2.6.4",
"minAppVersion": "0.15.0",
"description": "A ChatGPT Copilot in Obsidian.",
"author": "Logan Yang",

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "obsidian-copilot",
"version": "2.6.3",
"version": "2.6.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-copilot",
"version": "2.6.3",
"version": "2.6.4",
"license": "AGPL-3.0",
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-copilot",
"version": "2.6.3",
"version": "2.6.4",
"description": "ChatGPT integration for Obsidian",
"main": "main.js",
"scripts": {

View file

@ -6,7 +6,7 @@ import {
getNotesFromTags,
processVariableNameForNotePath,
} from "@/utils";
import { Notice, TFile, Vault } from "obsidian";
import { normalizePath, Notice, TFile, Vault } from "obsidian";
// TODO: To be deprecated once PouchDB is removed
export interface CustomPromptDB {
@ -65,7 +65,16 @@ export class CustomPromptProcessor {
}
async savePrompt(title: string, content: string): Promise<void> {
const filePath = `${this.settings.customPromptsFolder}/${title}.md`;
const folderPath = normalizePath(this.settings.customPromptsFolder);
const filePath = `${folderPath}/${title}.md`;
// Check if the folder exists and create it if it doesn't
const folderExists = await this.vault.adapter.exists(folderPath);
if (!folderExists) {
await this.vault.createFolder(folderPath);
}
// Create the file
await this.vault.create(filePath, content);
}

View file

@ -49,5 +49,6 @@
"2.6.0": "0.15.0",
"2.6.1": "0.15.0",
"2.6.2": "0.15.0",
"2.6.3": "0.15.0"
"2.6.3": "0.15.0",
"2.6.4": "0.15.0"
}