reactjs-tiptap-editor 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/lib/{ActionMenuButton-HYlhmRvw.js → ActionMenuButton-B4KDkZ0z.js} +1 -1
  2. package/lib/{ActionMenuButton-B8NhVw5m.cjs → ActionMenuButton-C3Cfeza9.cjs} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +25 -25
  5. package/lib/Blockquote.cjs +5 -5
  6. package/lib/Blockquote.js +1490 -53
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +3 -3
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +2 -2
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +222 -8
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +2 -2
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +56 -39
  17. package/lib/CodeBlock.cjs +1 -1
  18. package/lib/CodeBlock.js +8 -4
  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 +3 -3
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +2 -2
  25. package/lib/{Drawer-Was4hxYH.cjs → Drawer-D7E9kTca.cjs} +1 -1
  26. package/lib/{Drawer-CaXVhxo4.js → Drawer-DA0FLHs9.js} +20 -20
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +4 -4
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +1644 -148
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +10 -10
  33. package/lib/ExportPdf.cjs +1 -1
  34. package/lib/ExportPdf.js +2 -2
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +2 -2
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +5 -5
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +5 -5
  41. package/lib/FormatPainter.cjs +1 -0
  42. package/lib/FormatPainter.js +133 -0
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +15 -11
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +38 -32
  47. package/lib/History.cjs +7 -1
  48. package/lib/History.js +519 -478
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +2 -2
  51. package/lib/{Iframe-Bp986fj0.js → Iframe-DZ3r3QzK.js} +7 -7
  52. package/lib/{Iframe-BI0sq6pd.cjs → Iframe-OMVd0xa_.cjs} +1 -1
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +3 -3
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +6 -6
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +35 -35
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +15 -15
  61. package/lib/{Indent-FvM52kjA.cjs → Indent-QgCoonRk.cjs} +1 -1
  62. package/lib/{Indent-E6B8DkyN.js → Indent-kI4G-clX.js} +2 -2
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +2 -2
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +2 -2
  67. package/lib/{Katex-pzwyyiFJ.js → Katex-BPbXjcZQ.js} +6 -7
  68. package/lib/Katex-CUofhjB5.cjs +4 -0
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +3 -3
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +4 -4
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-OjN4F2rM.js → LinkEditBlock-BYWwH2_x.js} +59 -32
  76. package/lib/{LinkEditBlock-Cmkmp2fW.cjs → LinkEditBlock-Z7RRurvx.cjs} +2 -2
  77. package/lib/MarkdownPaste.cjs +1 -1
  78. package/lib/MarkdownPaste.js +1 -1
  79. package/lib/Mention.cjs +1 -1
  80. package/lib/Mention.js +9 -5
  81. package/lib/Mermaid.cjs +2 -2
  82. package/lib/Mermaid.js +61 -62
  83. package/lib/MoreMark.cjs +1 -1
  84. package/lib/MoreMark.js +5 -5
  85. package/lib/OrderedList.cjs +1 -1
  86. package/lib/OrderedList.js +2 -2
  87. package/lib/SearchAndReplace.cjs +1 -1
  88. package/lib/SearchAndReplace.js +14 -14
  89. package/lib/SlashCommand.cjs +1 -1
  90. package/lib/SlashCommand.js +7 -7
  91. package/lib/{SlashCommandNodeView-o323V8li.js → SlashCommandNodeView-C0l3Fb_3.js} +10 -10
  92. package/lib/{SlashCommandNodeView-DarAytvt.cjs → SlashCommandNodeView-DPPmYEjC.cjs} +1 -1
  93. package/lib/Strike.cjs +1 -1
  94. package/lib/Strike.js +2 -2
  95. package/lib/{Table-Clnz-i4l.cjs → Table-D5G3rfwb.cjs} +5 -5
  96. package/lib/{Table-CC9uNHPL.js → Table-DwseaFSD.js} +115 -97
  97. package/lib/Table.cjs +1 -1
  98. package/lib/Table.js +1 -1
  99. package/lib/TaskList.cjs +1 -1
  100. package/lib/TaskList.js +2 -2
  101. package/lib/TextAlign.cjs +1 -1
  102. package/lib/TextAlign.js +11 -11
  103. package/lib/TextDirection.cjs +1 -1
  104. package/lib/TextDirection.js +3 -3
  105. package/lib/TextUnderline.cjs +1 -1
  106. package/lib/TextUnderline.js +2 -2
  107. package/lib/{Twitter-BVnXL8we.js → Twitter-DP26Lkn8.js} +195 -195
  108. package/lib/Twitter-q4ZGZL0i.cjs +1 -0
  109. package/lib/Twitter.cjs +1 -1
  110. package/lib/Twitter.js +3 -3
  111. package/lib/Video.cjs +1 -1
  112. package/lib/Video.js +5 -5
  113. package/lib/bubble.cjs +6 -6
  114. package/lib/bubble.js +2783 -2137
  115. package/lib/{clsx-D6gYQn3o.cjs → clsx-DRbkQ4T7.cjs} +1 -1
  116. package/lib/{clsx-0OU6n9va.js → clsx-_bq4MQQ7.js} +14 -4
  117. package/lib/components/Bubble/RichTextBubbleCallout.d.ts +1 -1
  118. package/lib/components/Bubble/RichTextBubbleCodeBlock.d.ts +1 -1
  119. package/lib/components/Bubble/RichTextBubbleColumns.d.ts +1 -1
  120. package/lib/components/Bubble/RichTextBubbleDrawer.d.ts +1 -1
  121. package/lib/components/Bubble/RichTextBubbleExcalidraw.d.ts +1 -1
  122. package/lib/components/Bubble/RichTextBubbleIframe.d.ts +1 -1
  123. package/lib/components/Bubble/RichTextBubbleKatex.d.ts +2 -1
  124. package/lib/components/Bubble/RichTextBubbleLink.d.ts +1 -1
  125. package/lib/components/Bubble/RichTextBubbleMedia.d.ts +3 -3
  126. package/lib/components/Bubble/RichTextBubbleMenuDragHandle.d.ts +2 -1
  127. package/lib/components/Bubble/RichTextBubbleMermaid.d.ts +1 -1
  128. package/lib/components/Bubble/RichTextBubbleTable.d.ts +1 -1
  129. package/lib/components/Bubble/RichTextBubbleText.d.ts +1 -1
  130. package/lib/components/Bubble/RichTextBubbleTwitter.d.ts +1 -1
  131. package/lib/components/ColorPicker.d.ts +1 -1
  132. package/lib/components/ReactBus.d.ts +1 -1
  133. package/lib/components/RichTextProvider.d.ts +1 -1
  134. package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -1
  135. package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -1
  136. package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +2 -1
  137. package/lib/components/icons/Activity.d.ts +2 -1
  138. package/lib/components/icons/Animas.d.ts +2 -1
  139. package/lib/components/icons/AspectRatio.d.ts +1 -1
  140. package/lib/components/icons/Blockquote.d.ts +1 -1
  141. package/lib/components/icons/CodeView.d.ts +1 -1
  142. package/lib/components/icons/ColumnAddLeft.d.ts +1 -1
  143. package/lib/components/icons/ColumnAddRight.d.ts +1 -1
  144. package/lib/components/icons/DeleteColumn.d.ts +1 -1
  145. package/lib/components/icons/DeleteRow.d.ts +1 -1
  146. package/lib/components/icons/Direction.d.ts +1 -1
  147. package/lib/components/icons/Excalidraw.d.ts +1 -1
  148. package/lib/components/icons/ExportPdf.d.ts +1 -1
  149. package/lib/components/icons/ExportWord.d.ts +2 -1
  150. package/lib/components/icons/FileWordOutline.d.ts +1 -1
  151. package/lib/components/icons/Flag.d.ts +2 -1
  152. package/lib/components/icons/Food.d.ts +2 -1
  153. package/lib/components/icons/GIfIcon.d.ts +1 -1
  154. package/lib/components/icons/Html.d.ts +1 -1
  155. package/lib/components/icons/Icon.d.ts +1 -1
  156. package/lib/components/icons/IconColorFill.d.ts +1 -1
  157. package/lib/components/icons/IconHighlightFill.d.ts +1 -1
  158. package/lib/components/icons/ImportWord.d.ts +2 -1
  159. package/lib/components/icons/LeftToRight.d.ts +1 -1
  160. package/lib/components/icons/LineHeight.d.ts +1 -1
  161. package/lib/components/icons/MenuDown.d.ts +1 -1
  162. package/lib/components/icons/Mermaid.d.ts +1 -1
  163. package/lib/components/icons/NoFill.d.ts +1 -1
  164. package/lib/components/icons/Object.d.ts +2 -1
  165. package/lib/components/icons/RightToLeft.d.ts +1 -1
  166. package/lib/components/icons/SizeL.d.ts +1 -1
  167. package/lib/components/icons/SizeM.d.ts +1 -1
  168. package/lib/components/icons/SizeS.d.ts +1 -1
  169. package/lib/components/icons/Symbol.d.ts +2 -1
  170. package/lib/components/icons/Travel.d.ts +2 -1
  171. package/lib/components/icons/Twitter.d.ts +1 -1
  172. package/lib/components/ui/dialog.d.ts +2 -2
  173. package/lib/components/ui/dropdown-menu.d.ts +1 -1
  174. package/lib/components/ui/emoji-picker.d.ts +4 -4
  175. package/lib/components/ui/toaster.d.ts +1 -1
  176. package/lib/{dropdown-menu-BW2M6saA.js → dropdown-menu-BKSX4gvT.js} +1 -1
  177. package/lib/{dropdown-menu-BIGvxqiu.cjs → dropdown-menu-CURWpB9o.cjs} +1 -1
  178. package/lib/extensions/Attachment/components/NodeViewAttachment/FileIcon.d.ts +1 -1
  179. package/lib/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.d.ts +1 -1
  180. package/lib/extensions/Attachment/components/RichTextAttachment.d.ts +1 -1
  181. package/lib/extensions/Blockquote/components/RichTextBlockquote.d.ts +1 -1
  182. package/lib/extensions/Bold/components/RichTextBold.d.ts +1 -1
  183. package/lib/extensions/BulletList/components/RichTextBulletList.d.ts +1 -1
  184. package/lib/extensions/Callout/components/NodeViewCallout/NodeViewCallout.d.ts +1 -1
  185. package/lib/extensions/Callout/components/RichTextCallout.d.ts +1 -1
  186. package/lib/extensions/Clear/components/RichTextClear.d.ts +1 -1
  187. package/lib/extensions/Code/components/RichTextCode.d.ts +1 -1
  188. package/lib/extensions/CodeBlock/components/RichTextCodeBlock.d.ts +2 -1
  189. package/lib/extensions/CodeView/components/RichTextCodeView.d.ts +1 -1
  190. package/lib/extensions/Color/components/RichTextColor.d.ts +1 -1
  191. package/lib/extensions/Column/components/RichTextColumn.d.ts +1 -1
  192. package/lib/extensions/Drawer/components/ControlDrawer/ControlDrawer.d.ts +2 -1
  193. package/lib/extensions/Drawer/components/ControlDrawer/icon.d.ts +27 -27
  194. package/lib/extensions/Drawer/components/EditDrawerBlock.d.ts +1 -1
  195. package/lib/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.d.ts +2 -1
  196. package/lib/extensions/Drawer/components/RichTextDrawer.d.ts +1 -1
  197. package/lib/extensions/Emoji/components/RichTextEmoji.d.ts +2 -1
  198. package/lib/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.d.ts +2 -1
  199. package/lib/extensions/Excalidraw/components/RichTextExcalidraw.d.ts +1 -1
  200. package/lib/extensions/ExportPdf/components/RichTextExportPdf.d.ts +1 -1
  201. package/lib/extensions/ExportWord/components/RichTextExportWord.d.ts +1 -1
  202. package/lib/extensions/FontFamily/components/RichTextFontFamily.d.ts +1 -1
  203. package/lib/extensions/FontSize/components/RichTextFontSize.d.ts +1 -1
  204. package/lib/extensions/FormatPainter/FormatPainter.d.ts +17 -0
  205. package/lib/extensions/FormatPainter/components/RichTextFormatPainter.d.ts +1 -0
  206. package/lib/extensions/FormatPainter/index.d.ts +1 -0
  207. package/lib/extensions/Heading/components/RichTextHeading.d.ts +1 -1
  208. package/lib/extensions/Highlight/components/RichTextHighlight.d.ts +2 -1
  209. package/lib/extensions/History/components/RichTextHistory.d.ts +3 -2
  210. package/lib/extensions/HorizontalRule/components/RichTextHorizontalRule.d.ts +1 -1
  211. package/lib/extensions/Iframe/components/IframeNodeView.d.ts +1 -1
  212. package/lib/extensions/Iframe/components/RichTextIframe.d.ts +1 -1
  213. package/lib/extensions/Image/components/ImageCropper.d.ts +2 -1
  214. package/lib/extensions/Image/components/ImageView.d.ts +2 -1
  215. package/lib/extensions/Image/components/RichTextImage.d.ts +1 -1
  216. package/lib/extensions/ImageGif/components/ImageGifView.d.ts +2 -1
  217. package/lib/extensions/ImageGif/components/RichTextImageGif.d.ts +2 -1
  218. package/lib/extensions/ImportWord/components/RichTextImportWord.d.ts +1 -1
  219. package/lib/extensions/Indent/components/RichTextIndent.d.ts +1 -1
  220. package/lib/extensions/Italic/components/RichTextItalic.d.ts +1 -1
  221. package/lib/extensions/Katex/components/KatexWrapper.d.ts +1 -1
  222. package/lib/extensions/Katex/components/RichTextKatex.d.ts +1 -1
  223. package/lib/extensions/LineHeight/components/RichTextLightHeight.d.ts +1 -1
  224. package/lib/extensions/Link/components/LinkEditBlock.d.ts +1 -1
  225. package/lib/extensions/Link/components/LinkViewBlock.d.ts +2 -1
  226. package/lib/extensions/Link/components/RichTextLink.d.ts +1 -1
  227. package/lib/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.d.ts +2 -1
  228. package/lib/extensions/Mermaid/components/RichTextMermaid.d.ts +1 -1
  229. package/lib/extensions/MoreMark/components/RichTextMoreMark.d.ts +1 -1
  230. package/lib/extensions/OrderedList/components/RichTextOrderedList.d.ts +1 -1
  231. package/lib/extensions/SearchAndReplace/components/RichTextSearchAndReplace.d.ts +1 -1
  232. package/lib/extensions/SlashCommand/components/SlashCommandList.d.ts +1 -1
  233. package/lib/extensions/Strike/components/RichTextStrike.d.ts +1 -1
  234. package/lib/extensions/Table/components/CreateTablePopover.d.ts +2 -1
  235. package/lib/extensions/Table/components/RichTextTable.d.ts +2 -1
  236. package/lib/extensions/TaskList/components/RichTextTaskList.d.ts +1 -1
  237. package/lib/extensions/TextAlign/components/RichTextAlign.d.ts +1 -1
  238. package/lib/extensions/TextDirection/components/RichTextTextDirection.d.ts +1 -1
  239. package/lib/extensions/TextUnderline/components/RichTextUnderline.d.ts +1 -1
  240. package/lib/extensions/Twitter/components/FormEditLinkTwitter.d.ts +1 -1
  241. package/lib/extensions/Twitter/components/NodeViewTweet.d.ts +1 -1
  242. package/lib/extensions/Twitter/components/RichTextTwitter.d.ts +1 -1
  243. package/lib/extensions/Video/components/RichTextVideo.d.ts +1 -1
  244. package/lib/index-BGfIcDCQ.cjs +26 -0
  245. package/lib/index-BaR0Brts.js +1115 -0
  246. package/lib/index-BgNKVyMW.cjs +2 -0
  247. package/lib/index-BpLw6ebr.cjs +1 -0
  248. package/lib/{index-BrsJsbds.js → index-C52cuQ_Y.js} +1503 -1352
  249. package/lib/index-CDw4Eszh.cjs +12 -0
  250. package/lib/{index-CUvjYuRp.cjs → index-CHVV5iY-.cjs} +1 -1
  251. package/lib/{index-zw-Kd38i.js → index-CJMI7Fjf.js} +1 -1
  252. package/lib/{index-D-Ouz0vF.js → index-DQy9iBzV.js} +1 -1
  253. package/lib/index-Dbm_Mans.js +1756 -0
  254. package/lib/{index-oj858lQO.js → index-DtyAGMbq.js} +208 -208
  255. package/lib/{index-BblvcbTH.js → index-Dx-Dh7KS.js} +1464 -1348
  256. package/lib/{index-BAb_UADw.cjs → index-SEMQrdk2.cjs} +1 -1
  257. package/lib/index-aujjnfSJ.cjs +1 -0
  258. package/lib/index.cjs +1 -1
  259. package/lib/index.js +12 -12
  260. package/lib/{jsx-runtime-CT7Pcg-t.js → jsx-runtime-DE8oVoME.js} +3 -1
  261. package/lib/locale-bundle.cjs +1 -1
  262. package/lib/locale-bundle.js +1 -1
  263. package/lib/locales/index.d.ts +1 -1
  264. package/lib/{popover-BIVHT1W9.js → popover-BB-ZDnqk.js} +1 -1
  265. package/lib/{popover-DoSfJsFS.cjs → popover-CrywEkBR.cjs} +1 -1
  266. package/lib/{renderNodeView-D--fDFov.cjs → renderNodeView-5h3-p80E.cjs} +1 -1
  267. package/lib/{renderNodeView-CfWJK4rG.js → renderNodeView-DoKZ4GYy.js} +2 -2
  268. package/lib/{separator-SRbPfmGa.cjs → separator-BGO9AZp4.cjs} +1 -1
  269. package/lib/{separator-b-qOPJmp.js → separator-DuuOJRQd.js} +21 -21
  270. package/lib/store/EditorEditableReactive.d.ts +1 -1
  271. package/lib/store/ThemeColorReactive.d.ts +1 -1
  272. package/lib/style.css +1 -1
  273. package/lib/types.d.ts +2 -2
  274. package/lib/{updatePosition-DGPtRfWN.cjs → updatePosition-B1oRJE1x.cjs} +1 -1
  275. package/lib/{updatePosition-BwzAsiY0.js → updatePosition-CFTYKYNJ.js} +2 -2
  276. package/package.json +79 -66
  277. package/lib/Callout-B-S2f0Qo.cjs +0 -1
  278. package/lib/Callout-CF7Y9yJ7.js +0 -340
  279. package/lib/Katex-DP6EjdKz.cjs +0 -4
  280. package/lib/Twitter-0kmrijjL.cjs +0 -1
  281. package/lib/index-BF3EVCB1.cjs +0 -2
  282. package/lib/index-Bcj8cyOO.cjs +0 -24
  283. package/lib/index-CGjT-a9h.js +0 -1377
  284. package/lib/index-CPTpXLfX.cjs +0 -11
  285. package/lib/index-CWw4s87s.cjs +0 -1
  286. package/lib/index-Cal5SPfB.js +0 -779
  287. package/lib/index-deubsx3z.cjs +0 -1
  288. package/lib/textarea-CpxXPky_.js +0 -20
  289. package/lib/textarea-DbGw9oCU.cjs +0 -1
package/lib/Blockquote.js CHANGED
@@ -1,10 +1,1446 @@
1
- import { N as k, w as h, m as g } from "./index-BblvcbTH.js";
2
- import { h as p } from "./jsx-runtime-CT7Pcg-t.js";
3
- import { jsx as m, Fragment as b } from "react/jsx-runtime";
4
- import { u as f, d as q, A as v } from "./index-BrsJsbds.js";
1
+ import { N as xt, w as Nt, m as Rt } from "./index-Dx-Dh7KS.js";
2
+ import { h as Z } from "./jsx-runtime-DE8oVoME.js";
3
+ import { jsx as j, Fragment as Ot } from "react/jsx-runtime";
4
+ import { u as Et, d as Tt, A as At } from "./index-C52cuQ_Y.js";
5
5
  import "react";
6
6
  import "./theme.js";
7
- var B = /^\s*>\s$/, A = k.create({
7
+ function st(n, t, e) {
8
+ for (let r = 0; ; r++) {
9
+ if (r == n.childCount || r == t.childCount)
10
+ return n.childCount == t.childCount ? null : e;
11
+ let i = n.child(r), s = t.child(r);
12
+ if (i == s) {
13
+ e += i.nodeSize;
14
+ continue;
15
+ }
16
+ if (!i.sameMarkup(s))
17
+ return e;
18
+ if (i.isText && i.text != s.text) {
19
+ for (let o = 0; i.text[o] == s.text[o]; o++)
20
+ e++;
21
+ return e;
22
+ }
23
+ if (i.content.size || s.content.size) {
24
+ let o = st(i.content, s.content, e + 1);
25
+ if (o != null)
26
+ return o;
27
+ }
28
+ e += i.nodeSize;
29
+ }
30
+ }
31
+ function ot(n, t, e, r) {
32
+ for (let i = n.childCount, s = t.childCount; ; ) {
33
+ if (i == 0 || s == 0)
34
+ return i == s ? null : { a: e, b: r };
35
+ let o = n.child(--i), a = t.child(--s), l = o.nodeSize;
36
+ if (o == a) {
37
+ e -= l, r -= l;
38
+ continue;
39
+ }
40
+ if (!o.sameMarkup(a))
41
+ return { a: e, b: r };
42
+ if (o.isText && o.text != a.text) {
43
+ let h = 0, u = Math.min(o.text.length, a.text.length);
44
+ for (; h < u && o.text[o.text.length - h - 1] == a.text[a.text.length - h - 1]; )
45
+ h++, e--, r--;
46
+ return { a: e, b: r };
47
+ }
48
+ if (o.content.size || a.content.size) {
49
+ let h = ot(o.content, a.content, e - 1, r - 1);
50
+ if (h)
51
+ return h;
52
+ }
53
+ e -= l, r -= l;
54
+ }
55
+ }
56
+ var g = class m {
57
+ /**
58
+ @internal
59
+ */
60
+ constructor(t, e) {
61
+ if (this.content = t, this.size = e || 0, e == null)
62
+ for (let r = 0; r < t.length; r++)
63
+ this.size += t[r].nodeSize;
64
+ }
65
+ /**
66
+ Invoke a callback for all descendant nodes between the given two
67
+ positions (relative to start of this fragment). Doesn't descend
68
+ into a node when the callback returns `false`.
69
+ */
70
+ nodesBetween(t, e, r, i = 0, s) {
71
+ for (let o = 0, a = 0; a < e; o++) {
72
+ let l = this.content[o], h = a + l.nodeSize;
73
+ if (h > t && r(l, i + a, s || null, o) !== !1 && l.content.size) {
74
+ let u = a + 1;
75
+ l.nodesBetween(Math.max(0, t - u), Math.min(l.content.size, e - u), r, i + u);
76
+ }
77
+ a = h;
78
+ }
79
+ }
80
+ /**
81
+ Call the given callback for every descendant node. `pos` will be
82
+ relative to the start of the fragment. The callback may return
83
+ `false` to prevent traversal of a given node's children.
84
+ */
85
+ descendants(t) {
86
+ this.nodesBetween(0, this.size, t);
87
+ }
88
+ /**
89
+ Extract the text between `from` and `to`. See the same method on
90
+ [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
91
+ */
92
+ textBetween(t, e, r, i) {
93
+ let s = "", o = !0;
94
+ return this.nodesBetween(t, e, (a, l) => {
95
+ let h = a.isText ? a.text.slice(Math.max(t, l) - l, e - l) : a.isLeaf ? i ? typeof i == "function" ? i(a) : i : a.type.spec.leafText ? a.type.spec.leafText(a) : "" : "";
96
+ a.isBlock && (a.isLeaf && h || a.isTextblock) && r && (o ? o = !1 : s += r), s += h;
97
+ }, 0), s;
98
+ }
99
+ /**
100
+ Create a new fragment containing the combined content of this
101
+ fragment and the other.
102
+ */
103
+ append(t) {
104
+ if (!t.size)
105
+ return this;
106
+ if (!this.size)
107
+ return t;
108
+ let e = this.lastChild, r = t.firstChild, i = this.content.slice(), s = 0;
109
+ for (e.isText && e.sameMarkup(r) && (i[i.length - 1] = e.withText(e.text + r.text), s = 1); s < t.content.length; s++)
110
+ i.push(t.content[s]);
111
+ return new m(i, this.size + t.size);
112
+ }
113
+ /**
114
+ Cut out the sub-fragment between the two given positions.
115
+ */
116
+ cut(t, e = this.size) {
117
+ if (t == 0 && e == this.size)
118
+ return this;
119
+ let r = [], i = 0;
120
+ if (e > t)
121
+ for (let s = 0, o = 0; o < e; s++) {
122
+ let a = this.content[s], l = o + a.nodeSize;
123
+ l > t && ((o < t || l > e) && (a.isText ? a = a.cut(Math.max(0, t - o), Math.min(a.text.length, e - o)) : a = a.cut(Math.max(0, t - o - 1), Math.min(a.content.size, e - o - 1))), r.push(a), i += a.nodeSize), o = l;
124
+ }
125
+ return new m(r, i);
126
+ }
127
+ /**
128
+ @internal
129
+ */
130
+ cutByIndex(t, e) {
131
+ return t == e ? m.empty : t == 0 && e == this.content.length ? this : new m(this.content.slice(t, e));
132
+ }
133
+ /**
134
+ Create a new fragment in which the node at the given index is
135
+ replaced by the given node.
136
+ */
137
+ replaceChild(t, e) {
138
+ let r = this.content[t];
139
+ if (r == e)
140
+ return this;
141
+ let i = this.content.slice(), s = this.size + e.nodeSize - r.nodeSize;
142
+ return i[t] = e, new m(i, s);
143
+ }
144
+ /**
145
+ Create a new fragment by prepending the given node to this
146
+ fragment.
147
+ */
148
+ addToStart(t) {
149
+ return new m([t].concat(this.content), this.size + t.nodeSize);
150
+ }
151
+ /**
152
+ Create a new fragment by appending the given node to this
153
+ fragment.
154
+ */
155
+ addToEnd(t) {
156
+ return new m(this.content.concat(t), this.size + t.nodeSize);
157
+ }
158
+ /**
159
+ Compare this fragment to another one.
160
+ */
161
+ eq(t) {
162
+ if (this.content.length != t.content.length)
163
+ return !1;
164
+ for (let e = 0; e < this.content.length; e++)
165
+ if (!this.content[e].eq(t.content[e]))
166
+ return !1;
167
+ return !0;
168
+ }
169
+ /**
170
+ The first child of the fragment, or `null` if it is empty.
171
+ */
172
+ get firstChild() {
173
+ return this.content.length ? this.content[0] : null;
174
+ }
175
+ /**
176
+ The last child of the fragment, or `null` if it is empty.
177
+ */
178
+ get lastChild() {
179
+ return this.content.length ? this.content[this.content.length - 1] : null;
180
+ }
181
+ /**
182
+ The number of child nodes in this fragment.
183
+ */
184
+ get childCount() {
185
+ return this.content.length;
186
+ }
187
+ /**
188
+ Get the child node at the given index. Raise an error when the
189
+ index is out of range.
190
+ */
191
+ child(t) {
192
+ let e = this.content[t];
193
+ if (!e)
194
+ throw new RangeError("Index " + t + " out of range for " + this);
195
+ return e;
196
+ }
197
+ /**
198
+ Get the child node at the given index, if it exists.
199
+ */
200
+ maybeChild(t) {
201
+ return this.content[t] || null;
202
+ }
203
+ /**
204
+ Call `f` for every child node, passing the node, its offset
205
+ into this parent node, and its index.
206
+ */
207
+ forEach(t) {
208
+ for (let e = 0, r = 0; e < this.content.length; e++) {
209
+ let i = this.content[e];
210
+ t(i, r, e), r += i.nodeSize;
211
+ }
212
+ }
213
+ /**
214
+ Find the first position at which this fragment and another
215
+ fragment differ, or `null` if they are the same.
216
+ */
217
+ findDiffStart(t, e = 0) {
218
+ return st(this, t, e);
219
+ }
220
+ /**
221
+ Find the first position, searching from the end, at which this
222
+ fragment and the given fragment differ, or `null` if they are
223
+ the same. Since this position will not be the same in both
224
+ nodes, an object with two separate positions is returned.
225
+ */
226
+ findDiffEnd(t, e = this.size, r = t.size) {
227
+ return ot(this, t, e, r);
228
+ }
229
+ /**
230
+ Find the index and inner offset corresponding to a given relative
231
+ position in this fragment. The result object will be reused
232
+ (overwritten) the next time the function is called. @internal
233
+ */
234
+ findIndex(t) {
235
+ if (t == 0)
236
+ return B(0, t);
237
+ if (t == this.size)
238
+ return B(this.content.length, t);
239
+ if (t > this.size || t < 0)
240
+ throw new RangeError(`Position ${t} outside of fragment (${this})`);
241
+ for (let e = 0, r = 0; ; e++) {
242
+ let i = this.child(e), s = r + i.nodeSize;
243
+ if (s >= t)
244
+ return s == t ? B(e + 1, s) : B(e, r);
245
+ r = s;
246
+ }
247
+ }
248
+ /**
249
+ Return a debugging string that describes this fragment.
250
+ */
251
+ toString() {
252
+ return "<" + this.toStringInner() + ">";
253
+ }
254
+ /**
255
+ @internal
256
+ */
257
+ toStringInner() {
258
+ return this.content.join(", ");
259
+ }
260
+ /**
261
+ Create a JSON-serializeable representation of this fragment.
262
+ */
263
+ toJSON() {
264
+ return this.content.length ? this.content.map((t) => t.toJSON()) : null;
265
+ }
266
+ /**
267
+ Deserialize a fragment from its JSON representation.
268
+ */
269
+ static fromJSON(t, e) {
270
+ if (!e)
271
+ return m.empty;
272
+ if (!Array.isArray(e))
273
+ throw new RangeError("Invalid input for Fragment.fromJSON");
274
+ return m.fromArray(e.map(t.nodeFromJSON));
275
+ }
276
+ /**
277
+ Build a fragment from an array of nodes. Ensures that adjacent
278
+ text nodes with the same marks are joined together.
279
+ */
280
+ static fromArray(t) {
281
+ if (!t.length)
282
+ return m.empty;
283
+ let e, r = 0;
284
+ for (let i = 0; i < t.length; i++) {
285
+ let s = t[i];
286
+ r += s.nodeSize, i && s.isText && t[i - 1].sameMarkup(s) ? (e || (e = t.slice(0, i)), e[e.length - 1] = s.withText(e[e.length - 1].text + s.text)) : e && e.push(s);
287
+ }
288
+ return new m(e || t, r);
289
+ }
290
+ /**
291
+ Create a fragment from something that can be interpreted as a
292
+ set of nodes. For `null`, it returns the empty fragment. For a
293
+ fragment, the fragment itself. For a node or array of nodes, a
294
+ fragment containing those nodes.
295
+ */
296
+ static from(t) {
297
+ if (!t)
298
+ return m.empty;
299
+ if (t instanceof m)
300
+ return t;
301
+ if (Array.isArray(t))
302
+ return this.fromArray(t);
303
+ if (t.attrs)
304
+ return new m([t], t.nodeSize);
305
+ throw new RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
306
+ }
307
+ };
308
+ g.empty = new g([], 0);
309
+ var H = { index: 0, offset: 0 };
310
+ function B(n, t) {
311
+ return H.index = n, H.offset = t, H;
312
+ }
313
+ var It = class extends Error {
314
+ }, c = class y {
315
+ /**
316
+ Create a slice. When specifying a non-zero open depth, you must
317
+ make sure that there are nodes of at least that depth at the
318
+ appropriate side of the fragment—i.e. if the fragment is an
319
+ empty paragraph node, `openStart` and `openEnd` can't be greater
320
+ than 1.
321
+
322
+ It is not necessary for the content of open nodes to conform to
323
+ the schema's content constraints, though it should be a valid
324
+ start/end/middle for such a node, depending on which sides are
325
+ open.
326
+ */
327
+ constructor(t, e, r) {
328
+ this.content = t, this.openStart = e, this.openEnd = r;
329
+ }
330
+ /**
331
+ The size this slice would add when inserted into a document.
332
+ */
333
+ get size() {
334
+ return this.content.size - this.openStart - this.openEnd;
335
+ }
336
+ /**
337
+ @internal
338
+ */
339
+ insertAt(t, e) {
340
+ let r = lt(this.content, t + this.openStart, e, this.openStart + 1, this.openEnd + 1);
341
+ return r && new y(r, this.openStart, this.openEnd);
342
+ }
343
+ /**
344
+ @internal
345
+ */
346
+ removeBetween(t, e) {
347
+ return new y(at(this.content, t + this.openStart, e + this.openStart), this.openStart, this.openEnd);
348
+ }
349
+ /**
350
+ Tests whether this slice is equal to another slice.
351
+ */
352
+ eq(t) {
353
+ return this.content.eq(t.content) && this.openStart == t.openStart && this.openEnd == t.openEnd;
354
+ }
355
+ /**
356
+ @internal
357
+ */
358
+ toString() {
359
+ return this.content + "(" + this.openStart + "," + this.openEnd + ")";
360
+ }
361
+ /**
362
+ Convert a slice to a JSON-serializable representation.
363
+ */
364
+ toJSON() {
365
+ if (!this.content.size)
366
+ return null;
367
+ let t = { content: this.content.toJSON() };
368
+ return this.openStart > 0 && (t.openStart = this.openStart), this.openEnd > 0 && (t.openEnd = this.openEnd), t;
369
+ }
370
+ /**
371
+ Deserialize a slice from its JSON representation.
372
+ */
373
+ static fromJSON(t, e) {
374
+ if (!e)
375
+ return y.empty;
376
+ let r = e.openStart || 0, i = e.openEnd || 0;
377
+ if (typeof r != "number" || typeof i != "number")
378
+ throw new RangeError("Invalid input for Slice.fromJSON");
379
+ return new y(g.fromJSON(t, e.content), r, i);
380
+ }
381
+ /**
382
+ Create a slice from a fragment by taking the maximum possible
383
+ open value on both side of the fragment.
384
+ */
385
+ static maxOpen(t, e = !0) {
386
+ let r = 0, i = 0;
387
+ for (let s = t.firstChild; s && !s.isLeaf && (e || !s.type.spec.isolating); s = s.firstChild)
388
+ r++;
389
+ for (let s = t.lastChild; s && !s.isLeaf && (e || !s.type.spec.isolating); s = s.lastChild)
390
+ i++;
391
+ return new y(t, r, i);
392
+ }
393
+ };
394
+ c.empty = new c(g.empty, 0, 0);
395
+ function at(n, t, e) {
396
+ let { index: r, offset: i } = n.findIndex(t), s = n.maybeChild(r), { index: o, offset: a } = n.findIndex(e);
397
+ if (i == t || s.isText) {
398
+ if (a != e && !n.child(o).isText)
399
+ throw new RangeError("Removing non-flat range");
400
+ return n.cut(0, t).append(n.cut(e));
401
+ }
402
+ if (r != o)
403
+ throw new RangeError("Removing non-flat range");
404
+ return n.replaceChild(r, s.copy(at(s.content, t - i - 1, e - i - 1)));
405
+ }
406
+ function lt(n, t, e, r, i, s) {
407
+ let { index: o, offset: a } = n.findIndex(t), l = n.maybeChild(o);
408
+ if (a == t || l.isText)
409
+ return s && r <= 0 && i <= 0 && !s.canReplace(o, o, e) ? null : n.cut(0, t).append(e).append(n.cut(t));
410
+ let h = lt(l.content, t - a - 1, e, o == 0 ? r - 1 : 0, o == n.childCount - 1 ? i - 1 : 0, l);
411
+ return h && n.replaceChild(o, l.copy(h));
412
+ }
413
+ var ht = 65535, ut = Math.pow(2, 16);
414
+ function zt(n, t) {
415
+ return n + t * ut;
416
+ }
417
+ function _(n) {
418
+ return n & ht;
419
+ }
420
+ function Jt(n) {
421
+ return (n - (n & ht)) / ut;
422
+ }
423
+ var ct = 1, ft = 2, D = 4, pt = 8, tt = class {
424
+ /**
425
+ @internal
426
+ */
427
+ constructor(n, t, e) {
428
+ this.pos = n, this.delInfo = t, this.recover = e;
429
+ }
430
+ /**
431
+ Tells you whether the position was deleted, that is, whether the
432
+ step removed the token on the side queried (via the `assoc`)
433
+ argument from the document.
434
+ */
435
+ get deleted() {
436
+ return (this.delInfo & pt) > 0;
437
+ }
438
+ /**
439
+ Tells you whether the token before the mapped position was deleted.
440
+ */
441
+ get deletedBefore() {
442
+ return (this.delInfo & (ct | D)) > 0;
443
+ }
444
+ /**
445
+ True when the token after the mapped position was deleted.
446
+ */
447
+ get deletedAfter() {
448
+ return (this.delInfo & (ft | D)) > 0;
449
+ }
450
+ /**
451
+ Tells whether any of the steps mapped through deletes across the
452
+ position (including both the token before and after the
453
+ position).
454
+ */
455
+ get deletedAcross() {
456
+ return (this.delInfo & D) > 0;
457
+ }
458
+ }, k = class x {
459
+ /**
460
+ Create a position map. The modifications to the document are
461
+ represented as an array of numbers, in which each group of three
462
+ represents a modified chunk as `[start, oldSize, newSize]`.
463
+ */
464
+ constructor(t, e = !1) {
465
+ if (this.ranges = t, this.inverted = e, !t.length && x.empty)
466
+ return x.empty;
467
+ }
468
+ /**
469
+ @internal
470
+ */
471
+ recover(t) {
472
+ let e = 0, r = _(t);
473
+ if (!this.inverted)
474
+ for (let i = 0; i < r; i++)
475
+ e += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
476
+ return this.ranges[r * 3] + e + Jt(t);
477
+ }
478
+ mapResult(t, e = 1) {
479
+ return this._map(t, e, !1);
480
+ }
481
+ map(t, e = 1) {
482
+ return this._map(t, e, !0);
483
+ }
484
+ /**
485
+ @internal
486
+ */
487
+ _map(t, e, r) {
488
+ let i = 0, s = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
489
+ for (let a = 0; a < this.ranges.length; a += 3) {
490
+ let l = this.ranges[a] - (this.inverted ? i : 0);
491
+ if (l > t)
492
+ break;
493
+ let h = this.ranges[a + s], u = this.ranges[a + o], S = l + h;
494
+ if (t <= S) {
495
+ let X = h ? t == l ? -1 : t == S ? 1 : e : e, E = l + i + (X < 0 ? 0 : u);
496
+ if (r)
497
+ return E;
498
+ let v = t == (e < 0 ? l : S) ? null : zt(a / 3, t - l), Y = t == l ? ft : t == S ? ct : D;
499
+ return (e < 0 ? t != l : t != S) && (Y |= pt), new tt(E, Y, v);
500
+ }
501
+ i += u - h;
502
+ }
503
+ return r ? t + i : new tt(t + i, 0, null);
504
+ }
505
+ /**
506
+ @internal
507
+ */
508
+ touches(t, e) {
509
+ let r = 0, i = _(e), s = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
510
+ for (let a = 0; a < this.ranges.length; a += 3) {
511
+ let l = this.ranges[a] - (this.inverted ? r : 0);
512
+ if (l > t)
513
+ break;
514
+ let h = this.ranges[a + s], u = l + h;
515
+ if (t <= u && a == i * 3)
516
+ return !0;
517
+ r += this.ranges[a + o] - h;
518
+ }
519
+ return !1;
520
+ }
521
+ /**
522
+ Calls the given function on each of the changed ranges included in
523
+ this map.
524
+ */
525
+ forEach(t) {
526
+ let e = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
527
+ for (let i = 0, s = 0; i < this.ranges.length; i += 3) {
528
+ let o = this.ranges[i], a = o - (this.inverted ? s : 0), l = o + (this.inverted ? 0 : s), h = this.ranges[i + e], u = this.ranges[i + r];
529
+ t(a, a + h, l, l + u), s += u - h;
530
+ }
531
+ }
532
+ /**
533
+ Create an inverted version of this map. The result can be used to
534
+ map positions in the post-step document to the pre-step document.
535
+ */
536
+ invert() {
537
+ return new x(this.ranges, !this.inverted);
538
+ }
539
+ /**
540
+ @internal
541
+ */
542
+ toString() {
543
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
544
+ }
545
+ /**
546
+ Create a map that moves all positions by offset `n` (which may be
547
+ negative). This can be useful when applying steps meant for a
548
+ sub-document to a larger document, or vice-versa.
549
+ */
550
+ static offset(t) {
551
+ return t == 0 ? x.empty : new x(t < 0 ? [0, -t, 0] : [0, 0, t]);
552
+ }
553
+ };
554
+ k.empty = new k([]);
555
+ var $ = /* @__PURE__ */ Object.create(null), p = class {
556
+ /**
557
+ Get the step map that represents the changes made by this step,
558
+ and which can be used to transform between positions in the old
559
+ and the new document.
560
+ */
561
+ getMap() {
562
+ return k.empty;
563
+ }
564
+ /**
565
+ Try to merge this step with another one, to be applied directly
566
+ after it. Returns the merged step when possible, null if the
567
+ steps can't be merged.
568
+ */
569
+ merge(n) {
570
+ return null;
571
+ }
572
+ /**
573
+ Deserialize a step from its JSON representation. Will call
574
+ through to the step class' own implementation of this method.
575
+ */
576
+ static fromJSON(n, t) {
577
+ if (!t || !t.stepType)
578
+ throw new RangeError("Invalid input for Step.fromJSON");
579
+ let e = $[t.stepType];
580
+ if (!e)
581
+ throw new RangeError(`No step type ${t.stepType} defined`);
582
+ return e.fromJSON(n, t);
583
+ }
584
+ /**
585
+ To be able to serialize steps to JSON, each step needs a string
586
+ ID to attach to its JSON representation. Use this method to
587
+ register an ID for your step classes. Try to pick something
588
+ that's unlikely to clash with steps from other modules.
589
+ */
590
+ static jsonID(n, t) {
591
+ if (n in $)
592
+ throw new RangeError("Duplicate use of step JSON ID " + n);
593
+ return $[n] = t, t.prototype.jsonID = n, t;
594
+ }
595
+ }, d = class T {
596
+ /**
597
+ @internal
598
+ */
599
+ constructor(t, e) {
600
+ this.doc = t, this.failed = e;
601
+ }
602
+ /**
603
+ Create a successful step result.
604
+ */
605
+ static ok(t) {
606
+ return new T(t, null);
607
+ }
608
+ /**
609
+ Create a failed step result.
610
+ */
611
+ static fail(t) {
612
+ return new T(null, t);
613
+ }
614
+ /**
615
+ Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
616
+ arguments. Create a successful result if it succeeds, and a
617
+ failed one if it throws a `ReplaceError`.
618
+ */
619
+ static fromReplace(t, e, r, i) {
620
+ try {
621
+ return T.ok(t.replace(e, r, i));
622
+ } catch (s) {
623
+ if (s instanceof It)
624
+ return T.fail(s.message);
625
+ throw s;
626
+ }
627
+ }
628
+ };
629
+ function Q(n, t, e) {
630
+ let r = [];
631
+ for (let i = 0; i < n.childCount; i++) {
632
+ let s = n.child(i);
633
+ s.content.size && (s = s.copy(Q(s.content, t, s))), s.isInline && (s = t(s, e, i)), r.push(s);
634
+ }
635
+ return g.fromArray(r);
636
+ }
637
+ var mt = class A extends p {
638
+ /**
639
+ Create a mark step.
640
+ */
641
+ constructor(t, e, r) {
642
+ super(), this.from = t, this.to = e, this.mark = r;
643
+ }
644
+ apply(t) {
645
+ let e = t.slice(this.from, this.to), r = t.resolve(this.from), i = r.node(r.sharedDepth(this.to)), s = new c(Q(e.content, (o, a) => !o.isAtom || !a.type.allowsMarkType(this.mark.type) ? o : o.mark(this.mark.addToSet(o.marks)), i), e.openStart, e.openEnd);
646
+ return d.fromReplace(t, this.from, this.to, s);
647
+ }
648
+ invert() {
649
+ return new dt(this.from, this.to, this.mark);
650
+ }
651
+ map(t) {
652
+ let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
653
+ return e.deleted && r.deleted || e.pos >= r.pos ? null : new A(e.pos, r.pos, this.mark);
654
+ }
655
+ merge(t) {
656
+ return t instanceof A && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new A(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
657
+ }
658
+ toJSON() {
659
+ return {
660
+ stepType: "addMark",
661
+ mark: this.mark.toJSON(),
662
+ from: this.from,
663
+ to: this.to
664
+ };
665
+ }
666
+ /**
667
+ @internal
668
+ */
669
+ static fromJSON(t, e) {
670
+ if (typeof e.from != "number" || typeof e.to != "number")
671
+ throw new RangeError("Invalid input for AddMarkStep.fromJSON");
672
+ return new A(e.from, e.to, t.markFromJSON(e.mark));
673
+ }
674
+ };
675
+ p.jsonID("addMark", mt);
676
+ var dt = class I extends p {
677
+ /**
678
+ Create a mark-removing step.
679
+ */
680
+ constructor(t, e, r) {
681
+ super(), this.from = t, this.to = e, this.mark = r;
682
+ }
683
+ apply(t) {
684
+ let e = t.slice(this.from, this.to), r = new c(Q(e.content, (i) => i.mark(this.mark.removeFromSet(i.marks)), t), e.openStart, e.openEnd);
685
+ return d.fromReplace(t, this.from, this.to, r);
686
+ }
687
+ invert() {
688
+ return new mt(this.from, this.to, this.mark);
689
+ }
690
+ map(t) {
691
+ let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
692
+ return e.deleted && r.deleted || e.pos >= r.pos ? null : new I(e.pos, r.pos, this.mark);
693
+ }
694
+ merge(t) {
695
+ return t instanceof I && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new I(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
696
+ }
697
+ toJSON() {
698
+ return {
699
+ stepType: "removeMark",
700
+ mark: this.mark.toJSON(),
701
+ from: this.from,
702
+ to: this.to
703
+ };
704
+ }
705
+ /**
706
+ @internal
707
+ */
708
+ static fromJSON(t, e) {
709
+ if (typeof e.from != "number" || typeof e.to != "number")
710
+ throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
711
+ return new I(e.from, e.to, t.markFromJSON(e.mark));
712
+ }
713
+ };
714
+ p.jsonID("removeMark", dt);
715
+ var St = class z extends p {
716
+ /**
717
+ Create a node mark step.
718
+ */
719
+ constructor(t, e) {
720
+ super(), this.pos = t, this.mark = e;
721
+ }
722
+ apply(t) {
723
+ let e = t.nodeAt(this.pos);
724
+ if (!e)
725
+ return d.fail("No node at mark step's position");
726
+ let r = e.type.create(e.attrs, null, this.mark.addToSet(e.marks));
727
+ return d.fromReplace(t, this.pos, this.pos + 1, new c(g.from(r), 0, e.isLeaf ? 0 : 1));
728
+ }
729
+ invert(t) {
730
+ let e = t.nodeAt(this.pos);
731
+ if (e) {
732
+ let r = this.mark.addToSet(e.marks);
733
+ if (r.length == e.marks.length) {
734
+ for (let i = 0; i < e.marks.length; i++)
735
+ if (!e.marks[i].isInSet(r))
736
+ return new z(this.pos, e.marks[i]);
737
+ return new z(this.pos, this.mark);
738
+ }
739
+ }
740
+ return new gt(this.pos, this.mark);
741
+ }
742
+ map(t) {
743
+ let e = t.mapResult(this.pos, 1);
744
+ return e.deletedAfter ? null : new z(e.pos, this.mark);
745
+ }
746
+ toJSON() {
747
+ return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
748
+ }
749
+ /**
750
+ @internal
751
+ */
752
+ static fromJSON(t, e) {
753
+ if (typeof e.pos != "number")
754
+ throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
755
+ return new z(e.pos, t.markFromJSON(e.mark));
756
+ }
757
+ };
758
+ p.jsonID("addNodeMark", St);
759
+ var gt = class W extends p {
760
+ /**
761
+ Create a mark-removing step.
762
+ */
763
+ constructor(t, e) {
764
+ super(), this.pos = t, this.mark = e;
765
+ }
766
+ apply(t) {
767
+ let e = t.nodeAt(this.pos);
768
+ if (!e)
769
+ return d.fail("No node at mark step's position");
770
+ let r = e.type.create(e.attrs, null, this.mark.removeFromSet(e.marks));
771
+ return d.fromReplace(t, this.pos, this.pos + 1, new c(g.from(r), 0, e.isLeaf ? 0 : 1));
772
+ }
773
+ invert(t) {
774
+ let e = t.nodeAt(this.pos);
775
+ return !e || !this.mark.isInSet(e.marks) ? this : new St(this.pos, this.mark);
776
+ }
777
+ map(t) {
778
+ let e = t.mapResult(this.pos, 1);
779
+ return e.deletedAfter ? null : new W(e.pos, this.mark);
780
+ }
781
+ toJSON() {
782
+ return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
783
+ }
784
+ /**
785
+ @internal
786
+ */
787
+ static fromJSON(t, e) {
788
+ if (typeof e.pos != "number")
789
+ throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
790
+ return new W(e.pos, t.markFromJSON(e.mark));
791
+ }
792
+ };
793
+ p.jsonID("removeNodeMark", gt);
794
+ var U = class w extends p {
795
+ /**
796
+ The given `slice` should fit the 'gap' between `from` and
797
+ `to`—the depths must line up, and the surrounding nodes must be
798
+ able to be joined with the open sides of the slice. When
799
+ `structure` is true, the step will fail if the content between
800
+ from and to is not just a sequence of closing and then opening
801
+ tokens (this is to guard against rebased replace steps
802
+ overwriting something they weren't supposed to).
803
+ */
804
+ constructor(t, e, r, i = !1) {
805
+ super(), this.from = t, this.to = e, this.slice = r, this.structure = i;
806
+ }
807
+ apply(t) {
808
+ return this.structure && V(t, this.from, this.to) ? d.fail("Structure replace would overwrite content") : d.fromReplace(t, this.from, this.to, this.slice);
809
+ }
810
+ getMap() {
811
+ return new k([this.from, this.to - this.from, this.slice.size]);
812
+ }
813
+ invert(t) {
814
+ return new w(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
815
+ }
816
+ map(t) {
817
+ let e = t.mapResult(this.to, -1), r = this.from == this.to && w.MAP_BIAS < 0 ? e : t.mapResult(this.from, 1);
818
+ return r.deletedAcross && e.deletedAcross ? null : new w(r.pos, Math.max(r.pos, e.pos), this.slice, this.structure);
819
+ }
820
+ merge(t) {
821
+ if (!(t instanceof w) || t.structure || this.structure)
822
+ return null;
823
+ if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
824
+ let e = this.slice.size + t.slice.size == 0 ? c.empty : new c(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
825
+ return new w(this.from, this.to + (t.to - t.from), e, this.structure);
826
+ } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
827
+ let e = this.slice.size + t.slice.size == 0 ? c.empty : new c(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
828
+ return new w(t.from, this.to, e, this.structure);
829
+ } else
830
+ return null;
831
+ }
832
+ toJSON() {
833
+ let t = { stepType: "replace", from: this.from, to: this.to };
834
+ return this.slice.size && (t.slice = this.slice.toJSON()), this.structure && (t.structure = !0), t;
835
+ }
836
+ /**
837
+ @internal
838
+ */
839
+ static fromJSON(t, e) {
840
+ if (typeof e.from != "number" || typeof e.to != "number")
841
+ throw new RangeError("Invalid input for ReplaceStep.fromJSON");
842
+ return new w(e.from, e.to, c.fromJSON(t, e.slice), !!e.structure);
843
+ }
844
+ };
845
+ U.MAP_BIAS = 1;
846
+ p.jsonID("replace", U);
847
+ var wt = class q extends p {
848
+ /**
849
+ Create a replace-around step with the given range and gap.
850
+ `insert` should be the point in the slice into which the content
851
+ of the gap should be moved. `structure` has the same meaning as
852
+ it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
853
+ */
854
+ constructor(t, e, r, i, s, o, a = !1) {
855
+ super(), this.from = t, this.to = e, this.gapFrom = r, this.gapTo = i, this.slice = s, this.insert = o, this.structure = a;
856
+ }
857
+ apply(t) {
858
+ if (this.structure && (V(t, this.from, this.gapFrom) || V(t, this.gapTo, this.to)))
859
+ return d.fail("Structure gap-replace would overwrite content");
860
+ let e = t.slice(this.gapFrom, this.gapTo);
861
+ if (e.openStart || e.openEnd)
862
+ return d.fail("Gap is not a flat range");
863
+ let r = this.slice.insertAt(this.insert, e.content);
864
+ return r ? d.fromReplace(t, this.from, this.to, r) : d.fail("Content does not fit in gap");
865
+ }
866
+ getMap() {
867
+ return new k([
868
+ this.from,
869
+ this.gapFrom - this.from,
870
+ this.insert,
871
+ this.gapTo,
872
+ this.to - this.gapTo,
873
+ this.slice.size - this.insert
874
+ ]);
875
+ }
876
+ invert(t) {
877
+ let e = this.gapTo - this.gapFrom;
878
+ return new q(this.from, this.from + this.slice.size + e, this.from + this.insert, this.from + this.insert + e, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
879
+ }
880
+ map(t) {
881
+ let e = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? e.pos : t.map(this.gapFrom, -1), s = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
882
+ return e.deletedAcross && r.deletedAcross || i < e.pos || s > r.pos ? null : new q(e.pos, r.pos, i, s, this.slice, this.insert, this.structure);
883
+ }
884
+ toJSON() {
885
+ let t = {
886
+ stepType: "replaceAround",
887
+ from: this.from,
888
+ to: this.to,
889
+ gapFrom: this.gapFrom,
890
+ gapTo: this.gapTo,
891
+ insert: this.insert
892
+ };
893
+ return this.slice.size && (t.slice = this.slice.toJSON()), this.structure && (t.structure = !0), t;
894
+ }
895
+ /**
896
+ @internal
897
+ */
898
+ static fromJSON(t, e) {
899
+ if (typeof e.from != "number" || typeof e.to != "number" || typeof e.gapFrom != "number" || typeof e.gapTo != "number" || typeof e.insert != "number")
900
+ throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
901
+ return new q(e.from, e.to, e.gapFrom, e.gapTo, c.fromJSON(t, e.slice), e.insert, !!e.structure);
902
+ }
903
+ };
904
+ p.jsonID("replaceAround", wt);
905
+ function V(n, t, e) {
906
+ let r = n.resolve(t), i = e - t, s = r.depth;
907
+ for (; i > 0 && s > 0 && r.indexAfter(s) == r.node(s).childCount; )
908
+ s--, i--;
909
+ if (i > 0) {
910
+ let o = r.node(s).maybeChild(r.indexAfter(s));
911
+ for (; i > 0; ) {
912
+ if (!o || o.isLeaf)
913
+ return !0;
914
+ o = o.firstChild, i--;
915
+ }
916
+ }
917
+ return !1;
918
+ }
919
+ var Mt = class L extends p {
920
+ /**
921
+ Construct an attribute step.
922
+ */
923
+ constructor(t, e, r) {
924
+ super(), this.pos = t, this.attr = e, this.value = r;
925
+ }
926
+ apply(t) {
927
+ let e = t.nodeAt(this.pos);
928
+ if (!e)
929
+ return d.fail("No node at attribute step's position");
930
+ let r = /* @__PURE__ */ Object.create(null);
931
+ for (let s in e.attrs)
932
+ r[s] = e.attrs[s];
933
+ r[this.attr] = this.value;
934
+ let i = e.type.create(r, null, e.marks);
935
+ return d.fromReplace(t, this.pos, this.pos + 1, new c(g.from(i), 0, e.isLeaf ? 0 : 1));
936
+ }
937
+ getMap() {
938
+ return k.empty;
939
+ }
940
+ invert(t) {
941
+ return new L(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
942
+ }
943
+ map(t) {
944
+ let e = t.mapResult(this.pos, 1);
945
+ return e.deletedAfter ? null : new L(e.pos, this.attr, this.value);
946
+ }
947
+ toJSON() {
948
+ return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
949
+ }
950
+ static fromJSON(t, e) {
951
+ if (typeof e.pos != "number" || typeof e.attr != "string")
952
+ throw new RangeError("Invalid input for AttrStep.fromJSON");
953
+ return new L(e.pos, e.attr, e.value);
954
+ }
955
+ };
956
+ p.jsonID("attr", Mt);
957
+ var bt = class G extends p {
958
+ /**
959
+ Construct an attribute step.
960
+ */
961
+ constructor(t, e) {
962
+ super(), this.attr = t, this.value = e;
963
+ }
964
+ apply(t) {
965
+ let e = /* @__PURE__ */ Object.create(null);
966
+ for (let i in t.attrs)
967
+ e[i] = t.attrs[i];
968
+ e[this.attr] = this.value;
969
+ let r = t.type.create(e, t.content, t.marks);
970
+ return d.ok(r);
971
+ }
972
+ getMap() {
973
+ return k.empty;
974
+ }
975
+ invert(t) {
976
+ return new G(this.attr, t.attrs[this.attr]);
977
+ }
978
+ map(t) {
979
+ return this;
980
+ }
981
+ toJSON() {
982
+ return { stepType: "docAttr", attr: this.attr, value: this.value };
983
+ }
984
+ static fromJSON(t, e) {
985
+ if (typeof e.attr != "string")
986
+ throw new RangeError("Invalid input for DocAttrStep.fromJSON");
987
+ return new G(e.attr, e.value);
988
+ }
989
+ };
990
+ p.jsonID("docAttr", bt);
991
+ var C = class extends Error {
992
+ };
993
+ C = function n(t) {
994
+ let e = Error.call(this, t);
995
+ return e.__proto__ = n.prototype, e;
996
+ };
997
+ C.prototype = Object.create(Error.prototype);
998
+ C.prototype.constructor = C;
999
+ C.prototype.name = "TransformError";
1000
+ var K = /* @__PURE__ */ Object.create(null), f = class {
1001
+ /**
1002
+ Initialize a selection with the head and anchor and ranges. If no
1003
+ ranges are given, constructs a single range across `$anchor` and
1004
+ `$head`.
1005
+ */
1006
+ constructor(n, t, e) {
1007
+ this.$anchor = n, this.$head = t, this.ranges = e || [new Ct(n.min(t), n.max(t))];
1008
+ }
1009
+ /**
1010
+ The selection's anchor, as an unresolved position.
1011
+ */
1012
+ get anchor() {
1013
+ return this.$anchor.pos;
1014
+ }
1015
+ /**
1016
+ The selection's head.
1017
+ */
1018
+ get head() {
1019
+ return this.$head.pos;
1020
+ }
1021
+ /**
1022
+ The lower bound of the selection's main range.
1023
+ */
1024
+ get from() {
1025
+ return this.$from.pos;
1026
+ }
1027
+ /**
1028
+ The upper bound of the selection's main range.
1029
+ */
1030
+ get to() {
1031
+ return this.$to.pos;
1032
+ }
1033
+ /**
1034
+ The resolved lower bound of the selection's main range.
1035
+ */
1036
+ get $from() {
1037
+ return this.ranges[0].$from;
1038
+ }
1039
+ /**
1040
+ The resolved upper bound of the selection's main range.
1041
+ */
1042
+ get $to() {
1043
+ return this.ranges[0].$to;
1044
+ }
1045
+ /**
1046
+ Indicates whether the selection contains any content.
1047
+ */
1048
+ get empty() {
1049
+ let n = this.ranges;
1050
+ for (let t = 0; t < n.length; t++)
1051
+ if (n[t].$from.pos != n[t].$to.pos)
1052
+ return !1;
1053
+ return !0;
1054
+ }
1055
+ /**
1056
+ Get the content of this selection as a slice.
1057
+ */
1058
+ content() {
1059
+ return this.$from.doc.slice(this.from, this.to, !0);
1060
+ }
1061
+ /**
1062
+ Replace the selection with a slice or, if no slice is given,
1063
+ delete the selection. Will append to the given transaction.
1064
+ */
1065
+ replace(n, t = c.empty) {
1066
+ let e = t.content.lastChild, r = null;
1067
+ for (let o = 0; o < t.openEnd; o++)
1068
+ r = e, e = e.lastChild;
1069
+ let i = n.steps.length, s = this.ranges;
1070
+ for (let o = 0; o < s.length; o++) {
1071
+ let { $from: a, $to: l } = s[o], h = n.mapping.slice(i);
1072
+ n.replaceRange(h.map(a.pos), h.map(l.pos), o ? c.empty : t), o == 0 && nt(n, i, (e ? e.isInline : r && r.isTextblock) ? -1 : 1);
1073
+ }
1074
+ }
1075
+ /**
1076
+ Replace the selection with the given node, appending the changes
1077
+ to the given transaction.
1078
+ */
1079
+ replaceWith(n, t) {
1080
+ let e = n.steps.length, r = this.ranges;
1081
+ for (let i = 0; i < r.length; i++) {
1082
+ let { $from: s, $to: o } = r[i], a = n.mapping.slice(e), l = a.map(s.pos), h = a.map(o.pos);
1083
+ i ? n.deleteRange(l, h) : (n.replaceRangeWith(l, h, t), nt(n, e, t.isInline ? -1 : 1));
1084
+ }
1085
+ }
1086
+ /**
1087
+ Find a valid cursor or leaf node selection starting at the given
1088
+ position and searching back if `dir` is negative, and forward if
1089
+ positive. When `textOnly` is true, only consider cursor
1090
+ selections. Will return null when no valid selection position is
1091
+ found.
1092
+ */
1093
+ static findFrom(n, t, e = !1) {
1094
+ let r = n.parent.inlineContent ? new R(n) : N(n.node(0), n.parent, n.pos, n.index(), t, e);
1095
+ if (r)
1096
+ return r;
1097
+ for (let i = n.depth - 1; i >= 0; i--) {
1098
+ let s = t < 0 ? N(n.node(0), n.node(i), n.before(i + 1), n.index(i), t, e) : N(n.node(0), n.node(i), n.after(i + 1), n.index(i) + 1, t, e);
1099
+ if (s)
1100
+ return s;
1101
+ }
1102
+ return null;
1103
+ }
1104
+ /**
1105
+ Find a valid cursor or leaf node selection near the given
1106
+ position. Searches forward first by default, but if `bias` is
1107
+ negative, it will search backwards first.
1108
+ */
1109
+ static near(n, t = 1) {
1110
+ return this.findFrom(n, t) || this.findFrom(n, -t) || new b(n.node(0));
1111
+ }
1112
+ /**
1113
+ Find the cursor or leaf node selection closest to the start of
1114
+ the given document. Will return an
1115
+ [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
1116
+ exists.
1117
+ */
1118
+ static atStart(n) {
1119
+ return N(n, n, 0, 0, 1) || new b(n);
1120
+ }
1121
+ /**
1122
+ Find the cursor or leaf node selection closest to the end of the
1123
+ given document.
1124
+ */
1125
+ static atEnd(n) {
1126
+ return N(n, n, n.content.size, n.childCount, -1) || new b(n);
1127
+ }
1128
+ /**
1129
+ Deserialize the JSON representation of a selection. Must be
1130
+ implemented for custom classes (as a static class method).
1131
+ */
1132
+ static fromJSON(n, t) {
1133
+ if (!t || !t.type)
1134
+ throw new RangeError("Invalid input for Selection.fromJSON");
1135
+ let e = K[t.type];
1136
+ if (!e)
1137
+ throw new RangeError(`No selection type ${t.type} defined`);
1138
+ return e.fromJSON(n, t);
1139
+ }
1140
+ /**
1141
+ To be able to deserialize selections from JSON, custom selection
1142
+ classes must register themselves with an ID string, so that they
1143
+ can be disambiguated. Try to pick something that's unlikely to
1144
+ clash with classes from other modules.
1145
+ */
1146
+ static jsonID(n, t) {
1147
+ if (n in K)
1148
+ throw new RangeError("Duplicate use of selection JSON ID " + n);
1149
+ return K[n] = t, t.prototype.jsonID = n, t;
1150
+ }
1151
+ /**
1152
+ Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
1153
+ which is a value that can be mapped without having access to a
1154
+ current document, and later resolved to a real selection for a
1155
+ given document again. (This is used mostly by the history to
1156
+ track and restore old selections.) The default implementation of
1157
+ this method just converts the selection to a text selection and
1158
+ returns the bookmark for that.
1159
+ */
1160
+ getBookmark() {
1161
+ return R.between(this.$anchor, this.$head).getBookmark();
1162
+ }
1163
+ };
1164
+ f.prototype.visible = !0;
1165
+ var Ct = class {
1166
+ /**
1167
+ Create a range.
1168
+ */
1169
+ constructor(n, t) {
1170
+ this.$from = n, this.$to = t;
1171
+ }
1172
+ }, et = !1;
1173
+ function rt(n) {
1174
+ !et && !n.parent.inlineContent && (et = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + n.parent.type.name + ")"));
1175
+ }
1176
+ var R = class J extends f {
1177
+ /**
1178
+ Construct a text selection between the given points.
1179
+ */
1180
+ constructor(t, e = t) {
1181
+ rt(t), rt(e), super(t, e);
1182
+ }
1183
+ /**
1184
+ Returns a resolved position if this is a cursor selection (an
1185
+ empty text selection), and null otherwise.
1186
+ */
1187
+ get $cursor() {
1188
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
1189
+ }
1190
+ map(t, e) {
1191
+ let r = t.resolve(e.map(this.head));
1192
+ if (!r.parent.inlineContent)
1193
+ return f.near(r);
1194
+ let i = t.resolve(e.map(this.anchor));
1195
+ return new J(i.parent.inlineContent ? i : r, r);
1196
+ }
1197
+ replace(t, e = c.empty) {
1198
+ if (super.replace(t, e), e == c.empty) {
1199
+ let r = this.$from.marksAcross(this.$to);
1200
+ r && t.ensureMarks(r);
1201
+ }
1202
+ }
1203
+ eq(t) {
1204
+ return t instanceof J && t.anchor == this.anchor && t.head == this.head;
1205
+ }
1206
+ getBookmark() {
1207
+ return new kt(this.anchor, this.head);
1208
+ }
1209
+ toJSON() {
1210
+ return { type: "text", anchor: this.anchor, head: this.head };
1211
+ }
1212
+ /**
1213
+ @internal
1214
+ */
1215
+ static fromJSON(t, e) {
1216
+ if (typeof e.anchor != "number" || typeof e.head != "number")
1217
+ throw new RangeError("Invalid input for TextSelection.fromJSON");
1218
+ return new J(t.resolve(e.anchor), t.resolve(e.head));
1219
+ }
1220
+ /**
1221
+ Create a text selection from non-resolved positions.
1222
+ */
1223
+ static create(t, e, r = e) {
1224
+ let i = t.resolve(e);
1225
+ return new this(i, r == e ? i : t.resolve(r));
1226
+ }
1227
+ /**
1228
+ Return a text selection that spans the given positions or, if
1229
+ they aren't text positions, find a text selection near them.
1230
+ `bias` determines whether the method searches forward (default)
1231
+ or backwards (negative number) first. Will fall back to calling
1232
+ [`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
1233
+ doesn't contain a valid text position.
1234
+ */
1235
+ static between(t, e, r) {
1236
+ let i = t.pos - e.pos;
1237
+ if ((!r || i) && (r = i >= 0 ? 1 : -1), !e.parent.inlineContent) {
1238
+ let s = f.findFrom(e, r, !0) || f.findFrom(e, -r, !0);
1239
+ if (s)
1240
+ e = s.$head;
1241
+ else
1242
+ return f.near(e, r);
1243
+ }
1244
+ return t.parent.inlineContent || (i == 0 ? t = e : (t = (f.findFrom(t, -r, !0) || f.findFrom(t, r, !0)).$anchor, t.pos < e.pos != i < 0 && (t = e))), new J(t, e);
1245
+ }
1246
+ };
1247
+ f.jsonID("text", R);
1248
+ var kt = class vt {
1249
+ constructor(t, e) {
1250
+ this.anchor = t, this.head = e;
1251
+ }
1252
+ map(t) {
1253
+ return new vt(t.map(this.anchor), t.map(this.head));
1254
+ }
1255
+ resolve(t) {
1256
+ return R.between(t.resolve(this.anchor), t.resolve(this.head));
1257
+ }
1258
+ }, O = class M extends f {
1259
+ /**
1260
+ Create a node selection. Does not verify the validity of its
1261
+ argument.
1262
+ */
1263
+ constructor(t) {
1264
+ let e = t.nodeAfter, r = t.node(0).resolve(t.pos + e.nodeSize);
1265
+ super(t, r), this.node = e;
1266
+ }
1267
+ map(t, e) {
1268
+ let { deleted: r, pos: i } = e.mapResult(this.anchor), s = t.resolve(i);
1269
+ return r ? f.near(s) : new M(s);
1270
+ }
1271
+ content() {
1272
+ return new c(g.from(this.node), 0, 0);
1273
+ }
1274
+ eq(t) {
1275
+ return t instanceof M && t.anchor == this.anchor;
1276
+ }
1277
+ toJSON() {
1278
+ return { type: "node", anchor: this.anchor };
1279
+ }
1280
+ getBookmark() {
1281
+ return new Bt(this.anchor);
1282
+ }
1283
+ /**
1284
+ @internal
1285
+ */
1286
+ static fromJSON(t, e) {
1287
+ if (typeof e.anchor != "number")
1288
+ throw new RangeError("Invalid input for NodeSelection.fromJSON");
1289
+ return new M(t.resolve(e.anchor));
1290
+ }
1291
+ /**
1292
+ Create a node selection from non-resolved positions.
1293
+ */
1294
+ static create(t, e) {
1295
+ return new M(t.resolve(e));
1296
+ }
1297
+ /**
1298
+ Determines whether the given node may be selected as a node
1299
+ selection.
1300
+ */
1301
+ static isSelectable(t) {
1302
+ return !t.isText && t.type.spec.selectable !== !1;
1303
+ }
1304
+ };
1305
+ O.prototype.visible = !1;
1306
+ f.jsonID("node", O);
1307
+ var Bt = class yt {
1308
+ constructor(t) {
1309
+ this.anchor = t;
1310
+ }
1311
+ map(t) {
1312
+ let { deleted: e, pos: r } = t.mapResult(this.anchor);
1313
+ return e ? new kt(r, r) : new yt(r);
1314
+ }
1315
+ resolve(t) {
1316
+ let e = t.resolve(this.anchor), r = e.nodeAfter;
1317
+ return r && O.isSelectable(r) ? new O(e) : f.near(e);
1318
+ }
1319
+ }, b = class P extends f {
1320
+ /**
1321
+ Create an all-selection over the given document.
1322
+ */
1323
+ constructor(t) {
1324
+ super(t.resolve(0), t.resolve(t.content.size));
1325
+ }
1326
+ replace(t, e = c.empty) {
1327
+ if (e == c.empty) {
1328
+ t.delete(0, t.doc.content.size);
1329
+ let r = f.atStart(t.doc);
1330
+ r.eq(t.selection) || t.setSelection(r);
1331
+ } else
1332
+ super.replace(t, e);
1333
+ }
1334
+ toJSON() {
1335
+ return { type: "all" };
1336
+ }
1337
+ /**
1338
+ @internal
1339
+ */
1340
+ static fromJSON(t) {
1341
+ return new P(t);
1342
+ }
1343
+ map(t) {
1344
+ return new P(t);
1345
+ }
1346
+ eq(t) {
1347
+ return t instanceof P;
1348
+ }
1349
+ getBookmark() {
1350
+ return Ft;
1351
+ }
1352
+ };
1353
+ f.jsonID("all", b);
1354
+ var Ft = {
1355
+ map() {
1356
+ return this;
1357
+ },
1358
+ resolve(n) {
1359
+ return new b(n);
1360
+ }
1361
+ };
1362
+ function N(n, t, e, r, i, s = !1) {
1363
+ if (t.inlineContent)
1364
+ return R.create(n, e);
1365
+ for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
1366
+ let a = t.child(o);
1367
+ if (a.isAtom) {
1368
+ if (!s && O.isSelectable(a))
1369
+ return O.create(n, e - (i < 0 ? a.nodeSize : 0));
1370
+ } else {
1371
+ let l = N(n, a, e + i, i < 0 ? a.childCount : 0, i, s);
1372
+ if (l)
1373
+ return l;
1374
+ }
1375
+ e += a.nodeSize * i;
1376
+ }
1377
+ return null;
1378
+ }
1379
+ function nt(n, t, e) {
1380
+ let r = n.steps.length - 1;
1381
+ if (r < t)
1382
+ return;
1383
+ let i = n.steps[r];
1384
+ if (!(i instanceof U || i instanceof wt))
1385
+ return;
1386
+ let s = n.mapping.maps[r], o;
1387
+ s.forEach((a, l, h, u) => {
1388
+ o == null && (o = u);
1389
+ }), n.setSelection(f.near(n.doc.resolve(o), e));
1390
+ }
1391
+ function it(n, t) {
1392
+ return !t || !n ? n : n.bind(t);
1393
+ }
1394
+ var F = class {
1395
+ constructor(n, t, e) {
1396
+ this.name = n, this.init = it(t.init, e), this.apply = it(t.apply, e);
1397
+ }
1398
+ };
1399
+ new F("doc", {
1400
+ init(n) {
1401
+ return n.doc || n.schema.topNodeType.createAndFill();
1402
+ },
1403
+ apply(n) {
1404
+ return n.doc;
1405
+ }
1406
+ }), new F("selection", {
1407
+ init(n, t) {
1408
+ return n.selection || f.atStart(t.doc);
1409
+ },
1410
+ apply(n) {
1411
+ return n.selection;
1412
+ }
1413
+ }), new F("storedMarks", {
1414
+ init(n) {
1415
+ return n.storedMarks || null;
1416
+ },
1417
+ apply(n, t, e, r) {
1418
+ return r.selection.$cursor ? n.storedMarks : null;
1419
+ }
1420
+ }), new F("scrollToSelection", {
1421
+ init() {
1422
+ return 0;
1423
+ },
1424
+ apply(n, t) {
1425
+ return n.scrolledIntoView ? t + 1 : t;
1426
+ }
1427
+ });
1428
+ var Dt = (n, t) => {
1429
+ var e;
1430
+ const { state: r, view: i } = n, { selection: s } = r;
1431
+ if (!s.empty) return !1;
1432
+ const { $from: o } = s;
1433
+ if (o.parentOffset !== 0) return !1;
1434
+ const a = o.depth - 1, l = o.node(a), h = o.index(a);
1435
+ if (h === 0) return !1;
1436
+ if (l.type === t)
1437
+ return n.commands.lift(t.name);
1438
+ const u = l.child(h - 1);
1439
+ if (u.type !== t || !((e = u.lastChild) != null && e.isTextblock))
1440
+ return !1;
1441
+ const S = o.before(), E = S - 1 - 1, { tr: v } = r;
1442
+ return v.delete(S, o.after()).insert(E, o.parent.content), v.setSelection(R.create(v.doc, E)), i.dispatch(v.scrollIntoView()), !0;
1443
+ }, qt = /^\s*>\s$/, Lt = xt.create({
8
1444
  name: "blockquote",
9
1445
  addOptions() {
10
1446
  return {
@@ -17,89 +1453,90 @@ var B = /^\s*>\s$/, A = k.create({
17
1453
  parseHTML() {
18
1454
  return [{ tag: "blockquote" }];
19
1455
  },
20
- renderHTML({ HTMLAttributes: t }) {
21
- return /* @__PURE__ */ p("blockquote", { ...g(this.options.HTMLAttributes, t), children: /* @__PURE__ */ p("slot", {}) });
1456
+ renderHTML({ HTMLAttributes: n }) {
1457
+ return /* @__PURE__ */ Z("blockquote", { ...Rt(this.options.HTMLAttributes, n), children: /* @__PURE__ */ Z("slot", {}) });
22
1458
  },
23
- parseMarkdown: (t, o) => {
1459
+ parseMarkdown: (n, t) => {
24
1460
  var e;
25
- const n = (e = o.parseBlockChildren) != null ? e : o.parseChildren;
26
- return o.createNode("blockquote", void 0, n(t.tokens || []));
1461
+ const r = (e = t.parseBlockChildren) != null ? e : t.parseChildren;
1462
+ return t.createNode("blockquote", void 0, r(n.tokens || []));
27
1463
  },
28
- renderMarkdown: (t, o) => {
29
- if (!t.content)
1464
+ renderMarkdown: (n, t) => {
1465
+ if (!n.content)
30
1466
  return "";
31
- const e = ">", n = [];
32
- return t.content.forEach((r, i) => {
33
- var s, c;
34
- const a = ((c = (s = o.renderChild) == null ? void 0 : s.call(o, r, i)) != null ? c : o.renderChildren([r])).split(`
35
- `).map((d) => d.trim() === "" ? e : `${e} ${d}`);
36
- n.push(a.join(`
1467
+ const e = ">", r = [];
1468
+ return n.content.forEach((i, s) => {
1469
+ var o, a;
1470
+ const u = ((a = (o = t.renderChild) == null ? void 0 : o.call(t, i, s)) != null ? a : t.renderChildren([i])).split(`
1471
+ `).map((S) => S.trim() === "" ? e : `${e} ${S}`);
1472
+ r.push(u.join(`
37
1473
  `));
38
- }), n.join(`
1474
+ }), r.join(`
39
1475
  ${e}
40
1476
  `);
41
1477
  },
42
1478
  addCommands() {
43
1479
  return {
44
- setBlockquote: () => ({ commands: t }) => t.wrapIn(this.name),
45
- toggleBlockquote: () => ({ commands: t }) => t.toggleWrap(this.name),
46
- unsetBlockquote: () => ({ commands: t }) => t.lift(this.name)
1480
+ setBlockquote: () => ({ commands: n }) => n.wrapIn(this.name),
1481
+ toggleBlockquote: () => ({ commands: n }) => n.toggleWrap(this.name),
1482
+ unsetBlockquote: () => ({ commands: n }) => n.lift(this.name)
47
1483
  };
48
1484
  },
49
1485
  addKeyboardShortcuts() {
50
1486
  return {
51
- "Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
1487
+ "Mod-Shift-b": () => this.editor.commands.toggleBlockquote(),
1488
+ Backspace: () => Dt(this.editor, this.type)
52
1489
  };
53
1490
  },
54
1491
  addInputRules() {
55
1492
  return [
56
- h({
57
- find: B,
1493
+ Nt({
1494
+ find: qt,
58
1495
  type: this.type
59
1496
  })
60
1497
  ];
61
1498
  }
62
1499
  });
63
- function L() {
64
- const t = f(x.name), {
65
- icon: o = void 0,
1500
+ function Qt() {
1501
+ const n = Et(Pt.name), {
1502
+ icon: t = void 0,
66
1503
  tooltip: e = void 0,
67
- shortcutKeys: n = void 0,
68
- tooltipOptions: r = {},
69
- action: i = void 0,
70
- isActive: s = void 0
71
- } = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: c, disabled: u, update: l } = q(s), a = () => {
72
- u || i && (i(), l());
1504
+ shortcutKeys: r = void 0,
1505
+ tooltipOptions: i = {},
1506
+ action: s = void 0,
1507
+ isActive: o = void 0
1508
+ } = (n == null ? void 0 : n.componentProps) ?? {}, { dataState: a, disabled: l, update: h } = Tt(o), u = () => {
1509
+ l || s && (s(), h());
73
1510
  };
74
- return t ? /* @__PURE__ */ m(
75
- v,
1511
+ return n ? /* @__PURE__ */ j(
1512
+ At,
76
1513
  {
77
- action: a,
78
- dataState: c,
79
- disabled: u,
80
- icon: o,
81
- shortcutKeys: n,
1514
+ action: u,
1515
+ dataState: a,
1516
+ disabled: l,
1517
+ icon: t,
1518
+ shortcutKeys: r,
82
1519
  tooltip: e,
83
- tooltipOptions: r
1520
+ tooltipOptions: i
84
1521
  }
85
- ) : /* @__PURE__ */ m(b, {});
1522
+ ) : /* @__PURE__ */ j(Ot, {});
86
1523
  }
87
- const x = /* @__PURE__ */ A.extend({
1524
+ const Pt = /* @__PURE__ */ Lt.extend({
88
1525
  //@ts-expect-error
89
1526
  addOptions() {
90
- var t;
1527
+ var n;
91
1528
  return {
92
- ...(t = this.parent) == null ? void 0 : t.call(this),
1529
+ ...(n = this.parent) == null ? void 0 : n.call(this),
93
1530
  HTMLAttributes: {
94
1531
  class: "blockquote"
95
1532
  },
96
- button: ({ editor: o, t: e, extension: n }) => ({
1533
+ button: ({ editor: t, t: e, extension: r }) => ({
97
1534
  componentProps: {
98
- action: () => o.commands.toggleBlockquote(),
99
- isActive: () => o.isActive("blockquote"),
100
- disabled: !o.can().toggleBlockquote(),
1535
+ action: () => t.commands.toggleBlockquote(),
1536
+ isActive: () => t.isActive("blockquote"),
1537
+ disabled: !t.can().toggleBlockquote(),
101
1538
  icon: "TextQuote",
102
- shortcutKeys: n.options.shortcutKeys ?? ["shift", "mod", "B"],
1539
+ shortcutKeys: r.options.shortcutKeys ?? ["shift", "mod", "B"],
103
1540
  tooltip: e("editor.blockquote.tooltip")
104
1541
  }
105
1542
  })
@@ -107,6 +1544,6 @@ const x = /* @__PURE__ */ A.extend({
107
1544
  }
108
1545
  });
109
1546
  export {
110
- x as Blockquote,
111
- L as RichTextBlockquote
1547
+ Pt as Blockquote,
1548
+ Qt as RichTextBlockquote
112
1549
  };