schlechtenburg/docs/assets/index.md.f2252493.js

2 lines
368 KiB
JavaScript
Raw Normal View History

2022-03-17 18:16:01 +00:00
var mA=Object.defineProperty,FA=Object.defineProperties;var pA=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var OA=Object.prototype.hasOwnProperty,VA=Object.prototype.propertyIsEnumerable;var Z=(A,e,t)=>e in A?mA(A,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):A[e]=t,u=(A,e)=>{for(var t in e||(e={}))OA.call(e,t)&&Z(A,t,e[t]);if(Y)for(var t of Y(e))VA.call(e,t)&&Z(A,t,e[t]);return A},m=(A,e)=>FA(A,pA(e));import{i as U,r as C,e as L,f as SA,g as k,p as l,h as jA,w as b,j as GA,k as s,l as i,b as P,m as H,n as c,q as KA,s as HA,t as hA,F as xA,c as JA,u as WA,d as NA,o as YA}from"./app.87539bc2.js";var E=(A=>(A.Edit="edit",A.Display="display",A))(E||{});const oA=Symbol("Schlechtenburg mode");var F,ZA=new Uint8Array(16);function TA(){if(!F&&(F=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!F))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return F(ZA)}var _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;function $A(A){return typeof A=="string"&&_A.test(A)}var o=[];for(var V=0;V<256;++V)o.push((V+256).toString(16).substr(1));function Ae(A){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(o[A[e+0]]+o[A[e+1]]+o[A[e+2]]+o[A[e+3]]+"-"+o[A[e+4]]+o[A[e+5]]+"-"+o[A[e+6]]+o[A[e+7]]+"-"+o[A[e+8]]+o[A[e+9]]+"-"+o[A[e+10]]+o[A[e+11]]+o[A[e+12]]+o[A[e+13]]+o[A[e+14]]+o[A[e+15]]).toLowerCase();if(!$A(t))throw TypeError("Stringified UUID is invalid");return t}function ee(A,e,t){A=A||{};var n=A.random||(A.rng||TA)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(var g=0;g<16;++g)e[t+g]=n[g];return e}return Ae(n)}const h=ee,te={prop:"block",event:"update"},Dt={blockId:{type:String,default:h}},CA=Symbol("Schlechtenburg active block");function IA(A=null){const e=U(CA,C(null)),t=L(()=>e.value===A),n=(a=A)=>{e.value===a&&(e.value=null)},g=a=>n();SA(()=>{document.removeEventListener("click",g)});const Q=(a=A)=>{document.addEventListener("click",g,{once:!0}),e.value=a};return{activeBlockId:e,isActive:t,activate:Q,deactivate:n,requestActivation:()=>{e.value||Q()}}}const sA=Symbol("Schlechtenburg block library");function fA(){const A=U(oA,C(E.Edit)),e=U(sA,k({}));return{mode:A,customBlocks:e,getBlock:n=>e[n]}}const EA=Symbol("Schlechtenburg block dimensions"),cA=Symbol("Schlechtenburg editor dimensions");function dA(A,e){const t=C(null);l(e,t);const n=()=>{if(!A.value)return;const g=A.value.getBoundingClientRect();t.value={width:g.width,height:g.height,left:A.value.offsetLeft,top:A.value.offsetTop}};return jA(()=>{const g=new ResizeObserver(n),Q=new MutationObserver(n);b(A,()=>{!A.value||(g.observe(A.value),Q.observe(A.value,{attributes:!0,childList:!1,subtree:!1}))})}),{triggerSizeCalculation:n,dimensions:t}}function uA(){const A=U(cA,C(null)),e=U(EA,C(null));return{editorDimensions:A,blockDimensions:e}}const lA=Symbol("Schlechtenburg block tree"),j=Symbol("Schlechtenburg block tree register"),G=Symbol("Schlechtenburg block tree unregister");function bA(){const A=U(lA,C(null)),e=U(j,Q=>{}),t=U(G,Q=>{}),n=k({id:"",name:"",icon:"",children:[]});l(j,Q=>{n.children.find(r=>r.id===Q.id)||(n.children=[...n.children,Q])}),l(G,({id:Q})=>{n.children=n.children.filter(r=>r.id!==Q)});const g=Q=>{if(!Q.id)throw new Error(`Cannot register a block without an id: ${JSON.stringify(Q)}`);n.id=Q.id,n.name=Q.name,e(n)};return GA(()=>{n.id&&t(n)}),{blockTree:A,register:g}}const q=s({name:"sb-button",inheritAttrs:!1,setup(A,e){return()=>{var t,n;return i("button",m(u({},e.attrs),{class:(e.attrs.class||"")+" sb-button"}),[(n=(t=e.slots).default)==null?void 0:n.call(t)])}}});const DA=s({name:"sb-context-menu",props:{onClose:{type:Function,default:()=>{}},onOpen:{type:Function,default:()=>{}}},setup(A,e){const t=C(!1),n=()=>{t.value=!0},g=()=>{t.value=!1},Q=a=>{a.key==="Escape"&&g()},r=()=>{t.value?g():n()};return b(t,