wysimark-lite 0.23.0 → 0.25.0
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 +186 -131
- package/dist/index.mjs +1337 -1021
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -13
- package/dist/index.d.ts +0 -1074
package/dist/index.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
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
|
-
`}];case"footnote":throw new Error("footnote is not supported yet")}
|
|
4
|
-
`).map(t=>({type:"code-block-line",children:[{text:t}]}))}]}function Xr(e,{depth:t,ordered:o,checked:r}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:A(e.children)}]:o?[{type:"ordered-list-item",depth:t,children:A(e.children)}]:[{type:"unordered-list-item",depth:t,children:A(e.children)}];case"list":return pt(e,t+1);default:return yo(e)}}function Jr(e,t){let o=[];for(let r of e.children)o.push(...Xr(r,{...t,checked:e.checked}));return o}function pt(e,t=0){let o=[];for(let r of e.children)o.push(...Jr(r,{depth:t,ordered:!!e.ordered}));return o}function pp(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 dp="\xA0";function up(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==dp)}function Yr(e){let t=A(e.children);return pp(t)?[{...t[1],type:"image-block"}]:up(t)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:t}]}function Zr(e){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(t=>({align:t||"left"})),children:e.children.map(fp)}]}function fp(e){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(hp)}}function hp(e){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:A(e.children)}]}}function en(){return[{type:"horizontal-rule",children:[{text:""}]}]}function Ce(e){let t=[];for(let o of e)t.push(...yo(o));return t}function yo(e){switch(e.type){case"blockquote":return Br(e);case"code":return zr(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Nr(e);case"heading":return Qr(e);case"html":return jr(e);case"list":return pt(e);case"paragraph":return Yr(e);case"table":return Zr(e);case"thematicBreak":return en();case"yaml":return[]}de(e)}import{definitions as gp}from"mdast-util-definitions";import{SKIP as tn,visit as bp}from"unist-util-visit";function on(e){let t=gp(e);bp(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[tn,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 c=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]=c,[tn,r]}}})}var yp=xp().use(Ep).use(Rr());function kp(e){let t=yp.parse(e);return on(t),t}function ue(e){let t=kp(e);return t.children.length===0?[{type:"paragraph",children:[{text:""}]}]:Ce(t.children)}function Tp(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function rn(e){let t=[],o=-1;for(let r of e){if(!Tp(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 nn(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 an(e){let t=[],o=3;for(let r of e.children){let n=nn(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(`
|
|
1
|
+
"use client";import{createRef as cE,useCallback as pE,useImperativeHandle as dE,useRef as uE,useState as fE}from"react";import{createRoot as hE}from"react-dom/client";import nE from"lodash.throttle";import{useCallback as xt,useRef as go,useState as hp}from"react";import{Editor as iE,Transforms as aE}from"slate";import{ReactEditor as lE,Slate as sE}from"slate-react";import jp from"remark-parse";import{unified as Xp}from"unified";function ko(){return{enter:{table:Mp,tableData:Dr,tableHeader:Dr,tableRow:Cp},exit:{codeText:Sp,table:Pp,tableData:yo,tableHeader:yo,tableRow:yo}}}function Mp(e){let t=e._align;this.enter({type:"table",align:t.map(function(o){return o==="none"?null:o}),children:[]},e),this.data.inTable=!0}function Pp(e){this.exit(e),this.data.inTable=void 0}function Cp(e){this.enter({type:"tableRow",children:[]},e)}function yo(e){this.exit(e)}function Dr(e){this.enter({type:"tableCell",children:[]},e)}function Sp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Rp));let o=this.stack[this.stack.length-1];o.type,o.value=t,this.exit(e)}function Rp(e,t){return t==="|"?t:e}import{gfm as Lp}from"micromark-extension-gfm";import{gfmToMarkdown as Bp}from"mdast-util-gfm";function Nr(e){if(e)return function(t){return this.data||(this.data={}),e.call(this,t)}}function $r(){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(Lp());let n=function(){let i=ko();if(i.enter)for(let a of Object.keys(i.enter))i.enter[a]=Nr(i.enter[a]);if(i.exit)for(let a of Object.keys(i.exit))i.exit[a]=Nr(i.exit[a]);return i};o.push(n()),r.push(Bp())}}function ue(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o=[],r=0,n=e.replace(t,s=>(o.push(s),`__MARKDOWN_LINK_${r++}__`)),i=/(https?:\/\/[^\s]+)/g,l=n.replace(i,s=>s.replace(/\//g,"\\/"));for(let s=0;s<o.length;s++)l=l.replace(`__MARKDOWN_LINK_${s}__`,o[s]);return l}function et(e){return e.replace(/\\(.)/g,(t,o)=>o)}function Hr(e,t){if(!e)throw new Error(`${t}`)}function kt(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 fe(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function Ar(e){return[{type:"block-quote",children:Le(e.children)}]}function Or(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 Ur(e){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...Le(e.children)]}]}import{Text as Xr}from"slate";import{Text as Qr}from"slate";import*as tt from"slate";function O(e){return tt.Text.isText(e)}function oe(e){return tt.Element.isElement(e)}function B(e){return tt.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var Fr={bold:"**",italic:"_",strike:"~~",highlight:"<mark>",code:""},Vr={bold:"**",italic:"_",strike:"~~",highlight:"</mark>",code:""};function zp(e){if(e in Fr)return Fr[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_OPEN_TOKEN lookup`)}function Dp(e){if(e in Vr)return Vr[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_CLOSE_TOKEN lookup`)}function Kr(e){return e.map(zp).join("")}function _r(e){return e.map(Dp).join("")}import{Text as Np}from"slate";function ot(e){let{text:t,...o}=e;return Object.keys(o)}function vo(e){if(Np.isText(e)){if(B(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 ot(e)}else{if(e.type==="anchor")return To(e.children);throw new Error(`Unhandled type ${e.type}`)}}function To(e){let t;for(let o of e){if(!O(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(B(o))continue;let r=ot(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}if(t===void 0)throw new Error("No text segments were found as children in this anchor which should not be possible");return t}var Wr=["bold","italic","underline","strike","highlight","code"];function Gr(e){return e.slice().sort((t,o)=>Wr.indexOf(t)-Wr.indexOf(o))}var $p=["\\","`","*","_","[","]","(",")","#","+","-",".","!","|","^","~","<",">","{","}","=",":",";","$","%","&","?",'"',"'",",","\\","/","@"],Hp=new RegExp(`(${$p.map(e=>`\\${e}`).join("|")})`,"g");function qr(e){return e.replace(Hp,t=>`\\${t}`)}function Ap(e,t){let o=ot(e),r=ot(t);return o.length==r.length&&o.every(n=>r.includes(n))}function jr(e,t){let o=Qr.isText(e),r=Qr.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:Ap(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function Yr(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...jr(e[o],r))}return t.length===0&&t.push({text:""}),Xr.isText(t[0])||t.unshift({text:""}),Xr.isText(t[t.length-1])||t.push({text:""}),t}function Jr(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var Op=/^(\/[^?#]*)(?:\?([^#]*))?(#.*)?$/;function Be(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(Op);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 rt(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1]),height:parseInt(t[2])}}function Zr(e){let t=Be(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=rt(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]),srcHeight:parseInt(n[2])}}function en(e){let t=Be(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=rt(o.get("size")),n=rt(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 tn=[Zr,en,Jr];function on(e){for(let t of tn){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 Up(e,t){let o=e.match(/^<mark>(.+?)<\/mark>$/s);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function V(e,t={}){let o=[];for(let n of e)o.push(...Fp(n,t));return Yr(o)}function Fp(e,t={}){switch(e.type){case"delete":return V(e.children,{...t,strike:!0});case"emphasis":return V(e.children,{...t,italic:!0});case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return Up(e.value,t);case"image":return on(e);case"inlineCode":return[{text:e.value,...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:V(e.children,t)}];case"strong":return V(e.children,{...t,bold:!0});case"text":return[{text: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:`
|
|
3
|
+
`}];case"footnote":throw new Error("footnote is not supported yet")}fe(e)}function rn(e){return[{type:"heading",level:e.depth,children:V(e.children)}]}function nn(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function an(e,{depth:t,ordered:o,checked:r}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:V(e.children)}]:o?[{type:"ordered-list-item",depth:t,children:V(e.children)}]:[{type:"unordered-list-item",depth:t,children:V(e.children)}];case"list":return vt(e,t+1);default:return wo(e)}}function ln(e,t){let o=[];for(let r of e.children)o.push(...an(r,{...t,checked:e.checked}));return o}function vt(e,t=0){let o=[];for(let r of e.children)o.push(...ln(r,{depth:t,ordered:!!e.ordered}));return o}function Vp(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 Kp="\xA0";function _p(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==Kp)}function sn(e){let t=V(e.children);return Vp(t)?[{...t[1],type:"image-block"}]:_p(t)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:t}]}function mn(e){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(t=>({align:t||"left"})),children:e.children.map(Wp)}]}function Wp(e){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(Gp)}}function Gp(e){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:V(e.children)}]}}function cn(){return[{type:"horizontal-rule",children:[{text:""}]}]}function Le(e){let t=[];for(let o of e)t.push(...wo(o));return t}function wo(e){switch(e.type){case"blockquote":return Ar(e);case"code":return Or(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Ur(e);case"heading":return rn(e);case"html":return nn(e);case"list":return vt(e);case"paragraph":return sn(e);case"table":return mn(e);case"thematicBreak":return cn();case"yaml":return[]}fe(e)}import{definitions as qp}from"mdast-util-definitions";import{SKIP as pn,visit as Qp}from"unist-util-visit";function dn(e){let t=qp(e);Qp(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[pn,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 c=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]=c,[pn,r]}}})}var Yp=Xp().use(jp).use($r());function Jp(e){let t=Yp.parse(e);return dn(t),t}function he(e){let t=Jp(e);return t.children.length===0?[{type:"paragraph",children:[{text:""}]}]:Le(t.children)}function Zp(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function un(e){let t=[],o=-1;for(let r of e){if(!Zp(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 fn(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 hn(e){let t=[],o=3;for(let r of e.children){let n=fn(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
4
|
`)}
|
|
6
5
|
|
|
7
|
-
`}function
|
|
6
|
+
`}function gn(e){return e.url}function bn(e){if(e.url.startsWith("$"))return"";let{hostname:t}=Be(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function En(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 ed=[bn,En,gn];function Tt(e){for(let t of ed){let o=t(e);if(typeof o=="string")return o===""?"":``}throw new Error("Shouldn't get here")}function xn(e){let t=Tt(e);return t?`${t}
|
|
8
7
|
|
|
9
|
-
`:""}import{Element as
|
|
8
|
+
`:""}import{Element as id,Text as ad}from"slate";function yn(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:Gr(o)}}function kn(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 Io(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=kn(e,t),{orderedMarksToAdd:n}=yn(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as od}from"slate";function vn({node:e,nextNode:t,nodes:o,index:r}){return!O(e)||!B(e)||e.code||!O(t)||!B(t)||e.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function Tn({node:e,nodes:t,prevNode:o,index:r}){if(!oe(e)||e.type!=="anchor")return!1;let n=e.children[0];return O(n)&&B(n)?(e.children.splice(0,1),O(o)&&B(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function wn({node:e,nodes:t,nextNode:o,index:r}){if(!oe(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return O(n)&&B(n)?(e.children.splice(e.children.length-1,1),O(o)&&B(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function In({node:e}){return!oe(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function Mn({node:e,nodes:t,index:o}){if(!O(e)||B(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 Pn({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!O(o)||!B(o)?!1:r&&oe(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function Cn({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!O(o)||!B(o)?!1:r&&oe(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var Sn=[Mn,Tn,wn,vn,Cn,Pn,In];function Rn(e){for(let t of Sn)if(t(e))return!0;return!1}var td=72;function Mo(e,t){let o=!1,r,n=0,i=(e.length+1)*td;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(oe(l)&&Mo(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],c=e[a+1];if(Rn({parent:t,node:l,prevNode:s,nextNode:c,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var Ln=e=>e.map(t=>od.isElement(t)&&t.type==="anchor"?{...t,children:Ln(t.children)}:t);function Bn(e){let t={type:"line",children:Ln(e)};return Mo([t],void 0),t.children}import{Text as nd}from"slate";function zn(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 rd(e){return e.replace(/"/g,'\\"')}function Dn(e){let t=To(e.children);return e.href.startsWith("$")?W(e.children,t,t):typeof e.title=="string"&&e.title.length>0?`[${W(e.children,t,t)}](${e.href} "${rd(e.title)}")`:`[${W(e.children,t,t)}](${e.href})`}function Nn(e){return qr(e.text)}function $n(e){if(nd.isText(e))return e.code?zn(e):Nn(e);switch(e.type){case"anchor":return Dn(e);case"image-inline":return Tt(e);default:fe(e)}}function W(e,t=[],o=[]){let r=Bn(e),n=[],i=Io(t,vo(r[0]));for(let a=0;a<r.length;a++){let l=r[a];if(ad.isText(l)&&B(l)){n.push(l.text);continue}n.push(Kr(i.add)),n.push($n(l));let s=ld(r,a,o),c=Io(i.nextOrderedMarks,s);n.push(_r(c.remove)),i=c}return n.join("")}function ld(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!B(n)&&!(id.isElement(n)&&n.type==="image-inline"))return vo(n)}return o}function An(e){let t=[];return t.push(Hn(e.children[0])),t.push(sd(e.columns)),e.children.slice(1).forEach(o=>{t.push(Hn(o))}),`${t.join(`
|
|
10
9
|
`)}
|
|
11
10
|
|
|
12
|
-
`}function
|
|
11
|
+
`}function sd(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>md(o.align)).join("|")}|`}function md(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function Hn(e){return kt(e,"table-row"),`|${e.children.map(cd).join("|")}|`}function cd(e){return kt(e,"table-cell"),Hr(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(pd).join()}function pd(e){return kt(e,"table-content"),W(e.children)}var Po=4;function On(e,t){switch(e.type){case"anchor":return`[${W(e.children)}](${e.href})`;case"block-quote":return`${wt(e.children).split(`
|
|
13
12
|
`).map(r=>`> ${r}`.trim()).join(`
|
|
14
13
|
`)}
|
|
15
14
|
|
|
16
|
-
`;case"heading":return`${"#".repeat(e.level)} ${
|
|
15
|
+
`;case"heading":return`${"#".repeat(e.level)} ${W(e.children)}
|
|
17
16
|
|
|
18
17
|
`;case"horizontal-rule":return`---
|
|
19
18
|
|
|
20
|
-
`;case"paragraph":return`${
|
|
19
|
+
`;case"paragraph":return`${W(e.children)}
|
|
21
20
|
|
|
22
|
-
`;case"table":return
|
|
23
|
-
`;case"ordered-list-item":return`${" ".repeat(e.depth*
|
|
24
|
-
`;case"task-list-item":{let o=" ".repeat(e.depth*
|
|
25
|
-
`}case"image-block":return
|
|
21
|
+
`;case"table":return An(e);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*Po)}- ${W(e.children)}
|
|
22
|
+
`;case"ordered-list-item":return`${" ".repeat(e.depth*Po)}${t[e.depth]}. ${W(e.children)}
|
|
23
|
+
`;case"task-list-item":{let o=" ".repeat(e.depth*Po),r=W(e.children);return r.trim()===""&&(r=" "),`${o}- [${e.checked?"x":" "}] ${r}
|
|
24
|
+
`}case"image-block":return xn(e);case"code-block":return hn(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}
|
|
26
25
|
|
|
27
|
-
`)),
|
|
26
|
+
`}fe(e)}function wt(e){let t=[],o=[];for(let n=0;n<e.length;n++){let i=e[n],a=n<e.length-1?e[n+1]:null;i.type==="ordered-list-item"?(o[i.depth]=(o[i.depth]||0)+1,o=o.slice(0,i.depth+1)):i.type==="unordered-list-item"||i.type==="task-list-item"?o=o.slice(0,i.depth):o=[];let l=On(i,o);(i.type==="ordered-list-item"||i.type==="unordered-list-item"||i.type==="task-list-item")&&(!a||a.type!=="ordered-list-item"&&a.type!=="unordered-list-item"&&a.type!=="task-list-item")&&(l=l.replace(/\n$/,`
|
|
28
27
|
|
|
29
|
-
`)}function
|
|
28
|
+
`)),t.push(l)}let r=t.join("");return r.trim()===""?"":ud(dd(r)).trim()}function dd(e){return e.replace(/^\n\n/g,`\\
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
`)}function ud(e){return e.replace(/(\n{4,})/g,t=>{let o=t.length,r=Math.floor((o-2)/2);return`
|
|
31
|
+
|
|
32
|
+
`+Array(r).fill("\\").join(`
|
|
32
33
|
|
|
33
34
|
`)+`
|
|
34
35
|
|
|
35
|
-
`})}function
|
|
36
|
+
`})}function nt(e){let t=un(e);return wt(t)}var Co={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",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",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",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30D5\u30A1\u30A4\u30EB",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",saving:"\u4FDD\u5B58\u4E2D...",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",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",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",register:"Register",imageSourceUrl:"URL",imageSourceFile:"File",selectFile:"Select File",uploading:"Uploading...",saving:"Saving...",vaultPath:"Save Path:",vaultPathHint:"Enter the path within the vault to save the file"}},Un=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=Un();return Co[t==="ja"?"ja":"en"][e]},So=e=>{let t=Un();return Object.keys(Co[t==="ja"?"ja":"en"]).find(r=>Co[t==="ja"?"ja":"en"][r]===e)||""};var v=e=>({fn:e});import{useEffect as Ed,useMemo as Xn}from"react";import{Editor as xd}from"slate";import{useSlateStatic as yd}from"slate-react";function ne(e){return!!e}function Fn(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(ne);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 fd}from"slate-react";import{jsx as hd}from"react/jsx-runtime";function Vn(e){let t=e.map(r=>r.renderEditable).filter(ne),o=r=>hd(fd,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function It(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function Mt(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Kn=(e,t)=>{let o=It(t,"onKeyDown");return Mt(o,e)},_n=(e,t)=>{let o=It(t,"onKeyUp");return Mt(o,e)},Wn=(e,t)=>{let o=It(t,"onPaste");return Mt(o,e)},Gn=(e,t)=>{let o=It(t,"onDrop");return Mt(o,e)};function qn(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(ne);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 gd}from"react";function Qn(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(ne).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=gd(n,r.attributes),n}}function jn(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(ne);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 bd from"@emotion/styled";var it=bd("div")`
|
|
36
37
|
-webkit-font-smoothing: antialiased;
|
|
37
38
|
-moz-osx-font-smoothing: grayscale;
|
|
38
39
|
font-size: 16px;
|
|
39
40
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
40
41
|
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
41
42
|
box-sizing: border-box;
|
|
42
|
-
`;import{jsx as
|
|
43
|
+
`;import{jsx as kd}from"react/jsx-runtime";function Yn(e){let t=yd();Ed(()=>{xd.normalize(t,{force:!0})},[]);let{plugins:o}=t.sink,r=Xn(()=>({...e,decorate:Fn(e.decorate,o),renderElement:qn(e.renderElement,o),renderLeaf:Qn(e.renderLeaf,o),renderPlaceholder:jn(e.renderPlaceholder,o),onKeyDown:Kn(e.onKeyDown,o),onKeyUp:_n(e.onKeyUp,o),onPaste:Wn(e.onPaste,o),onDrop:Gn(e.onDrop,o)}),Object.values(e)),n=Xn(()=>Vn(o),[o]);return kd(n,{...r})}function ze(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let m=s.editor?.[t],d=m?.(a);if(typeof d=="boolean")return d}return r(a)}}function se(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let c of n){let m=c.editor?.[t]?.(...a);if(typeof m=="function")s.push(m);else if(m===!0){l=!0;break}}l||r(...a),s.forEach(c=>c())}}function Jn(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:se(r,"normalizeNode",n),deleteBackward:se(r,"deleteBackward",n),deleteForward:se(r,"deleteForward",n),deleteFragment:se(r,"deleteFragment",n),insertBreak:se(r,"insertBreak",n),insertFragment:se(r,"insertFragment",n),insertNode:se(r,"insertNode",n),insertText:se(r,"insertText",n),isInline:ze(r,"isInline",n),isVoid:ze(r,"isVoid",n),isMaster:ze(r,"isMaster",n),isSlave:ze(r,"isSlave",n),isStandalone:ze(r,"isStandalone",n)}),r}}var Zn=e=>{let t=e.map(n=>n.fn);return{withSink:Jn(t),SinkEditable:Yn}};import{Element as vd}from"slate";import{ReactEditor as Td}from"slate-react";function ei(e,t){return vd.isElement(t)?Td.findPath(e,t):t}function u(e,t){return e.bind(null,t)}function G(e,t,o){return e.bind(null,t,o)}var wd=/mac os x|macintosh/i,at;function Pt(){if(at!==void 0)return at;try{let{userAgent:e}=window.navigator;at=wd.test(e)}catch{at=!1}return at}function ve(e){e.preventDefault(),e.stopPropagation()}import{Editor as ri,Path as Id}from"slate";import{Element as ti}from"slate";function oi(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>ti.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>ti.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=ei(e,o),n=oi(t);if(Id.isPath(r)){let i=ri.node(e,r);if(i&&n(i[0]))return i}return ri.above(e,{at:r,match:n})}function De(...e){return E(...e)?.[1]}import{jsx as Md}from"react/jsx-runtime";var y=({strokeWidth:e=1.5,...t})=>Md("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 Pd}from"slate";function me(e){return e==null?!1:Pd.isCollapsed(e)}import{Element as ni}from"slate";function Ct(e){return Array.isArray(e)?t=>ni.isElement(t)&&e.includes(t.type):t=>ni.isElement(t)&&e==t.type}import{Editor as Cd}from"slate";function ii(e,t){let{selection:o}=e;if(!me(o))return!1;let r=E(e,t,{at:o});return!!r&&Cd.isEnd(e,o.anchor,r[1])}import{Editor as gv}from"slate";import{Editor as Sd}from"slate";function Te(e,t){let{selection:o}=e;if(!me(o))return!1;let r=E(e,t,{at:o});return!!r&&Sd.isStart(e,o.anchor,r[1])}import{isHotkey as ai}from"is-hotkey";import{Editor as Ro,Element as Rd,Range as Ld,Transforms as Bd}from"slate";var zd=ai(" "),Dd=ai("SHIFT+SPACE");function li(e,t){return o=>{if(!zd(o.nativeEvent)&&!Dd(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||Ld.isExpanded(r))return!1;let n=E(e,c=>Rd.isElement(c)&&e.convertElement.isConvertibleElement(c));if(!n)return!1;let i={anchor:Ro.start(e,n[1]),focus:r.focus},a=Ro.string(e,i),l=t[a];if(!l)return!1;ve(o);let s={anchor:Ro.start(e,n[1]),focus:r.focus};return Bd.delete(e,{at:s}),l(),!0}}import{isHotkey as Nd}from"is-hotkey";function si(e){let t=e.replace(/\bsuper\b/g,Pt()?"cmd+alt":"ctrl+shift");return Nd(t)}function $(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[si(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 $d,Transforms as mi}from"slate";function ci(e,t){$d.withoutNormalizing(e,()=>{mi.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),mi.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as pi}from"slate";function ge(e,t,o){let[,r]=t,n=pi.previous(e,{at:r});if(n&&o(n,t))return!0;let i=pi.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as di,Transforms as ui}from"slate";function q(e,t){ui.select(e,di.start(e,t))}function fi(e,t){ui.select(e,di.end(e,t))}function hi(e,t){return typeof t!="function"?t:t(e)}import{Editor as Lo,Element as Hd,Path as Ad,Transforms as lt}from"slate";function St(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>Hd.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;Lo.withoutNormalizing(e,()=>{lt.insertNodes(e,t,{at:o}),n&&(lt.select(e,n),lt.move(e))})}else{let n=Ad.next(r[1]);Lo.withoutNormalizing(e,()=>{lt.insertNodes(e,t,{at:n}),lt.select(e,Lo.start(e,n))})}return!0}import{Editor as gi,Transforms as bi}from"slate";function st(e,t,o){gi.withoutNormalizing(e,()=>{let r=gi.node(e,o),n=hi(r[0],t);bi.wrapNodes(e,n,{at:o}),bi.unwrapNodes(e,{at:[...o,0]})})}import{Editor as Od,Transforms as Ud}from"slate";function Rt(e,t,o){let r=Array.from(Od.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;Ud.setNodes(e,t(i),{at:n[1]})}return!0}function Ei(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 Fd(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function Fd(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Vd,Node as Kd,Transforms as Bo}from"slate";function xi(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(Bo.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Kd.string(a);r!==s&&Vd.withoutNormalizing(e,()=>{let c=a.children.length;for(let m=c-1;m>=0;m--)Bo.removeNodes(e,{at:[...l,m]});Bo.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as Lt,Range as _d,Text as Wd,Transforms as zo}from"slate";function yi(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:Lt.start(e,[0]),focus:Lt.start(e,[0])};if(_d.isCollapsed(i)){if(zo.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=Lt.node(e,e.selection);zo.select(e,a[1])}}else zo.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Wd.isText(a)||Lt.isInline(e,a)})}import{Transforms as Gd}from"slate";function ki(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(Gd.unwrapNodes(e,{at:o[1]}),!0):!1}function vi(e){return{insertLink:u(yi,e),removeLink:u(ki,e),editLink:u(xi,e)}}import{Element as Ti,Transforms as qd}from"slate";function wi(e,t){if(!Ti.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(!(!Ti.isElement(n)||n.type!=="anchor"))return qd.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Uu}from"clsx";import{useEffect as Fu,useRef as ca}from"react";import{useSelected as Vu,useSlate as Ku}from"slate-react";import{createContext as Mi,useState as jd}from"react";import{createPortal as Qd}from"react-dom";function Ii({children:e}){return Qd(e,document.body)}import{jsx as Do,jsxs as Yd}from"react/jsx-runtime";var No=Mi({}),Xd=Mi({});function Pi({children:e}){let[t,o]=jd({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Yd(No.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>Do(Ii,{children:Do(Xd.Provider,{value:i,children:Do(i.Component,{})})},i.type))]})}import{useContext as Jd}from"react";function A(e){let{openLayer:t,closeLayer:o,layers:r}=Jd(No);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import Bt from"@emotion/styled";var Ci=Bt("a")`
|
|
43
44
|
/**
|
|
44
45
|
* Link colors
|
|
45
46
|
*/
|
|
@@ -58,10 +59,10 @@
|
|
|
58
59
|
&.--selected {
|
|
59
60
|
background: var(--blue-50);
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
`,$o=Bt("span")`
|
|
62
63
|
display: inline;
|
|
63
64
|
padding: 0 1px 0 0;
|
|
64
|
-
`,
|
|
65
|
+
`,k1=Bt("span")`
|
|
65
66
|
position: fixed;
|
|
66
67
|
width: 100px;
|
|
67
68
|
background: var(--shade-50);
|
|
@@ -70,14 +71,14 @@
|
|
|
70
71
|
border: 1px solid var(--shade-400);
|
|
71
72
|
overflow: hidden;
|
|
72
73
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
73
|
-
`,
|
|
74
|
+
`,v1=Bt("span")`
|
|
74
75
|
position: absolute;
|
|
75
76
|
left: 0;
|
|
76
77
|
top: 0;
|
|
77
78
|
height: 14px;
|
|
78
79
|
background: var(--blue-400);
|
|
79
80
|
transition: width 100ms linear;
|
|
80
|
-
`;import
|
|
81
|
+
`;import Nu from"@emotion/styled";import{useCallback as Vt,useState as $u}from"react";import{useSlateStatic as Hu}from"slate-react";import{useRef as eu}from"react";import Zd from"@emotion/styled";var Si=Zd("div")`
|
|
81
82
|
position: fixed;
|
|
82
83
|
user-select: none;
|
|
83
84
|
top: 0;
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
bottom: 0;
|
|
87
88
|
overflow-y: auto;
|
|
88
89
|
background: rgba(0, 0, 0, 0.01);
|
|
89
|
-
`;import{jsx as
|
|
90
|
+
`;import{jsx as tu}from"react/jsx-runtime";function be({close:e}){let t=eu(null);return tu(Si,{ref:t,onClick:e})}var ie={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},ou={shift:ie.shift,opt:ie.opt,alt:ie.opt,ctrl:ie.ctrl,mod:ie.cmd,cmd:ie.cmd,enter:ie.enter,super:`${ie.opt}${ie.cmd}`},ru={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:ie.enter,super:"CTRL+SHIFT"};function Ri(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function nu(e){let t=[];return Object.entries(ou).forEach(([o,r])=>{e.includes(o)&&(t.push(r),Ri(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function iu(e){let t=[];return Object.entries(ru).forEach(([o,r])=>{e.includes(o)&&(t.push(r),Ri(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function zt(e){let t=e.toLowerCase().split("+");return Pt()?nu(t):iu(t)}import{useRef as gu}from"react";import{useSlateStatic as bu}from"slate-react";function Ho(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 Li(e){let t=Ho(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function Ao(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function Bi(){let e=Ao();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var zi=au;function au(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 Oo(e,t){return zi(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as mu}from"react";import lu from"lodash.throttle";import{useState as su}from"react";function Dt(e=100){let[t,o]=su(0),r=lu(()=>{o(n=>n+1)},e,{trailing:!0});return Object.assign(r,{counter:t})}function Uo(){let e=Dt();return mu(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function j(e,t){let o=Uo(),r=Oo(e,n=>Li(n));return t(r,Bi(),o)}function Nt(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 Fo from"@emotion/styled";import cu from"@emotion/styled";var X=cu(it)`
|
|
90
91
|
position: absolute;
|
|
91
92
|
z-index: 1000;
|
|
92
93
|
border: 1px solid var(--table-border-color);
|
|
@@ -112,23 +113,25 @@
|
|
|
112
113
|
* even if we did, it looks better this way.
|
|
113
114
|
*/
|
|
114
115
|
/* transition: left 100ms, top 100ms; */
|
|
115
|
-
`;var
|
|
116
|
-
padding: 1em;
|
|
116
|
+
`;var Di=Fo(X)`
|
|
117
117
|
width: 24em;
|
|
118
|
-
|
|
118
|
+
padding: 0;
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
`,$t=Fo("div")`
|
|
119
121
|
display: flex;
|
|
120
122
|
gap: 0.5em;
|
|
121
|
-
`,
|
|
123
|
+
`,Ht=Fo("input")`
|
|
122
124
|
flex: 1 1 auto;
|
|
123
125
|
padding: 0.5em 0.75em;
|
|
124
126
|
border-radius: 0.25em;
|
|
125
127
|
color: var(--shade-700);
|
|
128
|
+
background: var(--shade-50);
|
|
126
129
|
border: 1px solid var(--shade-300);
|
|
127
130
|
font-size: 0.9375em;
|
|
128
131
|
&:focus {
|
|
129
132
|
outline: 2px solid var(--blue-200);
|
|
130
133
|
}
|
|
131
|
-
`;import
|
|
134
|
+
`;import $i from"@emotion/styled";import pu from"@emotion/styled";var Ni=pu(it)`
|
|
132
135
|
border: 1px solid var(--shade-300); /* shade-300 */
|
|
133
136
|
border-radius: 0.5em;
|
|
134
137
|
color: rgb(39 39 42); /* shade-800 */
|
|
@@ -144,9 +147,9 @@
|
|
|
144
147
|
*/
|
|
145
148
|
outline: 2px solid var(--select-editor-color) !important;
|
|
146
149
|
}
|
|
147
|
-
`;var
|
|
150
|
+
`;var Hi=$i("div")`
|
|
148
151
|
padding: 2em;
|
|
149
|
-
`,
|
|
152
|
+
`,Ai=$i(Ni)`
|
|
150
153
|
/**
|
|
151
154
|
* We use this to make sure the top of the container is rounded even though
|
|
152
155
|
* the toolbar inside is square. We keep the toolbar square so that as the
|
|
@@ -167,16 +170,17 @@
|
|
|
167
170
|
overflow-y: clip;
|
|
168
171
|
display: flex;
|
|
169
172
|
flex-direction: column;
|
|
170
|
-
`;import
|
|
173
|
+
`;import Vo from"@emotion/styled";var Oi=Vo(X)`
|
|
171
174
|
position: absolute;
|
|
172
175
|
padding-top: 0.5em;
|
|
173
176
|
padding-bottom: 0.5em;
|
|
174
177
|
transition: all 200ms;
|
|
178
|
+
min-width: 12em;
|
|
175
179
|
/**
|
|
176
180
|
* Prevent clicks from stealing focus from the editor
|
|
177
181
|
*/
|
|
178
182
|
user-select: none;
|
|
179
|
-
`,
|
|
183
|
+
`,Ui=Vo("div")`
|
|
180
184
|
display: flex;
|
|
181
185
|
z-index: 10;
|
|
182
186
|
padding: 0 1em 0 1.5em;
|
|
@@ -200,9 +204,10 @@
|
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
.--title {
|
|
203
|
-
flex: 1
|
|
207
|
+
flex: 1 1 auto;
|
|
204
208
|
font-size: 0.875em;
|
|
205
209
|
color: var(--shade-800);
|
|
210
|
+
white-space: nowrap;
|
|
206
211
|
}
|
|
207
212
|
.--hotkey {
|
|
208
213
|
flex: 0 0;
|
|
@@ -215,12 +220,12 @@
|
|
|
215
220
|
&:hover {
|
|
216
221
|
background: var(--blue-50);
|
|
217
222
|
}
|
|
218
|
-
`,
|
|
223
|
+
`,Fi=Vo("div")`
|
|
219
224
|
height: 1px;
|
|
220
225
|
background: var(--shade-200);
|
|
221
226
|
margin-top: 0.25em;
|
|
222
227
|
margin-bottom: 0.25em;
|
|
223
|
-
`;import
|
|
228
|
+
`;import mt from"@emotion/styled";var Vi=mt("div")`
|
|
224
229
|
/**
|
|
225
230
|
* This flex rule applies to the "display: flex;" of the parent container.
|
|
226
231
|
* Ensures the toolbar does not shrink or grow vertically.
|
|
@@ -259,22 +264,22 @@
|
|
|
259
264
|
3em + 1px
|
|
260
265
|
); // $ToolbarDivider height + border-bottom of 1px above
|
|
261
266
|
overflow: hidden;
|
|
262
|
-
`,
|
|
267
|
+
`,Ki=mt("div")`
|
|
263
268
|
display: inline-block;
|
|
264
269
|
height: calc(
|
|
265
270
|
3em + 1px
|
|
266
271
|
); // $ToolbarDivider height + border-bottom of 1px above
|
|
267
|
-
`,
|
|
272
|
+
`,_i=mt("div")`
|
|
268
273
|
display: inline-block;
|
|
269
274
|
height: 3em;
|
|
270
275
|
padding: 0 0.375em;
|
|
271
|
-
|
|
276
|
+
`,Wi=mt("div")`
|
|
272
277
|
display: inline-block;
|
|
273
278
|
background: var(--shade-300);
|
|
274
279
|
opacity: 50%;
|
|
275
280
|
width: 1px;
|
|
276
281
|
height: 3em;
|
|
277
|
-
`,
|
|
282
|
+
`,Gi=mt("div")`
|
|
278
283
|
box-sizing: border-box;
|
|
279
284
|
position: relative;
|
|
280
285
|
display: inline-block;
|
|
@@ -324,7 +329,7 @@
|
|
|
324
329
|
margin-left: -0.25em;
|
|
325
330
|
opacity: 0.375;
|
|
326
331
|
}
|
|
327
|
-
`;import{useCallback as
|
|
332
|
+
`;import{useCallback as du}from"react";import{ReactEditor as uu}from"slate-react";import{Fragment as hu,jsx as Ne,jsxs as fu}from"react/jsx-runtime";function qi({editor:e,item:t,close:o,dest:r}){let n=A("menu"),i=du(()=>{if(t.Component){let a=t.Component;n.open(()=>Ne(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),uu.focus(e),o())},[e,t]);return Ne(hu,{children:fu(Ui,{onClick:i,children:[Ne("div",{className:"--icon",children:Ne(t.icon,{})}),Ne("div",{className:"--title",children:t.title}),Ne("div",{className:"--hotkey",children:t.hotkey?zt(t.hotkey):void 0})]})})}import{Fragment as Eu,jsx as At,jsxs as xu}from"react/jsx-runtime";function $e({dest:e,items:t,close:o}){let r=bu(),n=gu(null),i=j({src:n,dest:e},({dest:a})=>({left:a.left-8,top:a.top+a.height}));return xu(Eu,{children:[At(be,{close:o}),At(Oi,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?At(Fi,{},l):a.show&&!a.show(r)?null:At(qi,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as Yi}from"react";import Qi from"@emotion/styled";import{jsx as vu,jsxs as Tu}from"react/jsx-runtime";function Ko(e){return e.getBoundingClientRect()}var yu=Qi("div")`
|
|
328
333
|
position: fixed;
|
|
329
334
|
z-index: 10;
|
|
330
335
|
-webkit-font-smoothing: antialiased;
|
|
@@ -340,12 +345,12 @@
|
|
|
340
345
|
background: var(--shade-700);
|
|
341
346
|
border-radius: 0.25em;
|
|
342
347
|
white-space: nowrap;
|
|
343
|
-
`,
|
|
348
|
+
`,ku=Qi("span")`
|
|
344
349
|
margin-left: 0.75em;
|
|
345
350
|
font-size: 0.875em;
|
|
346
351
|
font-weight: 500;
|
|
347
352
|
color: var(--shade-400);
|
|
348
|
-
`;function
|
|
353
|
+
`;function ji({title:e,hotkey:t,dest:o}){let r=Ko(o);return Tu(yu,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?vu(ku,{children:t}):null]})}import wu from"@emotion/styled";import{jsx as Mu}from"react/jsx-runtime";var Iu=wu("span")`
|
|
349
354
|
position: fixed;
|
|
350
355
|
z-index: 10;
|
|
351
356
|
width: 0;
|
|
@@ -353,7 +358,7 @@
|
|
|
353
358
|
border-left: 0.375em solid transparent;
|
|
354
359
|
border-right: 0.375em solid transparent;
|
|
355
360
|
border-top: 0.375em solid var(--shade-700);
|
|
356
|
-
`;function
|
|
361
|
+
`;function Xi({dest:e}){let t=Ko(e);return Mu(Iu,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as Ji}from"react/jsx-runtime";function Y({title:e,hotkey:t},o=[]){let r=A("tooltip-label"),n=A("tooltip-triangle"),i=Yi(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>Ji(ji,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>Ji(Xi,{dest:s})))},o),a=Yi(()=>{r.close(),n.close()},o);return{onMouseEnter:i,onMouseLeave:a}}import Ru from"@emotion/styled";import{useCallback as Ae,useRef as Lu,useState as Ut}from"react";import{Node as Bu}from"slate";import{useSlateStatic as zu}from"slate-react";import Ee from"@emotion/styled";var He=Ee("div")`
|
|
357
362
|
margin: 0.5em 0;
|
|
358
363
|
&:first-of-type {
|
|
359
364
|
margin-top: 0;
|
|
@@ -361,39 +366,41 @@
|
|
|
361
366
|
&:last-of-type {
|
|
362
367
|
margin-bottom: 0;
|
|
363
368
|
}
|
|
364
|
-
`,
|
|
369
|
+
`,Ot=Ee("div")`
|
|
365
370
|
font-size: 0.9375em;
|
|
366
371
|
margin-bottom: 0.25em;
|
|
367
372
|
color: var(--shade-700);
|
|
368
|
-
`,
|
|
373
|
+
`,_o=Ee("div")`
|
|
369
374
|
font-size: 0.875em;
|
|
370
375
|
margin-top: 0.25em;
|
|
371
376
|
color: var(--shade-500);
|
|
372
|
-
`,
|
|
377
|
+
`,Zi=Ee("input")`
|
|
373
378
|
box-sizing: border-box;
|
|
374
379
|
width: 100%;
|
|
375
380
|
height: 6em;
|
|
376
381
|
padding: 0.5em 0.75em;
|
|
377
382
|
border-radius: 0.25em;
|
|
378
383
|
color: var(--shade-700);
|
|
384
|
+
background: var(--shade-50);
|
|
379
385
|
font-family: inherit;
|
|
380
386
|
border: 1px solid var(--shade-300);
|
|
381
387
|
font-size: 0.9375em;
|
|
382
388
|
&:focus {
|
|
383
389
|
outline: 2px solid var(--blue-200);
|
|
384
390
|
}
|
|
385
|
-
`,
|
|
391
|
+
`,Wo=Ee("input")`
|
|
386
392
|
box-sizing: border-box;
|
|
387
393
|
width: 100%;
|
|
388
394
|
padding: 0.5em 0.75em;
|
|
389
395
|
border-radius: 0.25em;
|
|
390
396
|
color: var(--shade-700);
|
|
397
|
+
background: var(--shade-50);
|
|
391
398
|
border: 1px solid var(--shade-300);
|
|
392
399
|
font-size: 0.9375em;
|
|
393
400
|
&:focus {
|
|
394
401
|
outline: 2px solid var(--blue-200);
|
|
395
402
|
}
|
|
396
|
-
`,
|
|
403
|
+
`,ea=Ee("div")`
|
|
397
404
|
/* Center vertically and horizontally */
|
|
398
405
|
display: flex;
|
|
399
406
|
align-items: center;
|
|
@@ -407,7 +414,7 @@
|
|
|
407
414
|
font-size: 1.25em;
|
|
408
415
|
stroke-width: 2px;
|
|
409
416
|
}
|
|
410
|
-
`,
|
|
417
|
+
`,ta=Ee(ea)`
|
|
411
418
|
color: var(--blue-50);
|
|
412
419
|
background: var(--blue-500);
|
|
413
420
|
outline: 0px solid white;
|
|
@@ -419,7 +426,7 @@
|
|
|
419
426
|
svg {
|
|
420
427
|
color: var(--blue-200);
|
|
421
428
|
}
|
|
422
|
-
`,
|
|
429
|
+
`,oa=Ee(ea)`
|
|
423
430
|
color: var(--shade-500);
|
|
424
431
|
background: var(--shade-200);
|
|
425
432
|
outline: 0px solid white;
|
|
@@ -431,16 +438,37 @@
|
|
|
431
438
|
svg {
|
|
432
439
|
color: var(--shade-400);
|
|
433
440
|
}
|
|
434
|
-
`;import{
|
|
441
|
+
`;import{useRef as Pu,useCallback as we}from"react";import na from"@emotion/styled";import{jsx as ra}from"react/jsx-runtime";var Cu=na.div`
|
|
442
|
+
display: flex;
|
|
443
|
+
align-items: center;
|
|
444
|
+
justify-content: center;
|
|
445
|
+
padding: 6px 0;
|
|
446
|
+
cursor: grab;
|
|
447
|
+
background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
|
|
448
|
+
border-bottom: 1px solid #ddd;
|
|
449
|
+
border-radius: 4px 4px 0 0;
|
|
450
|
+
user-select: none;
|
|
451
|
+
touch-action: none;
|
|
452
|
+
|
|
453
|
+
&:active {
|
|
454
|
+
cursor: grabbing;
|
|
455
|
+
}
|
|
456
|
+
`,Su=na.div`
|
|
457
|
+
width: 32px;
|
|
458
|
+
height: 4px;
|
|
459
|
+
background: #ccc;
|
|
460
|
+
border-radius: 2px;
|
|
461
|
+
`;function xe({onDrag:e}){let t=Pu(null),o=we((c,m)=>{t.current={x:c,y:m}},[]),r=we((c,m)=>{if(!t.current)return;let d=c-t.current.x,p=m-t.current.y;t.current={x:c,y:m},e(d,p)},[e]),n=we(()=>{t.current=null},[]),i=we(c=>{c.preventDefault(),o(c.clientX,c.clientY);let m=p=>{r(p.clientX,p.clientY)},d=()=>{n(),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",d)},[o,r,n]),a=we(c=>{if(c.touches.length!==1)return;let m=c.touches[0];o(m.clientX,m.clientY)},[o]),l=we(c=>{if(c.touches.length!==1)return;let m=c.touches[0];r(m.clientX,m.clientY)},[r]),s=we(()=>{n()},[n]);return ra(Cu,{onMouseDown:i,onTouchStart:a,onTouchMove:l,onTouchEnd:s,children:ra(Su,{})})}import{jsx as K,jsxs as ct}from"react/jsx-runtime";var Du=Ru(X)`
|
|
435
462
|
position: absolute;
|
|
436
463
|
width: 20em;
|
|
437
|
-
padding:
|
|
438
|
-
|
|
464
|
+
padding: 0;
|
|
465
|
+
overflow: hidden;
|
|
466
|
+
`;function ia({destAnchor:e,destStartEdge:t,element:o}){let r=A("dialog"),[n,i]=Ut({x:0,y:0}),a=Ae((k,I)=>{i(x=>({x:x.x+k,y:x.y+I}))},[]),l=j({destAnchor:e,destStartEdge:t},({destAnchor:k,destStartEdge:I})=>({left:I.left,top:k.top+k.height})),s={...l,left:l.left+n.x,top:l.top+n.y},c=zu(),[m,d]=Ut(o.href),[p,b]=Ut(Bu.string(o)),[g,T]=Ut(o.title||""),C=Lu({href:m,text:p,title:g});C.current={href:m,text:p,title:g};let P=Ae(k=>{d(k.target.value)},[]),w=Ae(k=>{b(k.target.value)},[]),S=Ae(k=>{T(k.target.value)},[]),M=Ae(()=>{r.open(()=>K(Ft,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),H=Ae(()=>{let{href:k,text:I,title:x}=C.current;c.anchor.editLink({href:k,text:I,title:x},{at:o}),M()},[M]);return ct(Du,{contentEditable:!1,style:s,children:[K(xe,{onDrag:a}),ct("div",{style:{padding:"1em"},children:[ct(He,{children:[K(Ot,{children:f("linkUrl")}),K(Zi,{as:"textarea",value:m,onChange:P})]}),ct(He,{children:[K(Ot,{children:f("linkText")}),K(Wo,{type:"text",value:p,onChange:w}),K(_o,{children:f("linkTextHint")})]}),ct(He,{children:[K(Ot,{children:f("tooltipText")}),K(Wo,{type:"text",value:g,onChange:S}),K(_o,{children:f("tooltipHint")})]}),K(He,{children:K(ta,{onClick:H,children:f("apply")})}),K(He,{children:K(oa,{onClick:M,children:f("cancel")})})]})]})}import{jsx as ye}from"react/jsx-runtime";var aa=e=>ye(y,{...e,children:ye("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"})}),la=e=>ye(y,{...e,children:ye("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"})}),sa=e=>ye(y,{...e,children:ye("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})}),ma=e=>ye(y,{...e,children:ye("path",{d:"M18 6L6 18M6 6l12 12"})});import{jsx as J,jsxs as pt}from"react/jsx-runtime";var Au=Nu(X)`
|
|
439
467
|
position: absolute;
|
|
440
|
-
display: flex;
|
|
441
468
|
width: 20em;
|
|
442
|
-
z-index:
|
|
443
|
-
padding:
|
|
469
|
+
z-index: 1000;
|
|
470
|
+
padding: 0;
|
|
471
|
+
overflow: hidden;
|
|
444
472
|
color: var(--shade-400);
|
|
445
473
|
|
|
446
474
|
.--icons {
|
|
@@ -519,10 +547,10 @@
|
|
|
519
547
|
height: 1.25em;
|
|
520
548
|
stroke-width: 1.5;
|
|
521
549
|
}
|
|
522
|
-
`;function
|
|
550
|
+
`;function Ou(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function Ft({destAnchor:e,destStartEdge:t,element:o}){let r=A("dialog"),n=Hu(),i=Ou(o.href),[a,l]=$u({x:0,y:0}),s=Vt((P,w)=>{l(S=>({x:S.x+P,y:S.y+w}))},[]),c=j({destAnchor:e,destStartEdge:t},({destAnchor:P,destStartEdge:w})=>({left:w.left,top:P.top+P.height})),m={...c,left:c.left+a.x,top:c.top+a.y},d=Y({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),p=Y({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),b=Y({title:"\u9589\u3058\u308B"}),g=Vt(()=>{r.close()},[r]),T=Vt(()=>{n.anchor.removeLink({at:o}),r.close()},[n,r]),C=Vt(()=>{p.onMouseLeave(),r.open(()=>J(ia,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]);return pt(Au,{contentEditable:!1,style:m,children:[J(xe,{onDrag:s}),pt("div",{style:{display:"flex",padding:"1em"},children:[pt("a",{className:"--link",href:o.href,target:"_blank",rel:"noreferrer",children:[J(aa,{}),pt("div",{className:"--url",children:[J("div",{className:"--hostname",children:i.hostname}),i.pathname===""||i.pathname==="/"?null:J("div",{className:"--pathname",children:i.pathname}),o.title==null||o.title===""?null:J("div",{className:"--tooltip",children:o.title})]})]}),pt("span",{className:"--icons",children:[J("span",{className:"--icon",onClick:T,onMouseEnter:d.onMouseEnter,onMouseLeave:d.onMouseLeave,children:J(la,{})}),J("span",{className:"--icon",onMouseEnter:p.onMouseEnter,onMouseLeave:p.onMouseLeave,onClick:C,children:J(sa,{})}),J("span",{className:"--icon",onClick:g,onMouseEnter:b.onMouseEnter,onMouseLeave:b.onMouseLeave,children:J(ma,{})})]})]})]})}import{jsx as Kt,jsxs as _u}from"react/jsx-runtime";function pa({element:e,attributes:t,children:o}){let r=ca(null),n=ca(null),i=Vu(),a=Ku(),l=A("dialog");return Fu(()=>{let s=n.current,c=r.current;if(!s||!c)return;let m=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!m?setTimeout(()=>{l.open(()=>Kt(Ft,{destAnchor:s,destStartEdge:c,element:e}))}):l.close()},[i,e]),_u(Ci,{className:Uu({"--selected":i}),href:e.href,target:e.target,...t,ref:n,children:[Kt($o,{ref:r,contentEditable:!1}),Kt("span",{children:o}),Kt($o,{contentEditable:!1})]})}import{jsx as Wu}from"react/jsx-runtime";var da=v((e,t,{createPolicy:o})=>(e.anchor=vi(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:u(wi,e)},editableProps:{onPaste:u(Ei,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return Wu(pa,{element:r,attributes:n,children:i})}}})));import{Editor as _t,Transforms as ha}from"slate";import{Element as ua,Path as fa}from"slate";function Go(e,t,o){if(!t||!o||fa.equals(t[1],o[1]))return!0;let r=E(e,i=>ua.isElement(i)&&e.isMaster(i),{at:t[1]}),n=E(e,i=>ua.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&fa.equals(r[1],n[1]))}var ga=v(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=_t.node(e,e.selection),o=_t.previous(e,{mode:"lowest"});return Go(e,t,o)?!1:(ha.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=_t.node(e,e.selection),o=_t.next(e,{mode:"lowest"});return Go(e,t,o)?!1:(ha.move(e,{unit:"character"}),!0)}}}));import{Transforms as zf}from"slate";import{ReactEditor as Df}from"slate-react";import{Editor as Gu,Transforms as ba}from"slate";import{ReactEditor as qu}from"slate-react";function Qu(e){}function ju(e,t,o,r){let{selection:n}=e;if(ba.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=Gu.end(e,[]);ba.select(e,i),qu.focus(e)}}function Ea(e){return{noop:u(Qu,e),insertImageFromUrl:u(ju,e)}}function xa(e,t){return!1}import{useSlateStatic as Cf}from"slate-react";import Xu from"@emotion/styled";var ya=Xu("div")`
|
|
523
551
|
display: block;
|
|
524
552
|
margin: 1em 0;
|
|
525
|
-
`;import{clsx as
|
|
553
|
+
`;import{clsx as If}from"clsx";import{useState as tl}from"react";import{useSelected as Mf}from"slate-react";import ka from"@emotion/styled";var va=ka("span")`
|
|
526
554
|
/**
|
|
527
555
|
* In order for this container to wrap tightly (without space), it needs to be
|
|
528
556
|
* an "inline-block". If it's just an "inline" we end up with spacing
|
|
@@ -534,7 +562,7 @@
|
|
|
534
562
|
* so that we can place UI controls for the image in and around the image.
|
|
535
563
|
*/
|
|
536
564
|
position: relative;
|
|
537
|
-
`,
|
|
565
|
+
`,Ta=ka("img")`
|
|
538
566
|
/**
|
|
539
567
|
* TODO:
|
|
540
568
|
*
|
|
@@ -596,7 +624,7 @@
|
|
|
596
624
|
.--dragging > & {
|
|
597
625
|
transition: border-radius 250ms;
|
|
598
626
|
}
|
|
599
|
-
`;import{clsx as
|
|
627
|
+
`;import{clsx as tf}from"clsx";import{useCallback as Sa}from"react";import{Transforms as Ra}from"slate";import{ReactEditor as Qo,useSlateStatic as of}from"slate-react";import{useEffect as Yu}from"react";function wa(){let e=Dt();return Yu(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import Ia from"@emotion/styled";var Ma=Ia("span")`
|
|
600
628
|
position: absolute;
|
|
601
629
|
display: block;
|
|
602
630
|
/**
|
|
@@ -623,7 +651,7 @@
|
|
|
623
651
|
/* background: green; */
|
|
624
652
|
width: 1.25em;
|
|
625
653
|
}
|
|
626
|
-
`,
|
|
654
|
+
`,Pa=Ia("span")`
|
|
627
655
|
position: absolute;
|
|
628
656
|
display: block;
|
|
629
657
|
background: var(--select-color);
|
|
@@ -716,7 +744,7 @@
|
|
|
716
744
|
.--small > & > .--bar-right {
|
|
717
745
|
left: calc(50% + 1px);
|
|
718
746
|
}
|
|
719
|
-
`;function
|
|
747
|
+
`;function qo({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 Ju}from"slate-react";function Wt(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function Zu(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function ef(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Wt(t.width,e)}else if(e.height>t.width)return Zu(t.height,e);return e}function Ie(e,t,o){switch(o.type){case"bounds":return ef(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function Ca(e){let t=Ju.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft)+parseInt(o.paddingRight);return t.clientWidth-r}import{Fragment as af,jsx as dt,jsxs as nf}from"react/jsx-runtime";function rf(e,t){let r=Qo.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function La({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=of();wa();let l=Ca(a),s=o.width,c=Math.min(t.width,l),m=Math.min(12,t.width),d=Sa(g=>{ve(g),i(!0);let T=g.clientX,P=rf(a,e).width,w={...o},S=H=>{let k=qo({value:P+H.clientX-T,min:m,max:c});w=Wt(k,t),r(w)},M=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",M);let H=Qo.findPath(a,e),k={width:w.width,height:w.height};r(k),Ra.setNodes(a,k,{at:H}),i(!1)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",M)},[t.width,t.height,o.width,e]),p=Sa(g=>{ve(g),i(!0);let T=g.changedTouches[0].clientX,C=o.width,P={...o},w=M=>{let H=M.changedTouches[0],k=qo({value:C+H.clientX-T,min:m,max:c});P=Wt(k,t),r(P)},S=()=>{document.removeEventListener("touchmove",w),document.removeEventListener("touchend",S);let M=Qo.findPath(a,e);Ra.setNodes(a,{width:P.width,height:P.height},{at:M}),i(!1)};document.addEventListener("touchmove",w),document.addEventListener("touchend",S)},[t.width,t.height,o.width,e]),b=tf({"--center":s<c&&s>m,"--left":s>=c&&s>m,"--right":s<=m&&s<c,"--dragging":n,"--small":s<=64||o.height<=64});return dt(af,{children:dt(Ma,{className:b,onMouseDown:d,onTouchStart:p,children:nf(Pa,{children:[dt("span",{className:"--bar --bar-left"}),dt("span",{className:"--bar --bar-center"}),dt("span",{className:"--bar --bar-right"})]})})})}import lf from"@emotion/styled";var Ba=lf("span")`
|
|
720
748
|
position: absolute;
|
|
721
749
|
/**
|
|
722
750
|
* The status appears with a 1px gap from the outline.
|
|
@@ -738,7 +766,7 @@
|
|
|
738
766
|
|
|
739
767
|
/* force numbers to be monospaced for better alignment */
|
|
740
768
|
font-variant-numeric: tabular-nums;
|
|
741
|
-
`;import{jsxs as
|
|
769
|
+
`;import{jsxs as sf}from"react/jsx-runtime";function za({size:e}){return sf(Ba,{children:[e.width," \xD7 ",e.height]})}import mf from"@emotion/styled";var Da=mf("span")`
|
|
742
770
|
position: absolute;
|
|
743
771
|
/**
|
|
744
772
|
* On top of the image +1 for space inside outline, +2 for outline,
|
|
@@ -769,7 +797,7 @@
|
|
|
769
797
|
}
|
|
770
798
|
display: flex;
|
|
771
799
|
gap: 0.25em;
|
|
772
|
-
`;import
|
|
800
|
+
`;import Na from"@emotion/styled";var Gt=Na("span")`
|
|
773
801
|
/* font-size: 0.75em; */
|
|
774
802
|
border-radius: 0.5em;
|
|
775
803
|
display: flex;
|
|
@@ -782,7 +810,7 @@
|
|
|
782
810
|
* see the border of the buttons.
|
|
783
811
|
*/
|
|
784
812
|
outline: 1px solid white;
|
|
785
|
-
`,
|
|
813
|
+
`,Oe=Na("span")`
|
|
786
814
|
font-size: 0.75em;
|
|
787
815
|
line-height: 2em;
|
|
788
816
|
padding: 0 0.625em;
|
|
@@ -836,17 +864,17 @@
|
|
|
836
864
|
font-size: 1.33em;
|
|
837
865
|
line-height: 1em;
|
|
838
866
|
}
|
|
839
|
-
`;import{clsx as
|
|
867
|
+
`;import{clsx as cf}from"clsx";import{useCallback as pf}from"react";import{Transforms as df}from"slate";import{ReactEditor as uf,useSlateStatic as ff}from"slate-react";import{jsx as hf}from"react/jsx-runtime";function $a({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=ff(),a=Ie(o,n,t),l=Y({title:t.title,hotkey:`${a.width}x${a.height}`}),s=pf(()=>{let b=uf.findPath(i,e),g=Ie(o,n,t);r(g),df.setNodes(i,g,{at:b})},[e,t,o,n]),m=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),d=o.width===a.width&&o.height===a.height,p=cf({"--disabled":m,"--selected":!m&&d});return hf(Oe,{className:p,onClick:m?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as Ha}from"react/jsx-runtime";function Aa({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Ha(Gt,{children:n.map((i,a)=>Ha($a,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as Ef}from"react";import{useSlateStatic as xf}from"slate-react";import{jsx as qt,jsxs as Fa}from"react/jsx-runtime";var Oa=e=>Fa(y,{...e,children:[qt("rect",{width:6,height:6,x:4,y:5,rx:1}),qt("path",{d:"M4 15h16M4 19h16"})]}),Ua=e=>Fa(y,{...e,children:[qt("rect",{width:6,height:6,x:9,y:5,rx:1}),qt("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as gf,Transforms as Va}from"slate";import{ReactEditor as bf}from"slate-react";function Ka(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=bf.findPath(e,t);gf.withoutNormalizing(e,()=>{let i=Ie(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});Va.setNodes(e,{type:"image-inline",...i},{at:n}),Va.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as _a}from"react/jsx-runtime";function Wa({element:e}){let t=xf(),o=Y({title:"Inline Image",hotkey:"In a line with text"}),r=Ef(()=>{e.type==="image-block"&&Ka(t,e)},[t,e]);return _a(Oe,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:_a(Ua,{})})}import{useCallback as kf}from"react";import{useSlateStatic as vf}from"slate-react";import{Editor as Ga,Text as qa,Transforms as Qt}from"slate";import{ReactEditor as yf}from"slate-react";function Qa(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=yf.findPath(e,t);Ga.withoutNormalizing(e,()=>{let i=Ie(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});Qt.setNodes(e,{type:"image-block",...i},{at:n});let a=E(e,T=>Ga.isBlock(e,T)&&T.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,c=l.children,m=l.children.length,d=n.slice(-1)[0],p=c[m-1];d===m-2&&qa.isText(p)&&p.text===""&&Qt.removeNodes(e,{at:[...s,m-1]});let b=c[0],g=d===1&&qa.isText(b)&&b.text==="";g&&Qt.removeNodes(e,{at:[...s,0]}),Qt.liftNodes(e,{at:[...s,g?d-1:d]})})}import{jsx as ja}from"react/jsx-runtime";function Xa({element:e}){let t=vf(),o=Y({title:"Block Image",hotkey:"On a line by itself"}),r=kf(()=>{e.type==="image-inline"&&Qa(t,e)},[t,e]);return ja(Oe,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ja(Oa,{})})}import{jsx as Ya,jsxs as Tf}from"react/jsx-runtime";function Ja({element:e}){return Tf(Gt,{children:[Ya(Xa,{element:e}),Ya(Wa,{element:e})]})}import{jsx as Za,jsxs as wf}from"react/jsx-runtime";function el({element:e,size:t,setSize:o,srcSize:r,presets:n}){return wf(Da,{children:[Za(Ja,{element:e}),Za(Aa,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as jt,jsxs as Pf}from"react/jsx-runtime";function Xt({element:e,presets:t}){let o=e.url,r=Mf(),[n,i]=tl(!1),[a,l]=tl(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,c=r&&a&&s,m=If({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return Pf(va,{className:m,children:[jt(Ta,{src:o,width:a?.width,height:a?.height}),c?jt(el,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?jt(za,{size:a}):null,c?jt(La,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import{jsx as ol,jsxs as Sf}from"react/jsx-runtime";function rl({element:e,attributes:t,children:o}){let r=Cf();return Sf("div",{...t,children:[ol(ya,{contentEditable:!1,children:ol(Xt,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as Lf}from"slate-react";import Rf from"@emotion/styled";var nl=Rf("span")`
|
|
840
868
|
display: inline;
|
|
841
|
-
`;import{jsx as
|
|
869
|
+
`;import{jsx as il,jsxs as Bf}from"react/jsx-runtime";function al({element:e,attributes:t,children:o}){let r=Lf();return Bf("span",{...t,style:{display:"inline-block"},children:[il(nl,{contentEditable:!1,children:il(Xt,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as ll}from"react/jsx-runtime";function sl({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return ll(rl,{element:e,attributes:t,children:o});case"image-inline":return ll(al,{element:e,attributes:t,children:o})}}function Nf(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=Df.findEventRange(e,t);n&&zf.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 $f={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}]},ml=v((e,t,{createPolicy:o})=>{let r={...$f,...t.image};return e.image={...Ea(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:u(xa,e)},editableProps:{renderElement:sl,onDrop:Nf(e)}})});import{Editor as ut,Element as Q,Transforms as Ue}from"slate";import Hf from"@emotion/styled";var cl=Hf("blockquote")`
|
|
842
870
|
position: relative;
|
|
843
871
|
margin-top: 1em;
|
|
844
872
|
margin-bottom: 1em;
|
|
845
873
|
margin-left: 0;
|
|
846
874
|
border-left: 0.25em solid rgba(0, 0, 0, 0.075);
|
|
847
875
|
padding-left: 1.5em;
|
|
848
|
-
`;import{jsx as
|
|
849
|
-
`),a=i.join(""),l=
|
|
876
|
+
`;import{jsx as Of}from"react/jsx-runtime";function pl(e){return Q.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 Af=2,dl=v(e=>(e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{Ue.wrapNodes(e,{type:"block-quote",children:[]},{match:pl})},outdent:()=>{Ue.liftNodes(e,{match:(t,o)=>pl(t)&&o.length>1})},isActive:()=>{let[t]=ut.nodes(e,{match:o=>Q.isElement(o)&&o.type==="block-quote"});return!!t},increaseDepth:()=>{let[t]=ut.nodes(e,{match:r=>Q.isElement(r)&&r.type==="block-quote"});if(!t||!e.blockQuotePlugin.canIncreaseDepth())return;let[,o]=t;Ue.select(e,o),Ue.wrapNodes(e,{type:"block-quote",children:[]},{at:o,split:!1})},decreaseDepth:()=>{let[t]=ut.nodes(e,{match:i=>Q.isElement(i)&&i.type==="block-quote"});if(!t||!e.blockQuotePlugin.canDecreaseDepth())return;let[o,r]=t,n=o.children;n.length===1&&Q.isElement(n[0])&&n[0].type==="block-quote"&&Ue.unwrapNodes(e,{at:[...r,0],match:i=>Q.isElement(i)&&i.type==="block-quote"})},canIncreaseDepth:()=>{let[t]=ut.nodes(e,{match:i=>Q.isElement(i)&&i.type==="block-quote"});if(!t)return!1;let[o]=t,r=0,n=o;for(;n.children.length===1&&Q.isElement(n.children[0])&&n.children[0]&&n.children[0]&&n.children[0].type==="block-quote";)r++,n=n.children[0];return r<Af},canDecreaseDepth:()=>{let[t]=ut.nodes(e,{match:r=>Q.isElement(r)&&r.type==="block-quote"});if(!t)return!1;let[o]=t;return o.children.length===1&&Q.isElement(o.children[0])&&o.children[0]&&o.children[0].type==="block-quote"}},{name:"block-quote",editor:{normalizeNode(t){let[o,r]=t;return!Q.isElement(o)||o.type!=="block-quote"?!1:ge(e,[o,r],(n,i)=>(Q.isElement(n[0])&&Q.isElement(i[0])&&n[0].type==="block-quote"&&i[0].type==="block-quote"&&Ue.mergeNodes(e,{at:i[1]}),!0))}},editableProps:{renderElement:({element:t,attributes:o,children:r})=>{if(t.type==="block-quote")return Of(cl,{...o,children:r})},onKeyDown:$({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent})}}));import{Editor as th,Element as oh,Transforms as Nl}from"slate";import Uf from"prismjs";import{Element as Kf,Node as _f}from"slate";var{languages:Ff,tokenize:Vf}=Uf;function Wf(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function ul(e){let[t,o]=e;if(!Kf.isElement(t))return[];if(t.type!=="code-block")return[];let r=Ff[t.language];if(r===void 0)return[];let i=t.children.map(p=>`${_f.string(p)}
|
|
877
|
+
`),a=i.join(""),l=Wf(i);function s(p){for(let b=l.length;b>=0;b--){let g=l[b];if(g<=p)return{path:[...o,b],offset:p-g}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let c=[],m=Vf(a,r),d=0;for(let p of m)if(typeof p=="string")d+=p.length;else{let b=s(d),g=s(d+p.length);c.push({anchor:b,focus:g,prismToken:p.type}),d+=p.length}return c}function fl(e,{language:t}){St(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as Gf,Transforms as qf}from"slate";function hl(e,t,o={}){let r=E(e,n=>Gf.isElement(n)&&n.type==="code-block",{at:o.at});return r?(qf.setNodes(e,{language:t},{at:r[1]}),!0):!1}function gl(e){return{createCodeBlock:u(fl,e),setCodeBlockLanguage:u(hl,e)}}var Yt={color:"#999988",fontStyle:"italic"},Qf={opacity:"0.7"},bl={color:"#e3116c"},El={color:"#393a34"},ae={color:"#36acaa"},jo={color:"#00a4db"},xl={color:"#9a050f"},yl={color:"#00009f"},Xo={fontWeight:"bold"},jf={fontStyle:"italic"},kl={comment:Yt,prolog:Yt,doctype:Yt,cdata:Yt,namespace:Qf,string:bl,"attr-value":bl,puncutation:El,operator:El,entity:ae,url:ae,symbol:ae,number:ae,boolean:ae,variable:ae,constant:ae,property:ae,regex:ae,insert:ae,atrule:jo,keyword:jo,"attr-name":jo,function:{...xl,...Xo},delete:xl,tag:yl,selector:yl,important:Xo,bold:Xo,italic:jf};var vl=["text","html","css","svg","javascript","java","c"];import{Element as Yo,Node as Jo,Transforms as Fe}from"slate";function Tl(e,t){if(!Yo.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of Jo.children(e,t[1]))if(Yo.isElement(o))return e.isVoid(o)?(Fe.removeNodes(e,{at:r}),!0):(Fe.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of Jo.children(e,t[1]))if(Yo.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(Fe.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(Fe.removeNodes(e,{at:r}),!0):(Fe.removeNodes(e,{at:r}),Fe.insertNodes(e,{type:"code-block-line",children:[{text:Jo.string(o)}]}),!0)}return!1}import{useCallback as Xf,useRef as Yf}from"react";import{useSelected as Jf}from"slate-react";import{jsx as wl}from"react/jsx-runtime";var Il=e=>wl(y,{...e,children:wl("path",{d:"m6 9 6 6 6-6"})});import Jt from"@emotion/styled";var Ml=Jt("div")`
|
|
850
878
|
position: relative;
|
|
851
879
|
background: var(--code-block-bgcolor);
|
|
852
880
|
margin: 1em 0;
|
|
@@ -865,11 +893,11 @@
|
|
|
865
893
|
* Otherwise they will be square.
|
|
866
894
|
*/
|
|
867
895
|
overflow-x: hidden;
|
|
868
|
-
`,
|
|
896
|
+
`,Pl=Jt("div")`
|
|
869
897
|
padding: 2.25em 1em 1.5em 1em;
|
|
870
898
|
border-radius: 0.5em;
|
|
871
899
|
overflow-x: auto;
|
|
872
|
-
`,
|
|
900
|
+
`,Cl=Jt("span")`
|
|
873
901
|
cursor: pointer;
|
|
874
902
|
position: absolute;
|
|
875
903
|
top: 0.25em;
|
|
@@ -895,7 +923,7 @@
|
|
|
895
923
|
color: var(--shade-800);
|
|
896
924
|
background: var(--shade-300);
|
|
897
925
|
}
|
|
898
|
-
`,
|
|
926
|
+
`,Sl=Jt("div")`
|
|
899
927
|
white-space: pre;
|
|
900
928
|
line-height: 1.5em;
|
|
901
929
|
counter-increment: line;
|
|
@@ -918,7 +946,33 @@
|
|
|
918
946
|
display: inline-block;
|
|
919
947
|
width: 2em;
|
|
920
948
|
} */
|
|
921
|
-
`;import{jsx as
|
|
949
|
+
`;import{jsx as ft,jsxs as Rl}from"react/jsx-runtime";function Ll({element:e,attributes:t,children:o}){let r=Yf(null),n=Jf(),i=A("code-block-dropdown"),a=Xf(()=>{i.layer&&i.close();let l=r.current;if(l===null)return;let s=vl.map(c=>({icon:()=>ft("span",{}),title:c,action:m=>{m.codeBlock.setCodeBlockLanguage(c,{at:e})}}));i.open(()=>ft($e,{dest:l,items:s,close:i.close}))},[e]);return Rl(Ml,{className:n?"--selected":"",...t,children:[Rl(Cl,{contentEditable:!1,onClick:a,ref:r,children:[ft("span",{children:e.language}),ft(Il,{})]}),ft(Pl,{children:o})]})}import{useSelected as Zf}from"slate-react";import{jsx as eh}from"react/jsx-runtime";function Bl({attributes:e,children:t}){let o=Zf();return eh(Sl,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as zl}from"react/jsx-runtime";function Dl({element:e,attributes:t,children:o}){if(e.type==="code-block")return zl(Ll,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return zl(Bl,{element:e,attributes:t,children:o})}import{jsx as rh}from"react/jsx-runtime";var $l=v((e,t,{createPolicy:o})=>{e.codeBlock=gl(e);function r(){let{selection:n}=e;if(!me(n))return!1;let i=E(e,"code-block");return i==null?!1:th.string(e,i[1])===""?(Nl.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:u(Tl,e)},editableProps:{decorate:ul,onKeyDown:$({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=E(e,i=>oh.isElement(i)&&i.type==="code-block");return n?(Nl.select(e,n[1]),!0):!1}}),renderElement:Dl,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&kl[n.prismToken]||null;return a===null?i:rh("span",{style:a,children:i})}}})});import{Transforms as ih}from"slate";import Hl from"@emotion/styled";var Al=Hl("div")`
|
|
950
|
+
position: relative;
|
|
951
|
+
background-color: var(--shade-100);
|
|
952
|
+
border: 1px solid var(--shade-300);
|
|
953
|
+
border-radius: 0.5em;
|
|
954
|
+
padding: 2em 1em 1em 1em;
|
|
955
|
+
margin: 1em 0;
|
|
956
|
+
font-family: "andale mono", AndaleMono, monospace;
|
|
957
|
+
font-size: 0.875em;
|
|
958
|
+
line-height: 1.5;
|
|
959
|
+
white-space: pre-wrap;
|
|
960
|
+
word-break: break-word;
|
|
961
|
+
color: var(--shade-700);
|
|
962
|
+
overflow-x: auto;
|
|
963
|
+
|
|
964
|
+
&.--selected {
|
|
965
|
+
outline: 2px solid var(--select-color);
|
|
966
|
+
}
|
|
967
|
+
`,Ol=Hl("span")`
|
|
968
|
+
position: absolute;
|
|
969
|
+
top: 0.25em;
|
|
970
|
+
right: 0.5em;
|
|
971
|
+
font-size: 0.625em;
|
|
972
|
+
color: var(--shade-500);
|
|
973
|
+
text-transform: uppercase;
|
|
974
|
+
letter-spacing: 0.5px;
|
|
975
|
+
`;import{jsx as Ul,jsxs as nh}from"react/jsx-runtime";function Fl({attributes:e,children:t,element:o}){return nh(Al,{...e,contentEditable:!1,children:[Ul(Ol,{children:"HTML"}),Ul("div",{children:et(o.html)}),t]})}import{jsx as ah}from"react/jsx-runtime";var Vl=v((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!me(n))return!1;let i=E(e,"html-block");return i==null?!1:(ih.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 ah(Fl,{element:n,attributes:i,children:a})}}})});import{Editor as Xl}from"slate";import{Element as ph}from"slate";import{Element as lh,Transforms as sh}from"slate";function Kl(e){return lh.isElement(e)&&e.type==="paragraph"}function _l(e,t){return ge(e,t,(o,r)=>!Kl(o[0])||!Kl(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(sh.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as mh,Transforms as ch}from"slate";function Zo(e,t){return mh.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function Wl(e,t){return Zo(e,t[0])?ge(e,t,(o,r)=>!Zo(e,o[0])||!Zo(e,r[0])?!1:(ch.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function Gl(e,t){let[o,r]=t;return ph.isElement(o)?!!(Wl(e,[o,r])||_l(e,[o,r])):!1}import{clsx as fh}from"clsx";import{useSelected as hh}from"slate-react";import dh from"@emotion/styled";var ql=dh("p")`
|
|
922
976
|
padding: 0;
|
|
923
977
|
margin: 0;
|
|
924
978
|
&:first-child {
|
|
@@ -948,42 +1002,42 @@
|
|
|
948
1002
|
}
|
|
949
1003
|
border-radius: 8px;
|
|
950
1004
|
}
|
|
951
|
-
`;import{Node as
|
|
1005
|
+
`;import{Node as uh}from"slate";function Ql(e){return e.children.length===1&&uh.string(e.children[0]).length===0}import{jsx as gh}from"react/jsx-runtime";function jl({element:e,attributes:t,children:o}){let r=hh(),n=Ql(e);return gh(ql,{...t,className:fh({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as bh}from"react/jsx-runtime";var Yl=v(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{let{selection:o}=e;if(o&&o.anchor.path[0]===o.focus.path[0]){let r=[o.anchor.path[0]],n=Xl.start(e,r);Xl.string(e,{anchor:n,focus:o.anchor}).endsWith(`
|
|
952
1006
|
`)?t():e.insertText(`
|
|
953
|
-
`)}else t()},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:u(
|
|
954
|
-
`)}function
|
|
955
|
-
`),a=
|
|
1007
|
+
`)}else t()},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:u(Gl,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{switch(o.type){case"paragraph":return bh(jl,{element:o,attributes:r,children:n})}},onKeyDown:$({"super+0":e.collapsibleParagraph.convertParagraph})}}});function Jl(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as _,Element as Zt,Node as re,Point as Ve,Range as Eh,Transforms as Me}from"slate";function Zl(e,t,o){try{let r=_.start(e,o),n=_.end(e,o);if(Ve.isBefore(t,r)||Ve.isAfter(t,n))return-1;let i={anchor:r,focus:t};return _.string(e,i).length}catch{return-1}}function es(e,t,o){try{let r=re.get(e,t);if(!Zt.isElement(r))return;let n=re.string(r),i=Math.min(o,n.length),a=_.start(e,t),l=0,s=a.path,c=0;for(let[d,p]of re.texts(r)){let b=d.text.length;if(l+b>=i){s=[...t,...p],c=i-l;break}l+=b}let m={path:s,offset:c};Me.select(e,{anchor:m,focus:m})}catch{}}function xh(e){return re.string(e).includes(`
|
|
1008
|
+
`)}function yh(e,t,o,r){let n=re.string(t),i=n.split(`
|
|
1009
|
+
`),a=_.start(e,o),l=_.end(e,o),s=Ve.isBefore(r.anchor,a)?a:Ve.isAfter(r.anchor,l)?l:r.anchor,c=Ve.isBefore(r.focus,a)?a:Ve.isAfter(r.focus,l)?l:r.focus,m=Math.min(_.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(_.string(e,{anchor:a,focus:c}).length,n.length),p=Math.min(m,d),b=Math.max(m,d),g=0,T=0,C=i.length-1;for(let P=0;P<i.length;P++){let w=g+i[P].length;if(g<=p&&p<=w&&(T=P),g<=b&&b<=w){C=P;break}g=w+1}return{startLineIndex:T,endLineIndex:C}}function kh(e,t,o,r){let n=re.string(t);if(!n.includes(`
|
|
956
1010
|
`))return o;let i=n.split(`
|
|
957
|
-
`);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}
|
|
958
|
-
`),T={...t,children:[{text:
|
|
1011
|
+
`);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=yh(e,t,o,r),s=i.slice(0,a),c=i.slice(a,l+1),m=i.slice(l+1);return s.length===0&&m.length===0?o:(_.withoutNormalizing(e,()=>{let d=o.slice(0,-1),p=o[o.length-1];if(m.length>0){let g=m.join(`
|
|
1012
|
+
`),T={...t,children:[{text:g}]};Me.insertNodes(e,T,{at:[...d,p+1]})}let b=t.children.length;for(let g=b-1;g>=0;g--)Me.removeNodes(e,{at:[...o,g]});if(s.length>0){Me.insertNodes(e,{text:s.join(`
|
|
959
1013
|
`)},{at:[...o,0]});let T={type:"paragraph",children:[{text:c.join(`
|
|
960
|
-
`)}]};
|
|
961
|
-
`)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function
|
|
1014
|
+
`)}]};Me.insertNodes(e,T,{at:[...d,p+1]})}else Me.insertNodes(e,{text:c.join(`
|
|
1015
|
+
`)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function ts(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=Eh.isCollapsed(n),s=Array.from(_.nodes(e,{match:p=>Zt.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(s.length>0){let[,p]=s[0];i=Zl(e,n.anchor,p),a=Zl(e,n.focus,p)}if(s.length===0)return!1;let c=[];_.withoutNormalizing(e,()=>{for(let p=s.length-1;p>=0;p--){let[b,g]=s[p];if(xh(b)){let T=kh(e,b,g,n);c.unshift(T)}else c.unshift(g)}});let m=c.map(p=>{try{let b=re.get(e,p);return Zt.isElement(b)?[b,p]:null}catch{return null}}).filter(p=>p!==null);if(m.length===0)return!1;if(r&&m.every(p=>t(p[0]))?_.withoutNormalizing(e,()=>{for(let p of m)st(e,{type:"paragraph"},p[1])}):_.withoutNormalizing(e,()=>{for(let p of m)st(e,o,p[1])}),m.length>0&&i>=0){let[,p]=m[0];if(l)es(e,p,i);else if(a>=0)try{let b=re.get(e,p);if(Zt.isElement(b)){let g=re.string(b),T=Math.min(i,g.length),C=Math.min(a,g.length),P=_.start(e,p),w=P.path,S=T,M=0;for(let[I,x]of re.texts(b)){let R=I.text.length;if(M+R>=T){w=[...p,...x],S=T-M;break}M+=R}let H=P.path,k=C;M=0;for(let[I,x]of re.texts(b)){let R=I.text.length;if(M+R>=C){H=[...p,...x],k=C-M;break}M+=R}Me.select(e,{anchor:{path:w,offset:S},focus:{path:H,offset:k}})}}catch{es(e,p,i)}}return!0}function os(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function rs(e){return{convertElementTypes:[],addConvertElementType:u(Jl,e),isConvertibleElement:u(os,e),convertElements:u(ts,e)}}var ns=v(e=>(e.convertElement=rs(e),{name:"convert-element"}));import{Editor as er,Path as vh,Range as Th,Transforms as is}from"slate";function as(e){let t=E(e,"heading");if(!t||!e.selection||Th.isExpanded(e.selection)||!er.isEnd(e,e.selection.anchor,t[1]))return!1;let o=vh.next(t[1]);return is.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),is.select(e,{anchor:er.start(e,o),focus:er.start(e,o)}),!0}import{Editor as wh}from"slate";function Ih(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Mh(e,t){let[o]=wh.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function ls(e){return{convertHeading:u(Ih,e),isHeadingActive:u(Mh,e)}}import{css as Ph}from"@emotion/react";import Ke from"@emotion/styled";var _e=Ph`
|
|
962
1016
|
margin-top: 1em;
|
|
963
1017
|
&:first-child {
|
|
964
1018
|
margin-top: 0;
|
|
965
1019
|
}
|
|
966
1020
|
font-weight: bold;
|
|
967
|
-
`,
|
|
968
|
-
${
|
|
1021
|
+
`,ss=Ke("h1")`
|
|
1022
|
+
${_e}
|
|
969
1023
|
font-size: 2.25em;
|
|
970
1024
|
letter-spacing: -0.01em;
|
|
971
|
-
`,
|
|
972
|
-
${
|
|
1025
|
+
`,ms=Ke("h2")`
|
|
1026
|
+
${_e}
|
|
973
1027
|
font-size: 1.5em;
|
|
974
|
-
`,
|
|
975
|
-
${
|
|
1028
|
+
`,cs=Ke("h3")`
|
|
1029
|
+
${_e}
|
|
976
1030
|
font-size: 1.25em;
|
|
977
|
-
`,
|
|
978
|
-
${
|
|
1031
|
+
`,ps=Ke("h4")`
|
|
1032
|
+
${_e}
|
|
979
1033
|
font-size: 1em;
|
|
980
|
-
`,
|
|
981
|
-
${
|
|
1034
|
+
`,ds=Ke("h5")`
|
|
1035
|
+
${_e}
|
|
982
1036
|
font-size: 1em;
|
|
983
|
-
`,
|
|
984
|
-
${
|
|
1037
|
+
`,us=Ke("h6")`
|
|
1038
|
+
${_e}
|
|
985
1039
|
font-size: 1em;
|
|
986
|
-
`;import{jsx as
|
|
1040
|
+
`;import{jsx as We}from"react/jsx-runtime";var fs=v(e=>{e.convertElement.addConvertElementType("heading"),e.heading=ls(e);let t=$({"super+1":G(e.heading.convertHeading,1,!0),"super+2":G(e.heading.convertHeading,2,!0),"super+3":G(e.heading.convertHeading,3,!0),"super+4":G(e.heading.convertHeading,4,!0),"super+5":G(e.heading.convertHeading,5,!0),"super+6":G(e.heading.convertHeading,6,!0)}),o=li(e,{"#":G(e.heading.convertHeading,1,!1),"##":G(e.heading.convertHeading,2,!1),"###":G(e.heading.convertHeading,3,!1),"####":G(e.heading.convertHeading,4,!1),"#####":G(e.heading.convertHeading,5,!1),"######":G(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:u(as,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return We(ss,{...n,children:i});case 2:return We(ms,{...n,children:i});case 3:return We(cs,{...n,children:i});case 4:return We(ps,{...n,children:i});case 5:return We(ds,{...n,children:i});case 6:return We(us,{...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 Sh}from"slate-react";import Ch from"@emotion/styled";var hs=Ch("hr")`
|
|
987
1041
|
position: relative;
|
|
988
1042
|
height: 1em;
|
|
989
1043
|
/* background-color: var(--hr-color); */
|
|
@@ -1013,7 +1067,7 @@
|
|
|
1013
1067
|
outline: 2px solid var(--select-color, blue);
|
|
1014
1068
|
}
|
|
1015
1069
|
}
|
|
1016
|
-
`;import{jsx as
|
|
1070
|
+
`;import{jsx as gs,jsxs as Rh}from"react/jsx-runtime";function bs({attributes:e,children:t}){let o=Sh();return Rh("div",{...e,draggable:!0,children:[t,gs("div",{contentEditable:!1,children:gs(hs,{className:o?"--selected":""})})]})}function Lh(e){return St(e,{type:"horizontal-rule",children:[{text:""}]})}function Es(e){return{insertHorizontalRule:u(Lh,e)}}import{jsx as Bh}from"react/jsx-runtime";var xs=v((e,t,{createPolicy:o})=>(e.horizontalRule=Es(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 Bh(bs,{...r})},onKeyDown:$({"super+-":e.horizontalRule.insertHorizontalRule})}})));import ys from"@emotion/styled";var ks=ys("code")`
|
|
1017
1071
|
color: var(--shade-600);
|
|
1018
1072
|
background-color: var(--inline-code-bgcolor);
|
|
1019
1073
|
border: 1px solid var(--inline-code-border-color);
|
|
@@ -1034,16 +1088,16 @@
|
|
|
1034
1088
|
*/
|
|
1035
1089
|
font-size: 0.75em;
|
|
1036
1090
|
vertical-align: baseline;
|
|
1037
|
-
`,
|
|
1091
|
+
`,tr=ys("span")`
|
|
1038
1092
|
display: inline-block;
|
|
1039
1093
|
opacity: 0;
|
|
1040
1094
|
width: 1px;
|
|
1041
1095
|
overflow: hidden;
|
|
1042
|
-
`;import{jsx as
|
|
1096
|
+
`;import{jsx as vs,jsxs as zh}from"react/jsx-runtime";var Ts=v(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?zh(ks,{spellCheck:!1,children:[vs(tr,{contentEditable:!1,children:"|"}),o,vs(tr,{contentEditable:!1,children:"|"})]}):o,onKeyDown:$({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as Qs,Path as js}from"slate";function ws(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 Is(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 Ms(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 Dh=2;function eo(e){let t=E(e,z);return t?t[0].depth:0}function or(e){return Te(e,z)?eo(e)<Dh:!1}function rr(e){return Te(e,z)?eo(e)>0:!1}function Ps(e){or(e)&&e.list.indent()}function Cs(e){rr(e)&&e.list.outdent()}function Ss(e){return Rt(e,t=>({depth:t.depth+1}),{match:z})}import{Editor as Nh,Transforms as nr}from"slate";function Rs(e){let t=E(e,z);if(!t)return!1;let[o,r]=t;if(Nh.isEmpty(e,o))return o.depth>0?(nr.setNodes(e,{depth:o.depth-1},{at:r}),!0):(st(e,{type:"paragraph"},r),!0);nr.splitNodes(e,{always:!0});let n=E(e,z);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&nr.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as $h}from"slate";function Ls(e){let t=Array.from($h.nodes(e,{match:z}));for(let o of t)if(o[0].depth===0)return!0;return Rt(e,o=>({depth:Math.max(0,o.depth-1)}),{match:z})}import{Transforms as Hh}from"slate";function Bs(e,{at:t=e.selection}={}){let o=E(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;Hh.setNodes(e,{checked:r},{at:o[1]})}function zs(e){return{indent:u(Ss,e),outdent:u(Ls,e),convertUnorderedList:u(Ms,e),convertOrderedList:u(ws,e),convertTaskList:u(Is,e),insertBreak:u(Rs,e),toggleTaskListItem:u(Bs,e),getListDepth:u(eo,e),canIncreaseDepth:u(or,e),canDecreaseDepth:u(rr,e),increaseDepth:u(Ps,e),decreaseDepth:u(Cs,e)}}import{Element as Ah,Transforms as Oh}from"slate";var Ds=Ct(["ordered-list-item"]);function to(e,t){let[o,r]=t;return Ah.isElement(o)?ge(e,[o,r],(n,i)=>{if(!Ds(i[0]))return!1;let a=Ds(n[0])||z(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(Oh.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function Ns(e,t){let[o]=t;return z(o)?to(e,t):!1}import{clsx as Fh}from"clsx";import{useEffect as Vh}from"react";import{ReactEditor as Kh,useSlateStatic as _h}from"slate-react";import oo from"@emotion/styled";var ir=oo("li")`
|
|
1043
1097
|
margin-top: 0.5em;
|
|
1044
1098
|
margin-bottom: 0.5em;
|
|
1045
1099
|
list-style-position: outside;
|
|
1046
|
-
|
|
1100
|
+
`,$s=oo(ir)`
|
|
1047
1101
|
position: relative;
|
|
1048
1102
|
list-style-type: none;
|
|
1049
1103
|
.--list-item-icon {
|
|
@@ -1053,7 +1107,7 @@
|
|
|
1053
1107
|
line-height: 1.5em;
|
|
1054
1108
|
color: var(--shade-600);
|
|
1055
1109
|
}
|
|
1056
|
-
`,
|
|
1110
|
+
`,Hs=oo(ir)`
|
|
1057
1111
|
position: relative;
|
|
1058
1112
|
list-style-type: none;
|
|
1059
1113
|
counter-increment: var(--list-item-var);
|
|
@@ -1078,7 +1132,7 @@
|
|
|
1078
1132
|
/* force numbers to be monospaced for better alignment */
|
|
1079
1133
|
font-variant-numeric: tabular-nums;
|
|
1080
1134
|
}
|
|
1081
|
-
`,
|
|
1135
|
+
`,As=oo(ir)`
|
|
1082
1136
|
position: relative;
|
|
1083
1137
|
list-style-type: none;
|
|
1084
1138
|
.--list-item-icon {
|
|
@@ -1092,7 +1146,7 @@
|
|
|
1092
1146
|
stroke-width: 3px;
|
|
1093
1147
|
}
|
|
1094
1148
|
}
|
|
1095
|
-
`;import{jsx as
|
|
1149
|
+
`;import{jsx as Wh}from"react/jsx-runtime";function Os({element:e,attributes:t,children:o}){let r=_h();Vh(()=>{let a=Kh.findPath(r,e);to(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=Fh({"--first-at-depth":e.__firstAtDepth});return Wh(Hs,{...t,className:i,style:n,children:o})}import{useCallback as Gh}from"react";import{useSlateStatic as qh}from"slate-react";import{jsx as Pe,jsxs as Ks}from"react/jsx-runtime";var Us=e=>Ks("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:[Pe("path",{d:"M0 0h24v24H0z",stroke:"none"}),Pe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Fs=e=>Ks("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:[Pe("path",{d:"M0 0h24v24H0z",stroke:"none"}),Pe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),Pe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Vs=e=>Pe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:Pe("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 ar,jsxs as Qh}from"react/jsx-runtime";function _s({element:e,attributes:t,children:o}){let r=qh(),n=Gh(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return Qh(As,{...t,style:{marginLeft:i},children:[ar("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?ar(Fs,{onClick:n,style:{cursor:"pointer"}}):ar(Us,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Ws,jsxs as jh}from"react/jsx-runtime";function Gs({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return jh($s,{...t,style:{marginLeft:r},children:[Ws("div",{className:"--list-item-icon",contentEditable:!1,children:Ws(Vs,{})}),o]})}import{jsx as lr}from"react/jsx-runtime";function qs({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return lr(Os,{element:e,attributes:t,children:o});case"unordered-list-item":return lr(Gs,{element:e,attributes:t,children:o});case"task-list-item":return lr(_s,{element:e,attributes:t,children:o})}}var Xs=["unordered-list-item","ordered-list-item","task-list-item"],z=Ct(Xs),Ys=v((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType(Xs);let r=e.list=zs(e),n=$({tab:r.indent,"shift+tab":r.outdent,"super+7":u(r.convertOrderedList,!0),"super+8":u(r.convertUnorderedList,!0),"super+9":u(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>Ns(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!Te(e,z))return!1;let a=E(e,z);if(!a)return!1;let l=a[1];if(!js.hasPrevious(l))return e.collapsibleParagraph.convertParagraph(),!0;let s=js.previous(l),c=Qs.node(e,s);return z(c[0])?!1:(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:qs,onKeyDown(i){return Qs.nodes(e,{match:z})?n(i):!1}}})});import{clsx as tg}from"clsx";import{Editor as sr,Point as og,Range as rg}from"slate";import{Editor as Xh,Text as Js,Transforms as Yh}from"slate";function Zs(e,{at:t=e.selection}={}){if(t==null)return;let o=[...Xh.nodes(e,{match:n=>Js.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);Yh.setNodes(e,r,{match:n=>Js.isText(n),split:!0,at:t})}import{Editor as Ce,Point as Jh,Range as Zh}from"slate";function Se(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=Zh.isRange(r)?r.focus:r,i=Jh.isPoint(n)&&(Ce.after(e,n)===null||Ce.isEnd(e,n,Ce.end(e,[]))),a=t,s=(Ce.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:c,...m}=e.activeMarks||{};e.activeMarks=m}s?Ce.removeMark(e,a):Ce.addMark(e,a,!0),typeof o=="string"&&Ce.removeMark(e,o)}function em(e){return{removeMarks:u(Zs,e),toggleMark:u(Se,e),toggleBold:()=>Se(e,"bold"),toggleItalic:()=>Se(e,"italic"),toggleUnderline:()=>Se(e,"underline"),toggleStrike:()=>Se(e,"strike"),toggleHighlight:()=>Se(e,"highlight")}}import eg from"@emotion/styled";var tm=eg("span")`
|
|
1096
1150
|
&.--bold {
|
|
1097
1151
|
font-weight: bold;
|
|
1098
1152
|
}
|
|
@@ -1113,9 +1167,9 @@
|
|
|
1113
1167
|
text-decoration: underline line-through;
|
|
1114
1168
|
}
|
|
1115
1169
|
&.--highlight {
|
|
1116
|
-
background-color: #
|
|
1170
|
+
background-color: #ffff00;
|
|
1117
1171
|
}
|
|
1118
|
-
`;import{jsx as
|
|
1172
|
+
`;import{jsx as ng}from"react/jsx-runtime";var om=v(e=>{e.marksPlugin=em(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){let n=rg.isRange(e.selection)?e.selection.focus:e.selection;og.isPoint(n)&&(sr.after(e,n)===null||sr.isEnd(e,n,sr.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>ng(tm,{className:tg({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike,"--highlight":n.highlight}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as ht,Point as rm}from"slate";function nm(e){if(!e.selection)return;let t=ht.parent(e,e.selection);ci(e,t[1])}var im=v(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=ht.parent(e,e.selection);return rm.equals(ht.start(e,t[1]),e.selection.anchor)?function(){nm(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=ht.parent(e,e.selection);return rm.equals(ht.end(e,t[1]),e.selection.anchor)?function(){nm(e)}:!1}},editableProps:{}}));import{Element as Wg}from"slate";import{Editor as lm,Path as lg,Transforms as sm}from"slate";import{Editor as ig,Path as ag}from"slate";function am(e,t,o){let r=[...ig.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=De(e,o,{at:i});for(let c of r){let m=De(e,o,{at:c});if(l&&m&&ag.equals(l,m)||l==null&&m==null)a=c;else{let d={anchor:i,focus:a};n.push(d),i=a=c,l=m}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function mm(e,t){if(e.selection==null)return!1;let[o,r]=lm.edges(e,e.selection),n=De(e,t,{at:o}),i=De(e,t,{at:r});if(!n&&!i||n&&i&&lg.equals(n,i))return!1;let a=am(e,e.selection,t);return lm.withoutNormalizing(e,()=>{for(let l of a)sm.delete(e,{at:l});sm.collapse(e,{edge:"start"})}),!0}import{Transforms as wg}from"slate";function D(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,[c,m]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:c,cellPath:m,cellIndex:m.slice(-1)[0],cellCount:l.children.length}}import{Editor as sg,Transforms as cm}from"slate";function Ge(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function pm(e,{offset:t=0,at:o=e.selection}={}){let r=D(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return sg.withoutNormalizing(e,()=>{let{columns:s}=n,c=[...s];c.splice(l,0,s[l]),cm.setNodes(e,{columns:c},{at:i}),n.children.forEach((m,d)=>{cm.insertNodes(e,Ge(l),{at:[...i,d,l]})})}),!0}import{Transforms as mg}from"slate";function cg(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ge(t))}}function mr(e,{at:t=e.selection,offset:o=0}={}){let r=D(e,{at:t});if(!r)return!1;let n=cg(r.tableElement.columns.length);return mg.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function dm(e,{at:t}={}){return mr(e,{at:t,offset:1})}import{Editor as cr,Element as pg,Path as dg,Transforms as gt}from"slate";function um(e){return[...Array(e).keys()]}function ug(e){return um(e).map(()=>({align:"left"}))}function fg(e,t){return{type:"table",columns:ug(e),children:um(t).map(()=>hg(e))}}function hg(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>Ge(t))}}function fm(e,t,o,{at:r=e.selection}={}){let n=fg(t,o);return gg(e,n,{at:r})}function gg(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>pg.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;cr.withoutNormalizing(e,()=>{gt.insertNodes(e,t,{at:o}),n&&(gt.select(e,n),gt.move(e))})}else{let n=dg.next(r[1]);cr.withoutNormalizing(e,()=>{gt.insertNodes(e,t,{at:n}),gt.select(e,cr.start(e,n))})}return!0}import{Path as hm}from"slate";function gm(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return q(e,[...i,r+1,o]),!0;try{return q(e,hm.next(i)),!0}catch{return!1}}function bm(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return q(e,[...n,r-1,o]),!0;try{return fi(e,hm.previous(n)),!0}catch{return!1}}import{ReactEditor as bg}from"slate-react";function Eg(){let e=window.getSelection();return e?e.getRangeAt(0).getBoundingClientRect():null}function xg(e,t){return bg.toDOMNode(e,t).getBoundingClientRect()}function pr(e,t){let o=Eg();if(!o)return!1;let r=xg(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function Em(e){let t=D(e);return t&&setTimeout(()=>{pr(e,t.cellElement)||gm(e,t)}),!1}function xm(e){let t=D(e);return t&&setTimeout(()=>{pr(e,t.cellElement)||bm(e,t)}),!1}import{Editor as ym,Transforms as dr}from"slate";import{Transforms as yg}from"slate";function qe(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(yg.removeNodes(e,{at:t.tablePath}),!0)}function km(e,{at:t=e.selection}={}){let o=D(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return qe(e);ym.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),dr.setNodes(e,{columns:s},{at:n}),r.children.forEach((m,d)=>{dr.removeNodes(e,{at:[...n,d,a]})});let c=ym.start(e,[...n,i,Math.min(a,l-2)]);dr.select(e,c)})}import{Editor as vm,Transforms as Tm}from"slate";function wm(e,{at:t=e.selection}={}){let o=D(e,{at:t});return o===void 0?!1:o.rowCount===1?(qe(e),!0):(vm.withoutNormalizing(e,()=>{Tm.removeNodes(e,{at:o.rowPath}),Tm.select(e,vm.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as kg}from"slate";function Im(e,t){let o=D(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}),kg.setNodes(e,{columns:a},{at:n}),!0}import{Path as vg,Transforms as Tg}from"slate";function Mm(e){let t=D(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return q(e,[...a,n,o+1]),!0;if(n<i-1)return q(e,[...a,n+1,0]),!0;let l=vg.next(a);return Tg.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),q(e,l),!0}function Pm(e){let t=D(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return q(e,[...i,n,o-1]),!0;if(n>0)return q(e,[...i,n-1,r-1]),!0}function Cm(e){let t=D(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(q(e,[...a,n,o+1]),!0):n<i-1?(q(e,[...a,n+1,0]),!0):(dm(e),q(e,[...a,n+1,0]),!0)}function Sm(e){return{getTableInfo:u(D,e),insertTable:u(fm,e),insertColumn:u(pm,e),insertRow:u(mr,e),removeTable:u(qe,e),removeColumn:u(km,e),removeRow:u(wm,e),tabForward:u(Mm,e),tabBackward:u(Pm,e),shiftEnterForward:u(Cm,e),selectCell:u(Ig,e),down:u(Em,e),up:u(xm,e),setTableColumnAlign:u(Im,e)}}function Ig(e,{at:t=e.selection}={}){let o=D(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return wg.select(e,r),!0}import{Transforms as Mg}from"slate";function ro(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(Mg.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as Pg,Transforms as ur}from"slate";function Rm(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(Pg.withoutNormalizing(e,()=>{ur.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)ur.mergeNodes(e,{at:[...r,n]});ur.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as Sg}from"react";import{ReactEditor as Rg,useSelected as Lg,useSlateStatic as Bg}from"slate-react";import io from"@emotion/styled";import ce from"@emotion/styled";var Lm=ce("div")`
|
|
1119
1173
|
position: absolute;
|
|
1120
1174
|
/**
|
|
1121
1175
|
* very slightly shaded
|
|
@@ -1139,7 +1193,7 @@
|
|
|
1139
1193
|
background: rgba(0, 0, 0, 0.15);
|
|
1140
1194
|
}
|
|
1141
1195
|
}
|
|
1142
|
-
`,
|
|
1196
|
+
`,Bm=ce(Lm)`
|
|
1143
1197
|
cursor: pointer;
|
|
1144
1198
|
/**
|
|
1145
1199
|
* hangs out on top
|
|
@@ -1149,7 +1203,7 @@
|
|
|
1149
1203
|
right: 0;
|
|
1150
1204
|
height: 3em;
|
|
1151
1205
|
top: -3em;
|
|
1152
|
-
`,
|
|
1206
|
+
`,zm=ce(Lm)`
|
|
1153
1207
|
/**
|
|
1154
1208
|
* hangs out on left
|
|
1155
1209
|
*/
|
|
@@ -1157,7 +1211,7 @@
|
|
|
1157
1211
|
bottom: -1px;
|
|
1158
1212
|
width: 3em;
|
|
1159
1213
|
left: -3em;
|
|
1160
|
-
`,
|
|
1214
|
+
`,Dm=ce("div")`
|
|
1161
1215
|
position: absolute;
|
|
1162
1216
|
background: rgba(0, 0, 0, 0.05);
|
|
1163
1217
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
@@ -1169,7 +1223,7 @@
|
|
|
1169
1223
|
left: 0;
|
|
1170
1224
|
right: 0;
|
|
1171
1225
|
bottom: 0;
|
|
1172
|
-
`,
|
|
1226
|
+
`,Nm=ce(Dm)`
|
|
1173
1227
|
top: 50%;
|
|
1174
1228
|
border-bottom: none;
|
|
1175
1229
|
border-right: none;
|
|
@@ -1195,7 +1249,7 @@
|
|
|
1195
1249
|
|
|
1196
1250
|
/* border-top-left-radius: 0.5em;
|
|
1197
1251
|
border-top-right-radius: 0.5em; */
|
|
1198
|
-
|
|
1252
|
+
`,$m=ce(Dm)`
|
|
1199
1253
|
left: 50%;
|
|
1200
1254
|
border-right: none;
|
|
1201
1255
|
border-bottom: none;
|
|
@@ -1221,7 +1275,7 @@
|
|
|
1221
1275
|
|
|
1222
1276
|
/* border-top-left-radius: 0.5em;
|
|
1223
1277
|
border-bottom-left-radius: 0.5em; */
|
|
1224
|
-
`,
|
|
1278
|
+
`,Hm=ce("div")`
|
|
1225
1279
|
position: absolute;
|
|
1226
1280
|
font-size: 1.5em;
|
|
1227
1281
|
background: white;
|
|
@@ -1230,27 +1284,27 @@
|
|
|
1230
1284
|
svg {
|
|
1231
1285
|
display: block;
|
|
1232
1286
|
}
|
|
1233
|
-
`,
|
|
1287
|
+
`,Qe=ce(Hm)`
|
|
1234
1288
|
color: #c0c0c0;
|
|
1235
1289
|
&:hover {
|
|
1236
1290
|
color: royalblue;
|
|
1237
1291
|
}
|
|
1238
|
-
`,
|
|
1292
|
+
`,no=ce(Hm)`
|
|
1239
1293
|
color: #c0c0c0;
|
|
1240
1294
|
&:hover {
|
|
1241
1295
|
color: firebrick;
|
|
1242
1296
|
}
|
|
1243
|
-
`;var
|
|
1297
|
+
`;var Am=io("table")`
|
|
1244
1298
|
border-collapse: collapse;
|
|
1245
1299
|
margin: 1em 0;
|
|
1246
1300
|
${({columns:e})=>e.map((t,o)=>`td:nth-of-type(${o+1}) { text-align: ${t.align}; }`).join(`
|
|
1247
1301
|
`)}
|
|
1248
|
-
`,
|
|
1302
|
+
`,Om=io("tr")`
|
|
1249
1303
|
position: relative;
|
|
1250
1304
|
&:first-of-type {
|
|
1251
1305
|
background: var(--table-head-bgcolor);
|
|
1252
1306
|
}
|
|
1253
|
-
`,
|
|
1307
|
+
`,Um=io("td")`
|
|
1254
1308
|
position: relative;
|
|
1255
1309
|
border-width: 1px;
|
|
1256
1310
|
border-style: solid;
|
|
@@ -1270,7 +1324,7 @@
|
|
|
1270
1324
|
&:last-of-type {
|
|
1271
1325
|
border-right-color: var(--table-border-color);
|
|
1272
1326
|
}
|
|
1273
|
-
`,
|
|
1327
|
+
`,Fm=io("div")`
|
|
1274
1328
|
/**
|
|
1275
1329
|
* Smaller font inside a table than outside of it
|
|
1276
1330
|
*/
|
|
@@ -1282,7 +1336,7 @@
|
|
|
1282
1336
|
color: rgba(0, 0, 0, 0.6);
|
|
1283
1337
|
font-size: 0.875em; /* 14px */
|
|
1284
1338
|
}
|
|
1285
|
-
`;import{createContext as
|
|
1339
|
+
`;import{createContext as Cg}from"react";var ao=Cg({isSelected:!1});import{jsx as fr}from"react/jsx-runtime";function Vm({element:e,attributes:t,children:o}){let r=Bg(),n=Lg();return Sg(()=>{let i=Rg.findPath(r,e);ro(r,[e,i])},[]),fr(ao.Provider,{value:{isSelected:n},children:fr(Am,{...t,columns:e.columns,children:fr("tbody",{children:o})})})}import{useContext as Ug}from"react";import{useSelected as Fg}from"slate-react";import{useCallback as hr,useRef as zg,useState as Dg}from"react";import{useSlateStatic as Ng}from"slate-react";import{jsx as Z}from"react/jsx-runtime";var je=e=>Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:Z("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"})}),lo=e=>Z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:Z("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"})}),so=()=>Z(y,{children:Z("path",{d:"M4 6h16M4 12h16M4 18h16"})}),Km=()=>Z(y,{children:Z("path",{d:"M4 6h16M4 12h10M4 18h14"})}),_m=()=>Z(y,{children:Z("path",{d:"M4 6h16M8 12h8M6 18h12"})}),Wm=()=>Z(y,{children:Z("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as $g,jsx as pe,jsxs as Gm}from"react/jsx-runtime";function qm({cellElement:e}){let t=Ng(),o=A("column-menu"),r=zg(null),[n,i]=Dg(!1),a=hr(()=>{i(!0)},[]),l=hr(()=>{i(!1)},[]),s=hr(()=>{o.layer&&o.close();let c=r.current;if(c===null)return;let m=[{icon:Km,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:_m,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:Wm,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>pe($e,{dest:c,items:m,close:o.close}))},[]);return Gm(Bm,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[pe(Nm,{className:"--tile",children:pe(so,{})}),n?Gm($g,{children:[pe(no,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:pe(lo,{})}),pe(Qe,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:pe(je,{})}),pe(Qe,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:pe(je,{})})]}):null]})}import{useState as Hg}from"react";import{useSlateStatic as Ag}from"slate-react";import{Fragment as Og,jsx as ke,jsxs as Qm}from"react/jsx-runtime";function jm({cellElement:e}){let t=Ag(),[o,r]=Hg(!1);return Qm(zm,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[ke($m,{className:"--tile",children:ke(so,{})}),o?Qm(Og,{children:[ke(no,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:ke(lo,{})}),ke(Qe,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:ke(je,{})}),ke(Qe,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:ke(je,{})})]}):null]})}import Xm from"@emotion/styled";var Ym=Xm("div")`
|
|
1286
1340
|
position: absolute;
|
|
1287
1341
|
/**
|
|
1288
1342
|
* very slightly shaded
|
|
@@ -1314,7 +1368,7 @@
|
|
|
1314
1368
|
background: rgba(0, 0, 0, 0.15);
|
|
1315
1369
|
}
|
|
1316
1370
|
}
|
|
1317
|
-
`,
|
|
1371
|
+
`,Jm=Xm("div")`
|
|
1318
1372
|
position: absolute;
|
|
1319
1373
|
left: 0;
|
|
1320
1374
|
top: 0;
|
|
@@ -1322,8 +1376,8 @@
|
|
|
1322
1376
|
height: 1.5em;
|
|
1323
1377
|
background: rgba(0, 0, 0, 0.05);
|
|
1324
1378
|
border-radius: 50%;
|
|
1325
|
-
`;import{jsx as
|
|
1326
|
-
`),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!
|
|
1379
|
+
`;import{jsx as Zm}from"react/jsx-runtime";function ec(){return Zm(Ym,{contentEditable:!1,children:Zm(Jm,{className:"--table-menu-tile"})})}import{jsx as gr,jsxs as Vg}from"react/jsx-runtime";function tc({element:e,attributes:t,children:o}){let r=Ug(ao),n=Fg(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return Vg(Um,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?gr(ec,{}):null,a?gr(jm,{cellElement:e}):null,l?gr(qm,{cellElement:e}):null]})}import{jsx as Kg}from"react/jsx-runtime";function oc({attributes:e,children:t}){return Kg(Fm,{...e,children:t})}import{jsx as _g}from"react/jsx-runtime";function rc({attributes:e,children:t}){return _g(Om,{...e,children:t})}import{jsx as mo}from"react/jsx-runtime";function nc({element:e,attributes:t,children:o}){switch(e.type){case"table":return mo(Vm,{element:e,attributes:t,children:o});case"table-row":return mo(rc,{element:e,attributes:t,children:o});case"table-cell":return mo(tc,{element:e,attributes:t,children:o});case"table-content":return mo(oc,{element:e,attributes:t,children:o})}}var ic=v((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=Sm(e),o({name:"table",editor:{deleteBackward:()=>Te(e,"table-cell"),deleteForward:()=>ii(e,"table-cell"),deleteFragment:()=>mm(e,["table-cell"]),insertBreak:()=>E(e,"table-cell")?(e.insertText(`
|
|
1380
|
+
`),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!Wg.isElement(n))return!1;switch(n.type){case"table":return ro(e,r);case"table-cell":return Rm(e,r)}return!1}},editableProps:{renderElement:nc,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 jg}from"@emotion/react";import{css as Gg}from"@emotion/react";var qg=`
|
|
1327
1381
|
--blue-50: rgb(239 246 255);
|
|
1328
1382
|
--blue-100: rgb(219 234 254);
|
|
1329
1383
|
--blue-200: rgb(191 219 254);
|
|
@@ -1334,7 +1388,7 @@
|
|
|
1334
1388
|
--blue-700: rgb(29 78 216);
|
|
1335
1389
|
--blue-800: rgb(30 64 175);
|
|
1336
1390
|
--blue-900: rgb(30 58 138);
|
|
1337
|
-
|
|
1391
|
+
`,Qg=`
|
|
1338
1392
|
--shade-50: rgb(250 250 250);
|
|
1339
1393
|
--shade-100: rgb(244 244 245);
|
|
1340
1394
|
--shade-200: rgb(228 228 231);
|
|
@@ -1345,11 +1399,11 @@
|
|
|
1345
1399
|
--shade-700: rgb(63 63 70);
|
|
1346
1400
|
--shade-800: rgb(39 39 42);
|
|
1347
1401
|
--shade-900: rgb(24 24 27);
|
|
1348
|
-
`,
|
|
1402
|
+
`,ac=Gg`
|
|
1349
1403
|
:root {
|
|
1350
1404
|
/* Tailwind Colors */
|
|
1351
|
-
${
|
|
1352
|
-
${
|
|
1405
|
+
${qg}
|
|
1406
|
+
${Qg}
|
|
1353
1407
|
/* Select Colors */
|
|
1354
1408
|
--select-color: var(--blue-400);
|
|
1355
1409
|
--select-editor-color: var(--blue-200);
|
|
@@ -1371,14 +1425,14 @@
|
|
|
1371
1425
|
/* Horizontal Rule Colors */
|
|
1372
1426
|
--hr-color: var(--shade-300);
|
|
1373
1427
|
}
|
|
1374
|
-
`;import{Fragment as
|
|
1428
|
+
`;import{Fragment as Xg,jsx as lc,jsxs as Yg}from"react/jsx-runtime";var sc=v(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>Yg(Xg,{children:[lc(jg,{styles:ac}),lc(o,{...t})]}),editableProps:{}}));import{clsx as Nb}from"clsx";import{useCallback as $b,useRef as Hb}from"react";import{Editor as Ab,Transforms as Ob}from"slate";import{ReactEditor as Ub,useFocused as Fb,useSlateStatic as Vb}from"slate-react";import{clsx as Jg}from"clsx";import{useCallback as dc,useRef as Zg,useState as eb}from"react";import{ReactEditor as tb,useSlateStatic as ob}from"slate-react";import br from"@emotion/styled";var mc=br(X)`
|
|
1375
1429
|
padding: 0.5em;
|
|
1376
|
-
`,
|
|
1430
|
+
`,cc=br("div")`
|
|
1377
1431
|
display: grid;
|
|
1378
1432
|
grid-template-columns: repeat(5, 1.75em);
|
|
1379
1433
|
grid-template-rows: 1.5em;
|
|
1380
1434
|
/* grid-gap: 1px; */
|
|
1381
|
-
`,
|
|
1435
|
+
`,pc=br("div")`
|
|
1382
1436
|
background: var(--shade-100);
|
|
1383
1437
|
height: 1.5em;
|
|
1384
1438
|
border-radius: 0.125em;
|
|
@@ -1388,10 +1442,11 @@
|
|
|
1388
1442
|
&.--selected {
|
|
1389
1443
|
background: var(--blue-100);
|
|
1390
1444
|
}
|
|
1391
|
-
`;import{Fragment as
|
|
1392
|
-
padding: 1em;
|
|
1445
|
+
`;import{Fragment as rb,jsx as co,jsxs as nb}from"react/jsx-runtime";function uc(e){return[...Array(e).keys()]}function fc({dest:e,close:t}){let[o,r]=eb({x:0,y:0}),n=ob(),i=Zg(null),a=j({src:i,dest:e},({dest:d})=>({left:d.left-8,top:d.top+d.height})),l=uc(5).map(d=>d+1),s=uc(5).map(d=>d+1),c=dc((d,p)=>{r({x:d,y:p})},[r]),m=dc((d,p)=>{n.tablePlugin.insertTable(d,p),tb.focus(n),t()},[n]);return nb(rb,{children:[co(be,{close:t}),co(mc,{ref:i,style:a,children:co(cc,{onMouseLeave:()=>c(0,0),children:l.map(d=>s.map(p=>{let b=p<=o.x&&d<=o.y;return co(pc,{className:Jg({"--selected":b}),onMouseEnter:()=>c(p,d),onClick:()=>m(p,d)},`${p},${d}`)}))})})]})}import Mb from"lodash.throttle";import{useEffect as Pb,useRef as Cb,useState as Sb}from"react";import{useSlateStatic as Rb}from"slate-react";import{jsx as h,jsxs as Xe}from"react/jsx-runtime";var hc=()=>h(y,{children:h("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),gc=()=>h(y,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:h("path",{d:"m2 12 4 4 4-4"})}),bc=()=>h(y,{width:"0.5em",viewBox:"6 0 12 24",children:h("path",{d:"M9 12h6M12 9v6"})}),Ec=()=>h(y,{children:h("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),xc=()=>h(y,{children:h("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"})}),yc=()=>h(y,{children:h("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 kc=()=>h(y,{children:h("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),Er=()=>h(y,{children:h("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),vc=()=>h(y,{children:h("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var po=()=>Xe(y,{children:[h("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),h("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 xr=()=>h(y,{children:h("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"})}),Tc=()=>Xe(y,{children:[h("path",{d:"M10 9l4 3-4 3"}),h("path",{d:"M16 9l4 3-4 3"})]});var wc=()=>h(y,{children:h("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),Ic=()=>Xe(y,{children:[h("rect",{x:4,y:4,width:16,height:16,rx:2}),h("path",{d:"M4 10h16M10 4v16"})]}),Mc=()=>h(y,{children:h("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),Pc=()=>h(y,{children:h("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),Cc=()=>Xe(y,{children:[h("path",{d:"M15 8h.01"}),h("rect",{x:4,y:4,width:16,height:16,rx:3}),h("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),h("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var Sc=()=>h(y,{children:h("path",{d:"M12 5v14M5 12h14"})}),Rc=()=>h(y,{children:h("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"})}),Lc=()=>h(y,{children:h("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var Bc=()=>Xe(y,{children:[h("path",{d:"m9 11 3 3 8-8"}),h("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),yr=()=>h(y,{children:h("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),zc=()=>h(y,{children:h("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),Dc=()=>h(y,{children:h("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})});var Nc=()=>h(y,{children:h("path",{d:"M18 6L6 18M6 6l12 12"})}),$c=()=>Xe(y,{children:[h("path",{d:"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4"}),h("path",{d:"M13.5 6.5l4 4"}),h("path",{d:"m14 19 6-6M18 15l2 2M5 21h4"})]});var kr=[{icon:zc,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:Dc,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],Hc=[{icon:kc,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:Ec,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:xc,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:yc,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],Ac=[...Hc],vr=[{icon:hc,title:f("paragraphStyle"),more:!0,children:Hc}];import{useState as le,useRef as Uc,useEffect as Fc,useCallback as Tr}from"react";import{useSlateStatic as ab}from"slate-react";import ib from"@emotion/styled";var Oc=ib(X)`
|
|
1393
1446
|
width: 18em;
|
|
1394
|
-
|
|
1447
|
+
padding: 0;
|
|
1448
|
+
overflow: hidden;
|
|
1449
|
+
`;import{Fragment as lb,jsx as N,jsxs as U}from"react/jsx-runtime";function Vc({dest:e,close:t}){let o=ab(),r=Uc(void 0),n=Uc(null),[i,a]=le({x:0,y:0}),l=Tr((L,F)=>{a(yt=>({x:yt.x+L,y:yt.y+F}))},[]),s=o.wysimark?.imageDialogState,c=!!o.wysimark?.onImageSave,[m,d]=le(s?.url??""),[p,b]=le(s?.alt??""),[g,T]=le(s?.title??""),[C,P]=le(!1),[w,S]=le(s?.imageSource??(c?"file":"url")),[M,H]=le(s?.vaultPath??""),[k,I]=le(s?.selectedFile),[x,R]=le(!1),[de,zr]=le(null),xp=Tr(L=>{let F=L.target.value;b(F),C||T(F)},[C]),yp=Tr(L=>{T(L.target.value),P(!0)},[]);Fc(()=>{if(k){let L=URL.createObjectURL(k);return zr(L),()=>URL.revokeObjectURL(L)}else zr(null)},[k]),Fc(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:m,alt:p,title:g,imageSource:w,vaultPath:M,selectedFile:k})},[m,p,g,w,M,k]);let bo=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},Eo=j({src:r,dest:e},({src:L,dest:F},yt)=>Nt(L,yt,{left:F.left-16,top:F.top+F.height},{margin:16})),kp={...Eo,left:Eo.left+i.x,top:Eo.top+i.y};async function vp(L){if(L.preventDefault(),w==="file"&&k&&o.wysimark?.onImageSave){if(M.trim()==="")return;R(!0);try{let F=await o.wysimark.onImageSave(k,M);o.image.insertImageFromUrl(F,p,g),bo(),t()}finally{R(!1)}}else if(w==="url"){if(m.trim()==="")return;o.image.insertImageFromUrl(m,p,g),bo(),t()}}function Tp(){bo(),t()}function wp(L){let F=L.target.files?.[0];F&&(I(F),M||H(`attachments/${F.name}`))}function Ip(){n.current?.click()}let xo=w==="file"?!k||M.trim()===""||x:m.trim()==="";return U(lb,{children:[N(be,{close:t}),U(Oc,{ref:r,style:kp,children:[N(xe,{onDrag:l}),U("form",{onSubmit:L=>void vp(L),style:{padding:"8px"},children:[c&&U("div",{style:{marginBottom:"12px"},children:[U("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[N("input",{type:"radio",name:"imageSource",value:"file",checked:w==="file",onChange:()=>S("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),U("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[N("input",{type:"radio",name:"imageSource",value:"url",checked:w==="url",onChange:()=>S("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),w==="url"?U("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),N("input",{type:"text",value:m,onChange:L=>d(L.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"})]}):U("div",{style:{marginBottom:"8px"},children:[N("input",{ref:n,type:"file",accept:"image/*",onChange:wp,style:{display:"none"}}),N("button",{type:"button",onClick:Ip,disabled:x,style:{padding:"8px 16px",backgroundColor:x?"#ccc":"#0078d4",color:x?"#666":"white",border:"none",borderRadius:"4px",cursor:x?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:f("selectFile")}),k&&U("div",{style:{marginTop:"8px"},children:[U("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px",marginBottom:"8px"},children:[de&&N("img",{src:de,alt:"Preview",style:{maxWidth:"60px",maxHeight:"60px",objectFit:"contain",borderRadius:"4px"}}),U("div",{style:{flex:1,minWidth:0},children:[N("div",{style:{fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.name}),U("div",{style:{fontSize:"12px",color:"var(--shade-500)"},children:[(k.size/1024).toFixed(1)," KB"]})]})]}),N("label",{style:{display:"block",marginBottom:"4px"},children:f("vaultPath")}),N("input",{type:"text",value:M,onChange:L=>H(L.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:"attachments/image.png"}),N("div",{style:{fontSize:"12px",color:"var(--shade-500)",marginTop:"4px"},children:f("vaultPathHint")})]})]}),U("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),N("input",{type:"text",value:p,onChange:xp,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")})]}),U("div",{style:{marginBottom:"8px"},children:[N("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),N("input",{type:"text",value:g,onChange:yp,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")})]}),U("div",{style:{display:"flex",gap:"8px"},children:[N("button",{type:"submit",disabled:xo,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:xo?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:xo?"not-allowed":"pointer",fontWeight:"bold"},children:x?f("saving"):f("register")}),N("button",{type:"button",onClick:Tp,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 sb}from"is-hotkey";import{useCallback as uo,useMemo as mb,useRef as cb,useState as bt}from"react";import{Editor as pb,Range as db}from"slate";import{ReactEditor as ub,useSlateStatic as fb}from"slate-react";import Kc from"@emotion/styled";var wr=Kc("div")`
|
|
1395
1450
|
/* Center vertically and horizontally */
|
|
1396
1451
|
display: flex;
|
|
1397
1452
|
align-items: center;
|
|
@@ -1415,9 +1470,9 @@
|
|
|
1415
1470
|
font-size: 1.25em;
|
|
1416
1471
|
stroke-width: 2px;
|
|
1417
1472
|
}
|
|
1418
|
-
`,
|
|
1473
|
+
`,_c=Kc("div")`
|
|
1419
1474
|
font-size: 0.875em;
|
|
1420
1475
|
margin-top: 0.5em;
|
|
1421
1476
|
color: var(--shade-500);
|
|
1422
1477
|
line-height: 1.375;
|
|
1423
|
-
`;import{Fragment as zg,jsx as ce,jsxs as ao}from"react/jsx-runtime";var Bg=Ig("enter");function wc({dest:e,close:t}){let o=Lg(),r=Pg(null),n=q({src:r,dest:e},({src:k,dest:w},D)=>wt(k,D,{left:w.left-12,top:w.top+w.height},{margin:16})),i=Mg(()=>{let{selection:k}=o;return k&&!Sg.isCollapsed(k)?Cg.string(o,k):""},[]),[a,l]=io(""),[s,c]=io(i),[m,d]=io(i),[p,g]=io(!1),b=()=>{let k=s.trim()||a,w=m.trim()||void 0;o.anchor.insertLink(a,k,{select:!0,title:w}),Rg.focus(o),t()},T=yr(k=>{l(k.currentTarget.value)},[l]),M=yr(k=>{let w=k.currentTarget.value;c(w),p||d(w)},[c,d,p]),I=yr(k=>{d(k.currentTarget.value),g(!0)},[d]),v=k=>{Bg(k)&&(k.preventDefault(),k.stopPropagation(),b())};return ao(zg,{children:[ce(he,{close:t}),ao(Ii,{ref:r,style:n,children:[ce(It,{children:ce(Mt,{type:"text",value:a,autoFocus:!0,placeholder:f("linkUrl"),onChange:T,onKeyDown:v})}),ce(It,{style:{marginTop:"0.5em"},children:ce(Mt,{type:"text",value:s,placeholder:f("linkText"),onChange:M,onKeyDown:v})}),ao(It,{style:{marginTop:"0.5em"},children:[ce(Mt,{type:"text",value:m,placeholder:f("tooltipText"),onChange:I,onKeyDown:v}),ao(Tc,{onClick:b,children:[ce(ro,{}),ce(Xm,{})]})]}),ce(vc,{children:f("tooltipHint")})]})]})}var kr=[{icon:ro,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:wc},{icon:lc,title:f("insertImageFromUrl"),more:!0,Component:yc},{icon:nc,title:f("insertTable"),more:!0,Component:qm}],Ic=kr,Mc=kr,Pc=[{icon:sc,title:f("insert"),more:!0,children:kr}];import{Editor as Ng}from"slate";function qe(e){let t=Ng.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 Cc=[{icon:hr,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>qe(e).bold},{icon:tc,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>qe(e).italic},{icon:mc,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>qe(e).strike},{icon:ic,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>qe(e).code},{icon:cc,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>qe(e).underline},{icon:hc,title:f("highlight"),action:e=>e.marksPlugin.toggleHighlight(),active:e=>qe(e).highlight,show:e=>!e.wysimark?.disableHighlight}],Tr=Cc,Sc=[{icon:hr,title:f("format"),more:!0,children:Cc}];var Rc=[{icon:rc,title:f("bulletList"),hotkey:"super+8",action:e=>e.list?.convertUnorderedList(!0),show:e=>!!e.list},{icon:br,title:f("numberedList"),hotkey:"super+7",action:e=>e.list?.convertOrderedList(!0),show:e=>!!e.list},{icon:pc,title:f("checkList"),hotkey:"super+9",action:e=>e.list?.convertTaskList(!0),show:e=>!!e.list&&!e.wysimark?.disableTaskList}],vr=[...Rc,"divider",...Er],Lc=[{icon:br,title:f("list"),more:!0,children:[...Rc,"divider",...Er],show:e=>!!e.list}];import{Editor as Bc,Transforms as lo}from"slate";var zc=[{icon:gr,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:oc,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:ac,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[r,n]=o,i=Bc.string(e,n);lo.removeNodes(e,{at:n}),lo.insertNodes(e,{type:"paragraph",children:[{text:i}]},{at:n});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock?.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=Bc.string(e,t);lo.delete(e),lo.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.codeBlock&&!e.wysimark?.disableCodeBlock}],wr=zc,Nc=[{icon:gr,title:f("quote"),more:!0,children:zc}];var so={icon:fc,title:f("switchToRawMarkdown"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&!e.wysimark.isRawMode,active:()=>!1},mo={icon:no,title:f("switchToVisualEditor"),action:e=>{e.wysimark&&typeof e.wysimark.toggleRawMode=="function"&&e.wysimark.toggleRawMode()},show:e=>!!(e.wysimark&&e.wysimark.isRawMode),active:()=>!1};var Dg=[...bc,"divider",...vr,"divider",...Tr,"divider",...Ic,"divider",...wr,"divider",so,mo],$g=[...xr,"divider",...vr,"divider",...Tr,"divider",...Mc,"divider",...wr,"divider",so,mo],Dc=[...xr,"divider",...Lc,"divider",...Sc,"divider",...Pc,"divider",...Nc,"divider",so,mo],$c=Dc;var Qe=[Dg,$g,Dc];import{clsx as Hg}from"clsx";import{useCallback as Ir,useRef as Ag}from"react";import{ReactEditor as Og,useSlate as Ug,useSlateStatic as Fg}from"slate-react";import{jsx as co,jsxs as Vg}from"react/jsx-runtime";function Hc({item:e}){let t=Fg(),o=Ug(),r=e.active?e.active(o):!1,n=Ag(null),i=J({title:e.title,hotkey:()=>e.hotkey?Tt(e.hotkey):void 0}),a=$("menu"),l=Ir(()=>{let m=n.current,d=e.children,p=e.Component;m&&(d?a.open(()=>co(Ct,{dest:m,items:d,close:a.close})):p&&a.open(()=>co(p,{dest:m,close:a.close})))},[e]),s=Ir(()=>{if(e.action){e.action(t),Og.focus(t);return}a.layer?a.close():l()},[a.layer,e]),c=Ir(m=>{i.onMouseEnter(m),a.layer&&l()},[a.layer]);return Vg(Hi,{"data-item-type":"button",ref:n,onMouseEnter:c,onMouseLeave:i.onMouseLeave,onClick:s,className:Hg({"--active":r&&!Io(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Io(e?.title)?.includes("Depth")}),children:[co(e.icon,{}),e.more?co(jm,{}):null]})}import{jsx as je}from"react/jsx-runtime";function Qg({item:e}){let t=qg();return e==="divider"?je(Di,{"data-item-type":"divider",children:je($i,{})}):(e.show===void 0?!0:e.show(t))?je(Hc,{item:e}):null}function jg(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");if(!t||!o)throw new Error("Button or divider not found");return{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function Xg(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var Jg=48;function Ac(){let e=_g(null),[t,o]=Gg($c);return Wg(()=>{let r=Kg(()=>{let i=e.current;if(!i)throw new Error("Toolbar not found");let a=jg(i);for(let l=0;l<Qe.length-1;l++)if(Xg(Qe[l],a.button,a.divider)<a.toolbar-Jg){o(Qe[l]);return}o(Qe[Qe.length-1])},100,{trailing:!0}),n=setTimeout(r,0);return window.addEventListener("resize",r),()=>{clearTimeout(n),window.removeEventListener("resize",r)}},[]),je(zi,{ref:e,children:je(Ni,{children:t.map((r,n)=>je(Qg,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Mr,jsxs as ab}from"react/jsx-runtime";function Oc({attributes:e,Editable:t}){let o=eb(null),r=ib(),n=nb(),i=Zg(a=>{a.target===a.currentTarget&&(ob.select(r,tb.end(r,[])),rb.focus(r))},[r]);return Mr(Ei,{children:ab(Si,{ref:o,className:Yg({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Mr(Ac,{}),Mr(t,{as:Ci,...e,style:{overflowY:"auto"}})]})})}var Uc=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:Oc,editableProps:{}}));import{Editor as Pr,Node as lb,Path as sb,Transforms as mb}from"slate";var Fc=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Pr.isEditor(t[0]))return!1;let o=[e.children.length-1],r=lb.child(e,e.children.length-1);return(Pr.hasBlocks(e,r)||Pr.isVoid(e,r))&&mb.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:sb.next(o)}),!0}}}));import{Transforms as cb}from"slate";function pb(e,t){let o=pe(t),r=ue(o);cb.insertNodes(e,r)}function Vc(e){return{pasteMarkdown:u(pb,e)}}var Kc=y(e=>(e.pasteMarkdown=Vc(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let{types:o}=t.clipboardData;if(o.length!==1||o[0]!=="text/plain")return!1;let r=t.clipboardData.getData("text/plain");return e.pasteMarkdown.pasteMarkdown(r),xe(t),!0}}}));import{jsx as ub}from"react/jsx-runtime";function db(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return ub("span",{...t,children:e.children})}var Wc=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:db}})));var _c=[Kc,Hl,ea,ql,Ds,os,el,kl,Am,Yl,Fc,Rs,na,As,Rl,Fm,Uc,Ja,Wc];var{withSink:Gc,SinkEditable:qc}=Wn(_c);import{useState as fb}from"react";import{createEditor as hb,Editor as gb,Transforms as bb}from"slate";import{withHistory as Eb}from"slate-history";import{withReact as xb}from"slate-react";function Cr({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l}={}){let[s]=fb(()=>{let c=hb(),m=Gc(xb(Eb(c)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return m.convertElement.addConvertElementType("paragraph"),c.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0},c.getMarkdown=()=>Ze(c.children),c.setMarkdown=d=>{let p=pe(d),g=ue(p);c.children=g,c.selection=null,bb.select(c,gb.start(c,[0]))},m});return s}import{jsx as re,jsxs as Mb}from"react/jsx-runtime";function Ib({children:e,attributes:t}){return re("span",{...t,children:e})}function jc({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,c]=Qc(!1),[m,d]=Qc(t),p=po(!1),g=po(void 0),b=po(void 0),T=po(void 0),M=Pe(yb(()=>{let P=Ze(e.children);e.wysimark.prevValue={markdown:P,children:e.children},T.current=P,o(P)},r,{leading:!1,trailing:!0}),[e,o,r]),I=Pe(P=>{if(p.current){p.current=!1,b.current=P;return}b.current=P,M()},[M]);if(e.wysimark.prevValue==null||g.current==null){p.current=!0;let P=s?t:pe(t),L=ue(P);e.children=L,b.current=g.current=L,e.wysimark.prevValue={markdown:t,children:L},T.current=t}else if(s)e.wysimark.prevValue.markdown=t,T.current=t;else{let P=t!==e.wysimark.prevValue.markdown,L=t!==T.current;if(P&&L){p.current=!0;let U=pe(t),G=ue(U);e.children=G,e.selection=null,Tb.select(e,kb.start(e,[0]))}}let v=Pe(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&vb.focus(e)},[e]),k=Pe(()=>{M.flush()},[M]),w=P=>{let L=P.target.value;d(L),o(L)},D=Pe(()=>{m!==e.getMarkdown()&&e.setMarkdown(m)},[e,m]),H=Pe(()=>{d(t)},[t]),ne=Pe(()=>{s?D():H(),c(!s)},[s,D,H]);return e.wysimark.isRawMode=s,e.wysimark.disableRawMode||(e.wysimark.toggleRawMode=ne),e.wysimark.onImageChange=l,Mb("div",{style:{position:"relative"},children:[s&&re("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:re("div",{onClick:ne,style:{background:"none",border:"1px solid #4a90e2",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:"rgba(74, 144, 226, 0.1)",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:f("switchToVisualEditor"),role:"button",tabIndex:0,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(ne(),P.preventDefault())},children:re("span",{style:{color:"#4a90e2",fontSize:"1.25em"},children:re(no,{})})})}),re("div",{style:{display:s?"block":"none",textAlign:"center"},children:re("textarea",{value:go(m).replace(/ /g,""),onChange:w,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"14px",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),re("div",{style:{display:s?"none":"block"},children:re(wb,{editor:e,initialValue:g.current??e.children,onChange:I,children:re(qc,{renderLeaf:Ib,onMouseDown:v,onBlur:k,placeholder:n,className:i,style:a})})})]})}import{jsx as Xc}from"react/jsx-runtime";function zb({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Lb(r.initialMarkdown||""),l=Rb(i),s=Cr(r);l.current=i,Sb(n,()=>({getMarkdown(){return l.current},setMarkdown(m){l.current=m,a(m)}}),[l,a]);let c=Cb(m=>{l.current=m,a(m),e?.(m)},[s]);return Xc(jc,{editor:s,value:i,className:o||"",onChange:c,placeholder:t})}function mH(e,t){let o=Pb(),r=Bb(e);return r.render(Xc(zb,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{jc as Editable,mH as createWysimark,Cr as useEditor};
|
|
1478
|
+
`;import{Fragment as gb,jsx as ee,jsxs as Et}from"react/jsx-runtime";var hb=sb("enter");function Wc({dest:e,close:t}){let o=fb(),r=cb(null),[n,i]=bt({x:0,y:0}),a=uo((I,x)=>{i(R=>({x:R.x+I,y:R.y+x}))},[]),l=j({src:r,dest:e},({src:I,dest:x},R)=>Nt(I,R,{left:x.left-12,top:x.top+x.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},c=mb(()=>{let{selection:I}=o;return I&&!db.isCollapsed(I)?pb.string(o,I):""},[]),[m,d]=bt(""),[p,b]=bt(c),[g,T]=bt(c),[C,P]=bt(!1),w=()=>{let I=p.trim()||m,x=g.trim()||void 0;o.anchor.insertLink(m,I,{select:!0,title:x}),ub.focus(o),t()},S=uo(I=>{d(I.currentTarget.value)},[d]),M=uo(I=>{let x=I.currentTarget.value;b(x),C||T(x)},[b,T,C]),H=uo(I=>{T(I.currentTarget.value),P(!0)},[T]),k=I=>{hb(I)&&(I.preventDefault(),I.stopPropagation(),w())};return Et(gb,{children:[ee(be,{close:t}),Et(Di,{ref:r,style:s,children:[ee(xe,{onDrag:a}),Et("div",{style:{padding:"0.75em"},children:[ee($t,{children:ee(Ht,{type:"text",value:m,autoFocus:!0,placeholder:f("linkUrl"),onChange:S,onKeyDown:k})}),ee($t,{style:{marginTop:"0.5em"},children:ee(Ht,{type:"text",value:p,placeholder:f("linkText"),onChange:M,onKeyDown:k})}),Et($t,{style:{marginTop:"0.5em"},children:[ee(Ht,{type:"text",value:g,placeholder:f("tooltipText"),onChange:H,onKeyDown:k}),Et(wr,{onClick:w,children:[ee(po,{}),ee(bc,{})]}),ee(wr,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:ee(Nc,{})})]}),ee(_c,{children:f("tooltipHint")})]})]})]})}var Ir=[{icon:po,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Wc},{icon:Cc,title:f("insertImageFromUrl"),more:!0,Component:Vc},{icon:Ic,title:f("insertTable"),more:!0,Component:fc}],Gc=Ir,qc=Ir,Qc=[{icon:Sc,title:f("insert"),more:!0,children:Ir}];import{Editor as bb}from"slate";function Ye(e){let t=bb.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 jc=[{icon:Er,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Ye(e).bold},{icon:vc,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Ye(e).italic},{icon:Rc,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Ye(e).strike},{icon:Mc,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Ye(e).code},{icon:Lc,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Ye(e).underline},{icon:$c,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Ye(e).highlight,show:e=>!e.wysimark.disableHighlight}],Mr=jc,Xc=[{icon:Er,title:f("format"),more:!0,children:jc}];var Yc=[{icon:wc,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:yr,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:Bc,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Pr=[...Yc,"divider",...kr],Jc=[{icon:yr,title:f("list"),more:!0,children:[...Yc,"divider",...kr]}];import{Editor as Zc,Transforms as fo}from"slate";var ep=[{icon:xr,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:Tc,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:Pc,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=Zc.string(e,r);fo.removeNodes(e,{at:r}),fo.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=Zc.string(e,t);fo.delete(e),fo.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}],Cr=ep,tp=[{icon:xr,title:f("quote"),more:!0,children:ep}];var Eb=[...Ac,"divider",...Pr,"divider",...Mr,"divider",...Gc,"divider",...Cr],xb=[...vr,"divider",...Pr,"divider",...Mr,"divider",...qc,"divider",...Cr],op=[...vr,"divider",...Jc,"divider",...Xc,"divider",...Qc,"divider",...tp],rp=op;var Je=[Eb,xb,op];import{clsx as yb}from"clsx";import{useCallback as Sr,useRef as kb}from"react";import{ReactEditor as vb,useSlate as Tb,useSlateStatic as wb}from"slate-react";import{jsx as ho,jsxs as Ib}from"react/jsx-runtime";function np({item:e}){let t=wb(),o=Tb(),r=e.active?e.active(o):!1,n=kb(null),i=Y({title:e.title,hotkey:()=>e.hotkey?zt(e.hotkey):void 0}),a=A("menu"),l=Sr(()=>{let m=n.current,d=e.children,p=e.Component;m&&(d?a.open(()=>ho($e,{dest:m,items:d,close:a.close})):p&&a.open(()=>ho(p,{dest:m,close:a.close})))},[e]),s=Sr(()=>{if(e.action){e.action(t),vb.focus(t);return}a.layer?a.close():l()},[a.layer,e]),c=Sr(m=>{i.onMouseEnter(m),a.layer&&l()},[a.layer]);return Ib(Gi,{"data-item-type":"button",ref:n,onMouseEnter:c,onMouseLeave:i.onMouseLeave,onClick:s,className:yb({"--active":r&&!So(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&So(e?.title)?.includes("Depth")}),children:[ho(e.icon,{}),e.more?ho(gc,{}):null]})}import{jsx as Ze}from"react/jsx-runtime";function Lb({item:e}){let t=Rb();return e==="divider"?Ze(_i,{"data-item-type":"divider",children:Ze(Wi,{})}):(e.show===void 0?!0:e.show(t))?Ze(np,{item:e}):null}function Bb(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");if(!t||!o)throw new Error("Button or divider not found");return{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function zb(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var Db=48;function ip(){let e=Cb(null),[t,o]=Sb(rp);return Pb(()=>{let r=Mb(()=>{let i=e.current;if(!i)throw new Error("Toolbar not found");let a=Bb(i);for(let l=0;l<Je.length-1;l++)if(zb(Je[l],a.button,a.divider)<a.toolbar-Db){o(Je[l]);return}o(Je[Je.length-1])},100,{trailing:!0}),n=setTimeout(r,0);return window.addEventListener("resize",r),()=>{clearTimeout(n),window.removeEventListener("resize",r)}},[]),Ze(Vi,{ref:e,children:Ze(Ki,{children:t.map((r,n)=>Ze(Lb,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Rr,jsxs as Kb}from"react/jsx-runtime";function ap({attributes:e,Editable:t}){let o=Hb(null),r=Vb(),n=Fb(),i=$b(a=>{a.target===a.currentTarget&&(Ob.select(r,Ab.end(r,[])),Ub.focus(r))},[r]);return Rr(Pi,{children:Kb(Ai,{ref:o,className:Nb({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Rr(ip,{}),Rr(t,{as:Hi,...e,style:{overflowY:"auto"}})]})})}var lp=v((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:ap,editableProps:{}}));import{Editor as Lr,Node as _b,Path as Wb,Transforms as Gb}from"slate";var sp=v(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Lr.isEditor(t[0]))return!1;let o=[e.children.length-1],r=_b.child(e,e.children.length-1);return(Lr.hasBlocks(e,r)||Lr.isVoid(e,r))&&Gb.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:Wb.next(o)}),!0}}}));import{Transforms as qb}from"slate";function Qb(e,t){let o=ue(t),r=he(o);qb.insertNodes(e,r)}function mp(e){return{pasteMarkdown:u(Qb,e)}}var cp=v(e=>(e.pasteMarkdown=mp(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let{types:o}=t.clipboardData;if(o.length!==1||o[0]!=="text/plain")return!1;let r=t.clipboardData.getData("text/plain");return e.pasteMarkdown.pasteMarkdown(r),ve(t),!0}}}));import{jsx as Xb}from"react/jsx-runtime";function jb(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return Xb("span",{...t,children:e.children})}var pp=v((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:jb}})));var dp=[cp,ns,da,fs,om,Ts,dl,$l,Vl,ic,xs,sp,Ys,ga,im,Yl,sc,lp,ml,pp];var Yb=Zn(dp),{withSink:up,SinkEditable:fp}=Yb;import{useState as Jb}from"react";import{createEditor as Zb,Editor as eE,Transforms as tE}from"slate";import{withHistory as oE}from"slate-history";import{withReact as rE}from"slate-react";function Br({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l}={}){let[s]=Jb(()=>{let c=Zb(),m=up(rE(oE(c)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return m.convertElement.addConvertElementType("paragraph"),c.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0},c.getMarkdown=()=>nt(c.children),c.setMarkdown=d=>{let p=ue(d),b=he(p);c.children=b,c.selection=null,tE.select(c,eE.start(c,[0]))},m});return s}import{jsx as te,jsxs as gp}from"react/jsx-runtime";function mE({children:e,attributes:t}){return te("span",{...t,children:e})}function bp({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,c]=hp(!1),[m,d]=hp(t),p=go(!1),b=go(void 0),g=go(void 0),T=go(null),C=xt(nE(()=>{let x=nt(e.children);e.wysimark.prevValue={markdown:x,children:e.children},o(x)},r,{leading:!1,trailing:!0}),[e,o,r]),P=xt(()=>{g.current!==e.children&&(g.current=e.children,C())},[C]);if(!s){let x=T.current??t;if(T.current!==null&&(T.current=null),e.wysimark.prevValue==null||b.current==null){p.current=!0;let R=ue(x),de=he(R);e.children=de,g.current=b.current=de,e.wysimark.prevValue={markdown:x,children:de}}else if(x!==e.wysimark.prevValue.markdown){p.current=!0;let R=ue(x),de=he(R);e.children=de,e.selection=null,aE.select(e,iE.start(e,[0]))}}let w=xt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&lE.focus(e)},[e]),S=xt(()=>{C.flush()},[C]),M=x=>{let R=x.target.value;d(R),o(R)},H=xt(()=>{let x=e.getMarkdown();d(x)},[e]),k=()=>{s?(T.current=m,e.wysimark.prevValue=void 0,b.current=void 0,g.current=void 0):H(),c(!s)};e.wysimark.onImageChange=l,e.wysimark.onChange=o;let I=e.wysimark.disableRawMode;return gp("div",{style:{position:"relative"},children:[!I&&te("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:te("div",{onClick:k,style:{background:"none",border:s?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:s?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:s?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:s?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(k(),x.preventDefault())},children:gp("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[te("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:s?"rgba(74, 144, 226, 0.05)":"transparent"}),te("path",{d:"M7 15V9L10 12L13 9V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),te("path",{d:"M16 9H18V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),te("path",{d:"M16 12H18",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),te("div",{style:{display:s?"block":"none",textAlign:"center"},children:te("textarea",{value:et(m).replace(/ /g,""),onChange:M,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"14px",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),te("div",{style:{display:s?"none":"block"},children:te(sE,{editor:e,initialValue:b.current,onChange:P,children:te(fp,{renderLeaf:mE,onMouseDown:w,onBlur:S,placeholder:n,className:i,style:a})})})]})}import{jsx as Ep}from"react/jsx-runtime";function gE({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=fE(r.initialMarkdown||""),l=uE(i),s=Br(r);l.current=i,dE(n,()=>({getMarkdown(){return l.current},setMarkdown(m){l.current=m,a(m)}}),[l,a]);let c=pE(m=>{l.current=m,a(m),e?.(m)},[s]);return Ep(bp,{editor:s,value:i,className:o||"",onChange:c,placeholder:t})}function EA(e,t){let o=cE(),r=hE(e);return r.render(Ep(gE,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{bp as Editable,EA as createWysimark,Br as useEditor};
|