joplin-plugin-explorer 1.1.3 → 1.1.4
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/publish/index.js +88 -16
- package/publish/manifest.json +1 -1
- package/publish/plugin.jpl +0 -0
- package/publish/webview/panel.js +2 -24
package/package.json
CHANGED
package/publish/index.js
CHANGED
|
@@ -254,6 +254,59 @@ joplin.plugins.register({
|
|
|
254
254
|
await joplin.views.panels.setHtml(panel, '<div id="notes-in-list-root"><p style="padding:12px;">' + t.loading + '</p></div>');
|
|
255
255
|
await joplin.views.panels.show(panel, true);
|
|
256
256
|
|
|
257
|
+
// Native dialogs
|
|
258
|
+
var inputDialog = await joplin.views.dialogs.create('explorerInputDialog');
|
|
259
|
+
var confirmDialog = await joplin.views.dialogs.create('explorerConfirmDialog');
|
|
260
|
+
var infoDialog = await joplin.views.dialogs.create('explorerInfoDialog');
|
|
261
|
+
|
|
262
|
+
async function showNativeConfirm(message) {
|
|
263
|
+
await joplin.views.dialogs.setHtml(confirmDialog,
|
|
264
|
+
'<div style="padding:10px;min-width:280px;">'
|
|
265
|
+
+ '<div style="font-size:13px;">' + escapeHtml(message) + '</div>'
|
|
266
|
+
+ '</div>'
|
|
267
|
+
);
|
|
268
|
+
await joplin.views.dialogs.setButtons(confirmDialog, [
|
|
269
|
+
{ id: 'ok', title: 'OK' },
|
|
270
|
+
{ id: 'cancel', title: t.cancel || 'Cancel' },
|
|
271
|
+
]);
|
|
272
|
+
var result = await joplin.views.dialogs.open(confirmDialog);
|
|
273
|
+
return result.id === 'ok';
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function showNativeInfo(title, body) {
|
|
277
|
+
await joplin.views.dialogs.setHtml(infoDialog,
|
|
278
|
+
'<div style="padding:10px;min-width:320px;">'
|
|
279
|
+
+ '<div style="font-size:14px;font-weight:bold;margin-bottom:10px;">' + escapeHtml(title) + '</div>'
|
|
280
|
+
+ '<div style="font-size:12px;line-height:1.8;white-space:pre-wrap;">' + escapeHtml(body) + '</div>'
|
|
281
|
+
+ '</div>'
|
|
282
|
+
);
|
|
283
|
+
await joplin.views.dialogs.setButtons(infoDialog, [
|
|
284
|
+
{ id: 'ok', title: 'OK' },
|
|
285
|
+
]);
|
|
286
|
+
await joplin.views.dialogs.open(infoDialog);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async function showNativeInput(label, defaultValue) {
|
|
290
|
+
await joplin.views.dialogs.setHtml(inputDialog,
|
|
291
|
+
'<div style="padding:10px;min-width:300px;">'
|
|
292
|
+
+ '<div style="margin-bottom:8px;font-size:13px;">' + escapeHtml(label) + '</div>'
|
|
293
|
+
+ '<form name="inputForm">'
|
|
294
|
+
+ '<input name="value" type="text" value="' + escapeHtml(defaultValue || '') + '" '
|
|
295
|
+
+ 'style="width:100%;box-sizing:border-box;padding:6px 8px;font-size:13px;" />'
|
|
296
|
+
+ '</form>'
|
|
297
|
+
+ '</div>'
|
|
298
|
+
);
|
|
299
|
+
await joplin.views.dialogs.setButtons(inputDialog, [
|
|
300
|
+
{ id: 'ok', title: 'OK' },
|
|
301
|
+
{ id: 'cancel', title: t.cancel || 'Cancel' },
|
|
302
|
+
]);
|
|
303
|
+
var result = await joplin.views.dialogs.open(inputDialog);
|
|
304
|
+
if (result.id === 'ok' && result.formData && result.formData.inputForm) {
|
|
305
|
+
return result.formData.inputForm.value || null;
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
|
|
257
310
|
var selectedNoteId = '';
|
|
258
311
|
var collapsedFolders = {};
|
|
259
312
|
var currentSort = 'updated_desc';
|
|
@@ -479,13 +532,23 @@ joplin.plugins.register({
|
|
|
479
532
|
expandToFolder(id);
|
|
480
533
|
break;
|
|
481
534
|
case 'newSubNotebook':
|
|
482
|
-
|
|
535
|
+
var subName = await showNativeInput(t.newNotebook, '');
|
|
536
|
+
if (subName && subName.trim()) {
|
|
537
|
+
await joplin.data.post(['folders'], null, { title: subName.trim(), parent_id: id });
|
|
538
|
+
}
|
|
483
539
|
break;
|
|
484
540
|
case 'deleteFolder':
|
|
485
|
-
await joplin.data.
|
|
541
|
+
var folderInfo = await joplin.data.get(['folders', id], { fields: ['title'] });
|
|
542
|
+
if (await showNativeConfirm(t.confirmDeleteFolder + '\n\n' + folderInfo.title)) {
|
|
543
|
+
await joplin.data.delete(['folders', id]);
|
|
544
|
+
}
|
|
486
545
|
break;
|
|
487
546
|
case 'renameFolder':
|
|
488
|
-
|
|
547
|
+
var folderData = await joplin.data.get(['folders', id], { fields: ['title'] });
|
|
548
|
+
var newFolderName = await showNativeInput(t.promptRename, folderData.title);
|
|
549
|
+
if (newFolderName && newFolderName.trim()) {
|
|
550
|
+
await joplin.data.put(['folders', id], null, { title: newFolderName.trim() });
|
|
551
|
+
}
|
|
489
552
|
break;
|
|
490
553
|
case 'exportFolder':
|
|
491
554
|
try { await joplin.commands.execute('exportFolders', [id]); } catch(e) {}
|
|
@@ -533,7 +596,11 @@ joplin.plugins.register({
|
|
|
533
596
|
}
|
|
534
597
|
break;
|
|
535
598
|
case 'renameNote':
|
|
536
|
-
|
|
599
|
+
var noteData = await joplin.data.get(['notes', id], { fields: ['title'] });
|
|
600
|
+
var newNoteName = await showNativeInput(t.promptRename, noteData.title);
|
|
601
|
+
if (newNoteName && newNoteName.trim()) {
|
|
602
|
+
await joplin.data.put(['notes', id], null, { title: newNoteName.trim() });
|
|
603
|
+
}
|
|
537
604
|
break;
|
|
538
605
|
case 'moveNote':
|
|
539
606
|
if (msg.targetFolderName) {
|
|
@@ -549,21 +616,26 @@ joplin.plugins.register({
|
|
|
549
616
|
}
|
|
550
617
|
break;
|
|
551
618
|
case 'noteInfo':
|
|
552
|
-
var info = await joplin.data.get(['notes', id], { fields: ['id', 'title', 'created_time', 'updated_time', 'is_todo', 'parent_id'] });
|
|
553
|
-
var
|
|
619
|
+
var info = await joplin.data.get(['notes', id], { fields: ['id', 'title', 'created_time', 'updated_time', 'is_todo', 'parent_id', 'body'] });
|
|
620
|
+
var pTitle = '';
|
|
554
621
|
for (var i = 0; i < allFoldersCache.length; i++) {
|
|
555
|
-
if (allFoldersCache[i].id === info.parent_id) {
|
|
622
|
+
if (allFoldersCache[i].id === info.parent_id) { pTitle = allFoldersCache[i].title; break; }
|
|
556
623
|
}
|
|
557
|
-
var
|
|
558
|
-
|
|
559
|
-
+ '\
|
|
560
|
-
+ '\
|
|
561
|
-
+ '\
|
|
562
|
-
+ '\
|
|
563
|
-
|
|
564
|
-
|
|
624
|
+
var bodyLen = (info.body || '').length;
|
|
625
|
+
var infoBody = 'ID: ' + info.id
|
|
626
|
+
+ '\n' + (t.ctxRenameNote || 'Title') + ': ' + info.title
|
|
627
|
+
+ '\n' + (t.newNotebook || 'Notebook') + ': ' + pTitle
|
|
628
|
+
+ '\n' + (t.sortUpdatedDesc ? t.sortUpdatedDesc.replace(/[↓↑\u2193\u2191]\s*/, '') : 'Created') + ': ' + new Date(info.created_time).toLocaleString()
|
|
629
|
+
+ '\n' + (t.sortUpdatedAsc ? t.sortUpdatedAsc.replace(/[↓↑\u2193\u2191]\s*/, '') : 'Updated') + ': ' + new Date(info.updated_time).toLocaleString()
|
|
630
|
+
+ '\nType: ' + (info.is_todo ? 'To-do' : 'Note')
|
|
631
|
+
+ '\n' + 'Size: ' + bodyLen + ' chars';
|
|
632
|
+
await showNativeInfo(info.title, infoBody);
|
|
633
|
+
break;
|
|
565
634
|
case 'deleteNote':
|
|
566
|
-
await joplin.data.
|
|
635
|
+
var noteForDel = await joplin.data.get(['notes', id], { fields: ['title'] });
|
|
636
|
+
if (await showNativeConfirm(t.confirmDeleteNote + '\n\n' + noteForDel.title)) {
|
|
637
|
+
await joplin.data.delete(['notes', id]);
|
|
638
|
+
}
|
|
567
639
|
break;
|
|
568
640
|
}
|
|
569
641
|
}
|
package/publish/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": 1,
|
|
3
3
|
"id": "com.github.joplin-explorer",
|
|
4
4
|
"app_min_version": "2.6.0",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.4",
|
|
6
6
|
"name": "Joplin Explorer",
|
|
7
7
|
"description": "A unified sidebar that displays notebooks and notes together in a single tree view",
|
|
8
8
|
"author": "lim0513",
|
package/publish/plugin.jpl
CHANGED
|
Binary file
|
package/publish/webview/panel.js
CHANGED
|
@@ -173,30 +173,8 @@ document.addEventListener('click', function(e) {
|
|
|
173
173
|
var id = ctxItem.dataset.id;
|
|
174
174
|
var itemType = ctxItem.dataset.type;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
showInlineInput(T('promptRename'), currentTitle, function(newTitle) {
|
|
179
|
-
if (newTitle !== null && newTitle.trim() !== '') {
|
|
180
|
-
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType, newTitle: newTitle.trim() });
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
} else if (action === 'deleteFolder') {
|
|
184
|
-
if (confirm(T('confirmDeleteFolder'))) {
|
|
185
|
-
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType });
|
|
186
|
-
}
|
|
187
|
-
} else if (action === 'deleteNote') {
|
|
188
|
-
if (confirm(T('confirmDeleteNote'))) {
|
|
189
|
-
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType });
|
|
190
|
-
}
|
|
191
|
-
} else if (action === 'moveNote') {
|
|
192
|
-
showInlineInput(T('promptMoveNote'), '', function(folderName) {
|
|
193
|
-
if (folderName !== null && folderName.trim() !== '') {
|
|
194
|
-
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType, targetFolderName: folderName.trim() });
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
} else {
|
|
198
|
-
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType });
|
|
199
|
-
}
|
|
176
|
+
// All dialogs handled by backend using native Joplin dialogs
|
|
177
|
+
postMsg({ name: 'contextMenu', action: action, id: id, itemType: itemType });
|
|
200
178
|
|
|
201
179
|
var menu = document.getElementById('ctx-menu');
|
|
202
180
|
if (menu) menu.remove();
|