wysimark-lite 0.25.7 → 0.25.9

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 CHANGED
@@ -28,7 +28,7 @@
28
28
  `)),t.push(l)}let r=t.join("");return r.trim()===""?"":r.replace(/^\n+/,"").trim()}function at(e){let t=gn(e);return Mt(t)}var Ro={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",horizontalRule:"\u533A\u5207\u308A\u7DDA",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30D5\u30A1\u30A4\u30EB",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",saving:"\u4FDD\u5B58\u4E2D...",uploadComplete:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5B8C\u4E86",vaultPath:"\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",vaultPathHint:"vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",highlight:"Highlight",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",horizontalRule:"Horizontal Rule",register:"Register",imageSourceUrl:"URL",imageSourceFile:"File",selectFile:"Select File",uploading:"Uploading...",saving:"Saving...",uploadComplete:"Upload Complete",vaultPath:"Save Path:",vaultPathHint:"Enter the path within the vault to save the file"}},Kn=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},g=e=>{let t=Kn();return Ro[t==="ja"?"ja":"en"][e]},Lo=e=>{let t=Kn();return Object.keys(Ro[t==="ja"?"ja":"en"]).find(r=>Ro[t==="ja"?"ja":"en"][r]===e)||""};var k=e=>({fn:e});import{useEffect as wd,useMemo as Zn}from"react";import{Editor as Id}from"slate";import{useSlateStatic as Md}from"slate-react";function ie(e){return!!e}function _n(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(ie);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 yd}from"slate-react";import{jsx as kd}from"react/jsx-runtime";function Wn(e){let t=e.map(r=>r.renderEditable).filter(ie),o=r=>kd(yd,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function Pt(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function Ct(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Gn=(e,t)=>{let o=Pt(t,"onKeyDown");return Ct(o,e)},qn=(e,t)=>{let o=Pt(t,"onKeyUp");return Ct(o,e)},Qn=(e,t)=>{let o=Pt(t,"onPaste");return Ct(o,e)},Xn=(e,t)=>{let o=Pt(t,"onDrop");return Ct(o,e)};function jn(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(ie);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 vd}from"react";function Yn(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(ie).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=vd(n,r.attributes),n}}function Jn(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(ie);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 Td from"@emotion/styled";var lt=Td("div")`
29
29
  -webkit-font-smoothing: antialiased;
30
30
  -moz-osx-font-smoothing: grayscale;
31
- font-size: 16px;
31
+ font-size: 1rem;
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;
@@ -327,7 +327,7 @@
327
327
  z-index: 10;
328
328
  -webkit-font-smoothing: antialiased;
329
329
  -moz-osx-font-smoothing: grayscale;
330
- font-size: 16px;
330
+ font-size: 1rem;
331
331
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
332
332
  Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
333
333
  color: white;
@@ -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(/&nbsp;/g,""),onChange:D,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}})}),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 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(/&nbsp;/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};
package/dist/index.mjs CHANGED
@@ -1995,7 +1995,7 @@ import styled from "@emotion/styled";
1995
1995
  var SinkReset = styled("div")`
1996
1996
  -webkit-font-smoothing: antialiased;
1997
1997
  -moz-osx-font-smoothing: grayscale;
1998
- font-size: 16px;
1998
+ font-size: 1rem;
1999
1999
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
2000
2000
  Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
2001
2001
  box-sizing: border-box;
@@ -3285,7 +3285,7 @@ var $Tooltip = styled10("div")`
3285
3285
  z-index: 10;
3286
3286
  -webkit-font-smoothing: antialiased;
3287
3287
  -moz-osx-font-smoothing: grayscale;
3288
- font-size: 16px;
3288
+ font-size: 1rem;
3289
3289
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
3290
3290
  Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
3291
3291
  color: white;
@@ -9871,7 +9871,7 @@ function Editable2({
9871
9871
  minHeight: "200px",
9872
9872
  padding: "20px",
9873
9873
  fontFamily: "monospace",
9874
- fontSize: "14px",
9874
+ fontSize: "1rem",
9875
9875
  color: "#333",
9876
9876
  lineHeight: "1.5",
9877
9877
  backgroundColor: "#fff",