cursorTracker.js000644 0000002315 14722554025011102 0ustar00000000 000000 (()=>{"use strict";var o={90:(o,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),o.exports={default:function(o){return{plugin:function(o){o.cm6&&(o.registerCommand("rn.getCursorAndScroll",(function(){const t=o.editor,e=t.state.selection.main,r=e.anchor,n=e.head,s=t.state.doc.lineAt(r),l=t.scrollDOM.getBoundingClientRect(),c=t.posAtCoords({x:l.left+5,y:l.top})||0,i=t.state.doc.lineAt(c);return{line:s.number,ch:r-s.from,scroll:i.number,selection:n-r}})),o.registerCommand("rn.setCursor",(function(t){const e=o.editor,{line:r,ch:n,selection:s}=t,l=e.state.doc.line(r).from+n;e.dispatch({selection:{anchor:l,head:s?l+s:l},scrollIntoView:!0})})),o.registerCommand("rn.setScroll",(function(t){const e=o.editor,{line:r,scroll:n}=t;let s=Math.max(1,n||r||1);const l=e.state.doc.lines;s>l&&(s=l);const c=e.state.doc.line(s).from,i=e.coordsAtPos(c);if(i){const o=i.top-e.scrollDOM.getBoundingClientRect().top+e.scrollDOM.scrollTop;e.scrollDOM.scrollTo({top:o,behavior:"auto"})}else console.error("Could not get coordinates for position",c)})))},codeMirrorOptions:{}}}}}},t={},e=function e(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return o[r](s,s.exports,e),s.exports}(90);exports.default=e.default})();index.js000644 0000026023 14722554023007360 0ustar00000000 000000 (()=>{"use strict";var e={998:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=joplin},143:(e,t)=>{var o,n,i,s,r,a,l,u,d,m;Object.defineProperty(t,"__esModule",{value:!0}),t.ContentScriptType=t.SettingStorage=t.AppType=t.SettingItemSubType=t.SettingItemType=t.ToolbarButtonLocation=t.isContextMenuItemLocation=t.MenuItemLocation=t.ModelType=t.ImportModuleOutputFormat=t.FileSystemItem=void 0,(m=t.FileSystemItem||(t.FileSystemItem={})).File="file",m.Directory="directory",(d=t.ImportModuleOutputFormat||(t.ImportModuleOutputFormat={})).Markdown="md",d.Html="html",(u=t.ModelType||(t.ModelType={}))[u.Note=1]="Note",u[u.Folder=2]="Folder",u[u.Setting=3]="Setting",u[u.Resource=4]="Resource",u[u.Tag=5]="Tag",u[u.NoteTag=6]="NoteTag",u[u.Search=7]="Search",u[u.Alarm=8]="Alarm",u[u.MasterKey=9]="MasterKey",u[u.ItemChange=10]="ItemChange",u[u.NoteResource=11]="NoteResource",u[u.ResourceLocalState=12]="ResourceLocalState",u[u.Revision=13]="Revision",u[u.Migration=14]="Migration",u[u.SmartFilter=15]="SmartFilter",u[u.Command=16]="Command",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"}(o=t.MenuItemLocation||(t.MenuItemLocation={})),t.isContextMenuItemLocation=function(e){return[o.Context,o.NoteListContextMenu,o.EditorContextMenu,o.FolderContextMenu,o.TagContextMenu].includes(e)},(l=t.ToolbarButtonLocation||(t.ToolbarButtonLocation={})).NoteToolbar="noteToolbar",l.EditorToolbar="editorToolbar",(a=t.SettingItemType||(t.SettingItemType={}))[a.Int=1]="Int",a[a.String=2]="String",a[a.Bool=3]="Bool",a[a.Array=4]="Array",a[a.Object=5]="Object",a[a.Button=6]="Button",(r=t.SettingItemSubType||(t.SettingItemSubType={})).FilePathAndArgs="file_path_and_args",r.FilePath="file_path",r.DirectoryPath="directory_path",(s=t.AppType||(t.AppType={})).Desktop="desktop",s.Mobile="mobile",s.Cli="cli",(i=t.SettingStorage||(t.SettingStorage={}))[i.Database=1]="Database",i[i.File=2]="File",(n=t.ContentScriptType||(t.ContentScriptType={})).MarkdownItPlugin="markdownItPlugin",n.CodeMirrorPlugin="codeMirrorPlugin"},156:function(e,t,o){var n=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(i,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=o(998),s=o(143);let r="",a="",l={},u={},d=!0,m=!1,c=!0,y=300,f=!0;function p(){return n(this,void 0,void 0,(function*(){if(!a)return;if(f)return;if(!(yield i.default.settings.globalValue("editor.codeView")))return;const e=yield i.default.commands.execute("editor.execCommand",{name:"rn.getCursorAndScroll"});c||(e.selection=null),e&&(u[a]=e,m?yield i.default.data.userDataSet(s.ModelType.Note,a,"cursor",e):yield i.default.settings.setValue("resumenote.noteCursorMap",JSON.stringify(u)))}))}function g(e){return n(this,void 0,void 0,(function*(){const t=yield function(e){return n(this,void 0,void 0,(function*(){return m?yield i.default.data.userDataGet(s.ModelType.Note,a,"cursor"):u[e]}))}(e);t&&(yield i.default.commands.execute("editor.focus"),yield new Promise((e=>setTimeout(e,y))),yield i.default.commands.execute("editor.execCommand",{name:"rn.setCursor",args:[{line:t.scroll,ch:1,selection:0}]}),yield i.default.commands.execute("editor.execCommand",{name:"rn.setScroll",args:[t]}),yield i.default.commands.execute("editor.execCommand",{name:"rn.setCursor",args:[t]})),f=!1}))}function v(){return n(this,void 0,void 0,(function*(){let e=!0,t=1;for(;e;){const o=yield i.default.data.get(["notes"],{fields:["id"],page:t++});e=o.has_more;for(const e of o.items)void 0!==(yield i.default.data.userDataGet(s.ModelType.Note,e.id,"cursor"))&&(yield i.default.data.userDataDelete(s.ModelType.Note,e.id,"cursor"))}for(e=!0,t=1;e;){const o=yield i.default.data.get(["folders"],{fields:["id"],page:t++});e=o.has_more;for(const e of o.items)void 0!==(yield i.default.data.userDataGet(s.ModelType.Folder,e.id,"note"))&&(yield i.default.data.userDataDelete(s.ModelType.Folder,e.id,"note"))}}))}function S(){return n(this,void 0,void 0,(function*(){yield i.default.settings.setValue("resumenote.folderNoteMap","{}"),yield i.default.settings.setValue("resumenote.noteCursorMap","{}")}))}i.default.plugins.register({onStart:function(){return n(this,void 0,void 0,(function*(){yield i.default.settings.registerSection("resumenote",{label:"Resume Note",iconName:"fas fa-i-cursor"}),yield i.default.settings.registerSettings({"resumenote.folderNoteMap":{value:"{}",type:s.SettingItemType.String,public:!1,section:"resumenote",label:"Folder Note Map"},"resumenote.saveFolderNote":{value:!0,type:s.SettingItemType.Bool,public:!0,section:"resumenote",label:"Save the last active note in each folder. Requires restart."},"resumenote.noteCursorMap":{value:"{}",type:s.SettingItemType.String,public:!1,section:"resumenote",label:"Note Cursor Map"},"resumenote.lastNoteId":{value:"",type:s.SettingItemType.String,public:!1,section:"resumenote",label:"Default Note ID"},"resumenote.homeNoteId":{value:"",type:s.SettingItemType.String,public:!0,section:"resumenote",label:"Home note ID"},"resumenote.startHomeNote":{value:!0,type:s.SettingItemType.Bool,public:!0,section:"resumenote",label:"Go to home note on startup"},"resumenote.refreshInterval":{value:2e3,type:s.SettingItemType.Int,public:!0,section:"resumenote",label:"Refresh interval for saving cursor and scroll position (ms)",description:"How often to save the cursor and scroll position (in ms). Requires restart.",minimum:500,maximum:1e4,step:100},"resumenote.restoreDelay":{value:300,type:s.SettingItemType.Int,public:!0,section:"resumenote",label:"Delay before setting cursor and scroll position (in ms)",description:"Delay before setting the cursor and scroll position after opening a note in the editor.",minimum:0,maximum:2e3,step:50},"resumenote.startupDelay":{value:1e3,type:s.SettingItemType.Int,public:!0,section:"resumenote",label:"Delay before starting the plugin (in ms)",description:"Delay after Joplin starts before the plugin is activated.",minimum:0,maximum:1e4,step:50},"resumenote.saveSelection":{value:!0,type:s.SettingItemType.Bool,public:!0,section:"resumenote",label:"Save cursor selection",description:"Save the selected text in the cursor position."},"resumenote.useUserData":{value:!1,type:s.SettingItemType.Bool,public:!0,section:"resumenote",label:"Sync data using note properties (Experimental)",description:"Store folder and cursor data using note properties instead of app settings. Data will sync across devices. When disabled, all data will be cleared from the note properties."}}),yield i.default.commands.register({name:"resumenote.clearUserData",label:"Clear Resume Note user data",execute:()=>n(this,void 0,void 0,(function*(){l={},u={},yield v()}))}),yield i.default.commands.register({name:"resumenote.clearSettingsData",label:"Clear Resume Note settings data",execute:()=>n(this,void 0,void 0,(function*(){l={},u={},yield S()}))}),yield i.default.commands.register({name:"resumenote.setHomeNote",label:"Set as home note",execute:()=>n(this,void 0,void 0,(function*(){const e=yield i.default.workspace.selectedNote();e&&(yield i.default.settings.setValue("resumenote.homeNoteId",e.id),yield i.default.views.dialogs.showMessageBox("Current note set as home note"))}))}),yield i.default.commands.register({name:"resumenote.goToHomeNote",label:"Go to home note",iconName:"fas fa-home",execute:()=>n(this,void 0,void 0,(function*(){const e=yield i.default.settings.value("resumenote.homeNoteId");e&&(yield i.default.commands.execute("openNote",e),setTimeout((()=>n(this,void 0,void 0,(function*(){yield i.default.commands.execute("openNote",e)}))),2*y))}))}),yield i.default.commands.register({name:"resumenote.resetHomeNote",label:"Reset home note",execute:()=>n(this,void 0,void 0,(function*(){yield i.default.settings.setValue("resumenote.homeNoteId",""),yield i.default.views.dialogs.showMessageBox("Home note reset")}))}),yield i.default.views.menuItems.create("resumenote.setHomeNoteMenuItem","resumenote.setHomeNote",s.MenuItemLocation.Note),yield i.default.views.menuItems.create("resumenote.goToHomeNoteMenuItem","resumenote.goToHomeNote",s.MenuItemLocation.Note),yield i.default.views.menuItems.create("resumenote.resetHomeNoteMenuItem","resumenote.resetHomeNote",s.MenuItemLocation.Note);const e=yield i.default.settings.value("resumenote.startupDelay");yield new Promise((t=>setTimeout(t,e))),yield i.default.contentScripts.register(s.ContentScriptType.CodeMirrorPlugin,"cursorTracker","./cursorTracker.js"),d=yield i.default.settings.value("resumenote.saveFolderNote"),m=yield i.default.settings.value("resumenote.useUserData"),c=yield i.default.settings.value("resumenote.saveSelection"),y=yield i.default.settings.value("resumenote.restoreDelay"),m||(d&&(l=JSON.parse(yield i.default.settings.value("resumenote.folderNoteMap"))),u=JSON.parse(yield i.default.settings.value("resumenote.noteCursorMap")));const t=yield i.default.settings.value("resumenote.lastNoteId"),o=yield i.default.settings.value("resumenote.homeNoteId"),h=yield i.default.settings.value("resumenote.startHomeNote");o&&(yield i.default.views.toolbarButtons.create("resumenote.goToHomeNoteToolbarButton","resumenote.goToHomeNote",s.ToolbarButtonLocation.NoteToolbar)),o&&h?(yield i.default.commands.execute("openNote",o),setTimeout((()=>n(this,void 0,void 0,(function*(){yield g(o)}))),2*y)):t&&(yield i.default.commands.execute("openNote",t),setTimeout((()=>n(this,void 0,void 0,(function*(){yield g(t)}))),2*y)),setInterval(p,yield i.default.settings.value("resumenote.refreshInterval")),yield i.default.workspace.onNoteSelectionChange((()=>n(this,void 0,void 0,(function*(){f=!0;const e=yield i.default.workspace.selectedNote();if(!e)return;a=e.id;const t=e.parent_id;if(yield i.default.settings.setValue("resumenote.lastNoteId",a),t!==r){r=t;const e=yield function(e){return n(this,void 0,void 0,(function*(){if(!d)return"";let t;return t=m?yield i.default.data.userDataGet(s.ModelType.Folder,e,"note"):l[e],t}))}(t);e&&(yield i.default.commands.execute("openNote",e))}else yield function(e,t){return n(this,void 0,void 0,(function*(){d&&(m?yield i.default.data.userDataSet(s.ModelType.Folder,e,"note",t):(l[e]=t,yield i.default.settings.setValue("resumenote.folderNoteMap",JSON.stringify(l))))}))}(r,a);yield g(a)})))),yield i.default.settings.onChange((e=>n(this,void 0,void 0,(function*(){e.keys.includes("resumenote.saveSelection")&&(c=yield i.default.settings.value("resumenote.saveSelection")),e.keys.includes("resumenote.restoreDelay")&&(y=yield i.default.settings.value("resumenote.restoreDelay")),e.keys.includes("resumenote.useUserData")&&(m=yield i.default.settings.value("resumenote.useUserData"),m?yield S():yield v())}))));const N=yield i.default.workspace.selectedNote();N&&(r=N.parent_id,a=N.id)}))}})}},t={};!function o(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,o),s.exports}(156)})();manifest.json000644 0000001021 14722554023010403 0ustar00000000 000000 { "manifest_version": 1, "id": "joplin.plugin.alondmnt.sticky-note", "app_min_version": "2.13", "version": "0.2.5", "name": "Resume Note", "description": "Continue editing the last active note in each notebook, and go back to the last cursor position", "author": "Alon Diament", "homepage_url": "https://github.com/alondmnt/joplin-plugin-resume-note#readme", "repository_url": "https://github.com/alondmnt/joplin-plugin-resume-note", "keywords": ["editor"], "categories": ["editor"], "screenshots": [], "icons": {} }