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 m6=Object.create;var o2=Object.defineProperty;var v6=Object.getOwnPropertyDescriptor;var z6=Object.getOwnPropertyNames;var p6=Object.getPrototypeOf,d6=Object.prototype.hasOwnProperty;var x4=e=>o2(e,"__esModule",{value:!0});var u6=(e,c)=>{x4(e);for(var a in c)o2(e,a,{get:c[a],enumerable:!0})},M6=(e,c,a)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of z6(c))!d6.call(e,i)&&i!=="default"&&o2(e,i,{get:()=>c[i],enumerable:!(a=v6(c,i))||a.enumerable});return e},i1=e=>M6(x4(o2(e!=null?m6(p6(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);u6(exports,{default:()=>v4});var V=i1(require("obsidian"));var L4=i1(require("obsidian"));function C6(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:","metadata:"],o=["title","collapse","icon","color","metadata"],r=c.split(`
|
||
|
`),t=0,l={};for(let p=0;p<r.length;p++){let z=C6(r[p],n);if(z===!1)break;let u=o[z];if(l[u]!==void 0)break;l[u]=r[p].slice(n[z].length).trim(),++t}let{title:f,collapse:s,icon:h,color:v,metadata:m}=l,M=r.slice(t).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,metadata:m}}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>',t2="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.
|
||
|
|
||
|
`],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 d.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 o=Object.values(this.plugin.data.userAdmonitions);this.download(o.filter(r=>n.selectedAdmonitions.includes(r.type)))},n.open()})),new d.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 d.Setting(c).setName(b("Add New")).setDesc("Add a new Admonition type. All custom Admonitions will also be usable as callouts.").addButton(i=>i.setTooltip(b("Add Additional")).setButtonText("+").onClick(async()=>{let o=new l1(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()})),new d.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:o}=n;if(!!o.length){try{let r=[];for(let t of Array.from(o))r.push(JSON.parse(await t.text()));for(let t of r.flat()){if(typeof t!="object")continue;t.icon||(t.icon={name:"pencil-alt",type:"font-awesome"});let l=e1.validateImport(this.plugin,t);if(l.success==!1){new d.Notice(createFragment(f=>{f.createSpan({text:`There was an issue importing the ${t.type} admonition:`}),f.createEl("br"),f.createSpan({text:l.message})}));continue}l.messages?.length&&new d.Notice(createFragment(f=>{f.createSpan({text:`There was an issue importing the ${t.type} admonition:`});for(let s of l.messages)f.createEl("br"),f.createSpan({text:s})})),await this.plugin.addAdmonition(t)}this.display()}catch(r){new d.Notice(`There was an error while importing the admonition${o.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 d.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 o=new d.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));o.inputEl.setAttribute("style",`height: ${o.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)){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 a=c.createEl("summary");new d.Setting(a).setHeading().setName("Advanced Settings"),a.createDiv("collapser").createDiv("handle"),new d.Setting(c).setName(b("Markdown Syntax Highlighting")).setDesc(b("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()})})}buildTypes(){this.additionalEl.empty();for(let c of Object.values(this.plugin.data.userAdmonitions)){let a=new d.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(b("Unregister Commands")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),await this.plugin.saveSettings(),this.display()})}):a.addExtraButton(n=>{n.setIcon(t2.toString()).setTooltip(b("Register Commands")).onClick(async()=>{this.plugin.registerCommandsFor(c),await this.plugin.saveSettings(),this.display()})}),a.addExtraButton(n=>{n.setIcon("pencil").setTooltip(b("Edit")).onClick(()=>{let o=new l1(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(b("Delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},l1=class extends d.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)}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(),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 d.Setting(a).setName(b("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.inputEl,m.message);return}l1.removeValidationError(h.inputEl),this.type=v,this.title||this.updateTitle(this.admonitionPreview,this.type?.[0].toUpperCase()+this.type?.slice(1).toLowerCase())})});o.controlEl.addClass("admonition-type-setting"),o.descEl.createSpan({text:"This is used to create the admonition (e.g., "}),o.descEl.createEl("code",{text:"note"}),o.descEl.createSpan({text:" or "}),o.descEl.createEl("code",{text:"abstract"}),o.descEl.createSpan({text:")"}),new d.Setting(a).setName(b("Admonition Title")).setDesc(b("This will be the default title for this admonition type.")).addText(h=>{h.setValue(this.title).onChange(v=>{if(!v.length){thi
|
||
|
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 Pb(){var e=P3,c=E3,a=_.familyPrefix,i=_.replacementClass,n=Tb;if(a!==e||i!==c){var o=new RegExp("\\.".concat(e,"\\-"),"g"),r=new RegExp("\\--".concat(e,"\\-"),"g"),t=new RegExp("\\.".concat(c),"g");n=n.replace(o,".".concat(a,"-")).replace(r,"--".concat(a,"-")).replace(t,".".concat(i))}return n}var Eb=function(){function e(){KL(this,e),this.definitions={}}return QL(e,[{key:"add",value:function(){for(var a=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){a.definitions[t]=N({},a.definitions[t]||{},r[t]),K3(t,r[t]),J3()})}},{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(o){var r=n[o],t=r.prefix,l=r.iconName,f=r.icon;a[t]||(a[t]={}),a[t][l]=f}),a}}]),e}();function Db(){_.autoAddCss&&!i6&&(Mb(Pb()),i6=!0)}function Ob(e,c){return Object.defineProperty(e,"abstract",{get:c}),Object.defineProperty(e,"html",{get:function(){return e.abstract.map(function(i){return c6(i)})}}),Object.defineProperty(e,"node",{get:function(){if(!!J2){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 X3(l4.definitions,a,i)||X3(n1.styles,a,i)}function Ib(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 Eb;var i6=!1;var n6=Ib(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,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,v=c.titleId,m=v===void 0?null:v,M=c.classes,p=M===void 0?[]:M,z=c.attributes,u=z===void 0?{}:z,C=c.styles,x=C===void 0?{}:C;if(!!e){var g=e.prefix,L=e.iconName,H=e.icon;return Ob(N({type:"icon"},e),function(){return Db(),_.autoA11y&&(h?u["aria-labelledby"]="".concat(_.replacementClass,"-title-").concat(m||V2()):(u["aria-hidden"]="true",u.focusable="false")),Nb({icons:{main:e6(H),mask:t?e6(t.icon):{found:!1,width:null,height:null,icon:{}}},prefix:g,iconName:L,transform:N({},R1,i),symbol:o,title:h,maskId:f,titleId:m,extra:{attributes:u,styles:x,classes:p}})})}});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),t&&(this.plugin.admonitions[n].copy??this.plugin.data.copyButton)){let M=t.createDiv("admonition-content-copy");(0,k1.setIcon)(M,"copy"),M.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(o.noTitle&&!i.dataset.calloutFold&&r.querySelector(".callout-title-inner")?.textContent?.toLowerCase()===o.type.toLowerCase()&&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 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 o=c.hasClass("is-collapsed");if(this.getComputedHeights(i),o)for(let r of this.heights)i.style.setProperty(r,"0px");a.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 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,"").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 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("")}`},v4=class extends V.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,V.addIcon)(t2,N4),(0,V.addIcon)(r2,A4),(0,V.addIcon)(F1,y4),(0,V.addIcon)(q1,S4),this.addCommand({id:"collapse-admonitions",name:"Collapse Admonitions in Note",checkCallback:c=>{if(c)return!!this.app.workspace.getActiveViewOfType(V.MarkdownView);let a=this.app.workspace.getActiveViewOfType(V.MarkdownView);if(!a||!(a instanceof V.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(V.MarkdownView);let a=this.app.workspace.getActiveViewOfType(V.MarkdownView);if(!a||!(a instanceof V.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="",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,a)=>{let i=new z2(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,a,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,metadata:h}=b4(c,a,this.admonitions[c]);this.data.autoCollapse&&!t?t=this.data.defaultCollapseType??"open":t&&t.trim()==="none"&&(t="");let v=this.admonitions[c],m=this.getAdmonitionElement(c,r,this.iconManager.iconDefinitions.find(({name:z})=>f===z)??v.icon,s??(v.injectColor??this.data.injectColor?v.color:null),t,o,h);this.renderAdmonitionContent(m,c,l,n,o,a),t&&t!="none"&&this.calloutManager.setCollapsible(m);let M=i.parentElement;M&&M.addClass("admonition-parent",`admonition-${c}-parent`),i.replaceWith(m);let p=app.workspace.getActiveViewOfType(V.MarkdownView);if(p?.editor?.cm?.state?.field(V.editorLivePreviewField)){let z=p.editor.cm;m.onClickEvent(u=>{if(!(u.defaultPrevented||u.detail>1||u.shiftKey))try{setTimeout(()=>{try{let C=z.posAtDOM(m);z.focus(),z.dispatch({selection:{head:C,anchor:C}})}catch{}},10)}catch{}})}return 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:
|
||
|
|
||
|
`+a}),i.replaceWith(r)}}getAdmonitionElement(c,a,i,n,o,r,t){let l=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":t??""}}),f=l.createDiv({cls:`callout-title admonition-title ${a?.trim().length?"":"no-title"}`});if(a&&a.trim().length){let s=f.createDiv("callout-icon admonition-title-icon");i&&i.name&&i.type&&s.appendChild(this.iconManager.getIconNode(i)??createDiv());let h=f.createDiv("callout-title-inner admonition-title-content");V.MarkdownRenderer.renderMarkdown(a,h,r??"",new V.Component),h.firstElementChild&&h.firstElementChild instanceof HTMLParagraphElement&&h.setChildrenInPlace(Array.from(h.firstElementChild.childNodes))}return o&&(l.addClass("is-collapsible"),o=="closed"&&l.addClass("is-collapsed")),this.data.dropShadow||l.addClass("no-drop"),l}renderAdmonitionContent(c,a,i,n,o,r){let t=new V.MarkdownRenderChild(c);if(t.containerEl=c,n&&typeof n!="string"&&n.addChild(t),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(()=>{V.MarkdownRenderer.renderMarkdown(i,l,o,t),c instanceof HTMLDetailsElement&&s&&c.removeAttribute("open")})}else V.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(v=>{let m=s.slice(h).findIndex(M=>/^[ \t>]*\- \[.\]/.test(M));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 o=n.createDiv("admonition-content-copy");(0,V.setIcon)(o,"copy"),o.addEventListener("click",()=>{navigator.clipboard.writeText(i.trim()).then(async()=>{new V.Notice("Admonition content copied to clipboard.")})})}return n}registerType(c){this.data.syntaxHighlight&&this.turnOnSyntaxHighlighting([c]),this.postprocessors.has(c)&&V.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c}`),this.postprocessors.set(c,this.registerMarkdownCodeBlockProcessor(`ad-${c}`,(i,n,o)=>this.postprocessor(c,i,n,o)));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 o=i.getDoc().getSelection();i.getDoc().replaceSelection(`> [!${c.type}]
|
||
|
> ${o.split(`
|
||
|
`).join(`
|
||
|
> `)}
|
||
|
`);let r=i.getCursor();i.setCursor(r.line-2)}catch{new V.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 o=i.getCursor();i.setCursor(o.line-2)}catch{new V.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 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 V.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)&&(V.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),V.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 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 V.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,o)=>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)
|
||
|
*/
|