16 lines
24 KiB
JavaScript
16 lines
24 KiB
JavaScript
|
|
/*
|
||
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
|
|
if you want to view the source, please visit the github repository of this plugin
|
||
|
|
*/
|
||
|
|
|
||
|
|
var ve=Object.create;var A=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Ee=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),be=(r,t)=>{for(var e in t)A(r,e,{get:t[e],enumerable:!0})},Q=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fe(t))!Ce.call(r,o)&&o!==e&&A(r,o,{get:()=>t[o],enumerable:!(s=ke(t,o))||s.enumerable});return r};var Se=(r,t,e)=>(e=r!=null?ve(De(r)):{},Q(t||!r||!r.__esModule?A(e,"default",{value:r,enumerable:!0}):e,r)),Te=r=>Q(A({},"__esModule",{value:!0}),r);var ae=Ee((_e,P)=>{(function(r){if(typeof P=="object"&&typeof P.exports=="object")P.exports=r();else if(typeof define=="function"&&define.amd)define(r);else{let t=typeof globalThis!="undefined"?globalThis:window;t.CalendarHeatmap=r()}})(function(){let t=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],e="calendar-heatmap-style",s={view:"year",year:new Date().getFullYear(),month:new Date().getMonth(),weekStart:0,recentDays:7,squareSize:14,squareGap:2,colorScale:t,maxValue:null,legend:!1,tooltip:!0,locale:void 0,language:"en"},o={en:{locale:"en-US",legend:{less:"Less",more:"More"},weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],tooltip:(n,a)=>`${n} on ${a}`},"zh-cn":{locale:"zh-CN",legend:{less:"\u8F83\u5C11",more:"\u8F83\u591A"},weekdays:["\u5468\u65E5","\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D"],tooltip:(n,a)=>`${a}\uFF1A${n}`},"zh-tw":{locale:"zh-TW",legend:{less:"\u8F03\u5C11",more:"\u8F03\u591A"},weekdays:["\u9031\u65E5","\u9031\u4E00","\u9031\u4E8C","\u9031\u4E09","\u9031\u56DB","\u9031\u4E94","\u9031\u516D"],tooltip:(n,a)=>`${a}\uFF1A${n}`},ja:{locale:"ja-JP",legend:{less:"\u5C11\u306A\u3044",more:"\u591A\u3044"},weekdays:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"],tooltip:(n,a)=>`${a}\uFF1A${n}`},fr:{locale:"fr-FR",legend:{less:"Moins",more:"Plus"},weekdays:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],tooltip:(n,a)=>`${n} le ${a}`},de:{locale:"de-DE",legend:{less:"Weniger",more:"Mehr"},weekdays:["So","Mo","Di","Mi","Do","Fr","Sa"],tooltip:(n,a)=>`${n} am ${a}`},ko:{locale:"ko-KR",legend:{less:"\uC801\uC74C",more:"\uB9CE\uC74C"},weekdays:["\uC77C","\uC6D4","\uD654","\uC218","\uBAA9","\uAE08","\uD1A0"],tooltip:(n,a)=>`${a} ${n}`},es:{locale:"es-ES",legend:{less:"Menos",more:"M\xE1s"},weekdays:["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"],tooltip:(n,a)=>`${n} el ${a}`},it:{locale:"it-IT",legend:{less:"Meno",more:"Pi\xF9"},weekdays:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],tooltip:(n,a)=>`${n} il ${a}`}},p={en:"en","en-us":"en","en-gb":"en",english:"en",zh:"zh-cn","zh-cn":"zh-cn","zh-hans":"zh-cn","zh-sg":"zh-cn","zh-tw":"zh-tw","zh-hant":"zh-tw","zh-hk":"zh-tw",ja:"ja","ja-jp":"ja",japanese:"ja",fr:"fr","fr-fr":"fr",french:"fr",de:"de","de-de":"de",german:"de",ko:"ko","ko-kr":"ko",korean:"ko",es:"es","es-es":"es",spanish:"es",it:"it","it-it":"it",italian:"it"};function m(n){let a=String(n||"en").toLowerCase(),i=p[a]||a;return o[i]||o.en}function k(n){if(!n)throw new Error("CalendarHeatmap: container is required.");if(typeof n=="string"){let a=document.querySelector(n);if(!a)throw new Error(`CalendarHeatmap: container selector "${n}" not found.`);return a}return n}function u(n){let a=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0");return`${a}-${i}-${l}`}function y(n){let a=new Map;return Array.isArray(n)&&n.forEach(i=>{if(!i)return;let l=new Date(i.date||i.day||i.dateString);if(Number.isNaN(l.getTime()))return;let c=u(l),h=typeof i.value=="number"?i.value:Number(i.count);Number.isNaN(h)||a.set(c,h)}),a}function E(n,a){let i=new Date(n);return i.setDate(n.getDate()+a),i}function S(n,a){let i=new Date(n),l=(i.getDay()-a+7)%7;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function U(n,a){let i=S(n,a);return E(i,6)}function oe(n,a){let i=a.weekStart%7,l,c;if(n==="year"){let d=Number(a.year);l=new Date(d,0,1),c=new Date(d,11,31)}else if(n==="month"){let d=Number(a.year),T=N
|
||
|
|
`),e=[];for(let s of t){let o=Me(s);o&&e.push(o)}return e}function W(r){let t=Z(new Date);return new RegExp(`^\\*\\s+${t}\\s+-`,"m").test(r)}function ee(r,t){let e=r.lastLine(),s=r.getLine(e).length,o=xe(t);r.replaceRange(`
|
||
|
|
${o}`,{line:e,ch:s})}function xe(r){return`* ${Z(new Date)} - ${r}`}var Ne={"notice.noActiveMarkdownView":"No active Markdown view","notice.alreadyCheckedIn":"Already checked in today","notice.editorUnavailable":"Editor instance not available","notice.onlyCheckInInEditMode":"Please switch to edit mode to check in.","notice.checkInTooFast":"You are checking in too frequently. Please wait a moment before trying again.","card.goalTitle":"My goal","card.goalPlaceholder":"Define your goal here!","card.activityHistoryTitle":"Activity history","card.buttonsTitle":"How did you do today?","card.checkInCongrats":"Another day done, you're making progress! \u{1F389}","card.defaultButton":"Button","command.insertCalendarHeatmap":"Insert calendar heatmap","command.insertCheckInComponent":"Insert check-in component","command.insertSingleCheckInComponent":"Insert single check-in component","command.insertDailyOverview":"Insert daily overview","command.insertMyGoal":"Insert my goal","snippet.justABit":"Just a bit","snippet.gotItDone":"Got it done","snippet.didExtra":"Did extra","snippet.checkIn":"Check in","setting.weekStartName":"Week start","setting.weekStartDescription":"Choose the first day of the week used by the calendar","setting.weekStart.monday":"Monday","setting.weekStart.sunday":"Sunday","overview.title":"Today's overview","overview.statusLabel":"Today's status","overview.statusValue.checkedIn":"Checked in","overview.statusValue.missed":"Missed","overview.statusHint.checkedIn":"Keep the pace","overview.statusHint.missed":"Remember to check in","overview.streakLabel":"Streak","overview.streakHint.active":"Keep it going","overview.streakHint.inactive":"Waiting to start","overview.gapLabel":"Most recent gap","overview.gapValue.none":"No gaps","overview.noData":"No data yet","overview.gapHint.present":"Review this day","overview.gapHint.none":"Looking steady","overview.streakValue":"{{count}} days"},Ie={"notice.noActiveMarkdownView":"\u6CA1\u6709\u6253\u5F00\u7684 Markdown \u89C6\u56FE","notice.alreadyCheckedIn":"\u4ECA\u5929\u5DF2\u7ECF\u6253\u5361\u4E86","notice.editorUnavailable":"\u65E0\u6CD5\u83B7\u53D6\u7F16\u8F91\u5668\u5B9E\u4F8B","notice.onlyCheckInInEditMode":"\u8BF7\u5207\u6362\u5230\u7F16\u8F91\u6A21\u5F0F\u4EE5\u8FDB\u884C\u6253\u5361\u3002","notice.checkInTooFast":"\u4F60\u6253\u5361\u5F97\u592A\u9891\u7E41\u4E86\uFF0C\u8BF7\u7A0D\u7B49\u7247\u523B\u518D\u8BD5\u3002","card.goalTitle":"\u6211\u7684\u76EE\u6807","card.goalPlaceholder":"\u5728\u8FD9\u91CC\u63CF\u8FF0\u4F60\u7684\u76EE\u6807\uFF01","card.activityHistoryTitle":"\u6D3B\u52A8\u8BB0\u5F55","card.buttonsTitle":"\u4ECA\u5929\u8868\u73B0\u5982\u4F55\uFF1F","card.checkInCongrats":"\u53C8\u575A\u6301\u4E86\u4E00\u5929\uFF0C\u4F60\u6B63\u5728\u4E0D\u65AD\u8FDB\u6B65\uFF01\u{1F389}","card.defaultButton":"\u6309\u94AE","command.insertCalendarHeatmap":"\u63D2\u5165\u65E5\u5386\u70ED\u529B\u56FE","command.insertCheckInComponent":"\u63D2\u5165\u6253\u5361\u7EC4\u4EF6","command.insertSingleCheckInComponent":"\u63D2\u5165\u5355\u6309\u94AE\u6253\u5361\u7EC4\u4EF6","command.insertDailyOverview":"\u63D2\u5165\u6BCF\u65E5\u6982\u89C8","command.insertMyGoal":"\u63D2\u5165\u76EE\u6807\u5361\u7247","snippet.justABit":"\u7A0D\u5FAE\u505A\u4E86\u4E00\u70B9","snippet.gotItDone":"\u987A\u5229\u5B8C\u6210","snippet.didExtra":"\u989D\u5916\u5B8C\u6210","snippet.checkIn":"\u6253\u5361","setting.weekStartName":"\u6BCF\u5468\u8D77\u59CB\u65E5","setting.weekStartDescription":"\u9009\u62E9\u70ED\u529B\u56FE\u4E2D\u7684\u6BCF\u5468\u8D77\u59CB\u65E5","setting.weekStart.monday":"\u5468\u4E00","setting.weekStart.sunday":"\u5468\u65E5","overview.title":"\u4ECA\u65E5\u6982\u89C8","overview.statusLabel":"\u4ECA\u65E5\u72B6\u6001","overview.statusValue.checkedIn":"\u5DF2\u6253\u5361","overview.statusValue.missed":"\u672A\u6253\u5361","overview.statusHint.checkedIn":"\u4FDD\u6301\u8282\u594F","overview.statusHint.missed":"\u522B\u5FD8\u4E86\u6253\u5361","overview.streakLabel":"\u8FDE\u7EED\u5929\u6570","overview.streakHint.active":"\u7EE7\u7EED\u4FDD\u6301","overview.streakHint.inactive":"\u7B4
|
||
|
|
`).map(o=>o.trim()).filter(Boolean);for(let[o,p]of s.entries()){let[m,k]=p.split("|").map(y=>y.trim()),u=new x.ButtonComponent(e);u.buttonEl.addClass("btn"),u.setButtonText(m||this.plugin.t("card.defaultButton")),u.onClick(()=>{let y=Number(k),E=Number.isFinite(y)?y:o+1;this.plugin.insertEntry(E)})}}};var j=require("obsidian"),se={weekStart:1},F=class extends j.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:t}=this;t.empty(),new j.Setting(t).setName(this.plugin.t("setting.weekStartName")).setDesc(this.plugin.t("setting.weekStartDescription")).addDropdown(e=>{e.addOption("1",this.plugin.t("setting.weekStart.monday")),e.addOption("0",this.plugin.t("setting.weekStart.sunday")),e.setValue(String(this.plugin.settings.weekStart)),e.onChange(async s=>{this.plugin.settings.weekStart=s==="0"?0:1,await this.plugin.saveSettings()})})}};var R=class extends C.Plugin{constructor(){super(...arguments);this.locale="en";this.translator=q("en");this.lastCheckInTime=0}t(e,s){return this.translator(e,s)}getSystemLocale(){return(0,C.getLanguage)()}refreshLocale(){let e=te(this.getSystemLocale());this.locale=e,this.translator=q(e),this.triggerRefresh()}triggerRefresh(){this.app.workspace.trigger("easy-tracker:refresh")}triggerSettingsRefresh(){this.app.workspace.trigger("easy-tracker-setting:refresh")}getActiveMarkdownView(){let e=this.app.workspace.getActiveViewOfType(C.MarkdownView);return e||(new C.Notice(this.t("notice.noActiveMarkdownView")),null)}getActiveContent(){let e=this.getActiveMarkdownView();return e&&e.editor.getValue()||""}isTodayCheckedIn(){let e=this.getActiveMarkdownView();if(!e)return!1;let s=e.editor.getValue()||"";return W(s)}insertEntry(e){let s=Date.now();if(s-this.lastCheckInTime<1e3)return new C.Notice(this.t("notice.checkInTooFast")),!1;this.lastCheckInTime=s;let o=this.getActiveMarkdownView();if(!o)return!1;if(o.getMode()!=="source")return new C.Notice(this.t("notice.onlyCheckInInEditMode")),!1;let p=o.editor.getValue()||"";if(W(p))return new C.Notice(this.t("notice.alreadyCheckedIn")),!1;let m=o.editor;return m?(ee(m,e),this.triggerRefresh(),!0):(new C.Notice(this.t("notice.editorUnavailable")),!1)}async onload(){await this.loadSettings(),this.refreshLocale(),this.registerMarkdownCodeBlockProcessor("easy-tracker-my-goal",(e,s,o)=>{let p=s.createDiv({cls:"easy-tracker-card"});p.setAttr("id","easy-tracker-my-goal"),p.createEl("div",{cls:"easy-tracker-card-title",text:this.t("card.goalTitle")}),p.createEl("div",{cls:"easy-tracker-my-goal",text:e.trim()||this.t("card.goalPlaceholder")})}),this.registerMarkdownCodeBlockProcessor("easy-tracker-year-calendar-heatmap",(e,s,o)=>{o.addChild(new V(this,s,e))}),this.registerMarkdownCodeBlockProcessor("easy-tracker-buttons",(e,s,o)=>{o.addChild(new _(this,s,e))}),this.registerMarkdownCodeBlockProcessor("easy-tracker-daily-overview",(e,s,o)=>{o.addChild(new z(this,s))}),this.addCommand({id:"insert-calendar-heatmap",name:this.t("command.insertCalendarHeatmap"),editorCallback:(e,s)=>{e.replaceSelection(["```easy-tracker-year-calendar-heatmap","```",""].join(`
|
||
|
|
`))}}),this.addCommand({id:"insert-check-in-component",name:this.t("command.insertCheckInComponent"),editorCallback:(e,s)=>{e.replaceSelection(["","```easy-tracker-daily-overview","```","```easy-tracker-year-calendar-heatmap","```","```easy-tracker-buttons",` ${this.t("snippet.justABit")} | 1`,` ${this.t("snippet.gotItDone")} | 2`,` ${this.t("snippet.didExtra")} | 3`,"```","```easy-tracker-my-goal",this.t("card.goalPlaceholder"),"```",""].join(`
|
||
|
|
`))}}),this.addCommand({id:"insert-single-check-in-component",name:this.t("command.insertSingleCheckInComponent"),editorCallback:(e,s)=>{e.replaceSelection(["","```easy-tracker-daily-overview","```","```easy-tracker-year-calendar-heatmap","```","```easy-tracker-buttons",` ${this.t("snippet.checkIn")} | 1`,"```","```easy-tracker-my-goal",this.t("card.goalPlaceholder"),"```",""].join(`
|
||
|
|
`))}}),this.addCommand({id:"insert-daily-overview",name:this.t("command.insertDailyOverview"),editorCallback:(e,s)=>{e.replaceSelection(["```easy-tracker-daily-overview","```",""].join(`
|
||
|
|
`))}}),this.addCommand({id:"insert-my-goal",name:this.t("command.insertMyGoal"),editorCallback:(e,s)=>{e.replaceSelection(["```easy-tracker-easy-tracker-my-goal",this.t("card.goalPlaceholder"),"```",""].join(`
|
||
|
|
`))}}),this.addSettingTab(new F(this.app,this))}onunload(){}async loadSettings(){let e=await this.loadData(),s=e==null?void 0:e.weakStart,o=typeof s!="undefined"?parseInt(String(s))===0?0:1:void 0,p={};typeof(e==null?void 0:e.weekStart)=="number"&&(p.weekStart=e.weekStart===0?0:1),typeof o!="undefined"&&(p.weekStart=o),this.settings={...se,...p}}async saveSettings(){await this.saveData(this.settings),this.triggerSettingsRefresh()}};
|
||
|
|
|
||
|
|
/* nosourcemap */
|