reactjs-tiptap-editor 1.0.16 → 1.0.18

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 (263) hide show
  1. package/lib/{ActionMenuButton-a8LhmHXe.js → ActionMenuButton-BOjCHFTA.js} +12 -16
  2. package/lib/ActionMenuButton-Df077oOH.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +47 -89
  5. package/lib/Blockquote.cjs +2 -2
  6. package/lib/Blockquote.js +11 -14
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +13 -16
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +15 -18
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +113 -113
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +12 -14
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +8 -11
  17. package/lib/CodeBlock.cjs +37 -37
  18. package/lib/CodeBlock.js +1566 -1613
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +9 -11
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +62 -82
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +27 -15
  25. package/lib/Drawer-DwrlY_lY.cjs +1 -0
  26. package/lib/Drawer-DxOoRiGQ.js +1099 -0
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +6 -5
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +71 -97
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +265 -5
  33. package/lib/ExportPdf.cjs +4 -4
  34. package/lib/ExportPdf.js +20 -31
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +11 -11
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +16 -39
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +25 -41
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +51 -65
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +60 -76
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +322 -320
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +8 -11
  49. package/lib/{Iframe-CmjbQQcz.js → Iframe-AhNV5WH5.js} +52 -65
  50. package/lib/Iframe-C6pBw-AF.cjs +1 -0
  51. package/lib/Iframe.cjs +1 -1
  52. package/lib/Iframe.js +5 -4
  53. package/lib/Image.cjs +1 -1
  54. package/lib/Image.js +5 -5
  55. package/lib/ImageGif.cjs +1 -1
  56. package/lib/ImageGif.js +148 -181
  57. package/lib/ImportWord.cjs +1 -1
  58. package/lib/ImportWord.js +19 -26
  59. package/lib/{Indent-BoG-vpIE.js → Indent-DZ5PcJA4.js} +24 -30
  60. package/lib/Indent-Do-X0AsY.cjs +1 -0
  61. package/lib/Indent.cjs +1 -1
  62. package/lib/Indent.js +2 -2
  63. package/lib/Italic.cjs +1 -1
  64. package/lib/Italic.js +11 -14
  65. package/lib/Katex-CIC9ygbL.cjs +4 -0
  66. package/lib/{Katex-ByL9snce.js → Katex-bIgoenn_.js} +243 -262
  67. package/lib/Katex.cjs +1 -1
  68. package/lib/Katex.js +5 -4
  69. package/lib/LineHeight.cjs +1 -1
  70. package/lib/LineHeight.js +23 -34
  71. package/lib/Link.cjs +1 -1
  72. package/lib/Link.js +2 -2
  73. package/lib/LinkEditBlock-B0ZaACZO.cjs +5 -0
  74. package/lib/{LinkEditBlock-Ckih17pU.js → LinkEditBlock-D_cF9fnc.js} +324 -381
  75. package/lib/MarkdownPaste.cjs +58 -0
  76. package/lib/MarkdownPaste.js +1656 -0
  77. package/lib/Mention.cjs +1 -1
  78. package/lib/Mention.js +22 -17
  79. package/lib/Mermaid.cjs +2 -2
  80. package/lib/Mermaid.js +125 -154
  81. package/lib/MoreMark.cjs +1 -1
  82. package/lib/MoreMark.js +28 -40
  83. package/lib/OrderedList.cjs +1 -1
  84. package/lib/OrderedList.js +13 -16
  85. package/lib/SearchAndReplace.cjs +1 -1
  86. package/lib/SearchAndReplace.js +114 -186
  87. package/lib/SlashCommand.cjs +1 -1
  88. package/lib/SlashCommand.js +15 -14
  89. package/lib/SlashCommandNodeView-Ba03hlVZ.cjs +1 -0
  90. package/lib/{SlashCommandNodeView-B2g1MbgN.js → SlashCommandNodeView-cg0x3NRF.js} +72 -79
  91. package/lib/Strike.cjs +1 -1
  92. package/lib/Strike.js +12 -15
  93. package/lib/{Table-BEwrZVup.js → Table-KqLiT5wG.js} +85 -125
  94. package/lib/Table-ddU2LSc6.cjs +9 -0
  95. package/lib/Table.cjs +1 -1
  96. package/lib/Table.js +1 -1
  97. package/lib/TaskList.cjs +1 -1
  98. package/lib/TaskList.js +18 -21
  99. package/lib/TextAlign.cjs +1 -1
  100. package/lib/TextAlign.js +65 -78
  101. package/lib/TextDirection.cjs +1 -1
  102. package/lib/TextDirection.js +51 -77
  103. package/lib/TextUnderline.cjs +1 -1
  104. package/lib/TextUnderline.js +7 -10
  105. package/lib/Twitter-BIiR78Jh.cjs +1 -0
  106. package/lib/{Twitter-4U_ZBhpv.js → Twitter-C1Lzqc7u.js} +567 -599
  107. package/lib/Twitter.cjs +1 -1
  108. package/lib/Twitter.js +4 -3
  109. package/lib/Video.cjs +1 -1
  110. package/lib/Video.js +5 -270
  111. package/lib/bubble.cjs +6 -4
  112. package/lib/bubble.js +3719 -3039
  113. package/lib/clsx-BWE7vnna.cjs +33 -0
  114. package/lib/clsx-eGVyq7ot.js +1062 -0
  115. package/lib/components/ActionButton.d.ts +2 -2
  116. package/lib/components/ActionMenuButton.d.ts +1 -1
  117. package/lib/components/Bubble/formatBubble.d.ts +5 -5
  118. package/lib/components/ReactBus.d.ts +11 -0
  119. package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -0
  120. package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -0
  121. package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +5 -0
  122. package/lib/components/ui/checkbox.d.ts +1 -1
  123. package/lib/components/ui/dialog.d.ts +1 -1
  124. package/lib/components/ui/dropdown-menu.d.ts +1 -1
  125. package/lib/components/ui/emoji-picker.d.ts +1 -1
  126. package/lib/components/ui/label.d.ts +1 -1
  127. package/lib/components/ui/popover.d.ts +1 -1
  128. package/lib/components/ui/select.d.ts +1 -1
  129. package/lib/components/ui/separator.d.ts +1 -1
  130. package/lib/components/ui/switch.d.ts +1 -1
  131. package/lib/components/ui/tabs.d.ts +1 -1
  132. package/lib/components/ui/toast.d.ts +1 -1
  133. package/lib/components/ui/toggle.d.ts +1 -1
  134. package/lib/components/ui/tooltip.d.ts +1 -1
  135. package/lib/{delete-node-IyVmiRbI.js → delete-node-eQHsyyhR.js} +3 -1
  136. package/lib/{dropdown-menu-CW3Kthwy.js → dropdown-menu-CexIkt_V.js} +8 -8
  137. package/lib/{dropdown-menu-eUeBXQeA.cjs → dropdown-menu-oSKIntXM.cjs} +1 -1
  138. package/lib/extensions/Blockquote/Blockquote.d.ts +1 -1
  139. package/lib/extensions/Bold/Bold.d.ts +1 -1
  140. package/lib/extensions/Code/Code.d.ts +1 -1
  141. package/lib/extensions/CodeView/CodeView.d.ts +2 -2
  142. package/lib/extensions/Heading/Heading.d.ts +1 -1
  143. package/lib/extensions/Highlight/Highlight.d.ts +1 -1
  144. package/lib/extensions/HorizontalRule/HorizontalRule.d.ts +1 -1
  145. package/lib/extensions/ImportWord/ImportWord.d.ts +2 -2
  146. package/lib/extensions/Italic/Italic.d.ts +1 -1
  147. package/lib/extensions/Link/Link.d.ts +1 -1
  148. package/lib/extensions/MarkdownPaste/MarkdownPaste.d.ts +5 -0
  149. package/lib/extensions/MarkdownPaste/index.d.ts +1 -0
  150. package/lib/extensions/Mermaid/Mermaid.d.ts +1 -1
  151. package/lib/extensions/MoreMark/MoreMark.d.ts +1 -1
  152. package/lib/extensions/Strike/Strike.d.ts +1 -1
  153. package/lib/extensions/Table/Table.d.ts +1 -1
  154. package/lib/extensions/TextAlign/TextAlign.d.ts +1 -1
  155. package/lib/extensions/TextUnderline/TextUnderline.d.ts +1 -1
  156. package/lib/index-BUTn2LY6.cjs +1 -0
  157. package/lib/{index-C07N8gA1.js → index-BlXGgvT-.js} +21 -18
  158. package/lib/{index-CpTykZBR.js → index-BnW6t8z6.js} +23 -23
  159. package/lib/{index-BsFvo9PG.cjs → index-BqL4vAWE.cjs} +1 -1
  160. package/lib/index-BtxvYLJ1.cjs +12 -0
  161. package/lib/{index-DR5tIdL7.js → index-C6xmkxrQ.js} +232 -217
  162. package/lib/index-CJ9pyCM4.cjs +1 -0
  163. package/lib/{index-neeeY2o7.cjs → index-D0lc95kr.cjs} +3 -3
  164. package/lib/index-DHUN85fV.js +4855 -0
  165. package/lib/index-DUpSE1Gb.cjs +1 -0
  166. package/lib/index-D_8P0LE5.js +1362 -0
  167. package/lib/{index-4bHF5ovf.js → index-RIXs7STX.js} +1 -1
  168. package/lib/index-mfGK4pFo.js +6469 -0
  169. package/lib/index-zig3Dj7A.cjs +22 -0
  170. package/lib/index.cjs +3 -3
  171. package/lib/index.js +60 -72
  172. package/lib/locale-bundle.cjs +1 -1
  173. package/lib/locale-bundle.js +1 -1
  174. package/lib/plugins/image-upload.d.ts +1 -1
  175. package/lib/popover-BYSZ3zBi.js +24 -0
  176. package/lib/popover-BcHDZqBt.cjs +1 -0
  177. package/lib/{renderNodeView-CSazLrKF.js → renderNodeView-BrM5kUj_.js} +2 -2
  178. package/lib/{renderNodeView-DfLmGrgA.cjs → renderNodeView-D1zydtli.cjs} +1 -1
  179. package/lib/{select-F0ZZ3VZB.js → select-C5SHDLFj.js} +8 -5
  180. package/lib/{select-Doa_-jkZ.cjs → select-DHjzKkcu.cjs} +1 -1
  181. package/lib/separator-BmixLrnJ.cjs +1 -0
  182. package/lib/separator-CFKVxAea.js +293 -0
  183. package/lib/store/editor.d.ts +1 -1
  184. package/lib/store/store.d.ts +2 -22
  185. package/lib/style.css +1 -1
  186. package/lib/{textarea-BAolHF_W.cjs → textarea-CasDcv3u.cjs} +1 -1
  187. package/lib/{textarea-tOsPnxHf.js → textarea-DNLrJoRl.js} +1 -1
  188. package/lib/theme.js +1 -1
  189. package/lib/types.d.ts +3 -3
  190. package/lib/updatePosition-CBRjbQMH.js +16 -0
  191. package/lib/updatePosition-CfmY5Trk.cjs +1 -0
  192. package/lib/utils/checkIsVideoUrl.d.ts +1 -0
  193. package/lib/utils/columns.d.ts +1 -1
  194. package/lib/utils/customEvents/events.constant.d.ts +1 -0
  195. package/lib/utils/mitt.d.ts +6 -3
  196. package/lib/utils/pdf.d.ts +1 -1
  197. package/lib/utils/utils.d.ts +1 -1
  198. package/package.json +262 -247
  199. package/lib/ActionMenuButton-BYu0NyVo.cjs +0 -1
  200. package/lib/Drawer-CbOJ1Igo.js +0 -1379
  201. package/lib/Drawer-DNaDMoAk.cjs +0 -1
  202. package/lib/Excalidraw-DnHTVOj8.js +0 -355
  203. package/lib/Excalidraw-DxfO1lQ_.cjs +0 -1
  204. package/lib/Icon-C0TJMAOm.js +0 -12
  205. package/lib/Icon-DzK0_ztP.cjs +0 -1
  206. package/lib/Iframe-BSNCsofW.cjs +0 -1
  207. package/lib/Image-BZEFuS0P.js +0 -925
  208. package/lib/Image-iKsGKjvg.cjs +0 -1
  209. package/lib/Indent-Bou16OcB.cjs +0 -1
  210. package/lib/Katex-BqDocr3a.cjs +0 -4
  211. package/lib/LinkEditBlock-B0I0EUrt.cjs +0 -5
  212. package/lib/SlashCommandNodeView-BEJhEzba.cjs +0 -1
  213. package/lib/Table-BclWwp6P.cjs +0 -9
  214. package/lib/Twitter-Dtq6PEMC.cjs +0 -1
  215. package/lib/button-Bwn6gUuS.js +0 -43
  216. package/lib/button-CqJztfH2.cjs +0 -1
  217. package/lib/checkbox-BAzbZY2Y.cjs +0 -1
  218. package/lib/checkbox-B_rpz5Xq.js +0 -27
  219. package/lib/clsx-CXbNJWDD.cjs +0 -54
  220. package/lib/clsx-DSzxBzvL.js +0 -7391
  221. package/lib/dialog-CJvpoeMm.js +0 -101
  222. package/lib/dialog-CWYTvz5J.cjs +0 -1
  223. package/lib/events.constant-Dq21NPdV.cjs +0 -1
  224. package/lib/events.constant-do95b767.js +0 -21
  225. package/lib/extensions/Image/store.d.ts +0 -4
  226. package/lib/extensions/Video/store.d.ts +0 -4
  227. package/lib/file-BLas99n7.js +0 -43
  228. package/lib/file-i7e4nQY2.cjs +0 -1
  229. package/lib/index-BCzvbrf5.cjs +0 -12
  230. package/lib/index-CL7JP-Xz.js +0 -426
  231. package/lib/index-CjhjjJsN.cjs +0 -1
  232. package/lib/index-Cn-t3Zxw.cjs +0 -1
  233. package/lib/index-Cs6cp0Y6.cjs +0 -1
  234. package/lib/index-D8li6EQ4.js +0 -1351
  235. package/lib/index-DoiuU6VA.js +0 -2315
  236. package/lib/index-VhKd73hZ.cjs +0 -1
  237. package/lib/input-B1egKb-t.js +0 -21
  238. package/lib/input-ZGRt7lWR.cjs +0 -1
  239. package/lib/isNumber-BTYSVlKo.cjs +0 -1
  240. package/lib/isNumber-ClwLypY2.js +0 -15
  241. package/lib/label-Cjrzc5H2.js +0 -19
  242. package/lib/label-tzSPdqui.cjs +0 -1
  243. package/lib/popover-C6Cya3Cz.cjs +0 -1
  244. package/lib/popover-CeY3RbI5.js +0 -24
  245. package/lib/separator-CUh5Y7Rh.cjs +0 -1
  246. package/lib/separator-Cjn4YH8a.js +0 -329
  247. package/lib/store/fast-context.d.ts +0 -7
  248. package/lib/store-BsJz5QRC.js +0 -10
  249. package/lib/store-DjkMIIEN.cjs +0 -1
  250. package/lib/tabs-BP8ypR_m.cjs +0 -1
  251. package/lib/tabs-CBDjOLl_.js +0 -46
  252. package/lib/throttle-D040PfWL.js +0 -249
  253. package/lib/throttle-gTTvqDTW.cjs +0 -1
  254. package/lib/toggle-C_SSvDRy.cjs +0 -1
  255. package/lib/toggle-DEerYRil.js +0 -99
  256. package/lib/tooltip-BJIvosho.js +0 -24
  257. package/lib/tooltip-FS1rsvd3.cjs +0 -1
  258. package/lib/updatePosition-CDK7OR0i.js +0 -16
  259. package/lib/updatePosition-Cjuj2E26.cjs +0 -1
  260. package/lib/useButtonProps-CtZCbMQu.js +0 -136
  261. package/lib/useButtonProps-Cz4W5dC8.cjs +0 -1
  262. package/lib/utils/_event.d.ts +0 -13
  263. package/lib/utils/customEvents/customEvents.d.ts +0 -3
package/lib/Mention.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./clsx-CXbNJWDD.cjs"),w=require("@tiptap/pm/model"),y=require("./index-Cs6cp0Y6.cjs"),T=require("@tiptap/pm/state"),m=require("react/jsx-runtime"),h=require("react"),M=require("scroll-into-view-if-needed"),x=require("./renderNodeView-DfLmGrgA.cjs");function L({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r="@"}){const s=new T.PluginKey;return{editor:e,char:r,pluginKey:s,command:({editor:o,range:a,props:l})=>{var u,i,d;const g=o.view.state.selection.$to.nodeAfter;((u=g==null?void 0:g.text)==null?void 0:u.startsWith(" "))&&(a.to+=1),o.chain().focus().insertContentAt(a,[{type:n,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(i=o.view.dom.ownerDocument.defaultView)==null?void 0:i.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:a})=>{const l=o.doc.resolve(a.from),u=o.schema.nodes[n];return!!l.parent.type.contentMatch.matchType(u)},...t}}function v(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>L({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function f(e,t){const n=v(e),r=n.find(s=>s.char===t);return r||(n.length?n[0]:null)}var S=c.Node3.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){var n,r;return`${(n=t==null?void 0:t.char)!=null?n:"@"}${(r=e.attrs.label)!=null?r:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){var r,s;return["span",c.mergeAttributes(this.HTMLAttributes,e.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(s=t.attrs.label)!=null?s:t.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:e=>e.getAttribute("data-mention-suggestion-char"),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){const n=f(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",c.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];const r={...this.options};r.HTMLAttributes=c.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t);const s=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof s=="string"?["span",c.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),s]:s},...c.createInlineMarkdownSpec({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:e=>{const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;r!==null;){const[,s,o,a]=r,l=o??a;t[s==="char"?"mentionSuggestionChar":s]=l,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,t])=>t!=null).map(([t,n])=>`${t==="mentionSuggestionChar"?"char":t}="${n}"`).join(" ")}),renderText({node:e}){const t={options:this.options,node:e,suggestion:f(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(t)):this.options.renderText(t)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:s,anchor:o}=r;if(!s)return!1;let a=new w.Node,l=0;return t.doc.nodesBetween(o-1,o,(u,i)=>{if(u.type.name===this.name)return n=!0,a=u,l=i,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?"":a.attrs.mentionSuggestionChar,l,l+a.nodeSize),n})}},addProseMirrorPlugins(){return v(this).map(y.Suggestion)}}),A=S;const b=h.forwardRef((e,t)=>{const n=h.useRef(null),[r,s]=h.useState(0),o=i=>{const d=e.items[i];d&&e.command(d)},a=()=>{s((r+e.items.length-1)%e.items.length)},l=()=>{s((r+1)%e.items.length)},u=()=>{o(r)};return h.useEffect(()=>s(0),[e.items]),h.useEffect(()=>{if(Number.isNaN(r+1))return;const i=n.current.querySelector(`span:nth-of-type(${r+1})`);i&&M(i,{behavior:"smooth",scrollMode:"if-needed"})},[r]),h.useImperativeHandle(t,()=>({onKeyDown:({event:i})=>i.key==="ArrowUp"?(a(),!0):i.key==="ArrowDown"?(l(),!0):i.key==="Enter"?(u(),!0):!1})),m.jsx("div",{className:" !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:n,children:m.jsx("div",{children:e.items.length>0?e.items.map((i,d)=>{var g;return m.jsxs("span",{className:c.clsx("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ",{"bg-item-active":d===r}),onClick:p=>{p.preventDefault(),o(d)},children:[((g=i==null?void 0:i.avatar)==null?void 0:g.src)&&m.jsx("img",{alt:i.label,className:"richtext-size-5 richtext-rounded-full",src:i.avatar.src}),i==null?void 0:i.label]},`mention-item-${i.id}`)}):m.jsx("div",{className:c.clsx("itemUserEmpty, richtext-text-foreground"),children:"Empty"})})})}),H=c.Extension.create({name:"richTextMentionWrapper",addExtensions(){var t,n,r,s;const e={...this.options};return(t=this.options)!=null&&t.suggestion&&(e.suggestion={render:x.renderNodeViewClosure(b),...this.options.suggestion}),(r=(n=this.options)==null?void 0:n.suggestions)!=null&&r.length&&(e.suggestions=(s=this.options.suggestions)==null?void 0:s.map(o=>({render:x.renderNodeViewClosure(b),...o}))),[A.configure({HTMLAttributes:{class:"mention"},...e})]}});exports.Mention=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-zig3Dj7A.cjs"),y=require("@tiptap/pm/model"),T=require("./index-DUpSE1Gb.cjs"),M=require("@tiptap/pm/state"),m=require("react/jsx-runtime"),x=require("./clsx-BWE7vnna.cjs"),h=require("react"),L=require("scroll-into-view-if-needed"),f=require("./renderNodeView-D1zydtli.cjs");function S({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r="@"}){const s=new M.PluginKey;return{editor:e,char:r,pluginKey:s,command:({editor:o,range:a,props:l})=>{var u,i,c;const g=o.view.state.selection.$to.nodeAfter;((u=g==null?void 0:g.text)==null?void 0:u.startsWith(" "))&&(a.to+=1),o.chain().focus().insertContentAt(a,[{type:n,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(c=(i=o.view.dom.ownerDocument.defaultView)==null?void 0:i.getSelection())==null||c.collapseToEnd()},allow:({state:o,range:a})=>{const l=o.doc.resolve(a.from),u=o.schema.nodes[n];return!!l.parent.type.contentMatch.matchType(u)},...t}}function w(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>S({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function b(e,t){const n=w(e),r=n.find(s=>s.char===t);return r||(n.length?n[0]:null)}var A=d.Node3.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){var n,r;return`${(n=t==null?void 0:t.char)!=null?n:"@"}${(r=e.attrs.label)!=null?r:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){var r,s;return["span",d.mergeAttributes(this.HTMLAttributes,e.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(s=t.attrs.label)!=null?s:t.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:e=>e.getAttribute("data-mention-suggestion-char"),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){const n=b(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",d.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];const r={...this.options};r.HTMLAttributes=d.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t);const s=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof s=="string"?["span",d.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),s]:s},...d.createInlineMarkdownSpec({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:e=>{const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;r!==null;){const[,s,o,a]=r,l=o??a;t[s==="char"?"mentionSuggestionChar":s]=l,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,t])=>t!=null).map(([t,n])=>`${t==="mentionSuggestionChar"?"char":t}="${n}"`).join(" ")}),renderText({node:e}){const t={options:this.options,node:e,suggestion:b(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(t)):this.options.renderText(t)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:s,anchor:o}=r;if(!s)return!1;let a=new y.Node,l=0;return t.doc.nodesBetween(o-1,o,(u,i)=>{if(u.type.name===this.name)return n=!0,a=u,l=i,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?"":a.attrs.mentionSuggestionChar,l,l+a.nodeSize),n})}},addProseMirrorPlugins(){return w(this).map(T.Suggestion)}}),H=A;const v=h.forwardRef((e,t)=>{const n=h.useRef(null),[r,s]=h.useState(0),o=i=>{const c=e.items[i];c&&e.command(c)},a=()=>{s((r+e.items.length-1)%e.items.length)},l=()=>{s((r+1)%e.items.length)},u=()=>{o(r)};return h.useEffect(()=>s(0),[e.items]),h.useEffect(()=>{if(Number.isNaN(r+1))return;const i=n.current.querySelector(`span:nth-of-type(${r+1})`);i&&L(i,{behavior:"smooth",scrollMode:"if-needed"})},[r]),h.useImperativeHandle(t,()=>({onKeyDown:({event:i})=>i.key==="ArrowUp"?(a(),!0):i.key==="ArrowDown"?(l(),!0):i.key==="Enter"?(u(),!0):!1})),m.jsx("div",{className:"!richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:n,children:m.jsx("div",{children:e.items.length>0?e.items.map((i,c)=>{var g;return m.jsxs("span",{className:x.clsx("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",{"bg-item-active":c===r}),onClick:p=>{p.preventDefault(),o(c)},children:[((g=i==null?void 0:i.avatar)==null?void 0:g.src)&&m.jsx("img",{alt:i.label,className:"richtext-size-5 richtext-rounded-full",src:i.avatar.src}),i==null?void 0:i.label]},`mention-item-${i.id}`)}):m.jsx("div",{className:x.clsx("itemUserEmpty, richtext-text-foreground"),children:"Empty"})})})}),N=d.Extension.create({name:"richTextMentionWrapper",addExtensions(){var t,n,r,s;const e={...this.options};return(t=this.options)!=null&&t.suggestion&&(e.suggestion={render:f.renderNodeViewClosure(v),...this.options.suggestion}),(r=(n=this.options)==null?void 0:n.suggestions)!=null&&r.length&&(e.suggestions=(s=this.options.suggestions)==null?void 0:s.map(o=>({render:f.renderNodeViewClosure(v),...o}))),[H.configure({HTMLAttributes:{class:"mention"},...e})]}});exports.Mention=N;
package/lib/Mention.js CHANGED
@@ -1,11 +1,12 @@
1
- import { N as T, B as y, m as h, j as p, E as M } from "./clsx-DSzxBzvL.js";
1
+ import { N as y, y as T, m as h, E as M } from "./index-mfGK4pFo.js";
2
2
  import { Node as L } from "@tiptap/pm/model";
3
- import { S } from "./index-D8li6EQ4.js";
3
+ import { S } from "./index-D_8P0LE5.js";
4
4
  import { PluginKey as H } from "@tiptap/pm/state";
5
5
  import { jsx as g, jsxs as A } from "react/jsx-runtime";
6
+ import { c as p } from "./clsx-eGVyq7ot.js";
6
7
  import { forwardRef as N, useRef as C, useState as $, useEffect as f, useImperativeHandle as k } from "react";
7
8
  import E from "scroll-into-view-if-needed";
8
- import { r as x } from "./renderNodeView-CSazLrKF.js";
9
+ import { r as x } from "./renderNodeView-BrM5kUj_.js";
9
10
  function _({
10
11
  editor: e,
11
12
  overrideSuggestionOptions: t,
@@ -53,7 +54,7 @@ function b(e, t) {
53
54
  const n = w(e), r = n.find((o) => o.char === t);
54
55
  return r || (n.length ? n[0] : null);
55
56
  }
56
- var I = T.create({
57
+ var I = y.create({
57
58
  name: "mention",
58
59
  priority: 101,
59
60
  addOptions() {
@@ -138,7 +139,7 @@ var I = T.create({
138
139
  });
139
140
  return typeof o == "string" ? ["span", h({ "data-type": this.name }, this.options.HTMLAttributes, t), o] : o;
140
141
  },
141
- ...y({
142
+ ...T({
142
143
  nodeName: "mention",
143
144
  name: "@",
144
145
  selfClosing: !0,
@@ -197,8 +198,7 @@ const v = N((e, t) => {
197
198
  s(r);
198
199
  };
199
200
  return f(() => o(0), [e.items]), f(() => {
200
- if (Number.isNaN(r + 1))
201
- return;
201
+ if (Number.isNaN(r + 1)) return;
202
202
  const i = n.current.querySelector(`span:nth-of-type(${r + 1})`);
203
203
  i && E(i, { behavior: "smooth", scrollMode: "if-needed" });
204
204
  }, [r]), k(t, () => ({
@@ -206,7 +206,7 @@ const v = N((e, t) => {
206
206
  })), /* @__PURE__ */ g(
207
207
  "div",
208
208
  {
209
- className: " !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
209
+ className: "!richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
210
210
  "data-richtext-portal": !0,
211
211
  ref: n,
212
212
  children: /* @__PURE__ */ g("div", { children: e.items.length > 0 ? e.items.map((i, c) => {
@@ -214,7 +214,10 @@ const v = N((e, t) => {
214
214
  return /* @__PURE__ */ A(
215
215
  "span",
216
216
  {
217
- className: p("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ", { "bg-item-active": c === r }),
217
+ className: p(
218
+ "richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",
219
+ { "bg-item-active": c === r }
220
+ ),
218
221
  onClick: (m) => {
219
222
  m.preventDefault(), s(c);
220
223
  },
@@ -235,7 +238,7 @@ const v = N((e, t) => {
235
238
  }) : /* @__PURE__ */ g("div", { className: p("itemUserEmpty, richtext-text-foreground"), children: "Empty" }) })
236
239
  }
237
240
  );
238
- }), Q = /* @__PURE__ */ M.create({
241
+ }), R = /* @__PURE__ */ M.create({
239
242
  name: "richTextMentionWrapper",
240
243
  addExtensions() {
241
244
  var t, n, r, o;
@@ -248,14 +251,16 @@ const v = N((e, t) => {
248
251
  }), (r = (n = this.options) == null ? void 0 : n.suggestions) != null && r.length && (e.suggestions = (o = this.options.suggestions) == null ? void 0 : o.map((s) => ({
249
252
  render: x(v),
250
253
  ...s
251
- }))), [K.configure({
252
- HTMLAttributes: {
253
- class: "mention"
254
- },
255
- ...e
256
- })];
254
+ }))), [
255
+ K.configure({
256
+ HTMLAttributes: {
257
+ class: "mention"
258
+ },
259
+ ...e
260
+ })
261
+ ];
257
262
  }
258
263
  });
259
264
  export {
260
- Q as Mention
265
+ R as Mention
261
266
  };
package/lib/Mermaid.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var X=Object.create;var $=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Z(e))!J.call(t,l)&&l!==r&&$(t,l,{get:()=>e[l],enumerable:!(a=U(e,l))||a.enumerable});return t};var Q=(t,e,r)=>(r=t!=null?X(Y(t)):{},K(e||!t||!t.__esModule?$(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./clsx-CXbNJWDD.cjs"),B=require("./throttle-gTTvqDTW.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),ee=require("./toggle-C_SSvDRy.cjs"),E=require("./dialog-CWYTvz5J.cjs"),te=require("./textarea-BAolHF_W.cjs"),L=require("./index-BsFvo9PG.cjs"),z=require("./useButtonProps-Cz4W5dC8.cjs"),re=require("./file-i7e4nQY2.cjs"),ie=require("./button-CqJztfH2.cjs"),se=`graph TB
2
- a-->b`;function ae(){const t=z.useEditorInstance(),e=z.useButtonProps(W.name),{tooltipOptions:r={},isActive:a=void 0,upload:l}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=z.useToggleActive(a),[d,C]=s.useState(se),[q,y]=s.useState(""),[c,_]=s.useState(!1),S=s.useRef(null),[h,k]=s.useState(null),[f,O]=s.useState(!0),D=s.useCallback(u=>{u&&import("mermaid").then(g=>{k(g.default)}).finally(()=>O(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},R=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&c&&R()},[h,c]),s.useEffect(()=>{!f&&h&&c&&I(d)},[h&&d]);const P=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:j}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(l){const i=re.dataURLtoFile(b,A);b=await l(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(d),width:g,height:j},!!d).run()}_(!1)}};return o.jsxs(E.Dialog,{onOpenChange:_,open:c,children:[o.jsx(E.DialogTrigger,{asChild:!0,children:o.jsx(ee.ActionButton,{disabled:T,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{T||_(!0)}})}),o.jsxs(E.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(E.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:D,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:f?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(te.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:u=>C(u.target.value),placeholder:"Text",required:!0,rows:10,value:d,style:{color:"hsl(var(--foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:q},ref:S,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(E.DialogFooter,{children:o.jsx(ie.Button,{disabled:!h,onClick:P,type:"button",children:"Save changes"})})]})]})}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ne({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[T,d]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[C,q]=s.useState({width:0,height:0}),[y]=s.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[c,_]=s.useState(!1),[S,h]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:k}=e==null?void 0:e.attrs,f=s.useMemo(()=>{const{src:i,alt:p,width:x,height:v}=e==null?void 0:e.attrs,w=N.isNumber(x)?`${x}px`:x,n=N.isNumber(v)?`${v}px`:v;return{src:i||void 0,alt:p||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),O=s.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function D(i){q({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const R=s.useCallback(B.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);d(p=>({...p,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function P(i,p){i.preventDefault(),i.stopPropagation();const x=C.width,v=C.height,w=x/v;let n=Number(e.attrs.width),M=Number(e.attrs.height);const m=T.width;n&&!M?(n=n>m?m:n,M=Math.round(n/w)):M&&!n?(n=Math.round(M*w),n=n>m?m:n):!n&&!M?(n=x>m?m:x,M=Math.round(n/w)):n=n>m?m:n,_(!0),h({x:i.clientX,y:i.clientY,w:n,h:M,dir:p})}const u=s.useCallback(B.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!c)return;const{x:p,w:x,dir:v}=S,w=(i.clientX-p)*(/l/.test(v)?-1:1),{width:n,height:M}=e==null?void 0:e.attrs,m=n/M,G=z.clamp(x+w,L.IMAGE_MIN_SIZE,T.width),V=Math.round(G/m);r({width:G,height:V})},L.IMAGE_THROTTLE_WAIT_TIME),[c,S,T,r,e==null?void 0:e.attrs]),g=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),I())},[c,I]),j=s.useCallback(()=>{document==null||document.addEventListener("mousemove",u,!0),document==null||document.addEventListener("mouseup",g,!0)},[u,g]),A=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",u,!0),document==null||document.removeEventListener("mouseup",g,!0)},[u,g]);s.useEffect(()=>(c?j():A(),()=>{A()}),[c,j,A]);const b=s.useMemo(()=>new ResizeObserver(()=>R()),[R]);return s.useEffect(()=>(b.observe(t.view.dom),()=>{b.disconnect()}),[t.view.dom,b]),o.jsx(N.NodeViewWrapper,{className:"image-view",style:{...O,width:"100%",textAlign:k},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...O,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:D,src:f.src,style:f.style}),t.view.editable&&(l||c)&&o.jsx("div",{className:"image-resizer",children:y==null?void 0:y.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:p=>P(p,i)},`image-dir-${i}`))})]})})}const W=B.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:r,extension:a})=>{var l;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(l=a==null?void 0:a.options)==null?void 0:l.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return N.ReactNodeViewRenderer(ne)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",N.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=W;exports.RichTextMermaid=ae;
1
+ "use strict";var V=Object.create;var B=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var J=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of U(e))!Y.call(t,c)&&c!==r&&B(t,c,{get:()=>e[c],enumerable:!(a=X(e,c))||a.enumerable});return t};var K=(t,e,r)=>(r=t!=null?V(Z(t)):{},J(e||!t||!t.__esModule?B(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./index-zig3Dj7A.cjs"),l=require("./index-BUTn2LY6.cjs"),$=require("./clsx-BWE7vnna.cjs"),o=require("react/jsx-runtime"),s=require("react"),L=require("./index-BqL4vAWE.cjs"),G=require("./shortId-Bfj8TyNr.cjs"),Q=require("./textarea-CasDcv3u.cjs"),j={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ee({editor:t,node:e,updateAttributes:r,getPos:a,selected:c}){const[y,h]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[N,H]=s.useState({width:0,height:0}),[_]=s.useState([j.TOP_LEFT,j.TOP_RIGHT,j.BOTTOM_LEFT,j.BOTTOM_RIGHT]),[u,I]=s.useState(!1),[A,g]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:z}=e==null?void 0:e.attrs,p=s.useMemo(()=>{const{src:i,alt:x,width:M,height:w}=e==null?void 0:e.attrs,T=D.isNumber(M)?`${M}px`:M,n=D.isNumber(w)?`${w}px`:w;return{src:i||void 0,alt:x||void 0,style:{width:T||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),C=s.useMemo(()=>{const{style:{width:i}}=p;return{width:i==="100%"?i:void 0}},[p]);function k(i){H({width:i.target.width,height:i.target.height})}function S(){t.commands.setNodeSelection(a())}const O=s.useCallback(l.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);h(x=>({...x,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function q(i,x){i.preventDefault(),i.stopPropagation();const M=N.width,w=N.height,T=M/w;let n=Number(e.attrs.width),b=Number(e.attrs.height);const f=y.width;n&&!b?(n=n>f?f:n,b=Math.round(n/T)):b&&!n?(n=Math.round(b*T),n=n>f?f:n):!n&&!b?(n=M>f?f:M,b=Math.round(n/T)):n=n>f?f:n,I(!0),g({x:i.clientX,y:i.clientY,w:n,h:b,dir:x})}const d=s.useCallback(l.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!u)return;const{x,w:M,dir:w}=A,T=(i.clientX-x)*(/l/.test(w)?-1:1),{width:n,height:b}=e==null?void 0:e.attrs,f=n/b,P=l.clamp(M+T,L.IMAGE_MIN_SIZE,y.width),W=Math.round(P/f);r({width:P,height:W})},L.IMAGE_THROTTLE_WAIT_TIME),[u,A,y,r,e==null?void 0:e.attrs]),m=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),u&&(g({x:0,y:0,w:0,h:0,dir:""}),I(!1),S())},[u,S]),R=s.useCallback(()=>{document==null||document.addEventListener("mousemove",d,!0),document==null||document.addEventListener("mouseup",m,!0)},[d,m]),E=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",d,!0),document==null||document.removeEventListener("mouseup",m,!0)},[d,m]);s.useEffect(()=>(u?R():E(),()=>{E()}),[u,R,E]);const v=s.useMemo(()=>new ResizeObserver(()=>O()),[O]);return s.useEffect(()=>(v.observe(t.view.dom),()=>{v.disconnect()}),[t.view.dom,v]),o.jsx($.NodeViewWrapper,{className:"image-view",style:{...C,width:"100%",textAlign:z},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...C,background:"#fff"},className:`image-view__body ${c?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:S,onLoad:k,src:p.src,style:p.style}),t.view.editable&&(c||u)&&o.jsx("div",{className:"image-resizer",children:_==null?void 0:_.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:x=>q(x,i)},`image-dir-${i}`))})]})})}const te=`graph TB
2
+ a-->b`;function re(){const t=l.useEditorInstance(),e=l.useButtonProps(F.name),{tooltipOptions:r={},isActive:a=void 0,upload:c}=(e==null?void 0:e.componentProps)??{},{editorDisabled:y}=l.useToggleActive(a),[h,N]=s.useState(te),[H,_]=s.useState(""),[u,I]=s.useState(!1),A=s.useRef(null),[g,z]=s.useState(null),[p,C]=s.useState(!0),k=s.useCallback(d=>{d&&import("mermaid").then(m=>{z(m.default)}).finally(()=>C(!1))},[]),S=async d=>{try{const{svg:m}=await g.render("mermaid-svg",d);_(m)}catch{_("")}},O=()=>{g.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),S(h)};s.useEffect(()=>{!p&&g&&u&&O()},[g,u]),s.useEffect(()=>{!p&&g&&u&&S(h)},[g&&h]);const q=async()=>{if(h!==""){if(h){const d=A.current.querySelector("svg"),{width:m,height:R}=d.getBoundingClientRect(),E=`mermaid-${G.shortId()}.svg`;let v=G.i(d.outerHTML);if(c){const i=l.dataURLtoFile(v,E);v=await c(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:v,alt:encodeURIComponent(h),width:m,height:R},!!h).run()}I(!1)}};return o.jsxs(l.Dialog,{onOpenChange:I,open:u,children:[o.jsx(l.DialogTrigger,{asChild:!0,children:o.jsx(l.ActionButton,{disabled:y,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{y||I(!0)}})}),o.jsxs(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(l.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:k,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:p?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(Q.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:d=>N(d.target.value),placeholder:"Text",required:!0,rows:10,value:h,style:{color:"hsl(var(--foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:H},ref:A,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(l.DialogFooter,{children:o.jsx(l.Button,{disabled:!g,onClick:q,type:"button",children:"Save changes"})})]})]})}const F=l.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:r,extension:a})=>{var c;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(c=a==null?void 0:a.options)==null?void 0:c.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return $.ReactNodeViewRenderer(ee)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",D.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=F;exports.RichTextMermaid=re;
package/lib/Mermaid.js CHANGED
@@ -1,148 +1,21 @@
1
- import { h as U, u as G, m as X, k as Z } from "./clsx-DSzxBzvL.js";
2
- import { a as j, c as Y } from "./throttle-D040PfWL.js";
3
- import { jsxs as H, jsx as n, Fragment as J } from "react/jsx-runtime";
4
- import { useState as m, useRef as K, useCallback as A, useEffect as R, useMemo as P } from "react";
5
- import { s as Q, i as tt } from "./shortId-WJVkrvml.js";
6
- import { A as et } from "./toggle-DEerYRil.js";
7
- import { D as rt, a as it, b as at, c as st, d as nt } from "./dialog-CJvpoeMm.js";
8
- import { T as ot } from "./textarea-tOsPnxHf.js";
9
- import { I as q, i as V, j as lt } from "./index-C07N8gA1.js";
10
- import { c as ct, u as dt, a as ut, j as ht } from "./useButtonProps-CtZCbMQu.js";
11
- import { d as mt } from "./file-BLas99n7.js";
12
- import { B as gt } from "./button-Bwn6gUuS.js";
13
- const pt = `graph TB
14
- a-->b`;
15
- function Ot() {
16
- const e = ct(), t = dt(vt.name), {
17
- tooltipOptions: i = {},
18
- isActive: s = void 0,
19
- upload: w
20
- } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = ut(s), [c, S] = m(pt), [D, y] = m(""), [o, _] = m(!1), L = K(null), [d, k] = m(null), [g, O] = m(!0), B = A(
21
- (l) => {
22
- l && import("mermaid").then((u) => {
23
- k(u.default);
24
- }).finally(() => O(!1));
25
- },
26
- []
27
- ), I = async (l) => {
28
- try {
29
- const { svg: u } = await d.render("mermaid-svg", l);
30
- y(u);
31
- } catch {
32
- y("");
33
- }
34
- }, E = () => {
35
- d.initialize({
36
- darkMode: !1,
37
- startOnLoad: !1,
38
- // fontFamily:'',
39
- fontSize: 12,
40
- theme: "base"
41
- }), I(c);
42
- };
43
- return R(() => {
44
- !g && d && o && E();
45
- }, [d, o]), R(() => {
46
- !g && d && o && I(c);
47
- }, [d && c]), /* @__PURE__ */ H(
48
- rt,
49
- {
50
- onOpenChange: _,
51
- open: o,
52
- children: [
53
- /* @__PURE__ */ n(it, { asChild: !0, children: /* @__PURE__ */ n(
54
- et,
55
- {
56
- disabled: T,
57
- icon: "Mermaid",
58
- tooltip: "Mermaid",
59
- tooltipOptions: i,
60
- action: () => {
61
- T || _(!0);
62
- }
63
- }
64
- ) }),
65
- /* @__PURE__ */ H(at, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
66
- /* @__PURE__ */ n(st, { children: "Mermaid" }),
67
- /* @__PURE__ */ n(
68
- "div",
69
- {
70
- ref: B,
71
- style: { height: "100%", border: "1px solid hsl(var(--border))" },
72
- children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(J, { children: /* @__PURE__ */ H("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
73
- /* @__PURE__ */ n(
74
- ot,
75
- {
76
- autoFocus: !0,
77
- className: "richtext-flex-1",
78
- onChange: (l) => S(l.target.value),
79
- placeholder: "Text",
80
- required: !0,
81
- rows: 10,
82
- value: c,
83
- style: {
84
- color: "hsl(var(--foreground))"
85
- }
86
- }
87
- ),
88
- /* @__PURE__ */ n(
89
- "div",
90
- {
91
- className: "richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",
92
- dangerouslySetInnerHTML: { __html: D },
93
- ref: L,
94
- style: { height: "100%", borderWidth: 1, minHeight: 500, background: "#fff" }
95
- }
96
- )
97
- ] }) })
98
- }
99
- ),
100
- /* @__PURE__ */ n(nt, { children: /* @__PURE__ */ n(
101
- gt,
102
- {
103
- disabled: !d,
104
- onClick: async () => {
105
- if (c !== "") {
106
- if (c) {
107
- const l = L.current.querySelector("svg"), { width: u, height: z } = l.getBoundingClientRect(), N = `mermaid-${Q()}.svg`;
108
- let M = tt(l.outerHTML);
109
- if (w) {
110
- const r = mt(M, N);
111
- M = await w(r);
112
- }
113
- e == null || e.chain().focus().setMermaid(
114
- {
115
- type: "mermaid",
116
- src: M,
117
- alt: encodeURIComponent(c),
118
- width: u,
119
- height: z
120
- },
121
- !!c
122
- ).run();
123
- }
124
- _(!1);
125
- }
126
- },
127
- type: "button",
128
- children: "Save changes"
129
- }
130
- ) })
131
- ] })
132
- ]
133
- }
134
- );
135
- }
1
+ import { q as G, m as U } from "./index-mfGK4pFo.js";
2
+ import { v as q, w as X, h as Z, u as Y, d as J, D as K, m as Q, A as tt, n as et, o as rt, p as it, B as at, x as st, y as nt } from "./index-DHUN85fV.js";
3
+ import { N as ot, a as lt } from "./clsx-eGVyq7ot.js";
4
+ import { jsx as n, jsxs as H, Fragment as ct } from "react/jsx-runtime";
5
+ import { useState as m, useMemo as P, useCallback as A, useEffect as R, useRef as dt } from "react";
6
+ import { I as V, i as W, j as ut } from "./index-BlXGgvT-.js";
7
+ import { s as ht, i as mt } from "./shortId-WJVkrvml.js";
8
+ import { T as gt } from "./textarea-DNLrJoRl.js";
136
9
  const C = {
137
10
  TOP_LEFT: "tl",
138
11
  TOP_RIGHT: "tr",
139
12
  BOTTOM_LEFT: "bl",
140
13
  BOTTOM_RIGHT: "br"
141
14
  };
142
- function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w }) {
15
+ function pt({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w }) {
143
16
  const [T, c] = m({
144
- width: q,
145
- height: q
17
+ width: V,
18
+ height: V
146
19
  }), [S, D] = m({
147
20
  width: 0,
148
21
  height: 0
@@ -157,7 +30,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
157
30
  w: 0,
158
31
  h: 0,
159
32
  dir: ""
160
- }), { align: k } = t == null ? void 0 : t.attrs, g = P(() => {
33
+ }), { align: B } = t == null ? void 0 : t.attrs, g = P(() => {
161
34
  const { src: r, alt: p, width: f, height: b } = t == null ? void 0 : t.attrs, x = G(f) ? `${f}px` : f, a = G(b) ? `${b}px` : b;
162
35
  return {
163
36
  src: r || void 0,
@@ -173,7 +46,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
173
46
  } = g;
174
47
  return { width: r === "100%" ? r : void 0 };
175
48
  }, [g]);
176
- function B(r) {
49
+ function k(r) {
177
50
  D({
178
51
  width: r.target.width,
179
52
  height: r.target.height
@@ -183,13 +56,13 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
183
56
  e.commands.setNodeSelection(s());
184
57
  }
185
58
  const E = A(
186
- j(() => {
59
+ q(() => {
187
60
  const { width: r } = getComputedStyle(e.view.dom);
188
61
  c((p) => ({
189
62
  ...p,
190
63
  width: Number.parseInt(r, 10)
191
64
  }));
192
- }, V),
65
+ }, W),
193
66
  [e]
194
67
  );
195
68
  function F(r, p) {
@@ -206,15 +79,15 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
206
79
  });
207
80
  }
208
81
  const l = A(
209
- j((r) => {
82
+ q((r) => {
210
83
  if (r.preventDefault(), r.stopPropagation(), !o)
211
84
  return;
212
- const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ = ht(f + x, lt, T.width), W = Math.round($ / h);
85
+ const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ = X(f + x, ut, T.width), j = Math.round($ / h);
213
86
  i({
214
87
  width: $,
215
- height: W
88
+ height: j
216
89
  });
217
- }, V),
90
+ }, W),
218
91
  [o, L, T, i, t == null ? void 0 : t.attrs]
219
92
  ), u = A(
220
93
  (r) => {
@@ -239,10 +112,10 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
239
112
  return R(() => (M.observe(e.view.dom), () => {
240
113
  M.disconnect();
241
114
  }), [e.view.dom, M]), /* @__PURE__ */ n(
242
- U,
115
+ ot,
243
116
  {
244
117
  className: "image-view",
245
- style: { ...O, width: "100%", textAlign: k },
118
+ style: { ...O, width: "100%", textAlign: B },
246
119
  children: /* @__PURE__ */ H(
247
120
  "div",
248
121
  {
@@ -258,7 +131,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
258
131
  className: "image-view__body__image block",
259
132
  height: "auto",
260
133
  onClick: I,
261
- onLoad: B,
134
+ onLoad: k,
262
135
  src: g.src,
263
136
  style: g.style
264
137
  }
@@ -277,9 +150,107 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
277
150
  }
278
151
  );
279
152
  }
280
- const vt = /* @__PURE__ */ Y.extend({
153
+ const ft = `graph TB
154
+ a-->b`;
155
+ function At() {
156
+ const e = Z(), t = Y(vt.name), { tooltipOptions: i = {}, isActive: s = void 0, upload: w } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = J(s), [c, S] = m(ft), [D, y] = m(""), [o, _] = m(!1), L = dt(null), [d, B] = m(null), [g, O] = m(!0), k = A((l) => {
157
+ l && import("mermaid").then((u) => {
158
+ B(u.default);
159
+ }).finally(() => O(!1));
160
+ }, []), I = async (l) => {
161
+ try {
162
+ const { svg: u } = await d.render("mermaid-svg", l);
163
+ y(u);
164
+ } catch {
165
+ y("");
166
+ }
167
+ }, E = () => {
168
+ d.initialize({
169
+ darkMode: !1,
170
+ startOnLoad: !1,
171
+ // fontFamily:'',
172
+ fontSize: 12,
173
+ theme: "base"
174
+ }), I(c);
175
+ };
176
+ return R(() => {
177
+ !g && d && o && E();
178
+ }, [d, o]), R(() => {
179
+ !g && d && o && I(c);
180
+ }, [d && c]), /* @__PURE__ */ H(K, { onOpenChange: _, open: o, children: [
181
+ /* @__PURE__ */ n(Q, { asChild: !0, children: /* @__PURE__ */ n(
182
+ tt,
183
+ {
184
+ disabled: T,
185
+ icon: "Mermaid",
186
+ tooltip: "Mermaid",
187
+ tooltipOptions: i,
188
+ action: () => {
189
+ T || _(!0);
190
+ }
191
+ }
192
+ ) }),
193
+ /* @__PURE__ */ H(et, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
194
+ /* @__PURE__ */ n(rt, { children: "Mermaid" }),
195
+ /* @__PURE__ */ n("div", { ref: k, style: { height: "100%", border: "1px solid hsl(var(--border))" }, children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(ct, { children: /* @__PURE__ */ H("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
196
+ /* @__PURE__ */ n(
197
+ gt,
198
+ {
199
+ autoFocus: !0,
200
+ className: "richtext-flex-1",
201
+ onChange: (l) => S(l.target.value),
202
+ placeholder: "Text",
203
+ required: !0,
204
+ rows: 10,
205
+ value: c,
206
+ style: {
207
+ color: "hsl(var(--foreground))"
208
+ }
209
+ }
210
+ ),
211
+ /* @__PURE__ */ n(
212
+ "div",
213
+ {
214
+ className: "richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",
215
+ dangerouslySetInnerHTML: { __html: D },
216
+ ref: L,
217
+ style: {
218
+ height: "100%",
219
+ borderWidth: 1,
220
+ minHeight: 500,
221
+ background: "#fff"
222
+ }
223
+ }
224
+ )
225
+ ] }) }) }),
226
+ /* @__PURE__ */ n(it, { children: /* @__PURE__ */ n(at, { disabled: !d, onClick: async () => {
227
+ if (c !== "") {
228
+ if (c) {
229
+ const l = L.current.querySelector("svg"), { width: u, height: z } = l.getBoundingClientRect(), N = `mermaid-${ht()}.svg`;
230
+ let M = mt(l.outerHTML);
231
+ if (w) {
232
+ const r = st(M, N);
233
+ M = await w(r);
234
+ }
235
+ e == null || e.chain().focus().setMermaid(
236
+ {
237
+ type: "mermaid",
238
+ src: M,
239
+ alt: encodeURIComponent(c),
240
+ width: u,
241
+ height: z
242
+ },
243
+ !!c
244
+ ).run();
245
+ }
246
+ _(!1);
247
+ }
248
+ }, type: "button", children: "Save changes" }) })
249
+ ] })
250
+ ] });
251
+ }
252
+ const vt = /* @__PURE__ */ nt.extend({
281
253
  name: "mermaid",
282
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
283
254
  //@ts-expect-error
284
255
  addOptions() {
285
256
  var e;
@@ -345,7 +316,7 @@ const vt = /* @__PURE__ */ Y.extend({
345
316
  };
346
317
  },
347
318
  addNodeView() {
348
- return Z(ft);
319
+ return lt(pt);
349
320
  },
350
321
  // @ts-ignore
351
322
  addCommands() {
@@ -371,7 +342,7 @@ const vt = /* @__PURE__ */ Y.extend({
371
342
  },
372
343
  [
373
344
  "img",
374
- X(
345
+ U(
375
346
  // @ts-ignore
376
347
  this.options.HTMLAttributes,
377
348
  e
@@ -399,5 +370,5 @@ const vt = /* @__PURE__ */ Y.extend({
399
370
  });
400
371
  export {
401
372
  vt as Mermaid,
402
- Ot as RichTextMermaid
373
+ At as RichTextMermaid
403
374
  };
package/lib/MoreMark.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./clsx-CXbNJWDD.cjs"),r=require("react/jsx-runtime"),M=require("react"),x=require("./toggle-C_SSvDRy.cjs");require("./index-Cn-t3Zxw.cjs");require("./theme.cjs");const h=require("./useButtonProps-Cz4W5dC8.cjs"),p=require("./dropdown-menu-eUeBXQeA.cjs"),f=require("./index-VhKd73hZ.cjs"),S=require("./Icon-DzK0_ztP.cjs");var k=c.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),A=c.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function v(){const t=h.useButtonProps(b.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:u,dataState:o}=h.useActive(l),d=M.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(p.DropdownMenu,{children:[r.jsx(p.DropdownMenuTrigger,{asChild:!0,disabled:u,children:r.jsx(x.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(f.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(p.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,a)=>r.jsxs(p.DropdownMenuCheckboxItem,{checked:d===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(S.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:h.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${a}`))})]}):r.jsx(r.Fragment,{})}const b=c.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var a,g;const l=n.options.subscript,u=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((a=n.options.shortcutKeys)==null?void 0:a[0])??["mod","."]},d={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return l!==!1&&e.push(o),u!==!1&&e.push(d),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(m=>m.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(k.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(A.configure(this.options.superscript)),t}});exports.MoreMark=b;exports.RichTextMoreMark=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-zig3Dj7A.cjs"),r=require("react/jsx-runtime"),M=require("react"),c=require("./index-BUTn2LY6.cjs");require("./theme.cjs");const l=require("./dropdown-menu-oSKIntXM.cjs");var x=u.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",u.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),f=u.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",u.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function S(){const t=c.useButtonProps(m.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:d=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:a,dataState:o}=c.useActive(d),h=M.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(l.DropdownMenu,{children:[r.jsx(l.DropdownMenuTrigger,{asChild:!0,disabled:a,children:r.jsx(c.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:a,icon:s,tooltip:n,children:r.jsx(c.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(l.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,p)=>r.jsxs(l.DropdownMenuCheckboxItem,{checked:h===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(c.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:c.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${p}`))})]}):r.jsx(r.Fragment,{})}const m=u.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var p,g;const d=n.options.subscript,a=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((p=n.options.shortcutKeys)==null?void 0:p[0])??["mod","."]},h={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return d!==!1&&e.push(o),a!==!1&&e.push(h),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(b=>b.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(x.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(f.configure(this.options.superscript)),t}});exports.MoreMark=m;exports.RichTextMoreMark=S;