reactjs-tiptap-editor 1.0.17 → 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 (212) hide show
  1. package/lib/{ActionMenuButton-lsIBc9sU.js → ActionMenuButton-BOjCHFTA.js} +6 -6
  2. package/lib/ActionMenuButton-Df077oOH.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +40 -78
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +2 -3
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +2 -3
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +2 -3
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +105 -99
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +2 -3
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +2 -3
  17. package/lib/CodeBlock.cjs +38 -38
  18. package/lib/CodeBlock.js +1561 -1605
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +2 -2
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +46 -63
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +24 -10
  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 +69 -93
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +99 -110
  33. package/lib/ExportPdf.cjs +4 -4
  34. package/lib/ExportPdf.js +4 -13
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +9 -7
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +12 -34
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +12 -27
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +34 -47
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +39 -52
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +318 -313
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +2 -3
  49. package/lib/{Iframe-CTajPyzs.js → Iframe-AhNV5WH5.js} +25 -34
  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 -4
  55. package/lib/ImageGif.cjs +1 -1
  56. package/lib/ImageGif.js +63 -91
  57. package/lib/ImportWord.cjs +1 -1
  58. package/lib/ImportWord.js +7 -11
  59. package/lib/{Indent-BGEHlRx_.js → Indent-DZ5PcJA4.js} +3 -7
  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 +2 -3
  65. package/lib/Katex-CIC9ygbL.cjs +4 -0
  66. package/lib/{Katex-tMh4bfBb.js → Katex-bIgoenn_.js} +241 -255
  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 +13 -21
  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-CA5NhP-m.js → LinkEditBlock-D_cF9fnc.js} +320 -370
  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 +118 -142
  81. package/lib/MoreMark.cjs +1 -1
  82. package/lib/MoreMark.js +10 -18
  83. package/lib/OrderedList.cjs +1 -1
  84. package/lib/OrderedList.js +2 -3
  85. package/lib/SearchAndReplace.cjs +1 -1
  86. package/lib/SearchAndReplace.js +68 -133
  87. package/lib/SlashCommand.cjs +1 -1
  88. package/lib/SlashCommand.js +15 -14
  89. package/lib/{SlashCommandNodeView-CZoM3ZlS.cjs → SlashCommandNodeView-Ba03hlVZ.cjs} +1 -1
  90. package/lib/{SlashCommandNodeView-DLuqbX2o.js → SlashCommandNodeView-cg0x3NRF.js} +15 -17
  91. package/lib/Strike.cjs +1 -1
  92. package/lib/Strike.js +2 -3
  93. package/lib/{Table-BC4Lbqzn.js → Table-KqLiT5wG.js} +95 -133
  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 +2 -3
  99. package/lib/TextAlign.cjs +1 -1
  100. package/lib/TextAlign.js +51 -60
  101. package/lib/TextDirection.cjs +1 -1
  102. package/lib/TextDirection.js +47 -69
  103. package/lib/TextUnderline.cjs +1 -1
  104. package/lib/TextUnderline.js +2 -3
  105. package/lib/Twitter-BIiR78Jh.cjs +1 -0
  106. package/lib/{Twitter-D8Cbgl7g.js → Twitter-C1Lzqc7u.js} +567 -593
  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 +3 -3
  111. package/lib/bubble.cjs +6 -4
  112. package/lib/bubble.js +3712 -3023
  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/ui/checkbox.d.ts +1 -1
  119. package/lib/components/ui/dialog.d.ts +1 -1
  120. package/lib/components/ui/dropdown-menu.d.ts +1 -1
  121. package/lib/components/ui/emoji-picker.d.ts +1 -1
  122. package/lib/components/ui/label.d.ts +1 -1
  123. package/lib/components/ui/popover.d.ts +1 -1
  124. package/lib/components/ui/select.d.ts +1 -1
  125. package/lib/components/ui/separator.d.ts +1 -1
  126. package/lib/components/ui/switch.d.ts +1 -1
  127. package/lib/components/ui/tabs.d.ts +1 -1
  128. package/lib/components/ui/toast.d.ts +1 -1
  129. package/lib/components/ui/toggle.d.ts +1 -1
  130. package/lib/components/ui/tooltip.d.ts +1 -1
  131. package/lib/{delete-node-IyVmiRbI.js → delete-node-eQHsyyhR.js} +3 -1
  132. package/lib/{dropdown-menu-q6RL_fkA.js → dropdown-menu-CexIkt_V.js} +8 -8
  133. package/lib/{dropdown-menu-C_F7LEy5.cjs → dropdown-menu-oSKIntXM.cjs} +1 -1
  134. package/lib/extensions/Blockquote/Blockquote.d.ts +1 -1
  135. package/lib/extensions/Bold/Bold.d.ts +1 -1
  136. package/lib/extensions/Code/Code.d.ts +1 -1
  137. package/lib/extensions/CodeView/CodeView.d.ts +2 -2
  138. package/lib/extensions/Heading/Heading.d.ts +1 -1
  139. package/lib/extensions/Highlight/Highlight.d.ts +1 -1
  140. package/lib/extensions/HorizontalRule/HorizontalRule.d.ts +1 -1
  141. package/lib/extensions/ImportWord/ImportWord.d.ts +2 -2
  142. package/lib/extensions/Italic/Italic.d.ts +1 -1
  143. package/lib/extensions/Link/Link.d.ts +1 -1
  144. package/lib/extensions/MarkdownPaste/MarkdownPaste.d.ts +5 -0
  145. package/lib/extensions/MarkdownPaste/index.d.ts +1 -0
  146. package/lib/extensions/Mermaid/Mermaid.d.ts +1 -1
  147. package/lib/extensions/MoreMark/MoreMark.d.ts +1 -1
  148. package/lib/extensions/Strike/Strike.d.ts +1 -1
  149. package/lib/extensions/Table/Table.d.ts +1 -1
  150. package/lib/extensions/TextAlign/TextAlign.d.ts +1 -1
  151. package/lib/extensions/TextUnderline/TextUnderline.d.ts +1 -1
  152. package/lib/index-BUTn2LY6.cjs +1 -0
  153. package/lib/{index-C07N8gA1.js → index-BlXGgvT-.js} +21 -18
  154. package/lib/{index-DqruLhsu.js → index-BnW6t8z6.js} +23 -23
  155. package/lib/{index-BsFvo9PG.cjs → index-BqL4vAWE.cjs} +1 -1
  156. package/lib/index-BtxvYLJ1.cjs +12 -0
  157. package/lib/{index-Do_dsOGB.js → index-C6xmkxrQ.js} +232 -217
  158. package/lib/index-CJ9pyCM4.cjs +1 -0
  159. package/lib/{index-neeeY2o7.cjs → index-D0lc95kr.cjs} +3 -3
  160. package/lib/{index-RcSPeQHn.js → index-DHUN85fV.js} +571 -657
  161. package/lib/index-DUpSE1Gb.cjs +1 -0
  162. package/lib/index-D_8P0LE5.js +1362 -0
  163. package/lib/{index-BDYJ8Ph2.js → index-RIXs7STX.js} +1 -1
  164. package/lib/index-mfGK4pFo.js +6469 -0
  165. package/lib/index-zig3Dj7A.cjs +22 -0
  166. package/lib/index.cjs +1 -1
  167. package/lib/index.js +26 -34
  168. package/lib/locale-bundle.cjs +1 -1
  169. package/lib/locale-bundle.js +1 -1
  170. package/lib/plugins/image-upload.d.ts +1 -1
  171. package/lib/popover-BYSZ3zBi.js +24 -0
  172. package/lib/popover-BcHDZqBt.cjs +1 -0
  173. package/lib/{renderNodeView-BEkECnnY.js → renderNodeView-BrM5kUj_.js} +2 -2
  174. package/lib/{renderNodeView-DfLmGrgA.cjs → renderNodeView-D1zydtli.cjs} +1 -1
  175. package/lib/{select-CmV5uTXr.js → select-C5SHDLFj.js} +8 -5
  176. package/lib/{select-CYyIeImH.cjs → select-DHjzKkcu.cjs} +1 -1
  177. package/lib/{separator-BLp6xpSY.cjs → separator-BmixLrnJ.cjs} +1 -1
  178. package/lib/separator-CFKVxAea.js +293 -0
  179. package/lib/store/editor.d.ts +1 -1
  180. package/lib/store/store.d.ts +1 -1
  181. package/lib/style.css +1 -1
  182. package/lib/{textarea-Cn75Cm2n.cjs → textarea-CasDcv3u.cjs} +1 -1
  183. package/lib/{textarea-CkVKMPqK.js → textarea-DNLrJoRl.js} +1 -1
  184. package/lib/theme.js +1 -1
  185. package/lib/types.d.ts +3 -3
  186. package/lib/updatePosition-CBRjbQMH.js +16 -0
  187. package/lib/updatePosition-CfmY5Trk.cjs +1 -0
  188. package/lib/utils/columns.d.ts +1 -1
  189. package/lib/utils/pdf.d.ts +1 -1
  190. package/lib/utils/utils.d.ts +1 -1
  191. package/package.json +262 -247
  192. package/lib/ActionMenuButton-B_E2mbAW.cjs +0 -1
  193. package/lib/Drawer-DQ4CxBwG.js +0 -1373
  194. package/lib/Drawer-FUeUKshi.cjs +0 -1
  195. package/lib/Iframe-EVWXCqe4.cjs +0 -1
  196. package/lib/Indent-q9cEWAa_.cjs +0 -1
  197. package/lib/Katex-ClqcEnN_.cjs +0 -4
  198. package/lib/LinkEditBlock-DZXk4ln_.cjs +0 -5
  199. package/lib/Table-BmDopO43.cjs +0 -9
  200. package/lib/Twitter-BbMD3Ybp.cjs +0 -1
  201. package/lib/clsx-CXbNJWDD.cjs +0 -54
  202. package/lib/clsx-DaPvp9ji.js +0 -7391
  203. package/lib/index-BCzvbrf5.cjs +0 -12
  204. package/lib/index-BnVcq33n.cjs +0 -1
  205. package/lib/index-CjhjjJsN.cjs +0 -1
  206. package/lib/index-Cs6cp0Y6.cjs +0 -1
  207. package/lib/index-Qcl3BG94.js +0 -1351
  208. package/lib/popover-CtinPbiy.js +0 -24
  209. package/lib/popover-DIMT3pae.cjs +0 -1
  210. package/lib/separator-C7luvaG8.js +0 -327
  211. package/lib/updatePosition-Cjuj2E26.cjs +0 -1
  212. package/lib/updatePosition-DRmKQBGm.js +0 -16
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-DaPvp9ji.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-Qcl3BG94.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-BEkECnnY.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 W=Object.create;var B=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var Y=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of X(e))!Z.call(t,c)&&c!==r&&B(t,c,{get:()=>e[c],enumerable:!(a=V(e,c))||a.enumerable});return t};var J=(t,e,r)=>(r=t!=null?W(U(t)):{},Y(e||!t||!t.__esModule?B(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./clsx-CXbNJWDD.cjs"),l=require("./index-BnVcq33n.cjs"),o=require("react/jsx-runtime"),s=require("react"),G=require("./shortId-Bfj8TyNr.cjs"),K=require("./textarea-Cn75Cm2n.cjs"),L=require("./index-BsFvo9PG.cjs"),Q=`graph TB
2
- a-->b`;function ee(){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,C]=s.useState(Q),[z,_]=s.useState(""),[u,I]=s.useState(!1),A=s.useRef(null),[g,k]=s.useState(null),[p,O]=s.useState(!0),q=s.useCallback(d=>{d&&import("mermaid").then(m=>{k(m.default)}).finally(()=>O(!1))},[]),S=async d=>{try{const{svg:m}=await g.render("mermaid-svg",d);_(m)}catch{_("")}},R=()=>{g.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),S(h)};s.useEffect(()=>{!p&&g&&u&&R()},[g,u]),s.useEffect(()=>{!p&&g&&u&&S(h)},[g&&h]);const D=async()=>{if(h!==""){if(h){const d=A.current.querySelector("svg"),{width:m,height:j}=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:j},!!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:q,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(K.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:d=>C(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:z},ref:A,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(l.DialogFooter,{children:o.jsx(l.Button,{disabled:!g,onClick:D,type:"button",children:"Save changes"})})]})]})}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({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}),[C,z]=s.useState({width:0,height:0}),[_]=s.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[u,I]=s.useState(!1),[A,g]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:k}=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=N.isNumber(M)?`${M}px`:M,n=N.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]),O=s.useMemo(()=>{const{style:{width:i}}=p;return{width:i==="100%"?i:void 0}},[p]);function q(i){z({width:i.target.width,height:i.target.height})}function S(){t.commands.setNodeSelection(a())}const R=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 D(i,x){i.preventDefault(),i.stopPropagation();const M=C.width,w=C.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),$=Math.round(P/f);r({width:P,height:$})},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]),j=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?j():E(),()=>{E()}),[u,j,E]);const v=s.useMemo(()=>new ResizeObserver(()=>R()),[R]);return s.useEffect(()=>(v.observe(t.view.dom),()=>{v.disconnect()}),[t.view.dom,v]),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 ${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:q,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=>D(x,i)},`image-dir-${i}`))})]})})}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 N.ReactNodeViewRenderer(te)},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=F;exports.RichTextMermaid=ee;
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,140 +1,18 @@
1
- import { h as U, u as G, m as X, k as Z } from "./clsx-DaPvp9ji.js";
2
- import { h as Y, u as J, d as K, D as Q, m as tt, A as et, n as rt, o as it, p as at, B as st, v as nt, w as q, x as ot, y as lt } from "./index-RcSPeQHn.js";
3
- import { jsxs as H, jsx as n, Fragment as ct } from "react/jsx-runtime";
4
- import { useState as m, useRef as dt, useCallback as A, useEffect as R, useMemo as P } from "react";
5
- import { s as ut, i as ht } from "./shortId-WJVkrvml.js";
6
- import { T as mt } from "./textarea-CkVKMPqK.js";
7
- import { I as V, i as W, j as gt } from "./index-C07N8gA1.js";
8
- const pt = `graph TB
9
- a-->b`;
10
- function It() {
11
- const e = Y(), t = J(vt.name), {
12
- tooltipOptions: i = {},
13
- isActive: s = void 0,
14
- upload: w
15
- } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = K(s), [c, S] = m(pt), [D, y] = m(""), [o, _] = m(!1), L = dt(null), [d, k] = m(null), [g, O] = m(!0), B = A(
16
- (l) => {
17
- l && import("mermaid").then((u) => {
18
- k(u.default);
19
- }).finally(() => O(!1));
20
- },
21
- []
22
- ), I = async (l) => {
23
- try {
24
- const { svg: u } = await d.render("mermaid-svg", l);
25
- y(u);
26
- } catch {
27
- y("");
28
- }
29
- }, E = () => {
30
- d.initialize({
31
- darkMode: !1,
32
- startOnLoad: !1,
33
- // fontFamily:'',
34
- fontSize: 12,
35
- theme: "base"
36
- }), I(c);
37
- };
38
- return R(() => {
39
- !g && d && o && E();
40
- }, [d, o]), R(() => {
41
- !g && d && o && I(c);
42
- }, [d && c]), /* @__PURE__ */ H(
43
- Q,
44
- {
45
- onOpenChange: _,
46
- open: o,
47
- children: [
48
- /* @__PURE__ */ n(tt, { asChild: !0, children: /* @__PURE__ */ n(
49
- et,
50
- {
51
- disabled: T,
52
- icon: "Mermaid",
53
- tooltip: "Mermaid",
54
- tooltipOptions: i,
55
- action: () => {
56
- T || _(!0);
57
- }
58
- }
59
- ) }),
60
- /* @__PURE__ */ H(rt, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
61
- /* @__PURE__ */ n(it, { children: "Mermaid" }),
62
- /* @__PURE__ */ n(
63
- "div",
64
- {
65
- ref: B,
66
- style: { height: "100%", border: "1px solid hsl(var(--border))" },
67
- 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: [
68
- /* @__PURE__ */ n(
69
- mt,
70
- {
71
- autoFocus: !0,
72
- className: "richtext-flex-1",
73
- onChange: (l) => S(l.target.value),
74
- placeholder: "Text",
75
- required: !0,
76
- rows: 10,
77
- value: c,
78
- style: {
79
- color: "hsl(var(--foreground))"
80
- }
81
- }
82
- ),
83
- /* @__PURE__ */ n(
84
- "div",
85
- {
86
- className: "richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",
87
- dangerouslySetInnerHTML: { __html: D },
88
- ref: L,
89
- style: { height: "100%", borderWidth: 1, minHeight: 500, background: "#fff" }
90
- }
91
- )
92
- ] }) })
93
- }
94
- ),
95
- /* @__PURE__ */ n(at, { children: /* @__PURE__ */ n(
96
- st,
97
- {
98
- disabled: !d,
99
- onClick: async () => {
100
- if (c !== "") {
101
- if (c) {
102
- const l = L.current.querySelector("svg"), { width: u, height: z } = l.getBoundingClientRect(), N = `mermaid-${ut()}.svg`;
103
- let M = ht(l.outerHTML);
104
- if (w) {
105
- const r = nt(M, N);
106
- M = await w(r);
107
- }
108
- e == null || e.chain().focus().setMermaid(
109
- {
110
- type: "mermaid",
111
- src: M,
112
- alt: encodeURIComponent(c),
113
- width: u,
114
- height: z
115
- },
116
- !!c
117
- ).run();
118
- }
119
- _(!1);
120
- }
121
- },
122
- type: "button",
123
- children: "Save changes"
124
- }
125
- ) })
126
- ] })
127
- ]
128
- }
129
- );
130
- }
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";
131
9
  const C = {
132
10
  TOP_LEFT: "tl",
133
11
  TOP_RIGHT: "tr",
134
12
  BOTTOM_LEFT: "bl",
135
13
  BOTTOM_RIGHT: "br"
136
14
  };
137
- 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 }) {
138
16
  const [T, c] = m({
139
17
  width: V,
140
18
  height: V
@@ -152,7 +30,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
152
30
  w: 0,
153
31
  h: 0,
154
32
  dir: ""
155
- }), { align: k } = t == null ? void 0 : t.attrs, g = P(() => {
33
+ }), { align: B } = t == null ? void 0 : t.attrs, g = P(() => {
156
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;
157
35
  return {
158
36
  src: r || void 0,
@@ -168,7 +46,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
168
46
  } = g;
169
47
  return { width: r === "100%" ? r : void 0 };
170
48
  }, [g]);
171
- function B(r) {
49
+ function k(r) {
172
50
  D({
173
51
  width: r.target.width,
174
52
  height: r.target.height
@@ -204,7 +82,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
204
82
  q((r) => {
205
83
  if (r.preventDefault(), r.stopPropagation(), !o)
206
84
  return;
207
- 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, $ = ot(f + x, gt, T.width), j = 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);
208
86
  i({
209
87
  width: $,
210
88
  height: j
@@ -234,10 +112,10 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
234
112
  return R(() => (M.observe(e.view.dom), () => {
235
113
  M.disconnect();
236
114
  }), [e.view.dom, M]), /* @__PURE__ */ n(
237
- U,
115
+ ot,
238
116
  {
239
117
  className: "image-view",
240
- style: { ...O, width: "100%", textAlign: k },
118
+ style: { ...O, width: "100%", textAlign: B },
241
119
  children: /* @__PURE__ */ H(
242
120
  "div",
243
121
  {
@@ -253,7 +131,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
253
131
  className: "image-view__body__image block",
254
132
  height: "auto",
255
133
  onClick: I,
256
- onLoad: B,
134
+ onLoad: k,
257
135
  src: g.src,
258
136
  style: g.style
259
137
  }
@@ -272,9 +150,107 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
272
150
  }
273
151
  );
274
152
  }
275
- const vt = /* @__PURE__ */ lt.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({
276
253
  name: "mermaid",
277
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
278
254
  //@ts-expect-error
279
255
  addOptions() {
280
256
  var e;
@@ -340,7 +316,7 @@ const vt = /* @__PURE__ */ lt.extend({
340
316
  };
341
317
  },
342
318
  addNodeView() {
343
- return Z(ft);
319
+ return lt(pt);
344
320
  },
345
321
  // @ts-ignore
346
322
  addCommands() {
@@ -366,7 +342,7 @@ const vt = /* @__PURE__ */ lt.extend({
366
342
  },
367
343
  [
368
344
  "img",
369
- X(
345
+ U(
370
346
  // @ts-ignore
371
347
  this.options.HTMLAttributes,
372
348
  e
@@ -394,5 +370,5 @@ const vt = /* @__PURE__ */ lt.extend({
394
370
  });
395
371
  export {
396
372
  vt as Mermaid,
397
- It as RichTextMermaid
373
+ At as RichTextMermaid
398
374
  };
package/lib/MoreMark.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./clsx-CXbNJWDD.cjs"),e=require("react/jsx-runtime"),M=require("react"),c=require("./index-BnVcq33n.cjs");require("./theme.cjs");const l=require("./dropdown-menu-C_F7LEy5.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?e.jsxs(l.DropdownMenu,{children:[e.jsx(l.DropdownMenuTrigger,{asChild:!0,disabled:a,children:e.jsx(c.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:a,icon:s,tooltip:n,children:e.jsx(c.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),e.jsx(l.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((r,p)=>e.jsxs(l.DropdownMenuCheckboxItem,{checked:h===r.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:r.action,children:[e.jsx(c.IconComponent,{name:r==null?void 0:r.icon}),e.jsx("span",{className:"richtext-ml-1",children:r.title}),!!(r!=null&&r.shortcutKeys)&&e.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:c.getShortcutKeys(r.shortcutKeys)})]},`more-mark-${p}`))})]}):e.jsx(e.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",","]},r=[];return d!==!1&&r.push(o),a!==!1&&r.push(h),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:r,isActive:()=>r==null?void 0:r.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;
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;
package/lib/MoreMark.js CHANGED
@@ -1,9 +1,9 @@
1
- import { M as h, m, E as b } from "./clsx-DaPvp9ji.js";
1
+ import { M as h, m, E as b } from "./index-mfGK4pFo.js";
2
2
  import { jsx as e, Fragment as M, jsxs as d } from "react/jsx-runtime";
3
3
  import { useMemo as f } from "react";
4
- import { u as x, e as A, A as S, M as k, I as v, g as y } from "./index-RcSPeQHn.js";
4
+ import { u as x, e as A, A as S, M as k, I as v, g as y } from "./index-DHUN85fV.js";
5
5
  import "./theme.js";
6
- import { D as T, a as K, b as w, c as C } from "./dropdown-menu-q6RL_fkA.js";
6
+ import { D as T, a as K, b as w, c as C } from "./dropdown-menu-CexIkt_V.js";
7
7
  var H = h.create({
8
8
  name: "subscript",
9
9
  addOptions() {
@@ -83,23 +83,16 @@ function z() {
83
83
  isActive: a = void 0
84
84
  } = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } = A(a), p = f(() => (o == null ? void 0 : o.title) || "", [o]);
85
85
  return t ? /* @__PURE__ */ d(T, { children: [
86
- /* @__PURE__ */ e(
87
- K,
86
+ /* @__PURE__ */ e(K, { asChild: !0, disabled: c, children: /* @__PURE__ */ e(
87
+ S,
88
88
  {
89
- asChild: !0,
89
+ customClass: "!richtext-w-12 richtext-h-12",
90
90
  disabled: c,
91
- children: /* @__PURE__ */ e(
92
- S,
93
- {
94
- customClass: "!richtext-w-12 richtext-h-12",
95
- disabled: c,
96
- icon: s,
97
- tooltip: n,
98
- children: /* @__PURE__ */ e(k, { className: "richtext-size-3 richtext-text-gray-500" })
99
- }
100
- )
91
+ icon: s,
92
+ tooltip: n,
93
+ children: /* @__PURE__ */ e(k, { className: "richtext-size-3 richtext-text-gray-500" })
101
94
  }
102
- ),
95
+ ) }),
103
96
  /* @__PURE__ */ e(w, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
104
97
  C,
105
98
  {
@@ -118,7 +111,6 @@ function z() {
118
111
  }
119
112
  const D = /* @__PURE__ */ b.create({
120
113
  name: "moreMark",
121
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
122
114
  //@ts-expect-error
123
115
  addOptions() {
124
116
  var t;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-BCzvbrf5.cjs"),r=require("react/jsx-runtime"),s=require("./index-BnVcq33n.cjs");require("react");require("./theme.cjs");function O(){const t=s.useButtonProps(c.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:o=void 0,tooltipOptions:u={},action:n=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:d,update:l}=s.useToggleActive(a),m=()=>{d||n&&(n(),l())};return t?r.jsx(s.ActionButton,{action:m,dataState:p,disabled:d,icon:e,shortcutKeys:o,tooltip:i,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=v.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:o})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:o.options.shortcutKeys??["mod","shift","7"],tooltip:i("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-BtxvYLJ1.cjs"),r=require("react/jsx-runtime"),s=require("./index-BUTn2LY6.cjs");require("react");require("./theme.cjs");function O(){const t=s.useButtonProps(c.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:o=void 0,tooltipOptions:u={},action:n=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:d,update:l}=s.useToggleActive(a),m=()=>{d||n&&(n(),l())};return t?r.jsx(s.ActionButton,{action:m,dataState:p,disabled:d,icon:e,shortcutKeys:o,tooltip:i,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=v.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:o})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:o.options.shortcutKeys??["mod","shift","7"],tooltip:i("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=O;
@@ -1,6 +1,6 @@
1
- import { O as u } from "./index-Do_dsOGB.js";
1
+ import { O as u } from "./index-C6xmkxrQ.js";
2
2
  import { jsx as n, Fragment as l } from "react/jsx-runtime";
3
- import { u as f, d as v, A as O } from "./index-RcSPeQHn.js";
3
+ import { u as f, d as v, A as O } from "./index-DHUN85fV.js";
4
4
  import "react";
5
5
  import "./theme.js";
6
6
  function K() {
@@ -28,7 +28,6 @@ function K() {
28
28
  ) : /* @__PURE__ */ n(l, {});
29
29
  }
30
30
  const A = /* @__PURE__ */ u.extend({
31
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
31
  //@ts-expect-error
33
32
  addOptions() {
34
33
  var t;