wysimark-lite 0.25.10 → 0.25.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -7
- package/dist/index.mjs +23 -29
- 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,4 +1,4 @@
|
|
|
1
|
-
"use client";import{createRef as
|
|
1
|
+
"use client";import{createRef as yE,useCallback as kE,useImperativeHandle as vE,useRef as TE,useState as wE}from"react";import{createRoot as IE}from"react-dom/client";import fE from"lodash.throttle";import{useCallback as kt,useRef as vt,useState as kp}from"react";import{Editor as hE,Transforms as gE}from"slate";import{ReactEditor as bE,Slate as EE}from"slate-react";import rd from"remark-parse";import{unified as nd}from"unified";function vo(){return{enter:{table:Rp,tableData:Hr,tableHeader:Hr,tableRow:zp},exit:{codeText:Bp,table:Lp,tableData:ko,tableHeader:ko,tableRow:ko}}}function Rp(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 Lp(e){this.exit(e),this.data.inTable=void 0}function zp(e){this.enter({type:"tableRow",children:[]},e)}function ko(e){this.exit(e)}function Hr(e){this.enter({type:"tableCell",children:[]},e)}function Bp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Dp));let o=this.stack[this.stack.length-1];o.type,o.value=t,this.exit(e)}function Dp(e,t){return t==="|"?t:e}import{gfm as Np}from"micromark-extension-gfm";import{gfmToMarkdown as $p}from"mdast-util-gfm";function Ar(e){if(e)return function(t){return this.data||(this.data={}),e.call(this,t)}}function Or(){return function(){if(!this)return;let e=this.data(),t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(Np());let n=function(){let i=vo();if(i.enter)for(let a of Object.keys(i.enter))i.enter[a]=Ar(i.enter[a]);if(i.exit)for(let a of Object.keys(i.exit))i.exit[a]=Ar(i.exit[a]);return i};o.push(n()),r.push($p())}}function fe(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o="\x07WYSIMARK_",r=`${o}LINK_`,n=`${o}HTML_`,i="\x07",a=[],l=0,s=e.replace(t,p=>(a.push(p),`${r}${l++}${i}`)),m=[];s=Ap(s,m,n,i);let d=/(https?:\/\/[^\s]+)/g;s=s.replace(d,p=>p.replace(/\//g,"\\/"));for(let p=0;p<m.length;p++)s=s.replace(`${n}${p}${i}`,m[p]);for(let p=0;p<a.length;p++)s=s.replace(`${r}${p}${i}`,a[p]);return s}function ot(e){return e.replace(/\\\//g,"/")}var Hp=new Set(["script","style"]);function Ap(e,t,o,r){let n="",i=0;for(;i<e.length;){let a=e.indexOf("<",i);if(a===-1){n+=e.slice(i);break}if(n+=e.slice(i,a),e.startsWith("<!--",a)){let u=e.indexOf("-->",a+4);if(u===-1){n+=e.slice(a);break}let h=e.slice(a,u+3);t.push(h),n+=`${o}${t.length-1}${r}`,i=u+3;continue}if(e.startsWith("<![CDATA[",a)){let u=e.indexOf("]]>",a+9);if(u===-1){n+=e.slice(a);break}let h=e.slice(a,u+3);t.push(h),n+=`${o}${t.length-1}${r}`,i=u+3;continue}let l=To(e,a);if(!l){n+="<",i=a+1;continue}let s=t.length,m=`${o}${s}${r}`;if(!l.name){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}let c=l.name.toLowerCase();if(l.isClosing||l.isSelfClosing){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}if(Hp.has(c)){let u=e.toLowerCase().indexOf(`</${c}`,l.endIndex+1);if(u!==-1){let h=To(e,u);if(h){let v=e.slice(a,h.endIndex+1);t.push(v),n+=m,i=h.endIndex+1;continue}}}let d=Up(e,c,l.endIndex+1);if(d!==null){let u=e.slice(a,d+1);t.push(u),n+=m,i=d+1;continue}let p=e.slice(a,l.endIndex+1);t.push(p),n+=m,i=l.endIndex+1}return n}function To(e,t){if(e[t]!=="<")return null;let o=Op(e,t);if(o===-1)return null;let r=t+1;if(r>=e.length)return null;let n=e[r];if(n==="!"||n==="?")return{name:null,endIndex:o,isClosing:!1,isSelfClosing:!0};let i=!1;n==="/"&&(i=!0,r+=1);let a=/^[A-Za-z][A-Za-z0-9-]*/.exec(e.slice(r));if(!a)return null;let l=a[0],s=e.slice(t,o+1),m=/\/\s*>$/.test(s);return{name:l,endIndex:o,isClosing:i,isSelfClosing:m}}function Op(e,t){let o=null;for(let r=t+1;r<e.length;r++){let n=e[r];if(o){n===o&&(o=null);continue}if(n==="'"||n==='"'){o=n;continue}if(n===">")return r}return-1}function Up(e,t,o){let r=1,n=o,i=t.toLowerCase();for(;n<e.length;){let a=e.indexOf("<",n);if(a===-1)return null;let l=To(e,a);if(!l||!l.name){n=a+1;continue}if(l.name.toLowerCase()===i&&(l.isClosing?r-=1:l.isSelfClosing||(r+=1),r===0))return l.endIndex;n=l.endIndex+1}return null}function Ur(e,t){if(!e)throw new Error(`${t}`)}function Tt(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 he(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function Fr(e){return[{type:"block-quote",children:Be(e.children)}]}function Vr(e){let t=e.value.split(`
|
|
2
2
|
`);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function Kr(e){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...Be(e.children)]}]}import{Text as Zr}from"slate";import{Text as Yr}from"slate";import*as rt from"slate";function A(e){return rt.Text.isText(e)}function re(e){return rt.Element.isElement(e)}function R(e){return rt.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var _r={bold:"**",italic:"_",strike:"~~",highlight:"<mark>",code:""},Wr={bold:"**",italic:"_",strike:"~~",highlight:"</mark>",code:""};function Fp(e){if(e in _r)return _r[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_OPEN_TOKEN lookup`)}function Vp(e){if(e in Wr)return Wr[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_CLOSE_TOKEN lookup`)}function Gr(e){return e.map(Fp).join("")}function qr(e){return e.map(Vp).join("")}import{Text as Kp}from"slate";function nt(e){let{text:t,...o}=e;return Object.keys(o)}function wo(e){if(Kp.isText(e)){if(R(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return nt(e)}else{if(e.type==="anchor")return Io(e.children);throw new Error(`Unhandled type ${e.type}`)}}function Io(e){let t;for(let o of e){if(!A(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(R(o))continue;let r=nt(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 Qr=["bold","italic","underline","strike","highlight","code"];function Xr(e){return e.slice().sort((t,o)=>Qr.indexOf(t)-Qr.indexOf(o))}var _p=["\\","`","*","_","[","]","~","|","<"],Wp=new RegExp(`(${_p.map(e=>`\\${e}`).join("|")})`,"g");function jr(e){let t=e.replace(Wp,o=>`\\${o}`);return t=t.replace(/^(#{1,6})(\s)/m,"\\$1$2"),t=t.replace(/^(\d+)([.)]\s)/m,"$1\\$2"),t=t.replace(/^([-+>])\s/m,"\\$1 "),t}function Gp(e,t){let o=nt(e),r=nt(t);return o.length==r.length&&o.every(n=>r.includes(n))}function Jr(e,t){let o=Yr.isText(e),r=Yr.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:Gp(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function en(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...Jr(e[o],r))}return t.length===0&&t.push({text:""}),Zr.isText(t[0])||t.unshift({text:""}),Zr.isText(t[t.length-1])||t.push({text:""}),t}function tn(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var qp=/^([^?#]*)(?:\?([^#]*))?(#.*)?$/;function De(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(qp);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 it(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1],10),height:parseInt(t[2],10)}}function on(e){let t=De(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=it(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1],10),srcHeight:parseInt(n[2],10)}}function rn(e){let t=De(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=it(o.get("size")),n=it(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 nn=[on,rn,tn];function an(e){for(let t of nn){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 Qp(e,t){let o=e.match(/^<mark>(.+?)<\/mark>$/s);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function V(e,t={}){let o=[];for(let n of e)o.push(...Xp(n,t));return en(o)}function Xp(e,t={}){switch(e.type){case"delete":return V(e.children,{...t,strike:!0});case"emphasis":return V(e.children,{...t,italic:!0});case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return Qp(e.value,t);case"image":return an(e);case"inlineCode":return[{text:e.value,...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:V(e.children,t)}];case"strong":return V(e.children,{...t,bold:!0});case"text":return[{text:e.value,...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
|
|
3
3
|
`}];case"footnote":throw new Error("footnote is not supported yet")}he(e)}function ln(e){return[{type:"heading",level:e.depth,children:V(e.children)}]}function sn(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function mn(e,{depth:t,ordered:o,checked:r}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:V(e.children)}]:o?[{type:"ordered-list-item",depth:t,children:V(e.children)}]:[{type:"unordered-list-item",depth:t,children:V(e.children)}];case"list":return wt(e,t+1);default:return Mo(e)}}function cn(e,t){let o=[];for(let r of e.children)o.push(...mn(r,{...t,checked:e.checked}));return o}function wt(e,t=0){let o=[];for(let r of e.children)o.push(...cn(r,{depth:t,ordered:!!e.ordered}));return o}function jp(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 Yp="\xA0";function Jp(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==Yp)}function pn(e){let t=V(e.children);return jp(t)?[{...t[1],type:"image-block"}]:Jp(t)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:t}]}function dn(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(Zp)}]}function Zp(e){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(ed)}}function ed(e){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:V(e.children)}]}}function un(){return[{type:"horizontal-rule",children:[{text:""}]}]}function Be(e){let t=[];for(let o of e)t.push(...Mo(o));return t}function Mo(e){switch(e.type){case"blockquote":return Fr(e);case"code":return Vr(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Kr(e);case"heading":return ln(e);case"html":return sn(e);case"list":return wt(e);case"paragraph":return pn(e);case"table":return dn(e);case"thematicBreak":return un();case"yaml":return[]}he(e)}import{definitions as td}from"mdast-util-definitions";import{SKIP as fn,visit as od}from"unist-util-visit";function hn(e){let t=td(e);od(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[fn,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let m=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=m,[fn,r]}}})}var id=nd().use(rd).use(Or());function ad(e){let t=id.parse(e);return hn(t),t}function ge(e){let t=ad(e);return t.children.length===0?[{type:"paragraph",children:[{text:""}]}]:Be(t.children)}function ld(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function gn(e){let t=[],o=-1;for(let r of e){if(!ld(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 bn(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 En(e){let t=[],o=3;for(let r of e.children){let n=bn(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
|
|
4
4
|
`)}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
33
33
|
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
34
34
|
box-sizing: border-box;
|
|
35
|
-
`;import{jsx as Pd}from"react/jsx-runtime";function ei(e){let t=Md();wd(()=>{Id.normalize(t,{force:!0})},[t]);let{plugins:o}=t.sink,r=Zn(()=>({...e,decorate:_n(e.decorate,o),renderElement:jn(e.renderElement,o),renderLeaf:Yn(e.renderLeaf,o),renderPlaceholder:Jn(e.renderPlaceholder,o),onKeyDown:Gn(e.onKeyDown,o),onKeyUp:qn(e.onKeyUp,o),onPaste:Qn(e.onPaste,o),onDrop:Xn(e.onDrop,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onDrop,e.placeholder,e.className,o]),n=Zn(()=>Wn(o),[o]);return Pd(n,{...r})}function Ne(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function se(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function ti(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:se(r,"normalizeNode",n),deleteBackward:se(r,"deleteBackward",n),deleteForward:se(r,"deleteForward",n),deleteFragment:se(r,"deleteFragment",n),insertBreak:se(r,"insertBreak",n),insertFragment:se(r,"insertFragment",n),insertNode:se(r,"insertNode",n),insertText:se(r,"insertText",n),isInline:Ne(r,"isInline",n),isVoid:Ne(r,"isVoid",n),isMaster:Ne(r,"isMaster",n),isSlave:Ne(r,"isSlave",n),isStandalone:Ne(r,"isStandalone",n)}),r}}var oi=e=>{let t=e.map(n=>n.fn);return{withSink:ti(t),SinkEditable:ei}};import{Element as Cd}from"slate";import{ReactEditor as Sd}from"slate-react";function ri(e,t){return Cd.isElement(t)?Sd.findPath(e,t):t}function f(e,t){return e.bind(null,t)}function G(e,t,o){return e.bind(null,t,o)}var Rd=/mac os x|macintosh/i,st;function St(){if(st!==void 0)return st;try{let{userAgent:e}=window.navigator;st=Rd.test(e)}catch{st=!1}return st}function we(e){e.preventDefault(),e.stopPropagation()}import{Editor as ai,Path as Ld}from"slate";import{Element as ni}from"slate";function ii(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>ni.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>ni.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=ri(e,o),n=ii(t);if(Ld.isPath(r)){let i=ai.node(e,r);if(i&&n(i[0]))return i}return ai.above(e,{at:r,match:n})}function $e(...e){return E(...e)?.[1]}import{jsx as zd}from"react/jsx-runtime";var y=({strokeWidth:e=1.5,...t})=>zd("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 Bd}from"slate";function me(e){return e==null?!1:Bd.isCollapsed(e)}import{Element as li}from"slate";function Rt(e){return Array.isArray(e)?t=>li.isElement(t)&&e.includes(t.type):t=>li.isElement(t)&&e==t.type}import{Editor as Dd}from"slate";function si(e,t){let{selection:o}=e;if(!me(o))return!1;let r=E(e,t,{at:o});return!!r&&Dd.isEnd(e,o.anchor,r[1])}import{Editor as
|
|
35
|
+
`;import{jsx as Pd}from"react/jsx-runtime";function ei(e){let t=Md();wd(()=>{Id.normalize(t,{force:!0})},[t]);let{plugins:o}=t.sink,r=Zn(()=>({...e,decorate:_n(e.decorate,o),renderElement:jn(e.renderElement,o),renderLeaf:Yn(e.renderLeaf,o),renderPlaceholder:Jn(e.renderPlaceholder,o),onKeyDown:Gn(e.onKeyDown,o),onKeyUp:qn(e.onKeyUp,o),onPaste:Qn(e.onPaste,o),onDrop:Xn(e.onDrop,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onDrop,e.placeholder,e.className,o]),n=Zn(()=>Wn(o),[o]);return Pd(n,{...r})}function Ne(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function se(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function ti(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:se(r,"normalizeNode",n),deleteBackward:se(r,"deleteBackward",n),deleteForward:se(r,"deleteForward",n),deleteFragment:se(r,"deleteFragment",n),insertBreak:se(r,"insertBreak",n),insertFragment:se(r,"insertFragment",n),insertNode:se(r,"insertNode",n),insertText:se(r,"insertText",n),isInline:Ne(r,"isInline",n),isVoid:Ne(r,"isVoid",n),isMaster:Ne(r,"isMaster",n),isSlave:Ne(r,"isSlave",n),isStandalone:Ne(r,"isStandalone",n)}),r}}var oi=e=>{let t=e.map(n=>n.fn);return{withSink:ti(t),SinkEditable:ei}};import{Element as Cd}from"slate";import{ReactEditor as Sd}from"slate-react";function ri(e,t){return Cd.isElement(t)?Sd.findPath(e,t):t}function f(e,t){return e.bind(null,t)}function G(e,t,o){return e.bind(null,t,o)}var Rd=/mac os x|macintosh/i,st;function St(){if(st!==void 0)return st;try{let{userAgent:e}=window.navigator;st=Rd.test(e)}catch{st=!1}return st}function we(e){e.preventDefault(),e.stopPropagation()}import{Editor as ai,Path as Ld}from"slate";import{Element as ni}from"slate";function ii(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>ni.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>ni.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=ri(e,o),n=ii(t);if(Ld.isPath(r)){let i=ai.node(e,r);if(i&&n(i[0]))return i}return ai.above(e,{at:r,match:n})}function $e(...e){return E(...e)?.[1]}import{jsx as zd}from"react/jsx-runtime";var y=({strokeWidth:e=1.5,...t})=>zd("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 Bd}from"slate";function me(e){return e==null?!1:Bd.isCollapsed(e)}import{Element as li}from"slate";function Rt(e){return Array.isArray(e)?t=>li.isElement(t)&&e.includes(t.type):t=>li.isElement(t)&&e==t.type}import{Editor as Dd}from"slate";function si(e,t){let{selection:o}=e;if(!me(o))return!1;let r=E(e,t,{at:o});return!!r&&Dd.isEnd(e,o.anchor,r[1])}import{Editor as Mv}from"slate";import{Editor as Nd}from"slate";function Ie(e,t){let{selection:o}=e;if(!me(o))return!1;let r=E(e,t,{at:o});return!!r&&Nd.isStart(e,o.anchor,r[1])}import{isHotkey as mi}from"is-hotkey";import{Editor as zo,Element as $d,Range as Hd,Transforms as Ad}from"slate";var Od=mi(" "),Ud=mi("SHIFT+SPACE");function ci(e,t){return o=>{if(!Od(o.nativeEvent)&&!Ud(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||Hd.isExpanded(r))return!1;let n=E(e,m=>$d.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:zo.start(e,n[1]),focus:r.focus},a=zo.string(e,i),l=t[a];if(!l)return!1;we(o);let s={anchor:zo.start(e,n[1]),focus:r.focus};return Ad.delete(e,{at:s}),l(),!0}}import{isHotkey as Fd}from"is-hotkey";function pi(e){let t=e.replace(/\bsuper\b/g,St()?"cmd+alt":"ctrl+shift");return Fd(t)}function N(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[pi(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 Vd,Transforms as di}from"slate";function ui(e,t){Vd.withoutNormalizing(e,()=>{di.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),di.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as fi}from"slate";function be(e,t,o){let[,r]=t,n=fi.previous(e,{at:r});if(n&&o(n,t))return!0;let i=fi.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as hi,Transforms as gi}from"slate";function q(e,t){gi.select(e,hi.start(e,t))}function bi(e,t){gi.select(e,hi.end(e,t))}function Ei(e,t){return typeof t!="function"?t:t(e)}import{Editor as Bo,Element as Kd,Path as _d,Transforms as mt}from"slate";function xi(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>Kd.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;Bo.withoutNormalizing(e,()=>{mt.insertNodes(e,t,{at:o}),n&&(mt.select(e,n),mt.move(e))})}else{let n=_d.next(r[1]);Bo.withoutNormalizing(e,()=>{mt.insertNodes(e,t,{at:n}),mt.select(e,Bo.start(e,n))})}return!0}import{Editor as yi,Transforms as ki}from"slate";function ct(e,t,o){yi.withoutNormalizing(e,()=>{let r=yi.node(e,o),n=Ei(r[0],t);ki.wrapNodes(e,n,{at:o}),ki.unwrapNodes(e,{at:[...o,0]})})}import{Editor as Wd,Transforms as Gd}from"slate";function Lt(e,t,o){let r=Array.from(Wd.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;Gd.setNodes(e,t(i),{at:n[1]})}return!0}function vi(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 qd(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function qd(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Qd,Node as Xd,Transforms as Do}from"slate";function Ti(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(Do.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Xd.string(a);r!==s&&Qd.withoutNormalizing(e,()=>{let m=a.children.length;for(let c=m-1;c>=0;c--)Do.removeNodes(e,{at:[...l,c]});Do.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as zt,Element as jd,Range as Yd,Text as Jd,Transforms as No}from"slate";function wi(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:zt.start(e,[0]),focus:zt.start(e,[0])};if(Yd.isCollapsed(i)){if(No.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=zt.node(e,e.selection);No.select(e,a[1])}}else No.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Jd.isText(a)||jd.isElement(a)&&zt.isInline(e,a)})}import{Transforms as Zd}from"slate";function Ii(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(Zd.unwrapNodes(e,{at:o[1]}),!0):!1}function Mi(e){return{insertLink:f(wi,e),removeLink:f(Ii,e),editLink:f(Ti,e)}}import{Element as Pi,Transforms as eu}from"slate";function Ci(e,t){if(!Pi.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(!(!Pi.isElement(n)||n.type!=="anchor"))return eu.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Qu}from"clsx";import{useEffect as Xu,useRef as fa}from"react";import{useSelected as ju,useSlate as Yu}from"slate-react";import{createContext as Ri,useState as ou}from"react";import{createPortal as tu}from"react-dom";function Si({children:e}){return typeof document>"u"||!document.body?null:tu(e,document.body)}import{jsx as $o,jsxs as nu}from"react/jsx-runtime";var Ho=Ri({}),ru=Ri({});function Li({children:e}){let[t,o]=ou({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return nu(Ho.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>$o(Si,{children:$o(ru.Provider,{value:i,children:$o(i.Component,{})})},i.type))]})}import{useContext as iu}from"react";function H(e){let{openLayer:t,closeLayer:o,layers:r}=iu(Ho);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import Bt from"@emotion/styled";var zi=Bt("a")`
|
|
36
36
|
/**
|
|
37
37
|
* Link colors
|
|
38
38
|
*/
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
`,Ao=Bt("span")`
|
|
55
55
|
display: inline;
|
|
56
56
|
padding: 0 1px 0 0;
|
|
57
|
-
`,
|
|
57
|
+
`,LT=Bt("span")`
|
|
58
58
|
position: fixed;
|
|
59
59
|
width: 100px;
|
|
60
60
|
background: var(--shade-50);
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
border: 1px solid var(--shade-400);
|
|
64
64
|
overflow: hidden;
|
|
65
65
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
66
|
-
`,
|
|
66
|
+
`,zT=Bt("span")`
|
|
67
67
|
position: absolute;
|
|
68
68
|
left: 0;
|
|
69
69
|
top: 0;
|
|
@@ -1418,7 +1418,7 @@
|
|
|
1418
1418
|
/* Horizontal Rule Colors */
|
|
1419
1419
|
--hr-color: var(--shade-300);
|
|
1420
1420
|
}
|
|
1421
|
-
`;import{Fragment as ab,jsx as uc,jsxs as lb}from"react/jsx-runtime";var fc=k(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>lb(ab,{children:[uc(ib,{styles:dc}),uc(o,{...t})]}),editableProps:{}}));import{clsx as
|
|
1421
|
+
`;import{Fragment as ab,jsx as uc,jsxs as lb}from"react/jsx-runtime";var fc=k(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>lb(ab,{children:[uc(ib,{styles:dc}),uc(o,{...t})]}),editableProps:{}}));import{clsx as Wb}from"clsx";import{useCallback as Gb,useRef as qb}from"react";import{Editor as Qb,Transforms as Xb}from"slate";import{ReactEditor as jb,useFocused as Yb,useSlateStatic as Jb}from"slate-react";import{clsx as sb}from"clsx";import{useCallback as Ec,useRef as mb,useState as cb}from"react";import{ReactEditor as pb,useSlateStatic as db}from"slate-react";import yr from"@emotion/styled";var hc=yr(Y)`
|
|
1422
1422
|
padding: 0.5em;
|
|
1423
1423
|
`,gc=yr("div")`
|
|
1424
1424
|
display: grid;
|
|
@@ -1435,7 +1435,7 @@
|
|
|
1435
1435
|
&.--selected {
|
|
1436
1436
|
background: var(--blue-100);
|
|
1437
1437
|
}
|
|
1438
|
-
`;import{Fragment as ub,jsx as fo,jsxs as fb}from"react/jsx-runtime";function xc(e){return[...Array(e).keys()]}function yc({dest:e,close:t}){let[o,r]=cb({x:0,y:0}),n=db(),i=mb(null),a=j({src:i,dest:e},({dest:d})=>d?{left:d.left-8,top:d.top+d.height}:{left:0,top:0}),l=xc(5).map(d=>d+1),s=xc(5).map(d=>d+1),m=Ec((d,p)=>{r({x:d,y:p})},[r]),c=Ec((d,p)=>{n.tablePlugin.insertTable(d,p),pb.focus(n),t()},[n]);return fb(ub,{children:[fo(Ee,{close:t}),fo(hc,{ref:i,style:a,children:fo(gc,{onMouseLeave:()=>m(0,0),children:l.map(d=>s.map(p=>{let u=p<=o.x&&d<=o.y;return fo(bc,{className:sb({"--selected":u}),onMouseEnter:()=>m(p,d),onClick:()=>c(p,d)},`${p},${d}`)}))})})]})}import
|
|
1438
|
+
`;import{Fragment as ub,jsx as fo,jsxs as fb}from"react/jsx-runtime";function xc(e){return[...Array(e).keys()]}function yc({dest:e,close:t}){let[o,r]=cb({x:0,y:0}),n=db(),i=mb(null),a=j({src:i,dest:e},({dest:d})=>d?{left:d.left-8,top:d.top+d.height}:{left:0,top:0}),l=xc(5).map(d=>d+1),s=xc(5).map(d=>d+1),m=Ec((d,p)=>{r({x:d,y:p})},[r]),c=Ec((d,p)=>{n.tablePlugin.insertTable(d,p),pb.focus(n),t()},[n]);return fb(ub,{children:[fo(Ee,{close:t}),fo(hc,{ref:i,style:a,children:fo(gc,{onMouseLeave:()=>m(0,0),children:l.map(d=>s.map(p=>{let u=p<=o.x&&d<=o.y;return fo(bc,{className:sb({"--selected":u}),onMouseEnter:()=>m(p,d),onClick:()=>c(p,d)},`${p},${d}`)}))})})]})}import{useEffect as Hb,useRef as Ab,useState as Ob}from"react";import{useSlateStatic as Ub}from"slate-react";import{jsx as b,jsxs as Je}from"react/jsx-runtime";var kc=()=>b(y,{children:b("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),vc=()=>b(y,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:b("path",{d:"m2 12 4 4 4-4"})}),Tc=()=>b(y,{width:"0.5em",viewBox:"6 0 12 24",children:b("path",{d:"M9 12h6M12 9v6"})}),wc=()=>b(y,{children:b("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),Ic=()=>b(y,{children:b("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),Mc=()=>b(y,{children:b("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var Pc=()=>b(y,{children:b("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),kr=()=>b(y,{children:b("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),Cc=()=>b(y,{children:b("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var ho=()=>Je(y,{children:[b("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),b("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var vr=()=>b(y,{children:b("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),Sc=()=>Je(y,{children:[b("path",{d:"M10 9l4 3-4 3"}),b("path",{d:"M16 9l4 3-4 3"})]});var Rc=()=>b(y,{children:b("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),Lc=()=>Je(y,{children:[b("rect",{x:4,y:4,width:16,height:16,rx:2}),b("path",{d:"M4 10h16M10 4v16"})]}),zc=()=>b(y,{children:b("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),Bc=()=>b(y,{children:b("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),Dc=()=>Je(y,{children:[b("path",{d:"M15 8h.01"}),b("rect",{x:4,y:4,width:16,height:16,rx:3}),b("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),b("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var Nc=()=>b(y,{children:b("path",{d:"M12 5v14M5 12h14"})}),$c=()=>b(y,{children:b("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),Hc=()=>b(y,{children:b("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var Ac=()=>Je(y,{children:[b("path",{d:"m9 11 3 3 8-8"}),b("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Tr=()=>b(y,{children:b("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),Oc=()=>b(y,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),Uc=()=>b(y,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})});var Fc=()=>b(y,{children:b("path",{d:"M18 6L6 18M6 6l12 12"})}),Vc=()=>Je(y,{children:[b("path",{d:"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4"}),b("path",{d:"M13.5 6.5l4 4"}),b("path",{d:"m14 19 6-6M18 15l2 2M5 21h4"})]}),Kc=()=>b(y,{children:b("path",{d:"M5 12h14"})});var wr=[{icon:Oc,title:g("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:Uc,title:g("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],_c=[{icon:Pc,title:g("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:wc,title:g("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:Ic,title:g("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:Mc,title:g("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],Wc=[..._c],Ir=[{icon:kc,title:g("paragraphStyle"),more:!0,children:_c}];import{useState as de,useRef as qc,useEffect as gb,useCallback as Mr}from"react";import{useSlateStatic as bb}from"slate-react";import hb from"@emotion/styled";var Gc=hb(Y)`
|
|
1439
1439
|
width: 18em;
|
|
1440
1440
|
padding: 0;
|
|
1441
1441
|
overflow: hidden;
|
|
@@ -1468,4 +1468,4 @@
|
|
|
1468
1468
|
margin-top: 0.5em;
|
|
1469
1469
|
color: var(--shade-500);
|
|
1470
1470
|
line-height: 1.375;
|
|
1471
|
-
`;import{Fragment as Pb,jsx as te,jsxs as yt}from"react/jsx-runtime";var Mb=xb("enter");function Yc({dest:e,close:t}){let o=Ib(),r=kb(null),[n,i]=xt({x:0,y:0}),a=go((x,I)=>{i(w=>({x:w.x+x,y:w.y+I}))},[]),l=j({src:r,dest:e},({src:x,dest:I},w)=>!x||!I?{left:0,top:0}:$t(x,w,{left:I.left-12,top:I.top+I.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=yb(()=>{let{selection:x}=o;return x&&!Tb.isCollapsed(x)?vb.string(o,x):""},[]),[c,d]=xt(""),[p,u]=xt(m),[h,v]=xt(m),[S,P]=xt(!1),M=()=>{let x=p.trim()||c,I=h.trim()||void 0;o.anchor.insertLink(c,x,{select:!0,title:I}),wb.focus(o),t()},B=go(x=>{d(x.currentTarget.value)},[d]),C=go(x=>{let I=x.currentTarget.value;u(I),S||v(I)},[u,v,S]),D=go(x=>{v(x.currentTarget.value),P(!0)},[v]),T=x=>{Mb(x)&&(x.preventDefault(),x.stopPropagation(),M())};return yt(Pb,{children:[te(Ee,{close:t}),yt(Ai,{ref:r,style:s,children:[te(ye,{onDrag:a}),yt("div",{style:{padding:"0.75em"},children:[te(Ht,{children:te(At,{type:"text",value:c,autoFocus:!0,placeholder:g("linkUrl"),onChange:B,onKeyDown:T})}),te(Ht,{style:{marginTop:"0.5em"},children:te(At,{type:"text",value:p,placeholder:g("linkText"),onChange:C,onKeyDown:T})}),yt(Ht,{style:{marginTop:"0.5em"},children:[te(At,{type:"text",value:h,placeholder:g("tooltipText"),onChange:D,onKeyDown:T}),yt(Pr,{onClick:M,children:[te(ho,{}),te(Tc,{})]}),te(Pr,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:te(Fc,{})})]}),te(jc,{children:g("tooltipHint")})]})]})]})}var Cr=[{icon:ho,title:g("insertLink"),more:!0,hotkey:"mod+k",Component:Yc},{icon:Dc,title:g("insertImageFromUrl"),more:!0,Component:Qc},{icon:Lc,title:g("insertTable"),more:!0,Component:yc},{icon:Kc,title:g("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Jc=Cr,Zc=Cr,ep=[{icon:Nc,title:g("insert"),more:!0,children:Cr}];import{Editor as Cb}from"slate";function Ze(e){let t=Cb.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 tp=[{icon:kr,title:g("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Ze(e).bold},{icon:Cc,title:g("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Ze(e).italic},{icon:$c,title:g("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Ze(e).strike},{icon:zc,title:g("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Ze(e).code},{icon:Hc,title:g("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Ze(e).underline},{icon:Vc,title:g("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Ze(e).highlight,show:e=>!e.wysimark.disableHighlight}],Sr=tp,op=[{icon:kr,title:g("format"),more:!0,children:tp}];var rp=[{icon:Rc,title:g("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:Tr,title:g("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:Ac,title:g("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Rr=[...rp,"divider",...wr],np=[{icon:Tr,title:g("list"),more:!0,children:[...rp,"divider",...wr]}];import{Editor as ip,Transforms as bo}from"slate";var ap=[{icon:vr,title:g("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:Sc,title:g("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:Bc,title:g("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=ip.string(e,r);bo.removeNodes(e,{at:r}),bo.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=ip.string(e,t);bo.delete(e),bo.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Lr=ap,lp=[{icon:vr,title:g("quote"),more:!0,children:ap}];var Sb=[...Wc,"divider",...Rr,"divider",...Sr,"divider",...Jc,"divider",...Lr],Rb=[...Ir,"divider",...Rr,"divider",...Sr,"divider",...Zc,"divider",...Lr],sp=[...Ir,"divider",...np,"divider",...op,"divider",...ep,"divider",...lp],mp=sp;var et=[Sb,Rb,sp];import{clsx as Lb}from"clsx";import{useCallback as zr,useRef as zb}from"react";import{ReactEditor as Bb,useSlate as Db,useSlateStatic as Nb}from"slate-react";import{jsx as Eo,jsxs as $b}from"react/jsx-runtime";function cp({item:e}){let t=Nb(),o=Db(),r=e.active?e.active(o):!1,n=zb(null),i=J({title:e.title,hotkey:()=>e.hotkey?Dt(e.hotkey):void 0}),a=H("menu"),l=zr(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>Eo(Ae,{dest:c,items:d,close:a.close})):p&&a.open(()=>Eo(p,{dest:c,close:a.close})))},[e]),s=zr(()=>{if(e.action){e.action(t),Bb.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=zr(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer]);return $b(ji,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Lb({"--active":r&&!Lo(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Lo(e?.title)?.includes("Depth")}),children:[Eo(e.icon,{}),e.more?Eo(vc,{}):null]})}import{jsx as tt}from"react/jsx-runtime";function Vb({item:e}){let t=Fb();return e==="divider"?tt(Qi,{"data-item-type":"divider",children:tt(Xi,{})}):(e.show===void 0?!0:e.show(t))?tt(cp,{item:e}):null}function Kb(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function _b(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var Wb=48;function pp(){let e=Ob(null),[t,o]=Ub(mp);return Ab(()=>{let r=Hb(()=>{let i=e.current;if(!i)throw new Error("Toolbar not found");let a=Kb(i);if(a){for(let l=0;l<et.length-1;l++)if(_b(et[l],a.button,a.divider)<a.toolbar-Wb){o(et[l]);return}o(et[et.length-1])}},100,{trailing:!0}),n=setTimeout(r,0);return window.addEventListener("resize",r),()=>{clearTimeout(n),window.removeEventListener("resize",r)}},[]),tt(Gi,{ref:e,children:tt(qi,{children:t.map((r,n)=>tt(Vb,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Br,jsxs as eE}from"react/jsx-runtime";function dp({attributes:e,Editable:t}){let o=Qb(null),r=Zb(),n=Jb(),i=qb(a=>{a.target===a.currentTarget&&(jb.select(r,Xb.end(r,[])),Yb.focus(r))},[r]);return Br(Li,{children:eE(Vi,{ref:o,className:Gb({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Br(pp,{}),Br(t,{as:Fi,...e,style:{overflowY:"auto"}})]})})}var up=k((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:dp,editableProps:{}}));import{Editor as Dr,Node as tE,Path as oE,Transforms as rE}from"slate";var fp=k(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Dr.isEditor(t[0]))return!1;let o=[e.children.length-1],r=tE.child(e,e.children.length-1);return(Dr.hasBlocks(e,r)||Dr.isVoid(e,r))&&rE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:oE.next(o)}),!0}}}));import{Transforms as nE}from"slate";function iE(e,t){let o=fe(t),r=ge(o);nE.insertNodes(e,r)}function hp(e){return{pasteMarkdown:f(iE,e)}}var gp=k(e=>(e.pasteMarkdown=hp(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),we(t),!0}}}));import{jsx as lE}from"react/jsx-runtime";function aE(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return lE("span",{...t,children:e.children})}var bp=k((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:aE}})));var Ep=[gp,ms,ga,xs,sm,Ss,gl,Fl,ql,pc,Is,fp,rm,ya,pm,os,fc,up,ul,bp];var sE=oi(Ep),{withSink:xp,SinkEditable:yp}=sE;import{useState as mE}from"react";import{createEditor as cE,Editor as pE,Transforms as dE}from"slate";import{withHistory as uE}from"slate-history";import{withReact as fE}from"slate-react";function Nr({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l}={}){let[s]=mE(()=>{let m=cE(),c=xp(fE(uE(m)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return c.convertElement.addConvertElementType("paragraph"),m.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0},m.getMarkdown=()=>at(m.children),m.setMarkdown=d=>{let p=fe(d),u=ge(p);m.children=u,m.selection=null,dE.select(m,pE.start(m,[0]))},c});return s}import{jsx as oe,jsxs as vp}from"react/jsx-runtime";function yE({children:e,attributes:t}){return oe("span",{...t,children:e})}function Tp({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,m]=kp(!1),[c,d]=kp(t),p=vt(!1),u=vt(void 0),h=vt(void 0),v=vt(null),S=vt(o);S.current=o;let P=kt(hE(()=>{let w=at(e.children);e.wysimark.prevValue={markdown:w,children:e.children},S.current(w)},r,{leading:!1,trailing:!0}),[e,r]),M=kt(()=>{h.current!==e.children&&(h.current=e.children,P())},[P]);if(!s){let w=v.current??t;if(v.current!==null&&(v.current=null),e.wysimark.prevValue==null||u.current==null){p.current=!0;let O=fe(w),Te=ge(O);e.children=Te,h.current=u.current=Te,e.wysimark.prevValue={markdown:w,children:Te}}else if(w!==e.wysimark.prevValue.markdown){p.current=!0;let O=fe(w),Te=ge(O);e.children=Te,e.selection=null,bE.select(e,gE.start(e,[0]))}}let B=kt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&EE.focus(e)},[e]),C=kt(()=>{P.flush()},[P]),D=w=>{let O=w.target.value;d(O),o(O)},T=kt(()=>{let w=e.getMarkdown();d(w)},[e]),x=()=>{s?(v.current=c,e.wysimark.prevValue=void 0,u.current=void 0,h.current=void 0):T(),m(!s)};e.wysimark.onImageChange=l,e.wysimark.onChange=o;let I=e.wysimark.disableRawMode;return vp("div",{style:{position:"relative"},children:[!I&&oe("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:oe("div",{onClick:x,style:{background:"none",border:s?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:s?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:s?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:s?g("switchToVisualEditor"):g("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(x(),w.preventDefault())},children:vp("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[oe("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:s?"rgba(74, 144, 226, 0.05)":"transparent"}),oe("path",{d:"M7 15V9L10 12L13 9V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe("path",{d:"M16 9H18V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe("path",{d:"M16 12H18",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),oe("div",{style:{display:s?"block":"none",textAlign:"center"},children:oe("textarea",{value:ot(c).replace(/ /g,""),onChange:D,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),oe("div",{style:{display:s?"none":"block"},children:oe(xE,{editor:e,initialValue:u.current,onChange:M,children:oe(yp,{renderLeaf:yE,onMouseDown:B,onBlur:C,placeholder:n,className:i,style:a})})})]})}import{jsx as wp}from"react/jsx-runtime";function PE({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=IE(r.initialMarkdown||""),l=wE(i),s=Nr(r);l.current=i,TE(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=vE(c=>{l.current=c,a(c),e?.(c)},[s]);return wp(Tp,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function SA(e,t){let o=kE(),r=ME(e);return r.render(wp(PE,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Tp as Editable,SA as createWysimark,Nr as useEditor};
|
|
1471
|
+
`;import{Fragment as Pb,jsx as te,jsxs as yt}from"react/jsx-runtime";var Mb=xb("enter");function Yc({dest:e,close:t}){let o=Ib(),r=kb(null),[n,i]=xt({x:0,y:0}),a=go((x,I)=>{i(w=>({x:w.x+x,y:w.y+I}))},[]),l=j({src:r,dest:e},({src:x,dest:I},w)=>!x||!I?{left:0,top:0}:$t(x,w,{left:I.left-12,top:I.top+I.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=yb(()=>{let{selection:x}=o;return x&&!Tb.isCollapsed(x)?vb.string(o,x):""},[]),[c,d]=xt(""),[p,u]=xt(m),[h,v]=xt(m),[S,P]=xt(!1),M=()=>{let x=p.trim()||c,I=h.trim()||void 0;o.anchor.insertLink(c,x,{select:!0,title:I}),wb.focus(o),t()},B=go(x=>{d(x.currentTarget.value)},[d]),C=go(x=>{let I=x.currentTarget.value;u(I),S||v(I)},[u,v,S]),D=go(x=>{v(x.currentTarget.value),P(!0)},[v]),T=x=>{Mb(x)&&(x.preventDefault(),x.stopPropagation(),M())};return yt(Pb,{children:[te(Ee,{close:t}),yt(Ai,{ref:r,style:s,children:[te(ye,{onDrag:a}),yt("div",{style:{padding:"0.75em"},children:[te(Ht,{children:te(At,{type:"text",value:c,autoFocus:!0,placeholder:g("linkUrl"),onChange:B,onKeyDown:T})}),te(Ht,{style:{marginTop:"0.5em"},children:te(At,{type:"text",value:p,placeholder:g("linkText"),onChange:C,onKeyDown:T})}),yt(Ht,{style:{marginTop:"0.5em"},children:[te(At,{type:"text",value:h,placeholder:g("tooltipText"),onChange:D,onKeyDown:T}),yt(Pr,{onClick:M,children:[te(ho,{}),te(Tc,{})]}),te(Pr,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:te(Fc,{})})]}),te(jc,{children:g("tooltipHint")})]})]})]})}var Cr=[{icon:ho,title:g("insertLink"),more:!0,hotkey:"mod+k",Component:Yc},{icon:Dc,title:g("insertImageFromUrl"),more:!0,Component:Qc},{icon:Lc,title:g("insertTable"),more:!0,Component:yc},{icon:Kc,title:g("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Jc=Cr,Zc=Cr,ep=[{icon:Nc,title:g("insert"),more:!0,children:Cr}];import{Editor as Cb}from"slate";function Ze(e){let t=Cb.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 tp=[{icon:kr,title:g("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Ze(e).bold},{icon:Cc,title:g("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Ze(e).italic},{icon:$c,title:g("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Ze(e).strike},{icon:zc,title:g("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Ze(e).code},{icon:Hc,title:g("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Ze(e).underline},{icon:Vc,title:g("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Ze(e).highlight,show:e=>!e.wysimark.disableHighlight}],Sr=tp,op=[{icon:kr,title:g("format"),more:!0,children:tp}];var rp=[{icon:Rc,title:g("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:Tr,title:g("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:Ac,title:g("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Rr=[...rp,"divider",...wr],np=[{icon:Tr,title:g("list"),more:!0,children:[...rp,"divider",...wr]}];import{Editor as ip,Transforms as bo}from"slate";var ap=[{icon:vr,title:g("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:Sc,title:g("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:Bc,title:g("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=ip.string(e,r);bo.removeNodes(e,{at:r}),bo.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&(t.anchor.offset!==t.focus.offset||JSON.stringify(t.anchor.path)!==JSON.stringify(t.focus.path))){let r=ip.string(e,t);bo.delete(e),bo.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Lr=ap,lp=[{icon:vr,title:g("quote"),more:!0,children:ap}];var Sb=[...Wc,"divider",...Rr,"divider",...Sr,"divider",...Jc,"divider",...Lr],Rb=[...Ir,"divider",...Rr,"divider",...Sr,"divider",...Zc,"divider",...Lr],sp=[...Ir,"divider",...np,"divider",...op,"divider",...ep,"divider",...lp],mp=sp;var et=[Sb,Rb,sp];import{clsx as Lb}from"clsx";import{useCallback as zr,useRef as zb}from"react";import{ReactEditor as Bb,useSlate as Db,useSlateStatic as Nb}from"slate-react";import{jsx as Eo,jsxs as $b}from"react/jsx-runtime";function cp({item:e}){let t=Nb(),o=Db(),r=e.active?e.active(o):!1,n=zb(null),i=J({title:e.title,hotkey:()=>e.hotkey?Dt(e.hotkey):void 0}),a=H("menu"),l=zr(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>Eo(Ae,{dest:c,items:d,close:a.close})):p&&a.open(()=>Eo(p,{dest:c,close:a.close})))},[e]),s=zr(()=>{if(e.action){e.action(t),Bb.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=zr(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer]);return $b(ji,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Lb({"--active":r&&!Lo(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Lo(e?.title)?.includes("Depth")}),children:[Eo(e.icon,{}),e.more?Eo(vc,{}):null]})}import{jsx as tt}from"react/jsx-runtime";function Fb({item:e}){let t=Ub();return e==="divider"?tt(Qi,{"data-item-type":"divider",children:tt(Xi,{})}):(e.show===void 0?!0:e.show(t))?tt(cp,{item:e}):null}function Vb(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function Kb(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var _b=4;function pp(){let e=Ab(null),[t,o]=Ob(mp);return Hb(()=>{let r=e.current;if(!r)return;let n=()=>{let a=Vb(r);if(a){for(let l=0;l<et.length-1;l++)if(Kb(et[l],a.button,a.divider)<a.toolbar-_b){o(et[l]);return}o(et[et.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),tt(Gi,{ref:e,children:tt(qi,{children:t.map((r,n)=>tt(Fb,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Br,jsxs as Zb}from"react/jsx-runtime";function dp({attributes:e,Editable:t}){let o=qb(null),r=Jb(),n=Yb(),i=Gb(a=>{a.target===a.currentTarget&&(Xb.select(r,Qb.end(r,[])),jb.focus(r))},[r]);return Br(Li,{children:Zb(Vi,{ref:o,className:Wb({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Br(pp,{}),Br(t,{as:Fi,...e,style:{overflowY:"auto"}})]})})}var up=k((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:dp,editableProps:{}}));import{Editor as Dr,Node as eE,Path as tE,Transforms as oE}from"slate";var fp=k(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Dr.isEditor(t[0]))return!1;let o=[e.children.length-1],r=eE.child(e,e.children.length-1);return(Dr.hasBlocks(e,r)||Dr.isVoid(e,r))&&oE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:tE.next(o)}),!0}}}));import{Transforms as rE}from"slate";function nE(e,t){let o=fe(t),r=ge(o);rE.insertNodes(e,r)}function hp(e){return{pasteMarkdown:f(nE,e)}}var gp=k(e=>(e.pasteMarkdown=hp(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),we(t),!0}}}));import{jsx as aE}from"react/jsx-runtime";function iE(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return aE("span",{...t,children:e.children})}var bp=k((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:iE}})));var Ep=[gp,ms,ga,xs,sm,Ss,gl,Fl,ql,pc,Is,fp,rm,ya,pm,os,fc,up,ul,bp];var lE=oi(Ep),{withSink:xp,SinkEditable:yp}=lE;import{useState as sE}from"react";import{createEditor as mE,Editor as cE,Transforms as pE}from"slate";import{withHistory as dE}from"slate-history";import{withReact as uE}from"slate-react";function Nr({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l}={}){let[s]=sE(()=>{let m=mE(),c=xp(uE(dE(m)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return c.convertElement.addConvertElementType("paragraph"),m.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0},m.getMarkdown=()=>at(m.children),m.setMarkdown=d=>{let p=fe(d),u=ge(p);m.children=u,m.selection=null,pE.select(m,cE.start(m,[0]))},c});return s}import{jsx as oe,jsxs as vp}from"react/jsx-runtime";function xE({children:e,attributes:t}){return oe("span",{...t,children:e})}function Tp({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l}){let[s,m]=kp(!1),[c,d]=kp(t),p=vt(!1),u=vt(void 0),h=vt(void 0),v=vt(null),S=vt(o);S.current=o;let P=kt(fE(()=>{let w=at(e.children);e.wysimark.prevValue={markdown:w,children:e.children},S.current(w)},r,{leading:!1,trailing:!0}),[e,r]),M=kt(()=>{h.current!==e.children&&(h.current=e.children,P())},[P]);if(!s){let w=v.current??t;if(v.current!==null&&(v.current=null),e.wysimark.prevValue==null||u.current==null){p.current=!0;let O=fe(w),Te=ge(O);e.children=Te,h.current=u.current=Te,e.wysimark.prevValue={markdown:w,children:Te}}else if(w!==e.wysimark.prevValue.markdown){p.current=!0;let O=fe(w),Te=ge(O);e.children=Te,e.selection=null,gE.select(e,hE.start(e,[0]))}}let B=kt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&bE.focus(e)},[e]),C=kt(()=>{P.flush()},[P]),D=w=>{let O=w.target.value;d(O),o(O)},T=kt(()=>{let w=e.getMarkdown();d(w)},[e]),x=()=>{s?(v.current=c,e.wysimark.prevValue=void 0,u.current=void 0,h.current=void 0):T(),m(!s)};e.wysimark.onImageChange=l,e.wysimark.onChange=o;let I=e.wysimark.disableRawMode;return vp("div",{style:{position:"relative"},children:[!I&&oe("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:oe("div",{onClick:x,style:{background:"none",border:s?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:s?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:s?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:s?g("switchToVisualEditor"):g("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(x(),w.preventDefault())},children:vp("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[oe("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:s?"rgba(74, 144, 226, 0.05)":"transparent"}),oe("path",{d:"M7 15V9L10 12L13 9V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe("path",{d:"M16 9H18V15",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe("path",{d:"M16 12H18",stroke:s?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),oe("div",{style:{display:s?"block":"none",textAlign:"center"},children:oe("textarea",{value:ot(c).replace(/ /g,""),onChange:D,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),oe("div",{style:{display:s?"none":"block"},children:oe(EE,{editor:e,initialValue:u.current,onChange:M,children:oe(yp,{renderLeaf:xE,onMouseDown:B,onBlur:C,placeholder:n,className:i,style:a})})})]})}import{jsx as wp}from"react/jsx-runtime";function ME({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=wE(r.initialMarkdown||""),l=TE(i),s=Nr(r);l.current=i,vE(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=kE(c=>{l.current=c,a(c),e?.(c)},[s]);return wp(Tp,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function PA(e,t){let o=yE(),r=IE(e);return r.render(wp(ME,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Tp as Editable,PA as createWysimark,Nr as useEditor};
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { createRoot } from "react-dom/client";
|
|
12
12
|
|
|
13
13
|
// src/entry/index.tsx
|
|
14
|
-
import
|
|
14
|
+
import throttle2 from "lodash.throttle";
|
|
15
15
|
import { useCallback as useCallback18, useRef as useRef15, useState as useState13 } from "react";
|
|
16
16
|
import { Editor as Editor67, Transforms as Transforms49 } from "slate";
|
|
17
17
|
import { ReactEditor as ReactEditor18, Slate as Slate2 } from "slate-react";
|
|
@@ -8264,7 +8264,6 @@ function TableDialog({
|
|
|
8264
8264
|
}
|
|
8265
8265
|
|
|
8266
8266
|
// src/toolbar-plugin/components/toolbar/toolbar.tsx
|
|
8267
|
-
import throttle2 from "lodash.throttle";
|
|
8268
8267
|
import { useEffect as useEffect9, useRef as useRef13, useState as useState11 } from "react";
|
|
8269
8268
|
import { useSlateStatic as useSlateStatic20 } from "slate-react";
|
|
8270
8269
|
|
|
@@ -9189,38 +9188,33 @@ function measureItemSetWidth(items, buttonWidth, dividerWidth) {
|
|
|
9189
9188
|
}
|
|
9190
9189
|
return width;
|
|
9191
9190
|
}
|
|
9192
|
-
var WIDTH_BUFFER_PX =
|
|
9191
|
+
var WIDTH_BUFFER_PX = 4;
|
|
9193
9192
|
function Toolbar() {
|
|
9194
9193
|
const ref = useRef13(null);
|
|
9195
9194
|
const [items, setItems] = useState11(initialItems);
|
|
9196
9195
|
useEffect9(() => {
|
|
9197
|
-
const
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
return;
|
|
9212
|
-
}
|
|
9196
|
+
const toolbar = ref.current;
|
|
9197
|
+
if (!toolbar) return;
|
|
9198
|
+
const refresh = () => {
|
|
9199
|
+
const widths = getWidths(toolbar);
|
|
9200
|
+
if (!widths) return;
|
|
9201
|
+
for (let i = 0; i < itemSets.length - 1; i++) {
|
|
9202
|
+
const itemSetWidth = measureItemSetWidth(
|
|
9203
|
+
itemSets[i],
|
|
9204
|
+
widths.button,
|
|
9205
|
+
widths.divider
|
|
9206
|
+
);
|
|
9207
|
+
if (itemSetWidth < widths.toolbar - WIDTH_BUFFER_PX) {
|
|
9208
|
+
setItems(itemSets[i]);
|
|
9209
|
+
return;
|
|
9213
9210
|
}
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
);
|
|
9219
|
-
const timeoutId = setTimeout(refresh, 0);
|
|
9220
|
-
window.addEventListener("resize", refresh);
|
|
9211
|
+
}
|
|
9212
|
+
setItems(itemSets[itemSets.length - 1]);
|
|
9213
|
+
};
|
|
9214
|
+
const observer = new ResizeObserver(refresh);
|
|
9215
|
+
observer.observe(toolbar);
|
|
9221
9216
|
return () => {
|
|
9222
|
-
|
|
9223
|
-
window.removeEventListener("resize", refresh);
|
|
9217
|
+
observer.disconnect();
|
|
9224
9218
|
};
|
|
9225
9219
|
}, []);
|
|
9226
9220
|
return /* @__PURE__ */ jsx64($ToolbarContainer, { ref, children: /* @__PURE__ */ jsx64($Toolbar, { children: items.map((item, index) => /* @__PURE__ */ jsx64(
|
|
@@ -9489,7 +9483,7 @@ function Editable2({
|
|
|
9489
9483
|
const onChangeRef = useRef15(onChange);
|
|
9490
9484
|
onChangeRef.current = onChange;
|
|
9491
9485
|
const onThrottledSlateChange = useCallback18(
|
|
9492
|
-
|
|
9486
|
+
throttle2(
|
|
9493
9487
|
() => {
|
|
9494
9488
|
const markdown = serialize(editor.children);
|
|
9495
9489
|
editor.wysimark.prevValue = {
|