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