wysimark-lite 0.27.4 → 0.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +99 -127
- package/dist/index.mjs +97 -96
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use client";import{createRef as
|
|
2
|
-
`);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function
|
|
3
|
-
`,...t}];let o=e.match(/^<mark\b[^>]*>(.+?)<\/mark>$/is);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function yu(e,t){let o=[],r=/(!)?\[\[((?:\\.|[^\]\\\n])+?)\]\]/g,n=0,i;for(;(i=r.exec(e))!==null;){let a=i.index;if(a>0&&e[a-1]==="\\")continue;a>n&&o.push({text:Oe(e.slice(n,a)),...t});let l=
|
|
4
|
-
`}];case"footnote":throw new Error("footnote is not supported yet")}Se(e)}function
|
|
1
|
+
"use client";import{createRef as $x,useCallback as Dx,useImperativeHandle as zx,useRef as Nx,useState as Hx}from"react";import{createRoot as Ax}from"react-dom/client";import Cx from"lodash.throttle";import{useCallback as Zt,useRef as eo,useState as Yd}from"react";import{Editor as Px,Transforms as Sx}from"slate";import{ReactEditor as Lx,Slate as Rx}from"slate-react";import Lu from"remark-parse";import{unified as Ru}from"unified";import{gfm as ou}from"micromark-extension-gfm";import{gfmFromMarkdown as ru,gfmToMarkdown as nu}from"mdast-util-gfm";function $n(e){if(e)return function(t){return this.data||(this.data={}),e.call(this,t)}}function iu(e){if(e.enter)for(let t of Object.keys(e.enter))e.enter[t]=$n(e.enter[t]);if(e.exit)for(let t of Object.keys(e.exit))e.exit[t]=$n(e.exit[t]);return e}function Dn(){return function(){if(!this)return;let e=this.data(),t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(ou());let n=ru().map(iu);o.push(...n),r.push(nu())}}var lr="wysimark:wiki-link:",sr="wysimark:wiki-embed:",zn="\uE000WYSIMARK_ESCAPED_WIKI_OPEN\uE000",Nn="\uE000WYSIMARK_ESCAPED_WIKI_CLOSE\uE000";function Hn(e){return e.replace(/\\\[\[/g,zn).replace(/\\\]/g,Nn)}function Oe(e){return e.replace(new RegExp(zn,"g"),"[[").replace(new RegExp(Nn,"g"),"]")}function Ce(e){return`${lr}${encodeURIComponent(e)}`}function no(e){return`${sr}${encodeURIComponent(e)}`}function se(e){return e.startsWith(lr)}function Ze(e){return e.startsWith(sr)}function $t(e){return decodeURIComponent(e.slice(lr.length))}function mr(e){return decodeURIComponent(e.slice(sr.length))}function et(e){let t=e.lastIndexOf("|");return t<0?{target:e.trim()}:{target:e.slice(0,t).trim(),display:e.slice(t+1).trim()}}function io(e){return et(e).target}function ao(e){let t=e.trim(),o=t.match(/^!?\[\[([\s\S]+)\]\]$/);return et(o?o[1]:t)}function me(e){let{target:t,display:o}=et(e);if(o)return o;if(t.startsWith("##"))return t.slice(2).trim()||"Headings";if(t.startsWith("^^"))return t.slice(2).trim()||"Blocks";let r=t.indexOf("#");if(r<0)return t;let n=t.slice(0,r).trim(),i=t.slice(r+1).split("#").map(a=>a.trim()).filter(Boolean);return n?i.length===0?n:[n,...i].join(" > "):i.join(" > ")}function An(e,t){let o=$t(e),{target:r,display:n}=et(o),i=t.trim();if(n&&i===n)return`[[${r}|${n}]]`;let a=me(r);return i&&i!==a?`[[${r}|${i}]]`:`[[${r}]]`}function On(e){return`![[${mr(e)}]]`}function Pe(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o="\x07WYSIMARK_",r=`${o}LINK_`,n=`${o}HTML_`,i="\x07",a=[],l=0,s=e.replace(t,p=>(a.push(p),`${r}${l++}${i}`)),m=[];s=lu(s,m,n,i);let d=/(https?:\/\/[^\s]+)/g;s=s.replace(d,p=>p.replace(/\//g,"\\/"));for(let p=0;p<m.length;p++)s=s.replace(`${n}${p}${i}`,m[p]);for(let p=0;p<a.length;p++)s=s.replace(`${r}${p}${i}`,a[p]);return s}function Dt(e){return e.replace(/\\\//g,"/")}function lo(e){return e.replace(/\\([\\`*_\[\]~|<])/g,"$1")}var au=new Set(["script","style"]);function lu(e,t,o,r){let n="",i=0;for(;i<e.length;){let a=e.indexOf("<",i);if(a===-1){n+=e.slice(i);break}if(n+=e.slice(i,a),e.startsWith("<!--",a)){let u=e.indexOf("-->",a+4);if(u===-1){n+=e.slice(a);break}let h=e.slice(a,u+3);t.push(h),n+=`${o}${t.length-1}${r}`,i=u+3;continue}if(e.startsWith("<![CDATA[",a)){let u=e.indexOf("]]>",a+9);if(u===-1){n+=e.slice(a);break}let h=e.slice(a,u+3);t.push(h),n+=`${o}${t.length-1}${r}`,i=u+3;continue}let l=cr(e,a);if(!l){n+="<",i=a+1;continue}let s=t.length,m=`${o}${s}${r}`;if(!l.name){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}let c=l.name.toLowerCase();if(l.isClosing||l.isSelfClosing){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}if(au.has(c)){let u=e.toLowerCase().indexOf(`</${c}`,l.endIndex+1);if(u!==-1){let h=cr(e,u);if(h){let k=e.slice(a,h.endIndex+1);t.push(k),n+=m,i=h.endIndex+1;continue}}}let d=mu(e,c,l.endIndex+1);if(d!==null){let u=e.slice(a,d+1);t.push(u),n+=m,i=d+1;continue}let p=e.slice(a,l.endIndex+1);t.push(p),n+=m,i=l.endIndex+1}return n}function cr(e,t){if(e[t]!=="<")return null;let o=su(e,t);if(o===-1)return null;let r=t+1;if(r>=e.length)return null;let n=e[r];if(n==="!"||n==="?")return{name:null,endIndex:o,isClosing:!1,isSelfClosing:!0};let i=!1;n==="/"&&(i=!0,r+=1);let a=/^[A-Za-z][A-Za-z0-9-]*/.exec(e.slice(r));if(!a)return null;let l=a[0],s=e.slice(t,o+1),m=/\/\s*>$/.test(s);return{name:l,endIndex:o,isClosing:i,isSelfClosing:m}}function su(e,t){let o=null;for(let r=t+1;r<e.length;r++){let n=e[r];if(o){n===o&&(o=null);continue}if(n==="'"||n==='"'){o=n;continue}if(n===">")return r}return-1}function mu(e,t,o){let r=1,n=o,i=t.toLowerCase();for(;n<e.length;){let a=e.indexOf("<",n);if(a===-1)return null;let l=cr(e,a);if(!l||!l.name){n=a+1;continue}if(l.name.toLowerCase()===i&&(l.isClosing?r-=1:l.isSelfClosing||(r+=1),r===0))return l.endIndex;n=l.endIndex+1}return null}function Un(e,t){if(!e)throw new Error(`${t}`)}function so(e,t){if(e.type!==t)throw new Error(`Expected element to be of type ${JSON.stringify(e)} but is ${JSON.stringify(e,null,2)}`)}function Se(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function cu(e){let t=e[0];if(!t||t.type!=="paragraph")return e;let o=t.children[0];if(!o||!("text"in o))return e;let r=o.text.match(/^(\[![A-Za-z0-9_-]+\][+-]?(?:[^\n]*))(?:\n([\s\S]*))?$/);if(!r)return e;let n=r[1],i=r[2],a={type:"paragraph",children:[{...o,text:n}]};if(!i)return[a,...e.slice(1)];let l={...t,children:[{...o,text:i},...t.children.slice(1)]};return[a,l,...e.slice(1)]}function Fn(e,t={}){return[{type:"block-quote",children:cu(tt(e.children,t))}]}function Wn(e){let t=e.value.split(`
|
|
2
|
+
`);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function Vn(e,t={}){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...tt(e.children,t)]}]}import{Text as ei}from"slate";import{Text as Jn}from"slate";import*as zt from"slate";function q(e){return zt.Text.isText(e)}function ce(e){return zt.Element.isElement(e)}function A(e){return zt.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var _n={bold:"**",italic:"_",strike:"~~",highlight:"<mark>",code:""},Kn={bold:"**",italic:"_",strike:"~~",highlight:"</mark>",code:""};function pu(e){if(e in _n)return _n[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_OPEN_TOKEN lookup`)}function du(e){if(e in Kn)return Kn[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_CLOSE_TOKEN lookup`)}function Gn(e){return e.map(pu).join("")}function qn(e){return e.map(du).join("")}import{Text as uu}from"slate";function Nt(e){let{text:t,...o}=e;return Object.keys(o)}function pr(e){if(uu.isText(e)){if(A(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return Nt(e)}else{if(e.type==="anchor")return mo(e.children);throw new Error(`Unhandled type ${e.type}`)}}function mo(e){let t;for(let o of e){if(!q(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(A(o))continue;let r=Nt(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}return t===void 0?[]:t}var Qn=["bold","italic","underline","strike","highlight","code"];function jn(e){return e.slice().sort((t,o)=>Qn.indexOf(t)-Qn.indexOf(o))}function fu(e){return/[!-/:-@\[-`{-~]/.test(e)}function rt(e){return e===""||/\s/u.test(e)}function ot(e){return e!==""&&/[\p{P}\p{S}]/u.test(e)}function hu(e){return/[a-zA-Z/?!]/.test(e)}function Xn(e,t,o){let r=new Set,n=[];for(let i=0;i<e.length;i++){if(e[i]!==t)continue;let a=i>0?e[i-1]:"",l=i+1<e.length?e[i+1]:"",s=!rt(l)&&(!ot(l)||rt(a)||ot(a)),m=!rt(a)&&(!ot(a)||rt(l)||ot(l)),c=s&&(o||!m||ot(a));m&&(o||!s||ot(l))&&n.length>0&&(r.add(n.pop()),r.add(i)),c&&n.push(i)}return r}function gu(e){let t=new Set,o=[];for(let r=0;r<e.length;r++){if(e[r]!=="~")continue;let n=r>0?e[r-1]:"",i=r+1<e.length?e[r+1]:"",a=!rt(i);!rt(n)&&o.length>0&&(t.add(o.pop()),t.add(r)),a&&o.push(r)}return t}function bu(e,t=!1){let o=new Set,r=[];for(let n=0;n<e.length;n++)if(e[n]==="[")t&&e[n+1]==="["&&o.add(n),e[n+1]==="^"&&o.add(n),r.push(n);else if(e[n]==="]"){let i=r.pop();i!==void 0&&e[n+1]==="("&&(o.add(i),o.add(n))}return o}function Yn(e,t={}){let o=Array.from(e),r=Xn(o,"_",!1),n=Xn(o,"*",!0),i=gu(o),a=bu(o,t.enableInternalLinks),l=t.escapeBackticks??o.filter(m=>m==="`").length>=2,s="";for(let m=0;m<o.length;m++){let c=o[m],d=m+1<o.length?o[m+1]:"";c==="`"?s+=l?"\\`":c:c==="\\"?s+=fu(d)?"\\\\":"\\":c==="<"?s+=hu(d)?"\\<":"<":c==="_"?s+=r.has(m)?`\\${c}`:c:c==="*"?s+=n.has(m)?`\\${c}`:c:c==="~"?s+=i.has(m)?`\\${c}`:c:c==="["||c==="]"?s+=t.inAnchorLabel||a.has(m)?`\\${c}`:c:s+=c}return s=s.replace(/^(#{1,6})(\s)/m,"\\$1$2"),s=s.replace(/^(\d+)([.)]\s)/m,"$1\\$2"),s=s.replace(/^([-+*>])\s/m,"\\$1 "),s}function Eu(e,t){let o=Nt(e),r=Nt(t);return o.length==r.length&&o.every(n=>r.includes(n))}function Zn(e,t){let o=Jn.isText(e),r=Jn.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:Eu(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function ti(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...Zn(e[o],r))}return t.length===0&&t.push({text:""}),ei.isText(t[0])||t.unshift({text:""}),ei.isText(t[t.length-1])||t.push({text:""}),t}function oi(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var ku=/^([^?#]*)(?:\?([^#]*))?(#.*)?$/;function nt(e){try{let t=new URL(e);return{origin:t.origin,hostname:t.hostname,pathname:t.pathname,searchParams:t.searchParams,hash:t.hash}}catch{let t=e.match(ku);if(t===null)throw new Error(`Invalid format should not happen: ${e}`);let[,o,r,n]=[...t];return{origin:"",hostname:"",pathname:o||"",searchParams:new URLSearchParams(r),hash:n||""}}}function Ht(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1],10),height:parseInt(t[2],10)}}function ri(e){let t=nt(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=Ht(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1],10),srcHeight:parseInt(n[2],10)}}function ni(e){let t=nt(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=Ht(o.get("size")),n=Ht(o.get("srcSize"));if(!(!r||!n))return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:n.width,srcHeight:n.height}}var ii=[ri,ni,oi];function ai(e){for(let t of ii){let o=t(e);if(o)return[{type:"image-inline",...o,children:[{text:""}]}]}throw new Error("Shouldn't get here because last parser always returns data")}function xu(e,t){if(/^<br\s*\/?>$/i.test(e))return[{text:`
|
|
3
|
+
`,...t}];let o=e.match(/^<mark\b[^>]*>(.+?)<\/mark>$/is);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function yu(e,t){let o=[],r=/(!)?\[\[((?:\\.|[^\]\\\n])+?)\]\]/g,n=0,i;for(;(i=r.exec(e))!==null;){let a=i.index;if(a>0&&e[a-1]==="\\")continue;a>n&&o.push({text:Oe(e.slice(n,a)),...t});let l=lo(Oe(i[2])).trim();i[1]?o.push({type:"image-inline",url:no(l),alt:l,children:[{text:""}]}):o.push({type:"anchor",href:Ce(l),children:[{text:me(l),...t}]}),n=a+i[0].length}return n===0?[{text:Oe(e),...t}]:(n<e.length&&o.push({text:Oe(e.slice(n)),...t}),o)}function J(e,t={},o={}){let r=[],n={...t};for(let a of e){if(a.type==="html"){if(/^<mark\b[^>]*>$/i.test(a.value)){n={...n,highlight:!0};continue}if(/^<\/mark>$/i.test(a.value)){let{highlight:l,...s}=n;n=s;continue}}r.push(...vu(a,n,o))}return ti(r)}function vu(e,t={},o={}){switch(e.type){case"delete":return J(e.children,{...t,strike:!0},o);case"emphasis":return J(e.children,{...t,italic:!0},o);case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return xu(e.value,t);case"image":return ai(e);case"inlineCode":return[{text:Oe(e.value),...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:J(e.children,t,o)}];case"strong":return J(e.children,{...t,bold:!0},o);case"text":return o.enableInternalLinks?yu(e.value,t):[{text:Oe(e.value),...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
|
|
4
|
+
`}];case"footnote":throw new Error("footnote is not supported yet")}Se(e)}function li(e,t={}){return[{type:"heading",level:e.depth,children:J(e.children,{},t)}]}function si(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function mi(e,{depth:t,ordered:o,checked:r},n={}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:J(e.children,{},n)}]:o?[{type:"ordered-list-item",depth:t,children:J(e.children,{},n)}]:[{type:"unordered-list-item",depth:t,children:J(e.children,{},n)}];case"list":return co(e,t+1,n);default:return dr(e,n)}}function ci(e,t,o={}){let r=[];for(let n of e.children)r.push(...mi(n,{...t,checked:e.checked},o));return r}function co(e,t=0,o={}){let r=[];for(let n of e.children)r.push(...ci(n,{depth:t,ordered:!!e.ordered},o));return r}function Tu(e){return!(e.length!==3||!("text"in e[0])||e[0].text!==""||!("text"in e[2])||e[2].text!==""||!("type"in e[1])||e[1].type!=="image-inline")}var wu="\xA0";function Iu(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==wu)}function pi(e,t={}){let o=J(e.children,{},t);return Tu(o)?[{...o[1],type:"image-block"}]:Iu(o)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:o}]}function di(e,t={}){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(o=>({align:o||"left"})),children:e.children.map(o=>Mu(o,t))}]}function Mu(e,t){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(o=>Cu(o,t))}}function Cu(e,t){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:J(e.children,{},t)}]}}function ui(){return[{type:"horizontal-rule",children:[{text:""}]}]}function tt(e,t={}){let o=[];for(let r=0;r<e.length;r++){if(r>0){let n=e[r-1],i=e[r];if(n.position&&i.position){let a=i.position.start.line-n.position.end.line-1;for(let l=1;l<a;l++)o.push({type:"paragraph",children:[{text:""}]})}}o.push(...dr(e[r],t))}return o}function dr(e,t={}){switch(e.type){case"blockquote":return Fn(e,t);case"code":return Wn(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Vn(e,t);case"heading":return li(e,t);case"html":return si(e);case"list":return co(e,0,t);case"paragraph":return pi(e,t);case"table":return di(e,t);case"thematicBreak":return ui();case"yaml":return[]}Se(e)}import{definitions as Pu}from"mdast-util-definitions";import{SKIP as fi,visit as Su}from"unist-util-visit";function hi(e){let t=Pu(e);Su(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[fi,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let m=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=m,[fi,r]}}})}var Bu=Ru().use(Lu).use(Dn());function $u(e,t={}){let o=Bu.parse(t.enableInternalLinks?Hn(e):e);return hi(o),o}function Le(e,t={}){let o=$u(e,t);return o.children.length===0?[{type:"paragraph",children:[{text:""}]}]:tt(o.children,t)}function Du(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function gi(e){let t=[],o=-1;for(let r of e){if(!Du(r)){t.push(r),o=-1;continue}let n=r.depth>o+1?o+1:r.depth;t.push({...r,depth:n}),o=n}return t}function bi(e){if(e.type!=="code-block-line")throw new Error(`Expected all children of code-block to be a codeline but is ${JSON.stringify(e,null,2)}`);return e.children.map(t=>t.text).join("")}function Ei(e){let t=[],o=3;for(let r of e.children){let n=bi(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
|
|
5
5
|
`)}
|
|
6
6
|
|
|
7
|
-
`}function
|
|
7
|
+
`}function ki(e){return e.url}function xi(e){if(e.url.startsWith("$"))return"";let{hostname:t}=nt(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function yi(e){if(e.width&&e.height&&e.srcWidth&&e.srcHeight)return`${e.url}#srcSize=${e.srcWidth}x${e.srcHeight}&size=${e.width}x${e.height}`}var zu=[xi,yi,ki];function po(e,t={}){if(t.enableInternalLinks&&Ze(e.url))return On(e.url);for(let o of zu){let r=o(e);if(typeof r=="string")return r===""?"":``}throw new Error("Shouldn't get here")}function vi(e,t={}){let o=po(e,t);return o?`${o}
|
|
8
8
|
|
|
9
|
-
`:""}import{Element as Uu,Text as
|
|
10
|
-
`)}function
|
|
9
|
+
`:""}import{Element as Uu,Text as Ui}from"slate";function Ti(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:jn(o)}}function wi(e,t){let o=[...e],r=e.filter(i=>!t.includes(i)),n=[];for(let i=0;i<e.length&&r.length!==0;i++){let a=o.pop();if(a===void 0)throw new Error("This shouldn't happen unless we made a mistake in the algorithm");n.push(a);let l=r.indexOf(a);l!==-1&&r.splice(l,1)}return{orderedMarksToRemove:n,nextOrderedMarks:o}}function ur(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=wi(e,t),{orderedMarksToAdd:n}=Ti(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as Hu}from"slate";function Ii({node:e,nextNode:t,nodes:o,index:r}){return!q(e)||!A(e)||e.code||!q(t)||!A(t)||t.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function Mi({node:e,nodes:t,prevNode:o,index:r}){if(!ce(e)||e.type!=="anchor")return!1;let n=e.children[0];return q(n)&&A(n)?(e.children.splice(0,1),q(o)&&A(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function Ci({node:e,nodes:t,nextNode:o,index:r}){if(!ce(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return q(n)&&A(n)?(e.children.splice(e.children.length-1,1),q(o)&&A(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function Pi({node:e}){return!ce(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function Si({node:e,nodes:t,index:o}){if(!q(e)||A(e)||e.code)return!1;let r=e.text.match(/^(\s*)(.*?)(\s*)$/);if(!r||r[1].length===0&&r[3].length===0)return!1;let n=[{text:r[1]},{...e,text:r[2]},{text:r[3]}].filter(i=>i.text!=="");return t.splice(o,1,...n),!0}function Li({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!q(o)||!A(o)?!1:r&&ce(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function Ri({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!q(o)||!A(o)?!1:r&&ce(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var Bi=[Si,Mi,Ci,Ii,Ri,Li,Pi];function $i(e){for(let t of Bi)if(t(e))return!0;return!1}var Nu=72;function fr(e,t){let o=!1,r,n=0,i=(e.length+1)*Nu;do{if(r=!1,n=n+1,n>i)throw new Error(`There have been ${n} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`);e:for(let a=0;a<e.length;a++){let l=e[a];if(ce(l)&&fr(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],m=e[a+1];if($i({parent:t,node:l,prevNode:s,nextNode:m,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var Di=e=>e.map(t=>Hu.isElement(t)&&t.type==="anchor"?{...t,children:Di(t.children)}:t);function zi(e){let t={type:"line",children:Di(e)};return fr([t],void 0),t.children}import{Text as Ou}from"slate";function Ni(e){let t=0;for(let o of e.text.matchAll(/[`]+/g))t=Math.max(t,o[0].length);return t===0?`\`${e.text.replace(/[`]/g,"\\`")}\``:`${"`".repeat(t+1)} ${e.text} ${"`".repeat(t+1)}`}function Au(e){return e.replace(/"/g,'\\"')}function Hi(e,t){if(t?.enableInternalLinks&&se(e.href)){let n=mo(e.children),i={...t,inAnchorLabel:!0};return An(e.href,X(e.children,n,n,i))}let o=mo(e.children),r={...t,inAnchorLabel:!0};return e.href.startsWith("$")?X(e.children,o,o,t):typeof e.title=="string"&&e.title.length>0?`[${X(e.children,o,o,r)}](${e.href} "${Au(e.title)}")`:`[${X(e.children,o,o,r)}](${e.href})`}function Ai(e,t){return Yn(e.text,t).replace(/\n/g,`
|
|
10
|
+
`)}function Oi(e,t){if(Ou.isText(e))return e.code?Ni(e):Ai(e,t);switch(e.type){case"anchor":return Hi(e,t);case"image-inline":return po(e,t);default:Se(e)}}function Fu(e){let t=0,o=r=>{for(let n of r)if(Ui.isText(n)){if(n.code)return!0;for(let i of n.text)if(i==="`"&&++t>=2)return!0}else if(n.type==="anchor"&&o(n.children))return!0;return!1};return o(e)}function X(e,t=[],o=[],r){let n=zi(e),i=[],a={...r,escapeBackticks:r?.escapeBackticks??Fu(n)},l=ur(t,pr(n[0]));for(let s=0;s<n.length;s++){let m=n[s];if(Ui.isText(m)&&A(m)){i.push(m.text);continue}i.push(Gn(l.add)),i.push(Oi(m,a));let c=Wu(n,s,o),d=ur(l.nextOrderedMarks,c);i.push(qn(d.remove)),l=d}return i.join("")}function Wu(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!A(n)&&!(Uu.isElement(n)&&n.type==="image-inline"))return pr(n)}return o}function Wi(e,t={}){let o=[];return o.push(Fi(e.children[0],t)),o.push(Vu(e.columns)),e.children.slice(1).forEach(r=>{o.push(Fi(r,t))}),`${o.join(`
|
|
11
11
|
`)}
|
|
12
12
|
|
|
13
|
-
`}function Vu(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>_u(o.align)).join("|")}|`}function _u(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function
|
|
13
|
+
`}function Vu(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>_u(o.align)).join("|")}|`}function _u(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function Fi(e,t){return so(e,"table-row"),`|${e.children.map(o=>Ku(o,t)).join("|")}|`}function Ku(e,t){return so(e,"table-cell"),Un(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(o=>Gu(o,t)).join("")}function Gu(e,t){return so(e,"table-content"),X(e.children,[],[],t).replace(/\|/g,"\\|").replace(/ {2}\n/g,"<br>").replace(/\n/g,"<br>")}var hr=4;function gr(e,t,o={}){switch(e.type){case"anchor":return`[${X(e.children)}](${e.href})`;case"block-quote":{let r=e.children,n=r[0];return`${(n?.type==="paragraph"&&/^\[![A-Za-z0-9_-]+\][+-]?(?:\s+.*)?$/.test(X(n.children))?`${gr(n,t,o).trimEnd()}
|
|
14
14
|
${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
15
15
|
`).map(l=>l?`> ${l}`:">").join(`
|
|
16
16
|
`)}
|
|
@@ -23,21 +23,21 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
23
23
|
|
|
24
24
|
`:`${r}
|
|
25
25
|
|
|
26
|
-
`}case"table":return
|
|
27
|
-
`;case"ordered-list-item":return`${" ".repeat(e.depth*
|
|
28
|
-
`;case"task-list-item":{let r=" ".repeat(e.depth*
|
|
29
|
-
`}case"image-block":return
|
|
26
|
+
`}case"table":return Wi(e,o);case"table-row":case"table-cell":case"table-content":throw new Error(`Table elements should only be present as children of table which should be handled by serializeTable. Got ${e.type} may indicate an error in normalization.`);case"unordered-list-item":return`${" ".repeat(e.depth*hr)}- ${X(e.children,[],[],o)}
|
|
27
|
+
`;case"ordered-list-item":return`${" ".repeat(e.depth*hr)}${t[e.depth]}. ${X(e.children,[],[],o)}
|
|
28
|
+
`;case"task-list-item":{let r=" ".repeat(e.depth*hr),n=X(e.children,[],[],o);return n.trim()===""&&(n=" "),`${r}- [${e.checked?"x":" "}] ${n}
|
|
29
|
+
`}case"image-block":return vi(e,o);case"image-inline":return``;case"code-block":return Ei(e);case"code-block-line":throw new Error("Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.");case"html-block":return`${e.html}
|
|
30
30
|
|
|
31
|
-
`}Se(e)}function At(e,t={}){let o=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],l=i<e.length-1?e[i+1]:null;a.type==="ordered-list-item"?(r[a.depth]=(r[a.depth]||0)+1,r=r.slice(0,a.depth+1)):a.type==="unordered-list-item"||a.type==="task-list-item"?r=r.slice(0,a.depth):r=[];let s=
|
|
31
|
+
`}Se(e)}function At(e,t={}){let o=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],l=i<e.length-1?e[i+1]:null;a.type==="ordered-list-item"?(r[a.depth]=(r[a.depth]||0)+1,r=r.slice(0,a.depth+1)):a.type==="unordered-list-item"||a.type==="task-list-item"?r=r.slice(0,a.depth):r=[];let s=gr(a,r,t);(a.type==="ordered-list-item"||a.type==="unordered-list-item"||a.type==="task-list-item")&&(!l||l.type!=="ordered-list-item"&&l.type!=="unordered-list-item"&&l.type!=="task-list-item")&&(s=s.replace(/\n$/,`
|
|
32
32
|
|
|
33
|
-
`)),o.push(s)}let n=o.join("");return n.replace(/[\t\n\r ]/g,"")===""?"":n.replace(/^\n+/,"").replace(/[\t\n\r ]+$/,"")}function fe(e,t={}){let o=
|
|
33
|
+
`)),o.push(s)}let n=o.join("");return n.replace(/[\t\n\r ]/g,"")===""?"":n.replace(/^\n+/,"").replace(/[\t\n\r ]+$/,"")}function fe(e,t={}){let o=gi(e);return At(o,t)}var br={ja:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",strike:"\u53D6\u308A\u6D88\u3057\u7DDA",inlineCode:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",underline:"\u4E0B\u7DDA",highlight:"\u30CF\u30A4\u30E9\u30A4\u30C8",increaseDepth:"\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",decreaseDepth:"\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",heading1:"\u898B\u51FA\u30571",heading2:"\u898B\u51FA\u30572",heading3:"\u898B\u51FA\u30573",normal:"\u6A19\u6E96",paragraph:"\u6BB5\u843D",paragraphStyle:"\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",bulletList:"\u7B87\u6761\u66F8\u304D",numberedList:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkList:"\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",list:"\u30EA\u30B9\u30C8",linkUrl:"\u30EA\u30F3\u30AF\u306EURL",linkTypeExternal:"\u5916\u90E8",linkTypeInternal:"\u5185\u90E8",internalLinkTarget:"\u5185\u90E8\u30EA\u30F3\u30AF\u5148",internalLinkTargetHint:"\u4F8B: Page \u307E\u305F\u306F Folder/Page#Heading",internalLinkEmbed:"\u57CB\u3081\u8FBC\u307F\u3068\u3057\u3066\u633F\u5165",internalLinkEmbedHint:"\u30AA\u30F3\u306B\u3059\u308B\u3068 ![[...]] \u3068\u3057\u3066\u57CB\u3081\u8FBC\u307E\u308C\u307E\u3059",linkText:"\u30EA\u30F3\u30AF\u30C6\u30AD\u30B9\u30C8",linkTextHint:"\u30EA\u30F3\u30AF\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u308B\u30C6\u30AD\u30B9\u30C8",tooltipText:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",tooltipHint:"\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",apply:"\u9069\u7528",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u524A\u9664",insertLink:"\u30EA\u30F3\u30AF",quote:"\u5F15\u7528",insertTable:"\u8868",insertImage:"\u753B\u50CF",insertImageFromUrl:"\u753B\u50CF",insert:"\u633F\u5165",format:"\u66F8\u5F0F",imageUrlRequired:"\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",altText:"\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",title:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\uFF1A",imageDescription:"\u753B\u50CF\u306E\u8AAC\u660E",imageTitle:"\u753B\u50CF\u306E\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",switchToVisualEditor:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",switchToRawMarkdown:"\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",codeBlock:"\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",increaseQuoteDepth:"\u5F15\u7528\u3092\u91CD\u306D\u308B",horizontalRule:"\u533A\u5207\u308A\u7DDA",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",saving:"\u4FDD\u5B58\u4E2D...",uploadComplete:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5B8C\u4E86",imageSourceSelect:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u6E08\u307F",vaultPath:"\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",vaultPathHint:"vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",highlight:"Highlight",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",linkTypeExternal:"External",linkTypeInternal:"Internal",internalLinkTarget:"Internal Link Target",internalLinkTargetHint:"Example: Page or Folder/Page#Heading",internalLinkEmbed:"Insert as embed",internalLinkEmbedHint:"When on, inserts as ![[...]]",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",edit:"Edit",remove:"Remove",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",horizontalRule:"Horizontal Rule",register:"Register",imageSourceUrl:"URL",imageSourceFile:"Upload",selectFile:"Select File",uploading:"Uploading...",saving:"Saving...",uploadComplete:"Upload Complete",imageSourceSelect:"Uploaded",vaultPath:"Save Path:",vaultPathHint:"Enter the path within the vault to save the file"}},Vi=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=Vi();return br[t==="ja"?"ja":"en"][e]},Er=e=>{let t=Vi();return Object.keys(br[t==="ja"?"ja":"en"]).find(r=>br[t==="ja"?"ja":"en"][r]===e)||""};var y=e=>({fn:e});import{useCallback as Yu,useEffect as Ju,useMemo as Zi,useRef as Zu}from"react";import{Editor as ho,Range as ef,Transforms as ea}from"slate";import{ReactEditor as tf,useSlateStatic as of}from"slate-react";function he(e){return!!e}function _i(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(he);return function(r){let n=[];for(let i of o){let a=i(r);n.push(...a)}return e&&n.push(...e(r)),n}}import{Editable as qu}from"slate-react";import{jsx as Qu}from"react/jsx-runtime";function Ki(e){let t=e.map(r=>r.renderEditable).filter(he),o=r=>Qu(qu,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function uo(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function fo(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Gi=(e,t)=>{let o=uo(t,"onKeyDown");return fo(o,e)},qi=(e,t)=>{let o=uo(t,"onKeyUp");return fo(o,e)},Qi=(e,t)=>{let o=uo(t,"onPaste");return fo(o,e)},ji=(e,t)=>{let o=uo(t,"onDrop");return fo(o,e)};function Xi(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(he);return function(n){for(let i of o){let a=i(n);if(a)return a}if(e===void 0)throw new Error(`Element with type ${n.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`);return e(n)}}import{cloneElement as ju}from"react";function Yi(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(he).reverse();return function(r){let n=e({...r,attributes:{}});for(let i of o){let a=i({...r,children:n});a&&(n=a)}return n=ju(n,r.attributes),n}}function Ji(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(he);if(o.length!==0)return function(r){if(o.length>1)throw new Error(`Only one plugin can define renderPlaceholder but there are ${o.length}`);let n=o[0];if(n==null)throw new Error("Expected fn to be defined");return n(r)}}import Xu from"@emotion/styled";var Ot=Xu("div")`
|
|
34
34
|
-webkit-font-smoothing: antialiased;
|
|
35
35
|
-moz-osx-font-smoothing: grayscale;
|
|
36
36
|
font-size: 1rem;
|
|
37
37
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
38
38
|
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
39
39
|
box-sizing: border-box;
|
|
40
|
-
`;import{jsx as lf}from"react/jsx-runtime";var ra=e=>/[^\x00-\x7F]/.test(e);function rf(e,t){let[o]=t.getTargetRanges();if(o)try{let r=tf.toSlateRange(e,o,{exactMatch:!1,suppressThrow:!1});oa.select(e,r)}catch{}}function nf(e,t,o){return r=>{let n=e?.(r);return n!=null||r.defaultPrevented||r.inputType!=="insertText"||r.isComposing||typeof r.data!="string"||r.data.length===0||!ra(r.data)?n:(rf(t,r),r.preventDefault(),fo.insertText(t,r.data),o.current=r.data,!0)}}function af(e,t,o){return r=>{let n=e?.(r);if(n!=null||r.defaultPrevented)return n;let i=r.nativeEvent;return!(i instanceof InputEvent)||i.inputType!=="insertText"||i.isComposing||typeof i.data!="string"||i.data.length===0||!ra(i.data)?n:o.current===i.data?(o.current=null,n):(fo.insertText(t,i.data),n)}}function na(e){let t=of(),o=Zu(null),r=Yu((l,s)=>{let{selection:m}=t;if(m==null||ef.isCollapsed(m))return!1;let c=fo.fragment(t,m),d=fe(c,{enableInternalLinks:t.wysimark.enableInternalLinks}).trimEnd();return d===""?!1:(l.preventDefault(),l.clipboardData.setData("text/plain",d),l.clipboardData.setData("text/markdown",d),s.deleteSelection&&oa.delete(t),!0)},[t]);Ju(()=>{fo.normalize(t,{force:!0})},[t]);let{plugins:n}=t.sink,i=ta(()=>({...e,decorate:Gi(e.decorate,n),renderElement:Ji(e.renderElement,n),renderLeaf:Zi(e.renderLeaf,n),renderPlaceholder:ea(e.renderPlaceholder,n),onKeyDown:Qi(e.onKeyDown,n),onKeyUp:ji(e.onKeyUp,n),onPaste:Xi(e.onPaste,n),onCopy:l=>{e.onCopy?.(l),l.defaultPrevented||r(l,{deleteSelection:!1})},onCut:l=>{e.onCut?.(l),l.defaultPrevented||r(l,{deleteSelection:!0})},onDrop:Yi(e.onDrop,n),onDOMBeforeInput:nf(e.onDOMBeforeInput,t,o),onInput:af(e.onInput,t,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onCopy,e.onCut,e.onDrop,e.onDOMBeforeInput,e.onInput,e.placeholder,e.className,t,n,r]),a=ta(()=>qi(n),[n]);return lf(a,{...i})}function it(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function xe(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function ia(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:xe(r,"normalizeNode",n),deleteBackward:xe(r,"deleteBackward",n),deleteForward:xe(r,"deleteForward",n),deleteFragment:xe(r,"deleteFragment",n),insertBreak:xe(r,"insertBreak",n),insertFragment:xe(r,"insertFragment",n),insertNode:xe(r,"insertNode",n),insertText:xe(r,"insertText",n),isInline:it(r,"isInline",n),isVoid:it(r,"isVoid",n),isMaster:it(r,"isMaster",n),isSlave:it(r,"isSlave",n),isStandalone:it(r,"isStandalone",n)}),r}}var aa=e=>{let t=e.map(n=>n.fn);return{withSink:ia(t),SinkEditable:na}};import{Element as sf}from"slate";import{ReactEditor as mf}from"slate-react";function la(e,t){return sf.isElement(t)?mf.findPath(e,t):t}function h(e,t){return e.bind(null,t)}function ee(e,t,o){return e.bind(null,t,o)}var cf=/mac os x|macintosh/i,Ut;function ho(){if(Ut!==void 0)return Ut;try{let{userAgent:e}=window.navigator;Ut=cf.test(e)}catch{Ut=!1}return Ut}function Ue(e){e.preventDefault(),e.stopPropagation()}import{Editor as ca,Path as pf}from"slate";import{Element as sa}from"slate";function ma(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>sa.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>sa.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=la(e,o),n=ma(t);if(pf.isPath(r)){let i=ca.node(e,r);if(i&&n(i[0]))return i}return ca.above(e,{at:r,match:n})}function at(...e){return E(...e)?.[1]}import{jsx as df}from"react/jsx-runtime";var x=({strokeWidth:e=1.5,...t})=>df("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as uf}from"slate";function ye(e){return e==null?!1:uf.isCollapsed(e)}import{Element as pa}from"slate";function go(e){return Array.isArray(e)?t=>pa.isElement(t)&&e.includes(t.type):t=>pa.isElement(t)&&e==t.type}import{Editor as ff}from"slate";function da(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&ff.isEnd(e,o.anchor,r[1])}import{Editor as GT}from"slate";import{Editor as hf}from"slate";function Fe(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&hf.isStart(e,o.anchor,r[1])}import{isHotkey as ua}from"is-hotkey";import{Editor as yr,Element as gf,Range as bf,Transforms as Ef}from"slate";var kf=ua(" "),xf=ua("SHIFT+SPACE");function bo(e,t){return o=>{if(!kf(o.nativeEvent)&&!xf(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||bf.isExpanded(r))return!1;let n=E(e,m=>gf.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:yr.start(e,n[1]),focus:r.focus},a=yr.string(e,i),l=t[a];if(!l)return!1;Ue(o);let s={anchor:yr.start(e,n[1]),focus:r.focus};return Ef.delete(e,{at:s}),l(),!0}}import{isHotkey as yf}from"is-hotkey";function fa(e){let t=e.replace(/\bsuper\b/g,ho()?"cmd+alt":"ctrl+shift");return yf(t)}function V(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[fa(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as vf,Transforms as ha}from"slate";function ga(e,t){vf.withoutNormalizing(e,()=>{ha.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),ha.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as ba}from"slate";function lt(e,t,o){let[,r]=t,n=ba.previous(e,{at:r});if(n&&o(n,t))return!0;let i=ba.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as Ea,Transforms as ka}from"slate";function te(e,t){ka.select(e,Ea.start(e,t))}function xa(e,t){ka.select(e,Ea.end(e,t))}function ya(e,t){return typeof t!="function"?t:t(e)}import{Editor as vr,Element as Tf,Path as wf,Transforms as Ft}from"slate";function va(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>Tf.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;vr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:o}),n&&(Ft.select(e,n),Ft.move(e))})}else{let n=wf.next(r[1]);vr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:n}),Ft.select(e,vr.start(e,n))})}return!0}import{Editor as Ta,Transforms as wa}from"slate";function Wt(e,t,o){Ta.withoutNormalizing(e,()=>{let r=Ta.node(e,o),n=ya(r[0],t);wa.wrapNodes(e,n,{at:o}),wa.unwrapNodes(e,{at:[...o,0]})})}import{Editor as If,Transforms as Mf}from"slate";function Eo(e,t,o){let r=Array.from(If.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;Mf.setNodes(e,t(i),{at:n[1]})}return!0}import{Editor as Cf,Path as ko,Range as xo}from"slate";import{ReactEditor as Ia,useSlate as Ma}from"slate-react";function Ca(e,t){if(!e)return!1;let o=e.anchor.path,r=e.focus.path;return ko.equals(t,o)||ko.equals(t,r)||ko.isAncestor(t,o)||ko.isAncestor(t,r)}function Pa(e){let t=Ma(),{selection:o}=t;if(!o)return!1;try{let r=Ia.findPath(t,e);return Ca(o,r)}catch{return!1}}function Sa(e){let t=Ma(),{selection:o}=t;if(!o)return!1;try{let r=Ia.findPath(t,e);if(Ca(o,r))return!0;let n=Cf.range(t,r);return xo.includes(o,n.anchor)||xo.includes(o,n.focus)||xo.includes(n,o.anchor)||xo.includes(n,o.focus)}catch{return!1}}function La(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return Pf(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function Pf(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Sf,Transforms as Ra}from"slate";function Ba(e,t,{at:o}){let r=E(e,"anchor",{at:o});if(!r)return!1;let[,n]=r;return Sf.withoutNormalizing(e,()=>{Ra.removeNodes(e,{at:n}),Ra.insertNodes(e,{type:"image-inline",url:no(t),alt:t,children:[{text:""}]},{at:n})}),!0}import{Editor as $a,Transforms as st}from"slate";function Da(e,t,{at:o}){let r=E(e,["image-inline","image-block"],{at:o});if(!r)return!1;let[n,i]=r,a=se(t),l={type:"anchor",href:Ce(t),children:[{text:a}]};if(n.type==="image-block"){let s={type:"paragraph",children:[{text:""},l,{text:""}]};$a.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,s,{at:i})});let m=[...i,1];return st.select(e,m),[l,m]}return $a.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,l,{at:i})}),st.select(e,i),[l,i]}import{Editor as Lf,Node as Rf,Transforms as Tr}from"slate";function za(e,{href:t,title:o,text:r},{at:n}){let i=E(e,"anchor",{at:n});if(!i)return!1;let[a,l]=i;if(Tr.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Rf.string(a);r!==s&&Lf.withoutNormalizing(e,()=>{let m=a.children.length;for(let c=m-1;c>=0;c--)Tr.removeNodes(e,{at:[...l,c]});Tr.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as yo,Element as Bf,Range as $f,Text as Df,Transforms as wr}from"slate";function Na(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:yo.start(e,[0]),focus:yo.start(e,[0])};if($f.isCollapsed(i)){if(wr.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=yo.node(e,e.selection);wr.select(e,a[1])}}else wr.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Df.isText(a)||Bf.isElement(a)&&yo.isInline(e,a)})}import{Transforms as zf}from"slate";function Ha(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(zf.unwrapNodes(e,{at:o[1]}),!0):!1}function Aa(e){return{insertLink:h(Na,e),removeLink:h(Ha,e),editLink:h(za,e),convertToEmbed:h(Ba,e),convertToLink:h(Da,e)}}import{Element as Oa,Transforms as Nf}from"slate";function Ua(e,t){if(!Oa.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!Oa.isElement(n)||n.type!=="anchor"))return Nf.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Lh}from"clsx";import{useEffect as Rh,useRef as wl}from"react";import{useSelected as Bh,useSlate as $h}from"slate-react";import{createContext as Wa,useState as Af}from"react";import{createPortal as Hf}from"react-dom";function Fa({children:e}){return typeof document>"u"||!document.body?null:Hf(e,document.body)}import{jsx as Ir,jsxs as Uf}from"react/jsx-runtime";var Mr=Wa({}),Of=Wa({});function Va({children:e}){let[t,o]=Af({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Uf(Mr.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>Ir(Fa,{children:Ir(Of.Provider,{value:i,children:Ir(i.Component,{})})},i.type))]})}import{useContext as Ff}from"react";function F(e){let{openLayer:t,closeLayer:o,layers:r}=Ff(Mr);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import vo from"@emotion/styled";var _a=vo("a")`
|
|
40
|
+
`;import{jsx as lf}from"react/jsx-runtime";var ta=e=>/[^\x00-\x7F]/.test(e);function rf(e,t){let[o]=t.getTargetRanges();if(o)try{let r=tf.toSlateRange(e,o,{exactMatch:!1,suppressThrow:!1});ea.select(e,r)}catch{}}function nf(e,t,o){return r=>{let n=e?.(r);return n!=null||r.defaultPrevented||r.inputType!=="insertText"||r.isComposing||typeof r.data!="string"||r.data.length===0||!ta(r.data)?n:(rf(t,r),r.preventDefault(),ho.insertText(t,r.data),o.current=r.data,!0)}}function af(e,t,o){return r=>{let n=e?.(r);if(n!=null||r.defaultPrevented)return n;let i=r.nativeEvent;return!(i instanceof InputEvent)||i.inputType!=="insertText"||i.isComposing||typeof i.data!="string"||i.data.length===0||!ta(i.data)?n:o.current===i.data?(o.current=null,n):(ho.insertText(t,i.data),n)}}function oa(e){let t=of(),o=Zu(null),r=Yu((l,s)=>{let{selection:m}=t;if(m==null||ef.isCollapsed(m))return!1;let c=ho.fragment(t,m),d=fe(c,{enableInternalLinks:t.wysimark.enableInternalLinks}).trimEnd();return d===""?!1:(l.preventDefault(),l.clipboardData.setData("text/plain",d),l.clipboardData.setData("text/markdown",d),s.deleteSelection&&ea.delete(t),!0)},[t]);Ju(()=>{ho.normalize(t,{force:!0})},[t]);let{plugins:n}=t.sink,i=Zi(()=>({...e,decorate:_i(e.decorate,n),renderElement:Xi(e.renderElement,n),renderLeaf:Yi(e.renderLeaf,n),renderPlaceholder:Ji(e.renderPlaceholder,n),onKeyDown:Gi(e.onKeyDown,n),onKeyUp:qi(e.onKeyUp,n),onPaste:Qi(e.onPaste,n),onCopy:l=>{e.onCopy?.(l),l.defaultPrevented||r(l,{deleteSelection:!1})},onCut:l=>{e.onCut?.(l),l.defaultPrevented||r(l,{deleteSelection:!0})},onDrop:ji(e.onDrop,n),onDOMBeforeInput:nf(e.onDOMBeforeInput,t,o),onInput:af(e.onInput,t,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onCopy,e.onCut,e.onDrop,e.onDOMBeforeInput,e.onInput,e.placeholder,e.className,t,n,r]),a=Zi(()=>Ki(n),[n]);return lf(a,{...i})}function it(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function xe(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function ra(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:xe(r,"normalizeNode",n),deleteBackward:xe(r,"deleteBackward",n),deleteForward:xe(r,"deleteForward",n),deleteFragment:xe(r,"deleteFragment",n),insertBreak:xe(r,"insertBreak",n),insertFragment:xe(r,"insertFragment",n),insertNode:xe(r,"insertNode",n),insertText:xe(r,"insertText",n),isInline:it(r,"isInline",n),isVoid:it(r,"isVoid",n),isMaster:it(r,"isMaster",n),isSlave:it(r,"isSlave",n),isStandalone:it(r,"isStandalone",n)}),r}}var na=e=>{let t=e.map(n=>n.fn);return{withSink:ra(t),SinkEditable:oa}};import{Element as sf}from"slate";import{ReactEditor as mf}from"slate-react";function ia(e,t){return sf.isElement(t)?mf.findPath(e,t):t}function g(e,t){return e.bind(null,t)}function ee(e,t,o){return e.bind(null,t,o)}var cf=/mac os x|macintosh/i,Ut;function go(){if(Ut!==void 0)return Ut;try{let{userAgent:e}=window.navigator;Ut=cf.test(e)}catch{Ut=!1}return Ut}function Ue(e){e.preventDefault(),e.stopPropagation()}import{Editor as sa,Path as pf}from"slate";import{Element as aa}from"slate";function la(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>aa.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>aa.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=ia(e,o),n=la(t);if(pf.isPath(r)){let i=sa.node(e,r);if(i&&n(i[0]))return i}return sa.above(e,{at:r,match:n})}function at(...e){return E(...e)?.[1]}import{jsx as df}from"react/jsx-runtime";var x=({strokeWidth:e=1.5,...t})=>df("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as uf}from"slate";function ye(e){return e==null?!1:uf.isCollapsed(e)}import{Element as ma}from"slate";function bo(e){return Array.isArray(e)?t=>ma.isElement(t)&&e.includes(t.type):t=>ma.isElement(t)&&e==t.type}import{Editor as ff}from"slate";function ca(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&ff.isEnd(e,o.anchor,r[1])}import{Editor as qT}from"slate";import{Editor as hf}from"slate";function Fe(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&hf.isStart(e,o.anchor,r[1])}import{isHotkey as pa}from"is-hotkey";import{Editor as kr,Element as gf,Range as bf,Transforms as Ef}from"slate";var kf=pa(" "),xf=pa("SHIFT+SPACE");function Eo(e,t){return o=>{if(!kf(o.nativeEvent)&&!xf(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||bf.isExpanded(r))return!1;let n=E(e,m=>gf.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:kr.start(e,n[1]),focus:r.focus},a=kr.string(e,i),l=t[a];if(!l)return!1;Ue(o);let s={anchor:kr.start(e,n[1]),focus:r.focus};return Ef.delete(e,{at:s}),l(),!0}}import{isHotkey as yf}from"is-hotkey";function da(e){let t=e.replace(/\bsuper\b/g,go()?"cmd+alt":"ctrl+shift");return yf(t)}function _(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[da(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as vf,Transforms as ua}from"slate";function fa(e,t){vf.withoutNormalizing(e,()=>{ua.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),ua.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as ha}from"slate";function lt(e,t,o){let[,r]=t,n=ha.previous(e,{at:r});if(n&&o(n,t))return!0;let i=ha.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as ga,Transforms as ba}from"slate";function te(e,t){ba.select(e,ga.start(e,t))}function Ea(e,t){ba.select(e,ga.end(e,t))}function ka(e,t){return typeof t!="function"?t:t(e)}import{Editor as xr,Element as Tf,Path as wf,Transforms as Ft}from"slate";function xa(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>Tf.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;xr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:o}),n&&(Ft.select(e,n),Ft.move(e))})}else{let n=wf.next(r[1]);xr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:n}),Ft.select(e,xr.start(e,n))})}return!0}import{Editor as ya,Transforms as va}from"slate";function Wt(e,t,o){ya.withoutNormalizing(e,()=>{let r=ya.node(e,o),n=ka(r[0],t);va.wrapNodes(e,n,{at:o}),va.unwrapNodes(e,{at:[...o,0]})})}import{Editor as If,Transforms as Mf}from"slate";function ko(e,t,o){let r=Array.from(If.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;Mf.setNodes(e,t(i),{at:n[1]})}return!0}import{Editor as Cf,Path as xo,Range as yo}from"slate";import{ReactEditor as Ta,useSlate as wa}from"slate-react";function Ia(e,t){if(!e)return!1;let o=e.anchor.path,r=e.focus.path;return xo.equals(t,o)||xo.equals(t,r)||xo.isAncestor(t,o)||xo.isAncestor(t,r)}function Ma(e){let t=wa(),{selection:o}=t;if(!o)return!1;try{let r=Ta.findPath(t,e);return Ia(o,r)}catch{return!1}}function Ca(e){let t=wa(),{selection:o}=t;if(!o)return!1;try{let r=Ta.findPath(t,e);if(Ia(o,r))return!0;let n=Cf.range(t,r);return yo.includes(o,n.anchor)||yo.includes(o,n.focus)||yo.includes(n,o.anchor)||yo.includes(n,o.focus)}catch{return!1}}function Pa(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return Pf(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function Pf(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Sf,Transforms as Sa}from"slate";function La(e,t,{at:o}){let r=E(e,"anchor",{at:o});if(!r)return!1;let[,n]=r;return Sf.withoutNormalizing(e,()=>{Sa.removeNodes(e,{at:n}),Sa.insertNodes(e,{type:"image-inline",url:no(t),alt:t,children:[{text:""}]},{at:n})}),!0}import{Editor as Ra,Transforms as st}from"slate";function Ba(e,t,{at:o}){let r=E(e,["image-inline","image-block"],{at:o});if(!r)return!1;let[n,i]=r,a=me(t),l={type:"anchor",href:Ce(t),children:[{text:a}]};if(n.type==="image-block"){let s={type:"paragraph",children:[{text:""},l,{text:""}]};Ra.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,s,{at:i})});let m=[...i,1];return st.select(e,m),[l,m]}return Ra.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,l,{at:i})}),st.select(e,i),[l,i]}import{Editor as Lf,Node as Rf,Transforms as yr}from"slate";function $a(e,{href:t,title:o,text:r},{at:n}){let i=E(e,"anchor",{at:n});if(!i)return!1;let[a,l]=i;if(yr.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Rf.string(a);r!==s&&Lf.withoutNormalizing(e,()=>{let m=a.children.length;for(let c=m-1;c>=0;c--)yr.removeNodes(e,{at:[...l,c]});yr.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as vo,Element as Bf,Range as $f,Text as Df,Transforms as vr}from"slate";function Da(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:vo.start(e,[0]),focus:vo.start(e,[0])};if($f.isCollapsed(i)){if(vr.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=vo.node(e,e.selection);vr.select(e,a[1])}}else vr.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Df.isText(a)||Bf.isElement(a)&&vo.isInline(e,a)})}import{Transforms as zf}from"slate";function za(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(zf.unwrapNodes(e,{at:o[1]}),!0):!1}function Na(e){return{insertLink:g(Da,e),removeLink:g(za,e),editLink:g($a,e),convertToEmbed:g(La,e),convertToLink:g(Ba,e)}}import{Element as Ha,Transforms as Nf}from"slate";function Aa(e,t){if(!Ha.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!Ha.isElement(n)||n.type!=="anchor"))return Nf.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Lh}from"clsx";import{useEffect as Rh,useRef as wl}from"react";import{useSelected as Bh,useSlate as $h}from"slate-react";import{createContext as Ua,useState as Af}from"react";import{createPortal as Hf}from"react-dom";function Oa({children:e}){return typeof document>"u"||!document.body?null:Hf(e,document.body)}import{jsx as Tr,jsxs as Uf}from"react/jsx-runtime";var wr=Ua({}),Of=Ua({});function Fa({children:e}){let[t,o]=Af({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Uf(wr.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>Tr(Oa,{children:Tr(Of.Provider,{value:i,children:Tr(i.Component,{})})},i.type))]})}import{useContext as Ff}from"react";function W(e){let{openLayer:t,closeLayer:o,layers:r}=Ff(wr);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import To from"@emotion/styled";var Wa=To("a")`
|
|
41
41
|
/**
|
|
42
42
|
* Link colors
|
|
43
43
|
*/
|
|
@@ -59,10 +59,10 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
59
59
|
&.--selected {
|
|
60
60
|
background: var(--blue-50);
|
|
61
61
|
}
|
|
62
|
-
`,
|
|
62
|
+
`,Ir=To("span")`
|
|
63
63
|
display: inline;
|
|
64
64
|
padding: 0 1px 0 0;
|
|
65
|
-
`,
|
|
65
|
+
`,hM=To("span")`
|
|
66
66
|
position: fixed;
|
|
67
67
|
width: 100px;
|
|
68
68
|
background: var(--shade-50);
|
|
@@ -71,14 +71,14 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
71
71
|
border: 1px solid var(--shade-400);
|
|
72
72
|
overflow: hidden;
|
|
73
73
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
74
|
-
`,
|
|
74
|
+
`,gM=To("span")`
|
|
75
75
|
position: absolute;
|
|
76
76
|
left: 0;
|
|
77
77
|
top: 0;
|
|
78
78
|
height: 14px;
|
|
79
79
|
background: var(--blue-400);
|
|
80
80
|
transition: width 100ms linear;
|
|
81
|
-
`;import wh from"@emotion/styled";import{useCallback as
|
|
81
|
+
`;import wh from"@emotion/styled";import{useCallback as So,useRef as Ih,useState as Mh}from"react";import{useSlateStatic as Ch}from"slate-react";import{useRef as Vf}from"react";import Wf from"@emotion/styled";var Va=Wf("div")`
|
|
82
82
|
position: fixed;
|
|
83
83
|
user-select: none;
|
|
84
84
|
top: 0;
|
|
@@ -87,7 +87,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
87
87
|
bottom: 0;
|
|
88
88
|
overflow-y: auto;
|
|
89
89
|
background: rgba(0, 0, 0, 0.01);
|
|
90
|
-
`;import{jsx as _f}from"react/jsx-runtime";function Re({close:e}){let t=Vf(null);return _f(
|
|
90
|
+
`;import{jsx as _f}from"react/jsx-runtime";function Re({close:e}){let t=Vf(null);return _f(Va,{ref:t,onClick:e})}var ge={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},Kf={shift:ge.shift,opt:ge.opt,alt:ge.opt,ctrl:ge.ctrl,mod:ge.cmd,cmd:ge.cmd,enter:ge.enter,super:`${ge.opt}${ge.cmd}`},Gf={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:ge.enter,super:"CTRL+SHIFT"};function _a(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function qf(e){let t=[];return Object.entries(Kf).forEach(([o,r])=>{e.includes(o)&&(t.push(r),_a(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function Qf(e){let t=[];return Object.entries(Gf).forEach(([o,r])=>{e.includes(o)&&(t.push(r),_a(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function wo(e){let t=e.toLowerCase().split("+");return go()?qf(t):Qf(t)}import{useRef as ah}from"react";import{useSlateStatic as lh}from"slate-react";function Mr(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}}function Ka(e){let t=Mr(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function Cr(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function Ga(){let e=Cr();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var qa=jf;function jf(e,t){for(var o={},r=Object.keys(e),n=r.length,i=0;i<n;i++){var a=r[i];o[a]=t(e[a],a,e)}return o}function Pr(e,t){return qa(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as Zf}from"react";import Xf from"lodash.throttle";import{useMemo as Yf,useState as Jf}from"react";function Io(e=100){let[t,o]=Jf(0),r=Yf(()=>Xf(()=>{o(n=>n+1)},e,{trailing:!0}),[e]);return Object.assign(r,{counter:t})}function Sr(){let e=Io();return Zf(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function oe(e,t){let o=Sr(),r=Pr(e,n=>Ka(n));return t(r,Ga(),o)}function Be(e,t,o,{margin:r=0}={}){if(e==null)return{...o,left:-1024};let{top:n}=o,{left:i}=o,a=t.right-t.left-r*2;return e.width>=a?i=t.left+r:(i+e.width>t.right-r&&(i=t.right-e.width-r),i<t.left+r&&(i=t.left+r)),{left:i,top:n}}import Lr from"@emotion/styled";import eh from"@emotion/styled";var re=eh(Ot)`
|
|
91
91
|
position: absolute;
|
|
92
92
|
z-index: 1000;
|
|
93
93
|
border: 1px solid var(--table-border-color);
|
|
@@ -116,14 +116,14 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
116
116
|
* even if we did, it looks better this way.
|
|
117
117
|
*/
|
|
118
118
|
/* transition: left 100ms, top 100ms; */
|
|
119
|
-
`;var
|
|
119
|
+
`;var Qa=Lr(re)`
|
|
120
120
|
width: 24em;
|
|
121
121
|
padding: 0;
|
|
122
122
|
overflow: hidden;
|
|
123
|
-
`,Vt=
|
|
123
|
+
`,Vt=Lr("div")`
|
|
124
124
|
display: flex;
|
|
125
125
|
gap: 0.5em;
|
|
126
|
-
`,_t=
|
|
126
|
+
`,_t=Lr("input")`
|
|
127
127
|
flex: 1 1 auto;
|
|
128
128
|
padding: 0.5em 0.75em;
|
|
129
129
|
border-radius: 0.25em;
|
|
@@ -134,7 +134,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
134
134
|
&:focus {
|
|
135
135
|
outline: 2px solid var(--blue-200);
|
|
136
136
|
}
|
|
137
|
-
`;import
|
|
137
|
+
`;import Xa from"@emotion/styled";import th from"@emotion/styled";var ja=th(Ot)`
|
|
138
138
|
border: 1px solid var(--shade-300); /* shade-300 */
|
|
139
139
|
border-radius: 0.5em;
|
|
140
140
|
color: rgb(39 39 42); /* shade-800 */
|
|
@@ -150,11 +150,11 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
150
150
|
*/
|
|
151
151
|
outline: 2px solid var(--select-editor-color) !important;
|
|
152
152
|
}
|
|
153
|
-
`;var
|
|
153
|
+
`;var Ya=Xa("div")`
|
|
154
154
|
padding: 2em;
|
|
155
155
|
flex: 1;
|
|
156
156
|
min-height: 0;
|
|
157
|
-
`,
|
|
157
|
+
`,Ja=Xa(ja)`
|
|
158
158
|
/**
|
|
159
159
|
* We use this to make sure the top of the container is rounded even though
|
|
160
160
|
* the toolbar inside is square. We keep the toolbar square so that as the
|
|
@@ -177,7 +177,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
177
177
|
flex-direction: column;
|
|
178
178
|
flex: 1;
|
|
179
179
|
min-height: 0;
|
|
180
|
-
`;import
|
|
180
|
+
`;import Rr from"@emotion/styled";var Za=Rr(re)`
|
|
181
181
|
position: absolute;
|
|
182
182
|
padding-top: 0.5em;
|
|
183
183
|
padding-bottom: 0.5em;
|
|
@@ -187,7 +187,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
187
187
|
* Prevent clicks from stealing focus from the editor
|
|
188
188
|
*/
|
|
189
189
|
user-select: none;
|
|
190
|
-
`,
|
|
190
|
+
`,el=Rr("div")`
|
|
191
191
|
display: flex;
|
|
192
192
|
z-index: 10;
|
|
193
193
|
padding: 0 1em 0 1.5em;
|
|
@@ -227,12 +227,12 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
227
227
|
&:hover {
|
|
228
228
|
background: var(--blue-50);
|
|
229
229
|
}
|
|
230
|
-
`,
|
|
230
|
+
`,tl=Rr("div")`
|
|
231
231
|
height: 1px;
|
|
232
232
|
background: var(--shade-200);
|
|
233
233
|
margin-top: 0.25em;
|
|
234
234
|
margin-bottom: 0.25em;
|
|
235
|
-
`;import Kt from"@emotion/styled";var
|
|
235
|
+
`;import Kt from"@emotion/styled";var ol=Kt("div")`
|
|
236
236
|
/**
|
|
237
237
|
* This flex rule applies to the "display: flex;" of the parent container.
|
|
238
238
|
* Ensures the toolbar does not shrink or grow vertically.
|
|
@@ -271,22 +271,22 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
271
271
|
3em + 1px
|
|
272
272
|
); // $ToolbarDivider height + border-bottom of 1px above
|
|
273
273
|
overflow: hidden;
|
|
274
|
-
`,
|
|
274
|
+
`,rl=Kt("div")`
|
|
275
275
|
display: inline-block;
|
|
276
276
|
height: calc(
|
|
277
277
|
3em + 1px
|
|
278
278
|
); // $ToolbarDivider height + border-bottom of 1px above
|
|
279
|
-
`,
|
|
279
|
+
`,nl=Kt("div")`
|
|
280
280
|
display: inline-block;
|
|
281
281
|
height: 3em;
|
|
282
282
|
padding: 0 0.375em;
|
|
283
|
-
`,
|
|
283
|
+
`,il=Kt("div")`
|
|
284
284
|
display: inline-block;
|
|
285
285
|
background: var(--shade-300);
|
|
286
286
|
opacity: 50%;
|
|
287
287
|
width: 1px;
|
|
288
288
|
height: 3em;
|
|
289
|
-
`,
|
|
289
|
+
`,al=Kt("div")`
|
|
290
290
|
box-sizing: border-box;
|
|
291
291
|
position: relative;
|
|
292
292
|
display: inline-block;
|
|
@@ -336,7 +336,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
336
336
|
margin-left: -0.25em;
|
|
337
337
|
opacity: 0.375;
|
|
338
338
|
}
|
|
339
|
-
`;import{useCallback as oh}from"react";import{ReactEditor as rh}from"slate-react";import{Fragment as ih,jsx as mt,jsxs as nh}from"react/jsx-runtime";function
|
|
339
|
+
`;import{useCallback as oh}from"react";import{ReactEditor as rh}from"slate-react";import{Fragment as ih,jsx as mt,jsxs as nh}from"react/jsx-runtime";function ll({editor:e,item:t,close:o,dest:r}){let n=W("menu"),i=oh(()=>{if(t.Component){let a=t.Component;n.open(()=>mt(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),rh.focus(e),o())},[e,t]);return mt(ih,{children:nh(el,{onClick:i,children:[mt("div",{className:"--icon",children:mt(t.icon,{})}),mt("div",{className:"--title",children:t.title}),mt("div",{className:"--hotkey",children:t.hotkey?wo(t.hotkey):void 0})]})})}import{Fragment as sh,jsx as Mo,jsxs as mh}from"react/jsx-runtime";function ct({dest:e,items:t,close:o}){let r=lh(),n=ah(null),i=oe({src:n,dest:e},({dest:a})=>a?{left:a.left-8,top:a.top+a.height}:{left:0,top:0});return mh(sh,{children:[Mo(Re,{close:o}),Mo(Za,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?Mo(tl,{},l):a.show&&!a.show(r)?null:Mo(ll,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as pl}from"react";import sl from"@emotion/styled";import{jsx as dh,jsxs as uh}from"react/jsx-runtime";function Br(e){return e.getBoundingClientRect()}var ch=sl("div")`
|
|
340
340
|
position: fixed;
|
|
341
341
|
z-index: 10;
|
|
342
342
|
-webkit-font-smoothing: antialiased;
|
|
@@ -352,12 +352,12 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
352
352
|
background: var(--shade-700);
|
|
353
353
|
border-radius: 0.25em;
|
|
354
354
|
white-space: nowrap;
|
|
355
|
-
`,ph=
|
|
355
|
+
`,ph=sl("span")`
|
|
356
356
|
margin-left: 0.75em;
|
|
357
357
|
font-size: 0.875em;
|
|
358
358
|
font-weight: 500;
|
|
359
359
|
color: var(--shade-400);
|
|
360
|
-
`;function
|
|
360
|
+
`;function ml({title:e,hotkey:t,dest:o}){let r=Br(o);return uh(ch,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?dh(ph,{children:t}):null]})}import fh from"@emotion/styled";import{jsx as gh}from"react/jsx-runtime";var hh=fh("span")`
|
|
361
361
|
position: fixed;
|
|
362
362
|
z-index: 10;
|
|
363
363
|
width: 0;
|
|
@@ -365,7 +365,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
365
365
|
border-left: 0.375em solid transparent;
|
|
366
366
|
border-right: 0.375em solid transparent;
|
|
367
367
|
border-top: 0.375em solid var(--shade-700);
|
|
368
|
-
`;function
|
|
368
|
+
`;function cl({dest:e}){let t=Br(e);return gh(hh,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as dl}from"react/jsx-runtime";function ne({title:e,hotkey:t},o=[]){let r=W("tooltip-label"),n=W("tooltip-triangle"),i=pl(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>dl(ml,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>dl(cl,{dest:s})))},[e,t,r,n,...o]),a=pl(()=>{r.close(),n.close()},[r,n,...o]);return{onMouseEnter:i,onMouseLeave:a}}import xh from"@emotion/styled";import{useCallback as Te,useRef as kl,useState as Ve}from"react";import{Node as xl}from"slate";import{useSlateStatic as yh}from"slate-react";import $e from"@emotion/styled";var ve=$e("div")`
|
|
369
369
|
margin: 0.5em 0;
|
|
370
370
|
&:first-of-type {
|
|
371
371
|
margin-top: 0;
|
|
@@ -381,7 +381,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
381
381
|
font-size: 0.875em;
|
|
382
382
|
margin-top: 0.25em;
|
|
383
383
|
color: var(--shade-500);
|
|
384
|
-
`,
|
|
384
|
+
`,ul=$e("input")`
|
|
385
385
|
box-sizing: border-box;
|
|
386
386
|
width: 100%;
|
|
387
387
|
height: 6em;
|
|
@@ -395,7 +395,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
395
395
|
&:focus {
|
|
396
396
|
outline: 2px solid var(--blue-200);
|
|
397
397
|
}
|
|
398
|
-
`,
|
|
398
|
+
`,Co=$e("input")`
|
|
399
399
|
box-sizing: border-box;
|
|
400
400
|
width: 100%;
|
|
401
401
|
padding: 0.5em 0.75em;
|
|
@@ -407,7 +407,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
407
407
|
&:focus {
|
|
408
408
|
outline: 2px solid var(--blue-200);
|
|
409
409
|
}
|
|
410
|
-
`,
|
|
410
|
+
`,fl=$e("div")`
|
|
411
411
|
/* Center vertically and horizontally */
|
|
412
412
|
display: flex;
|
|
413
413
|
align-items: center;
|
|
@@ -421,7 +421,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
421
421
|
font-size: 1.25em;
|
|
422
422
|
stroke-width: 2px;
|
|
423
423
|
}
|
|
424
|
-
`,
|
|
424
|
+
`,hl=$e(fl)`
|
|
425
425
|
color: var(--blue-50);
|
|
426
426
|
background: var(--blue-500);
|
|
427
427
|
outline: 0px solid white;
|
|
@@ -433,7 +433,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
433
433
|
svg {
|
|
434
434
|
color: var(--blue-200);
|
|
435
435
|
}
|
|
436
|
-
`,
|
|
436
|
+
`,gl=$e(fl)`
|
|
437
437
|
color: var(--shade-500);
|
|
438
438
|
background: var(--shade-200);
|
|
439
439
|
outline: 0px solid white;
|
|
@@ -445,7 +445,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
445
445
|
svg {
|
|
446
446
|
color: var(--shade-400);
|
|
447
447
|
}
|
|
448
|
-
`;import{useRef as bh,useCallback as We}from"react";import
|
|
448
|
+
`;import{useRef as bh,useCallback as We}from"react";import El from"@emotion/styled";import{jsx as bl}from"react/jsx-runtime";var Eh=El.div`
|
|
449
449
|
display: flex;
|
|
450
450
|
align-items: center;
|
|
451
451
|
justify-content: center;
|
|
@@ -460,12 +460,12 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
460
460
|
&:active {
|
|
461
461
|
cursor: grabbing;
|
|
462
462
|
}
|
|
463
|
-
`,kh=
|
|
463
|
+
`,kh=El.div`
|
|
464
464
|
width: 32px;
|
|
465
465
|
height: 4px;
|
|
466
466
|
background: #ccc;
|
|
467
467
|
border-radius: 2px;
|
|
468
|
-
`;function De({onDrag:e}){let t=bh(null),o=We((m,c)=>{t.current={x:m,y:c}},[]),r=We((m,c)=>{if(!t.current)return;let d=m-t.current.x,p=c-t.current.y;t.current={x:m,y:c},e(d,p)},[e]),n=We(()=>{t.current=null},[]),i=We(m=>{m.preventDefault(),o(m.clientX,m.clientY);let c=p=>{r(p.clientX,p.clientY)},d=()=>{n(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)},[o,r,n]),a=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];o(c.clientX,c.clientY)},[o]),l=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];r(c.clientX,c.clientY)},[r]),s=We(()=>{n()},[n]);return
|
|
468
|
+
`;function De({onDrag:e}){let t=bh(null),o=We((m,c)=>{t.current={x:m,y:c}},[]),r=We((m,c)=>{if(!t.current)return;let d=m-t.current.x,p=c-t.current.y;t.current={x:m,y:c},e(d,p)},[e]),n=We(()=>{t.current=null},[]),i=We(m=>{m.preventDefault(),o(m.clientX,m.clientY);let c=p=>{r(p.clientX,p.clientY)},d=()=>{n(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)},[o,r,n]),a=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];o(c.clientX,c.clientY)},[o]),l=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];r(c.clientX,c.clientY)},[r]),s=We(()=>{n()},[n]);return bl(Eh,{onMouseDown:i,onTouchStart:a,onTouchMove:l,onTouchEnd:s,children:bl(kh,{})})}import{Fragment as Th,jsx as N,jsxs as be}from"react/jsx-runtime";var vh=xh(re)`
|
|
469
469
|
position: absolute;
|
|
470
470
|
width: 20em;
|
|
471
471
|
padding: 0;
|
|
@@ -494,7 +494,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
494
494
|
background: white;
|
|
495
495
|
box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
|
|
496
496
|
}
|
|
497
|
-
`;function
|
|
497
|
+
`;function Po({destAnchor:e,destStartEdge:t,element:o,initialEmbed:r=!1,onCancel:n}){let i=W("dialog"),a=kl(null),[l,s]=Ve({x:0,y:0}),m=Te((z,j)=>{s(I=>({x:I.x+z,y:I.y+j}))},[]),c=oe({src:a,destAnchor:e,destStartEdge:t},({src:z,destAnchor:j,destStartEdge:I},F)=>Be(z,F,{left:I.left,top:j.top+j.height},{margin:16})),d={...c,left:c.left+l.x,top:c.top+l.y},p=yh(),u=se(o.href),h=u?$t(o.href):"",k=et(h),L=u?k.target:"",[M,T]=Ve(u?"internal":"external"),[D,P]=Ve(r),[H,C]=Ve(o.href),[B,S]=Ve(L),[R,w]=Ve(u?k.display||xl.string(o):xl.string(o)),[U,v]=Ve(o.title||""),$=kl({href:H,target:B,text:R,title:U,mode:M,embed:D});$.current={href:H,target:B,text:R,title:U,mode:M,embed:D};let de=Te(z=>{C(z.target.value)},[]),to=Te(z=>{w(z.target.value)},[]),Rt=Te(z=>{v(z.target.value)},[]),nr=Te(z=>{let j=z.target.value,I=ao(j);S(I.target),I.display!==void 0&&w(I.display)},[]),oo=Te(z=>{T(z),z==="external"&&C(j=>se(j)?"":j)},[]),Je=Te(()=>{i.open(()=>N(pt,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),ir=Te(()=>{if(n){n();return}Je()},[n,Je]),ar=Te(()=>{let{href:z,target:j,text:I,title:F,mode:ue,embed:tu}=$.current;if(ue==="internal"){let Bt=j.trim();if(Bt==="")return;let ro=I.trim(),Bn=ro&&ro!==me(Bt)?`${Bt}|${ro}`:Bt;if(tu){p.anchor.convertToEmbed(Bn,{at:o}),i.close();return}p.anchor.editLink({href:Ce(Bn),text:ro||me(Bt),title:void 0},{at:o})}else{if(z.trim()===""||se(z))return;p.anchor.editLink({href:z,text:I,title:F},{at:o})}Je()},[p,o,i,Je]);return be(vh,{ref:a,contentEditable:!1,style:d,children:[N(De,{onDrag:m}),be("div",{style:{padding:"1em"},children:[p.wysimark.enableInternalLinks?N(ve,{children:be("div",{className:"--link-type",children:[N("button",{type:"button",className:M==="external"?"--active":void 0,onClick:()=>oo("external"),children:f("linkTypeExternal")}),N("button",{type:"button",className:M==="internal"?"--active":void 0,onClick:()=>oo("internal"),children:f("linkTypeInternal")})]})}):null,M==="internal"?be(Th,{children:[be(ve,{children:[N(Gt,{children:f("internalLinkTarget")}),N(Co,{type:"text",value:B,onChange:nr}),N(qt,{children:f("internalLinkTargetHint")})]}),be(ve,{children:[be("label",{style:{display:"flex",alignItems:"center",gap:"0.5em",cursor:"pointer"},children:[N("input",{type:"checkbox",checked:D,onChange:z=>P(z.target.checked)}),f("internalLinkEmbed")]}),N(qt,{children:f("internalLinkEmbedHint")})]})]}):be(ve,{children:[N(Gt,{children:f("linkUrl")}),N(ul,{as:"textarea",value:H,onChange:de})]}),M==="external"||M==="internal"?be(ve,{children:[N(Gt,{children:f("linkText")}),N(Co,{type:"text",value:R,onChange:to}),N(qt,{children:f("linkTextHint")})]}):null,M==="external"?be(ve,{children:[N(Gt,{children:f("tooltipText")}),N(Co,{type:"text",value:U,onChange:Rt}),N(qt,{children:f("tooltipHint")})]}):null,N(ve,{children:N(hl,{onClick:ar,children:f("apply")})}),N(ve,{children:N(gl,{onClick:ir,children:f("cancel")})})]})]})}import{jsx as ze}from"react/jsx-runtime";var $r=e=>ze(x,{...e,children:ze("path",{d:"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5"})}),yl=e=>ze(x,{...e,children:ze("path",{d:"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11"})}),vl=e=>ze(x,{...e,children:ze("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})}),Tl=e=>ze(x,{...e,children:ze("path",{d:"M18 6L6 18M6 6l12 12"})});import{jsx as Q,jsxs as _e}from"react/jsx-runtime";var Ph=wh(re)`
|
|
498
498
|
position: absolute;
|
|
499
499
|
width: 20em;
|
|
500
500
|
z-index: 1000;
|
|
@@ -603,7 +603,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
603
603
|
height: 1.25em;
|
|
604
604
|
stroke-width: 1.5;
|
|
605
605
|
}
|
|
606
|
-
`;function Sh(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function
|
|
606
|
+
`;function Sh(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function pt({destAnchor:e,destStartEdge:t,element:o,embed:r}){let n=W("dialog"),i=Ch(),a=Ih(null),l=!!r,s=o?.href??"",m=Sh(s),c=l||se(s),d=l?r.target:se(s)?io($t(s)):"",p=c?i.wysimark.renderInternalLinkPreview?.(d):null,[u,h]=Mh({x:0,y:0}),k=So((S,R)=>{h(w=>({x:w.x+S,y:w.y+R}))},[]),L=oe({src:a,destAnchor:e,destStartEdge:t},({src:S,destAnchor:R,destStartEdge:w},U)=>Be(S,U,{left:w.left,top:R.top+R.height},{margin:16})),M={...L,left:L.left+u.x,top:L.top+u.y},T=ne({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),D=ne({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),P=ne({title:"\u9589\u3058\u308B"}),H=So(()=>{n.close()},[n]),C=So(()=>{if(r){r.onRemove(),n.close();return}o&&i.anchor.removeLink({at:o}),n.close()},[i,n,r,o]),B=So(()=>{if(D.onMouseLeave(),r){r.onEdit();return}o&&n.open(()=>Q(Po,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o,r,D,n]);return _e(Ph,{ref:a,contentEditable:!1,style:M,children:[Q(De,{onDrag:k}),_e("div",{style:{display:"flex",padding:"1em"},children:[c?_e("span",{className:"--internal-link",style:i.wysimark.onInternalLinkClick?{cursor:"pointer"}:void 0,onMouseDown:S=>{i.wysimark.onInternalLinkClick&&(S.preventDefault(),i.wysimark.onInternalLinkClick(d),n.close())},children:[Q($r,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:f("linkTypeInternal")}),Q("div",{className:"--pathname",children:d}),Q("div",{className:"--internal-preview",children:p??d})]})]}):_e("a",{className:"--link",href:s,target:"_blank",rel:"noreferrer",children:[Q($r,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:m.hostname}),m.pathname===""||m.pathname==="/"?null:Q("div",{className:"--pathname",children:m.pathname}),o?.title==null||o.title===""?null:Q("div",{className:"--tooltip",children:o.title})]})]}),_e("span",{className:"--icons",children:[Q("span",{className:"--icon",onClick:C,onMouseEnter:T.onMouseEnter,onMouseLeave:T.onMouseLeave,children:Q(yl,{})}),Q("span",{className:"--icon",onMouseEnter:D.onMouseEnter,onMouseLeave:D.onMouseLeave,onClick:B,children:Q(vl,{})}),Q("span",{className:"--icon",onClick:H,onMouseEnter:P.onMouseEnter,onMouseLeave:P.onMouseLeave,children:Q(Tl,{})})]})]})]})}import{jsx as Lo,jsxs as Dh}from"react/jsx-runtime";function Il({element:e,attributes:t,children:o}){let r=wl(null),n=wl(null),i=Bh(),a=$h(),l=W("dialog"),s=se(e.href);return Rh(()=>{let m=n.current,c=r.current;if(!m||!c)return;let d=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!d?setTimeout(()=>{l.open(()=>Lo(pt,{destAnchor:m,destStartEdge:c,element:e}))}):l.close()},[i,e]),Dh(Wa,{className:Lh({"--selected":i,"--internal-link":s}),href:s?void 0:e.href,target:s?void 0:e.target,"data-internal-link":s?"true":void 0,onClick:s?m=>m.preventDefault():void 0,...t,ref:n,children:[Lo(Ir,{ref:r,contentEditable:!1}),Lo("span",{children:o}),Lo(Ir,{contentEditable:!1})]})}import{jsx as zh}from"react/jsx-runtime";var Ml=y((e,t,{createPolicy:o})=>(e.anchor=Na(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:g(Aa,e)},editableProps:{onPaste:g(Pa,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return zh(Il,{element:r,attributes:n,children:i})}}})));import{Editor as Ro,Transforms as Sl}from"slate";import{Element as Cl,Path as Pl}from"slate";function Dr(e,t,o){if(!t||!o||Pl.equals(t[1],o[1]))return!0;let r=E(e,i=>Cl.isElement(i)&&e.isMaster(i),{at:t[1]}),n=E(e,i=>Cl.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&Pl.equals(r[1],n[1]))}var Ll=y(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=Ro.node(e,e.selection),o=Ro.previous(e,{mode:"lowest"});return Dr(e,t,o)?!1:(Sl.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=Ro.node(e,e.selection),o=Ro.next(e,{mode:"lowest"});return Dr(e,t,o)?!1:(Sl.move(e,{unit:"character"}),!0)}}}));import{Transforms as Sg}from"slate";import{ReactEditor as Lg}from"slate-react";import{Editor as Nh,Transforms as Rl}from"slate";import{ReactEditor as Hh}from"slate-react";function Ah(e){}function Oh(e,t,o,r){let{selection:n}=e;if(Rl.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=Nh.end(e,[]);Rl.select(e,i),Hh.focus(e)}}function Bl(e){return{noop:g(Ah,e),insertImageFromUrl:g(Oh,e)}}function $l(e,t){return!1}import{useSlateStatic as Mg}from"slate-react";import Uh from"@emotion/styled";var Dl=Uh("div")`
|
|
607
607
|
display: block;
|
|
608
608
|
margin: 1em 0;
|
|
609
609
|
`;import{clsx as gg}from"clsx";import{useState as hs}from"react";import{useSelected as bg}from"slate-react";import zl from"@emotion/styled";var Nl=zl("span")`
|
|
@@ -681,7 +681,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
681
681
|
.--dragging > & {
|
|
682
682
|
transition: border-radius 250ms;
|
|
683
683
|
}
|
|
684
|
-
`;import{clsx as Kh}from"clsx";import{useCallback as Vl,useEffect as Gh,useRef as
|
|
684
|
+
`;import{clsx as Kh}from"clsx";import{useCallback as Vl,useEffect as Gh,useRef as $o}from"react";import{Transforms as _l}from"slate";import{ReactEditor as Nr,useSlateStatic as qh}from"slate-react";import{useEffect as Fh}from"react";function Al(){let e=Io();return Fh(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import Ol from"@emotion/styled";var Ul=Ol("span")`
|
|
685
685
|
position: absolute;
|
|
686
686
|
display: block;
|
|
687
687
|
/**
|
|
@@ -801,7 +801,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
801
801
|
.--small > & > .--bar-right {
|
|
802
802
|
left: calc(50% + 1px);
|
|
803
803
|
}
|
|
804
|
-
`;function
|
|
804
|
+
`;function zr({value:e,min:t,max:o}){if(!(o>=t))throw new Error("Expected max >= min but is not");return Math.max(t,Math.min(o,e))}import{ReactEditor as Wh}from"slate-react";function Bo(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function Vh(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function _h(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Bo(t.width,e)}else if(e.height>t.height)return Vh(t.height,e);return e}function Ke(e,t,o){switch(o.type){case"bounds":return _h(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function Wl(e){let t=Wh.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft,10)+parseInt(o.paddingRight,10);return t.clientWidth-r}import{Fragment as Xh,jsx as Qt,jsxs as jh}from"react/jsx-runtime";function Qh(e,t){let r=Nr.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function Kl({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=qh(),l=$o(null),s=$o(null),m=$o(null),c=$o(null);Al();let d=Wl(a),p=o.width,u=Math.min(t.width,d),h=Math.min(12,t.width),k=Vl(T=>{Ue(T),i(!0);let D=T.clientX,H=Qh(a,e).width,C={...o},B=R=>{let w=zr({value:H+R.clientX-D,min:h,max:u});C=Bo(w,t),r(C)},S=()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",S),l.current=null,s.current=null;let R=Nr.findPath(a,e),w={width:C.width,height:C.height};r(w),_l.setNodes(a,w,{at:R}),i(!1)};l.current=B,s.current=S,document.addEventListener("mousemove",B),document.addEventListener("mouseup",S)},[t.width,t.height,o.width,e]),L=Vl(T=>{Ue(T),i(!0);let D=T.changedTouches[0].clientX,P=o.width,H={...o},C=S=>{let R=S.changedTouches[0],w=zr({value:P+R.clientX-D,min:h,max:u});H=Bo(w,t),r(H)},B=()=>{document.removeEventListener("touchmove",C),document.removeEventListener("touchend",B),m.current=null,c.current=null;let S=Nr.findPath(a,e);_l.setNodes(a,{width:H.width,height:H.height},{at:S}),i(!1)};m.current=C,c.current=B,document.addEventListener("touchmove",C),document.addEventListener("touchend",B)},[t.width,t.height,o.width,e]);Gh(()=>()=>{l.current&&document.removeEventListener("mousemove",l.current),s.current&&document.removeEventListener("mouseup",s.current),m.current&&document.removeEventListener("touchmove",m.current),c.current&&document.removeEventListener("touchend",c.current)},[]);let M=Kh({"--center":p<u&&p>h,"--left":p>=u&&p>h,"--right":p<=h&&p<u,"--dragging":n,"--small":p<=64||o.height<=64});return Qt(Xh,{children:Qt(Ul,{className:M,onMouseDown:k,onTouchStart:L,children:jh(Fl,{children:[Qt("span",{className:"--bar --bar-left"}),Qt("span",{className:"--bar --bar-center"}),Qt("span",{className:"--bar --bar-right"})]})})})}import Yh from"@emotion/styled";var Gl=Yh("span")`
|
|
805
805
|
position: absolute;
|
|
806
806
|
/**
|
|
807
807
|
* The status appears with a 1px gap from the outline.
|
|
@@ -854,7 +854,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
854
854
|
}
|
|
855
855
|
display: flex;
|
|
856
856
|
gap: 0.25em;
|
|
857
|
-
`;import jl from"@emotion/styled";var
|
|
857
|
+
`;import jl from"@emotion/styled";var Do=jl("span")`
|
|
858
858
|
/* font-size: 0.75em; */
|
|
859
859
|
border-radius: 0.5em;
|
|
860
860
|
display: flex;
|
|
@@ -867,7 +867,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
867
867
|
* see the border of the buttons.
|
|
868
868
|
*/
|
|
869
869
|
outline: 1px solid white;
|
|
870
|
-
`,
|
|
870
|
+
`,dt=jl("span")`
|
|
871
871
|
font-size: 0.75em;
|
|
872
872
|
line-height: 2em;
|
|
873
873
|
padding: 0 0.625em;
|
|
@@ -921,41 +921,13 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
921
921
|
font-size: 1.33em;
|
|
922
922
|
line-height: 1em;
|
|
923
923
|
}
|
|
924
|
-
`;import{clsx as eg}from"clsx";import{useCallback as tg}from"react";import{Transforms as og}from"slate";import{ReactEditor as rg,useSlateStatic as ng}from"slate-react";import{jsx as ig}from"react/jsx-runtime";function Xl({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=ng(),a=Ke(o,n,t),l=ne({title:t.title,hotkey:`${a.width}x${a.height}`}),s=tg(()=>{let u=rg.findPath(i,e),
|
|
924
|
+
`;import{clsx as eg}from"clsx";import{useCallback as tg}from"react";import{Transforms as og}from"slate";import{ReactEditor as rg,useSlateStatic as ng}from"slate-react";import{jsx as ig}from"react/jsx-runtime";function Xl({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=ng(),a=Ke(o,n,t),l=ne({title:t.title,hotkey:`${a.width}x${a.height}`}),s=tg(()=>{let u=rg.findPath(i,e),h=Ke(o,n,t);r(h),og.setNodes(i,h,{at:u})},[e,t,o,n]),c=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),d=o.width===a.width&&o.height===a.height,p=eg({"--disabled":c,"--selected":!c&&d});return ig(dt,{className:p,onClick:c?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as Yl}from"react/jsx-runtime";function Jl({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Yl(Do,{children:n.map((i,a)=>Yl(Xl,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as sg}from"react";import{useSlateStatic as mg}from"slate-react";import{jsx as zo,jsxs as ts}from"react/jsx-runtime";var Zl=e=>ts(x,{...e,children:[zo("rect",{width:6,height:6,x:4,y:5,rx:1}),zo("path",{d:"M4 15h16M4 19h16"})]}),es=e=>ts(x,{...e,children:[zo("rect",{width:6,height:6,x:9,y:5,rx:1}),zo("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as ag,Transforms as os}from"slate";import{ReactEditor as lg}from"slate-react";function rs(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=lg.findPath(e,t);ag.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});os.setNodes(e,{type:"image-inline",...i},{at:n}),os.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as ns}from"react/jsx-runtime";function is({element:e}){let t=mg(),o=ne({title:"Inline Image",hotkey:"In a line with text"}),r=sg(()=>{e.type==="image-block"&&rs(t,e)},[t,e]);return ns(dt,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ns(es,{})})}import{useCallback as dg}from"react";import{useSlateStatic as ug}from"slate-react";import{Editor as as,Element as cg,Text as ls,Transforms as No}from"slate";import{ReactEditor as pg}from"slate-react";function ss(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=pg.findPath(e,t);as.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});No.setNodes(e,{type:"image-block",...i},{at:n});let a=E(e,k=>cg.isElement(k)&&as.isBlock(e,k)&&k.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,m=l.children,c=l.children.length,d=n.slice(-1)[0],p=m[c-1];d===c-2&&ls.isText(p)&&p.text===""&&No.removeNodes(e,{at:[...s,c-1]});let u=m[0],h=d===1&&ls.isText(u)&&u.text==="";h&&No.removeNodes(e,{at:[...s,0]}),No.liftNodes(e,{at:[...s,h?d-1:d]})})}import{jsx as ms}from"react/jsx-runtime";function cs({element:e}){let t=ug(),o=ne({title:"Block Image",hotkey:"On a line by itself"}),r=dg(()=>{e.type==="image-inline"&&ss(t,e)},[t,e]);return ms(dt,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ms(Zl,{})})}import{jsx as ps,jsxs as fg}from"react/jsx-runtime";function ds({element:e}){return fg(Do,{children:[ps(cs,{element:e}),ps(is,{element:e})]})}import{jsx as us,jsxs as hg}from"react/jsx-runtime";function fs({element:e,size:t,setSize:o,srcSize:r,presets:n}){return hg(Ql,{children:[us(ds,{element:e}),us(Jl,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as Ho,jsxs as Eg}from"react/jsx-runtime";function Ao({element:e,presets:t}){let o=e.url,r=bg(),[n,i]=hs(!1),[a,l]=hs(e.srcWidth&&e.srcHeight&&e.width&&e.height?{width:e.width,height:e.height}:null),s=e.srcWidth&&e.srcHeight?{width:e.srcWidth,height:e.srcHeight}:null,m=r&&a&&s,c=gg({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return Eg(Nl,{className:c,children:[Ho(Hl,{src:o,width:a?.width,height:a?.height}),m?Ho(fs,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?Ho(ql,{size:a}):null,m?Ho(Kl,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import kg from"@emotion/styled";import{useCallback as gs,useEffect as xg,useRef as bs}from"react";import{Transforms as yg}from"slate";import{ReactEditor as Hr,useSelected as vg,useSlate as Tg}from"slate-react";import{jsx as Ar,jsxs as Ig}from"react/jsx-runtime";var wg=kg("span")`
|
|
925
925
|
position: relative;
|
|
926
926
|
display: inline-block;
|
|
927
|
-
|
|
928
|
-
.--wiki-embed-toolbar {
|
|
929
|
-
position: absolute;
|
|
930
|
-
top: 0.25em;
|
|
931
|
-
right: 0.25em;
|
|
932
|
-
display: flex;
|
|
933
|
-
gap: 0.125em;
|
|
934
|
-
padding: 0.125em;
|
|
935
|
-
border-radius: 0.25em;
|
|
936
|
-
background: var(--shade-100);
|
|
937
|
-
box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
.--wiki-embed-toolbar button {
|
|
941
|
-
display: flex;
|
|
942
|
-
align-items: center;
|
|
943
|
-
border: 0;
|
|
944
|
-
border-radius: 0.1875em;
|
|
945
|
-
padding: 0.1875em;
|
|
946
|
-
color: var(--shade-500);
|
|
947
|
-
background: transparent;
|
|
948
|
-
cursor: pointer;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
.--wiki-embed-toolbar button:hover {
|
|
952
|
-
color: var(--shade-700);
|
|
953
|
-
background: white;
|
|
954
|
-
}
|
|
955
|
-
`;function Fo({element:e}){let t=Tg(),o=vg(),r=F("dialog"),n=gs(null),i=gs(null),a=t.wysimark.renderInternalEmbed,l=pr(e.url),s=xg(c=>{c.preventDefault(),c.stopPropagation();let d=n.current,p=i.current;if(!d||!p)return;let u=Or.findPath(t,e),g=t.anchor.convertToLink(l,{at:u});if(!g)return;let[k]=g;setTimeout(()=>{let C=d;try{C=Or.toDOMNode(t,k)}catch{}let T=C.querySelector('[contenteditable="false"]')||p;r.open(()=>dt(Co,{destAnchor:C,destStartEdge:T,element:k,initialEmbed:!0,onCancel:()=>{t.anchor.convertToEmbed(l,{at:k}),r.close()}}))})},[r,t,e,l]),m=c=>{c.preventDefault(),c.stopPropagation();let d=Or.findPath(t,e);yg.removeNodes(t,{at:d})};return bs(wg,{ref:n,contentEditable:!1,onMouseDown:s,children:[dt("span",{ref:i,style:{display:"none"}}),a?.(l),o?bs("span",{className:"--wiki-embed-toolbar",children:[dt("button",{type:"button",title:f("edit"),onMouseDown:s,children:dt(So,{width:"1em",height:"1em"})}),dt("button",{type:"button",title:f("remove"),onMouseDown:m,children:dt(Lo,{width:"1em",height:"1em"})})]}):null]})}import{jsx as Ur,jsxs as Es}from"react/jsx-runtime";function ks({element:e,attributes:t,children:o}){let r=Ig();return Ze(e.url)&&r.wysimark.renderInternalEmbed?Es("div",{...t,children:[Ur(Fo,{element:e}),o]}):Es("div",{...t,children:[Ur(Dl,{contentEditable:!1,children:Ur(Uo,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as Cg}from"slate-react";import Mg from"@emotion/styled";var xs=Mg("span")`
|
|
927
|
+
`;function Oo({element:e}){let t=Tg(),o=vg(),r=W("dialog"),n=bs(null),i=bs(null),a=t.wysimark.renderInternalEmbed,l=mr(e.url),s=gs(()=>{let c=n.current,d=i.current;if(!c||!d)return;let p=Hr.findPath(t,e),u=t.anchor.convertToLink(l,{at:p});if(!u)return;let[h]=u;setTimeout(()=>{let k=c;try{k=Hr.toDOMNode(t,h)}catch{}let L=k.querySelector('[contenteditable="false"]')||d;r.open(()=>Ar(Po,{destAnchor:k,destStartEdge:L,element:h,initialEmbed:!0,onCancel:()=>{t.anchor.convertToEmbed(l,{at:h}),r.close()}}))})},[r,t,e,l]),m=gs(()=>{let c=Hr.findPath(t,e);yg.removeNodes(t,{at:c})},[t,e]);return xg(()=>{let c=n.current,d=i.current;if(!c||!d)return;let p=t.selection&&t.selection.anchor.offset!==t.selection.focus.offset;o&&!p?setTimeout(()=>{r.open(()=>Ar(pt,{destAnchor:c,destStartEdge:d,embed:{target:io(l),onEdit:s,onRemove:m}}))}):r.close()},[o,l]),Ig(wg,{ref:n,contentEditable:!1,children:[Ar("span",{ref:i,style:{display:"none"}}),a?.(l)]})}import{jsx as Or,jsxs as Es}from"react/jsx-runtime";function ks({element:e,attributes:t,children:o}){let r=Mg();return Ze(e.url)&&r.wysimark.renderInternalEmbed?Es("div",{...t,children:[Or(Oo,{element:e}),o]}):Es("div",{...t,children:[Or(Dl,{contentEditable:!1,children:Or(Ao,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as Pg}from"slate-react";import Cg from"@emotion/styled";var xs=Cg("span")`
|
|
956
928
|
display: inline;
|
|
957
|
-
`;import{jsx as
|
|
958
|
-
`,1)[0].trim().match(/^\[!([A-Za-z0-9_-]+)\]([+-])?(?:\s+(.*))?$/);if(!r)return null;let n=r[1].toLowerCase(),i=
|
|
929
|
+
`;import{jsx as Ur,jsxs as ys}from"react/jsx-runtime";function vs({element:e,attributes:t,children:o}){let r=Pg();return Ze(e.url)&&r.wysimark.renderInternalEmbed?ys("span",{...t,style:{display:"inline-block"},children:[Ur(Oo,{element:e}),o]}):ys("span",{...t,style:{display:"inline-block"},children:[Ur(xs,{contentEditable:!1,children:Ur(Ao,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as Ts}from"react/jsx-runtime";function ws({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return Ts(ks,{element:e,attributes:t,children:o});case"image-inline":return Ts(vs,{element:e,attributes:t,children:o})}}function Rg(e){return t=>{let{dataTransfer:o}=t;if(!o.files||o.files.length===0)return!1;let r=Array.from(o.files).filter(a=>a.type.startsWith("image/"));if(r.length===0)return!1;t.preventDefault(),t.stopPropagation();let n=Lg.findEventRange(e,t);n&&Sg.select(e,n);let i=e.wysimark?.onImageChange;for(let a of r)if(i)i(a).then(l=>{l&&e.image.insertImageFromUrl(l,a.name,"")}).catch(()=>{});else{let l=new FileReader;l.onload=()=>{let s=l.result;e.image.insertImageFromUrl(s,a.name,"")},l.readAsDataURL(a)}return!0}}var Bg={maxInitialInlineImageSize:{width:64,height:64},maxInitialImageSize:{width:320,height:320},maxImageSize:{width:1024,height:1024},imageBlockPresets:[{name:"S",title:"Small",type:"bounds",width:160,height:160},{name:"M",title:"Medium",type:"bounds",width:320,height:320},{name:"L",title:"Large",type:"bounds",width:640,height:640},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}],imageInlinePresets:[{name:"16",title:"16 pixels",type:"bounds",width:16,height:16},{name:"24",title:"24 pixels",type:"bounds",width:24,height:24},{name:"32",title:"32 pixels",type:"bounds",width:32,height:32},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}]},Is=y((e,t,{createPolicy:o})=>{let r={...Bg,...t.image};return e.image={...Bl(e),maxInitialInlineImageSize:r.maxInitialInlineImageSize,maxInitialImageSize:r.maxInitialImageSize,maxImageSize:r.maxImageSize,imageBlockPresets:r.imageBlockPresets,imageInlinePresets:r.imageInlinePresets},o({name:"image",editor:{isVoid:n=>{if(["image-block","image-inline"].includes(n.type))return!0},isInline:n=>{if(n.type==="image-inline")return!0},normalizeNode:g($l,e)},editableProps:{renderElement:ws,onDrop:Rg(e)}})});import{Editor as ut,Element as Ee,Transforms as ft}from"slate";import{ReactEditor as zs,useFocused as Ag,useSlateStatic as Og}from"slate-react";import{Element as $g,Node as Dg}from"slate";var zg=new Set(["note","abstract","info","todo","tip","success","question","warning","failure","danger","bug","example","quote"]),Ng={summary:"abstract",tldr:"abstract",hint:"tip",important:"tip",check:"success",done:"success",help:"question",faq:"question",caution:"warning",attention:"warning",fail:"failure",missing:"failure",error:"danger",cite:"quote"},Ms={note:"i",abstract:"\u2261",info:"i",todo:"\u2713",tip:"\u2691",success:"\u2713",question:"?",warning:"!",failure:"\xD7",danger:"!",bug:"\u25CF",example:"\u25A1",quote:"\u201C"};function Hg(e){return e.split("-").filter(Boolean).map(t=>`${t.charAt(0).toUpperCase()}${t.slice(1)}`).join(" ")}function Cs(e){let t=e.children[0];if(!$g.isElement(t)||t.type!=="paragraph")return null;let r=Dg.string(t).split(`
|
|
930
|
+
`,1)[0].trim().match(/^\[!([A-Za-z0-9_-]+)\]([+-])?(?:\s+(.*))?$/);if(!r)return null;let n=r[1].toLowerCase(),i=Ng[n]||n,a=zg.has(i)?i:"note",l=r[2]==="+"?"open":r[2]==="-"?"closed":void 0,s=r[3]?.trim()||Hg(n);return{type:a,displayType:n,title:s,fold:l,icon:Ms[a]||Ms.note}}import Ne from"@emotion/styled";var Ps=Ne("blockquote")`
|
|
959
931
|
position: relative;
|
|
960
932
|
margin-top: 1em;
|
|
961
933
|
margin-bottom: 1em;
|
|
@@ -1073,8 +1045,8 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1073
1045
|
margin-right: 0.5em;
|
|
1074
1046
|
color: var(--shade-400);
|
|
1075
1047
|
}
|
|
1076
|
-
`;import{jsx as ht,jsxs as Hs}from"react/jsx-runtime";function
|
|
1077
|
-
`),a=i.join(""),l=
|
|
1048
|
+
`;import{jsx as ht,jsxs as Hs}from"react/jsx-runtime";function Ug({element:e,attributes:t,children:o}){let r=Og(),n=Cs(e),i=Ag(),a=Ma(e),l=i&&a;function s(m){let c=m.target;if(c instanceof HTMLElement&&c.closest(".wysimark-callout-body"))return;m.preventDefault();let d=zs.findPath(r,e);ft.select(r,ut.start(r,d)),zs.focus(r)}return n&&!l?Hs(Ss,{...t,"data-callout":n.type,"data-callout-source-type":n.displayType,"data-callout-fold":n.fold,onMouseDown:s,children:[Hs(Ls,{className:"wysimark-callout-title",contentEditable:!1,"data-fold":n.fold,children:[ht(Bs,{children:n.fold==="closed"?"\u203A":n.fold==="open"?"\u2304":null}),ht(Rs,{children:n.icon}),ht(Ds,{children:n.title})]}),ht($s,{className:"wysimark-callout-body",children:o})]}):ht(Ps,{...t,children:o})}function Ns(e){return Ee.isElement(e)&&(e.type==="paragraph"||e.type==="code-block"||e.type==="table"||e.type==="horizontal-rule"||e.type==="task-list-item"||e.type==="unordered-list-item"||e.type==="ordered-list-item"||e.type==="heading")}var Fg=2,As=y(e=>{e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{ft.wrapNodes(e,{type:"block-quote",children:[]},{match:Ns})},outdent:()=>{ft.liftNodes(e,{match:(r,n)=>Ns(r)&&n.length>1})},isActive:()=>{let[r]=ut.nodes(e,{match:n=>Ee.isElement(n)&&n.type==="block-quote"});return!!r},increaseDepth:()=>{let[r]=ut.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r||!e.blockQuotePlugin.canIncreaseDepth())return;let[,n]=r;ft.select(e,n),ft.wrapNodes(e,{type:"block-quote",children:[]},{at:n,split:!1})},decreaseDepth:()=>{let[r]=ut.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r||!e.blockQuotePlugin.canDecreaseDepth())return;let[n,i]=r,a=n.children;a.length===1&&Ee.isElement(a[0])&&a[0].type==="block-quote"&&ft.unwrapNodes(e,{at:[...i,0],match:l=>Ee.isElement(l)&&l.type==="block-quote"})},canIncreaseDepth:()=>{let[r]=ut.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r)return!1;let[n]=r,i=0,a=n;for(;a.children.length===1&&Ee.isElement(a.children[0])&&a.children[0].type==="block-quote";)i++,a=a.children[0];return i<Fg},canDecreaseDepth:()=>{let[r]=ut.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r)return!1;let[n]=r;return n.children.length===1&&Ee.isElement(n.children[0])&&n.children[0]&&n.children[0].type==="block-quote"}};let t=Eo(e,{">":e.blockQuotePlugin.indent}),o=_({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent});return{name:"block-quote",editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="block-quote")return ht(Ug,{element:r,attributes:n,children:i})},onKeyDown:r=>!!(o(r)||t(r))}}});import{Editor as Eb,Element as kb,Transforms as Em}from"slate";import Wg from"prismjs";import{Element as Kg,Node as Gg}from"slate";var{languages:Vg,tokenize:_g}=Wg;function qg(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function Os(e){let[t,o]=e;if(!Kg.isElement(t))return[];if(t.type!=="code-block")return[];let r=Vg[t.language];if(r===void 0)return[];let i=t.children.map(p=>`${Gg.string(p)}
|
|
1049
|
+
`),a=i.join(""),l=qg(i);function s(p){for(let u=l.length-1;u>=0;u--){let h=l[u];if(h<=p)return{path:[...o,u],offset:p-h}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let m=[],c=_g(a,r),d=0;for(let p of c)if(typeof p=="string")d+=p.length;else{let u=s(d),h=s(d+p.length);m.push({anchor:u,focus:h,prismToken:p.type}),d+=p.length}return m}function Us(e,{language:t}){xa(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as Qg,Transforms as jg}from"slate";function Fs(e,t,o={}){let r=E(e,n=>Qg.isElement(n)&&n.type==="code-block",{at:o.at});return r?(jg.setNodes(e,{language:t},{at:r[1]}),!0):!1}function Ws(e){return{createCodeBlock:g(Us,e),setCodeBlockLanguage:g(Fs,e)}}var Uo={color:"#999988",fontStyle:"italic"},Xg={opacity:"0.7"},Vs={color:"#e3116c"},_s={color:"#393a34"},ke={color:"#36acaa"},Fr={color:"#00a4db"},Ks={color:"#9a050f"},Gs={color:"#00009f"},Wr={fontWeight:"bold"},Yg={fontStyle:"italic"},qs={comment:Uo,prolog:Uo,doctype:Uo,cdata:Uo,namespace:Xg,string:Vs,"attr-value":Vs,puncutation:_s,operator:_s,entity:ke,url:ke,symbol:ke,number:ke,boolean:ke,variable:ke,constant:ke,property:ke,regex:ke,insert:ke,atrule:Fr,keyword:Fr,"attr-name":Fr,function:{...Ks,...Wr},delete:Ks,tag:Gs,selector:Gs,important:Wr,bold:Wr,italic:Yg};var Qs=["text","html","css","svg","mermaid","javascript","java","c"];import{Element as Vr,Node as _r,Transforms as gt}from"slate";function js(e,t){if(!Vr.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of _r.children(e,t[1]))if(Vr.isElement(o))return e.isVoid(o)?(gt.removeNodes(e,{at:r}),!0):(gt.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of _r.children(e,t[1]))if(Vr.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(gt.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(gt.removeNodes(e,{at:r}),!0):(gt.removeNodes(e,{at:r}),gt.insertNodes(e,{type:"code-block-line",children:[{text:_r.string(o)}]}),!0)}return!1}import{useCallback as pb,useRef as db}from"react";import{useFocused as ub,useSelected as fb}from"slate-react";import{jsx as Xs}from"react/jsx-runtime";var Ys=e=>Xs(x,{...e,children:Xs("path",{d:"m6 9 6 6 6-6"})});import ie from"@emotion/styled";var Kr=ie("div")`
|
|
1078
1050
|
position: relative;
|
|
1079
1051
|
background: var(--code-block-bgcolor);
|
|
1080
1052
|
margin: 1em 0;
|
|
@@ -1093,11 +1065,11 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1093
1065
|
* Otherwise they will be square.
|
|
1094
1066
|
*/
|
|
1095
1067
|
overflow-x: hidden;
|
|
1096
|
-
`,
|
|
1068
|
+
`,Gr=ie("div")`
|
|
1097
1069
|
padding: 2.25em 1em 1.5em 1em;
|
|
1098
1070
|
border-radius: 0.5em;
|
|
1099
1071
|
overflow-x: auto;
|
|
1100
|
-
`,Js=ie(
|
|
1072
|
+
`,Js=ie(Gr)`
|
|
1101
1073
|
padding-top: 1em;
|
|
1102
1074
|
`,Zs=ie("div")`
|
|
1103
1075
|
position: absolute;
|
|
@@ -1106,7 +1078,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1106
1078
|
z-index: 2;
|
|
1107
1079
|
display: flex;
|
|
1108
1080
|
gap: 0.25em;
|
|
1109
|
-
`,
|
|
1081
|
+
`,qr=ie("button")`
|
|
1110
1082
|
width: 2em;
|
|
1111
1083
|
height: 2em;
|
|
1112
1084
|
display: inline-flex;
|
|
@@ -1184,7 +1156,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1184
1156
|
display: inline-block;
|
|
1185
1157
|
width: 2em;
|
|
1186
1158
|
} */
|
|
1187
|
-
`,om=ie(
|
|
1159
|
+
`,om=ie(Kr)`
|
|
1188
1160
|
min-height: 8em;
|
|
1189
1161
|
cursor: text;
|
|
1190
1162
|
`,rm=ie("div")`
|
|
@@ -1220,8 +1192,8 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1220
1192
|
overflow: hidden;
|
|
1221
1193
|
opacity: 0;
|
|
1222
1194
|
pointer-events: none;
|
|
1223
|
-
`;import{useCallback as am}from"react";import{Transforms as
|
|
1224
|
-
`),[e.children]),[l,s]=cm(""),[m,c]=cm("");
|
|
1195
|
+
`;import{useCallback as am}from"react";import{Transforms as Jg}from"slate";import{ReactEditor as lm,useSlateStatic as Zg}from"slate-react";import{jsx as mm,jsxs as eb}from"react/jsx-runtime";async function sm(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API is unavailable")}function Fo({element:e}){let t=Zg(),o=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{}},[e]),r=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{return}let i=lm.findPath(t,e);Jg.removeNodes(t,{at:i}),lm.focus(t)},[t,e]);return eb(Zs,{contentEditable:!1,children:[mm(qr,{"aria-label":"Copy code block",title:"Copy",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:o,children:"\u29C9"}),mm(qr,{"aria-label":"Cut code block",title:"Cut",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:r,children:"\u2702"})]})}import{useEffect as tb,useMemo as ob,useState as cm}from"react";import dm from"mermaid";import{Editor as rb,Node as nb,Transforms as ib}from"slate";import{ReactEditor as pm,useFocused as ab,useSelected as lb,useSlateStatic as sb}from"slate-react";import{jsx as bt,jsxs as cb}from"react/jsx-runtime";dm.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default"});var mb=0;function um({element:e,attributes:t,children:o}){let r=sb(),n=lb(),i=ab(),a=ob(()=>e.children.map(p=>nb.string(p)).join(`
|
|
1196
|
+
`),[e.children]),[l,s]=cm(""),[m,c]=cm("");tb(()=>{let p=!1,u=`wysimark-mermaid-${++mb}`;c(""),s("");async function h(){try{let k=await dm.render(u,a);p||s(k.svg)}catch(k){p||c(k instanceof Error?k.message:"Invalid Mermaid diagram")}}return h(),()=>{p=!0}},[a]);function d(p){p.preventDefault(),p.stopPropagation();let u=pm.findPath(r,e);ib.select(r,rb.start(r,u)),pm.focus(r)}return cb(om,{...t,onMouseDown:d,children:[n&&i?bt(Fo,{element:e}):null,bt(rm,{contentEditable:!1,onMouseDown:d,children:m?bt(nm,{children:m}):l?bt("div",{dangerouslySetInnerHTML:{__html:l}}):bt("span",{children:"Rendering diagram..."})}),bt(im,{"aria-hidden":"true",children:o})]})}import{Fragment as hb,jsx as He,jsxs as Qr}from"react/jsx-runtime";function fm({element:e,attributes:t,children:o}){let r=db(null),n=fb(),i=ub(),a=Ca(e),l=i&&a,s=W("code-block-dropdown"),m=pb(()=>{s.layer&&s.close();let c=r.current;if(c===null)return;let d=Qs.map(p=>({icon:()=>He("span",{}),title:p,action:u=>{u.codeBlock.setCodeBlockLanguage(p,{at:e})}}));s.open(()=>He(ct,{dest:c,items:d,close:s.close}))},[s,e]);return e.language.toLowerCase()==="mermaid"&&!l?He(um,{element:e,attributes:t,children:o}):Qr(Kr,{className:n?"--selected":"",...t,children:[n&&i?He(Fo,{element:e}):null,l?He(Js,{children:o}):Qr(hb,{children:[Qr(em,{contentEditable:!1,onClick:m,ref:r,children:[He("span",{children:e.language}),He(Ys,{})]}),He(Gr,{children:o})]})]})}import{useSelected as gb}from"slate-react";import{jsx as bb}from"react/jsx-runtime";function hm({attributes:e,children:t}){let o=gb();return bb(tm,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as gm}from"react/jsx-runtime";function bm({element:e,attributes:t,children:o}){if(e.type==="code-block")return gm(fm,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return gm(hm,{element:e,attributes:t,children:o})}import{Fragment as xb,jsx as km}from"react/jsx-runtime";var xm=y((e,t,{createPolicy:o})=>{e.codeBlock=Ws(e);function r(){let{selection:n}=e;if(!ye(n))return!1;let i=E(e,"code-block");return i==null?!1:Eb.string(e,i[1])===""?(Em.removeNodes(e,{at:i[1]}),!0):!1}return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isVoid(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isMaster(n){if(n.type==="code-block")return!0},normalizeNode:g(js,e)},editableProps:{decorate:Os,onKeyDown:_({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=E(e,i=>kb.isElement(i)&&i.type==="code-block");return n?(Em.select(e,n[1]),!0):!1}}),renderElement:bm,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&qs[n.prismToken]||null;return a===null?km(xb,{children:i}):km("span",{style:a,children:i})}}})});import{Transforms as vb}from"slate";import ym from"@emotion/styled";var vm=ym("div")`
|
|
1225
1197
|
position: relative;
|
|
1226
1198
|
background-color: var(--shade-100);
|
|
1227
1199
|
border: 1px solid var(--shade-300);
|
|
@@ -1247,7 +1219,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1247
1219
|
color: var(--shade-500);
|
|
1248
1220
|
text-transform: uppercase;
|
|
1249
1221
|
letter-spacing: 0.5px;
|
|
1250
|
-
`;import{jsx as wm,jsxs as
|
|
1222
|
+
`;import{jsx as wm,jsxs as yb}from"react/jsx-runtime";function Im({attributes:e,children:t,element:o}){return yb(vm,{...e,contentEditable:!1,children:[wm(Tm,{children:"HTML"}),wm("div",{children:Dt(o.html)}),t]})}import{jsx as Tb}from"react/jsx-runtime";var Mm=y((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!ye(n))return!1;let i=E(e,"html-block");return i==null?!1:(vb.removeNodes(e,{at:i[1]}),!0)}return o({name:"html-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="html-block")return!1},isVoid(n){if(n.type==="html-block")return!0},isMaster(n){if(n.type==="html-block")return!0}},editableProps:{renderElement:({element:n,attributes:i,children:a})=>{if(n.type==="html-block")return Tb(Im,{element:n,attributes:i,children:a})}}})});import{Element as Pb}from"slate";import{Element as wb,Transforms as Ib}from"slate";function Cm(e){return wb.isElement(e)&&e.type==="paragraph"}function Pm(e,t){return lt(e,t,(o,r)=>!Cm(o[0])||!Cm(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(Ib.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as Mb,Transforms as Cb}from"slate";function jr(e,t){return Mb.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function Sm(e,t){return jr(e,t[0])?lt(e,t,(o,r)=>!jr(e,o[0])||!jr(e,r[0])?!1:(Cb.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function Lm(e,t){let[o,r]=t;return Pb.isElement(o)?!!(Sm(e,[o,r])||Pm(e,[o,r])):!1}import{clsx as Rb}from"clsx";import{useSelected as Bb}from"slate-react";import Sb from"@emotion/styled";var Rm=Sb("p")`
|
|
1251
1223
|
padding: 0;
|
|
1252
1224
|
margin: 0;
|
|
1253
1225
|
&:first-of-type {
|
|
@@ -1281,16 +1253,16 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1281
1253
|
}
|
|
1282
1254
|
border-radius: 8px;
|
|
1283
1255
|
}
|
|
1284
|
-
`;import{Node as
|
|
1285
|
-
`)},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:
|
|
1286
|
-
`)}function
|
|
1287
|
-
`),a=Z.start(e,o),l=Z.end(e,o),s=Et.isBefore(r.anchor,a)?a:Et.isAfter(r.anchor,l)?l:r.anchor,m=Et.isBefore(r.focus,a)?a:Et.isAfter(r.focus,l)?l:r.focus,c=Math.min(Z.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(Z.string(e,{anchor:a,focus:m}).length,n.length),p=Math.min(c,d),u=Math.max(c,d),
|
|
1256
|
+
`;import{Node as Lb}from"slate";function Bm(e){return e.children.length===1&&Lb.string(e.children[0]).length===0}import{jsx as $b}from"react/jsx-runtime";function $m({element:e,attributes:t,children:o}){let r=Bb(),n=Bm(e);return $b(Rm,{...t,className:Rb({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as Db}from"react/jsx-runtime";var Dm=y(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{t()},e.insertSoftBreak=()=>{e.insertText(`
|
|
1257
|
+
`)},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:g(Lm,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{if(o.type==="paragraph")return Db($m,{element:o,attributes:r,children:n})},onKeyDown:o=>o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),o.shiftKey?e.insertSoftBreak():e.insertBreak(),!0):_({"super+0":e.collapsibleParagraph.convertParagraph})(o)}}});function zm(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as Z,Element as Wo,Node as pe,Point as Et,Range as zb,Transforms as Ge}from"slate";function Nm(e,t,o){try{let r=Z.start(e,o),n=Z.end(e,o);if(Et.isBefore(t,r)||Et.isAfter(t,n))return-1;let i={anchor:r,focus:t};return Z.string(e,i).length}catch{return-1}}function Hm(e,t,o){try{let r=pe.get(e,t);if(!Wo.isElement(r))return;let n=pe.string(r),i=Math.min(o,n.length),a=Z.start(e,t),l=0,s=a.path,m=0;for(let[d,p]of pe.texts(r)){let u=d.text.length;if(l+u>=i){s=[...t,...p],m=i-l;break}l+=u}let c={path:s,offset:m};Ge.select(e,{anchor:c,focus:c})}catch{}}function Nb(e){return pe.string(e).includes(`
|
|
1258
|
+
`)}function Hb(e,t,o,r){let n=pe.string(t),i=n.split(`
|
|
1259
|
+
`),a=Z.start(e,o),l=Z.end(e,o),s=Et.isBefore(r.anchor,a)?a:Et.isAfter(r.anchor,l)?l:r.anchor,m=Et.isBefore(r.focus,a)?a:Et.isAfter(r.focus,l)?l:r.focus,c=Math.min(Z.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(Z.string(e,{anchor:a,focus:m}).length,n.length),p=Math.min(c,d),u=Math.max(c,d),h=0,k=0,L=i.length-1;for(let M=0;M<i.length;M++){let T=h+i[M].length;if(h<=p&&p<=T&&(k=M),h<=u&&u<=T){L=M;break}h=T+1}return{startLineIndex:k,endLineIndex:L}}function Ab(e,t,o,r){let n=pe.string(t);if(!n.includes(`
|
|
1288
1260
|
`))return o;let i=n.split(`
|
|
1289
|
-
`);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=
|
|
1290
|
-
`),k={...t,children:[{text:
|
|
1261
|
+
`);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=Hb(e,t,o,r),s=i.slice(0,a),m=i.slice(a,l+1),c=i.slice(l+1);return s.length===0&&c.length===0?o:(Z.withoutNormalizing(e,()=>{let d=o.slice(0,-1),p=o[o.length-1];if(c.length>0){let h=c.join(`
|
|
1262
|
+
`),k={...t,children:[{text:h}]};Ge.insertNodes(e,k,{at:[...d,p+1]})}let u=t.children.length;for(let h=u-1;h>=0;h--)Ge.removeNodes(e,{at:[...o,h]});if(s.length>0){Ge.insertNodes(e,{text:s.join(`
|
|
1291
1263
|
`)},{at:[...o,0]});let k={type:"paragraph",children:[{text:m.join(`
|
|
1292
1264
|
`)}]};Ge.insertNodes(e,k,{at:[...d,p+1]})}else Ge.insertNodes(e,{text:m.join(`
|
|
1293
|
-
`)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Am(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=
|
|
1265
|
+
`)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Am(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=zb.isCollapsed(n),s=Array.from(Z.nodes(e,{match:p=>Wo.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(s.length>0){let[,p]=s[0];i=Nm(e,n.anchor,p),a=Nm(e,n.focus,p)}if(s.length===0)return!1;let m=[];Z.withoutNormalizing(e,()=>{for(let p=s.length-1;p>=0;p--){let[u,h]=s[p];if(Nb(u)){let k=Ab(e,u,h,n);m.unshift(k)}else m.unshift(h)}});let c=m.map(p=>{try{let u=pe.get(e,p);return Wo.isElement(u)?[u,p]:null}catch{return null}}).filter(p=>p!==null);if(c.length===0)return!1;if(r&&c.every(p=>t(p[0]))?Z.withoutNormalizing(e,()=>{for(let p of c)Wt(e,{type:"paragraph"},p[1])}):Z.withoutNormalizing(e,()=>{for(let p of c)Wt(e,o,p[1])}),c.length>0&&i>=0){let[,p]=c[0];if(l)Hm(e,p,i);else if(a>=0)try{let u=pe.get(e,p);if(Wo.isElement(u)){let h=pe.string(u),k=Math.min(i,h.length),L=Math.min(a,h.length),M=Z.start(e,p),T=M.path,D=k,P=0;for(let[B,S]of pe.texts(u)){let R=B.text.length;if(P+R>=k){T=[...p,...S],D=k-P;break}P+=R}let H=M.path,C=L;P=0;for(let[B,S]of pe.texts(u)){let R=B.text.length;if(P+R>=L){H=[...p,...S],C=L-P;break}P+=R}Ge.select(e,{anchor:{path:T,offset:D},focus:{path:H,offset:C}})}}catch{Hm(e,p,i)}}return!0}function Om(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function Um(e){return{convertElementTypes:[],addConvertElementType:g(zm,e),isConvertibleElement:g(Om,e),convertElements:g(Am,e)}}var Fm=y(e=>(e.convertElement=Um(e),{name:"convert-element"}));import{Editor as Xr,Path as Ob,Range as Ub,Transforms as Wm}from"slate";function Vm(e){let t=E(e,"heading");if(!t||!e.selection||Ub.isExpanded(e.selection)||!Xr.isEnd(e,e.selection.anchor,t[1]))return!1;let o=Ob.next(t[1]);return Wm.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),Wm.select(e,{anchor:Xr.start(e,o),focus:Xr.start(e,o)}),!0}import{Editor as Fb}from"slate";function Wb(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Vb(e,t){let[o]=Fb.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function _m(e){return{convertHeading:g(Wb,e),isHeadingActive:g(Vb,e)}}import{css as _b}from"@emotion/react";import kt from"@emotion/styled";var xt=_b`
|
|
1294
1266
|
margin-top: 1em;
|
|
1295
1267
|
&:first-of-type {
|
|
1296
1268
|
margin-top: 0;
|
|
@@ -1315,7 +1287,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1315
1287
|
`,Xm=kt("h6")`
|
|
1316
1288
|
${xt}
|
|
1317
1289
|
font-size: 1em;
|
|
1318
|
-
`;import{jsx as yt}from"react/jsx-runtime";var Ym=y(e=>{e.convertElement.addConvertElementType("heading"),e.heading=_m(e);let t=
|
|
1290
|
+
`;import{jsx as yt}from"react/jsx-runtime";var Ym=y(e=>{e.convertElement.addConvertElementType("heading"),e.heading=_m(e);let t=_({"super+1":ee(e.heading.convertHeading,1,!0),"super+2":ee(e.heading.convertHeading,2,!0),"super+3":ee(e.heading.convertHeading,3,!0),"super+4":ee(e.heading.convertHeading,4,!0),"super+5":ee(e.heading.convertHeading,5,!0),"super+6":ee(e.heading.convertHeading,6,!0)}),o=Eo(e,{"#":ee(e.heading.convertHeading,1,!1),"##":ee(e.heading.convertHeading,2,!1),"###":ee(e.heading.convertHeading,3,!1),"####":ee(e.heading.convertHeading,4,!1),"#####":ee(e.heading.convertHeading,5,!1),"######":ee(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:g(Vm,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return yt(Km,{...n,children:i});case 2:return yt(Gm,{...n,children:i});case 3:return yt(qm,{...n,children:i});case 4:return yt(Qm,{...n,children:i});case 5:return yt(jm,{...n,children:i});case 6:return yt(Xm,{...n,children:i});default:{let a=r.level;throw new Error(`Expected element.level to be 1-6 but got ${a}`)}}},onKeyDown:r=>!!(t(r)||o(r))}}});import{useSelected as Gb}from"slate-react";import Kb from"@emotion/styled";var Jm=Kb("hr")`
|
|
1319
1291
|
position: relative;
|
|
1320
1292
|
height: 1em;
|
|
1321
1293
|
/* background-color: var(--hr-color); */
|
|
@@ -1345,7 +1317,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1345
1317
|
outline: 2px solid var(--select-color, blue);
|
|
1346
1318
|
}
|
|
1347
1319
|
}
|
|
1348
|
-
`;import{jsx as Zm,jsxs as
|
|
1320
|
+
`;import{jsx as Zm,jsxs as qb}from"react/jsx-runtime";function ec({attributes:e,children:t}){let o=Gb();return qb("div",{...e,draggable:!0,children:[t,Zm("div",{contentEditable:!1,children:Zm(Jm,{className:o?"--selected":""})})]})}import{Editor as Yr,Element as Qb,Path as tc,Transforms as Vo}from"slate";function jb(e){let{selection:t}=e;if(!t)return!1;let o=E(e,i=>Qb.isElement(i)&&e.isMaster(i)),r={type:"horizontal-rule",children:[{text:""}]},n={type:"paragraph",children:[{text:""}]};if(o==null)Yr.withoutNormalizing(e,()=>{Vo.insertNodes(e,[r,n]),Vo.move(e)});else{let i=tc.next(o[1]);Yr.withoutNormalizing(e,()=>{Vo.insertNodes(e,[r,n],{at:i});let a=tc.next(i);Vo.select(e,Yr.start(e,a))})}return!0}function oc(e){return{insertHorizontalRule:g(jb,e)}}import{jsx as Xb}from"react/jsx-runtime";var rc=y((e,t,{createPolicy:o})=>(e.horizontalRule=oc(e),o({name:"horizontal-rule",editor:{isVoid(r){if(r.type==="horizontal-rule")return!0}},editableProps:{renderElement:r=>{if(r.element.type==="horizontal-rule")return Xb(ec,{...r})},onKeyDown:_({"super+-":e.horizontalRule.insertHorizontalRule})}})));import nc from"@emotion/styled";var ic=nc("code")`
|
|
1349
1321
|
color: var(--shade-600);
|
|
1350
1322
|
background-color: var(--inline-code-bgcolor);
|
|
1351
1323
|
border: 1px solid var(--inline-code-border-color);
|
|
@@ -1366,16 +1338,16 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1366
1338
|
*/
|
|
1367
1339
|
font-size: 0.75em;
|
|
1368
1340
|
vertical-align: baseline;
|
|
1369
|
-
`,
|
|
1341
|
+
`,Jr=nc("span")`
|
|
1370
1342
|
display: inline-block;
|
|
1371
1343
|
opacity: 0;
|
|
1372
1344
|
width: 1px;
|
|
1373
1345
|
overflow: hidden;
|
|
1374
|
-
`;import{jsx as ac,jsxs as
|
|
1346
|
+
`;import{jsx as ac,jsxs as Yb}from"react/jsx-runtime";var lc=y(e=>{if(!e.marksPlugin)throw new Error("InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin");return e.inlineCode={toggleInlineCode:()=>e.marksPlugin.toggleMark("code")},{name:"inline-code",editableProps:{renderLeaf:({leaf:t,children:o})=>t.code?Yb(ic,{spellCheck:!1,children:[ac(Jr,{contentEditable:!1,children:"|"}),o,ac(Jr,{contentEditable:!1,children:"|"})]}):o,onKeyDown:_({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as jt,Element as fE,Range as hE,Transforms as Bc}from"slate";function sc(e,t){return e.convertElement.convertElements(o=>o.type==="ordered-list-item",o=>({type:"ordered-list-item",depth:"depth"in o?o.depth:0}),t)}function mc(e,t){return e.convertElement.convertElements(o=>o.type==="task-list-item",o=>({type:"task-list-item",checked:"checked"in o?o.checked:!1,depth:"depth"in o?o.depth:0}),t)}function cc(e,t){return e.convertElement.convertElements(o=>o.type==="unordered-list-item",o=>({type:"unordered-list-item",depth:"depth"in o?o.depth:0}),t)}var Jb=2;function _o(e){let t=E(e,V);return t?t[0].depth:0}function Zr(e){return Fe(e,V)?_o(e)<Jb:!1}function en(e){return Fe(e,V)?_o(e)>0:!1}function pc(e){Zr(e)&&e.list.indent()}function dc(e){en(e)&&e.list.outdent()}function uc(e){return ko(e,t=>({depth:t.depth+1}),{match:V})}import{Editor as Zb,Transforms as tn}from"slate";function fc(e){let t=E(e,V);if(!t)return!1;let[o,r]=t;if(Zb.isEmpty(e,o))return o.depth>0?(tn.setNodes(e,{depth:o.depth-1},{at:r}),!0):(Wt(e,{type:"paragraph"},r),!0);tn.splitNodes(e,{always:!0});let n=E(e,V);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&tn.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as eE}from"slate";function hc(e){let t=Array.from(eE.nodes(e,{match:V}));for(let o of t)if(o[0].depth===0)return!0;return ko(e,o=>({depth:Math.max(0,o.depth-1)}),{match:V})}import{Transforms as tE}from"slate";function gc(e,{at:t=e.selection}={}){let o=E(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;return tE.setNodes(e,{checked:r},{at:o[1]}),!0}function bc(e){return{indent:g(uc,e),outdent:g(hc,e),convertUnorderedList:g(cc,e),convertOrderedList:g(sc,e),convertTaskList:g(mc,e),insertBreak:g(fc,e),toggleTaskListItem:g(gc,e),getListDepth:g(_o,e),canIncreaseDepth:g(Zr,e),canDecreaseDepth:g(en,e),increaseDepth:g(pc,e),decreaseDepth:g(dc,e)}}import{Element as oE,Transforms as rE}from"slate";var Ec=bo(["ordered-list-item"]);function Ko(e,t){let[o,r]=t;return oE.isElement(o)?lt(e,[o,r],(n,i)=>{if(!Ec(i[0]))return!1;let a=Ec(n[0])||V(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(rE.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function kc(e,t){let[o]=t;return V(o)?Ko(e,t):!1}import{clsx as iE}from"clsx";import{useEffect as aE}from"react";import{ReactEditor as lE,useSlateStatic as sE}from"slate-react";import Go from"@emotion/styled";var on=Go("li")`
|
|
1375
1347
|
margin-top: 0.5em;
|
|
1376
1348
|
margin-bottom: 0.5em;
|
|
1377
1349
|
list-style-position: outside;
|
|
1378
|
-
`,xc=
|
|
1350
|
+
`,xc=Go(on)`
|
|
1379
1351
|
position: relative;
|
|
1380
1352
|
list-style-type: none;
|
|
1381
1353
|
.--list-item-icon {
|
|
@@ -1385,7 +1357,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1385
1357
|
line-height: 1.5em;
|
|
1386
1358
|
color: var(--shade-600);
|
|
1387
1359
|
}
|
|
1388
|
-
`,yc=
|
|
1360
|
+
`,yc=Go(on)`
|
|
1389
1361
|
position: relative;
|
|
1390
1362
|
list-style-type: none;
|
|
1391
1363
|
counter-increment: var(--list-item-var);
|
|
@@ -1410,7 +1382,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1410
1382
|
/* force numbers to be monospaced for better alignment */
|
|
1411
1383
|
font-variant-numeric: tabular-nums;
|
|
1412
1384
|
}
|
|
1413
|
-
`,vc=
|
|
1385
|
+
`,vc=Go(on)`
|
|
1414
1386
|
position: relative;
|
|
1415
1387
|
list-style-type: none;
|
|
1416
1388
|
.--list-item-icon {
|
|
@@ -1424,7 +1396,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1424
1396
|
stroke-width: 3px;
|
|
1425
1397
|
}
|
|
1426
1398
|
}
|
|
1427
|
-
`;import{jsx as
|
|
1399
|
+
`;import{jsx as mE}from"react/jsx-runtime";function Tc({element:e,attributes:t,children:o}){let r=sE();aE(()=>{let a=lE.findPath(r,e);Ko(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=iE({"--first-at-depth":e.__firstAtDepth});return mE(yc,{...t,className:i,style:n,children:o})}import{useCallback as cE}from"react";import{useSlateStatic as pE}from"slate-react";import{jsx as qe,jsxs as Cc}from"react/jsx-runtime";var wc=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Ic=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),qe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Mc=e=>qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:qe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as rn,jsxs as dE}from"react/jsx-runtime";function Pc({element:e,attributes:t,children:o}){let r=pE(),n=cE(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return dE(vc,{...t,style:{marginLeft:i},children:[rn("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?rn(Ic,{onClick:n,style:{cursor:"pointer"}}):rn(wc,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Sc,jsxs as uE}from"react/jsx-runtime";function Lc({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return uE(xc,{...t,style:{marginLeft:r},children:[Sc("div",{className:"--list-item-icon",contentEditable:!1,children:Sc(Mc,{})}),o]})}import{jsx as nn}from"react/jsx-runtime";function Rc({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return nn(Tc,{element:e,attributes:t,children:o});case"unordered-list-item":return nn(Lc,{element:e,attributes:t,children:o});case"task-list-item":return nn(Pc,{element:e,attributes:t,children:o})}}var $c=["unordered-list-item","ordered-list-item","task-list-item"],V=bo($c);function gE(e,t){if(t!==" "||!e.selection||!hE.isCollapsed(e.selection))return!1;let[o]=Array.from(jt.nodes(e,{match:s=>fE.isElement(s)&&s.type==="paragraph",mode:"lowest"}));if(!o)return!1;let[,r]=o,i={anchor:jt.start(e,r),focus:e.selection.anchor},a=jt.string(e,i),l=/^-\s+\[([ xX])\]$/.exec(a);return l?(jt.withoutNormalizing(e,()=>{Bc.delete(e,{at:i}),e.convertElement.convertElements(s=>s.type==="task-list-item",s=>({type:"task-list-item",checked:l[1].toLowerCase()==="x",depth:"depth"in s&&typeof s.depth=="number"?s.depth:0}),!1)}),!0):!1}var Dc=y((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType($c);let r=e.list=bc(e),n=_({tab:r.indent,"shift+tab":r.outdent,"super+7":g(r.convertOrderedList,!0),"super+8":g(r.convertUnorderedList,!0),"super+9":g(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>kc(e,i),insertText:i=>gE(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!Fe(e,V))return!1;let a=E(e,V);if(!a)return!1;let[l,s]=a;return l.depth>0?(Bc.setNodes(e,{depth:l.depth-1},{at:s}),!0):(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:Rc,onKeyDown(i){return jt.nodes(e,{match:V})?n(i):!1}}})});import{clsx as vE}from"clsx";import{Editor as an,Range as TE}from"slate";import{Editor as bE,Text as zc,Transforms as EE}from"slate";function Nc(e,{at:t=e.selection}={}){if(t==null)return;let o=[...bE.nodes(e,{match:n=>zc.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);EE.setNodes(e,r,{match:n=>zc.isText(n),split:!0,at:t})}import{Editor as Qe,Point as kE,Range as xE}from"slate";function je(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=xE.isRange(r)?r.focus:r,i=kE.isPoint(n)&&(Qe.after(e,n)===null||Qe.isEnd(e,n,Qe.end(e,[]))),a=t,s=(Qe.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:m,...c}=e.activeMarks||{};e.activeMarks=c}s?Qe.removeMark(e,a):Qe.addMark(e,a,!0),typeof o=="string"&&Qe.removeMark(e,o)}function Hc(e){return{removeMarks:g(Nc,e),toggleMark:g(je,e),toggleBold:()=>je(e,"bold"),toggleItalic:()=>je(e,"italic"),toggleUnderline:()=>je(e,"underline"),toggleStrike:()=>je(e,"strike"),toggleHighlight:()=>je(e,"highlight")}}import yE from"@emotion/styled";var Ac=yE("span")`
|
|
1428
1400
|
&.--bold {
|
|
1429
1401
|
font-weight: bold;
|
|
1430
1402
|
}
|
|
@@ -1447,7 +1419,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1447
1419
|
&.--highlight {
|
|
1448
1420
|
background-color: #ffff00;
|
|
1449
1421
|
}
|
|
1450
|
-
`;import{jsx as
|
|
1422
|
+
`;import{jsx as wE}from"react/jsx-runtime";var Oc=y(e=>{e.marksPlugin=Hc(e),e.activeMarks={};let t=_({"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike,"mod+h":e.marksPlugin.toggleHighlight}),{insertText:o}=e;e.insertText=n=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:i}=e;Object.entries(i).forEach(([a,l])=>{l&&e.addMark(a,!0)})}o(n)};let{removeMarks:r}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(r(),e.selection&&TE.isRange(e.selection)){let n=e.selection.focus;(an.after(e,n)===null||an.isEnd(e,n,an.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>wE(Ac,{className:vE({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike,"--highlight":n.highlight}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as Xt,Point as Uc}from"slate";function Fc(e){if(!e.selection)return;let t=Xt.parent(e,e.selection);fa(e,t[1])}var Wc=y(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.start(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.end(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1}},editableProps:{}}));import{Element as pk}from"slate";import{Editor as _c,Path as CE,Transforms as Kc}from"slate";import{Editor as IE,Path as ME}from"slate";function Vc(e,t,o){let r=[...IE.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=at(e,o,{at:i});for(let m of r){let c=at(e,o,{at:m});if(l&&c&&ME.equals(l,c)||l==null&&c==null)a=m;else{let d={anchor:i,focus:a};n.push(d),i=a=m,l=c}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Gc(e,t){if(e.selection==null)return!1;let[o,r]=_c.edges(e,e.selection),n=at(e,t,{at:o}),i=at(e,t,{at:r});if(!n&&!i||n&&i&&CE.equals(n,i))return!1;let a=Vc(e,e.selection,t);return _c.withoutNormalizing(e,()=>{for(let l of a)Kc.delete(e,{at:l});Kc.collapse(e,{edge:"start"})}),!0}import{Transforms as _E}from"slate";function O(e,{at:t=e.selection}={}){if(t==null)return;let o=E(e,"table-cell",{at:t});if(!o)return;let r=E(e,"table-row",{at:t});if(!r)return;let n=E(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[m,c]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:m,cellPath:c,cellIndex:c.slice(-1)[0],cellCount:l.children.length}}import{Editor as PE,Transforms as qc}from"slate";function vt(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Qc(e,{offset:t=0,at:o=e.selection}={}){let r=O(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return PE.withoutNormalizing(e,()=>{let{columns:s}=n,m=[...s],c=Math.min(l,s.length-1);m.splice(l,0,s[c]),qc.setNodes(e,{columns:m},{at:i}),n.children.forEach((d,p)=>{qc.insertNodes(e,vt(l),{at:[...i,p,l]})})}),!0}import{Transforms as SE}from"slate";function LE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function ln(e,{at:t=e.selection,offset:o=0}={}){let r=O(e,{at:t});if(!r)return!1;let n=LE(r.tableElement.columns.length);return SE.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function jc(e,{at:t}={}){return ln(e,{at:t,offset:1})}import{Editor as sn,Element as RE,Path as BE,Transforms as Yt}from"slate";function Xc(e){return[...Array(e).keys()]}function $E(e){return Xc(e).map(()=>({align:"left"}))}function DE(e,t){return{type:"table",columns:$E(e),children:Xc(t).map(()=>zE(e))}}function zE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function Yc(e,t,o,{at:r=e.selection}={}){let n=DE(t,o);return NE(e,n,{at:r})}function NE(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>RE.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;sn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:o}),n&&(Yt.select(e,n),Yt.move(e))})}else{let n=BE.next(r[1]);sn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:n}),Yt.select(e,sn.start(e,n))})}return!0}import{Path as Jc}from"slate";function Zc(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return te(e,[...i,r+1,o]),!0;try{return te(e,Jc.next(i)),!0}catch{return!1}}function ep(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return te(e,[...n,r-1,o]),!0;try{return Ea(e,Jc.previous(n)),!0}catch{return!1}}import{ReactEditor as HE}from"slate-react";function AE(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;try{return e.getRangeAt(0).getBoundingClientRect()}catch{return null}}function OE(e,t){return HE.toDOMNode(e,t).getBoundingClientRect()}function mn(e,t){let o=AE();if(!o)return!1;let r=OE(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function tp(e){let t=O(e);return t&&setTimeout(()=>{mn(e,t.cellElement)||Zc(e,t)}),!1}function op(e){let t=O(e);return t&&setTimeout(()=>{mn(e,t.cellElement)||ep(e,t)}),!1}import{Editor as rp,Transforms as cn}from"slate";import{Transforms as UE}from"slate";function Tt(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(UE.removeNodes(e,{at:t.tablePath}),!0)}function np(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return Tt(e);rp.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),cn.setNodes(e,{columns:s},{at:n}),r.children.forEach((c,d)=>{cn.removeNodes(e,{at:[...n,d,a]})});let m=rp.start(e,[...n,i,Math.min(a,l-2)]);cn.select(e,m)})}import{Editor as ip,Transforms as ap}from"slate";function lp(e,{at:t=e.selection}={}){let o=O(e,{at:t});return o===void 0?!1:o.rowCount===1?(Tt(e),!0):(ip.withoutNormalizing(e,()=>{ap.removeNodes(e,{at:o.rowPath}),ap.select(e,ip.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as FE}from"slate";function sp(e,t){let o=O(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),FE.setNodes(e,{columns:a},{at:n}),!0}import{Path as WE,Transforms as VE}from"slate";function mp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return te(e,[...a,n,o+1]),!0;if(n<i-1)return te(e,[...a,n+1,0]),!0;let l=WE.next(a);return VE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),te(e,l),!0}function cp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return te(e,[...i,n,o-1]),!0;if(n>0)return te(e,[...i,n-1,r-1]),!0}function pp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(te(e,[...a,n,o+1]),!0):n<i-1?(te(e,[...a,n+1,0]),!0):(jc(e),te(e,[...a,n+1,0]),!0)}function dp(e){return{getTableInfo:g(O,e),insertTable:g(Yc,e),insertColumn:g(Qc,e),insertRow:g(ln,e),removeTable:g(Tt,e),removeColumn:g(np,e),removeRow:g(lp,e),tabForward:g(mp,e),tabBackward:g(cp,e),shiftEnterForward:g(pp,e),selectCell:g(KE,e),down:g(tp,e),up:g(op,e),setTableColumnAlign:g(sp,e)}}function KE(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return _E.select(e,r),!0}import{Transforms as GE}from"slate";function qo(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(GE.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as qE,Transforms as pn}from"slate";function up(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(qE.withoutNormalizing(e,()=>{pn.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)pn.mergeNodes(e,{at:[...r,n]});pn.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as jE}from"react";import{ReactEditor as XE,useSelected as YE,useSlateStatic as JE}from"slate-react";import jo from"@emotion/styled";import we from"@emotion/styled";var fp=we("div")`
|
|
1451
1423
|
position: absolute;
|
|
1452
1424
|
/**
|
|
1453
1425
|
* very slightly shaded
|
|
@@ -1567,22 +1539,22 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1567
1539
|
&:hover {
|
|
1568
1540
|
color: royalblue;
|
|
1569
1541
|
}
|
|
1570
|
-
`,
|
|
1542
|
+
`,Qo=we(xp)`
|
|
1571
1543
|
color: #c0c0c0;
|
|
1572
1544
|
&:hover {
|
|
1573
1545
|
color: firebrick;
|
|
1574
1546
|
}
|
|
1575
|
-
`;var yp=
|
|
1547
|
+
`;var yp=jo("table")`
|
|
1576
1548
|
border-collapse: collapse;
|
|
1577
1549
|
margin: 1em 0;
|
|
1578
1550
|
${({columns:e})=>e.map((t,o)=>`td:nth-of-type(${o+1}) { text-align: ${t.align}; }`).join(`
|
|
1579
1551
|
`)}
|
|
1580
|
-
`,vp=
|
|
1552
|
+
`,vp=jo("tr")`
|
|
1581
1553
|
position: relative;
|
|
1582
1554
|
&:first-of-type {
|
|
1583
1555
|
background: var(--table-head-bgcolor);
|
|
1584
1556
|
}
|
|
1585
|
-
`,Tp=
|
|
1557
|
+
`,Tp=jo("td")`
|
|
1586
1558
|
position: relative;
|
|
1587
1559
|
border-width: 1px;
|
|
1588
1560
|
border-style: solid;
|
|
@@ -1602,7 +1574,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1602
1574
|
&:last-of-type {
|
|
1603
1575
|
border-right-color: var(--table-border-color);
|
|
1604
1576
|
}
|
|
1605
|
-
`,wp=
|
|
1577
|
+
`,wp=jo("div")`
|
|
1606
1578
|
/**
|
|
1607
1579
|
* Smaller font inside a table than outside of it
|
|
1608
1580
|
*/
|
|
@@ -1614,7 +1586,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1614
1586
|
color: rgba(0, 0, 0, 0.6);
|
|
1615
1587
|
font-size: 0.875em; /* 14px */
|
|
1616
1588
|
}
|
|
1617
|
-
`;import{createContext as
|
|
1589
|
+
`;import{createContext as QE}from"react";var Xo=QE({isSelected:!1});import{jsx as dn}from"react/jsx-runtime";function Ip({element:e,attributes:t,children:o}){let r=JE(),n=YE();return jE(()=>{try{let i=XE.findPath(r,e);qo(r,[e,i])}catch{}},[]),dn(Xo.Provider,{value:{isSelected:n},children:dn(yp,{...t,columns:e.columns,children:dn("tbody",{children:o})})})}import{useContext as ak}from"react";import{useSelected as lk}from"slate-react";import{useCallback as un,useRef as ZE,useState as ek}from"react";import{useSlateStatic as tk}from"slate-react";import{jsx as ae}from"react/jsx-runtime";var It=e=>ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:ae("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z",clipRule:"evenodd"})}),Yo=e=>ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:ae("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z",clipRule:"evenodd"})}),Jo=()=>ae(x,{children:ae("path",{d:"M4 6h16M4 12h16M4 18h16"})}),Mp=()=>ae(x,{children:ae("path",{d:"M4 6h16M4 12h10M4 18h14"})}),Cp=()=>ae(x,{children:ae("path",{d:"M4 6h16M8 12h8M6 18h12"})}),Pp=()=>ae(x,{children:ae("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as ok,jsx as Ie,jsxs as Sp}from"react/jsx-runtime";function Lp({cellElement:e}){let t=tk(),o=W("column-menu"),r=ZE(null),[n,i]=ek(!1),a=un(()=>{i(!0)},[]),l=un(()=>{i(!1)},[]),s=un(()=>{o.layer&&o.close();let m=r.current;if(m===null)return;let c=[{icon:Mp,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:Cp,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:Pp,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>Ie(ct,{dest:m,items:c,close:o.close}))},[]);return Sp(hp,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[Ie(Ep,{className:"--tile",children:Ie(Jo,{})}),n?Sp(ok,{children:[Ie(Qo,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:Ie(Yo,{})}),Ie(wt,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:Ie(It,{})}),Ie(wt,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:Ie(It,{})})]}):null]})}import{useState as rk}from"react";import{useSlateStatic as nk}from"slate-react";import{Fragment as ik,jsx as Ae,jsxs as Rp}from"react/jsx-runtime";function Bp({cellElement:e}){let t=nk(),[o,r]=rk(!1);return Rp(gp,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[Ae(kp,{className:"--tile",children:Ae(Jo,{})}),o?Rp(ik,{children:[Ae(Qo,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:Ae(Yo,{})}),Ae(wt,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:Ae(It,{})}),Ae(wt,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:Ae(It,{})})]}):null]})}import $p from"@emotion/styled";var Dp=$p("div")`
|
|
1618
1590
|
position: absolute;
|
|
1619
1591
|
/**
|
|
1620
1592
|
* very slightly shaded
|
|
@@ -1654,8 +1626,8 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1654
1626
|
height: 1.5em;
|
|
1655
1627
|
background: rgba(0, 0, 0, 0.05);
|
|
1656
1628
|
border-radius: 50%;
|
|
1657
|
-
`;import{jsx as Np}from"react/jsx-runtime";function Hp(){return Np(Dp,{contentEditable:!1,children:Np(zp,{className:"--table-menu-tile"})})}import{jsx as
|
|
1658
|
-
`),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!
|
|
1629
|
+
`;import{jsx as Np}from"react/jsx-runtime";function Hp(){return Np(Dp,{contentEditable:!1,children:Np(zp,{className:"--table-menu-tile"})})}import{jsx as fn,jsxs as sk}from"react/jsx-runtime";function Ap({element:e,attributes:t,children:o}){let r=ak(Xo),n=lk(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return sk(Tp,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?fn(Hp,{}):null,a?fn(Bp,{cellElement:e}):null,l?fn(Lp,{cellElement:e}):null]})}import{jsx as mk}from"react/jsx-runtime";function Op({attributes:e,children:t}){return mk(wp,{...e,children:t})}import{jsx as ck}from"react/jsx-runtime";function Up({attributes:e,children:t}){return ck(vp,{...e,children:t})}import{jsx as Zo}from"react/jsx-runtime";function Fp({element:e,attributes:t,children:o}){switch(e.type){case"table":return Zo(Ip,{element:e,attributes:t,children:o});case"table-row":return Zo(Up,{element:e,attributes:t,children:o});case"table-cell":return Zo(Ap,{element:e,attributes:t,children:o});case"table-content":return Zo(Op,{element:e,attributes:t,children:o})}}var Wp=y((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=dp(e),o({name:"table",editor:{deleteBackward:()=>Fe(e,"table-cell"),deleteForward:()=>ca(e,"table-cell"),deleteFragment:()=>Gc(e,["table-cell"]),insertBreak:()=>E(e,"table-cell")?(e.insertText(`
|
|
1630
|
+
`),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!pk.isElement(n))return!1;switch(n.type){case"table":return qo(e,r);case"table-cell":return up(e,r)}return!1}},editableProps:{renderElement:Fp,onKeyDown:_({tab:e.tablePlugin.tabForward,"shift+tab":e.tablePlugin.tabBackward,"shift+enter":e.tablePlugin.shiftEnterForward,down:e.tablePlugin.down,up:e.tablePlugin.up,"mod+a":e.tablePlugin.selectCell,"super+t":()=>e.tablePlugin.insertTable(3,2),"mod+shift+enter":()=>e.tablePlugin.insertRow({offset:0}),"mod+enter":()=>e.tablePlugin.insertRow({offset:1}),"super+[":()=>e.tablePlugin.insertColumn({offset:0}),"super+]":()=>e.tablePlugin.insertColumn({offset:1}),"super+backspace":e.tablePlugin.removeTable,"mod+backspace":e.tablePlugin.removeRow,"mod+shift+backspace":e.tablePlugin.removeColumn})}})));import{Global as hk}from"@emotion/react";import{css as dk}from"@emotion/react";var uk=`
|
|
1659
1631
|
--blue-50: rgb(239 246 255);
|
|
1660
1632
|
--blue-100: rgb(219 234 254);
|
|
1661
1633
|
--blue-200: rgb(191 219 254);
|
|
@@ -1666,7 +1638,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1666
1638
|
--blue-700: rgb(29 78 216);
|
|
1667
1639
|
--blue-800: rgb(30 64 175);
|
|
1668
1640
|
--blue-900: rgb(30 58 138);
|
|
1669
|
-
`,
|
|
1641
|
+
`,fk=`
|
|
1670
1642
|
--shade-50: rgb(250 250 250);
|
|
1671
1643
|
--shade-100: rgb(244 244 245);
|
|
1672
1644
|
--shade-200: rgb(228 228 231);
|
|
@@ -1677,11 +1649,11 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1677
1649
|
--shade-700: rgb(63 63 70);
|
|
1678
1650
|
--shade-800: rgb(39 39 42);
|
|
1679
1651
|
--shade-900: rgb(24 24 27);
|
|
1680
|
-
`,Vp=
|
|
1652
|
+
`,Vp=dk`
|
|
1681
1653
|
:root {
|
|
1682
1654
|
/* Tailwind Colors */
|
|
1683
|
-
${dk}
|
|
1684
1655
|
${uk}
|
|
1656
|
+
${fk}
|
|
1685
1657
|
/* Select Colors */
|
|
1686
1658
|
--select-color: var(--blue-400);
|
|
1687
1659
|
--select-editor-color: var(--blue-200);
|
|
@@ -1703,14 +1675,14 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1703
1675
|
/* Horizontal Rule Colors */
|
|
1704
1676
|
--hr-color: var(--shade-300);
|
|
1705
1677
|
}
|
|
1706
|
-
`;import{Fragment as
|
|
1678
|
+
`;import{Fragment as gk,jsx as _p,jsxs as bk}from"react/jsx-runtime";var Kp=y(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>bk(gk,{children:[_p(hk,{styles:Vp}),_p(o,{...t})]}),editableProps:{}}));import{clsx as ox}from"clsx";import{useCallback as rx,useRef as nx}from"react";import{Editor as ix,Transforms as ax}from"slate";import{ReactEditor as lx,useFocused as sx,useSlateStatic as mx}from"slate-react";import{clsx as Ek}from"clsx";import{useCallback as jp,useRef as kk,useState as xk}from"react";import{ReactEditor as yk,useSlateStatic as vk}from"slate-react";import hn from"@emotion/styled";var Gp=hn(re)`
|
|
1707
1679
|
padding: 0.5em;
|
|
1708
|
-
`,qp=
|
|
1680
|
+
`,qp=hn("div")`
|
|
1709
1681
|
display: grid;
|
|
1710
1682
|
grid-template-columns: repeat(5, 1.75em);
|
|
1711
1683
|
grid-template-rows: 1.5em;
|
|
1712
1684
|
/* grid-gap: 1px; */
|
|
1713
|
-
`,Qp=
|
|
1685
|
+
`,Qp=hn("div")`
|
|
1714
1686
|
background: var(--shade-100);
|
|
1715
1687
|
height: 1.5em;
|
|
1716
1688
|
border-radius: 0.125em;
|
|
@@ -1720,11 +1692,11 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1720
1692
|
&.--selected {
|
|
1721
1693
|
background: var(--blue-100);
|
|
1722
1694
|
}
|
|
1723
|
-
`;import{Fragment as
|
|
1695
|
+
`;import{Fragment as Tk,jsx as er,jsxs as wk}from"react/jsx-runtime";function Xp(e){return[...Array(e).keys()]}function Yp({dest:e,close:t}){let[o,r]=xk({x:0,y:0}),n=vk(),i=kk(null),a=oe({src:i,dest:e},({dest:d})=>d?{left:d.left-8,top:d.top+d.height}:{left:0,top:0}),l=Xp(5).map(d=>d+1),s=Xp(5).map(d=>d+1),m=jp((d,p)=>{r({x:d,y:p})},[r]),c=jp((d,p)=>{n.tablePlugin.insertTable(d,p),yk.focus(n),t()},[n]);return wk(Tk,{children:[er(Re,{close:t}),er(Gp,{ref:i,style:a,children:er(qp,{onMouseLeave:()=>m(0,0),children:l.map(d=>s.map(p=>{let u=p<=o.x&&d<=o.y;return er(Qp,{className:Ek({"--selected":u}),onMouseEnter:()=>m(p,d),onClick:()=>c(p,d)},`${p},${d}`)}))})})]})}import{useEffect as Qk,useRef as jk,useState as Xk}from"react";import{useSlateStatic as Yk}from"slate-react";import{jsx as b,jsxs as Mt}from"react/jsx-runtime";var Jp=()=>b(x,{children:b("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),Zp=()=>b(x,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:b("path",{d:"m2 12 4 4 4-4"})}),ed=()=>b(x,{width:"0.5em",viewBox:"6 0 12 24",children:b("path",{d:"M9 12h6M12 9v6"})}),td=()=>b(x,{children:b("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),od=()=>b(x,{children:b("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),rd=()=>b(x,{children:b("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var nd=()=>b(x,{children:b("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),gn=()=>b(x,{children:b("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),id=()=>b(x,{children:b("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var tr=()=>Mt(x,{children:[b("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),b("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var bn=()=>b(x,{children:b("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),ad=()=>Mt(x,{children:[b("path",{d:"M10 9l4 3-4 3"}),b("path",{d:"M16 9l4 3-4 3"})]});var ld=()=>b(x,{children:b("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),sd=()=>Mt(x,{children:[b("rect",{x:4,y:4,width:16,height:16,rx:2}),b("path",{d:"M4 10h16M10 4v16"})]}),md=()=>b(x,{children:b("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),cd=()=>b(x,{children:b("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),pd=()=>Mt(x,{children:[b("path",{d:"M15 8h.01"}),b("rect",{x:4,y:4,width:16,height:16,rx:3}),b("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),b("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var dd=()=>b(x,{children:b("path",{d:"M12 5v14M5 12h14"})}),ud=()=>b(x,{children:b("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),fd=()=>b(x,{children:b("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var hd=()=>Mt(x,{children:[b("path",{d:"m9 11 3 3 8-8"}),b("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),En=()=>b(x,{children:b("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),gd=()=>b(x,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),bd=()=>b(x,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})});var Ed=()=>b(x,{children:b("path",{d:"M18 6L6 18M6 6l12 12"})}),kd=()=>Mt(x,{children:[b("path",{d:"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4"}),b("path",{d:"M13.5 6.5l4 4"}),b("path",{d:"m14 19 6-6M18 15l2 2M5 21h4"})]}),xd=()=>b(x,{children:b("path",{d:"M5 12h14"})});var kn=[{icon:gd,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:bd,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],yd=[{icon:nd,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:td,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:od,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:rd,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],vd=[...yd],xn=[{icon:Jp,title:f("paragraphStyle"),more:!0,children:yd}];import{useState as Me,useRef as wd,useEffect as Mk,useCallback as yn}from"react";import{useSlateStatic as Ck}from"slate-react";import Ik from"@emotion/styled";var Td=Ik(re)`
|
|
1724
1696
|
width: 18em;
|
|
1725
1697
|
padding: 0;
|
|
1726
1698
|
overflow: hidden;
|
|
1727
|
-
`;import{Fragment as
|
|
1699
|
+
`;import{Fragment as Pk,jsx as K,jsxs as Y}from"react/jsx-runtime";function Id({dest:e,close:t}){let o=Ck(),r=wd(null),n=wd(null),[i,a]=Me({x:0,y:0}),l=yn((I,F)=>{a(ue=>({x:ue.x+I,y:ue.y+F}))},[]),s=o.wysimark?.imageDialogState,m=!!o.wysimark?.onImageChange,c=!!o.wysimark?.onFileSelect,d=s?.imageSource??(m?"file":c?"select":"url"),[p,u]=Me(s?.url??""),[h,k]=Me(s?.alt??""),[L,M]=Me(s?.title??""),[T,D]=Me(!1),[P,H]=Me(d),[C,B]=Me(!1),[S,R]=Me(s?.uploadedUrl??""),w=I=>{H(I),R(""),v("")},[U,v]=Me(""),$=yn(I=>{let F=I.target.value;k(F),T||M(F)},[T]),de=yn(I=>{M(I.target.value),D(!0)},[]);Mk(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:p,alt:h,title:L,imageSource:P,uploadedUrl:S})},[o,p,h,L,P,S]);let to=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},Rt=oe({src:r,dest:e},({src:I,dest:F},ue)=>Be(I,ue,{left:F.left-16,top:F.top+F.height},{margin:16})),nr={...Rt,left:Rt.left+i.x,top:Rt.top+i.y};function oo(I){I.preventDefault();let F=P==="file"||P==="select"?S:p;F.trim()!==""&&(o.image.insertImageFromUrl(F,h,L),to(),t())}function Je(){to(),t()}async function ir(I){let F=I.target.files?.[0];if(!(!F||!o.wysimark?.onImageChange)){v(F.name),B(!0);try{let ue=await o.wysimark.onImageChange(F);R(ue)}catch(ue){}finally{B(!1)}}}function ar(){n.current?.click()}async function z(){if(o.wysimark?.onFileSelect){B(!0);try{let I=await o.wysimark.onFileSelect();I&&R(I)}catch(I){}finally{B(!1)}}}let j=P==="file"||P==="select"?S.trim()===""||C:p.trim()==="";return Y(Pk,{children:[K(Re,{close:t}),Y(Td,{ref:r,style:nr,children:[K(De,{onDrag:l}),Y("form",{onSubmit:I=>{oo(I)},style:{padding:"8px"},children:[(m||c)&&Y("div",{style:{marginBottom:"12px"},children:[m&&Y("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[K("input",{type:"radio",name:"imageSource",value:"file",checked:P==="file",onChange:()=>w("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),c&&Y("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[K("input",{type:"radio",name:"imageSource",value:"select",checked:P==="select",onChange:()=>w("select"),style:{marginRight:"4px"}}),f("imageSourceSelect")]}),Y("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[K("input",{type:"radio",name:"imageSource",value:"url",checked:P==="url",onChange:()=>w("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),P==="url"?Y("div",{style:{marginBottom:"8px"},children:[K("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),K("input",{type:"text",value:p,onChange:I=>u(I.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:"https://example.com/image.jpg"})]}):P==="select"?Y("div",{style:{marginBottom:"8px"},children:[K("button",{type:"button",onClick:()=>{z()},disabled:C,style:{padding:"8px 16px",backgroundColor:C?"#ccc":"#0078d4",color:C?"#666":"white",border:"none",borderRadius:"4px",cursor:C?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:C?f("uploading"):f("imageSourceSelect")}),S&&K("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:Y("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",S.split("/").pop()]})})]}):Y("div",{style:{marginBottom:"8px"},children:[K("input",{ref:n,type:"file",accept:"image/*",onChange:I=>{ir(I)},style:{display:"none"}}),K("button",{type:"button",onClick:ar,disabled:C,style:{padding:"8px 16px",backgroundColor:C?"#ccc":"#0078d4",color:C?"#666":"white",border:"none",borderRadius:"4px",cursor:C?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:C?f("uploading"):f("selectFile")}),S&&K("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:Y("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",U]})})]}),Y("div",{style:{marginBottom:"8px"},children:[K("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),K("input",{type:"text",value:h,onChange:$,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageDescription")})]}),Y("div",{style:{marginBottom:"8px"},children:[K("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),K("input",{type:"text",value:L,onChange:de,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageTitle")})]}),Y("div",{style:{display:"flex",gap:"8px"},children:[K("button",{type:"submit",disabled:j,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:j?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:j?"not-allowed":"pointer",fontWeight:"bold"},children:f("register")}),K("button",{type:"button",onClick:Je,style:{padding:"8px 16px",backgroundColor:"var(--shade-100)",color:"var(--shade-700)",border:"1px solid var(--shade-300)",borderRadius:"4px",cursor:"pointer"},children:f("cancel")})]})]})]})]})}import{isHotkey as Sk}from"is-hotkey";import{useCallback as Jt,useMemo as Lk,useRef as Rk,useState as Ye}from"react";import{Editor as Bk,Range as $k}from"slate";import{ReactEditor as Dk,useSlateStatic as zk}from"slate-react";import Md from"@emotion/styled";var vn=Md("div")`
|
|
1728
1700
|
/* Center vertically and horizontally */
|
|
1729
1701
|
display: flex;
|
|
1730
1702
|
align-items: center;
|
|
@@ -1748,9 +1720,9 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1748
1720
|
font-size: 1.25em;
|
|
1749
1721
|
stroke-width: 2px;
|
|
1750
1722
|
}
|
|
1751
|
-
`,
|
|
1723
|
+
`,Tn=Md("div")`
|
|
1752
1724
|
font-size: 0.875em;
|
|
1753
1725
|
margin-top: 0.5em;
|
|
1754
1726
|
color: var(--shade-500);
|
|
1755
1727
|
line-height: 1.375;
|
|
1756
|
-
`;import{Fragment as Nk,jsx as K,jsxs as Ct}from"react/jsx-runtime";var zk=Pk("enter");function Cd({dest:e,close:t}){let o=Dk(),r=Lk(null),[n,i]=Ye({x:0,y:0}),a=Jt((v,$)=>{i(pe=>({x:pe.x+v,y:pe.y+$}))},[]),l=oe({src:r,dest:e},({src:v,dest:$},pe)=>!v||!$?{left:0,top:0}:Be(v,pe,{left:$.left-12,top:$.top+$.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=Sk(()=>{let{selection:v}=o;return v&&!Bk.isCollapsed(v)?Rk.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[g,k]=Ye(m),[C,T]=Ye(m),[M,O]=Ye("external"),[P,B]=Ye(!1),w=()=>{if(M==="internal"){let v=p.trim();if(v==="")return;let $=g.trim(),pe=$&&$!==se(v)?`${v}|${$}`:v;o.anchor.insertLink(Ce(pe),$||se(v),{select:!0})}else{let v=g.trim()||c,$=C.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:$})}$k.focus(o),t()},L=Jt(v=>{d(v.currentTarget.value)},[d]),R=Jt(v=>{let $=io(v.currentTarget.value);u($.target),$.display!==void 0&&k($.display)},[u,k]),D=Jt(v=>{let $=v.currentTarget.value;k($),P||T($)},[k,T,P]),S=Jt(v=>{T(v.currentTarget.value),B(!0)},[T]),G=v=>{zk(v)&&(v.preventDefault(),v.stopPropagation(),w())};return Ct(Nk,{children:[K(Re,{close:t}),Ct(Xa,{ref:r,style:s,children:[K(De,{onDrag:a}),Ct("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?K(Vt,{children:Ct("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[K("button",{type:"button",onClick:()=>O("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:M==="external"?"white":"transparent",color:M==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:M==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),K("button",{type:"button",onClick:()=>O("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:M==="internal"?"white":"transparent",color:M==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:M==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,K(Vt,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:M==="internal"?K(_t,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:R,onKeyDown:G}):K(_t,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:L,onKeyDown:G})}),K(Vt,{style:{marginTop:"0.5em"},children:K(_t,{type:"text",value:g,placeholder:f("linkText"),onChange:D,onKeyDown:G})}),Ct(Vt,{style:{marginTop:"0.5em"},children:[M==="external"?K(_t,{type:"text",value:C,placeholder:f("tooltipText"),onChange:S,onKeyDown:G}):K("span",{style:{flex:"1 1 auto"}}),Ct(Tn,{onClick:w,children:[K(rr,{}),K(ed,{})]}),K(Tn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:K(Ed,{})})]}),M==="external"?K(wn,{children:f("tooltipHint")}):K(wn,{children:f("internalLinkTargetHint")})]})]})]})}var In=[{icon:rr,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Cd},{icon:pd,title:f("insertImageFromUrl"),more:!0,Component:Id},{icon:sd,title:f("insertTable"),more:!0,Component:Yp},{icon:xd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Pd=In,Sd=In,Ld=[{icon:dd,title:f("insert"),more:!0,children:In}];import{Editor as Hk}from"slate";function Pt(e){let t=Hk.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Rd=[{icon:bn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Pt(e).bold},{icon:id,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Pt(e).italic},{icon:ud,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Pt(e).strike},{icon:md,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Pt(e).code},{icon:fd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Pt(e).underline},{icon:kd,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Pt(e).highlight,show:e=>!e.wysimark.disableHighlight}],Mn=Rd,Bd=[{icon:bn,title:f("format"),more:!0,children:Rd}];var $d=[{icon:ld,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:kn,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:hd,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Cn=[...$d,"divider",...xn],Dd=[{icon:kn,title:f("list"),more:!0,children:[...$d,"divider",...xn]}];import{Editor as zd,Path as Ak,Transforms as nr}from"slate";var Nd=[{icon:En,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:ad,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:cd,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=zd.string(e,r);nr.removeNodes(e,{at:r}),nr.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!Ak.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=zd.string(e,t);nr.delete(e),nr.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Pn=Nd,Hd=[{icon:En,title:f("quote"),more:!0,children:Nd}];var Ok=[...vd,"divider",...Cn,"divider",...Mn,"divider",...Pd,"divider",...Pn],Uk=[...yn,"divider",...Cn,"divider",...Mn,"divider",...Sd,"divider",...Pn],Ad=[...yn,"divider",...Dd,"divider",...Bd,"divider",...Ld,"divider",...Hd],Od=Ad;var St=[Ok,Uk,Ad];import{clsx as Fk}from"clsx";import{useCallback as Sn,useRef as Wk}from"react";import{ReactEditor as Vk,useSlate as _k,useSlateStatic as Kk}from"slate-react";import{jsx as ir,jsxs as Gk}from"react/jsx-runtime";function Ud({item:e}){let t=Kk(),o=_k(),r=e.active?e.active(o):!1,n=Wk(null),i=ne({title:e.title,hotkey:()=>e.hotkey?To(e.hotkey):void 0}),a=F("menu"),l=Sn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>ir(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>ir(p,{dest:c,close:a.close})))},[e]),s=Sn(()=>{if(e.action){e.action(t),Vk.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=Sn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return Gk(sl,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Fk({"--active":r&&!xr(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&xr(e?.title)?.includes("Depth")}),children:[ir(e.icon,{}),e.more?ir(Zp,{}):null]})}import{jsx as Lt}from"react/jsx-runtime";function Yk({item:e}){let t=Xk();return e==="divider"?Lt(al,{"data-item-type":"divider",children:Lt(ll,{})}):(e.show===void 0?!0:e.show(t))?Lt(Ud,{item:e}):null}function Jk(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function Zk(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var e0=4;function Fd(){let e=Qk(null),[t,o]=jk(Od);return qk(()=>{let r=e.current;if(!r)return;let n=()=>{let a=Jk(r);if(a){for(let l=0;l<St.length-1;l++)if(Zk(St[l],a.button,a.divider)<a.toolbar-e0){o(St[l]);return}o(St[St.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),Lt(nl,{ref:e,children:Lt(il,{children:t.map((r,n)=>Lt(Yk,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Ln,jsxs as m0}from"react/jsx-runtime";function Wd({attributes:e,Editable:t}){let o=r0(null),r=s0(),n=l0(),i=o0(a=>{a.target===a.currentTarget&&(i0.select(r,n0.end(r,[])),a0.focus(r))},[r]);return Ln(Va,{children:m0(el,{ref:o,className:t0({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Ln(Fd,{}),Ln(t,{as:Za,...e,style:{overflowY:"auto"}})]})})}var Vd=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Wd,editableProps:{}}));import{Editor as Rn,Node as c0,Path as p0,Transforms as d0}from"slate";var _d=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Rn.isEditor(t[0]))return!1;let o=[e.children.length-1],r=c0.child(e,e.children.length-1);return(Rn.hasBlocks(e,r)||Rn.isVoid(e,r))&&d0.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:p0.next(o)}),!0}}}));import{Transforms as u0}from"slate";function f0(e,t){let o=Pe(t),r=Le(o,{enableInternalLinks:e.wysimark.enableInternalLinks});u0.insertNodes(e,r)}function Kd(e){return{pasteMarkdown:h(f0,e)}}function h0(e){return e.length===1&&e[0]==="text/plain"}function g0(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Gd=y(e=>(e.pasteMarkdown=Kd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(h0(o)||g0(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as E0}from"react/jsx-runtime";function b0(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return E0("span",{...t,children:e.children})}var qd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:b0}})));var Qd=[Gd,Fm,Ml,Ym,Oc,lc,As,xm,Mm,Wp,rc,_d,Dc,Ll,Wc,Dm,Kp,Vd,Is,qd];var k0=aa(Qd),{withSink:jd,SinkEditable:Xd}=k0;import{useState as x0}from"react";import{createEditor as y0,Editor as v0,Transforms as T0}from"slate";import{withHistory as w0}from"slate-history";import{withReact as I0}from"slate-react";function Bn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d}={}){let[p]=x0(()=>{let u=y0(),g=jd(I0(w0(u)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return g.convertElement.addConvertElementType("paragraph"),u.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d},u.getMarkdown=()=>fe(u.children,{enableInternalLinks:u.wysimark.enableInternalLinks}),u.setMarkdown=k=>{let C=Pe(k),T=Le(C,{enableInternalLinks:u.wysimark.enableInternalLinks});u.children=T,u.selection=null,T0.select(u,v0.start(u,[0]))},g});return p.wysimark.renderInternalLinkPreview=m,p.wysimark.renderInternalEmbed=c,p.wysimark.onInternalLinkClick=d,p}import{jsx as le,jsxs as Jd}from"react/jsx-runtime";function R0({children:e,attributes:t}){return le("span",{...t,children:e})}function Zd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Yd(!1),[d,p]=Yd(t),u=eo(!1),g=eo(void 0),k=eo(void 0),C=eo(null),T=eo(o);T.current=o;let M=Zt(M0(()=>{let S=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:S,children:e.children},T.current(S)},r,{leading:!1,trailing:!0}),[e,r]),O=Zt(()=>{k.current!==e.children&&(k.current=e.children,M())},[M]);if(!m){let S=C.current??t;if(C.current!==null&&(C.current=null),e.wysimark.prevValue==null||g.current==null){u.current=!0;let G=Pe(S),v=Le(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,k.current=g.current=v,e.wysimark.prevValue={markdown:S,children:v}}else if(S!==e.wysimark.prevValue.markdown){u.current=!0;let G=Pe(S),v=Le(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,P0.select(e,C0.start(e,[0]))}}let P=Zt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&S0.focus(e)},[e]),B=Zt(()=>{M.flush()},[M]),w=S=>{let G=S.target.value;p(G),o(G)},L=Zt(()=>{let S=e.getMarkdown();p(S)},[e]),R=()=>{m?(C.current=d,e.wysimark.prevValue=void 0,g.current=void 0,k.current=void 0):L(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let D=e.wysimark.disableRawMode;return Jd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!D&&le("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:le("div",{onClick:R,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(R(),S.preventDefault())},children:Jd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),le("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),le("div",{style:{display:m?"block":"none",textAlign:"center"},children:le("textarea",{value:Dt(d),onChange:w,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),le("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:le(L0,{editor:e,initialValue:g.current,onChange:O,children:le(Xd,{renderLeaf:R0,onMouseDown:P,onBlur:B,placeholder:n,className:i,style:a})})})]})}import{jsx as eu}from"react/jsx-runtime";function A0({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=N0(r.initialMarkdown||""),l=z0(i),s=Bn(r);l.current=i,D0(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=$0(c=>{l.current=c,a(c),e?.(c)},[s]);return eu(Zd,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function o6(e,t){let o=B0(),r=H0(e);return r.render(eu(A0,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Zd as Editable,o6 as createWysimark,ao as unescapeMarkdown,Bn as useEditor};
|
|
1728
|
+
`;import{Fragment as Hk,jsx as G,jsxs as Ct}from"react/jsx-runtime";var Nk=Sk("enter");function Cd({dest:e,close:t}){let o=zk(),r=Rk(null),[n,i]=Ye({x:0,y:0}),a=Jt((v,$)=>{i(de=>({x:de.x+v,y:de.y+$}))},[]),l=oe({src:r,dest:e},({src:v,dest:$},de)=>!v||!$?{left:0,top:0}:Be(v,de,{left:$.left-12,top:$.top+$.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=Lk(()=>{let{selection:v}=o;return v&&!$k.isCollapsed(v)?Bk.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[h,k]=Ye(m),[L,M]=Ye(m),[T,D]=Ye("external"),[P,H]=Ye(!1),C=()=>{if(T==="internal"){let v=p.trim();if(v==="")return;let $=h.trim(),de=$&&$!==me(v)?`${v}|${$}`:v;o.anchor.insertLink(Ce(de),$||me(v),{select:!0})}else{let v=h.trim()||c,$=L.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:$})}Dk.focus(o),t()},B=Jt(v=>{d(v.currentTarget.value)},[d]),S=Jt(v=>{let $=ao(v.currentTarget.value);u($.target),$.display!==void 0&&k($.display)},[u,k]),R=Jt(v=>{let $=v.currentTarget.value;k($),P||M($)},[k,M,P]),w=Jt(v=>{M(v.currentTarget.value),H(!0)},[M]),U=v=>{Nk(v)&&(v.preventDefault(),v.stopPropagation(),C())};return Ct(Hk,{children:[G(Re,{close:t}),Ct(Qa,{ref:r,style:s,children:[G(De,{onDrag:a}),Ct("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?G(Vt,{children:Ct("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[G("button",{type:"button",onClick:()=>D("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="external"?"white":"transparent",color:T==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),G("button",{type:"button",onClick:()=>D("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="internal"?"white":"transparent",color:T==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,G(Vt,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:T==="internal"?G(_t,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:S,onKeyDown:U}):G(_t,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:B,onKeyDown:U})}),G(Vt,{style:{marginTop:"0.5em"},children:G(_t,{type:"text",value:h,placeholder:f("linkText"),onChange:R,onKeyDown:U})}),Ct(Vt,{style:{marginTop:"0.5em"},children:[T==="external"?G(_t,{type:"text",value:L,placeholder:f("tooltipText"),onChange:w,onKeyDown:U}):G("span",{style:{flex:"1 1 auto"}}),Ct(vn,{onClick:C,children:[G(tr,{}),G(ed,{})]}),G(vn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:G(Ed,{})})]}),T==="external"?G(Tn,{children:f("tooltipHint")}):G(Tn,{children:f("internalLinkTargetHint")})]})]})]})}var wn=[{icon:tr,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Cd},{icon:pd,title:f("insertImageFromUrl"),more:!0,Component:Id},{icon:sd,title:f("insertTable"),more:!0,Component:Yp},{icon:xd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Pd=wn,Sd=wn,Ld=[{icon:dd,title:f("insert"),more:!0,children:wn}];import{Editor as Ak}from"slate";function Pt(e){let t=Ak.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Rd=[{icon:gn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Pt(e).bold},{icon:id,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Pt(e).italic},{icon:ud,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Pt(e).strike},{icon:md,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Pt(e).code},{icon:fd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Pt(e).underline},{icon:kd,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Pt(e).highlight,show:e=>!e.wysimark.disableHighlight}],In=Rd,Bd=[{icon:gn,title:f("format"),more:!0,children:Rd}];var $d=[{icon:ld,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:En,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:hd,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Mn=[...$d,"divider",...kn],Dd=[{icon:En,title:f("list"),more:!0,children:[...$d,"divider",...kn]}];import{Editor as zd,Path as Ok,Transforms as or}from"slate";var Nd=[{icon:bn,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:ad,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:cd,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=zd.string(e,r);or.removeNodes(e,{at:r}),or.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!Ok.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=zd.string(e,t);or.delete(e),or.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Cn=Nd,Hd=[{icon:bn,title:f("quote"),more:!0,children:Nd}];var Uk=[...vd,"divider",...Mn,"divider",...In,"divider",...Pd,"divider",...Cn],Fk=[...xn,"divider",...Mn,"divider",...In,"divider",...Sd,"divider",...Cn],Ad=[...xn,"divider",...Dd,"divider",...Bd,"divider",...Ld,"divider",...Hd],Od=Ad;var St=[Uk,Fk,Ad];import{clsx as Wk}from"clsx";import{useCallback as Pn,useRef as Vk}from"react";import{ReactEditor as _k,useSlate as Kk,useSlateStatic as Gk}from"slate-react";import{jsx as rr,jsxs as qk}from"react/jsx-runtime";function Ud({item:e}){let t=Gk(),o=Kk(),r=e.active?e.active(o):!1,n=Vk(null),i=ne({title:e.title,hotkey:()=>e.hotkey?wo(e.hotkey):void 0}),a=W("menu"),l=Pn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>rr(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>rr(p,{dest:c,close:a.close})))},[e]),s=Pn(()=>{if(e.action){e.action(t),_k.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=Pn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return qk(al,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Wk({"--active":r&&!Er(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Er(e?.title)?.includes("Depth")}),children:[rr(e.icon,{}),e.more?rr(Zp,{}):null]})}import{jsx as Lt}from"react/jsx-runtime";function Jk({item:e}){let t=Yk();return e==="divider"?Lt(nl,{"data-item-type":"divider",children:Lt(il,{})}):(e.show===void 0?!0:e.show(t))?Lt(Ud,{item:e}):null}function Zk(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function ex(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var tx=4;function Fd(){let e=jk(null),[t,o]=Xk(Od);return Qk(()=>{let r=e.current;if(!r)return;let n=()=>{let a=Zk(r);if(a){for(let l=0;l<St.length-1;l++)if(ex(St[l],a.button,a.divider)<a.toolbar-tx){o(St[l]);return}o(St[St.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),Lt(ol,{ref:e,children:Lt(rl,{children:t.map((r,n)=>Lt(Jk,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Sn,jsxs as cx}from"react/jsx-runtime";function Wd({attributes:e,Editable:t}){let o=nx(null),r=mx(),n=sx(),i=rx(a=>{a.target===a.currentTarget&&(ax.select(r,ix.end(r,[])),lx.focus(r))},[r]);return Sn(Fa,{children:cx(Ja,{ref:o,className:ox({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Sn(Fd,{}),Sn(t,{as:Ya,...e,style:{overflowY:"auto"}})]})})}var Vd=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Wd,editableProps:{}}));import{Editor as Ln,Node as px,Path as dx,Transforms as ux}from"slate";var _d=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Ln.isEditor(t[0]))return!1;let o=[e.children.length-1],r=px.child(e,e.children.length-1);return(Ln.hasBlocks(e,r)||Ln.isVoid(e,r))&&ux.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:dx.next(o)}),!0}}}));import{Transforms as fx}from"slate";function hx(e,t){let o=Pe(t),r=Le(o,{enableInternalLinks:e.wysimark.enableInternalLinks});fx.insertNodes(e,r)}function Kd(e){return{pasteMarkdown:g(hx,e)}}function gx(e){return e.length===1&&e[0]==="text/plain"}function bx(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Gd=y(e=>(e.pasteMarkdown=Kd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(gx(o)||bx(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as kx}from"react/jsx-runtime";function Ex(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return kx("span",{...t,children:e.children})}var qd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:Ex}})));var Qd=[Gd,Fm,Ml,Ym,Oc,lc,As,xm,Mm,Wp,rc,_d,Dc,Ll,Wc,Dm,Kp,Vd,Is,qd];var xx=na(Qd),{withSink:jd,SinkEditable:Xd}=xx;import{useState as yx}from"react";import{createEditor as vx,Editor as Tx,Transforms as wx}from"slate";import{withHistory as Ix}from"slate-history";import{withReact as Mx}from"slate-react";function Rn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d}={}){let[p]=yx(()=>{let u=vx(),h=jd(Mx(Ix(u)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return h.convertElement.addConvertElementType("paragraph"),u.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d},u.getMarkdown=()=>fe(u.children,{enableInternalLinks:u.wysimark.enableInternalLinks}),u.setMarkdown=k=>{let L=Pe(k),M=Le(L,{enableInternalLinks:u.wysimark.enableInternalLinks});u.children=M,u.selection=null,wx.select(u,Tx.start(u,[0]))},h});return p.wysimark.renderInternalLinkPreview=m,p.wysimark.renderInternalEmbed=c,p.wysimark.onInternalLinkClick=d,p}import{jsx as le,jsxs as Jd}from"react/jsx-runtime";function Bx({children:e,attributes:t}){return le("span",{...t,children:e})}function Zd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Yd(!1),[d,p]=Yd(t),u=eo(!1),h=eo(void 0),k=eo(void 0),L=eo(null),M=eo(o);M.current=o;let T=Zt(Cx(()=>{let w=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:w,children:e.children},M.current(w)},r,{leading:!1,trailing:!0}),[e,r]),D=Zt(()=>{k.current!==e.children&&(k.current=e.children,T())},[T]);if(!m){let w=L.current??t;if(L.current!==null&&(L.current=null),e.wysimark.prevValue==null||h.current==null){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,k.current=h.current=v,e.wysimark.prevValue={markdown:w,children:v}}else if(w!==e.wysimark.prevValue.markdown){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,Sx.select(e,Px.start(e,[0]))}}let P=Zt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&Lx.focus(e)},[e]),H=Zt(()=>{T.flush()},[T]),C=w=>{let U=w.target.value;p(U),o(U)},B=Zt(()=>{let w=e.getMarkdown();p(w)},[e]),S=()=>{m?(L.current=d,e.wysimark.prevValue=void 0,h.current=void 0,k.current=void 0):B(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let R=e.wysimark.disableRawMode;return Jd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!R&&le("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:le("div",{onClick:S,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(S(),w.preventDefault())},children:Jd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),le("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),le("div",{style:{display:m?"block":"none",textAlign:"center"},children:le("textarea",{value:Dt(d),onChange:C,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),le("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:le(Rx,{editor:e,initialValue:h.current,onChange:D,children:le(Xd,{renderLeaf:Bx,onMouseDown:P,onBlur:H,placeholder:n,className:i,style:a})})})]})}import{jsx as eu}from"react/jsx-runtime";function Ox({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Hx(r.initialMarkdown||""),l=Nx(i),s=Rn(r);l.current=i,zx(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=Dx(c=>{l.current=c,a(c),e?.(c)},[s]);return eu(Zd,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function o6(e,t){let o=$x(),r=Ax(e);return r.render(eu(Ox,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Zd as Editable,o6 as createWysimark,lo as unescapeMarkdown,Rn as useEditor};
|