reactjs-tiptap-editor 0.3.31 → 0.4.1

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 (275) hide show
  1. package/README.md +8 -2
  2. package/lib/{ActionMenuButton-BCgqJsST.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
  3. package/lib/{ActionMenuButton-D97K0UWT.js → ActionMenuButton-DKRF6oa0.js} +1 -1
  4. package/lib/Attachment.cjs +2 -2
  5. package/lib/Attachment.d.cts +25 -29
  6. package/lib/Attachment.d.ts +25 -29
  7. package/lib/Attachment.js +7 -6
  8. package/lib/BaseKit.cjs +3 -0
  9. package/lib/BaseKit.d.cts +481 -0
  10. package/lib/BaseKit.d.ts +481 -0
  11. package/lib/BaseKit.js +132 -0
  12. package/lib/Blockquote.cjs +5 -1
  13. package/lib/Blockquote.d.cts +25 -29
  14. package/lib/Blockquote.d.ts +25 -29
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +25 -29
  18. package/lib/Bold.d.ts +25 -29
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +26 -30
  22. package/lib/BulletList.d.ts +26 -30
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +25 -29
  26. package/lib/Clear.d.ts +25 -29
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +25 -29
  30. package/lib/Code.d.ts +25 -29
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +25 -29
  34. package/lib/CodeBlock.d.ts +25 -29
  35. package/lib/CodeBlock.js +3 -3
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +25 -29
  38. package/lib/CodeView.d.ts +25 -29
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +26 -30
  42. package/lib/Color.d.ts +26 -30
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +25 -29
  46. package/lib/Document.d.ts +25 -29
  47. package/lib/Document.js +4 -8
  48. package/lib/{Drawer-BHkje8ys.js → Drawer-CaAfmqNo.js} +37 -35
  49. package/lib/{Drawer-5Q_-WRhc.cjs → Drawer-CdvCMSzN.cjs} +1 -1
  50. package/lib/Drawer.cjs +1 -1
  51. package/lib/Drawer.d.cts +25 -29
  52. package/lib/Drawer.d.ts +25 -29
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +28 -30
  56. package/lib/Emoji.d.ts +28 -30
  57. package/lib/Emoji.js +19795 -184
  58. package/lib/{Excalidraw-GUVW-IqC.cjs → Excalidraw-BbMQhNvs.cjs} +1 -1
  59. package/lib/{Excalidraw-CG498239.js → Excalidraw-CVWz2Vyn.js} +20 -20
  60. package/lib/Excalidraw.cjs +1 -1
  61. package/lib/Excalidraw.d.cts +25 -29
  62. package/lib/Excalidraw.d.ts +25 -29
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +25 -29
  66. package/lib/ExportPdf.d.ts +25 -29
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +25 -29
  70. package/lib/ExportWord.d.ts +25 -29
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +26 -30
  74. package/lib/FontFamily.d.ts +26 -30
  75. package/lib/FontFamily.js +44 -73
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +25 -29
  78. package/lib/FontSize.d.ts +25 -29
  79. package/lib/FontSize.js +7 -5
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +25 -29
  82. package/lib/FormatPainter.d.ts +25 -29
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +25 -29
  86. package/lib/Heading.d.ts +25 -29
  87. package/lib/Heading.js +71 -60
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +25 -29
  90. package/lib/Highlight.d.ts +25 -29
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +27 -31
  94. package/lib/History.d.ts +27 -31
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +25 -29
  98. package/lib/HorizontalRule.d.ts +25 -29
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +25 -29
  102. package/lib/Iframe.d.ts +25 -29
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +25 -29
  106. package/lib/Image.d.ts +25 -29
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +25 -29
  110. package/lib/ImageGif.d.ts +25 -29
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +25 -29
  114. package/lib/ImportWord.d.ts +25 -29
  115. package/lib/ImportWord.js +5652 -5615
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +25 -29
  118. package/lib/Indent.d.ts +25 -29
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +25 -29
  122. package/lib/Italic.d.ts +25 -29
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +25 -29
  126. package/lib/Katex.d.ts +25 -29
  127. package/lib/Katex.js +12 -12
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +25 -29
  130. package/lib/LineHeight.d.ts +25 -29
  131. package/lib/LineHeight.js +5 -3
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +25 -29
  134. package/lib/Link.d.ts +25 -29
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +30 -30
  138. package/lib/ListItem.d.ts +30 -30
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +25 -29
  142. package/lib/Mention.d.ts +25 -29
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +25 -29
  146. package/lib/Mermaid.d.ts +25 -29
  147. package/lib/Mermaid.js +50 -48
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +25 -29
  150. package/lib/MoreMark.d.ts +25 -29
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +25 -29
  154. package/lib/MultiColumn.d.ts +25 -29
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +26 -30
  158. package/lib/OrderedList.d.ts +26 -30
  159. package/lib/OrderedList.js +11 -75
  160. package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
  161. package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
  162. package/lib/SearchAndReplace.cjs +1 -1
  163. package/lib/SearchAndReplace.d.cts +38 -112
  164. package/lib/SearchAndReplace.d.ts +38 -112
  165. package/lib/SearchAndReplace.js +204 -192
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +25 -29
  168. package/lib/Selection.d.ts +25 -29
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +25 -29
  172. package/lib/SlashCommand.d.ts +25 -29
  173. package/lib/SlashCommand.js +178 -223
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +25 -29
  176. package/lib/Strike.d.ts +25 -29
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +25 -29
  180. package/lib/SubAndSuperScript.d.ts +25 -29
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +28 -32
  184. package/lib/Table.d.ts +28 -32
  185. package/lib/Table.js +382 -2022
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +25 -29
  188. package/lib/TableOfContent.d.ts +25 -29
  189. package/lib/TableOfContent.js +5 -5
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +27 -31
  192. package/lib/TaskList.d.ts +27 -31
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +25 -29
  196. package/lib/TextAlign.d.ts +25 -29
  197. package/lib/TextAlign.js +11 -9
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +25 -29
  200. package/lib/TextBubble.d.ts +25 -29
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +25 -29
  204. package/lib/TextDirection.d.ts +25 -29
  205. package/lib/TextDirection.js +2 -3
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +25 -29
  208. package/lib/TextUnderline.d.ts +25 -29
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +25 -29
  212. package/lib/TrailingNode.d.ts +25 -29
  213. package/lib/TrailingNode.js +1 -1
  214. package/lib/Twitter-BFULyqdR.js +1628 -0
  215. package/lib/Twitter-Cutpkh3h.cjs +1 -0
  216. package/lib/Twitter.cjs +1 -1
  217. package/lib/Twitter.d.cts +25 -29
  218. package/lib/Twitter.d.ts +25 -29
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +25 -29
  222. package/lib/Video.d.ts +25 -29
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +25 -29
  226. package/lib/bubble-extra.d.ts +25 -29
  227. package/lib/bubble-extra.js +200 -192
  228. package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
  229. package/lib/dom-dataset-lYeH6gfI.js +2361 -0
  230. package/lib/index-5iBZLua9.cjs +12 -0
  231. package/lib/index-6D1J-A-o.cjs +1 -0
  232. package/lib/index-B96Cclrj.cjs +3 -0
  233. package/lib/index-BBz7Nmv9.js +55 -0
  234. package/lib/index-BeCTd5v2.cjs +1 -0
  235. package/lib/index-ByurDDMv.js +237 -0
  236. package/lib/index-CUogRI7j.cjs +1 -0
  237. package/lib/index-Ch6dBBad.js +709 -0
  238. package/lib/index-DF2Lp4HZ.cjs +100 -0
  239. package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
  240. package/lib/index-Dbvi-Bvh.cjs +1 -0
  241. package/lib/index-DpCrt7xs.cjs +1 -0
  242. package/lib/index-DsAX1Vq8.cjs +1 -0
  243. package/lib/index-Dy4DlW9o.js +12 -0
  244. package/lib/index-J3jHHZ4d.js +200 -0
  245. package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
  246. package/lib/index-VvXaaKe3.js +898 -0
  247. package/lib/index-kbO3iWqL.js +13432 -0
  248. package/lib/index.cjs +1 -2
  249. package/lib/index.d.cts +26 -229
  250. package/lib/index.d.ts +26 -229
  251. package/lib/index.js +2 -588
  252. package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
  253. package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
  254. package/lib/locale-bundle.cjs +1 -1
  255. package/lib/locale-bundle.d.cts +25 -29
  256. package/lib/locale-bundle.d.ts +25 -29
  257. package/lib/locale-bundle.js +1 -1
  258. package/lib/style.css +1 -1
  259. package/lib/{textarea-DdH64g04.cjs → textarea-DFo_aXnj.cjs} +1 -1
  260. package/lib/{textarea-CktfkXNe.js → textarea-aPtytkDx.js} +1 -1
  261. package/package.json +76 -70
  262. package/lib/RichTextEditor-DWlLqTl9.cjs +0 -140
  263. package/lib/RichTextEditor-KP2Rgcqe.js +0 -12751
  264. package/lib/Twitter-99ivY5qv.js +0 -1744
  265. package/lib/Twitter-BvfvUtNT.cjs +0 -17
  266. package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
  267. package/lib/dom-dataset-Di3tIRrR.js +0 -1031
  268. package/lib/index-BI-IcZcN.cjs +0 -1
  269. package/lib/index-ByRfqzMr.cjs +0 -89
  270. package/lib/index-C1fzuXpN.js +0 -46
  271. package/lib/index-CbQQFj2T.js +0 -133
  272. package/lib/index-DI9T3iLd.js +0 -12354
  273. package/lib/index-D_A0TBRA.cjs +0 -1
  274. package/lib/index-DclQSrIx.cjs +0 -1
  275. package/lib/index-Z4b9rzn-.cjs +0 -1
package/lib/index.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("react"),C=require("./RichTextEditor-DWlLqTl9.cjs"),x=require("./dom-dataset-Byuf1YmW.cjs"),a=require("./index-ByRfqzMr.cjs"),b=require("./ListItem.cjs"),S=require("./index-DclQSrIx.cjs"),v=require("./Document.cjs"),k=require("./Selection.cjs"),P=require("./TextBubble.cjs"),M=require("./TrailingNode.cjs"),m=require("./index-D_A0TBRA.cjs");function T(){var l;const t=p.useRef({editor:null}),[e,i]=p.useState(!1),[o,r]=p.useState(null);return p.useEffect(()=>{var s;(s=t.current)!=null&&s.editor&&(i(!0),r(t.current.editor))},[t,(l=t.current)==null?void 0:l.editor]),{isReady:e,editor:o,editorRef:t}}const E=a.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const o=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(o)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,i=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(i)}},addProseMirrorPlugins(){let t=!1;return[new a.Plugin({key:new a.PluginKey("characterCount"),appendTransaction:(e,i,o)=>{if(t)return;const r=this.options.limit;if(r==null||r===0){t=!0;return}const l=this.storage.characters({node:o.doc});if(l>r){const s=l-r,n=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const u=o.tr.deleteRange(n,c);return t=!0,u}t=!0},filterTransaction:(e,i)=>{const o=this.options.limit;if(!e.docChanged||o===0||o===null||o===void 0)return!0;const r=this.storage.characters({node:i.doc}),l=this.storage.characters({node:e.doc});if(l<=o||r>o&&l>o&&l<=r)return!0;if(r>o&&l>o&&l>r||!e.getMeta("paste"))return!1;const n=e.selection.$head.pos,c=l-o,u=n-c,h=n;return e.deleteRange(u,h),!(this.storage.characters({node:e.doc})>o)}})]}});function A(t={}){return new a.Plugin({view(e){return new O(e,t)}})}class O{constructor(e,i){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(o=i.width)!==null&&o!==void 0?o:1,this.color=i.color===!1?void 0:i.color||"black",this.class=i.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let l=s=>{this[r](s)};return e.dom.addEventListener(r,l),{name:r,handler:l}})}destroy(){this.handlers.forEach(({name:e,handler:i})=>this.editorView.dom.removeEventListener(e,i))}update(e,i){this.cursorPos!=null&&i.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),i=!e.parent.inlineContent,o;if(i){let n=e.nodeBefore,c=e.nodeAfter;if(n||c){let u=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(u){let h=u.getBoundingClientRect(),f=n?h.bottom:h.top;n&&c&&(f=(f+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),o={left:h.left,right:h.right,top:f-this.width/2,bottom:f+this.width/2}}}}if(!o){let n=this.editorView.coordsAtPos(this.cursorPos);o={left:n.left-this.width/2,right:n.left+this.width/2,top:n.top,bottom:n.bottom}}let r=this.editorView.dom.offsetParent;this.element||(this.element=r.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",i),this.element.classList.toggle("prosemirror-dropcursor-inline",!i);let l,s;if(!r||r==document.body&&getComputedStyle(r).position=="static")l=-pageXOffset,s=-pageYOffset;else{let n=r.getBoundingClientRect();l=n.left-r.scrollLeft,s=n.top-r.scrollTop}this.element.style.left=o.left-l+"px",this.element.style.top=o.top-s+"px",this.element.style.width=o.right-o.left+"px",this.element.style.height=o.bottom-o.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let i=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),o=i&&i.inside>=0&&this.editorView.state.doc.nodeAt(i.inside),r=o&&o.type.spec.disableDropCursor,l=typeof r=="function"?r(this.editorView,i,e):r;if(i&&!l){let s=i.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let n=a.dropPoint(this.editorView.state.doc,s,this.editorView.dragging.slice);n!=null&&(s=n)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const B=a.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[A(this.options)]}}),N=a.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new a.Plugin({key:new a.PluginKey("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:i,isFocused:o}=this.editor,{anchor:r}=e,l=[];if(!i||!o)return a.DecorationSet.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(r>=u&&r<=u+c.nodeSize-1))return!1;s+=1});let n=0;return t.descendants((c,u)=>{if(c.isText||!(r>=u&&r<=u+c.nodeSize-1))return!1;if(n+=1,this.options.mode==="deepest"&&s-n>0||this.options.mode==="shallowest"&&n>1)return this.options.mode==="deepest";l.push(a.Decoration.node(u,u+c.nodeSize,{class:this.options.className}))}),a.DecorationSet.create(t,l)}}})]}});class d extends a.Selection{constructor(e){super(e,e)}map(e,i){let o=e.resolve(i.map(this.head));return d.valid(o)?new d(o):a.Selection.near(o)}content(){return a.Slice.empty}eq(e){return e instanceof d&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,i){if(typeof i.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new d(e.resolve(i.pos))}getBookmark(){return new y(this.anchor)}static valid(e){let i=e.parent;if(i.isTextblock||!z(e)||!D(e))return!1;let o=i.type.spec.allowGapCursor;if(o!=null)return o;let r=i.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,i,o=!1){e:for(;;){if(!o&&d.valid(e))return e;let r=e.pos,l=null;for(let s=e.depth;;s--){let n=e.node(s);if(i>0?e.indexAfter(s)<n.childCount:e.index(s)>0){l=n.child(i>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;r+=i;let c=e.doc.resolve(r);if(d.valid(c))return c}for(;;){let s=i>0?l.firstChild:l.lastChild;if(!s){if(l.isAtom&&!l.isText&&!a.NodeSelection.isSelectable(l)){e=e.doc.resolve(r+l.nodeSize*i),o=!1;continue e}break}l=s,r+=i;let n=e.doc.resolve(r);if(d.valid(n))return n}return null}}}d.prototype.visible=!1;d.findFrom=d.findGapCursorFrom;a.Selection.jsonID("gapcursor",d);class y{constructor(e){this.pos=e}map(e){return new y(e.map(this.pos))}resolve(e){let i=e.resolve(this.pos);return d.valid(i)?new d(i):a.Selection.near(i)}}function z(t){for(let e=t.depth;e>=0;e--){let i=t.index(e),o=t.node(e);if(i==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(i-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function D(t){for(let e=t.depth;e>=0;e--){let i=t.indexAfter(e),o=t.node(e);if(i==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(i);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function L(){return new a.Plugin({props:{decorations:q,createSelectionBetween(t,e,i){return e.pos==i.pos&&d.valid(i)?new d(i):null},handleClick:V,handleKeyDown:R,handleDOMEvents:{beforeinput:H}}})}const R=a.keydownHandler({ArrowLeft:g("horiz",-1),ArrowRight:g("horiz",1),ArrowUp:g("vert",-1),ArrowDown:g("vert",1)});function g(t,e){const i=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,l){let s=o.selection,n=e>0?s.$to:s.$from,c=s.empty;if(s instanceof a.TextSelection){if(!l.endOfTextblock(i)||n.depth==0)return!1;c=!1,n=o.doc.resolve(e>0?n.after():n.before())}let u=d.findGapCursorFrom(n,e,c);return u?(r&&r(o.tr.setSelection(new d(u))),!0):!1}}function V(t,e,i){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!d.valid(o))return!1;let r=t.posAtCoords({left:i.clientX,top:i.clientY});return r&&r.inside>-1&&a.NodeSelection.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new d(o))),!0)}function H(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof d))return!1;let{$from:i}=t.state.selection,o=i.parent.contentMatchAt(i.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=a.Fragment.empty;for(let s=o.length-1;s>=0;s--)r=a.Fragment.from(o[s].createAndFill(null,r));let l=t.state.tr.replace(i.pos,i.pos,new a.Slice(r,0,0));return l.setSelection(a.TextSelection.near(l.doc.resolve(i.pos+1))),t.dispatch(l),!1}function q(t){if(!(t.selection instanceof d))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",a.DecorationSet.create(t.doc,[a.Decoration.widget(t.selection.head,e,{key:"gapcursor"})])}const F=a.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[L()]},extendNodeSchema(t){var e;const i={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=a.callOrReturn(a.getExtensionField(t,"allowGapCursor",i)))!==null&&e!==void 0?e:null}}}),I=a.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",a.mergeAttributes(this.options.HTMLAttributes,t)]},renderText(){return`
2
- `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:i,editor:o})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:r,storedMarks:l}=i;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:n}=o.extensionManager,c=l||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:h})=>{if(h&&c&&s){const f=c.filter(w=>n.includes(w.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),K=a.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",a.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),W=a.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new a.Plugin({key:new a.PluginKey("placeholder"),props:{decorations:({doc:t,selection:e})=>{const i=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=e,r=[];if(!i)return null;const l=this.editor.isEmpty;return t.descendants((s,n)=>{const c=o>=n&&o<=n+s.nodeSize,u=!s.isLeaf&&a.isNodeEmpty(s);if((c||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=a.Decoration.node(n,n+s.nodeSize,{class:h.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:n,hasAnchor:c}):this.options.placeholder});r.push(f)}return this.options.includeChildren}),a.DecorationSet.create(t,r)}}})]}}),G=a.Node.create({name:"text",group:"inline"}),J=a.Extension.create({name:"base-kit",addExtensions(){const t=[];return this.options.document!==!1&&t.push(v.Document.configure()),this.options.placeholder!==!1&&t.push(W.configure({placeholder:({node:e,pos:i,editor:o})=>{var r,l,s,n,c;return((r=e==null?void 0:e.type)==null?void 0:r.name)==="columns"||((l=e==null?void 0:e.content)==null?void 0:l.size)!==0?"":((s=e==null?void 0:e.type)==null?void 0:s.name)==="heading"?`${m.localeActions.t(`editor.heading.h${e.attrs.level}.tooltip`)}`:((n=e==null?void 0:e.type)==null?void 0:n.name)==="codeBlock"||((c=e==null?void 0:e.type)==null?void 0:c.name)==="table"?"":o.extensionManager.extensions.some(u=>u.name==="slashCommand")?m.localeActions.t("editor.slash"):m.localeActions.t("editor.content")},...this.options.placeholder})),this.options.focus!==!1&&t.push(N.configure({className:"focus",...this.options.focus})),this.options.text!==!1&&t.push(G.configure()),this.options.textBubble!==!1&&t.push(P.TextBubble.configure()),this.options.gapcursor!==!1&&t.push(F.configure()),this.options.dropcursor!==!1&&t.push(B.configure({...this.options.dropcursor,width:2,class:"ProseMirror-dropcursor border-black"})),this.options.characterCount!==!1&&t.push(E.configure(this.options.characterCount)),this.options.paragraph!==!1&&t.push(K.configure(this.options.paragraph)),this.options.hardBreak!==!1&&t.push(I.configure(this.options.hardBreak)),this.options.listItem!==!1&&t.push(b.ListItem.configure(this.options.listItem)),this.options.textStyle!==!1&&t.push(S.TextStyle.configure(this.options.textStyle)),this.options.trailingNode!==!1&&t.push(M.TrailingNode.configure(this.options.trailingNode)),this.options.selection!==!1&&t.push(k.Selection),this.options.multiColumn!==!1&&t.push(C.Column,C.MultiColumn),t}});exports.default=C.RichTextEditor;exports.BubbleMenu=x.BubbleMenu;exports.BaseKit=J;exports.useEditorState=T;
1
+ "use strict";const t=require("./RichTextEditor-CxvwGvQG.cjs");module.exports=t.RichTextEditor_default;
package/lib/index.d.cts CHANGED
@@ -1,19 +1,9 @@
1
1
  import { AnyExtension } from '@tiptap/core';
2
- import { BubbleMenu } from '@tiptap/react';
3
- import { CharacterCountOptions } from '@tiptap/extension-character-count';
4
2
  import { default as default_2 } from 'react';
5
- import { DropcursorOptions } from '@tiptap/extension-dropcursor';
6
3
  import { Editor } from '@tiptap/react';
7
4
  import { Editor as Editor_2 } from '@tiptap/core';
8
- import { Extension } from '@tiptap/core';
9
- import { FocusOptions as FocusOptions_2 } from '@tiptap/extension-focus';
10
5
  import { ForwardRefExoticComponent } from 'react';
11
- import { HardBreakOptions } from '@tiptap/extension-hard-break';
12
- import { ListItemOptions } from '@tiptap/extension-list-item';
13
- import { ParagraphOptions } from '@tiptap/extension-paragraph';
14
- import { PlaceholderOptions } from '@tiptap/extension-placeholder';
15
6
  import { RefAttributes } from 'react';
16
- import { TextStyleOptions } from '@tiptap/extension-text-style';
17
7
  import { TooltipContentProps } from '@radix-ui/react-tooltip';
18
8
  import { UseEditorOptions } from '@tiptap/react';
19
9
 
@@ -35,115 +25,6 @@ declare interface ActionButtonProps {
35
25
  initialDisplayedColor?: string;
36
26
  }
37
27
 
38
- export declare const BaseKit: Extension<BaseKitOptions, any>;
39
-
40
- /**
41
- * Represents the interface for options in the base toolkit.
42
- */
43
- export declare interface BaseKitOptions {
44
- /**
45
- * Whether to enable the document option
46
- *
47
- * @default true
48
- */
49
- document: false;
50
- /**
51
- * Whether to enable the document option
52
- *
53
- * @default false
54
- */
55
- multiColumn?: boolean;
56
- /**
57
- * Whether to enable the text option
58
- *
59
- * @default true
60
- */
61
- text: false;
62
- /**
63
- * Whether to enable the Gapcursor
64
- *
65
- * @default true
66
- */
67
- gapcursor: false;
68
- /**
69
- * Dropcursor options or false, indicating whether to enable the drop cursor
70
- *
71
- * @default true
72
- */
73
- dropcursor: Partial<DropcursorOptions> | false;
74
- /**
75
- * character count options or false, indicating whether to enable character count
76
- *
77
- * @default true
78
- */
79
- characterCount: Partial<CharacterCountOptions> | false;
80
- /**
81
- * HardBreak options or false, indicating whether to enable hard breaks
82
- *
83
- * @default true
84
- */
85
- hardBreak: Partial<HardBreakOptions> | false;
86
- /**
87
- * Placeholder options or false, indicating whether to enable placeholders
88
- *
89
- * @default true
90
- */
91
- placeholder: Partial<PlaceholderOptions> | false;
92
- /**
93
- * Paragraph options or false, indicating whether to enable paragraph functionality
94
- *
95
- * @default true
96
- */
97
- paragraph: Partial<ParagraphOptions> | false;
98
- /**
99
- * Focus options or false, indicating whether to enable focus functionality
100
- *
101
- * @default true
102
- */
103
- focus: Partial<FocusOptions_2> | false;
104
- /**
105
- * ListItem options or false, indicating whether to enable list item functionality
106
- *
107
- * @default true
108
- */
109
- listItem: Partial<ListItemOptions> | false;
110
- /**
111
- * Text Style options or false, indicating whether to enable text style functionality
112
- *
113
- * @default true
114
- */
115
- textStyle: Partial<TextStyleOptions> | false;
116
- /**
117
- * Bubble options, taking `BubbleOptions<BaseKitOptions>` as parameters, indicating whether to enable the bubble functionality
118
- */
119
- bubble: any;
120
- /**
121
- * Iframe options or false, indicating whether to enable the iframe
122
- *
123
- * @default true
124
- */
125
- /**
126
- * Trailing node options or false, indicating whether to enable the trailing node
127
- *
128
- * @default true
129
- */
130
- trailingNode: Partial<TrailingNodeOptions> | false;
131
- /**
132
- * textBubble options or false, indicating whether to enable the textBubble
133
- *
134
- * @default true
135
- */
136
- textBubble: Partial<TextBubbleOptions> | false;
137
- /**
138
- * selection options or false, indicating whether to enable the selection
139
- *
140
- * @default true
141
- */
142
- selection: any | false;
143
- }
144
-
145
- export { BubbleMenu }
146
-
147
28
  /**
148
29
  * Represents the BubbleMenuProps.
149
30
  */
@@ -253,35 +134,6 @@ declare interface BubbleMenuRenderProps {
253
134
  extensionsNames: string[];
254
135
  }
255
136
 
256
- /**
257
- * Represents the ButtonView function.
258
- */
259
- declare type ButtonView<T = any> = (options: ButtonViewParams<T>) => ButtonViewReturn | ButtonViewReturn[];
260
-
261
- /**
262
- * Represents the parameters for the ButtonView function.
263
- */
264
- declare interface ButtonViewParams<T = any> {
265
- /** Editor object */
266
- editor: Editor;
267
- /** Extension object */
268
- extension: Extension<T>;
269
- /** Translation function */
270
- t: (path: string) => string;
271
- }
272
-
273
- /**
274
- * Represents the return value for the ButtonView component.
275
- */
276
- declare interface ButtonViewReturn {
277
- /** Component */
278
- component: unknown;
279
- /** Component props */
280
- componentProps: ButtonViewReturnComponentProps;
281
- /** Component slots */
282
- componentSlots?: ButtonViewReturnComponentSlots;
283
- }
284
-
285
137
  /**
286
138
  * Represents the props for the ButtonView component.
287
139
  */
@@ -297,38 +149,11 @@ declare interface ButtonViewReturnComponentProps {
297
149
  [x: string]: any;
298
150
  }
299
151
 
300
- /**
301
- * Represents the slots for the ButtonView component.
302
- */
303
- declare interface ButtonViewReturnComponentSlots {
304
- /** Dialog slot */
305
- dialog: () => any;
306
- [x: string]: () => any;
307
- }
308
-
309
152
  declare const _default: ForwardRefExoticComponent<RichTextEditorProps & RefAttributes< {
310
153
  editor: Editor_2 | null;
311
154
  }>>;
312
155
  export default _default;
313
156
 
314
- export { Editor }
315
-
316
- /**
317
- * Represents the general options for Tiptap extensions.
318
- */
319
- declare interface GeneralOptions<T> {
320
- /** Enabled divider */
321
- divider: boolean;
322
- /** Enabled spacer */
323
- spacer: boolean;
324
- /** Button view function */
325
- button: ButtonView<T>;
326
- /** Show on Toolbar */
327
- toolbar?: boolean;
328
- /** Shortcut keys override */
329
- shortcutKeys?: string[] | string[][];
330
- }
331
-
332
157
  /**
333
158
  * Interface for RichTextEditor component props
334
159
  */
@@ -377,6 +202,7 @@ declare interface RichTextEditorProps {
377
202
  resetCSS?: boolean;
378
203
  /** This option gives us the control to enable the default behavior of rendering the editor immediately.*/
379
204
  immediatelyRender?: boolean;
205
+ shouldRerenderOnTransaction?: boolean;
380
206
  }
381
207
 
382
208
  declare interface TableMenuConfig {
@@ -395,9 +221,6 @@ declare interface TableMenuConfig {
395
221
  hiddenActions?: string[];
396
222
  }
397
223
 
398
- declare interface TextBubbleOptions extends GeneralOptions<TextBubbleOptions> {
399
- }
400
-
401
224
  /**
402
225
  * Represents the ToolbarItemProps.
403
226
  */
@@ -422,28 +245,6 @@ declare interface ToolbarRenderProps {
422
245
  disabled: boolean;
423
246
  }
424
247
 
425
- /**
426
- * Extension based on:
427
- * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
428
- * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
429
- */
430
- declare interface TrailingNodeOptions {
431
- node: string;
432
- notAfter: string[];
433
- }
434
-
435
- export { UseEditorOptions }
436
-
437
- export declare function useEditorState(): UseEditorStateReturn;
438
-
439
- export declare interface UseEditorStateReturn {
440
- isReady: boolean;
441
- editor: Editor_2 | null;
442
- editorRef: React.MutableRefObject<{
443
- editor: Editor_2 | null;
444
- }>;
445
- }
446
-
447
248
  export { }
448
249
 
449
250
 
@@ -487,18 +288,6 @@ declare module '@tiptap/core' {
487
288
  }
488
289
 
489
290
 
490
- declare module '@tiptap/core' {
491
- interface Commands<ReturnType> {
492
- emoji: {
493
- setEmoji: (emoji: {
494
- name: string;
495
- emoji: string;
496
- }) => ReturnType;
497
- };
498
- }
499
- }
500
-
501
-
502
291
  declare module '@tiptap/core' {
503
292
  interface Commands<ReturnType> {
504
293
  excalidraw: {
@@ -590,19 +379,15 @@ declare module '@tiptap/core' {
590
379
 
591
380
  declare module '@tiptap/core' {
592
381
  interface Commands<ReturnType> {
593
- imageGifUpload: {
594
- /**
595
- * Add an image gif
596
- */
597
- setImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
382
+ indent: {
598
383
  /**
599
- * Update an image gif
384
+ * Set the indent attribute
600
385
  */
601
- updateImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
386
+ indent: () => ReturnType;
602
387
  /**
603
- * Set image alignment
388
+ * Set the outdent attribute
604
389
  */
605
- setAlignImageGif: (align: 'left' | 'center' | 'right') => ReturnType;
390
+ outdent: () => ReturnType;
606
391
  };
607
392
  }
608
393
  }
@@ -610,15 +395,19 @@ declare module '@tiptap/core' {
610
395
 
611
396
  declare module '@tiptap/core' {
612
397
  interface Commands<ReturnType> {
613
- indent: {
398
+ imageGifUpload: {
614
399
  /**
615
- * Set the indent attribute
400
+ * Add an image gif
616
401
  */
617
- indent: () => ReturnType;
402
+ setImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
618
403
  /**
619
- * Set the outdent attribute
404
+ * Update an image gif
620
405
  */
621
- outdent: () => ReturnType;
406
+ updateImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
407
+ /**
408
+ * Set image alignment
409
+ */
410
+ setAlignImageGif: (align: 'left' | 'center' | 'right') => ReturnType;
622
411
  };
623
412
  }
624
413
  }
@@ -672,16 +461,24 @@ declare module '@tiptap/core' {
672
461
  search: {
673
462
  setSearchTerm: (searchTerm: string) => ReturnType;
674
463
  setReplaceTerm: (replaceTerm: string) => ReturnType;
464
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
465
+ resetIndex: () => ReturnType;
466
+ nextSearchResult: () => ReturnType;
467
+ previousSearchResult: () => ReturnType;
675
468
  replace: () => ReturnType;
676
469
  replaceAll: () => ReturnType;
677
- goToPrevSearchResult: () => void;
678
- goToNextSearchResult: () => void;
679
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
680
470
  };
681
471
  }
682
472
  }
683
473
 
684
474
 
475
+ declare module '@tiptap/core' {
476
+ interface Storage {
477
+ searchAndReplace: SearchAndReplaceStorage;
478
+ }
479
+ }
480
+
481
+
685
482
  declare module '@tiptap/core' {
686
483
  interface Commands<ReturnType> {
687
484
  tableOfContents: {