index.js000644 0000020276 14562173740007371 0ustar00000000 000000 !function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";var n=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(i,l){function u(e){try{a(n.next(e))}catch(e){l(e)}}function d(e){try{a(n.throw(e))}catch(e){l(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(u,d)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=o(1),l=o(2);function u(e){return e?e.split(","):[]}function d(e,t){return n(this,void 0,void 0,(function*(){let o,n=[],l=1;do{o=yield i.default.data.get(e,Object.assign(Object.assign({},t),{page:l++,limit:100})),n.push(...o.items)}while(o.has_more);return n}))}i.default.plugins.register({onStart:function(){return n(this,void 0,void 0,(function*(){yield i.default.settings.registerSection("openRandomNoteSection",{label:"Random Note Reloaded",iconName:"fas fa-random"}),yield i.default.settings.registerSettings({showToolBarIcon:{value:!0,type:l.SettingItemType.Bool,section:"openRandomNoteSection",label:"Show Tool Bar Button",public:!0,description:"Alternative to using Hotkeys to open random notes"},useCustomHotkey:{value:!1,type:l.SettingItemType.Bool,section:"openRandomNoteSection",label:"Use Custom Hotkey",public:!0,description:"Enter custom hotkey after selecting this option"},customHotkey:{value:"Ctrl+Alt+R",type:l.SettingItemType.String,section:"openRandomNoteSection",public:!0,description:"Separate your keys with a +",label:"Enter Custom Hotkey"},rootNotebooks:{value:"",type:l.SettingItemType.String,section:"openRandomNoteSection",public:!0,description:"Consider notes from these notebooks only",label:"Root Notebooks"},excludedNotes:{value:"",type:l.SettingItemType.String,section:"openRandomNoteSection",public:!0,description:"Comma separated list of note IDs",label:"Excluded Notes"},excludedNotebooks:{value:"",type:l.SettingItemType.String,section:"openRandomNoteSection",public:!0,description:"Comma separated list of notebook IDs",label:"Excluded Notebooks"},excludeCompletedTodos:{value:"",type:l.SettingItemType.Bool,section:"openRandomNoteSection",public:!0,label:"Exclude completed todos"}}),yield i.default.commands.register({name:"openRandomNote",label:"Open a random note",iconName:"fas fa-random",execute:()=>n(this,void 0,void 0,(function*(){const e=u(yield i.default.settings.value("rootNotebooks"));let t=[];if(0!==e.length){console.debug("[Random Note] Get notes from root notebooks: "+e);for(const o of e){const e=yield d(["folders",o,"notes"],{fields:["id","is_todo","todo_completed"]});t.push(...e)}}else console.debug("[Random Note] Get all notes"),t=yield d(["notes"],{fields:["id","is_todo","todo_completed"]});if(console.debug("[Random Note] Total notes: "+t.length),!t.length)return;t=(yield i.default.settings.value("excludeCompletedTodos"))?t.filter(e=>!(e.is_todo&&e.todo_completed)):t,console.debug("[Random Note] Notes after todo filter: "+t.length);const o=yield i.default.workspace.selectedNote(),n=u(yield i.default.settings.value("excludedNotes")),l=u(yield i.default.settings.value("excludedNotebooks")),a=[];for(const e of l){const t=yield d(["folders",e,"notes"],{fields:["id"]});a.push(...t.map(e=>e.id))}const s=Array.from(new Set([o.id].concat(n,a))),r=t.filter(e=>!s.includes(e.id));console.debug("[Random Note] Notes after manual filter: "+r.length);const c=Math.floor(Math.random()*r.length);console.debug("[Random Note] Random index: "+c),yield i.default.commands.execute("openNote",r[c].id)}))}),yield i.default.commands.register({name:"noteContextMenuExclude",label:"Random Note: Exclude",execute:e=>n(this,void 0,void 0,(function*(){console.debug("[Random Note] Excluding notes: "+e);const t=u(yield i.default.settings.value("excludedNotes"));t.push(...e);const o=Array.from(new Set(t));yield i.default.settings.setValue("excludedNotes",o.join(","))}))}),yield i.default.commands.register({name:"notebookContextMenuExclude",label:"Random Note: Exclude",execute:e=>n(this,void 0,void 0,(function*(){console.debug("[Random Note] Excluding notebook: "+e);const t=u(yield i.default.settings.value("excludedNotebooks"));t.push(e);const o=Array.from(new Set(t));yield i.default.settings.setValue("excludedNotebooks",o.join(","))}))}),yield i.default.commands.register({name:"notebookContextMenuAddRoot",label:"Random Note: Add root notebook",execute:e=>n(this,void 0,void 0,(function*(){console.debug("[Random Note] Add root notebook: "+e);const t=u(yield i.default.settings.value("rootNotebooks"));t.push(e);const o=Array.from(new Set(t));yield i.default.settings.setValue("rootNotebooks",o.join(","))}))});const e=yield i.default.settings.value("useCustomHotkey"),t=yield i.default.settings.value("customHotkey");let o;!1===e?o="Ctrl+Alt+R":t.length>0?o=function(e){if(""!=e.trim()){const t=/\s+/g;let o;return o=e.replace(t,"").replace(/\+/g," ").split(" ").map(e=>e[0].toUpperCase()+e.substr(1)).join("+"),o}}(t):(yield i.default.settings.setValue("customHotkey","Ctrl+Alt+R"),o="Ctrl+Alt+R"),yield i.default.views.menuItems.create("openRandomNoteMenu","openRandomNote",l.MenuItemLocation.EditorContextMenu,{accelerator:o}),yield i.default.views.menus.create("myMenu","Open Random Note",[{commandName:"openRandomNote",accelerator:o}]);(yield i.default.settings.value("showToolBarIcon"))&&(yield i.default.views.toolbarButtons.create("openRandomNoteMenuViaToolbar","openRandomNote",l.ToolbarButtonLocation.EditorToolbar)),yield i.default.views.menuItems.create("noteContextMenuItem1","noteContextMenuExclude",l.MenuItemLocation.NoteListContextMenu),yield i.default.views.menuItems.create("notebookContextMenuItem1","notebookContextMenuExclude",l.MenuItemLocation.FolderContextMenu),yield i.default.views.menuItems.create("notebookContextMenuItem2","notebookContextMenuAddRoot",l.MenuItemLocation.FolderContextMenu)}))}})},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=joplin},function(e,t,o){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ContentScriptType=t.SettingStorage=t.AppType=t.SettingItemType=t.ToolbarButtonLocation=t.isContextMenuItemLocation=t.MenuItemLocation=t.ImportModuleOutputFormat=t.FileSystemItem=void 0,function(e){e.File="file",e.Directory="directory"}(t.FileSystemItem||(t.FileSystemItem={})),function(e){e.Markdown="md",e.Html="html"}(t.ImportModuleOutputFormat||(t.ImportModuleOutputFormat={})),function(e){e.File="file",e.Edit="edit",e.View="view",e.Note="note",e.Tools="tools",e.Help="help",e.Context="context",e.NoteListContextMenu="noteListContextMenu",e.EditorContextMenu="editorContextMenu",e.FolderContextMenu="folderContextMenu",e.TagContextMenu="tagContextMenu"}(n=t.MenuItemLocation||(t.MenuItemLocation={})),t.isContextMenuItemLocation=function(e){return[n.Context,n.NoteListContextMenu,n.EditorContextMenu,n.FolderContextMenu,n.TagContextMenu].includes(e)},function(e){e.NoteToolbar="noteToolbar",e.EditorToolbar="editorToolbar"}(t.ToolbarButtonLocation||(t.ToolbarButtonLocation={})),function(e){e[e.Int=1]="Int",e[e.String=2]="String",e[e.Bool=3]="Bool",e[e.Array=4]="Array",e[e.Object=5]="Object",e[e.Button=6]="Button"}(t.SettingItemType||(t.SettingItemType={})),function(e){e.Desktop="desktop",e.Mobile="mobile",e.Cli="cli"}(t.AppType||(t.AppType={})),function(e){e[e.Database=1]="Database",e[e.File=2]="File"}(t.SettingStorage||(t.SettingStorage={})),function(e){e.MarkdownItPlugin="markdownItPlugin",e.CodeMirrorPlugin="codeMirrorPlugin"}(t.ContentScriptType||(t.ContentScriptType={}))}]);manifest.json000644 0000000764 14562173740010425 0ustar00000000 000000 { "manifest_version": 1, "id": "com.plugin.randomNoteReloadedPlugin", "app_min_version": "1.7", "version": "1.0.4", "name": "Random Note Reloaded", "description": "Opens a random note from your workspace", "author": "Fork: Marph, Original: Azamah Junior", "homepage_url": "https://github.com/marph91/joplin-random-note-reloaded/blob/master/README.md", "repository_url": "https://github.com/marph91/joplin-random-note-reloaded.git", "keywords": ["note", "random", "random note"] }