UnisMindMap/web_ui/dist/markmap/markmap-toolbar.js

9 lines
6.4 KiB
JavaScript
Raw Normal View History

/**
* Minified by jsDelivr using Terser v5.39.0.
* Original file: /npm/markmap-toolbar@0.18.12/dist/index.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(t){"use strict";
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */const e="http://www.w3.org/1999/xlink",A={show:e,actuate:e,href:e};function r(t,e){let A;if("string"==typeof t)A=1;else{if("function"!=typeof t)throw new Error("Invalid VNode type");A=2}return{vtype:A,type:t,props:e}}const i=r;function n(t){return t.children}const o={isSvg:!1};function s(t,e){Array.isArray(e)||(e=[e]),(e=e.filter(Boolean)).length&&t.append(...e)}const l={className:"class",labelFor:"for"};function h(t,e,r,i){if(e=l[e]||e,!0===r)t.setAttribute(e,"");else if(!1===r)t.removeAttribute(e);else{const n=i?A[e]:void 0;void 0!==n?t.setAttributeNS(n,e,r):t.setAttribute(e,r)}}function a(t,e){return Array.isArray(t)?t.map((t=>a(t,e))).reduce(((t,e)=>t.concat(e)),[]):c(t,e)}function c(t,e=o){if(null==t||"boolean"==typeof t)return null;if(t instanceof Node)return t;if(2===(null==(A=t)?void 0:A.vtype)){const{type:A,props:r}=t;if(A===n){const t=document.createDocumentFragment();if(r.children){s(t,a(r.children,e))}return t}return c(A(r),e)}var A;if((t=>"string"==typeof t||"number"==typeof t)(t))return document.createTextNode(`${t}`);if((t=>1===(null==t?void 0:t.vtype))(t)){let A;const{type:r,props:i}=t;if(e.isSvg||"svg"!==r||(e=Object.assign({},e,{isSvg:!0})),A=e.isSvg?document.createElementNS("http://www.w3.org/2000/svg",r):document.createElement(r),function(t,e,A){for(const r in e)if("key"!==r&&"children"!==r&&"ref"!==r)if("dangerouslySetInnerHTML"===r)t.innerHTML=e[r].__html;else if("innerHTML"===r||"textContent"===r||"innerText"===r||"value"===r&&["textarea","select"].includes(t.tagName)){const A=e[r];null!=A&&(t[r]=A)}else r.startsWith("on")?t[r.toLowerCase()]=e[r]:h(t,r,e[r],A.isSvg)}(A,i,e),i.children){let t=e;e.isSvg&&"foreignObject"===r&&(t=Object.assign({},t,{isSvg:!1}));const n=a(i.children,t);null!=n&&s(A,n)}const{ref:n}=i;return"function"==typeof n&&n(A),A}throw new Error("mount: Invalid Vnode!")}function g(t){return c(t)}const v="mm-toolbar-item";function d({title:t,content:e,onClick:A}){return r("div",{className:v,title:t,onClick:A,children:e})}let u;const m=class t{constructor(){this.showBrand=!0,this.registry={},this.el=g(r("div",{className:"mm-toolbar"})),this.items=[...t.defaultItems],this.register({id:"zoomIn",title:"Zoom in",content:t.icon("M9 5v4h-4v2h4v4h2v-4h4v-2h-4v-4z"),onClick:this.getHandler((t=>t.rescale(1.25)))}),this.register({id:"zoomOut",title:"Zoom out",content:t.icon("M5 9h10v2h-10z"),onClick:this.getHandler((t=>t.rescale(.8)))}),this.register({id:"fit",title:"Fit window size",content:t.icon("M4 7h2v-2h2v4h-4zM4 13h2v2h2v-4h-4zM16 7h-2v-2h-2v4h4zM16 13h-2v2h-2v-4h4z"),onClick:this.getHandler((t=>t.fit()))}),this.register({id:"recurse",title:"Toggle recursively",content:t.icon("M16 4h-12v12h12v-8h-8v4h2v-2h4v4h-8v-8h10z"),onClick:t=>{var e;const A=t.target.closest(`.${v}`),r=null==A?void 0:A.classList.toggle("active");null==(e=this.markmap)||e.setOptions({toggleRecursively:r})}}),this.register({id:"dark",title:"Toggle dark theme",content:t.icon("M10 4a6 6 0 0 0 0 12a6 6 0 0 0 0 -12v2a4 4 0 0 1 0 8z"),onClick:()=>{document.documentElement.classList.toggle("markmap-dark")}}),this.render()}static create(e){const A=new t;return A.attach(e),A}static icon(t,e={}){return e={stroke:"none",fill:"currentColor","fill-rule":"evenodd",...e},r("svg",{width:"20",height:"20",viewBox:"0 0 20 20",children:r("path",{...e,d:t})})}setBrand(t){return this.showBrand=t,this.render()}register(t){this.registry[t.id]=t}getHandler(t){var e;return e=t,t=async(...t)=>{if(!u){u=e(...t);try{await u}finally{u=void 0}}},()=>{this.markmap&&t(this.markmap)}}setItems(t){return this.items=[...t],this.render()}attach(t){this.markmap=t}render(){const t=this.items.map((t=>{if("string"==typeof t){const e=this.registry[t];return e||console.warn(`[markmap-toolbar] ${t} not found`),e}return t})).filter(Boolean);for(;this.el.firstChild;)this.el.firstChild.remove();return this.el.append(g(i(n,{children:[this.showBrand&&i("a",{className:"mm-toolbar-brand",href:"https://markmap.js.org/",children:[r("img",{alt:"markmap",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAA
//# sourceMappingURL=/sm/571b88618f99827ab8ae85efa381e3933ac067d6c68a0f0b0b24075722ae75ff.map