react-reason-editor 1.0.24 → 1.0.26

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 (99) hide show
  1. package/README.md +24 -0
  2. package/dist/{Attachment-DGzsbPZZ.js → Attachment-FN0H4pdR.js} +2 -2
  3. package/dist/Attachment.js +1 -1
  4. package/dist/BulletList.cjs +1 -1
  5. package/dist/{Callout-heY7R-Zu.js → Callout-C6kKHIbW.js} +2 -2
  6. package/dist/Callout.js +1 -1
  7. package/dist/{CodeBlock-B7Wklup8.js → CodeBlock-DLhI2Guf.js} +1 -1
  8. package/dist/{CodeBlock-D2OKvGCF.cjs → CodeBlock-zh4cX5EA.cjs} +1 -1
  9. package/dist/CodeBlock.cjs +1 -1
  10. package/dist/CodeBlock.js +1 -1
  11. package/dist/CodeView.cjs +1 -1
  12. package/dist/CodeView.js +1 -1
  13. package/dist/{Color-BxzxtvJH.cjs → Color-D5zLljFV.cjs} +1 -1
  14. package/dist/Color.cjs +1 -1
  15. package/dist/{Drawer-DxCO6TBr.cjs → Drawer-B0QvuSOf.cjs} +1 -1
  16. package/dist/{Drawer-Dunw22Q1.js → Drawer-bqo2XUCW.js} +12 -12
  17. package/dist/Drawer.cjs +1 -1
  18. package/dist/Drawer.js +1 -1
  19. package/dist/{Drawio-eqEGDkwW.js → Drawio-CIXM-WGy.js} +4 -4
  20. package/dist/Drawio.js +1 -1
  21. package/dist/{Emoji-BU-itkPp.js → Emoji-CTvSFbHz.js} +3 -3
  22. package/dist/Emoji.js +1 -1
  23. package/dist/FontFamily.js +2 -2
  24. package/dist/{Highlight-BeqLxfbY.cjs → Highlight-DQxtCrNN.cjs} +1 -1
  25. package/dist/Highlight.cjs +1 -1
  26. package/dist/{History-C6yBYB2w.js → History-PbMa-usl.js} +1 -1
  27. package/dist/History.js +1 -1
  28. package/dist/Image.js +1 -1
  29. package/dist/{ImageCropper-Dlz4nJQu.js → ImageCropper-CN_GzBBG.js} +5 -5
  30. package/dist/{ImageGif-D5Qw_Xf-.js → ImageGif-D9goI48J.js} +3 -3
  31. package/dist/ImageGif.js +1 -1
  32. package/dist/{ImportWord-BCcs3dYp.js → ImportWord-Bux3L57d.js} +1 -1
  33. package/dist/ImportWord.js +1 -1
  34. package/dist/{Indent-DpTPoZMk.js → Indent-fBwkYx_q.js} +1 -1
  35. package/dist/Indent.js +1 -1
  36. package/dist/{Katex-D_vF5gsD.cjs → Katex-B1xls7hE.cjs} +1 -1
  37. package/dist/{Katex-Bo_vfXrd.js → Katex-D2g86C-B.js} +3 -3
  38. package/dist/Katex.cjs +1 -1
  39. package/dist/Katex.js +1 -1
  40. package/dist/LineHeight.js +1 -1
  41. package/dist/{Link-C0cNnjXo.js → Link-Dpaom2jX.js} +1 -1
  42. package/dist/Link.js +1 -1
  43. package/dist/{Mention-DEkbeL04.js → Mention-D0HVk1SC.js} +1 -1
  44. package/dist/Mention.js +1 -1
  45. package/dist/{Mermaid-BB15qd24.cjs → Mermaid-3vSlkOlc.cjs} +1 -1
  46. package/dist/Mermaid-B3KGZMBo.js +5 -0
  47. package/dist/Mermaid.cjs +1 -1
  48. package/dist/Mermaid.js +1 -1
  49. package/dist/MoreMark.js +1 -1
  50. package/dist/OrderedList.cjs +1 -1
  51. package/dist/SearchAndReplace.cjs +1 -1
  52. package/dist/SearchAndReplace.js +1 -1
  53. package/dist/{SlashCommand-8LkH8bHy.js → SlashCommand-ZFZhrxKb.js} +1 -1
  54. package/dist/SlashCommand.js +1 -1
  55. package/dist/{Table-C9t-k9Qu.js → Table-6kM52sUH.js} +2 -2
  56. package/dist/Table.js +1 -1
  57. package/dist/TaskList.cjs +1 -1
  58. package/dist/{TextAlign-C75gn_OM.js → TextAlign-BKo82ocx.js} +1 -1
  59. package/dist/TextAlign.js +1 -1
  60. package/dist/TextDirection.js +1 -1
  61. package/dist/{Twitter-DyrQT0n4.cjs → Twitter-3yCP2UdP.cjs} +1 -1
  62. package/dist/{Twitter-D5UNfT-K.js → Twitter-D38giVew.js} +2 -2
  63. package/dist/Twitter.cjs +1 -1
  64. package/dist/Twitter.js +1 -1
  65. package/dist/{Video-_YlAC2R_.js → Video-DcfPDZLP.js} +3 -3
  66. package/dist/Video.js +1 -1
  67. package/dist/WordCount.js +1 -1
  68. package/dist/{bubble---c27x7L.js → bubble-4RecyKlX.js} +1 -1
  69. package/dist/bubble.cjs +1 -1
  70. package/dist/bubble.js +1 -1
  71. package/dist/editor-kit.cjs +1 -0
  72. package/dist/editor-kit.d.ts +13 -0
  73. package/dist/editor-kit.js +1 -0
  74. package/dist/editor-views/components/AlignToolbar.d.ts +4 -0
  75. package/dist/editor-views/components/BubbleMenus.d.ts +4 -0
  76. package/dist/editor-views/components/EditorContainer.d.ts +10 -0
  77. package/dist/editor-views/components/Header.d.ts +8 -0
  78. package/dist/editor-views/components/Toolbar.d.ts +26 -0
  79. package/dist/editor-views/components/constants.d.ts +14 -0
  80. package/dist/editor-views/components/extensions.d.ts +8 -0
  81. package/dist/editor-views/components/index.d.ts +9 -0
  82. package/dist/editor-views/config/baseKit.d.ts +7 -0
  83. package/dist/editor-views/config/editorConfig.d.ts +37 -0
  84. package/dist/editor-views/config/pluginRegistry.d.ts +43 -0
  85. package/dist/editorConfig-Cgs4P8O5.js +184 -0
  86. package/dist/editorConfig-CnzPmOCy.cjs +1 -0
  87. package/dist/html-to-docx.esm-DkztZsL5-BqrjWkoQ.cjs +1 -0
  88. package/dist/index.cjs +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/reason-docs.cjs +1 -1
  91. package/dist/reason-docs.js +1 -1
  92. package/dist/{separator-BHN46aj5.cjs → separator-CXjMk9dM.cjs} +1 -1
  93. package/dist/src-73l1pSjp.js +463 -0
  94. package/dist/src-CF0U82SA.cjs +1 -0
  95. package/package.json +12 -2
  96. package/dist/Mermaid-DxpFRVu0.js +0 -5
  97. package/dist/html-to-docx.esm-DkztZsL5-DQYdhD3B.cjs +0 -1
  98. package/dist/src-C7k3RYxJ.js +0 -646
  99. package/dist/src-DYbBlAjR.cjs +0 -1
package/dist/Emoji.js CHANGED
@@ -1 +1 @@
1
- import{n as o,r,t as s}from"./Emoji-BU-itkPp.js";export{s as EXTENSION_PRIORITY_HIGHEST,o as Emoji,r as RichTextEmoji};
1
+ import{n as o,r,t as s}from"./Emoji-CTvSFbHz.js";export{s as EXTENSION_PRIORITY_HIGHEST,o as Emoji,r as RichTextEmoji};
@@ -1,2 +1,2 @@
1
- import{t}from"./ActionMenuButton-DHYJFTev.js";import{f as e,n as i}from"./locales-DfkG6-1b.js";import{a as o,f as a,n,r as s,s as r,t as l}from"./dropdown-menu-CfGzSpIy.js";import{r as c,s as m,t as d}from"./useButtonProps-DSIajp_B.js";import{n as u}from"./dist-BZqs5TU5.js";import f,{Fragment as p,useMemo as h}from"react";import{Fragment as v,jsx as x,jsxs as y}from"react/jsx-runtime";function F(){const{t:e}=i(),c=d(b.name),{icon:u,tooltip:f,items:F=[],isActive:A}=c?.componentProps??{},{disabled:j,dataState:w}=m(A),D=h(()=>w?.font||"Inter",[w]);return c?/* @__PURE__ */y(l,{children:[/* @__PURE__ */x(a,{asChild:!0,disabled:j,children:/* @__PURE__ */x("div",{className:"richtext-w-full",children:/* @__PURE__ */x(t,{disabled:j,icon:u,title:D,tooltip:f})})}),/* @__PURE__ */y(s,{className:"richtext-max-h-96 richtext-w-56 richtext-overflow-y-auto",children:[/* @__PURE__ */x(o,{className:"richtext-text-xs richtext-text-muted-foreground",children:"Font Family"}),F?.map((t,e)=>{const i=t.default?{}:{fontFamily:t.font};/* @__PURE__ */
2
- return y(p,{children:[/* @__PURE__ */x(n,{checked:D===t.font,onClick:t.action,children:/* @__PURE__ */x("div",{className:"richtext-truncate",style:i,children:t.title})}),t.default&&/* @__PURE__ */x(r,{})]},`font-family-${e}`)})]})]}):/* @__PURE__ */x(v,{})}var b=u.extend({addOptions(){return{...this.parent?.(),fontFamilyList:e,button({editor:t,extension:e,t:i}){const o=c(e?.options?.fontFamilyList||[]),a=o.map(e=>({action:()=>{"Default"!==e.value?t.chain().focus().setFontFamily(e.value).run():t.chain().focus().unsetFontFamily().run()},isActive:()=>t.isActive("textStyle",{fontFamily:e.value})||!1,title:"Default"===e.value?"Inter":e.name,font:"Default"===e.value?"Inter":e.value,default:"Default"===e.value})).sort((t,e)=>t.default?-1:e.default?1:t.title.localeCompare(e.title,void 0,{sensitivity:"base"}));return{componentProps:{tooltip:i("editor.fontFamily.tooltip"),disabled:!1,items:a,isActive:()=>{const t=a?.find(t=>t.isActive());return t&&!t.default?t:{title:"Inter",font:"Inter",isActive:()=>!1,disabled:!1}},icon:"MenuDown",fontFamilyList:o}}}}}});export{b as FontFamily,F as RichTextFontFamily};
1
+ import{t}from"./ActionMenuButton-DHYJFTev.js";import{f as e,n as i}from"./locales-DfkG6-1b.js";import{a as o,f as a,n,r as s,s as r,t as l}from"./dropdown-menu-CfGzSpIy.js";import{r as c,s as m,t as d}from"./useButtonProps-DSIajp_B.js";import{n as u}from"./dist-BZqs5TU5.js";import f,{Fragment as p,useMemo as h}from"react";import{Fragment as v,jsx as x,jsxs as y}from"react/jsx-runtime";function F(){const{t:e}=i(),c=d(A.name),{icon:u,tooltip:f,items:F=[],isActive:b}=c?.componentProps??{},{disabled:j,dataState:w}=m(b),D=h(()=>w?.font||"Inter",[w]);return c?/* @__PURE__ */y(l,{children:[/* @__PURE__ */x(a,{asChild:!0,disabled:j,children:/* @__PURE__ */x("div",{className:"richtext-w-full",children:/* @__PURE__ */x(t,{disabled:j,icon:u,title:D,tooltip:f})})}),/* @__PURE__ */y(s,{className:"richtext-max-h-96 richtext-w-56 richtext-overflow-y-auto",children:[/* @__PURE__ */x(o,{className:"richtext-text-xs richtext-text-muted-foreground",children:"Font Family"}),F?.map((t,e)=>{const i=t.default?{}:{fontFamily:t.font};/* @__PURE__ */
2
+ return y(p,{children:[/* @__PURE__ */x(n,{checked:D===t.font,onClick:t.action,children:/* @__PURE__ */x("div",{className:"richtext-truncate",style:i,children:t.title})}),t.default&&/* @__PURE__ */x(r,{})]},`font-family-${e}`)})]})]}):/* @__PURE__ */x(v,{})}var A=u.extend({addOptions(){return{...this.parent?.(),fontFamilyList:e,button({editor:t,extension:e,t:i}){const o=c(e?.options?.fontFamilyList||[]),a=o.map(e=>({action:()=>{"Default"!==e.value?t.chain().focus().setFontFamily(e.value).run():t.chain().focus().unsetFontFamily().run()},isActive:()=>t.isActive("textStyle",{fontFamily:e.value})||!1,title:"Default"===e.value?"Inter":e.name,font:"Default"===e.value?"Inter":e.value,default:"Default"===e.value})).sort((t,e)=>t.default?-1:e.default?1:t.title.localeCompare(e.title,void 0,{sensitivity:"base"}));return{componentProps:{tooltip:i("editor.fontFamily.tooltip"),disabled:!1,items:a,isActive:()=>{const t=a?.find(t=>t.isActive());return t&&!t.default?t:{title:"Inter",font:"Inter",isActive:()=>!1,disabled:!1}},icon:"MenuDown",fontFamilyList:o}}}}}});export{A as FontFamily,F as RichTextFontFamily};
@@ -1 +1 @@
1
- const t=require("./rolldown-runtime-BeavJI0R.cjs"),e=require("./toggle-CRftKzl0.cjs"),r=require("./separator-BHN46aj5.cjs"),i=require("./Icon-DQdA22_-.cjs"),o=require("./useButtonProps-D2Hd5DbR.cjs");let n=require("react");n=t.__toESM(n,1);let s=require("react/jsx-runtime"),l=require("@tiptap/core");var h=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,a=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;function c({fill:t}){return(0,s.jsx)("svg",{height:"18px",version:"1.1",viewBox:"0 0 256 256",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:(0,s.jsxs)("g",{id:"icon/背景颜色",children:[(0,s.jsx)("g",{fill:"currentColor",children:(0,s.jsxs)("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",children:[(0,s.jsx)("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),(0,s.jsx)("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),(0,s.jsx)("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),(0,s.jsx)("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",fill:"string"==typeof t?t:"none",id:"矩形"})]})})})}function u(){const t=o.useButtonProps(d.name),{tooltip:l,isActive:h,defaultColor:a,colors:u,action:g,shortcutKeys:p}=t?.componentProps??{},{editorDisabled:m}=o.useActive(h),[f,x]=(0,n.useState)(a);return t?(0,s.jsx)(r.ColorPicker,{colors:u,disabled:m,highlight:!0,onChange:function(t){m||g&&(g?.(t),x(t))},value:f,children:(0,s.jsx)(e.ActionButton,{disabled:m,tooltip:l,shortcutKeys:p,children:(0,s.jsxs)("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[(0,s.jsx)(c,{fill:f}),(0,s.jsx)(i.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):(0,s.jsx)(s.Fragment,{})}var d=l.Mark.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||(0,l.getStyleProperty)(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",(0,l.mergeAttributes)(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,r){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const t=i[2].trim(),e=r.inlineTokens(t);return{type:"highlight",raw:i[0],text:t,tokens:e}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[(0,l.markInputRule)({find:h,type:this.type})]},addPasteRules(){return[(0,l.markPasteRule)({find:a,type:this.type})]}}).extend({addStorage(){return{currentColor:this.options.defaultColor||void 0}},addOptions(){return{...this.parent?.(),multicolor:!0,button:({editor:t,t:e,extension:r})=>({componentProps:{action:e=>{if("string"==typeof e)return t.storage.highlight.currentColor=e,void t.chain().focus().setHighlight({color:e}).run();t.chain().focus().unsetHighlight().run()},isActive:()=>t.isActive("highlight")||!1,disabled:!1,shortcutKeys:r.options.shortcutKeys??["⇧","mod","H"],tooltip:e("editor.highlight.tooltip"),defaultColor:r.options.defaultColor}})}},addKeyboardShortcuts(){return{...this.parent?.(),"Mod-Shift-h":()=>{const t=this.storage.currentColor||this.options.defaultColor;if(!t){const{color:t}=this.editor.getAttributes("highlight");return!!t&&this.editor.chain().focus().unsetHighlight().run()}return this.editor.isActive("highlight",{color:t})?this.editor.chain().focus().unsetHighlight().run():this.editor.chain().focus().setHighlight({color:t}).run()}}}});Object.defineProperty(exports,"Highlight",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"RichTextHighlight",{enumerable:!0,get:function(){return u}});
1
+ const t=require("./rolldown-runtime-BeavJI0R.cjs"),e=require("./toggle-CRftKzl0.cjs"),r=require("./separator-CXjMk9dM.cjs"),i=require("./Icon-DQdA22_-.cjs"),o=require("./useButtonProps-D2Hd5DbR.cjs");let n=require("react");n=t.__toESM(n,1);let s=require("react/jsx-runtime"),l=require("@tiptap/core");var h=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,a=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;function c({fill:t}){return(0,s.jsx)("svg",{height:"18px",version:"1.1",viewBox:"0 0 256 256",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:(0,s.jsxs)("g",{id:"icon/背景颜色",children:[(0,s.jsx)("g",{fill:"currentColor",children:(0,s.jsxs)("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",children:[(0,s.jsx)("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),(0,s.jsx)("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),(0,s.jsx)("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),(0,s.jsx)("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",fill:"string"==typeof t?t:"none",id:"矩形"})]})})})}function u(){const t=o.useButtonProps(d.name),{tooltip:l,isActive:h,defaultColor:a,colors:u,action:g,shortcutKeys:p}=t?.componentProps??{},{editorDisabled:m}=o.useActive(h),[f,x]=(0,n.useState)(a);return t?(0,s.jsx)(r.ColorPicker,{colors:u,disabled:m,highlight:!0,onChange:function(t){m||g&&(g?.(t),x(t))},value:f,children:(0,s.jsx)(e.ActionButton,{disabled:m,tooltip:l,shortcutKeys:p,children:(0,s.jsxs)("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[(0,s.jsx)(c,{fill:f}),(0,s.jsx)(i.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):(0,s.jsx)(s.Fragment,{})}var d=l.Mark.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||(0,l.getStyleProperty)(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",(0,l.mergeAttributes)(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,r){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const t=i[2].trim(),e=r.inlineTokens(t);return{type:"highlight",raw:i[0],text:t,tokens:e}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[(0,l.markInputRule)({find:h,type:this.type})]},addPasteRules(){return[(0,l.markPasteRule)({find:a,type:this.type})]}}).extend({addStorage(){return{currentColor:this.options.defaultColor||void 0}},addOptions(){return{...this.parent?.(),multicolor:!0,button:({editor:t,t:e,extension:r})=>({componentProps:{action:e=>{if("string"==typeof e)return t.storage.highlight.currentColor=e,void t.chain().focus().setHighlight({color:e}).run();t.chain().focus().unsetHighlight().run()},isActive:()=>t.isActive("highlight")||!1,disabled:!1,shortcutKeys:r.options.shortcutKeys??["⇧","mod","H"],tooltip:e("editor.highlight.tooltip"),defaultColor:r.options.defaultColor}})}},addKeyboardShortcuts(){return{...this.parent?.(),"Mod-Shift-h":()=>{const t=this.storage.currentColor||this.options.defaultColor;if(!t){const{color:t}=this.editor.getAttributes("highlight");return!!t&&this.editor.chain().focus().unsetHighlight().run()}return this.editor.isActive("highlight",{color:t})?this.editor.chain().focus().unsetHighlight().run():this.editor.chain().focus().setHighlight({color:t}).run()}}}});Object.defineProperty(exports,"Highlight",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"RichTextHighlight",{enumerable:!0,get:function(){return u}});
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const i=require("./Highlight-BeqLxfbY.cjs");exports.Highlight=i.Highlight,exports.RichTextHighlight=i.RichTextHighlight;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const i=require("./Highlight-DQxtCrNN.cjs");exports.Highlight=i.Highlight,exports.RichTextHighlight=i.RichTextHighlight;
@@ -1 +1 @@
1
- import{n as t}from"./dist-CsCFCV4K.js";import{n as o}from"./toggle-BXl_NYYh.js";import{s as e,t as n}from"./useButtonProps-DSIajp_B.js";import r from"react";import{Fragment as s,jsx as i}from"react/jsx-runtime";import{Extension as a,callOrReturn as d,getChangedRanges as c,getExtensionField as p,isNodeEmpty as l,isNodeSelection as u}from"@tiptap/core";import{Plugin as h,PluginKey as m}from"@tiptap/pm/state";import{dropCursor as f}from"@tiptap/pm/dropcursor";import{Decoration as y,DecorationSet as g}from"@tiptap/pm/view";import{gapCursor as w}from"@tiptap/pm/gapcursor";import{history as A,redo as b,undo as C}from"@tiptap/pm/history";a.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(t=>""!==t).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=t=>{const o=(null==t?void 0:t.node)||this.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||this.options.mode)){const t=o.textBetween(0,o.content.size,void 0," ");return this.options.textCounter(t)}return o.nodeSize},this.storage.words=t=>{const o=(null==t?void 0:t.node)||this.editor.state.doc,e=o.textBetween(0,o.content.size," "," ");return this.options.wordCounter(e)}},addProseMirrorPlugins(){let t=!1;return[new h({key:new m("characterCount"),appendTransaction:(o,e,n)=>{if(t)return;const r=this.options.limit,s=this.options.autoTrim;if(null==r||0===r||!1===s)return void(t=!0);const i=this.storage.characters({node:n.doc});if(i>r){const o=0,e=i-r,s=n.tr.deleteRange(o,e);return t=!0,s}t=!0},filterTransaction:(t,o)=>{const e=this.options.limit;if(!t.docChanged||0===e||null==e)return!0;const n=this.storage.characters({node:o.doc}),r=this.storage.characters({node:t.doc});if(r<=e)return!0;if(n>e&&r>e&&r<=n)return!0;if(n>e&&r>e&&r>n)return!1;if(!t.getMeta("paste"))return!1;const s=t.selection.$head.pos,i=s-(r-e),a=s;return t.deleteRange(i,a),!(this.storage.characters({node:t.doc})>e)}})]}});var v=a.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[f(this.options)]}}),M=(a.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new h({key:new m("focus"),props:{decorations:({doc:t,selection:o})=>{const{isEditable:e,isFocused:n}=this.editor,{anchor:r}=o,s=[];if(!e||!n)return g.create(t,[]);let i=0;"deepest"===this.options.mode&&t.descendants((t,o)=>{if(!t.isText)return r>=o&&r<=o+t.nodeSize-1&&void(i+=1)});let a=0;return t.descendants((t,o)=>!t.isText&&(r>=o&&r<=o+t.nodeSize-1&&(a+=1,"deepest"===this.options.mode&&i-a>0||"shallowest"===this.options.mode&&a>1?"deepest"===this.options.mode:void s.push(y.node(o,o+t.nodeSize,{class:this.options.className}))))),g.create(t,s)}}})]}}),a.create({name:"gapCursor",addProseMirrorPlugins:()=>[w()],extendNodeSchema(t){var o;const e={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:null!=(o=d(p(t,"allowGapCursor",e)))?o:null}}})),z="placeholder",S=new m("tiptap__placeholder");function O(t){const{editor:o,placeholder:e,dataAttribute:n,pos:r,node:s,isEmptyDoc:i,hasAnchor:a,classes:{emptyNode:d,emptyEditor:c}}=t,p=[d];return i&&p.push(c),y.node(r,r+s.nodeSize,{class:p.join(" "),[n]:"function"==typeof e?e({editor:o,node:s,pos:r,hasAnchor:a}):e})}function E(t,o){return"function"==typeof t?t(o):t}function P({editor:t,options:o,dataAttribute:e,doc:n,selection:r,from:s,to:i}){const{anchor:a}=r,d=[],c=t.isEmpty;return n.nodesBetween(s,i,(n,r)=>{const s=a>=r&&a<=r+n.nodeSize,i=!n.isLeaf&&l(n);return n.type.isTextblock?(!s&&o.showOnlyCurrent||!i||d.push(O({editor:t,isEmptyDoc:c,dataAttribute:e,hasAnchor:s,placeholder:o.placeholder,classes:{emptyEditor:o.emptyEditorClass,emptyNode:E(o.emptyNodeClass,{editor:t,node:n,pos:r,hasAnchor:s})},node:n,pos:r})),o.includeChildren):o.includeChildren}),d}function x({editor:t,options:o,dataAttribute:e,doc:n,selection:r}){if(!t.isEditable&&o.showOnlyWhenEditable)return null;const{anchor:s}=r,i=[],a=t.isEmpty;if(o.showOnlyCurrent&&!o.includeChildren){const r=n.resolve(s),d=r.depth>0?r.node(1):r.nodeAfter,c=r.depth>0?r.before(1):s;if(d&&d.type.isTextblock&&l(d)){const n=s>=c&&s<=c+d.nodeSize;i.push(O({editor:t,isEmptyDoc:a,dataAttribute:e,hasAnchor:n,placeholder:o.placeholder,classes:{emptyEditor:o.emptyEditorClass,emptyNode:E(o.emptyNodeClass,{editor:t,node:d,pos:c,hasAnchor:n})},node:d,pos:c}))}}else i.push(...P({editor:t,options:o,dataAttribute:e,doc:n,selection:r,from:0,to:n.content.size}));return g.create(n,i)}function N(t,o){var e;const n=t.resolve(o);if(0===n.depth){const t=null!=(e=n.nodeAfter)?e:n.nodeBefore;if(!t)return{from:o,to:o};const r=n.nodeAfter?o:o-t.nodeSize;return{from:r,to:r+t.nodeSize}}const r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function T(t,o){return{from:Math.max(0,o.from-1),to:Math.min(t.content.size,o.to-1)}}function K(t,o){const e=function(t,o,e){const n=[];return t.forEach((t,r)=>{const s=r,i=s+t.nodeSize;s+1<e&&i+1>o&&n.push({from:s,to:i})}),n}(t,o.from,o.to);return e.push(T(t,N(t,o.from))),o.to>o.from?e.push(T(t,N(t,Math.min(o.to,t.content.size+1)-1))):o.from<t.content.size+1&&e.push(T(t,N(t,Math.min(o.from+1,t.content.size)))),e}function k(t,o,e){const n=[];if(t.docChanged){const o=c(t);for(const t of o)n.push(...K(e.doc,t.newRange))}return t.selectionSet&&(n.push(T(e.doc,N(e.doc,t.mapping.map(o.selection.anchor)))),n.push(T(e.doc,N(e.doc,e.selection.anchor)))),function(t){if(0===t.length)return[];const o=[...t].sort((t,o)=>t.from-o.from),e=[{...o[0]}];for(let n=1;n<o.length;n+=1){const t=e[e.length-1],r=o[n];r.from<=t.to?t.to=Math.max(t.to,r.to):e.push({...r})}return e}(n)}function D(t,o,e){const n=Math.max(0,Math.min(t,e.content.size));return{from:n,to:Math.max(n,Math.min(o,e.content.size))}}function j({editor:t,options:o,dataAttribute:e}){return{init(n,r){const s=x({editor:t,options:o,dataAttribute:e,doc:r.doc,selection:r.selection});return null!=s?s:g.empty},apply:(n,r,s,i)=>n.docChanged||n.selectionSet?function({decorations:t,ranges:o,editor:e,options:n,dataAttribute:r,doc:s,selection:i}){let a=t;for(const d of o){const{from:t,to:o}=D(d.from,d.to,s),c=a.find(t,o).filter(e=>e.from>=t&&e.to<=o);c.length&&(a=a.remove(c));const p=P({editor:e,options:n,dataAttribute:r,doc:s,selection:i,from:t,to:o});p.length&&(a=a.add(s,p))}return a}({decorations:r.map(n.mapping,n.doc),ranges:k(n,s,i),editor:t,options:o,dataAttribute:e,doc:i.doc,selection:i.selection}):r}}function B({editor:t,options:o}){const e=o.dataAttribute?`data-${n=o.dataAttribute,n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${z}`;var n;const r=o.showOnlyCurrent&&!o.includeChildren;return new h({key:S,...r?{}:{state:j({editor:t,options:o,dataAttribute:e})},props:{decorations:r?({doc:n,selection:r})=>x({editor:t,options:o,dataAttribute:e,doc:n,selection:r}):e=>{var n;return o.showOnlyWhenEditable&&!t.isEditable?g.empty:null!=(n=S.getState(e))?n:g.empty}}})}var R=a.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:z,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[B({editor:this.editor,options:this.options})]}});function F(t,o){return!t.selection.empty&&!u(t.selection)&&o.isEditable}a.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:o}=this;return[new h({key:new m("selection"),props:{decorations:e=>function(t,o){return F(t,o)&&!o.isFocused&&!o.view.dragging}(e,t)?g.create(e.doc,[y.inline(e.selection.from,e.selection.to,{class:o.className})]):null,handleDOMEvents:{blur(o){return!!F(o.state,t)&&(null==(e=window.getSelection())||e.removeAllRanges(),!1);var e},focus:o=>!!F(o.state,t)&&(requestAnimationFrame(()=>{!t.isDestroyed&&o.hasFocus()&&function(t){t.focus()}(o)}),!1)}}})]}});function G({types:t,node:o}){return o&&Array.isArray(t)&&t.includes(o.type)||(null==o?void 0:o.type)===t}var W=a.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t;const o=new m(this.name),e=this.options.node||(null==(t=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:t.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(e).includes(t.name));return[new h({key:o,appendTransaction:(t,n,r)=>{const{doc:s,tr:i,schema:a}=r,d=o.getState(r),c=s.content.size,p=a.nodes[e];if(!t.some(t=>t.getMeta("skipTrailingNode"))&&d)return i.insert(c,p.create())},state:{init:(t,o)=>!G({node:o.tr.doc.lastChild,types:n}),apply:(t,o)=>{if(!t.docChanged)return o;if(t.getMeta("__uniqueIDTransaction"))return o;return!G({node:t.doc.lastChild,types:n})}}})]}});function _(){const r=n(Z.name),{icon:a,tooltip:d,shortcutKeys:c,tooltipOptions:p={},action:l,isActive:u}=r?.componentProps?.undo??{},{disabled:h}=e(u),m=t[a];return r&&m?/* @__PURE__ */i(o,{action:()=>{h||l&&l()},disabled:h,icon:a,shortcutKeys:c,tooltip:d,tooltipOptions:p}):/* @__PURE__ */i(s,{})}function q(){const t=n(Z.name),{icon:r,tooltip:a,shortcutKeys:d,tooltipOptions:c={},action:p,isActive:l}=t?.componentProps?.redo??{},{disabled:u}=e(l);return t?/* @__PURE__ */i(o,{action:()=>{u||p&&p()},disabled:u,icon:r,shortcutKeys:d,tooltip:a,tooltipOptions:c}):/* @__PURE__ */i(s,{})}var Z=a.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:o})=>C(t,o),redo:()=>({state:t,dispatch:o})=>b(t,o)}),addProseMirrorPlugins(){return[A(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}).extend({addOptions(){return{...this.parent?.(),depth:100,newGroupDelay:500,button:({editor:t,t:o,extension:e})=>({componentProps:{undo:{action:()=>{t.chain().focus().undo().run()},shortcutKeys:e.options.shortcutKeys?.[0]??["mod","Z"],isActive:()=>t.can().undo(),icon:"Undo2",tooltip:o("editor.undo.tooltip")},redo:{action:()=>{t.chain().focus().redo().run()},shortcutKeys:e.options.shortcutKeys?.[1]??["shift","mod","Z"],isActive:()=>t.can().redo(),icon:"Redo2",tooltip:o("editor.redo.tooltip")}}})}}});export{M as a,v as i,q as n,R as o,_ as r,W as s,Z as t};
1
+ import{n as t}from"./dist-CsCFCV4K.js";import{n as o}from"./toggle-BXl_NYYh.js";import{s as e,t as n}from"./useButtonProps-DSIajp_B.js";import r from"react";import{Fragment as s,jsx as i}from"react/jsx-runtime";import{Extension as a,callOrReturn as d,getChangedRanges as c,getExtensionField as p,isNodeEmpty as l,isNodeSelection as u}from"@tiptap/core";import{Plugin as h,PluginKey as m}from"@tiptap/pm/state";import{dropCursor as f}from"@tiptap/pm/dropcursor";import{Decoration as y,DecorationSet as g}from"@tiptap/pm/view";import{gapCursor as w}from"@tiptap/pm/gapcursor";import{history as A,redo as b,undo as C}from"@tiptap/pm/history";a.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(t=>""!==t).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=t=>{const o=(null==t?void 0:t.node)||this.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||this.options.mode)){const t=o.textBetween(0,o.content.size,void 0," ");return this.options.textCounter(t)}return o.nodeSize},this.storage.words=t=>{const o=(null==t?void 0:t.node)||this.editor.state.doc,e=o.textBetween(0,o.content.size," "," ");return this.options.wordCounter(e)}},addProseMirrorPlugins(){let t=!1;return[new h({key:new m("characterCount"),appendTransaction:(o,e,n)=>{if(t)return;const r=this.options.limit,s=this.options.autoTrim;if(null==r||0===r||!1===s)return void(t=!0);const i=this.storage.characters({node:n.doc});if(i>r){const o=0,e=i-r,s=n.tr.deleteRange(o,e);return t=!0,s}t=!0},filterTransaction:(t,o)=>{const e=this.options.limit;if(!t.docChanged||0===e||null==e)return!0;const n=this.storage.characters({node:o.doc}),r=this.storage.characters({node:t.doc});if(r<=e)return!0;if(n>e&&r>e&&r<=n)return!0;if(n>e&&r>e&&r>n)return!1;if(!t.getMeta("paste"))return!1;const s=t.selection.$head.pos,i=s-(r-e),a=s;return t.deleteRange(i,a),!(this.storage.characters({node:t.doc})>e)}})]}});var v=a.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[f(this.options)]}}),M=(a.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new h({key:new m("focus"),props:{decorations:({doc:t,selection:o})=>{const{isEditable:e,isFocused:n}=this.editor,{anchor:r}=o,s=[];if(!e||!n)return g.create(t,[]);let i=0;"deepest"===this.options.mode&&t.descendants((t,o)=>{if(!t.isText)return r>=o&&r<=o+t.nodeSize-1&&void(i+=1)});let a=0;return t.descendants((t,o)=>!t.isText&&(r>=o&&r<=o+t.nodeSize-1&&(a+=1,"deepest"===this.options.mode&&i-a>0||"shallowest"===this.options.mode&&a>1?"deepest"===this.options.mode:void s.push(y.node(o,o+t.nodeSize,{class:this.options.className}))))),g.create(t,s)}}})]}}),a.create({name:"gapCursor",addProseMirrorPlugins:()=>[w()],extendNodeSchema(t){var o;const e={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:null!=(o=d(p(t,"allowGapCursor",e)))?o:null}}})),z="placeholder",S=new m("tiptap__placeholder");function O(t){const{editor:o,placeholder:e,dataAttribute:n,pos:r,node:s,isEmptyDoc:i,hasAnchor:a,classes:{emptyNode:d,emptyEditor:c}}=t,p=[d];return i&&p.push(c),y.node(r,r+s.nodeSize,{class:p.join(" "),[n]:"function"==typeof e?e({editor:o,node:s,pos:r,hasAnchor:a}):e})}function E(t,o){return"function"==typeof t?t(o):t}function P({editor:t,options:o,dataAttribute:e,doc:n,selection:r,from:s,to:i}){const{anchor:a}=r,d=[],c=t.isEmpty;return n.nodesBetween(s,i,(n,r)=>{const s=a>=r&&a<=r+n.nodeSize,i=!n.isLeaf&&l(n);return n.type.isTextblock?(!s&&o.showOnlyCurrent||!i||d.push(O({editor:t,isEmptyDoc:c,dataAttribute:e,hasAnchor:s,placeholder:o.placeholder,classes:{emptyEditor:o.emptyEditorClass,emptyNode:E(o.emptyNodeClass,{editor:t,node:n,pos:r,hasAnchor:s})},node:n,pos:r})),o.includeChildren):o.includeChildren}),d}function x({editor:t,options:o,dataAttribute:e,doc:n,selection:r}){if(!t.isEditable&&o.showOnlyWhenEditable)return null;const{anchor:s}=r,i=[],a=t.isEmpty;if(o.showOnlyCurrent&&!o.includeChildren){const r=n.resolve(s),d=r.depth>0?r.node(1):r.nodeAfter,c=r.depth>0?r.before(1):s;if(d&&d.type.isTextblock&&l(d)){const n=s>=c&&s<=c+d.nodeSize;i.push(O({editor:t,isEmptyDoc:a,dataAttribute:e,hasAnchor:n,placeholder:o.placeholder,classes:{emptyEditor:o.emptyEditorClass,emptyNode:E(o.emptyNodeClass,{editor:t,node:d,pos:c,hasAnchor:n})},node:d,pos:c}))}}else i.push(...P({editor:t,options:o,dataAttribute:e,doc:n,selection:r,from:0,to:n.content.size}));return g.create(n,i)}function N(t,o){var e;const n=t.resolve(o);if(0===n.depth){const t=null!=(e=n.nodeAfter)?e:n.nodeBefore;if(!t)return{from:o,to:o};const r=n.nodeAfter?o:o-t.nodeSize;return{from:r,to:r+t.nodeSize}}const r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function T(t,o){return{from:Math.max(0,o.from-1),to:Math.min(t.content.size,o.to-1)}}function K(t,o){const e=function(t,o,e){const n=[];return t.forEach((t,r)=>{const s=r,i=s+t.nodeSize;s+1<e&&i+1>o&&n.push({from:s,to:i})}),n}(t,o.from,o.to);return e.push(T(t,N(t,o.from))),o.to>o.from?e.push(T(t,N(t,Math.min(o.to,t.content.size+1)-1))):o.from<t.content.size+1&&e.push(T(t,N(t,Math.min(o.from+1,t.content.size)))),e}function k(t,o,e){const n=[];if(t.docChanged){const o=c(t);for(const t of o)n.push(...K(e.doc,t.newRange))}return t.selectionSet&&(n.push(T(e.doc,N(e.doc,t.mapping.map(o.selection.anchor)))),n.push(T(e.doc,N(e.doc,e.selection.anchor)))),function(t){if(0===t.length)return[];const o=[...t].sort((t,o)=>t.from-o.from),e=[{...o[0]}];for(let n=1;n<o.length;n+=1){const t=e[e.length-1],r=o[n];r.from<=t.to?t.to=Math.max(t.to,r.to):e.push({...r})}return e}(n)}function D(t,o,e){const n=Math.max(0,Math.min(t,e.content.size));return{from:n,to:Math.max(n,Math.min(o,e.content.size))}}function j({editor:t,options:o,dataAttribute:e}){return{init(n,r){const s=x({editor:t,options:o,dataAttribute:e,doc:r.doc,selection:r.selection});return null!=s?s:g.empty},apply:(n,r,s,i)=>n.docChanged||n.selectionSet?function({decorations:t,ranges:o,editor:e,options:n,dataAttribute:r,doc:s,selection:i}){let a=t;for(const d of o){const{from:t,to:o}=D(d.from,d.to,s),c=a.find(t,o).filter(e=>e.from>=t&&e.to<=o);c.length&&(a=a.remove(c));const p=P({editor:e,options:n,dataAttribute:r,doc:s,selection:i,from:t,to:o});p.length&&(a=a.add(s,p))}return a}({decorations:r.map(n.mapping,n.doc),ranges:k(n,s,i),editor:t,options:o,dataAttribute:e,doc:i.doc,selection:i.selection}):r}}function B({editor:t,options:o}){const e=o.dataAttribute?`data-${n=o.dataAttribute,n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${z}`;var n;const r=o.showOnlyCurrent&&!o.includeChildren;return new h({key:S,...r?{}:{state:j({editor:t,options:o,dataAttribute:e})},props:{decorations:r?({doc:n,selection:r})=>x({editor:t,options:o,dataAttribute:e,doc:n,selection:r}):e=>{var n;return o.showOnlyWhenEditable&&!t.isEditable?g.empty:null!=(n=S.getState(e))?n:g.empty}}})}var R=a.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:z,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[B({editor:this.editor,options:this.options})]}});function F(t,o){return!t.selection.empty&&!u(t.selection)&&o.isEditable}a.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:o}=this;return[new h({key:new m("selection"),props:{decorations:e=>function(t,o){return F(t,o)&&!o.isFocused&&!o.view.dragging}(e,t)?g.create(e.doc,[y.inline(e.selection.from,e.selection.to,{class:o.className})]):null,handleDOMEvents:{blur(o){return!!F(o.state,t)&&(null==(e=window.getSelection())||e.removeAllRanges(),!1);var e},focus:o=>!!F(o.state,t)&&(requestAnimationFrame(()=>{!t.isDestroyed&&o.hasFocus()&&function(t){t.focus()}(o)}),!1)}}})]}});function G({types:t,node:o}){return o&&Array.isArray(t)&&t.includes(o.type)||(null==o?void 0:o.type)===t}var W=a.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t;const o=new m(this.name),e=this.options.node||(null==(t=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:t.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(e).includes(t.name));return[new h({key:o,appendTransaction:(t,n,r)=>{const{doc:s,tr:i,schema:a}=r,d=o.getState(r),c=s.content.size,p=a.nodes[e];if(!t.some(t=>t.getMeta("skipTrailingNode"))&&d)return i.insert(c,p.create())},state:{init:(t,o)=>!G({node:o.tr.doc.lastChild,types:n}),apply:(t,o)=>{if(!t.docChanged)return o;if(t.getMeta("__uniqueIDTransaction"))return o;return!G({node:t.doc.lastChild,types:n})}}})]}});function _(){const r=n($.name),{icon:a,tooltip:d,shortcutKeys:c,tooltipOptions:p={},action:l,isActive:u}=r?.componentProps?.undo??{},{disabled:h}=e(u),m=t[a];return r&&m?/* @__PURE__ */i(o,{action:()=>{h||l&&l()},disabled:h,icon:a,shortcutKeys:c,tooltip:d,tooltipOptions:p}):/* @__PURE__ */i(s,{})}function Z(){const t=n($.name),{icon:r,tooltip:a,shortcutKeys:d,tooltipOptions:c={},action:p,isActive:l}=t?.componentProps?.redo??{},{disabled:u}=e(l);return t?/* @__PURE__ */i(o,{action:()=>{u||p&&p()},disabled:u,icon:r,shortcutKeys:d,tooltip:a,tooltipOptions:c}):/* @__PURE__ */i(s,{})}var $=a.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:o})=>C(t,o),redo:()=>({state:t,dispatch:o})=>b(t,o)}),addProseMirrorPlugins(){return[A(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}).extend({addOptions(){return{...this.parent?.(),depth:100,newGroupDelay:500,button:({editor:t,t:o,extension:e})=>({componentProps:{undo:{action:()=>{t.chain().focus().undo().run()},shortcutKeys:e.options.shortcutKeys?.[0]??["mod","Z"],isActive:()=>t.can().undo(),icon:"Undo2",tooltip:o("editor.undo.tooltip")},redo:{action:()=>{t.chain().focus().redo().run()},shortcutKeys:e.options.shortcutKeys?.[1]??["shift","mod","Z"],isActive:()=>t.can().redo(),icon:"Redo2",tooltip:o("editor.redo.tooltip")}}})}}});export{M as a,v as i,Z as n,R as o,_ as r,W as s,$ as t};
package/dist/History.js CHANGED
@@ -1 +1 @@
1
- import{n as r,r as s,t}from"./History-C6yBYB2w.js";export{t as History,r as RichTextRedo,s as RichTextUndo};
1
+ import{n as r,r as s,t as o}from"./History-PbMa-usl.js";export{o as History,r as RichTextRedo,s as RichTextUndo};
package/dist/Image.js CHANGED
@@ -1 +1 @@
1
- import{i as r,n as a,r as m}from"./ImageCropper-Dlz4nJQu.js";export{a as DEFAULT_OPTIONS,m as Image,r as RichTextImage};
1
+ import{i as r,n as a,r as o}from"./ImageCropper-CN_GzBBG.js";export{a as DEFAULT_OPTIONS,o as Image,r as RichTextImage};
@@ -1,11 +1,11 @@
1
- import{n as e}from"./toggle-BXl_NYYh.js";import{g as t,n as i}from"./locales-DfkG6-1b.js";import{t as a}from"./Icon-CJJ9AQtR.js";import{t as r}from"./button-CXcuJkiM.js";import{t as n}from"./checkbox-zfuPZBhD.js";import{a as o,n as l,o as s,r as d,t as c}from"./dialog-DgdVbRUv.js";import{t as m}from"./input-CMD6LZFr.js";import{t as u}from"./label-Dx1mMx8l.js";import{i as p,n as g,r as h,t as f}from"./tabs-BovAV0Y3.js";import{o as b,t as v}from"./throttle-BpbN7uB1.js";import{n as x,t as y}from"./isNumber-7Fi2iQVS.js";import{c as w,d as A,o as I,t as T}from"./useButtonProps-DSIajp_B.js";import{o as S,t as N}from"./file-aBzFF1LO.js";import{NodeViewWrapper as M,ReactNodeViewRenderer as E}from"@tiptap/react";import*as C from"react";import L,{useCallback as j,useEffect as _,useMemo as O,useRef as D,useState as k}from"react";import{Fragment as z,jsx as U,jsxs as H}from"react/jsx-runtime";import $ from"react-image-crop";import{mergeAttributes as P}from"@tiptap/core";var R=0;var X=/* @__PURE__ */new Map;function Y(e){if(X.has(e))return;const t=setTimeout(()=>{X.delete(e),q({type:"REMOVE_TOAST",toastId:e})},1e6);X.set(e,t)}var F=[],W={toasts:[]};function q(e){W=function(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:i}=t;return i?Y(i):e.toasts.forEach(e=>{Y(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===i||void 0===i?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}}(W,e),F.forEach(e=>{e(W)})}function B({...e}){const t=(R=(R+1)%Number.MAX_SAFE_INTEGER).toString(),i=()=>q({type:"DISMISS_TOAST",toastId:t});return q({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||i()}}}),{id:t,dismiss:i,update:e=>q({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function V(){const[e,t]=C.useState(W);return C.useEffect(()=>(F.push(t),()=>{const e=F.indexOf(t);e>-1&&F.splice(e,1)}),[e]),{...e,toast:B,dismiss:e=>q({type:"DISMISS_TOAST",toastId:e})}}var G="tl",J="tr",K="bl",Q="br";function Z(e){const[i,a]=k({width:t,height:t}),[r,n]=k({width:0,height:0}),[o]=k([G,J,K,Q]),[l,s]=k(!1),[d,c]=k({x:0,y:0,w:0,h:0,dir:""}),{align:m,inline:u}=e.node.attrs,p=u&&("left"===m||"right"===m),g=O(()=>{const{src:t,alt:i,width:a,height:r,flipX:n,flipY:o}=e.node.attrs,l=y(a)?`${a}px`:a,s=y(r)?`${r}px`:r,d=[];n&&d.push("rotateX(180deg)"),o&&d.push("rotateY(180deg)");return{src:t||void 0,alt:i||void 0,style:{width:l||void 0,height:s||void 0,transform:d.join(" ")||"none",...p?{float:m}:{}}}},[e?.node?.attrs]),h=O(()=>{const{style:{width:e}}=g;return{width:"100%"===e?e:void 0}},[g]);function f(){const{editor:t,getPos:i}=e;t.commands.setNodeSelection(i())}const b=j(v(()=>{const{editor:t}=e,{width:i}=getComputedStyle(t.view.dom);a(e=>({...e,width:Number.parseInt(i,10)}))},16),[e?.editor]);const w=j(v(t=>{if(t.preventDefault(),t.stopPropagation(),!l)return;const{x:a,w:r,dir:n}=d,o=(t.clientX-a)*(/l/.test(n)?-1:1),s=x(r+o,20,i.width);e.updateAttributes({width:s,height:null})},16),[l,d,i,e.updateAttributes]),A=j(e=>{e.preventDefault(),e.stopPropagation(),l&&(c({x:0,y:0,w:0,h:0,dir:""}),s(!1),f())},[l,f]),I=j(()=>{document?.addEventListener("mousemove",w,!0),document?.addEventListener("mouseup",A,!0)},[w,A]),T=j(()=>{document?.removeEventListener("mousemove",w,!0),document?.removeEventListener("mouseup",A,!0)},[w,A]);_(()=>(l?I():T(),()=>{T()}),[l,I,T]);const S=O(()=>new ResizeObserver(()=>b()),[b]);return _(()=>(S.observe(e.editor.view.dom),()=>{S.disconnect()}),[e.editor.view.dom,S]),/* @__PURE__ */U(M,{as:u?"span":"div",className:"image-view",style:{float:p?m:void 0,margin:p?"left"===m?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:u?"inline":"block",textAlign:p?void 0:m,width:g.style?.width??"auto",...p?{}:h},children:/* @__PURE__ */H("div",{"data-drag-handle":!0,draggable:"true",style:h,className:`image-view__body ${e?.selected?"image-view__body--focused":""} ${l?"image-view__body--resizing":""}`,children:[/* @__PURE__ */U("img",{alt:g.alt,className:"image-view__body__image block",height:"auto",onClick:f,onLoad:function(e){n({width:e.target.width,height:e.target.height})},src:g.src,style:g.style}),e?.editor.view.editable&&(e?.selected||l)&&/* @__PURE__ */U("div",{className:"image-resizer",children:o?.map(t=>/* @__PURE__ */U("span",{className:`image-resizer__handler image-resizer__handler--${t}`,onMouseDown:a=>function(t,a){t.preventDefault(),t.stopPropagation();const n=r.width,o=n/r.height;let l=Number(e.node.attrs.width),d=Number(e.node.attrs.height);const m=i.width;l&&!d?(l=l>m?m:l,d=Math.round(l/o)):d&&!l?(l=Math.round(d*o),l=l>m?m:l):l||d?l=l>m?m:l:(l=n>m?m:n,d=Math.round(l/o)),s(!0),c({x:t.clientX,y:t.clientY,w:l,h:d,dir:a})}(a,t)},`image-dir-${t}`))})]})})}function ee(e,t){const{acceptMimes:i,maxSize:a,t:r,toast:n}=t,o=[];return(Array.isArray(e)?e:Object.values(e)).forEach(e=>{if(function(e,t){if(!t||0===t.length)return!0;const i=e.type,a=e.name.toLowerCase(),r=a.split(".").pop();if(!r)return!1;const n=i||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[r];return t.some(e=>{if(e.startsWith("."))return a.endsWith(e);if(e.endsWith("/*")){const t=e.split("/")[0];return n?.startsWith(t+"/")}return n===e})}(e,i)){if(e.size>a){const i=(a/1024/1024).toFixed(2);return void(t.onError?t.onError({type:"size",message:r("editor.upload.fileSizeTooBig",{fileName:e.name,size:i}),file:e}):n({variant:"default",title:r("editor.upload.fileSizeTooBig",{fileName:e.name,size:i})}))}o.push(e)}else t.onError?t.onError({type:"type",message:r("editor.upload.fileTypeNotSupported",{fileName:e.name}),file:e}):n({variant:"default",title:r("editor.upload.fileTypeNotSupported",{fileName:e.name})})}),o}function te(){const{t:t}=i(),{toast:d}=V(),b=A(),v=T(ae.name),{icon:x,tooltip:y}=v?.componentProps??{},{editorDisabled:S}=w(),[N,M]=k(!1),[E,C]=k(!1),L=I(ae.name),[j,_]=k(""),[$,P]=k(""),R=D(null),X=L?.options.defaultInline||!1,[Y,F]=k(X),W=O(()=>L?.options||ie,[L]);return v?/* @__PURE__ */H(c,{onOpenChange:M,open:N,children:[/* @__PURE__ */U(s,{asChild:!0,children:/* @__PURE__ */U(e,{disabled:S,icon:x,tooltip:y,action:()=>{S||M(!0)}})}),/* @__PURE__ */H(l,{children:[/* @__PURE__ */U(o,{children:t("editor.image.dialog.title")}),/* @__PURE__ */H(f,{activationMode:"manual",defaultValue:"both"===W.resourceImage||"upload"===W.resourceImage?"upload":"link",children:["both"===W.resourceImage&&/* @__PURE__ */H(h,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[/* @__PURE__ */U(p,{value:"upload",children:t("editor.image.dialog.tab.upload")}),/* @__PURE__ */U(p,{value:"link",children:t("editor.image.dialog.tab.url")})]}),
1
+ import{n as e}from"./toggle-BXl_NYYh.js";import{g as t,n as i}from"./locales-DfkG6-1b.js";import{t as a}from"./Icon-CJJ9AQtR.js";import{t as r}from"./button-CXcuJkiM.js";import{t as n}from"./checkbox-zfuPZBhD.js";import{a as o,n as l,o as s,r as d,t as c}from"./dialog-DgdVbRUv.js";import{t as m}from"./input-CMD6LZFr.js";import{t as u}from"./label-Dx1mMx8l.js";import{i as p,n as g,r as h,t as f}from"./tabs-BovAV0Y3.js";import{o as b,t as v}from"./throttle-BpbN7uB1.js";import{n as x,t as y}from"./isNumber-7Fi2iQVS.js";import{c as w,d as A,o as I,t as T}from"./useButtonProps-DSIajp_B.js";import{o as S,t as N}from"./file-aBzFF1LO.js";import{NodeViewWrapper as M,ReactNodeViewRenderer as E}from"@tiptap/react";import*as C from"react";import L,{useCallback as j,useEffect as _,useMemo as O,useRef as D,useState as z}from"react";import{Fragment as k,jsx as U,jsxs as H}from"react/jsx-runtime";import $ from"react-image-crop";import{mergeAttributes as P}from"@tiptap/core";var R=0;var X=/* @__PURE__ */new Map;function Y(e){if(X.has(e))return;const t=setTimeout(()=>{X.delete(e),q({type:"REMOVE_TOAST",toastId:e})},1e6);X.set(e,t)}var F=[],W={toasts:[]};function q(e){W=function(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:i}=t;return i?Y(i):e.toasts.forEach(e=>{Y(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===i||void 0===i?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}}(W,e),F.forEach(e=>{e(W)})}function B({...e}){const t=(R=(R+1)%Number.MAX_SAFE_INTEGER).toString(),i=()=>q({type:"DISMISS_TOAST",toastId:t});return q({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||i()}}}),{id:t,dismiss:i,update:e=>q({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function V(){const[e,t]=C.useState(W);return C.useEffect(()=>(F.push(t),()=>{const e=F.indexOf(t);e>-1&&F.splice(e,1)}),[e]),{...e,toast:B,dismiss:e=>q({type:"DISMISS_TOAST",toastId:e})}}var G="tl",J="tr",K="bl",Q="br";function Z(e){const[i,a]=z({width:t,height:t}),[r,n]=z({width:0,height:0}),[o]=z([G,J,K,Q]),[l,s]=z(!1),[d,c]=z({x:0,y:0,w:0,h:0,dir:""}),{align:m,inline:u}=e.node.attrs,p=u&&("left"===m||"right"===m),g=O(()=>{const{src:t,alt:i,width:a,height:r,flipX:n,flipY:o}=e.node.attrs,l=y(a)?`${a}px`:a,s=y(r)?`${r}px`:r,d=[];n&&d.push("rotateX(180deg)"),o&&d.push("rotateY(180deg)");return{src:t||void 0,alt:i||void 0,style:{width:l||void 0,height:s||void 0,transform:d.join(" ")||"none",...p?{float:m}:{}}}},[e?.node?.attrs]),h=O(()=>{const{style:{width:e}}=g;return{width:"100%"===e?e:void 0}},[g]);function f(){const{editor:t,getPos:i}=e;t.commands.setNodeSelection(i())}const b=j(v(()=>{const{editor:t}=e,{width:i}=getComputedStyle(t.view.dom);a(e=>({...e,width:Number.parseInt(i,10)}))},16),[e?.editor]);const w=j(v(t=>{if(t.preventDefault(),t.stopPropagation(),!l)return;const{x:a,w:r,dir:n}=d,o=(t.clientX-a)*(/l/.test(n)?-1:1),s=x(r+o,20,i.width);e.updateAttributes({width:s,height:null})},16),[l,d,i,e.updateAttributes]),A=j(e=>{e.preventDefault(),e.stopPropagation(),l&&(c({x:0,y:0,w:0,h:0,dir:""}),s(!1),f())},[l,f]),I=j(()=>{document?.addEventListener("mousemove",w,!0),document?.addEventListener("mouseup",A,!0)},[w,A]),T=j(()=>{document?.removeEventListener("mousemove",w,!0),document?.removeEventListener("mouseup",A,!0)},[w,A]);_(()=>(l?I():T(),()=>{T()}),[l,I,T]);const S=O(()=>new ResizeObserver(()=>b()),[b]);return _(()=>(S.observe(e.editor.view.dom),()=>{S.disconnect()}),[e.editor.view.dom,S]),/* @__PURE__ */U(M,{as:u?"span":"div",className:"image-view",style:{float:p?m:void 0,margin:p?"left"===m?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:u?"inline":"block",textAlign:p?void 0:m,width:g.style?.width??"auto",...p?{}:h},children:/* @__PURE__ */H("div",{"data-drag-handle":!0,draggable:"true",style:h,className:`image-view__body ${e?.selected?"image-view__body--focused":""} ${l?"image-view__body--resizing":""}`,children:[/* @__PURE__ */U("img",{alt:g.alt,className:"image-view__body__image block",height:"auto",onClick:f,onLoad:function(e){n({width:e.target.width,height:e.target.height})},src:g.src,style:g.style}),e?.editor.view.editable&&(e?.selected||l)&&/* @__PURE__ */U("div",{className:"image-resizer",children:o?.map(t=>/* @__PURE__ */U("span",{className:`image-resizer__handler image-resizer__handler--${t}`,onMouseDown:a=>function(t,a){t.preventDefault(),t.stopPropagation();const n=r.width,o=n/r.height;let l=Number(e.node.attrs.width),d=Number(e.node.attrs.height);const m=i.width;l&&!d?(l=l>m?m:l,d=Math.round(l/o)):d&&!l?(l=Math.round(d*o),l=l>m?m:l):l||d?l=l>m?m:l:(l=n>m?m:n,d=Math.round(l/o)),s(!0),c({x:t.clientX,y:t.clientY,w:l,h:d,dir:a})}(a,t)},`image-dir-${t}`))})]})})}function ee(e,t){const{acceptMimes:i,maxSize:a,t:r,toast:n}=t,o=[];return(Array.isArray(e)?e:Object.values(e)).forEach(e=>{if(function(e,t){if(!t||0===t.length)return!0;const i=e.type,a=e.name.toLowerCase(),r=a.split(".").pop();if(!r)return!1;const n=i||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[r];return t.some(e=>{if(e.startsWith("."))return a.endsWith(e);if(e.endsWith("/*")){const t=e.split("/")[0];return n?.startsWith(t+"/")}return n===e})}(e,i)){if(e.size>a){const i=(a/1024/1024).toFixed(2);return void(t.onError?t.onError({type:"size",message:r("editor.upload.fileSizeTooBig",{fileName:e.name,size:i}),file:e}):n({variant:"default",title:r("editor.upload.fileSizeTooBig",{fileName:e.name,size:i})}))}o.push(e)}else t.onError?t.onError({type:"type",message:r("editor.upload.fileTypeNotSupported",{fileName:e.name}),file:e}):n({variant:"default",title:r("editor.upload.fileTypeNotSupported",{fileName:e.name})})}),o}function te(){const{t:t}=i(),{toast:d}=V(),b=A(),v=T(ae.name),{icon:x,tooltip:y}=v?.componentProps??{},{editorDisabled:S}=w(),[N,M]=z(!1),[E,C]=z(!1),L=I(ae.name),[j,_]=z(""),[$,P]=z(""),R=D(null),X=L?.options.defaultInline||!1,[Y,F]=z(X),W=O(()=>L?.options||ie,[L]);return v?/* @__PURE__ */H(c,{onOpenChange:M,open:N,children:[/* @__PURE__ */U(s,{asChild:!0,children:/* @__PURE__ */U(e,{disabled:S,icon:x,tooltip:y,action:()=>{S||M(!0)}})}),/* @__PURE__ */H(l,{children:[/* @__PURE__ */U(o,{children:t("editor.image.dialog.title")}),/* @__PURE__ */H(f,{activationMode:"manual",defaultValue:"both"===W.resourceImage||"upload"===W.resourceImage?"upload":"link",children:["both"===W.resourceImage&&/* @__PURE__ */H(h,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[/* @__PURE__ */U(p,{value:"upload",children:t("editor.image.dialog.tab.upload")}),/* @__PURE__ */U(p,{value:"link",children:t("editor.image.dialog.tab.url")})]}),
2
2
  /* @__PURE__ */H("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[/* @__PURE__ */U(n,{checked:Y,onCheckedChange:e=>{F(e)}}),/* @__PURE__ */U(u,{children:t("editor.link.dialog.inline")})]}),W.enableAlt&&/* @__PURE__ */H("div",{className:"richtext-my-[10px]",children:[/* @__PURE__ */U(u,{className:"mb-[6px]",children:t("editor.imageUpload.alt")}),/* @__PURE__ */U(m,{onChange:e=>P(e.target.value),required:!0,type:"text",value:$})]}),
3
- /* @__PURE__ */H(g,{value:"upload",children:[/* @__PURE__ */H("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[/* @__PURE__ */U(r,{className:"richtext-mt-1 richtext-w-full",disabled:E,onClick:function(e){e.preventDefault(),R.current?.click()},size:"sm",children:E?/* @__PURE__ */H(z,{children:[t("editor.imageUpload.uploading"),/* @__PURE__ */U(a,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):t("editor.image.dialog.tab.upload")}),/* @__PURE__ */U(re,{alt:$,disabled:E,editor:b,imageInline:Y,onClose:()=>{P("")}})]}),/* @__PURE__ */U("input",{accept:W?.acceptMimes?.join(",")||"image/*",multiple:W.multiple,onChange:async function(e){const i=e?.target?.files;if(!b||b.isDestroyed||0===i.length||E)return void(e.target.value="");const a=ee(i,{acceptMimes:W?.acceptMimes,maxSize:W?.maxSize,t:t,toast:d,onError:W.onError});if(a.length<=0)e.target.value="";else{C(!0);try{if(W?.multiple){const e=a.map(async e=>{let t="";return t=W.upload?await W.upload(e):URL.createObjectURL(e),t});(await Promise.all(e)).forEach(e=>{b.chain().focus().setImageInline({src:e,inline:Y,alt:$}).run()})}else{const e=a[0];let t="";t=W.upload?await W.upload(e):URL.createObjectURL(e),b.chain().focus().setImageInline({src:t,inline:Y,alt:$}).run()}M(!1),P(""),F(X)}catch(r){W.onError?W.onError({type:"upload",message:t("editor.upload.error")}):d({variant:"destructive",title:t("editor.upload.error")})}finally{C(!1),e.target.value=""}}},ref:R,style:{display:"none"},type:"file"})]}),
4
- /* @__PURE__ */U(g,{value:"link",children:/* @__PURE__ */U("form",{onSubmit:function(e){e.preventDefault(),e.stopPropagation(),b.chain().focus().setImageInline({src:j,inline:Y,alt:$}).run(),M(!1),F(X),_(""),P("")},children:/* @__PURE__ */H("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[/* @__PURE__ */U(m,{autoFocus:!0,onChange:e=>_(e.target.value),placeholder:t("editor.image.dialog.placeholder"),required:!0,type:"url",value:j}),/* @__PURE__ */U(r,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})]})]}):/* @__PURE__ */U(z,{})}var ie={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:5242880,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},ae=b.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{...ie,...this.parent?.(),upload:()=>Promise.reject("Image Upload Function"),button:({editor:e,extension:t,t:i})=>({componentProps:{action:()=>!0,upload:t.options.upload,disabled:!e.can().setImage?.({}),icon:"ImageUp",tooltip:i("editor.image.tooltip")}})}},addAttributes(){return{...this.parent?.(),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||null;return t?Number.parseInt(t,10):null},renderHTML:e=>({width:e.width})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})},inline:{default:!1,parseHTML:e=>Boolean(e.getAttribute("inline")),renderHTML:e=>({inline:e.inline})},alt:{default:"",parseHTML:e=>e.getAttribute("alt"),renderHTML:e=>({alt:e.alt})}}},addNodeView:()=>E(Z),addCommands(){return{...this.parent?.(),setImageInline:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{...e,inline:e.inline??this.options.defaultInline}}),updateImage:e=>({commands:t})=>t.updateAttributes(this.name,e),setAlignImage:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:i,align:a,inline:r}=e,n=r&&("left"===a||"right"===a);return[r?"span":"div",{style:n?"":`text-align: ${a};`,class:"image"},["img",P({height:"auto",style:`${n?`float: ${a};`:""}${n?"left"===a?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${t||i?`transform: rotateX(${t?"180":"0"}deg) rotateY(${i?"180":"0"}deg);`:""}`},this.options.HTMLAttributes,e)]]},parseHTML:()=>[{tag:"span.image img",getAttrs:e=>{const t=e?.parentElement,i=e?.getAttribute("width"),a=e?.getAttribute("flipx")||!1,r=e?.getAttribute("flipy")||!1;return{src:e?.getAttribute("src"),alt:e?.getAttribute("alt"),caption:e?.getAttribute("caption"),width:i?Number.parseInt(i,10):null,align:e?.getAttribute("align")||t?.style?.textAlign||null,inline:e?.getAttribute("inline")||!1,flipX:"true"===a,flipY:"true"===r}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),i=t?.getAttribute("width"),a=t?.getAttribute("flipx")||!1,r=t?.getAttribute("flipy")||!1;return{src:t?.getAttribute("src"),alt:t?.getAttribute("alt"),caption:t?.getAttribute("caption"),width:i?Number.parseInt(i,10):null,align:t?.getAttribute("align")||e.style.textAlign||null,inline:t?.getAttribute("inline")||!1,flipX:"true"===a,flipY:"true"===r}}},{tag:'img[src]:not([src^="data:"])'}]});function re({editor:e,imageInline:t,onClose:n,disabled:m,alt:u}){const{t:p}=i(),{toast:g}=V(),[h,f]=k(!1),[b,v]=k(!1),x=L.useRef(null),[y,w]=L.useState(),[A,T]=L.useState(""),M=D(null),[E,C]=k({src:"",file:null}),j=I(ae.name),_=O(()=>j?.options??{},[j]);function P(e){if(x.current&&e.width&&e.height){const t=function(e,t){const i=document.createElement("canvas"),a=e.naturalWidth/e.width,r=e.naturalHeight/e.height;i.width=t.width*a,i.height=t.height*r;const n=i.getContext("2d");n&&(n.imageSmoothingEnabled=!1,n.drawImage(e,t.x*a,t.y*r,t.width*a,t.height*r,0,0,t.width*a,t.height*r));return i.toDataURL("image/png",1)}(x.current,e);T(t)}}const R=L.useCallback(async()=>{if(!b){v(!0);try{const i=N(A,E?.file?.name||"image.png");let a="";a=_.upload?await _.upload(i):URL.createObjectURL(i),e.chain().focus().setImageInline({src:a,inline:t,alt:u}).run(),f(!1),C({src:"",file:null}),X(),n()}catch(i){}finally{v(!1)}}},[A,e,t,b,n,E?.file?.name,_]);const X=()=>{M.current&&(M.current.value="")};/* @__PURE__ */
5
- return H(z,{children:[
3
+ /* @__PURE__ */H(g,{value:"upload",children:[/* @__PURE__ */H("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[/* @__PURE__ */U(r,{className:"richtext-mt-1 richtext-w-full",disabled:E,onClick:function(e){e.preventDefault(),R.current?.click()},size:"sm",children:E?/* @__PURE__ */H(k,{children:[t("editor.imageUpload.uploading"),/* @__PURE__ */U(a,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):t("editor.image.dialog.tab.upload")}),/* @__PURE__ */U(re,{alt:$,disabled:E,editor:b,imageInline:Y,onClose:()=>{P("")}})]}),/* @__PURE__ */U("input",{accept:W?.acceptMimes?.join(",")||"image/*",multiple:W.multiple,onChange:async function(e){const i=e?.target?.files;if(!b||b.isDestroyed||0===i.length||E)return void(e.target.value="");const a=ee(i,{acceptMimes:W?.acceptMimes,maxSize:W?.maxSize,t:t,toast:d,onError:W.onError});if(a.length<=0)e.target.value="";else{C(!0);try{if(W?.multiple){const e=a.map(async e=>{let t="";return t=W.upload?await W.upload(e):URL.createObjectURL(e),t});(await Promise.all(e)).forEach(e=>{b.chain().focus().setImageInline({src:e,inline:Y,alt:$}).run()})}else{const e=a[0];let t="";t=W.upload?await W.upload(e):URL.createObjectURL(e),b.chain().focus().setImageInline({src:t,inline:Y,alt:$}).run()}M(!1),P(""),F(X)}catch(r){W.onError?W.onError({type:"upload",message:t("editor.upload.error")}):d({variant:"destructive",title:t("editor.upload.error")})}finally{C(!1),e.target.value=""}}},ref:R,style:{display:"none"},type:"file"})]}),
4
+ /* @__PURE__ */U(g,{value:"link",children:/* @__PURE__ */U("form",{onSubmit:function(e){e.preventDefault(),e.stopPropagation(),b.chain().focus().setImageInline({src:j,inline:Y,alt:$}).run(),M(!1),F(X),_(""),P("")},children:/* @__PURE__ */H("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[/* @__PURE__ */U(m,{autoFocus:!0,onChange:e=>_(e.target.value),placeholder:t("editor.image.dialog.placeholder"),required:!0,type:"url",value:j}),/* @__PURE__ */U(r,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})]})]}):/* @__PURE__ */U(k,{})}var ie={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:5242880,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},ae=b.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{...ie,...this.parent?.(),upload:()=>Promise.reject("Image Upload Function"),button:({editor:e,extension:t,t:i})=>({componentProps:{action:()=>!0,upload:t.options.upload,disabled:!e.can().setImage?.({}),icon:"ImageUp",tooltip:i("editor.image.tooltip")}})}},addAttributes(){return{...this.parent?.(),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||null;return t?Number.parseInt(t,10):null},renderHTML:e=>({width:e.width})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})},inline:{default:!1,parseHTML:e=>Boolean(e.getAttribute("inline")),renderHTML:e=>({inline:e.inline})},alt:{default:"",parseHTML:e=>e.getAttribute("alt"),renderHTML:e=>({alt:e.alt})}}},addNodeView:()=>E(Z),addCommands(){return{...this.parent?.(),setImageInline:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{...e,inline:e.inline??this.options.defaultInline}}),updateImage:e=>({commands:t})=>t.updateAttributes(this.name,e),setAlignImage:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:i,align:a,inline:r}=e,n=r&&("left"===a||"right"===a);return[r?"span":"div",{style:n?"":`text-align: ${a};`,class:"image"},["img",P({height:"auto",style:`${n?`float: ${a};`:""}${n?"left"===a?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${t||i?`transform: rotateX(${t?"180":"0"}deg) rotateY(${i?"180":"0"}deg);`:""}`},this.options.HTMLAttributes,e)]]},parseHTML:()=>[{tag:"span.image img",getAttrs:e=>{const t=e?.parentElement,i=e?.getAttribute("width"),a=e?.getAttribute("flipx")||!1,r=e?.getAttribute("flipy")||!1;return{src:e?.getAttribute("src"),alt:e?.getAttribute("alt"),caption:e?.getAttribute("caption"),width:i?Number.parseInt(i,10):null,align:e?.getAttribute("align")||t?.style?.textAlign||null,inline:e?.getAttribute("inline")||!1,flipX:"true"===a,flipY:"true"===r}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),i=t?.getAttribute("width"),a=t?.getAttribute("flipx")||!1,r=t?.getAttribute("flipy")||!1;return{src:t?.getAttribute("src"),alt:t?.getAttribute("alt"),caption:t?.getAttribute("caption"),width:i?Number.parseInt(i,10):null,align:t?.getAttribute("align")||e.style.textAlign||null,inline:t?.getAttribute("inline")||!1,flipX:"true"===a,flipY:"true"===r}}},{tag:'img[src]:not([src^="data:"])'}]});function re({editor:e,imageInline:t,onClose:n,disabled:m,alt:u}){const{t:p}=i(),{toast:g}=V(),[h,f]=z(!1),[b,v]=z(!1),x=L.useRef(null),[y,w]=L.useState(),[A,T]=L.useState(""),M=D(null),[E,C]=z({src:"",file:null}),j=I(ae.name),_=O(()=>j?.options??{},[j]);function P(e){if(x.current&&e.width&&e.height){const t=function(e,t){const i=document.createElement("canvas"),a=e.naturalWidth/e.width,r=e.naturalHeight/e.height;i.width=t.width*a,i.height=t.height*r;const n=i.getContext("2d");n&&(n.imageSmoothingEnabled=!1,n.drawImage(e,t.x*a,t.y*r,t.width*a,t.height*r,0,0,t.width*a,t.height*r));return i.toDataURL("image/png",1)}(x.current,e);T(t)}}const R=L.useCallback(async()=>{if(!b){v(!0);try{const i=N(A,E?.file?.name||"image.png");let a="";a=_.upload?await _.upload(i):URL.createObjectURL(i),e.chain().focus().setImageInline({src:a,inline:t,alt:u}).run(),f(!1),C({src:"",file:null}),X(),n()}catch(i){}finally{v(!1)}}},[A,e,t,b,n,E?.file?.name,_]);const X=()=>{M.current&&(M.current.value="")};/* @__PURE__ */
5
+ return H(k,{children:[
6
6
  /* @__PURE__ */U(r,{className:"richtext-mt-1 richtext-w-full",disabled:m,onClick:function(e){e.preventDefault(),M.current?.click()},size:"sm",children:p("editor.image.dialog.tab.uploadCrop")}),
7
7
  /* @__PURE__ */H(c,{open:h,onOpenChange:e=>{f(e),e||(C({src:"",file:null}),X())},children:[/* @__PURE__ */U(s,{}),/* @__PURE__ */H(l,{children:[
8
8
  /* @__PURE__ */U(o,{children:p("editor.image.dialog.tab.uploadCrop")}),
9
9
  /* @__PURE__ */U("div",{children:E.src&&/* @__PURE__ */U($,{className:"richtext-w-full",crop:y,onChange:e=>w(e),onComplete:e=>P(e),children:/* @__PURE__ */U("img",{alt:"Crop me",ref:x,src:E.src})})}),
10
- /* @__PURE__ */H(d,{children:[/* @__PURE__ */H(r,{disabled:b,onClick:()=>{f(!1),C({src:"",file:null}),X()},children:[p("editor.imageUpload.cancel"),/* @__PURE__ */U(a,{className:"richtext-ml-1",name:"Trash2"})]}),/* @__PURE__ */U(r,{className:"richtext-w-fit",disabled:b||!y,onClick:R,children:/* @__PURE__ */H(z,b?{children:[p("editor.imageUpload.uploading"),/* @__PURE__ */U(a,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}:{children:[p("editor.imageUpload.crop"),/* @__PURE__ */U(a,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),
10
+ /* @__PURE__ */H(d,{children:[/* @__PURE__ */H(r,{disabled:b,onClick:()=>{f(!1),C({src:"",file:null}),X()},children:[p("editor.imageUpload.cancel"),/* @__PURE__ */U(a,{className:"richtext-ml-1",name:"Trash2"})]}),/* @__PURE__ */U(r,{className:"richtext-w-fit",disabled:b||!y,onClick:R,children:/* @__PURE__ */H(k,b?{children:[p("editor.imageUpload.uploading"),/* @__PURE__ */U(a,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}:{children:[p("editor.imageUpload.crop"),/* @__PURE__ */U(a,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),
11
11
  /* @__PURE__ */U("input",{accept:_?.acceptMimes?.join(",")||"image/*",multiple:!1,onChange:async t=>{const i=t?.target?.files;if(!e||e.isDestroyed||0===i.length)return void(t.target.value="");const a=ee(i,{acceptMimes:_?.acceptMimes,maxSize:_?.maxSize,t:p,toast:g,onError:_.onError});if(a.length<=0)return void(t.target.value="");const r=a[0],n=await S(r);f(!0),C({src:n.src,file:r})},ref:M,style:{display:"none"},type:"file"})]})}export{ee as a,te as i,ie as n,V as o,ae as r,re as t};
@@ -1,3 +1,3 @@
1
- import{n as t}from"./toggle-BXl_NYYh.js";import{g as e}from"./locales-DfkG6-1b.js";import{t as i}from"./input-CMD6LZFr.js";import{n as r,r as a,t as n}from"./popover-DGEv-NbL.js";import{n as s,o,t as d}from"./throttle-BpbN7uB1.js";import{n as c,t as l}from"./isNumber-7Fi2iQVS.js";import{c as m,t as h}from"./useButtonProps-DSIajp_B.js";import{NodeViewWrapper as g,ReactNodeViewRenderer as p}from"@tiptap/react";import u,{useCallback as f,useEffect as w,useMemo as v,useRef as y,useState as b}from"react";import{Fragment as x,jsx as _,jsxs as A}from"react/jsx-runtime";import{mergeAttributes as N}from"@tiptap/core";import I from"grab-url";var $="tl",L="tr",M="bl",G="br";function k(t){const[i,r]=b({width:e,height:e}),[a,n]=b({width:0,height:0}),[s]=b([$,L,M,G]),[o,m]=b(!1),[h,p]=b({x:0,y:0,w:0,h:0,dir:""}),{align:u}=t.node.attrs,y=v(()=>{const{src:e,alt:i,width:r,height:a}=t.node.attrs;return{src:e||void 0,alt:i||void 0,style:{width:(l(r)?`${r}px`:r)||void 0,height:(l(a)?`${a}px`:a)||void 0}}},[t?.node?.attrs]),x=v(()=>{const{style:{width:t}}=y;return{width:"100%"===t?t:void 0}},[y]);function N(){const{editor:e,getPos:i}=t;e.commands.setNodeSelection(i())}const I=f(d(()=>{const{editor:e}=t,{width:i}=getComputedStyle(e.view.dom);r(t=>({...t,width:Number.parseInt(i,10)}))},16),[t?.editor]);const k=f(d(e=>{if(e.preventDefault(),e.stopPropagation(),!o)return;const{x:r,w:a,dir:n}=h,s=(e.clientX-r)*(/l/.test(n)?-1:1),d=c(a+s,20,i.width);t.updateAttributes({width:d,height:null})},16),[o,h,i,t.updateAttributes]),P=f(t=>{t.preventDefault(),t.stopPropagation(),o&&(p({x:0,y:0,w:0,h:0,dir:""}),m(!1),N())},[o,N]),T=f(()=>{document?.addEventListener("mousemove",k,!0),document?.addEventListener("mouseup",P,!0)},[k,P]),j=f(()=>{document?.removeEventListener("mousemove",k,!0),document?.removeEventListener("mouseup",P,!0)},[k,P]);w(()=>(o?T():j(),()=>{j()}),[o,T,j]);const C=v(()=>new ResizeObserver(()=>I()),[I]);return w(()=>(C.observe(t.editor.view.dom),()=>{C.disconnect()}),[t.editor.view.dom,C]),/* @__PURE__ */_(g,{className:"image-view",style:{...x,width:"100%",textAlign:u},children:/* @__PURE__ */A("div",{"data-drag-handle":!0,draggable:"true",style:x,className:`image-view__body ${t?.selected?"image-view__body--focused":""} ${o?"image-view__body--resizing":""}`,children:[/* @__PURE__ */_("img",{alt:y.alt,className:"image-view__body__image block",height:"auto",onClick:N,onLoad:function(t){n({width:t.target.width,height:t.target.height})},src:y.src,style:y.style}),t?.editor.view.editable&&(t?.selected||o)&&/* @__PURE__ */_("div",{className:"image-resizer",children:s?.map(e=>/* @__PURE__ */_("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const n=a.width,s=n/a.height;let o=Number(t.node.attrs.width),d=Number(t.node.attrs.height);const c=i.width;o&&!d?(o=o>c?c:o,d=Math.round(o/s)):d&&!o?(o=Math.round(d*s),o=o>c?c:o):o||d?o=o>c?c:o:(o=n>c?c:n,d=Math.round(o/s)),m(!0),p({x:e.clientX,y:e.clientY,w:o,h:d,dir:r})}(r,e)},`image-dir-${e}`))})]})})}function P(t,e){return{searchTrending:async()=>e?"giphy"===t?async function(t){return(await I(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${t}`)).data?.data?.map(t=>({id:t?.id,src:t?.images.original?.url,width:+t?.images.original?.width,height:+t?.images.original?.width}))}(e):"tenor"===t?async function(t){const e=(await I(`https://tenor.googleapis.com/v2/trending_terms?key=${t}&limit=10`)).data;return(await I(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e?.results?.[0]}&limit=15`)).data?.results?.map(t=>({id:t?.id,src:t?.media_formats?.gif?.url,width:t?.media_formats?.gif?.dims?.[0],height:t?.media_formats?.gif?.dims?.[1]}))}(e):[]:[],searchWord:async i=>e?"giphy"===t?async function(t,e){return(await I(`https://api.giphy.com/v1/gifs/search?q=${t}&limit=15&api_key=${e}`)).data?.data?.map(t=>({id:t?.id,src:t?.images.original?.url,width:+t?.images.original?.width,height:+t?.images.original?.width}))}(i,e):"tenor"===t?async function(t,e){return(await I(`https://tenor.googleapis.com/v2/search?key=${e}&q=${t}&limit=15`)).data?.results?.map(t=>({id:t?.id,src:t?.media_formats?.gif?.url,width:t?.media_formats?.gif?.dims?.[0],height:t?.media_formats?.gif?.dims?.[1]}))}(i,e):[]:[]}}function T({selectImage:t,apiKey:e,provider:o,children:d}){const[c,l]=b(!1),[h,g]=b([]),{editorDisabled:p}=m(),u=y(null),{searchTrending:v,searchWord:N}=P(o,e);w(()=>{(async()=>{const t=await v();g(t)})()},[]);const I=f(s(async t=>{if(!t.target.value){const t=await v();return void g(t)}const e=await N(t.target.value);g(e)},350),[]);/* @__PURE__ */
2
- return A(n,{modal:!0,onOpenChange:l,open:c,children:[/* @__PURE__ */_(a,{asChild:!0,disabled:p,children:d}),/* @__PURE__ */_(r,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:e?/* @__PURE__ */A(x,{children:[/* @__PURE__ */_("div",{className:"richtext-mb-[10px] richtext-w-full",children:/* @__PURE__ */_(i,{onChange:I,placeholder:"Search GIF",ref:u,type:"text"})}),/* @__PURE__ */_("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:/* @__PURE__ */_("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1",children:h?.length?h?.map(e=>/* @__PURE__ */_("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:e.src,onClick:()=>{t(e.src),l(!1)}},e.id)):/* @__PURE__ */_("p",{children:"No GIFs found"})})})]}):/* @__PURE__ */_("div",{children:/* @__PURE__ */_("p",{children:"Missing Giphy API Key"})})})]})}function j(){const{action:e,icon:i,tooltip:r,apiKey:a,provider:n}=h(C.name)?.componentProps??{},{editorDisabled:s}=m();/* @__PURE__ */
3
- return _(T,{apiKey:a,provider:n,selectImage:t=>{s||e&&e(t)},children:/* @__PURE__ */_(t,{disabled:s,icon:i,tooltip:r})})}var C=o.extend({name:"imageGif",addOptions(){return{...this.parent?.(),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:e,t:i})=>{const r=e?.options?.provider||"",a=e?.options?.API_KEY||"";return{componentProps:{action:e=>{t.chain().focus().setImageGif({src:e}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:i("editor.imageGif.tooltip"),apiKey:a,provider:r}}}}},addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:t=>{const e=t.style.width||t.getAttribute("width")||"10";return void 0===e?null:Number.parseInt(`${e}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView:()=>p(k),addCommands(){return{...this.parent?.(),setImageGif:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:e})=>e.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageGIf"},["img",N({height:"auto"},this.options.HTMLAttributes,t)]]},parseHTML:()=>[{tag:"div[class=imageGIf]",getAttrs:t=>{const e=t.querySelector("img"),i=e?.getAttribute("width");return{src:e?.getAttribute("src"),alt:e?.getAttribute("alt"),title:e?.getAttribute("title"),width:i?Number.parseInt(i,10):null,align:e?.getAttribute("align")||t.style.textAlign||null}}}]});export{j as n,C as t};
1
+ import{n as t}from"./toggle-BXl_NYYh.js";import{g as e}from"./locales-DfkG6-1b.js";import{t as i}from"./input-CMD6LZFr.js";import{n as r,r as a,t as n}from"./popover-DGEv-NbL.js";import{n as s,o,t as d}from"./throttle-BpbN7uB1.js";import{n as c,t as l}from"./isNumber-7Fi2iQVS.js";import{c as m,t as h}from"./useButtonProps-DSIajp_B.js";import{NodeViewWrapper as g,ReactNodeViewRenderer as p}from"@tiptap/react";import u,{useCallback as f,useEffect as w,useMemo as v,useRef as y,useState as b}from"react";import{Fragment as x,jsx as _,jsxs as A}from"react/jsx-runtime";import{mergeAttributes as N}from"@tiptap/core";import I from"grab-url";var $="tl",L="tr",M="bl",G="br";function j(t){const[i,r]=b({width:e,height:e}),[a,n]=b({width:0,height:0}),[s]=b([$,L,M,G]),[o,m]=b(!1),[h,p]=b({x:0,y:0,w:0,h:0,dir:""}),{align:u}=t.node.attrs,y=v(()=>{const{src:e,alt:i,width:r,height:a}=t.node.attrs;return{src:e||void 0,alt:i||void 0,style:{width:(l(r)?`${r}px`:r)||void 0,height:(l(a)?`${a}px`:a)||void 0}}},[t?.node?.attrs]),x=v(()=>{const{style:{width:t}}=y;return{width:"100%"===t?t:void 0}},[y]);function N(){const{editor:e,getPos:i}=t;e.commands.setNodeSelection(i())}const I=f(d(()=>{const{editor:e}=t,{width:i}=getComputedStyle(e.view.dom);r(t=>({...t,width:Number.parseInt(i,10)}))},16),[t?.editor]);const j=f(d(e=>{if(e.preventDefault(),e.stopPropagation(),!o)return;const{x:r,w:a,dir:n}=h,s=(e.clientX-r)*(/l/.test(n)?-1:1),d=c(a+s,20,i.width);t.updateAttributes({width:d,height:null})},16),[o,h,i,t.updateAttributes]),k=f(t=>{t.preventDefault(),t.stopPropagation(),o&&(p({x:0,y:0,w:0,h:0,dir:""}),m(!1),N())},[o,N]),P=f(()=>{document?.addEventListener("mousemove",j,!0),document?.addEventListener("mouseup",k,!0)},[j,k]),T=f(()=>{document?.removeEventListener("mousemove",j,!0),document?.removeEventListener("mouseup",k,!0)},[j,k]);w(()=>(o?P():T(),()=>{T()}),[o,P,T]);const C=v(()=>new ResizeObserver(()=>I()),[I]);return w(()=>(C.observe(t.editor.view.dom),()=>{C.disconnect()}),[t.editor.view.dom,C]),/* @__PURE__ */_(g,{className:"image-view",style:{...x,width:"100%",textAlign:u},children:/* @__PURE__ */A("div",{"data-drag-handle":!0,draggable:"true",style:x,className:`image-view__body ${t?.selected?"image-view__body--focused":""} ${o?"image-view__body--resizing":""}`,children:[/* @__PURE__ */_("img",{alt:y.alt,className:"image-view__body__image block",height:"auto",onClick:N,onLoad:function(t){n({width:t.target.width,height:t.target.height})},src:y.src,style:y.style}),t?.editor.view.editable&&(t?.selected||o)&&/* @__PURE__ */_("div",{className:"image-resizer",children:s?.map(e=>/* @__PURE__ */_("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const n=a.width,s=n/a.height;let o=Number(t.node.attrs.width),d=Number(t.node.attrs.height);const c=i.width;o&&!d?(o=o>c?c:o,d=Math.round(o/s)):d&&!o?(o=Math.round(d*s),o=o>c?c:o):o||d?o=o>c?c:o:(o=n>c?c:n,d=Math.round(o/s)),m(!0),p({x:e.clientX,y:e.clientY,w:o,h:d,dir:r})}(r,e)},`image-dir-${e}`))})]})})}function k(t,e){return{searchTrending:async()=>e?"giphy"===t?async function(t){return(await I(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${t}`)).data?.data?.map(t=>({id:t?.id,src:t?.images.original?.url,width:+t?.images.original?.width,height:+t?.images.original?.width}))}(e):"tenor"===t?async function(t){const e=(await I(`https://tenor.googleapis.com/v2/trending_terms?key=${t}&limit=10`)).data;return(await I(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e?.results?.[0]}&limit=15`)).data?.results?.map(t=>({id:t?.id,src:t?.media_formats?.gif?.url,width:t?.media_formats?.gif?.dims?.[0],height:t?.media_formats?.gif?.dims?.[1]}))}(e):[]:[],searchWord:async i=>e?"giphy"===t?async function(t,e){return(await I(`https://api.giphy.com/v1/gifs/search?q=${t}&limit=15&api_key=${e}`)).data?.data?.map(t=>({id:t?.id,src:t?.images.original?.url,width:+t?.images.original?.width,height:+t?.images.original?.width}))}(i,e):"tenor"===t?async function(t,e){return(await I(`https://tenor.googleapis.com/v2/search?key=${e}&q=${t}&limit=15`)).data?.results?.map(t=>({id:t?.id,src:t?.media_formats?.gif?.url,width:t?.media_formats?.gif?.dims?.[0],height:t?.media_formats?.gif?.dims?.[1]}))}(i,e):[]:[]}}function P({selectImage:t,apiKey:e,provider:o,children:d}){const[c,l]=b(!1),[h,g]=b([]),{editorDisabled:p}=m(),u=y(null),{searchTrending:v,searchWord:N}=k(o,e);w(()=>{(async()=>{const t=await v();g(t)})()},[]);const I=f(s(async t=>{if(!t.target.value){const t=await v();return void g(t)}const e=await N(t.target.value);g(e)},350),[]);/* @__PURE__ */
2
+ return A(n,{modal:!0,onOpenChange:l,open:c,children:[/* @__PURE__ */_(a,{asChild:!0,disabled:p,children:d}),/* @__PURE__ */_(r,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:e?/* @__PURE__ */A(x,{children:[/* @__PURE__ */_("div",{className:"richtext-mb-[10px] richtext-w-full",children:/* @__PURE__ */_(i,{onChange:I,placeholder:"Search GIF",ref:u,type:"text"})}),/* @__PURE__ */_("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:/* @__PURE__ */_("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1",children:h?.length?h?.map(e=>/* @__PURE__ */_("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:e.src,onClick:()=>{t(e.src),l(!1)}},e.id)):/* @__PURE__ */_("p",{children:"No GIFs found"})})})]}):/* @__PURE__ */_("div",{children:/* @__PURE__ */_("p",{children:"Missing Giphy API Key"})})})]})}function T(){const{action:e,icon:i,tooltip:r,apiKey:a,provider:n}=h(C.name)?.componentProps??{},{editorDisabled:s}=m();/* @__PURE__ */
3
+ return _(P,{apiKey:a,provider:n,selectImage:t=>{s||e&&e(t)},children:/* @__PURE__ */_(t,{disabled:s,icon:i,tooltip:r})})}var C=o.extend({name:"imageGif",addOptions(){return{...this.parent?.(),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:e,t:i})=>{const r=e?.options?.provider||"",a=e?.options?.API_KEY||"";return{componentProps:{action:e=>{t.chain().focus().setImageGif({src:e}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:i("editor.imageGif.tooltip"),apiKey:a,provider:r}}}}},addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:t=>{const e=t.style.width||t.getAttribute("width")||"10";return void 0===e?null:Number.parseInt(`${e}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView:()=>p(j),addCommands(){return{...this.parent?.(),setImageGif:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:e})=>e.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageGIf"},["img",N({height:"auto"},this.options.HTMLAttributes,t)]]},parseHTML:()=>[{tag:"div[class=imageGIf]",getAttrs:t=>{const e=t.querySelector("img"),i=e?.getAttribute("width");return{src:e?.getAttribute("src"),alt:e?.getAttribute("alt"),title:e?.getAttribute("title"),width:i?Number.parseInt(i,10):null,align:e?.getAttribute("align")||t.style.textAlign||null}}}]});export{T as n,C as t};
package/dist/ImageGif.js CHANGED
@@ -1 +1 @@
1
- import{n as a,t as m}from"./ImageGif-D5Qw_Xf-.js";export{m as ImageGif,a as RichTextImageGif};
1
+ import{n as a,t as m}from"./ImageGif-D9goI48J.js";export{m as ImageGif,a as RichTextImageGif};