reactjs-tiptap-editor 1.0.21 → 1.0.23

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.
Files changed (136) hide show
  1. package/lib/{ActionMenuButton-Cpla3oSm.js → ActionMenuButton-C53IYt_R.js} +1 -1
  2. package/lib/{ActionMenuButton-BVaZBdL3.cjs → ActionMenuButton-Da0H9Beu.cjs} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +2 -2
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +1 -1
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +1 -1
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +1 -1
  11. package/lib/{Callout-JL3mm4GU.cjs → Callout-CdXbDkZ6.cjs} +1 -1
  12. package/lib/{Callout-mb31jDcR.js → Callout-igc-a1lj.js} +2 -2
  13. package/lib/Callout.cjs +1 -1
  14. package/lib/Callout.js +2 -2
  15. package/lib/Clear.cjs +1 -1
  16. package/lib/Clear.js +1 -1
  17. package/lib/Code.cjs +1 -1
  18. package/lib/Code.js +1 -1
  19. package/lib/CodeBlock.cjs +1 -1
  20. package/lib/CodeBlock.js +1 -1
  21. package/lib/CodeView.cjs +1 -1
  22. package/lib/CodeView.js +1 -1
  23. package/lib/Color.cjs +1 -1
  24. package/lib/Color.js +2 -2
  25. package/lib/Column.cjs +1 -1
  26. package/lib/Column.js +1 -1
  27. package/lib/{Drawer-94nAoli4.cjs → Drawer-CrMuQNbZ.cjs} +1 -1
  28. package/lib/{Drawer-d9e69c7G.js → Drawer-DzroBQds.js} +2 -2
  29. package/lib/Drawer.cjs +1 -1
  30. package/lib/Drawer.js +2 -2
  31. package/lib/Emoji.cjs +1 -1
  32. package/lib/Emoji.js +3 -3
  33. package/lib/Excalidraw.cjs +1 -1
  34. package/lib/Excalidraw.js +1 -1
  35. package/lib/ExportPdf.cjs +1 -1
  36. package/lib/ExportPdf.js +1 -1
  37. package/lib/ExportWord.cjs +1 -1
  38. package/lib/ExportWord.js +1 -1
  39. package/lib/FontFamily.cjs +1 -1
  40. package/lib/FontFamily.js +4 -4
  41. package/lib/FontSize.cjs +1 -1
  42. package/lib/FontSize.js +8 -8
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +4 -4
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +2 -2
  47. package/lib/History.cjs +1 -1
  48. package/lib/History.js +1 -1
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +1 -1
  51. package/lib/{Iframe-qCivhCR5.cjs → Iframe-DVLx3H0m.cjs} +1 -1
  52. package/lib/{Iframe-CkUClxtI.js → Iframe-Dt2Styg8.js} +1 -1
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +1 -1
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +1 -1
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +45 -45
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +2 -2
  61. package/lib/{Indent-BTzj50Sf.js → Indent-BCZFJKcN.js} +1 -1
  62. package/lib/{Indent-DtgugDpq.cjs → Indent-CQCn1r9U.cjs} +1 -1
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +1 -1
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +1 -1
  67. package/lib/{Katex-BuFwL_MA.js → Katex--VT0zcjU.js} +3 -3
  68. package/lib/{Katex-RcbH2O5p.cjs → Katex-By61XteD.cjs} +1 -1
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +1 -1
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +3 -3
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +1 -1
  75. package/lib/{LinkEditBlock-CSKh_5n7.cjs → LinkEditBlock-BLkA2CYZ.cjs} +1 -1
  76. package/lib/{LinkEditBlock-DYOmu7jQ.js → LinkEditBlock-C_F9zWEj.js} +3 -3
  77. package/lib/Mermaid.cjs +1 -1
  78. package/lib/Mermaid.js +10 -10
  79. package/lib/MoreMark.cjs +1 -1
  80. package/lib/MoreMark.js +2 -2
  81. package/lib/OrderedList.cjs +1 -1
  82. package/lib/OrderedList.js +1 -1
  83. package/lib/SearchAndReplace.cjs +1 -1
  84. package/lib/SearchAndReplace.js +3 -3
  85. package/lib/SlashCommand.cjs +1 -1
  86. package/lib/SlashCommand.js +3 -3
  87. package/lib/{SlashCommandNodeView-CYdYVjeb.cjs → SlashCommandNodeView-Aqc77oRC.cjs} +1 -1
  88. package/lib/{SlashCommandNodeView-CT_-28t6.js → SlashCommandNodeView-DxlBPKPV.js} +2 -2
  89. package/lib/Strike.cjs +1 -1
  90. package/lib/Strike.js +1 -1
  91. package/lib/{Table-DOl6C6To.cjs → Table-DqXkwJAY.cjs} +1 -1
  92. package/lib/{Table-CEHV8gmO.js → Table-r09L4PvT.js} +3 -3
  93. package/lib/Table.cjs +1 -1
  94. package/lib/Table.js +1 -1
  95. package/lib/TaskList.cjs +1 -1
  96. package/lib/TaskList.js +1 -1
  97. package/lib/TextAlign.cjs +1 -1
  98. package/lib/TextAlign.js +2 -2
  99. package/lib/TextDirection.cjs +1 -1
  100. package/lib/TextDirection.js +2 -2
  101. package/lib/TextUnderline.cjs +1 -1
  102. package/lib/TextUnderline.js +1 -1
  103. package/lib/{Twitter-DxqKzo3U.js → Twitter-DP_9V0zb.js} +3 -3
  104. package/lib/{Twitter-DDuJwWdF.cjs → Twitter-f-oMDZuV.cjs} +1 -1
  105. package/lib/Twitter.cjs +1 -1
  106. package/lib/Twitter.js +1 -1
  107. package/lib/Video.cjs +1 -1
  108. package/lib/Video.js +2 -2
  109. package/lib/bubble.cjs +2 -2
  110. package/lib/bubble.js +25 -17
  111. package/lib/{dropdown-menu-CoZZaqv5.cjs → dropdown-menu-DeBV2h9-.cjs} +1 -1
  112. package/lib/{dropdown-menu-BYbds8yQ.js → dropdown-menu-uIj8M0jD.js} +1 -1
  113. package/lib/{index-B1SzsIsE.js → index-BVtsbzV8.js} +1 -1
  114. package/lib/index-CWw4s87s.cjs +1 -0
  115. package/lib/{index-DirFiHQ6.cjs → index-ezTXvA7H.cjs} +1 -1
  116. package/lib/{index-BlXGgvT-.js → index-oj858lQO.js} +243 -33
  117. package/lib/index.cjs +1 -1
  118. package/lib/index.js +1 -1
  119. package/lib/locale-bundle.cjs +1 -1
  120. package/lib/locale-bundle.js +7 -6
  121. package/lib/locales/en.d.ts +2 -0
  122. package/lib/locales/fi.d.ts +2 -0
  123. package/lib/locales/hu.d.ts +2 -0
  124. package/lib/locales/index.d.ts +211 -1
  125. package/lib/locales/ja.d.ts +198 -0
  126. package/lib/locales/pt-br.d.ts +2 -0
  127. package/lib/locales/vi.d.ts +2 -0
  128. package/lib/locales/zh-cn.d.ts +2 -0
  129. package/lib/{popover-BaAurWOZ.cjs → popover-Cq1iLY7i.cjs} +1 -1
  130. package/lib/{popover-CK54Ip2N.js → popover-mlZeH-7I.js} +1 -1
  131. package/lib/{separator-XZA3-egy.js → separator-Bh_ttGZg.js} +3 -3
  132. package/lib/{separator-ByK1SKWn.cjs → separator-DvAvl5_5.cjs} +1 -1
  133. package/lib/{textarea-mwHtiXJV.cjs → textarea-CKXzGwId.cjs} +1 -1
  134. package/lib/{textarea--IMIy9VF.js → textarea-MU5imD7D.js} +1 -1
  135. package/package.json +1 -1
  136. package/lib/index-BqL4vAWE.cjs +0 -1
package/lib/ImageGif.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-C4WLt4NA.cjs"),f=require("./index-DirFiHQ6.cjs"),z=require("./clsx-DSAWW32g.cjs"),l=require("react/jsx-runtime"),u=require("react"),j=require("./index-BqL4vAWE.cjs");require("./theme.cjs");const L=require("./popover-BaAurWOZ.cjs"),N={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function W(e){var P,k;const[t,r]=u.useState({width:j.IMAGE_MAX_SIZE,height:j.IMAGE_MAX_SIZE}),[o,i]=u.useState({width:0,height:0}),[n]=u.useState([N.TOP_LEFT,N.TOP_RIGHT,N.BOTTOM_LEFT,N.BOTTOM_RIGHT]),[s,a]=u.useState(!1),[h,b]=u.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=(P=e==null?void 0:e.node)==null?void 0:P.attrs,m=u.useMemo(()=>{var x;const{src:c,alt:w,width:v,height:A}=(x=e==null?void 0:e.node)==null?void 0:x.attrs,G=f.isNumber(v)?`${v}px`:v,d=f.isNumber(A)?`${A}px`:A;return{src:c||void 0,alt:w||void 0,style:{width:G||void 0,height:d||void 0}}},[(k=e==null?void 0:e.node)==null?void 0:k.attrs]),_=u.useMemo(()=>{const{style:{width:c}}=m;return{width:c==="100%"?c:void 0}},[m]);function g(c){i({width:c.target.width,height:c.target.height})}function I(){const{editor:c,getPos:w}=e;c.commands.setNodeSelection(w())}const M=u.useCallback(f.throttle(()=>{const{editor:c}=e,{width:w}=getComputedStyle(c.view.dom);r(v=>({...v,width:Number.parseInt(w,10)}))},j.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function q(c,w){c.preventDefault(),c.stopPropagation();const v=o.width,A=o.height,G=v/A;let d=Number(e.node.attrs.width),x=Number(e.node.attrs.height);const y=t.width;d&&!x?(d=d>y?y:d,x=Math.round(d/G)):x&&!d?(d=Math.round(x*G),d=d>y?y:d):!d&&!x?(d=v>y?y:v,x=Math.round(d/G)):d=d>y?y:d,a(!0),b({x:c.clientX,y:c.clientY,w:d,h:x,dir:w})}const E=u.useCallback(f.throttle(c=>{if(c.preventDefault(),c.stopPropagation(),!s)return;const{x:w,w:v,dir:A}=h,G=(c.clientX-w)*(/l/.test(A)?-1:1),d=f.clamp$1(v+G,j.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:d,height:null})},j.IMAGE_THROTTLE_WAIT_TIME),[s,h,t,e.updateAttributes]),S=u.useCallback(c=>{c.preventDefault(),c.stopPropagation(),s&&(b({x:0,y:0,w:0,h:0,dir:""}),a(!1),I())},[s,I]),$=u.useCallback(()=>{document==null||document.addEventListener("mousemove",E,!0),document==null||document.addEventListener("mouseup",S,!0)},[E,S]),O=u.useCallback(()=>{document==null||document.removeEventListener("mousemove",E,!0),document==null||document.removeEventListener("mouseup",S,!0)},[E,S]);u.useEffect(()=>(s?$():O(),()=>{O()}),[s,$,O]);const R=u.useMemo(()=>new ResizeObserver(()=>M()),[M]);return u.useEffect(()=>(R.observe(e.editor.view.dom),()=>{R.disconnect()}),[e.editor.view.dom,R]),l.jsx(z.NodeViewWrapper,{className:"image-view",style:{..._,width:"100%",textAlign:T},children:l.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:_,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[l.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:g,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||s)&&l.jsx("div",{className:"image-resizer",children:n==null?void 0:n.map(c=>l.jsx("span",{className:`image-resizer__handler image-resizer__handler--${c}`,onMouseDown:w=>q(w,c)},`image-dir-${c}`))})]})})}async function p(e){var o;const r=await(await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();return(o=r==null?void 0:r.data)==null?void 0:o.map(i=>{var n,s,a;return{id:i==null?void 0:i.id,src:(n=i==null?void 0:i.images.original)==null?void 0:n.url,width:+((s=i==null?void 0:i.images.original)==null?void 0:s.width),height:+((a=i==null?void 0:i.images.original)==null?void 0:a.width)}})}async function D(e,t){var i;const o=await(await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();return(i=o==null?void 0:o.data)==null?void 0:i.map(n=>{var s,a,h;return{id:n==null?void 0:n.id,src:(s=n==null?void 0:n.images.original)==null?void 0:s.url,width:+((a=n==null?void 0:n.images.original)==null?void 0:a.width),height:+((h=n==null?void 0:n.images.original)==null?void 0:h.width)}})}async function F(e){var n,s;const t=await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),r=await(t==null?void 0:t.json()),i=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n=r==null?void 0:r.results)==null?void 0:n[0]}&limit=15`)).json();return(s=i==null?void 0:i.results)==null?void 0:s.map(a=>{var h,b,T,m,_,g,I,M;return{id:a==null?void 0:a.id,src:(b=(h=a==null?void 0:a.media_formats)==null?void 0:h.gif)==null?void 0:b.url,width:(_=(m=(T=a==null?void 0:a.media_formats)==null?void 0:T.gif)==null?void 0:m.dims)==null?void 0:_[0],height:(M=(I=(g=a==null?void 0:a.media_formats)==null?void 0:g.gif)==null?void 0:I.dims)==null?void 0:M[1]}})}async function B(e,t){var i;const o=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();return(i=o==null?void 0:o.results)==null?void 0:i.map(n=>{var s,a,h,b,T,m,_,g;return{id:n==null?void 0:n.id,src:(a=(s=n==null?void 0:n.media_formats)==null?void 0:s.gif)==null?void 0:a.url,width:(T=(b=(h=n==null?void 0:n.media_formats)==null?void 0:h.gif)==null?void 0:b.dims)==null?void 0:T[0],height:(g=(_=(m=n==null?void 0:n.media_formats)==null?void 0:m.gif)==null?void 0:_.dims)==null?void 0:g[1]}})}function V(e,t){return{searchTrending:async()=>t?e==="giphy"?p(t):e==="tenor"?F(t):[]:[],searchWord:async i=>t?e==="giphy"?D(i,t):e==="tenor"?B(i,t):[]:[]}}function X({selectImage:e,apiKey:t,provider:r,children:o}){const[i,n]=u.useState(!1),[s,a]=u.useState([]),{editorDisabled:h}=f.useToggleActive(),b=u.useRef(null),{searchTrending:T,searchWord:m}=V(r,t);u.useEffect(()=>{(async()=>{const g=await T();a(g)})()},[]);const _=u.useCallback(f.debounce(async g=>{if(!g.target.value){const M=await T();a(M);return}const I=await m(g.target.value);a(I)},350),[]);return l.jsxs(L.Popover,{modal:!0,onOpenChange:n,open:i,children:[l.jsx(L.PopoverTrigger,{asChild:!0,disabled:h,children:o}),l.jsx(L.PopoverContent,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:l.jsx(f.Input,{onChange:_,placeholder:"Search GIF",ref:b,type:"text"})}),l.jsx("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:l.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1",children:s!=null&&s.length?s==null?void 0:s.map(g=>l.jsx("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:g.src,onClick:()=>{e(g.src),n(!1)}},g.id)):l.jsx("p",{children:"No GIFs found"})})})]}):l.jsx("div",{children:l.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Y(){const e=f.useButtonProps(C.name),{action:t,icon:r,tooltip:o,apiKey:i,provider:n}=(e==null?void 0:e.componentProps)??{},{editorDisabled:s}=f.useToggleActive(),a=h=>{s||t&&t(h)};return l.jsx(X,{apiKey:i,provider:n,selectImage:a,children:l.jsx(f.ActionButton,{disabled:s,icon:r,tooltip:o})})}const C=f.index_default.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:r,t:o})=>{var s,a;const i=((s=r==null?void 0:r.options)==null?void 0:s.provider)||"",n=((a=r==null?void 0:r.options)==null?void 0:a.API_KEY)||"";return{componentProps:{action:h=>{t.chain().focus().setImageGif({src:h}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:o("editor.imageGif.tooltip"),apiKey:n,provider:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const r=t.style.width||t.getAttribute("width")||"10";return r===void 0?null:Number.parseInt(`${r}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return z.ReactNodeViewRenderer(W)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:r})=>r.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:r})=>r.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",H.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:r?Number.parseInt(r,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});exports.ImageGif=C;exports.RichTextImageGif=Y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-C4WLt4NA.cjs"),f=require("./index-ezTXvA7H.cjs"),z=require("./clsx-DSAWW32g.cjs"),l=require("react/jsx-runtime"),u=require("react"),j=require("./index-CWw4s87s.cjs");require("./theme.cjs");const L=require("./popover-Cq1iLY7i.cjs"),N={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function W(e){var P,k;const[t,r]=u.useState({width:j.IMAGE_MAX_SIZE,height:j.IMAGE_MAX_SIZE}),[o,i]=u.useState({width:0,height:0}),[n]=u.useState([N.TOP_LEFT,N.TOP_RIGHT,N.BOTTOM_LEFT,N.BOTTOM_RIGHT]),[s,a]=u.useState(!1),[h,b]=u.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=(P=e==null?void 0:e.node)==null?void 0:P.attrs,m=u.useMemo(()=>{var x;const{src:c,alt:w,width:v,height:A}=(x=e==null?void 0:e.node)==null?void 0:x.attrs,G=f.isNumber(v)?`${v}px`:v,d=f.isNumber(A)?`${A}px`:A;return{src:c||void 0,alt:w||void 0,style:{width:G||void 0,height:d||void 0}}},[(k=e==null?void 0:e.node)==null?void 0:k.attrs]),_=u.useMemo(()=>{const{style:{width:c}}=m;return{width:c==="100%"?c:void 0}},[m]);function g(c){i({width:c.target.width,height:c.target.height})}function I(){const{editor:c,getPos:w}=e;c.commands.setNodeSelection(w())}const M=u.useCallback(f.throttle(()=>{const{editor:c}=e,{width:w}=getComputedStyle(c.view.dom);r(v=>({...v,width:Number.parseInt(w,10)}))},j.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function q(c,w){c.preventDefault(),c.stopPropagation();const v=o.width,A=o.height,G=v/A;let d=Number(e.node.attrs.width),x=Number(e.node.attrs.height);const y=t.width;d&&!x?(d=d>y?y:d,x=Math.round(d/G)):x&&!d?(d=Math.round(x*G),d=d>y?y:d):!d&&!x?(d=v>y?y:v,x=Math.round(d/G)):d=d>y?y:d,a(!0),b({x:c.clientX,y:c.clientY,w:d,h:x,dir:w})}const E=u.useCallback(f.throttle(c=>{if(c.preventDefault(),c.stopPropagation(),!s)return;const{x:w,w:v,dir:A}=h,G=(c.clientX-w)*(/l/.test(A)?-1:1),d=f.clamp$1(v+G,j.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:d,height:null})},j.IMAGE_THROTTLE_WAIT_TIME),[s,h,t,e.updateAttributes]),S=u.useCallback(c=>{c.preventDefault(),c.stopPropagation(),s&&(b({x:0,y:0,w:0,h:0,dir:""}),a(!1),I())},[s,I]),$=u.useCallback(()=>{document==null||document.addEventListener("mousemove",E,!0),document==null||document.addEventListener("mouseup",S,!0)},[E,S]),O=u.useCallback(()=>{document==null||document.removeEventListener("mousemove",E,!0),document==null||document.removeEventListener("mouseup",S,!0)},[E,S]);u.useEffect(()=>(s?$():O(),()=>{O()}),[s,$,O]);const R=u.useMemo(()=>new ResizeObserver(()=>M()),[M]);return u.useEffect(()=>(R.observe(e.editor.view.dom),()=>{R.disconnect()}),[e.editor.view.dom,R]),l.jsx(z.NodeViewWrapper,{className:"image-view",style:{..._,width:"100%",textAlign:T},children:l.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:_,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[l.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:g,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||s)&&l.jsx("div",{className:"image-resizer",children:n==null?void 0:n.map(c=>l.jsx("span",{className:`image-resizer__handler image-resizer__handler--${c}`,onMouseDown:w=>q(w,c)},`image-dir-${c}`))})]})})}async function p(e){var o;const r=await(await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();return(o=r==null?void 0:r.data)==null?void 0:o.map(i=>{var n,s,a;return{id:i==null?void 0:i.id,src:(n=i==null?void 0:i.images.original)==null?void 0:n.url,width:+((s=i==null?void 0:i.images.original)==null?void 0:s.width),height:+((a=i==null?void 0:i.images.original)==null?void 0:a.width)}})}async function D(e,t){var i;const o=await(await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();return(i=o==null?void 0:o.data)==null?void 0:i.map(n=>{var s,a,h;return{id:n==null?void 0:n.id,src:(s=n==null?void 0:n.images.original)==null?void 0:s.url,width:+((a=n==null?void 0:n.images.original)==null?void 0:a.width),height:+((h=n==null?void 0:n.images.original)==null?void 0:h.width)}})}async function F(e){var n,s;const t=await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),r=await(t==null?void 0:t.json()),i=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n=r==null?void 0:r.results)==null?void 0:n[0]}&limit=15`)).json();return(s=i==null?void 0:i.results)==null?void 0:s.map(a=>{var h,b,T,m,_,g,I,M;return{id:a==null?void 0:a.id,src:(b=(h=a==null?void 0:a.media_formats)==null?void 0:h.gif)==null?void 0:b.url,width:(_=(m=(T=a==null?void 0:a.media_formats)==null?void 0:T.gif)==null?void 0:m.dims)==null?void 0:_[0],height:(M=(I=(g=a==null?void 0:a.media_formats)==null?void 0:g.gif)==null?void 0:I.dims)==null?void 0:M[1]}})}async function B(e,t){var i;const o=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();return(i=o==null?void 0:o.results)==null?void 0:i.map(n=>{var s,a,h,b,T,m,_,g;return{id:n==null?void 0:n.id,src:(a=(s=n==null?void 0:n.media_formats)==null?void 0:s.gif)==null?void 0:a.url,width:(T=(b=(h=n==null?void 0:n.media_formats)==null?void 0:h.gif)==null?void 0:b.dims)==null?void 0:T[0],height:(g=(_=(m=n==null?void 0:n.media_formats)==null?void 0:m.gif)==null?void 0:_.dims)==null?void 0:g[1]}})}function V(e,t){return{searchTrending:async()=>t?e==="giphy"?p(t):e==="tenor"?F(t):[]:[],searchWord:async i=>t?e==="giphy"?D(i,t):e==="tenor"?B(i,t):[]:[]}}function X({selectImage:e,apiKey:t,provider:r,children:o}){const[i,n]=u.useState(!1),[s,a]=u.useState([]),{editorDisabled:h}=f.useToggleActive(),b=u.useRef(null),{searchTrending:T,searchWord:m}=V(r,t);u.useEffect(()=>{(async()=>{const g=await T();a(g)})()},[]);const _=u.useCallback(f.debounce(async g=>{if(!g.target.value){const M=await T();a(M);return}const I=await m(g.target.value);a(I)},350),[]);return l.jsxs(L.Popover,{modal:!0,onOpenChange:n,open:i,children:[l.jsx(L.PopoverTrigger,{asChild:!0,disabled:h,children:o}),l.jsx(L.PopoverContent,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:l.jsx(f.Input,{onChange:_,placeholder:"Search GIF",ref:b,type:"text"})}),l.jsx("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:l.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1",children:s!=null&&s.length?s==null?void 0:s.map(g=>l.jsx("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:g.src,onClick:()=>{e(g.src),n(!1)}},g.id)):l.jsx("p",{children:"No GIFs found"})})})]}):l.jsx("div",{children:l.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Y(){const e=f.useButtonProps(C.name),{action:t,icon:r,tooltip:o,apiKey:i,provider:n}=(e==null?void 0:e.componentProps)??{},{editorDisabled:s}=f.useToggleActive(),a=h=>{s||t&&t(h)};return l.jsx(X,{apiKey:i,provider:n,selectImage:a,children:l.jsx(f.ActionButton,{disabled:s,icon:r,tooltip:o})})}const C=f.index_default.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:r,t:o})=>{var s,a;const i=((s=r==null?void 0:r.options)==null?void 0:s.provider)||"",n=((a=r==null?void 0:r.options)==null?void 0:a.API_KEY)||"";return{componentProps:{action:h=>{t.chain().focus().setImageGif({src:h}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:o("editor.imageGif.tooltip"),apiKey:n,provider:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const r=t.style.width||t.getAttribute("width")||"10";return r===void 0?null:Number.parseInt(`${r}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return z.ReactNodeViewRenderer(W)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:r})=>r.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:r})=>r.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",H.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:r?Number.parseInt(r,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});exports.ImageGif=C;exports.RichTextImageGif=Y;
package/lib/ImageGif.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import { m as B } from "./index-D0EmqTpe.js";
2
- import { H as k, t as C, J as q, u as V, d as D, A as X, K as Y, j as Z, y as J } from "./index-B1SzsIsE.js";
2
+ import { H as k, t as C, J as q, u as V, d as D, A as X, K as Y, j as Z, y as J } from "./index-BVtsbzV8.js";
3
3
  import { N as U, a as Q } from "./clsx-Bg-2aTKh.js";
4
4
  import { jsx as u, jsxs as z, Fragment as K } from "react/jsx-runtime";
5
5
  import { useState as G, useMemo as P, useCallback as M, useEffect as $, useRef as ee } from "react";
6
- import { I as j, i as W, j as te } from "./index-BlXGgvT-.js";
6
+ import { I as j, j as W, k as te } from "./index-oj858lQO.js";
7
7
  import "./theme.js";
8
- import { P as ne, a as re, b as ie } from "./popover-CK54Ip2N.js";
8
+ import { P as ne, a as re, b as ae } from "./popover-mlZeH-7I.js";
9
9
  const O = {
10
10
  TOP_LEFT: "tl",
11
11
  TOP_RIGHT: "tr",
12
12
  BOTTOM_LEFT: "bl",
13
13
  BOTTOM_RIGHT: "br"
14
14
  };
15
- function ae(e) {
15
+ function ie(e) {
16
16
  var p, H;
17
17
  const [t, r] = G({
18
18
  width: j,
19
19
  height: j
20
- }), [c, i] = G({
20
+ }), [c, a] = G({
21
21
  width: 0,
22
22
  height: 0
23
23
  }), [n] = G([
@@ -25,7 +25,7 @@ function ae(e) {
25
25
  O.TOP_RIGHT,
26
26
  O.BOTTOM_LEFT,
27
27
  O.BOTTOM_RIGHT
28
- ]), [a, s] = G(!1), [l, v] = G({
28
+ ]), [i, s] = G(!1), [l, v] = G({
29
29
  x: 0,
30
30
  y: 0,
31
31
  w: 0,
@@ -49,7 +49,7 @@ function ae(e) {
49
49
  return { width: o === "100%" ? o : void 0 };
50
50
  }, [g]);
51
51
  function h(o) {
52
- i({
52
+ a({
53
53
  width: o.target.width,
54
54
  height: o.target.height
55
55
  });
@@ -83,7 +83,7 @@ function ae(e) {
83
83
  }
84
84
  const N = M(
85
85
  C((o) => {
86
- if (o.preventDefault(), o.stopPropagation(), !a)
86
+ if (o.preventDefault(), o.stopPropagation(), !i)
87
87
  return;
88
88
  const { x: m, w: f, dir: x } = l, A = (o.clientX - m) * (/l/.test(x) ? -1 : 1), d = q(f + A, te, t.width);
89
89
  e.updateAttributes({
@@ -91,10 +91,10 @@ function ae(e) {
91
91
  height: null
92
92
  });
93
93
  }, W),
94
- [a, l, t, e.updateAttributes]
94
+ [i, l, t, e.updateAttributes]
95
95
  ), E = M(
96
96
  (o) => {
97
- o.preventDefault(), o.stopPropagation(), a && (v({
97
+ o.preventDefault(), o.stopPropagation(), i && (v({
98
98
  x: 0,
99
99
  y: 0,
100
100
  w: 0,
@@ -102,15 +102,15 @@ function ae(e) {
102
102
  dir: ""
103
103
  }), s(!1), _());
104
104
  },
105
- [a, _]
105
+ [i, _]
106
106
  ), R = M(() => {
107
107
  document == null || document.addEventListener("mousemove", N, !0), document == null || document.addEventListener("mouseup", E, !0);
108
108
  }, [N, E]), S = M(() => {
109
109
  document == null || document.removeEventListener("mousemove", N, !0), document == null || document.removeEventListener("mouseup", E, !0);
110
110
  }, [N, E]);
111
- $(() => (a ? R() : S(), () => {
111
+ $(() => (i ? R() : S(), () => {
112
112
  S();
113
- }), [a, R, S]);
113
+ }), [i, R, S]);
114
114
  const L = P(() => new ResizeObserver(() => I()), [I]);
115
115
  return $(() => (L.observe(e.editor.view.dom), () => {
116
116
  L.disconnect();
@@ -125,7 +125,7 @@ function ae(e) {
125
125
  "data-drag-handle": !0,
126
126
  draggable: "true",
127
127
  style: y,
128
- className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${a ? "image-view__body--resizing" : ""}`,
128
+ className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${i ? "image-view__body--resizing" : ""}`,
129
129
  children: [
130
130
  /* @__PURE__ */ u(
131
131
  "img",
@@ -139,7 +139,7 @@ function ae(e) {
139
139
  style: g.style
140
140
  }
141
141
  ),
142
- (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || a) && /* @__PURE__ */ u("div", { className: "image-resizer", children: n == null ? void 0 : n.map((o) => /* @__PURE__ */ u(
142
+ (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || i) && /* @__PURE__ */ u("div", { className: "image-resizer", children: n == null ? void 0 : n.map((o) => /* @__PURE__ */ u(
143
143
  "span",
144
144
  {
145
145
  className: `image-resizer__handler image-resizer__handler--${o}`,
@@ -156,39 +156,39 @@ function ae(e) {
156
156
  async function se(e) {
157
157
  var c;
158
158
  const r = await (await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();
159
- return (c = r == null ? void 0 : r.data) == null ? void 0 : c.map((i) => {
160
- var n, a, s;
159
+ return (c = r == null ? void 0 : r.data) == null ? void 0 : c.map((a) => {
160
+ var n, i, s;
161
161
  return {
162
- id: i == null ? void 0 : i.id,
163
- src: (n = i == null ? void 0 : i.images.original) == null ? void 0 : n.url,
164
- width: +((a = i == null ? void 0 : i.images.original) == null ? void 0 : a.width),
165
- height: +((s = i == null ? void 0 : i.images.original) == null ? void 0 : s.width)
162
+ id: a == null ? void 0 : a.id,
163
+ src: (n = a == null ? void 0 : a.images.original) == null ? void 0 : n.url,
164
+ width: +((i = a == null ? void 0 : a.images.original) == null ? void 0 : i.width),
165
+ height: +((s = a == null ? void 0 : a.images.original) == null ? void 0 : s.width)
166
166
  };
167
167
  });
168
168
  }
169
169
  async function oe(e, t) {
170
- var i;
170
+ var a;
171
171
  const c = await (await fetch(
172
172
  `https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`
173
173
  )).json();
174
- return (i = c == null ? void 0 : c.data) == null ? void 0 : i.map((n) => {
175
- var a, s, l;
174
+ return (a = c == null ? void 0 : c.data) == null ? void 0 : a.map((n) => {
175
+ var i, s, l;
176
176
  return {
177
177
  id: n == null ? void 0 : n.id,
178
- src: (a = n == null ? void 0 : n.images.original) == null ? void 0 : a.url,
178
+ src: (i = n == null ? void 0 : n.images.original) == null ? void 0 : i.url,
179
179
  width: +((s = n == null ? void 0 : n.images.original) == null ? void 0 : s.width),
180
180
  height: +((l = n == null ? void 0 : n.images.original) == null ? void 0 : l.width)
181
181
  };
182
182
  });
183
183
  }
184
184
  async function ce(e) {
185
- var n, a;
185
+ var n, i;
186
186
  const t = await fetch(
187
187
  `https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`
188
- ), r = await (t == null ? void 0 : t.json()), i = await (await fetch(
188
+ ), r = await (t == null ? void 0 : t.json()), a = await (await fetch(
189
189
  `https://tenor.googleapis.com/v2/search?key=${e}&q=${(n = r == null ? void 0 : r.results) == null ? void 0 : n[0]}&limit=15`
190
190
  )).json();
191
- return (a = i == null ? void 0 : i.results) == null ? void 0 : a.map((s) => {
191
+ return (i = a == null ? void 0 : a.results) == null ? void 0 : i.map((s) => {
192
192
  var l, v, b, g, y, h, _, I;
193
193
  return {
194
194
  id: s == null ? void 0 : s.id,
@@ -199,15 +199,15 @@ async function ce(e) {
199
199
  });
200
200
  }
201
201
  async function de(e, t) {
202
- var i;
202
+ var a;
203
203
  const c = await (await fetch(
204
204
  `https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`
205
205
  )).json();
206
- return (i = c == null ? void 0 : c.results) == null ? void 0 : i.map((n) => {
207
- var a, s, l, v, b, g, y, h;
206
+ return (a = c == null ? void 0 : c.results) == null ? void 0 : a.map((n) => {
207
+ var i, s, l, v, b, g, y, h;
208
208
  return {
209
209
  id: n == null ? void 0 : n.id,
210
- src: (s = (a = n == null ? void 0 : n.media_formats) == null ? void 0 : a.gif) == null ? void 0 : s.url,
210
+ src: (s = (i = n == null ? void 0 : n.media_formats) == null ? void 0 : i.gif) == null ? void 0 : s.url,
211
211
  width: (b = (v = (l = n == null ? void 0 : n.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.dims) == null ? void 0 : b[0],
212
212
  height: (h = (y = (g = n == null ? void 0 : n.media_formats) == null ? void 0 : g.gif) == null ? void 0 : y.dims) == null ? void 0 : h[1]
213
213
  };
@@ -216,11 +216,11 @@ async function de(e, t) {
216
216
  function le(e, t) {
217
217
  return {
218
218
  searchTrending: async () => t ? e === "giphy" ? se(t) : e === "tenor" ? ce(t) : [] : [],
219
- searchWord: async (i) => t ? e === "giphy" ? oe(i, t) : e === "tenor" ? de(i, t) : [] : []
219
+ searchWord: async (a) => t ? e === "giphy" ? oe(a, t) : e === "tenor" ? de(a, t) : [] : []
220
220
  };
221
221
  }
222
222
  function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
223
- const [i, n] = G(!1), [a, s] = G([]), { editorDisabled: l } = D(), v = ee(null), { searchTrending: b, searchWord: g } = le(r, t);
223
+ const [a, n] = G(!1), [i, s] = G([]), { editorDisabled: l } = D(), v = ee(null), { searchTrending: b, searchWord: g } = le(r, t);
224
224
  $(() => {
225
225
  (async () => {
226
226
  const h = await b();
@@ -240,10 +240,10 @@ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
240
240
  // Adjust the debounce delay as needed
241
241
  []
242
242
  );
243
- return /* @__PURE__ */ z(ne, { modal: !0, onOpenChange: n, open: i, children: [
243
+ return /* @__PURE__ */ z(ne, { modal: !0, onOpenChange: n, open: a, children: [
244
244
  /* @__PURE__ */ u(re, { asChild: !0, disabled: l, children: c }),
245
245
  /* @__PURE__ */ u(
246
- ie,
246
+ ae,
247
247
  {
248
248
  align: "start",
249
249
  className: "richtext-size-full richtext-p-2",
@@ -259,7 +259,7 @@ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
259
259
  type: "text"
260
260
  }
261
261
  ) }),
262
- /* @__PURE__ */ u("div", { className: "richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto", children: /* @__PURE__ */ u("div", { className: "richtext-grid richtext-grid-cols-2 richtext-gap-1", children: a != null && a.length ? a == null ? void 0 : a.map((h) => /* @__PURE__ */ u(
262
+ /* @__PURE__ */ u("div", { className: "richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto", children: /* @__PURE__ */ u("div", { className: "richtext-grid richtext-grid-cols-2 richtext-gap-1", children: i != null && i.length ? i == null ? void 0 : i.map((h) => /* @__PURE__ */ u(
263
263
  "img",
264
264
  {
265
265
  alt: "",
@@ -277,10 +277,10 @@ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
277
277
  ] });
278
278
  }
279
279
  function Te() {
280
- const e = V(ue.name), { action: t, icon: r, tooltip: c, apiKey: i, provider: n } = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a } = D();
281
- return /* @__PURE__ */ u(he, { apiKey: i, provider: n, selectImage: (l) => {
282
- a || t && t(l);
283
- }, children: /* @__PURE__ */ u(X, { disabled: a, icon: r, tooltip: c }) });
280
+ const e = V(ue.name), { action: t, icon: r, tooltip: c, apiKey: a, provider: n } = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: i } = D();
281
+ return /* @__PURE__ */ u(he, { apiKey: a, provider: n, selectImage: (l) => {
282
+ i || t && t(l);
283
+ }, children: /* @__PURE__ */ u(X, { disabled: i, icon: r, tooltip: c }) });
284
284
  }
285
285
  const ue = /* @__PURE__ */ J.extend({
286
286
  name: "imageGif",
@@ -299,8 +299,8 @@ const ue = /* @__PURE__ */ J.extend({
299
299
  selectable: !0,
300
300
  atom: !0,
301
301
  button: ({ editor: t, extension: r, t: c }) => {
302
- var a, s;
303
- const i = ((a = r == null ? void 0 : r.options) == null ? void 0 : a.provider) || "", n = ((s = r == null ? void 0 : r.options) == null ? void 0 : s.API_KEY) || "";
302
+ var i, s;
303
+ const a = ((i = r == null ? void 0 : r.options) == null ? void 0 : i.provider) || "", n = ((s = r == null ? void 0 : r.options) == null ? void 0 : s.API_KEY) || "";
304
304
  return {
305
305
  componentProps: {
306
306
  action: (l) => {
@@ -311,7 +311,7 @@ const ue = /* @__PURE__ */ J.extend({
311
311
  icon: "GifIcon",
312
312
  tooltip: c("editor.imageGif.tooltip"),
313
313
  apiKey: n,
314
- provider: i
314
+ provider: a
315
315
  }
316
316
  };
317
317
  }
@@ -341,7 +341,7 @@ const ue = /* @__PURE__ */ J.extend({
341
341
  };
342
342
  },
343
343
  addNodeView() {
344
- return Q(ae);
344
+ return Q(ie);
345
345
  },
346
346
  addCommands() {
347
347
  var e;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-C4WLt4NA.cjs"),u=require("react/jsx-runtime"),H=require("mammoth"),A=require("react"),s=require("./index-DirFiHQ6.cjs");require("./theme.cjs");const P=require("./index-BqL4vAWE.cjs");function N(o,t){const a=atob(o.split(",")[1]),l=Array.from({length:a.length});for(let i=0;i<a.length;i++)l[i]=a.charCodeAt(i);const m=new Uint8Array(l);return new Blob([m],{type:t})}function k(o,t){return new File([o],t,{type:o.type})}function z(){const o=s.useEditorInstance(),t=s.useButtonProps(y.name),{icon:a=void 0,tooltip:l=void 0,tooltipOptions:m={},isActive:i=void 0,mammothOptions:w,limit:j,convert:b}=(t==null?void 0:t.componentProps)??{},{editorDisabled:W}=s.useToggleActive(i),p=s.useExtension(y.name),{toast:q}=s.useToast(),{t:S}=P.useLocale(),[C,v]=A.useState(!1),x=A.useRef(null);function O(){var e;(e=x.current)==null||e.click()}function R(e){const n=e.target.files[0];if(n){if(n.size>j){q({variant:"destructive",title:S("editor.importWord.limitSize")});return}E(n)}}async function B(e){const c=new DOMParser().parseFromString(e,"text/html"),f=c.querySelectorAll("img");if(f.length===0)return c.body.innerHTML;if(s.hasExtension(o,s.Image.name)){const g=p==null?void 0:p.options;if(g&&typeof g.upload=="function"){const T=[];for(const h of f){const d=h.getAttribute("src"),r=N(d,"image/jpeg"),L=k(r,"image.jpeg");T.push(L)}const F=await g.upload(T);for(const[h,d]of f.entries()){d.setAttribute("src",F[h].src);const r=d.parentElement;(r==null?void 0:r.tagName)==="P"&&(r.insertAdjacentElement("beforebegin",d),!r.hasChildNodes()&&r.textContent===""&&r.remove())}return c.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),c.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),c.body.innerHTML}async function E(e){v(!0);try{if(b){const n=await b(e);I(n)}else{const n=await e.arrayBuffer(),{value:c}=await H.convertToHtml({arrayBuffer:n},w);I(c)}}finally{v(!1)}}async function I(e){const n=await B(e);o.chain().setContent(n,!0).run()}return t?u.jsxs(u.Fragment,{children:[u.jsx(s.ActionButton,{action:O,disabled:W,icon:a,loading:C,tooltip:l,tooltipOptions:m}),u.jsx("input",{accept:".docx",onChange:R,ref:x,type:"file",style:{display:"none"}})]}):u.jsx(u.Fragment,{})}const y=M.Extension.create({name:"importWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({extension:t,t:a})=>{const{convert:l,limit:m,mammothOptions:i}=t.options;return{componentProps:{convert:l,limit:m,mammothOptions:i,icon:"Word",shortcutKeys:t.options.shortcutKeys??["alt","mod","S"],tooltip:a("editor.importWord.tooltip")}}}}}});exports.ImportWord=y;exports.RichTextImportWord=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index-C4WLt4NA.cjs"),u=require("react/jsx-runtime"),H=require("mammoth"),A=require("react"),s=require("./index-ezTXvA7H.cjs");require("./theme.cjs");const P=require("./index-CWw4s87s.cjs");function N(o,t){const a=atob(o.split(",")[1]),l=Array.from({length:a.length});for(let i=0;i<a.length;i++)l[i]=a.charCodeAt(i);const m=new Uint8Array(l);return new Blob([m],{type:t})}function k(o,t){return new File([o],t,{type:o.type})}function z(){const o=s.useEditorInstance(),t=s.useButtonProps(y.name),{icon:a=void 0,tooltip:l=void 0,tooltipOptions:m={},isActive:i=void 0,mammothOptions:w,limit:j,convert:b}=(t==null?void 0:t.componentProps)??{},{editorDisabled:W}=s.useToggleActive(i),p=s.useExtension(y.name),{toast:q}=s.useToast(),{t:S}=P.useLocale(),[C,v]=A.useState(!1),x=A.useRef(null);function O(){var e;(e=x.current)==null||e.click()}function R(e){const n=e.target.files[0];if(n){if(n.size>j){q({variant:"destructive",title:S("editor.importWord.limitSize")});return}E(n)}}async function B(e){const c=new DOMParser().parseFromString(e,"text/html"),f=c.querySelectorAll("img");if(f.length===0)return c.body.innerHTML;if(s.hasExtension(o,s.Image.name)){const g=p==null?void 0:p.options;if(g&&typeof g.upload=="function"){const T=[];for(const h of f){const d=h.getAttribute("src"),r=N(d,"image/jpeg"),L=k(r,"image.jpeg");T.push(L)}const F=await g.upload(T);for(const[h,d]of f.entries()){d.setAttribute("src",F[h].src);const r=d.parentElement;(r==null?void 0:r.tagName)==="P"&&(r.insertAdjacentElement("beforebegin",d),!r.hasChildNodes()&&r.textContent===""&&r.remove())}return c.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),c.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),c.body.innerHTML}async function E(e){v(!0);try{if(b){const n=await b(e);I(n)}else{const n=await e.arrayBuffer(),{value:c}=await H.convertToHtml({arrayBuffer:n},w);I(c)}}finally{v(!1)}}async function I(e){const n=await B(e);o.chain().setContent(n,!0).run()}return t?u.jsxs(u.Fragment,{children:[u.jsx(s.ActionButton,{action:O,disabled:W,icon:a,loading:C,tooltip:l,tooltipOptions:m}),u.jsx("input",{accept:".docx",onChange:R,ref:x,type:"file",style:{display:"none"}})]}):u.jsx(u.Fragment,{})}const y=M.Extension.create({name:"importWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({extension:t,t:a})=>{const{convert:l,limit:m,mammothOptions:i}=t.options;return{componentProps:{convert:l,limit:m,mammothOptions:i,icon:"Word",shortcutKeys:t.options.shortcutKeys??["alt","mod","S"],tooltip:a("editor.importWord.tooltip")}}}}}});exports.ImportWord=y;exports.RichTextImportWord=z;
package/lib/ImportWord.js CHANGED
@@ -2,9 +2,9 @@ import { E as M } from "./index-D0EmqTpe.js";
2
2
  import { jsx as g, Fragment as I, jsxs as P } from "react/jsx-runtime";
3
3
  import R from "mammoth";
4
4
  import { useState as N, useRef as k } from "react";
5
- import { h as z, u as D, d as K, m as U, n as q, A as G, o as J, p as Q } from "./index-B1SzsIsE.js";
5
+ import { h as z, u as D, d as K, m as U, n as q, A as G, o as J, p as Q } from "./index-BVtsbzV8.js";
6
6
  import "./theme.js";
7
- import { u as V } from "./index-BlXGgvT-.js";
7
+ import { u as V } from "./index-oj858lQO.js";
8
8
  function X(e, t) {
9
9
  const s = atob(e.split(",")[1]), c = Array.from({ length: s.length });
10
10
  for (let i = 0; i < s.length; i++)
@@ -1,7 +1,7 @@
1
1
  import { o as y, E as x } from "./index-D0EmqTpe.js";
2
2
  import { TextSelection as b, AllSelection as I } from "@tiptap/pm/state";
3
3
  import { jsx as d, Fragment as m, jsxs as A } from "react/jsx-runtime";
4
- import { u as T, d as K, A as p } from "./index-B1SzsIsE.js";
4
+ import { u as T, d as K, A as p } from "./index-BVtsbzV8.js";
5
5
  import "react";
6
6
  import "./theme.js";
7
7
  var a = /* @__PURE__ */ ((t) => (t[t.max = 7] = "max", t[t.min = 0] = "min", t[t.more = 1] = "more", t[t.less = -1] = "less", t))(a || {});
@@ -1 +1 @@
1
- "use strict";const p=require("./index-C4WLt4NA.cjs"),l=require("@tiptap/pm/state"),c=require("react/jsx-runtime"),u=require("./index-DirFiHQ6.cjs");require("react");require("./theme.cjs");var a=(t=>(t[t.max=7]="max",t[t.min=0]="min",t[t.more=1]="more",t[t.less=-1]="less",t))(a||{});function b(t,e,n){return t<e?e:t>n?n:t}function T(t,e,n,o){const{doc:s,selection:i}=t;if(!s||!i||!(i instanceof l.TextSelection||i instanceof l.AllSelection))return t;const{from:r,to:d}=i;return s.nodesBetween(r,d,(m,x)=>{const I=m.type;return n.includes(I.name)?(t=h(t,x,e),!1):!p.isList(m.type.name,o.extensionManager.extensions)}),t}function h(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o)return t;const r=b((o.attrs.indent||0)+n,0,7);if(r===o.attrs.indent)return t;const d={...o.attrs,indent:r};return t.setNodeMarkup(e,o.type,d,o.marks)}function f({delta:t,types:e}){return({state:n,dispatch:o,editor:s})=>{const{selection:i}=n;let{tr:r}=n;return r=r.setSelection(i),r=T(r,t,e,s),r.docChanged?(o&&o(r),!0):!1}}function A(){const t=u.useButtonProps(y.name),{indent:e,outdent:n}=(t==null?void 0:t.componentProps)??{},{editorDisabled:o}=u.useToggleActive(),s=()=>{o||e!=null&&e.action&&(e==null||e.action())},i=()=>{o||n!=null&&n.action&&(n==null||n.action())};return t?c.jsxs(c.Fragment,{children:[c.jsx(u.ActionButton,{action:s,disabled:o,icon:e==null?void 0:e.icon,shortcutKeys:e==null?void 0:e.shortcutKeys,tooltip:e==null?void 0:e.tooltip}),c.jsx(u.ActionButton,{action:i,disabled:o,icon:n==null?void 0:n.icon,shortcutKeys:n==null?void 0:n.shortcutKeys,tooltip:n==null?void 0:n.tooltip})]}):c.jsx(c.Fragment,{})}const y=p.Extension.create({name:"richtextIndentOutdent",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["paragraph","heading","blockquote"],minIndent:a.min,maxIndent:a.max,button({editor:e,t:n,extension:o}){var s,i;return{componentProps:{indent:{action:()=>{e.commands.indent()},shortcutKeys:((s=o.options.shortcutKeys)==null?void 0:s[0])??["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")},outdent:{action:()=>{e.commands.outdent()},shortcutKeys:((i=o.options.shortcutKeys)==null?void 0:i[1])??["Shift","Tab"],icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.dataset.indent;return(e?Number.parseInt(e,10):0)||0},renderHTML:t=>t.indent?{"data-indent":t.indent}:{}}}}]},addCommands(){return{indent:()=>f({delta:a.more,types:this.options.types}),outdent:()=>f({delta:a.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});exports.Indent=y;exports.IndentProps=a;exports.RichTextIndent=A;exports.setNodeIndentMarkup=h;
1
+ "use strict";const p=require("./index-C4WLt4NA.cjs"),l=require("@tiptap/pm/state"),c=require("react/jsx-runtime"),u=require("./index-ezTXvA7H.cjs");require("react");require("./theme.cjs");var a=(t=>(t[t.max=7]="max",t[t.min=0]="min",t[t.more=1]="more",t[t.less=-1]="less",t))(a||{});function b(t,e,n){return t<e?e:t>n?n:t}function T(t,e,n,o){const{doc:s,selection:i}=t;if(!s||!i||!(i instanceof l.TextSelection||i instanceof l.AllSelection))return t;const{from:r,to:d}=i;return s.nodesBetween(r,d,(m,x)=>{const I=m.type;return n.includes(I.name)?(t=h(t,x,e),!1):!p.isList(m.type.name,o.extensionManager.extensions)}),t}function h(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o)return t;const r=b((o.attrs.indent||0)+n,0,7);if(r===o.attrs.indent)return t;const d={...o.attrs,indent:r};return t.setNodeMarkup(e,o.type,d,o.marks)}function f({delta:t,types:e}){return({state:n,dispatch:o,editor:s})=>{const{selection:i}=n;let{tr:r}=n;return r=r.setSelection(i),r=T(r,t,e,s),r.docChanged?(o&&o(r),!0):!1}}function A(){const t=u.useButtonProps(y.name),{indent:e,outdent:n}=(t==null?void 0:t.componentProps)??{},{editorDisabled:o}=u.useToggleActive(),s=()=>{o||e!=null&&e.action&&(e==null||e.action())},i=()=>{o||n!=null&&n.action&&(n==null||n.action())};return t?c.jsxs(c.Fragment,{children:[c.jsx(u.ActionButton,{action:s,disabled:o,icon:e==null?void 0:e.icon,shortcutKeys:e==null?void 0:e.shortcutKeys,tooltip:e==null?void 0:e.tooltip}),c.jsx(u.ActionButton,{action:i,disabled:o,icon:n==null?void 0:n.icon,shortcutKeys:n==null?void 0:n.shortcutKeys,tooltip:n==null?void 0:n.tooltip})]}):c.jsx(c.Fragment,{})}const y=p.Extension.create({name:"richtextIndentOutdent",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["paragraph","heading","blockquote"],minIndent:a.min,maxIndent:a.max,button({editor:e,t:n,extension:o}){var s,i;return{componentProps:{indent:{action:()=>{e.commands.indent()},shortcutKeys:((s=o.options.shortcutKeys)==null?void 0:s[0])??["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")},outdent:{action:()=>{e.commands.outdent()},shortcutKeys:((i=o.options.shortcutKeys)==null?void 0:i[1])??["Shift","Tab"],icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.dataset.indent;return(e?Number.parseInt(e,10):0)||0},renderHTML:t=>t.indent?{"data-indent":t.indent}:{}}}}]},addCommands(){return{indent:()=>f({delta:a.more,types:this.options.types}),outdent:()=>f({delta:a.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});exports.Indent=y;exports.IndentProps=a;exports.RichTextIndent=A;exports.setNodeIndentMarkup=h;
package/lib/Indent.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-C4WLt4NA.cjs");const e=require("./Indent-DtgugDpq.cjs");exports.Indent=e.Indent;exports.RichTextIndent=e.RichTextIndent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-C4WLt4NA.cjs");const e=require("./Indent-CQCn1r9U.cjs");exports.Indent=e.Indent;exports.RichTextIndent=e.RichTextIndent;
package/lib/Indent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./index-D0EmqTpe.js";
2
- import { I as o, R as r } from "./Indent-BTzj50Sf.js";
2
+ import { I as o, R as r } from "./Indent-BCZFJKcN.js";
3
3
  export {
4
4
  o as Indent,
5
5
  r as RichTextIndent
package/lib/Italic.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-C4WLt4NA.cjs"),s=require("react/jsx-runtime"),a=require("./index-DirFiHQ6.cjs");require("react");require("./theme.cjs");var y=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,I=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,h=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,k=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,v=r.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",r.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[r.markInputRule({find:y,type:this.type}),r.markInputRule({find:h,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:I,type:this.type}),r.markPasteRule({find:k,type:this.type})]}}),f=v;function M(){const t=a.useButtonProps(u.name),{icon:e=void 0,tooltip:n=void 0,shortcutKeys:i=void 0,tooltipOptions:c={},action:o=void 0,isActive:d=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:m,disabled:l,update:p}=a.useToggleActive(d),g=()=>{l||o&&(o(),p())};return t?s.jsx(a.ActionButton,{action:g,dataState:m,disabled:l,icon:e,shortcutKeys:i,tooltip:n,tooltipOptions:c}):s.jsx(s.Fragment,{})}const u=f.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:e,t:n,extension:i}){return{componentProps:{action:()=>e.commands.toggleItalic(),isActive:()=>e.isActive("italic")||!1,disabled:!1,shortcutKeys:i.options.shortcutKeys??["mod","I"],icon:"Italic",tooltip:n("editor.italic.tooltip")}}}}}});exports.Italic=u;exports.RichTextItalic=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-C4WLt4NA.cjs"),s=require("react/jsx-runtime"),a=require("./index-ezTXvA7H.cjs");require("react");require("./theme.cjs");var y=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,I=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,h=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,k=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,v=r.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",r.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[r.markInputRule({find:y,type:this.type}),r.markInputRule({find:h,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:I,type:this.type}),r.markPasteRule({find:k,type:this.type})]}}),f=v;function M(){const t=a.useButtonProps(u.name),{icon:e=void 0,tooltip:n=void 0,shortcutKeys:i=void 0,tooltipOptions:c={},action:o=void 0,isActive:d=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:m,disabled:l,update:p}=a.useToggleActive(d),g=()=>{l||o&&(o(),p())};return t?s.jsx(a.ActionButton,{action:g,dataState:m,disabled:l,icon:e,shortcutKeys:i,tooltip:n,tooltipOptions:c}):s.jsx(s.Fragment,{})}const u=f.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:e,t:n,extension:i}){return{componentProps:{action:()=>e.commands.toggleItalic(),isActive:()=>e.isActive("italic")||!1,disabled:!1,shortcutKeys:i.options.shortcutKeys??["mod","I"],icon:"Italic",tooltip:n("editor.italic.tooltip")}}}}}});exports.Italic=u;exports.RichTextItalic=M;
package/lib/Italic.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as g, f as o, h as i, m as y } from "./index-D0EmqTpe.js";
2
2
  import { jsx as d, Fragment as h } from "react/jsx-runtime";
3
- import { u as f, d as I, A as v } from "./index-B1SzsIsE.js";
3
+ import { u as f, d as I, A as v } from "./index-BVtsbzV8.js";
4
4
  import "react";
5
5
  import "./theme.js";
6
6
  var M = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, k = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, A = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, _ = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, R = g.create({
@@ -3,11 +3,11 @@ import { N as $o, a as Eo } from "./clsx-Bg-2aTKh.js";
3
3
  import { jsx as er, jsxs as _r } from "react/jsx-runtime";
4
4
  import Xa from "katex";
5
5
  import { useState as Ur, useRef as xo, useEffect as Bo, useMemo as Hr, useCallback as To } from "react";
6
- import { u as Mo, d as jo, h as Co, D as Do, r as Fo, A as No, s as _o, v as Wo, L as un, w as ko, B as Lo } from "./index-B1SzsIsE.js";
6
+ import { u as Mo, d as jo, h as Co, D as Do, r as Fo, A as No, s as _o, v as Wo, L as un, w as ko, B as Lo } from "./index-BVtsbzV8.js";
7
7
  import "./theme.js";
8
- import { T as fn } from "./textarea--IMIy9VF.js";
8
+ import { T as fn } from "./textarea-MU5imD7D.js";
9
9
  import { a as Uo, c as Gr, g as Ho } from "./_commonjsHelpers-B4e78b8K.js";
10
- import { u as Go } from "./index-BlXGgvT-.js";
10
+ import { u as Go } from "./index-oj858lQO.js";
11
11
  var ae, sn;
12
12
  function Qa() {
13
13
  if (sn) return ae;