saveinme 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/editor.js +76 -27
package/package.json
CHANGED
package/src/editor.js
CHANGED
|
@@ -49,30 +49,55 @@ export async function saveFromClipboard(titleArg, notebookOverride) {
|
|
|
49
49
|
}
|
|
50
50
|
console.log(chalk.dim(' └──────────────────────────────────────────────────\n'));
|
|
51
51
|
|
|
52
|
-
// Resolve title
|
|
53
|
-
const title = (titleArg && titleArg.trim()) || `Clipboard Note - ${getTimestamp()}`;
|
|
54
|
-
const existingNote = getNoteByTitle(title);
|
|
55
|
-
|
|
56
52
|
// Resolve notebook target
|
|
57
53
|
const defaultNotebook = getDefaultNotebook();
|
|
58
|
-
const
|
|
54
|
+
const tempCategory = (notebookOverride !== null) ? notebookOverride.trim() : defaultNotebook;
|
|
55
|
+
|
|
56
|
+
// Resolve title
|
|
57
|
+
let title = (titleArg && titleArg.trim()) || '';
|
|
58
|
+
let isAppend = false;
|
|
59
|
+
|
|
60
|
+
if (!title) {
|
|
61
|
+
if (tempCategory) {
|
|
62
|
+
title = tempCategory;
|
|
63
|
+
isAppend = true;
|
|
64
|
+
} else {
|
|
65
|
+
title = `Clipboard Note - ${getTimestamp()}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const existingNoteResolve = getNoteByTitle(title);
|
|
70
|
+
const category = (notebookOverride !== null) ? notebookOverride.trim() : (existingNoteResolve?.category ?? defaultNotebook);
|
|
71
|
+
let finalContent = clipboardContent;
|
|
72
|
+
|
|
73
|
+
if (existingNoteResolve && isAppend) {
|
|
74
|
+
finalContent = existingNoteResolve.content + '\n' + clipboardContent;
|
|
75
|
+
}
|
|
59
76
|
|
|
60
77
|
saveNote({
|
|
61
|
-
id:
|
|
78
|
+
id: existingNoteResolve?.id, // updates if title matches exactly
|
|
62
79
|
title: title.trim(),
|
|
63
|
-
content:
|
|
80
|
+
content: finalContent,
|
|
64
81
|
category: category.trim(),
|
|
65
|
-
tags:
|
|
66
|
-
priority:
|
|
67
|
-
pinned:
|
|
82
|
+
tags: existingNoteResolve?.tags ?? [],
|
|
83
|
+
priority: existingNoteResolve?.priority ?? 'medium',
|
|
84
|
+
pinned: existingNoteResolve?.pinned ?? false,
|
|
68
85
|
});
|
|
69
86
|
|
|
70
87
|
const wc = clipboardContent.split(/\s+/).filter(Boolean).length;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
88
|
+
if (existingNoteResolve && isAppend) {
|
|
89
|
+
showSuccess(
|
|
90
|
+
`Appended clipboard text to note "${title.trim()}"` +
|
|
91
|
+
(category ? ` in notebook "${category.trim()}"` : '') +
|
|
92
|
+
chalk.dim(` (+${wc} words)`)
|
|
93
|
+
);
|
|
94
|
+
} else {
|
|
95
|
+
showSuccess(
|
|
96
|
+
`Clipboard note "${title.trim()}" saved!` +
|
|
97
|
+
(category ? ` [Notebook: ${category.trim()}]` : '') +
|
|
98
|
+
chalk.dim(` (${wc} words)`)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
76
101
|
}
|
|
77
102
|
|
|
78
103
|
// ─── Save piped stdin directly ────────────────────────────────────────────────
|
|
@@ -96,25 +121,49 @@ export async function savePipedInput(inputContent, titleArg, notebookOverride) {
|
|
|
96
121
|
const category = (notebookOverride !== null) ? notebookOverride.trim() : defaultNotebook;
|
|
97
122
|
|
|
98
123
|
// Resolve title
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
let title = (titleArg && titleArg.trim()) || '';
|
|
125
|
+
let isAppend = false;
|
|
126
|
+
|
|
127
|
+
if (!title) {
|
|
128
|
+
if (category) {
|
|
129
|
+
title = category;
|
|
130
|
+
isAppend = true;
|
|
131
|
+
} else {
|
|
132
|
+
title = `Piped Note - ${getTimestamp()}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const existingNoteResolve = getNoteByTitle(title);
|
|
137
|
+
let finalContent = content;
|
|
138
|
+
|
|
139
|
+
if (existingNoteResolve && isAppend) {
|
|
140
|
+
finalContent = existingNoteResolve.content + '\n' + content;
|
|
141
|
+
}
|
|
101
142
|
|
|
102
143
|
saveNote({
|
|
103
|
-
id:
|
|
144
|
+
id: existingNoteResolve?.id,
|
|
104
145
|
title: title.trim(),
|
|
105
|
-
content:
|
|
146
|
+
content: finalContent,
|
|
106
147
|
category: category,
|
|
107
|
-
tags:
|
|
108
|
-
priority:
|
|
109
|
-
pinned:
|
|
148
|
+
tags: existingNoteResolve?.tags ?? [],
|
|
149
|
+
priority: existingNoteResolve?.priority ?? 'medium',
|
|
150
|
+
pinned: existingNoteResolve?.pinned ?? false,
|
|
110
151
|
});
|
|
111
152
|
|
|
112
153
|
const wc = content.split(/\s+/).filter(Boolean).length;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
154
|
+
if (existingNoteResolve && isAppend) {
|
|
155
|
+
showSuccess(
|
|
156
|
+
`Appended piped text to note "${title.trim()}"` +
|
|
157
|
+
(category ? ` in notebook "${category}"` : '') +
|
|
158
|
+
chalk.dim(` (+${wc} words)`)
|
|
159
|
+
);
|
|
160
|
+
} else {
|
|
161
|
+
showSuccess(
|
|
162
|
+
`Saved piped note "${title.trim()}"` +
|
|
163
|
+
(category ? ` to notebook "${category}"` : '') +
|
|
164
|
+
chalk.dim(` (${wc} words)`)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
118
167
|
}
|
|
119
168
|
|
|
120
169
|
// ─── Main editor entry point ──────────────────────────────────────────────────
|