512 lines
1.3 MiB
JavaScript
512 lines
1.3 MiB
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 t4=Object.create;var J=Object.defineProperty;var s4=Object.getOwnPropertyDescriptor;var h4=Object.getOwnPropertyNames;var v4=Object.getPrototypeOf,m4=Object.prototype.hasOwnProperty;var F1=i=>J(i,"__esModule",{value:!0});var z4=(i,c)=>()=>(c||i((c={exports:{}}).exports,c),c.exports),p4=(i,c)=>{F1(i);for(var a in c)J(i,a,{get:c[a],enumerable:!0})},d4=(i,c,a)=>{if(c&&typeof c=="object"||typeof c=="function")for(let e of h4(c))!m4.call(i,e)&&e!=="default"&&J(i,e,{get:()=>c[e],enumerable:!(a=s4(c,e))||a.enumerable});return i},S=i=>d4(F1(J(i!=null?t4(v4(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var X1=z4((LL,Q1)=>{"use strict";var h1=Object.defineProperty,H4=Object.getOwnPropertyDescriptor,V4=Object.getOwnPropertyNames,g4=Object.prototype.hasOwnProperty,L4=(i,c)=>{for(var a in c)h1(i,a,{get:c[a],enumerable:!0})},x4=(i,c,a,e)=>{if(c&&typeof c=="object"||typeof c=="function")for(let n of V4(c))!g4.call(i,n)&&n!==a&&h1(i,n,{get:()=>c[n],enumerable:!(e=H4(c,n))||e.enumerable});return i},b4=i=>x4(h1({},"__esModule",{value:!0}),i),$1={};L4($1,{FileInputSuggest:()=>A4,FolderInputSuggest:()=>N4,FuzzyInputSuggest:()=>m1,createCollapsibleSection:()=>w4,setNodeIcon:()=>y4});Q1.exports=b4($1);var v1=require("obsidian"),m1=class extends v1.AbstractInputSuggest{constructor(i,c,a){super(i,c.inputEl);this.items=a}getSuggestions(i){let c=(0,v1.prepareSimpleSearch)(i),a=[];for(let e of this.items){let n=c(this.getItemText(e));n&&a.push({item:e,match:n})}return a}renderSuggestion(i,c){c.addClass("mod-complex");let a=c.createDiv({cls:"suggestion-content"});if(!i?.item){a.setText("No match found"),a.parentElement?.addClass("is-selected");return}this.renderTitle(a.createDiv("suggestion-title"),i),this.renderNote?.(a.createDiv("suggestion-note"),i),this.renderFlair?.(c.createDiv("suggestion-aux").createDiv("suggestion-flair"),i)}renderMatches(i,c,a,e){(0,v1.renderMatches)(i,c,a,e)}},Y1=require("obsidian"),N4=class extends m1{getItemText(i){return i.path}renderNote(i,c){let{item:a,match:e}=c;(0,Y1.renderMatches)(i,a.path,e.matches)}renderTitle(i,c){let{item:a,match:e}=c;(0,Y1.renderMatches)(i,a.name,e.matches,a.path.length-a.name.length)}},K1=require("obsidian"),A4=class extends m1{getItemText(i){return i.path}renderNote(i,c){let{item:a,match:e}=c;(0,K1.renderMatches)(i,a.path,e.matches)}renderTitle(i,c){let{item:a,match:e}=c;(0,K1.renderMatches)(i,a.name,e.matches,a.path.length-a.name.length)}},S4=require("obsidian");function y4(i,c){i.addClass("has-node-icon"),(0,S4.setIcon)(i,c)}var J1=require("obsidian");function w4(i,c,a,e){let n=i.createEl("details",{cls:"javalent-nested-settings",attr:{...a??!0?{open:"open"}:{}}});n.ontoggle=async()=>{e&&e(n.open)};let l=n.createEl("summary");return new J1.Setting(l).setHeading().setName(c),(0,J1.setIcon)(l.createDiv("handle"),"chevron-right"),n}});p4(exports,{default:()=>B1});var d=S(require("obsidian"));var q1=S(require("obsidian"));function M4(i,c){for(let a=0;a<c.length;a++)if(i.startsWith(c[a]))return a;return!1}function R1(i,c,a){let e=a.title??i[0].toUpperCase()+i.slice(1).toLowerCase(),n=["title:","collapse:","icon:","color:","metadata:"],l=["title","collapse","icon","color","metadata"],o=c.split(`
|
||
|
`),r=0,f={};for(let H=0;H<o.length;H++){let p=M4(o[H],n);if(p===!1)break;let u=l[p];if(f[u]!==void 0)break;f[u]=o[H].slice(n[p].length).trim(),++r}let{title:s,collapse:h,icon:t,color:m,metadata:z}=f;if(m&&m.startsWith("rgb")&&(m=m.slice(4,-1)),m&&m.startsWith("#")){let H=m.slice(1),p=parseInt(H,16),u=p>>16&255,g=p>>8&255,L=p&255;m=`${u}, ${g}, ${L}`}if(m&&m.startsWith("hsl")){let[H,p,u]=m.slice(4,-1).split(",").map(Z=>Number(Z.replace("%","").trim())),[g,L,w]=u4(H,p,u);m=`${g}, ${L}, ${w}`}if(m&&(m.startsWith("hsb")||m.startsWith("hsv"))){let[H,p,u]=m.slice(4,-1).split(",").map(Z=>Number(Z.replace("%","").trim())),[g,L,w]=C4(H,p,u);m=`${g}, ${L}, ${w}`}let V=o.slice(r).join(`
|
||
|
`);return h!==void 0&&h!=="none"&&h!=="open"&&h!=="closed"&&(h="closed"),"title"in f||a.noTitle||(s=e),s&&s.trim()===""&&h!==void 0&&h!=="none"&&(s=e,new q1.Notice("An admonition must have a title if it is collapsible.")),{title:s,collapse:h,content:V,icon:t,color:m,metadata:z}}function u4(i,c,a){i/=360,c/=100,a/=100;let e,n,l;if(c===0)e=n=l=a;else{let o=(s,h,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(h-s)*6*t:t<1/2?h:t<2/3?s+(h-s)*(2/3-t)*6:s),r=a<.5?a*(1+c):a+c-a*c,f=2*a-r;e=o(f,r,i+1/3),n=o(f,r,i),l=o(f,r,i-1/3)}return[Math.round(e*255),Math.round(n*255),Math.round(l*255)]}function C4(i,c,a){i/=360,c/=100,a/=100;let e,n,l,o=Math.floor(i*6),r=i*6-o,f=a*(1-c),s=a*(1-r*c),h=a*(1-(1-r)*c);switch(o%6){case 0:e=a,n=h,l=f;break;case 1:e=s,n=a,l=f;break;case 2:e=f,n=a,l=h;break;case 3:e=f,n=s,l=a;break;case 4:e=h,n=f,l=a;break;case 5:e=a,n=f,l=s;break}return[Math.round(e*255),Math.round(n*255),Math.round(l*255)]}var U1='<svg viewBox="0 0 100 100" class="add-admonition-command"><path fill="currentColor" stroke="currentColor" d="M37,16c-4.4,0-8.3,3.3-9.2,7.6l-11.6,52c-0.5,2.2,0,4.3,1.2,5.9c1.2,1.6,3.2,2.6,5.4,2.6H79c4.4,0,8.3-3.3,9.2-7.6 l11.6-52c0.5-2.2,0-4.3-1.2-5.9C97.4,17,95.4,16,93.2,16L37,16z M37,20h56.2c1.1,0,1.8,0.4,2.2,1c0.5,0.6,0.7,1.4,0.4,2.6l-1,4.4 H30.8l0.8-3.6C32.1,22.2,34.8,20,37,20z M29.9,32H94l-9.6,43.6C83.9,77.8,81.2,80,79,80H22.8c-1.1,0-1.8-0.4-2.2-1 c-0.5-0.6-0.7-1.4-0.4-2.6L29.9,32z M0,36v4h19.6l0.9-4L0,36z M36.7,38c-0.8,0.1-1.4,0.7-1.6,1.5l-3.5,14c-0.2,0.6,0,1.2,0.4,1.7 c0.4,0.5,1,0.8,1.6,0.8H81c0.9,0,1.7-0.6,1.9-1.5l3.5-14c0.2-0.6,0-1.3-0.4-1.8c-0.4-0.5-1-0.8-1.6-0.8H37.1c-0.1,0-0.1,0-0.2,0 C36.9,38,36.8,38,36.7,38L36.7,38z M38.7,42h43.2l-2.4,10H36.2L38.7,42z M0,52v4h16l0.9-4H0z M0,68v4h12.4l0.9-4H0z"></path><circle fill="white" transform="translate(50 50) scale(3 3)" cx="8" cy="8" r="8"/><path fill="green" transform="translate(50 50) scale(3 3)" d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/></svg>',Q="admonition-add-command",G1='<svg viewBox="0 0 100 100" class="remove-admonition-command"><path fill="currentColor" stroke="currentColor" d="M37,16c-4.4,0-8.3,3.3-9.2,7.6l-11.6,52c-0.5,2.2,0,4.3,1.2,5.9c1.2,1.6,3.2,2.6,5.4,2.6H79c4.4,0,8.3-3.3,9.2-7.6 l11.6-52c0.5-2.2,0-4.3-1.2-5.9C97.4,17,95.4,16,93.2,16L37,16z M37,20h56.2c1.1,0,1.8,0.4,2.2,1c0.5,0.6,0.7,1.4,0.4,2.6l-1,4.4 H30.8l0.8-3.6C32.1,22.2,34.8,20,37,20z M29.9,32H94l-9.6,43.6C83.9,77.8,81.2,80,79,80H22.8c-1.1,0-1.8-0.4-2.2-1 c-0.5-0.6-0.7-1.4-0.4-2.6L29.9,32z M0,36v4h19.6l0.9-4L0,36z M36.7,38c-0.8,0.1-1.4,0.7-1.6,1.5l-3.5,14c-0.2,0.6,0,1.2,0.4,1.7 c0.4,0.5,1,0.8,1.6,0.8H81c0.9,0,1.7-0.6,1.9-1.5l3.5-14c0.2-0.6,0-1.3-0.4-1.8c-0.4-0.5-1-0.8-1.6-0.8H37.1c-0.1,0-0.1,0-0.2,0 C36.9,38,36.8,38,36.7,38L36.7,38z M38.7,42h43.2l-2.4,10H36.2L38.7,42z M0,52v4h16l0.9-4H0z M0,68v4h12.4l0.9-4H0z"></path><circle fill="white" transform="translate(50 50) scale(3 3)" cx="8" cy="8" r="8"/><path fill="#dc3545" transform="translate(50 50) scale(3 3)" d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM4.5 7.5a.5.5 0 0 0 0 1h7a.5.5 0 0 0 0-1h-7z"/></svg>',X="admonition-remove-command",_1='<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Pro 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>',G="admonition-warning",W1='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, In
|
||
|
|
||
|
`],l=new Blob([this.plugin.calloutManager.generateCssString()],{type:"text/css"});createEl("a",{attr:{download:"custom_callouts.css",href:URL.createObjectURL(l)}}).click()}).setDisabled(!Object.keys(this.plugin.data.userAdmonitions).length)),new v.Setting(c).setName("Export Custom Types as JSON").setDesc("Choose custom types to export as a JSON file that you can then share with other users.").addButton(e=>e.setButtonText("Download All").setCta().onClick(()=>{let n=Object.values(this.plugin.data.userAdmonitions);this.download(n)})).addButton(e=>e.setButtonText("Select & Download").onClick(()=>{let n=new a1(this.plugin);n.onClose=()=>{if(!n.export)return;let l=Object.values(this.plugin.data.userAdmonitions);this.download(l.filter(o=>n.selectedAdmonitions.includes(o.type)))},n.open()})),new v.Setting(c).setName("Use CSS Snippet for Custom Callouts").setDesc("Instead of managing it internally, Admonitions will maintain a CSS snippet to enable your custom types for callouts.").addToggle(e=>e.setValue(this.plugin.data.useSnippet).onChange(n=>{this.plugin.data.useSnippet=n,this.plugin.saveSettings(),this.plugin.calloutManager.setUseSnippet()})),new v.Setting(c).setName(M("Add New")).setDesc("Add a new Admonition type. All custom Admonitions will also be usable as callouts.").addButton(e=>e.setTooltip(M("Add Additional")).setButtonText("+").onClick(async()=>{let l=new T(this.plugin);l.onClose=async()=>{if(l.saved){let o={type:l.type,color:l.color,icon:l.icon,command:!1,title:l.title,injectColor:l.injectColor,noTitle:l.noTitle,copy:l.copy};this.plugin.addAdmonition(o),this.plugin.calloutManager.addAdmonition(o),this.display()}},l.open()})),new v.Setting(c).setName("Import Admonition(s)").setDesc("Import admonitions from a JSON definition.").addButton(e=>{let n=createEl("input",{attr:{type:"file",name:"merge",accept:".json",multiple:!0,style:"display: none;"}});n.onchange=async()=>{let{files:l}=n;if(!!l.length){try{let o=[];for(let r of Array.from(l))o.push(JSON.parse(await r.text()));for(let r of o.flat()){if(typeof r!="object")continue;r.icon||(r.icon={name:"pencil-alt",type:"font-awesome"});let f=y.validateImport(this.plugin,r);if(f.success==!1){new v.Notice(createFragment(s=>{s.createSpan({text:`There was an issue importing the ${r.type} admonition:`}),s.createEl("br"),s.createSpan({text:f.message})}));continue}f.messages?.length&&new v.Notice(createFragment(s=>{s.createSpan({text:`There was an issue importing the ${r.type} admonition:`});for(let h of f.messages)s.createEl("br"),s.createSpan({text:h})})),await this.plugin.addAdmonition(r)}this.display()}catch(o){new v.Notice(`There was an error while importing the admonition${l.length==1?"":"s"}.`),console.error(o)}n.value=null}},e.setButtonText("Choose Files"),e.buttonEl.appendChild(n),e.onClick(()=>n.click())}).addExtraButton(e=>e.setIcon("info").onClick(()=>{let n=new v.Modal(this.plugin.app);n.onOpen=()=>{n.contentEl.createSpan({text:"Import one or more admonition definitions as a JSON array. An admonition definition should look as follows at minimum:"}),n.contentEl.createEl("br");let l=new v.TextAreaComponent(n.contentEl.createDiv()).setDisabled(!0).setValue(JSON.stringify({type:"embed-affliction",color:"149, 214, 148",icon:{name:"head-side-cough",type:"font-awesome"}},null,4));l.inputEl.setAttribute("style",`height: ${l.inputEl.scrollHeight}px; resize: none;`),n.contentEl.createEl("br"),n.contentEl.createSpan({text:"See the plugin ReadMe for more information."})},n.open()})),this.additionalEl=c.createDiv("additional"),this.buildTypes(),this.buildAdmonitions(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.admonitions?{open:!0}:{}}})),this.buildIcons(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.icons?{open:!0}:{}}})),this.buildOtherSyntaxes(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...this.plugin.data.open.other?{open:!0}:{}}})),this.buildAdvanced(this.containerEl.createEl("details",{cls:"admonitions-nested-settings",attr:{...th
|
||
|
`).slice(1,-1)){if(f){if(/^title:/.test(h)){l=h.match(/^title:(.*)/)?.[1].trim()??n[0].toUpperCase()+n.slice(1).toLowerCase();continue}if(/^collapse:/.test(h)){o=(h.match(/^collapse:\s?(.*)/)?.[1].trim()??"open")=="open"?"+":"-";continue}/^(title|collapse|color|icon):/.test(h)||(f=!1)}r.push(h)}let s=r.join(`
|
||
|
`);/^(`{3,})ad-(\w+)([\s\S]*?)?\n^\1/m.test(s)&&(s=this.replaceCodeBlockInPlace(s)),c=c.replace(e,`> [!${n}]${o}${l.length?" ":""}${l}
|
||
|
> ${s.split(`
|
||
|
`).join(`
|
||
|
> `)}`),this.converted++}return c}buildAdvanced(c){c.empty(),c.ontoggle=()=>{this.plugin.data.open.advanced=c.open,this.plugin.saveSettings()};let a=c.createEl("summary");new v.Setting(a).setHeading().setName("Advanced Settings"),a.createDiv("collapser").createDiv("handle"),new v.Setting(c).setName(M("Markdown Syntax Highlighting")).setDesc(M("Use Obsidian's markdown syntax highlighter in admonition code blocks. This setting is experimental and could cause errors.")).addToggle(e=>{e.setValue(this.plugin.data.syntaxHighlight),e.onChange(async n=>{this.plugin.data.syntaxHighlight=n,n?this.plugin.turnOnSyntaxHighlighting():this.plugin.turnOffSyntaxHighlighting(),await this.plugin.saveSettings()})})}buildTypes(){this.additionalEl.empty();for(let c of Object.values(this.plugin.data.userAdmonitions)){let a=new v.Setting(this.additionalEl),e=this.plugin.getAdmonitionElement(c.type,c.type[0].toUpperCase()+c.type.slice(1).toLowerCase(),c.icon,c.injectColor??this.plugin.data.injectColor?c.color:null);a.infoEl.replaceWith(e),c.command?a.addExtraButton(n=>{n.setIcon(X.toString()).setTooltip(M("Unregister Commands")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),await this.plugin.saveSettings(),this.display()})}):a.addExtraButton(n=>{n.setIcon(Q.toString()).setTooltip(M("Register Commands")).onClick(async()=>{this.plugin.registerCommandsFor(c),await this.plugin.saveSettings(),this.display()})}),a.addExtraButton(n=>{n.setIcon("pencil").setTooltip(M("Edit")).onClick(()=>{let l=new T(this.plugin,c);l.onClose=async()=>{if(l.saved){let o=c.command,r={type:l.type,color:l.color,icon:l.icon,command:o,title:l.title,injectColor:l.injectColor,noTitle:l.noTitle,copy:l.copy};if(r.type!=c.type){this.plugin.unregisterType(c);let f=Object.entries(this.plugin.data.userAdmonitions);this.plugin.data.userAdmonitions=Object.fromEntries(f.map(([s,h])=>s==c.type?[r.type,r]:[s,h]))}else this.plugin.data.userAdmonitions[r.type]=r;this.plugin.registerType(r.type),this.plugin.calloutManager.addAdmonition(r),this.display()}},l.open()})}).addExtraButton(n=>{n.setIcon("trash").setTooltip(M("Delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},T=class extends v.Modal{constructor(c,a){super(c.app);this.plugin=c;this.color="#7d7d7d";this.icon={};this.saved=!1;this.error=!1;this.injectColor=this.plugin.data.injectColor;this.noTitle=!1;this.editing=!1;a&&(this.editing=!0,this.color=a.color,this.icon=a.icon,this.type=a.type,this.originalType=a.type,this.title=a.title,this.injectColor=a.injectColor??this.injectColor,this.noTitle=a.noTitle??!1,this.copy=a.copy??this.plugin.data.copyButton)}setAdmonitionElement(c){this.admonitionPreviewParent.empty(),this.admonitionPreview=this.plugin.getAdmonitionElement(this.type,c[0].toUpperCase()+c.slice(1).toLowerCase(),this.icon,this.injectColor??this.plugin.data.injectColor?this.color:null),this.admonitionPreview.createDiv("callout-content admonition-content").createEl("p",{text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla."}),this.admonitionPreviewParent.appendChild(this.admonitionPreview)}async display(){this.containerEl.addClass("admonition-settings-modal"),this.titleEl.setText(`${this.editing?"Edit":"Add"} Admonition`);let{contentEl:c}=this;c.empty();let a=c.createDiv(),e=this.title??this.type??"...";this.admonitionPreviewParent=c.createDiv(),this.setAdmonitionElement(e[0].toUpperCase()+e.slice(1).toLowerCase());let n,l=new v.Setting(a).setName(M("Admonition Type")).addText(t=>{n=t,n.setValue(this.type).onChange(m=>{let z=y.validateType(m,this.plugin,this.originalType);if(z.success==!1){T.setValidationError(t.inputEl,z.message);return}T.removeValidationError(t.inputEl),this.type=m,this.title||this.setAdmonitionElement(this.type?.[0].toUpperCase()+this.type?.slice(1).toLowerCase())})});l.controlEl.addClass("admonition-type-setting"),l.descEl.createSpan({text:"This is used to create the admonition (e.g., "}),l.descEl.createEl("code",{text:"note"}),l.descEl.createSpan({text:" or "}),l.descEl.createEl("code",{text:"abstract"}),l.descEl.createSpan({text:")"}),new
|
||
|
overflow: visible;
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa {
|
||
|
display: inline-block;
|
||
|
font-size: inherit;
|
||
|
height: 1em;
|
||
|
overflow: visible;
|
||
|
vertical-align: -0.125em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-lg {
|
||
|
vertical-align: -0.225em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-1 {
|
||
|
width: 0.0625em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-2 {
|
||
|
width: 0.125em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-3 {
|
||
|
width: 0.1875em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-4 {
|
||
|
width: 0.25em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-5 {
|
||
|
width: 0.3125em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-6 {
|
||
|
width: 0.375em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-7 {
|
||
|
width: 0.4375em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-8 {
|
||
|
width: 0.5em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-9 {
|
||
|
width: 0.5625em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-10 {
|
||
|
width: 0.625em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-11 {
|
||
|
width: 0.6875em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-12 {
|
||
|
width: 0.75em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-13 {
|
||
|
width: 0.8125em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-14 {
|
||
|
width: 0.875em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-15 {
|
||
|
width: 0.9375em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-16 {
|
||
|
width: 1em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-17 {
|
||
|
width: 1.0625em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-18 {
|
||
|
width: 1.125em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-19 {
|
||
|
width: 1.1875em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-w-20 {
|
||
|
width: 1.25em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-pull-left {
|
||
|
margin-right: 0.3em;
|
||
|
width: auto;
|
||
|
}
|
||
|
.svg-inline--fa.fa-pull-right {
|
||
|
margin-left: 0.3em;
|
||
|
width: auto;
|
||
|
}
|
||
|
.svg-inline--fa.fa-border {
|
||
|
height: 1.5em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-li {
|
||
|
width: 2em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-fw {
|
||
|
width: 1.25em;
|
||
|
}
|
||
|
|
||
|
.fa-layers svg.svg-inline--fa {
|
||
|
bottom: 0;
|
||
|
left: 0;
|
||
|
margin: auto;
|
||
|
position: absolute;
|
||
|
right: 0;
|
||
|
top: 0;
|
||
|
}
|
||
|
|
||
|
.fa-layers {
|
||
|
display: inline-block;
|
||
|
height: 1em;
|
||
|
position: relative;
|
||
|
text-align: center;
|
||
|
vertical-align: -0.125em;
|
||
|
width: 1em;
|
||
|
}
|
||
|
.fa-layers svg.svg-inline--fa {
|
||
|
-webkit-transform-origin: center center;
|
||
|
transform-origin: center center;
|
||
|
}
|
||
|
|
||
|
.fa-layers-counter, .fa-layers-text {
|
||
|
display: inline-block;
|
||
|
position: absolute;
|
||
|
text-align: center;
|
||
|
}
|
||
|
|
||
|
.fa-layers-text {
|
||
|
left: 50%;
|
||
|
top: 50%;
|
||
|
-webkit-transform: translate(-50%, -50%);
|
||
|
transform: translate(-50%, -50%);
|
||
|
-webkit-transform-origin: center center;
|
||
|
transform-origin: center center;
|
||
|
}
|
||
|
|
||
|
.fa-layers-counter {
|
||
|
background-color: #ff253a;
|
||
|
border-radius: 1em;
|
||
|
-webkit-box-sizing: border-box;
|
||
|
box-sizing: border-box;
|
||
|
color: #fff;
|
||
|
height: 1.5em;
|
||
|
line-height: 1;
|
||
|
max-width: 5em;
|
||
|
min-width: 1.5em;
|
||
|
overflow: hidden;
|
||
|
padding: 0.25em;
|
||
|
right: 0;
|
||
|
text-overflow: ellipsis;
|
||
|
top: 0;
|
||
|
-webkit-transform: scale(0.25);
|
||
|
transform: scale(0.25);
|
||
|
-webkit-transform-origin: top right;
|
||
|
transform-origin: top right;
|
||
|
}
|
||
|
|
||
|
.fa-layers-bottom-right {
|
||
|
bottom: 0;
|
||
|
right: 0;
|
||
|
top: auto;
|
||
|
-webkit-transform: scale(0.25);
|
||
|
transform: scale(0.25);
|
||
|
-webkit-transform-origin: bottom right;
|
||
|
transform-origin: bottom right;
|
||
|
}
|
||
|
|
||
|
.fa-layers-bottom-left {
|
||
|
bottom: 0;
|
||
|
left: 0;
|
||
|
right: auto;
|
||
|
top: auto;
|
||
|
-webkit-transform: scale(0.25);
|
||
|
transform: scale(0.25);
|
||
|
-webkit-transform-origin: bottom left;
|
||
|
transform-origin: bottom left;
|
||
|
}
|
||
|
|
||
|
.fa-layers-top-right {
|
||
|
right: 0;
|
||
|
top: 0;
|
||
|
-webkit-transform: scale(0.25);
|
||
|
transform: scale(0.25);
|
||
|
-webkit-transform-origin: top right;
|
||
|
transform-origin: top right;
|
||
|
}
|
||
|
|
||
|
.fa-layers-top-left {
|
||
|
left: 0;
|
||
|
right: auto;
|
||
|
top: 0;
|
||
|
-webkit-transform: scale(0.25);
|
||
|
transform: scale(0.25);
|
||
|
-webkit-transform-origin: top left;
|
||
|
transform-origin: top left;
|
||
|
}
|
||
|
|
||
|
.fa-lg {
|
||
|
font-size: 1.3333333333em;
|
||
|
line-height: 0.75em;
|
||
|
vertical-align: -0.0667em;
|
||
|
}
|
||
|
|
||
|
.fa-xs {
|
||
|
font-size: 0.75em;
|
||
|
}
|
||
|
|
||
|
.fa-sm {
|
||
|
font-size: 0.875em;
|
||
|
}
|
||
|
|
||
|
.fa-1x {
|
||
|
font-size: 1em;
|
||
|
}
|
||
|
|
||
|
.fa-2x {
|
||
|
font-size: 2em;
|
||
|
}
|
||
|
|
||
|
.fa-3x {
|
||
|
font-size: 3em;
|
||
|
}
|
||
|
|
||
|
.fa-4x {
|
||
|
font-size: 4em;
|
||
|
}
|
||
|
|
||
|
.fa-5x {
|
||
|
font-size: 5em;
|
||
|
}
|
||
|
|
||
|
.fa-6x {
|
||
|
font-size: 6em;
|
||
|
}
|
||
|
|
||
|
.fa-7x {
|
||
|
font-size: 7em;
|
||
|
}
|
||
|
|
||
|
.fa-8x {
|
||
|
font-size: 8em;
|
||
|
}
|
||
|
|
||
|
.fa-9x {
|
||
|
font-size: 9em;
|
||
|
}
|
||
|
|
||
|
.fa-10x {
|
||
|
font-size: 10em;
|
||
|
}
|
||
|
|
||
|
.fa-fw {
|
||
|
text-align: center;
|
||
|
width: 1.25em;
|
||
|
}
|
||
|
|
||
|
.fa-ul {
|
||
|
list-style-type: none;
|
||
|
margin-left: 2.5em;
|
||
|
padding-left: 0;
|
||
|
}
|
||
|
.fa-ul > li {
|
||
|
position: relative;
|
||
|
}
|
||
|
|
||
|
.fa-li {
|
||
|
left: -2em;
|
||
|
position: absolute;
|
||
|
text-align: center;
|
||
|
width: 2em;
|
||
|
line-height: inherit;
|
||
|
}
|
||
|
|
||
|
.fa-border {
|
||
|
border: solid 0.08em #eee;
|
||
|
border-radius: 0.1em;
|
||
|
padding: 0.2em 0.25em 0.15em;
|
||
|
}
|
||
|
|
||
|
.fa-pull-left {
|
||
|
float: left;
|
||
|
}
|
||
|
|
||
|
.fa-pull-right {
|
||
|
float: right;
|
||
|
}
|
||
|
|
||
|
.fa.fa-pull-left,
|
||
|
.fas.fa-pull-left,
|
||
|
.far.fa-pull-left,
|
||
|
.fal.fa-pull-left,
|
||
|
.fab.fa-pull-left {
|
||
|
margin-right: 0.3em;
|
||
|
}
|
||
|
.fa.fa-pull-right,
|
||
|
.fas.fa-pull-right,
|
||
|
.far.fa-pull-right,
|
||
|
.fal.fa-pull-right,
|
||
|
.fab.fa-pull-right {
|
||
|
margin-left: 0.3em;
|
||
|
}
|
||
|
|
||
|
.fa-spin {
|
||
|
-webkit-animation: fa-spin 2s infinite linear;
|
||
|
animation: fa-spin 2s infinite linear;
|
||
|
}
|
||
|
|
||
|
.fa-pulse {
|
||
|
-webkit-animation: fa-spin 1s infinite steps(8);
|
||
|
animation: fa-spin 1s infinite steps(8);
|
||
|
}
|
||
|
|
||
|
@-webkit-keyframes fa-spin {
|
||
|
0% {
|
||
|
-webkit-transform: rotate(0deg);
|
||
|
transform: rotate(0deg);
|
||
|
}
|
||
|
100% {
|
||
|
-webkit-transform: rotate(360deg);
|
||
|
transform: rotate(360deg);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@keyframes fa-spin {
|
||
|
0% {
|
||
|
-webkit-transform: rotate(0deg);
|
||
|
transform: rotate(0deg);
|
||
|
}
|
||
|
100% {
|
||
|
-webkit-transform: rotate(360deg);
|
||
|
transform: rotate(360deg);
|
||
|
}
|
||
|
}
|
||
|
.fa-rotate-90 {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";
|
||
|
-webkit-transform: rotate(90deg);
|
||
|
transform: rotate(90deg);
|
||
|
}
|
||
|
|
||
|
.fa-rotate-180 {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";
|
||
|
-webkit-transform: rotate(180deg);
|
||
|
transform: rotate(180deg);
|
||
|
}
|
||
|
|
||
|
.fa-rotate-270 {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
|
||
|
-webkit-transform: rotate(270deg);
|
||
|
transform: rotate(270deg);
|
||
|
}
|
||
|
|
||
|
.fa-flip-horizontal {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";
|
||
|
-webkit-transform: scale(-1, 1);
|
||
|
transform: scale(-1, 1);
|
||
|
}
|
||
|
|
||
|
.fa-flip-vertical {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";
|
||
|
-webkit-transform: scale(1, -1);
|
||
|
transform: scale(1, -1);
|
||
|
}
|
||
|
|
||
|
.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {
|
||
|
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";
|
||
|
-webkit-transform: scale(-1, -1);
|
||
|
transform: scale(-1, -1);
|
||
|
}
|
||
|
|
||
|
:root .fa-rotate-90,
|
||
|
:root .fa-rotate-180,
|
||
|
:root .fa-rotate-270,
|
||
|
:root .fa-flip-horizontal,
|
||
|
:root .fa-flip-vertical,
|
||
|
:root .fa-flip-both {
|
||
|
-webkit-filter: none;
|
||
|
filter: none;
|
||
|
}
|
||
|
|
||
|
.fa-stack {
|
||
|
display: inline-block;
|
||
|
height: 2em;
|
||
|
position: relative;
|
||
|
width: 2.5em;
|
||
|
}
|
||
|
|
||
|
.fa-stack-1x,
|
||
|
.fa-stack-2x {
|
||
|
bottom: 0;
|
||
|
left: 0;
|
||
|
margin: auto;
|
||
|
position: absolute;
|
||
|
right: 0;
|
||
|
top: 0;
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa.fa-stack-1x {
|
||
|
height: 1em;
|
||
|
width: 1.25em;
|
||
|
}
|
||
|
.svg-inline--fa.fa-stack-2x {
|
||
|
height: 2em;
|
||
|
width: 2.5em;
|
||
|
}
|
||
|
|
||
|
.fa-inverse {
|
||
|
color: #fff;
|
||
|
}
|
||
|
|
||
|
.sr-only {
|
||
|
border: 0;
|
||
|
clip: rect(0, 0, 0, 0);
|
||
|
height: 1px;
|
||
|
margin: -1px;
|
||
|
overflow: hidden;
|
||
|
padding: 0;
|
||
|
position: absolute;
|
||
|
width: 1px;
|
||
|
}
|
||
|
|
||
|
.sr-only-focusable:active, .sr-only-focusable:focus {
|
||
|
clip: auto;
|
||
|
height: auto;
|
||
|
margin: 0;
|
||
|
overflow: visible;
|
||
|
position: static;
|
||
|
width: auto;
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa .fa-primary {
|
||
|
fill: var(--fa-primary-color, currentColor);
|
||
|
opacity: 1;
|
||
|
opacity: var(--fa-primary-opacity, 1);
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa .fa-secondary {
|
||
|
fill: var(--fa-secondary-color, currentColor);
|
||
|
opacity: 0.4;
|
||
|
opacity: var(--fa-secondary-opacity, 0.4);
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa.fa-swap-opacity .fa-primary {
|
||
|
opacity: 0.4;
|
||
|
opacity: var(--fa-secondary-opacity, 0.4);
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa.fa-swap-opacity .fa-secondary {
|
||
|
opacity: 1;
|
||
|
opacity: var(--fa-primary-opacity, 1);
|
||
|
}
|
||
|
|
||
|
.svg-inline--fa mask .fa-primary,
|
||
|
.svg-inline--fa mask .fa-secondary {
|
||
|
fill: black;
|
||
|
}
|
||
|
|
||
|
.fad.fa-inverse {
|
||
|
color: #fff;
|
||
|
}`;function hL(){var i=D2,c=E2,a=b.familyPrefix,e=b.replacementClass,n=sL;if(a!==i||e!==c){var l=new RegExp("\\.".concat(i,"\\-"),"g"),o=new RegExp("\\--".concat(i,"\\-"),"g"),r=new RegExp("\\.".concat(c),"g");n=n.replace(l,".".concat(a,"-")).replace(o,"--".concat(a,"-")).replace(r,".".concat(e))}return n}var vL=function(){function i(){Sg(this,i),this.definitions={}}return yg(i,[{key:"add",value:function(){for(var a=this,e=arguments.length,n=new Array(e),l=0;l<e;l++)n[l]=arguments[l];var o=n.reduce(this._pullDefinitions,{});Object.keys(o).forEach(function(r){a.definitions[r]=C({},a.definitions[r]||{},o[r]),J2(r,o[r]),X2()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(a,e){var n=e.prefix&&e.iconName&&e.icon?{0:e}:e;return Object.keys(n).map(function(l){var o=n[l],r=o.prefix,f=o.iconName,s=o.icon;a[r]||(a[r]={}),a[r][f]=s}),a}}]),i}();function mL(){b.autoAddCss&&!n4&&(Kg(hL()),n4=!0)}function zL(i,c){return Object.defineProperty(i,"abstract",{get:c}),Object.defineProperty(i,"html",{get:function(){return i.abstract.map(function(e){return a4(e)})}}),Object.defineProperty(i,"node",{get:function(){if(!!L1){var e=x.createElement("div");return e.innerHTML=i.html,e.children}}}),i}function F(i){var c=i.prefix,a=c===void 0?"fa":c,e=i.iconName;if(!!e)return c4(P1.definitions,a,e)||c4(k.styles,a,e)}function pL(i){return function(c){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=(c||{}).icon?c:F(c||{}),n=a.mask;return n&&(n=(n||{}).icon?n:F(n||{})),i(e,C({},a,{mask:n}))}}var P1=new vL;var n4=!1;var l4=pL(function(i){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=c.transform,e=a===void 0?U:a,n=c.symbol,l=n===void 0?!1:n,o=c.mask,r=o===void 0?null:o,f=c.maskId,s=f===void 0?null:f,h=c.title,t=h===void 0?null:h,m=c.titleId,z=m===void 0?null:m,V=c.classes,H=V===void 0?[]:V,p=c.attributes,u=p===void 0?{}:p,g=c.styles,L=g===void 0?{}:g;if(!!i){var w=i.prefix,Z=i.iconName,E=i.icon;return zL(C({type:"icon"},i),function(){return mL(),b.autoA11y&&(t?u["aria-labelledby"]="".concat(b.replacementClass,"-title-").concat(z||f1()):(u["aria-hidden"]="true",u.focusable="false")),nL({icons:{main:i4(E),mask:r?i4(r.icon):{found:!1,width:null,height:null,icon:{}}},prefix:w,iconName:Z,transform:C({},U,e),symbol:l,title:t,maskId:s,titleId:z,extra:{attributes:u,styles:L,classes:H}})})}});var I=S(require("obsidian"));P1.add(H1,C1,V1,u1);var D1=class{constructor(c){this.plugin=c;this.DOWNLOADED={};this.FONT_AWESOME_MAP=new Map([Object.values(H1),Object.values(C1),Object.values(V1)].flat().map(c=>[c.iconName,{name:c.iconName,type:"font-awesome"}]));this.iconDefinitions=[]}async load(){for(let c of this.plugin.data.icons)await this.plugin.app.vault.adapter.exists(this.localIconPath(c))?this.DOWNLOADED[c]=JSON.parse(await this.plugin.app.vault.adapter.read(`${this.plugin.app.plugins.getPluginFolder()}/obsidian-admonition/${c}.json`)):await this.downloadIcon(c);this.setIconDefinitions()}setIconDefinitions(){let c=[];for(let a of this.plugin.data.icons){if(!(a in this.DOWNLOADED))continue;let e=this.DOWNLOADED[a];c.push(...Object.keys(e).map(n=>({type:a,name:n})))}this.iconDefinitions=[...this.plugin.data.useFontAwesome?this.FONT_AWESOME_MAP.values():[],...(0,I.getIconIds)().map(a=>({type:"obsidian",name:a})),...c]}iconPath(c){return`https://raw.githubusercontent.com/valentine195/obsidian-admonition/master/icons/${c}/icons.json`}localIconPath(c){return`${this.plugin.app.plugins.getPluginFolder()}/obsidian-admonition/${c}.json`}async downloadIcon(c){try{let a=await(await fetch(this.iconPath(c))).json();this.plugin.data.icons.push(c),this.plugin.data.icons=[...new Set(this.plugin.data.icons)],await this.plugin.app.vault.adapter.write(this.localIconPath(c),JSON.stringify(a)),this.DOWNLOADED[c]=a,await this.plugin.saveSettings(),this.setIconDefinitions(),new I.Notice(`${B[c]} successfully downloaded.`)}catch(a){console.error(a),new I.Notice("Could not download icon pack")}}async removeIcon(c){await this.plugin.app.vault.adapter.remove(this.localIconPath(c)),delete this.DOWNLOADED[c],t
|
||
|
`)[h],[,z]=m.match(/> \[!.+\|(.*)]/)??[];if(z&&(e.dataset.calloutMetadata=z),r&&(this.plugin.admonitions[n].copy??this.plugin.data.copyButton)){let V=r.createDiv("admonition-content-copy");(0,q.setIcon)(V,"copy"),V.addEventListener("click",()=>{navigator.clipboard.writeText(s.split(`
|
||
|
`).slice(h+1,t+1).join(`
|
||
|
`).replace(/^> /gm,"")).then(async()=>{new q.Notice("Callout content copied to clipboard.")})})}}if(l.noTitle&&!e.dataset.calloutFold&&o.querySelector(".callout-title-inner")?.textContent?.toLowerCase()===l.type.toLowerCase()&&o.addClass("no-title"),!l.noTitle&&this.plugin.data.autoCollapse&&!e.dataset.calloutFold&&this.setCollapsible(e),l.title&&o.textContent==n[0].toUpperCase()+n.slice(1).toLowerCase()){let s=o.querySelector(".callout-title-inner");s&&s.setText(l.title)}this.plugin.data.dropShadow&&e.addClass("drop-shadow")}setCollapsible(c){let a=c.querySelector(".callout-title"),e=c.querySelector(".callout-content");if(!e)return;c.addClass("is-collapsible"),this.plugin.data.defaultCollapseType=="closed"?(c.dataset.calloutFold="-",c.addClass("is-collapsed")):c.dataset.calloutFold="+";let n=a.createDiv("callout-fold");(0,q.setIcon)(n,"chevron-down");let l=c.hasClass("is-collapsed");if(this.getComputedHeights(e),l)for(let o of this.heights)e.style.setProperty(o,"0px");a.onclick=o=>{this.collapse(c,o)}}collapse(c,a){a?.preventDefault();let e=c.querySelector(".callout-content");function n(o){e.removeEventListener("transitionend",n),e.style.removeProperty("transition")}e.addEventListener("transitionend",n),e.style.setProperty("transition","all 100ms cubic-bezier(.02, .01, .47, 1)");let l=c.hasClass("is-collapsed");if(!a||a.button==0){let o=this.getComputedHeights(e);for(let r of this.heights)e.style.setProperty(r,l?o[r]:"0px");c.toggleClass("is-collapsed",!l)}}getComputedHeights(c){if(this.heightMap.has(c))return this.heightMap.get(c);let a=getComputedStyle(c),e={};for(let n of this.heights)e[n]=a.getPropertyValue(n);return this.heightMap.set(c,e),e}generateCssString(){let c=[`/* This snippet was auto-generated by the Admonitions plugin */
|
||
|
|
||
|
`];for(let a of Array.from(this.sheet.cssRules))c.push(a.cssText);return c.join(`
|
||
|
|
||
|
`)}addAdmonition(c){if(!c.icon)return;let a,e=c.injectColor??this.plugin.data.injectColor?`--callout-color: ${c.color};`:"";c.icon.type=="obsidian"?a=`.callout[data-callout="${c.type.toLowerCase()}"] {
|
||
|
${e}
|
||
|
--callout-icon: ${c.icon.name}; /* Icon name from the Obsidian Icon Set */
|
||
|
}`:a=`.callout[data-callout="${c.type.toLowerCase()}"] {
|
||
|
${e}
|
||
|
--callout-icon: "${(this.plugin.iconManager.getIconNode(c.icon)?.outerHTML??"").replace(/(width|height)=(\\?"|')\d+(\\?"|')/g,"").replace(/"/g,'\\"')}";
|
||
|
}`,this.indexing.contains(c.type)&&this.sheet.deleteRule(this.indexing.indexOf(c.type)),this.indexing=[...this.indexing.filter(n=>n!=c.type),c.type],this.sheet.insertRule(a,this.sheet.cssRules.length),this.updateSnippet()}removeAdmonition(c){if(!this.indexing.contains(c.type))return;let a=this.indexing.indexOf(c.type);this.sheet.deleteRule(a),this.indexing.splice(a,1),this.updateSnippet()}get sheet(){return this.style.sheet}unload(){this.style.detach()}get snippetPath(){return this.plugin.app.customCss.getSnippetPath(this.plugin.data.snippetPath)}setUseSnippet(){this.plugin.data.useSnippet&&this.updateSnippet()}async updateSnippet(){!this.plugin.data.useSnippet||(await this.plugin.app.vault.adapter.exists(this.snippetPath)?await this.plugin.app.vault.adapter.write(this.snippetPath,this.generateCssString()):await this.plugin.app.vault.create(this.snippetPath,this.generateCssString()),this.plugin.app.customCss.setCssEnabledStatus(this.plugin.data.snippetPath,!0),this.plugin.app.customCss.readSnippets())}};var dL={userAdmonitions:{},syntaxHighlight:!1,copyButton:!1,version:"",autoCollapse:!1,defaultCollapseType:"open",injectColor:!0,parseTitles:!0,dropShadow:!0,hideEmpty:!1,open:{admonitions:!0,icons:!0,other:!0,advanced:!1},icons:[],useFontAwesome:!0,rpgDownloadedOnce:!1,msDocConverted:!1,useSnippet:!1,snippetPath:`custom-admonitions.${[...Array(6).keys()].map(()=>(16*Math.random()|0).toString(16)).join("")}`},B1=class extends d.Plugin{constructor(){super(...arguments);this.postprocessors=new Map;this.iconManager=new D1(this)}get types(){return Object.keys(this.admonitions)}get admonitionArray(){return Object.keys(this.admonitions).map(c=>({...this.admonitions[c],type:c}))}async onload(){console.log("Obsidian Admonition loaded"),this.postprocessors=new Map,await this.loadSettings(),await this.iconManager.load(),this.app.workspace.onLayoutReady(async()=>{this.addChild(this.calloutManager=new s1(this)),this.registerEditorSuggest(new Z1(this)),Object.keys(this.admonitions).forEach(c=>{this.registerType(c)}),this.addSettingTab(new e1(this.app,this)),(0,d.addIcon)(Q,U1),(0,d.addIcon)(X,G1),(0,d.addIcon)(G,_1),(0,d.addIcon)(_,W1),this.addCommand({id:"collapse-admonitions",name:"Collapse Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(d.MarkdownView);let a=this.app.workspace.getActiveViewOfType(d.MarkdownView);if(!a||!(a instanceof d.MarkdownView))return;let e=a.contentEl.querySelectorAll(".callout.is-collapsible:not(.is-collapsed)");for(let n=0;n<e.length;n++){let l=e[n];this.calloutManager.collapse(l)}}}),this.addCommand({id:"open-admonitions",name:"Open Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(d.MarkdownView);let a=this.app.workspace.getActiveViewOfType(d.MarkdownView);if(!a||!(a instanceof d.MarkdownView))return;let e=a.contentEl.querySelectorAll(".callout.is-collapsible.is-collapsed");for(let n=0;n<e.length;n++){let l=e[n];this.calloutManager.collapse(l)}}}),this.addCommand({id:"insert-admonition",name:"Insert Admonition",editorCallback:(c,a)=>{let e=new c1(this);e.onClose=()=>{if(!e.insert)return;let n="",l="";e.title.length&&e.title.toLowerCase()!=e.type.toLowerCase()&&(n=`title: ${e.title}
|
||
|
`),(this.data.autoCollapse&&e.collapse!=this.data.defaultCollapseType||!this.data.autoCollapse&&e.collapse!="none")&&(l=`collapse: ${e.collapse}
|
||
|
`),c.getDoc().replaceSelection(`\`\`\`ad-${e.type}
|
||
|
${n}${l}
|
||
|
${c.getDoc().getSelection()}
|
||
|
\`\`\`
|
||
|
`);let o=c.getCursor();c.setCursor(o.line-3)},e.open()}}),this.addCommand({id:"insert-callout",name:"Insert Callout",editorCallback:(c,a)=>{let e=new c1(this);e.onClose=()=>{if(!e.insert)return;let n="",l="";if(this.data.autoCollapse&&e.collapse!=this.data.defaultCollapseType||!this.data.autoCollapse&&e.collapse!="none")switch(e.collapse){case"open":{l="+";break}case"closed":{l="-";break}}e.title.length&&e.title.toLowerCase()!=e.type.toLowerCase()&&(n=` ${e.title}`);let o=c.getDoc().getSelection();c.getDoc().replaceSelection(`> [!${e.type}]${l}${n}
|
||
|
> ${o.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`)},e.open()}})})}async downloadIcon(c){this.iconManager.downloadIcon(c)}async removeIcon(c){this.iconManager.removeIcon(c)}async postprocessor(c,a,e,n){if(!!this.admonitions[c])try{let l=typeof n=="string"?n:n?.sourcePath??this.app.workspace.getActiveFile()?.path??"",{title:o,collapse:r,content:f,icon:s,color:h,metadata:t}=R1(c,a,this.admonitions[c]);this.data.autoCollapse&&!r?r=this.data.defaultCollapseType??"open":r&&r.trim()==="none"&&(r="");let m=this.admonitions[c],z=this.getAdmonitionElement(c,o,this.iconManager.iconDefinitions.find(({name:p})=>s===p)??m.icon,h??(m.injectColor??this.data.injectColor?m.color:null),r,l,t);this.renderAdmonitionContent(z,c,f,n,l,a),r&&r!="none"&&this.calloutManager.setCollapsible(z);let V=e.parentElement;V&&V.addClass("admonition-parent",`admonition-${c}-parent`),e.replaceWith(z);let H=app.workspace.getActiveViewOfType(d.MarkdownView);if(H?.editor?.cm?.state?.field(d.editorLivePreviewField)){let p=H.editor.cm;z.onClickEvent(u=>{if(!(u.defaultPrevented||u.detail>1||u.shiftKey))try{setTimeout(()=>{try{let g=p.posAtDOM(z);p.focus(),p.dispatch({selection:{head:g,anchor:g}})}catch{}},10)}catch{}})}return z}catch(l){console.error(l);let o=createEl("pre");o.createEl("code",{attr:{style:"color: var(--text-error) !important"}}).createSpan({text:`There was an error rendering the admonition:
|
||
|
|
||
|
`+a}),e.replaceWith(o)}}getAdmonitionElement(c,a,e,n,l,o,r){let f=createDiv({cls:`callout admonition admonition-${c} admonition-plugin ${a?.trim().length?"":"no-title"}`,attr:{style:n?`--callout-color: ${n};`:"","data-callout":c,"data-callout-fold":"","data-callout-metadata":r??""}}),s=f.createDiv({cls:`callout-title admonition-title ${a?.trim().length?"":"no-title"}`});if(a&&a.trim().length){let h=s.createDiv("callout-icon admonition-title-icon");e&&e.name&&e.type&&h.appendChild(this.iconManager.getIconNode(e)??createDiv());let t=s.createDiv("callout-title-inner admonition-title-content");d.MarkdownRenderer.render(this.app,a,t,o??"",this),t.firstElementChild&&t.firstElementChild instanceof HTMLParagraphElement&&t.setChildrenInPlace(Array.from(t.firstElementChild.childNodes))}return l&&(f.addClass("is-collapsible"),l=="closed"&&f.addClass("is-collapsed")),this.data.dropShadow||f.addClass("no-drop"),f}renderAdmonitionContent(c,a,e,n,l,o){let r=new d.MarkdownRenderChild(c);if(r.containerEl=c,n&&typeof n!="string"&&n.addChild(r),e&&e?.trim().length){let f=this.getAdmonitionContentElement(a,c,e);if(/^`{3,}mermaid/m.test(e)){let h=!c.hasAttribute("open");c instanceof HTMLDetailsElement&&c.setAttribute("open","open"),setImmediate(()=>{d.MarkdownRenderer.renderMarkdown(e,f,l,r),c instanceof HTMLDetailsElement&&h&&c.removeAttribute("open")})}else d.MarkdownRenderer.renderMarkdown(e,f,l,r);(!e.length||f.textContent.trim()=="")&&this.data.hideEmpty&&c.addClass("no-content");let s=f.querySelectorAll(".task-list-item-checkbox");if(s?.length){let h=o.split(`
|
||
|
`),t=0;s.forEach(m=>{let z=h.slice(t).findIndex(V=>/^[ \t>]*\- \[.\]/.test(V));z!=-1&&(m.dataset.line=`${z+t+1}`,t=z+t+1)})}}}getAdmonitionContentElement(c,a,e){let n=a.createDiv("callout-content admonition-content");if(this.admonitions[c].copy??this.data.copyButton){let l=n.createDiv("admonition-content-copy");(0,d.setIcon)(l,"copy"),l.addEventListener("click",()=>{navigator.clipboard.writeText(e.trim()).then(async()=>{new d.Notice("Admonition content copied to clipboard.")})})}return n}registerType(c){this.data.syntaxHighlight&&this.turnOnSyntaxHighlighting([c]),this.postprocessors.has(c)&&d.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c}`),this.postprocessors.set(c,this.registerMarkdownCodeBlockProcessor(`ad-${c}`,(e,n,l)=>this.postprocessor(c,e,n,l)));let a=this.admonitions[c];a.command&&this.registerCommandsFor(a)}get admonitions(){return{...j1,...this.data.userAdmonitions}}async addAdmonition(c){this.data.userAdmonitions={...this.data.userAdmonitions,[c.type]:c},this.registerType(c.type),this.calloutManager.addAdmonition(c),await this.saveSettings()}registerCommandsFor(c){c.command=!0,this.addCommand({id:`insert-${c.type}-callout`,name:`Insert ${c.type} Callout`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{let l=e.getDoc().getSelection();e.getDoc().replaceSelection(`> [!${c.type}]
|
||
|
> ${l.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`);let o=e.getCursor();e.setCursor(o.line-2)}catch{new d.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}`,name:`Insert ${c.type}`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
|
||
|
${e.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let l=e.getCursor();e.setCursor(l.line-2)}catch{new d.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}-with-title`,name:`Insert ${c.type} With Title`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{let l=c.title??"";e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
title: ${l}
|
||
|
|
||
|
${e.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let o=e.getCursor();e.setCursor(o.line-3)}catch{new d.Notice("There was an issue inserting the admonition.")}}})}unregisterType(c){this.data.syntaxHighlight&&this.turnOffSyntaxHighlighting([c.type]),c.command&&this.unregisterCommandsFor(c),this.postprocessors.has(c.type)&&(d.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),d.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c.type}`),this.postprocessors.delete(c.type))}async removeAdmonition(c){this.data.userAdmonitions[c.type]&&delete this.data.userAdmonitions[c.type],this.unregisterType(c),this.calloutManager.removeAdmonition(c),await this.saveSettings()}unregisterCommandsFor(c){c.command=!1,this.app.commands.findCommand(`obsidian-admonition:insert-${c.type}`)&&(delete this.app.commands.editorCommands[`obsidian-admonition:insert-${c.type}`],delete this.app.commands.editorCommands[`obsidian-admonition:insert-${c.type}-with-title`],delete this.app.commands.commands[`obsidian-admonition:insert-${c.type}`],delete this.app.commands.commands[`obsidian-admonition:insert-${c.type}-with-title`])}async saveSettings(){this.data.version=this.manifest.version,await this.saveData(this.data)}async loadSettings(){let c=await this.loadData();if(this.data=Object.assign({},dL,c),this.data.userAdmonitions){if(!this.data.version||Number(this.data.version.split(".")[0])<5)for(let a in this.data.userAdmonitions)Object.prototype.hasOwnProperty.call(this.data.userAdmonitions[a],"type")||(this.data.userAdmonitions[a]={...this.data.userAdmonitions[a],icon:{type:"font-awesome",name:this.data.userAdmonitions[a].icon}});(!this.data.version||Number(this.data.version.split(".")[0])<8)&&new d.Notice(createFragment(a=>{a.createSpan({text:"Admonitions: Obsidian now has native support for callouts! Check out the "}),a.createEl("a",{text:"Admonitions ReadMe",href:"obsidian://show-plugin?id=obsidian-admonition"}),a.createSpan({text:" for what that means for Admonitions going forward."})}),0)}if(!this.data.rpgDownloadedOnce&&this.data.userAdmonitions&&Object.values(this.data.userAdmonitions).some(a=>{if(a.icon.type=="rpg")return!0})&&!this.data.icons.includes("rpg"))try{await this.downloadIcon("rpg"),this.data.rpgDownloadedOnce=!0}catch{}await this.saveSettings()}turnOnSyntaxHighlighting(c=Object.keys(this.admonitions)){!this.data.syntaxHighlight||(c.forEach(a=>{if(this.data.syntaxHighlight){let[,e]=`${a}`.match(/^([\w+#-]*)[^\n`]*$/);window.CodeMirror.defineMode(`ad-${e}`,(n,l)=>window.CodeMirror.getMode({},"hypermd"))}}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(a=>a.setOption("mode",a.getOption("mode")))))}turnOffSyntaxHighlighting(c=Object.keys(this.admonitions)){c.forEach(a=>{window.CodeMirror.modes.hasOwnProperty(`ad-${a}`)&&delete window.CodeMirror.modes[`ad-${a}`]}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(a=>a.setOption("mode",a.getOption("mode"))))}async onunload(){console.log("Obsidian Admonition unloaded"),this.postprocessors=null,this.turnOffSyntaxHighlighting()}};
|
||
|
/*!
|
||
|
* Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
|
||
|
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||
|
*/
|