vault backup: 2025-07-17 15:56:06

This commit is contained in:
CrazyJasonwell committed 2025-07-17 15:56:06 +08:00
1 parent 81d7800964
commit 21298fa9c4
19 files changed
+6781 -19322

No files matched your search

+133
View File
@@ -0,0 +1,133 @@
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var Kt=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var Tn=Object.prototype.hasOwnProperty;var En=(s,e)=>{for(var t in e)Kt(s,t,{get:e[t],enumerable:!0})},wn=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yn(e))!Tn.call(s,n)&&n!==t&&Kt(s,n,{get:()=>e[n],enumerable:!(r=pn(e,n))||r.enumerable});return s};var Sn=s=>wn(Kt({},"__esModule",{value:!0}),s);var fa={};En(fa,{default:()=>jt});module.exports=Sn(fa);var H=require("obsidian");var Ps=require("obsidian");var ye=require("obsidian"),W="all_folders",vt=class extends ye.Modal{constructor(t,r,n,i){super(t);this.selectedFolders=new Set;this.folders=[];this.folders=r,n&&n.length>0&&n.forEach(a=>{a&&this.selectedFolders.add(a)}),this.onConfirm=i}async onOpen(){let{contentEl:t}=this;t.createEl("h2",{text:"Manage Cubox folders to be synced"}),t.addClass("cubox-modal"),this.listEl=t.createDiv({cls:"folder-list-container cubox-list-container"}),this.footerEl=t.createDiv({cls:"modal-footer"}),this.createFolderList(),this.footerEl.createEl("button",{text:"Cancel"}).addEventListener("click",()=>{this.close()}),this.footerEl.createEl("button",{text:"Done",cls:"mod-cta"}).addEventListener("click",()=>{if(this.selectedFolders.size===0){new ye.Notice("Please select at least one option.");return}let i=this.selectedFolders.has(W)?[W]:Array.from(this.selectedFolders);this.onConfirm(i),this.close()})}createFolderList(){this.listEl.empty();let t=new ye.Setting(this.listEl).setName("All items");this.selectedFolders.has(W)&&t.settingEl.addClass("is-selected"),t.settingEl.addEventListener("click",()=>{let r=this.selectedFolders.has(W);this.handleFolderToggle(W,!r),this.redraw()}),this.folders.forEach(r=>{let n=new ye.Setting(this.listEl).setName(r.nested_name);this.selectedFolders.has(W)?n.settingEl.addClass("is-disabled"):(this.selectedFolders.has(r.id)&&n.settingEl.addClass("is-selected"),n.settingEl.addEventListener("click",()=>{let i=this.selectedFolders.has(r.id);this.handleFolderToggle(r.id,!i),this.redraw()}))})}isFolderSelected(t){return this.selectedFolders.has(t)}handleFolderToggle(t,r){t===W?r?(this.selectedFolders.clear(),this.selectedFolders.add(W)):this.selectedFolders.delete(W):r?(this.selectedFolders.delete(W),this.selectedFolders.add(t)):this.selectedFolders.delete(t)}redraw(){this.createFolderList()}onClose(){let{contentEl:t}=this;t.empty()}};var le=require("obsidian"),A="all_items",Qt="",Ft=class extends le.Modal{constructor(t,r,n,i){super(t);this.selectedTags=new Set;this.tags=[];this.tags=r,n&&n.length>0&&n.forEach(a=>{this.selectedTags.add(a)}),this.onConfirm=i}async onOpen(){let{contentEl:t}=this;t.createEl("h2",{text:"Manage Cubox tags to be synced"}),t.addClass("cubox-modal"),this.listEl=t.createDiv({cls:"tag-list-container cubox-list-container"}),this.footerEl=t.createDiv({cls:"modal-footer"}),this.createTagList(),this.footerEl.createEl("button",{text:"Cancel"}).addEventListener("click",()=>{this.close()}),this.footerEl.createEl("button",{text:"Done",cls:"mod-cta"}).addEventListener("click",()=>{if(this.selectedTags.size===0){new le.Notice("Please select at least one option.");return}let i=this.selectedTags.has(A)?[A]:Array.from(this.selectedTags);this.onConfirm(i),this.close()})}createTagList(){this.listEl.empty();let t=new le.Setting(this.listEl).setName("All items");this.selectedTags.has(A)&&t.settingEl.addClass("is-selected"),t.settingEl.addEventListener("click",()=>{let n=this.selectedTags.has(A);this.handleTagToggle(A,!n),this.redraw()});let r=new le.Setting(this.listEl).setName("No tags");this.selectedTags.has(A)?r.settingEl.addClass("is-disabled"):(this.selectedTags.has(Qt)&&r.settingEl.addClass("is-selected"),r.settingEl.addEventListener("click",()=>{let n=this.selectedTags.has(Qt);this.handleTagToggle(Qt,!n),this.redraw()})),this.tags.forEach(n=>{let i=new le.Setting(this.listEl).setName(n.nested_name);this.selectedTags.has(A)?i.settingEl.addClass("is-disabled"):(this.selectedTags.has(n.id)&&i.settingEl.addClass("is-selected"),i.settingEl.addEventListener("click",()=>{let a=this.selectedTags.has(n.id);this.handleTagToggle(n.id,!a),this.redraw()}))})}isTagSelected(t){return this.selectedTags.has(t)}handleTagToggle(t,r){t===A?r?(this.selectedTags.clear(),this.selectedTags.add(A)):this.selectedTags.delete(A):r?(this.selectedTags.delete(A),this.selectedTags.add(t)):this.selectedTags.delete(t)}redraw(){this.createTagList()}onClose(){let{contentEl:t}=this;t.empty()}};var ve=require("obsidian"),ue="all",kt=class extends ve.Modal{constructor(t,r,n={},i){super(t);this.statuses=[{id:"all",name:"All items"},{id:"read",name:"Already read items only",value:!0},{id:"starred",name:"Starred items only",value:!0},{id:"annotated",name:"Annotated items only",value:!0}];this.selectedStatuses=new Set;this.statusValues=new Map;this.onSave=i,this.statuses.forEach(a=>{if(a.id!=="all"){let o=n[a.id]!==void 0?n[a.id]:a.value||!0;this.statusValues.set(a.id,o)}}),r&&r.length>0&&r.forEach(a=>{a&&this.Line truncated
`&&(c(),l="",u=0,t=!1);if(!S.scan(h))break;if(a=!0,b=S.scan(la)||"name",S.scan(ia),b==="="?(M=S.scanUntil(rn),S.scan(rn),S.scanUntil(y)):b==="{"?(M=S.scanUntil(g),S.scan(oa),S.scanUntil(y),b="&"):M=S.scanUntil(y),!S.scan(y))throw new Error("Unclosed tag at "+S.pos);if(b==">"?se=[b,M,F,S.pos,l,u,t]:se=[b,M,F,S.pos],u++,n.push(se),b==="#"||b==="^")r.push(se);else if(b==="/"){if(Z=r.pop(),!Z)throw new Error('Unopened section "'+M+'" at '+F);if(Z[1]!==M)throw new Error('Unclosed section "'+Z[1]+'" at '+F)}else b==="name"||b==="{"||b==="&"?o=!0:b==="="&&k(M)}if(c(),Z=r.pop(),Z)throw new Error('Unclosed section "'+Z[1]+'" at '+S.pos);return da(ca(n))}function ca(s){for(var e=[],t,r,n=0,i=s.length;n<i;++n)t=s[n],t&&(t[0]==="text"&&r&&r[0]==="text"?(r[1]+=t[1],r[3]=t[3]):(e.push(t),r=t));return e}function da(s){for(var e=[],t=e,r=[],n,i,a=0,o=s.length;a<o;++a)switch(n=s[a],n[0]){case"#":case"^":t.push(n),r.push(n),t=n[4]=[];break;case"/":i=r.pop(),i[5]=n[2],t=r.length>0?r[r.length-1][4]:e;break;default:t.push(n)}return e}function xt(s){this.string=s,this.tail=s,this.pos=0}xt.prototype.eos=function(){return this.tail===""};xt.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r};xt.prototype.scanUntil=function(e){var t=this.tail.search(e),r;switch(t){case-1:r=this.tail,this.tail="";break;case 0:r="";break;default:r=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=r.length,r};function Ue(s,e){this.view=s,this.cache={".":this.view},this.parent=e}Ue.prototype.push=function(e){return new Ue(e,this)};Ue.prototype.lookup=function(e){var t=this.cache,r;if(t.hasOwnProperty(e))r=t[e];else{for(var n=this,i,a,o,l=!1;n;){if(e.indexOf(".")>0)for(i=n.view,a=e.split("."),o=0;i!=null&&o<a.length;)o===a.length-1&&(l=sn(i,a[o])||Qi(i,a[o])),i=i[a[o++]];else i=n.view[e],l=sn(n.view,e);if(l){r=i;break}n=n.parent}t[e]=r}return Rs(r)&&(r=r.call(this.view)),r};function L(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}L.prototype.clearCache=function(){typeof this.templateCache!="undefined"&&this.templateCache.clear()};L.prototype.parse=function(e,t){var r=this.templateCache,n=e+":"+(t||B.tags).join(":"),i=typeof r!="undefined",a=i?r.get(n):void 0;return a==null&&(a=ua(e,t),i&&r.set(n,a)),a};L.prototype.render=function(e,t,r,n){var i=this.getConfigTags(n),a=this.parse(e,i),o=t instanceof Ue?t:new Ue(t,void 0);return this.renderTokens(a,o,r,e,n)};L.prototype.renderTokens=function(e,t,r,n,i){for(var a="",o,l,u,c=0,h=e.length;c<h;++c)u=void 0,o=e[c],l=o[0],l==="#"?u=this.renderSection(o,t,r,n,i):l==="^"?u=this.renderInverted(o,t,r,n,i):l===">"?u=this.renderPartial(o,t,r,i):l==="&"?u=this.unescapedValue(o,t):l==="name"?u=this.escapedValue(o,t,i):l==="text"&&(u=this.rawValue(o)),u!==void 0&&(a+=u);return a};L.prototype.renderSection=function(e,t,r,n,i){var a=this,o="",l=t.lookup(e[1]);function u(y){return a.render(y,t,r,i)}if(l){if($e(l))for(var c=0,h=l.length;c<h;++c)o+=this.renderTokens(e[4],t.push(l[c]),r,n,i);else if(typeof l=="object"||typeof l=="string"||typeof l=="number")o+=this.renderTokens(e[4],t.push(l),r,n,i);else if(Rs(l)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(t.view,n.slice(e[3],e[5]),u),l!=null&&(o+=l)}else o+=this.renderTokens(e[4],t,r,n,i);return o}};L.prototype.renderInverted=function(e,t,r,n,i){var a=t.lookup(e[1]);if(!a||$e(a)&&a.length===0)return this.renderTokens(e[4],t,r,n,i)};L.prototype.indentPartial=function(e,t,r){for(var n=t.replace(/[^ \t]/g,""),i=e.split(`
`),a=0;a<i.length;a++)i[a].length&&(a>0||!r)&&(i[a]=n+i[a]);return i.join(`
`)};L.prototype.renderPartial=function(e,t,r,n){if(r){var i=this.getConfigTags(n),a=Rs(r)?r(e[1]):r[e[1]];if(a!=null){var o=e[6],l=e[5],u=e[4],c=a;l==0&&u&&(c=this.indentPartial(a,u,o));var h=this.parse(c,i);return this.renderTokens(h,t,r,c,n)}}};L.prototype.unescapedValue=function(e,t){var r=t.lookup(e[1]);if(r!=null)return r};L.prototype.escapedValue=function(e,t,r){var n=this.getConfigEscape(r)||B.escape,i=t.lookup(e[1]);if(i!=null)return typeof i=="number"&&n===B.escape?String(i):n(i)};L.prototype.rawValue=function(e){return e[1]};L.prototype.getConfigTags=function(e){return $e(e)?e:e&&typeof e=="object"?e.tags:void 0};L.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!$e(e))return e.escape};var B={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(s){St.templateCache=s},get templateCache(){return St.templateCache}},St=new L;B.clearCache=function(){return St.clearCache()};B.parse=function(e,t){return St.parse(e,t)};B.render=function(e,t,r,n){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Ki(e)+'" was given as the first argument for mustache#render(template, view, partials)');return St.render(e,t,r,n)};B.escape=na;B.Scanner=xt;B.Context=Ue;B.Writer=L;var Hs=B;var Us=require("obsidian"),nn=["title","article_title","tags","create_time","update_time","domain","url","cubox_url","description","description","words_count","type","words_count","id"],Bt=class{constructor(){this.dateFormat="yyyy-MM-dd"}setDateFormat(e){this.dateFormat=e}processFilenameTemplate(e,t){if(!e)return t.title||"Untitled";let r={title:t.title||"",article_title:t.article_title||"",create_time:t.create_time?te(t.create_time,this.dateFormat):"",update_time:t.update_time?te(t.update_time,this.dateFormat):"",domain:t.domain||"",type:t.type||"",id:t.id||""},n="";try{n=Hs.render(e,r)}catch(a){console.error("\u6A21\u677F\u6E32\u67D3\u5931\u8D25:",a),n=t.title||"Untitled"}let i=100;return n.length>i&&(n=n.substring(0,i)),tn(n)}processFrontMatter(e,t){let r={id:t.id};if(e.length===0)return(0,Us.stringifyYaml)(r);for(let n of e){let i=n.split("::"),a=i[0],o=i.length>1?i[1]:a;if(a==="tags"&&t.tags&&t.tags.length>0){r[o]=t.tags;continue}if(a==="create_time"&&t.create_time){r[o]=te(t.create_time,this.dateFormat);continue}if(a==="update_time"&&t.update_time){r[o]=te(t.update_time,this.dateFormat);continue}let l=this.getArticleProperty(t,a);l&&(r[o]=l)}return(0,Us.stringifyYaml)(r)}processContentTemplate(e,t){if(!e){let n="";return t.content&&(n+=t.content+`
`),t.highlights&&t.highlights.length>0&&(n+=`## Highlights
`,t.highlights.forEach(i=>{n+=`- ${i.text}
`})),n}let r=this.createArticleView(t);return e.includes("content_highlighted")&&t.content&&t.highlights&&t.highlights.length>0&&(r.content_highlighted=this.generateHighlightedContent(t.content,t.highlights)),Hs.render(e,r)}createArticleView(e){var r;let t={...e,highlights:[],tags:e.tags||[],highlights_length:((r=e.highlights)==null?void 0:r.length)||0,create_time:e.create_time?te(e.create_time,this.dateFormat):"",update_time:e.update_time?te(e.update_time,this.dateFormat):""};return e.highlights&&e.highlights.length>0&&(t.highlights=e.highlights.map(n=>this.createHighlightView(n))),t.highlights.length===0?t.highlights_length=0:t.highlights_length=t.highlights.length,t}createHighlightView(e){let t=e.text||"";!t&&e.image_url?t=`![](${e.image_url})`:t.includes(`
`)&&(t=t.split(`
`).map((o,l)=>l===0?o:o.trim()?"> "+o:">").join(`
`));let r=e.note&&e.note.trim()?e.note.trim()+`
`:"",n={...e,text:t,note:r,create_time:e.create_time?te(e.create_time,this.dateFormat):""};return n.cubox_url||(n.cubox_url=""),n}generateHighlightedContent(e,t){if(!e||!t||t.length===0)return e||"";let r=e.length,n=new Array(r).fill(!1);for(let o of t){let l=o.text;if(!l)continue;let u=0,c;for(;(c=e.indexOf(l,u))!==-1;){for(let h=0;h<l.length;h++)n[c+h]=!0;u=c+1}}let i="",a=!1;for(let o=0;o<r;o++){let l=n[o];l&&!a&&(i+="==",a=!0),!l&&a&&(i+="==",a=!1),i+=e[o]}return a&&(i+="=="),i}getArticleProperty(e,t){return e[t]}needsArticleContent(e){return e?e.includes("{{content}}")||e.includes("{{{content}}}")||e.includes("{{content_highlighted}}")||e.includes("{{{content_highlighted}}}"):!0}};var x=require("obsidian");var $s=(s,e)=>{if(s==="cubox.pro")switch(e){case"filename":return"https://help.cubox.pro/share/obplugin/#%E6%96%87%E4%BB%B6%E5%90%8D%E6%A8%A1%E6%9D%BF";case"metadata":return"https://help.cubox.pro/share/obplugin/#%E5%85%83%E5%B1%9E%E6%80%A7";case"content":return"https://help.cubox.pro/share/obplugin/#%E5%86%85%E5%AE%B9%E6%A8%A1%E6%9D%BF";case"date":return"https://help.cubox.pro/share/obplugin/#%E6%97%A5%E6%9C%9F%E6%A0%BC%E5%BC%8F";default:return"#"}else if(s==="cubox.cc")switch(e){case"filename":return"https://help.cubox.cc/share/obplugin/#filename-template";case"metadata":return"https://help.cubox.cc/share/obplugin/#metadata";case"content":return"https://help.cubox.cc/share/obplugin/#content-template";case"date":return"https://help.cubox.cc/share/obplugin/#date-format";default:return"#"}return"#"},Yt=(s,e)=>s?`<div class="cubox-reference">For more, refer to <a href="${$s(s,e)}" class="reference-link" target="_blank">reference</a>.</div>`:'<div class="cubox-reference">For more, refer to <a href="#" class="reference-link">reference</a>.</div>',an=s=>Yt(s,"filename"),on=s=>Yt(s,"metadata"),ln=s=>Yt(s,"content"),un=s=>Yt(s,"date"),cn=`
Enter template for creating synced article file name.
<div class="cubox-variables-container">
<div class="cubox-variables-title">Available variables</div>
<ul class="cubox-variables-list">
<li>{{{title}}}</li>
<li>{{{article_title}}}</li>
<li>{{{create_time}}}</li>
<li>{{{update_time}}}</li>
<li>{{{domain}}}</li>
<li>{{{type}}}</li>
</ul>
<div class="cubox-reference domain-reference-filename"></div>
</div>
`,dn=`
Enter the metadata separated by comma. you can also use custom aliases in the format of metadata::alias. For syncing purposes, the id will always be included.
<div class="cubox-variables-container">
<div class="cubox-variables-title">Available variables</div>
<ul class="cubox-variables-list">
<li>title</li>
<li>article_title</li>
<li>tags</li>
<li>create_time</li>
<li>update_time</li>
<li>domain</li>
<li>url</li>
<li>cubox_url</li>
<li>description</li>
<li>words_count</li>
<li>type</li>
</ul>
<div class="cubox-reference domain-reference-metadata"></div>
</div>
`,hn=`
Enter template for creating synced article content.
<div class="cubox-variables-container">
<div class="cubox-variables-title">Available variables</div>
<ul class="cubox-variables-list">
<li>{{{id}}}</li>
<li>{{{title}}}</li>
<li>{{{description}}}</li>
<li>{{{article_title}}}</li>
<li>{{{content}}}</li>
<li>{{{content_highlighted}}}</li>
<li>{{{highlights}}}</li>
<li class="highlight-item">
<ul class="highlight-sublist">
<li>{{{text}}}</li>
<li>{{{image_url}}}</li>
<li>{{{cubox_url}}}</li>
<li>{{{note}}}</li>
<li>{{{color}}}</li>
<li>{{{create_time}}}</li>
</ul>
</li>
<li>{{{tags}}}</li>
<li>{{{create_time}}}</li>
<li>{{{update_time}}}</li>
<li>{{{domain}}}</li>
<li>{{{url}}}</li>
<li>{{{cubox_url}}}</li>
<li>{{{words_count}}}</li>
</ul>
<div class="cubox-reference domain-reference-content"></div>
</div>
`,fn=`
If date is used on above templates, enter the format date.
<div class="cubox-variables-container">
<div class="cubox-variables-title">Example</div>
<ul class="cubox-variables-list">
<li>yyyy-MM-dd</li>
<li>MM/dd/yyyy</li>
<li>dd.MM.yyyy</li>
<li>yyyy-MM-dd HH:mm:ss</li>
</ul>
<div class="cubox-reference domain-reference-date"></div>
</div>
`;var Ze=require("obsidian"),Zs=["Article","Snippet","Memo","Image","Audio","Video","File"],Gt=class extends Ze.Modal{constructor(t,r=[],n){super(t);this.selectedTypes=new Set;this.onSave=n,r&&r.length>0&&r.forEach(i=>{i&&this.selectedTypes.add(i)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h2",{text:"Manage Cubox content types to be synced"}),t.addClass("cubox-modal"),this.listEl=t.createDiv({cls:"type-list-container cubox-list-container"}),this.footerEl=t.createDiv({cls:"modal-footer"}),this.createTypeList(),this.footerEl.createEl("button",{text:"Cancel"}).addEventListener("click",()=>{this.close()}),this.footerEl.createEl("button",{text:"Done",cls:"mod-cta"}).addEventListener("click",()=>{if(this.selectedTypes.size===0){new Ze.Notice("Please select at least one option.");return}let i=Array.from(this.selectedTypes);this.onSave(i),this.close()})}createTypeList(){this.listEl.empty(),Zs.forEach(t=>{let r=new Ze.Setting(this.listEl).setName(t);this.selectedTypes.has(t)&&r.settingEl.addClass("is-selected"),r.settingEl.addEventListener("click",()=>{let n=this.selectedTypes.has(t);this.handleTypeToggle(t,!n),this.redraw()})})}handleTypeToggle(t,r){r?this.selectedTypes.add(t):this.selectedTypes.delete(t)}redraw(){this.createTypeList()}onClose(){let{contentEl:t}=this;t.empty()}};var mn=require("obsidian"),ha=`# {{{title}}}
{{{description}}}
[Read in Cubox]({{{cubox_url}}})
[Read Original]({{{url}}})
---
{{#highlights.length}}
## Annotations
{{#highlights}}
> {{{text}}}
{{#note}}
{{{note}}}
{{/note}}
[Link\uFE0F]({{{cubox_url}}})
{{/highlights}}
{{/highlights.length}}`,pe={domain:"",apiKey:"",folderFilter:[],typeFilter:[],statusFilter:[],isRead:!0,isStarred:!0,isAnnotated:!0,tagsFilter:[],syncFrequency:30,targetFolder:"Cubox",filenameTemplate:"{{{title}}}-{{{create_time}}}",frontMatterVariables:["id","cubox_url","url","tags"],contentTemplate:ha,highlightInContent:!0,dateFormat:"yyyy-MM-dd",lastSyncTime:0,lastSyncCardId:null,lastCardUpdateTime:null,syncing:!1},Jt=class extends x.PluginSettingTab{constructor(t,r){super(t,r);this.plugin=r}display(){let{containerEl:t}=this;t.empty(),new x.Setting(t).setName("Cubox server domain").setDesc("Select the correct domain name of the Cubox you are using.").addDropdown(o=>o.addOption("","Choose region").addOption("cubox.cc","cubox.cc (international)").addOption("cubox.pro","cubox.pro").setValue(this.plugin.settings.domain).onChange(async l=>{this.plugin.settings.domain=l,await this.plugin.saveSettings(),this.updateApiKeySetting(),this.plugin.updateCuboxApiConfig(l,this.plugin.settings.apiKey),this.updateHelpLinks(l)})),this.apiKeySetting=new x.Setting(t).setName("Your Cubox API key").setDesc("Please select a region first").addText(o=>(o.setPlaceholder("Enter your API key").setValue(this.plugin.settings.apiKey).onChange(async l=>{let u=l.trim();if(u.includes("://"))try{let c=u.includes("://")?new URL(u):null;if(c){let h=c.pathname.split("/").filter(y=>y.length>0);h.length>0&&(u=h[h.length-1])}o.setValue(u)}catch(c){new x.Notice("Invalid API key")}this.plugin.settings.apiKey=u,await this.plugin.saveSettings(),this.plugin.updateCuboxApiConfig(this.plugin.settings.domain,u)}),this.plugin.settings.domain||(o.inputEl.disabled=!0),o)),this.updateApiKeySetting(),new x.Setting(t).setName("Filter").setHeading(),new x.Setting(t).setName("Folder filter").setDesc("Manage Cubox folders to be synced").addButton(o=>o.setButtonText(this.getFolderFilterButtonText()).setCta().onClick(async()=>{if(!this.plugin.settings.apiKey){new x.Notice("Please enter the API key first");return}o.setButtonText("Loading folders...");try{let l=await this.plugin.cuboxApi.getFolders();new vt(this.app,l,this.plugin.settings.folderFilter,async c=>{this.plugin.settings.folderFilter=c,await this.plugin.saveSettings(),o.setButtonText(this.getFolderFilterButtonText())}).open()}catch(l){console.error("\u83B7\u53D6\u6587\u4EF6\u5939\u5217\u8868\u5931\u8D25:",l),new x.Notice("Failed to get Cubox folders"),o.setButtonText(this.getFolderFilterButtonText())}o.setButtonText(this.getFolderFilterButtonText())})),new x.Setting(t).setName("Tag filter").setDesc("Manage Cubox tags to be synced").addButton(o=>o.setButtonText(this.getTagFilterButtonText()).setCta().onClick(async()=>{if(!this.plugin.settings.apiKey){new x.Notice("Please enter the API key first");return}o.setButtonText("Loading tags...");try{let l=await this.plugin.cuboxApi.getTags();new Ft(this.app,l,this.plugin.settings.tagsFilter,async c=>{this.plugin.settings.tagsFilter=c,await this.plugin.saveSettings(),o.setButtonText(this.getTagFilterButtonText())}).open()}catch(l){console.error("\u83B7\u53D6\u6807\u7B7E\u5217\u8868\u5931\u8D25:",l),new x.Notice("Failed to get Cubox tags"),o.setButtonText(this.getTagFilterButtonText())}o.setButtonText(this.getTagFilterButtonText())})),new x.Setting(t).setName("Type filter").setDesc("Manage Cubox content types to be synced").addButton(o=>o.setButtonText(this.getTypeFilterButtonText()).setCta().onClick(async()=>{if(!this.plugin.settings.apiKey){new x.Notice("Please enter the API key first");return}new Gt(this.app,this.plugin.settings.typeFilter,async u=>{this.plugin.settings.typeFilter=u,await this.plugin.saveSettings(),o.setButtonText(this.getTypeFilterButtonText())}).open()})),new x.Setting(t).setName("Status filter").setDesc("Manage Cubox content status to be synced").addButton(o=>o.setButtonText(this.getStatusFilterButtonText()).setCta().onClick(async()=>{if(!this.plugin.settings.apiKey){new x.Notice("Please enter the API key first");return}let l={read:this.plugin.settings.isRead,starred:this.plugin.settings.isStarred,annotated:this.plugin.settings.isAnnotated};new kt(this.app,this.plugin.settings.statusFilter,l,async(c,h)=>{this.plugin.settings.statusFilter=c,this.plugin.settings.isRead=h.read,this.plugin.settings.isStarred=h.starred,this.plugin.settings.isAnnotated=h.annotated,await this.plugin.saveSettings(),o.setButtonText(this.getStatusFilterButtonText())}).open()})),new x.Setting(t).setName("Sync").setHeading(),new x.Setting(t).setName("Sync interval").setDesc("Auto sync interval (in minutes). 0 means manual sync. Each item syncs only once. Subsequent updates won't be synced, and modifications in Obsidian won't affect Cubox. We recommend avoiding frequent updates.").addText(o=>o.setPlaceholder("Enter the interval").setValue(String(this.plugin.settings.syncFrequency)).onChange(async u=>{let c=parseInt(u);if(isNaN(c)){new x.Notice("Frequency must be a positive integer");return}c=Math.min(c,9999),this.plugin.settings.syncFrequency=c,await this.plugin.saveSett Line truncated
${se}
---
`),re+=Z,await this.app.vault.create(M,re),o++}catch(F){l++,console.error("\u540C\u6B65 Cubox \u6570\u636E\u5931\u8D25:",F)}a=g,y.length>0&&(n=y[y.length-1].id,i=y[y.length-1].update_time,this.settings.lastSyncCardId=n,this.settings.lastCardUpdateTime=i,await this.saveSettings())}this.settings.lastSyncTime=Date.now(),this.settings.syncing=!1,await this.saveSettings();let c=`Cubox sync completed: ${o} new items${u>0?`, ${u} skipped`:""}${l>0?`, ${l} errors`:""}`;new H.Notice(c)}catch(n){console.error("\u540C\u6B65 Cubox \u6570\u636E\u5931\u8D25:",n),new H.Notice("Cubox sync failed. Please check settings or network.")}finally{this.settings.syncing=!1,await this.saveSettings()}}async ensureTargetFolder(){let t=this.settings.targetFolder;this.app.vault.getAbstractFileByPath(t)instanceof H.TFolder||await this.app.vault.createFolder(t)}formatLastSyncTime(){return this.settings.lastSyncTime?te(new Date(this.settings.lastSyncTime).toISOString(),"yyyy-MM-dd HH:mm"):"never"}updateCuboxApiConfig(t,r){this.cuboxApi.updateConfig(t,r)}updateTemplateProcessorDateFormat(t){this.templateProcessor.setDateFormat(t)}};
/*! Bundled license information:
mustache/mustache.mjs:
(*!
* mustache.js - Logic-less {{mustache}} templates with JavaScript
* http://github.com/janl/mustache.js
*)
*/
/* nosourcemap */
+9
View File
@@ -0,0 +1,9 @@
{
"id": "cubox-sync",
"name": "Cubox",
"version": "1.0.6",
"minAppVersion": "0.15.0",
"description": "Sync your Cubox articles & annotations",
"author": "delphi-2015",
"isDesktopOnly": false
}
+213
View File
@@ -0,0 +1,213 @@
/*
This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.
*/
.modal-footer {
display: flex;
justify-content: flex-end;
padding: 16px;
border-top: 1px solid var(--background-modifier-border);
}
.modal-footer button {
margin-left: 8px;
}
.modal-footer button.mod-cta {
background-color: var(--interactive-accent);
color: var(--text-on-accent);
}
/* 变量列表样式优化 */
.cubox-variables-container {
margin: 20px 0;
color: var(--text-muted);
}
.cubox-variables-title {
font-weight: 500;
margin-bottom: 8px;
color: var(--text-normal);
}
.cubox-variables-list {
margin: 0;
padding-left: 15px;
list-style-type: disc;
}
.cubox-variables-list li {
margin-bottom: 4px;
line-height: 1.2;
}
.highlight-sublist {
margin-top: 4px;
padding-left: 15px;
list-style-type: disc;
}
.cubox-reference {
margin-top: 10px;
font-size: 1.0em;
}
.reference-link {
color: var(--text-accent);
text-decoration: none;
}
.reference-link:hover {
text-decoration: underline;
}
/* Modal Dialog Styles */
.cubox-modal {
display: flex;
flex-direction: column;
height: 100%;
}
.cubox-list-container {
flex-grow: 1;
overflow-y: auto;
padding-top: 20px;
padding-right: 10px;
overflow-anchor: none;
scroll-behavior: auto;
height: 100%;
max-height: 65vh;
}
/* Setting item styles for modal dialogs */
.cubox-list-container .setting-item {
position: relative;
padding-left: 36px;
border-radius: 4px;
transition: background-color 0.1s ease;
display: flex;
align-items: center;
min-height: 40px;
box-sizing: border-box;
}
.cubox-list-container .setting-item:hover {
background-color: var(--background-modifier-hover);
}
/* Setting item name styles */
.cubox-list-container .setting-item-name {
display: flex;
align-items: center;
padding: 0;
margin: 0;
}
/* Custom checkbox styles */
.cubox-list-container .setting-item::before {
content: "";
position: absolute;
width: 16px;
height: 16px;
border: 1px solid var(--checkbox-border-color, var(--background-modifier-border));
border-radius: 3px;
background-color: var(--checkbox-color, var(--background-primary));
box-sizing: border-box;
}
/* First child checkbox positioning */
.cubox-list-container .setting-item:first-child::before {
left: 10px;
top: 12px;
}
/* Other items checkbox positioning */
.cubox-list-container .setting-item:not(:first-child)::before {
left: 10px;
top: 50%;
transform: translateY(-50%);
}
/* Selected checkbox state */
.cubox-list-container .setting-item.is-selected::before {
background-color: var(--checkbox-color-checked, var(--interactive-accent));
border-color: var(--checkbox-border-color-checked, var(--interactive-accent));
}
/* Checkmark for selected items */
.cubox-list-container .setting-item.is-selected::after {
content: "";
position: absolute;
width: 5px;
height: 9px;
border-right: 2px solid var(--text-on-accent);
border-bottom: 2px solid var(--text-on-accent);
}
/* First child checkmark positioning */
.cubox-list-container .setting-item:first-child.is-selected::after {
left: 14px;
top: 13px;
transform: rotate(45deg);
}
/* Other items checkmark positioning */
.cubox-list-container .setting-item:not(:first-child).is-selected::after {
left: 14px;
top: 50%;
transform: translateY(-60%) rotate(45deg);
}
/* First item special styling */
.cubox-list-container .setting-item:first-child {
margin-top: 0;
padding-top: 0;
}
.cubox-list-container .setting-item:first-child .setting-item-name {
margin-top: 0;
padding-top: 0;
position: relative;
top: 6px;
font-weight: bold;
}
/* Disabled state styling */
.cubox-list-container .setting-item.is-disabled {
opacity: 0.3;
pointer-events: none;
}
.cubox-list-container .setting-item.is-disabled::before {
background-color: var(--background-primary);
border-color: var(--background-modifier-border);
}
.cubox-list-container .setting-item.is-disabled::after {
content: "";
position: absolute;
width: 8px;
height: 2px;
background-color: var(--text-muted);
left: 14px;
top: 50%;
transform: translateY(-50%);
border: none;
}
/* Consistent line height for all items */
.cubox-list-container .setting-item-heading,
.cubox-list-container .setting-item-name {
line-height: normal;
margin: auto 0;
}
/* Override first row bold font for type modal */
.type-list-container .setting-item:first-child .setting-item-name {
font-weight: normal;
}