wysimark-lite 0.25.8 → 0.25.10

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;
@@ -968,7 +968,7 @@
968
968
  `;import{jsx as Wl,jsxs as fh}from"react/jsx-runtime";function Gl({attributes:e,children:t,element:o}){return fh(Kl,{...e,contentEditable:!1,children:[Wl(_l,{children:"HTML"}),Wl("div",{children:ot(o.html)}),t]})}import{jsx as gh}from"react/jsx-runtime";var ql=k((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!me(n))return!1;let i=E(e,"html-block");return i==null?!1:(hh.removeNodes(e,{at:i[1]}),!0)}return o({name:"html-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="html-block")return!1},isVoid(n){if(n.type==="html-block")return!0},isMaster(n){if(n.type==="html-block")return!0}},editableProps:{renderElement:({element:n,attributes:i,children:a})=>{if(n.type==="html-block")return gh(Gl,{element:n,attributes:i,children:a})}}})});import{Editor as ts}from"slate";import{Element as kh}from"slate";import{Element as bh,Transforms as Eh}from"slate";function Ql(e){return bh.isElement(e)&&e.type==="paragraph"}function Xl(e,t){return be(e,t,(o,r)=>!Ql(o[0])||!Ql(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(Eh.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as xh,Transforms as yh}from"slate";function tr(e,t){return xh.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function jl(e,t){return tr(e,t[0])?be(e,t,(o,r)=>!tr(e,o[0])||!tr(e,r[0])?!1:(yh.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function Yl(e,t){let[o,r]=t;return kh.isElement(o)?!!(jl(e,[o,r])||Xl(e,[o,r])):!1}import{clsx as wh}from"clsx";import{useSelected as Ih}from"slate-react";import vh from"@emotion/styled";var Jl=vh("p")`
969
969
  padding: 0;
970
970
  margin: 0;
971
- &:first-child {
971
+ &:first-of-type {
972
972
  margin-top: 0;
973
973
  }
974
974
 
@@ -997,7 +997,7 @@
997
997
  }
998
998
  `;import{Node as Th}from"slate";function Zl(e){return e.children.length===1&&Th.string(e.children[0]).length===0}import{jsx as Mh}from"react/jsx-runtime";function es({element:e,attributes:t,children:o}){let r=Ih(),n=Zl(e);return Mh(Jl,{...t,className:wh({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as Ph}from"react/jsx-runtime";var os=k(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{let{selection:o}=e;if(o&&o.anchor.path[0]===o.focus.path[0]){let r=[o.anchor.path[0]],n=ts.start(e,r);ts.string(e,{anchor:n,focus:o.anchor}).endsWith(`
999
999
  `)?t():e.insertText(`
1000
- `)}else t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:f(Yl,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{switch(o.type){case"paragraph":return Ph(es,{element:o,attributes:r,children:n})}},onKeyDown:N({"super+0":e.collapsibleParagraph.convertParagraph})}}});function rs(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as _,Element as to,Node as ne,Point as _e,Range as Ch,Transforms as Ce}from"slate";function ns(e,t,o){try{let r=_.start(e,o),n=_.end(e,o);if(_e.isBefore(t,r)||_e.isAfter(t,n))return-1;let i={anchor:r,focus:t};return _.string(e,i).length}catch{return-1}}function is(e,t,o){try{let r=ne.get(e,t);if(!to.isElement(r))return;let n=ne.string(r),i=Math.min(o,n.length),a=_.start(e,t),l=0,s=a.path,m=0;for(let[d,p]of ne.texts(r)){let u=d.text.length;if(l+u>=i){s=[...t,...p],m=i-l;break}l+=u}let c={path:s,offset:m};Ce.select(e,{anchor:c,focus:c})}catch{}}function Sh(e){return ne.string(e).includes(`
1000
+ `)}else t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:f(Yl,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{if(o.type==="paragraph")return Ph(es,{element:o,attributes:r,children:n})},onKeyDown:N({"super+0":e.collapsibleParagraph.convertParagraph})}}});function rs(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as _,Element as to,Node as ne,Point as _e,Range as Ch,Transforms as Ce}from"slate";function ns(e,t,o){try{let r=_.start(e,o),n=_.end(e,o);if(_e.isBefore(t,r)||_e.isAfter(t,n))return-1;let i={anchor:r,focus:t};return _.string(e,i).length}catch{return-1}}function is(e,t,o){try{let r=ne.get(e,t);if(!to.isElement(r))return;let n=ne.string(r),i=Math.min(o,n.length),a=_.start(e,t),l=0,s=a.path,m=0;for(let[d,p]of ne.texts(r)){let u=d.text.length;if(l+u>=i){s=[...t,...p],m=i-l;break}l+=u}let c={path:s,offset:m};Ce.select(e,{anchor:c,focus:c})}catch{}}function Sh(e){return ne.string(e).includes(`
1001
1001
  `)}function Rh(e,t,o,r){let n=ne.string(t),i=n.split(`
1002
1002
  `),a=_.start(e,o),l=_.end(e,o),s=_e.isBefore(r.anchor,a)?a:_e.isAfter(r.anchor,l)?l:r.anchor,m=_e.isBefore(r.focus,a)?a:_e.isAfter(r.focus,l)?l:r.focus,c=Math.min(_.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(_.string(e,{anchor:a,focus:m}).length,n.length),p=Math.min(c,d),u=Math.max(c,d),h=0,v=0,S=i.length-1;for(let P=0;P<i.length;P++){let M=h+i[P].length;if(h<=p&&p<=M&&(v=P),h<=u&&u<=M){S=P;break}h=M+1}return{startLineIndex:v,endLineIndex:S}}function Lh(e,t,o,r){let n=ne.string(t);if(!n.includes(`
1003
1003
  `))return o;let i=n.split(`
@@ -1007,7 +1007,7 @@
1007
1007
  `)}]};Ce.insertNodes(e,v,{at:[...d,p+1]})}else Ce.insertNodes(e,{text:m.join(`
1008
1008
  `)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function as(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=Ch.isCollapsed(n),s=Array.from(_.nodes(e,{match:p=>to.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(s.length>0){let[,p]=s[0];i=ns(e,n.anchor,p),a=ns(e,n.focus,p)}if(s.length===0)return!1;let m=[];_.withoutNormalizing(e,()=>{for(let p=s.length-1;p>=0;p--){let[u,h]=s[p];if(Sh(u)){let v=Lh(e,u,h,n);m.unshift(v)}else m.unshift(h)}});let c=m.map(p=>{try{let u=ne.get(e,p);return to.isElement(u)?[u,p]:null}catch{return null}}).filter(p=>p!==null);if(c.length===0)return!1;if(r&&c.every(p=>t(p[0]))?_.withoutNormalizing(e,()=>{for(let p of c)ct(e,{type:"paragraph"},p[1])}):_.withoutNormalizing(e,()=>{for(let p of c)ct(e,o,p[1])}),c.length>0&&i>=0){let[,p]=c[0];if(l)is(e,p,i);else if(a>=0)try{let u=ne.get(e,p);if(to.isElement(u)){let h=ne.string(u),v=Math.min(i,h.length),S=Math.min(a,h.length),P=_.start(e,p),M=P.path,B=v,C=0;for(let[x,I]of ne.texts(u)){let w=x.text.length;if(C+w>=v){M=[...p,...I],B=v-C;break}C+=w}let D=P.path,T=S;C=0;for(let[x,I]of ne.texts(u)){let w=x.text.length;if(C+w>=S){D=[...p,...I],T=S-C;break}C+=w}Ce.select(e,{anchor:{path:M,offset:B},focus:{path:D,offset:T}})}}catch{is(e,p,i)}}return!0}function ls(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function ss(e){return{convertElementTypes:[],addConvertElementType:f(rs,e),isConvertibleElement:f(ls,e),convertElements:f(as,e)}}var ms=k(e=>(e.convertElement=ss(e),{name:"convert-element"}));import{Editor as or,Path as zh,Range as Bh,Transforms as cs}from"slate";function ps(e){let t=E(e,"heading");if(!t||!e.selection||Bh.isExpanded(e.selection)||!or.isEnd(e,e.selection.anchor,t[1]))return!1;let o=zh.next(t[1]);return cs.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),cs.select(e,{anchor:or.start(e,o),focus:or.start(e,o)}),!0}import{Editor as Dh}from"slate";function Nh(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function $h(e,t){let[o]=Dh.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function ds(e){return{convertHeading:f(Nh,e),isHeadingActive:f($h,e)}}import{css as Hh}from"@emotion/react";import We from"@emotion/styled";var Ge=Hh`
1009
1009
  margin-top: 1em;
1010
- &:first-child {
1010
+ &:first-of-type {
1011
1011
  margin-top: 0;
1012
1012
  }
1013
1013
  font-weight: bold;
@@ -1111,7 +1111,7 @@
1111
1111
  * if isDebug is true, then show a highlight on list items that are marked
1112
1112
  * as the first at a given depth.
1113
1113
  */
1114
- background: ${!1?"rgba(0, 255, 0, 0.2)":"inherit"};
1114
+ background: ${"inherit"};
1115
1115
  }
1116
1116
 
1117
1117
  &:before {
@@ -1439,7 +1439,7 @@
1439
1439
  width: 18em;
1440
1440
  padding: 0;
1441
1441
  overflow: hidden;
1442
- `;import{Fragment as Eb,jsx as F,jsxs as X}from"react/jsx-runtime";function Qc({dest:e,close:t}){let o=bb(),r=qc(null),n=qc(null),[i,a]=de({x:0,y:0}),l=Mr(($,U)=>{a(ue=>({x:ue.x+$,y:ue.y+U}))},[]),s=o.wysimark?.imageDialogState,m=!!o.wysimark?.onImageChange,[c,d]=de(s?.url??""),[p,u]=de(s?.alt??""),[h,v]=de(s?.title??""),[S,P]=de(!1),[M,B]=de(s?.imageSource??(m?"file":"url")),[C,D]=de(!1),[T,x]=de(s?.uploadedUrl??""),[I,w]=de(""),O=Mr($=>{let U=$.target.value;u(U),S||v(U)},[S]),Te=Mr($=>{v($.target.value),P(!0)},[]);gb(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:c,alt:p,title:h,imageSource:M,uploadedUrl:T})},[c,p,h,M,T]);let $r=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},xo=j({src:r,dest:e},({src:$,dest:U},ue)=>$t($,ue,{left:U.left-16,top:U.top+U.height},{margin:16})),Ip={...xo,left:xo.left+i.x,top:xo.top+i.y};function Mp($){$.preventDefault();let U=M==="file"?T:c;U.trim()!==""&&(o.image.insertImageFromUrl(U,p,h),$r(),t())}function Pp(){$r(),t()}async function Cp($){let U=$.target.files?.[0];if(!(!U||!o.wysimark?.onImageChange)){w(U.name),D(!0);try{let ue=await o.wysimark.onImageChange(U);x(ue)}catch(ue){}finally{D(!1)}}}function Sp(){n.current?.click()}let yo=M==="file"?T.trim()===""||C:c.trim()==="";return X(Eb,{children:[F(Ee,{close:t}),X(Gc,{ref:r,style:Ip,children:[F(ye,{onDrag:l}),X("form",{onSubmit:$=>void Mp($),style:{padding:"8px"},children:[m&&X("div",{style:{marginBottom:"12px"},children:[X("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[F("input",{type:"radio",name:"imageSource",value:"file",checked:M==="file",onChange:()=>B("file"),style:{marginRight:"4px"}}),g("imageSourceFile")]}),X("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[F("input",{type:"radio",name:"imageSource",value:"url",checked:M==="url",onChange:()=>B("url"),style:{marginRight:"4px"}}),g("imageSourceUrl")]})]}),M==="url"?X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("imageUrlRequired")}),F("input",{type:"text",value:c,onChange:$=>d($.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:"https://example.com/image.jpg"})]}):X("div",{style:{marginBottom:"8px"},children:[F("input",{ref:n,type:"file",accept:"image/*",onChange:$=>void Cp($),style:{display:"none"}}),F("button",{type:"button",onClick:Sp,disabled:C,style:{padding:"8px 16px",backgroundColor:C?"#ccc":"#0078d4",color:C?"#666":"white",border:"none",borderRadius:"4px",cursor:C?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:C?g("uploading"):g("selectFile")}),T&&X("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:[X("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",g("uploadComplete")]}),I&&F("div",{style:{fontSize:"12px",color:"var(--shade-500)"},children:I})]})]}),X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("altText")}),F("input",{type:"text",value:p,onChange:O,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:g("imageDescription")})]}),X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("title")}),F("input",{type:"text",value:h,onChange:Te,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:g("imageTitle")})]}),X("div",{style:{display:"flex",gap:"8px"},children:[F("button",{type:"submit",disabled:yo,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:yo?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:yo?"not-allowed":"pointer",fontWeight:"bold"},children:g("register")}),F("button",{type:"button",onClick:Pp,style:{padding:"8px 16px",backgroundColor:"var(--shade-100)",color:"var(--shade-700)",border:"1px solid var(--shade-300)",borderRadius:"4px",cursor:"pointer"},children:g("cancel")})]})]})]})]})}import{isHotkey as xb}from"is-hotkey";import{useCallback as go,useMemo as yb,useRef as kb,useState as xt}from"react";import{Editor as vb,Range as Tb}from"slate";import{ReactEditor as wb,useSlateStatic as Ib}from"slate-react";import Xc from"@emotion/styled";var Pr=Xc("div")`
1442
+ `;import{Fragment as Eb,jsx as F,jsxs as X}from"react/jsx-runtime";function Qc({dest:e,close:t}){let o=bb(),r=qc(null),n=qc(null),[i,a]=de({x:0,y:0}),l=Mr(($,U)=>{a(ue=>({x:ue.x+$,y:ue.y+U}))},[]),s=o.wysimark?.imageDialogState,m=!!o.wysimark?.onImageChange,[c,d]=de(s?.url??""),[p,u]=de(s?.alt??""),[h,v]=de(s?.title??""),[S,P]=de(!1),[M,B]=de(s?.imageSource??(m?"file":"url")),[C,D]=de(!1),[T,x]=de(s?.uploadedUrl??""),[I,w]=de(""),O=Mr($=>{let U=$.target.value;u(U),S||v(U)},[S]),Te=Mr($=>{v($.target.value),P(!0)},[]);gb(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:c,alt:p,title:h,imageSource:M,uploadedUrl:T})},[c,p,h,M,T]);let $r=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},xo=j({src:r,dest:e},({src:$,dest:U},ue)=>$t($,ue,{left:U.left-16,top:U.top+U.height},{margin:16})),Ip={...xo,left:xo.left+i.x,top:xo.top+i.y};function Mp($){$.preventDefault();let U=M==="file"?T:c;U.trim()!==""&&(o.image.insertImageFromUrl(U,p,h),$r(),t())}function Pp(){$r(),t()}async function Cp($){let U=$.target.files?.[0];if(!(!U||!o.wysimark?.onImageChange)){w(U.name),D(!0);try{let ue=await o.wysimark.onImageChange(U);x(ue)}catch(ue){}finally{D(!1)}}}function Sp(){n.current?.click()}let yo=M==="file"?T.trim()===""||C:c.trim()==="";return X(Eb,{children:[F(Ee,{close:t}),X(Gc,{ref:r,style:Ip,children:[F(ye,{onDrag:l}),X("form",{onSubmit:$=>{Mp($)},style:{padding:"8px"},children:[m&&X("div",{style:{marginBottom:"12px"},children:[X("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[F("input",{type:"radio",name:"imageSource",value:"file",checked:M==="file",onChange:()=>B("file"),style:{marginRight:"4px"}}),g("imageSourceFile")]}),X("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[F("input",{type:"radio",name:"imageSource",value:"url",checked:M==="url",onChange:()=>B("url"),style:{marginRight:"4px"}}),g("imageSourceUrl")]})]}),M==="url"?X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("imageUrlRequired")}),F("input",{type:"text",value:c,onChange:$=>d($.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:"https://example.com/image.jpg"})]}):X("div",{style:{marginBottom:"8px"},children:[F("input",{ref:n,type:"file",accept:"image/*",onChange:$=>{Cp($)},style:{display:"none"}}),F("button",{type:"button",onClick:Sp,disabled:C,style:{padding:"8px 16px",backgroundColor:C?"#ccc":"#0078d4",color:C?"#666":"white",border:"none",borderRadius:"4px",cursor:C?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:C?g("uploading"):g("selectFile")}),T&&X("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:[X("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",g("uploadComplete")]}),I&&F("div",{style:{fontSize:"12px",color:"var(--shade-500)"},children:I})]})]}),X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("altText")}),F("input",{type:"text",value:p,onChange:O,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:g("imageDescription")})]}),X("div",{style:{marginBottom:"8px"},children:[F("label",{style:{display:"block",marginBottom:"4px"},children:g("title")}),F("input",{type:"text",value:h,onChange:Te,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:g("imageTitle")})]}),X("div",{style:{display:"flex",gap:"8px"},children:[F("button",{type:"submit",disabled:yo,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:yo?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:yo?"not-allowed":"pointer",fontWeight:"bold"},children:g("register")}),F("button",{type:"button",onClick:Pp,style:{padding:"8px 16px",backgroundColor:"var(--shade-100)",color:"var(--shade-700)",border:"1px solid var(--shade-300)",borderRadius:"4px",cursor:"pointer"},children:g("cancel")})]})]})]})]})}import{isHotkey as xb}from"is-hotkey";import{useCallback as go,useMemo as yb,useRef as kb,useState as xt}from"react";import{Editor as vb,Range as Tb}from"slate";import{ReactEditor as wb,useSlateStatic as Ib}from"slate-react";import Xc from"@emotion/styled";var Pr=Xc("div")`
1443
1443
  /* Center vertically and horizontally */
1444
1444
  display: flex;
1445
1445
  align-items: center;
@@ -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};