docsify-plugin-flexible-alerts
Version:
docsify plugin to convert blockquotes into beautiful and configurable alerts using preconfigured or own styles and alert types.
10 lines (9 loc) • 14.2 kB
JavaScript
/*!
* docsify-plugin-flexible-alerts
* v1.2.0
* https://github.com/fzankl/docsify-plugin-flexible-alerts#readme
* (c) 2025 Fabian Zankl
* MIT license
*/
!function(){"use strict";function t(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function r(r){for(var o=1;o<arguments.length;o++){var c=null!=arguments[o]?arguments[o]:{};o%2?e(Object(c),!0).forEach(function(e){t(r,e,c[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(c)):e(Object(c)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(c,t))})}return r}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}!function(t,e){void 0===e&&(e={});var r=e.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css","top"===r&&o.firstChild?o.insertBefore(c,o.firstChild):o.appendChild(c),c.styleSheet?c.styleSheet.cssText=t:c.appendChild(document.createTextNode(t))}}(".alert{word-wrap:break-word;display:block;margin-bottom:1rem!important;padding:.75rem 1.25rem!important;position:relative;word-break:break-word}.alert>*{max-width:100%}.alert>:first-child{margin-top:0}.alert>:last-child{margin-bottom:0}.alert:before{content:unset!important}.alert+.alert{margin-top:-.25rem!important}.alert p{margin-bottom:.5rem;margin-top:.5rem}.alert .title{align-items:center;display:flex;flex-wrap:wrap;font-weight:600;margin:0}.icon{background-repeat:no-repeat;display:inline-block;height:20px;margin-right:.5rem;width:20px}.alert.callout{background:var(--background);border:1px solid #eee;border-left-width:.25rem;border-radius:.25rem}.alert.callout.note{border-left-color:#17a2b8!important}.alert.callout.note .title{color:#17a2b8}.alert.callout.note .icon-note{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%2317a2b8' d='M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9 2 12t.788-3.9 2.137-3.175T8.1 2.788 12 2t3.9.788 3.175 2.137T21.213 8.1 22 12t-.788 3.9-2.137 3.175-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4 6.325 6.325 4 12t2.325 5.675T12 20m0-8'/%3E%3C/svg%3E\")}.alert.callout.tip{border-left-color:#28a745!important}.alert.callout.tip .title{color:#28a745}.alert.callout.tip .icon-tip{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%2328a745' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M9 18h6m-5 3h4m-5-6c.001-2-.499-2.5-1.5-3.5S6.025 9.487 6 8c-.047-3.05 2-5 6-5 4.001 0 6.049 1.95 6 5-.023 1.487-.5 2.5-1.5 3.5-.999 1-1.499 1.5-1.5 3.5'/%3E%3C/svg%3E\")}.alert.callout.important{border-left-color:#8250df!important}.alert.callout.important .title{color:#8250df}.alert.callout.important .icon-important{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%238250df' d='M16.586 52.246c1.172 0 1.969-.61 3.375-1.875l8.11-7.195h15.023c6.984 0 10.734-3.867 10.734-10.735V14.488c0-6.867-3.75-10.734-10.734-10.734H12.906c-6.96 0-10.734 3.844-10.734 10.734v17.953c0 6.891 3.773 10.735 10.734 10.735h1.125v6.093c0 1.805.938 2.977 2.555 2.977m.96-4.289V41.16c0-1.265-.468-1.758-1.757-1.758h-2.86c-4.757 0-6.984-2.414-6.984-6.984v-17.93c0-4.57 2.227-6.96 6.985-6.96h30.164c4.734 0 6.96 2.39 6.96 6.96v17.93c0 4.57-2.226 6.984-6.96 6.984H27.906c-1.289 0-1.968.188-2.86 1.102Zm10.618-19.758c1.125 0 1.781-.633 1.805-1.851l.328-12.375c.023-1.196-.914-2.086-2.156-2.086-1.266 0-2.157.867-2.133 2.062l.328 12.399c.024 1.195.656 1.851 1.828 1.851m0 7.617c1.36 0 2.531-1.078 2.531-2.437 0-1.36-1.148-2.438-2.53-2.438-1.384 0-2.532 1.102-2.532 2.438s1.172 2.437 2.531 2.437'/%3E%3C/svg%3E\")}.alert.callout.warning{border-left-color:#f0ad4e!important}.alert.callout.warning .title{color:#f0ad4e}.alert.callout.warning .icon-warning{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%23f0ad4e' d='M9.965 50.207h36.07c3.985 0 6.469-2.86 6.469-6.469 0-1.078-.281-2.18-.867-3.187L33.567 9.074c-1.22-2.133-3.352-3.281-5.555-3.281-2.18 0-4.336 1.148-5.579 3.281l-18.07 31.5a6.25 6.25 0 0 0-.867 3.164c0 3.61 2.508 6.469 6.469 6.469m.047-3.68c-1.641 0-2.72-1.336-2.72-2.789 0-.422.071-.914.306-1.406l18.046-31.477c.516-.89 1.454-1.312 2.368-1.312s1.804.398 2.32 1.312l18.047 31.5c.234.47.351.961.351 1.383 0 1.453-1.125 2.79-2.742 2.79Zm18-12.117c1.125 0 1.78-.656 1.804-1.875l.328-12.351c.024-1.196-.914-2.086-2.156-2.086-1.265 0-2.156.867-2.133 2.062l.305 12.375c.023 1.196.68 1.875 1.852 1.875m0 7.617c1.359 0 2.53-1.078 2.53-2.437 0-1.383-1.148-2.438-2.53-2.438-1.383 0-2.532 1.078-2.532 2.438 0 1.336 1.172 2.437 2.532 2.437'/%3E%3C/svg%3E\")}.alert.callout.attention{border-left-color:#dc3545!important}.alert.callout.attention .title{color:#dc3545}.alert.callout.attention .icon-attention{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%23dc3545' d='M20.887 50.71h14.226c2.977 0 4.407-.96 5.93-2.624l8.625-9.563c1.547-1.71 1.945-2.836 1.945-5.156v-10.71c0-2.344-.398-3.446-1.945-5.157l-8.625-9.562c-1.523-1.665-2.953-2.649-5.93-2.649H20.887c-2.977 0-4.383.984-5.93 2.649L6.332 17.5c-1.547 1.71-1.945 2.813-1.945 5.156v10.711c0 2.32.398 3.446 1.945 5.156l8.625 9.563c1.547 1.664 2.953 2.625 5.93 2.625m1.265-3.75c-2.343 0-3-.515-4.312-1.921l-7.97-8.79c-.937-1.031-1.148-1.617-1.148-3.328v-9.82c0-1.711.21-2.297 1.148-3.329l7.969-8.789c1.312-1.43 1.969-1.921 4.312-1.921h11.696c2.343 0 3 .492 4.312 1.921l7.992 8.79c.914 1.03 1.126 1.617 1.126 3.328v9.82c0 1.71-.212 2.297-1.126 3.328l-7.992 8.789c-1.312 1.406-1.969 1.922-4.312 1.922Zm5.86-14.835c1.101 0 1.758-.633 1.78-1.852l.352-12.375c.024-1.195-.914-2.085-2.156-2.085-1.265 0-2.156.867-2.133 2.062l.305 12.398c.023 1.196.68 1.852 1.852 1.852m0 7.617c1.336 0 2.508-1.078 2.508-2.437 0-1.36-1.149-2.438-2.508-2.438-1.383 0-2.532 1.102-2.532 2.438s1.172 2.437 2.532 2.437'/%3E%3C/svg%3E\")}.alert.flat{background-color:#e2e3e5;border:1px solid #d6d8db;border-radius:.125rem;color:#383d41}.alert.flat.note{background-color:#cdeefd;border-color:#b7e7fc;color:#02587f}.alert.flat.note .title{color:#01354d}.alert.flat.note .icon-note{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%2301354d' d='M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9 2 12t.788-3.9 2.137-3.175T8.1 2.788 12 2t3.9.788 3.175 2.137T21.213 8.1 22 12t-.788 3.9-2.137 3.175-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4 6.325 6.325 4 12t2.325 5.675T12 20m0-8'/%3E%3C/svg%3E\")}.alert.flat.tip{background-color:#dbefdc;border-color:#cbe8cd;color:#285b2a}.alert.flat.tip .title{color:#18381a}.alert.flat.tip .icon-tip{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%2318381a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M9 18h6m-5 3h4m-5-6c.001-2-.499-2.5-1.5-3.5S6.025 9.487 6 8c-.047-3.05 2-5 6-5 4.001 0 6.049 1.95 6 5-.023 1.487-.5 2.5-1.5 3.5-.999 1-1.499 1.5-1.5 3.5'/%3E%3C/svg%3E\")}.alert.flat.important{background-color:#d0cede;border-color:#c4c1d5;color:#8250df}.alert.flat.important .title{color:#8250df}.alert.flat.important .icon-important{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%238250df' d='M16.586 52.246c1.172 0 1.969-.61 3.375-1.875l8.11-7.195h15.023c6.984 0 10.734-3.867 10.734-10.735V14.488c0-6.867-3.75-10.734-10.734-10.734H12.906c-6.96 0-10.734 3.844-10.734 10.734v17.953c0 6.891 3.773 10.735 10.734 10.735h1.125v6.093c0 1.805.938 2.977 2.555 2.977m.96-4.289V41.16c0-1.265-.468-1.758-1.757-1.758h-2.86c-4.757 0-6.984-2.414-6.984-6.984v-17.93c0-4.57 2.227-6.96 6.985-6.96h30.164c4.734 0 6.96 2.39 6.96 6.96v17.93c0 4.57-2.226 6.984-6.96 6.984H27.906c-1.289 0-1.968.188-2.86 1.102Zm10.618-19.758c1.125 0 1.781-.633 1.805-1.851l.328-12.375c.023-1.196-.914-2.086-2.156-2.086-1.266 0-2.157.867-2.133 2.062l.328 12.399c.024 1.195.656 1.851 1.828 1.851m0 7.617c1.36 0 2.531-1.078 2.531-2.437 0-1.36-1.148-2.438-2.53-2.438-1.384 0-2.532 1.102-2.532 2.438s1.172 2.437 2.531 2.437'/%3E%3C/svg%3E\")}.alert.flat.warning{background-color:#ffddd3;border-color:#ffcbbc;color:#852d12}.alert.flat.warning .title{color:#581e0c}.alert.flat.warning .icon-warning{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%23581e0c' d='M9.965 50.207h36.07c3.985 0 6.469-2.86 6.469-6.469 0-1.078-.281-2.18-.867-3.187L33.567 9.074c-1.22-2.133-3.352-3.281-5.555-3.281-2.18 0-4.336 1.148-5.579 3.281l-18.07 31.5a6.25 6.25 0 0 0-.867 3.164c0 3.61 2.508 6.469 6.469 6.469m.047-3.68c-1.641 0-2.72-1.336-2.72-2.789 0-.422.071-.914.306-1.406l18.046-31.477c.516-.89 1.454-1.312 2.368-1.312s1.804.398 2.32 1.312l18.047 31.5c.234.47.351.961.351 1.383 0 1.453-1.125 2.79-2.742 2.79Zm18-12.117c1.125 0 1.78-.656 1.804-1.875l.328-12.351c.024-1.196-.914-2.086-2.156-2.086-1.265 0-2.156.867-2.133 2.062l.305 12.375c.023 1.196.68 1.875 1.852 1.875m0 7.617c1.359 0 2.53-1.078 2.53-2.437 0-1.383-1.148-2.438-2.53-2.438-1.383 0-2.532 1.078-2.532 2.438 0 1.336 1.172 2.437 2.532 2.437'/%3E%3C/svg%3E\")}.alert.flat.attention{background-color:#fdd9d7;border-color:#fcc4c1;color:#7f231c}.alert.flat.attention .title{color:#551713}.alert.flat.attention .icon-attention{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 56 56'%3E%3Cpath fill='%23551713' d='M20.887 50.71h14.226c2.977 0 4.407-.96 5.93-2.624l8.625-9.563c1.547-1.71 1.945-2.836 1.945-5.156v-10.71c0-2.344-.398-3.446-1.945-5.157l-8.625-9.562c-1.523-1.665-2.953-2.649-5.93-2.649H20.887c-2.977 0-4.383.984-5.93 2.649L6.332 17.5c-1.547 1.71-1.945 2.813-1.945 5.156v10.711c0 2.32.398 3.446 1.945 5.156l8.625 9.563c1.547 1.664 2.953 2.625 5.93 2.625m1.265-3.75c-2.343 0-3-.515-4.312-1.921l-7.97-8.79c-.937-1.031-1.148-1.617-1.148-3.328v-9.82c0-1.711.21-2.297 1.148-3.329l7.969-8.789c1.312-1.43 1.969-1.921 4.312-1.921h11.696c2.343 0 3 .492 4.312 1.921l7.992 8.79c.914 1.03 1.126 1.617 1.126 3.328v9.82c0 1.71-.212 2.297-1.126 3.328l-7.992 8.789c-1.312 1.406-1.969 1.922-4.312 1.922Zm5.86-14.835c1.101 0 1.758-.633 1.78-1.852l.352-12.375c.024-1.195-.914-2.085-2.156-2.085-1.265 0-2.156.867-2.133 2.062l.305 12.398c.023 1.196.68 1.852 1.852 1.852m0 7.617c1.336 0 2.508-1.078 2.508-2.437 0-1.36-1.149-2.438-2.508-2.438-1.383 0-2.532 1.102-2.532 2.438s1.172 2.437 2.532 2.437'/%3E%3C/svg%3E\")}"),function(){var t={style:"callout",note:{icon:"icon-note",className:"note"},tip:{icon:"icon-tip",className:"tip"},warning:{icon:"icon-warning",className:"warning"},important:{icon:"icon-important",className:"important"},attention:{icon:"icon-attention",className:"attention"},typeMappings:{info:"note",danger:"attention",caution:"attention"}};function e(t,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;for(var c in r)try{r[c].constructor===Object&&o<1?t[c]=e(t[c],r[c],o+1):t[c]=r[c]}catch(e){t[c]=r[c]}return t}var c=function(r,c){var a=e(t,c.config["flexible-alerts"]||c.config.flexibleAlerts),l=function(t,e,r,o){var c=(t||"").match(new RegExp("".concat(e,":(([\\u002E\\s\\w\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF-]*))")));return c?o?o(c[1]):c[1]:o?o(r):r};r.afterEach(function(t){return t.replace(/<\s*blockquote[^>]*>\s?(?:<p>)?\[!(\w*)((?:\|[\w*:[\u002E\s\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF-]*)*?)]([\s\S]*?)(?:<\/p>)?<\s*\/\s*blockquote>/g,function(t,e,r,n){!a[e.toLowerCase()]&&a.typeMappings[e.toLowerCase()]&&(e=a.typeMappings[e.toLowerCase()]);var i=a[e.toLowerCase()];if(!i)return t;var s=l(r,"style",a.style),d=l(r,"iconVisibility","visible",function(t){return"hidden"!==t}),u=l(r,"labelVisibility","visible",function(t){return"hidden"!==t}),g=l(r,"icon",i.icon),m=l(r,"className",i.className),p=e.replace(/(\w)(\w*)/g,function(t,e,r){return"".concat(e.toUpperCase()).concat(r.toLowerCase())}),f=l(r,"label",p);if("object"===o(f)){var h=Object.keys(f).filter(function(t){return c.route.path.indexOf(t)>-1});h&&h.length>0?f=f[h[0]]:(u=!1,d=!1)}var w='<span class="icon '.concat(g,'"></span>'),v='<p class="title">'.concat(d?w:"").concat(u?f:"","</p>");return'<div class="alert '.concat(s," ").concat(m,'">\n ').concat(d||u?v:"","\n <p>").concat(n,"</p>\n </div>")})})},a=window.$docsify||{},l=window.Docsify.version.split(".")[0];window.$docsify=r(r({},a),{},l<=4?{plugins:[].concat(c,a.plugins)}:{plugins:[].concat(c,a.plugins),markdown:{renderer:{blockquote:function(t){var e=t.tokens;return"<blockquote>".concat(this.parser.parse(e),"</blockquote>")}}}})}()}();
//# sourceMappingURL=docsify-plugin-flexible-alerts.min.js.map