mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
7 lines
8.2 KiB
JavaScript
7 lines
8.2 KiB
JavaScript
/**
|
|
* Skipped minification because the original files appears to be already minified.
|
|
* Original file: /npm/editorjs-layout@1.2.5/dist/index.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EditorJSLayout=e():t.EditorJSLayout=e()}(self,(()=>(()=>{"use strict";var t,e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{LayoutBlockTool:()=>O});class o extends Error{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,o),this.name="EditorJSLayoutError"}}var r=new Uint8Array(16);function i(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(r)}const a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var s=[],d=0;d<256;++d)s.push((d+256).toString(16).substr(1));const c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&a.test(t)}(n))throw TypeError("Stringified UUID is invalid");return n},l=function(t,e,n){var o=(t=t||{}).random||(t.rng||i)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e){n=n||0;for(var r=0;r<16;++r)e[n+r]=o[r];return e}return c(o)};const u=({EditorJS:t,data:e,dispatchData:n,editorJSConfig:o,itemContentId:r,readOnly:i})=>{const a=l(),s=document.createElement("div");s.id=a,i?s.classList.add("read-only"):s.addEventListener("click",(()=>{const i=(({EditorJS:t,data:e,editorJSConfig:n,onClose:o})=>{const r=document.createElement("dialog");r.style.maxWidth="960px",r.style.padding="0",r.style.width="calc(100% - 64px)";const i=document.createElement("div"),a=l();i.id=a,r.append(i);const s=new t(Object.assign(Object.assign({},n),{holder:a,data:e})),d=t=>{t.target instanceof Node&&t.target.isEqualNode(r)&&r.close()};r.addEventListener("click",d);const c=()=>{return t=void 0,e=void 0,i=function*(){const t=yield s.save();s.destroy(),r.removeEventListener("click",d),r.removeEventListener("close",c),r.remove(),null==o||o({editorJSData:t})},new((n=void 0)||(n=Promise))((function(o,r){function a(t){try{d(i.next(t))}catch(t){r(t)}}function s(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}d((i=i.apply(t,e||[])).next())}));var t,e,n,i};return r.addEventListener("close",c),r})({EditorJS:t,data:e,editorJSConfig:o,onClose:({editorJSData:t})=>{return e=void 0,o=void 0,a=function*(){return n((({itemContent:e,layout:n})=>({itemContent:Object.assign(Object.assign({},e),{[r]:{blocks:t.blocks}}),layout:n})))},new((i=void 0)||(i=Promise))((function(t,n){function r(t){try{d(a.next(t))}catch(t){n(t)}}function s(t){try{d(a.throw(t))}catch(t){n(t)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,s)}d((a=a.apply(e,o||[])).next())}));var e,o,i,a}});document.body.append(i),i.showModal()})),new t(Object.assign(Object.assign({},o),{holder:a,data:e,minHeight:0,readOnly:!0}));const d=document.createElement("style");return d.textContent=`\n #${CSS.escape(a)} {\n cursor: pointer;\n }\n\n #${CSS.escape(a)}.read-only {\n cursor: unset;\n }\n\n #${CSS.escape(a)} .codex-editor__loader {\n display: none;\n }\n `,s.append(d),s};const f=t=>{var{data:e,itemContentData:n}=t,r=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["data","itemContentData"]);const i=document.createElement("div");return i.id=e.id,i.className=e.className,i.style.cssText=e.style,e.children.forEach((t=>{let e;switch(t.type){case"container":e=f(Object.assign(Object.assign({},r),{data:t,itemContentData:n}));break;case"item":e=(t=>{var e,{data:n,itemContentData:o}=t,r=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["data","itemContentData"]);const i=document.createElement("div");i.id=n.id,i.className=n.className,i.style.cssText=n.style;const a=null!==(e=o[n.itemContentId])&&void 0!==e?e:{blocks:[]};return i.append(u(Object.assign(Object.assign({},r),{data:a,itemContentId:n.itemContentId}))),i})(Object.assign(Object.assign({},r),{data:t,itemContentData:n}));break;default:throw new o}i.append(e)})),i};var p,y,h,m,v,w,g=function(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(t,n):r?r.value=n:e.set(t,n),n},b=function(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)};class O{static get isReadOnlySupported(){return!0}static get shortcut(){return"CMD+L"}static get toolbox(){return{icon:'\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 512 512">\n <rect x="48" y="48" width="176" height="176" rx="20" ry="20" style="fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/>\n <rect x="288" y="48" width="176" height="176" rx="20" ry="20" style="fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/>\n <rect x="48" y="288" width="176" height="176" rx="20" ry="20" style="fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/>\n <rect x="288" y="288" width="176" height="176" rx="20" ry="20" style="fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/>\n </svg>\n ',title:"Layout"}}constructor({config:t,data:e,readOnly:n}){p.set(this,void 0),y.set(this,void 0),h.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,(t=>{const e=t({itemContent:b(this,m,"f"),layout:b(this,v,"f")});g(this,m,e.itemContent,"f"),g(this,v,e.layout,"f"),this.renderWrapper()})),g(this,y,n,"f"),g(this,h,document.createElement("div"),"f"),g(this,m,{},"f"),g(this,v,{type:"container",id:"",className:"",style:"",children:[]},"f"),t&&"EditorJS"in t&&(g(this,p,t,"f"),g(this,m,t.initialData.itemContent,"f"),t.initialData.layout&&g(this,v,t.initialData.layout,"f")),e&&"itemContent"in e&&(g(this,m,e.itemContent,"f"),e.layout&&g(this,v,e.layout,"f"))}render(){return this.renderWrapper(),b(this,h,"f")}save(){return{itemContent:b(this,m,"f"),layout:b(this,p,"f").enableLayoutSaving?b(this,v,"f"):void 0}}validate(t){return!0}renderWrapper(){b(this,h,"f").innerHTML="",b(this,h,"f").append(f({EditorJS:b(this,p,"f").EditorJS,data:b(this,v,"f"),dispatchData:b(this,w,"f"),editorJSConfig:b(this,p,"f").editorJSConfig,itemContentData:b(this,m,"f"),readOnly:b(this,y,"f")}))}}return p=new WeakMap,y=new WeakMap,h=new WeakMap,m=new WeakMap,v=new WeakMap,w=new WeakMap,n})())); |