Files
BlueRoseNote/.obsidian/plugins/obsidian-admonition/main.js

518 lines
1.3 MiB
JavaScript
Raw Normal View History

2025-08-02 12:09:34 +08:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
2026-05-06 17:32:44 +08:00
var M1=Object.defineProperty;var Q2=Object.getOwnPropertyDescriptor;var X2=Object.getOwnPropertyNames;var c4=Object.prototype.hasOwnProperty;var a4=(i,l)=>{for(var c in l)M1(i,c,{get:l[c],enumerable:!0})},e4=(i,l,c,a)=>{if(l&&typeof l=="object"||typeof l=="function")for(let e of X2(l))!c4.call(i,e)&&e!==c&&M1(i,e,{get:()=>l[e],enumerable:!(a=Q2(l,e))||a.enumerable});return i};var i4=i=>e4(M1({},"__esModule",{value:!0}),i);var $g={};a4($g,{default:()=>d1});module.exports=i4($g);var C=require("obsidian");var O1='<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>',a1="admonition-add-command",F1='<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>',e1="admonition-remove-command",q1='<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>',U="admonition-warning",R1='<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 28
`),r=0,t={};for(let d=0;d<o.length;d++){let u=n4(o[d],e);if(u===!1)break;let V=n[u];if(t[V]!==void 0)break;t[V]=o[d].slice(e[u].length).trim(),++r}let{title:h,collapse:v,icon:m,color:s,metadata:p}=t;if(s?.startsWith("rgb")&&(s=s.slice(4,-1)),s?.startsWith("#")){let d=s.slice(1),u=Number.parseInt(d,16),V=u>>16&255,L=u>>8&255,g=u&255;s=`${V}, ${L}, ${g}`}if(s?.startsWith("hsl")){let[d,u,V]=s.slice(4,-1).split(",").map(y=>Number(y.replace("%","").trim())),[L,g,x]=l4(d,u,V);s=`${L}, ${g}, ${x}`}if(s&&(s.startsWith("hsb")||s.startsWith("hsv"))){let[d,u,V]=s.slice(4,-1).split(",").map(y=>Number(y.replace("%","").trim())),[L,g,x]=o4(d,u,V);s=`${L}, ${g}, ${x}`}let M=o.slice(r).join(`
`);return v!==void 0&&v!=="none"&&v!=="open"&&v!=="closed"&&(v="closed"),"title"in t||c.noTitle||(h=a),h&&h.trim()===""&&v!==void 0&&v!=="none"&&(h=a,new W1.Notice("An admonition must have a title if it is collapsible.")),{title:h,collapse:v,content:M,icon:m,color:s,metadata:p}}function l4(i,l,c){let a=i/360,e=l/100,n=c/100,o=0,r=0,t=0;if(e===0)o=n,r=n,t=n;else{let h=(s,p,M)=>{let d=M<0?M+1:M>1?M-1:M;return d<.16666666666666666?s+(p-s)*6*d:d<.5?p:d<.6666666666666666?s+(p-s)*(.6666666666666666-d)*6:s},v=n<.5?n*(1+e):n+e-n*e,m=2*n-v;o=h(m,v,a+1/3),r=h(m,v,a),t=h(m,v,a-1/3)}return[Math.round(o*255),Math.round(r*255),Math.round(t*255)]}function o4(i,l,c){let a=i/360,e=l/100,n=c/100,o=0,r=0,t=0,h=Math.floor(a*6),v=a*6-h,m=n*(1-e),s=n*(1-v*e),p=n*(1-(1-v)*e);switch(h%6){case 0:o=n,r=p,t=m;break;case 1:o=s,r=n,t=m;break;case 2:o=m,r=n,t=p;break;case 3:o=m,r=s,t=n;break;case 4:o=p,r=m,t=n;break;case 5:o=n,r=m,t=s;break}return[Math.round(o*255),Math.round(r*255),Math.round(t*255)]}var I=require("obsidian");var _1=require("obsidian"),i1=class extends _1.EditorSuggest{constructor(c){super(c.app);this.plugin=c}getSuggestions(c){return c.query?.length?Object.entries(this.plugin.admonitions).filter(a=>a[0].toLowerCase().contains(c.query.toLowerCase())):Object.entries(this.plugin.admonitions)}renderSuggestion([c,a],e){e.addClasses(["admonition-suggester-item","mod-complex"]),e.style.setProperty("--callout-color",a.color),e.createSpan({text:c});let n=e.createDiv("suggestion-aux").createDiv({cls:"suggestion-flair",attr:{style:"color: rgb(var(--callout-color))"}}),o=this.plugin.iconManager.getIconNode(a.icon);o instanceof HTMLDivElement&&o.childElementCount===1?o=o.firstElementChild:o!==null&&(o.removeClass("svg-inline--fa"),o.addClass("svg-icon")),n.appendChild(o??createDiv())}onTrigger(c,a){let e=a.getLine(c.line),n=this.testAndReturnQuery(e,c);if(!n)return null;let[o,r,t]=n;return Object.keys(this.plugin.admonitions).find(h=>h.toLowerCase()===t.toLowerCase())?null:{end:c,start:{ch:n.index+r.length,line:c.line},query:t}}},n1=class extends i1{selectSuggestion([l],c){if(!this.context)return;let{editor:a,query:e,start:n,end:o}=this.context,r=a.getLine(o.line).slice(o.ch),[t,h]=r.match(/^(\] ?)/)??[];a.replaceRange(`${l}] `,n,{...o,ch:n.ch+e.length+(h?.length??0)},"admonitions"),a.setCursor(n.line,n.ch+l.length+2),this.close()}testAndReturnQuery(l,c){if(/> ?\[!\w+\]/.test(l.slice(0,c.ch)))return null;let a=l.match(/(> ?\[!)(\w*)\]?/);return a||null}},l1=class extends i1{selectSuggestion([l],c){if(!this.context)return;let{editor:a,start:e,end:n}=this.context;a.replaceRange(`${l}`,e,n,"admonitions"),a.setCursor(e.line,e.ch+l.length),this.close()}testAndReturnQuery(l,c){if(!/```ad-\w*/.test(l))return null;let a=l.match(/(```ad-)(\w*)/);return a||null}};var G=class extends I.Component{constructor(c){super();this.plugin=c;this.heights=["height","padding-top","padding-bottom","margin-top","margin-bottom"];this.heightMap=new WeakMap;this.indexing=[];this.style=document.head.createEl("style",{attr:{id:"ADMONITIONS_CUSTOM_STYLE_SHEET"}})}onload(){document.head.appendChild(this.style);for(let c of Object.values(this.plugin.data.userAdmonitions))this.addAdmonition(c);this.setUseSnippet(),this.plugin.registerEditorSuggest(new n1(this.plugin)),this.plugin.registerMarkdownPostProcessor(this.calloutProcessor.bind(this))}calloutProcessor(c,a){let e=c?.querySelector(".callout");if(!e)return;let n=e.dataset.callout,o=this.plugin.admonitions[n];if(!o)return;let r=e.querySelector(".callout-title"),t=e.querySelector(".callout-content"),h=a.getSectionInfo(c);if(h){let{text:v,lineStart:m,lineEnd:s}=h,p=v.split(`
`)[m],[,M]=p.match(/> \[!.+\|(.*)]/)??[];if(M&&(e.dataset.calloutMetadata=M),t&&(this.plugin.admonitions[n].copy??this.plugin.data.copyButton)){let d=t.createDiv("admonition-content-copy");(0,I.setIcon)(d,"copy"),d.addEventListener("click",()=>{navigator.clipboard.writeText(v.split(`
`).slice(m+1,s+1).join(`
`).replace(/^> /gm,"")).then(async()=>{new I.Notice("Callout content copied to clipboard.")})})}}if(o.noTitle&&!e.dataset.calloutFold&&r.querySelector(".callout-title-inner")?.textContent?.toLowerCase()===o.type.toLowerCase()&&r.addClass("no-title"),!o.noTitle&&this.plugin.data.autoCollapse&&!e.dataset.calloutFold&&this.setCollapsible(e),o.title&&r.textContent===n[0].toUpperCase()+n.slice(1).toLowerCase()){let v=r.querySelector(".callout-title-inner");v&&v.setText(o.title)}this.plugin.data.dropShadow&&e.addClass("drop-shadow")}setCollapsible(c){let a=c.querySelector(".callout-title"),e=c.querySelector(".callout-content");if(!e)return;c.addClass("is-collapsible"),this.plugin.data.defaultCollapseType==="closed"?(c.dataset.calloutFold="-",c.addClass("is-collapsed")):c.dataset.calloutFold="+";let n=a.createDiv("callout-fold");(0,I.setIcon)(n,"chevron-down");let o=c.hasClass("is-collapsed");if(this.getComputedHeights(e),o)for(let r of this.heights)e.style.setProperty(r,"0px");a.onclick=r=>{this.collapse(c,r)}}collapse(c,a){a?.preventDefault();let e=c.querySelector(".callout-content");function n(r){e.removeEventListener("transitionend",n),e.style.removeProperty("transition")}e.addEventListener("transitionend",n),e.style.setProperty("transition","all 100ms cubic-bezier(.02, .01, .47, 1)");let o=c.hasClass("is-collapsed");if(!a||a.button===0){let r=this.getComputedHeights(e);for(let t of this.heights)e.style.setProperty(t,o?r[t]:"0px");c.toggleClass("is-collapsed",!o)}}getComputedHeights(c){if(this.heightMap.has(c))return this.heightMap.get(c);let a=getComputedStyle(c),e={};for(let n of this.heights)e[n]=a.getPropertyValue(n);return this.heightMap.set(c,e),e}generateCssString(){let c=[`/* This snippet was auto-generated by the Admonitions plugin */
`];for(let a of Array.from(this.sheet.cssRules))c.push(a.cssText);return c.join(`
`)}addAdmonition(c){let a=c.type.toLowerCase();if(this.indexing.contains(a)){let o=this.indexing.indexOf(a);this.sheet.deleteRule(o),this.indexing.splice(o,1)}if(this.plugin.isStyledWithCss(c)){this.updateSnippet();return}if(!c.icon){this.updateSnippet();return}let e,n=this.plugin.shouldInjectColor(c)?`--callout-color: ${c.color};`:"";c.icon.type==="obsidian"?e=`.callout[data-callout="${a}"] {
${n}
--callout-icon: ${c.icon.name}; /* Icon name from the Obsidian Icon Set */
}`:e=`.callout[data-callout="${a}"] {
${n}
--callout-icon: "${(this.plugin.iconManager.getIconNode(c.icon)?.outerHTML??"").replace(/(width|height)=(\\?"|')\d+(\\?"|')/g,"").replace(/"/g,'\\"')}";
}`,this.indexing=[...this.indexing.filter(o=>o!==a),a],this.sheet.insertRule(e,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():(this.plugin.app.customCss.setCssEnabledStatus(this.plugin.data.snippetPath,!1),this.plugin.app.customCss.readSnippets(),this.plugin.data.snippetPath&&this.plugin.app.vault.adapter.remove(this.snippetPath).catch(()=>{}))}async updateSnippet(){if(!this.plugin.data.useSnippet)return;let c=this.snippetPath,a=c.substring(0,c.lastIndexOf("/"));await this.plugin.app.vault.adapter.exists(a)||await this.plugin.app.vault.adapter.mkdir(a),await this.plugin.app.vault.adapter.write(c,this.generateCssString()),this.plugin.app.customCss.setCssEnabledStatus(this.plugin.data.snippetPath,!0),this.plugin.app.customCss.readSnippets()}};function j(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?j=function(l){return typeof l}:j=function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},j(i)}function r4(i,l){if(!(i instanceof l))throw new TypeError("Cannot call a class as a function")}function j1(i,l){for(var c=0;c<l.length;c++){var a=l[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(i,a.key,a)}}function t4(i,l,c){return l&&j1(i.prototype,l),c&&j1(i,c),i}function f4(i,l,c){return l in i?Object.defineProperty(i,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[l]=c,i}function H(i){for(var l=1;l<arguments.length;l++){var c=arguments[l]!=null?arguments[l]:{},a=Object.keys(c);typeof Object.getOwnPropertySymbols=="function"&&(a=a.concat(Object.getOwnPropertySymbols(c).filter(function(e){return Object.getOwnPropertyDescriptor(c,e).enumerable}))),a.forEach(function(e){f4(i,e,c[e])})}return i}function n2(i,l){return s4(i)||h4(i,l)||v4()}function s4(i){if(Array.isArray(i))return i}function h4(i,l){var c=[],a=!0,e=!1,n=void 0;try{for(var o=i[Symbol.iterator](),r;!(a=(r=o.next()).done)&&(c.push(r.value),!(l&&c.length===l));a=!0);}catch(t){e=!0,n=t}finally{try{!a&&o.return!=null&&o.return()}finally{if(e)throw n}}return c}function v4(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var $1=function(){},x1={},l2={},m4=null,o2={mark:$1,measure:$1};try{typeof window<"u"&&(x1=window),typeof document<"u"&&(l2=document),typeof MutationObserver<"u"&&(m4=MutationObserver),typeof performance<"u"&&(o2=performance)}catch{}var z4=x1.navigator||{},Y1=z4.userAgent,K1=Y1===void 0?"":Y1,h1=x1,b=l2;var o1=o2,nL=!!h1.document,b1=!!b.documentElement&&!!b.head&&typeof b.addEventListener=="function"&&typeof b.createElement=="function",lL=~K1.indexOf("MSIE")||~K1.indexOf("Trident/"),k="___FONT_AWESOME___";var r2="fa",t2="svg-inline--fa",p4="data-fa-i2svg";var oL=(function(){try{return!0}catch{return!1}})();var f2=[1,2,3,4,5,6,7,8,9,10],d4=f2.concat([11,12,13,14,15,16,17,18,19,20]);var Z={GROUP:"group",SWAP_OPACITY:"swap-opacity",PRIMARY:"primary",SECONDARY:"secondary"},rL=["xs","sm","lg","fw","ul","li","border","pull-left","pull-right","spin","pulse","rotate-90","rotate-180","rotate-270","flip-horizontal","flip-vertical","flip-both","stack","stack-1x","stack-2x","inverse","layers","layers-text","layers-counter",Z.GROUP,Z.SWAP_OPACITY,Z.PRIMARY,Z.SECONDARY].concat(f2.map(function(i){return"".concat(i,"x")})).concat(d4.map(function(i){return"w-".concat(i)})),s2=h1.FontAwesomeConfig||{};function M4(i){var l=b.querySelector("script["+i+"]");if(l)return l.getAttribute(i)}function u4(i){return i===""?!0:i==="false"?!1:i==="true"?!0:i}b&&typeof b.querySelector=="function"&&(J1=[["data-family-prefix","familyPrefix"],["data-replacement-class","replacementClass"],["data-auto-replace-svg","autoReplaceSvg"],
2025-08-02 12:09:34 +08:00
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;
2026-05-06 17:32:44 +08:00
}`;function W4(){var i=r2,l=t2,c=N.familyPrefix,a=N.replacementClass,e=U4;if(c!==i||a!==l){var n=new RegExp("\\.".concat(i,"\\-"),"g"),o=new RegExp("\\--".concat(i,"\\-"),"g"),r=new RegExp("\\.".concat(l),"g");e=e.replace(n,".".concat(c,"-")).replace(o,"--".concat(c,"-")).replace(r,".".concat(a))}return e}var G4=(function(){function i(){r4(this,i),this.definitions={}}return t4(i,[{key:"add",value:function(){for(var c=this,a=arguments.length,e=new Array(a),n=0;n<a;n++)e[n]=arguments[n];var o=e.reduce(this._pullDefinitions,{});Object.keys(o).forEach(function(r){c.definitions[r]=H({},c.definitions[r]||{},o[r]),V2(r,o[r]),g2()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(c,a){var e=a.prefix&&a.iconName&&a.icon?{0:a}:a;return Object.keys(e).map(function(n){var o=e[n],r=o.prefix,t=o.iconName,h=o.icon;c[r]||(c[r]={}),c[r][t]=h}),c}}]),i})();function _4(){N.autoAddCss&&!i2&&(y4(W4()),i2=!0)}function j4(i,l){return Object.defineProperty(i,"abstract",{get:l}),Object.defineProperty(i,"html",{get:function(){return i.abstract.map(function(a){return L2(a)})}}),Object.defineProperty(i,"node",{get:function(){if(b1){var a=b.createElement("div");return a.innerHTML=i.html,a.children}}}),i}function B(i){var l=i.prefix,c=l===void 0?"fa":l,a=i.iconName;if(a)return a2(y1.definitions,c,a)||a2(w.styles,c,a)}function $4(i){return function(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(l||{}).icon?l:B(l||{}),e=c.mask;return e&&(e=(e||{}).icon?e:B(e||{})),i(a,H({},c,{mask:e}))}}var y1=new G4;var i2=!1;var b2=$4(function(i){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},c=l.transform,a=c===void 0?F:c,e=l.symbol,n=e===void 0?!1:e,o=l.mask,r=o===void 0?null:o,t=l.maskId,h=t===void 0?null:t,v=l.title,m=v===void 0?null:v,s=l.titleId,p=s===void 0?null:s,M=l.classes,d=M===void 0?[]:M,u=l.attributes,V=u===void 0?{}:u,L=l.styles,g=L===void 0?{}:L;if(i){var x=i.prefix,y=i.iconName,P=i.icon;return j4(H({type:"icon"},i),function(){return _4(),N.autoA11y&&(m?V["aria-labelledby"]="".concat(N.replacementClass,"-title-").concat(p||s1()):(V["aria-hidden"]="true",V.focusable="false")),Z4({icons:{main:e2(P),mask:r?e2(r.icon):{found:!1,width:null,height:null,icon:{}}},prefix:x,iconName:y,transform:H({},F,a),symbol:n,title:m,maskId:h,titleId:p,extra:{attributes:V,styles:g,classes:d}})})}});var Y4={prefix:"fab",iconName:"500px",icon:[448,512,[],"f26e","M103.3 344.3c-6.5-14.2-6.9-18.3 7.4-23.1 25.6-8 8 9.2 43.2 49.2h.3v-93.9c1.2-50.2 44-92.2 97.7-92.2 53.9 0 97.7 43.5 97.7 96.8 0 63.4-60.8 113.2-128.5 93.3-10.5-4.2-2.1-31.7 8.5-28.6 53 0 89.4-10.1 89.4-64.4 0-61-77.1-89.6-116.9-44.6-23.5 26.4-17.6 42.1-17.6 157.6 50.7 31 118.3 22 160.4-20.1 24.8-24.8 38.5-58 38.5-93 0-35.2-13.8-68.2-38.8-93.3-24.8-24.8-57.8-38.5-93.3-38.5s-68.8 13.8-93.5 38.5c-.3.3-16 16.5-21.2 23.9l-.5.6c-3.3 4.7-6.3 9.1-20.1 6.1-6.9-1.7-14.3-5.8-14.3-11.8V20c0-5 3.9-10.5 10.5-10.5h241.3c8.3 0 8.3 11.6 8.3 15.1 0 3.9 0 15.1-8.3 15.1H130.3v132.9h.3c104.2-109.8 282.8-36 282.8 108.9 0 178.1-244.8 220.3-310.1 62.8zm63.3-260.8c-.5 4.2 4.6 24.5 14.6 20.6C306 56.6 384 144.5 390.6 144.5c4.8 0 22.8-15.3 14.3-22.8-93.2-89-234.5-57-238.3-38.2zM393 414.7C283 524.6 94 475.5 61 310.5c0-12.2-30.4-7.4-28.9 3.3 24 173.4 246 256.9 381.6 121.3 6.9-7.8-12.6-28.4-20.7-20.4zM213.6 306.6c0 4 4.3 7.3 5.5 8.5 3 3 6.1 4.4 8.5 4.4 3.8 0 2.6.2 22.3-19.5 19.6 19.3 19.1 19.5 22.3 19.5 5.4 0 18.5-10.4 10.7-18.2L265.6 284l18.2-18.2c6.3-6.8-10.1-21.8-16.2-15.7L249.7 268c-18.6-18.8-18.4-19.5-21.5-19.5-5 0-18 11.7-12.4 17.3L234 284c-18.1 17.9-20.4 19.2-20.4 22.6z"]},K4={prefix:"fab",iconName:"accessible-icon",icon:[448,512,[],"f368","M423.9 255.8L411 413.1c-3.3 40.7-63.9 35.1-60.6-4.9l10-122.5-41.1 2.3c10.1 20.7 15.8 43.9 15.8 68.5 0 41.2-16.1 78.7-42.3 106.5l-39.3-39.3c57.9-63.7 13.1-167.2-74-167.2-25.9 0-49.5 9.9-67.2 26L73 243.2c22-20.7 50.1-35.1 81.4-40.2l75.3-85.7-42.6-24.8-51.6 46c-30 26.8-70.6-18.5-40.5-45.4l68-60.7c9.8-8.8 24.1-10.2 35.5-3.6 0 0 139.3 80.9 139.5 81.1 16.2 10.1 20.7 36 6.1 52.6L285.7 229l106.1-5.9c18.5-1.1 33.6 14.4 32.1 32.
`).slice(1,-1)){if(v){if(/^title:/.test(s)){r=s.match(/^title:(.*)/)?.[1].trim()??o[0].toUpperCase()+o.slice(1).toLowerCase();continue}if(/^collapse:/.test(s)){t=(s.match(/^collapse:\s?(.*)/)?.[1].trim()??"open")==="open"?"+":"-";continue}/^(title|collapse|color|icon):/.test(s)||(v=!1)}h.push(s)}let m=h.join(`
`);/^(`{3,})ad-(\w+)([\s\S]*?)?\n^\1/m.test(m)&&(m=this.replaceCodeBlockInPlace(m)),a=a.replace(n,`> [!${o}]${t}${r.length?" ":""}${r}
> ${m.split(`
`).join(`
> `)}`),this.converted++}return a}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(f("heading.advanced")),a.createDiv("collapser").createDiv("handle"),new z.Setting(c).setName(f("markdown-highlight.name")).setDesc(f("markdown-highlight.desc")).addToggle(e=>{e.setValue(this.plugin.data.syntaxHighlight),e.onChange(async n=>{this.plugin.data.syntaxHighlight=n,n?this.plugin.turnOnSyntaxHighlighting():this.plugin.turnOffSyntaxHighlighting(),await this.plugin.saveSettings()})})}buildTypes(){this.additionalEl.empty();for(let c of Object.values(this.plugin.data.userAdmonitions)){let a=new z.Setting(this.additionalEl),e=this.plugin.getAdmonitionElement(c.type,c.type[0].toUpperCase()+c.type.slice(1).toLowerCase(),this.plugin.isStyledWithCss(c)?{}:c.icon,this.plugin.shouldInjectColor(c)?c.color:null);a.infoEl.replaceWith(e),c.command?a.addExtraButton(n=>{n.setIcon(e1.toString()).setTooltip(f("btn.unregister")).onClick(async()=>{this.plugin.unregisterCommandsFor(c),await this.plugin.saveSettings(),this.display()})}):a.addExtraButton(n=>{n.setIcon(a1.toString()).setTooltip(f("btn.register")).onClick(async()=>{this.plugin.registerCommandsFor(c),await this.plugin.saveSettings(),this.display()})}),a.addExtraButton(n=>{n.setIcon("pencil").setTooltip(f("btn.edit")).onClick(()=>{let o=new p1(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,styleWithCss:o.styleWithCss,injectColor:o.styleWithCss?!1:void 0,noTitle:o.noTitle,copy:o.copy};if(t.type!==c.type){this.plugin.unregisterType(c);let h=Object.entries(this.plugin.data.userAdmonitions);this.plugin.data.userAdmonitions=Object.fromEntries(h.map(([v,m])=>v===c.type?[t.type,t]:[v,m]))}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(f("btn.delete")).onClick(()=>{this.plugin.removeAdmonition(c),this.display()})})}}},p1=class i extends z.Modal{constructor(c,a){super(c.app);this.plugin=c;this.color="#7d7d7d";this.icon={};this.saved=!1;this.error=!1;this.styleWithCss=!1;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.styleWithCss=this.plugin.isStyledWithCss(a),this.noTitle=a.noTitle??!1,this.copy=a.copy??this.plugin.data.copyButton)}setAdmonitionElement(c){this.admonitionPreviewParent.empty(),this.admonitionPreview=this.plugin.getAdmonitionElement(this.type,c[0].toUpperCase()+c.slice(1).toLowerCase(),this.styleWithCss?{}:this.icon,!this.styleWithCss&&this.plugin.data.injectColor?this.color:null),this.admonitionPreview.createDiv("callout-content admonition-content").createEl("p",{text:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla."}),this.admonitionPreviewParent.appendChild(this.admonitionPreview)}async display(){this.containerEl.addClass("admonition-settings-modal"),this.titleEl.setText(`${this.editing?"Edit":"Add"} Admonition`);let{contentEl:c}=this;c.empty();let a=c.createDiv(),e=this.title??this.type??"...";this.admonitionPreviewParent=c.createDiv(),this.setAdmonitionElement(e[0].toUpperCase()+e.slice(1).toLowerCase());let n,o=new z.Setting(a).setName(f("admonition-type.name")).addText(s=>{n=s,n.setValue(this.type).onChange(p=>{let M=E.validateType(p,this.plugin,this.originalType);if(M.success===!1){i.setValidationError(s.inputEl,M.message);return}i.removeValidationError(s.inputEl),this.type=p,this.title||this.setAdmonitionElement(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 z.Setting(a).setName(f("admon
`),e.collapse!=="default"&&(o=`collapse: ${e.collapse}
`),c.getDoc().replaceSelection(`\`\`\`ad-${e.type}
2025-08-02 12:09:34 +08:00
${n}${o}
${c.getDoc().getSelection()}
\`\`\`
2026-05-06 17:32:44 +08:00
`);let r=c.getCursor();c.setCursor(r.line-3)},e.open()}}),this.addCommand({id:"insert-callout",name:"Insert Callout",editorCallback:(c,a)=>{let e=new K(this);e.onClose=()=>{if(!e.insert)return;let n="",o="";if(e.collapse!=="default")switch(e.collapse){case"open":o="+";break;case"closed":o="-";break;case"none":o="";break}e.title.length&&e.title.toLowerCase()!==e.type.toLowerCase()&&(n=` ${e.title}`);let r=c.getDoc().getSelection();c.getDoc().replaceSelection(`> [!${e.type}]${o}${n}
2025-08-02 12:09:34 +08:00
> ${r.split(`
`).join(`
> `)}
2026-05-06 17:32:44 +08:00
`)},e.open()}})})}async downloadIcon(c){this.iconManager.downloadIcon(c)}async removeIcon(c){this.iconManager.removeIcon(c)}async postprocessor(c,a,e,n){if(this.admonitions[c])try{let o=typeof n=="string"?n:n?.sourcePath??this.app.workspace.getActiveFile()?.path??"",{title:r,collapse:t,content:h,icon:v,color:m,metadata:s}=G1(c,a,this.admonitions[c]);this.data.autoCollapse&&!t?t=this.data.defaultCollapseType??"open":t&&t.trim()==="none"&&(t="");let p=this.admonitions[c],M=this.isStyledWithCss(p),d=v?this.iconManager.iconDefinitions.find(({name:g})=>v===g):null,u=this.getAdmonitionElement(c,r,d??(M?{}:p.icon),m??(this.shouldInjectColor(p)?p.color:null),t,o,s);this.renderAdmonitionContent(u,c,h,n,o,a),t&&t!=="none"&&this.calloutManager.setCollapsible(u);let V=e.parentElement;V&&V.addClass("admonition-parent",`admonition-${c}-parent`),e.replaceWith(u);let L=app.workspace.getActiveViewOfType(C.MarkdownView);if(L?.editor?.cm?.state?.field(C.editorLivePreviewField)){let g=L.editor.cm;u.onClickEvent(x=>{if(!(x.defaultPrevented||x.detail>1||x.shiftKey))try{setTimeout(()=>{try{let y=g.posAtDOM(u);g.focus(),g.dispatch({selection:{head:y,anchor:y}})}catch{}},10)}catch{}})}return u}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:
2025-08-02 12:09:34 +08:00
2026-05-06 17:32:44 +08:00
`+a}),e.replaceWith(r)}}getAdmonitionElement(c,a,e,n,o,r,t){let h=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??""}}),v=h.createDiv({cls:`callout-title admonition-title ${a?.trim().length?"":"no-title"}`});if(a?.trim().length){let m=v.createDiv("callout-icon admonition-title-icon");e?.name&&e.type&&m.appendChild(this.iconManager.getIconNode(e)??createDiv());let s=v.createDiv("callout-title-inner admonition-title-content");C.MarkdownRenderer.render(this.app,a,s,r??"",this),s.firstElementChild&&s.firstElementChild instanceof HTMLParagraphElement&&s.setChildrenInPlace(Array.from(s.firstElementChild.childNodes))}return o&&(h.addClass("is-collapsible"),o==="closed"&&h.addClass("is-collapsed")),this.data.dropShadow||h.addClass("no-drop"),h}renderAdmonitionContent(c,a,e,n,o,r){let t=new C.MarkdownRenderChild(c);if(t.containerEl=c,n&&typeof n!="string"&&n.addChild(t),e?.trim().length){let h=this.getAdmonitionContentElement(a,c,e);if(/^`{3,}mermaid/m.test(e)){let m=!c.hasAttribute("open");c instanceof HTMLDetailsElement&&c.setAttribute("open","open"),setImmediate(()=>{C.MarkdownRenderer.renderMarkdown(e,h,o,t),c instanceof HTMLDetailsElement&&m&&c.removeAttribute("open")})}else C.MarkdownRenderer.renderMarkdown(e,h,o,t);(!e.length||h.textContent.trim()==="")&&this.data.hideEmpty&&c.addClass("no-content");let v=h.querySelectorAll(".task-list-item-checkbox");if(v?.length){let m=r.split(`
`),s=0;v.forEach(p=>{let M=m.slice(s).findIndex(d=>/^[ \t>]*- \[.\]/.test(d));M!==-1&&(p.dataset.line=`${M+s+1}`,s=M+s+1)})}}}getAdmonitionContentElement(c,a,e){let n=a.createDiv("callout-content admonition-content");if(this.admonitions[c].copy??this.data.copyButton){let o=n.createDiv("admonition-content-copy");(0,C.setIcon)(o,"copy"),o.addEventListener("click",()=>{navigator.clipboard.writeText(e.trim()).then(async()=>{new C.Notice("Admonition content copied to clipboard.")})})}return n}registerType(c){this.data.syntaxHighlight&&this.turnOnSyntaxHighlighting([c]),this.postprocessors.has(c)&&C.MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(`ad-${c}`),this.postprocessors.set(c,this.registerMarkdownCodeBlockProcessor(`ad-${c}`,(e,n,o)=>this.postprocessor(c,e,n,o)));let a=this.admonitions[c];a.command&&this.registerCommandsFor(a)}get admonitions(){return{...U1,...this.data.userAdmonitions}}async addAdmonition(c){c.type=c.type.toLowerCase(),this.data.userAdmonitions={...this.data.userAdmonitions,[c.type]:c},this.registerType(c.type),this.calloutManager.addAdmonition(c),await this.saveSettings()}registerCommandsFor(c){c.command=!0,this.addCommand({id:`insert-${c.type}-callout`,name:`Insert ${c.type} Callout`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{let o=e.getDoc().getSelection();e.getDoc().replaceSelection(`> [!${c.type}]
2025-08-02 12:09:34 +08:00
> ${o.split(`
`).join(`
> `)}
2026-05-06 17:32:44 +08:00
`);let r=e.getCursor();e.setCursor(r.line-2)}catch{new C.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}`,name:`Insert ${c.type}`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
2025-08-02 12:09:34 +08:00
2026-05-06 17:32:44 +08:00
${e.getDoc().getSelection()}
2025-08-02 12:09:34 +08:00
\`\`\`
2026-05-06 17:32:44 +08:00
`);let o=e.getCursor();e.setCursor(o.line-2)}catch{new C.Notice("There was an issue inserting the admonition.")}}}),this.addCommand({id:`insert-${c.type}-with-title`,name:`Insert ${c.type} With Title`,editorCheckCallback:(a,e,n)=>{if(a)return c.command;if(c.command)try{let o=c.title??"";e.getDoc().replaceSelection(`\`\`\`ad-${c.type}
2025-08-02 12:09:34 +08:00
title: ${o}
2026-05-06 17:32:44 +08:00
${e.getDoc().getSelection()}
2025-08-02 12:09:34 +08:00
\`\`\`
2026-05-06 17:32:44 +08:00
`);let r=e.getCursor();e.setCursor(r.line-3)}catch{new C.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)&&(C.MarkdownPreviewRenderer.unregisterPostProcessor(this.postprocessors.get(c.type)),C.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({},jg,c),this.data.userAdmonitions){if(!this.data.version||Number(this.data.version.split(".")[0])<5)for(let a in this.data.userAdmonitions)Object.hasOwn(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 C.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);for(let a of Object.keys(this.data.userAdmonitions)){let e=this.data.userAdmonitions[a];e.styleWithCss===void 0&&e.injectColor===!1&&(e.styleWithCss=!0)}}if(!this.data.rpgDownloadedOnce&&this.data.userAdmonitions&&Object.values(this.data.userAdmonitions).some(a=>a.icon.type==="rpg")&&!this.data.icons.includes("rpg"))try{await this.downloadIcon("rpg"),this.data.rpgDownloadedOnce=!0}catch{}if(this.data.userAdmonitions)for(let a of Object.keys(this.data.userAdmonitions)){let e=a.toLowerCase();e!==a&&(this.data.userAdmonitions[e]={...this.data.userAdmonitions[a],type:e},delete this.data.userAdmonitions[a])}await this.saveSettings()}turnOnSyntaxHighlighting(c=Object.keys(this.admonitions)){this.data.syntaxHighlight&&(c.forEach(a=>{if(this.data.syntaxHighlight){let[,e]=`${a}`.match(/^([\w+#-]*)[^\n`]*$/);window.CodeMirror.defineMode(`ad-${e}`,(n,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=>{Object.hasOwn(window.CodeMirror.modes,`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()}};
/*! Bundled license information:
@fortawesome/fontawesome-svg-core/index.es.js:
@fortawesome/free-brands-svg-icons/index.es.js:
@fortawesome/free-regular-svg-icons/index.es.js:
@fortawesome/free-solid-svg-icons/index.es.js:
(*!
* 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)
*)
*/
/* nosourcemap */