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