Compare commits
11 Commits
fc33a9c051
...
0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
740454d87e | ||
|
|
18a5730605 | ||
|
|
65094d3df6 | ||
|
|
ef3af6ae75 | ||
|
|
9a897ef3a7 | ||
|
|
a43c3221da | ||
|
|
75d3488de0 | ||
|
|
1806a612b6 | ||
|
|
b4b627b6bb | ||
|
|
921c4a29a7 | ||
|
|
5e633d9dd6 |
21
README.md
21
README.md
@@ -2,10 +2,6 @@
|
||||
|
||||
An Electron application with Vue
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
|
||||
|
||||
## Project Setup
|
||||
|
||||
### Install
|
||||
@@ -32,3 +28,20 @@ $ npm run build:mac
|
||||
# For Linux
|
||||
$ npm run build:linux
|
||||
```
|
||||
|
||||
### Releasing Versions
|
||||
|
||||
Before releasing a new version, make sure that all code is committed and pushed to the remote repository. Then, update the version number in `package.json`.
|
||||
|
||||
Create a new release tag and push it to the remote repository.
|
||||
|
||||
```bash
|
||||
$ git tag -a <version> -m "Release <version>"
|
||||
$ git push --tags
|
||||
```
|
||||
|
||||
Run the release script to build and package the application and upload it to the SeaweedFS bucket.
|
||||
|
||||
```bash
|
||||
$ npm run release:<platform>
|
||||
```
|
||||
|
||||
163
bin/uploadArtifacts.js
Normal file
163
bin/uploadArtifacts.js
Normal file
@@ -0,0 +1,163 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { execSync } from 'child_process'
|
||||
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config({ quiet: true })
|
||||
|
||||
const DIST_DIR = path.resolve('dist')
|
||||
const BUCKET = 'dist'
|
||||
|
||||
const client = new S3Client({
|
||||
region: 'us-east-1',
|
||||
endpoint: 'https://s3.takerofnotes.com',
|
||||
forcePathStyle: true,
|
||||
credentials: {
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
})
|
||||
|
||||
const getContentType = (file) => {
|
||||
if (file.endsWith('.yml')) return 'text/yaml'
|
||||
if (file.endsWith('.json')) return 'application/json'
|
||||
if (file.endsWith('.AppImage')) return 'application/octet-stream'
|
||||
if (file.endsWith('.deb')) return 'application/vnd.debian.binary-package'
|
||||
if (file.endsWith('.exe'))
|
||||
return 'application/vnd.microsoft.portable-executable'
|
||||
if (file.endsWith('.dmg')) return 'application/x-apple-diskimage'
|
||||
return 'application/octet-stream'
|
||||
}
|
||||
|
||||
const getCurrentTag = () => {
|
||||
try {
|
||||
const tag = execSync('git describe --tags --exact-match 2>/dev/null', {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
}).trim()
|
||||
return tag
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const isGitTagDirty = () => {
|
||||
try {
|
||||
const status = execSync('git status --porcelain', {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
}).trim()
|
||||
return status.length > 0
|
||||
} catch {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const uploadFile = async (filePath, platform, version) => {
|
||||
const fileStream = fs.createReadStream(filePath)
|
||||
const fileName = path.basename(filePath)
|
||||
const key = `${platform}/${version}/${fileName}`
|
||||
|
||||
console.log(`Uploading ${fileName} → ${key}`)
|
||||
|
||||
await client.send(
|
||||
new PutObjectCommand({
|
||||
Bucket: BUCKET,
|
||||
Key: key,
|
||||
Body: fileStream,
|
||||
ContentType: getContentType(fileName),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const uploadFileToRoot = async (filePath, platform) => {
|
||||
const fileStream = fs.createReadStream(filePath)
|
||||
const fileName = path.basename(filePath)
|
||||
const key = `${platform}/${fileName}`
|
||||
|
||||
console.log(`Uploading ${fileName} → ${key} (latest)`)
|
||||
|
||||
await client.send(
|
||||
new PutObjectCommand({
|
||||
Bucket: BUCKET,
|
||||
Key: key,
|
||||
Body: fileStream,
|
||||
ContentType: getContentType(fileName),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const platform = process.argv[2]
|
||||
const version = process.argv[3]
|
||||
|
||||
if (!platform || !version) {
|
||||
console.error('Usage: node uploadArtifacts.js <platform> <version>')
|
||||
console.error('Example: node uploadArtifacts.js win 1.0.0')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const currentTag = getCurrentTag()
|
||||
if (!currentTag) {
|
||||
console.log(
|
||||
'No git tag found. Skipping upload (artifacts are only uploaded on tagged commits).',
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (currentTag !== version && !currentTag.startsWith(version)) {
|
||||
console.log(
|
||||
`Git tag (${currentTag}) does not match version (${version}). Skipping upload.`,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (isGitTagDirty()) {
|
||||
console.log('Git working directory is dirty. Skipping upload.')
|
||||
return
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Uploading artifacts for ${platform} v${version} (tag: ${currentTag})`,
|
||||
)
|
||||
|
||||
if (!fs.existsSync(DIST_DIR)) {
|
||||
throw new Error('dist directory not found. Run build first.')
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(DIST_DIR)
|
||||
|
||||
const uploadTargets = files.filter((file) => {
|
||||
return (
|
||||
file.endsWith('.yml') ||
|
||||
file.endsWith('.AppImage') ||
|
||||
file.endsWith('.deb') ||
|
||||
file.endsWith('.exe') ||
|
||||
file.endsWith('.dmg')
|
||||
)
|
||||
})
|
||||
|
||||
if (uploadTargets.length === 0) {
|
||||
console.log('No artifacts found to upload.')
|
||||
return
|
||||
}
|
||||
|
||||
for (const file of uploadTargets) {
|
||||
const fullPath = path.join(DIST_DIR, file)
|
||||
|
||||
// Keep latest.yml up to date for platform
|
||||
if (file.startsWith('latest') && file.endsWith('.yml')) {
|
||||
await uploadFileToRoot(fullPath, platform)
|
||||
} else {
|
||||
await uploadFile(fullPath, platform, version)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Upload complete.')
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -30,7 +30,6 @@ dmg:
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
- snap
|
||||
- deb
|
||||
maintainer: electronjs.org
|
||||
category: Utility
|
||||
@@ -38,6 +37,5 @@ appImage:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: s3
|
||||
bucket: dist
|
||||
endpoint: https://s3.takerofnotes.com
|
||||
provider: generic
|
||||
url: https://s3.takerofnotes.com/dist
|
||||
|
||||
@@ -1,593 +0,0 @@
|
||||
import "dotenv/config";
|
||||
import { electronApp, optimizer, is } from "@electron-toolkit/utils";
|
||||
import { app, ipcMain, BrowserWindow, shell } from "electron";
|
||||
import filesystemPlugin from "@takerofnotes/plugin-filesystem";
|
||||
import supabasePlugin from "@takerofnotes/plugin-supabase";
|
||||
import s3Plugin from "@takerofnotes/plugin-s3";
|
||||
import postgresPlugin from "@takerofnotes/plugin-postgre-sql";
|
||||
import Ajv from "ajv";
|
||||
import sodium from "libsodium-wrappers";
|
||||
import { v4 } from "uuid";
|
||||
import { Index } from "flexsearch";
|
||||
import { join } from "path";
|
||||
import __cjs_mod__ from "node:module";
|
||||
const __filename = import.meta.filename;
|
||||
const __dirname = import.meta.dirname;
|
||||
const require2 = __cjs_mod__.createRequire(import.meta.url);
|
||||
const createPluginManager = (registry) => {
|
||||
let activePluginId = null;
|
||||
let adapter = null;
|
||||
return {
|
||||
listPlugins() {
|
||||
return registry.list();
|
||||
},
|
||||
getPlugin(pluginId) {
|
||||
return registry.get(pluginId);
|
||||
},
|
||||
getAdapter(pluginId, adapterConfig = {}) {
|
||||
const plugin = registry.get(pluginId);
|
||||
if (!plugin) {
|
||||
throw new Error(`Plugin not found: ${pluginId}`);
|
||||
}
|
||||
return plugin.createAdapter(adapterConfig);
|
||||
},
|
||||
setActivePlugin(pluginId, adapterConfig = {}) {
|
||||
activePluginId = pluginId;
|
||||
adapter = this.getAdapter(pluginId, adapterConfig);
|
||||
return adapter;
|
||||
},
|
||||
async testPlugin(pluginId, adapterConfig = {}) {
|
||||
const plugin = registry.get(pluginId);
|
||||
if (!plugin) {
|
||||
throw new Error(`Plugin not found: ${pluginId}`);
|
||||
}
|
||||
const adapter2 = this.getAdapter(pluginId, adapterConfig);
|
||||
await adapter2.init();
|
||||
return await adapter2.testConnection();
|
||||
},
|
||||
getActiveAdapter() {
|
||||
return adapter;
|
||||
},
|
||||
getActivePluginId() {
|
||||
return activePluginId;
|
||||
}
|
||||
};
|
||||
};
|
||||
class PluginRegistry {
|
||||
constructor() {
|
||||
this.plugins = /* @__PURE__ */ new Map();
|
||||
}
|
||||
register(plugin) {
|
||||
if (!plugin.id) {
|
||||
throw new Error("Plugin must have an id");
|
||||
}
|
||||
this.plugins.set(plugin.id, plugin);
|
||||
}
|
||||
get(id) {
|
||||
return this.plugins.get(id);
|
||||
}
|
||||
list() {
|
||||
return Array.from(this.plugins.values()).map((plugin) => ({
|
||||
id: plugin.id,
|
||||
name: plugin.name,
|
||||
description: plugin.description,
|
||||
configSchema: plugin.configSchema
|
||||
}));
|
||||
}
|
||||
}
|
||||
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||
const getDefaultConfig = () => {
|
||||
return {
|
||||
activeAdapter: "browser",
|
||||
theme: "dark"
|
||||
};
|
||||
};
|
||||
const CONFIG_SCHEMA = {
|
||||
type: "object",
|
||||
properties: {
|
||||
activeAdapter: { type: "string" },
|
||||
theme: { type: "string", enum: ["dark", "light"] },
|
||||
encryptionKey: { type: "string" },
|
||||
adapters: { type: "object" }
|
||||
},
|
||||
required: ["activeAdapter"],
|
||||
additionalProperties: true
|
||||
};
|
||||
const validateConfig = ajv.compile(CONFIG_SCHEMA);
|
||||
const convertSchemaToJson = (schemaArray) => {
|
||||
const properties = {};
|
||||
const required = [];
|
||||
for (const field of schemaArray) {
|
||||
properties[field.key] = { type: "string" };
|
||||
if (field.required) {
|
||||
required.push(field.key);
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: "object",
|
||||
properties,
|
||||
required,
|
||||
additionalProperties: false
|
||||
};
|
||||
};
|
||||
const validateAdapterConfigs = (adapters, pluginManager) => {
|
||||
if (!adapters || !pluginManager) return { valid: true, errors: [] };
|
||||
const errors = [];
|
||||
for (const [adapterId, adapterConfig] of Object.entries(adapters)) {
|
||||
const plugin = pluginManager.getPlugin(adapterId);
|
||||
if (!plugin?.configSchema) continue;
|
||||
const schema = convertSchemaToJson(plugin.configSchema);
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(adapterConfig);
|
||||
if (!valid) {
|
||||
const adapterErrors = validate.errors.map(
|
||||
(e) => `${adapterId}${e.instancePath}: ${e.message}`
|
||||
);
|
||||
errors.push(...adapterErrors);
|
||||
}
|
||||
}
|
||||
return { valid: errors.length === 0, errors };
|
||||
};
|
||||
const createConfigManager = (storage, pluginManager) => {
|
||||
let config = null;
|
||||
return {
|
||||
async loadConfig() {
|
||||
if (config) return config;
|
||||
const stored = await storage.load();
|
||||
config = stored || getDefaultConfig();
|
||||
if (!stored) {
|
||||
await storage.save(config);
|
||||
}
|
||||
return config;
|
||||
},
|
||||
getConfig() {
|
||||
return config;
|
||||
},
|
||||
async setConfig(newConfig) {
|
||||
const valid = validateConfig(newConfig);
|
||||
if (!valid) {
|
||||
const errors = validateConfig.errors.map((e) => `${e.instancePath || "root"}: ${e.message}`).join("; ");
|
||||
throw new Error(`Config validation failed: ${errors}`);
|
||||
}
|
||||
const adapterValidation = validateAdapterConfigs(
|
||||
newConfig.adapters,
|
||||
pluginManager
|
||||
);
|
||||
if (!adapterValidation.valid) {
|
||||
throw new Error(
|
||||
`Adapter config validation failed: ${adapterValidation.errors.join("; ")}`
|
||||
);
|
||||
}
|
||||
config = newConfig;
|
||||
await storage.save(newConfig);
|
||||
},
|
||||
async refreshConfig() {
|
||||
config = await storage.load();
|
||||
}
|
||||
};
|
||||
};
|
||||
class NotesAPI {
|
||||
constructor(adapter, encryptionKey = null) {
|
||||
if (!adapter) {
|
||||
throw new Error("NotesAPI requires a storage adapter");
|
||||
}
|
||||
this.adapter = adapter;
|
||||
this.notesCache = /* @__PURE__ */ new Map();
|
||||
this.categories = /* @__PURE__ */ new Set();
|
||||
this.encryptionKey = encryptionKey;
|
||||
this._sodiumReady = false;
|
||||
this._decryptionFailures = [];
|
||||
this.index = new Index({
|
||||
tokenize: "forward"
|
||||
});
|
||||
}
|
||||
async _initSodium() {
|
||||
if (!this._sodiumReady) {
|
||||
await sodium.ready;
|
||||
this._sodiumReady = true;
|
||||
}
|
||||
}
|
||||
_hexToUint8Array(hex) {
|
||||
return Uint8Array.from(
|
||||
hex.match(/.{1,2}/g),
|
||||
(byte) => parseInt(byte, 16)
|
||||
);
|
||||
}
|
||||
_concatUint8Arrays(a, b) {
|
||||
const result = new Uint8Array(a.length + b.length);
|
||||
result.set(a, 0);
|
||||
result.set(b, a.length);
|
||||
return result;
|
||||
}
|
||||
_uint8ArrayToBase64(bytes) {
|
||||
return btoa(String.fromCharCode(...bytes));
|
||||
}
|
||||
_base64ToUint8Array(base64) {
|
||||
const binary = atob(base64);
|
||||
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
||||
}
|
||||
_encrypt(note) {
|
||||
if (!this.encryptionKey) {
|
||||
throw new Error("Encryption key not set");
|
||||
}
|
||||
const key = this._hexToUint8Array(this.encryptionKey);
|
||||
if (key.length !== 32) {
|
||||
throw new Error(
|
||||
"Encryption key must be 64 hex characters (32 bytes)"
|
||||
);
|
||||
}
|
||||
const nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
|
||||
const message = JSON.stringify(note);
|
||||
const ciphertext = sodium.crypto_secretbox_easy(
|
||||
new TextEncoder().encode(message),
|
||||
nonce,
|
||||
key
|
||||
);
|
||||
const combined = this._concatUint8Arrays(nonce, ciphertext);
|
||||
return this._uint8ArrayToBase64(combined);
|
||||
}
|
||||
_decrypt(encryptedData) {
|
||||
if (!this.encryptionKey) {
|
||||
throw new Error("Encryption key not set");
|
||||
}
|
||||
const key = this._hexToUint8Array(this.encryptionKey);
|
||||
if (key.length !== 32) {
|
||||
throw new Error(
|
||||
"Encryption key must be 64 hex characters (32 bytes)"
|
||||
);
|
||||
}
|
||||
let combined;
|
||||
try {
|
||||
combined = this._base64ToUint8Array(encryptedData);
|
||||
} catch (e) {
|
||||
throw new Error("Invalid encrypted data: not valid base64");
|
||||
}
|
||||
if (combined.length < sodium.crypto_secretbox_NONCEBYTES + sodium.crypto_secretbox_MACBYTES) {
|
||||
throw new Error("Invalid encrypted data: too short");
|
||||
}
|
||||
const nonce = combined.slice(0, sodium.crypto_secretbox_NONCEBYTES);
|
||||
const ciphertext = combined.slice(sodium.crypto_secretbox_NONCEBYTES);
|
||||
let decrypted;
|
||||
try {
|
||||
decrypted = sodium.crypto_secretbox_open_easy(
|
||||
ciphertext,
|
||||
nonce,
|
||||
key
|
||||
);
|
||||
} catch (e) {
|
||||
throw new Error("Decryption failed: wrong key or corrupted data");
|
||||
}
|
||||
if (!decrypted) {
|
||||
throw new Error("Decryption failed: no data returned");
|
||||
}
|
||||
const decryptedStr = new TextDecoder().decode(decrypted);
|
||||
try {
|
||||
return JSON.parse(decryptedStr);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Decryption succeeded but invalid JSON: ${decryptedStr}`
|
||||
);
|
||||
}
|
||||
}
|
||||
async init() {
|
||||
await this._initSodium();
|
||||
await this.adapter.init();
|
||||
this.notesCache.clear();
|
||||
this.categories.clear();
|
||||
this._decryptionFailures = [];
|
||||
const encryptedNotes = await this.adapter.getAll();
|
||||
for (const encryptedNote of encryptedNotes) {
|
||||
const noteId = encryptedNote.id || "unknown";
|
||||
try {
|
||||
const note = this._decrypt(encryptedNote.data || encryptedNote);
|
||||
this.notesCache.set(note.id, note);
|
||||
if (note.category) {
|
||||
this.categories.add(note.category);
|
||||
}
|
||||
const searchText = note.plainText || this._extractPlainText(note.content);
|
||||
this.index.add(note.id, note.title + "\n" + searchText);
|
||||
} catch (error) {
|
||||
console.error("Failed to decrypt note:", error);
|
||||
this._decryptionFailures.push(noteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
getDecryptionFailures() {
|
||||
return [...this._decryptionFailures];
|
||||
}
|
||||
_extractPlainText(content) {
|
||||
if (!content) return "";
|
||||
if (typeof content === "string") return content;
|
||||
const extractText = (node) => {
|
||||
if (typeof node === "string") return node;
|
||||
if (!node || !node.content) return "";
|
||||
return node.content.map(extractText).join(" ");
|
||||
};
|
||||
return extractText(content);
|
||||
}
|
||||
getCategories() {
|
||||
return Array.from(this.categories).sort();
|
||||
}
|
||||
getCategoryNotes(categoryName = null) {
|
||||
return Array.from(this.notesCache.values()).filter((n) => n.category === categoryName).sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt)).map((n) => ({ ...n }));
|
||||
}
|
||||
getNote(id) {
|
||||
const note = this.notesCache.get(id);
|
||||
return note ? { ...note } : null;
|
||||
}
|
||||
async createNote(metadata = {}, content = "", plainText = "") {
|
||||
const id = v4();
|
||||
const now = (/* @__PURE__ */ new Date()).toISOString();
|
||||
const note = {
|
||||
id,
|
||||
title: metadata.title || "Untitled",
|
||||
category: metadata.category || null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
content,
|
||||
plainText
|
||||
};
|
||||
const encryptedNote = {
|
||||
id: note.id,
|
||||
data: this._encrypt(note)
|
||||
};
|
||||
this.notesCache.set(id, note);
|
||||
if (note.category) {
|
||||
this.categories.add(note.category);
|
||||
}
|
||||
this.index.add(id, note.title + "\n" + plainText);
|
||||
await this.adapter.create(encryptedNote);
|
||||
return note;
|
||||
}
|
||||
async deleteNote(id) {
|
||||
const note = this.notesCache.get(id);
|
||||
const category = note?.category;
|
||||
await this.adapter.delete(id);
|
||||
this.notesCache.delete(id);
|
||||
this.index.remove(id);
|
||||
if (category) {
|
||||
const notesWithCategory = Array.from(
|
||||
this.notesCache.values()
|
||||
).filter((n) => n.category === category);
|
||||
if (notesWithCategory.length === 0) {
|
||||
this.categories.delete(category);
|
||||
}
|
||||
}
|
||||
if (this._decryptionFailures.includes(id)) {
|
||||
this._decryptionFailures = this._decryptionFailures.filter(
|
||||
(id2) => id2 !== id2
|
||||
);
|
||||
}
|
||||
}
|
||||
async updateNote(id, updates = {}) {
|
||||
const note = this.notesCache.get(id);
|
||||
if (!note) throw new Error("Note not found");
|
||||
const allowedFields = ["title", "category", "content", "plainText"];
|
||||
for (const key of Object.keys(updates)) {
|
||||
if (!allowedFields.includes(key)) {
|
||||
throw new Error(`Invalid update field: ${key}`);
|
||||
}
|
||||
}
|
||||
const oldCategory = note.category;
|
||||
const updatedNote = {
|
||||
...note,
|
||||
...updates,
|
||||
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
||||
};
|
||||
const encryptedNote = {
|
||||
id: updatedNote.id,
|
||||
data: this._encrypt(updatedNote)
|
||||
};
|
||||
this.notesCache.set(id, updatedNote);
|
||||
if (updates.category !== void 0) {
|
||||
if (oldCategory) {
|
||||
const notesWithOldCategory = Array.from(
|
||||
this.notesCache.values()
|
||||
).filter((n) => n.category === oldCategory && n.id !== id);
|
||||
if (notesWithOldCategory.length === 0) {
|
||||
this.categories.delete(oldCategory);
|
||||
}
|
||||
}
|
||||
if (updatedNote.category) {
|
||||
this.categories.add(updatedNote.category);
|
||||
}
|
||||
}
|
||||
const searchText = updatedNote.plainText || this._extractPlainText(updatedNote.content);
|
||||
this.index.update(id, updatedNote.title + "\n" + searchText);
|
||||
await this.adapter.update(encryptedNote);
|
||||
return updatedNote;
|
||||
}
|
||||
search(query) {
|
||||
const ids = this.index.search(query, {
|
||||
limit: 50,
|
||||
suggest: true
|
||||
});
|
||||
return ids.map((id) => this.notesCache.get(id));
|
||||
}
|
||||
}
|
||||
const generateEncryptionKey = () => {
|
||||
const array = new Uint8Array(32);
|
||||
crypto.getRandomValues(array);
|
||||
return Array.from(array).map((b) => b.toString(16).padStart(2, "0")).join("");
|
||||
};
|
||||
const initPluginManager = (runtime, plugins) => {
|
||||
const registry = new PluginRegistry();
|
||||
for (const plugin of plugins) {
|
||||
registry.register(plugin);
|
||||
}
|
||||
return createPluginManager(registry);
|
||||
};
|
||||
const initConfigManager = async (runtime, pluginManager) => {
|
||||
let storage;
|
||||
{
|
||||
const { createNodeStorage } = await import("./NodeStorage-B8VFtrTS.js");
|
||||
const filesystemPlugin2 = (await import("@takerofnotes/plugin-filesystem")).default;
|
||||
storage = createNodeStorage(filesystemPlugin2);
|
||||
}
|
||||
return createConfigManager(storage, pluginManager);
|
||||
};
|
||||
const initializeCore = async (runtime, { plugins }) => {
|
||||
const pluginManager = initPluginManager(runtime, plugins);
|
||||
const configManager = await initConfigManager(runtime, pluginManager);
|
||||
const config = await configManager.loadConfig();
|
||||
const activeConfig = config.adapters?.[config.activeAdapter] || {};
|
||||
pluginManager.setActivePlugin(config.activeAdapter, activeConfig);
|
||||
let notesAPI = null;
|
||||
let initPromise = null;
|
||||
const getNotesAPI = async () => {
|
||||
if (notesAPI) return notesAPI;
|
||||
if (!initPromise) {
|
||||
initPromise = (async () => {
|
||||
const latestConfig = await configManager.loadConfig();
|
||||
let encryptionKey = latestConfig?.encryptionKey;
|
||||
if (!encryptionKey) {
|
||||
encryptionKey = generateEncryptionKey();
|
||||
await configManager.setConfig({
|
||||
...latestConfig,
|
||||
encryptionKey
|
||||
});
|
||||
}
|
||||
const pluginId = latestConfig?.activeAdapter || "filesystem";
|
||||
const adapterConfig = latestConfig?.adapters?.[pluginId] || {};
|
||||
const adapter = pluginManager.getAdapter(
|
||||
pluginId,
|
||||
adapterConfig
|
||||
);
|
||||
notesAPI = new NotesAPI(adapter, encryptionKey);
|
||||
await notesAPI.init();
|
||||
return notesAPI;
|
||||
})();
|
||||
}
|
||||
return initPromise;
|
||||
};
|
||||
return {
|
||||
runtime,
|
||||
pluginManager,
|
||||
configManager,
|
||||
getNotesAPI
|
||||
};
|
||||
};
|
||||
const DEFAULT_WINDOW_SIZE = { width: 354, height: 549 };
|
||||
const DEFAULT_MOVE_WINDOW_SIZE = { width: 708, height: 549 };
|
||||
const preloadPath = join(__dirname, "../preload/index.mjs");
|
||||
const rendererPath = join(__dirname, "../renderer/index.html");
|
||||
function createWindow() {
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: DEFAULT_WINDOW_SIZE.width,
|
||||
height: DEFAULT_WINDOW_SIZE.height,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: preloadPath,
|
||||
sandbox: false
|
||||
}
|
||||
});
|
||||
mainWindow.on("ready-to-show", () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url);
|
||||
return { action: "deny" };
|
||||
});
|
||||
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
|
||||
mainWindow.loadURL(process.env["ELECTRON_RENDERER_URL"]);
|
||||
} else {
|
||||
mainWindow.loadFile(rendererPath);
|
||||
}
|
||||
}
|
||||
function createNoteWindow(noteId) {
|
||||
const noteWindow = new BrowserWindow({
|
||||
width: DEFAULT_WINDOW_SIZE.width,
|
||||
height: DEFAULT_WINDOW_SIZE.height,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: preloadPath,
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: false
|
||||
}
|
||||
});
|
||||
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
|
||||
noteWindow.loadURL(
|
||||
`${process.env["ELECTRON_RENDERER_URL"]}/#/note/${noteId}`
|
||||
);
|
||||
} else {
|
||||
noteWindow.loadFile(rendererPath, {
|
||||
hash: `/note/${noteId}`
|
||||
});
|
||||
}
|
||||
}
|
||||
app.whenReady().then(async () => {
|
||||
ipcMain.on("open-note-window", (_, noteId) => {
|
||||
createNoteWindow(noteId);
|
||||
});
|
||||
const broadcastNoteChange = (event, data) => {
|
||||
BrowserWindow.getAllWindows().forEach((win) => {
|
||||
win.webContents.send(event, data);
|
||||
});
|
||||
};
|
||||
const { pluginManager, configManager } = await initializeCore(
|
||||
"electron-main",
|
||||
{
|
||||
plugins: [
|
||||
filesystemPlugin,
|
||||
s3Plugin,
|
||||
postgresPlugin,
|
||||
supabasePlugin
|
||||
]
|
||||
}
|
||||
);
|
||||
ipcMain.handle("pluginManager:call", async (_, method, ...args) => {
|
||||
const methodCall = await pluginManager[method](...args);
|
||||
if (method === "setActivePlugin") {
|
||||
broadcastNoteChange("plugin-changed");
|
||||
}
|
||||
return methodCall;
|
||||
});
|
||||
ipcMain.handle("configManager:call", async (_, method, ...args) => {
|
||||
return await configManager[method](...args);
|
||||
});
|
||||
ipcMain.handle("adapter:call", async (_, method, ...args) => {
|
||||
const adapter = pluginManager.getActiveAdapter();
|
||||
if (!adapter[method]) {
|
||||
throw new Error(`Invalid adapter method: ${method}`);
|
||||
}
|
||||
return await adapter[method](...args);
|
||||
});
|
||||
ipcMain.on("note-changed", (_, event, data) => {
|
||||
broadcastNoteChange(event, data);
|
||||
});
|
||||
ipcMain.handle("move-opened", (_) => {
|
||||
const activeWindow = BrowserWindow.getFocusedWindow();
|
||||
const windowSize = activeWindow.getSize();
|
||||
if (windowSize[0] < DEFAULT_MOVE_WINDOW_SIZE.width) {
|
||||
activeWindow.setSize(
|
||||
DEFAULT_MOVE_WINDOW_SIZE.width,
|
||||
DEFAULT_MOVE_WINDOW_SIZE.height
|
||||
);
|
||||
}
|
||||
});
|
||||
ipcMain.handle("move-closed", (_) => {
|
||||
const activeWindow = BrowserWindow.getFocusedWindow();
|
||||
const windowSize = activeWindow.getSize();
|
||||
if (windowSize[0] === 708) {
|
||||
activeWindow.setSize(
|
||||
DEFAULT_WINDOW_SIZE.width,
|
||||
DEFAULT_WINDOW_SIZE.height
|
||||
);
|
||||
}
|
||||
});
|
||||
electronApp.setAppUserModelId("com.electron");
|
||||
app.on("browser-window-created", (_, window) => {
|
||||
optimizer.watchWindowShortcuts(window);
|
||||
});
|
||||
createWindow();
|
||||
app.on("activate", function() {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
const api = {
|
||||
pluginManagerCall: (method, ...args) => ipcRenderer.invoke(
|
||||
"pluginManager:call",
|
||||
method,
|
||||
...args.length ? args : []
|
||||
),
|
||||
configManagerCall: (method, ...args) => ipcRenderer.invoke(
|
||||
"configManager:call",
|
||||
method,
|
||||
...args.length ? args : []
|
||||
),
|
||||
adapterCall: (method, ...args) => ipcRenderer.invoke(
|
||||
"adapter:call",
|
||||
method,
|
||||
...args.length ? args : []
|
||||
),
|
||||
openNoteWindow: (noteId) => {
|
||||
ipcRenderer.send("open-note-window", noteId);
|
||||
},
|
||||
onNoteCreated: (callback) => {
|
||||
ipcRenderer.on("note-created", (_, data) => callback(data));
|
||||
},
|
||||
onNoteUpdated: (callback) => {
|
||||
ipcRenderer.on("note-updated", (_, data) => callback(data));
|
||||
},
|
||||
onNoteDeleted: (callback) => {
|
||||
ipcRenderer.on("note-deleted", (_, data) => callback(data));
|
||||
},
|
||||
onPluginChanged: (callback) => {
|
||||
ipcRenderer.on("plugin-changed", (_, data) => callback(data));
|
||||
},
|
||||
notifyNoteChanged: (event, data) => {
|
||||
ipcRenderer.send("note-changed", event, data);
|
||||
},
|
||||
moveOpened: () => {
|
||||
ipcRenderer.invoke("move-opened");
|
||||
},
|
||||
moveClosed: () => {
|
||||
ipcRenderer.invoke("move-closed");
|
||||
}
|
||||
};
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
contextBridge.exposeInMainWorld("api", api);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
window.api = api;
|
||||
}
|
||||
635
package-lock.json
generated
635
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "takerofnotes-app",
|
||||
"version": "0.1.0",
|
||||
"version": "0.3.0",
|
||||
"description": "An Electron application with Vue",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "example.com",
|
||||
@@ -19,10 +19,12 @@
|
||||
"build": "electron-vite build",
|
||||
"build:web": "vite build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:unpack": "npm run build && electron-builder --dir",
|
||||
"build:win": "npm run build && electron-builder --win",
|
||||
"build:mac": "npm run build && electron-builder --mac",
|
||||
"build:linux": "npm run build && electron-builder --linux"
|
||||
"build:linux": "npm run build && electron-builder --linux",
|
||||
"release:win": "node bin/uploadArtifacts.js win $npm_package_version",
|
||||
"release:mac": "node bin/uploadArtifacts.js mac $npm_package_version",
|
||||
"release:linux": "node bin/uploadArtifacts.js linux $npm_package_version"
|
||||
},
|
||||
"dependencies": {
|
||||
"@capacitor/android": "^8.3.0",
|
||||
@@ -64,6 +66,7 @@
|
||||
"vue-router": "^5.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aws-sdk/client-s3": "^3.1025.0",
|
||||
"@capacitor/cli": "^8.3.0",
|
||||
"@vitejs/plugin-vue": "^6.0.2",
|
||||
"electron": "^39.2.6",
|
||||
|
||||
@@ -6,6 +6,8 @@ const getDefaultConfig = () => {
|
||||
return {
|
||||
activeAdapter: 'browser',
|
||||
theme: 'dark',
|
||||
enableBlackletter: 'true',
|
||||
openNotesInNewWindow: 'true',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,12 @@ export const createPluginManagerClient = () => {
|
||||
},
|
||||
|
||||
async testPlugin(id, config) {
|
||||
return window.api.pluginManagerCall('testPlugin', { id, config })
|
||||
const test = await window.api.pluginManagerCall(
|
||||
'testPlugin',
|
||||
id,
|
||||
config,
|
||||
)
|
||||
return test
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,35 @@ const initConfigManager = async (runtime, pluginManager) => {
|
||||
return createConfigManager(storage, pluginManager)
|
||||
}
|
||||
|
||||
let notesAPI = null
|
||||
let initPromise = null
|
||||
const initNotesAPI = async (configManager, pluginManager) => {
|
||||
// Get fresh config to ensure adapters are populated from main process
|
||||
const latestConfig = await configManager.loadConfig()
|
||||
|
||||
let encryptionKey = latestConfig?.encryptionKey
|
||||
|
||||
if (!encryptionKey) {
|
||||
encryptionKey = generateEncryptionKey()
|
||||
await configManager.setConfig({
|
||||
...latestConfig,
|
||||
encryptionKey,
|
||||
})
|
||||
}
|
||||
|
||||
const pluginId = latestConfig?.activeAdapter || 'filesystem'
|
||||
const adapterConfig = latestConfig?.adapters?.[pluginId] || {}
|
||||
|
||||
const adapter = pluginManager.getAdapter(pluginId, adapterConfig)
|
||||
|
||||
const api = new NotesAPI(adapter, encryptionKey)
|
||||
await api.init()
|
||||
|
||||
notesAPI = api
|
||||
|
||||
return api
|
||||
}
|
||||
|
||||
export const initializeCore = async (runtime, { plugins }) => {
|
||||
const pluginManager = initPluginManager(runtime, plugins)
|
||||
const configManager = await initConfigManager(runtime, pluginManager)
|
||||
@@ -60,39 +89,11 @@ export const initializeCore = async (runtime, { plugins }) => {
|
||||
pluginManager.setActivePlugin(config.activeAdapter, activeConfig)
|
||||
|
||||
// Create API instance
|
||||
let notesAPI = null
|
||||
let initPromise = null
|
||||
const getNotesAPI = async () => {
|
||||
if (notesAPI) return notesAPI
|
||||
|
||||
if (!initPromise) {
|
||||
initPromise = (async () => {
|
||||
// Get fresh config to ensure adapters are populated from main process
|
||||
const latestConfig = await configManager.loadConfig()
|
||||
|
||||
let encryptionKey = latestConfig?.encryptionKey
|
||||
|
||||
if (!encryptionKey) {
|
||||
encryptionKey = generateEncryptionKey()
|
||||
await configManager.setConfig({
|
||||
...latestConfig,
|
||||
encryptionKey,
|
||||
})
|
||||
}
|
||||
|
||||
const pluginId = latestConfig?.activeAdapter || 'filesystem'
|
||||
const adapterConfig = latestConfig?.adapters?.[pluginId] || {}
|
||||
|
||||
const adapter = pluginManager.getAdapter(
|
||||
pluginId,
|
||||
adapterConfig,
|
||||
)
|
||||
|
||||
notesAPI = new NotesAPI(adapter, encryptionKey)
|
||||
await notesAPI.init()
|
||||
|
||||
return notesAPI
|
||||
})()
|
||||
initPromise = initNotesAPI(configManager, pluginManager)
|
||||
}
|
||||
|
||||
return initPromise
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dotenv/config'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||
import { app, shell, BrowserWindow, ipcMain, dialog } from 'electron'
|
||||
import filesystemPlugin from '@takerofnotes/plugin-filesystem'
|
||||
import supabasePlugin from '@takerofnotes/plugin-supabase'
|
||||
import s3Plugin from '@takerofnotes/plugin-s3'
|
||||
@@ -137,6 +137,13 @@ app.whenReady().then(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('open-directory-dialog', async () => {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
return result.canceled ? null : result.filePaths[0]
|
||||
})
|
||||
|
||||
electronApp.setAppUserModelId('com.electron')
|
||||
|
||||
app.on('browser-window-created', (_, window) => {
|
||||
|
||||
@@ -44,6 +44,9 @@ const api = {
|
||||
moveClosed: () => {
|
||||
ipcRenderer.invoke('move-closed')
|
||||
},
|
||||
openDirectoryDialog: () => {
|
||||
return ipcRenderer.invoke('open-directory-dialog')
|
||||
},
|
||||
}
|
||||
|
||||
if (process.contextIsolated) {
|
||||
|
||||
31
src/renderer/src/components/Btn.vue
Normal file
31
src/renderer/src/components/Btn.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<component :is="tag" class="btn">
|
||||
<svg-btn-outline />
|
||||
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SvgBtnOutline from '@/components/svg/BtnOutline.vue'
|
||||
|
||||
const props = defineProps({
|
||||
tag: {
|
||||
type: String,
|
||||
default: 'button',
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.btn {
|
||||
text-transform: uppercase;
|
||||
padding: 5px 16px 6px;
|
||||
color: var(--grey-100);
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
36
src/renderer/src/components/DeleteMenu.vue
Normal file
36
src/renderer/src/components/DeleteMenu.vue
Normal file
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<div class="delete-menu">
|
||||
<button
|
||||
:class="['delete-button', { active: model }]"
|
||||
@click="model = true"
|
||||
>
|
||||
Delete Items
|
||||
</button>
|
||||
|
||||
<button v-if="model" class="close-button" @click="model = false">
|
||||
X Close
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const model = defineModel()
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.delete-menu {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.delete-button {
|
||||
color: var(--grey-100);
|
||||
|
||||
&:hover,
|
||||
&.active {
|
||||
color: var(--red);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<transition name="menu">
|
||||
<div v-if="menuOpen" class="menu" ref="container">
|
||||
<Nav />
|
||||
<div
|
||||
v-if="menuOpen || lockOpen"
|
||||
:class="['menu', { locked: lockOpen }]"
|
||||
ref="container"
|
||||
>
|
||||
<Nav v-if="!lockOpen" />
|
||||
|
||||
<div class="menu-wrap layout-block">
|
||||
<new-note class="menu-item" @noteOpened="closeMenu" />
|
||||
@@ -32,6 +36,10 @@ import useMenu from '@/composables/useMenu'
|
||||
import { useRoute } from 'vue-router'
|
||||
import useExport from '@/composables/useExport'
|
||||
|
||||
const props = defineProps({
|
||||
lockOpen: { type: Boolean, default: () => false },
|
||||
})
|
||||
|
||||
const container = ref()
|
||||
|
||||
const { menuOpen, closeMenu } = useMenu()
|
||||
@@ -85,6 +93,10 @@ const handleExport = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
&.locked .menu-wrap {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
&.menu-enter-active,
|
||||
&.menu-leave-active {
|
||||
transition: transform 300ms var(--ease-out-expo);
|
||||
|
||||
51
src/renderer/src/components/Modal.vue
Normal file
51
src/renderer/src/components/Modal.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="modal theme-dark">
|
||||
<div class="modal-container" ref="container">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onClickOutside } from '@vueuse/core'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const container = ref(null)
|
||||
|
||||
onClickOutside(container, () => {
|
||||
emit('close')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.modal-container {
|
||||
background: var(--theme-bg);
|
||||
color: var(--theme-fg);
|
||||
border: 1px solid var(--grey-100);
|
||||
border-radius: 16px;
|
||||
padding: 27px 21px;
|
||||
text-align: center;
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
margin-top: 26px;
|
||||
|
||||
.btn {
|
||||
min-width: 80px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -56,7 +56,11 @@ watch(open, async () => {
|
||||
<style lang="scss">
|
||||
.move-menu {
|
||||
width: 50vw;
|
||||
height: 100%;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
overflow-y: auto;
|
||||
padding-bottom: 20px;
|
||||
border-left: 1px solid var(--grey-100);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -21,7 +21,7 @@ const onClick = async () => {
|
||||
},
|
||||
'',
|
||||
)
|
||||
openNote(note.id)
|
||||
await openNote(note.id)
|
||||
emit('noteOpened')
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,76 @@
|
||||
<template>
|
||||
<div :class="['note-row', { 'move-active': moveActive }]">
|
||||
<span class="date">{{ formatDate(note.updatedAt) }}</span>
|
||||
<div
|
||||
:class="[
|
||||
'note-row',
|
||||
{ 'move-active': moveActive, 'delete-active': deleteActive },
|
||||
]"
|
||||
>
|
||||
<button
|
||||
v-if="deleteActive"
|
||||
class="delete"
|
||||
@click="deleteModalOpen = true"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
<span v-else class="date">{{ formatDate(note.updatedAt) }}</span>
|
||||
|
||||
<div class="title-actions">
|
||||
<button class="title bold" @click="openNote(note.id)">
|
||||
<button
|
||||
class="title bold"
|
||||
@click="!deleteActive && openNote(note.id)"
|
||||
>
|
||||
{{ note.title }}
|
||||
</button>
|
||||
|
||||
<button class="action bold" @click="openNote(note.id)">
|
||||
<button
|
||||
class="action bold"
|
||||
@click="!deleteActive && openNote(note.id)"
|
||||
>
|
||||
(open)
|
||||
</button>
|
||||
<button class="action bold move" @click="onMoveOpened">
|
||||
(move)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<teleport to="body">
|
||||
<modal v-if="deleteModalOpen" @close="deleteModalOpen = false">
|
||||
<p>Are you sure?</p>
|
||||
|
||||
<div class="btn-row">
|
||||
<btn @click="onDelete">Yes</btn>
|
||||
<btn @click="deleteModalOpen = false">No</btn>
|
||||
</div>
|
||||
</modal>
|
||||
</teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import useOpenNote from '@/composables/useOpenNote'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { computed } from 'vue'
|
||||
import useNotes from '@/composables/useNotes'
|
||||
import Modal from '@/components/Modal.vue'
|
||||
import Btn from '@/components/Btn.vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { format } from 'fecha'
|
||||
|
||||
const props = defineProps({ note: Object })
|
||||
const props = defineProps({ note: Object, deleteActive: Boolean })
|
||||
|
||||
const deleteModalOpen = ref(false)
|
||||
|
||||
const { openNote } = useOpenNote()
|
||||
const { deleteNote } = useNotes()
|
||||
|
||||
const formatDate = (date) => {
|
||||
const d = new Date(date)
|
||||
return format(d, 'MM/DD/YYYY')
|
||||
}
|
||||
|
||||
const onDelete = async () => {
|
||||
await deleteNote(props.note.id)
|
||||
}
|
||||
|
||||
// Moving
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -72,14 +112,32 @@ const moveActive = computed(() => route.query.move === props.note.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
&:hover,
|
||||
&.move-active {
|
||||
color: var(--theme-accent);
|
||||
|
||||
.title-actions .action {
|
||||
opacity: 1;
|
||||
&.delete-active {
|
||||
align-items: flex-start;
|
||||
|
||||
.title,
|
||||
.action {
|
||||
cursor: default;
|
||||
}
|
||||
.delete {
|
||||
cursor: pointer;
|
||||
}
|
||||
&:hover {
|
||||
color: var(--red);
|
||||
}
|
||||
}
|
||||
&:not(.delete-active) {
|
||||
&:hover,
|
||||
&.move-active {
|
||||
color: var(--theme-accent);
|
||||
|
||||
.title-actions .action {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.move-active {
|
||||
.title-actions .move {
|
||||
color: var(--theme-accent);
|
||||
|
||||
@@ -15,6 +15,7 @@ import SvgSpinner from '@/components/svg/Spinner.vue'
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
pointer-events: none;
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
ref="input"
|
||||
@input="emit('input', model.value)"
|
||||
/>
|
||||
|
||||
<svg-btn-outline />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SvgBtnOutline from '@/components/svg/BtnOutline.vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -38,37 +41,10 @@ defineExpose({
|
||||
position: relative;
|
||||
padding: 5px 15px 6px;
|
||||
background: var(--theme-bg);
|
||||
--clip-start: 16px;
|
||||
clip-path: polygon(
|
||||
var(--clip-start) 1px,
|
||||
calc(100% - var(--clip-start)) 1px,
|
||||
calc(100% - 1.5px) 50%,
|
||||
calc(100% - var(--clip-start)) calc(100% - 1px),
|
||||
var(--clip-start) calc(100% - 1px),
|
||||
1.5px 50%
|
||||
);
|
||||
|
||||
&::placeholder {
|
||||
color: var(--grey-100);
|
||||
}
|
||||
}
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--theme-fg);
|
||||
--clip-start: 15px;
|
||||
clip-path: polygon(
|
||||
var(--clip-start) 0,
|
||||
calc(100% - var(--clip-start)) 0,
|
||||
100% 50%,
|
||||
calc(100% - var(--clip-start)) 100%,
|
||||
var(--clip-start) 100%,
|
||||
0% 50%
|
||||
);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
67
src/renderer/src/components/preferences/BooleanInput.vue
Normal file
67
src/renderer/src/components/preferences/BooleanInput.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="preferences-boolean-input">
|
||||
<label :for="key">
|
||||
{{ label }}
|
||||
</label>
|
||||
|
||||
<button
|
||||
:class="['toggle-container', { active: model === 'true' }]"
|
||||
@click="onToggleClick"
|
||||
>
|
||||
<div class="toggle-button" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
label: String,
|
||||
key: String,
|
||||
required: Boolean,
|
||||
default: String,
|
||||
})
|
||||
|
||||
const model = defineModel()
|
||||
|
||||
const onToggleClick = () => {
|
||||
if (model.value === 'true') {
|
||||
model.value = 'false'
|
||||
} else {
|
||||
model.value = 'true'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.preferences-boolean-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.toggle-container {
|
||||
width: 26px;
|
||||
height: 15px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--theme-fg);
|
||||
position: relative;
|
||||
|
||||
.toggle-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--theme-fg);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--grey-100);
|
||||
|
||||
.toggle-button {
|
||||
transform: translateX(11px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,40 +1,68 @@
|
||||
<template>
|
||||
<div class="preferences-directory-input">
|
||||
<input v-model="model" type="text" />
|
||||
<label :for="key"> {{ label }}{{ required ? '*' : '' }} </label>
|
||||
|
||||
<button @click="openDirectoryPicker">Browse</button>
|
||||
<div class="input-row">
|
||||
<input
|
||||
v-model="model"
|
||||
:id="key"
|
||||
type="text"
|
||||
:placeholder="default"
|
||||
:required="required"
|
||||
readonly
|
||||
/>
|
||||
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
webkitdirectory
|
||||
style="display: none"
|
||||
@change="handleDirectoryChange"
|
||||
/>
|
||||
<button @click="openDirectoryPicker" type="button">Browse</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
const props = defineProps({
|
||||
label: String,
|
||||
key: String,
|
||||
required: Boolean,
|
||||
default: String,
|
||||
})
|
||||
|
||||
const model = defineModel()
|
||||
const fileInput = ref(null)
|
||||
|
||||
function openDirectoryPicker() {
|
||||
fileInput.value?.click()
|
||||
}
|
||||
|
||||
function handleDirectoryChange(event) {
|
||||
const files = event.target.files
|
||||
if (files.length > 0) {
|
||||
const path = files[0].webkitRelativePath || files[0].path
|
||||
const directoryPath = path.split('/').slice(0, -1).join('/')
|
||||
model.value = directoryPath || files[0].path
|
||||
const openDirectoryPicker = async () => {
|
||||
const path = await window.api.openDirectoryDialog()
|
||||
if (path) {
|
||||
model.value = path
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.preferences-directory-input {
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.input-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
input {
|
||||
flex: 1;
|
||||
border: 1px solid var(--grey-100);
|
||||
border-radius: 0.2em;
|
||||
padding: 0.2em 0.5em;
|
||||
}
|
||||
button {
|
||||
padding: 0.2em 0.5em;
|
||||
background: var(--theme-bg);
|
||||
color: var(--theme-fg);
|
||||
border: 1px solid var(--grey-100);
|
||||
border-radius: 0.2em;
|
||||
|
||||
&:hover {
|
||||
background: var(--theme-fg);
|
||||
color: var(--theme-bg);
|
||||
border-color: var(--theme-fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<preferences-text-input
|
||||
v-model.trim="config.encryptionKey"
|
||||
type="text"
|
||||
type="password"
|
||||
label="Encryption Key"
|
||||
key="encryptionKey"
|
||||
required
|
||||
|
||||
48
src/renderer/src/components/preferences/General.vue
Normal file
48
src/renderer/src/components/preferences/General.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<div v-if="config" class="preferences-general">
|
||||
<h2 class="section-title h1 mono">General</h2>
|
||||
|
||||
<div class="options">
|
||||
<preferences-boolean-input
|
||||
v-model="config.enableBlackletter"
|
||||
label="Enable Blackletter"
|
||||
key="enableBlackletter"
|
||||
/>
|
||||
<preferences-boolean-input
|
||||
v-model="config.openNotesInNewWindow"
|
||||
label="Open Notes in New Window"
|
||||
key="openNotesInNewWindow"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import PreferencesBooleanInput from '@/components/preferences/BooleanInput.vue'
|
||||
import useConfig from '@/composables/useConfig'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { config, ensureConfig } = useConfig()
|
||||
|
||||
onMounted(async () => {
|
||||
await ensureConfig()
|
||||
})
|
||||
|
||||
const validate = async () => {
|
||||
// if (!config.value.encryptionKey) {
|
||||
// throw new Error('Please fill in the encryption key')
|
||||
// }
|
||||
}
|
||||
|
||||
defineExpose({ validate })
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.preferences-general {
|
||||
.options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -38,6 +38,11 @@
|
||||
v-model="config.adapters[plugin.id][field.key]"
|
||||
v-bind="field"
|
||||
/>
|
||||
<boolean-input
|
||||
v-else-if="field.type === 'boolean'"
|
||||
v-model="config.adapters[plugin.id][field.key]"
|
||||
v-bind="field"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,6 +52,7 @@
|
||||
|
||||
<script setup>
|
||||
import DirectoryInput from '@/components/preferences/DirectoryInput.vue'
|
||||
import BooleanInput from '@/components/preferences/BooleanInput.vue'
|
||||
import TextInput from '@/components/preferences/TextInput.vue'
|
||||
import usePlugins from '@/composables/usePlugins'
|
||||
import useConfig from '@/composables/useConfig'
|
||||
@@ -102,11 +108,10 @@ const validate = async () => {
|
||||
}
|
||||
|
||||
// Test connection
|
||||
// const testResult = await testPlugin(plugin.id, adapterConfig)
|
||||
// console.log(testResult)
|
||||
// if (!testResult) {
|
||||
// validationError.value = `Failed to connect to ${plugin.name}`
|
||||
// }
|
||||
const testResult = await testPlugin(plugin.id, adapterConfig)
|
||||
if (!testResult) {
|
||||
throw new Error(`Failed to connect to ${plugin.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
await setActivePlugin(selectedPluginId.value, adapterConfig)
|
||||
@@ -137,6 +142,8 @@ defineExpose({ validate })
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1;
|
||||
|
||||
.description {
|
||||
color: var(--grey-100);
|
||||
margin-top: 6px;
|
||||
@@ -146,7 +153,7 @@ defineExpose({ validate })
|
||||
.config {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,30 @@
|
||||
<div class="preferences-text-input">
|
||||
<label :for="key"> {{ label }}{{ required ? '*' : '' }} </label>
|
||||
|
||||
<input
|
||||
v-model="model"
|
||||
:id="key"
|
||||
:type="type"
|
||||
:placeholder="default"
|
||||
:required="required"
|
||||
/>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
v-model="model"
|
||||
:id="key"
|
||||
:type="isPasswordVisible ? 'text' : type"
|
||||
:placeholder="default"
|
||||
:required="required"
|
||||
/>
|
||||
|
||||
<button
|
||||
v-if="type === 'password'"
|
||||
type="button"
|
||||
class="toggle-password"
|
||||
@click="isPasswordVisible = !isPasswordVisible"
|
||||
>
|
||||
👁️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
label: String,
|
||||
key: String,
|
||||
@@ -22,6 +35,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const model = defineModel()
|
||||
const isPasswordVisible = ref(false)
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -30,11 +44,26 @@ const model = defineModel()
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
input {
|
||||
width: 100%;
|
||||
border: 1px solid var(--grey-100);
|
||||
border-radius: 0.2em;
|
||||
padding: 0.2em 0.5em;
|
||||
padding-right: 2.5em;
|
||||
}
|
||||
.toggle-password {
|
||||
position: absolute;
|
||||
right: 0.5em;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
67
src/renderer/src/components/svg/BtnOutline.vue
Normal file
67
src/renderer/src/components/svg/BtnOutline.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="svg-btn-outline">
|
||||
<svg
|
||||
class="side left"
|
||||
width="16"
|
||||
height="28"
|
||||
viewBox="0 0 16 28"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M15.7207 0.5H14.7207L0.720634 14.8612L14.7207 27.5H15.7207"
|
||||
stroke="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<div class="fill">
|
||||
<div class="borders" />
|
||||
</div>
|
||||
|
||||
<svg
|
||||
class="side right"
|
||||
width="16"
|
||||
height="28"
|
||||
viewBox="0 0 16 28"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M15.7207 0.5H14.7207L0.720634 14.8612L14.7207 27.5H15.7207"
|
||||
stroke="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.svg-btn-outline {
|
||||
grid-template-columns: auto 1fr auto;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
|
||||
.side {
|
||||
height: 100%;
|
||||
|
||||
&.right {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
}
|
||||
.fill {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
|
||||
.borders {
|
||||
position: absolute;
|
||||
inset: 0 -1px;
|
||||
border: solid currentColor;
|
||||
border-width: 1px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,6 +12,7 @@ export default () => {
|
||||
// Change listeners for electron
|
||||
const { setupListeners, broadcastChange, changeCount } = useNoteListeners()
|
||||
setupListeners()
|
||||
getNotesAPI()
|
||||
|
||||
const getDecryptionFailures = async () => {
|
||||
const api = await getNotesAPI()
|
||||
@@ -30,7 +31,8 @@ export default () => {
|
||||
}
|
||||
const loadNote = async (id) => {
|
||||
const api = await getNotesAPI()
|
||||
return api.getNote(id)
|
||||
console.log(api)
|
||||
return await api.getNote(id)
|
||||
}
|
||||
|
||||
// Create
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useEnvironment, ENVIRONMENTS } from './useEnvironment'
|
||||
import useConfig from '@/composables/useConfig'
|
||||
|
||||
export default () => {
|
||||
const router = useRouter()
|
||||
const { config, ensureConfig } = useConfig()
|
||||
|
||||
function openNote(noteId, options = {}) {
|
||||
const { newWindow = true } = options
|
||||
const openNote = async (noteId) => {
|
||||
await ensureConfig()
|
||||
const newWindow =
|
||||
config.value.openNotesInNewWindow === 'true' ? true : false
|
||||
|
||||
const environment = useEnvironment()
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export default async () => {
|
||||
}
|
||||
|
||||
const testPlugin = async (pluginId, config = {}) => {
|
||||
await pluginManager.testPlugin(pluginId, { ...config })
|
||||
return await pluginManager.testPlugin(pluginId, { ...config })
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,6 +5,7 @@ const colors = {
|
||||
green: '#87FF5B',
|
||||
blue: '#5B92FF',
|
||||
purple: '#94079E',
|
||||
red: '#D40202',
|
||||
}
|
||||
|
||||
const themes = {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// z-index
|
||||
.menu {
|
||||
z-index: 20;
|
||||
}
|
||||
.nav {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,15 @@
|
||||
@edited="onCategoryEdited"
|
||||
/>
|
||||
|
||||
<delete-menu v-model="deleteActive" />
|
||||
|
||||
<div class="notes">
|
||||
<note-row v-for="note in notes" :note="note" :key="note.id" />
|
||||
<note-row
|
||||
v-for="note in notes"
|
||||
:note="note"
|
||||
:deleteActive="deleteActive"
|
||||
:key="note.id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<new-note :category="id" />
|
||||
@@ -22,12 +29,14 @@ import useNotes from '@/composables/useNotes'
|
||||
import NoteRow from '@/components/NoteRow.vue'
|
||||
import CategoryRow from '@/components/CategoryRow.vue'
|
||||
import NewNote from '@/components/NewNote.vue'
|
||||
import DeleteMenu from '@/components/DeleteMenu.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const id = route.params?.id
|
||||
const router = useRouter()
|
||||
|
||||
const notes = ref()
|
||||
const deleteActive = ref(false)
|
||||
|
||||
const refreshNotes = async () => {
|
||||
if (id) {
|
||||
@@ -48,7 +57,6 @@ onMounted(async () => {
|
||||
|
||||
if (!categories.value?.length) {
|
||||
await loadCategories()
|
||||
console.log(categories.value)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -75,6 +83,9 @@ main.category {
|
||||
.category-row {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.delete-menu {
|
||||
margin: 10px 0 12px;
|
||||
}
|
||||
.notes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<main v-if="loaded" class="directory layout-block">
|
||||
<main
|
||||
v-if="loaded && (categories?.length || notes?.length)"
|
||||
class="directory layout-block"
|
||||
>
|
||||
<category-row
|
||||
v-for="(category, i) in categories"
|
||||
:index="i"
|
||||
@@ -7,10 +10,19 @@
|
||||
:key="category"
|
||||
/>
|
||||
|
||||
<h2 v-if="notes?.length" class="label">Summarium</h2>
|
||||
<div class="bar">
|
||||
<h2 v-if="notes?.length" class="label">Summarium</h2>
|
||||
|
||||
<delete-menu v-model="deleteActive" />
|
||||
</div>
|
||||
|
||||
<div class="notes">
|
||||
<note-row v-for="note in notes" :note="note" :key="note.id" />
|
||||
<note-row
|
||||
v-for="note in notes"
|
||||
:note="note"
|
||||
:deleteActive="deleteActive"
|
||||
:key="note.id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<new-note />
|
||||
@@ -18,6 +30,10 @@
|
||||
<decryption-warning :failedIds="decryptionFailures" />
|
||||
</main>
|
||||
|
||||
<main v-else-if="loaded">
|
||||
<Menu lockOpen />
|
||||
</main>
|
||||
|
||||
<page-loading v-else />
|
||||
</template>
|
||||
|
||||
@@ -26,10 +42,12 @@ import DecryptionWarning from '@/components/DecryptionWarning.vue'
|
||||
import { onMounted, ref, watchEffect, watch } from 'vue'
|
||||
import CategoryRow from '@/components/CategoryRow.vue'
|
||||
import PageLoading from '@/components/PageLoading.vue'
|
||||
import DeleteMenu from '@/components/DeleteMenu.vue'
|
||||
import NoteRow from '@/components/NoteRow.vue'
|
||||
import useNotes from '@/composables/useNotes'
|
||||
import NewNote from '@/components/NewNote.vue'
|
||||
import { useMagicKeys } from '@vueuse/core'
|
||||
import Menu from '@/components/Menu.vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -43,6 +61,7 @@ const {
|
||||
|
||||
const notes = ref()
|
||||
const loaded = ref(false)
|
||||
const deleteActive = ref(false)
|
||||
|
||||
const refreshNotes = async () => {
|
||||
loaded.value = false
|
||||
@@ -73,10 +92,16 @@ main.directory {
|
||||
padding-top: var(--nav-height);
|
||||
padding-bottom: 60px;
|
||||
|
||||
.label {
|
||||
text-transform: uppercase;
|
||||
.bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 27px;
|
||||
margin: 17px 0 24px;
|
||||
@include p;
|
||||
|
||||
.label {
|
||||
text-transform: uppercase;
|
||||
@include p;
|
||||
}
|
||||
}
|
||||
.notes {
|
||||
display: flex;
|
||||
|
||||
@@ -15,6 +15,7 @@ const renderedContent = md.render(content)
|
||||
<style lang="scss">
|
||||
main.instructions {
|
||||
padding-top: var(--nav-height);
|
||||
padding-bottom: 50px;
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<main class="note layout-block">
|
||||
<main v-if="note" class="note layout-block">
|
||||
<router-link v-if="!hideBack" class="back-link" to="/">
|
||||
<- Back
|
||||
</router-link>
|
||||
|
||||
<note-download :title="editorRef?.title" :editor="editorRef?.editor" />
|
||||
|
||||
<note-find
|
||||
@@ -14,17 +18,24 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watchEffect } from 'vue'
|
||||
import { computed, ref, watchEffect } from 'vue'
|
||||
import { useMagicKeys } from '@vueuse/core'
|
||||
import { useRoute } from 'vue-router'
|
||||
import useNotes from '@/composables/useNotes'
|
||||
import NoteEditor from '@/components/note/Editor.vue'
|
||||
import NoteFind from '@/components/note/Find.vue'
|
||||
import NoteDownload from '@/components/note/Download.vue'
|
||||
import useConfig from '@/composables/useConfig'
|
||||
import { useEnvironment } from '@/composables/useEnvironment'
|
||||
|
||||
const route = useRoute()
|
||||
const id = route.params.id
|
||||
|
||||
const { config, ensureConfig } = useConfig()
|
||||
await ensureConfig()
|
||||
|
||||
const environment = useEnvironment()
|
||||
|
||||
const { loadNote } = useNotes()
|
||||
const note = await loadNote(id)
|
||||
|
||||
@@ -52,6 +63,12 @@ const onTargetClick = () => {
|
||||
editorRef.value.editor.getText().length + 1,
|
||||
)
|
||||
}
|
||||
|
||||
const hideBack = computed(
|
||||
() =>
|
||||
environment === 'electron' &&
|
||||
config.value.openNotesInNewWindow === 'true',
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -61,6 +78,11 @@ main.note {
|
||||
grid-template-rows: auto auto 1fr;
|
||||
display: grid;
|
||||
|
||||
.back-link {
|
||||
color: var(--grey-100);
|
||||
margin-right: auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.click-target {
|
||||
cursor: pointer;
|
||||
min-height: 1em;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<h1 class="title">Preferences</h1>
|
||||
|
||||
<div class="sections">
|
||||
<preferences-general />
|
||||
|
||||
<preferences-encryption ref="encryption" />
|
||||
|
||||
<suspense @resolve="ready = true">
|
||||
@@ -22,6 +24,7 @@
|
||||
|
||||
<script setup>
|
||||
import PreferencesEncryption from '@/components/preferences/Encryption.vue'
|
||||
import PreferencesGeneral from '@/components/preferences/General.vue'
|
||||
import PreferencesStorage from '@/components/preferences/Storage.vue'
|
||||
import SvgSpinner from '@/components/svg/Spinner.vue'
|
||||
import { ref } from 'vue'
|
||||
@@ -61,6 +64,7 @@ const save = async () => {
|
||||
.preferences {
|
||||
padding-top: var(--nav-height);
|
||||
padding-bottom: 60px;
|
||||
position: relative;
|
||||
|
||||
.title {
|
||||
margin-bottom: 25px;
|
||||
@@ -69,14 +73,20 @@ const save = async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30px;
|
||||
max-width: 500px;
|
||||
}
|
||||
.section-title {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
margin-top: 16px;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #ba3632;
|
||||
padding: 5px var(--layout-margin);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
|
||||
Reference in New Issue
Block a user