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 v6=Object.create;var t2=Object.defineProperty;var z6=Object.getOwnPropertyDescriptor;var p6=Object.getOwnPropertyNames;var d6=Object.getPrototypeOf,u6=Object.prototype.hasOwnProperty;var x4=e=>t2(e,"__esModule",{value:!0});var M6=(e,c)=>{x4(e);for(var a in c)t2(e,a,{get:c[a],enumerable:!0})},C6=(e,c,a)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of p6(c))!u6.call(e,i)&&i!=="default"&&t2(e,i,{get:()=>c[i],enumerable:!(a=z6(c,i))||a.enumerable});return e},i1=e=>C6(x4(t2(e!=null?v6(d6(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);M6(exports,{default:()=>v4});var b=i1(require("obsidian"));var L4=i1(require("obsidian"));function H6(e,c){for(let a=0;a<c.length;a++)if(e.startsWith(c[a]))return a;return!1}function b4(e,c,a){let i=a.title??e[0].toUpperCase()+e.slice(1).toLowerCase(),n=["title:","collapse:","icon:","color:"],t=["title","collapse","icon","color"],r=c.split(`
|
||
|
`),o=0,l={};for(let u=0;u<r.length;u++){let d=H6(r[u],n);if(d===!1)break;let p=t[d];if(l[p]!==void 0)break;l[p]=r[u].slice(n[d].length).trim(),++o}let{title:f,collapse:s,icon:h,color:v}=l,m=r.slice(o).join(`
|
||
|
`);return s!==void 0&&s!=="none"&&s!=="open"&&s!=="closed"&&(s="closed"),"title"in l||a.noTitle||(f=i),f&&f.trim()===""&&s!==void 0&&s!=="none"&&(f=i,new L4.Notice("An admonition must have a title if it is collapsible.")),{title:f,collapse:s,content:m,icon:h,color:v}}var N4='<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>',o2="admonition-add-command",A4='<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>',r2="admonition-remove-command",y4='<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>',F1="admonition-warning",S4='<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, Inc. --><path d="M304 48C304 74.51 282.5 96 256 96C229.5 96 208 74.51 208 48C208 21.49 229.5 0 256 0C282.5 0 304 21.49 304 48zM304 464C304 490.5 282.5 512 256 512C229.5 512 208 490.5 208 464C208 437.5 229.5 416 256 416C282.5 416 304 437.5 304 464zM0 256C0 229.5 21.49 208 48 208C74.51 208 96 229.5 96 256C96 282.5 74.51 304 48 304C21.49 304 0 282.5 0 256zM512 256C512 282.5 490.5 304 464 304C437.5 304 416 282.5 416 256C416 229.5 437.5 208 464 208C490.5 208 512 229.5 512 256zM74.98 437C56.23 418.3 56.23 387.9 74.98 369.1C93.73 350.4 124.1 350.4 142.9 369.1C161.6 387.9 161.6 418.3 142.9 437C124.1 455.8 93.73 455.8 74.98 437V437zM142.9 142.9C124
|
||
|
|
||
|
`],t=new Blob([this.plugin.calloutManager.generateCssString()],{type:"text/css"});createEl("a",{attr:{download:"custom_callouts.css",href:URL.createObjectURL(t)}}).click()}).setDisabled(!Object.keys(this.plugin.data.userAdmonitions).length)),new z.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(i=>i.setButtonText("Download All").setCta().onClick(()=>{let n=Object.values(this.plugin.data.userAdmonitions);this.download(n)})).addButton(i=>i.setButtonText("Select & Download").onClick(()=>{let n=new p2(this.plugin);n.onClose=()=>{if(!n.export)return;let t=Object.values(this.plugin.data.userAdmonitions);this.download(t.filter(r=>n.selectedAdmonitions.includes(r.type)))},n.open()})),new z.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(i=>i.setValue(this.plugin.data.useSnippet).onChange(n=>{this.plugin.data.useSnippet=n,this.plugin.saveSettings(),this.plugin.calloutManager.setUseSnippet()})),new z.Setting(c).setName(L("Add New")).setDesc("Add a new Admonition type. All custom Admonitions will also be usable as callouts.").addButton(i=>i.setTooltip(L("Add Additional")).setButtonText("+").onClick(async()=>{let t=new l1(this.plugin);t.onClose=async()=>{if(t.saved){let r={type:t.type,color:t.color,icon:t.icon,command:!1,title:t.title,injectColor:t.injectColor,noTitle:t.noTitle,copy:t.copy};this.plugin.addAdmonition(r),this.plugin.calloutManager.addAdmonition(r),this.display()}},t.open()})),new z.Setting(c).setName("Import Admonition(s)").setDesc("Import admonitions from a JSON definition.").addButton(i=>{let n=createEl("input",{attr:{type:"file",name:"merge",accept:".json",multiple:!0,style:"display: none;"}});n.onchange=async()=>{let{files:t}=n;if(!!t.length){try{let r=[];for(let o of Array.from(t))r.push(JSON.parse(await o.text()));for(let o of r.flat()){if(typeof o!="object")continue;o.icon||(o.icon={name:"pencil-alt",type:"font-awesome"});let l=e1.validateImport(this.plugin,o);if(l.success==!1){new z.Notice(createFragment(f=>{f.createSpan({text:`There was an issue importing the ${o.type} admonition:`}),f.createEl("br"),f.createSpan({text:l.message})}));continue}l.messages?.length&&new z.Notice(createFragment(f=>{f.createSpan({text:`There was an issue importing the ${o.type} admonition:`});for(let s of l.messages)f.createEl("br"),f.createSpan({text:s})})),await this.plugin.addAdmonition(o)}this.display()}catch(r){new z.Notice(`There was an error while importing the admonition${t.length==1?"":"s"}.`),console.error(r)}n.value=null}},i.setButtonText("Choose Files"),i.buttonEl.appendChild(n),i.onClick(()=>n.click())}).addExtraButton(i=>i.setIcon("info").onClick(()=>{let n=new z.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 t=new z.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));t.inputEl.setAttribute("style",`height: ${t.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:{...
|
||
|
`).slice(1,-1)){if(l){if(/^title:/.test(s)){t=s.match(/^title:(.*)/)?.[1].trim()??n[0].toUpperCase()+n.slice(1).toLowerCase();continue}if(/^collapse:/.test(s)){r=(s.match(/^collapse:\s?(.*)/)?.[1].trim()??"open")=="open"?"+":"-";continue}/^(title|collapse|color|icon):/.test(s)||(l=!1)}o.push(s)}let f=o.join(`
|
||
|
`);/^(`{3,})ad-(\w+)([\s\S]*?)?\n^\1/m.test(f)&&(f=this.replaceCodeBlockInPlace(f)),c=c.replace(i,`> [!${n}]${r}${t.length?" ":""}${t}
|
||
|
> ${f.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 z.Setting(a).setHeading().setName("Advanced Settings"),a.createDiv("collapser").createDiv("handle"),new z.Setting(c).setName(L("Markdown Syntax Highlighting")).setDesc(L("Use Obsidian's markdown syntax highlighter in admonition code blocks. This setting is experimental and could cause errors.")).addToggle(i=>{i.setValue(this.plugin.data.syntaxHighlight),i.onChange(async n=>{this.plugin.data.syntaxHighlight=n,n?this.plugin.turnOnSyntaxHighlighting():this.plugin.turnOffSyntaxHighlighting(),await this.plugin.saveSettings()})}),new z.Setting(c).setName("Generate JS for Publish").setDesc(createFragment(i=>{i.createSpan({text:"Generate a javascript file to place in your "}),i.createEl("code",{text:"publish.js"}),i.createSpan({text:"file."}),i.createEl("br"),i.createEl("strong",{text:"Please note that this can only be done on custom domain publish sites."})})).addButton(i=>{i.setButtonText("Generate"),i.onClick(n=>{let t={};for(let f in this.plugin.admonitions){let s=this.plugin.admonitions[f];t[f]={icon:this.plugin.iconManager.getIconNode(s.icon)?.outerHTML??"",color:s.color}}let r=c3.replace(/ADMONITION_ICON_MAP\s?=\s?\{\}/,"ADMONITION_ICON_MAP="+JSON.stringify(t)),o=new Blob([r],{type:"text/javascript"}),l=createEl("a",{href:URL.createObjectURL(o),attr:{download:"publish.admonition.js"}});l.click(),l.detach()})})}buildTypes(){this.additionalEl.empty();for(let c of Object.values(this.plugin.data.userAdmonitions)){let a=new z.Setting(this.additionalEl),i=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(i),c.command?a.addExtraButton(n=>{n.setIcon(r2.toString()).setTooltip(L("Unregister Commands")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),await this.plugin.saveSettings(),this.display()})}):a.addExtraButton(n=>{n.setIcon(o2.toString()).setTooltip(L("Register Commands")).onClick(async()=>{this.plugin.registerCommandsFor(c),await this.plugin.saveSettings(),this.display()})}),a.addExtraButton(n=>{n.setIcon("pencil").setTooltip(L("Edit")).onClick(()=>{let t=new l1(this.plugin,c);t.onClose=async()=>{if(t.saved){let r=c.command,o={type:t.type,color:t.color,icon:t.icon,command:r,title:t.title,injectColor:t.injectColor,noTitle:t.noTitle,copy:t.copy};if(o.type!=c.type){this.plugin.unregisterType(c);let l=Object.entries(this.plugin.data.userAdmonitions);this.plugin.data.userAdmonitions=Object.fromEntries(l.map(([f,s])=>f==c.type?[o.type,o]:[f,s]))}else this.plugin.data.userAdmonitions[o.type]=o;this.plugin.registerType(o.type),this.plugin.calloutManager.addAdmonition(o),this.display()}},t.open()})}).addExtraButton(n=>{n.setIcon("trash").setTooltip(L("Delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},l1=class extends z.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;a&&(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)}async display(){let{contentEl:c}=this;c.empty();let a=c.createDiv(),i=this.title??this.type??"...";this.admonitionPreview=this.plugin.getAdmonitionElement(this.type,i[0].toUpperCase()+i.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."}),c.appendChild(this.admonitionPreview);let n,t=new z.Setting(a).setName(L("Admonition Type")).addText(h=>{n=h,n.setValue(this.type).onChange(v=>{let m=e1.validateType(v,this.plugin,this.originalType);if(m.success==!1){l1.setValidationError(h.inpu
|
||
|
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 Db(){var e=P3,c=D3,a=_.familyPrefix,i=_.replacementClass,n=Pb;if(a!==e||i!==c){var t=new RegExp("\\.".concat(e,"\\-"),"g"),r=new RegExp("\\--".concat(e,"\\-"),"g"),o=new RegExp("\\.".concat(c),"g");n=n.replace(t,".".concat(a,"-")).replace(r,"--".concat(a,"-")).replace(o,".".concat(i))}return n}var Ob=function(){function e(){QL(this,e),this.definitions={}}return XL(e,[{key:"add",value:function(){for(var a=this,i=arguments.length,n=new Array(i),t=0;t<i;t++)n[t]=arguments[t];var r=n.reduce(this._pullDefinitions,{});Object.keys(r).forEach(function(o){a.definitions[o]=N({},a.definitions[o]||{},r[o]),J3(o,r[o]),X3()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(a,i){var n=i.prefix&&i.iconName&&i.icon?{0:i}:i;return Object.keys(n).map(function(t){var r=n[t],o=r.prefix,l=r.iconName,f=r.icon;a[o]||(a[o]={}),a[o][l]=f}),a}}]),e}();function Ib(){_.autoAddCss&&!n6&&(Hb(Db()),n6=!0)}function Bb(e,c){return Object.defineProperty(e,"abstract",{get:c}),Object.defineProperty(e,"html",{get:function(){return e.abstract.map(function(i){return a6(i)})}}),Object.defineProperty(e,"node",{get:function(){if(!!Q2){var i=U.createElement("div");return i.innerHTML=e.html,i.children}}}),e}function w1(e){var c=e.prefix,a=c===void 0?"fa":c,i=e.iconName;if(!!i)return c6(l4.definitions,a,i)||c6(n1.styles,a,i)}function Rb(e){return function(c){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=(c||{}).icon?c:w1(c||{}),n=a.mask;return n&&(n=(n||{}).icon?n:w1(n||{})),e(i,N({},a,{mask:n}))}}var l4=new Ob;var n6=!1;var t6=Rb(function(e){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=c.transform,i=a===void 0?R1:a,n=c.symbol,t=n===void 0?!1:n,r=c.mask,o=r===void 0?null:r,l=c.maskId,f=l===void 0?null:l,s=c.title,h=s===void 0?null:s,v=c.titleId,m=v===void 0?null:v,u=c.classes,d=u===void 0?[]:u,p=c.attributes,M=p===void 0?{}:p,g=c.styles,V=g===void 0?{}:g;if(!!e){var H=e.prefix,x=e.iconName,C=e.icon;return Bb(N({type:"icon"},e),function(){return Ib(),_.autoA11y&&(h?M["aria-labelledby"]="".concat(_.replacementClass,"-title-").concat(m||V2()):(M["aria-hidden"]="true",M.focusable="false")),yb({icons:{main:i6(C),mask:o?i6(o.icon):{found:!1,width:null,height:null,icon:{}}},prefix:H,iconName:x,transform:N({},R1,i),symbol:t,title:h,maskId:f,titleId:m,extra:{attributes:M,styles:V,classes:d}})})}});var z1=i1(require("obsidian"));l4.add(Y2,$2,K2,_2);var f4=class{constructor(c){this.plugin=c;this.DOWNLOADED={};this.FONT_AWESOME_MAP=new Map([Object.values(Y2),Object.values($2),Object.values(K2)].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 i=this.DOWNLOADED[a];c.push(...Object.keys(i).map(n=>({type:a,name:n})))}this.iconDefinitions=[...this.plugin.data.useFontAwesome?this.FONT_AWESOME_MAP.values():[],...(0,z1.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 z1.Notice(`${y1[c]} successfully downloaded.`)}catch(a){console.error(a),new z1.Notice("Could not download icon pack")}}async removeIcon(c){await this.plugin.app.vault.adapter.remove(this.localIconPath(c)),delete this.DOW
|
||
|
`)[s],[,m]=v.match(/> \[!.+\|(.*)]/)??[];if(m&&(i.dataset.calloutMetadata=m),this.plugin.admonitions[n].copy??this.plugin.data.copyButton){let u=o.createDiv("admonition-content-copy");(0,k1.setIcon)(u,"copy"),u.addEventListener("click",()=>{navigator.clipboard.writeText(f.split(`
|
||
|
`).slice(s+1,h+1).join(`
|
||
|
`).replace(/^> /gm,"")).then(async()=>{new k1.Notice("Callout content copied to clipboard.")})})}}if(t.noTitle&&!i.dataset.calloutFold&&r.addClass("no-title"),!t.noTitle&&this.plugin.data.autoCollapse&&!i.dataset.calloutFold&&this.setCollapsible(i),t.title&&r.textContent==n[0].toUpperCase()+n.slice(1).toLowerCase()){let f=r.querySelector(".callout-title-inner");f&&f.setText(t.title)}this.plugin.data.dropShadow&&i.addClass("drop-shadow")}setCollapsible(c){let a=c.querySelector(".callout-title"),i=c.querySelector(".callout-content");if(!i)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,k1.setIcon)(n,"chevron-down");let t=c.hasClass("is-collapsed");if(this.getComputedHeights(i),t)for(let r of this.heights)i.style.setProperty(r,"0px");a.onclick=r=>{r.preventDefault();function o(l){i.removeEventListener("transitionend",o),i.style.removeProperty("transition")}if(i.addEventListener("transitionend",o),i.style.setProperty("transition","all 100ms cubic-bezier(.02, .01, .47, 1)"),t=c.hasClass("is-collapsed"),r.button==0){for(let l of this.heights){let f=this.getComputedHeights(i);i.style.setProperty(l,t?f[l]:"0px")}c.toggleClass("is-collapsed",!t)}}}getComputedHeights(c){if(this.heightMap.has(c))return this.heightMap.get(c);let a=getComputedStyle(c),i={};for(let n of this.heights)i[n]=a.getPropertyValue(n);return this.heightMap.set(c,i),i}generateCssString(){let c=[`/* This snippet was auto-generated by the Admonitions plugin on ${new Date().toLocaleString()} */
|
||
|
|
||
|
`];for(let a of Array.from(this.sheet.cssRules))c.push(a.cssText);return c.join(`
|
||
|
|
||
|
`)}addAdmonition(c){if(!c.icon)return;let a,i=c.injectColor??this.plugin.data.injectColor?`--callout-color: ${c.color};`:"";c.icon.type=="obsidian"?a=`.callout[data-callout="${c.type.toLowerCase()}"] {
|
||
|
${i}
|
||
|
--callout-icon: ${c.icon.name}; /* Icon name from the Obsidian Icon Set */
|
||
|
}`:a=`.callout[data-callout="${c.type.toLowerCase()}"] {
|
||
|
${i}
|
||
|
--callout-icon: '${(this.plugin.iconManager.getIconNode(c.icon)?.outerHTML??"").replace(/(width|height)=(\\?"|')\d+(\\?"|')/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 Zb={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("")}`},v4=class extends b.Plugin{constructor(){super(...arguments);this.postprocessors=new Map;this.iconManager=new f4(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 L2(this)),this.registerEditorSuggest(new m4(this)),Object.keys(this.admonitions).forEach(c=>{this.registerType(c)}),this.addSettingTab(new d2(this.app,this)),(0,b.addIcon)(o2,N4),(0,b.addIcon)(r2,A4),(0,b.addIcon)(F1,y4),(0,b.addIcon)(q1,S4),this.addCommand({id:"collapse-admonitions",name:"Collapse Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(b.MarkdownView);let a=this.app.workspace.getActiveViewOfType(b.MarkdownView);if(!a||!(a instanceof b.MarkdownView))return;let i=a.contentEl.querySelectorAll("details[open].admonition-plugin");for(let n=0;n<i.length;n++)i[n].removeAttribute("open")}}),this.addCommand({id:"open-admonitions",name:"Open Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(b.MarkdownView);let a=this.app.workspace.getActiveViewOfType(b.MarkdownView);if(!a||!(a instanceof b.MarkdownView))return;let i=a.contentEl.querySelectorAll("details:not([open]).admonition-plugin");for(let n=0;n<i.length;n++)i[n].setAttribute("open","open")}}),this.addCommand({id:"insert-admonition",name:"Insert Admonition",editorCallback:(c,a)=>{let i=new z2(this);i.onClose=()=>{if(!i.insert)return;let n="",t="";i.title.length&&i.title.toLowerCase()!=i.type.toLowerCase()&&(n=`title: ${i.title}
|
||
|
`),(this.data.autoCollapse&&i.collapse!=this.data.defaultCollapseType||!this.data.autoCollapse&&i.collapse!="none")&&(t=`collapse: ${i.collapse}
|
||
|
`),c.getDoc().replaceSelection(`\`\`\`ad-${i.type}
|
||
|
${n}${t}
|
||
|
${c.getDoc().getSelection()}
|
||
|
\`\`\`
|
||
|
`);let r=c.getCursor();c.setCursor(r.line-3)},i.open()}}),this.addCommand({id:"insert-callout",name:"Insert Callout",editorCallback:(c,a)=>{let i=new z2(this);i.onClose=()=>{if(!i.insert)return;let n="",t="";if(this.data.autoCollapse&&i.collapse!=this.data.defaultCollapseType||!this.data.autoCollapse&&i.collapse!="none")switch(i.collapse){case"open":{t="+";break}case"closed":{t="-";break}}i.title.length&&i.title.toLowerCase()!=i.type.toLowerCase()&&(n=` ${i.title}`);let r=c.getDoc().getSelection();c.getDoc().replaceSelection(`> [!${i.type}]${t}${n}
|
||
|
> ${r.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`)},i.open()}})})}async downloadIcon(c){this.iconManager.downloadIcon(c)}async removeIcon(c){this.iconManager.removeIcon(c)}async postprocessor(c,a,i,n){if(!!this.admonitions[c])try{let t=typeof n=="string"?n:n?.sourcePath??this.app.workspace.getActiveFile()?.path??"",{title:r,collapse:o,content:l,icon:f,color:s}=b4(c,a,this.admonitions[c]);this.data.autoCollapse&&!o?o=this.data.defaultCollapseType??"open":o&&o.trim()==="none"&&(o="");let h=this.admonitions[c],v=this.getAdmonitionElement(c,r,this.iconManager.iconDefinitions.find(({name:u})=>f===u)??h.icon,s??(h.injectColor??this.data.injectColor?h.color:null),o);this.renderAdmonitionContent(v,c,l,n,t,a),o&&o!="none"&&this.calloutManager.setCollapsible(v);let m=i.parentElement;return m&&m.addClass("admonition-parent",`admonition-${c}-parent`),i.replaceWith(v),v}catch(t){console.error(t);let r=createEl("pre");r.createEl("code",{attr:{style:"color: var(--text-error) !important"}}).createSpan({text:`There was an error rendering the admonition:
|
||
|
|
||
|
`+a}),i.replaceWith(r)}}getAdmonitionElement(c,a,i,n,t){let r=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":""}}),o=r.createDiv({cls:`callout-title admonition-title ${a?.trim().length?"":"no-title"}`});if(a&&a.trim().length){let l=o.createDiv("callout-icon admonition-title-icon");i&&i.name&&i.type&&l.appendChild(this.iconManager.getIconNode(i)??createDiv());let f=o.createDiv("callout-title-inner admonition-title-content");b.MarkdownRenderer.renderMarkdown(a,f,"",null),f.firstElementChild&&f.firstElementChild instanceof HTMLParagraphElement&&f.setChildrenInPlace(Array.from(f.firstElementChild.childNodes))}return t&&(r.addClass("is-collapsible"),t=="closed"&&r.addClass("is-collapsed")),this.data.dropShadow||r.addClass("no-drop"),r}renderAdmonitionContent(c,a,i,n,t,r){let o=new b.MarkdownRenderChild(c);if(o.containerEl=c,n&&typeof n!="string"&&n.addChild(o),i&&i?.trim().length){let l=this.getAdmonitionContentElement(a,c,i);if(/^`{3,}mermaid/m.test(i)){let s=!c.hasAttribute("open");c instanceof HTMLDetailsElement&&c.setAttribute("open","open"),setImmediate(()=>{b.MarkdownRenderer.renderMarkdown(i,l,t,o),c instanceof HTMLDetailsElement&&s&&c.removeAttribute("open")})}else b.MarkdownRenderer.renderMarkdown(i,l,t,o);(!i.length||l.textContent.trim()=="")&&this.data.hideEmpty&&c.addClass("no-content");let f=l.querySelectorAll(".task-list-item-checkbox");if(f?.length){let s=r.split(`
|
||
|
`),h=0;f.forEach(v=>{let m=s.slice(h).findIndex(u=>/^[ \t>]*\- \[.\]/.test(u));m!=-1&&(v.dataset.line=`${m+h+1}`,h=m+h+1)})}}}getAdmonitionContentElement(c,a,i){let n=a.createDiv("callout-content admonition-content");if(this.admonitions[c].copy??this.data.copyButton){let t=n.createDiv("admonition-content-copy");(0,b.setIcon)(t,"copy"),t.addEventListener("click",()=>{navigator.clipboard.writeText(i.trim()).then(async()=>{new b.Notice("Admonition content copied to clipboard.")})})}return n}registerType(c){this.data.syntaxHighlight&&this.turnOnSyntaxHighlighting([c]),this.postprocessors.has(c)&&b.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c}`),this.postprocessors.set(c,this.registerMarkdownCodeBlockProcessor(`ad-${c}`,(i,n,t)=>this.postprocessor(c,i,n,t)));let a=this.admonitions[c];a.command&&this.registerCommandsFor(a)}get admonitions(){return{...w4,...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,i,n)=>{if(a)return c.command;if(c.command)try{let t=i.getDoc().getSelection();i.getDoc().replaceSelection(`> [!${c.type}]
|
||
|
> ${t.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`);let r=i.getCursor();i.setCursor(r.line-2)}catch{new b.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}`,name:`Insert ${c.type}`,editorCheckCallback:(a,i,n)=>{if(a)return c.command;if(c.command)try{i.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
|
||
|
${i.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let t=i.getCursor();i.setCursor(t.line-2)}catch{new b.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}-with-title`,name:`Insert ${c.type} With Title`,editorCheckCallback:(a,i,n)=>{if(a)return c.command;if(c.command)try{let t=c.title??"";i.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
title: ${t}
|
||
|
|
||
|
${i.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let r=i.getCursor();i.setCursor(r.line-3)}catch{new b.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)&&(b.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),b.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({},Zb,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 b.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[,i]=`${a}`.match(/^([\w+#-]*)[^\n`]*$/);window.CodeMirror.defineMode(`ad-${i}`,(n,t)=>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)
|
||
|
*/
|