Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add logic to duplicate a note

thecodrr167baece191b
diff --git a/packages/core/models/note.js b/packages/core/models/note.js
index d0251ed15..b7dc7bc63 100644
--- a/packages/core/models/note.js
+++ b/packages/core/models/note.js
@@ -101,6 +101,26 @@ export default class Note {
return content.data;
}
+ async duplicate() {
+ const content = await this._db.content.raw(this._note.contentId);
+ return await this._db.notes.add({
+ ...this._note,
+ id: undefined,
+ content: {
+ type: content.type,
+ data: content.data,
+ },
+ readonly: false,
+ favorite: false,
+ pinned: false,
+ contentId: null,
+ title: this._note.title + " (Copy)",
+ dateEdited: null,
+ dateCreated: null,
+ dateModified: null,
+ });
+ }
+
async color(color) {
if (!(await checkIsUserPremium(CHECK_IDS.noteColor))) return;
await this.uncolor();
diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json
index a97d6e636..b6564302d 100644
--- a/packages/core/package-lock.json
+++ b/packages/core/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "notes-core",
- "version": "6.16.2",
+ "version": "6.16.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "notes-core",
- "version": "6.16.2",
+ "version": "6.16.4",
"dependencies": {
"@stablelib/blake2s": "^1.0.1",
"async-mutex": "^0.3.2",