generated from DNDs/dnd-template
516 lines
1.3 MiB
JavaScript
516 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 c6=Object.create;var X1=Object.defineProperty;var a6=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var i6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var p4=a=>X1(a,"__esModule",{value:!0});var o6=(a,c)=>{p4(a);for(var e in c)X1(a,e,{get:c[e],enumerable:!0})},t6=(a,c,e)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of e6(c))!n6.call(a,i)&&i!=="default"&&X1(a,i,{get:()=>c[i],enumerable:!(e=a6(c,i))||e.enumerable});return a},J=a=>t6(p4(X1(a!=null?c6(i6(a)):{},"default",a&&a.__esModule&&"default"in a?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);o6(exports,{default:()=>r4});var x=J(require("obsidian"));var d4=J(require("obsidian")),g2=J(require("obsidian"));function r6(a,c){for(let e=0;e<c.length;e++)if(a.startsWith(c[e]))return e;return!1}function u4(a,c,e){let i=e.title??a[0].toUpperCase()+a.slice(1).toLowerCase(),n=["title:","collapse:","icon:","color:"],o=["title","collapse","icon","color"],r=c.split(`
|
||
|
`),t=0,l={};for(let v=0;v<r.length;v++){let M=r6(r[v],n);if(M===!1)break;let p=o[M];if(l[p]!==void 0)break;l[p]=r[v].slice(n[M].length).trim(),++t}let{title:f,collapse:s,icon:h,color:m}=l,z=r.slice(t).join(`
|
||
|
`);return s!==void 0&&s!=="none"&&s!=="open"&&s!=="closed"&&(s="closed"),"title"in l||e.noTitle||(f=i),f&&f.trim()===""&&s!==void 0&&s!=="none"&&(f=i,new d4.Notice("An admonition must have a title if it is collapsible.")),{title:f,collapse:s,content:z,icon:h,color:m}}var M4='<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>',K1="admonition-add-command",C4='<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>',Q1="admonition-remove-command",H4='<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>',P1="admonition-warning",g4='<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
|
||
|
|
||
|
`],o=new Blob([this.plugin.calloutManager.generateCssString()],{type:"text/css"});createEl("a",{attr:{download:"custom_callouts.css",href:URL.createObjectURL(o)}}).click()}).setDisabled(!Object.keys(this.plugin.data.userAdmonitions).length)),new u.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 u.Setting(c).setName(g("Add New")).setDesc("Add a new Admonition type. All custom Admonitions will also be usable as callouts.").addButton(i=>i.setTooltip(g("Add Additional")).setButtonText("+").onClick(async()=>{let o=new F(this.plugin);o.onClose=async()=>{if(o.saved){let r={type:o.type,color:o.color,icon:o.icon,command:!1,title:o.title,injectColor:o.injectColor,noTitle:o.noTitle,copy:o.copy};this.plugin.addAdmonition(r),this.plugin.calloutManager.addAdmonition(r),this.display()}},o.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:{...this.plugin.data.open.advanced?{open:!0}:{}}})),this.containerEl.createDiv("coffee").createEl("a",{href:"https://www.buymeacoffee.com/valentine195"}).createEl("img",{attr:{src:"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=\u2615&slug=valentine195&button_colour=e3e7ef&font_colour=262626&font_family=Inter&outline_colour=262626&coffee_colour=ff0000"}})}buildAdmonitions(c){c.empty(),c.ontoggle=()=>{this.plugin.data.open.admonitions=c.open,this.plugin.saveSettings()};let e=c.createEl("summary");new u.Setting(e).setHeading().setName("Admonitions & Callouts"),e.createDiv("collapser").createDiv("handle"),new u.Setting(c).setName("Add Drop Shadow").setDesc("A drop shadow will be added to admonitions.").addToggle(i=>{i.setValue(this.plugin.data.dropShadow).onChange(async n=>{this.plugin.data.dropShadow=n,this.display(),await this.plugin.saveSettings()})}),new u.Setting(c).setName(g("Collapsible by Default")).setDesc(createFragment(i=>{i.createSpan({text:"All admonitions & callouts will be collapsible by default. Use "}),i.createEl("code",{text:"collapse: none"}),i.createSpan({text:g(" to prevent.")})})).addToggle(i=>{i.setValue(this.plugin.data.autoCollapse).onChange(async n=>{this.plugin.data.autoCollapse=n,this.display(),await this.plugin.saveSettings()})}),this.plugin.data.autoCollapse&&new u.Setting(c).setName(g("Default Collapse Type")).setDesc("Collapsible admonitions & callouts will be either opened or closed.").addDropdown(i=>{i.addOption("open","open"),i.addOption("closed","closed"),i.setValue(this.plugin.data.defaultCollapseType),i.onChange(async n=>{this.plugin.data.defaultCollapseType=n,await this.plugin.saveSettings()})}),new u.Setting(c).setName(g("Add Copy Button")).setDesc("Add a 'copy content' button to admonitions & callouts.").addToggle(i=>{i.setValue(this.plugin.data.copyButton),i.onChange(async n=>{this.plugin.data.copyButton=n,n||document.querySelectorAll(".admonition-content-copy").forEach(o=>{o.detach()}),await this.plugin.saveSettings()})}),new u.Setting(c).setName(g("Parse Titles as Markdown")).setDesc(g("Admonition Titles will be rendered as markdown.")).addToggle(i=>{i.setValue(this.plugin.data.parseTitles),i.onChange(async n=>{this.plugin.data.parseTitles=n,await this.plugin.saveSettings()})}),new u.Setting(c).setName("Set Admonition Colors").setDesc("Disable this setting to turn off admonition colorin
|
||
|
`).slice(1,-1)){if(l){if(/^title:/.test(s)){o=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)}t.push(s)}let f=t.join(`
|
||
|
`);/^(`{3,})ad-(\w+)([\s\S]*?)?\n^\1/m.test(f)&&(f=this.replaceCodeBlockInPlace(f)),c=c.replace(i,`> [!${n}]${r}${o.length?" ":""}${o}
|
||
|
> ${f.split(`
|
||
|
`).join(`
|
||
|
> `)}`),this.converted++}return c}buildAdvanced(c){c.empty(),c.ontoggle=()=>{this.plugin.data.open.advanced=c.open,this.plugin.saveSettings()};let e=c.createEl("summary");new u.Setting(e).setHeading().setName("Advanced Settings"),e.createDiv("collapser").createDiv("handle"),new u.Setting(c).setName(g("Markdown Syntax Highlighting")).setDesc(g("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 u.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 o={};for(let f in this.plugin.admonitions){let s=this.plugin.admonitions[f];o[f]={icon:this.plugin.iconManager.getIconNode(s.icon)?.outerHTML??"",color:s.color}}let r=W4.replace(/ADMONITION_ICON_MAP\s?=\s?\{\}/,"ADMONITION_ICON_MAP="+JSON.stringify(o)),t=new Blob([r],{type:"text/javascript"}),l=createEl("a",{href:URL.createObjectURL(t),attr:{download:"publish.admonition.js"}});l.click(),l.detach()})})}buildTypes(){this.additionalEl.empty();for(let c of Object.values(this.plugin.data.userAdmonitions)){let e=new u.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);e.infoEl.replaceWith(i),c.command?e.addExtraButton(n=>{n.setIcon(Q1.toString()).setTooltip(g("Unregister Commands")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),await this.plugin.saveSettings(),this.display()})}):e.addExtraButton(n=>{n.setIcon(K1.toString()).setTooltip(g("Register Commands")).onClick(async()=>{this.plugin.registerCommandsFor(c),await this.plugin.saveSettings(),this.display()})}),e.addExtraButton(n=>{n.setIcon("pencil").setTooltip(g("Edit")).onClick(()=>{let o=new F(this.plugin,c);o.onClose=async()=>{if(o.saved){let r=c.command,t={type:o.type,color:o.color,icon:o.icon,command:r,title:o.title,injectColor:o.injectColor,noTitle:o.noTitle,copy:o.copy};if(t.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?[t.type,t]:[f,s]))}else this.plugin.data.userAdmonitions[t.type]=t;this.plugin.registerType(t.type),this.plugin.calloutManager.addAdmonition(t),this.display()}},o.open()})}).addExtraButton(n=>{n.setIcon("trash").setTooltip(g("Delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},F=class extends u.Modal{constructor(c,e){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;e&&(this.color=e.color,this.icon=e.icon,this.type=e.type,this.originalType=e.type,this.title=e.title,this.injectColor=e.injectColor??this.injectColor,this.noTitle=e.noTitle??!1,this.copy=e.copy??this.plugin.data.copyButton)}async display(){let{contentEl:c}=this;c.empty();let e=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,o=new u.Setting(e).setName(g("Admonition Type")).addText(h=>{n=h,n.setValue(this.type).onChange(m=>{if(!m.length){F.setValidationError(h,g("Admonition type cannot be empty."));return}if(m.includes(" ")){
|
||
|
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 Hb(){var a=N3,c=A3,e=G.familyPrefix,i=G.replacementClass,n=Cb;if(e!==a||i!==c){var o=new RegExp("\\.".concat(a,"\\-"),"g"),r=new RegExp("\\--".concat(a,"\\-"),"g"),t=new RegExp("\\.".concat(c),"g");n=n.replace(o,".".concat(e,"-")).replace(r,"--".concat(e,"-")).replace(t,".".concat(i))}return n}var gb=function(){function a(){Ix(this,a),this.definitions={}}return Bx(a,[{key:"add",value:function(){for(var e=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];var r=n.reduce(this._pullDefinitions,{});Object.keys(r).forEach(function(t){e.definitions[t]=b({},e.definitions[t]||{},r[t]),q3(t,r[t]),W3()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(e,i){var n=i.prefix&&i.iconName&&i.icon?{0:i}:i;return Object.keys(n).map(function(o){var r=n[o],t=r.prefix,l=r.iconName,f=r.icon;e[t]||(e[t]={}),e[t][l]=f}),e}}]),a}();function Vb(){G.autoAddCss&&!X3&&(ob(Hb()),X3=!0)}function Lb(a,c){return Object.defineProperty(a,"abstract",{get:c}),Object.defineProperty(a,"html",{get:function(){return a.abstract.map(function(i){return _3(i)})}}),Object.defineProperty(a,"node",{get:function(){if(!!W2){var i=U.createElement("div");return i.innerHTML=a.html,i.children}}}),a}function V1(a){var c=a.prefix,e=c===void 0?"fa":c,i=a.iconName;if(!!i)return G3(a4.definitions,e,i)||G3(a1.styles,e,i)}function xb(a){return function(c){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=(c||{}).icon?c:V1(c||{}),n=e.mask;return n&&(n=(n||{}).icon?n:V1(n||{})),a(i,b({},e,{mask:n}))}}var a4=new gb;var X3=!1;var K3=xb(function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=c.transform,i=e===void 0?k1:e,n=c.symbol,o=n===void 0?!1:n,r=c.mask,t=r===void 0?null:r,l=c.maskId,f=l===void 0?null:l,s=c.title,h=s===void 0?null:s,m=c.titleId,z=m===void 0?null:m,v=c.classes,M=v===void 0?[]:v,p=c.attributes,C=p===void 0?{}:p,H=c.styles,L=H===void 0?{}:H;if(!!a){var d=a.prefix,N=a.iconName,V=a.icon;return Lb(b({type:"icon"},a),function(){return Vb(),G.autoA11y&&(h?C["aria-labelledby"]="".concat(G.replacementClass,"-title-").concat(z||z2()):(C["aria-hidden"]="true",C.focusable="false")),vb({icons:{main:Y3(V),mask:t?Y3(t.icon):{found:!1,width:null,height:null,icon:{}}},prefix:d,iconName:N,transform:b({},k1,i),symbol:o,title:h,maskId:f,titleId:z,extra:{attributes:C,styles:L,classes:M}})})}});var W1=J(require("obsidian"));var e4=["logo-crystal","create-new","trash","search","right-triangle","document","folder","pencil","left-arrow","right-arrow","three-horizontal-bars","dot-network","audio-file","image-file","pdf-file","gear","documents","blocks","go-to-file","presentation","cross-in-box","microphone","microphone-filled","link","popup-open","checkmark","hashtag","left-arrow-with-tail","right-arrow-with-tail","up-arrow-with-tail","down-arrow-with-tail","lines-of-text","vertical-three-dots","pin","magnifying-glass","info","horizontal-split","vertical-split","calendar-with-checkmark","sheets-in-box","up-and-down-arrows","broken-link","cross","any-key","reset","star","crossed-star","dice","filled-pin","enter","help","vault","open-vault","paper-plane","bullet-list","uppercase-lowercase-a","star-list","expand-vertically","languages","switch","pane-layout","install","sync","check-in-circle","sync-small","check-small","paused","forward-arrow","stacked-levels","bracket-glyph","note-glyph","tag-glyph","price-tag-glyph","heading-glyph","bold-glyph","italic-glyph","strikethrough-glyph","highlight-glyph","code-glyph","quote-glyph","link-glyph","bullet-list-glyph","number-list-glyph","checkbox-glyph","undo-glyph","redo-glyph","up-chevron-glyph","down-chevron-glyph","left-chevron-glyph","right-chevron-glyph","percent-sign-glyph","keyboard-glyph","double-up-arrow-glyph","double-down-arrow-glyph","image-glyph","wrench-screwdriver-glyph","clock","plus-with-circle","minus-with-circle","indent-glyph","unindent-glyph","fullscreen","exit-fullscreen","cloud","run-command","compress-glyph","enlarge-glyph","scissors-glyph","up-curly-arrow-glyph","down-curly-arrow-glyph","plus-minus-glyph","links-g
|
||
|
`)[s],[,z]=m.match(/> \[!.+\|(.*)]/)??[];if(z&&(i.dataset.calloutMetadata=z),this.plugin.admonitions[n].copy??this.plugin.data.copyButton){let v=t.createDiv("admonition-content-copy");(0,L1.setIcon)(v,"copy"),v.addEventListener("click",()=>{navigator.clipboard.writeText(f.split(`
|
||
|
`).slice(s+1,h+1).join(`
|
||
|
`).replace(/^> /gm,"")).then(async()=>{new L1.Notice("Callout content copied to clipboard.")})})}}if(o.noTitle&&!i.dataset.calloutFold&&r.addClass("no-title"),!o.noTitle&&this.plugin.data.autoCollapse&&!i.dataset.calloutFold&&this.setCollapsible(i),o.title&&r.textContent==n[0].toUpperCase()+n.slice(1).toLowerCase()){let f=r.querySelector(".callout-title-inner");f&&f.setText(o.title)}this.plugin.data.dropShadow&&i.addClass("drop-shadow")}setCollapsible(c){let e=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=e.createDiv("callout-fold");(0,L1.setIcon)(n,"chevron-down");let o=c.hasClass("is-collapsed");if(this.getComputedHeights(i),o)for(let r of this.heights)i.style.setProperty(r,"0px");e.onclick=r=>{r.preventDefault();function t(l){i.removeEventListener("transitionend",t),i.style.removeProperty("transition")}if(i.addEventListener("transitionend",t),i.style.setProperty("transition","all 100ms cubic-bezier(.02, .01, .47, 1)"),o=c.hasClass("is-collapsed"),r.button==0){for(let l of this.heights){let f=this.getComputedHeights(i);i.style.setProperty(l,o?f[l]:"0px")}c.toggleClass("is-collapsed",!o)}}}getComputedHeights(c){if(this.heightMap.has(c))return this.heightMap.get(c);let e=getComputedStyle(c),i={};for(let n of this.heights)i[n]=e.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 e of Array.from(this.sheet.cssRules))c.push(e.cssText);return c.join(`
|
||
|
|
||
|
`)}addAdmonition(c){if(!c.icon)return;let e,i=c.injectColor??this.plugin.data.injectColor?`--callout-color: ${c.color};`:"";c.icon.type=="obsidian"?e=`.callout[data-callout="${c.type}"] {
|
||
|
${i}
|
||
|
--callout-icon: ${c.icon.name}; /* Icon name from the Obsidian Icon Set */
|
||
|
}`:e=`.callout[data-callout="${c.type}"] {
|
||
|
${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(e,this.sheet.cssRules.length),this.updateSnippet()}removeAdmonition(c){if(!this.indexing.contains(c.type))return;let e=this.indexing.indexOf(c.type);this.sheet.deleteRule(e),this.indexing.splice(e,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.readCssFolders())}};var bb={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("")}`},r4=class extends x.Plugin{constructor(){super(...arguments);this.postprocessors=new Map;this.iconManager=new i4(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 d2(this)),this.registerEditorSuggest(new t4(this)),Object.keys(this.admonitions).forEach(c=>{this.registerType(c)}),this.addSettingTab(new l2(this.app,this)),(0,x.addIcon)(K1,M4),(0,x.addIcon)(Q1,C4),(0,x.addIcon)(P1,H4),(0,x.addIcon)(E1,g4),this.addCommand({id:"collapse-admonitions",name:"Collapse Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(x.MarkdownView);let e=this.app.workspace.getActiveViewOfType(x.MarkdownView);if(!e||!(e instanceof x.MarkdownView))return;let i=e.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(x.MarkdownView);let e=this.app.workspace.getActiveViewOfType(x.MarkdownView);if(!e||!(e instanceof x.MarkdownView))return;let i=e.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,e)=>{let i=new r2(this);i.onClose=()=>{if(!i.insert)return;let n="",o="";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")&&(o=`collapse: ${i.collapse}
|
||
|
`),c.getDoc().replaceSelection(`\`\`\`ad-${i.type}
|
||
|
${n}${o}
|
||
|
${c.getDoc().getSelection()}
|
||
|
\`\`\`
|
||
|
`);let r=c.getCursor();c.setCursor(r.line-3)},i.open()}}),this.addCommand({id:"insert-callout",name:"Insert Callout",editorCallback:(c,e)=>{let i=new r2(this);i.onClose=()=>{if(!i.insert)return;let n="",o="";if(this.data.autoCollapse&&i.collapse!=this.data.defaultCollapseType||!this.data.autoCollapse&&i.collapse!="none")switch(i.collapse){case"open":{o="+";break}case"closed":{o="-";break}}i.title.length&&i.title.toLowerCase()!=i.type.toLowerCase()&&(n=` ${i.title}`);let r=c.getDoc().getSelection();c.getDoc().replaceSelection(`> [!${i.type}]${o}${n}
|
||
|
> ${r.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`)},i.open()}})})}async downloadIcon(c){this.iconManager.downloadIcon(c)}async removeIcon(c){this.iconManager.removeIcon(c)}async postprocessor(c,e,i,n){if(!!this.admonitions[c])try{let o=typeof n=="string"?n:n?.sourcePath??this.app.workspace.getActiveFile()?.path??"",{title:r,collapse:t,content:l,icon:f,color:s}=u4(c,e,this.admonitions[c]);this.data.autoCollapse&&!t?t=this.data.defaultCollapseType??"open":t&&t.trim()==="none"&&(t="");let h=this.admonitions[c],m=this.getAdmonitionElement(c,r,this.iconManager.iconDefinitions.find(({name:v})=>f===v)??h.icon,s??(h.injectColor??this.data.injectColor?h.color:null),t);this.renderAdmonitionContent(m,c,l,n,o,e),t&&t!="none"&&this.calloutManager.setCollapsible(m);let z=i.parentElement;return z&&z.addClass("admonition-parent",`admonition-${c}-parent`),i.replaceWith(m),m}catch(o){console.error(o);let r=createEl("pre");r.createEl("code",{attr:{style:"color: var(--text-error) !important"}}).createSpan({text:`There was an error rendering the admonition:
|
||
|
|
||
|
`+e}),i.replaceWith(r)}}getAdmonitionElement(c,e,i,n,o){let r=createDiv({cls:`callout admonition admonition-${c} admonition-plugin ${e?.trim().length?"":"no-title"}`,attr:{style:n?`--callout-color: ${n};`:"","data-callout":c,"data-callout-fold":""}}),t=r.createDiv({cls:`callout-title admonition-title ${e?.trim().length?"":"no-title"}`});if(e&&e.trim().length){let l=t.createDiv("callout-icon admonition-title-icon");i&&i.name&&i.type&&l.appendChild(this.iconManager.getIconNode(i)??createDiv());let f=t.createDiv("callout-title-inner admonition-title-content");x.MarkdownRenderer.renderMarkdown(e,f,"",null),f.firstElementChild&&f.firstElementChild instanceof HTMLParagraphElement&&f.setChildrenInPlace(Array.from(f.firstElementChild.childNodes))}return o&&(r.addClass("is-collapsible"),o=="closed"&&r.addClass("is-collapsed")),this.data.dropShadow||r.addClass("no-drop"),r}renderAdmonitionContent(c,e,i,n,o,r){let t=new x.MarkdownRenderChild(c);if(t.containerEl=c,n&&typeof n!="string"&&n.addChild(t),i&&i?.trim().length){let l=this.getAdmonitionContentElement(e,c,i);if(/^`{3,}mermaid/m.test(i)){let s=!c.hasAttribute("open");c instanceof HTMLDetailsElement&&c.setAttribute("open","open"),setImmediate(()=>{x.MarkdownRenderer.renderMarkdown(i,l,o,t),c instanceof HTMLDetailsElement&&s&&c.removeAttribute("open")})}else x.MarkdownRenderer.renderMarkdown(i,l,o,t);(!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(m=>{let z=s.slice(h).findIndex(v=>/^[ \t>]*\- \[.\]/.test(v));z!=-1&&(m.dataset.line=`${z+h+1}`,h=z+h+1)})}}}getAdmonitionContentElement(c,e,i){let n=e.createDiv("callout-content admonition-content");if(this.admonitions[c].copy??this.data.copyButton){let o=n.createDiv("admonition-content-copy");(0,x.setIcon)(o,"copy"),o.addEventListener("click",()=>{navigator.clipboard.writeText(i.trim()).then(async()=>{new x.Notice("Admonition content copied to clipboard.")})})}return n}registerType(c){this.data.syntaxHighlight&&this.turnOnSyntaxHighlighting([c]),this.postprocessors.has(c)&&x.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c}`),this.postprocessors.set(c,this.registerMarkdownCodeBlockProcessor(`ad-${c}`,(i,n,o)=>this.postprocessor(c,i,n,o)));let e=this.admonitions[c];e.command&&this.registerCommandsFor(e)}get admonitions(){return{...V4,...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:(e,i,n)=>{if(e)return c.command;if(c.command)try{let o=i.getDoc().getSelection();i.getDoc().replaceSelection(`> [!${c.type}]
|
||
|
> ${o.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`);let r=i.getCursor();i.setCursor(r.line-2)}catch{new x.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}`,name:`Insert ${c.type}`,editorCheckCallback:(e,i,n)=>{if(e)return c.command;if(c.command)try{i.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
|
||
|
${i.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let o=i.getCursor();i.setCursor(o.line-2)}catch{new x.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}-with-title`,name:`Insert ${c.type} With Title`,editorCheckCallback:(e,i,n)=>{if(e)return c.command;if(c.command)try{let o=c.title??"";i.getDoc().replaceSelection(`\`\`\`ad-${c.type}
|
||
|
title: ${o}
|
||
|
|
||
|
${i.getDoc().getSelection()}
|
||
|
|
||
|
\`\`\`
|
||
|
`);let r=i.getCursor();i.setCursor(r.line-3)}catch{new x.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)&&(x.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),x.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({},bb,c),this.data.userAdmonitions){if(!this.data.version||Number(this.data.version.split(".")[0])<5)for(let e in this.data.userAdmonitions)Object.prototype.hasOwnProperty.call(this.data.userAdmonitions[e],"type")||(this.data.userAdmonitions[e]={...this.data.userAdmonitions[e],icon:{type:"font-awesome",name:this.data.userAdmonitions[e].icon}});(!this.data.version||Number(this.data.version.split(".")[0])<8)&&new x.Notice(createFragment(e=>{e.createSpan({text:"Admonitions: Obsidian now has native support for callouts! Check out the "}),e.createEl("a",{text:"Admonitions ReadMe",href:"obsidian://show-plugin?id=obsidian-admonition"}),e.createSpan({text:" for what that means for Admonitions going forward."})}),0)}if(!this.data.rpgDownloadedOnce&&this.data.userAdmonitions&&Object.values(this.data.userAdmonitions).some(e=>{if(e.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(e=>{if(this.data.syntaxHighlight){let[,i]=`${e}`.match(/^([\w+#-]*)[^\n`]*$/);window.CodeMirror.defineMode(`ad-${i}`,(n,o)=>window.CodeMirror.getMode({},"hypermd"))}}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(e=>e.setOption("mode",e.getOption("mode")))))}turnOffSyntaxHighlighting(c=Object.keys(this.admonitions)){c.forEach(e=>{window.CodeMirror.modes.hasOwnProperty(`ad-${e}`)&&delete window.CodeMirror.modes[`ad-${e}`]}),this.app.workspace.onLayoutReady(()=>this.app.workspace.iterateCodeMirrors(e=>e.setOption("mode",e.getOption("mode"))))}async onunload(){console.log("Obsidian Admonition unloaded"),this.postprocessors=null,this.turnOffSyntaxHighlighting()}};
|
||
|
/*!
|
||
|
* Font Awesome Free 5.15.3 by @fontawesome - https://fontawesome.com
|
||
|
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||
|
*/
|
||
|
/*!
|
||
|
* 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)
|
||
|
*/
|